#include #include #define int long long #define rep(i, n) for(i = 0; i < n; i++) using namespace std; void chmax(int &a, int b) { a = max(a, b); } int n, m; int a[1000]; int dp[1001][2]; signed main() { int i, j; cin >> n >> m; rep(i, n) { rep(j, m) { int x; scanf("%lld", &x); a[i] += x; } } int INF = 1e+16; rep(i, n + 1) rep(j, 2) dp[i][j] = -INF; dp[0][0] = 0; rep(i, n) { rep(j, 2) { chmax(dp[i + 1][j], dp[i][j]); chmax(dp[i + 1][!j], dp[i][j] + a[i] * (j == 0 ? 1 : -1)); } } cout << max(dp[n][0], dp[n][1]) << endl; return 0; }