// #pragma GCC target("avx2") // #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using lg = long long; using pii = pair; using pll = pair; #define TEST cerr << "TEST" << endl #define AMARI 998244353 // #define AMARI 1000000007 #define TEMOTO ((sizeof(long double) == 16) ? false : true) #define TIME_LIMIT 1980 * (TEMOTO ? 1 : 1000) #define el '\n' #define El '\n' #define MULTI_TEST_CASE false void solve(void) { int h,w; cin >> h >> w; vector> a(h,vector(w)); for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ cin >> a[i][j]; } } int ans = 0; int mhx = max(h,w); for(int dx = -1; dx <= 1; dx++){ for(int dy = -1; dy <= 1; dy++){ if(dx == 0 && dy == 0)continue; for(int dx2 = dx; dx2 <= 1; dx2++){ for(int dy2 = -1; dy2 <= 1; dy2++){ if(dx2 == 0 && dy2 == 0)continue; for(int k = -1 * mhx; k <= mhx; k++){ for(int l = -1 * mhx; l <= mhx; l++){ int temp = 0; for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ if(i * dx + j * dy == k || i * dx2 + j * dy2 == l)temp += a[i][j]; } } ans = max(ans,temp); } } } } } } cout << ans << el; return; } void calc(void) { return; } signed main(void) { cin.tie(nullptr); ios::sync_with_stdio(false); calc(); int t = 1; if(MULTI_TEST_CASE) cin >> t; while(t--) { solve(); } return 0; }