Language: C++

#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll dp[100005][100005];
ll n,a[100005];

int helper(int day, int chose)
{
    if(day == n) return 0;

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

    int maxi = 0;
    if(chose == 0)
    {
        maxi = max(maxi, a[day][1]+ helper(day+1, 1));
        maxi = max(maxi, a[day][2]+ helper(day+1, 2));
        maxi = max(maxi, a[day][3]+ helper(day+1, 3));
    }
    else if(chose == 1)
    {
        maxi = max(maxi, a[day][2], helper(day+1, 2));  
        maxi = max(maxi, a[day][3], helper(day+1, 3));
    }
    else if(chose == 1)
    {
        maxi = max(maxi, a[day][2]+ helper(day+1, 2));  
        maxi = max(maxi, a[day][3]+ helper(day+1, 3));
    }
    else if(chose == 2)
    {
        maxi = max(maxi, a[day][1]+ helper(day+1, 1));  
        maxi = max(maxi, a[day][3]+ helper(day+1, 3));
    }
    else 
    {
        maxi = max(maxi, a[day][2], helper(day+1, 2));  
        maxi = max(maxi, a[day][1], helper(day+1, 1));
    }
    return dp[day][chose] = maxi;
}
int main() {

    cin >> n;
    memset(dp, -1, sizeof dp);

    for(int i=0; i<n; i++)
        for(int j=1; j<=3; j++)
            cin >> a[i][j];

    cout<<helper(0,0);
}

Compiler output:
a.cc: In function 'int helper(int, int)':
a.cc:11:16: error: 'flag' was not declared in this scope
   11 |     if(dp[day][flag] != -1) return dp[day][chose];
      |                ^~~~
a.cc:16:32: error: invalid types 'long long int[int]' for array subscript
   16 |         maxi = max(maxi, a[day][1]+ helper(day+1, 1));
      |                                ^
a.cc:17:32: error: invalid types 'long long int[int]' for array subscript
   17 |         maxi = max(maxi, a[day][2]+ helper(day+1, 2));
      |                                ^
a.cc:18:32: error: invalid types 'long long int[int]' for array subscript
   18 |         maxi = max(maxi, a[day][3]+ helper(day+1, 3));
      |                                ^
a.cc:22:32: error: invalid types 'long long int[int]' for array subscript
   22 |         maxi = max(maxi, a[day][2], helper(day+1, 2));
      |                                ^
a.cc:23:32: error: invalid types 'long long int[int]' for array subscript
   23 |         maxi = max(maxi, a[day][3], helper(day+1, 3));
      |                                ^
a.cc:27:32: error: invalid types 'long long int[int]' for array subscript
   27 |         maxi = max(maxi, a[day][2]+ helper(day+1, 2));
      |                                ^
a.cc:28:32: error: invalid types 'long long int[int]' for array subscript
   28 |         maxi = max(maxi, a[day][3]+ helper(day+1, 3));
      |                                ^
a.cc:32:32: error: invalid types 'long long int[int]' for array subscript
   32 |         maxi = max(maxi, a[day][1]+ helper(day+1, 1));
      |                                ^
a.cc:33:32: error: invalid types 'long long int[int]' for array subscript
   33 |         maxi = max(maxi, a[day][3]+ helper(day+1, 3));
      |                                ^
a.cc:37:32: error: invalid types 'long long int[int]' for array subscript
   37 |         maxi = max(maxi, a[day][2], helper(day+1, 2));
      |                                ^
a.cc:38:32: error: invalid types 'long long int[int]' for array subscript
   38 |         maxi = max(maxi, a[day][1], helper(day+1, 1));
      |                                ^
a.cc: In function 'int main()':
a.cc:49:24: error: invalid types 'long long int[int]' for array subscript
   49 |             cin >> a[i][j];
      |                        ^