#include using namespace std; using ll = long long; #define dbl long double #define vec vector #define um unordered_map #define us unordered_set using ull = unsigned long long; using vi = vec; using vl = vector; using vd = vector; using pii = pair; using pll = pair; using pdd = pair; int main(){ cin.sync_with_stdio(false); cin.tie(0); cin.exceptions(ios::failbit); int r, c; cin >> r >> c; if (r % 2 != 0 || c % 2 != 0) { ll acc = 0; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { int x; cin >> x; acc += x; } } cout << acc << endl; return 0; } ll min1 = 1e6; ll acc = 0; for (int i = 0; i < r; i++) { for (int j = 0; j < c; j++) { int x; cin >> x; acc += x; if ((i + j) % 2 == 0) { continue; } if (x < min1) min1 = x; } } cout << acc - min1 << endl; }