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

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

int solve(vector<activity> &ar, int);
struct activity
{
    int A, B, C;
};
int solve(vector<activity> &ar, int n)
{
    int dp[n + 1][3];
    dp[1][0] = ar[1].A;
    dp[1][1] = ar[1].B;
    dp[1][2] = ar[1].C;

    for (int i = 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][1], dp[i - 1][0]);
    }
    return max({dp[n][0], dp[n][1], dp[n][2]});
}
int main()
{
    int n, k;
    cin >> n;
    vector<activity> ar(n + 1);
    for (int i = 1; i <= n; i++)
    {
        cin >> ar[i].A;
        cin >> ar[i].B;
        cin >> ar[i].C;
    }
    cout << solve(ar, n);

    return 0;
}

Compiler output:
a.cc:4:18: error: 'activity' was not declared in this scope
    4 | int solve(vector<activity> &ar, int);
      |                  ^~~~~~~~
a.cc:4:26: error: template argument 1 is invalid
    4 | int solve(vector<activity> &ar, int);
      |                          ^
a.cc:4:26: error: template argument 2 is invalid
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n;
vector<vector<int>> v;

int memo[(int)1e5+5][3];

int maxPoints(int day, int notodo) {

	if (memo[day][notodo]!=-1)
		return memo[day][notodo];

	if (day==n)
		return 0;

	int answer=-inf;
	for (int i=0; i<3; i++) {
		if (i!=notodo) {
			answer=max(answer, v[day][i] + maxPoints(day+1,i));
		}	
	}

	memo[day][notodo]=answer;
	return answer;
}

int main()
{
	
	cin.tie(NULL);
	cout.tie(NULL);
	scanf("%d",&n);
	v.resize(n);
	for (int i=0; i<n; i++)
		v[i].resize(3);

	for (int i=0; i<n; i++) {
		scanf("%d%d%d",&v[i][0],&v[i][1],&v[i][2]);
	}

	memset(memo,-1,sizeof(memo));	
	cout<<maxPoints(0,3)<<endl;

    return 0;
}


Compiler output:
a.cc: In function 'int maxPoints(int, int)':
a.cc:16:21: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   16 |         int answer=-inf;
      |                     ^~~
      |                     ynf
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define lli long long int
#define ld long double
#define pb push_back
#define is insert
#define iamspid ios_base::sync_with_stdio(false); cin.tie(NULL);
int main()
{
    iamspid
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    lli n;
    cin>>n;
    lli a[n], b[n], c[n];
    for(lli i=0;i<n;i++)
    {
        cin>>a[i]>>b[i]>>c[i];
    }
    
    dp[0][0]=a[0], dp[0][1]=b[0], dp[0][2]=c[0];
    for(lli 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]);
    }
    cout<<max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]))<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:5: error: 'dp' was not declared in this scope; did you mean 'dup'?
   22 |     dp[0][0]=a[0], dp[0][1]=b[0], dp[0][2]=c[0];
      |     ^~
      |     dup
Language: Java

public class Main {

	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int days = scan.nextInt();
		int activites[][] = new int[days+1][4];
		for(int i=1;i<=days;i++) {
			activites[i][1] = scan.nextInt();
			activites[i][2] = scan.nextInt();
			activites[i][3] = scan.nextInt();
		}
		
		int points = Integer.MIN_VALUE;
		
		int[][] dp = new int[days+1][4];
		for(int i=1;i<=3;i++) {
			points = Math.max(points, happiness(activites,1,i,dp));
		}
				
		System.out.println(points);
	}
	
	public static int happiness(int[][] act,int day,int currentActvity, int[][] dp) {
		
		if(day >= act.length) {
			return 0;
		}
		
		if(dp[day][currentActvity] != 0) {
			return dp[day][currentActvity];
		}
		
		int points = Integer.MIN_VALUE;
				
		for(int i=1;i<=3;i++) {
			if(i != currentActvity) {
				points = Math.max(points, happiness(act, day+1, i,dp));
			}
		}
		
		dp[day][currentActvity] = points + act[day][currentActvity];
		return dp[day][currentActvity];
	}
}

Compiler output:
Main.java:4: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
		Scanner scan = new Scanner(System.in);
		                   ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C++

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


#define endl '\n'
#define mem(a,b) memset(a, b, sizeof(a) )
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


const in max = 1e5+123;

const int inf = 2000000000;

int dp[mx][4],  h[mx][4],n;


int solve (int i , int f1)
{
           if (i>n) return 0;
           if (dp[i][f1] != -1) return dp[i][f1];

           int ret = 0;
           for (int j=1; j<=3; j++){

            if (j != f1){

             ret=max(ret, h[i][j] + solve (i+1, j));
}

           }
           return dp[i][f1] = ret;





}
    int main (){

             optimise();

             cin>>n;
             for(int i=1; i<=n; i++){
                  cin>>h[i][1] >> h[i][2] >> h[i][3];


}

            memset (dp , -1 , sizeof(dp));
            cout<<solve(1, 0) <<endl;

return 0;

}




Compiler output:
a.cc:10:7: error: 'in' does not name a type; did you mean 'int'?
   10 | const in max = 1e5+123;
      |       ^~
      |       int
a.cc:14:8: error: 'mx' was not declared in this scope
   14 | int dp[mx][4],  h[mx][4],n;
      |        ^~
a.cc:14:19: error: 'mx' was not declared in this scope
   14 | int dp[mx][4],  h[mx][4],n;
      |                   ^~
a.cc: In function 'int solve(int, int)':
a.cc:20:16: error: 'dp' was not declared in this scope; did you mean 'dup'?
   20 |            if (dp[i][f1] != -1) return dp[i][f1];
      |                ^~
      |                dup
a.cc:27:27: error: 'h' was not declared in this scope
   27 |              ret=max(ret, h[i][j] + solve (i+1, j));
      |                           ^
a.cc:31:19: error: 'dp' was not declared in this scope; did you mean 'dup'?
   31 |            return dp[i][f1] = ret;
      |                   ^~
      |                   dup
a.cc: In function 'int main()':
a.cc:40:14: error: 'optimise' was not declared in this scope; did you mean 'optimize'?
   40 |              optimise();
      |              ^~~~~~~~
      |              optimize
a.cc:44:24: error: 'h' was not declared in this scope
   44 |                   cin>>h[i][1] >> h[i][2] >> h[i][3];
      |                        ^
a.cc:49:21: error: 'dp' was not declared in this scope; did you mean 'dup'?
   49 |             memset (dp , -1 , sizeof(dp));
      |                     ^~
      |                     dup
Language: C++

#include <iostream>
using namespace std;

int maximum(int a,int b){
    return a>b?a:b;
}

int main() {
    //cout<<"givr n"<<endl;
	int n;
	cin>>n;
	int matrix[n][3];
	for(int i=0;i<n;i++){
	    //cout<<"give row"<<endl;
	    for(int j=0;j<3;j++){
	        cin>>matrix[i][j];
	    }
	}
	
	int dp[n][3];
	dp[0][0]=matrix[0][0];dp[0][1]=matrix[0][1];
	dp[0][2]=matrix[0][2];
	
	int max=dp[0][0]>dp[0][1]?(dp[0][0]>dp[0][2]?dp[0][0]:dp[0][2]):(dp[0][1]>dp[0][2]:dp[0][1]:dp[0][2]);
	for(int i=1;i<n;i++){
	    for(int j=0;j<3;j++){
	        dp[i][j]=matrix[i][j]+maximum(dp[i-1][(j+1)%3],dp[i-1][(j-1>=0?j-1:3+j-1)%3]);
	        max=dp[i][j]>max?dp[i][j]:max;
	    }
	}
	
	cout<<max<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:91: error: expected ')' before ':' token
   24 |         int max=dp[0][0]>dp[0][1]?(dp[0][0]>dp[0][2]?dp[0][0]:dp[0][2]):(dp[0][1]>dp[0][2]:dp[0][1]:dp[0][2]);
      |                                                                         ~                 ^
      |                                                                                           )
Language: Java

import java.util.Scanner;
public class vacation
{
    public static void main(String args[])
        {
            Scanner s = new Scanner(System.in);
            int days = s.nextInt(); 
            int arr[][] = new int[days][3];
            for(int i=0;i<3;i++)
                {
                    for(int j=0;j<days;j++)
                        {
                            arr[i][j] = s.nextInt();
                        }
                }
            solver(arr,days);
        }
    private static void solver(int arr[][],int days)
        {
            int max = Integer.MIN_VALUE;
            for(int i=0;i<arr.length;i++)
                {
                    for(int j=0;j<arr[0].length;j++)
                        {
                            if(i==0) continue;
                            else
                                {
                                    arr[i][j] = helper(arr,i-1,j)+arr[i][j];
                                }
                            max = Math.max(arr[i][j],max);
                            //System.out.println(max);
                        }
                }
            System.out.println(max);
        }
    private static int helper(int arr[][],int row,int col)
        {
            int max = Integer.MIN_VALUE;
            for(int i=0;i<arr[0].length;i++)
                {
                   if(i!=col) max = Math.max(arr[row][i],max);
                }
            return max;
        }
}


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

ll solve(vector<ll>a,vector<ll>b,vector<ll>c,ll n,ll f,ll dp[][4]){
    if(n==0) return 0;
    if(dp[n][f]!=-1)
        return dp[n][f];
    if (f==1)
        return dp[n][1]=max(b[n-1]+solve(a,b,c,n-1,2,dp),c[n-1]+solve(a,b,c,n-1,3,dp));
    if(f==2)
        return dp[n][2]=max(a[n-1]+solve(a,b,c,n-1,1,dp),c[n-1]+solve(a,b,c,n-1,3,dp));
    if(f==3)
        return dp[n][3]=max(b[n-1]+solve(a,b,c,n-1,2,dp),a[n-1]+solve(a,b,c,n-1,1,dp));
    return max(a[n-1]+solve(a,b,c,n-1,1,dp),max(b[n-1]+solve(a,b,c,n-1,2,dp),c[n-1]+solve(a,b,c,n-1,3,dp)));
}
int main() {
    ll n;
    cin>>n;
    vector<ll>a(n);
    vector<ll>b(n);
    vector<ll>c(n);
    ll dp[n+1][4];
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
    cout<<solve(a,b,c,n,0,dp);
}


Compiler output:
a.cc:1:1: error: 'll' does not name a type
    1 | ll solve(vector<ll>a,vector<ll>b,vector<ll>c,ll n,ll f,ll dp[][4]){
      | ^~
a.cc: In function 'int main()':
a.cc:14:5: error: 'll' was not declared in this scope
   14 |     ll n;
      |     ^~
a.cc:15:5: error: 'cin' was not declared in this scope
   15 |     cin>>n;
      |     ^~~
a.cc:15:10: error: 'n' was not declared in this scope
   15 |     cin>>n;
      |          ^
a.cc:16:5: error: 'vector' was not declared in this scope
   16 |     vector<ll>a(n);
      |     ^~~~~~
a.cc:16:15: error: 'a' was not declared in this scope
   16 |     vector<ll>a(n);
      |               ^
a.cc:17:15: error: 'b' was not declared in this scope
   17 |     vector<ll>b(n);
      |               ^
a.cc:18:15: error: 'c' was not declared in this scope
   18 |     vector<ll>c(n);
      |               ^
a.cc:19:7: error: expected ';' before 'dp'
   19 |     ll dp[n+1][4];
      |       ^~~
      |       ;
a.cc:20:12: error: 'dp' was not declared in this scope
   20 |     memset(dp,-1,sizeof(dp));
      |            ^~
a.cc:20:5: error: 'memset' was not declared in this scope
   20 |     memset(dp,-1,sizeof(dp));
      |     ^~~~~~
a.cc:1:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
  +++ |+#include <cstring>
    1 | ll solve(vector<ll>a,vector<ll>b,vector<ll>c,ll n,ll f,ll dp[][4]){
a.cc:21:11: error: expected ';' before 'i'
   21 |     for(ll i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
      |           ^~
      |           ;
a.cc:21:16: error: 'i' was not declared in this scope
   21 |     for(ll i=0;i<n;i++) cin>>a[i]>>b[i]>>c[i];
      |                ^
a.cc:22:5: error: 'cout' was not declared in this scope
   22 |     cout<<solve(a,b,c,n,0,dp);
      |     ^~~~
a.cc:22:11: error: 'solve' was not declared in this scope
   22 |     cout<<solve(a,b,c,n,0,dp);
      |           ^~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int arr[n][3];
  int dp[n][3];
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      cin>>arr[i][j];
    }
  }
  memset(dp,-1,size(dp));
  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++)
  {
    dp[i][0] = dp[0][0] + max(arr[i-1][1],arr[i-1][2]);
    dp[i][1] = dp[0][1] + max(arr[i-1][0],arr[i-1][2]);
    dp[i][2] = dp[0][2] + max(arr[i-1][1],arr[i-1][0]);
  }
  int ans = max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
  cout<<ans<<"\n";
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:20: error: no matching function for call to 'size(int [n][3])'
   15 |   memset(dp,-1,size(dp));
      |                ~~~~^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:   template argument deduction/substitution failed:
a.cc:15:20: note:   variable-sized array type 'int [n][3]' is not a valid template argument
   15 |   memset(dp,-1,size(dp));
      |                ~~~~^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note:   template argument deduction/substitution failed:
a.cc:15:20: note:   variable-sized array type 'long int' is not a valid template argument
   15 |   memset(dp,-1,size(dp));
      |                ~~~~^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int arr[n][3];
  int dp[n][3];
  for(i=0;i<n;i++)
  {
    for(int j=0;j<n;j++)
    {
      cin>>arr[i][j];
    }
  }
  memset(dp,-1,size(dp));
  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++)
  {
    dp[i][0] = dp[0][0] + max(arr[i-1][1],arr[i-1][2]);
    dp[i][1] = dp[0][1] + max(arr[i-1][0],arr[i-1][2]);
    dp[i][2] = dp[0][2] + max(arr[i-1][1],arr[i-1][0]);
  }
  int ans = max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
  cout<<ans<<"\n";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:7: error: 'i' was not declared in this scope
    8 |   for(i=0;i<n;i++)
      |       ^
a.cc:15:20: error: no matching function for call to 'size(int [n][3])'
   15 |   memset(dp,-1,size(dp));
      |                ~~~~^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:262:5: note: candidate: 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:   template argument deduction/substitution failed:
a.cc:15:20: note:   variable-sized array type 'int [n][3]' is not a valid template argument
   15 |   memset(dp,-1,size(dp));
      |                ~~~~^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidate: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note:   template argument deduction/substitution failed:
a.cc:15:20: note:   variable-sized array type 'long int' is not a valid template argument
   15 |   memset(dp,-1,size(dp));
      |                ~~~~^~~~
Language: C++

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	vector<vector<int>> a(n,vecotr<int>(3)),dp(n,vecotr<int>(3,INT_MIN));
	for(int i=0;i<n;i++)
		for(int j=0;j<3;j++)
			cin >> a[i][j];
	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++)
		for(int j=0;j<3;j++)
			for(int k=0;k<3;k++)
				if(j != k)
					dp[i][j] = max(dp[i-1][j],dp[i-1][k] + a[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:7:33: error: 'vecotr' was not declared in this scope
    7 |         vector<vector<int>> a(n,vecotr<int>(3)),dp(n,vecotr<int>(3,INT_MIN));
      |                                 ^~~~~~
a.cc:7:40: error: expected primary-expression before 'int'
    7 |         vector<vector<int>> a(n,vecotr<int>(3)),dp(n,vecotr<int>(3,INT_MIN));
      |                                        ^~~
a.cc:7:61: error: expected primary-expression before 'int'
    7 |         vector<vector<int>> a(n,vecotr<int>(3)),dp(n,vecotr<int>(3,INT_MIN));
      |                                                             ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define MAXN 100000
#define INF 2000000000
int a[MAXN],b[MAXN],c[MAXN];
int dpa[MAXN+1],dpb[MAXN+1],dpc[MAXN+1];
int n,k;
int main() {
	int i
	int j;
	scanf("%d",&n,&k);
	for (i=0; i<n;i++) {
		scanf("%d %d %d",&a[i],&b[i],&c[i]);
	}
	dpa[n]=dpb[n]=dpc[n]=0;
	for (i=n-1; i>=0; i--) {
		dpa[i]=a[i]+max(dpb[i+1],dpc[i+1]);
		dpb[i]=b[i]+max(dpa[i+1],dpc[i+1]);
		dpc[i]=c[i]+max(dpa[i+1],dpb[i+1]);
	}
	printf("%d\n",max(dpa[0], max(dpb[0], dpc[0])));
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:9: error: expected initializer before 'int'
   10 |         int j;
      |         ^~~
a.cc:12:14: error: 'i' was not declared in this scope
   12 |         for (i=0; i<n;i++) {
      |              ^
a.cc:16:14: error: 'i' was not declared in this scope
   16 |         for (i=n-1; i>=0; i--) {
      |              ^
Language: Java

import java.util.Scanner;

public class Vacation {
    static long dp[][] = new long[100005][3]; /// dp[dia][actividad]   para el dia d, actvidad j max abajo
    static int n;
    static int[][] matrix;
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        n = in.nextInt();
        matrix = new int[n][3];

        for(int i=0;i<n;i++) {
            for(int j=0;j<3;j++) {
                int curr = in.nextInt();
                matrix[i][j]=curr;
            }

        }
        solve(0,0); solve(0,1); solve(0,2);
        long max = Long.max(Long.max(dp[0][0],dp[0][1]), dp[0][2]);
        System.out.println(max);

    }

    public static long solve(int dia, int actividad) {
        // caso base
        if(dia == n-1) {dp[dia][actividad]=matrix[dia][actividad]; return matrix[dia][actividad];}
        if(dp[dia][actividad]!=0) return dp[dia][actividad];

        long a=0;long b=0; long c=0;
        if(actividad!=0)a = solve(dia+1,0) + matrix[dia][actividad]; 
        if(actividad!=1)b = solve(dia+1,1)+ matrix[dia][actividad];
        if(actividad!=2)c = solve(dia+1,2)+ matrix[dia][actividad]; 

        long max = Long.max(Long.max(a,b), c);
        dp[dia][actividad]=max;
        return max;
    }

}

Compiler output:
Main.java:3: error: class Vacation is public, should be declared in a file named Vacation.java
public class Vacation {
       ^
1 error
Language: Java

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Vacation {

	public static void main(String[] args) throws IOException {
		BufferedReader lector = new BufferedReader(new InputStreamReader(System.in));
		int filas = Integer.parseInt(lector.readLine());
		int[][] matriz = new int[filas][3];
		for (int i = 0; i < matriz.length; i++) {
			String[] datos = lector.readLine().split(" ");
			for (int j = 0; j < matriz[0].length; j++) {
				matriz[i][j] = Integer.parseInt(datos[j]);
			}
		}
		int mayor = 0;
		int actual = 0;
		int posAnterior = 0;
		int posActual = 0;
		int total = 0;
		for (int i = 0; i < matriz.length; i++) {
			for (int j = 0; j < matriz[0].length; j++) {
				if (i == 0) {
					actual = matriz[i][j];
					if (actual > mayor) {
						mayor = actual;
						posActual = j;
					}
				} else {
					if(j!=posAnterior) {
						actual=matriz[i][j];
						if(actual>mayor) {
							mayor=actual;
							posActual=j;
						}
					}

				}
			}
			posAnterior=posActual;
			actual=0;
			total+=mayor;
			mayor=0;
		}
		System.out.println(total);
	}
}


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

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

int n;
int data[3][MAX];
long long dp[3][MAX];
long long m;

int main(){
    cin>>n;
    for(int i=1; i<=n; i++){
        for(int j=0; j<3; j++)
            cin>>data[j][i];
    }
    for(int i=1; i<=n; i++){
        for(int j=0; j<3; j++)
            for(int k=0; k<3; k++){
                if(k!=j)dp[j][i] = max(dp[k][i-1]+data[j][i], dp[j][i]);
                m = max(dp[j][i], m);
            }
    }
    cout<<m<<"\n";
    return 0;
}
/*
3
10 40 70
20 50 80
30 60 90
*/


Compiler output:
a.cc: In function 'int main()':
a.cc:14:18: error: reference to 'data' is ambiguous
   14 |             cin>>data[j][i];
      |                  ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:6:5: note:                 'int data [3][100005]'
    6 | int data[3][MAX];
      |     ^~~~
a.cc:19:51: error: reference to 'data' is ambiguous
   19 |                 if(k!=j)dp[j][i] = max(dp[k][i-1]+data[j][i], dp[j][i]);
      |                                                   ^~~~
/usr/include/c++/14/bits/range_access.h:344:5: note: candidates are: 'template<class _Tp> constexpr const _Tp* std::data(initializer_list<_Tp>)'
  344 |     data(initializer_list<_Tp> __il) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:334:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::data(_Tp (&)[_Nm])'
  334 |     data(_Tp (&__array)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:323:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(const _Container&)'
  323 |     data(const _Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:312:5: note:                 'template<class _Container> constexpr decltype (__cont.data()) std::data(_Container&)'
  312 |     data(_Container& __cont) noexcept(noexcept(__cont.data()))
      |     ^~~~
a.cc:6:5: note:                 'int data [3][100005]'
    6 | int data[3][MAX];
      |     ^~~~
Language: C++

#include <iostream>
#included <vector>
 using namespace std;
int main() {
    int  n;
    cin >> n; 
    vector<vector<int> >arr(n, vector<int>(3));
    for (int i = 0; i < n; ++i)
    {
        for (int j = 0; j < 3; ++j)
        {
            cin >> arr[i][j];
        }
    }
    vector<vector<int>> DP(n + 1, vector<int>(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)
    {
        DP[i][0] = arr[i][0] + max(DP[i - 1][1], DP[i - 1][2]);
        DP[i][1] = arr[i][1] + max(DP[i - 1][0], DP[i - 1][2]);
        DP[i][2] = arr[i][2] + max(DP[i - 1][0], DP[i - 1][1]);
    }

    cout << max(max(DP[n - 1][0], DP[n - 1][1]), DP[n - 1][2]) << "\n";
    return 0;
}

Compiler output:
a.cc:2:2: error: invalid preprocessing directive #included; did you mean #include?
    2 | #included <vector>
      |  ^~~~~~~~
      |  include
a.cc: In function 'int main()':
a.cc:7:5: error: 'vector' was not declared in this scope
    7 |     vector<vector<int> >arr(n, vector<int>(3));
      |     ^~~~~~
a.cc:2:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    1 | #include <iostream>
  +++ |+#include <vector>
    2 | #included <vector>
a.cc:7:19: error: expected primary-expression before 'int'
    7 |     vector<vector<int> >arr(n, vector<int>(3));
      |                   ^~~
a.cc:12:20: error: 'arr' was not declared in this scope
   12 |             cin >> arr[i][j];
      |                    ^~~
a.cc:15:19: error: expected primary-expression before 'int'
   15 |     vector<vector<int>> DP(n + 1, vector<int>(3));
      |                   ^~~
a.cc:16:5: error: 'DP' was not declared in this scope
   16 |     DP[0][0] = arr[0][0];
      |     ^~
a.cc:16:16: error: 'arr' was not declared in this scope
   16 |     DP[0][0] = arr[0][0];
      |                ^~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main(void){
    int n;
    cin>>n;
    int a[100001][3];
    int dp[100001][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;
                } else {
                    chmax(dp[i+1][k],dp[i][j]+a[i][k]);
                }
            }
        }
    }
    long long int ans=0;
    for (int i=0;i<3;i++) {
        chmax(ans,dp[n][i]);
    }
    cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:33:14: error: no matching function for call to 'chmax(long long int&, int&)'
   33 |         chmax(ans,dp[n][i]);
      |         ~~~~~^~~~~~~~~~~~~~
a.cc:3:31: note: candidate: 'template<class T> bool chmax(T&, T)'
    3 | template<class T> inline bool chmax(T& a, T b) {
      |                               ^~~~~
a.cc:3:31: note:   template argument deduction/substitution failed:
a.cc:33:14: note:   deduced conflicting types for parameter 'T' ('long long int' and 'int')
   33 |         chmax(ans,dp[n][i]);
      |         ~~~~~^~~~~~~~~~~~~~
Language: Java


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


Compiler output:
Main.java:4: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
        ^
  symbol:   class Scanner
  location: class Main
Main.java:4: error: cannot find symbol
        Scanner scanner = new Scanner(System.in);
                              ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: C

#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n;
const int Max=100;
const int OO=1e6;
int r[Max];
int g[Max];
int b[Max];
string housing[Max];
int grid[100][100];
int value[100][100];
vector<pair<int,int>>v;
vector<int>vn;
bool valid(int x,int y){
	return x>-1 && y>-1 && x<n && y<n;
}
int sum(int r,int c)
{
    if(!valid(r,c))
        return 0;
    if(r==n-1 && c==n-1)
        return value[r-1][c-1]=grid[r][c];
        if(value[r][c]!=-1)
            return value[r][c];
    int path1=sum(r+1,c);
    int path2=sum(r,c+1);
    return   value[r][c]=grid[r][c]+max(path1,path2);
}
void printpath(int r,int c)
{
    if(!valid(r,c))
        return ;
     v.push_back({r,c});
     vn.push_back(value[r][c]);
     int l=value[r+1][c  ];
     int h=value[r  ][c+1];
     (l>h)?printpath(r+1,c):printpath(r,c+1);
}
char Char[100][100];
bool solve(int r,int c)
{
    if(!valid(r,c)||value[r][c]==1||Char[r][c]=='X')
        return 0;
    if(Char[r][c]=='E')
        return 1;
    value[r][c]=1;
    if(solve(r,c-1))return 1;
    if(solve(r,c+1))return 1;
    if(solve(r+1,c))return 1;
    if(solve(r-1,c))return 1;
    value[r][c]=0;
    return 0;
}
    vector<string >st;
void gbinary(int len,string cur="")
{
    if(len==0)
    {
        st.push_back(cur);
        return ;
    }
    gbinary(len-1,cur+"a");
    gbinary(len-1,cur+"b");
}
int mem[10000];
int fib(int a)
{
    if(a<=1)
    return 1;
    int &ret=mem[a];
    if(~ret)return ret;
    ret= fib(a-1)+fib(a-2);
    return ret;
}
int memo[Max][4];
void init()
{
    memset(memo,-1,sizeof memo);
}
int V[4]={5,6,7,8};
int cnt=0;
bool T=false;
/**first video in dp eng mostafa saad all
 possible probility for sum or substrak 5,6,7,8 and sum divisible by k ;

 */
void tryall(int i ,int sum)
{

    if(i==4)
    {
        cout<<sum<<endl;
       if ((sum%26)==0)
        T=1;
        return;
    }
   tryall(i+1,sum+V[i]);
   tryall(i+1,sum-V[i]);

}
int costmin(int i,int last )
{
    if(i==n)
    return 0;
    int &ret=memo[i][last];
    if(~ret)return ret;
    ret=0;

    if(last!=0)
    ret=max(ret, r[i]+costmin(i+1,0));

    if(last!=1)
    ret=max(ret, g[i]+costmin(i+1,1));

    if(last!=2)
    ret=max(ret, b[i]+costmin(i+1,2));

    return ret;

}
int main()
{
    init();
    scanf("%d",&n);
    for(int i=0; i<n;i++)
    {
        cin>>r[i]>>g[i]>>b[i];
    }

    printf("%lld\n",costmin(0,3));

}



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>
using namespace std;

int main()
{
    int n;
    cin >> n;
    long long dp[100010][3], a[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;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + dp[i][k]);
            }
        }
    }

    long long res = 0;
    for(int j = 0; j < 3; j++){
        res = max(res, dp[n][j])
    }
    cout << res << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:33: error: expected ';' before '}' token
   26 |         res = max(res, dp[n][j])
      |                                 ^
      |                                 ;
   27 |     }
      |     ~
Language: C++

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

int main()
{
    int n;
    cin >> n;
    long long dp[100010][3], a[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;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + dp[i][k]);
            }
        }
    }

    long long res = 0;
    for(int j = 0; j < 3; j++){
        res = max(res, dp[n][i])
    }
    cout << res << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:30: error: 'i' was not declared in this scope
   26 |         res = max(res, dp[n][i])
      |                              ^
Language: C++


#include<iostream>
using namespace std;
int mod = 1e9+7;


class activity{
public:
    int A;
    int B;
    int C;
};

int vacation(vector<activity>v,int n){

     int dp[n+1][3];
     dp[1][0]=v[1].A;
     dp[1][1]=v[1].B;
     dp[1][2]=v[1].C;

    for(int i=2;i<=n;i++){
      dp[i][0]=(v[i].A + max(dp[i-1][1],dp[i-1][2]))%mod;
      dp[i][1]=(v[i].B + max(dp[i-1][0],dp[i-1][2]))%mod;
      dp[i][2]=(v[i].C + max(dp[i-1][0],dp[i-1][1]))%mod;
    }

    int ans = max(dp[n][0],max(dp[n][1],dp[n][2]));
    return ans % mod;
}



int main(){

     int n,k;
     cin>>n;
     vector<activity>v(n+1);
     for(int i=1;i<=n;i++){
       cin>>v[i].A;
       cin>>v[i].B;
       cin>>v[i].C;
     }

     cout<<vacation(v,n)<<endl;

     return 0;
}


Compiler output:
a.cc:14:14: error: 'vector' was not declared in this scope
   14 | int vacation(vector<activity>v,int n){
      |              ^~~~~~
a.cc:3:1: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
    2 | #include<iostream>
  +++ |+#include <vector>
    3 | using namespace std;
a.cc:14:29: error: expected primary-expression before '>' token
   14 | int vacation(vector<activity>v,int n){
      |                             ^
a.cc:14:30: error: 'v' was not declared in this scope
   14 | int vacation(vector<activity>v,int n){
      |                              ^
a.cc:14:32: error: expected primary-expression before 'int'
   14 | int vacation(vector<activity>v,int n){
      |                                ^~~
a.cc:14:37: error: expression list treated as compound expression in initializer [-fpermissive]
   14 | int vacation(vector<activity>v,int n){
      |                                     ^
a.cc: In function 'int main()':
a.cc:37:6: error: 'vector' was not declared in this scope
   37 |      vector<activity>v(n+1);
      |      ^~~~~~
a.cc:37:6: note: 'std::vector' is defined in header '<vector>'; this is probably fixable by adding '#include <vector>'
a.cc:37:21: error: expected primary-expression before '>' token
   37 |      vector<activity>v(n+1);
      |                     ^
a.cc:37:22: error: 'v' was not declared in this scope
   37 |      vector<activity>v(n+1);
      |                      ^
a.cc:44:20: error: 'vacation' cannot be used as a function
   44 |      cout<<vacation(v,n)<<endl;
      |            ~~~~~~~~^~~~~
Language: C++

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

int main(){
  int n,x;
  cin >> n;
  vector<vector<int>> arr;
  for(int i=0;i<n;i++){
      cin >> a >> b >> c;
      arr.push_back({a,b,c});
  }
  vector<int> temp = arr[arr.size()-1];
  
  for(int i=arr.size()-2;i>=0;i++){
     vector<int> temp1(3,0);
	 temp1[0] = temp[0] + max(temp[1],temp[2]);
     temp1[1] = temp[1] + max(temp[2],temp[0]);
     temp1[2] = temp[2] + max(temp[0],temp[1]);
     temp = temp1;
  }
  int mm = INT_MIN;
  for(int i=0;i<temp.size();i++){
    mm = max(mm,temp[i]);
  }
  cout << mm << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: 'a' was not declared in this scope
    9 |       cin >> a >> b >> c;
      |              ^
a.cc:9:19: error: 'b' was not declared in this scope
    9 |       cin >> a >> b >> c;
      |                   ^
a.cc:9:24: error: 'c' was not declared in this scope
    9 |       cin >> a >> b >> c;
      |                        ^
a.cc:10:20: error: no matching function for call to 'std::vector<std::vector<int> >::push_back(<brace-enclosed initializer list>)'
   10 |       arr.push_back({a,b,c});
      |       ~~~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; value_type = std::vector<int>]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const std::vector<std::vector<int> >::value_type&' {aka 'const std::vector<int>&'}
 1283 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = std::vector<int>; _Alloc = std::allocator<std::vector<int> >; value_type = std::vector<int>]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::vector<int> >::value_type&&' {aka 'std::vector<int>&&'}
 1300 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:28:21: error: 'ans' was not declared in this scope; did you mean 'abs'?
   28 |         cout << max(ans[n][1], max(ans[n][2],ans[n][3]));
      |                     ^~~
      |                     abs
Language: C++

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

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

Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   16 |         ans[1] = 0;
      |         ^~~
      |         abs
Language: C++

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

#define ll long long

ll n = 0;
ll a[100009];
ll b[10009];
ll c[100009];
//ll dp[10009];

ll solve(int i,int prev)
{
    if(i == n)
        return 0;

    ll ans;
    ans = INT_MIN;

  //  if(dp[i] != -1)
    //    return dp[i];

    if(prev == 0)
    {
        ans = max(b[i] + solve(i+1,1),ans);
        ans = max(c[i] + solve(i+1,2),ans);
    }

   else if(prev == 1)
    {
        ans = max(a[i] + solve(i+1,0),ans);
        ans = max(c[i] + solve(i+1,2),ans);
    }

    else if(prev == 2)
    {
        ans = max(a[i] + solve(i+1,0),ans);
        ans = max(b[i] + solve(i+1,1),ans);
    }
    else
    {
        ans = max(c[i] + solve(i+1,2),ans);
        ans = max(b[i] + solve(i+1,1),ans);
        ans = max(a[i] + solve(i+1,0),ans);
    }
    return ans;
}



int main()
{
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        cin>>b[i];
        cin>>c[i];
    }
    memset(dp,-1,sizeof(dp));
    cout<<"\n"<<solve(0,3);
    return 0;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:62:12: error: 'dp' was not declared in this scope; did you mean 'dup'?
   62 |     memset(dp,-1,sizeof(dp));
      |            ^~
      |            dup
Language: C

#include <stdio.h>
 
#define MAX 100000
 
int max(int a, int b){
  if(a>b) return a;
  return b;
}
 
void main(){
  int n;
  int a[MAX], b[MAX], c[MAX], dp[3][MAX];
  int ans;
  scanf("%d", &n);
  for(int i=0; i<n; i++) {
  	scanf("%d %d %d", &a[i], &b[i], &c[i]);
  }
  dp[0][0] = a[i];
  dp[1][0] = b[i];
  dp[2][0] = c[i];
  for(int i=1; i<n; i++) {
    dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
    dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b[i];
    dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c[i];
  }
  ans = max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]);
  printf("%d", ans);
}

Compiler output:
main.c: In function 'main':
main.c:18:16: error: 'i' undeclared (first use in this function)
   18 |   dp[0][0] = a[i];
      |                ^
main.c:18:16: note: each undeclared identifier is reported only once for each function it appears in
Language: C

#include <stdio.h>

#define MAX 100000

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

void main(){
  int n;
  int a[MAX], b[MAX], c[MAX], dp[3][MAX];
  int ans;
  scanf("%d", n);
  for(int i=0; i<n; i++) {
  	scanf("%d %d %d", a[i], b[i], c[i]);
  }
  dp[0][0] = a[i];
  dp[1][0] = b[i];
  dp[2][0] = c[i];
  for(int i=1; i<n; i++) {
    dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
    dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b[i];
    dp[2][i] = max(dp[0][i-1], dp[1][i-1]) + c[i];
  }
  ans = max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1]);
  printf("%d", ans);
}

Compiler output:
main.c: In function 'main':
main.c:18:16: error: 'i' undeclared (first use in this function)
   18 |   dp[0][0] = a[i];
      |                ^
main.c:18:16: note: each undeclared identifier is reported only once for each function it appears in
Language: Java

public class Main {
    public static Scanner scanner = new Scanner(System.in);

    public static void main(String[] args) {
        int n = scanner.nextInt();
        int dp[][] = new int[n+1][4];
        int activity[][] = new int[n+1][4];
        for(int i = 1 ; i<=n ; i++){
            for(int j = 1 ; j<=3 ; j++){
                activity[i][j] = scanner.nextInt();
            }
        }
        System.out.println(solve(n,activity,dp));
    }
  public static int solve(int n , int[][] activity , int[][] dp){
        dp[1][1] = activity[1][1];
        dp[1][2] = activity[1][2];
        dp[1][3] = activity[1][3];
        for(int i = 2 ; i<= n ; i++){
            dp[i][1] = activity[i][1] + Math.max(dp[i-1][2] ,dp[i-1][3]);
            dp[i][2] = activity[i][2] + Math.max(dp[i-1][1] , dp[i-1][3]);
            dp[i][3] = activity[i][3] + Math.max(dp[i-1][2] ,dp[i-1][1]);
        }
      return Math.max(Math.max(dp[n][1],dp[n][2]),dp[n][3]);
  }
}







Compiler output:
Main.java:2: error: cannot find symbol
    public static Scanner scanner = new Scanner(System.in);
                  ^
  symbol:   class Scanner
  location: class Main
Main.java:2: error: cannot find symbol
    public static Scanner scanner = new Scanner(System.in);
                                        ^
  symbol:   class Scanner
  location: class Main
2 errors
Language: Java

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

public class Vacation {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[][] activities = new int[n+1][3];
		String[] s;
		for (int i = 1; i < n+1; i++) {
			s = br.readLine().split(" ");
			for (int j = 0; j < 3; j++)
				activities[i][j] = Integer.parseInt(s[j]);
		}

		int[][] max = new int[n + 1][3];
		for (int i = 1; i < n + 1; i++) {
			max[i][0] = activities[i][0] + Math.max(max[i - 1][1], max[i - 1][2]);
			max[i][1] = activities[i][1] + Math.max(max[i - 1][0], max[i - 1][2]);
			max[i][2] = activities[i][2] + Math.max(max[i - 1][0], max[i - 1][1]);
		}

		int k = -1;
		for (int i = 0; i < 3; i++) {
			if (max[n][i] > k)
				k = max[n][i];
		}
		System.out.println(k);
	}

}


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

#include <algorithm>
#include <cstring>

using namespace std;

const int N = 1e5 + 1;
int n, dp[N][3];

int main(int argc, char** argv)
{
#ifdef LOCAL
  freopen(strcat(argv[0], ".in"), "ab+", stdin);
#endif
  
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
   
  cin >> n;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;

    dp[i][0] = i ? max(dp[i - 1][1], dp[i - 1][2]) + a : a;
    dp[i][1] = i ? max(dp[i - 1][0], dp[i - 1][2]) + b : b;
    dp[i][2] = i ? max(dp[i - 1][0], dp[i - 1][1]) + c : c;
  }

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




Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:15:3: error: 'ios_base' has not been declared
   15 |   ios_base::sync_with_stdio(false);
      |   ^~~~~~~~
a.cc:16:3: error: 'cin' was not declared in this scope
   16 |   cin.tie(nullptr);
      |   ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <cstring>
  +++ |+#include <iostream>
    3 | 
a.cc:28:3: error: 'cout' was not declared in this scope
   28 |   cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
      |   ^~~~
a.cc:28:3: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<bits/stdc++.h>
using namespace std;
int max(int a,int b)
{
    return a>b?a:b;
}
int main()
{
    int n;
    cin>>n;
    int a[n],b[n],c[n];
    for(int i=0;i<n;i++)
    {
        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];
    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]);
    }
    res=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
    cout<<res<<endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:26:5: error: 'res' was not declared in this scope
   26 |     res=max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
      |     ^~~
Language: C++

#include<iostream>
#include<math.h>
using namespace std;

#define ll long long 


ll n, a[100009],b[100009],c[100009];

ll dp[100009][4];

ll solve(int idx, int prev) {
	
	if(idx == n)
		return 0;

	if(dp[idx][prev] != -1)
		return dp[idx][prev];

	ll ans = INT_MIN;

	if(prev == 0) {
		ans = max(ans, b[idx] + solve(idx + 1, 1));
		ans = max(ans, c[idx] + solve(idx + 1, 2));
	} else if(prev == 1) {
		ans = max(ans, a[idx] + solve(idx + 1, 0));
		ans = max(ans, c[idx] + solve(idx + 1, 2));
	} else if(prev == 2) {
		ans = max(ans, b[idx] + solve(idx + 1, 1));
		ans = max(ans, a[idx] + solve(idx + 1, 0));
	} else {
		ans = max(ans, c[idx] + solve(idx + 1, 2));
		ans = max(ans, b[idx] + solve(idx + 1, 1));
		ans = max(ans, a[idx] + solve(idx + 1, 0));
	}

	return dp[idx][prev] = ans;
}


int main() {

// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif	

	// a => 0, b => 1, c => 2

	memset(dp, -1, sizeof(dp));

	cin>>n;

	for(int i = 0; i < n; i++) {
        cin>>a[i]>>b[i]>>c[i];
    }

	ll ans = solve(0, 3);

	cout<<ans<<endl;
	
}

Compiler output:
a.cc: In function 'long long int solve(int, int)':
a.cc:20:18: error: 'INT_MIN' was not declared in this scope
   20 |         ll ans = INT_MIN;
      |                  ^~~~~~~
a.cc:3:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    2 | #include<math.h>
  +++ |+#include <climits>
    3 | using namespace std;
a.cc: In function 'int main()':
a.cc:50:9: error: 'memset' was not declared in this scope
   50 |         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<math.h>
  +++ |+#include <cstring>
    3 | using namespace std;