#include using namespace std; using ll = long long; #define int long long #define F first #define S second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define sz(x) (int)(x).size() int n, m; vector a; void solve() { } signed main() { cin >> n >> m; int a[n][m]; for (int i=0; i> a[i][j]; int sum = 0; for (int i=0; i> b{{0, 0}, {1, 1}, {0, m - 2}, {1, m - 1}, {n - 2, 0}, {n - 1, 1}, {n - 2, m - 2}, {n - 1, m - 1}}; if (n % 2 || m % 2) { cout << sum << endl; return 0; } else { int mn = INT32_MAX; for (int i = 0; i < n; i++) { for (int j = 0; j < m; j++) { pair idx{i, j}; bool F = 1; for (auto cant : b) { if (cant == idx) F = 0; } if (F) mn = min(mn, a[i][j]); } } cout << sum - mn << endl; } solve(); return 0; }