Language: C++

#include<bits/stdc++.h>
#define forn(i,n) for(int i=0;i<n;i++)

#define ALL(x) x.begin(),x.end()
#define LL long long int

int mod = pow(10,9) +7;
const int inf = 2e9;
const LL linf = 2e18;
const double eps = 1e-9;

/////////////////////////////////////////////

const int N = 3e3+100;
LL arr[N];
LL dp[N][N];

LL total(LL x,LL y , bool c ){
    // trace(x,y,c);
    if(dp[x][y] != -1LL) return dp[x][y] ;
    if(x > y ) return 0;
    if(c == 0) return  dp[x][y ]=  max( arr[x] + total(x+1,y,!c) , arr[y] + total(x,y-1,!c) );
    else return dp[x][y] =  min(total(x+1,y,!c) -arr[x],total(x,y-1,!c) -arr[y]);
} 


int solve(int x, int y,int c){
    if(x == y){
        return arr[x];
    }
    int mini = min(arr[x] + solve(x+1,y,c^1),arr[y] + solve(x,y-1,c^1));
    int maxi = min(arr[x] + solve(x+1,y,c^1),arr[y] + solve(x,y-1,c^1));

    int play1 = min( arr[x] + solve(x+1,y,1) - solve(x+1,y,0) ,arr[y] +  solve(x,y-1,1) - solve(x,y-1,0) );
    int play2 = min( arr[x] + solve(x+1,y,1) - solve(x+1,y,0) ,arr[y] +  solve(x,y-1,1) - solve(x,y-1,0) );
    if(c == 0){
        return play1;
    }else{
        return play2;
    }
}


int main()
{
    
    LL n;
    cin >> n;
    forn(i,n) forn(j,n) dp[i][j] = -1LL;
    forn(i,n) cin >> arr[i];
    cout << total(0,n-1,0) << endl;
}

Compiler output:
a.cc: In function 'long long int total(long long int, long long int, bool)':
a.cc:22:36: error: 'max' was not declared in this scope; did you mean 'std::max'?
   22 |     if(c == 0) return  dp[x][y ]=  max( arr[x] + total(x+1,y,!c) , arr[y] + total(x,y-1,!c) );
      |                                    ^~~
      |                                    std::max
In file included from /usr/include/c++/14/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: 'std::max' declared here
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc:23:29: error: 'min' was not declared in this scope; did you mean 'std::min'?
   23 |     else return dp[x][y] =  min(total(x+1,y,!c) -arr[x],total(x,y-1,!c) -arr[y]);
      |                             ^~~
      |                             std::min
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int solve(int, int, int)':
a.cc:31:16: error: 'min' was not declared in this scope; did you mean 'std::min'?
   31 |     int mini = min(arr[x] + solve(x+1,y,c^1),arr[y] + solve(x,y-1,c^1));
      |                ^~~
      |                std::min
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: 'std::min' declared here
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
a.cc: In function 'int main()':
a.cc:48:5: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
   48 |     cin >> n;
      |     ^~~
      |     std::cin
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:146:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:51:5: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   51 |     cout << total(0,n-1,0) << endl;
      |     ^~~~
      |     std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:51:31: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   51 |     cout << total(0,n-1,0) << endl;
      |                               ^~~~
      |                               std::endl
In file included from /usr/include/c++/14/istream:41,
                 from /usr/include/c++/14/sstream:40,
                 from /usr/include/c++/14/complex:45,
                 from /usr/include/c++/14/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:127:
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~