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

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

int vacation(vector<vector<int>> v){
  int n=v.size();
  for(int i=1; i<n; i++){
    v[i][0] += max(v[i-1][1], v[i-1][2]);
    v[i][1] += max(v[i-1][0], v[i-1][2]);
    v[i][2] += max(v[i-1][0], v[i-1][1]);
  }
  return max({v[n-1][0], v[n-1][1], v[i-1][2]});
}

int main(){
  int n;
  cin>>n;
  vector<vector<int>> v(n,vector<int>(3);
  for(int i=0; i<n; i++) cin>>v[i][0]>>v[i][1]>>v[i][2];
  cout<<vacation(v);
  return 0;
}

Compiler output:
a.cc: In function 'int vacation(std::vector<std::vector<int> >)':
a.cc:11:39: error: 'i' was not declared in this scope
   11 |   return max({v[n-1][0], v[n-1][1], v[i-1][2]});
      |                                       ^
a.cc:11:13: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   11 |   return max({v[n-1][0], v[n-1][1], v[i-1][2]});
      |          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
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:   template argument deduction/substitution failed:
/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:   candidate expects 2 arguments, 1 provided
a.cc: In function 'int main()':
a.cc:17:41: error: expected ')' before ';' token
   17 |   vector<vector<int>> v(n,vector<int>(3);
      |                        ~                ^
      |                                         )
Language: C++

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

int maxi(int a, int b, int c){
  return max(max(a, b), c);
}

int maxsec(int a, int b, int c){
  if((a >= b && a <= c) || (a >= c && a <= b)) return a;
  if((b >= a && b <= c) || (b >= c && b <= a)) return b;
  return c;
}

int solve(int n, int arr[][]){
  int dp[n];
  if(n == 1) return maxi(arr[0][0], arr[0][1], arr[0][2]);
  dp[0] = maxi(arr[0][0], arr[0][1], arr[0][2]);
  if(n == 2) return maxi(arr[1][0], arr[1][1], arr[1][2])+dp[0];
  dp[1] = maxi(arr[1][0], arr[1][1], arr[1][2])+dp[0];
  for(int i = 2; i < n; i++){
    dp[i] = max(dp[i-1] + maxsec(arr[i][0], arr[i][1], arr[i][2]), maxi(arr[i][0], arr[i][1], arr[i][2])+maxsec(arr[i][0], arr[i][1], arr[i][2])+dp[i-2]);
  }
  return dp[n-1];
}

int main(){
  int n;
  cin >> n;
  int arr[n][3];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 3; j++){
      cin >> arr[i][j];
    }
  }
  solve
}

Compiler output:
a.cc:14:22: error: declaration of 'arr' as multidimensional array must have bounds for all dimensions except the first
   14 | int solve(int n, int arr[][]){
      |                      ^~~
a.cc: In function 'int solve(...)':
a.cc:15:10: error: 'n' was not declared in this scope; did you mean 'yn'?
   15 |   int dp[n];
      |          ^
      |          yn
a.cc:16:26: error: 'arr' was not declared in this scope
   16 |   if(n == 1) return maxi(arr[0][0], arr[0][1], arr[0][2]);
      |                          ^~~
a.cc:17:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   17 |   dp[0] = maxi(arr[0][0], arr[0][1], arr[0][2]);
      |   ^~
      |   dup
a.cc:17:16: error: 'arr' was not declared in this scope
   17 |   dp[0] = maxi(arr[0][0], arr[0][1], arr[0][2]);
      |                ^~~
a.cc: In function 'int main()':
a.cc:35:8: error: expected ';' before '}' token
   35 |   solve
      |        ^
      |        ;
   36 | }
      | ~
Language: C

#include <bits/stdc++.h>
//#define int long long

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int N;
    cin >> N;
    int t = N;
    vector<int> A;
    vector<int> B;
    vector<int> C;
    while (t--)
    {
        int a, b, c;
        cin >> a >> b >> c;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
    }

    // cout << "hello";
    vector<vector<int>> dp(N, vector<int>(3, 0));
    dp[0][0] = A[0];
    dp[1][0] = B[0];
    dp[2][0] = C[0];
    for (int i = 1; i < N; i++)
    {
        dp[0][i] = A[i] + max(dp[1][i - 1], dp[2][i - 1]);
        dp[1][i] = B[i] + max(dp[0][i - 1], dp[2][i - 1]);
        dp[2][i] = C[i] + max(dp[1][i - 1], dp[0][i - 1]);
    }
    int maxVal = max({dp[0][N - 1], dp[1][N - 1], dp[2][N - 1]});
    cout << maxVal;
    return 0;
}

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

#include<bits/stdc++.h>
int dp[100010],a[100010][3],n;
using namespace std;
int solve(int i,int s)
{
  if(i==-1)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  int m=0;
  for(int j=0;j<3;j++)
  { if(j==s)
      continue;
    m=max(m,a[i][j]+solve(i-1,j));}
  return dp[i]=m;
}
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  cout<<max(a[n-1][0]+solve(n-2,0),max(a[n-1][1]+solve(n-2,2),a[n-1][2]+solve(n-2,2)))<<"\n";
  return 0;
}
#include<btis/stdc++.h>
int dp[100010],a[100010][3],n;
using namespace std;
int solve(int i,int s)
{
  if(i==-1)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  int m=0;
  for(int j=0;j<3;j++)
  { if(j==s)
      continue;
    m=max(m,a[i][j]+solve(i-1,j));}
  return dp[i]=m;
}
int main()
{
  cin>>n;
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  cout<<max(a[n-1][0]+solve(n-2,0),max(a[n-1][1]+solve(n-2,2),a[n-1][2]+solve(n-2,2)))<<"\n";
  return 0;
}
Submission Info

Compiler output:
a.cc:25:9: fatal error: btis/stdc++.h: No such file or directory
   25 | #include<btis/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
//#define int long long

using namespace std;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    int N;
    cin >> N;
    int t = N;
    vector<int> A;
    vector<int> B;
    vector<int> C;
    while (t--)
    {
        int a, b, c;
        cin >> a >> b >> c;
        A.push_back(a);
        B.push_back(b);
        C.push_back(c);
    }

    // cout << "hello";
    vector<vector<int>> dp(N, vector<int>(3, 0));
    dp[0][0] = A[0];
    dp[1][0] = B[0];
    dp[2][0] = C[0];
    for (int i = 1; i < N; i++)
    {
        dp[0][i] = A[i] + max(dp[1][i - 1], dp[2][i - 1]);
        dp[1][i] = B[i] + max(dp[0][i - 1], dp[2][i - 1]);
        dp[2][i] = C[i] + max(dp[1][i - 1], dp[0][i - 1]);
    }
    int maxVal = max(dp[0][N - 1], dp[1][N - 1], dp[2][N - 1]);
    cout << maxVal;
    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 = int; _Compare = int]':
a.cc:38:21:   required from here
   38 |     int maxVal = max(dp[0][N - 1], dp[1][N - 1], dp[2][N - 1]);
      |                  ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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<btis/stdc++.h>
int dp[100010],a[100010][3],n;
using namespace std;
int solve(int i,int s)
{
  if(i==-1)
    return 0;
  if(dp[i]!=-1)
    return dp[i];
  int m=0;
  for(int j=0;j<3;j++)
  { if(j==s)
      continue;
    m=max(m,a[i][j]+solve(i-1,j));}
  return dp[i]=m;
}
int main()
{
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
  cout<<max(a[n-1][0]+solve(n-2,0),max(a[n-1][1]+solve(n-2,2),a[n-1][2]+solve(n-2,2)))<<"\n";
  return 0;
}

Compiler output:
a.cc:1:9: fatal error: btis/stdc++.h: No such file or directory
    1 | #include<btis/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define int long long int
#define double long double
#define mod 1000000007
#define PI 3.141592
#define w(t) int t; cin>>t; while(t--)
#define f(i,a,n) for( int i=a;i<n;i++)
#define pb push_back
#define pob pop_back
#define mk make_pair
#define ARMY ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
{int32_t main()
  {

  int n;
  cin>>n;
  int a[n],b[n],c[n];
  f(i,0,n)
  cin>>a[i]>>b[i]>>c[i];
  int dp[n][3];
  dp[0][0]=a[0];
  dp[0][1]=b[0];
  dp[0][2]=c[0];
  f(i,1,n)
   {
     dp[i][0]=a[i]+max(dp[i-1][1],dp[i-1][2]);
     dp[i][1]=b[i]+max(dp[i-1][2],dp[i-1][0]);
     dp[i][2]=c[i]+max(dp[i-1][0],dp[i-1][1]);
   }

  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}

Compiler output:
a.cc:13:1: error: expected unqualified-id before '{' token
   13 | {int32_t main()
      | ^
Language: C++

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

int main(){
    int n;
    cin>>n;
    int arr[n][3];
    int x=n;
    while(n--)
        cin>>arr[n-x-1][0]>>arr[n-x-1][1]>>arr[n-x-1][2];
    int dp[n][3];
    dp[0][0]= arr[0][0];
    dp[0][1]= arr[0][1];
    dp[0][2]= arr[0][2];
    for(int i=1; i<n; i++){
        int a, b, c;
        a= arr[i][0]+ max(dp[i-1][1], dp[i-1][2]);
        b= arr[i][1]+ max(dp[i-1][0], dp[i-1][2]);
        c= arr[i][2]+ max(dp[i-1][0], dp[i-1][1]);
        dp[i][0]= a;
        dp[i][1]= b;
        dp[i][2]= c;
    }
    cout<<max(dp[n-1][0], dp[n-1][1], dp[n-1][2]);
}

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 = int; _Compare = int]':
a.cc:24:14:   required from here
   24 |     cout<<max(dp[n-1][0], dp[n-1][1], dp[n-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;
int main()
{
  int n,i,j,k;
  cin>>n;
  int arr[n][3];
  for(i=0;i<n;i++)
  {
    for(j=0;j<3;j++)
      cin>>arr[i][j];
  }
  for(i=1;i<n;i++)
  {
    for(j=0;j<3;j++)
    {
      int x=INT_MIN;
      for(k=0;k<3;k++)
      {
        if(k!=j)
        {
          x=max(x,dp[i-1][k]+dp[i][j]);
        }
      }
      dp[i][j]=x;
    }
  }
  int mx=INT_MIN;
  for(i=0;i<3;i++)
  {
    mx=max(mx,dp[n-1][i]);
  } 
  cout<<mx<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:19: error: 'dp' was not declared in this scope; did you mean 'dup'?
   22 |           x=max(x,dp[i-1][k]+dp[i][j]);
      |                   ^~
      |                   dup
a.cc:25:7: error: 'dp' was not declared in this scope; did you mean 'dup'?
   25 |       dp[i][j]=x;
      |       ^~
      |       dup
a.cc:31:15: error: 'dp' was not declared in this scope; did you mean 'dup'?
   31 |     mx=max(mx,dp[n-1][i]);
      |               ^~
      |               dup
Language: C++

#include<iostream>
#include<vector>
using namespace std;
 
struct activity{
  int A,B,C;
};
int vacations(vector<activity> ar ,int n)
{
  int dp[n+1][3];
  dp[1][0] = ar.A[1];
   dp[1][1] = ar.B[1];
   dp[1][2] = ar.C[1];
  for(int =2;i<=n;i++)
  {
    dp[i][0] = ar[i].A +max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = ar[i].B +max(dp[i-1][0],dp[i-1][2]);
    dp[i][2] = ar[i].C +max(dp[i-1][0],dp[i-1][1]);
  }
  return max(dp[n][0],max(dp[n][1]),dp[n][2]);
}
int main(){
	int n ;
	cout<<"enter the input :";
	cin>>n;
	vector<activity> ar(n+1);
	for(int i=0;i<=n;i++){
		cout<<ar[i].A;
		cout<<ar[i].B;
		cout<<ar[i].C;
		
	}
	cout<<vacations(ar,n);
}

Compiler output:
a.cc: In function 'int vacations(std::vector<activity>, int)':
a.cc:11:17: error: 'class std::vector<activity>' has no member named 'A'
   11 |   dp[1][0] = ar.A[1];
      |                 ^
a.cc:12:18: error: 'class std::vector<activity>' has no member named 'B'
   12 |    dp[1][1] = ar.B[1];
      |                  ^
a.cc:13:18: error: 'class std::vector<activity>' has no member named 'C'
   13 |    dp[1][2] = ar.C[1];
      |                  ^
a.cc:14:11: error: expected unqualified-id before '=' token
   14 |   for(int =2;i<=n;i++)
      |           ^
a.cc:14:10: error: expected ';' before '=' token
   14 |   for(int =2;i<=n;i++)
      |          ^~
      |          ;
a.cc:14:11: error: expected primary-expression before '=' token
   14 |   for(int =2;i<=n;i++)
      |           ^
a.cc:14:14: error: 'i' was not declared in this scope
   14 |   for(int =2;i<=n;i++)
      |              ^
a.cc:14:18: error: expected ')' before ';' token
   14 |   for(int =2;i<=n;i++)
      |      ~           ^
      |                  )
a.cc:14:19: error: 'i' was not declared in this scope
   14 |   for(int =2;i<=n;i++)
      |                   ^
a.cc:20:26: error: no matching function for call to 'max(int&)'
   20 |   return max(dp[n][0],max(dp[n][1]),dp[n][2]);
      |                       ~~~^~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   candidate expects 2 arguments, 1 provided
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 1 provided
Language: Java

import java.util.*;
public class Main {
public static void main(String args[]){
 int t=0;
Scanner obj=new Scanner(System.in);
t=obj.nextInt();
if(t<1)
return 0;
int arr[][]=new int[t][3];
for(int i=0;i<t;i++){
for(int j=0;j<3;j++){
      arr[i][j]=obj.nextInt();
}
}
int dp[][]=new int[t][3];
dp[0][0]=Math.max(arr[0][1],arr[0][2]);
dp[0][1]=Math.max(arr[0][0],arr[0][2]);
dp[0][2]=Math.max(arr[0][1],arr[0][0]);
for(int i=1;i<t;i++){
           dp[i][0]=Math.max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
            dp[i][1]=Math.max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
              dp[i][2]=Math.max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]);
}
System.out.println(math.max(dp[t-1][0],Math.max(dp[t-1][1],dp[t-1][2])));
}

}


Compiler output:
Main.java:8: error: incompatible types: unexpected return value
return 0;
       ^
Main.java:24: error: cannot find symbol
System.out.println(math.max(dp[t-1][0],Math.max(dp[t-1][1],dp[t-1][2])));
                   ^
  symbol:   variable math
  location: class Main
2 errors
Language: Java

public class Main {
public static void main(String args[]){
 int t=0;
Scanner obj=new Scanner(System.in);
t=obj.nextInt();
if(t<1)
return 0;
int arr[][]=new int[t][3];
for(int i=0;i<t;i++){
for(int j=0;j<3;j++){
      arr[i][j]=obj.nextInt();
}
}
int dp[][]=new int[t][3];
dp[0][0]=Math.max(arr[0][1],arr[0][2]);
dp[0][1]=Math.max(arr[0][0],arr[0][2]);
dp[0][2]=Math.max(arr[0][1],arr[0][0]);
for(int i=1;i<t;i++){
           dp[i][0]=Math.max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
            dp[i][1]=Math.max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
              dp[i][2]=Math.max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]);
}
System.out.println(math.max(dp[t-1][0],Math.max(dp[t-1][1],dp[t-1][2])));
}

}


Compiler output:
Main.java:4: error: cannot find symbol
Scanner obj=new Scanner(System.in);
^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
Scanner obj=new Scanner(System.in);
                ^
  symbol:   class Scanner
  location: class Main
Main.java:7: error: incompatible types: unexpected return value
return 0;
       ^
Main.java:23: error: cannot find symbol
System.out.println(math.max(dp[t-1][0],Math.max(dp[t-1][1],dp[t-1][2])));
                   ^
  symbol:   variable math
  location: class Main
4 errors
Language: Java

public class Main {
public static void main(String args[]){
 int t=0;
Scanner obj=new Scanner(System.in);
t=obj.nextInt();
if(t<1)
return 0;
int arr[][]=new int[t][3];
for(int i=0;i<t;i++){
for(int j=0;j<3;j++){
      arr[i][j]=obj.nextInt();
}
}
int dp[][]=new int[t][3];
dp[0][0]=Math.max(arr[0][1],arr[0][2]);
dp[0][1]=Math.max(arr[0][0],arr[0][2]);
dp[0][2]=Math.max(arr[0][1],arr[0][0]);
for(int i=1;i<t;i++){
           d[[i][0]=Math.max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
            d[[i][1]=Math.max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
              d[[i][2]=Math.max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]);
}
System.out.println(math.max(dp[t-1][0],Math.max(dp[t-1][1],dp[t-1][2])));
}

}

Compiler output:
Main.java:19: error: illegal start of expression
           d[[i][0]=Math.max(dp[i-1][1]+arr[i][0],dp[i-1][2]+arr[i][0]);
             ^
Main.java:20: error: illegal start of expression
            d[[i][1]=Math.max(dp[i-1][0]+arr[i][1],dp[i-1][2]+arr[i][1]);
              ^
Main.java:21: error: illegal start of expression
              d[[i][2]=Math.max(dp[i-1][1]+arr[i][2],dp[i-1][0]+arr[i][2]);
                ^
3 errors
Language: C++

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

vector<vector<int>> dp(100005, vector<int>(4,-1));

int rec(int day, int type, vector<vector<int>>& a)
{
    int n = a.size();
    if(day == n) return 0;

    if(dp[day][type] != -1) return dp[day][type];

    int points = 0;

    if(type == 3)
    {
        points = max( points, rec(day+1, 0, a) + a[day][0]);
        points = max( points, rec(day+1, 1, a) + a[day][1]);
        points = max( points, rec(day+1, 2, a) + a[day][2]);
    }

    if(type == 0)
    {
        points = max( rec(day+1, 1, a) + a[day][1], rec(day+1, 2, a) + a[day][2] );
    }
    else if(type == 1)
    {
        points = max( rec(day+1, 0, a) + a[day][0], rec(day+1, 2, a) + a[day][2] );
    }
    else if(type == 2)
    {
        points = max( rec(day+1, 1, a) + a[day][1], rec(day+1, 0, a) + a[day][0] );
    }

    return dp[day][type] = points;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

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

vector<vector<int>> dp(100005, vector<int>(4,-1));

int rec(int day, int type, vector<vector<int>>& a)
{
    int n = a.size();
    if(day == n) return 0;

    if(dp[day][type] != -1) return dp[day][type];

    int points = 0;

    if(type == 3)
    {
        points = max( points, rec(day+1, 0, a) + a[day][0]);
        points = max( points, rec(day+1, 1, a) + a[day][1]);
        points = max( points, rec(day+1, 2, a) + a[day][2]);
    }

    if(type == 0)
    {
        points = max( rec(day+1, 1, a) + a[day][1], rec(day+1, 2, a) + a[day][2] );
    }
    else if(type == 1)
    {
        points = max( rec(day+1, 0, a) + a[day][0], rec(day+1, 2, a) + a[day][2] );
    }
    else if(type == 2)
    {
        points = max( rec(day+1, 1, a) + a[day][1], rec(day+1, 0, a) + a[day][0] );
    }

    return dp[day][type] = points;
}

Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<algorithm>
#include<climits>
using namespace std;
#define ll long long


ll dp[100001][4];

int solve(ll a[][4],ll i,ll prev,ll n)
{
	if(i==n)
	{
		return(0);
	}
	if(dp[i][prev]!=-1)
	{
		return(dp[i][prev]);
	}
    ll ans=INT_MIN,j;
	for(j=1;j<=3;j++)
	{
		if(prev!=j)
		{
			ans=max(ans,solve(a,i+1,j,n)+a[i][j]);
		}
	}
	return(dp[i][prev]=ans);
}

int main()
{
	ll n,i;
	cin>>n;
	ll a[n][4];
	memset(dp,-1,sizeof(dp));
	for(i=0;i<n;i++)
	{
		cin>>a[i][1]>>a[i][2]>>a[i][3];
	}
	cout<<solve(a,0,0,n);
}

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


#include <bits/stdc++.h> 
using namespace std; 
int i,j,n,m,dp,mini;

int max(int a,int b)
{
    if(a>b)
    return a;
    return b;
}

int main()
{
    int N;
    cin >> N;
    int A[N][3];
    int i=0;
    int j=0;
    int k=0;
    for(i=0;i<N;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>A[i][j];
        }

    }
    int happy [N][3];
    happy[0][0]=A[0][0];
    happy[0][1]=A[0][1];
    happy[0][2]=A[0][2];

    for(k=1;k<N;k++)
    {
        happy[k][0]=max(happy[k-1][1]+A[k][0],happy[k-1][2]+A[k][0]);
        happy[k][1]=max(happy[k-1][0]+A[k][1],happy[k-1][2]+A[k][1]);
        happy[k][2]=max(happy[k-1][1]+A[k][2],happy[k-1][0]+A[k][2]);
    }

    cout << max(happy[N-1][0],max(happy[N-1][1],happy[N-1][2]));
    return 0;

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


#include <bits/stdc++.h> 
using namespace std; 
int i,j,n,m,dp,mini;

int max(int a,int b)
{
    if(a>b)
    return a;
    return b;
}

int mod (int a)
{
    if(a<0)
    return a*(-1);
    return a;
}

int main()
{
    int N;
    cin >> N;
    int A[N][3];
    int i=0;
    int j=0;
    int k=0;
    for(i=0;i<N;i++)
    {
        for(j=0;j<3;j++)
        {
            cin>>A[i][j];
        }

    }
    int happy [N][3];
    happy[0][0]=A[0][0];
    happy[0][1]=A[0][1];
    happy[0][2]=A[0][2];

    for(k=1;k<N;k++)
    {
        happy[k][0]=max(happy[k-1][1]+A[k][0],happy[k-1][2]+A[k][0]);
        happy[k][1]=max(happy[k-1][0]+A[k][1],happy[k-1][2]+A[k][1]);
        happy[k][2]=max(happy[k-1][1]+A[k][2],happy[k-1][0]+A[k][2]);
    }

    cout << max(happy[N-1][0],max(happy[N-1][1],happy[N-1][2]);
    return 0;

   
}

Compiler output:
a.cc: In function 'int main()':
a.cc:48:63: error: expected ')' before ';' token
   48 |     cout << max(happy[N-1][0],max(happy[N-1][1],happy[N-1][2]);
      |                ~                                              ^
      |                                                               )
Language: C++

#include<bits/stdc++.h>
#define ll long long int 
using namespace std; 
ll dp[100005][4];
ll solve(vector<vector<ll>>&v,ll n,ll tag)
{
    if(n<=0)
      return 0;

      if(dp[n][tag]!=-1)
        return dp[n][tag];
    ll ans=0;
    for(int i=1;i<=3;i++)
    {
      if(i!=tag)
      {
        ans=max(ans,v[n][i]+solve(v,n-1,i));
      }
    }
    return dp[n][tag]=ans;
}
int main() 
{
  int t=1;
  //cin>>t;
  while (t--)
  {
    memset(dp,-1,sizeof(dp));
      ll n;
    cin>>n;
    vector<vector<int>>v(n+1);
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=3;j++)
      {
        ll x;
        cin>>x;
        v[i].push_back(x);
      }
    }
    cout<<solve(v,n,0)<<endl;
  }
  

  
} 


Compiler output:
a.cc: In function 'int main()':
a.cc:41:17: error: invalid initialization of reference of type 'std::vector<std::vector<long long int> >&' from expression of type 'std::vector<std::vector<int> >'
   41 |     cout<<solve(v,n,0)<<endl;
      |                 ^
a.cc:5:29: note: in passing argument 1 of 'long long int solve(std::vector<std::vector<long long int> >&, long long int, long long int)'
    5 | ll solve(vector<vector<ll>>&v,ll n,ll tag)
      |          ~~~~~~~~~~~~~~~~~~~^
Language: C++

#include <iostream>
#include <algorithm>

using namespace std;


int n;
int a[100005][4];
int dp[10005][4];

int go(int i, int prev) {
    if(i == n){
        return 0;
    }
    if(dp[i][prev] != -1){
        return dp[i][prev];
    }
    int ans = 0;

    if(prev == 0){
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][2] + go(i+1,2));
        ans = max(ans, a[i][3] + go(i+1,3));
    }else if(prev == 1){
        ans = max(ans, a[i][2] + go(i+1,2));
        ans = max(ans, a[i][3] + go(i+1,3));
    }else if (prev== 2){
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][3] + go(i+1,3));
    }else if(prev == 3){
        ans = max(ans, a[i][1] + go(i+1,1));
        ans = max(ans, a[i][2] + go(i+1,2));
    }
    dp[i][prev] = ans;
    return dp[i][prev];
}

int main(){
    cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 3; j++) {
			cin >> a[i][j];
		}
	}
    memset(dp, -1, sizeof(dp));

    int ans = go(0, 0);
    cout << ans << endl; 
}


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

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Codechef
{
	public static void main (String[] args) throws java.lang.Exception
	{
	 Scanner sc=new Scanner(System.in);
	 int N=sc.nextInt();
	 int [][] mat=new int[N][3];
	 for(int i=0;i<N;i++)
	 {
	     for(int j=0;j<3;j++)
	     {
	         mat[i][j]=sc.nextInt();
	         // System.out.print(mat[i][j]+" ");
	     }
	    // System.out.println();
	 }
	 int [][] dp=new int[N][3];
	 dp[0][0]=mat[0][0];
	 dp[0][1]=mat[0][1];
	 dp[0][2]=mat[0][2];
	 
	 for(int i=1;i<N;i++)
	 {
	     for(int j=0;j<3;j++)
	     {
	         if(j==0)
	         {
	             dp[i][j]=mat[i][j]+Math.max(dp[i-1][j+1],dp[i-1][j+2]);
	         }
	         if(j==1)
	         {
	             dp[i][j]=mat[i][j]+Math.max(dp[i-1][j-1],dp[i-1][j+1]);
	         }
	         if(j==2)
	         {
	             dp[i][j]=mat[i][j]+Math.max(dp[i-1][j-2],dp[i-1][j-1]);
	         }
	     }
	 }
	 int max=0;
	 for(int j=0;j<3;j++)
	 {
	     if(dp[N-1][j]>max)
	     {  max=dp[N-1][j];}
	 }
	
	 System.out.println(max);
	}
}


Compiler output:
Main.java:6: error: class Codechef is public, should be declared in a file named Codechef.java
public class Codechef
       ^
1 error
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dp[100005][4];
int a[100005][4];
int n;
int func(int day,int flag)
{
    if(day==n)
    return 0;
    if(dp[day][flag]!-1)
    return dp[day][flag];
    int maxi=0;
    if(flag==0)
    {
        maxi=max(maxi,a[day][1]+func(day+1,1));
        maxi=max(maxi,a[day][2]+func(day+1,2));
        maxi=max(maxi,a[day][3]+func(day+1,3));
    }
    else if(flag==1)
    {
        maxi=max(maxi,a[day][2]+func(day+1,2));
        maxi=max(maxi,a[day][3]+func(day+1,3));
    }
    else if(flag==2)
    {
        maxi=max(maxi,a[day][1]+func(day+1,1));
        maxi=max(maxi,a[day][3]+func(day+1,3));
    }
    else
    {
        maxi=max(maxi,a[day][1]+func(day+1,1));
        maxi=max(maxi,a[day][2]+func(day+1,2));
    }
    return dp[day][flag]=maxi;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=3;j++)
        cin>>a[i][j];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=1;j<=3;j++)
        dp[i][j]=-1;
    }
    cout<<func(0,0);
}


Compiler output:
a.cc: In function 'int func(int, int)':
a.cc:10:21: error: expected ')' before '!' token
   10 |     if(dp[day][flag]!-1)
      |       ~             ^
      |                     )
Language: C++

#include <bits/stdc++.h>
#define ll long long int
#define rep(i,a) for(ll i=0;i<n;i++)
#define foi(i,a,b) for(ll i=a;i<b;i++)
#define el '\n'
using namespace std;
void solve(){
  ll n;
  cin>>n;
  vl a(n),b(n),c(n);
  rep(i,n)cin>>a[i]>>b[i]>>c[i];
  dp[n][3];
  dp[0][0] = a[0];dp[0][1] = b[0];dp[0][2] = c[0];
  foi(i,1,n){
    dp[i][0] = max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
    dp[i][1] = max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
    dp[i][2] = max(dp[i-1][1]+c[i],dp[i-1][0]+c[i]);
}
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<el;
int main(){
  solve();
  return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:10:3: error: 'vl' was not declared in this scope; did you mean 'el'?
   10 |   vl a(n),b(n),c(n);
      |   ^~
      |   el
a.cc:11:16: error: 'a' was not declared in this scope
   11 |   rep(i,n)cin>>a[i]>>b[i]>>c[i];
      |                ^
a.cc:11:22: error: 'b' was not declared in this scope
   11 |   rep(i,n)cin>>a[i]>>b[i]>>c[i];
      |                      ^
a.cc:11:28: error: 'c' was not declared in this scope
   11 |   rep(i,n)cin>>a[i]>>b[i]>>c[i];
      |                            ^
a.cc:12:3: error: 'dp' was not declared in this scope; did you mean 'dup'?
   12 |   dp[n][3];
      |   ^~
      |   dup
a.cc:13:14: error: 'a' was not declared in this scope
   13 |   dp[0][0] = a[0];dp[0][1] = b[0];dp[0][2] = c[0];
      |              ^
a.cc:13:30: error: 'b' was not declared in this scope
   13 |   dp[0][0] = a[0];dp[0][1] = b[0];dp[0][2] = c[0];
      |                              ^
a.cc:13:46: error: 'c' was not declared in this scope
   13 |   dp[0][0] = a[0];dp[0][1] = b[0];dp[0][2] = c[0];
      |                                              ^
a.cc:20:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   20 | int main(){
      |         ^~
a.cc:20:9: note: remove parentheses to default-initialize a variable
   20 | int main(){
      |         ^~
      |         --
a.cc:20:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:20:11: error: a function-definition is not allowed here before '{' token
   20 | int main(){
      |           ^
a.cc:23:2: error: expected '}' at end of input
   23 | }
      |  ^
a.cc:7:13: note: to match this '{'
    7 | void solve(){
      |             ^
Language: C

#include <iostream>
#include <vector>
#include <cstring>
#include <cassert>

int N;
int a[100002], b[100002], c[100002];

// ボトムアップに解く
int solveBottomUp() {
  // DP
  int dp[100002][3]; // dp[i][j] := i日目にjを選んだ時の幸福度最大値
  memset(dp, 0, sizeof(dp)); // 0で初期化しておく
  
  // 1日目は先に埋めておく
  dp[1][0] = a[1];
  dp[1][1] = b[1];
  dp[1][2] = c[1];

  // DP更新
  for (int i = 2; i <= N; i++) {
    // i日目に0(A)を選んだ時の幸福度最大値
    //  = 前日にB,Cを選んだ時の最大値のmax + i日目にAを選ぶ最大値
    dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][2]) + a[i];

    // i日目に1(B)を選んだ時の幸福度最大値
    dp[i][1] = std::max(dp[i - 1][0], dp[i - 1][2]) + b[i];

    // i日目に2(C)を選んだ時の幸福度最大値
    dp[i][2] = std::max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }

  // N日目にA,B,Cを選んだ時の最大値の最大値を取る
  int result = std::max(dp[N][0], std::max(dp[N][1], dp[N][2]));

  return result;
}


// トップダウンに解く
int memo[100002][3]; // memo[i][j] := i日目にjを選んだ時の幸福度最大値
int solveRecursive(int n, int action) {
  int &cache = memo[n][action];
  if (cache != -1) return cache;
  if (n == 0) return 0;
  if (action == 0) {
    return cache = std::max(solveRecursive(n-1, 1), solveRecursive(n-1, 2)) + a[n];
  }
  if (action == 1) {
    return cache = std::max(solveRecursive(n-1, 0), solveRecursive(n-1, 2)) + b[n];
  }
  if (action == 2) {
    return cache = std::max(solveRecursive(n-1, 0), solveRecursive(n-1, 1)) + c[n];
  }
  assert(0);
  return -1;
}
int solveTopDown() {
  memset(memo, -1, sizeof(memo)); // -1で初期化しておく
  int result_a = solveRecursive(N, 0);
  int result_b = solveRecursive(N, 1);
  int result_c = solveRecursive(N, 2);
  return std::max(result_a, std::max(result_b, result_c));
}

int main(void) {
  std::cin >> N;
  // 入力の受け取り
  for (int i = 1; i <= N; i++) { // 1-indexedで入れる
    std::cin >> a[i] >> b[i] >> c[i];
  }
  
  std::cout << solveBottomUp() << std::endl;
  // std::cout << solveTopDown() << std::endl;

  return 0;
}

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

#include <iostream>
#include <vector>
#include <cstring>

int main(void) {
  int N;
  std::cin >> N;

  // 入力の受け取り
  std::vector<int> a(N), b(N), c(N);
  for (int i = 1; i <= N; i++) { // 1-indexで入れる
    std::cin >> a[i] >> b[i] >> c[i];
  }

  // DP
  int dp[100002][3]; // dp[i][j] := i日目にjを選んだ時の幸福度最大値
  memset(dp, 0, sizeof(dp)); // 0で初期化しておく
  
  // 1日目は先に埋めておく
  dp[1][0] = a[1];
  dp[1][1] = b[1];
  dp[1][2] = c[1];

  // DP更新
  for (int i = 2; i <= N; i++) {
    // i日目に0(A)を選んだ時の幸福度最大値
    //  = 前日にB, Cを選んだ時の最大値 + i日目にAを選ぶ最大値
    dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][2]) + a[i];

    // i日目に1(B)を選んだ時の幸福度最大値
    dp[i][1] = std::max(dp[i - 1][0], dp[i - 1][2]) + b[i];

    // i日目に2(C)を選んだ時の幸福度最大値
    dp[i][2] = std::max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }
  int result = std::max({dp[N][0], dp[N][1], dp[N][2]});
  std::cout << result << std::endl;

  return 0;
}

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

#include <iostream>
#include <vector>
#include <cstring>

int main(void) {
  int N;
  std::cin >> N;

  // 入力の受け取り
  std::vector<int> a(N), b(N), c(N);
  for (int i = 1; i <= N; i++) { // 1-indexで入れる
    std::cin >> a[i] >> b[i] >> c[i];
  }

  // DP
  int dp[100002][3]; // dp[i][j] := i日目にjを選んだ時の幸福度最大値
  memset(dp, 0, sizeof(dp)); // 0で初期化しておく
  
  // 1日目は先に埋めておく
  dp[1][0] = a[1];
  dp[1][1] = b[1];
  dp[1][2] = c[1];

  // DP更新
  for (int i = 2; i <= N; i++) {
    // i日目に0(A)を選んだ時の幸福度最大値
    //  = 前日にB, Cを選んだ時の最大値 + i日目にAを選ぶ最大値
    dp[i][0] = std::max(dp[i - 1][1], dp[i - 1][2]) + a[i];

    // i日目に1(B)を選んだ時の幸福度最大値
    dp[i][1] = std::max(dp[i - 1][0], dp[i - 1][2]) + b[i];

    // i日目に2(C)を選んだ時の幸福度最大値
    dp[i][2] = std::max(dp[i - 1][0], dp[i - 1][1]) + c[i];
  }
  std::cout << std::max({dp[N][0], dp[N][1], dp[N][2]}) << std::endl;

  return 0;
}

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

#include <iostream>
#include <fstream>
#include <algorithm>
#include <limits.h>
using namespace std;

int n, k, mt[100000][4], dp[100000][4];

int main() {
    cin >> n;

    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= 3; ++j)
            fin >> mt[i][j];

    dp[1][1] = mt[1][1];
    dp[1][2] = mt[1][2];
    dp[1][3] = mt[1][3];

    for (int i = 2; i <= n; ++i) {
        dp[i][1] += max (dp[i-1][2], dp[i-1][3]) + mt[i][1];
        dp[i][2] += max (dp[i-1][1], dp[i-1][3]) + mt[i][2];
        dp[i][3] += max (dp[i-1][1], dp[i-1][2]) + mt[i][3];
        //cout << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << '\n';
    }

    cout << max (dp[n][1], max(dp[n][2], dp[n][3]) );
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:13: error: 'fin' was not declared in this scope
   14 |             fin >> mt[i][j];
      |             ^~~
Language: C

#include<stdio.h>
#define SIZE 100000
int a[SIZE][3];
int b[SIZE][3];
int c[SIZE][3];
int t[SIZE][3];
int max(int x,int y);
int solve(int m,int k);

int main(void)
{
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;i++)
  {
    scanf("%d %d %d",&a[i],&b[i],&c[i]);
  }
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      t[i][j]=-1;
    }
  }
  int cost;
  cost=solve(0,3);
  printf("%d",cost);
  return 0;
}

int solve(int m,int k)
{
  int cost=INT_MIN;
  if(m==0)
  {
    return 0;
  }
  else
  {
    if(t[m][k]!=-1)
    {
      return t[m][k];
    }
    else
    {
      if(k==0)
      {
        cost=max(cost,b[m]+solve(m+1,1);
        cost=max(cost,c[m]+solve(m+1,2);
      }
      else if(k==1)
      {
        cost=max(cost,a[m]+solve(m+1,0);
        cost=max(cost,c[m]+solve(m+1,2);
      }
      else if(k==2)
      {
        cost=max(cost,a[m]+solve(m+1,0);
        cost=max(cost,b[m]+solve(m+1,1);
      }
      else
      {
        cost=max(cost,c[m]+solve(m+1,2);
        cost=max(cost,a[m]+solve(m+1,0);
        cost=max(cost,b[m]+solve(m+1,1);
      }
   }
 }
 return t[m][k]=cost;
}
                 
int max(int x,int y)
{
  return x>y?x:y;
}

Compiler output:
main.c: In function 'solve':
main.c:33:12: error: 'INT_MIN' undeclared (first use in this function)
   33 |   int cost=INT_MIN;
      |            ^~~~~~~
main.c:2:1: note: 'INT_MIN' is defined in header '<limits.h>'; this is probably fixable by adding '#include <limits.h>'
    1 | #include<stdio.h>
  +++ |+#include <limits.h>
    2 | #define SIZE 100000
main.c:33:12: note: each undeclared identifier is reported only once for each function it appears in
   33 |   int cost=INT_MIN;
      |            ^~~~~~~
main.c:48:40: error: expected ')' before ';' token
   48 |         cost=max(cost,b[m]+solve(m+1,1);
      |                 ~                      ^
      |                                        )
main.c:48:27: error: passing argument 2 of 'max' makes integer from pointer without a cast [-Wint-conversion]
   48 |         cost=max(cost,b[m]+solve(m+1,1);
      |                       ~~~~^~~~~~~~~~~~~
      |                           |
      |                           int *
main.c:7:19: note: expected 'int' but argument is of type 'int *'
    7 | int max(int x,int y);
      |               ~~~~^
main.c:75:1: error: expected declaration or statement at end of input
   75 | }
      | ^
main.c:75:1: error: expected declaration or statement at end of input
main.c:75:1: error: expected declaration or statement at end of input
main.c:75:1: error: expected declaration or statement at end of input
Language: C++

#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
int dp[100000][3]={0};

int ans(int a[100000][3],int i,int j,int n)
{
	if(i==n)
		return 0;

	if(dp[i][j]!=0)
		return dp[i][j];

	int best=0;
	for(j;j<3;j++)
	{
		for(int k=0;k<3;k++) 
		{
			if(k==j)
				continue;
			best=max(best,a[i][j]+ans(a,i+1,k,n));
		}
		if(i!=0)
			break;
		cout<<best<<endl;
	}
	return dp[i][j]=best;
}

int main()
{
	ios_base::sync_with_stdio(0);            //fast input and output
	cin.tie(NULL);
	cout.tie(NULL);
	int n,a[100000][3];
	// cin>>n;
	io.scan(n);
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<3;j++)
			cin>>a[i][j];
	}
	cout<<ans(a,0,0,n);
    
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:9: error: 'io' was not declared in this scope
   38 |         io.scan(n);
      |         ^~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<vector<int>>hp(n,vector<int>(3));
  for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>hp[i][j];
  vector<vector<int>>ans(n,vector<int>(3));
  ans[0][0]=hp[0][0];
  ans[0][1]=hp[0][1];
  ans[0][2]=hp[0][2];
  for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
      ans[i][j]=hp[i][j]+max(hp[i-1][(j+1)%3],hp[i-1][(j+2)%3)]);
    }
  }
  int val=INT_MIN;
  val=max(ans[n-1][0],max(ans[n-1][1],ans[n-1][2]));
  cout<<val<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:62: error: expected ']' before ')' token
   14 |       ans[i][j]=hp[i][j]+max(hp[i-1][(j+1)%3],hp[i-1][(j+2)%3)]);
      |                                                              ^
      |                                                              ]
a.cc:14:63: error: expected ';' before ']' token
   14 |       ans[i][j]=hp[i][j]+max(hp[i-1][(j+1)%3],hp[i-1][(j+2)%3)]);
      |                                                               ^
      |                                                               ;
Language: C++

#include<bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define fo(i,a,n) for(int i=a;i<n;i++)
#define ll long long int
#define li long int
using namespace std;
int n;
vector<int> a(100005);
vector<int> b(100005);
vector<int> c(100005);
vector<vector<ll>> dp(100005,vector<ll> (4,-1));
int cost(int ind,int parent)
{
    if(ind==n-1)
    {
        if(parent==1)
            return a[ind];
        else if(parent==1)
            return b[ind];
        else
            return c[ind];
    }
    if(dp[ind][parent]==-1)
    {
        if(parent==1)
        {
            dp[ind][parent]=a[ind]+max(cost(ind+1,2),cost(ind+1,3));
            //return dp[ind][parent];
        }
        else if(parent==2)
        {
            dp[ind][parent]=b[ind]+max(cost(ind+1,1),cost(ind+1,3));
            //return dp2[ind];
        }
        else
        {
            dp[ind][parent]=c[ind]+max(cost(ind+1,2),cost(ind+1,1));
            //return dp3[ind];
        }
    }
    return dp[ind][parent];

}
int main()
{
    cin>>n;
    f(i,n)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    ll ans=max(cost(0,1),cost(0,2));
    ans=max(ans,cost(0,3));
    cout<<ans;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:52:12: error: no matching function for call to 'max(long long int&, int)'
   52 |     ans=max(ans,cost(0,3));
      |         ~~~^~~~~~~~~~~~~~~
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:52:12: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   52 |     ans=max(ans,cost(0,3));
      |         ~~~^~~~~~~~~~~~~~~
/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:52:12: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   52 |     ans=max(ans,cost(0,3));
      |         ~~~^~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const long long INF=1LL<<60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
int main(){
int n; cin>>n;
  long long a [100010][3];
  long long dp[100010][3];
for(int i=0;i<n;i++){
   for(int j=0;j<3;j++){
     cin>>a[i][j];
   }
 }
   
  for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                chmax(dp[i + 1][k], dp[i][j] + a[i][k]);
            }
        }
    }
long long res=0;
  for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:23: error: 'N' was not declared in this scope
   17 |   for (int i = 0; i < N; ++i) {
      |                       ^
a.cc:26:45: error: 'N' was not declared in this scope
   26 |   for (int j = 0; j < 3; ++j) chmax(res, dp[N][j]);
      |                                             ^