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

#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <tuple>
#include <queue>
#include <bitset>
#include <set>
#include <map>
#include <list>

using ll = long long;
using ld = long double;
using namespace std;
const int INF = 1e9+100;
const ll INF64 = 7e18l;
const int mod = 1000000007;
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define ALL(a) (a).begin(), (a).end()
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main(){
    FIN;
    int n,k; cin >> n >> k;
    deque<ll> deq,p,m;
    for(int i=0;i<n;i++){
        ll v; cin >> v;
        if(v>=0) p.push_back(v);
        else m.push_back(v);
        deq.push_back(v);
    }
    ll ans = 0;
    if(k>=n+m.size()){
        ans += p.pop_front();
        p.pop_front();
    }


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


Compiler output:
a.cc: In function 'int main()':
a.cc:39:27: error: void value not ignored as it ought to be
   39 |         ans += p.pop_front();
      |                ~~~~~~~~~~~^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
#define all(x) (x).begin(), (x).end()
#define fsp(x) cout << fixed << setprecision(x)
const ll inf = LLONG_MAX;
const long double pi = acos(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	//ios::sync_with_stdio(false);
	//cin.tie(nullptr);

	ll a, b, p = 1e9 + 7;
	cin >> a >> b;
	if (a == b) {
		cout << 1 << endl;
		return 0;
	}

	vll prime(1, 2);
	ll lim = sqrt(1e9);
	//vector<bool> is_prime(lim + 1, false);
	//is_prime[2] = true;
	for (ll i = 3; i <= lim; i += 2) {
		for (ll j = 0; j < prime.size(); j++) {
			if (i % prime[j] == 0) break;
			if (j == prime.size() - 1) {
				prime.push_back(i);
				//is_prime[i] = true;
				break;
			}
		}
	}

	map<ll, ll> mp;
	for (ll i = b + 1; i <= a; i++) {
		ll x = i;
		if (is_prime(x)) mp[x]++;
		else {
			for (ll j = 0; j < prime.size(); j++) {
				if (x % prime[j]) continue;
				ll cnt = 0;
				while (x % prime[j] == 0) {
					x /= prime[j];
					cnt++;
				}
				mp[prime[j]] += cnt;
				if (x == 1) break;
				if (is_prime(x)) {
					mp[x]++;
					break;
				}
			}
		}
	}

	ll ans = 1;
	for (auto i = mp.begin(); i != mp.end(); i++) {
		//cout << (i -> first) << "\t: " << (i -> second) << endl;
		ans *= (i -> second) + 1;
		//cout << ans << endl;
		ans %= p;
		//cout << ans << endl;
	}
	cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:21: error: 'is_prime' was not declared in this scope; did you mean 'prime'?
   43 |                 if (is_prime(x)) mp[x]++;
      |                     ^~~~~~~~
      |                     prime
Language: Java

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

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = Integer.parseInt(sc.next());
		int K = Integer.parseInt(sc.next());
		long[] v = new long[N];
		for (int i = 0; i < N; i++) {
			v[i] = Integer.parseInt(sc.next());
		}
		sc.close();

		long ans = 0;
		int OP = Math.min(K, N);
		for (int a = 0; a <= OP; a++) {
			long sa = 0;
			ArrayList<Integer> alist = new ArrayList<Integer>();
			for (int i = 0; i < a; i++) {
				sa += v[i];
				if (v[i] < 0) {
					alist.add(v[i]);
				}
			}
			for (int b = 0; b < OP - a; b++) {
				long sb = sa;
				ArrayList<Integer> blist = (ArrayList<Integer>) alist.clone();
				for (int i = N - 1; i > N - 1 - b; i--) {
					sb += v[i];
					if (v[i] < 0) {
						blist.add(v[i]);
					}
				}

				Collections.sort(blist);
				int pop = K - (a + b);
				for (int n : blist) {
					if (pop == 0) {
						break;
					}
					sb += Math.abs(n);
					pop--;
				}
				ans = Math.max(ans, sb);
			}
		}

		System.out.println(ans);

	}

}

Compiler output:
Main.java:26: error: incompatible types: long cannot be converted to Integer
					alist.add(v[i]);
					           ^
Main.java:35: error: incompatible types: long cannot be converted to Integer
						blist.add(v[i]);
						           ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
Note: Some messages have been simplified; recompile with -Xdiags:verbose to get full output
2 errors
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, k, m = 0;
  cin >> n >> k;
  deque<int> d;
  rep(i, n){
    int e;
    cin >> e;
    d.push_back(e);
  }
  rep(i, k+1){
    rep(j, k-i+1){
      int t = 0, a = 0, b = 0;
      deque<int> c = d;
      priority_queue<int, vector<int>, greater<int>> pq;
      while(a < i && !c.empty())){
        pq.push(c.front());
        c.pop_front();
        ++a;
      }
      while(b < j && !c.empty()){
        pq.push(c.back());
        c.pop_back();
        ++b;
      }
      rep(l, min(k-a-b, (int)pq.size())){
        if(pq.top() < 0) pq.pop();
        else break;
      }
      while(!pq.empty()){
        t += pq.top();
        pq.pop();
      }
      m = max(m, t);
    }
  }
  cout << m << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:33: error: expected primary-expression before ')' token
   44 |       while(a < i && !c.empty())){
      |                                 ^
Language: C++

#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main() {
  int n, k, m = 0;
  cin >> n >> k;
  deque<int> d;
  rep(i, n){
    int e;
    cin >> e;
    d.push_back(e);
  }
  rep(i, k+1){
    rep(j, k-i+1){
      int t = 0;
      deque<int> c = d;
      priority_pueue<int> pq;
      rep(l, i){
        pq.push(c.front());
        c.pop_front();
      }
      rep(l, j){
        pq.push(c.back());
        c.pop_back();
      }
      rep(l, k-i-j){
        if(pq.top() < 0) pq.pop();
        else break;
      }
      while(!pq.empty()){
        t += pq.top();
        pq.pop();
      }
      m = max(m, t);
    }
  }
  cout << m << endl;
  return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:43:7: error: 'priority_pueue' was not declared in this scope
   43 |       priority_pueue<int> pq;
      |       ^~~~~~~~~~~~~~
a.cc:43:22: error: expected primary-expression before 'int'
   43 |       priority_pueue<int> pq;
      |                      ^~~
a.cc:45:9: error: 'pq' was not declared in this scope
   45 |         pq.push(c.front());
      |         ^~
a.cc:49:9: error: 'pq' was not declared in this scope
   49 |         pq.push(c.back());
      |         ^~
a.cc:53:12: error: 'pq' was not declared in this scope
   53 |         if(pq.top() < 0) pq.pop();
      |            ^~
a.cc:56:14: error: 'pq' was not declared in this scope
   56 |       while(!pq.empty()){
      |              ^~
Language: C++

#include <bits/stdc++.h>

using namespace std;

int N,K;
int V[110];

int sum_l[110],sum_r[110];

int ans=INT32_MIN;

int main(){

    cin>>N>>K;
    for(int i=0;i<N;++i)cin>>V[i];

    int R=min(N,K)

    for(int X=0;X<=R;++X){
        for(int A=0;A<=X;++A){
            for(int B=0;B<=A;++B){
                if(X-2*A>0)continue;
                int v=0;
                vector<int> v_push;
                for(int i=0;i<B;++i){
                    v+=V[i];
                    v_push.push_back(V[i]);
                }
                for(int i=0;i<A-B;++i){
                    v+=V[N-i-1];
                    v_push.push_back(V[N-i-1]);
                }
                sort(v_push.begin(),v_push.end());
                for(int i=0;i<X-A;++i)v-=v_push[i];
                ans=max(ans,v);
            }
        }
    }

    cout<<ans<<endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:5: error: expected ',' or ';' before 'for'
   19 |     for(int X=0;X<=R;++X){
      |     ^~~
a.cc:19:17: error: 'X' was not declared in this scope
   19 |     for(int X=0;X<=R;++X){
      |                 ^
Language: C++

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

int main() {
    int N,K;cin >> N >> K;
    vector<ll> D(N);
    for (int i = 0;i < N;i++) cin >> D[i];
    ll res = 0;
    for (int a = 0;a <= min(N,K);a++){
        for (int b = 0;a + b <= min(N,K);b++){
            vector<ll> v;
            ll cur = 0;
            for (int i = 0;i < a;i++) v.push_back(D[i]),cur += D[i];
            for (int i = 0;i < b;i++) v.push_back(D[N - 1 - i]),cur += D[N - 1 - i];
            sort(v.begin(),v.end());
            for (int i = 0;i < min((K - a - b),v.size());i++){
                if (v[i] < 0) cur -= v[i];
            }
            res = max(res,cur);
        }
    }
    cout << res << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:17:35: error: no matching function for call to 'min(int, std::vector<long long int>::size_type)'
   17 |             for (int i = 0;i < min((K - a - b),v.size());i++){
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~
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:17:35: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'})
   17 |             for (int i = 0;i < min((K - a - b),v.size());i++){
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~
/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:17:35: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   17 |             for (int i = 0;i < min((K - a - b),v.size());i++){
      |                                ~~~^~~~~~~~~~~~~~~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
 
int main(){
int i,j,k;
int N,K;
cin >> N >> K;
int M = min(N,K);
int V[N];
vector<int> H;
vector<int> H2;
int count = 0;
int count2;
int ans = 0;
int tmp;
for(i=0;i<N;i++)cin >> V[i];
for(i=0;i<M+1;i++){
    count += V[i];
    if(V[i]<0)H.push_back(V[i]);
    copy(H.begin(),H.end(),H2.begin());
    count2=count;
    for(j=0;j<M+1-i;j++){
        count2+=V[N-j-1];
        if(V[N-j-i]<0)H2.push_back(V[N-j-1]);
        sort(H2.begin(),H2.end());
        tmp = count2;
        for(k=0;k<min(K-i-j,(int)H2.size()),k++)tmp = tmp - H2[k];
        ans=max(ans,tmp);
    }
    H2.clear();
}
cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:27:48: error: expected ';' before ')' token
   27 |         for(k=0;k<min(K-i-j,(int)H2.size()),k++)tmp = tmp - H2[k];
      |                                                ^
      |                                                ;
Language: C++

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n, k;
int a[MAXN];
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n >> k;
    REP (i, n) {
        cin >> a[i];
    }

    int ans = 0;

    for (int l=0; l<=n; l++) {
        for (int r=0; r<=n; r++) {
            if (l + r <= n && l + r <= k) {
                vector<int> hand;

                int sum = 0;
                REP (j, l) {
                    hand.eb(a[j]);
                    sum += a[j];
                }
                REP (j, r) {
                    hand.eb(a[n-1-j]);
                    sum += a[n-1-j];
                }
                sort(ALL(hand)2);
                debug(hand);

                debug(sum);

                REP (j, min(k-l-r, l+r)) {
                    if (hand[j] >= 0) {
                        break;
                    }
                    sum -= hand[j];
                }
                debug(sum);

                ans = max(ans, sum);

            }
        }
    }

    cout << ans << endl;


}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:31: error: expected ')' before numeric constant
   66 |                 sort(ALL(hand)2);
      |                     ~         ^
Language: C

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

ll lcm(ll a, ll b){
  return a/gcd(a,b) * b;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int main(){
  int N,K;
  cin >> N >> K;
  vector<int> V(N);
  rep(i,N){
    cin >> V[i];
  }
  vector<int> Vr(N);
  Vr = V;
  reverse(Vr.begin(),Vr.begin());

  
  int R = min(N,K);
  int ans = 0;
  int sum = 0;
  for(int A = 0;A<R;A++){
    for(int B = 0;B<R;B++){
      if(A + B > R) continue;
      vector<int> temoto;
      
      //前からA個、後ろからB個を手元に追加
      for(int i = 0;i<A;i++) {
        temoto.push_back(V[i]);
        sum += V[i];
      }
      for(int i = 0;i<B;i++) {
        temoto.push_back(V[N-1-i]);
        sum += V[N-1-i];
      }
      sort(temoto.begin(),temoto.end());
      for(int i = 0;i<min(K-A-B,(int)temoto.size());i++){
        if(temoto[i] < 0){
          sum += -temoto[i];
        }
      }
      //全てたし終わったらansを更新
      ans = max(ans,sum);
      sum = 0;
    }
  }
  cout << ans << endl;

}

Compiler output:
main.c:1:10: fatal error: bits/stdc++.h: No such file or directory
    1 | #include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~
compilation terminated.
Language: Java

public class Main {

	public static void main(String[] args) {

		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		LinkedList<Integer> deque = new LinkedList<>();
		for (int i = 0; i < n; ++i) {
			deque.addLast(scanner.nextInt());
		}
		int ret = findMaxSequence(deque, k);

		String out = String.valueOf(ret);

		System.out.print(out);
	}

	public static int findMaxSequence(LinkedList<Integer> deque, int k) {
		int n = deque.size();
		int min = Math.min(n, k);
		LinkedList<Integer> list = new LinkedList<>();
		int max = Integer.MIN_VALUE;
		for (int i = 0; i <= min; ++i) {
			for (int j = min - i; j >= 0; j--) {
				if (j == 0 && i == j) {
					break;
				}
				Deque<Integer> newDeque = (Deque<Integer>) deque.clone();
				list.clear();
				int a = i;
				int b = j;
				while (a > 0) {
					list.add(newDeque.pollFirst());
					a--;
				}
				while (b > 0) {
					list.add(newDeque.pollLast());
					b--;
				}
				Collections.sort(list);
				int remind = min - i - j;

				while (remind > 0 && !list.isEmpty() && list.peek() <= 0) {
					list.poll();
					remind--;
				}
				int newMax = 0;
				for (Integer integer : list)
					newMax += integer;
				if (max < newMax)
					max = newMax;
			}
		}
		return max < 0 ? 0 : max;
	}
}

Compiler output:
Main.java:19: error: cannot find symbol
	public static int findMaxSequence(LinkedList<Integer> deque, int k) {
	                                  ^
  symbol:   class LinkedList
  location: class Main
Main.java:5: error: cannot find symbol
		Scanner scanner = new Scanner(System.in);
		^
  symbol:   class Scanner
  location: class Main
Main.java:5: error: cannot find symbol
		Scanner scanner = new Scanner(System.in);
		                      ^
  symbol:   class Scanner
  location: class Main
Main.java:8: error: cannot find symbol
		LinkedList<Integer> deque = new LinkedList<>();
		^
  symbol:   class LinkedList
  location: class Main
Main.java:8: error: cannot find symbol
		LinkedList<Integer> deque = new LinkedList<>();
		                                ^
  symbol:   class LinkedList
  location: class Main
Main.java:22: error: cannot find symbol
		LinkedList<Integer> list = new LinkedList<>();
		^
  symbol:   class LinkedList
  location: class Main
Main.java:22: error: cannot find symbol
		LinkedList<Integer> list = new LinkedList<>();
		                               ^
  symbol:   class LinkedList
  location: class Main
Main.java:29: error: cannot find symbol
				Deque<Integer> newDeque = (Deque<Integer>) deque.clone();
				^
  symbol:   class Deque
  location: class Main
Main.java:29: error: cannot find symbol
				Deque<Integer> newDeque = (Deque<Integer>) deque.clone();
				                           ^
  symbol:   class Deque
  location: class Main
Main.java:41: error: cannot find symbol
				Collections.sort(list);
				^
  symbol:   variable Collections
  location: class Main
10 errors
Language: C++

public class Main {

	public static void main(String[] args) throws IOException {

		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int k = scanner.nextInt();
		LinkedList<Integer> deque = new LinkedList<>();
		for (int i = 0; i < n; ++i) {
			deque.addLast(scanner.nextInt());
		}
		int ret = findMaxSequence(deque, k);

		String out = String.valueOf(ret);

		System.out.print(out);
	}

	public static int findMaxSequence(LinkedList<Integer> deque, int k) {
		int n = deque.size();
		int min = Math.min(n, k);
		LinkedList<Integer> list = new LinkedList<>();
		int max = Integer.MIN_VALUE;
		for (int i = 0; i <= min; ++i) {
			for (int j = min - i; j >= 0; j--) {
				if (j == 0 && i == j) {
					break;
				}
				Deque<Integer> newDeque = (Deque<Integer>) deque.clone();
				list.clear();
				int a = i;
				int b = j;
				while (a > 0) {
					list.add(newDeque.pollFirst());
					a--;
				}
				while (b > 0) {
					list.add(newDeque.pollLast());
					b--;
				}
				Collections.sort(list);
				int remind = min - i - j;

				while (remind > 0 && !list.isEmpty() && list.peek() <= 0) {
					list.poll();
					remind--;
				}
				int newMax = 0;
				for (Integer integer : list)
					newMax += integer;
				if (max < newMax)
					max = newMax;
			}
		}
		return max < 0 ? 0 : max;
	}
}

Compiler output:
a.cc:1:1: error: expected unqualified-id before 'public'
    1 | public class Main {
      | ^~~~~~
Language: C++

#include<iostream>
#include<algorithm>
#define LL long long
#define Max 107
#define pb push_back
using namespace std;
int n,k;
LL a[Max];
priority_queue<LL,vector<LL>,greater<LL>>p;
LL fun(int l,int r){
for(int i=1;i<=l;i++)
p.push(a[i]);
for(int j=1,t=n;j<=r;j++,t--)
p.push(a[t]);
int opt=k-l-r;
while(p.size() && p.top()<0 && opt)
p.pop(),opt--;
LL sum=0;
while(p.size())
sum+=p.top(),p.pop();
return sum;
}
int main()
{
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++){
cin>>a[i];
}
LL sum=0;
for(int i=0;i<=k;i++){
for(int j=0;(i+j)<=min(n,k);j++){
sum=max(fun(i,j),sum);
}
}
cout<<sum<<endl;
return 0;
}

Compiler output:
a.cc:9:1: error: 'priority_queue' does not name a type
    9 | priority_queue<LL,vector<LL>,greater<LL>>p;
      | ^~~~~~~~~~~~~~
a.cc: In function 'long long int fun(int, int)':
a.cc:12:1: error: 'p' was not declared in this scope
   12 | p.push(a[i]);
      | ^
a.cc:14:1: error: 'p' was not declared in this scope
   14 | p.push(a[t]);
      | ^
a.cc:16:7: error: 'p' was not declared in this scope
   16 | while(p.size() && p.top()<0 && opt)
      |       ^
a.cc:19:7: error: 'p' was not declared in this scope
   19 | while(p.size())
      |       ^
Language: C++

#include<iostream>
#include<stdio.h>
#define LL long long
#define Max 105
#define mem(a,b) memset(a,(int)b,sizeof(a));
#define pb push_back
#define mp make_pair
using namespace std;
int n,k;
LL fun(int l,int r){
for(int i=1;i<=l;i++)
p.push(a[i]);
for(int j=1,t=n;j<=r;j++,t--)
p.push(a[t]);
int opt=k-l-r;
while(p.size() && p.top()<0 && opt)
p.pop(),opt--;
LL sum=0;
while(p.size())
sum+=p.top(),p.pop();
return sum;
}
int main()
{
scanf("%d%d",&n,&k);
for(int i=1;i<=n;i++){
cin>>a[i];
}
LL sum=0;
for(int i=0;i<=k;i++){
for(int j=0;(i+j)<=min(n,k);j++){
sum=max(fun(i,j),sum);
}
}
cout<<sum<<endl;
return 0;
}

Compiler output:
a.cc: In function 'long long int fun(int, int)':
a.cc:12:1: error: 'p' was not declared in this scope
   12 | p.push(a[i]);
      | ^
a.cc:12:8: error: 'a' was not declared in this scope
   12 | p.push(a[i]);
      |        ^
a.cc:14:1: error: 'p' was not declared in this scope
   14 | p.push(a[t]);
      | ^
a.cc:14:8: error: 'a' was not declared in this scope
   14 | p.push(a[t]);
      |        ^
a.cc:16:7: error: 'p' was not declared in this scope
   16 | while(p.size() && p.top()<0 && opt)
      |       ^
a.cc:19:7: error: 'p' was not declared in this scope
   19 | while(p.size())
      |       ^
a.cc: In function 'int main()':
a.cc:27:6: error: 'a' was not declared in this scope
   27 | cin>>a[i];
      |      ^
Language: C++

#include <iostream>
#include <queue>
using namespace std;
int main()
{
    int n, k;
    int v[50];
    int su[50];
    

    cin >> n >> k;
    for (int i = 0;i < n;i++)
    {
        cin >> v[i];
    }

    su[0] = v[0];
    for (int i = 1;i < n;i++)
    {
        su[i] = su[i - 1] + v[i]; 
    }

    int ans = 0;
    for (int r = 1;r < n;r++)
    {
        for (int l = 0;l < r;l++)
        {
            int po = l + n - 1 - r;
            if (po < k - po || po > k)continue;
            int s = (l == 0 ? 0 : su[l - 1]) + (su[n - 1] - su[r]);
            priority_queue<int, vector<int>, greater<int> > q;
            for (int i = 0;i < l;i++)
            {
                q.push(v[i]);
            }
            for (int i = r + 1;i < n;i++)
            {
                q.push(v[i]);
            }
            for (int i = 0;i < (k - po)z;i++)
            {
                s -= q.top(); q.pop();
            }
            ans = max(ans, s);
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:40: error: expected ';' before 'z'
   40 |             for (int i = 0;i < (k - po)z;i++)
      |                                        ^
      |                                        ;
a.cc:40:40: error: 'z' was not declared in this scope
a.cc:40:41: error: expected ')' before ';' token
   40 |             for (int i = 0;i < (k - po)z;i++)
      |                 ~                       ^
      |                                         )
a.cc:40:42: error: 'i' was not declared in this scope
   40 |             for (int i = 0;i < (k - po)z;i++)
      |                                          ^
Language: C++

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

int main(){
  long long n, k; cin >> n >> k;
  vector<long long> v(n);
  for(int i = 0;i < n; i++){
    cin >> v.at(i);
  }
  long long out = 0;
  for(int i = 1; i < k + 1; i++){
    for(int j = 0; j < k + 1; j++){
      vector<long long> tmp(i);
      long long out_tmp = 0;
      for(int l = 0; l < j; l++) tmp.at(l) += v.at(l);
      for(int l = 0; l < i - j; l++) tmp.t(l + j) += v.at(n - 1 - l);
      sort(tmp.begin(), tmp.end());
      for(int l = 0; l < i; l++){
        out_tmp += tmp.at(l);
      }
      for(int l = 0; l < k - i; l++){
        if(tmp.at(l) >= 0){
          break;
        }else{
          out_tmp -= tmp.at(l);
        }
      }
      if(out_tmp > out) out = out_tmp;
    }
  }
  cout << out;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:42: error: 'class std::vector<long long int>' has no member named 't'; did you mean 'at'?
   16 |       for(int l = 0; l < i - j; l++) tmp.t(l + j) += v.at(n - 1 - l);
      |                                          ^
      |                                          at
Language: C++

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

#define lint long long

#define Pair pair<string, int>;
const int INF = 1E9;

int main(){
    int N, K;
    
    cin >> N >> K;
    
    vector<int> V(N);
    
    for(int i = 0; i < N; ++i){
        cin >> V[i];
    }
    
    lint largest = 0;
    
    for(int i = 0; i <= K; ++i){
        for(int j = 0; j <= K - i; ++j){
            vector<int> nums;
            for(int k = 0; k < i; ++k){
                nums.push_back(V[k]);
            }
            for(int k = N - 1; k >= N - j; --k){
                nums.push_back(V[k]);
            }
            sort(nums.begin(), nums.end());
            
            lint sum = 0;
            
            for(int nums[k] = 0; k < (i + j) ; ++k){
                if(k > 0 || k > (K - (i + j) - 1)){
                    sum += nums[k];
                }
            }
            largest = max(largest, sum);
        }
    }
    
    cout << largest  << endl;
    
}


Compiler output:
a.cc: In function 'int main()':
a.cc:35:26: error: 'k' was not declared in this scope
   35 |             for(int nums[k] = 0; k < (i + j) ; ++k){
      |                          ^
Language: C++

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1e11;

int main() {
  int n, kk;
  cin >> n >> kk;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];

  int m = min(n, k);
  ll ans = -1LL*INF;
  for (int i = 0; i <= m; ++i) {
    for (int j = 0; i + j <= m; ++j) {
      ll val = 0;
      int c = kk - i - j;
      vector<ll> a;
      for (int k = 0; k < i; ++k) a.push_back(v[k]);
      for (int k = 0; k < j; ++k) a.push_back(v[n - 1 - k]);
      for (auto aa : a) val += aa;
      sort(a.begin(), a.end());
      for (int k = 0; k < c && k < a.size() && a[k] < 0; ++k) val -= a[k];
      ans = max(ans, val);
    }
  }

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


Compiler output:
a.cc: In function 'int main()':
a.cc:14:18: error: 'k' was not declared in this scope
   14 |   int m = min(n, k);
      |                  ^
Language: C++

#include<iostream>
#include<algorithm>

using namespace std;

int v[110], dp[55][55][110];

int f(int i, int j, int k) {
	if (k == 0 || i > j)
		return 0;
  
	if (dp[i][j][k] != -1)
		return dp[i][j][k];
  
	int ans = 0;
	if (k > 0) {
      
      
		ans = max(v[i] + f(i + 1, j, k - 1), ans);
		ans = max(v[j] + f(i, j - 1, k - 1), ans);
	}
	if (k > 1) {
      
		ans = max(f(i + 1, j, k - 2), ans);
		ans = max(f(i, j - 1, k - 2), ans);
	}
	return dp[i][j][k] = ans;
}

int main() {
	int n, k;
  cin >> n >> k;
  
	for (int i = 0; i < n; i++) cin >> v[i];
  
	memset(dp, -1, sizeof(int) * 250000);
  
	cout << f(0, n - 1, k) << endl;

	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:36:9: error: 'memset' was not declared in this scope
   36 |         memset(dp, -1, sizeof(int) * 250000);
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<algorithm>
  +++ |+#include <cstring>
    3 |
Language: C++

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

int v[100], dp[50][50][100];

int f(int i, int j, int k) {
	if (k == 0 || i > j)
		return 0;
	if (dp[i][j][k] != -1)
		return dp[i][j][k];
	int ans = 0;
	if (k > 0) {
		ans = max(v[i] + f(i + 1, j, k - 1), ans);
		ans = max(v[j] + f(i, j - 1, k - 1), ans);
	}
	if (k > 1) {
		ans = max(f(i + 1, j, k - 2), ans);
		ans = max(f(i, j - 1, k - 2), ans);
	}
	return dp[i][j][k] = ans;
}

int main() {
	int n, k; cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> v[i];
	memset(dp, -1, sizeof(int) * 250000);
	cout << f(0, n - 1, k) << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:27:9: error: 'memset' was not declared in this scope
   27 |         memset(dp, -1, sizeof(int) * 250000);
      |         ^~~~~~
a.cc:3:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    2 | #include<algorithm>
  +++ |+#include <cstring>
    3 | using namespace std;
Language: C++

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

int main(){
  int n, k;
  cin >> n >> k;
  vector<int> v(n);
  for(int i = 0; i < n; i++){
    cin >> v.at(i);
  }
  long int out = 0;
  for(int i = 0; i < n; i++){
    for(int j = 0; j < k + 1 - i; j++){
      vector<int> value(i + j);
      for(int l = 0; l < i; l++){
        value.at(l) = v.at(l);
      }
      for(int l = 0; l < j; l++){
        value.at(i + l) = v.at(n - 1 - l);
      }
      sort(value.begin(), value.end());
      for(int l = 0; l < k - i - j; l++){
        if(value.at(l) < 0){
          value.pop_front();
        }else{
          break;
        }
      }
      long int tmp = 0;
      while(value.size() != 0){
        tmp += value.at(0);
        value.pop_front();
      }
      if(tmp > out) out = tmp;
    }
  }
  cout << out;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:24:17: error: 'class std::vector<int>' has no member named 'pop_front'
   24 |           value.pop_front();
      |                 ^~~~~~~~~
a.cc:32:15: error: 'class std::vector<int>' has no member named 'pop_front'
   32 |         value.pop_front();
      |               ^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, K, ans = 0, all = 0;
    cin >> N >> K;
    vector<int> V(N), L(N), R(N);
    for (int i = 0; i < N; i++) {
        cin >> V.at(i);
        all += V.at(i);
    }
    for (int i = 0; i < N - 1; i++) {
        L.at(i + 1) = L.at(i) + V.at(i);
    }
    for (int i = 0; i < N - 1; i++) {
        R.at(i + 1) = R.at(i) + V.at(N - i - 1);
    }

    for (int i = 1; i <= K; i++) {
        vector<int> A(i);
        if (i == N) {
            int sum = all;
            A = V;
            sort(ALL(A));
            for (int j = 0; j < K - N; i++){
                if (A.at(j) < 0) {
                    sum -= A.at(j);
                }
                else {
                    cout << max(ans, sum) << endl;
                    return 0;
                }
                if (j == K - N - 1){
                    cout << max(ans, sum) << endl;
                    return 0;
                }
            }
            cout << max(ans, sum) << endl;
            return 0;
        }
        for (int j = 0; j < i + 1; j++) {
            
            int sum = 0;
            sum += L.at(j) + R.at(i - j);
            for (int k = 0; k < j; k++) {
                A.at(k) = V.at(k);
            }
            for (int k = j; k < i; k++) {
                A.at(k) = V.at(N + j - k - 1);
            }
            sort(ALL(A));
            if (i == k) {
                ans = max(ans, sum);
            }
            
            for (int k = 0; k < K - i; k++) {
                if (A.at(k) < 0) {
                    sum -= A.at(k);
                }
                else {
                    ans = max(ans, sum);
                    break;
                }
                if (k == K - i - 1 || k == i - 1){
                    ans = max(ans, sum);
                    break;
                }
            }
        }
    }
    cout << ans << endl;

}


Compiler output:
a.cc: In function 'int main()':
a.cc:56:22: error: 'k' was not declared in this scope
   56 |             if (i == k) {
      |                      ^
Language: C++

#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <deque>
using ll = long long;

using namespace std;

int main() {
    ll N,K;
    cin >> N >> K;
    deque<ll> baseDeq;
    for(ll i = 0; i < N; i++){
        ll tmp;
        cin >> tmp;
        baseDeq.push_back(tmp);
    }
    ll 

Compiler output:
a.cc: In function 'int main()':
a.cc:22:7: error: expected unqualified-id at end of input
   22 |     ll
      |       ^
a.cc:22:7: error: expected '}' at end of input
a.cc:13:12: note: to match this '{'
   13 | int main() {
      |            ^
Language: C++

#include <bits/stdc++.h>

#define rep0(i, n) for(int i=0; i<(int)(n);i++)
#define rep1(i, n) for(int i=1; i<=(int)(n);i++)
#define all(x) (x).begin(), (x).end()

#define debug(a) if(flagdebug){cout << "debug (" #a "):" << endl << (a) << endl;}
template<typename T> ostream& operator << (ostream& s, const vector<T>& v);
bool flagdebug = false;

using namespace std;
typedef int64_t lint;

int main(){
    //flagdebug = true; ///本番時削除！！！！！

    lint n, k;
    cin >> n >> k;
    vector<lint> v(n + 1); //1~n
    rep1(i,n)
    {
        cin >> v[i];
    }

    lint lp = 0; //左から取ったときの価値プラスの合計
    vector<lint> lgabage; //左から取った時に発生するゴミ
    lint ans = 0; //解答

    //左から取る回数で全探索
    for(lint l = 0 ; l <= min(k,n) ; l ++)
    {
        if(l > 0)
        {
            if(v[l]>=0)//価値0以上のみlpに加算
            {
                lp+=v[l];
            }
            else //それ以下はゴミとして保存
            {
                lgabage.push_back(v[l]);
            }
        }

        lint rp = 0;
        vector<lint> gabage;//右から取った時に発生するゴミ（左からの分もコピーしておく）
        copy(all(lgabage), back_inserter(gabage));
        //右から取る回数の全探索
        for ( lint r = 0 ; r <= min(k,n) ; r ++)
        {
            if(l + r > n)break; //筒が空なら
            if(l + r > k)break; //行動回数制限を超えていたら

            if(r > 0)
            {
                if(v[n+1-r]>=0) //価値0以上のみrpに加算
                {
                    rp+=v[n+1-r];
                }
                else //それ以下はゴミとして保存
                {
                    gabage.push_back(v[n+1-r]);
                }
            }

            lint val = lp + rp; //価値（マイナスは含まない）

            //余った行動回数(k - l - r)でマイナスを捨てることを考える
            if(k - l - r < gabage.size())
            {
                //行動回数が足りないのでマイナスを一部加算する
                //昇順に並べ替えるとマイナスの絶対値が大きいものが前にくる
                //前の方は捨てるので後ろの方のみ結果に加算する
                sort(all(gabage));
                for(lint i = k - l - r; i < gabage.size() ; i++)
                {
                    val += gabage[i];
                }
            }
            //else//行動回数があるのでマイナスは全て捨てる（ので，余計な作業はいらない）


            ans = max(val,ans);
        }
    }

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

//vectorprint用
template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
    s << "[\t";
    for (auto i = v.begin(); i < v.end() - 1; i++){s << *i << "\t";}
    s << *(v.end() - 1) << "\t]\n";
	return s;
}

Compiler output:
a.cc:8:22: error: 'ostream' does not name a type
    8 | template<typename T> ostream& operator << (ostream& s, const vector<T>& v);
      |                      ^~~~~~~
Language: C++

#include <bits/stdc++.h>
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];
  }
  long long ans=0;
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k-i;j++){
      if(i+j>n) break;
      int d=k-i-j;
      vector<int> s(0);
      int now=0;
      for(int a=0;a<i;a++){
        now+=v[a];
        s.push_back(v[a]);
      }
      for(int b=n-j;b<n;b++){
        now+=v[b];
        s.push_back(v[b]);
      }
      sort(s.begin(),s.end());
      for(int r=0;r<d;r++){
        if(r==s.size()) break;
        if(s[i]>0) break;
        now-=s[i];
      }
      ans=max(now,ans);
    }
  }
  cout<<ans<<endl;
}
      

Compiler output:
a.cc: In function 'int main()':
a.cc:32:14: error: no matching function for call to 'max(int&, long long int&)'
   32 |       ans=max(now,ans);
      |           ~~~^~~~~~~~~
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:32:14: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   32 |       ans=max(now,ans);
      |           ~~~^~~~~~~~~
/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:32:14: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   32 |       ans=max(now,ans);
      |           ~~~^~~~~~~~~
Language: C++

#include "stdafx.h"

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>
#include <queue>
#include <sstream>
#include <iomanip>

using namespace std;

#define PI 3.14159265359

int main()
{
	int N, K;
	cin >> N >> K;

	vector<int> Vs(N);

	for (int ni = 0; ni < N; ni++) {
		cin >> Vs[ni];
	}


	int R = min(N, K);
	long long ans = 0;
	long long sc;

	for (int a = 0; a <= N; a++) {
		for (int b = 0; a + b <= R; b++) {
			vector<long long> bag;

			for (int ni = 0; ni < N; ni++){
				if (ni < a || N -b <= ni){
					bag.push_back(Vs[ni]);
				}
			}

			sort(bag.begin(), bag.end());

			for (int ci = 0; ci < R - a - b; ci++) {
				if (ci >= bag.size())break;
				if (bag[ci] < 0){
					bag[ci] = 0;
				}
			}

			sc = 0;
			for(int di = 0; di < bag.size(); di++){
				sc += bag[di];
			}

			if (sc > ans) {
				ans = sc;
			}
		}
	}

	cout << ans;

	return 0;
}



Compiler output:
a.cc:1:10: fatal error: stdafx.h: No such file or directory
    1 | #include "stdafx.h"
      |          ^~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0; i < n; ++i)
const ll MOD = 1000000007;

int main(){
    int n, k; cin >> n >> k;
    vector<ll> v(n); rep(i,n) cin >> v[i];
    priority_queue<ll,vector<ll>,greater<ll>> have;
    int r = min(n,k);
    ll ans = -100000000;
    ll tmp = 0;
    for(int a = 0; a <= r; ++a){
        for(int b = 0; a+b <= r; ++b){
            tmp = 0;
            rep(i,a) have.push(v[i]);
            rep(i,b) have.push(v[n-i-1]);
            rep(i,k-(a+b)) if(!have.empty() && have.top() < 0) have.pop();
            int tmp_have_size = have.size();
            rep(i,tmp_have_size){
                tmp += have.top();
                have.pop();
            }
            ans = max(ans, tmp);
            while(!have.empty()) have.pop();
        }
    }
    cout << ans << endl;
}

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

#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <map>
#include <cassert>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)

using namespace std;
typedef long long int ll;

int nextsmallest(vector<int> &v, int sidx) {
    int l = 0, u = v.size()-1;
    if (v[0] > sidx) {
        u = 0;
    } else if (v[u] > sidx) {
        while (u - l > 1) {
            int b = (l+u+1)/2;
            ll h = v[b];
            if (h > sidx) u = b;
            else if (h < sidx) l = b;
            else u = l = b+1;
        }
    } else u = u + 1;
    
    u = u%v.size();
    return u;
}

int main(int argc, const char * argv[]) {
    ll N, K;
    cin >> N >> K;
    vector<ll> V(N);
    REP(i, N) {
        cin >> V[i];
    }
    
    ll score = 0;
    REP(k, K+1) {
        ll take = K - k;
        ll give = k;
        
        if (take >= N) continue;
        REP(l, take+1) {
            ll r = take-l;
            vector<ll> s;
            ll q = 0;
            REP(i, N) {
                if (i < l || N-r-1 < i) {
                    s.push_back(V[i]);
                }
            }
            sort(s.begin(), s.end());
            REP(i, s.size()-give) {
                q += s[give+i];
            }
            score = max(score, q);
        }
        
    }
    cout << score << endl;
}


Compiler output:
a.cc: In function 'int main(int, const char**)':
a.cc:53:13: error: 'sort' was not declared in this scope; did you mean 'short'?
   53 |             sort(s.begin(), s.end());
      |             ^~~~
      |             short
Language: C++

#include <bits/stdc++.h>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> v(n);

  rep(i, n) cin >> v[i];

  const int n = min(N, K);
  int ans = -2e9;
  for (int a = 0; a <= n; a++) {
    for (int b = 0; a + b <= n; b++) {
      const int c = K - a - b;
      vector<int> t;
      for (int i = 0; i < a; i++) t.push_back(v[i]);
      for (int i = 0; i < b; i++) t.push_back(v[N - i - 1]);
      sort(t.begin(), t.end());
      int s = 0;
      for (int& x : t) s += x;
      for (int i = 0; i < c && i < t.size() && t[i] < 0; i++) s -= t[i];
      ans = max(ans, s);
    }
  }
  cout << ans;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:15:13: error: conflicting declaration 'const int n'
   15 |   const int n = min(N, K);
      |             ^
a.cc:9:7: note: previous declaration as 'int n'
    9 |   int n, k;
      |       ^
a.cc:15:21: error: 'N' was not declared in this scope
   15 |   const int n = min(N, K);
      |                     ^
a.cc:15:24: error: 'K' was not declared in this scope
   15 |   const int n = min(N, K);
      |                        ^
Language: C++

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int>a(n);
  rep(i,n)cin>>a[i];
  int ans=0;
  
  for(int l=0;l<k;++l){
    for(int r=0;r<k-l;r++){
      if (l+r>n)continue;
      int d=k-l-r;
      int now=0;
      vector<int>s;
      rep(i,l){
        now+=a[i];
        s.push_back();
      }
      for(int i=n-r;i<n;++i){
        now+=a[i];
        s.push_back();
      }
      sort(s.begin(),s.end());
      for(int i=0;i<d;++i){
        if(i>=s.size())break;
        if(s[i]>0)break;
        now-=s[i];
      }
      ans=max(ans,now);
    }
  }
  cout<<ans<<endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:20:20: error: no matching function for call to 'std::vector<int>::push_back()'
   20 |         s.push_back();
      |         ~~~~~~~~~~~^~
In file included from /usr/include/c++/14/vector:66,
                 from /usr/include/c++/14/functional:64,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:53,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 0 provided
a.cc:24:20: error: no matching function for call to 'std::vector<int>::push_back()'
   24 |         s.push_back();
      |         ~~~~~~~~~~~^~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1283 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1283:7: note:   candidate expects 1 argument, 0 provided
/usr/include/c++/14/bits/stl_vector.h:1300:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; value_type = int]'
 1300 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/14/bits/stl_vector.h:1300:7: note:   candidate expects 1 argument, 0 provided