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

/*#include <bits/stdc++.h>

using namespace std;

pair<unsigned long int,unsigned long int> max1(unsigned long int A,unsigned long int B, unsigned long int C )
{
    pair <unsigned long int,unsigned long int> p;
    int f=0;
    p.first= A > B ? (A > C ? A : C) : (B > C ? B : C);
    if(p.first==A)
    {
        p.second=1;
    }
    else if(p.first==B)
    {
        p.second=2;
    }
    else if(p.first==C)
    {
        p.second=3;
    }
 return p;
}


int main()
{
    unsigned long int n,i=0,sum=0;
    cin>>n;
    unsigned long int a[n],b[n],c[n];
    pair <unsigned long int,unsigned long int> dp[n];
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    for(i=0;i<n-1;i++)
    {
       /* if(i==0)
        {
            dp[i]=max1(a[i],b[i],c[i]);
        }
        else
        {
            if(max1(a[i],b[i],c[i]).second==dp[i-1].second)
            {
                if(dp[i-1].second==1)
                {
                    dp[i]=max1(0,b[i],c[i]);
                }
                else if(dp[i-1].second==2)
                {
                    dp[i]=max1(a[i],0,c[i]);
                }
                else if(dp[i-1].second==3)
                {
                    dp[i]=max1(a[i],b[i],0);
                }
            }
            else
                dp[i]=max1(a[i],b[i],c[i]);
        }
        sum+=dp[i].first*/
/*        sum=max1(sum+a[i]+max(b[i+1],c[i+1]),sum+b[i]+max(a[i+1],c[i+1]),sum+c[i]+max(b[i+1],a[i+1])).first;
    }
    cout<<sum;
    return 0;
}
*/


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

int solve(n,a,dp)
{
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<3;j++)
        {
            if(i==0)
            {
                dp[i][j]=a[i][j];
            }
            else if(j==0)
            {
                dp[i][0]=a[i][0]+max(dp[i-1][1],dp[i-1][2]);
            }
            else if(j==1)
            {
                dp[i][1]=a[i][1]+max(dp[i-1][0],dp[i-1][2]);
            }
            else if(j==2)
            {
                dp[i][2]=a[i][2]+max(dp[i-1][1],dp[i-1][0]);
            }
        }
    }
    return max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}
int main()
{
  int n;
  cin>>n;
  int a[n][3],dp[n][3];
  for(int i=0;i<n;i++)
  {
      for(int j=0;j<3;j++)
      {
          cin>>a[i][j];
          dp[i][j]=-1;
      }
  }
  int ans=0;
  ans=solve(n,a,dp);
  cout<<ans;
  return 0;
}

Compiler output:
a.cc:76:11: error: 'n' was not declared in this scope; did you mean 'yn'?
   76 | int solve(n,a,dp)
      |           ^
      |           yn
a.cc:76:13: error: 'a' was not declared in this scope
   76 | int solve(n,a,dp)
      |             ^
a.cc:76:15: error: 'dp' was not declared in this scope; did you mean 'dup'?
   76 | int solve(n,a,dp)
      |               ^~
      |               dup
a.cc:76:17: error: expression list treated as compound expression in initializer [-fpermissive]
   76 | int solve(n,a,dp)
      |                 ^
a.cc: In function 'int main()':
a.cc:116:12: error: 'solve' cannot be used as a function
  116 |   ans=solve(n,a,dp);
      |       ~~~~~^~~~~~~~
Language: C++

#include<iostream>
using namespace std;
int a[100001][3];
int dp[100001][3];
int n; 
int rec(int idx, int prev)
{
	if(idx==n){return 0;}
	if(prev==-1)
	{
		int x=rec(idx+1,0)+a[idx][0];
		 int y=rec(idx+1,1)+a[idx][1];
		 int z=rec(idx+1,2)+a[idx][2];
		 return dp[idx][prev+1]=max({x,y,z});
	}
		
	if(dp[idx][prev]!=0)
	{
		return dp[idx][prev];
	}
	if(prev==0)
	{
		 int x=rec(idx+1,1)+a[idx][1];
		 int y=rec(idx+1,2)+a[idx][2];
		 return dp[idx][prev]=max(x,y);
	}
	if(prev==1)
	{
		int x=rec(idx+1,0)+a[idx][0];
		 int y=rec(idx+1,2)+a[idx][2];
		 return dp[idx][prev]=max(x,y);
	}
	if(prev==2)
	{
		int x=rec(idx+1,0)+a[idx][0];
		 int y=rec(idx+1,1)+a[idx][1];
		 return dp[idx][prev]=max(x,y);
	}
	
	
}
int main()
{
	cin>>n;
	for(int i=0;i<n;i++)
	{for(int j=0;j<3;j++)
	{
		cin>>a[i][j];
	}
	}
	cout<<rec(0,-1);
}
	

Compiler output:
a.cc: In function 'int rec(int, int)':
a.cc:14:44: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   14 |                  return dp[idx][prev+1]=max({x,y,z});
      |                                         ~~~^~~~~~~~~
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++

N = int(input())
Table = []
dp = [[0]*3 for i in range(10**6)]

for _ in range(N):
    a,b,c = map(int, input().split())
    Table.append([a,b,c])
dp[0][0] = Table[0][0]
dp[0][1] = Table[0][1]
dp[0][2] = Table[0][2]

for i in range(N):
    for j in range(3):
        for k in range(3):
            if j==k:
                continue
            dp[i][j] = max(dp[i][j], dp[i-1][k]+Table[i][j])


print(max(dp[N-1][0], dp[N-1][1], dp[N-1][2]))

Compiler output:
a.cc:1:1: error: 'N' does not name a type
    1 | N = int(input())
      | ^
Language: C++

#include <iostream>
using namespace std;

const int rest = 1000001;
int dp[3][rest];
int ac[rest][3];
int it;

int va(int a, int i){
	if(i == it){
      return 0;
	}
	if(dp[a][i] != -1){
      return dp[a][i];
	}
	int& ans = dp[a][i];
	if(a==0){
		ans=max(ans, va(1, i+1)+ac[i][0]);
		ans=max(ans, va(2, i+1)+ac[i][0]);
	}
	if(a==1){
		ans=max(ans, va(0, i+1)+ac[i][1]);
		ans=max(ans, va(2, i+1)+ac[i][1]);
	}
	if(a==2){
		ans=max(ans, va(0, i+1)+ac[i][2]);
		ans=max(ans, va(1, i+1)+ac[i][2]);
	}

	return ans;
}
int main(){
	cin>>it;
	for(int i=0; i<it; i++){
        cin>>ac[i][0];
        cin>>ac[i][1];
        cin>>ac[i][2];
	}

	memset(dp, -1, sizeof dp);
	cout<<max(va(0,0),max(va(1,0),va(2,0)))<<"\n";
	return 0;
}

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

import java.util.*;
import java.util.function.Predicate;

public class Main {

    public static void main(String[] args) {
        new Main().run();
    }

    void run() {
        Scanner cin = new Scanner(System.in);
        N = cin.nextInt();
        A = new int[N];
        B = new int[N];
        C = new int[N];
        for (int i = 0; i < N; i ++){
            A[i] = cin.nextInt();
            B[i] = cin.nextInt();
            C[i] = cin.nextInt();
        }
        dp = new int[N][3];
        for (int i=0;i<N;i++){
            for (int j=0;j<3;j++){
                dp[i][j] = -1;
            }
        }

        System.out.println(dfs(0, -1));
    }

    int N;  //最大日数
    int[] A, B, C;  //それぞれの行動で得られる幸福度
    int[][] dp; // day, preChoiceの2引数に対する答えを記録する -1で初期化済み
    //何日目で最後に選んだのがどれの時に、これ以降最大どれだけの幸福度が得られるかを返す
    int dfs(int day, int preChoice) {
        //もし最終日であれば、もう幸福度は得られないので、0を返す
        if (day == N) return 0;
        //答えが計算済みであれば、dp配列から答えを返す
        if (dp[day][preChoice] != -1) return -1;
        //最終日でなければ、3つの選択肢から選ぶ
        int chooseA, chooseB, chooseC;
        //選べない場合の最低値を入れておく。
        chooseA = chooseB = chooseC = Integer.MIN_VALUE;
        //A, B, Cをそれぞれ選んだ場合の幸福度を計算する
        if (preChoice != 0) chooseA = A[day] + dfs(day + 1, 0);
        if (preChoice != 1) chooseB = B[day] + dfs(day + 1, 1);
        if (preChoice != 2) chooseC = C[day] + dfs(day + 1, 2);
        //最も幸福度が高かったものを返す dp配列に記録する
        return dp[day][preChoice] Math.max(chooseA, Math.max(chooseB, chooseC));
    }
}



Compiler output:
Main.java:49: error: ';' expected
        return dp[day][preChoice] Math.max(chooseA, Math.max(chooseB, chooseC));
                                 ^
1 error
Language: Java


import java.util.Scanner;

public class c_vacation {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[][] map = new long[N][3];
        for(int i = 0 ; i < N ; i++)
        {
            for(int j = 0 ; j < 3; j++)
                map[i][j] = sc.nextInt();
            if(i>0)
            {
                for(int j = 0 ; j < 3 ; j++)
                {
                    map[i][j] = Math.max(map[i-1][(j+1) % 3] + map[i][j], map[i-1][(j+2 )% 3]+map[i][j]);
                }
            }
        }
        System.out.println(Math.max(Math.max(map[N-1][0],map[N-1][1]),map[N-1][2]));

    }
}


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

#include <bits/stdc++.h>

using namespace std;


void solve(){
    int N;
    cin>>N;
    vector <int> dp(3);

    for(int day = 0;day<N;day++){
        vector <int> new_dp(3,0);
        vector <int> c(3);
        for(int i =0;i<3;i++){
            cin>>i;
        }
        for(int i = 0;i<3;i++){
            for(int j =0;j<3;j++){
                if(i!=j){
                    new_dp[j] = max(new_dp[j] , dp[i]+c[j]);
                }
            }
        }
        dp = new_dp;

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

int main(){
    solve();
}


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:27:10:   required from here
   27 | cout<<max(dp[0],dp[1],dp[2])<<endl;
      |       ~~~^~~~~~~~~~~~~~~~~~~
/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<iostream>
#include<cstring>

using namespace std;

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

  int n;
  cin>>n;
  int dp[n][3];
  
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>dp[i][j];   
    }
  }
  
 
  for(int 1=1;i<n;i++)
  {
    dp[i][0]=dp[i][0]+max(dp[i-1][1],max(dp[i-1][2]);                          
    dp[i][1]=dp[i][1]+max(dp[i-1][0],max(dp[i-1][2]);                          
    dp[i][2]=dp[i][2]+max(dp[i-1][0],max(dp[i-1][1]);
  }
  
   int m=max(dp[n-1][0],dp[n-1][1]);
        m=max(m,dp[n-1][2]);
        cout<<m;
  
  return 0;  
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:29:11: error: expected unqualified-id before numeric constant
   29 |   for(int 1=1;i<n;i++)
      |           ^
a.cc:29:10: error: expected ';' before numeric constant
   29 |   for(int 1=1;i<n;i++)
      |          ^~
      |          ;
a.cc:29:11: error: lvalue required as left operand of assignment
   29 |   for(int 1=1;i<n;i++)
      |           ^
a.cc:29:15: error: 'i' was not declared in this scope
   29 |   for(int 1=1;i<n;i++)
      |               ^
a.cc:29:18: error: expected ')' before ';' token
   29 |   for(int 1=1;i<n;i++)
      |      ~           ^
      |                  )
a.cc:29:19: error: 'i' was not declared in this scope
   29 |   for(int 1=1;i<n;i++)
      |                   ^
Language: C++

#include<iostream>
#include<cstring>

using namespace std;

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

  int n;
  cin>>n;
  int dp[n][3];
  
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
    {
      cin>>dp[i][j];   
    }
  }
  
 
  for(int 1=1;i<n;i++)
  {
    dp[i][0]=dp[i][0]+max(dp[i-1][1],max(dp[i-1][2]);                          
    dp[i][1]=dp[i][1]+max(dp[i-1][0],max(dp[i-1][2]);                          
    dp[i][2]=dp[i][2]+max(dp[i-1][0],max(dp[i-1][1]);
  }
  
   cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
  
  return 0;  
  }



Compiler output:
a.cc: In function 'int main()':
a.cc:29:11: error: expected unqualified-id before numeric constant
   29 |   for(int 1=1;i<n;i++)
      |           ^
a.cc:29:10: error: expected ';' before numeric constant
   29 |   for(int 1=1;i<n;i++)
      |          ^~
      |          ;
a.cc:29:11: error: lvalue required as left operand of assignment
   29 |   for(int 1=1;i<n;i++)
      |           ^
a.cc:29:15: error: 'i' was not declared in this scope
   29 |   for(int 1=1;i<n;i++)
      |               ^
a.cc:29:18: error: expected ')' before ';' token
   29 |   for(int 1=1;i<n;i++)
      |      ~           ^
      |                  )
a.cc:29:19: error: 'i' was not declared in this scope
   29 |   for(int 1=1;i<n;i++)
      |                   ^
Language: C++

#include <bits/stdc++.h>
 
using namespace std;
 
int main() {
    int N;
    cin>>N;
    int A,A0,B,B0,C,C0;
    cin>>A>>B>>C;
    A0=A;
    B0=B;
    C0=C;
    for(int i=1;i<N;i++)
    {
        cin>>A>>B>>C;
        int a0,b0,c0;
        a0=A+max(B0,C0);
        b0=A+max(A0,C0);
        c0=A+max(B0,A0);
        A0=a0;
        B0=b0;
        C0=c0;
    }
    cout<<max(A0,B0,C0);
    
    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:24:14:   required from here
   24 |     cout<<max(A0,B0,C0);
      |           ~~~^~~~~~~~~~
/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;
#define rep(i,n) for(int i = 0; i < (n); ++i)
using ll = long long;
const ll INF = 100100100;
template <typename T> inline bool chmin(T& a, T b) { 
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline bool chmax(T& a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

int N;
long long a[100010][3]; // a[i], b[i], c[i] をそれぞれまとめて a[i][0], a[i][1], a[i][2] にしてしまう

// DP テーブル
long long dp[100010][3];

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

    // 初期化は既に 0 に初期化される
    // 初期条件も既に 0 で OK

    // ループ
    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 i = 0; j < 3; ++i) chmax(res, dp[N][i]);
    cout << res << endl;
}

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

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
using ll = long long;
const ll INF = 100100100;
template <typename T> inline bool chmin(T& a, T b) { 
  if(a > b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T> inline bool chmax(T& a, T b) {
  if(a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  int a[100010][3];
  for(int i = 0; i < n; ++i) for(int j = 0; j < 3; ++j) cin >> a[i][j];
  int dp[100010][3];

  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;
        dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
      }
    }
  }

  ll ans = 0;
  rep(i,3) ans = max(ans, dp[n][i]);
  printf("%d\n", ans);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:38:21: error: no matching function for call to 'max(ll&, int&)'
   38 |   rep(i,3) ans = max(ans, dp[n][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:38:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   38 |   rep(i,3) ans = max(ans, dp[n][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:38:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   38 |   rep(i,3) ans = max(ans, dp[n][i]);
      |                  ~~~^~~~~~~~~~~~~~~
Language: C++

int main()
{
     long long int i,n,s=0;
     cin>>n;
     long long int a[n+10],b[n+10],c[n+10],A[n+10],B[n+10],C[n+10];
     for (i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
        A[1]=a[1];
        B[1]=b[1];
        C[1]=c[1];
      for (i=1;i<=n;i++)
      {
      	A[i]=max(B[i-1],C[i-1])+a[i];
      	B[i]=max(A[i-1],C[i-1])+b[i];
      	C[i]=max(B[i-1],A[i-1])+c[i];
	  }
	  s=max(max(A[n],B[n]),C[n]);
	  cout<<s;
}
        

Compiler output:
a.cc: In function 'int main()':
a.cc:4:6: error: 'cin' was not declared in this scope
    4 |      cin>>n;
      |      ^~~
a.cc:13:14: error: 'max' was not declared in this scope
   13 |         A[i]=max(B[i-1],C[i-1])+a[i];
      |              ^~~
a.cc:17:17: error: 'max' was not declared in this scope
   17 |           s=max(max(A[n],B[n]),C[n]);
      |                 ^~~
a.cc:17:13: error: 'max' was not declared in this scope
   17 |           s=max(max(A[n],B[n]),C[n]);
      |             ^~~
a.cc:18:11: error: 'cout' was not declared in this scope
   18 |           cout<<s;
      |           ^~~~
Language: C++

int main()
{
     long long int i,n,s=0;
     cin>>n;
     long long int a[n+10],b[n+10],c[n+10],A[n+10],B[n+10],C[n+10];
     for (i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
        A[1]=a[1];
        B[1]=b[1];
        C[1]=c[1];
      for (i=1;i<=n;i++)
      {
      	A[i]=max(B[i-1],C[i-1])+a[i];
      	B[i]=max(A[i-1],C[i-1])+b[i];
      	C[i]=max(B[i-1],A[i-1])+c[i];
	  }
	  s=A[n]+B[n]+C[n];
	  cout<<s;
}
        

Compiler output:
a.cc: In function 'int main()':
a.cc:4:6: error: 'cin' was not declared in this scope
    4 |      cin>>n;
      |      ^~~
a.cc:13:14: error: 'max' was not declared in this scope
   13 |         A[i]=max(B[i-1],C[i-1])+a[i];
      |              ^~~
a.cc:18:11: error: 'cout' was not declared in this scope
   18 |           cout<<s;
      |           ^~~~
Language: C++

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

int main()
{
     int i,n,s=0,abm1,abm;
     int a[1000],b[1000],c[1000];
     cin>>n;
     for (i=1;i<=n;i++)
        cin>>a[i]>>b[i]>>c[i];
        abm1=max(a[1],b[1]);
     s=s+max(abm1,c[1]);
     for (i=1;i<=n-1;i++)
     {
         abm=max(a[i],b[i]);
         if (a[i]==max(abm,c[i])) {s=s+max(b[i+1],c[i+1]);}
         else{
          if (b[i]==max(abm,c[i])) {s=s+max(a[i+1],c[i+1]);}
          else{
           if (c[i]==max(abm,c[i])) {s=s+max(a[i+1],b[i+1]);}}
     }
     }
     cout<<s;
}


Compiler output:
a.cc:1:1: error: 'include' does not name a type
    1 | include <bits/stdc++.h>
      | ^~~~~~~
a.cc: In function 'int main()':
a.cc:8:6: error: 'cin' was not declared in this scope
    8 |      cin>>n;
      |      ^~~
a.cc:11:14: error: 'max' was not declared in this scope
   11 |         abm1=max(a[1],b[1]);
      |              ^~~
a.cc:23:6: error: 'cout' was not declared in this scope
   23 |      cout<<s;
      |      ^~~~
Language: C++

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

const ll INF =100000000009;
ll dp[100005][3];
ll abc[100005][3];

templete<class T> inline bool chmax(T &x, T y){
	if(x < y){x = y; return true;}
	else return false;
}

int main(){
	ll n; cin >> n;
	rep(i,n){
		rep(j,3){
			cin >> abc[i][j];
		}
	}
	rep(i,n){
		rep(now,3){
			rep(nex,3){
				if(now == nex)continue;
				chmax(dp[i+1][nex],dp[i][now]+abc[i][nex]);
			}
		}
	}
	ll ans = 0;
	rep(i,3)ans =max(ans,dp[n-1][i]);
	cout << ans << endl;
}

Compiler output:
a.cc:11:1: error: 'templete' does not name a type
   11 | templete<class T> inline bool chmax(T &x, T y){
      | ^~~~~~~~
a.cc: In function 'int main()':
a.cc:27:33: error: 'chmax' was not declared in this scope
   27 |                                 chmax(dp[i+1][nex],dp[i][now]+abc[i][nex]);
      |                                 ^~~~~
Language: C++

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

const ll INF =100000000009;
ll dp[100005][3];
ll abc[100005][3];

bool chmax(ll &x,ll &y){
	if(x < y){x = y; return true;}
	else return false;
}

int main(){
	ll n; cin >> n;
	rep(i,n){
		rep(j,3){
			cin >> abc[i][j];
		}
	}
	rep(i,n){
		rep(now,3){
			rep(nex,3){
				if(now == nex)continue;
				chmax(dp[i+1][nex],dp[i][now]+abc[i][nex]);
			}
		}
	}
	ll ans = 0;
	rep(i,3)ans =max(ans,dp[n-1][i]);
	cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:62: error: cannot bind non-const lvalue reference of type 'll&' {aka 'long long int&'} to an rvalue of type 'll' {aka 'long long int'}
   27 |                                 chmax(dp[i+1][nex],dp[i][now]+abc[i][nex]);
      |                                                    ~~~~~~~~~~^~~~~~~~~~~~
a.cc:11:22: note:   initializing argument 2 of 'bool chmax(ll&, ll&)'
   11 | bool chmax(ll &x,ll &y){
      |                  ~~~~^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

bool chmax(in &a,in b){
if(a<b){a=b;return 1;}
  return 0;
}


int main(){
  int n;
  cin>>n;
  int abc[100010][3];
  rep(i,n) cin>>abc[i][0]>>abc[i][1]>>abc[i][2];
   int dp[100010][3];
  rep(i,n+3)rep(j,3) dp[i][j]=0;
  
 
  dp[0][0]=abc[0][0];
  dp[0][1]=abc[0][1];
  dp[0][2]=abc[0][2];
  
  for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
       for(int k=0;k<3;k++){
          if(j==k) continue;
          chmax(dp[i][j],dp[i-1][k]+abc[i][j]);
       }
    }
  }
  
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:32:24: error: cannot bind non-const lvalue reference of type 'in&' {aka 'long int&'} to a value of type 'int'
   32 |           chmax(dp[i][j],dp[i-1][k]+abc[i][j]);
      |                 ~~~~~~~^
a.cc:9:16: note:   initializing argument 1 of 'bool chmax(in&, in)'
    9 | bool chmax(in &a,in b){
      |            ~~~~^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
using in = int64_t;

bool chmax(int &a,int b){
if(a<b){a=b;return 1;}
  return 0;
}


int main(){
  int n;
  cin>>n;
  int abc[100010][3];
  rep(i,n) cin>>abc[i][1]>>abc[i][2]>>abc[i][3];
  
  rep(i,n+100)rep(j,3) dp[i][j]=0;
  
  int dp[100010][3];
  dp[0][0]=abc[0][0];
  dp[0][1]=abc[0][1];
  dp[0][2]=abc[0][2];
  
  for(int i=1;i<n;i++){
    for(int j=0;j<3;j++){
       for(int k=0;k<3;k++){
          if(j==k) continue;
          chmax(dp[i][j],dp[i-1][k]+abc[i][j]);
       }
    }
  }
  
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:24: error: 'dp' was not declared in this scope; did you mean 'dup'?
   21 |   rep(i,n+100)rep(j,3) dp[i][j]=0;
      |                        ^~
      |                        dup
Language: C++

#include <iostream>

int abs(int a)
{
  return (a > 0) ? a : -a;
}

int main()
{
	
  int n;
  std::cin >> n;
  
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++ )
    std::cin >> a[i] >> b[i] >> c[i];
 
  int dpa[n], dpb[n], dpc[n];
  dpa[0] = a[0];
  dpb[0] = b[0];
  dpc[0] = c[0];
  
  for ( int i = 1; i < n; i++ )
  {
    dpa[i] = a[i] + std::max(dpb[i - 1], dpc[i - 1]);
    dpb[i] = b[i] + std::max(dba[i - 1], dpc[i - 1]);
    dpc[i] = c[i] + std::max(dba[i - 1], dpb[i - 1]);
  }
  
  std::cout << std::max(a[n - 1], std::max(b[n - 1], c[n - 1])) << std::endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:30: error: 'dba' was not declared in this scope; did you mean 'dpa'?
   26 |     dpb[i] = b[i] + std::max(dba[i - 1], dpc[i - 1]);
      |                              ^~~
      |                              dpa
Language: C++

#include <iostream>

int abs(int a)
{
  return (a > 0) ? a : -a;
}

int main()
{
	
  int n;
  std::cin >> n;
  
  int a[n], b[n], c[n];
  for (int i = 0; i < n; i++ )
    std::cin >> a[i] >> b[i] >> c[i];
 
  int dpa[n], dpb[n], dpc[n];
  dpa[0] = a[0];
  dpb[0] = b[0];
  dpc[0] = c[0];
  
  for ( int i = 1; i < n; i++ )
  {
    dpa[i] = a[i] + std::min(dpb[i - 1], dpc[i - 1]);
    dpb[i] = b[i] + std::min(dba[i - 1], dpc[i - 1]);
    dpc[i] = c[i] + std::min(dba[i - 1], dpb[i - 1]);
  }
  
  std::cout << std::min(a[n - 1], std::min(b[n - 1], c[n - 1])) << std::endl;
  
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:30: error: 'dba' was not declared in this scope; did you mean 'dpa'?
   26 |     dpb[i] = b[i] + std::min(dba[i - 1], dpc[i - 1]);
      |                              ^~~
      |                              dpa
Language: C++

#include<bits/stdc++.h>
using namespace std;
vector<vector<long long> > dp(n,vector<long long>(3,-1));
long long solve(int n,int i,int j,vector<vector<int> > h,vector<vector<long long int> > dp)
{
	if(i==n-1){
		return h[i][j];
	}
  if(i>n)
    return 0;
  if(dp[i][j]!=-1)
    return dp[i][j]; 
  
  	long long c=h[i][j];
  	if(j==0)
      c=c+max(solve(n,i+1,j+1,h,dp),solve(n,i+1,j+2,h,dp));
    else if(j==1)
      c=c+max(solve(n,i+1,j+1,h,dp),solve(n,i+1,j-1,h,dp));
    else if(j==2)
      c=c+max(solve(n,i+1,j-1,h,dp),solve(n,i+1,j-2,h,dp));
    dp[i][j]=c;
  
   return c;
}
int main()
{
 	 int n;
  cin>>n;
  vector<vector<int> > h(n,vector<int>(3));
  for(int i=0;i<n;i++)
    for(int j=0;j<3;j++)
      cin>>h[i][j];
      if(n!=1){
      	long long m=max({solve(n,0,0,h,dp),solve(n,0,1,h,dp),solve(n,0,2,h,dp)});
		cout<<m;
      }
      else{
      	int m=max({h[0][1],h[0][2],h[0][0]});
       	cout<<m;
      }
  
}


Compiler output:
a.cc:3:31: error: 'n' was not declared in this scope; did you mean 'yn'?
    3 | vector<vector<long long> > dp(n,vector<long long>(3,-1));
      |                               ^
      |                               yn
Language: C++

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


int main() {
	int n;
	cin >> n;
	int happy[100000][3];
	for(int i=0; i<n; i++){
		cin >> happy[i][0] >> happy[i][1] >> happy[i][2];
	}
	long long dp[100000][3];
	for(int i=0; i<n; i++){
		for(int j=0; j<3; j++){
			dp[i][j] = 0;
		}
	}
	for(int i=0; i<3; i++){
		dp[0][i] = happy[0][i];
	}
	for(int i=0; i<n-1; i++){
		int a = happy[i+1][0];
		int b = happy[i+1][1];
		int c = happy[i+1][2];
		dp[i+1][0] = max(dp[i][1]+a, dp[i][2]+a);
		dp[i+1][1] = max(dp[i][0]+b, dp[i][2]+b);
		dp[i+1][2] = max(dp[i][0]+c, dp[i][1]+c); 
	}
	long long max = max(dp[n-1][0], dp[n-1][1]);
	max = max(max, dp[n-1][2]);
	cout << max << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:29:28: error: 'max' cannot be used as a function
   29 |         long long max = max(dp[n-1][0], dp[n-1][1]);
      |                         ~~~^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:30:18: error: 'max' cannot be used as a function
   30 |         max = max(max, dp[n-1][2]);
      |               ~~~^~~~~~~~~~~~~~~~~
Language: C++

#include <iostream>
#include <math.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int t[n][3], inc[n][3], excl[n][3];
	
	for(int i=0;i<n;++i)
	{
		cin >> t[i][0] >> t[i][1] >> t[i][2];
	}
	
	for(int i=0;i<n;++i)
	{
		if (!i)
		{
			inc[i][0] = t[i][0];
			inc[i][1] = t[i][1];
			inc[i][2] = t[i][2];
			
			excl[i][0] = max(t[i][1], t[i][2]);
			excl[i][1] = max(t[i][0], t[i][2]);
			excl[i][2] = max(t[i][0], t[i][1]);
		}
		else
		{
			inc[i][0] += excl[i-1][0];
			inc[i][1] += excl[i-1][1];
			inc[i][2] += excl[i-1][2];
			
			excl[i][0] = max(inc[i][1], inc[i][2]);
			excl[i][1] = max(inc[i][0], inc[i][2]);
			excl[i][2] = max(inc[i][0], inc[i][1]);
		}
	}
	
	cout<<max(inc[n-1][0], max([n-1][1], inc[n-1][2]))<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:38: error: expected ',' before '-' token
   39 |         cout<<max(inc[n-1][0], max([n-1][1], inc[n-1][2]))<<endl;
      |                                      ^
      |                                      ,
a.cc:39:38: error: expected identifier before '-' token
a.cc: In lambda function:
a.cc:39:41: error: expected '{' before '[' token
   39 |         cout<<max(inc[n-1][0], max([n-1][1], inc[n-1][2]))<<endl;
      |                                         ^
a.cc: In function 'int main()':
a.cc:39:41: error: no match for 'operator[]' (operand types are 'main()::<lambda()>' and 'int')
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: missing template arguments before '(' token
   10 |   vector(int> c(n, 0);
      |         ^
a.cc:10:10: error: expected primary-expression before 'int'
   10 |   vector(int> c(n, 0);
      |          ^~~
a.cc:12:29: error: 'c' was not declared in this scope
   12 |      cin >> a[i] >> b[i] >> c[i];
      |                             ^
a.cc:18:14: error: 'c' was not declared in this scope
   18 |   dp[0][2] = c[0];
      |              ^
Language: C++

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

int dp[1000004]={0};
func(int i,int arr[][3],int j,int n)
{
    int very_min=-2;
    if(i>n-1)
    {
        return 0;
    }
    for(int k=0;k<=2;k++)
    {
        if(k!=j)
        {
        int ref=arr[i][k]+func(i+1,arr,k,n);
        if(ref>very_min)
        {
            very_min=ref;
        }
        }
    }
    dp[i]=very_min;
    //dp[i]=max(arr[i][0]+func(i+1,arr),arr[i][1]+func(i+1,arr),arr[i][2]+func(i+1,arr));
    return dp[i];
}
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];
        }
    }
    func(0,arr,4,n);
    cout<<dp[0];
}


Compiler output:
a.cc:6:1: error: ISO C++ forbids declaration of 'func' with no type [-fpermissive]
    6 | func(int i,int arr[][3],int j,int n)
      | ^~~~
Language: C++

#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
ll h[300000005];
ll dp[300000005];
int main() {
	ll n;
	cin >> n;
	int a, b, c;
	
	int j = 0;
	for (int i = 0; i < n; i++) {
		cin >> a >> b >> c;
		
		h[j] = a;
		h[j + 1] = b;
		h[j + 2] = c;
		j += i + 3;
	}
	for (int i = 0; i < n; i++) {
		dp[i] = -100000;
	}
	ll mega = -10000;
	int x;
	for (int i = 0; i < 3; i++) {
		if (mega < h[i]) {
			mega = h[i];
			dp[0] = mega;
			x = i;
		}
	}
	if (n == 1) {
		cout << dp[0] << endl;
		return 0;
	}
	
	for (int i = 1; i < n; i++) {
		for (int j = i*3; j < n * 3; j++) {
			if (x % 3 != j % 3) {
				dp[i] = max(dp[i], dp[i - 1] + h[j]);
			}
			x = j;
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Compiler output:
/tmp/cc709Lt7.o: in function `main':
a.cc:(.text+0x104): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc709Lt7.o
a.cc:(.text+0x175): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc709Lt7.o
a.cc:(.text+0x196): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc709Lt7.o
a.cc:(.text+0x246): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc709Lt7.o
a.cc:(.text+0x27d): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc709Lt7.o
a.cc:(.text+0x2a7): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc709Lt7.o
a.cc:(.text+0x2ff): relocation truncated to fit: R_X86_64_PC32 against symbol `dp' defined in .bss section in /tmp/cc709Lt7.o
collect2: error: ld returned 1 exit status
Language: C++

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

#if !ONLINE_JUDGE
    #include "/home/tushar_garg/Desktop/cpp/debug.h"
#else
    #define dbg(x...)
#endif

typedef     long long                            ll; 
typedef     pair<ll, ll>                         pl; 
typedef     vector<ll>                           vl;
typedef     vector<char>                         vc;
typedef     vector<bool>                         vb; 
typedef     vector<vl>                           vvl; 
typedef     vector<pl>                           vll; 
typedef     map<ll, ll>                          dict; 
typedef     map<ll, ll, greater <ll> >           sdict; 
typedef     map<char, ll>                        mcl;
typedef     priority_queue<ll>                   pqi;
typedef     priority_queue<pl>                   pqii;
typedef     priority_queue<ll, vl, greater<ll>>  pqmini;

#define rep(i, a, n) for (auto i=(a)-((a)>(n)); i!=(n)-((a)>(n)); i+=1-2*((a)>(n)))
#define trav(i, a) for(auto &i:a)
#define fi first 
#define se second 
#define mp make_pair 
#define pb push_back
#define eb emplace_back
#define flash ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr)
#define QuickSilver cin.exceptions(cin.failbit),setprecision(12),cout.precision(12);
#define fill(a, b) memset(a, b, sizeof(a)
#define get(a) rep(i,0,sz(a))cin>>a[i];
#define sz(a) (ll)(a.size())
#define all(a) a.begin(), a.end()
#define mod 1000000009

int main(){
	flash; QuickSilver;
	int n; cin>>n;
	vl v(3, 0), p(3, 0);
	rep(i,0,n){
		int a, b, c; cin>>a>>b>>c;
		p[0]=a+max(v[1], v[2]);
		p[1]=b+max(v[0], v[2]);
		p[2]=c+max(v[0], v[1]);
		v=p;
	}
	cout<<max(v[0], max(v[1], v[2]))<<"\n";
    return 0;
} 

Compiler output:
a.cc:5:14: fatal error: /home/tushar_garg/Desktop/cpp/debug.h: No such file or directory
    5 |     #include "/home/tushar_garg/Desktop/cpp/debug.h"
      |              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int> dp(3);
    for(int i = 0; i < n; i++)
    {
        vector<int> new_dp(3,0);
        vector<int> points(3);
        for(int j = 0; j < 3; j++)
            cin >> points[j];
        for(int k = 0; k < 3; k++)
        {
            for(int l = 0; l < 3; l++)
            {
                if(k != l)
                {
                    new_dp[l] = max(new_dp[l], dp[k]+points[l]);
                   // cout << new_dp[l]<<endl;
                }
            }
        }
        dp = new_dp;
    }
   /* for(int r = 0; r < 3; r++)
    {
        cout << dp[r]<<" ";
    }
    int m = dp[0];*/
    for(int o = 1; o < 3; o++)
    {
        m = max(m, dp[o]);
    }
    cout << m;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:9: error: 'm' was not declared in this scope
   34 |         m = max(m, dp[o]);
      |         ^
a.cc:36:13: error: 'm' was not declared in this scope
   36 |     cout << m;
      |             ^
Language: C++

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

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


Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: 'j' was not declared in this scope
   16 |         dp[i][j]=a[i][j]+max(dp[i-1][1],dp[i-1][2]);
      |               ^
Language: C++

from sys import stdin,stdout

n = int(stdin.readline())
a = []
for i in range(n):
    x,y,z = map(int,stdin.readline().split())
    a.append([x,y,z])
dp = [[0,0,0] for i in range(n)]
dp[0] =  [a[0][0],a[0][1],a[0][2]] 
for i in range(1,n):
    dp[i][0] = a[i][0] + max( dp[i-1][1],dp[i-1][2] )
    dp[i][1] = a[i][1] + max( dp[i-1][0],dp[i-1][2] )
    dp[i][2] = a[i][2] + max( dp[i-1][0],dp[i-1][1] )
ans = max(dp[n-1])
stdout.write(str(ans))


Compiler output:
a.cc:1:1: error: 'from' does not name a type
    1 | from sys import stdin,stdout
      | ^~~~
Language: C++

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

int main(){
    int n;
    cin>>n;

    vector<int> dp(3);

    for(int i=0; i<n; i++){
      vector<int> newdp(3,0);
      vector<int> c(3);
      for(int j=0; j<3; j++) cin>>c[j];

      for(int j=0; j<3; j++){
        if(j!=i) newdp[j] = max(newdp[j], dp[i]+c[j]);
      }

    dp = newdp;
    }

    cout<<max(dp[0],dp[1],dp[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:22:14:   required from here
   22 |     cout<<max(dp[0],dp[1],dp[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++

memo = {}

def solve(a, b, c, i, last_option):
	if (i, last_option) not in memo:
		if i == len(a):
			result = 0
		elif i == 0:
			result = max(a[i] + solve(a, b, c, i + 1, 1), b[i] + solve(a, b, c, i + 1, 2), c[i] + solve(a, b, c, i + 1, 3))
		else:
			if last_option == 1:
				result = max(b[i] + solve(a, b, c, i + 1, 2), c[i] + solve(a, b, c, i + 1, 3))
			elif last_option == 2:
				result = max(a[i] + solve(a, b, c, i + 1, 1), c[i] + solve(a, b, c, i + 1, 3))
			else:
				result = max(a[i] + solve(a, b, c, i + 1, 1), b[i] + solve(a, b, c, i + 1, 2))
		memo[(i, last_option)] = result
		return result
	else:
		return memo[(i, last_option)]

n = int(input())
a = [None for i in range(n)]
b = [None for i in range(n)]
c = [None for i in range(n)]
for i in range(n):
	a[i], b[i], c[i] = map(int, input().split())
print(solve(a, b, c, 0, 4))


Compiler output:
a.cc:1:1: error: 'memo' does not name a type
    1 | memo = {}
      | ^~~~
a.cc:3:1: error: 'def' does not name a type
    3 | def solve(a, b, c, i, last_option):
      | ^~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  int sum=0;
  while(n)
  {int p=-1;
    n--;
    int arr[3];
    int max=-1,max1=-1,q;
    for(int i=0;i<3;i++)
    {cin>>arr[i];
     if(max<arr[i])
     {
       if(max==-1)
       {
         max=arr[i];}
       else{max1=max;max=arr[i];}
       q=i;}
     if(q==p)
       sum+=max1;
     else sum+=max;
     q=p;
    }
   cout<<sum;
  }
      

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

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll a[100010][3];
ll dp[100010][3];
int N;
int main() {
    int N; cin >> N;
    REP(i,N){
        REP(j,3){
            cin >> a[i][j];
        }
    }
    REP(i,N){
        REP(j,3){
            REP(k,3){
                if(j != k){
                    if(dp[i+1][k]<dp[i][j] + a[i][k]){
                    dp[i+1][k] = dp[i][j] + a[i][k];
                }  
            }
        }
    }
    ll res = 0;
    REP(i,3){
        if(res<dp[N][i]){
            res = dp[N][i];
        }
    }
    cout << res << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll a[100010][3];
ll dp[100010][3];

int main() {
    int N; cin >> N;
    REP(i,N){
        REP(j,3){
            cin >> a[i][j];
        }
    }
    REP(i,N){
        REP(j,3){
            REP(k,3){
                if(j != k){
                    if(dp[i+1][k]<dp[i][j] + a[i][k]){
                    dp[i+1][k] = dp[i][j] + a[i][k];
                }  
            }
        }
    }
    ll res = 0;
    REP(i,3){
        if(res<dp[N][i]){
            res = dp[N][i];
        }
    }
    cout << res << endl;
}


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

#include <bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a[n],b[n],c[n];
	int hap[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	hap[0]=max(a[0],b[0],c[0]);
	
	for(int i=1;i<n;i++)
	{
		if(i==1)
		{
			hap[1]=max((a[0]+max(b[1],c[1])),(b[0]+max(a[1],c[1])),(c[0]+max(a[1],b[1])));
		}
		else
		{
			int p,q,r,x;
			p=0;
			q=0;
			r=0;
			x=hap[i-1]-hap[i-2];
			if(x==a[i-1])
			{
				p=max(b[i],c[i]);
			}
			if(x==b[i-1])
			{
				q=max(a[i],c[i]);
			}
			if(x==c[i-1])
			{
				r=max(a[i],b[i]);
			}
			hap[i]=hap[i-1]+max(p,q,r);
		}
	}
	cout<<hap[n-1]<<endl;
}

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:13:12:   required from here
   13 |         hap[0]=max(a[0],b[0],c[0]);
      |                ~~~^~~~~~~~~~~~~~~~
/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 <iostream>
#include <vector>
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N), C(N);
    for (int i = 0; i < N; i++)
        cin >> A[i] >> B[i] >> C[i];

    vector<vector<int>> dp(N, vector<int>(3));
    dp[0][0] = A[0], dp[0][1] = B[0], dp[0][2] = C[0];
    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 3; j++) {
            if (j == 0) dp[i][j] = A[i] + max(dp[i - 1][1], dp[i - 1][2]);
            if (j == 1) dp[i][j] = B[i] + max(dp[i - 1][2], dp[i - 1][0]);
            if (j == 2) dp[i][j] = C[i] + max(dp[i - 1][0], dp[i - 1][1]);
        }
    }

    cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:16: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   22 |     cout << max({dp[N - 1][0], dp[N - 1][1], dp[N - 1][2]}) << 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