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

#include <iostream>
#include <vector>
#include <queue>
// #include <fstream>
#define dequeAll(queue) while(!queue.empty()) queue.pop()

using namespace std;

int main(){
    int r, c, k, index = 0;
    long long sum;
    // ifstream ins;
    // ins.open("./Atcoder Challenges/Basic_August2020/PickingGoods.txt");
    int loc1, loc2, value;
    priority_queue<int, vector<long long>, greater<long long>> pickedElements;
    ios_base::sync_with_stdio(false);
    cin >> r >> c >> k;
    vector<vector<long long>> grid(r, vector<long long>(c, 0));
    vector<long long> dp(c, 0);
    for (int i = 0; i < k; i++){
        cin >> loc1 >> loc2 >> value;
        grid[loc1 - 1][loc2 - 1] = value;
    }

    for (auto i: grid){
        sum = 0;
        dequeAll(pickedElements);
        index = 0;
        dp[index] += i[0];
        pickedElements.push(i[0]);
        index++;
        for (auto j = i.begin() + 1; j != i.end(); j++){
            if(dp[index] >= dp[index - 1]){
                dequeAll(pickedElements);
                pickedElements.push(*j);
                dp[index] += *j;
            } else if(pickedElements.size() < 3){
                dp[index] = *j + dp[index - 1];
                pickedElements.push(*j);
            } else if(*j > pickedElements.top()){
                dp[index] = dp[index - 1] + *j - pickedElements.top();
                pickedElements.push(*j);
                pickedElements.pop();
            } else {
                dp[index] = dp[index - 1];
            }
            index++;
        }
    }

    cout << dp.back() << endl;

}

Compiler output:
In file included from /usr/include/c++/14/queue:66,
                 from a.cc:3:
/usr/include/c++/14/bits/stl_queue.h: In instantiation of 'class std::priority_queue<int, std::vector<long long int>, std::greater<long long int> >':
a.cc:15:64:   required from here
   15 |     priority_queue<int, vector<long long>, greater<long long>> pickedElements;
      |                                                                ^~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_queue.h:520:67: error: static assertion failed: value_type must be the same as the underlying container
  520 |       static_assert(is_same<_Tp, typename _Sequence::value_type>::value,
      |                                                                   ^~~~~
/usr/include/c++/14/bits/stl_queue.h:520:67: note: 'std::integral_constant<bool, false>::value' evaluates to false
Language: C++

#include <iostream>
#include <bits\stdc++.h>
// #include <fstream>

using namespace std;

int main(){
    int r, c, k, sum = 0, index = 0;
    // ifstream ins;
    // ins.open("./Atcoder Challenges/Basic_August2020/PickingGoods.txt");
    int loc1, loc2, value;
    priority_queue<int, vector<int>, greater<int>> pickedElements;
    ios_base::sync_with_stdio(false);
    cin >> r >> c >> k;
    vector<vector<int>> grid(r, vector<int>(c, 0));
    vector<int> dp(c, -1);
    for (int i = 0; i < k; i++){
        cin >> loc1 >> loc2 >> value;
        grid[loc1 - 1][loc2 - 1] = value;
    }

    for (auto i: grid){
        sum = 0;
        pickedElements = priority_queue<int, vector<int>, greater<int>>();
        index = 0;
        for (auto j: i){
            if (pickedElements.size() < 3 || pickedElements.top() < j){
                pickedElements.push(j);
                sum += j;
            }
            if (pickedElements.size() > 3 && pickedElements.top() < j){
                sum -= pickedElements.top();
                pickedElements.pop();
            }
            if (dp[index] != -1 && sum <= j + dp[index]){
                sum =  j + dp[index];
                pickedElements = priority_queue<int, vector<int>, greater<int>>();
                pickedElements.push(j);
            }
            dp[index] = sum;
            index++;
        }
    }

    cout << dp.back() << endl;

}


Compiler output:
a.cc:2:10: fatal error: bits\stdc++.h: No such file or directory
    2 | #include <bits\stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
  
using namespace std;
using namespace __gnu_pbds;
 
#define ll long long
#define uint unsigned int
#define ull  unsigned long long
#define pb push_back
#define mk make_pair
#define ins insert
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define X first
#define Y second
#define umap unordered_map
#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n
#define mset multiset
#define pqueue priority_queue
   
template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
        
const int  N = 3e3 + 12;
const int INF = 1e9;
const double PI = acos(-1);
const int MOD = 1e9 + 7;
const double eps = 1e-9;
const long long LINF = 1e18 + 3141;
ll a[N][N];
ll dp[N][N][4];
int n, m, k;
 
void maxself(ll &a, ll c) {
    a = max(a, c);
}
ll get(int x, int y, int t) {
    if(t < 0)
        return -LINF;
    if(x < 0 || x > n || y > m || y < 0)
        return -LINF;
    if(dp[x][y][t] != -1)
        return dp[x][y][t];
    if(t == 0) {
        ll fromUp = get(x - 1, y, 0);
        maxself(fromUp, get(x - 1, y, 1));
        maxself(fromUp, get(x - 1, y, 2));
        maxself(fromUp, get(x - 1, y, 3));
        ll fromLeft = get(x, y - 1, 0);
        return dp[x][y][t] = max(fromLeft, fromUp);
    }
    ll fromUp = 0;
    if(a[x][y] && t == 1) {
        fromUp = get(x - 1, y, 0);
        maxself(fromUp, get(x - 1, y, 1));
        maxself(fromUp, get(x - 1, y, 2));
        maxself(fromUp, get(x - 1, y, 3));
        fromUp += a[x][y];
    }
    // dont take
    ll fromLeft = get(x, y - 1, t);
    maxself(fromLeft, get(x, y - 1, t - 1) + a[x][y]);
 
    return dp[x][y][t] = max(fromLeft, fromUp);
 
} 
void solve(){
    cin >> n >> m >> k;
    while(k --) {
        int x, y, v;
        cin >> x >> y >> v;
        a[x][y] = v;
    }
    for(int i = 0; i <= n; ++i)
        for(int j = 0; j <= m; ++j)
            dp[i][j] = -1;
    ll mx = 0;
    for(int i = 0; i <= 3; ++i){
        mx = max(mx, get(n, m, i));
    }
    cout << mx;
}
 
int main(){
    speed();
    int t = 1;
    // cin >> t;
    while(t--)solve();
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:78:22: error: incompatible types in assignment of 'int' to 'long long int [4]'
   78 |             dp[i][j] = -1;
      |             ~~~~~~~~~^~~~
Language: C++

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main{
int r,c,k;
cin>>r>>c>>k;
int arr[r][c]={0};
for(int i=0;i<k;i++){
int p,q,t;
cin>>p>>q>>t;
arr[p-1][q-1]=t;
}
int dp[r+1][c+1][4]={0};
for(int i=1;i<=r;i++){
for(int j=1;j<=c;j++){
if(i>1){
dp[i][j][0]=max(dp[i][j][0],max(dp[i-1][j][1],max(dp[i-1][j][2],dp[i-1][j][3])));
}
if(j>1){
                dp[i][j][0] = maxl(dp[i][j][0],dp[i][j-1][0]);
                dp[i][j][1] = maxl(dp[i][j][1],dp[i][j-1][1]);
                dp[i][j][2] = maxl(dp[i][j][2],dp[i][j-1][2]);
                dp[i][j][3] = maxl(dp[i][j][3],dp[i][j-1][3]);
}
             if(arr[i-1][j-1]>0){
dp[i][j][1]=max(dp[i][j][1],dp[i-1][j-1][0]+arr[i-1][j-1]);
dp[i][j][2]=max(dp[i][j][2],dp[i-1][j-1][1]+arr[i-1][j-1]);
dp[i][j][3]=max(dp[i][j][3],dp[i-1][j-1][2]+arr[i-1][j-1]);
}
}
}
cout<<max(dp[r][c][0],max(dp[r][c][1],max(dp[r][c][2],dp[r][c][3])))<<endl;
}


Compiler output:
a.cc:4:5: error: cannot declare '::main' to be a global variable
    4 | int main{
      |     ^~~~
a.cc:5:1: error: expected primary-expression before 'int'
    5 | int r,c,k;
      | ^~~
a.cc:5:1: error: expected '}' before 'int'
a.cc:4:9: note: to match this '{'
    4 | int main{
      |         ^
a.cc:6:1: error: 'cin' does not name a type
    6 | cin>>r>>c>>k;
      | ^~~
a.cc:7:9: error: 'r' was not declared in this scope
    7 | int arr[r][c]={0};
      |         ^
a.cc:7:12: error: 'c' was not declared in this scope
    7 | int arr[r][c]={0};
      |            ^
a.cc:8:1: error: expected unqualified-id before 'for'
    8 | for(int i=0;i<k;i++){
      | ^~~
a.cc:8:13: error: 'i' does not name a type
    8 | for(int i=0;i<k;i++){
      |             ^
a.cc:8:17: error: 'i' does not name a type
    8 | for(int i=0;i<k;i++){
      |                 ^
a.cc:13:8: error: 'r' was not declared in this scope
   13 | int dp[r+1][c+1][4]={0};
      |        ^
a.cc:13:13: error: 'c' was not declared in this scope
   13 | int dp[r+1][c+1][4]={0};
      |             ^
a.cc:14:1: error: expected unqualified-id before 'for'
   14 | for(int i=1;i<=r;i++){
      | ^~~
a.cc:14:13: error: 'i' does not name a type
   14 | for(int i=1;i<=r;i++){
      |             ^
a.cc:14:18: error: 'i' does not name a type
   14 | for(int i=1;i<=r;i++){
      |                  ^
a.cc:32:1: error: 'cout' does not name a type
   32 | cout<<max(dp[r][c][0],max(dp[r][c][1],max(dp[r][c][2],dp[r][c][3])))<<endl;
      | ^~~~
a.cc:33:1: error: expected declaration before '}' token
   33 | }
      | ^
Language: C++

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main()
{
  int R, C, K;
  cin >> R >> C >> K;

  vector<vector<vector<ll>>> A(R, vector<vector<ll>>(C, vector<ll>(4, -1)));

  vector<vector<ll>> Vs(R, vector<ll>(C, 0));

  for (int i = 0; i < K; i++)
  {

    int r, c, v;
    cin >> r >> c >> v;

    Vs[r - 1][c - 1] = v;
  }

  if (Vs[0][0] == 0)
  {
    A[0][0][0] = 0;
  }
  else
  {

    A[0][0][1] = Vs[0][0];
  }

  if (C > 1)
  {
    for (int i = 0; i < (C - 1); i++)
    {

      A[0][i + 1][0] = 0;

      for (int k = 1; k < 4; k++)
      {

        if (Vs[0][i + 1] > 0 && A[0][i][k - 1] != -1)
        {

          A[0][i + 1][k] = max(A[0][i][k - 1] + Vs[0][i + 1], A[0][i][k]);
        }
        else
        {

          A[0][i + 1][k] = A[0][i][k];
        }
      }
    }
  }

  if (R > 1)
  {
    for (int j = 0; j < (R - 1); j++)
    {

      ll art0 = max(A[j][0][0], A[j][i + 1][1]);
      if (Vs[0][0] == 0)
      {
        A[j + 1][0][0] = art0;
      }
      else
      {

        A[j + 1][0][1] = art0 + Vs[j + 1][0];
      }

      if (C > 1)
      {

        for (int i = 0; i < (C - 1); i++)
        {

          ll art = max(A[j][i + 1][0], A[j][i + 1][1]);
          art = max(A[j][i + 1][2], art);
          art = max(A[j][i + 1][3], art);

          A[j + 1][i + 1][0] = max(A[j + 1][i][0], art);

          for (int k = 1; k < 4; k++)
          {

            if (Vs[j + 1][i + 1] > 0 && A[j + 1][i][k - 1] != -1)
            {

              A[j + 1][i + 1][k] = max(A[j + 1][i][k - 1] + Vs[j + 1][i + 1], A[j + 1][i][k]);

              if (k == 1)
              {

                A[j + 1][i + 1][k] = max(art + Vs[j + 1][i + 1], A[j + 1][i + 1][k]);
              }
            }
            else
            {

              A[j + 1][i + 1][k] = A[j + 1][i][k];
            }
          }
        }
      }
    }
  }

  ll ans = max(A[R - 1][C - 1][0], A[R - 1][C - 1][1]);
  ans = max(A[R - 1][C - 1][2], ans);
  ans = max(A[R - 1][C - 1][3], ans);

  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:38: error: 'i' was not declared in this scope
   63 |       ll art0 = max(A[j][0][0], A[j][i + 1][1]);
      |                                      ^
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();
		long [][] item = new long [r+1][c+1];
        long [][][] ans = new long [r+1][c+1][4];
        for(int i=0;i<k;i++){int R = sc.nextInt();
                             int C = sc.nextInt();
                             long K = sc.nextLong();
                             item[R][C]=K;
                            }		
        for(int i=1;i<=r;i++){                              
          for(int j=1;j<=c;j++){                               
            if(item[i][j]==0){                                
              ans[i][j][0]=Math.max(ans[i][j-1][0],Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3]))));            
            for(int k=1;k<=3;k++){ans[i][j][k]=ans[i][j-1][k];}
            }
            else{ans[i][j][0]=Math.max(ans[i][j-1][0],Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3]))));
              for(int k=1;k<=3;k++){ans[i][j][k]=Math.max(ans[i][j-1][k],ans[i][j-1][k-1]+item[i][j]);}           
                }                                  
          } 
        }      
		System.out.println(Math.max(ans[r][c][0],Math.max(ans[r][c][1],Math.max(ans[r][c][2],ans[r][c][3]))));
	}
}


Compiler output:
Main.java:19: error: variable k is already defined in method main(String[])
            for(int k=1;k<=3;k++){ans[i][j][k]=ans[i][j-1][k];}
                    ^
Main.java:22: error: variable k is already defined in method main(String[])
              for(int k=1;k<=3;k++){ans[i][j][k]=Math.max(ans[i][j-1][k],ans[i][j-1][k-1]+item[i][j]);}           
                      ^
2 errors
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();
		long [][] item = new long [r+1][c+1];
        long [][][] ans = new long [r+1][c+1][4];
        for(int i=0;i<k;i++){int R = sc.nextInt();
                             int C = sc.nextInt();
                             long K = sc.nextLong();
                             item[R][C]=K;
                            }		
        for(int i=1;i<=r;i++){                              
          for(int j=1;j<=c;j++){                               
            if(item[i][j]==0){                                
              ans[i][j][0]=Math.max(ans[i][j-1][0],Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3]))));            
            for(int k=1;k<=3;k++){ans[i][j][k]=ans[i][j-1][k];}
            }
            else{ans[i][j][0]=Math.max(ans[i][j-1][0],Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3]))));
              for(int k=1;k<=3;k++){ans[i][j][k]=Math.max(ans[i][j-1][k],ans[i][j-1][k-1]+item[i][j];)}           
                }                                  
          } 
        }      
		System.out.println(Math.max(ans[r][c][0],Math.max(ans[r][c][1],Math.max(ans[r][c][2],ans[r][c][3]))));
	}
}

Compiler output:
Main.java:22: error: ')' or ',' expected
              for(int k=1;k<=3;k++){ans[i][j][k]=Math.max(ans[i][j-1][k],ans[i][j-1][k-1]+item[i][j];)}           
                                                                                                    ^
Main.java:22: error: illegal start of expression
              for(int k=1;k<=3;k++){ans[i][j][k]=Math.max(ans[i][j-1][k],ans[i][j-1][k-1]+item[i][j];)}           
                                                                                                     ^
2 errors
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();
		long [][] item = new long [r+1][c+1];
        long [][][] ans = new long [r+1][c+1][4];
        for(int i=0;i<k;i++){int R = sc.nextInt();
                             int C = sc.nextInt();
                             long K = sc.nextLong();
                             item[R][C]=K;
                            }		
        for(int i=1;i<=r;i++){                              
          for(int j=1;j<=c;j++){                               
            if(item[i][j]==0){                                
              ans[i][j][0]=Math.max(ans[i][j-1][0],Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3]))));            
            for(int k=1;k<=3;k++){ans[i][j][k]=ans[i][j-1][k];}
            }
            else{ans[i][j][0]=Math.max(ans[i][j-1][0],Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3]))));
              for(int k=1;k<=3;k++){ans[i][j][k]=Math.max(ans[i][j-1][k],ans[i][j-1][k-1]+item[i][j];}           
                }                                  
          } 
        }      
		System.out.println(Math.max(ans[r][c][0],Math.max(ans[r][c][1],Math.max(ans[r][c][2],ans[r][c][3]))));
	}
}

Compiler output:
Main.java:22: error: ')' or ',' expected
              for(int k=1;k<=3;k++){ans[i][j][k]=Math.max(ans[i][j-1][k],ans[i][j-1][k-1]+item[i][j];}           
                                                                                                    ^
1 error
Language: C++

#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
const int mxn  = 3e3+1;
// const int len = 1e7;
ll dp[mxn][mxn][4][4];
map <pii,ll> vals; 
int r,c;

ll find(int x, int y, int xl, int yl){
	if(x<0 || x >= r ) return 0ll;
	if(y<0 || y>=c) return 0ll;
	ll &ans = dp[x][y][xl][yl];
	if(ans!=-1){
		return ans;
	}
	ans = 0;
	if(yl>1 && vals[{x,y}].find()!=vals.end()){
		ans = max(ans, vals[{x,y}] + find(x+1,y,3,yl-1));
	}
	if(xl>1 && vals[{x,y}].find()!=vals.end()){
		ans = max(ans,vals[{x,y}] + find(x,y+1,xl-1,3));
	}
	ans = max(ans, max(find(x+1,y,3,yl), find(x,y+1,xl,3)));
	// cout << x << ' ' << y << " " << xl << " " << yl << " " << ans << endl;
	return ans;

}

void solve(){
	int k;
	cin >> r >> c >> k;
	memset(dp,-1,sizeof(dp));
	for(int i =0;i<k;i++){
		int x,y,val;
		cin >> x >> y;
		--x,--y;
		cin >> vals[{x,y}]; 
	}

	ll ans = find(0,0,3,3);

	cout << ans << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Compiler output:
a.cc: In function 'll find(int, int, int, int)':
a.cc:51:32: error: request for member 'find' in 'vals.std::map<std::pair<int, int>, long long int>::operator[](std::pair<int, int>(x, y))', which is of non-class type 'std::map<std::pair<int, int>, long long int>::mapped_type' {aka 'long long int'}
   51 |         if(yl>1 && vals[{x,y}].find()!=vals.end()){
      |                                ^~~~
a.cc:54:32: error: request for member 'find' in 'vals.std::map<std::pair<int, int>, long long int>::operator[](std::pair<int, int>(x, y))', which is of non-class type 'std::map<std::pair<int, int>, long long int>::mapped_type' {aka 'long long int'}
   54 |         if(xl>1 && vals[{x,y}].find()!=vals.end()){
      |                                ^~~~
Language: C++

#include<bits/stdc++.h>
#include "test.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
#define P pair<int,int>
#define PI 3.141592653589793
const int INF = 1001001001;
const ll MX = 1e18;
const int mod = 1000000007;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

ll a[3005][3005];
ll dp[3005][3005][4];

int main() {
	int R, C, k;
	cin >> R >> C >> k;
	rep(i, k) {
		int r, c,v;
		cin >> r >> c >> v;
		r--; c--;
		a[r][c] = v;
	}
	dp[0][0][0] = 0;
	rep(i, R)rep(j, C) {
		for (int K = 2; K >= 0; K--) {
			chmax(dp[i][j][K+1], dp[i][j][K] + a[i][j]);
		}
		rep(k, 3) {
			chmax(dp[i + 1][j][0], dp[i][j][k]);
			chmax(dp[i][j+1][k], dp[i][j][k]);
		}
	}
	ll ans = 0;
	rep(k,4) {
		ans = max(ans,dp[R-1][C-1][k]);
	}
	cout << ans << endl;
}

Compiler output:
a.cc:2:10: fatal error: test.h: No such file or directory
    2 | #include "test.h"
      |          ^~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void solve() {
    ll R, C, K;
    cin >> R >> C >> K;
    vector<vector<ll>> grid(R + 1, vector<ll>(C + 1, 0));
    rep(i, K) {
        ll r, c, v;
        cin >> r >> c >> v;
        r--;
        c--;
        grid[r][c] = v;
    }
    vector<vector<vector<ll>>> dp(R + 1, vector<vector<ll>>(C + 1, vector<ll>(4, 0)));
    rep(i, R) {
        rep(j, C) {
            rep(k, 4) {
                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                if (k <= 2) {
                    dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + grid[i][j]);
                }
            }
        }
        rep2(j, 1, C + 1) {
            rep(k, 4) {
                dp[i + 1][j - 1][0] = max(dp[i + 1][j - 1][0], dp[i][j][k]);
            }
        }
    }
    ll ans = 0;
    rep(j, C + 1) {
        rep(k, 4) {
            ans = max(ans, dp[R][j[k]);
        }
    }
    cout << ans << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Compiler output:
a.cc: In function 'void solve()':
a.cc:57:35: error: invalid types 'll {aka long long int}[ll {aka long long int}]' for array subscript
   57 |             ans = max(ans, dp[R][j[k]);
      |                                   ^
a.cc:57:38: error: expected ']' before ')' token
   57 |             ans = max(ans, dp[R][j[k]);
      |                                      ^
      |                                      ]
Language: C++

#include <iostream>
#include <vector>
#include <set>
typedef long long int ll;

using namespace std;

int main(){
	int r, c, k;
	cin >> r >> c >> k;
	vector<vector<ll> > dp(r, vector<ll> (c, 0));
	//int sum[30][30][30] = {0};
	vector<vector<vector<ll> > > sum(r, vector<vector<ll> > (c, vector<ll> (c, 0))); 
	// sum[i][start][end]: i-th max_three_sum from board[i][start] to board[i][end]
	vector<vector<int> > board(r, vector<int> (c, 0));
	for (int i = 0; i < k; i++){
		int tr, tc, tv;
		cin >> tr >> tc >> tv;
		tr -= 1, tc -= 1;
		board[tr][tc] = tv;
	}
	for (int i = 0; i < r; i++){
		for (int j = 0; j < c; j++){
			vector<int> tmp;
			tmp.push_back(board[i][j]);
			sum[i][j][j] = board[i][j];
			for (int k = j + 1; k < c; k++){
				if (tmp.size() < 3) 
					sum[i][j][k] = sum[i][j][k - 1] + board[i][k], tmp.push_back(board[i][k]);
				else{
					if (board[i][k] > tmp[0]){
						sum[i][j][k] = sum[i][j][k - 1] - tmp[0] + board[i][k];
						tmp[0] = board[i][k];
					}
					else sum[i][j][k] = sum[i][j][k - 1];
				}
				sort(tmp.begin(), tmp.end());
			}
		}
	}
	for (int i = 0; i < c; i++)
		dp[0][i] = sum[0][0][i];
	for (int i = 1; i < r; i++)
		for (int j = 0; j < c; j++)
			for (int k = 0; k <= j; k++)
				dp[i][j] = max(dp[i][j], dp[i - 1][k] + sum[i][k][j]);
	cout << dp[r - 1][c - 1] << '\n';
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:37:33: error: 'sort' was not declared in this scope; did you mean 'short'?
   37 |                                 sort(tmp.begin(), tmp.end());
      |                                 ^~~~
      |                                 short
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();
		long [][] item = new long [r+1][c+1];
        long [][][] ans = new long [r+1][c+1][4];
        String [] str = new String [a];
        for(int i=0;i<k;i++){int R = sc.nextInt();
                             int C = sc.nextInt();
                             long K = sc.nextLong();
                             item[R][C]=K;
                            }		
        for(int i=1;i<=r;i++){
          int count = 0;                              
          for(int j=1;j<=c;j++){                               
            if(item[i][j]==0 || count == 3){                                
              ans[i][j][count]=ans[i][j-1][count];
              ans[i][j][0]=Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3])));
              if(item[i][j]>0){count=1;ans[i][j][1]=ans[i][j][0]+item[i][j];}
            }                              
            else{count++;
                 ans[i][j][count]=ans[i][j-1][count-1]+item[i][j];}
                 if(Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3])))+item[i][j]>=ans[i][j][count])
                 {count=1;
                  ans[i][j][1]=Math.max(ans[i-1][j][0],Math.max(ans[i-1][j][1],Math.max(ans[i-1][j][2],ans[i-1][j][3])))+item[i][j];}
          }                           
        }       
		System.out.println(Math.max(ans[c][k][0],Math.max(ans[c][k][1],Math.max(ans[c][k][2],ans[c][k][3]))));
	}
}

Compiler output:
Main.java:10: error: cannot find symbol
        String [] str = new String [a];
                                    ^
  symbol:   variable a
  location: class Main
1 error
Language: C++

#include<bits/stdc++.h>

using namespace std;

#define int long long

const int N=3005;

vector<vector<int>>m(N,vector<int>(N));
vector<vector<int>>s(N,vector<int>(N));

int32_t main()
{
    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;
        m[r][c]=v;
    }
    vector<int>rr(R);
    for(int i=0;i<R;i++){
        for(int j=0;j<C;j++){
            if(rr[i]==3)continue;
            if(i==0&&j==0)
               s[i][j]=m[i][j];
            else if(i-1==-1)
               s[i][j]=s[i][j-1]+m[i][j],;
            else if(j-1==-1)
                s[i][j]=s[i-1][j]+m[i][j];
            else
                s[i][j]=max(s[i-1][j],s[i][j-1])+m[i][j];
            ++rr[i];
        }
    }
    cout<<s[R-1][C-1]<<endl;
}


Compiler output:
a.cc: In function 'int32_t main()':
a.cc:29:42: error: expected primary-expression before ';' token
   29 |                s[i][j]=s[i][j-1]+m[i][j],;
      |                                          ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep3(i, s, n) for (int i = (s); i <= (int)(n); i++)

int main() {
	int R;
	int C;
	int K;
	int x;
	int y;
	long long z;
	long long ans;


	cin >> R >> C >> K;

	long long rcv[R+5][C+5];
	long long p[R+5][C+5][5];

	rep(i, R+2){
		rep(j, C+2){
			rcv[i][j]=0;
			rep(kk, 4) p[i][j][kk]=0;
		}
	}

	rep3(i, 1, K) {
		cin >> x >> y >> z;
		rcv[x][y]=z;
	}

	rep3(i, 1, R) {
		rep3(j, 1, C) {
			z=rcv[i][j];
//			p[i][j][3]=max(p[i][j][3],p[i][j][2]+z);
//			p[i][j][2]=max(p[i][j][2],p[i][j][1]+z);
//			p[i][j][1]=max(p[i][j][1],p[i][j][0]+z);
//			p[i+1][j][0]=max(p[i+1][j][0],p[i][j][0]);
//			p[i+1][j][0]=max(p[i+1][j][0],p[i][j][1]);
//			p[i+1][j][0]=max(p[i+1][j][0],p[i][j][2]);
//			p[i+1][j][0]=max(p[i+1][j][0],p[i][j][3]);
//			p[i][j+1][0]=max(p[i][j+1][0],p[i][j][0]);
//			p[i][j+1][1]=max(p[i][j+1][1],p[i][j][1]);
//			p[i][j+1][2]=max(p[i][j+1][2],p[i][j][2]);
//			p[i][j+1][3]=max(p[i][j+1][3],p[i][j][3]);
		}
	}
	ans=max(p[R][C][0],p[R][C][1]);
	ans=max(ans,p[R][C][2]);
	ans=max(ans,p[R][C][3]);

	cout << ans << endl;
	return 0;

Compiler output:
a.cc: In function 'int main()':
a.cc:55:18: error: expected '}' at end of input
   55 |         return 0;
      |                  ^
a.cc:7:12: note: to match this '{'
    7 | int main() {
      |            ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	int r,c,k;
	cin>>r>>c>>k;
	ll mtr[3001][3001]; //increase the dimensions
	for(int i=0; i<k; i++){
		int a,b,c;
		cin>>a>>b>>c;
		mtr[a][b]=c;
	}
	for(int i=0; i<=3000; i++){
		for(int j=0; j<=3000; j++){
			for(int k=0; k<=3; k++)
			 dp[i][j][k]=0;
		}
	}
	ll dp[3001][3001][4];  //increase the dimensions
	if(mtr[1][1]>0){
		for(int x=1; x<=3; x++)
		 dp[1][1][x]=mtr[1][1];
	}
	for(int i=1; i<=r; i++){
		for(int j=1; j<=c; j++)
		{
			if(i>1){
				if(mtr[i][j]>0){
					for(int x=0; x<=3; x++)
                     dp[i][j][1]=max(dp[i][j][1],mtr[i][j]+dp[i-1][j][x]);
				}
				for(int x=0; x<=3; x++)
				 dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][x]);
			}
			if(j>1){
				if(mtr[i][j]>0){
					for(int x=1; x<=3; x++)
					 dp[i][j][x]=max(dp[i][j][x],mtr[i][j]+dp[i][j-1][x-1]);
				}
				for(int x=0; x<=3; x++)
				 dp[i][j][x]=max(dp[i][j][x],dp[i][j-1][x]);
			}
		}
	}
	ll ans=0;
	for(int i=0; i<=3; i++)
	 ans=max(ans,dp[r][c][i]);
	cout<<ans;
	return 0;
	
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:26: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |                          dp[i][j][k]=0;
      |                          ^~
      |                          dup
Language: C++

/**
*	created: 16.08.2020 13:39:33
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
using ll = long long;
using P = pair<int,int>;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = LLONG_MAX;
const int MOD = 1000000007;
// const int MOD = 998244353;

int a[3005][3005];
int dp[3005][3005][4];

signed main() {

    cin.tie(0);
    ios_base::sync_with_stdio(false);

    int r, c, n; cin >> r >> c >> n;
    rep(i,n) {
        int a, b, v; cin >> a >> b >> v;
        a[r-1][c-1] = v;
    }
    rep(i,r) rep(j,c) {
        for (int k = 3; k >= 0; k--) {
            chmax(dp[i][j][k+1], dp[i][j][k]+a[i][j]);
        }
        rep(k,4) {
            chmax(dp[i+1][j][0]),dp[i][j][k])
            chmax(dp[i][j+1][k]),dp[i][j][k])
        }
    }
    int ans = 0;
    rep(i,4) chmax(ans,dp[r-1][j-1][k]);
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:36:10: error: invalid types 'long long int[long long int]' for array subscript
   36 |         a[r-1][c-1] = v;
      |          ^
a.cc:43:18: error: no matching function for call to 'chmax(long long int&)'
   43 |             chmax(dp[i+1][j][0]),dp[i][j][k])
      |             ~~~~~^~~~~~~~~~~~~~~
a.cc:17:24: note: candidate: 'template<class T> bool chmax(T&, const T&)'
   17 | template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return 1;} return 0;}
      |                        ^~~~~
a.cc:17:24: note:   candidate expects 2 arguments, 1 provided
a.cc:48:32: error: 'j' was not declared in this scope
   48 |     rep(i,4) chmax(ans,dp[r-1][j-1][k]);
      |                                ^
a.cc:48:37: error: 'k' was not declared in this scope
   48 |     rep(i,4) chmax(ans,dp[r-1][j-1][k]);
      |                                     ^
Language: C++

#include <unistd.h>
#include <algorithm>

typedef long long ll;

int mat[3000][3000];

ll dp[3000][3000][4];
ll dpl[3000];

char buf[1048576];
int lim = 0;
int cur = 0;

void refill()
{
    lim = read(STDIN_FILENO, buf, sizeof buf);
    cur = 0;
}

int rd()
{
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return -1;
        } else {
            if (buf[cur] >= '0' && buf[cur] <= '9') break;
            cur++;
        }
    }
    int acc = buf[cur++] - '0';
    while (true) {
        if (cur == lim) {
            refill();
            if (lim == 0) return acc;
        } else {
            if (buf[cur] < '0' || buf[cur] > '9') return acc;
            acc = acc * 10 + buf[cur++] - '0';
        }
    }
}

int main(int argc, char **argv)
{
    int rr = rd();
    int cc = rd();
    int k  = rd();

    for (int i = 1; i <= k; i++) {
        int r = rd();
        int c = rd();
        int v = rd();
        mat[r - 1][c - 1] = v;
    }
    dp[0][0][1] = mat[0][0];
    for (int y = 0; y < rr; y++) {
        for (int x = 0; x < cc; x++) {
            for (int c = 0; c < 4; c++) {
                int v = mat[y][x];
                ll q;
                if (c == 0 || v == 0) {
                    q = (x == 0) ? dpl[x] : std::max(dpl[x], dp[y][x - 1][c]);
                } else {
                    q = (x == 0) ? dpl[x] + v : std::max(dpl[x] + v, std::max(dp[y][x - 1][c], dp[y][x - 1][c - 1] + v));
                }
                dp[y][x][c] = q;
            }
        }
        for (int x = 0; x < cc; x++) {
            dpl[x] = std::max(std::max(dp[y][x][0], dp[y][x][1]), std::max(dp[y][x][2], dp[y][x][3]));
        }
    }
    printf("%lld\n", dpl[cc - 1]);
    return 0;
}

Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:74:5: error: 'printf' was not declared in this scope
   74 |     printf("%lld\n", dpl[cc - 1]);
      |     ^~~~~~
a.cc:3:1: note: 'printf' is defined in header '<cstdio>'; this is probably fixable by adding '#include <cstdio>'
    2 | #include <algorithm>
  +++ |+#include <cstdio>
    3 |
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;
#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back
int main()
{
    ll R, C, K;
    cin >> R >> C >> K;
    map<pair<ll,ll>,ll> S;
    REP(i,0,K) {
        ll r, c, v;
        cin >> r >> c >> v;
        S[{r, c}] = v;
    }

    vector<vector<vector<ll>>> dp(R+1, vector<vector<ll>>(C+1, vector<ll>(4)));
    REP(i,0,R+1) REP(j,0,C+1) REP(k,0,4) dp[i][j][k] = 0;
    REP(i,1,R+1) {
        REP(j,1,C+1) {
            ll x = 0;
            if(S.count({i, j}) > 0) x = S[{i, j}];
            dp[i][j][0] = MAX(dp[i][j][0],dp[i][j-1][0]);
            REP(k,0,4) dp[i][j][0] = MAX(dp[i][j][0],dp[i-1][j][k]);
            REP(k,1,4) dp[i][j][k] = MAX(dp[i][j][0],dp[i][j-1][k]);
            dp[i][j][1] = MAX(dp[i][j][1],dp[i][j-1][0]+x);
            REP(k,0,4) 
				dp[i][j][1]=MAX(dp[i][j][1],dp[i-1][j][k]+x);
            REP(k,2,4) 
				dp[i][j][k]=MAX(dp[i][j][k],dp[i][j-1][k-1]+x);
        }
    }
    ll ans=MAX(dp[R][C][0],dp[R][C][1]);
    ans=MAX(ans,dp[R][C][2]);
    an=MAX(ans,dp[R][C][3]);
    PR(ans);
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:5: error: 'an' was not declared in this scope; did you mean 'ans'?
   52 |     an=MAX(ans,dp[R][C][3]);
      |     ^~
      |     ans
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define mp make_pair
#define all(n) (n).begin(),(n).end()
#define fi first
#define se second
 
typedef pair<int, int> PII;
typedef long long ll;
 
const int MOD = 1e9+7;
#define MAXN = 3009
int main() {
 
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int r,c,k;
	cin >> r >> c >> k;
	ll gr[MAXN][MAXN];
	memset(gr,0,sizeof(gr));
	for (int i = 0; i < k; i++) {
		int a,b,v;
		cin >> a >> b >> v;
		gr[a][b]=v;
	}
	ll dp[MAXN][MAXN][4];
	memset(dp,0,sizeof(dp));
	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][0]);
			for (int k = 1; k < 4; k++) {
				dp[i][j][k]=max(dp[i][j-1][k],dp[i][j-1][k-1]+gr[i][j]);
				dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][k]);
			}
			dp[i][j][1]=max(dp[i][j][1],dp[i][j][0]+gr[i][j]);
			// cout << dp[i][j][0] << " " << dp[i][j][1] << " " << dp[i][j][2] << " " << dp[i][j][3] << "\n";
		}
	}
	ll ans = 0;
	for (int i = 0; i < 4; i++) ans = max(ans,dp[r][c][i]);
	cout << ans << "\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:14: error: expected primary-expression before '=' token
   14 | #define MAXN = 3009
      |              ^
a.cc:22:15: note: in expansion of macro 'MAXN'
   22 |         ll gr[MAXN][MAXN];
      |               ^~~~
a.cc:14:14: error: expected primary-expression before '=' token
   14 | #define MAXN = 3009
      |              ^
a.cc:22:21: note: in expansion of macro 'MAXN'
   22 |         ll gr[MAXN][MAXN];
      |                     ^~~~
a.cc:23:16: error: 'gr' was not declared in this scope; did you mean 'r'?
   23 |         memset(gr,0,sizeof(gr));
      |                ^~
      |                r
a.cc:14:14: error: expected primary-expression before '=' token
   14 | #define MAXN = 3009
      |              ^
a.cc:29:15: note: in expansion of macro 'MAXN'
   29 |         ll dp[MAXN][MAXN][4];
      |               ^~~~
a.cc:14:14: error: expected primary-expression before '=' token
   14 | #define MAXN = 3009
      |              ^
a.cc:29:21: note: in expansion of macro 'MAXN'
   29 |         ll dp[MAXN][MAXN][4];
      |                     ^~~~
a.cc:30:16: error: 'dp' was not declared in this scope; did you mean 'dup'?
   30 |         memset(dp,0,sizeof(dp));
      |                ^~
      |                dup
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;
  }
  dp[r+1][c+1][4];
  for(int i=0;i<r+1;i++){
    for(int l=0;l<4;l++){
      dp[i][0][l]=0;
    }
  }
  for(int i=0;i<r+1;i++){
    for(int l=0;l<4;l++){
      dp[0][i][l]=0;
    }
  }
  for(int i=1;i<r+1;i++){
    for(int j=1;j<c+1;j++){
      for(int l=0;l<4;l++){
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][l]);
      }
      dp[i][j][0]=max(dp[i][j][0],dp[i][j-1][0]);
      dp[i][j][1]=max(dp[i][j-1][1],dp[i][j][0]+memo[i][j]);
      dp[i][j][2]=max(dp[i][j-1][2],dp[i][j-1][1]+memo[i][j]);
      dp[i][j][3]=max(dp[i][j-1][3],dp[i][j-1][2]+memo[i][j]);
    }
  }
  ll ans=0;
  for(int i=0;i<4;i++){
    ans=max(ans,dp[r][c][i]);
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   41 |   dp[r+1][c+1][4];
      |   ^~
      |   dup
Language: C++

#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x,y) x = max(x,y)
using ll = long long;


int a[3005][3005];
ll dp[3005][3005][4];
int a[3005][3005];
ll dp[3005][3005][4];
int main(){
	int R,C,K;
   cin >> R >> C >> K;
   rep(i,K){
      int r,c,v;
      cin >> r >> c >> v;
      a[r-1][c-1] = v;
   }

   rep(i,R) rep(j,C){
      for(int k=2;k>=0;k--){
         chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
      }
      rep(k,4){
         chmax(dp[i+1][j][0],dp[i][j][k]);
         chmax(dp[i][j+1][k],dp[i][j][k]);
      }
   }

   ll ans=0;
   rep(k,4) chmax(ans,dp[R-1][C-1][k]); 

   cout << ans << endl;
	return 0;
}



Compiler output:
a.cc:11:5: error: redefinition of 'int a [3005][3005]'
   11 | int a[3005][3005];
      |     ^
a.cc:9:5: note: 'int a [3005][3005]' previously declared here
    9 | int a[3005][3005];
      |     ^
a.cc:12:4: error: redefinition of 'll dp [3005][3005][4]'
   12 | ll dp[3005][3005][4];
      |    ^~
a.cc:10:4: note: 'll dp [3005][3005][4]' previously declared here
   10 | ll dp[3005][3005][4];
      |    ^~
Language: C++

#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x,y) x = max(x,y)

int a[3005][3005];
ll dp[3005][3005][4];
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int R,C,K;
	cin >> R >> C >> K;
	rep(i,K){
	  int r,c,v;
	  cin >> r >> c >> v;
	  a[r-1][c-1] = v;
	}
	
	rep(i,R) rep(j,C){
	  for(int k=2;k>=0;k--){
	     chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
	  }
	  rep(k,4){
	     chmax(dp[i+1][j][0],dp[i][j][k]);
	     chmax(dp[i][j+1][k],dp[i][j][k]);
	  }
	}
	
	ll ans=0;
	rep(k,4) chmax(ans,dp[R-1][C-1][k]); 
	
	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc:8:1: error: 'll' does not name a type
    8 | ll dp[3005][3005][4];
      | ^~
a.cc: In function 'int main()':
a.cc:24:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   24 |              chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
      |                    ^~
a.cc:5:20: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                    ^
a.cc:27:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   27 |              chmax(dp[i+1][j][0],dp[i][j][k]);
      |                    ^~
a.cc:5:20: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                    ^
a.cc:32:9: error: 'll' was not declared in this scope
   32 |         ll ans=0;
      |         ^~
a.cc:33:24: error: 'ans' was not declared in this scope; did you mean 'abs'?
   33 |         rep(k,4) chmax(ans,dp[R-1][C-1][k]);
      |                        ^~~
a.cc:5:20: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                    ^
a.cc:33:28: error: 'dp' was not declared in this scope; did you mean 'dup'?
   33 |         rep(k,4) chmax(ans,dp[R-1][C-1][k]);
      |                            ^~
a.cc:5:30: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                              ^
a.cc:35:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   35 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define chmax(x,y) x = max(x,y)
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	int R,C,K;
	cin >> R >> C >> K;
	rep(i,K){
	  int r,c,v;
	  cin >> r >> c >> v;
	  a[r-1][c-1] = v;
	}
	
	rep(i,R) rep(j,C){
	  for(int k=2;k>=0;k--){
	     chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
	  }
	  rep(k,4){
	     chmax(dp[i+1][j][0],dp[i][j][k]);
	     chmax(dp[i][j+1][k],dp[i][j][k]);
	  }
	}
	
	ll ans=0;
	rep(k,4) chmax(ans,dp[R-1][C-1][k]); 
	
	cout << ans << endl;
	return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:16:11: error: 'a' was not declared in this scope
   16 |           a[r-1][c-1] = v;
      |           ^
a.cc:21:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |              chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
      |                    ^~
a.cc:5:20: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                    ^
a.cc:21:46: error: 'a' was not declared in this scope
   21 |              chmax(dp[i][j][k+1],dp[i][j][k]+a[i][j]);
      |                                              ^
a.cc:5:30: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                              ^
a.cc:24:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   24 |              chmax(dp[i+1][j][0],dp[i][j][k]);
      |                    ^~
a.cc:5:20: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                    ^
a.cc:29:9: error: 'll' was not declared in this scope
   29 |         ll ans=0;
      |         ^~
a.cc:30:24: error: 'ans' was not declared in this scope; did you mean 'abs'?
   30 |         rep(k,4) chmax(ans,dp[R-1][C-1][k]);
      |                        ^~~
a.cc:5:20: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                    ^
a.cc:30:28: error: 'dp' was not declared in this scope; did you mean 'dup'?
   30 |         rep(k,4) chmax(ans,dp[R-1][C-1][k]);
      |                            ^~
a.cc:5:30: note: in definition of macro 'chmax'
    5 | #define chmax(x,y) x = max(x,y)
      |                              ^
a.cc:32:17: error: 'ans' was not declared in this scope; did you mean 'abs'?
   32 |         cout << ans << endl;
      |                 ^~~
      |                 abs
Language: C++

#include <iostream>
using namespace std;


int main()
{
    long long R, C, K;
    cin >> R >> C >> K;
    long long a[R + 10][C + 10];
    for (int i = 0; i <= R; i++)
    {
        for (int j = 0; j <= C; j++)
        {
            a[i][j] = 0;
        }
    }
    long long r, c, v;
  　long long x,y,z;
    for (int i = 0; i < K; i++)
    {
        cin >> r >> c >> v;
        a[r][c] = v;
    }

    long long dp[4][R + 10][C + 10];
    for (int i = 0; i <= 3; i++)
    {
        for (int j = 0; j <= R; j++)
        {
            for (int k = 0; k <= C; k++)
            {
                dp[i][j][k] = 0;
            }
        }
    }
  
    for (int i = 1; i <= R; i++)
    {
        for (int j = 1; j <= C; j++)
        {
            if (a[i][j] > 0)
            {
                x = a[i][j];
                y = dp[0][i - 1][j];

                for (int s = 1; s <= 3; s++)
                {
                  y =max(y,dp[s][i-1][j]);   
                }
                dp[0][i][j] = max(dp[0][i][j - 1], y);
                dp[1][i][j] = max(dp[0][i][j - 1] + x, dp[1][i][j - 1]);
                dp[1][i][j] = max(dp[1][i][j], y + x);
                dp[2][i][j] = max(dp[1][i][j - 1] + x, dp[2][i][j - 1]);
                dp[3][i][j] = max(dp[2][i][j - 1] + x, dp[3][i][j - 1]);
            }
            else
            {
                y = dp[0][i - 1][j];
                for (int s = 1; s <= 3; s++)
                {
                  y =max(y,dp[s][i-1][j]);   
                }
                dp[0][i][j] = max(dp[0][i][j - 1], y);
                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];
            }
        }
    }

    long long ans = 0;
    for (int i = 0; i <= 3; i++)
    {
        ans = max(ans, dp[i][R][C]);
    }
    cout << ans << endl;
    return 0;
}


Compiler output:
a.cc:18:3: error: extended character 　 is not valid in an identifier
   18 |   　long long x,y,z;
      |   ^
a.cc: In function 'int main()':
a.cc:18:3: error: '\U00003000long' was not declared in this scope; did you mean 'ulong'?
   18 |   　long long x,y,z;
      |   ^~~~~~
      |   ulong
a.cc:43:17: error: 'x' was not declared in this scope
   43 |                 x = a[i][j];
      |                 ^
a.cc:44:17: error: 'y' was not declared in this scope
   44 |                 y = dp[0][i - 1][j];
      |                 ^
a.cc:58:17: error: 'y' was not declared in this scope
   58 |                 y = dp[0][i - 1][j];
      |                 ^