#include #include using ll = long long; ll chmax(ll &x, const ll &y){ if(x < y) x = y; return x; } int main(){ int n, m; std::cin >> n >> m; std::vector a(n, 0); for(int i = 0; i < n; ++i){ for(int j = 0; j < m; ++j){ ll tmp; std::cin >> tmp; a[i] += tmp; } } std::vector plus(n + 1, 0), minus(n + 1, 0); ll ans = 0; for(int i = 0; i < n; ++i){ chmax(ans, chmax(plus[i + 1], minus[i] + a[i])); chmax(ans, chmax(minus[i + 1], plus[i] - a[i])); } std::cout << ans << std::endl; }