criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>

using namespace std;

int main() {
	int r, c, k; cin >> r >> c >> k;
	vector<vector<int> > g1(r + 1, vector<ll> (c + 1)), g2(g1), g3(g2), g(g1);
	for (int i = 0; i < k; ++i) {
		int row, col, val; cin >> row >> col >> val;
		g[row][col] = val;
	}
	g1[1][1] = g2[1][1] = g3[1][1] = g[1][1];
	for (int i = 1; i <= r; ++i) {
		for (int j = 1; j <= c; ++j) {
			
				if (i > 1) {
					g1[i][j] = g3[i-1][j] + g[i][j] ;
					g2[i][j] = g1[i][j];
					g3[i][j] = g2[i][j];
				}
				if (j > 1) {
					g1[i][j] = max({g[i][j], g1[i][j-1], g1[i][j]});
					g2[i][j] = max({g[i][j] + g1[i][j-1], g2[i][j], g2[i][j-1]});
					g3[i][j] = max({g3[i][j], g[i][j] + g2[i][j-1], g3[i][j-1]});
				}
			
		}
	}
	cout << g3[r][c] << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:7:47: error: 'll' was not declared in this scope
    7 |         vector<vector<int> > g1(r + 1, vector<ll> (c + 1)), g2(g1), g3(g2), g(g1);
      |                                               ^~
a.cc:7:49: error: template argument 1 is invalid
    7 |         vector<vector<int> > g1(r + 1, vector<ll> (c + 1)), g2(g1), g3(g2), g(g1);
      |                                                 ^
a.cc:7:49: error: template argument 2 is invalid
Language: C++

#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  int r,c,k;
  cin>>r>>c>>k;
  ll memo[r+1][c+1];
  for(int i=0;i<r+1;i++){
    for(int j=0;j<c+1;j++){
      memo[i][j]=0;
    }
  }
  for(int i=0;i<k;i++){
    int R,C
    ll v;
    cin>>R>>C>>v;
    memo[R][C]=v;
  }
  ll dp[4][r+1][c+1];
  for(int i=0;i<4;i++){
    for(int j=0;j<r+1;j++){
      for(int l=0;l<c+1;l++){
        dp[i][j][l]=0;
      }
    }
  }
  for(int i=1;i<r+1;i++){
    for(int j=1;j<c+1;j++){
      if(memo[i][j]==0) {
        dp[0][i][j]=max({dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j],dp[0][i][j-1]});
        dp[1][i][j]=dp[1][i][j-1];
        dp[2][i][j]=dp[2][i][j-1];
        dp[3][i][j]=dp[3][i][j-1];
        continue;
      }
      dp[0][i][j]=max({dp[0][i-1][j],dp[1][i-1][j],dp[2][i-1][j],dp[3][i-1][j],dp[0][i][j-1]});
      dp[1][i][j]=max(dp[1][i][j-1],dp[0][i][j]+memo[i][j]);
      dp[2][i][j]=max(dp[2][i][j-1],dp[1][i][j-1]+memo[i][j]);
      dp[3][i][j]=max(dp[3][i][j-1],dp[2][i][j-1]+memo[i][j]);
    }
  }
  cout<<max({dp[0][r][c],dp[1][r][c],dp[2][r][c],dp[3][r][c]})<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:5: error: expected initializer before 'll'
   37 |     ll v;
      |     ^~
a.cc:38:13: error: 'C' was not declared in this scope
   38 |     cin>>R>>C>>v;
      |             ^
a.cc:38:16: error: 'v' was not declared in this scope
   38 |     cin>>R>>C>>v;
      |                ^
Language: C++

#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint dp[R][C][4];

int main(){
  int R,C,K;
  cin>>R>>C>>K;
  map<pair<int,int>,lint> m;
  REP(i,K){
    int r,c,v;
    cin>>r>>c>>v;
    r--;c--;
    m[make_pair(r,c)]=v;
  }
  REP(r,R){
    REP(c,C){
      REP(i,4)dp[r][c][i]=0;
      if(r>0){
        REP(i,4)dp[r][c][0]=max(dp[r][c][0],dp[r-1][c][i]);
      }
      if(c>0){
        REP(i,4)dp[r][c][i]=max(dp[r][c][i],dp[r][c-1][i]);
      }
      if(m.find(make_pair(r,c))!=m.end()){
        for(int i=2;i>=0;i--)dp[r][c][i+1]=max(dp[r][c][i+1],dp[r][c][i]+m[make_pair(r,c)]);
      }
    }
  }
  lint ans=0;
  REP(i,4)ans=max(ans,dp[R-1][C-1][i]);
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc:19:9: error: 'R' was not declared in this scope
   19 | lint dp[R][C][4];
      |         ^
a.cc:19:12: error: 'C' was not declared in this scope
   19 | lint dp[R][C][4];
      |            ^
a.cc: In function 'int main()':
a.cc:33:15: error: 'dp' was not declared in this scope
   33 |       REP(i,4)dp[r][c][i]=0;
      |               ^~
a.cc:35:17: error: 'dp' was not declared in this scope
   35 |         REP(i,4)dp[r][c][0]=max(dp[r][c][0],dp[r-1][c][i]);
      |                 ^~
a.cc:38:17: error: 'dp' was not declared in this scope
   38 |         REP(i,4)dp[r][c][i]=max(dp[r][c][i],dp[r][c-1][i]);
      |                 ^~
a.cc:41:30: error: 'dp' was not declared in this scope
   41 |         for(int i=2;i>=0;i--)dp[r][c][i+1]=max(dp[r][c][i+1],dp[r][c][i]+m[make_pair(r,c)]);
      |                              ^~
a.cc:46:23: error: 'dp' was not declared in this scope
   46 |   REP(i,4)ans=max(ans,dp[R-1][C-1][i]);
      |                       ^~
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int R,C,K;
  cin>>R>>C>>K;
  
  ll DP[R+2][C+2][4];
  for(int i=0; i<=R+1; ++i){
    for(int j=0; j<=C+1; ++j){
      for(int k=0; k<4; ++k){
        DP[i][j][k]=0ll;
      }
    }
  }
  
  ll RR[K],CC[K],VV[K];
  REP(i,K){
    cin>>RR[i]>>CC[i]>>VV[i];
    item[RR[i]][CC[i]]=VV[i];
  }
  
  co(DP[R+1][C+1][0]);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:86:5: error: 'item' was not declared in this scope; did you mean 'tm'?
   86 |     item[RR[i]][CC[i]]=VV[i];
      |     ^~~~
      |     tm
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int R,C,K;
  cin>>R>>C>>K;
  
  ll DP[R+2][C+2][4];
  for(int i=0; i<=R+1; ++i){
    for(int j=0; j<=C+1; ++j){
      for(int k=0; k<4; ++k){
        DP[i][j][k]=0;
      }
    }
  }
  
  ll RR[K],CC[K],VV[K];
  REP(i,K){
    cin>>RR[i]>>CC[i]>>VV[i];
    item[RR[i]][CC[i]]=VV[i];
  }
  
  co(DP[R+1][C+1][0]);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:86:5: error: 'item' was not declared in this scope; did you mean 'tm'?
   86 |     item[RR[i]][CC[i]]=VV[i];
      |     ^~~~
      |     tm
Language: C++

#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  int R,C,K;
  cin>>R>>C>>K;
  
  ll DP[R+2][C+2][4];
  DP[R+1][C+1][0]=0
  co(DP[R+1][C+1][0]);
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:75:20: error: expected ';' before 'cout'
   75 |   DP[R+1][C+1][0]=0
      |                    ^
      |                    ;
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long val[3001][3001];
long long dp[3001][3001][4];

int main()
{
	memset(dp, 0, sizeof(dp));

	int R, C, K;
	cin >> R >> C >> K;

	for (int i = 0; i < K; ++i) {
		int r, c, v;
		cin >> r >> c >> v;
		--r;
		--c;
		val[r][c] = v;
	}

	dp[0][0][0] = 0;
	dp[0][0][1] = val[0][0];

	for (int r = 1; r < R; ++r) {
		dp[r][0][0] = *max_element(begin(dp[r - 1][0]), end(dp[r- 1][0]));
		dp[r][0][1] = *max_element(begin(dp[r - 1][0]), end(dp[r - 1][0])) + val[r][0];
	}

	for (int c = 1; c < C; ++c) {
		for (int k = 0; k < 4; ++k) {
			dp[0][c][k] = dp[0][c - 1][k];
			if (k != 0) {
				dp[0][c][k] = max(dp[0][c][k], dp[0][c - 1][k - 1] + val[0][c]);
			}
		}
	}

	for (int r = 1; r < R; ++r) {
		for (int c = 1; c < C; ++c) {
			dp[r][c][0] = *max_element(begin(dp[r - 1][c]), end(dp[r - 1][c]));
			dp[r][c][1] = *max_element(begin(dp[r - 1][c]), end(dp[r - 1][c])) + val[r][c];
			for (int k = 0; k < 4; ++k) {
				dp[r][c][k] = max(dp[r][c][k], dp[r][c - 1][k]);
				if (k != 0) {
					dp[r][c][k] = max(dp[r][c][k], dp[r][c - 1][k - 1] + val[r][c]);
				}
			}
		}
	}

	long long ans = 0;
	for (int k = 0; k < 4; ++k) {
		ans = max(ans, dp[R - 1][C - 1][k]);
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: 'memset' was not declared in this scope
   12 |         memset(dp, 0, sizeof(dp));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 |
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"NO"<<endl
#define YES() cout<<"YES"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());


ll a[3001][3001];
map<pair<ll,ll>,ll> val;
ll n,m;
int dp[3001][3001][4];
ll sol(int i,int j,int k)
{
    //cout<<i<<" "<<j<<' '<<k<<ee;
    if(i>=n || j>=m) return 0;
    if(k==0) 
    {
        return 0;
    }
    if(a[i][j]==0)
    {
        ll a1=0;
        ll a2=0;
        if(i+1<n) 
        {
            a1=sol(i+1,j,3);
         
        }
        if(j+1<m ) 
        {
            a2=sol(i,j+1,k);

        }
        return max(a1,a2);
    }
    else
    {
        ll a1=0,a2=0;
        if(i+1<n ) a1=sol(i+1,j,3);
        if(j+1<m) a2=sol(i,j+1,k-1);
        ll a3=val[{i,j}]+max(a1,a2);
        a1=0;a2=0;
        if(i+1<n ) a1=sol(i+1,j,3);
        if(j+1<m ) a2=sol(i,j+1,k);
        a3=max(a3,max(a1,a2));
        //cout<<"in "<<i<<" "<<j<<" "<<k<<" "<<a3<<ee;
        return a3;
    }
    //cout<<i<<" "<<j<<" "<<k<<" "<<dp[i][j][k]<<ee;
    return dp[i][j][k];
}

void solve()
{
    ll i,j,k,l;
    cin>>n>>m>>k;
    for(i=0;i<=n;i++)
    {
        for(j=0;j<=m;j++)
        {
            for(l=0;l<=3;l++)
            dp[i][j][k]=-1;
        }
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
            a[i][j]=0;
    }
    while(k--)
    {
        cin>>i>>j>>l;
        a[i-1][j-1]=1;
        val[{i-1,j-1}]=l;
    }
    // for(i=0;i<n;i++)
    // {
    //     for(j=0;j<m;j++)
    //     {
    //         cout<<a[i][j]<<" ";
    //     }
    //     cout<<ee;
    // }
    ans=0;
    k=sol(0,0,3);
    cout<<k<<ee;
}


int main() {
    fast;
    ll i,j,l,k,t,n;
    t=1;
    while(t--)
    solve();
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:96:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   96 |     ans=0;
      |     ^~~
      |     abs
Language: Java

import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int R = sc.nextInt();
        int C = sc.nextInt();
        int K = sc.nextInt();

        int[][] field = new int[R + 1][C + 1];
        for(int i = 0; i < K; i++){
            field[sc.nextInt()][sc.nextInt()] = sc.nextInt();
        }

        long[][][] dp = new long[R + 1][C + 1][4];
        for(int i = 1; i < R; i++){
            for(int j = 1; j < C; j++){
                Arrays.fill(dp[i][j], Long.MIN_VALUE);
            }
        }
        dp[1][1][0] = 0;

        for(int i = 1; i <= R; i++){
            for(int j = 1; j <= C; j++){
                if(field[i][j] > 0){
                    dp[i][j][0] = Math.max(dp[i - 1][j][3], dp[i][j - 1][0]);
                    dp[i][j][1] = Math.max(dp[i - 1][j][3], dp[i][j - 1][0]) + field[i][j];
                    dp[i][j][2] = Math.max(dp[i - 1][j][3], dp[i][j - 1][1]) + field[i][j];
                    dp[i][j][3] = Math.max(dp[i - 1][j][3], dp[i][j - 1][2]) + field[i][j];
                }else{
                    dp[i][j][0] = Math.max(dp[i - 1][j][3], dp[i][j - 1][0]);
                    dp[i][j][1] = Math.max(dp[i - 1][j][3], dp[i][j - 1][1]);
                    dp[i][j][2] = Math.max(dp[i - 1][j][3], dp[i][j - 1][2]);
                    dp[i][j][3] = Math.max(dp[i - 1][j][3], dp[i][j - 1][3]);
                }
            }
        }

        System.out.println(dp[R][C][3]);

}


Compiler output:
Main.java:42: error: reached end of file while parsing
}
 ^
1 error
Language: C++

#include<bits/stdc++.h>

#define ll long long
#define y1 caibictq
#define P pair<int, int>
#define fi first
#define se second

using namespace std;

const int MAXN = 6010;
const int MAXM = 100010;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;

int n, m, k;
ll tot, cnt, ans;

int read() {
	int f = 1, s = 0;
	char ch = getchar();
	while ('0' > ch || ch > '9') {if (ch == '-') f = -1; ch = getchar();}
	while ('0' <= ch && ch <= '9') {s = (s << 1) + (s << 3) + ((int)ch ^ 48); ch = getchar();}
	return s * f;
}

ll a[MAXN][MAXN]

ll f[MAXN][MAXN][4];

int main() {
	int T;
	scanf("%d%d%d", &n, &m, &k);
	for (int i = 1, x, y, v; i <= k; i++) {
		scanf("%d%d%d", &x, &y, &v);
		a[x][y] = v;
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
//			printf("%d ", a[i][j]);
			f[i][j][1] = max(f[i - 1][j][1], max(f[i - 1][j][2], f[i - 1][j][3])) + a[i][j];
		}
//		puts("");
		int mx1 = 1, mx2 = 1;
		for (int j = 2; j <= m; j++) {
			f[i][j][2] = f[i][mx1][1] + a[i][j];
			if (j > 2) f[i][j][3] = f[i][mx2][2] + a[i][j];
			if (f[i][mx1][1] < f[i][j][1]) mx1 = j;
			if (f[i][mx2][2] < f[i][j][2]) mx2 = j;
		}
	}
	for (int k = 1; k <= 3; k++) {
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
//				printf("%lld ", f[i][j][k]);
				ans = max(ans, f[i][j][k]);
			}
//			puts("");
		}
	}
	printf("%lld\n", ans);
	return 0;
}


Compiler output:
a.cc:3:12: error: expected initializer before 'long'
    3 | #define ll long long
      |            ^~~~
a.cc:29:1: note: in expansion of macro 'll'
   29 | ll f[MAXN][MAXN][4];
      | ^~
a.cc: In function 'int main()':
a.cc:36:17: error: 'a' was not declared in this scope
   36 |                 a[x][y] = v;
      |                 ^
a.cc:41:25: error: 'f' was not declared in this scope
   41 |                         f[i][j][1] = max(f[i - 1][j][1], max(f[i - 1][j][2], f[i - 1][j][3])) + a[i][j];
      |                         ^
a.cc:41:97: error: 'a' was not declared in this scope
   41 |                         f[i][j][1] = max(f[i - 1][j][1], max(f[i - 1][j][2], f[i - 1][j][3])) + a[i][j];
      |                                                                                                 ^
a.cc:46:25: error: 'f' was not declared in this scope
   46 |                         f[i][j][2] = f[i][mx1][1] + a[i][j];
      |                         ^
a.cc:46:53: error: 'a' was not declared in this scope
   46 |                         f[i][j][2] = f[i][mx1][1] + a[i][j];
      |                                                     ^
a.cc:56:48: error: 'f' was not declared in this scope
   56 |                                 ans = max(ans, f[i][j][k]);
      |                                                ^
Language: C++

#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <utility>

using namespace std;

int main() {
  int R, C, K;
  cin >> R >> C >> K;
  map <pair <int, int>, long long> value;
  for (int i = 0; i < K; ++i) {
    int r, c;
    long long v;
    cin >> r >> c >> v;
    r--;
    c--;
    value[make_pair(r, c)] = v;
  }
  
  vector <vector <vector <long long> > > dp(R, 
    vector <vector <long long> >(C, 
      vector <long long> (4, 0)
    )
  );
  dp[0][0][0] = 0;
  for (int r = 0; r < R; ++r) { 
    for (int c = 0; c < C; ++c) {
      pair <int, int> coord = make_pair(r, c);
      if (value.find(coord) != value.end()) {
        for (int k = 0; k < 4; ++k) {
          if (c - 1 >= 0 && k - 1 >= 0) {
            dp[r][c][k] = max(dp[r][c][k], 
                              dp[r][c - 1][k - 1] + value[coord]);
          }
          if (r - 1 >= 0) {
            dp[r][c][0] = max(dp[r][c][0], 
                              dp[r - 1][c][k]);
          }
      }
  }

  long long ans = 0;
  for (int k = 0; k < 4; ++k) {
    ans = max(dp[R - 1][C - 1][k], ans);
  }
    
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:51:2: error: expected '}' at end of input
   51 | }
      |  ^
a.cc:28:31: note: to match this '{'
   28 |   for (int r = 0; r < R; ++r) {
      |                               ^
a.cc:51:2: error: expected '}' at end of input
   51 | }
      |  ^
a.cc:9:12: note: to match this '{'
    9 | int main() {
      |            ^
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

static int32_t dp[3001][3001][4][4];
static ll te[3001][3001];
int main(void){
    
    ll R, C, K;
    cin>>R>>C>>K;
    ll r, c, v;
    
    MEMSET(te, 0);
    MEMSET(dp, 0);
    rep(i, K){
        cin>>r>>c>>v;
        te[c-1][r-1]=v;
    }
    dp[0][0][1][1]=te[0][0];
    rep(j, R) rep(i, C){
        dp[i+1][j][0][0]=max({dp[i][j][0][0],
            dp[i][j][0][1],
            dp[i][j][0][2],
            dp[i][j][0][3],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
            dp[i][j][k][0],
            dp[i][j][k][1],
            dp[i][j][k][2],
            dp[i][j][k][3],
            dp[i][j][k-1][0]+te[i+1][j],
            dp[i][j][k-1][1]+te[i+1][j],
            dp[i][j][k-1][2]+te[i+1][j],
            dp[i][j][k-1][3]+te[i+1][j]});
        dp[i][j+1][0][0]=max({dp[i][j][0][0],
            dp[i][j][1][0],
            dp[i][j][3][0],
            dp[i][j][2][0],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
            dp[i][j][0][k],
            dp[i][j][1][k],
            dp[i][j][2][k],
            dp[i][j][3][k],
            dp[i][j][0][k-1]+te[i][j+1],
            dp[i][j][1][k-1]+te[i][j+1],
            dp[i][j][2][k-1]+te[i][j+1],
            dp[i][j][3][k-1]+te[i][j+1]});
    }
    ll Maxim=0;
    rep(i, 4) rep(j, 4){
        Maxim=max(Maxim, dp[C-1][R-1][i][j]);
    }
    cout<<Maxim<<endl;
    return 0;
}


Compiler output:
a.cc:15:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   15 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

static unsigned long long int dp[3001][3001][4][4];
static ll te[3001][3001];
int main(void){
    
    ll R, C, K;
    cin>>R>>C>>K;
    ll r, c, v;
    
    MEMSET(te, 0);
    MEMSET(dp, 0);
    rep(i, K){
        cin>>r>>c>>v;
        te[c-1][r-1]=v;
    }
    dp[0][0][1][1]=te[0][0];
    rep(j, R) rep(i, C){
        dp[i+1][j][0][0]=max({dp[i][j][0][0],
            dp[i][j][0][1],
            dp[i][j][0][2],
            dp[i][j][0][3],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
            dp[i][j][k][0],
            dp[i][j][k][1],
            dp[i][j][k][2],
            dp[i][j][k][3],
            dp[i][j][k-1][0]+te[i+1][j],
            dp[i][j][k-1][1]+te[i+1][j],
            dp[i][j][k-1][2]+te[i+1][j],
            dp[i][j][k-1][3]+te[i+1][j]});
        dp[i][j+1][0][0]=max({dp[i][j][0][0],
            dp[i][j][1][0],
            dp[i][j][3][0],
            dp[i][j][2][0],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
            dp[i][j][0][k],
            dp[i][j][1][k],
            dp[i][j][2][k],
            dp[i][j][3][k],
            dp[i][j][0][k-1]+te[i][j+1],
            dp[i][j][1][k-1]+te[i][j+1],
            dp[i][j][2][k-1]+te[i][j+1],
            dp[i][j][3][k-1]+te[i][j+1]});
    }
    ll Maxim=0;
    rep(i, 4) rep(j, 4){
        Maxim=max(Maxim, dp[C-1][R-1][i][j]);
    }
    cout<<Maxim<<endl;
    return 0;
}


Compiler output:
a.cc:15:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   15 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

static long dp[3001][3001][4][4];
static ll te[3001][3001];
int main(void){
    
    ll R, C, K;
    cin>>R>>C>>K;
    ll r, c, v;
    
    MEMSET(te, 0);
    MEMSET(dp, 0);
    rep(i, K){
        cin>>r>>c>>v;
        te[c-1][r-1]=v;
    }
    dp[0][0][1][1]=te[0][0];
    rep(j, R) rep(i, C){
        dp[i+1][j][0][0]=max({dp[i][j][0][0],
            dp[i][j][0][1],
            dp[i][j][0][2],
            dp[i][j][0][3],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
            dp[i][j][k][0],
            dp[i][j][k][1],
            dp[i][j][k][2],
            dp[i][j][k][3],
            dp[i][j][k-1][0]+te[i+1][j],
            dp[i][j][k-1][1]+te[i+1][j],
            dp[i][j][k-1][2]+te[i+1][j],
            dp[i][j][k-1][3]+te[i+1][j]});
        dp[i][j+1][0][0]=max({dp[i][j][0][0],
            dp[i][j][1][0],
            dp[i][j][3][0],
            dp[i][j][2][0],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
            dp[i][j][0][k],
            dp[i][j][1][k],
            dp[i][j][2][k],
            dp[i][j][3][k],
            dp[i][j][0][k-1]+te[i][j+1],
            dp[i][j][1][k-1]+te[i][j+1],
            dp[i][j][2][k-1]+te[i][j+1],
            dp[i][j][3][k-1]+te[i][j+1]});
    }
    ll Maxim=0;
    rep(i, 4) rep(j, 4){
        Maxim=max(Maxim, dp[C-1][R-1][i][j]);
    }
    cout<<Maxim<<endl;
    return 0;
}


Compiler output:
a.cc:15:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   15 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

static long int dp[3001][3001][4][4];
static ll te[3001][3001];
int main(void){
    
    ll R, C, K;
    cin>>R>>C>>K;
    ll r, c, v;
    
    MEMSET(te, 0);
    MEMSET(dp, 0);
    rep(i, K){
        cin>>r>>c>>v;
        te[c-1][r-1]=v;
    }
    dp[0][0][1][1]=te[0][0];
    rep(j, R) rep(i, C){
        dp[i+1][j][0][0]=max({dp[i][j][0][0],
            dp[i][j][0][1],
            dp[i][j][0][2],
            dp[i][j][0][3],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
            dp[i][j][k][0],
            dp[i][j][k][1],
            dp[i][j][k][2],
            dp[i][j][k][3],
            dp[i][j][k-1][0]+te[i+1][j],
            dp[i][j][k-1][1]+te[i+1][j],
            dp[i][j][k-1][2]+te[i+1][j],
            dp[i][j][k-1][3]+te[i+1][j]});
        dp[i][j+1][0][0]=max({dp[i][j][0][0],
            dp[i][j][1][0],
            dp[i][j][3][0],
            dp[i][j][2][0],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
            dp[i][j][0][k],
            dp[i][j][1][k],
            dp[i][j][2][k],
            dp[i][j][3][k],
            dp[i][j][0][k-1]+te[i][j+1],
            dp[i][j][1][k-1]+te[i][j+1],
            dp[i][j][2][k-1]+te[i][j+1],
            dp[i][j][3][k-1]+te[i][j+1]});
    }
    ll Maxim=0;
    rep(i, 4) rep(j, 4){
        Maxim=max(Maxim, dp[C-1][R-1][i][j]);
    }
    cout<<Maxim<<endl;
    return 0;
}


Compiler output:
a.cc:15:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   15 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

static unsigned__int32 dp[3001][3001][4][4];
static ll te[3001][3001];
int main(void){
    
    ll R, C, K;
    cin>>R>>C>>K;
    ll r, c, v;
    
    MEMSET(te, 0);
    MEMSET(dp, 0);
    rep(i, K){
        cin>>r>>c>>v;
        te[c-1][r-1]=v;
    }
    dp[0][0][1][1]=te[0][0];
    rep(j, R) rep(i, C){
        dp[i+1][j][0][0]=max({dp[i][j][0][0],
            dp[i][j][0][1],
            dp[i][j][0][2],
            dp[i][j][0][3],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
            dp[i][j][k][0],
            dp[i][j][k][1],
            dp[i][j][k][2],
            dp[i][j][k][3],
            dp[i][j][k-1][0]+te[i+1][j],
            dp[i][j][k-1][1]+te[i+1][j],
            dp[i][j][k-1][2]+te[i+1][j],
            dp[i][j][k-1][3]+te[i+1][j]});
        dp[i][j+1][0][0]=max({dp[i][j][0][0],
            dp[i][j][1][0],
            dp[i][j][3][0],
            dp[i][j][2][0],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
            dp[i][j][0][k],
            dp[i][j][1][k],
            dp[i][j][2][k],
            dp[i][j][3][k],
            dp[i][j][0][k-1]+te[i][j+1],
            dp[i][j][1][k-1]+te[i][j+1],
            dp[i][j][2][k-1]+te[i][j+1],
            dp[i][j][3][k-1]+te[i][j+1]});
    }
    ll Maxim=0;
    rep(i, 4) rep(j, 4){
        Maxim=max(Maxim, dp[C-1][R-1][i][j]);
    }
    cout<<Maxim<<endl;
    return 0;
}


Compiler output:
a.cc:15:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   15 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <cstring>
#include <utility>
#include <set>
#include <stack>
#include <climits>
#include <cmath>
#include <iomanip>
#include <unordered_map>
#include <map>
#include <boost/multiprecision/cpp_int.hpp>

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define reps(i,s,n) for(int i=s, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define MEMSET(v, h) memset((v), h, sizeof(v))
typedef long long ll;
typedef long double ld;
const char sp = ' ';

using namespace boost::multiprecision;
using namespace std;

static unsigned __int32 dp[3001][3001][4][4];
static ll te[3001][3001];
int main(void){
    
    ll R, C, K;
    cin>>R>>C>>K;
    ll r, c, v;
    
    MEMSET(te, 0);
    MEMSET(dp, 0);
    rep(i, K){
        cin>>r>>c>>v;
        te[c-1][r-1]=v;
    }
    dp[0][0][1][1]=te[0][0];
    rep(j, R) rep(i, C){
        dp[i+1][j][0][0]=max({dp[i][j][0][0],
            dp[i][j][0][1],
            dp[i][j][0][2],
            dp[i][j][0][3],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i+1][j][k][0]=max({dp[i+1][j][k][0],
            dp[i][j][k][0],
            dp[i][j][k][1],
            dp[i][j][k][2],
            dp[i][j][k][3],
            dp[i][j][k-1][0]+te[i+1][j],
            dp[i][j][k-1][1]+te[i+1][j],
            dp[i][j][k-1][2]+te[i+1][j],
            dp[i][j][k-1][3]+te[i+1][j]});
        dp[i][j+1][0][0]=max({dp[i][j][0][0],
            dp[i][j][1][0],
            dp[i][j][3][0],
            dp[i][j][2][0],
            dp[i+1][j][0][0]});
        rep1(k, 3) dp[i][j+1][0][k]=max({dp[i][j+1][0][k],
            dp[i][j][0][k],
            dp[i][j][1][k],
            dp[i][j][2][k],
            dp[i][j][3][k],
            dp[i][j][0][k-1]+te[i][j+1],
            dp[i][j][1][k-1]+te[i][j+1],
            dp[i][j][2][k-1]+te[i][j+1],
            dp[i][j][3][k-1]+te[i][j+1]});
    }
    ll Maxim=0;
    rep(i, 4) rep(j, 4){
        Maxim=max(Maxim, dp[C-1][R-1][i][j]);
    }
    cout<<Maxim<<endl;
    return 0;
}


Compiler output:
a.cc:15:10: fatal error: boost/multiprecision/cpp_int.hpp: No such file or directory
   15 | #include <boost/multiprecision/cpp_int.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
using namespace std;

long long r, c, k, a, b, w, g[3005][3005], dp[3005][3005][5];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> r >> c >> k;
    for (int i = 0; i < k; i++){
        cin >> a >> b >> w;
        g[a][b] = w;
    }
    for (int i = 1; i <= r; i++){
        for (int j = 1; j <= c; j++){
            dp[i][j][0] = max(dp[i][j-1][0], dp[i-1][j][4]);
            dp[i][j][1] = max(dp[i][j-1][1], dp[i-1][j][4]+g[i][j]);
            dp[i][j][2] = max(dp[i][j-1][2], dp[i][j-1][1]+g[i][j]);
            dp[i][j][3] = max(dp[i][j-1][3], dp[i][j-1][2]+g[i][j]);
            dp[i][j][4] = max({dp[i][j][0], dp[i][j][1], dp[i][j][2], dp[i][j][3]});
        }
    }
    cout << dp[r][c][4] << "\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:30: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   20 |             dp[i][j][4] = max({dp[i][j][0], dp[i][j][1], dp[i][j][2], dp[i][j][3]});
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
Language: C++

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll R, C, K, r[212345], c[212345], v[212345];
ll memo[4][3123][3123];

ll item[3123][3123];

ll dp(ll rr, ll cc, ll i) {
	if (memo[i][rr][cc] != -1) return memo[i][rr][cc];
	if (rr == 0 && cc == 0) {
		if (i == 0) return memo[i][rr][cc] = 0;
		else return memo[i][rr][cc] = item[rr][cc];
	}
	ll ret = LLONG_MIN;
	if (rr > 0) ret = max(ret, dp(rr - 1, cc, 3));
	if (cc > 0) ret = max(ret, dp(rr, cc - 1, i));
	if (i) {
		if (rr > 0) ret = max(ret, dp(rr - 1, cc, 3) + item[rr][cc]);
		if (cc > 0) ret = max(ret, dp(rr, cc - 1, i - 1) + item[rr][cc]);
	}

	return memo[i][rr][cc] = ret;
}

int main() {

	memset(memo, 0xff, sizeof(memo));
	cin >> R >> C >> K;
	rep(i, K) cin >> r[i] >> c[i] >> v[i];
	rep(i, K) item[r[i] - 1][c[i] - 1] = v[i];

	cout << dp(R - 1, C - 1, 3) << endl;

	return 0;
}


Compiler output:
a.cc: In function 'll dp(ll, ll, ll)':
a.cc:38:18: error: 'LLONG_MIN' was not declared in this scope
   38 |         ll ret = LLONG_MIN;
      |                  ^~~~~~~~~
a.cc:20:1: note: 'LLONG_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   19 | #include <bitset>
  +++ |+#include <climits>
   20 |
Language: C

#include <bits/stdc++.h>
using namespace std;
 
#define int int64_t
const int M1 =  998244353;
const int M2 =  1000000007;


void solve() {
  int n, m, k;
  cin >> n >> m >> k;
  int a[n][m];
  memset(a, 0, sizeof(a));
  int dp[4][n][m];
  memset(dp, 0, sizeof(dp));
  while(k--) {
    int x, y, z;
    cin >> x >> y >> z;
    a[--x][--y] = z;
  }
  for(int i = 0; i < n; i++) {
    if(i == 0) {
      if(a[0][0])
        dp[1][0][0] = a[0][0];
    }
    else {
      for(int x = 0; x <= 3; x++)
        dp[0][i][0] = dp[x][i - 1][0];
      if(a[i][0]) {
        for(int x = 0; x <= 3; x++)
          dp[1][i][0] = max(dp[1][i][0], dp[x][i - 1][0] + a[i][0]);
      }
    }
    for(int j = 1; j < m; j++) {
      for(int x = 0; x <= 3; x++) {
        dp[x][i][j] = max(dp[x][i][j], dp[x][i][j - 1]);
        if(x && a[i][j])
          dp[x][i][j] = max(dp[x][i][j], dp[x - 1][i][j - 1] + a[i][j]);
      }
      if(i) {
        for(int x = 0; x <= 3; x++) {
          dp[0][i][j] = max(dp[0][i][j], dp[x][i - 1][j]);
          dp[1][i][j] = max(dp[1][i][j], dp[x][i - 1][j] + a[i][j]);
        }
      }
    }
  }
  int ans = 0;
  for(int i = 0; i <= 3; i++)
    ans = max(ans, dp[i][n -1][m - 1]);
  cout << ans << "\n";
}
 
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  solve();
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For(i, 0, n)
#define rrep(i, n) rFor(i, n, 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1000000007;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int h, w, K;
lint dp[2][3010][4];
vector<pair<int, lint>> item[3010];
int r[MAX], c[MAX];
lint v[MAX];
vector<int> vx, vy;

int main(){
    scanf("%d%d%d", &h, &w, &K);
    rep(i, K){
        scanf("%d%d%lld", &r[i], &c[i], &v[i]);
        vx.push_back(r[i]);
        vy.push_back(c[i]);
    }
    vx.push_back(0);
    vy.push_back(0);
    sort(vx.begin(), vx.end());
    vx.erase(unique(vx.begin(), vx.end()), vx.end());
    sort(vy.begin(), vy.end());
    vy.erase(unique(vy.begin(), vy.end()), vy.end());
    rep(i, K){
        int x = lower_bound(vx.begin(), vx.end(), r[i]) - vx.begin();
        item[x].emplace_back(c[i], v[i]);
    }
    h = vx.size();
    w = vy.size();
    rep(i, h) sort(item[i].begin(), item[i].end());

    rep(i, 2)rep(j, w + 1)rep(k, 4) dp[i][j][k] = -1;
    dp[0][0][0] = 0;
    rep(i, vx.size()){
        rep(j, w)rep(k, 4)if(dp[0][j][k] >= 0){
            chmax(dp[1][j][0], dp[0][j][k]);
            chmax(dp[0][j + 1][k], dp[0][j][k]);
            auto itr = lower_bound(item[i].begin(), item[i].end(), pair<int, lint>(vy[j], -1LL));
            if(k <= 2 && itr != item[i].end() && itr->fi == vy[j]){
                chmax(dp[1][j][0], dp[0][j][k] + itr->se);
                chmax(dp[0][j + 1][k + 1], dp[0][j][k] + itr->se);
            }
        }

        /*rep(j, w + 1){
            rep(k, 4) printf("%lld ", dp[1][j][k]);
            printf("\n");
        }
        printf("\n");*/

        rep(j, w + 1)rep(k, 4){
            dp[0][j][k] = dp[1][j][k];
            dp[1][j][k] = -1;
        }
    }

    lint ans = 0;
    rep(i, 4) chmax(ans, dp[0][w - 1][i]);
    printf("%lld\n", ans);
}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

/*** akshaykumar99 ***/
 
#include<bits/stdc++.h> 
using namespace std;
 
const long long MOD = 1e9+7;
const long double PI = acos(-1);
const long long N = 5e5+1;
 
typedef long long ll;
typedef long double ld;

ll n, m, k;
ll res[3001][3001][4];
ll res1[3001][3001];

ll dfs(ll i,ll j,ll cur)
{
    if(i == n || j == m || cur == 3)
        return 0;
    if(res[i][j][cur] != -1)
        return res[i][j][cur];
    ll &ans = res[i][j][cur];
    ll ans = 0;
    if(res1[i][j] == 0)
        ans = max({ans,dfs(i+1,j,0), dfs(i,j+1,cur)});
    else
        ans = max({ans,res1[i][j] + dfs(i+1,j,0),res1[i][j] + dfs(i,j+1,cur+1),dfs(i,j+1,cur),dfs(i+1,j,0)});
    return ans;
}
void test_case()
{
	cin >> n >> m >> k;
    memset(res,-1,sizeof(res));
    for(int i = 0; i < k; i++)
    {
        int x, y, z;
        cin >> x >> y >> z;
        res1[x-1][y-1] = z;
    }
    cout << dfs(0,0,0);

}
 
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL); 
    ll tc=1;
    // cin>>tc;
    while(tc--)
        test_case();
    return 0;
}

Compiler output:
a.cc: In function 'll dfs(ll, ll, ll)':
a.cc:24:8: error: conflicting declaration 'll ans'
   24 |     ll ans = 0;
      |        ^~~
a.cc:23:9: note: previous declaration as 'll& ans'
   23 |     ll &ans = res[i][j][cur];
      |         ^~~
Language: C++

#include<iostream>
#include<map>
using namespace std;
const int BUF = 55;
const long long INF = 1LL << 60;


int nStr;
string s[BUF];
int cost[BUF];

void read() {
    cin >> nStr;
    for (int i = 0; i < nStr; ++i) {
        cin >> s[i] >> cost[i];
    }
}


bool isPalindrome(string &str) {
    for (int i = 0; i < str.size() / 2; ++i) {
        if (str[i] != str[str.size() - 1 - i]) {
            return false;
        }
    }
    return true;
}


bool aStartsWithB(string &a, string &b) {
    return a.size() >= b.size() && a.substr(0, b.size()) == b;
}


bool aEndsWithB(string &a, string &b) {
    return a.size() >= b.size() && a.substr(a.size() - b.size()) == b;
}


long long rec(string bgn, string end, map<pair<string, string>, long long> &dp) {

    if (dp.count(make_pair(bgn, end))) {
        return dp[make_pair(bgn, end)];
    }

    if ((bgn.empty() && isPalindrome(end)) || (end.empty() && isPalindrome(bgn))) {
        return dp[make_pair(bgn, end)] = 0;
    }
    
    long long ret = INF;

    if (bgn.empty()) {
        for (int i = 0; i < nStr; ++i) {
            string &str = s[i];
            if (aEndsWithB(str, end)) {
                string nextBgn = str.substr(0, str.size() - end.size());
                reverse(nextBgn.begin(), nextBgn.end());
                ret = min(ret, rec(nextBgn, "", dp) + cost[i]);
            } else if (aEndsWithB(end, str)) {
                ret = min(ret, rec("", end.substr(0, end.size() - str.size()), dp) + cost[i]);
            }
        }
    } else {
        for (int i = 0; i < nStr; ++i) {
            string &str = s[i];
            if (aStartsWithB(str, bgn)) {
                string nextEnd = str.substr(bgn.size());
                reverse(nextEnd.begin(), nextEnd.end());
                ret = min(ret, rec("", nextEnd, dp) + cost[i]);
            } else if (aEndsWithB(bgn, str)) {
                ret = min(ret, rec(bgn.substr(str.size()), "", dp) + cost[i]);
            }
        }        
    }
    

    return dp[make_pair(bgn, end)] = ret;
}


void work() {
    long long minV = INF;
    
    map<pair<string, string>, long long> dp;
    for (int i = 0; i < nStr; ++i) {
        string nextEnd = s[i];
        reverse(nextEnd.begin(), nextEnd.end());
        minV = min(minV, rec("", nextEnd, dp) + cost[i]);
    }

    cout << (minV == INF ? -1 : minV) << endl;
}


int main() {
    read();
    work();
    return 0;
}


Compiler output:
a.cc: In function 'long long int rec(std::string, std::string, std::map<std::pair<std::__cxx11::basic_string<char>, std::__cxx11::basic_string<char> >, long long int>&)':
a.cc:57:17: error: 'reverse' was not declared in this scope
   57 |                 reverse(nextBgn.begin(), nextBgn.end());
      |                 ^~~~~~~
a.cc:68:17: error: 'reverse' was not declared in this scope
   68 |                 reverse(nextEnd.begin(), nextEnd.end());
      |                 ^~~~~~~
a.cc: In function 'void work()':
a.cc:87:9: error: 'reverse' was not declared in this scope
   87 |         reverse(nextEnd.begin(), nextEnd.end());
      |         ^~~~~~~