#include #define rep(i,n) for(int i=(0);i<(n);i++) using namespace std; typedef long long ll; template bool chmax(T &a, const T &b) { if (a bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; } int main(){ cin.tie(0); ios::sync_with_stdio(false); int n, m; cin >> n >> m; vector> a(n, vector(m, 0)); rep(i, n) rep(j, m) cin >> a[i][j]; vector b(n, 0); rep(i, n) rep(j, m) b[i] += a[i][j]; ll INF = 1e17; vector> dp(n+1, vector(2, -INF)); dp[0][0] = 0; rep(i, n){ if(dp[i][0] != INF){ chmax(dp[i+1][0], dp[i][0]); chmax(dp[i+1][1], dp[i][0] + b[i]); } if(dp[i][1] != INF){ chmax(dp[i+1][0], dp[i][1] - b[i]); chmax(dp[i+1][1], dp[i][1]); } } cout << max(dp[n][0], dp[n][1]) << endl; }