#include #include using namespace std; int main() { int rows; int cols; cin >> rows >> cols; vector> elements(rows, vector(cols, 0)); if (rows % 2 == 0 && cols % 2 == 0) { int summary = 0; int min = __INT32_MAX__; for (int y = 0; y < rows; y++) { for (int x = 0; x < cols; x++) { int in; cin >> in; summary += in; if (y % 2 == 0 && x % 2 != 0) { if (min >= in) { min = in; } } if (y % 2 != 0 && x % 2 == 0) { if (min >= in) { min = in; } } } } summary -= min; cout << summary; } else { int summary = 0; for (int y = 0; y < rows; y++) { for (int x = 0; x < cols; x++) { int in; cin >> in; summary += in; } } cout << summary; } }