Language: C++

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

# define ll long long
# define pll pair<ll,ll>
# define F first
# define S second
# define pb push_back
# define ld long double
# define vll vector<ll>
# define vvll vector<vector<ll>>
# define vpll vector<pll>
# define ppll pair<pll,ll>
ll M=1000000007;
ll MAX=LONG_LONG_MAX;
template<typename T>
//using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}
ll func(int i,int j,int b,vvll &dp,vll &v)
{
   if(i==j){ 
      if(b==1)
   return v[i];
   else
   return 0;}
   if(dp[i][j]!=-1)
   return dp[i][j];
   if(b==1)
   {
      return dp[i][j]=max(func(i+1,j,2,dp,v)+v[i],func(i,j-1,2,dp,v)+v[j]);
   }
   else
   {
       return dp[i][j]=min(func(i+1,j,1,dp,v),func(i,j-1,1,dp,v));
   }
   

}
int main()
{
   int n;
   cin>>n;
   ll c=0;
   vvll dp(n,vll(n,-1));
   vll v(n);
   for(int i=0;i<n;i++){
    cin>>v[i]; c+=v[i];}
    cout<<2*func(0,n-1,1,dp,v)-c;

}#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 

using namespace std;
using namespace __gnu_pbds; 

# define ll long long
# define pll pair<ll,ll>
# define F first
# define S second
# define pb push_back
# define ld long double
# define vll vector<ll>
# define vvll vector<vector<ll>>
# define vpll vector<pll>
# define ppll pair<pll,ll>
ll M=1000000007;
ll MAX=LONG_LONG_MAX;
template<typename T>
//using ordered_set=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll power(ll a,ll m,ll mod){
	ll ans=1;
	while(m){
		if(m%2){
			ans*=a;
			ans%=(mod);
		}
		a=(a*a)%(mod);
		m>>=1;
	}
	return ans;
}
ll func(int i,int j,int b,vvll &dp,vll &v)
{
   if(i==j){ 
      if(b==1)
   return v[i];
   else
   return 0;}
   if(dp[i][j]!=-1)
   return dp[i][j];
   if(b==1)
   {
      return dp[i][j]=max(func(i+1,j,2,dp,v)+v[i],func(i,j-1,2,dp,v)+v[j]);
   }
   else
   {
       return dp[i][j]=min(func(i+1,j,1,dp,v),func(i,j-1,1,dp,v));
   }
   

}
int main()
{
   int n;
   cin>>n;
   ll c=0;
   vvll dp(n,vll(n,-1));
   vll v(n);
   for(int i=0;i<n;i++){
    cin>>v[i]; c+=v[i];}
    cout<<2*func(0,n-1,1,dp,v)-c;

}

Compiler output:
a.cc:65:2: error: stray '#' in program
   65 | }#include <bits/stdc++.h>
      |  ^
a.cc:65:3: error: 'include' does not name a type
   65 | }#include <bits/stdc++.h>
      |   ^~~~~~~
a.cc:82:4: error: redefinition of 'long long int M'
   82 | ll M=1000000007;
      |    ^
a.cc:18:4: note: 'long long int M' previously defined here
   18 | ll M=1000000007;
      |    ^
a.cc:83:4: error: redefinition of 'long long int MAX'
   83 | ll MAX=LONG_LONG_MAX;
      |    ^~~
a.cc:19:4: note: 'long long int MAX' previously defined here
   19 | ll MAX=LONG_LONG_MAX;
      |    ^~~
a.cc:86:4: error: redefinition of 'template<class T> long long int power(long long int, long long int, long long int)'
   86 | ll power(ll a,ll m,ll mod){
      |    ^~~~~
a.cc:22:4: note: 'template<class T> long long int power(long long int, long long int, long long int)' previously declared here
   22 | ll power(ll a,ll m,ll mod){
      |    ^~~~~
a.cc:98:4: error: redefinition of 'long long int func(int, int, int, std::vector<std::vector<long long int> >&, std::vector<long long int>&)'
   98 | ll func(int i,int j,int b,vvll &dp,vll &v)
      |    ^~~~
a.cc:34:4: note: 'long long int func(int, int, int, std::vector<std::vector<long long int> >&, std::vector<long long int>&)' previously defined here
   34 | ll func(int i,int j,int b,vvll &dp,vll &v)
      |    ^~~~
a.cc:118:5: error: redefinition of 'int main()'
  118 | int main()
      |     ^~~~
a.cc:54:5: note: 'int main()' previously defined here
   54 | int main()
      |     ^~~~