#include #include #include #include #include #include #include #include #include #include #include #include #include #include int main() { int n, m; std::cin >> n >> m; std::vector happiness(n, 0); for (auto& h : happiness) { for (auto i = 0; i < m; ++i) { long long int a; std::cin >> a; h += a; } } std::vector memo(2, LLONG_MIN >> 1); memo[0] = 0; for (const auto h : happiness) { const auto odd = memo[0]; const auto even = memo[1]; memo[0] = std::max(odd, even - h); memo[1] = std::max(even, odd + h); } std::cout << *std::max_element(memo.begin(), memo.end()) << '\n'; }