criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <bits/stdc++.h>
using namespace std;
long long main(){
	long long N,K;
	cin>>N>>K;
	long long R = min(N,K);
	vector<long long> arr;
	for(long long i =0;i<N;i++){
		long long t;
		cin>>t;
		arr.push_back(t);
	}
	priority_queue<long long,vector<long long>,greater<long long>> chsx;
	priority_queue<long long,vector<long long>,greater<long long>> chs;
	priority_queue<long long,vector<long long>,greater<long long>> calcq;
	long long max_ans = -1;
	long long arra_sum = 0;
	long long arra_sum_x = 0;
	for(long long x = 0;x<=R;x++){
		if(x){
			chsx.push(arr[x-1]);
			chs = chsx;
			arra_sum_x+=arr[x-1];
			arra_sum = arra_sum_x;
		}
		//cerr<<x <<" "<<arra_sum<<" "<<arra_sum_x<<" "<<endl;
		for(long long y=0;x+y<=R;y++){
			if(y){
				arra_sum+=arr[N-y];
				chs.push(arr[N-y]);
			}
			calcq = chs;
			//long long sum = 0;
			long long diu = R - x - y;
			//cerr<<y<<" "<<arra_sum<<endl;
			long long tmp = arra_sum;
			while(!calcq.empty()){
				//cerr<<"hi"<<endl;
				if(!diu)break;
				long long nx = calcq.top();
				if(nx>=0)break;
				else {calcq.pop();tmp-=nx;diu-=1;}
			}
			max_ans = max(max_ans,tmp);
		}
	
	}
	cout<<max_ans<<endl;
	return 0;
}


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

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int>v(n);
    for(int i=0; i<n; i++)cin >> v[i];
    int a=min(n, k);
    vector<int>f;
    int ret=0;
    for(int l=0; l<=a; l++){
        for(int r=0; r<=a-l; r++){
            for(int m=0; m<=k-l-r; m++){
                if(m>l+r)break;
//                f.resize(0);
                f.clear()
                for(int i=0; i<l; i++)f.push_back(v[i]);
                for(int i=0; i<r; i++)f.push_back(v[n-1-i]);
                sort(f.rbegin(), f.rend());
                ret=max(ret, accumulate(f.begin(), f.begin()+l+r-m, 0));
            }
        }
    }
    cout << ret;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:26: error: expected ';' before 'for'
   20 |                 f.clear()
      |                          ^
      |                          ;
   21 |                 for(int i=0; i<l; i++)f.push_back(v[i]);
      |                 ~~~       
a.cc:21:30: error: 'i' was not declared in this scope
   21 |                 for(int i=0; i<l; i++)f.push_back(v[i]);
      |                              ^
Language: C++

#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define all(V) V.begin,V.end
const int N = 100005;
int v[60];
int n,k;
int solve(int l, int r)
{
    vector<int> temp;
    for(int i=0; i<l; ++i) temp.push_back(v[i]);
    for(int i=r+1;i<n;++i) temp.push_back(v[i]);
    sort(all(temp));
    int ans = 0;
    int lim = (int) temp.size() - k;
    if(lim < 0) return 0;
    for(auto &i:temp)
    {
        if(i<0 and lim) lim--;
        else ans += i;
    }
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> k;
    int ans = 0;
    for(int l=-1; l<n ;++l)
    {
        for(int r = l; r < n; ++r)
        {
            ans = max(ans,solve(l,r));
        }
    }
}

Compiler output:
a.cc: In function 'int solve(int, int)':
a.cc:13:9: error: no matching function for call to 'sort(<unresolved overloaded function type>, <unresolved overloaded function type>)'
   13 |     sort(all(temp));
      |     ~~~~^~~~~~~~~~~
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:4762:5: note: candidate: 'template<class _RAIter> void std::sort(_RAIter, _RAIter)'
 4762 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last)
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4762:5: note:   template argument deduction/substitution failed:
a.cc:13:9: note:   couldn't deduce template parameter '_RAIter'
   13 |     sort(all(temp));
      |     ~~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note: candidate: 'template<class _RAIter, class _Compare> void std::sort(_RAIter, _RAIter, _Compare)'
 4793 |     sort(_RandomAccessIterator __first, _RandomAccessIterator __last,
      |     ^~~~
/usr/include/c++/14/bits/stl_algo.h:4793:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:86:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator, class _Compare> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator, _Compare)'
  292 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last, _Compare __comp);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:292:1: note:   candidate expects 4 arguments, 2 provided
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: candidate: 'template<class _ExecutionPolicy, class _RandomAccessIterator> __pstl::__internal::__enable_if_execution_policy<_ExecutionPolicy, void> std::sort(_ExecutionPolicy&&, _RandomAccessIterator, _RandomAccessIterator)'
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note:   candidate expects 3 arguments, 2 provided
Language: C++

#include <bits/stdc++.h>
int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<int> V(N);
    for(int i = 0; i < N; i++){std::cin >> V[i];}
    int ans = 0;
    for(int l = 0;l < N;l++){
        for(int r = N; r > l and (N-r+l)<=K; r--){
            std::priority_queue<int, std::vector<int>,std::greater<int>> Q;
            int sum=0;
            for(int i = 0; i < l; i++){Q.push(V[i]),sum+=V[i]}
            for(int i = N-1; i >= r; i--){Q.push(V[i]),sum+=V[i];}
            const int E = K-l-(N-r);
            for(int i = 0; i < E and not Q.empty(); i++){
                const int T = Q.top();
                Q.pop();
                if(T>0){break;}
                sum -= T;
            }
            ans = std::max(ans, sum);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:62: error: expected ';' before '}' token
   13 |             for(int i = 0; i < l; i++){Q.push(V[i]),sum+=V[i]}
      |                                                              ^
      |                                                              ;
Language: C++

#include <bits/stdc++.h>
int main()
{
    int N, K;
    std::cin >> N >> K;
    std::vector<int> V(N);
    for(int i = 0; i < N; i++){std::cin >> V[i];}
    int ans = 0;
    for(int l = 0;l < N;l++){
        for(int r = N; r > l and (N-r+l)<=K; r--){
            std::priority_queue<int, std::vector<int>,std::greater<int>> Q;
            int sum=0;
            for(int i = 0; i < l; i++){Q.push(V[i]);,sum+=V[i]}
            for(int i = N-1; i >= r; i--){Q.push(V[i]),sum+=V[i];}
            const int E = K-l-(N-r);
            for(int i = 0; i < E and not Q.empty(); i++){
                const int T = Q.top();
                Q.pop();
                if(T>0){break;}
                sum -= T;
            }
            ans = std::max(ans, sum);
        }
    }
    std::cout << ans << std::endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:53: error: expected primary-expression before ',' token
   13 |             for(int i = 0; i < l; i++){Q.push(V[i]);,sum+=V[i]}
      |                                                     ^
Language: C++

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

int main()
{
	int n,k;
	cin>>n>>k;
	int a[n+1];
	for(int i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;i+j<=min(n,k);j++)
		{
			vector<int> v;
			int s=0;
			for(int x=1;x<=i;x++){v.push_back(a[x]);s++;}
			for(int x=0;x<j;x++){v.push_back(a[n-x]);s++;}
			sort(v.begin(),v.end());
			int k1=k-s;
			//cout<<k1<<" i "<<i<<" j "<<j<<" sum ";
			while(k1>0 && !v.empty() && *v.begin()<0)
			{
				v.erase(v.begin());
				k1--;
			}
			int sum=0;
			for(int d=0;d<v.size();d++)
			{
				sum+=v[d];
			}
			//cout<<sum<<endl;
			ans=max(ans,sum);	
		}
	}
	cout<<ans;
	return 0;
}

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

#include <bits/stdc++.h>
using namespace std;
int main(){
	int N,K;
	cin>>N>>K;
	int R = min(N,K);
	vector<int> arr;
	for(int i =0;i<N;i++){
		int t;
		cin>>t;
		arr.push_back(t);
	}
	priority_queue<int,vector<int>,greater<int>> chsx;
	priority_queue<int,vector<int>,greater<int>> chs;
	priority_queue<int,vector<int>,greater<int>> calcq;
	int max_ans = -1;
	int arra_sum = 0;
	int arra_sum_x = 0;
	for(int x = 0;x<=R;x++){
		if(!x){
			chsx.push(arr[x-1]);
			chs = chsx;
			arra_sum_x+=arr[x-1];
			arra_sum = arra_sum_x;
		}
		for(int y=0;x+y<=R;y++){
			if(!y){
				arra_sum+=arr[N-y];
				chs.push(arr[N-y]);
			}
			calcq = chs;
			//int sum = 0;
			int diu = R - x - y;
			while(!calcq.empty()){
				if(!diu)break;
				int nx = calcq.top();
				if(nx>=0)break;
				else {calcq.pop();arra_sum-=nx;diu-=1;}
			}
			max_ans = max(max_ans,arra_sum):
		}
	
	}
	cout<<max_ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:56: error: expected ';' before ':' token
   40 |                         max_ans = max(max_ans,arra_sum):
      |                                                        ^
      |                                                        ;
Language: C++

#include <bits/stdc++>
using namespace std;
int main(){
	int N,K;
	cin>>N>>K;
	int R = min(N,K);
	vector<int> arr;
	for(int i =0;i<N;i++){
		int t;
		cin>>t;
		arr.push_back(t);
	}
	priority_queue<int,vector<int>,less<int>()> chsx;
	priority_queue<int,vector<int>,less<int>()> chs;
	priority_queue<int,vector<int>,less<int>()> calcq;
	int max_ans = -1;
	int arra_sum = 0;
	int arra_sum_x = 0;
	for(int x = 0;x<=R;x++){
		if(!x){
			chsx.push(arr[x-1]);
			chs = chsx;
			arra_sum_x+=arr[x-1];
			arra_sum = arra_sum_x;
		}
		for(int y=0;x+y<=R;y++){
			if(!y){
				arra_sum+=arr[N-y];
				chs.push(arr[N-y]);
			}
			calcq = chs;
			//int sum = 0;
			int diu = R - x - y;
			while(!calcq.empty()){
				if(!diu)break;
				int nx = calcq.top();
				if(nx>=0)break;
				else {calcq.pop();arra_sum-=nx;diu-=1;}
			}
			max_ans = max(max_ans,arra_sum):
		}
	
	}
	cout<<max_ans<<endl;
	return 0;
}

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

#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    // ll sum=0;

    rep(i,n){
        cin>>v[i];
        //sum+=v[i];
    }

    int ans=-INF;
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){
        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

            for(int i=0;i<l;i++){
                sum+=v[i];
                if(v[i]<0) {
                    te.push_back(v[i]);
                }
            }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }

            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());
           // if(min(a,b)!=0) {
                for (int tt = 0; tt < =min(a, b); tt++) {
                    /*if (te[tt] < 0) {
                        sum -= te[tt];
                        if (ans < sum) {
                            ans = sum;
                        }

                    } else { break; }*/
                   if(tt!=0){ sum -= te[tt-1];}
                    if (ans < sum) {
                        ans = sum;
                    }
                    //cout<<l<<" "<<r<<" "<<sum<<endl;

                }
          /*  }else {
                if (ans < sum) {
                    ans = sum;
                }
            }*/




        }
    }

    cout<<ans<<endl;



    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:39: error: expected primary-expression before '=' token
   63 |                 for (int tt = 0; tt < =min(a, b); tt++) {
      |                                       ^
Language: C++

#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
    // ll sum=0;

    rep(i,n){
        cin>>v[i];
        //sum+=v[i];
    }

    int ans=-INF;
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){
        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

            for(int i=0;i<l;i++){
                sum+=v[i];
                if(v[i]<0) {
                    te.push_back(v[i]);
                }
            }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }

            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());
           // if(min(a,b)!=0) {
                for (int tt = 0; tt < =min(a, b); tt++) {
                    /*if (te[tt] < 0) {
                        sum -= te[tt];
                        if (ans < sum) {
                            ans = sum;
                        }

                    } else { break; }*/
                   if(tt!=0){ sum -= te[tt];}
                    if (ans < sum) {
                        ans = sum;
                    }
                    //cout<<l<<" "<<r<<" "<<sum<<endl;

                }
          /*  }else {
                if (ans < sum) {
                    ans = sum;
                }
            }*/




        }
    }

    cout<<ans<<endl;



    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:63:39: error: expected primary-expression before '=' token
   63 |                 for (int tt = 0; tt < =min(a, b); tt++) {
      |                                       ^
Language: Java

import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Collections;

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

       
	// 左右それぞれ何個ずつ取るかをきめる
	// left + right + remove
	int max = 0;
	for(int left = 0; left < N; left++){
	    for(int right = 0; right < N; right++){
		if(left + right > Math.min(N, K)) break;
		int remove = K - right - left;

		// 実際に取りましょう
		ArrayList<Integer> score = new ArrayList<Integer>();
		// もしなんか全部とるってことになっていたら
		else{ 
		    for(int i = 0; i < left; i++) score.add(V[i]);
		    for(int i = 0; i < right; i++) score.add(V[N - 1 - i]);
		}
		// ソートします
		Collections.sort(score);

		// 負の数を除きながら総和を取る
		int sum = 0;
		int k = 0;
		for(int x : score){
		    if(x < 0 && k < remove){
			k++;
		    }
		    else{
			sum += x;
		    }
		}
		max = Math.max(max, sum);
							 
		
	    }
	}
	System.out.println(max);
    }
}


Compiler output:
Main.java:28: error: 'else' without 'if'
		else{ 
		^
1 error
Language: C++

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

#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int

using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 312345;
// const double pi = 3.14159265359;
const double eps = 0.00000001;

int n, k;
int arr[55];

inline calc(int i, int j) {
    return i + (n - 1 - j);
}

int job (int i, int j, int x) {
    vi a;
    for (int k = 0; k < i; ++k) {
        a.push_back(arr[k]);
    }
    for (int k = n - 1; k > j; --k) {
        a.push_back(arr[k]);
    }
    sort(all(a));
    int u = 0, res = 0;
    while (u < (int)a.size() && a[u] < 0 && x) ++u, --x;
    for (int k = u; k < (int)a.size(); ++k) res += a[k];
    //cout << i << ' ' << j << ' ' << x << ' ' << res << endl;
    return res;
}

int dp[2][52][52];
bool seen[2][52][52];

int sol (int i, int j, bool f) {
    int& pd = dp[f][i][j];
    bool& vis = seen[f][i][j];
    if (i >= j || calc(i, j) > k) {
        return -INF;
    }
    if (vis) {
        return pd;
    }
    if (f) {
        return job(i, j, k - calc(i, j));
    }
    pd = -INF;
    pd = max(pd, sol(i + 1, j, 0));
    pd = max(pd, sol(i, j - 1, 0));
    pd = max(pd, sol(i, j, 1));
    vis = 1;
    return pd;
}

int32_t main() {
    $

    cin >> n >> k;
    forn (0, n) {
        cin >> arr[i];
    }

    cout << sol(0, n - 1, 0) << endl;
}


Compiler output:
a.cc:31:8: error: ISO C++ forbids declaration of 'calc' with no type [-fpermissive]
   31 | inline calc(int i, int j) {
      |        ^~~~
Language: C++

#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

#define rep(i, n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {

    int n,k;
    cin>>n>>k;
    vector<int> v(n);
   // ll sum=0;

    rep(i,n){
        cin>>v[i];
        //sum+=v[i];
    }

    int ans=min(v[0],v[n-1];
    int lim=min(n,k);
    for(int l=0;l<=lim;l++){

        for(int r=0;r<=lim-l;r++){

            vector<int> te;
            int sum=0;

        for(int i=0;i<l;i++){
            sum+=v[i];
            if(v[i]<0) {
                te.push_back(v[i]);
            }
        }
            for(int i=0;i<r;i++){
                sum+=v[n-i-1];
                if(v[n-i-1]<0) {
                    te.push_back(v[n - i - 1]);
                }
            }
            int a=k-(l+r);
            int b=te.size();
            sort(te.begin(),te.end());

            for(int tt=0;tt<min(a,b);tt++){
             //if(tt!=0){
                 sum-=te[tt];
             //}
             //cout<<l<<" "<<r<<" "<<sum<<endl;
                if(ans<sum){
                    ans=sum;
                }

            }


        }
    }

    cout<<ans<<endl;



    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:38:28: error: expected ')' before ';' token
   38 |     int ans=min(v[0],v[n-1];
      |                ~           ^
      |                            )
Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long N, K;
    cin >> N >> K;
    vector<int> V(N);
    REP(i, N) { cin >> V[i]; }
    ll ans = 0;
    REP(i, min(K, N)) {
        //左からi-1番目まで穫る
        REP(j, min(N, N - i)) {
            //右からj-1番目まで穫る
            vector<int> tmp(i + j);
            REP(k, i) { tmp[k] = V[i]; }
            REP(l, j) { tmp[i + l] = V[N - l]; }
            int resop = K - i - j;
            if(resop > 0) {
                sort(tmp.begin(), tmp.end());
                REP(m, resop) {
                    if(tmp[m] < 0) {
                        tmp[m] = 0;
                    }
                }
                ans = max(ans, (long long)accumulate(tmp.begin(), tmp.end()));
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:53:53: error: no matching function for call to 'accumulate(std::vector<int>::iterator, std::vector<int>::iterator)'
   53 |                 ans = max(ans, (long long)accumulate(tmp.begin(), tmp.end()));
      |                                           ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided
Language: C++

#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K; cin >> N >> K;
  ll ans = 0;
  ll V[110];
  ll revV[110];
  rep(i, N) {
      cin >> V[i];
  }
  rep(i, N) {
      revV[N - 1 - i] = V[i];
  }
  rep(i, N + 1) {
    rep(j, N - i + 1) {
      if(i + j <= K) {
        ll ret = 0;
        priority_queue<ll, vector<ll>, greater<ll>> pque;
        rep(k, i) {
          pque.push(V[k]); ret += V[k];
        }
        rep(k, j) {
          pque.push(revV[k]); ret += revV[k];
        }
        rep(k,0, K - i - j) {
          ll rem = pque.top(); pque.pop();
          if(rem < 0) ret -= rem;
        }
        ans = max(ans, ret);
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Compiler output:
a.cc:75:27: error: macro "rep" passed 3 arguments, but takes just 2
   75 |         rep(k,0, K - i - j) {
      |                           ^
a.cc:27:9: note: macro "rep" defined here
   27 | #define rep(i,n) for(int i=0;i<n;i++)
      |         ^~~
a.cc: In function 'int main()':
a.cc:75:9: error: 'rep' was not declared in this scope
   75 |         rep(k,0, K - i - j) {
      |         ^~~
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 k = sc.nextInt();
    long[] v = sc.nextLong();
    for(int i = 0; i < n; i++) {
      v[i] = sc.nextLong();
    }
    long ans = 0;
    for(int a = 0; a <= Math.min(n, k); a++) {
      for(int b = 0; a + b <= Math.min(n, k); b++) {
        ArrayList<Long> list = new ArrayList<Long>();
        for(int c = 0; c < a; c++) {
          list.add(v[c]);
        }
        for(int c = n - 1; c >= n - b; c--) {
          list.add(v[c]);
        }
        Collections.sort(list);
        long sum = 0;
        for(int i = 0; i < a + b; i++) {
          sum += list.get(i);
        }
        for(int i = 0; i < k - a - b; i++) {
          if(list.get(i) < 0) sum -= list.get(i); 
        }
        ans = Math.max(ans, sum);
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:8: error: incompatible types: long cannot be converted to long[]
    long[] v = sc.nextLong();
                          ^
1 error
Language: C++

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

using namespace std;

int Sum(const vector<int>& Jwels, size_t a, size_t b, size_t suteru)
{
  int val = 0;
  
  list<int> Hands;
  while(a > 0)
  {
    const int temp = Jwels[a - 1];
    val += temp;
    if(temp < 0)
	    Hands.emplace_back(temp);    
    -- a;
  }
  
  while(b > 0)
  {
    const int temp = Jwels[Jwels.size() - b];
    val += temp;
    if(temp < 0)
	    Hands.emplace_back(temp);    
    -- b;
  }
  
  Hands.sort();
  for(auto Itr = Hands.cbegin(); suteru > 0 && Itr != Hands.cend(); -- suteru, ++ Itr)
  {
    if(*Itr > 0)
      break;
    
    val += -(*Itr);
  }
    
  return val;
}

int main()
{
  size_t n, k;
  cin >> n >> k;
  
  vector<int> Jwels(n, 0)
  for(size_t i = 0; i < n; ++ i)
    cin >> Jwels[i];
  
  const int min_pop = min(n, k);
  int max_val = 0;
  for(size_t a = 0; a <= min_pop; ++ a)
  {
    for(size_t b = 0; b <= min_pop - a; ++ b)
    {
      const int val = Sum(Jwels, a, b, k - (a+b));
      if(max_val < val)
        max_val = val;
    }
  }
  cout << max_val << endl;
  
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:49:3: error: expected ',' or ';' before 'for'
   49 |   for(size_t i = 0; i < n; ++ i)
      |   ^~~
a.cc:49:21: error: 'i' was not declared in this scope
   49 |   for(size_t i = 0; i < n; ++ i)
      |                     ^
Language: Java

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class MainD {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] v = new int[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for (int a = 0; a <= n && a <= k; a++) {
			for (int b = 0; b <= n && b <= k; b++) {
				int x = a + b;
				if (x > k || x > n) {
					break;
				}

				int val = 0;
				List<Integer> list = new ArrayList<Integer>(a + b);
				for (int i = 0; i < a; i++) {
					val += v[i];
					list.add(v[i]);
				}
				for (int i = n - 1; i >= n - b; i--) {
					val += v[i];
					list.add(v[i]);
				}

				Collections.sort(list);
				for (int i = 0; i < k - x && i < list.size(); i++) {
					int m = list.get(i);
					if (m < 0) {
						val -= m;
					} else {
						break;
					}
				}
				ans = Math.max(ans, val);
			}
		}
		System.out.println(ans);
	}
}


Compiler output:
Main.java:6: error: class MainD is public, should be declared in a file named MainD.java
public class MainD {
       ^
1 error
Language: C++


#include <bits/stdc++.h>

using namespace std;

#define lli long long int
#define REP(i,s,l) for(lli i=s;i<l;i++)
#define DEBUG 0
#define MOD 1000000007
#define INF (1LL)<<50;

signed main(){

	lli n;
	cin>>n;
	lli k;
	cin>>k;
	vector<lli> v(n);
	REP(i,0,n)cin>>v[i];

	lli ans=-INF;

	/*まず左側でどこまでとるか*/
	for(lli i=0;i<n;i++){

		vector<lli> p; /*マイナスの宝石入れ*/
		lli left=i;
		lli sum=0;

		/*左端から宝石をとっていく*/
		for(lli ii=0;ii<left;ii++){
			sum += v[ii];
			if(v[ii]<0)p.push_back(v[ii]);
			flag[ii]++;
		}

		/*次に右端についてどこまで宝石をとるか*/
		for(lli j=0;j<=n;j++){

			/*操作回数が超えていたらやめる*/
			if(i+j>k)continue;

			/*右端からどこまでとるかについての情報を持つ*/
			/*すでにとっている宝石や、左端まで行ってしまう場合はやめる*/
			lli right=n-j-1;
			if(left>right])continue;

			/*左端で取った宝石の情報を引き継ぐ*/
			vector<lli> pp;
			lli nextSum=sum;
			REP(g,0,p.size())pp.push_back(p[g]);

			/*右端から宝石をとっていく*/
			for(lli jj=n-1;jj>right;jj--){
				nextSum+= v[jj];
				if(v[jj]<0)pp.push_back(v[jj]);
			}

			/*マイナスの宝石入れのソートを行う、これで上からマイナスがでかい宝石を捨てれるようになる*/
			sort(pp.begin(),pp.end());

			/*残り操作回数*/
			lli allowCnt = k-(i+j);

			for(lli g=0;(g<allowCnt && g<pp.size());g++){
				nextSum -= pp[g];
			}
			ans = max(ans,nextSum);
		}
	}

	cout<<ans<<endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:34:25: error: 'flag' was not declared in this scope
   34 |                         flag[ii]++;
      |                         ^~~~
a.cc:46:38: error: expected ')' before ']' token
   46 |                         if(left>right])continue;
      |                           ~          ^
      |                                      )
a.cc:46:38: error: expected primary-expression before ']' token
Language: C++

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int inf=1e9,mod=1e9+7;
typedef long long ll;
int read() {
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9') f=(c=='-')?-1:1,c=getchar();
	while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
	return x*f;
}
int a[1000001];
priority_queue<int,vector<int>,greater<int> > q;
main() {
	int n=read(),m=read(),maxx=0;
	for(int i=1; i<=n; i++)
		a[i]=read();
	for(int i=0; i<=min(m,n); i++)
		for(int j=0; j<=min(n-i,m-i); j++)
			for(int z=n+1; z>=max(n-(m-i-j)+1,i+1); z--) {
				if(i+max((n-z+1),0)<=j) continue;
				for(int k=1; k<=i; k++)
					q.push(a[k]);
				cout<<i<<" "<<z<<" "<<j<<endl;
				for(int k=n; k>=z; k--)
					q.push(a[k]);
				for(int k=1; k<=j; k++)
					q.pop();
				int ans=0;
				while(!q.empty())
					ans+=q.top(),q.pop();
				maxx=max(ans,maxx);
			}
	cout<<maxx;
}

Compiler output:
a.cc:15:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   15 | main() {
      | ^~~~
a.cc: In function 'int main()':
a.cc:22:41: error: no matching function for call to 'max(long long int, int)'
   22 |                                 if(i+max((n-z+1),0)<=j) continue;
      |                                      ~~~^~~~~~~~~~~
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:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:22:41: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   22 |                                 if(i+max((n-z+1),0)<=j) continue;
      |                                      ~~~^~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303: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:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:22:41: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   22 |                                 if(i+max((n-z+1),0)<=j) continue;
      |                                      ~~~^~~~~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<((ll)n);i++)
#define rep1(i,n) for(ll i=1;i<=((ll)n);i++)
#define pb push_back
#define mp make_pair
#define int ll
#define F first
#define S second
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define meow(a) cout<<a<<" meow\n";
typedef pair<long long,long long> pii;
typedef vector<pii> vii;
const ll maxn=200005;
const ll MOD=998244353;
double mypow(ll a,ll b){
	double res=1;
	while(b){
		if(b&1) res=res*a;
		a=a*a;

		b>>=1;
	}
	return res;
}
ll t,n,m,k;

int main()
{
    //IOS;
    //cin>>t;
    while(cin>>n>>k)
    {
        vector<ll> v;
        rep(i,n)
        {
            ll x;cin>>x;
            v.pb(x);
        }
        ll ans=0;
        rep(l,n)
        {
            rep(r,n)
            {
                if(l+r>min(n,k)) break;
                vector<int> choose;
                ll sum=0;
                for(int i=n-1;i>=n-r;i--)
                {
                    choose.pb(v[i]);
                    sum+=v[i];
                }
                for(int i=0;i<l;i++)
                {
                    choose.pb(v[i]);
                    sum+=v[i];
                }
                sort(choose.begin(),choose.end());
                ll cost=l+r;
                //cout<<sum<<"\n";
                for(auto i:choose)
                {
                    if(i<0&&cost<=k-1) {sum=sum-i;cost+=1;}
                    else break;
                }
                //cout<<l<<" "<<r<<" "<<sum<<"\n";
                ans=max(ans,sum);
            }
        }
        cout<<ans<<"\n";
    }
    return 0;
}


Compiler output:
a.cc:8:13: error: '::main' must return 'int'
    8 | #define int ll
      |             ^~
a.cc:29:1: note: in expansion of macro 'int'
   29 | int main()
      | ^~~
Language: C++

#include <algorithm>
#include <climits>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <string.h>
#include <utility>
#include <vector>
using namespace std;

#define dlog(str) cout << "====" << str << endl;
#define INF 999999999
#define REP(i, n) for(int i = 0, i##_l = (n); i < i##_l; i++)
#define REPR(i, n) for(int i = n - 1; 0 <= i; i--)
#define FOR(i, s, e) for(int i = s; i <= e; i++)
#define FORR(i, s, e) for(int i = s; e <= i; i--)
#define LLI long long int
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(a, shift) ((a>>shift)&1))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
// int 2.14E±9    lli 9.2E±18    double 1.7E±380

struct ST {
    int a, b;
    ST(int _a, int _b) : a(_a), b(_b) {}
    bool operator<(const ST &an) { return a < an.a; }
};

vector<int> d;
int f(int s, int e, vector<int> v, int n) {
    int ma = 0;
    int sum = 0;
    for(int i = 0, l = v2.size(); i < l; i++) {
        if(i < n && v2[i] < 0) {
            sum += v2[i];
        }
    }

    if(n == 0 || e <= s)
        return 0;

    v.push_back(d[s]);
    {
        vector<int> v2;
        for(auto f : v) {
            v2.push_back(f);
        }
        SORT(v2);
        chmax(sum, f(s + 1, e, v2, n - 1));
        v.pop_back();
    }
    {
        vector<int> v2;
        for(auto f : v) {
            v2.push_back(f);
        }
        SORT(v2);
        v.push_back(d[e]);
        chmax(sum, f(s, e - 1, v, n - 1));
        v.pop_back();
    }

    return sum;
}

int main() {
    int N, K;
    cin >> N >> K;
    int vf;
    REP(i, N) {
        cin >> vf;
        d.push_back(vf);
    }
    vector<int> v;
    cout << f(0, N - 1, v, K);

    return 0;
}

Compiler output:
a.cc: In function 'int f(int, int, std::vector<int>, int)':
a.cc:37:24: error: 'v2' was not declared in this scope; did you mean 'v'?
   37 |     for(int i = 0, l = v2.size(); i < l; i++) {
      |                        ^~
      |                        v
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>

using namespace std;    
typedef long long ll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

int main(){

    int N, K;
    cin >> N >> K;

    vector<ll> v(N);
    for(int i = 0; i < N; i++) cin >> v[i];

    //ret 返却する個数
    ll ans = 0;
    bool first = true;
    //for(int get = 0; get <= K;  get++){
        bool flag2 = true;
        for(int i = 0; i < N; i++){
            if(v[i] >0) falg2 = false;
        }
        if(flag2){
cout << 0 << endl;
return 0;
        } 



        for(int ret = 0; ret <= K / 2; ret ++){
            int get = K - ret;
            if(get > N) get = N;
            for(int left = 0; left <= N - get ; left++){ //左からleft個とる
                vector<ll> getV;
                for(int l = 0; l < left; l++){
                    getV.push_back(v[l]);
                }
                for(int r = 0; r < get - left; r++){
                    getV.push_back(v[N - 1 - r]);
                }
                sort(rall(getV));
                //if(getV[0] == 8 && getV[1]== 6 && getV[2] == -10) cout << "a" << get << "ret" << ret << endl;
                ll ans_tmp = 0;
                for(int i = 0; i < get - ret; i++){
                    ans_tmp += getV[i];
                }
                //ll ans_tmp = accumulate(getV.begin(), (getV.begin() + get - ret ) , 0ll );
                //ll ans_tmp = accumulate(all(getV) , 0ll );

                if(first ){
                    ans = ans_tmp;
                    first = false;
                }
                else{
                    first = false;
                    ans = max(ans, ans_tmp);
                }
                for(int i = 0; i < getV.size(); i++) cout << getV[i] << " ";
                cout << endl;
            }
        }

    //}

    cout << ans << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:25: error: 'falg2' was not declared in this scope; did you mean 'flag2'?
   27 |             if(v[i] >0) falg2 = false;
      |                         ^~~~~
      |                         flag2
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N, K; cin >> N >> K;
    vector<ll> v(N);

    vector<int> posid;
    for(int i=0; i<N; i++){
        int d; cin >> d;
        if(d > 0) posid.push_back(i);
        v[i] = d;
    }
    // for(int i=0; i<posid.size(); i++) cout << posid[i] << " ";
    // cout << endl;

    ll ans = 0;
    for(int l=-1; l<posid.size(); l++){
        for(int r=l+1; r<=posid.size(); r++){
            priority_queue<ll> pq;
            ll sum = 0;
            if(l>=0){
                for(int i=0; i<=posid[l]; i++){
                    if(v[i]<0) pq.push(-v[i]);
                    sum += v[i];
                }
            }
            if(r<posid.size()){
                for(int i=N-1; i>=posid[r]; i--){
                    if(v[i]<0) pq.push(-v[i]);
                    sum += v[i];
                }
            }

            int cnt = 0
            if(l>=0) cnt += posid[l]+1;
            if(r<posid.size()) cnt += N-posid[r];
            
            if(cnt > K) continue;

            K -= cnt;
            while(K>0 && !pq.empty()){
                ll u=pq.top(); pq.pop();
                sum += u;
                K--;
            }

            ans = max(ans, sum);

        }
    }    

    cout << ans << endl;
    // int minuscnt = 0;
    // for(int i=0; i<N; i++){
    //     int V; cin >> V;
    //     v[i] = V;
    //     if(V < 0) minuscnt++;
    // }
    // vector<pair<ll, int>> lmax, rmax;
    // int id=0;
    // priority_queue<ll> nega1;
    // ll sum = 0;
    // while(true){
    //     if(nega1.empty() || v[id] >= 0 || v[id] > nega1.top()) { sum += v[id]; id++; }
    //     else if(v[id] <= nega1.top()) { sum }


    //     if(id == N) break;
    // }

    // ll ans = 0;
    // for(int cnt=0; cnt<=K; cnt++){
    //     for(int left=0; left<=K; left++){
    //         priority_queue<ll> nega;
    //         ll sum = 0;
    //         int i=0;
    //         while(i<left){
                
    //         }
    //     }
    // }

}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:13: error: expected ',' or ';' before 'if'
   44 |             if(l>=0) cnt += posid[l]+1;
      |             ^~
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 k = sc.nextInt();
    long[] v = new long[n];
    for(int i = 0; i < n; i++) {
      v[i] = sc.nextLong();
    }
    long[][] left = new long[n + 1][n + 1];
    long[][] right = new long[n + 1][n + 1];
    HashMap<Integer, ArrayList<Long>> leftmap = new HashMap<Integer, ArrayList<Long>>();
    HashMap<Integer, ArrayList<Long>> rightmap = new HashMap<Integer, ArrayList<Long>>();
    ArrayList<Long> leftlist = new ArrayList<Long>();
    ArrayList<Long> rightlist = new ArrayList<Long>();
    for(int i = 0; i < n; i++) {
      leftlist.add(v[i]);
      Collections.sort(leftlist);
      leftmap.put(i + 1, leftlist);
    }
    for(int i = n - 1; i >= 0; i--) {
      rightlist.add(v[i]);
      Collections.sort(rightlist);
      rightmap.put(n - i, rightlist);
    }
    for(int i = 1; i <= n; i++) {
      ArrayList<Long> list = leftmap.get(i);
      long t = 0;
      for(int j = 1; j <= i; j++) {
        t += list.get(i - j);
        left[i][j] = t;
      }
    }
    for(int i = 1; i <= n; i++) {
      ArrayList<Long> list = rightmap.get(i);
      long t = 0;
      for(int j = 1; j <= i; j++) {
        t += list.get(i - j);
        right[i][j] = t;
      }
    }
    // iから高々j取るときの最大値
    long[][] rightmax = new long[n + 1][n + 1];
    for(int i = 1; i <= n; i++) {
      rightmax[i][0] = 0;
      long t = 0;
      for(int j = 1; j <= i; j++) 
        rightmax[i][j] = Math.max(rightmax[i][j - 1], right[i][j]);
      }
    }
    long ans = 0;
    for(int i = 0; i <= (int)Math.min(n, k); i++) {
      for(int j = 0; j <= (int)Math.min(n - i, k - i); j++) {
        for(int i2 = 0; i2 <= (int)Math.min(i, k - i - j); i2++) {
          long t = left[i][i2] + rightmax[j][k - i - j - i2];
          ans = Math.max(ans, t);
        }
      }
    }
    System.out.println(ans);
  }
}

Compiler output:
Main.java:54: error: illegal start of type
    for(int i = 0; i <= (int)Math.min(n, k); i++) {
    ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= (int)Math.min(n, k); i++) {
                    ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= (int)Math.min(n, k); i++) {
                            ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= (int)Math.min(n, k); i++) {
                                     ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= (int)Math.min(n, k); i++) {
                                       ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= (int)Math.min(n, k); i++) {
                                          ^
Main.java:54: error: <identifier> expected
    for(int i = 0; i <= (int)Math.min(n, k); i++) {
                                              ^
Main.java:62: error: <identifier> expected
    System.out.println(ans);
                      ^
Main.java:62: error: <identifier> expected
    System.out.println(ans);
                          ^
Main.java:64: error: class, interface, enum, or record expected
}
^
10 errors
Language: C++

#include <iostream>
#include <vector>
#include <deque>
#include <numeric>
#include <algorithm>
using namespace std;

int search(deque<int> V_que, vector<int> V_hand, int K, int cnt) {
	vector<int> total(4);

	if (cnt >= K) return 0;

	// manipulation A & B
	if (V_que.size > 0) {

		// manipulation A
		int tmp_val = 0;
		deque<int>  tmp_V_que  = V_que;
		vector<int> tmp_V_hand = V_hand;
		tmp_val = tmp_V_que.front();
		tmp_V_que.pop_front();
		tmp_V_hand.push_back(tmp_val);
		total.at(0) = search(tmp_V_que, tmp_V_hand, K, cnt+1);
		// manipulation B
		tmp_val = 0;
		tmp_V_que  = V_que;
		tmp_V_hand = V_hand;
		tmp_val = tmp_V_que.back();
		tmp_V_que.pop_back();
		tmp_V_hand.push_back(tmp_val);
		total.at(1) = search(tmp_V_que, tmp_V_hand, K, cnt+1);
	}

	if (!V_hand.empty()) {
		// manipulate C
		int tmp_val = 0;
		deque<int>  tmp_V_que  = V_que;
		vector<int> tmp_V_hand = V_hand;

		sort(tmp_V_hand.begin(), tmp_V_hand.end());
		tmp_val = tmp_V_hand.at(0);
		tmp_V_hand.erase(tmp_V_hand.begin());
		tmp_V_que.push_front(tmp_val);
		total.at(2) = search(tmp_V_que, tmp_V_hand, K, cnt+1);	

		// manipulate D
		tmp_val = 0;
		tmp_V_que  = V_que;
		tmp_V_que.push_back(tmp_val);
		total.at(3) = search(tmp_V_que, tmp_V_hand, K, cnt+1);		
	}

	auto iter = max_element(total.begin(), total.end());
	if (*iter > 0) return *iter;
	else return 0;
}


int main() {
	int N, K;
	// N: #juery, K:#manu
	cin >> N >> K;

	// temochi
	vector<int> V_hand(N);
	// queue
	deque<int>  V_que(N);

	int v;
	for (size_t i=0; i<N; i++) {
		cin >> v;
		V_que.push_back(v);
	}

	int total = 0;
	total = search(V_que, V_hand, K, 0);

	cout << total << endl;

}

Compiler output:
a.cc: In function 'int search(std::deque<int>, std::vector<int>, int, int)':
a.cc:14:19: error: invalid use of member function 'std::deque<_Tp, _Alloc>::size_type std::deque<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   14 |         if (V_que.size > 0) {
      |             ~~~~~~^~~~
      |                       ()
Language: C++


#include<stdio.h>
#include<vector>
#include<algorithm>


int main()
{
	int N, K;
	scanf("%d %d", &N, &K);
	int* V = new int[N];
	for (int i = 0; i < N; i++) {
		scanf("%d", &V[i]);
	}
	int max = 0;
	for (int take = 1; take <= K; take++) {
		for (int left = 0; left <= take; left++) {
			int* takes = new int[take];
			for (int i = 0; i < take; i++) {
				takes[i] = i < left ? V[i] : V[N + left - 1 - i];
			}
			sort(takes, takes + take);
			int val = 0;
			for (int i = 0; i < take; i++) {
				if (takes[i] > 0 || i >= N - take) {
					val += V[i];
				}
			}
			if (max < val) {
				max = val;
			}
		}
	}
	printf("%d", max);
}

Compiler output:
a.cc: In function 'int main()':
a.cc:22:25: error: 'sort' was not declared in this scope; did you mean 'std::sort'?
   22 |                         sort(takes, takes + take);
      |                         ^~~~
      |                         std::sort
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:4:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:296:1: note: 'std::sort' declared here
  296 | sort(_ExecutionPolicy&& __exec, _RandomAccessIterator __first, _RandomAccessIterator __last);
      | ^~~~