#include using namespace std; #define ll long long int main(){ int r, c; cin >> r >> c; ll res = 0; vector> grid; for(int i = 0; i < r; i++){ grid.push_back({}); for(int j = 0; j < c; j++){ ll a; cin >> a; res += a; grid[i].push_back(a); } } if(r % 2 != 0 || c % 2 != 0){ cout << res << endl; return 0; } ll best = 0; for(int i = 0; i < r; i++){ int start = i % 2 == 1 ? 0 : 1; for(int y = start; y < c; y+=2){ if((i == 0 && y ==0 ) || (i == r - 1 && y == c -1)) continue; best = max(best, res - grid[i][y]); } } cout << best << endl; }