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

#include<bits/stdc++.h>
using namespace std;

#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (ll i = m; i < (n); i++)

using ll = long long;
using pii = pair<int, int>;
using Vi = vector<int>;


int main(){
  int R,C,K;
  cin >> R >> C >> K;
  vector<vector<int>> item(3010, vector<int>(3010,0));
  
  int r,c,v;
  for(int i = 0; i<K; i++){
    cin >> r >> c >> v;
    item[r][c] = v;
  }
  
  vector<vector<vector<int>>> dp(3010, vector<vector<int>>(3010, vector<int> (4, 0)));
  
  for(int i = 1; i<=3000; i++){
    for(int j = 1; j<=3000; j++){
      for(int k = 0; k<=3; k++){
        if(k==0){
          dp[i][j][k] = max(dp[i-1][j][3], dp[i][j-1][0]);
        }   
        else{
          if(item[i][j]==0){
             dp[i][j][k] = max(dp[i][j-1][k],dp[i][j][k-1]);
          }
          else{
            
             dp[i][j][k] = max(dp[i][j-1][k],max(dp[i-1][j][3],dp[i][j-1][k-1])+item[i][j]);
          }
        }
      }
    }
  }
  
  cout << dp[R][C][3]  << endl;
  

Compiler output:
a.cc: In function 'int main()':
a.cc:44:32: error: expected '}' at end of input
   44 |   cout << dp[R][C][3]  << endl;
      |                                ^
a.cc:12:11: note: to match this '{'
   12 | int main(){
      |           ^
Language: C++

#include <iostream>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cassert>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

typedef long long ll;
#define rep2(i, n) for(ll i = 2; i <=(ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
#define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

ll pow(ll a, ll n) { //compute a^n with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a;
        a = a * a;
        n >>= 1;
    }
    return res;
}

ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

const int MAX = 199;
const int MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

//順列計算
ll PER(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[n - k] % MOD) % MOD;
}

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; }

#define MX 3010
int main(){
    const ll INF = 1e18;
    ll dp[MX][MX][4];
    ll v[MX][MX];
    int R, C, K;
    cin >> R >> C >> K;
    rep0(i, K-1){
        int r, c, val;
        cin >> r >> c >> val;
        --r, --c;
        v[r][c] = val;
    }
    rep0(i, MX-1) rep0(j, MX-1) rep0(k, 3) dp[i][j][k] = -INF;
    dp[0][0][0] = 0;
    ll ans = -INF;
    rep0(i, R-1){ rep0(j, C-1){
        for(int k = 2; k >= 0; --k){
            if(dp[i][j][k] >= 0) chmax(dp[i][j][k + 1], dp[i][j][k] + v[i][j]);
        }
        rep0(k, 3){
            if(dp[i][j][k] >= 0){
                if(i + 1 < R) chmax(dp[i + 1][j][0], dp[i][j][k]);
                if(j + 1 < C) chmax(dp[i][j + 1][k], dp[i][j][k]);
            }
        }
    }}
    rep0(k, 3) chmax(ans, dp[R - 1][C - 1][k]);
    cout << ans << endl;
    */
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:104:6: error: expected primary-expression before '/' token
  104 |     */
      |      ^
a.cc:105:5: error: expected primary-expression before 'return'
  105 |     return 0;
      |     ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define _USE_MATH_DEFINES  // M_PI等のフラグ
#define MOD 1000000007
#define COUNTOF(array) (sizeof(array)/sizeof(array[0]))
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;


void solve(){
    int R, C, K;
    cin >> R >> C >> K;
    vector<vector<int>> grid(R, vector<int>(C, 0));
    for (int i=0; i<K; i++) {
        int r, c, v;
        cin >> r >> c >> v;
        grid.at(--r).at(--c) = v;
    }

    // dp[i][j][x] := i行j列目で、このマスの行でx個のアイテムを取ったときの価値の最大値
    vector<vector<vector<int>>> dp(R, vector<vector<int>>(C, vector<int>(4, 0)));
    dp[0][0][1] = grid[0][0];

    for (int i=0; i<R; i++) {
        for (int j=0; j<C; j++) {
            // grid[i-1][j]からgrid[i][j]へ移動する場合
            for (int x=0; x<4; x++) {
                if (i-1>=0) {
                // 拾わない場合
                    dp[i][j][0] = max(dp[i][j][0], dp[i-1][j][x]);
                // 拾う場合
                    dp[i][j][1] = max(dp[i][j][1], dp[i-1][j][x] + grid[i][j]);
            }
            // grid[i][j-1]からgrid[i][j]へ移動する場合
            for (int x=0; x<4; x++) {
                if (j-1>=0) {
                    // 拾わない場合
                    dp[i][j][x] = max(dp[i][j][x], dp[i][j-1][x]);
                    // 拾う場合
                    if (x-1>=0) {
                        dp[i][j][x] = max(dp[i][j][x], dp[i][j-1][x-1] + grid[i][j]);
                    }
                }
            }
        }
    }

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


int main(int argc, char const *argv[]){
    solve();
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:58:39: error: a function-definition is not allowed here before '{' token
   58 | int main(int argc, char const *argv[]){
      |                                       ^
a.cc:61:2: error: expected '}' at end of input
   61 | }
      |  ^
a.cc:11:13: note: to match this '{'
   11 | void solve(){
      |             ^
Language: C++

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int R,C,r,c,n;
  cin >> R>>C>>n;
  int v[3005][3005];
  ll d[3005][3005][4];
  rep(i,n){
    cin >> r>>c;
    cin >> v[r-1][c-1];
  }
  rep(i,R)rep(j,C){
    for(k=2;k>=0;k--){
      chmax(d[i][j][k+1],d[i][j][k]+v[i][j]);
    }
    rep(k,4){
      chmax(d[i+1][j][0], d[i][j][k]);
      chmax(d[i][j+1][k], d[i][j][k]);
    }
  }
  ll ans=0;
  rep(k, 4){
    chmax(ans, d[R-1][C-1][k]);
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:70:9: error: 'k' was not declared in this scope
   70 |     for(k=2;k>=0;k--){
      |         ^
Language: C++

#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define square(x) pow(x,2.0)
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define max_queue(x) priority_queue<x>
#define min_queue(x) priority_queue<x, vector<x>, greater<x>>
#define big_sort(v) sort(all(v), [](int a, int b) { return a > b; })//大きい順にソート
using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
using vs = vector<string>;
using vd = vector<long double>;
#define co(x) cout << x << endl;
#define cins(n,v) rep(i,n){cin >> v.at(i);}
#define couts(v) rep(i,v.size()){cout << v.at(i) << endl;}
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
/*
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
*/
int main() {
  int R,C,r,c,n;
  cin >> R>>C>>k;
  int v[3005][3005];
  ll d[3005][3005][4];
  rep(i,n){
    cin >> r>>c;
    cin >> v[r-1][c-1];
  }
  rep(i,R)rep(j,C){
    for(k=2;k>=0;k--){
      chmax(d[i][j][k+1],d[i][j][k]+v[i][j]);
    }
    rep(k,4){
      chmax(d[i+1][j][0], d[i][j][k]);
      chmax(d[i][j+1][k], d[i][j][k]);
    }
  }
  ll ans=0;
  rep(k, 4){
    chmax(ans, d[R-1][C-1][k]);
  }
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:16: error: 'k' was not declared in this scope
   62 |   cin >> R>>C>>k;
      |                ^
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100//000000000
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,P>
#define T tuple<int,int,int> 
using namespace std;

ll dp[3010][3010][4];
ll d[3010][3010];

int main(){
    int r,c,k; cin >> r >> c >> k;
    map<P,ll> m;
    rep(i,k){
        int a,b,v; cin >> a >> b >> v;
        a--; b--;
        d[a][b]=v;
    }

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

    rep(i,r)rep(j,c){
        for(int k=2; k>=0; k--){
            dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j][k]+d[a][b]);
        }
        rep(k,4){
            dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
            dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
        }
    }
    ll ans=0;
    rep(i,4) ans=max(ans,dp[r-1][c-1][i]);
    cout << ans << endl;
return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:59: error: 'a' was not declared in this scope
   29 |             dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j][k]+d[a][b]);
      |                                                           ^
a.cc:29:62: error: 'b' was not declared in this scope
   29 |             dp[i][j][k+1]=max(dp[i][j][k+1],dp[i][j][k]+d[a][b]);
      |                                                              ^
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;

template <typename T> // *s.find_by_order(0), s.order_of_key(2) ;
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define reMin(a, b) a = min(a, b)
#define reMax(a, b) a = max(a, b)

#define lint long long
#define pb push_back
#define F first 
#define S second 
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define SET(x, val) memset(x, val, sizeof(x))
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef vector < int > vi ;
typedef pair < int, int > pii ;

// template <typename T>
inline int modpow(lint base, int exp, int modulo) {
  base %= modulo;
  lint result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulo;
    base = (base * base) % modulo;
    exp >>= 1;
  }
  return result;
}

const int N = 3e3 + 2 ;
const int MOD = 1e9 + 7 ;
const lint INF = 1e18 ;

lint dp[N][N][4] ;
int val[N][N] ;
int index[N][N] ;
int n, m, k ;

lint solve(int i, int j, int curRow) {
	if(i >= n) return 0;
	if(j >= m) return 0;
	if(dp[i][j][curRow] != -1) return dp[i][j][curRow] ; 
	lint ans = 0 ;
	
	// dont pick
	reMax(ans, max(solve(i, j+1, curRow), solve(i+1, j, 0)));

	// pick
	if(curRow < 3) {
		reMax(ans, solve(i, j+1, curRow + 1) + val[i][j]);
		reMax(ans, solve(i+1, j, 0) + val[i][j]); 
	}
	return dp[i][j][curRow] = ans ; 
}

int main()
{
    fastio; cin >> n >> m >> k ; int r, c, v ;
    SET(index, -1); SET(val, 0);
    for(int i = 0; i < k; i++) {
    	cin >> r >> c >> v ;
    	r-- ; c-- ; 
    	index[r][c] = i ; 
    	val[r][c] = v ; 
    }
    SET(dp, -1); cout << solve(0, 0, 0); 
}


Compiler output:
a.cc:44:15: error: 'int index [3002][3002]' redeclared as different kind of entity
   44 | int index[N][N] ;
      |               ^
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int main()':
a.cc:20:36: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   20 | #define SET(x, val) memset(x, val, sizeof(x))
      |                                    ^~~~~~~~~
a.cc:67:5: note: in expansion of macro 'SET'
   67 |     SET(index, -1); SET(val, 0);
      |     ^~~
a.cc:20:27: error: cannot resolve overloaded function 'index' based on conversion to type 'void*'
   20 | #define SET(x, val) memset(x, val, sizeof(x))
      |                     ~~~~~~^~~~~~~~~~~~~~~~~~~
a.cc:67:5: note: in expansion of macro 'SET'
   67 |     SET(index, -1); SET(val, 0);
      |     ^~~
a.cc:71:14: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   71 |         index[r][c] = i ;
      |              ^
Language: C++

#include <iostream>
#include <algorithm>
#include <deque>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
#include <cmath>
#define rep0(i, n) for (i = 0; i < n; i++)
#define rep(s, i, n) for (i = s; i < n; i++)
using namespace std;

long long dp[3001][3001][5];
int value[3001][3001];

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

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

    int i, j, k, r, c, v;
    rep0(i, K)
    {
        cin >> r >> c >> v;
        value[r-1][c-1] = v;
    }

    dp[0][0][1] = value[0][0];

    rep0(i, R)
    {
        rep0(j, C)
        {
            rep0(k, 4)
            {
                //to down
                dp[i + 1][j][0] = max(dp[i][j][k], dp[i + 1][j][0]);
                dp[i + 1][j][1] = max(dp[i][j][k] + value[i + 1][j], dp[i + 1][j][1]);

                dp[i][j + 1][k] = max(dp[i][j + 1][k], dp[i][j][k]);
                dp[i][j + 1][k + 1] = max(dp[i][j + 1][k + 1], dp[i][j][k] + value[i][j + 1]);
            }
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:23:5: error: 'memset' was not declared in this scope
   23 |     memset(dp, 0, sizeof(dp));
      |     ^~~~~~
a.cc:14:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
   13 | #include <cmath>
  +++ |+#include <cstring>
   14 | #define rep0(i, n) for (i = 0; i < n; i++)
Language: C++

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

const long long INF = 1LL << 60;

int main()
{
    int i, j, k, R, C, K;
    cin >> R >> C >> K;
    int V[R+1][C+1];
    unsigned int dp[R+1][C+1][5];
    memset(V, 0, sizeof(V));
    memset(dp, 0, sizeof(dp));
    int r, c, v;
    rep(i, K){
        cin >> r >> c >> v;
        V[r-1][c-1]=v;
    }

    dp[0][0][1] = V[0][0];

    rep(i, R){ rep(j, C) { rep(k, 4){
        // to right
        dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+V[i][j+1]);
        dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
        // to down
        dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+V[i+1][j]);
        dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
    }}}

    long long ans=0;
    rep(i,4) ans=max(ans,dp[R-1][C-1][i]);

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

Compiler output:
a.cc: In function 'int main()':
a.cc:33:21: error: no matching function for call to 'max(long long int&, unsigned int&)'
   33 |     rep(i,4) ans=max(ans,dp[R-1][C-1][i]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:   template argument deduction/substitution failed:
a.cc:33:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'unsigned int')
   33 |     rep(i,4) ans=max(ans,dp[R-1][C-1][i]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~
/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, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:33:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |     rep(i,4) ans=max(ans,dp[R-1][C-1][i]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~
Language: C++

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

const long long INF = 1LL << 60;

int main()
{
    int i, j, k, R, C, K;
    cin >> R >> C >> K;
    int V[R+1][C+1];
    unsigned dp[R+1][C+1][5];
    memset(V, 0, sizeof(V));
    memset(dp, 0, sizeof(dp));
    int r, c, v;
    rep(i, K){
        cin >> r >> c >> v;
        V[r-1][c-1]=v;
    }

    dp[0][0][1] = V[0][0];

    rep(i, R){ rep(j, C) { rep(k, 4){
        // to right
        dp[i][j+1][k+1]=max(dp[i][j+1][k+1],dp[i][j][k]+V[i][j+1]);
        dp[i][j+1][k]=max(dp[i][j+1][k],dp[i][j][k]);
        // to down
        dp[i+1][j][1]=max(dp[i+1][j][1],dp[i][j][k]+V[i+1][j]);
        dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][k]);
    }}}

    long long ans=0;
    rep(i,4) ans=max(ans,dp[R-1][C-1][i]);

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

Compiler output:
a.cc: In function 'int main()':
a.cc:33:21: error: no matching function for call to 'max(long long int&, unsigned int&)'
   33 |     rep(i,4) ans=max(ans,dp[R-1][C-1][i]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 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:   template argument deduction/substitution failed:
a.cc:33:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'unsigned int')
   33 |     rep(i,4) ans=max(ans,dp[R-1][C-1][i]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~
/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, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:33:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   33 |     rep(i,4) ans=max(ans,dp[R-1][C-1][i]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define MAXR 3001
#define MAXC 3001
#define MAXK 200001
ll item[MAXR][MAXC];
ll dp[MAXR][MAXC][4];
int main() {
    int r, c;
    ll k;
    cin >> r >> c >> k;
    memset(item, 0, sizeof(item));
    memset(dp, 0, sizeof(dp));
    for (int i = 1; i <= k; i++) {
        ll R, C, V;
        cin >> R >> C >> V;
        item[R][C] = V;
    }
    ll max1 = 0;
    ll max2 = 0;
    ll max3 = 0;
    for (int i = 1; i <= c; i++) {
        if (item[1][i] > max1) {
            max3 = max2;
            max2 = max1;
            max1 = item[1][i];
        }
        else if (item[1][i] > max2) {
            max3 = max2;
            max2 = item[1][i];
        }
        else if (item[1][i] > max3) {
            max3 = item[1][i];
        }
        dp[1][i][1] = max1;
        dp[1][i][2] = max1 + max2;
        dp[1][i][3] = max1 + max2 + max3;
    }
    //cout << dp[1][2][3] << endl;
    for (int i = 2; i <= r; i++) {
        dp[r][1][0] = dp[r - 1][1][1];
        dp[r][1][1] = dp[r - 1][1][1] + item[r][1];
        dp[r][1][2] = dp[r][1][1];
        dp[r][1][3] = dp[r][1][1];
    }
    for (int i = 2; i <= r; i++) {
        for (int j = 2; j <= c; j++) {
            dp[i][j][0] = max(dp[i - 1][j][3], dp[i][j - 1][0]);
            dp[i][j][1] = max(dp[i][j][0] + item[i][j], dp[i][j - 1][1]);
            dp[i][j][2] = max(dp[i][j - 1][1] + item[i][j], dp[i][j][1], dp[i][j - 1][2]);
            dp[i][j][3] = max(dp[i][j - 1][2] + item[i][j], dp[i][j][2], dp[i][j - 1][3]);
        }
    }
    cout << dp[r][c][3] << endl;
    return 0;
}

Compiler output:
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = long long int; _Compare = long long int]':
a.cc:51:30:   required from here
   51 |             dp[i][j][2] = max(dp[i][j - 1][1] + item[i][j], dp[i][j][1], dp[i][j - 1][2]);
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
  306 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll R, C, K;
  cin>>R>>C>>K;
  vector<ll> RR(K), CC(K), VV(K);
  vector<vector<ll>> Check(R, vector<ll>(C, 0));
  rep(i, K){
    cin>>RR[i]>>CC[i]>>VV[i];
    RR[i]--; CC[i]--;
    Check[RR[i]][CC[i]]=VV[i];
  }
  ll dp[3010][3010][4];
  rep(i, R+1){
    rep(j, C+1){
      rep(k, 4){
       	dp[i][j][k]=-1*INF;
      }
    }
  }
  /*rep(i, R){
rep(j, C){
  cout<<Check[i][j]<<" ";
}
  cout<<endl;}**/
  
  dp[0][0][0]=0;
  if(Check[0][0]>0)dp[0][0][1]=Check[0][0];
  
  rep(i, R){
    rep(j, C){
      
      if(i>0){
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][0]);
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][1]);
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][2]);
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][3]);
        if(Check[i][j]>0){
          dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][0]+Check[i][j]);
          dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][1]+Check[i][j]);
          dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][2]+Check[i][j]);
          dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][3]+Check[i][j]);
        }
      }
      if(j>0){
        dp[i][j][0]=max(dp[i][j][0], dp[i][j-1][0]);
        dp[i][j][1]=max(dp[i][j][1], dp[i][j-1][1]);
        dp[i][j][2]=max(dp[i][j][2], dp[i][j-1][2]);
        dp[i][j][3]=max(dp[i][j][3], dp[i][j-1][3]);
        if(Check[i][j]>0){
          dp[i][j][1]=max(dp[i][j][1], dp[i][j-1][0]+Check[i][j]);
          dp[i][j][2]=max(dp[i][j][2], dp[i][j-1][1]+Check[i][j]);
          dp[i][j][3]=max(dp[i][j][3], dp[i][j-1][2]+Check[i][j]);
        }
      }
      //cout<<i<<" "<<j<<"   "<<dp[i][j][0]<<" "<<dp[i][j][1]<<" "<<dp[i][j][2]<<" "<<dp[i][j][3]<<endl;
    }
  }
  
  //ll Ans=max(dp[R-1][C-1][0], dp[R-1][C-1][1]);
  ll Anss=max(dp[R-1][C-1][2], dp[R-1][C-1][3]);
  
  cout<<max(Ans)<<endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:77:13: error: 'Ans' was not declared in this scope; did you mean 'Anss'?
   77 |   cout<<max(Ans)<<endl;
      |             ^~~
      |             Anss
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll R, C, K;
  cin>>R>>C>>K;
  vector<ll> RR(K), CC(K), VV(K);
  vector<vector<ll>> Check(R, vector<ll>(C, 0));
  rep(i, K){
    cin>>RR[i]>>CC[i]>>VV[i];
    RR[i]--; CC[i]--;
    Check[RR[i]][CC[i]]=VV[i];
  }
  ll dp[3010][3010][4];
  rep(i, R+1){
    rep(j, C+1){
      rep(k, 4){
       	dp[i][j][k]=-1*INF;
      }
    }
  }
  /*rep(i, R){
rep(j, C){
  cout<<Check[i][j]<<" ";
}
  cout<<endl;}**/
  
  dp[0][0][0]=0;
  if(Check[0][0]>0)dp[0][0][1]=Check[0][0];
  
  rep(i, R){
    rep(j, C){
      
      if(i>0){
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][0]);
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][1]);
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][2]);
        dp[i][j][0]=max(dp[i][j][0],dp[i-1][j][3]);
        if(Check[i][j]>0){
          dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][0]+Check[i][j]);
          dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][1]+Check[i][j]);
          dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][2]+Check[i][j]);
          dp[i][j][1]=max(dp[i][j][1], dp[i-1][j][3]+Check[i][j]);
        }
      }
      if(j>0){
        dp[i][j][0]=max(dp[i][j][0], dp[i][j-1][0]);
        dp[i][j][1]=max(dp[i][j][1], dp[i][j-1][1]);
        dp[i][j][2]=max(dp[i][j][2], dp[i][j-1][2]);
        dp[i][j][3]=max(dp[i][j][3], dp[i][j-1][3]);
        if(Check[i][j]>0){
          dp[i][j][1]=max(dp[i][j][1], dp[i][j-1][0]+Check[i][j]);
          dp[i][j][2]=max(dp[i][j][2], dp[i][j-1][1]+Check[i][j]);
          dp[i][j][3]=max(dp[i][j][3], dp[i][j-1][2]+Check[i][j]);
        }
      }
      //cout<<i<<" "<<j<<"   "<<dp[i][j][0]<<" "<<dp[i][j][1]<<" "<<dp[i][j][2]<<" "<<dp[i][j][3]<<endl;
    }
  }
  /*
  ll Ans=max(dp[R-1][C-1][0], dp[R-1][C-1][1]);
  ll Anss=max(dp[R-1][C-1][2], dp[R-1][C-1][3]);
  */
  cout<<max(Ans, Anss)<<endl;
  return 0;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:77:13: error: 'Ans' was not declared in this scope
   77 |   cout<<max(Ans, Anss)<<endl;
      |             ^~~
a.cc:77:18: error: 'Anss' was not declared in this scope
   77 |   cout<<max(Ans, Anss)<<endl;
      |                  ^~~~
Language: C++

#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void llchmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void llchmax(ll &a, ll b){
  if(a < b)
    a = b;
}
int item[3010][3010]
ll dp[3010][3010][4]

int main(){
  int r, c, k;
  cin >> r >> c >> k;
  // int item[3010][3010];
  // ll dp[3010][3010][4];
  rep(i, 0, 3010){
    rep(j, 0, 3010){
      item[i][j] = -1;
      rep(d, 0, 4){
        dp[i][j][d] = 0;
      }
    }
  }
  rep(i, 0, k){
    int x, y;
    cin >> x >> y;
    x--;y--;
    cin >> item[x][y];
  }
 
  rep(i, 0, r){
    rep(j, 0, c){
      rep(d, 0, 4){
        llchmax(dp[i][j+1][d], dp[i][j][d]);
        llchmax(dp[i+1][j][0], dp[i][j][d]);
        
        if(item[i][j] == -1 || d == 3){
          continue;
        }
       
        ll v = item[i][j];
        llchmax(dp[i+1][j][0], dp[i][j][d] + v);
        llchmax(dp[i][j+1][d+1], dp[i][j][d] + v);
        
      }
    }
  }
  
  cout << dp[r][c-1][0] << endl;
  
  return 0;
  
}


Compiler output:
a.cc:23:1: error: expected initializer before 'll'
   23 | ll dp[3010][3010][4]
      | ^~
Language: C++

#include<iostream>
#include<vector>
using namespace std;

int main() {
  int H, W, K; cin >> H >> W >> K;
  int M[H][W], r, c, v;
  for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) M[i][j] = 0;
  for (int i = 0; i < K; i++) {
    cin >> r >> c >> v; r--; c--; M[r][c] = v;
  }
  long dp[H][W][4];
  dp[0][0][0] = 0;
  dp[0][0][1] = dp[0][0][2] = dp[0][0][3] = M[0][0];
  for (int i = 1; i < H; i++) {
    for (int k = 0; k <= 3; k++) {
      dp[i][0][k] = dp[i-1][0][3];
      if (k > 0) dp[i][0][k] = max(dp[i][0][k], dp[i-1][0][3] + M[i][0]);
    }
  }
  for (int j = 1; j < W; j++) {
    for (int k = 0; k <= 3; k++) {
      dp[0][j][k] = dp[0][j-1][k];
      if (k > 0) dp[0][j][k] = max(dp[0][j][k], dp[0][j-1][k-1] + M[0][j]);
    }
  }
  for (int i = 1; i < H; i++) {
    for (int j = 1; j < W; j++) {
      for (int k = 0; k <= 3; k++) {
        dp[i][j][k] = max(dp[i-1][j][3], dp[i][j-1][k]);
        if (k > 0) dp[i][j][k] = max(dp[i][j][k],
          max(dp[i-1][j][3], dp[i][j-1][k-1]) + M[i][j]);
      }
    }
  }
  int max_p = 0;
  for (int i = 0; i < H; i++)
    for (int j = 0; j < W; j++)
      for (int k = 0; k <= 3; k++)
        max_p = max(max_p, dp[i][j][k]);
  cout << max_p << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:20: error: no matching function for call to 'max(int&, long int&)'
   40 |         max_p = max(max_p, dp[i][j][k]);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~
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:   template argument deduction/substitution failed:
a.cc:40:20: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long int')
   40 |         max_p = max(max_p, dp[i][j][k]);
      |                 ~~~^~~~~~~~~~~~~~~~~~~~
/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, 2 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
ll dp[3001][3001][3], a[3001][3001];
 
int main() {
    ll r,c,items, x , y, v, maxi = 0;
    cin >> r >> c >> items;
    while(items--) {
    	cin >> x >> y >> v;
    	x--, y--;
    	dp[x][y][0] = a[x][y] = v;
    }
    for(int i=0;i<r;i++) for(int j=0;j<c;j++) {
        for(int k=0;k<3;k++) {
            if(k > 0) dp[i][j][k] = max(dp[i][j][k], dp[i][j][k-1]);
            if(j+1 < c) dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k]);
            if(j+1 < c && k > 0) dp[i][j+1][k] = max(dp[i][j+1][k], dp[i][j][k-1] + a[i][j+1]);
        }
        if(i+1 < r) dp[i+1][j][0] = dp[i+1][j][1] = dp[i+1][j][2] = max({dp[i][j][0], dp[i][j][1], dp[i][j][2]}) + a[i+1][j];
    }

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

#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define FOR(i, a, b) for (int i = a; i <= (b); i++)
#define ROF(i, a, b) for (int i = a; i >= (b); i--)

using pii = pair<int, int>; using vpii = vector<pii>;
using vi = vector<int>; using vvi = vector<vi>;
using ll = long long;
using pll = pair<ll, ll>; using vpll = vector<pll>;
using vll = vector<ll>; using vvll = vector<vll>;

int main() {
    int r, c, k; cin >> r >> c >> k;
    vvll a(r + 1, vll(c + 1));
    FOR(i, 1, k) {
        int x, y, v; cin >> x >> y >> v;
        a[x][y] = v;
    }
    vector <vvll> dp(r + 1, vvll(c + 1, vll(4)));
    ll ans = 0;
    FOR(i, 1, r) FOR(j, 1, c) {
        FOR(l, 0, 3)
            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]);
        FOR(l, 1, 3)
            dp[i][j][l] = dp[i][j - 1][l]
        ROF(l, 3, 1)
            dp[i][j][l] = max(dp[i][j][l], dp[i][j][l - 1] + a[i][j]);
        FOR(l, 0, 3)
            ans = max(ans, dp[i][j][l]);
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:42: error: expected ';' before 'for'
   32 |             dp[i][j][l] = dp[i][j - 1][l]
      |                                          ^
      |                                          ;
a.cc:33:13: error: 'l' was not declared in this scope
   33 |         ROF(l, 3, 1)
      |             ^
a.cc:10:38: note: in definition of macro 'ROF'
   10 | #define ROF(i, a, b) for (int i = a; i >= (b); i--)
      |                                      ^
Language: C++

#include <bits/stdc++.h>
#define roop(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) { x = max(x, y) }

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

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    roop(i, K){
        int r, c, v;
        cin >> r >> c >> v;
        a[r - 1][c - 1] = v; //各マスのアイテム
    }
    roop(i, R){
        roop(j, C){
            for(int k = 2; k >= 0; k--){
                chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
            }
            roop(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;
    roop(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:6:37: error: expected ';' before '}' token
    6 | #define chmax(x, y) { x = max(x, y) }
      |                                     ^
a.cc:22:17: note: in expansion of macro 'chmax'
   22 |                 chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
      |                 ^~~~~
a.cc:6:37: error: expected ';' before '}' token
    6 | #define chmax(x, y) { x = max(x, y) }
      |                                     ^
a.cc:25:17: note: in expansion of macro 'chmax'
   25 |                 chmax(dp[i + 1][j][0], dp[i][j][k]);
      |                 ^~~~~
a.cc:6:37: error: expected ';' before '}' token
    6 | #define chmax(x, y) { x = max(x, y) }
      |                                     ^
a.cc:26:17: note: in expansion of macro 'chmax'
   26 |                 chmax(dp[i][j + 1][k], dp[i][j][k]);
      |                 ^~~~~
a.cc:6:37: error: expected ';' before '}' token
    6 | #define chmax(x, y) { x = max(x, y) }
      |                                     ^
a.cc:32:9: note: in expansion of macro 'chmax'
   32 |         chmax(ans, dp[R - 1][C - 1][k]);
      |         ^~~~~
Language: C++

#include <bits/stdc++.h>
#define roop(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)

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

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    roop(i, K){
        int r, c, v;
        cin >> r >> c >> v;
        a[r - 1][c - 1] = v;
    }
    roop(i, R){
        roop(j, C){
            for(int k = 2; k >= 0; k--){
                chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
            }
            roop(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;
    roop(k, 4){
        chmax(ans, dp[R - 1][C - 1][k]);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:9:1: error: expected initializer before 'll'
    9 | ll dp[3005][3005][4];
      | ^~
a.cc: In function 'int main()':
a.cc:17:9: error: 'a' was not declared in this scope
   17 |         a[r - 1][c - 1] = v;
      |         ^
a.cc:22:23: error: 'dp' was not declared in this scope; did you mean 'dup'?
   22 |                 chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
      |                       ^~
a.cc:6:21: note: in definition of macro 'chmax'
    6 | #define chmax(x, y) x = max(x, y)
      |                     ^
a.cc:22:54: error: 'a' was not declared in this scope
   22 |                 chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
      |                                                      ^
a.cc:6:32: note: in definition of macro 'chmax'
    6 | #define chmax(x, y) x = max(x, y)
      |                                ^
a.cc:25:23: error: 'dp' was not declared in this scope; did you mean 'dup'?
   25 |                 chmax(dp[i + 1][j][0], dp[i][j][k]);
      |                       ^~
a.cc:6:21: note: in definition of macro 'chmax'
    6 | #define chmax(x, y) x = max(x, y)
      |                     ^
a.cc:32:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   32 |         chmax(ans, dp[R - 1][C - 1][k]);
      |                    ^~
a.cc:6:32: note: in definition of macro 'chmax'
    6 | #define chmax(x, y) x = max(x, y)
      |                                ^
Language: C++

#include <bits/stdc++.h>
#define roop(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define chmax(x, y) x = max(x, y)

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

int main() {
    int R, C, K;
    cin >> R >> C >> K;
    roop(i, K){
        int r, c, v;
        cin >> r >> c >> v;
        a[r - 1][c - 1] = v;
    }
    roop(i, R){
        roop(j, C){
            for(int k = 2, k >= 0; k--){
                chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
            }
            roop(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;
    roop(k, 4){
        chmax(ans, dp[R - 1][C - 1][k]);
    }
    cout << ans << endl;
    return 0;
}

Compiler output:
a.cc:9:1: error: expected initializer before 'll'
    9 | ll dp[3005][3005][4];
      | ^~
a.cc: In function 'int main()':
a.cc:17:9: error: 'a' was not declared in this scope
   17 |         a[r - 1][c - 1] = v;
      |         ^
a.cc:21:29: error: expected ';' before '>=' token
   21 |             for(int k = 2, k >= 0; k--){
      |                             ^~~
      |                             ;
a.cc:21:30: error: expected primary-expression before '>=' token
   21 |             for(int k = 2, k >= 0; k--){
      |                              ^~
a.cc:22:23: error: 'dp' was not declared in this scope; did you mean 'dup'?
   22 |                 chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
      |                       ^~
a.cc:6:21: note: in definition of macro 'chmax'
    6 | #define chmax(x, y) x = max(x, y)
      |                     ^
a.cc:22:54: error: 'a' was not declared in this scope
   22 |                 chmax(dp[i][j][k + 1], dp[i][j][k] + a[i][j]);
      |                                                      ^
a.cc:6:32: note: in definition of macro 'chmax'
    6 | #define chmax(x, y) x = max(x, y)
      |                                ^
a.cc:25:23: error: 'dp' was not declared in this scope; did you mean 'dup'?
   25 |                 chmax(dp[i + 1][j][0], dp[i][j][k]);
      |                       ^~
a.cc:6:21: note: in definition of macro 'chmax'
    6 | #define chmax(x, y) x = max(x, y)
      |                     ^
a.cc:32:20: error: 'dp' was not declared in this scope; did you mean 'dup'?
   32 |         chmax(ans, dp[R - 1][C - 1][k]);
      |                    ^~
a.cc:6:32: note: in definition of macro 'chmax'
    6 | #define chmax(x, y) x = max(x, y)
      |                                ^
Language: C++

#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
#define i_7 (long long)(1e9+7)
//#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int R, C, k;
  cin>>R>>C>>k;
  int r[k], c[k];
  long long v[k];
  REP(i, k){
    cin>>r[i]>>c[i]>>v[k];
    r[i]--; c[i]--;
  }
  long long dp[R][C][4];
  REP(i, R) REP(j, C) REP(l, 4) dp[i][j][l] = 0;
  long long exist[R][C];
  REP(i, R) REP(j, C) exist[i][j] = 0;
  REP(i, k) exist[r[i]][c[i]] = v[i];
  REP(i, R){
    REP(j, C){
      for(int l = 3; l >= 1; l--) if(exist[i][j] > 0) dp[i][j][l] = max(dp[i][j][l], exist[i][j] + dp[i][j][l - 1]);
      if(i + 1 < R) dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][l]);
      if(j + 1 < C) dp[i][j + 1][l] = max(dp[i][j + 1][l], dp[i][j][l]);  
    }
  }
  long long ans = 0;
  REP(l, 4) ans = max(ans, dp[R - 1][C - 1][l]);
  cout << ans << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:87:69: error: 'l' was not declared in this scope
   87 |       if(i + 1 < R) dp[i + 1][j][0] = max(dp[i + 1][j][0], dp[i][j][l]);
      |                                                                     ^
a.cc:88:34: error: 'l' was not declared in this scope
   88 |       if(j + 1 < C) dp[i][j + 1][l] = max(dp[i][j + 1][l], dp[i][j][l]);
      |                                  ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define MOD 1000000007
#define endl "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define all(c) (c).begin(),(c).end()
#define ss second
#define MAXX 9000000000000000000
#define pii pair<int,int>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vpi vector<pair<int,int> > 
#define vvpi vector<vector<pair<int,int> > >
#define Inp(a,n) for(int i=0;i<n;i++)cin>>a[i]
#define Out(a,n,ch) for(int i=0;i<n;i++)cout<<a[i]<<ch;cout<<endl;

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	
	int t=1;
	//cin>>t;

	while(t--)
	{
		int k,R,C,ans=-1;
		cin>>R>>C>>K;
		int a[R+1][C+1]={0},dp[R+1][C+1][4];
		for(int i=0;i<=R;i++)
		{
			for(int j=0;j<=C;j++)
			{
				for(int k=0;k<4;k++)
					dp[i][j][k] = 0;
			}
		}
		for(int i=0;i<K;i++)
		{
			int r,c,v;
			cin>>r>>c>>v;
			a[r][c] = v;
		}
		for(int i=1;i<=R;i++)
		{
			for(int j=1;j<=C;j++)
			{
				//from top
				int mtop=-1;
				for(int k=0;k<4;k++)
					mtop = max(mtop,dp[i-1][j][k]);
				dp[i][j][3] = max(dp[i][j][3],mtop); //max from this ;
				dp[i][j][2] = max(dp[i][j][2],mtop) +a[i][j];

				//from left
				dp[i][j][3] = max(dp[i][j][3],dp[i][j-1][3]);
				dp[i][j][2] = max(dp[i][j][2],dp[i][j-1][3]+a[i][j]);
				dp[i][j][2] = max(dp[i][j][2],dp[i][j-1][2]);
				dp[i][j][1] = max(dp[i][j][1],dp[i][j-1][2]+a[i][j]);
				dp[i][j][1] = max(dp[i][j][1],dp[i][j-1][1]);
				dp[i][j][0] = max(dp[i][j][0],dp[i][j-1][1]+a[i][j]);
				dp[i][j][0] = max(dp[i][j][0],dp[i][j-1][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 'int32_t main()':
a.cc:35:28: error: 'K' was not declared in this scope
   35 |                 cin>>R>>C>>K;
      |                            ^