#include #define rep(i, n) for(int i = 0; i < (int)(n); ++i) using namespace std; using ll = long long; template inline bool chmin(T& a, T b) { if(a > b) { a = b; return true; } return false; } template inline bool chmax(T& a, T b) { if(a < b) { a = b; return true; } return false; } struct Unionfind { vector par; Unionfind(int n) : par(n) { for(int i = 0; i < n; ++i) par[i] = i; } int root(int x) { if(par[x] == x) return x; return par[x] = root(par[x]); } void unite(int x, int y) { int rx = root(x); int ry = root(y); if(rx == ry) return; par[rx] =ry; } bool same(int x, int y) { int rx = root(x); int ry = root(y); return rx == ry; } }; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int n, m; cin >> n >> m; vector a(n); rep(i, n) { ll t = 0; rep(j, m) { int ac; cin >> ac; t += ac; } a[i] = t; } vector> dp(n, vector(2)); dp[0][0] = a[0]; dp[0][1] = 0; for(int i = 0; i < n - 1; ++i) { dp[i+1][0] = max(dp[i][1] + a[i+1], dp[i][0]); dp[i+1][1] = max(dp[i][0] - a[i+1], dp[i][1]); } cout << max(dp[n-1][0], dp[n-1][1]) << endl; return 0; }