func_code_string: #include <bits/stdc++.h>   using namespace std;   int n, m;   int v[1010][1010];   int dpa[1010][1010];   int dpreva[1010][1010];   int dpb[1010][1010];   int dprevb[1010][1010];   int solvea(int currx, int curry) {     if (currx == n && curry == m) return dpa[currx][curry] = v[currx][curry];     int& ret = dpa[currx][curry];     if (ret != -1) return ret;     if (currx + 1 <= n) {       ret = max(ret, solvea(currx + 1, curry) + v[currx][curry]);     }     if (curry + 1 <= m) {       ret = max(ret, solvea(currx, curry + 1) + v[currx][curry]);     }     return ret;   }   int solvereva(int currx, int curry) {     if (currx == 1 && curry == 1) return dpreva[currx][curry] = v[currx][curry];     int& ret = dpreva[currx][curry];     if (ret != -1) return ret;     if (currx - 1 >= 1) {       ret = max(ret, solvereva(currx - 1, curry) + v[currx][curry]);     }     if (curry - 1 >= 1) {       ret = max(ret, solvereva(currx, curry - 1) + v[currx][curry]);     }     return ret;   }   int solveb(int currx, int curry) {     if (currx == 1 && curry == m) return dpb[currx][curry] = v[currx][curry];     int& ret = dpb[currx][curry];     if (ret != -1) return ret;     if (currx - 1 >= 1) {       ret = max(ret, solveb(currx - 1, curry) + v[currx][curry]);     }     if (curry + 1 <= m) {       ret = max(ret, solveb(currx, curry + 1) + v[currx][curry]);     }     return ret;   }   int solverevb(int currx, int curry) {     if (currx == n && curry == 1) return dprevb[currx][curry] = v[currx][curry];     int& ret = dprevb[currx][curry];     if (ret != -1) return ret;     if (currx + 1 <= n) {       ret = max(ret, solverevb(currx + 1, curry) + v[currx][curry]);     }     if (curry - 1 >= 1) {       ret = max(ret, solverevb(currx, curry - 1) + v[currx][curry]);     }     return ret;   }   int main(void) {     ios ::sync_with_stdio(false);     cin >> n >> m;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         cin >> v[i][j];       }     }     memset(dpa, -1, sizeof dpa);     memset(dpreva, -1, sizeof dpreva);     memset(dpb, -1, sizeof dpb);     memset(dprevb, -1, sizeof dprevb);     solvea(1, 1);     solvereva(n, m);     solveb(n, 1);     solverevb(1, m);     int res = 0;     for (int i = 1; i <= n; ++i) {       for (int j = 1; j <= m; ++j) {         int dist = 0;         int dist2 = 0;         if (j - 1 >= 1 && j + 1 <= m && i - 1 >= 1 && i + 1 <= n) {           dist =               dprevb[i][j - 1] + dpb[i][j + 1] + dpreva[i - 1][j] + dpa[i + 1][j];           dist2 =               dprevb[i + 1][j] + dpb[i - 1][j] + dpreva[i][j - 1] + dpa[i][j + 1];         }         res = max(res, dist);         res = max(res, dist2);       }     }     cout << res <<   n ;     return 0;   }   