Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define mod 1000000007
#define dd double
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
int dp[100001][4];
int a,b,c;
int size;
int knap(int arr[][3],int n,int a){
	if(n==0)
		return 0;
	if(dp[n][a]!=-1)
		return dp[n][a];
	if(a == 0){
		a = arr[size-n][0] + knap(arr,n-1,1);
		b = arr[size-n][1] + knap(arr,n-1,2);
		c = arr[size-n][2] + knap(arr,n-1,3);
	}
	if(a == 1){
		a = -1;
		b = arr[size-n][1] + knap(arr,n-1,2);
		c = arr[size-n][2] + knap(arr,n-1,3);
	}
	if(a == 2){
		b = -1;
		a = arr[size-n][0] + knap(arr,n-1,1);
		c = arr[size-n][2] + knap(arr,n-1,3);
	}
	if(a == 3){
		c = -1;
		a = arr[size-n][0] + knap(arr,n-1,1);
		b = arr[size-n][1] + knap(arr,n-1,2);		
	}
	return dp[n][a] = max(max(a,b),c);
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
#ifndef ONLINE_JUDGE    
    freopen("input.txt", "r", stdin);     
    freopen("output.txt", "w", stdout);
#endif
int n;
cin>>n;
size = n;
int arr[n][3];
	rep(i,n){
		cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	}
	// rep(i,n){
	// 	cout<<arr[i][0]<<arr[i][1]<<arr[i][2]<<endl;
	// }
	memset(dp,-1,sizeof(dp));
	cout<<knap(arr,n,0);









#ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed: " << 1.0*clock() / CLOCKS_PER_SEC << " sec\n";
#endif

return 0;
}

Compiler output:
a.cc: In function 'int knap(int (*)[3], int, int)':
a.cc:23:25: error: reference to 'size' is ambiguous
   23 |                 a = arr[size-n][0] + knap(arr,n-1,1);
      |                         ^~~~
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:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc:24:25: error: reference to 'size' is ambiguous
   24 |                 b = arr[size-n][1] + knap(arr,n-1,2);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc:25:25: error: reference to 'size' is ambiguous
   25 |                 c = arr[size-n][2] + knap(arr,n-1,3);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc:29:25: error: reference to 'size' is ambiguous
   29 |                 b = arr[size-n][1] + knap(arr,n-1,2);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc:30:25: error: reference to 'size' is ambiguous
   30 |                 c = arr[size-n][2] + knap(arr,n-1,3);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc:34:25: error: reference to 'size' is ambiguous
   34 |                 a = arr[size-n][0] + knap(arr,n-1,1);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc:35:25: error: reference to 'size' is ambiguous
   35 |                 c = arr[size-n][2] + knap(arr,n-1,3);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc:39:25: error: reference to 'size' is ambiguous
   39 |                 a = arr[size-n][0] + knap(arr,n-1,1);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc:40:25: error: reference to 'size' is ambiguous
   40 |                 b = arr[size-n][1] + knap(arr,n-1,2);
      |                         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~
a.cc: In function 'int main()':
a.cc:53:1: error: reference to 'size' is ambiguous
   53 | size = n;
      | ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: '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:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:16:5: note:                 'int size'
   16 | int size;
      |     ^~~~