#include using namespace std; /* typedef */ typedef long long ll; typedef pair pii; /* constant */ const int INF = 1 << 30; const ll LINF = 1LL << 50; const int NIL = -1; const int MAX = 10000; const int mod = 1000000007; const double pi = 3.141592653589; /* global variables */ /* function */ /* main */ int main(){ int N, M; cin >> N >> M; vector happinessDegrees(N, 0LL); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { ll hp; cin >> hp; happinessDegrees[i] += hp; } } vector dp(N+1, -LINF); // N個選んだときのMax dp[0] = 0; for (int i = 0; i < N; i++) { for (int j = 0; j <= i; j++) { dp[j + 1] = max(dp[j + 1], dp[j] + happinessDegrees[i] * (j % 2 ? -1 : 1)); } } cout << *max_element(dp.begin(), dp.end()) << '\n'; }