Language: C++

#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long dp[205][205][205][205];
long long H, W;
long long a[205][205];

int main(){
	cin >> H >> W;
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			for(int k = 0; k < H; k++){
				for(int l = 0; l < W; l++){
					dp[i][j][k][l] = - INT_MAX;
				}
			}
		}
	}


	dp[0][0][0][0] = 0;

	for(int i = 0; i < H; i++){
		for(int j = 0; j < W; j++){
			for(int k = 0; k < H; k++){
				for(int l = 0; l < W; l++){
					if(i == k && j == l){
						if(i != H - 1){
							if(k != H - 1){
								dp[i+1][j][k+1][l] = max(dp[i+1][j][k+1][l], dp[i][j][k][l] + a[i][j]);
							}
							if(l != W - 1){
								dp[i+1][j][k][l+1] = max(dp[i+1][j][k][l+1], dp[i][j][k][l] + a[i][j]);
							}
						}
						if(j != W - 1){
							if(k != H - 1){
								dp[i][j+1][k+1][l] = max(dp[i][j+1][k+1][l], dp[i][j][k][l] + a[i][j]);
							}
							if(l != W - 1){
								dp[i][j+1][k][l+1] = max(dp[i][j+1][k][l+1], dp[i][j][k][l] + a[i][j]);
							}
						}

					}else{
						if(i != H - 1){
							if(k != H - 1){
								dp[i+1][j][k+1][l] = max(dp[i+1][j][k+1][l], dp[i][j][k][l] + a[i][j] + a[k][l]);
							}
							if(l != W - 1){
								dp[i+1][j][k][l+1] = max(dp[i+1][j][k][l+1], dp[i][j][k][l] + a[i][j] + a[k][l]);
							}
						}
						if(j != W - 1){
							if(k != H - 1){
								dp[i][j+1][k+1][l] = max(dp[i][j+1][k+1][l], dp[i][j][k][l] + a[i][j] + a[k][l]);
							}
							if(l != W - 1){
								dp[i][j+1][k][l+1] = max(dp[i][j+1][k][l+1], dp[i][j][k][l] + a[i][j] + a[k][l]);
							}
						}
					}
				}
			}
		}
	}


	cout << dp[H-1][W-1][H-1][W-1] + a[H-1][W-1] << endl;





}



Compiler output:
/tmp/ccSy64Jf.o: in function `main':
a.cc:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against symbol `H' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0x27): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against symbol `a' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0xa4): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0xba): relocation truncated to fit: R_X86_64_PC32 against symbol `H' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0x162): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0x178): relocation truncated to fit: R_X86_64_PC32 against symbol `H' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0x192): relocation truncated to fit: R_X86_64_PC32 against symbol `W' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0x1ac): relocation truncated to fit: R_X86_64_PC32 against symbol `H' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0x215): relocation truncated to fit: R_X86_64_PC32 against symbol `H' defined in .bss section in /tmp/ccSy64Jf.o
a.cc:(.text+0x22f): additional relocation overflows omitted from the output
collect2: error: ld returned 1 exit status