criyle/codenet-compile-errors huggingface dataset:
Language: Java

import java.util.*;
import java.util.function.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++)
      a[i] = sc.nextInt();
    sc.close();

    long ans = 0;
    List<Long> list = Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors.toList());
    while (1 < list.size()) {
      long min = Long.MAX_VALUE;
      int idx = 0;
      for (int i = 1; i < list.size(); i++) {
        long s = list.get(i - 1) + list.get(i);
        if (s < min) {
          min = s;
          idx = i;
        }
      }
      list.remove(idx);
      list.set(idx - 1, min);
      ans += min;
    }
    System.out.println(ans);
  }
}


Compiler output:
Main.java:14: error: cannot find symbol
    List<Long> list = Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors.toList());
                                                                       ^
  symbol:   variable Collectors
  location: class Main
1 error
Language: Java

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++)
      a[i] = sc.nextInt();
    sc.close();

    long ans = 0;
    List<Long> list = Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors.toList());
    while (1 < list.size()) {
      long min = Long.MAX_VALUE;
      int idx = 0;
      for (int i = 1; i < list.size(); i++) {
        long s = list.get(i - 1) + list.get(i);
        if (s < min) {
          min = s;
          idx = i;
        }
      }
      list.remove(idx);
      list.set(idx - 1, min);
      ans += min;
    }
    System.out.println(ans);
  }
}


Compiler output:
Main.java:13: error: cannot find symbol
    List<Long> list = Arrays.stream(a).mapToObj(Long::valueOf).collect(Collectors.toList());
                                                                       ^
  symbol:   variable Collectors
  location: class Main
1 error
Language: C++

#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
#define speed                   \
  ios_base::sync_with_stdio(0); \
  cin.tie(0);                   \
  cout.tie(0);
#define oprecision    \
  cout.precision(30); \
  cerr.precision(7);
#define bb bool
#define ii int
#define ll long long
#define ff float
#define dd double
#define cc char
#define ss string
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(i, sz) for (int i = 1; i <= sz; i++)
#define fornid(i, m, sz) for (int i = m; i <= sz; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vii vector<ii>
#define vii64 vector<ll>
#define vb vector<bb>
#define F first
#define S second
#define int ll
using namespace std;
const int inf = 1000000000000000000;
int n, a[500], p[500], dp[500][500];
int rec(int l, int r) {
  if (l == r) return a[l];
  if (dp[l][r] != -1) return dp[l][r];
  int ans = inf;
  for (int i = l; i < r; i++) ans = min(rec(l, i) + rec(i + 1, r), ans);
  return dp[l][r] = ans + p[r] - p[l - 1];
}
int main() {
  speed;
  oprecision;
  // code
  memset(dp, -1, sizeof dp);
  cin >> n;
  forn(n) cin >> a[i], p[i] = p[i - 1] + a[i];
  cout << rec(1, n) - p[n];
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Compiler output:
cc1plus: error: '::main' must return 'int'
Language: C++

#include<iostream>
#include<vector>
using namespace std;
vector<long long> V;
long long Ans;
int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
  {
    long long X;
    cin>>X;
    V.push_back(X);
  }
  while(N>1)
  {
    N--;
    int p;
    long long a=20000000000000ll;
    for(int i=0;i<N;i++)
      if(V[i]+V[i+1]<a)
      {
        a=V[i]+V[i+1];
        p=i;
      }
    Ans+=V[p]+V[p+1];
    V[p]+=V[p+1];
    V[p+1]=999999999999999999
  }
  cout<<Ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:29:30: error: expected ';' before '}' token
   29 |     V[p+1]=999999999999999999
      |                              ^
      |                              ;
   30 |   }
      |   ~
Language: C++

#include<iostream>
#include<vector>
using namespace std;
vector<int> V;
long long Ans;
int main()
{
  int N;
  cin>>N;
  for(int i=0;i<N;i++)
  {
    int X;
    cin>>X;
    V.push_back(X);
  }
  while(--N)
  {
    int p,a=2000000000;
    for(int i=0;i<N;i++)
      if(V[i]+V[i+1]<a)
        a=V[i]+V[i+1],
        p=i;
    Ans+=V[i]+V[i+1];
    V[i]+=V[i+1];
    V.erase(V.begin()+i+1);
  }
  cout<<Ans<<endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:12: error: 'i' was not declared in this scope
   23 |     Ans+=V[i]+V[i+1];
      |            ^
Language: C++

#include<iostram>
using namespace std;

long long const inf = 1e18;
int const mxn = 4e3+10;

 
 
long long l[mxn],par[mxn],dp[mxn][mxn];


int main(){
	int n;
	cin>>n;
	for (int i = 1;i<=n;i++)
		cin>>l[i];
	par[1]=l[1];
	for (int i = 1;i<=n;i++)
		par[i] = par[i-1] + l[i];
		
	for (int i =0;i<mxn;i++)
		for (int j =0;j<mxn;j++)	
			dp[i][j]=1e18;
			
	for (int i = 1;i<=n;i++)
		dp[i][i]=0;
		
		
		
		
	for (int t = 1;t<=n;t++){
		
		for (long long  i =1 ;i+t<=n;i++){
			
			long long  k  = i + t;
			
			for (long long  j = i;j<=k;j++){
				
				dp[i][k] = min(dp[i][k], dp[i][j]+dp[j+1][k]+par[k]-par[i-1]);
				
			}
		}
	}
	cout<<dp[1][n];
	return 0;
}

Compiler output:
a.cc:1:9: fatal error: iostram: No such file or directory
    1 | #include<iostram>
      |         ^~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n,num,sum;
    cin>>n;
    ll dp[n+1][n+1],a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,0,sizeof(dp));
    for(int i=1;i<n;i++){
        for(int j=0;j<n-i;j++){
            num=1e18;
            sum=0;
            for(k=j;k<j+1;k++){
                num=min(num,dp[j][k]+dp[k+1][j+i]);
                sum+=a[k];
            }
            sum+=a[j+i];
            dp[j][j+i]=num+sum;
        }
    }
    cout << (solve(0,n-1))<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:22:17: error: 'k' was not declared in this scope
   22 |             for(k=j;k<j+1;k++){
      |                 ^
a.cc:30:14: error: 'solve' was not declared in this scope
   30 |     cout << (solve(0,n-1))<<endl;
      |              ^~~~~
Language: C++

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
	    Scanner sc = new Scanner(System.in);
	    int N = sc.nextInt();
	    long[] as = new long[N+1];
        long[][] dp = new long[N+1][N+1];
	    long[] prefixSum = new long[N+1];

	    for(int i=1; i<=N; ++i) {
	        as[i] = sc.nextLong();
	        prefixSum[i] = prefixSum[i-1] + as[i];
        }

        for(int ij_d=1; ij_d<=N; ++ij_d) {
            for(int i=1; i+ij_d<=N; ++i) {
                int j = i+ij_d;
                dp[i][j] = Long.MAX_VALUE;

                for(int k=i; k<j; ++k) {
                    dp[i][j] = Math.min(dp[i][j], dp[i][k] + dp[k+1][j] + (prefixSum[j] - prefixSum[i-1]));
                }
            }
        }

	    System.out.println(dp[1][N]);
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.util.Scanner;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)

using namespace std;

typedef long long ll;
const int inf = INT_MAX / 2;
const ll infl = 1LL << 60;
const ll mod = 1e9+7;

template<typename T> ostream& operator << (ostream& os, vector<T> v) {
  for (auto& i : v) os << i << " "; return os; 
}
template<typename T> istream& operator >> (istream& is, vector<T>& v) {
  for (auto& i : v) is >> i; return is;
}
template<typename K, typename V> ostream& operator << (ostream& os, unordered_map<K, V> m) {
  for (auto& i : m) os << i.first << ":" << i.second << endl; return os;
}
template<typename T> inline bool chmin(T& x, T y) {
  if (x > y) {
    x = y;
    return true;
  }
  return false;
}
template<typename T> inline bool chmax(T& x, T y) {
  if (x < y) {
    x = y;
    return true;
  }
  return false;
}

int N;
ll A[401];

ll B[404];
void init() {
    B[0] = A[0];
    rep(i, 1, N) B[i] = B[i - 1] + A[i];
}
ll get(int L, int R) {
    ll res = B[R];
    if (L) res -= B[L - 1];
    return res;
}

ll memo[404][404];
int vis[404][404];
ll dp(int L, int R) {
    if (L == R) return 0;
    if (vis[L][R]) return memo[L][R];
    vis[L][R] = 1;
 
    ll res = infl;
    rep(c, L, R) chmin(res, dp(L, c) + dp(c + 1, R) + get(L, R));
    return memo[L][R] = res;
}

void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    init();
    cout << dp(0, N - 1) << endl;
}


Compiler output:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x17): undefined reference to `main'
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<fstream>
using namespace std;
int n;
long long dp[100005][100005];
long long slimes[1000005];
long long p[1000005];
void init()
{
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            dp[i][j] = 100000006;
    //for(int i = 0; i <= n; i++)
      //  slimes[i] = 0;
}
void prelucrare();
void read()
{
    cin >> n;
    init();
    for(int i = 1; i <= n; i++)
    {
        dp[i][i] = 0;
        cin >> slimes[i];
        p[i] = p[i-1] + slimes[i];

    }
    prelucrare();
}
void prelucrare()
{
    for(int i = 1; i+ 1 <= n ; i++)
        for(int j = 1; i + j  <= n; j++)
        {
            int x = i + j;
            for(int k = j; k < x; k++)
            {
                if(dp[j][x] > dp[j][k] + dp[k + 1][x] + p[x] - p[j - 1])
                    dp[j][x] = dp[j][k] + dp[k + 1][x] + p[x] - p[j - 1];
            }
        }
}
void show()
{
    cout << dp[1][n];
}
int main()
{
read();
show();
}

Compiler output:
/tmp/ccyLm6yn.o: in function `read()':
a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `slimes' defined in .bss section in /tmp/ccyLm6yn.o
a.cc:(.text+0xed): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccyLm6yn.o
a.cc:(.text+0x105): relocation truncated to fit: R_X86_64_PC32 against symbol `slimes' defined in .bss section in /tmp/ccyLm6yn.o
a.cc:(.text+0x121): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccyLm6yn.o
/tmp/ccyLm6yn.o: in function `prelucrare()':
a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccyLm6yn.o
a.cc:(.text+0x223): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccyLm6yn.o
a.cc:(.text+0x2a1): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccyLm6yn.o
a.cc:(.text+0x2bf): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/ccyLm6yn.o
collect2: error: ld returned 1 exit status
Language: C++

#include<iostream>
#include<fstream>
using namespace std;
int n;
long long dp[1000005][1000005];
long long slimes[1000005];
long long p[1000005];
void init()
{
    for(int i = 0; i <= n; i++)
        for(int j = 0; j <= n; j++)
            dp[i][j] = 100000006;
    //for(int i = 0; i <= n; i++)
      //  slimes[i] = 0;
}
void prelucrare();
void read()
{
    cin >> n;
    init();
    for(int i = 1; i <= n; i++)
    {
        dp[i][i] = 0;
        cin >> slimes[i];
        p[i] = p[i-1] + slimes[i];

    }
    prelucrare();
}
void prelucrare()
{
    for(int i = 1; i+ 1 <= n ; i++)
        for(int j = 1; i + j  <= n; j++)
        {
            int x = i + j;
            for(int k = j; k < x; k++)
            {
                if(dp[j][x] > dp[j][k] + dp[k + 1][x] + p[x] - p[j - 1])
                    dp[j][x] = dp[j][k] + dp[k + 1][x] + p[x] - p[j - 1];
            }
        }
}
void show()
{
    cout << dp[1][n];
}
int main()
{
read();
show();
}

Compiler output:
/tmp/cct7bZUM.o: in function `read()':
a.cc:(.text+0xc1): relocation truncated to fit: R_X86_64_PC32 against symbol `slimes' defined in .bss section in /tmp/cct7bZUM.o
a.cc:(.text+0xed): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cct7bZUM.o
a.cc:(.text+0x105): relocation truncated to fit: R_X86_64_PC32 against symbol `slimes' defined in .bss section in /tmp/cct7bZUM.o
a.cc:(.text+0x121): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cct7bZUM.o
/tmp/cct7bZUM.o: in function `prelucrare()':
a.cc:(.text+0x205): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cct7bZUM.o
a.cc:(.text+0x223): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cct7bZUM.o
a.cc:(.text+0x2a1): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cct7bZUM.o
a.cc:(.text+0x2bf): relocation truncated to fit: R_X86_64_PC32 against symbol `p' defined in .bss section in /tmp/cct7bZUM.o
collect2: error: ld returned 1 exit status
Language: C++

        #include <bits/stdc++.h>
         
        using namespace std;
        using ull = unsigned long long;
         
        const int MAX_N = 400;
        const ull MAX_VAL = numeric_limits<ull>::max();
        ull costs[MAX_N + 1][MAX_N + 1];
        ull sums[MAX_N + 1][MAX_N + 1];
        ull inp[MAX_N + 1];
         
        int main() {
        	ios_base::sync_with_stdio(false);
        	int N; cin >> N;
        	for (int i = 0; i <= MAX_N; i++) {
        		for (int j = 0; j <= MAX_N; j++) {
        			costs[i][j] = MAX_VAL;
        		}
        	}
        	for (int i = 1; i <= N; i++) {
        		cin >> inp[i];
        		costs[i][i] = 0;
        	}
         
        	for (int i = 1; i <= N; i++) {
        		sums[i][i] = inp[i];
        		for (int j = i + 1; j <= N; j++) {
        			sums[i][j] = inp[j] + sums[i][j - 1];
        		}
        	}
        	
        	for (int L = 1; L <= N; L++) {
        		for (int start = 1; start + L <= N; start++) {
        			for (int div = 0; div + 1 <= L; div++) {
        				costs[start][start + L] = min(costs[start][start + L], costs[start][start + div] + costs[start + div + 1][start + L]);
        			}
                  	costs[start][start + L) +=  sums[start][start + L];
        		}
        	}
        	cout << costs[1][N] << endl;
        	return 0;
        }

Compiler output:
a.cc: In function 'int main()':
a.cc:37:47: error: expected ']' before ')' token
   37 |                         costs[start][start + L) +=  sums[start][start + L];
      |                                               ^
      |                                               ]
a.cc:37:47: error: expected ';' before ')' token
   37 |                         costs[start][start + L) +=  sums[start][start + L];
      |                                               ^
      |                                               ;
Language: C++

#include <iostream>
#include <fstream>
#include <map>
#include <vector>

#define NMAX 502
#define MOD 1000000007
#define f cin


using namespace std;

//ifstream f("text3.in");
//ofstream g("text3.out");

long long int dp[NMAX][NMAX];

long long int n;
long long int v[NMAX], l[NMAX];

long long int get_sum(long long int st, long long int dr) {

    if (st == 0) {
        return l[dr];
    }
    return l[dr] - l[st - 1];

}

int main() {
    f >> n;
    for (long long int i = 0; i < n; ++i) {
        f >> v[i];
        if (i == 0) l[i] = v[i];
        else l[i] = (l[i - 1] + v[i]);
    }

    for (long long int dist = 1; dist < n; ++dist) {
        for (int i = 0; i + dist < n; ++i) {
            long long int vmin = 1e17;
            for (long long int k = i; k < i + dist; ++k) {
                vmin = min(vmin, dp[i][k] + dp[k + 1][i + dist] + get_sum(i, k) + get_sum(k + 1, i + dist) );
            }
            dp[i][i + dist] = vmin;
        }
    }

    g << dp[0][n - 1];

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:48:5: error: 'g' was not declared in this scope
   48 |     g << dp[0][n - 1];
      |     ^
Language: C++

#include <iostream>
#include <fstream>
#include <bits/stdc++.h>
#include <map>
#define pb push_back
#define ll long long
using namespace std;
int n;
ll a[410];
ll dp[410][410]
int main()
{
    ifstream fin("z.in");
    ofstream fout("z.out");
    cin>>n;
    int i,j;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=n;i++)
    {
        dp[1][i]=a[i];
    }
    for(i=2;i<=n;i++)
        for(j=i;j<=n;j++){
        if(j!=n)
        {
            dp[i][j]=min(dp[i-1][j-1]+dp[i-1][j],dp[i-1][j]+dp[i]);
        }
        else
        {
            dp[i][j]=dp[i-1][j-1]+dp[i-1][j];
        }
    }
    cout<<dp[n][n];
    fin.close();
    fout.close();
    return 0;
}


Compiler output:
a.cc:11:1: error: expected initializer before 'int'
   11 | int main()
      | ^~~
Language: C++

#include<iostream>
#include<bits/stdc++.h>
#define db(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,n) for(int i=0;i<(n);++i)
#define fr(i,a,n) for(int i=a;i<=(n);++i)
#define rf(i,a,n) for(int i=a;i>=(n);--i)
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define F first
#define S second
#define pb push_back
#define pf push_front
#define mp make_pair
#define pll pair<ll,ll>
#define _ <<" "<<
using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int,int> ii;
typedef pair<int,pair<int,int>> iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

vector<bool> vis;
vvi dp;

ll stones(vi a, int i, int j){
	if(i>=j)
		return 0;
	if(i+1==j)
		return a[i]+a[j];
	ll minval=LLONG_MAX;
	db2(i,j);
	for(int k=i;k<j;k++){
		minval=min(minval,stones(a,i,k)+a[k]+a[k+1]+stones(a,k+1,j));
	}
	db(minval);
	return minval;
}
 
int main(){eopen("test.txt","r",stdin);
	#endif
  	int n;
  	cin>>n;
  	vi a(n),sum(n,0);
  	for(int i=0;i<n;i++){
  		cin>>a[i];
  		if(i>0)
  			sum[i]=a[i]+sum[i-1];
  		else
  			sum[i]=a[i];
  	}
  	// cout<<stones(a,0,n-1);
  	dp.resize(n,vi(n,INT_MAX));
  	for(int gap=0;gap<n;gap++){
  		for(int i=0,j=i+gap;j<n;j++,i++){
  			if(i==j){
  				dp[i][j]=0;
  				// cout<<dp[i][j]<<endl;
  				continue;
  			}
  			for(int k=i;k<j;k++){
  				// db3(i,k,j);
  				// db2(dp[i][k],dp[k+1][i]);
  				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]);
  			}
  			// db(sum[j]);
  			dp[i][j]+=sum[j];
  			if(i>0)
  				dp[i][j]-=sum[i-1];
  			// cout<<dp[i][j]<<endl;
  		}
  		// cout<<endl;B
  	}
  	cout<<dp[0][n-1]<<endl;
  	return 0;
}



Compiler output:
a.cc:47:10: error: #endif without #if
   47 |         #endif
      |          ^~~~~
a.cc: In function 'int main()':
a.cc:46:12: error: 'eopen' was not declared in this scope; did you mean 'popen'?
   46 | int main(){eopen("test.txt","r",stdin);
      |            ^~~~~
      |            popen
Language: C++

#include <iostream>
#include <vector>

using namespace std;

long long int dp(int x, vector<long long int> arr){
    return arr[x] + arr[x + 1];
}

int main()
{
    int n;
    cin >> n;
    vector<long long int> arr;

    /*for (int i = 0; i < n; i++){
        arr.push_back(1000000000);
    }*/

    for (int i = 0; i < n; i++){
        long long int temp;
        cin >> temp;
        arr.push_back(temp);

    n--;
    unsigned long long int cost = 0;
    for (int j = 0; j < n; j++){
        int x = 0;
        for (int i = 0; i < arr.size() - 1; i++){
            if (dp(x, arr) > dp (i, arr))
                x = i;
        }
        arr[x] = arr[x] + arr [x + 1];
        cost += arr[x];
        arr.erase(arr.begin() + x + 1);
    }
    cout << cost;
    return false;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:39:2: error: expected '}' at end of input
   39 | }
      |  ^
a.cc:11:1: note: to match this '{'
   11 | {
      | ^
Language: C++

#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int a[n];
    for (int i = 0; i < n; i++)
        cin >> a[i];
    long long b[n][n];
    long long suma[n];
    suma[0] = a[0];
    for (int i = 1; i < n; i++) {
        suma[i] = suma[i - 1] + a[i];
    }
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++) {
            if (i == 0) {
                b[j][j] = 0;
                continue;
            }
            long long min1 = LONG_LONG_MAX;
            for (int k = 0; k < i; k++) {
                long long x = b[j][j + k] + b[j + k + 1][j + i] + suma[j + i] - (j == 0? 0:suma[j - 1]);
                if (x < min1)
                    min1 = x;
            }
            b[j][j + i] = min1;
        }
    cout << b[0][n - 1];
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:30: error: 'LONG_LONG_MAX' was not declared in this scope
   23 |             long long min1 = LONG_LONG_MAX;
      |                              ^~~~~~~~~~~~~
Language: C++

int N; ll A[401];
//---------------------------------------------------------------------------------------------------
ll B[404];
void init() {
    B[0] = A[0];
    rep(i, 1, N) B[i] = B[i - 1] + A[i];
}
ll get(int L, int R) {
    ll res = B[R];
    if (L) res -= B[L - 1];
    return res;
}
//---------------------------------------------------------------------------------------------------
ll memo[404][404];
int vis[404][404];
ll dp(int L, int R) {
    if (L == R) return 0;
    if (vis[L][R]) return memo[L][R];
    vis[L][R] = 1;
 
    ll res = infl;
    rep(c, L, R) chmin(res, dp(L, c) + dp(c + 1, R) + get(L, R));
    return memo[L][R] = res;
}
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) cin >> A[i];
    init();
    cout << dp(0, N - 1) << endl;
}

Compiler output:
a.cc:1:8: error: 'll' does not name a type
    1 | int N; ll A[401];
      |        ^~
a.cc:3:1: error: 'll' does not name a type
    3 | ll B[404];
      | ^~
a.cc: In function 'void init()':
a.cc:5:5: error: 'B' was not declared in this scope
    5 |     B[0] = A[0];
      |     ^
a.cc:5:12: error: 'A' was not declared in this scope
    5 |     B[0] = A[0];
      |            ^
a.cc:6:9: error: 'i' was not declared in this scope
    6 |     rep(i, 1, N) B[i] = B[i - 1] + A[i];
      |         ^
a.cc:6:5: error: 'rep' was not declared in this scope
    6 |     rep(i, 1, N) B[i] = B[i - 1] + A[i];
      |     ^~~
a.cc: At global scope:
a.cc:8:1: error: 'll' does not name a type
    8 | ll get(int L, int R) {
      | ^~
a.cc:14:1: error: 'll' does not name a type
   14 | ll memo[404][404];
      | ^~
a.cc:16:1: error: 'll' does not name a type
   16 | ll dp(int L, int R) {
      | ^~
a.cc: In function 'void _main()':
a.cc:27:5: error: 'cin' was not declared in this scope
   27 |     cin >> N;
      |     ^~~
a.cc:28:9: error: 'i' was not declared in this scope
   28 |     rep(i, 0, N) cin >> A[i];
      |         ^
a.cc:28:5: error: 'rep' was not declared in this scope
   28 |     rep(i, 0, N) cin >> A[i];
      |     ^~~
a.cc:30:5: error: 'cout' was not declared in this scope
   30 |     cout << dp(0, N - 1) << endl;
      |     ^~~~
a.cc:30:13: error: 'dp' was not declared in this scope
   30 |     cout << dp(0, N - 1) << endl;
      |             ^~
a.cc:30:29: error: 'endl' was not declared in this scope
   30 |     cout << dp(0, N - 1) << endl;
      |                             ^~~~
Language: C++

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

#define ll long long int
const int mod = 1e9+7;
int a[407];
ll dp[401][401];
ll sum[401];
int main(){
  int n;
  cin>>n;
  memset(sum,0,sizeof(sum));
  for(int i=0;i<n;i++){
    cin>>a[i];
    sum[i+1]=sum[i]+a[i];
  }
  memset(dp,0,sizeof(dp));
  //vector<vector<pair<int,int>>> dp(401, vector<pair<int,int>>(401))
  for(int i=n-1;i>=0;i--){
    for(int j=i;j<n;j++){
      if(i==j){
        dp[i][j]=0;
        continue;
      }
      else{
        dp[i][j]=INT_MAX;
        for(int k=i;k<j;k++){
          dp[i][j] = min(dp[i][j]%mod,(dp[i][k]%mod+dp[k+1][j]%mod+sum[j+1]%mod-sum[i]%mod+mod)%mod;
        }
      }
    }
  }
  cout<<dp[0][n-1]%mod<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:28:100: error: expected ')' before ';' token
   28 |           dp[i][j] = min(dp[i][j]%mod,(dp[i][k]%mod+dp[k+1][j]%mod+sum[j+1]%mod-sum[i]%mod+mod)%mod;
      |                         ~                                                                          ^
      |                                                                                                    )
Language: C++

#include<iostream>


//matrix chain multiplication

int main (){
	long long n,temp;
	cin>>n;

	long long a[n],dp[n][n],sum[n][n];

	memset(dp,0,sizeof(dp));
	memset(sum,0,sizeof(sum));

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

	for(long long i=0;i<n-1;i++){
		dp[i][i] = 0;
		dp[i][i+1] = a[i]+a[i+1];
	}
	dp[n-1][n-1] = 0;

	for(long long i=0;i<n;i++){
		sum[i][i] = a[i];
		for(long long j=i+1;j<n;j++){
			sum[i][j] = sum[i][j-1]+a[j];
		}
	}

	for(long long i=2;i<n;i++){
		for(long long j=0;j+i<n;j++){
			temp = 999999999999999; 
			for(long long k=0;k<i;k++){
				temp = min(temp,dp[j][j+k] + dp[j+k+1][j+i]);
			}
			dp[j][j+i] = temp+sum[j][j+i];
		}
	}

	cout<<dp[0][n-1]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |         cin>>n;
      |         ^~~
      |         std::cin
In file included from a.cc:1:
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:12:9: error: 'memset' was not declared in this scope
   12 |         memset(dp,0,sizeof(dp));
      |         ^~~~~~
a.cc:2:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    1 | #include<iostream>
  +++ |+#include <cstring>
    2 | 
a.cc:36:40: error: 'min' was not declared in this scope; did you mean 'std::min'?
   36 |                                 temp = min(temp,dp[j][j+k] + dp[j+k+1][j+i]);
      |                                        ^~~
      |                                        std::min
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41:
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: 'std::min' declared here
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
a.cc:42:9: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   42 |         cout<<dp[0][n-1]<<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:42:27: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   42 |         cout<<dp[0][n-1]<<endl;
      |                           ^~~~
      |                           std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
Language: C++

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

#define ll long long int
const ll INF = 0xFFFFFFFFFFFFFFFL;

ll dp[402][402]={-1},n,ar[402],pr[402];

ll solve(int i,int j){
    if(dp[i][j]!=-1)
        return dp[i][j];
    else if(i==j)
        return dp[i][j]=0;
    ll var = INF;
    for(int k=i;k<j;k++){
        var=min(var,solve(i,k)+solve(k+1,j)+pr[j]-pr[i-1]);
    }
    return dp[i][j]=var;
}

int main(){
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>ar[i];
    for(int i=0;i<=n;i++)
        pr[i]=pr[i-1]+ar[i];
    cout<<solve(1,n)<<"\n";

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:23:9: error: 'i' was not declared in this scope
   23 |     for(i=1;i<=n;i++)
      |         ^
Language: C++

#include <iostream>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <map>
using namespace std;
#define mod (1000000007)
#define ll long long int

int N;
vector<ll> aa;
vector<ll> raa;
vector<vector<ll>> dp;

ll calc(int l, int r){
  if(r-l <= 0){
    return 0;
  }else if(r-l == 1){
    return aa[l]+aa[r];
  }else{
    if(dp[l][r] != -1){
      return dp[l][r];
    }else{
      ll tmp = LLONG_MAX;
      for (int s = l; s < r; s++) {
        tmp = min(calc(l,s)+calc(s+1,r)+raa[r+1]-raa[l],tmp);
      }
      dp[l][r] = tmp;
      return tmp;
    }
  }
}


int main(void){
  cin >> N;
  ll tmp = 0;

  aa.assign(N,0);
  raa.assign(N+1,0);
  dp.assign(N,vector<ll>(N,-1));
  for (size_t i = 0; i < N; i++){
    cin >> aa[i];
    tmp += aa[i];
    raa[i+1] = tmp;
  }

  cout << calc(0,N-1) << endl;

}


Compiler output:
a.cc: In function 'long long int calc(int, int)':
a.cc:29:16: error: 'LLONG_MAX' was not declared in this scope
   29 |       ll tmp = LLONG_MAX;
      |                ^~~~~~~~~
a.cc:11:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <map>
  +++ |+#include <climits>
   11 | using namespace std;
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define fi first
#define sec second 
#define MOD 1000000007
#define pb push_back
#define endl "\n"
#define test cout<<"debuged\n";
#define INF 10000000000
#define si 1000000
#define pi pair<ll,ll>

 vector<ll> v(500);

ll sum(ll i,ll j)
{
    ll s=0;
    for(ll k=i;k<=j;k++)
        s+=v[k];
    return s;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  
    ll n;
    cin>>n;
    for(ll i=1;i<=n;i++)
        {
            cin>>v[i];
            pre[i]=pre[i-1]+v[i];
        }
    ll dp[n+5][n+5];
    for(ll i=n;i>=1;i--)
        for(ll j=i;j<=n;j++)
        {   
            if(i==j)
            {
                dp[i][j]=0;
                continue;
            }
            for(ll k=i;k<j;k++)
            {
                 dp[i][j]=INF;
                dp[i][j]=min(dp[i][j],(dp[i][k]+dp[k+1][j]+sum(i,j)));
            }
        }
        cout<<dp[1][n];
}

















Compiler output:
a.cc: In function 'int main()':
a.cc:34:13: error: 'pre' was not declared in this scope; did you mean 'pread'?
   34 |             pre[i]=pre[i-1]+v[i];
      |             ^~~
      |             pread
Language: C++

#include<iostream>
#include<vector>
using namespace std;

long long int prefix[500];
int a[500];

long long int sum(int i, int j)
{
  auto sub = i ? prefix[i-1] : 0;
  return prefix[j] - sub;
}


long long int f(int i, int j, vector<vector<long long>>& dp)
{
  auto S = sum(i,j);
  if (i == j)
    return a[i];
  auto& res = dp[i][j];
  if (res != numeric_limits<long long>::max())
    return res;
  for (int k = i; k < j; ++k)
  {
    res = min(res, S + f(i, k, dp) + f(k+1, j, dp));
  }
  return res;
}


int main()
{
  int n, k;
  cin >> n ;
  vector<int> a(n);
  vector<vector<long long>> dp(n, vector<long long>(n,numeric_limits<long long>::max()));
  for (int i = 0; i < n; ++i)
    cin >> a[i];
  prefix[0] = a[0];
  for (int i = 1; i < n; ++i)
    prefix[i] = (prefix[i-1] + a[i]);


  cout << f(0, n-1, dp) <<'\n';


  return 0;
}


Compiler output:
a.cc: In function 'long long int f(int, int, std::vector<std::vector<long long int> >&)':
a.cc:21:14: error: 'numeric_limits' was not declared in this scope
   21 |   if (res != numeric_limits<long long>::max())
      |              ^~~~~~~~~~~~~~
a.cc:21:29: error: expected primary-expression before 'long'
   21 |   if (res != numeric_limits<long long>::max())
      |                             ^~~~
a.cc:21:29: error: expected ')' before 'long'
   21 |   if (res != numeric_limits<long long>::max())
      |      ~                      ^~~~
      |                             )
a.cc: In function 'int main()':
a.cc:36:55: error: 'numeric_limits' was not declared in this scope
   36 |   vector<vector<long long>> dp(n, vector<long long>(n,numeric_limits<long long>::max()));
      |                                                       ^~~~~~~~~~~~~~
a.cc:36:52: error: expected primary-expression before '(' token
   36 |   vector<vector<long long>> dp(n, vector<long long>(n,numeric_limits<long long>::max()));
      |                                                    ^
a.cc:36:70: error: expected primary-expression before 'long'
   36 |   vector<vector<long long>> dp(n, vector<long long>(n,numeric_limits<long long>::max()));
      |                                                                      ^~~~
Language: C++

#include <iostream>
using namespace std;
int a[401];
long long dp[401][401];
long long pref[401];
int main() {
  long long n,l;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  pref[0] = a[0];
  for (int i = 1; i < n; i++) {
      pref[i] = pref[i-1] + a[i];
  }
  for (int len = 1; len <= n; len++) {
    for (l = 0; l < n; l++) {
        int r = l + len - 1;
        if (r == n) break;
        else if (len == 1) dp[l][l] = 0;
        else {
            dp[l][r] = 2e18;
            for (int mid = l; mid < r; mid++) {
                if (l > 0) {
                long long calc = dp[l][mid] + dp[mid+1][r] + pref[r] - pref[l-1];
                dp[l][r] = min(dp[l][r], calc);
                } else {
                    long long calc = dp[l][mid] + dp[mid+1][r] + pref[r];
                    dp[l][r] = min(dp[l][r], calc);
                }
            }
        }
    }
  }
  }
  cout << dp[0][n-1];
  }

Compiler output:
a.cc:36:3: error: 'cout' does not name a type
   36 |   cout << dp[0][n-1];
      |   ^~~~
a.cc:37:3: error: expected declaration before '}' token
   37 |   }
      |   ^
Language: C++

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

#define pb push_back
#define pa pair<long long,long long>
#define Mod 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    long long n;
    cin>>n;
    long long A[n],sum=0,B[n];
    for(i=0;i<n;i++)
    {
        cin>>A[i];
        sum+=A[i];
        B[i]=sum;
    }

    long long dp[n][n];
    for(i=0;i<n;i++)
        dp[i][i]=0;

    for(i=0;i<n-1;i++)
        dp[i][i+1]=A[i]+A[i+1];

    for(gap=3;gap<=n;gap++)
    {
        for(i=0;i<n-gap+1;i++)
        {
            j=i+gap-1;
            dp[i][j]=1e18;
            for(k=i;k<j;k++)
            {
                dp[i][j]=min(dp[i][k]+dp[k+1][j]+B[j]-B[i]+A[i],dp[i][j]);
            }
        }
    }
    cout<<dp[0][n-1]<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:9: error: 'i' was not declared in this scope
   16 |     for(i=0;i<n;i++)
      |         ^
a.cc:24:9: error: 'i' was not declared in this scope
   24 |     for(i=0;i<n;i++)
      |         ^
a.cc:27:9: error: 'i' was not declared in this scope
   27 |     for(i=0;i<n-1;i++)
      |         ^
a.cc:30:9: error: 'gap' was not declared in this scope
   30 |     for(gap=3;gap<=n;gap++)
      |         ^~~
a.cc:32:13: error: 'i' was not declared in this scope
   32 |         for(i=0;i<n-gap+1;i++)
      |             ^
a.cc:34:13: error: 'j' was not declared in this scope
   34 |             j=i+gap-1;
      |             ^
a.cc:36:17: error: 'k' was not declared in this scope
   36 |             for(k=i;k<j;k++)
      |                 ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long a[401],dp[402][402];
long long inf=1000000000000;

int main(){
  long long n,tmp,sum;
  cin >> n;
  for(int i=0;i<n;i++)cin >> a[i];
  for(int i=1;i<=n;i++){
    for(int j=0;j<n-i;j++){
      tmp=inf; sum=0;
      for(int k=j;k<j+1;k++){
        tmp=min(tmp,dp[j][k]+dp[k+1][j+1]);
        sum+=a[k];
      }
      sum+=a[j+1];
      dp[j][j+1]=tmp+sum;
    }
  }
  cout << dp[0][n-1] << endl;

Compiler output:
a.cc: In function 'int main()':
a.cc:21:30: error: expected '}' at end of input
   21 |   cout << dp[0][n-1] << endl;
      |                              ^
a.cc:6:11: note: to match this '{'
    6 | int main(){
      |           ^
Language: C++

#include <vector>
#include <algorithm>
using namespace std;
using ll = long long int;
const int MAX_N = 400;
vector<ll> a(MAX_N);
vector<ll> a_sum(MAX_N+1, 0);
vector<vector<ll>> memo(MAX_N, vector<ll>(MAX_N, -1));

// Get minimum cost in [l,r)
ll dfs(int l, int r){
    if(memo[l][r] != -1){return memo[l][r];}
    if(r-l <= 1){return 0;}
    ll ret = 1e12;
    for(int i=l+1; i<r; i++){
        ll val = 0;
        val += dfs(l, i);
        val += dfs(i, r);
        ret = min(val, ret);
    }
    ret += a_sum[r] - a_sum[l];
    memo[l][r] = ret;
    return ret;
}

int main(){
    int n; cin >> n;
    for(int i=0; i<n; i++){
        cin >> a[i];
        a_sum[i+1] = a_sum[i] + a[i];
    }
    cout << dfs(0, n) << "\n";
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:12: error: 'cin' was not declared in this scope
   27 |     int n; cin >> n;
      |            ^~~
a.cc:3:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    2 | #include <algorithm>
  +++ |+#include <iostream>
    3 | using namespace std;
a.cc:32:5: error: 'cout' was not declared in this scope
   32 |     cout << dfs(0, n) << "\n";
      |     ^~~~
a.cc:32:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
Language: C++

#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
main()
{
	int n;
	cin>>n;
	
	vector<long long> v(n);
	
	for(int i=0;i<n;i++)
	cin>>v[i];
	
	long long ans=0;
	
	for(int i=n-1;i>0;i--)
	{
		long long hi=1e15,pos;
		
		for(int j=0;j<i;j++)
		{
			if(v[j]+v[j+1]<hi)
			{
				hi=v[j]+v[j+1];
				pos=j;
			}
		}
		
		v[pos]=hi;
		
		for(int j=pos+1;j<i;j++)
		{
			v[j]=v[j+1];
		}
		
		ans+=hi;
	}
	
	cout<<ans;
}#include<bits/stdc++.h>
#define MOD 1000000007
using namespace std;
main()
{
	int n;
	cin>>n;
	
	vector<long long> v(n);
	
	for(int i=0;i<n;i++)
	cin>>v[i];
	
	long long ans=0;
	
	for(int i=n-1;i>0;i--)
	{
		long long hi=1e15,pos;
		
		for(int j=0;j<i;j++)
		{
			if(v[j]+v[j+1]<hi)
			{
				hi=v[j]+v[j+1];
				pos=j;
			}
		}
		
		v[pos]=hi;
		
		for(int j=pos+1;j<i;j++)
		{
			v[j]=v[j+1];
		}
		
		ans+=hi;
	}
	
	cout<<ans;
}

Compiler output:
a.cc:40:2: error: stray '#' in program
   40 | }#include<bits/stdc++.h>
      |  ^
a.cc:4:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    4 | main()
      | ^~~~
a.cc:40:3: error: 'include' does not name a type
   40 | }#include<bits/stdc++.h>
      |   ^~~~~~~
a.cc:43:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   43 | main()
      | ^~~~
a.cc:43:1: error: redefinition of 'int main()'
a.cc:4:1: note: 'int main()' previously defined here
    4 | main()
      | ^~~~
Language: C++

#include <bits/stdc++.h>

#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(obj) obj.begin(), obj.end()

const int iINF = 1e9;
const long long llINF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int N;
long long a[500], acc[500], dp[500][500];

//[l, r)
long long getAcc(int l, int r) {
    if (l == 0) {
        return acc[r - 1];
    } else {
        return acc[r - 1] - acc[l - 1];
    }
}
//[l, r)
long long rec(int l, int r) {
    if (dp[l][r] != -1) {
        return dp[l][r];
    }

    // 1
    if (l == r - 1) {
        return 0;
    }

    long long res = llINF;

　// 2
    for (int mid = l + 1; mid < r; mid++) {
        res = min(res, rec(l, mid) + rec(mid, r) + getAcc(l, r));
    }

    return dp[l][r] = res;
}

int main() {
    cin >> N;
    REP(i, N) {
        cin >> a[i];
        acc[i] = a[i];
    }
    REP(i, N - 1) { acc[i + 1] += acc[i]; }
    fill(dp[0], dp[500], -1);
    cout << rec(0, N) << endl;
}

Compiler output:
a.cc:36:1: error: extended character 　 is not valid in an identifier
   36 | 　// 2
      | ^
a.cc: In function 'long long int rec(int, int)':
a.cc:36:1: error: '\U00003000' was not declared in this scope
   36 | 　// 2
      | ^~
a.cc:37:27: error: 'mid' was not declared in this scope
   37 |     for (int mid = l + 1; mid < r; mid++) {
      |                           ^~~
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

long long dp[405][405];
vector<int> cost;
vector<long long> prefix;

long long pref(int start, int end) {
	if (start <= 0)
		return prefix[end];
	return prefix[end] - prefix[start-1];
}

long long solve(int start, int end) {
	if (dp[start][end] != -1)
		return dp[start][end];
	if (end < start)
		return 0;
	if (end == start + 1)
		return dp[start][end] = (long long)(cost[start] + cost[end]);
	
	long long mini = LLONG_MAX, sum = 0;
	for (int i = start+1; i <= end-1; i++) {
		mini = min(mini, solve(start, i - 1) + solve(i + 1, end) + pref(start, i - 1) + (long long)(2 * cost[i]) + pref(i + 1, end) + min(pref(start, i - 1), pref(i + 1, end)));
	}
	return dp[start][end] = mini;
}

int main() {
	int n;
	cin >> n;
	memset(dp, -1, 405 * 405 * sizeof(long long));
	cost.resize(n);
	prefix.resize(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> cost[i];
		dp[i][i] = 0;
	}
	prefix[0] = cost[0];
	for (int i = 1; i < n; i++) {
		prefix[i] = prefix[i - 1] + (long long)cost[i];
	}
	cout << solve(0, n - 1) << "\n";
	return 0;
}

Compiler output:
a.cc: In function 'long long int solve(int, int)':
a.cc:25:26: error: 'LLONG_MAX' was not declared in this scope
   25 |         long long mini = LLONG_MAX, sum = 0;
      |                          ^~~~~~~~~
a.cc:4:1: note: 'LLONG_MAX' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    3 | #include <algorithm>
  +++ |+#include <climits>
    4 | 
a.cc: In function 'int main()':
a.cc:35:9: error: 'memset' was not declared in this scope
   35 |         memset(dp, -1, 405 * 405 * sizeof(long long));
      |         ^~~~~~
a.cc:4:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    3 | #include <algorithm>
  +++ |+#include <cstring>
    4 |
Language: C++

#include<bits/stdc++.h>
using namespace std;
long long int dp[413][413];
int main()
{
	long long int n,i,l,j,k;
	unsigned long long int s; 
	cin>>n;
	long long int a[n+10];
	for(i=0;i<n;i++)
	{
		cin>>a[i];
	}
	long long int sum[n+10]={0};
//	sum[0]=0;
	for(i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i-1];
	}
	//long long int dp[n+10][n+10];
	
	unsigned long long int p=1000000000000000013;
	for(l=2;l<=n;l++)
	{
		for(i=1;i<=n-l+1;i++)
		{
			j=i+l-1;
			dp[i][j]=p;
			s=sum[j]-sum[i-1];
			for(k=i;k<j;k++)
			{
				dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
			}
		}
	}
	cout<<dp[1][n]<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:32:45: error: no matching function for call to 'min(long long int&, long long unsigned int)'
   32 |                                 dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:32:45: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'long long unsigned int')
   32 |                                 dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:32:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   32 |                                 dp[i][j]=min(dp[i][j],dp[i][k]+dp[k+1][j]+s);
      |                                          ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Language: C++

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

bool dp[100000+10];
int main(){
  ll n;
  cin >> n;
  VLL a(n);
  rep(i,n) cin >> a[i];

  ll dp[n+10][n+10] = {0};

  for(int i = n-1; i >= 0; i--){
    rep(int j = i; j < n; j++){
      if(((n-1 - i) - j) % 2 == 0){
        //太郎’s turn
        dp[i][j] = max(dp[i+1][j]+a[i],dp[i][j-1]+a[j]);
      }else{
        //次郎’s turn
        dp[i][j] = min(dp[i+1][j]-a[i],dp[i][j-1]-a[j]);
      }
    }
  }
  cout << dp[0][n-1] << endl;
  return 0;
}


Compiler output:
a.cc:36:30: error: macro "rep" requires 2 arguments, but only 1 given
   36 |     rep(int j = i; j < n; j++){
      |                              ^
a.cc:6:9: note: macro "rep" defined here
    6 | #define rep(i, n) for(int i = 0; i < (int)(n); i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:36:5: error: 'rep' was not declared in this scope
   36 |     rep(int j = i; j < n; j++){
      |     ^~~