criyle/codenet-compile-errors huggingface dataset:
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;
  int now=0;
  vector<int>s;
  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;
      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:19:20: error: no matching function for call to 'std::vector<int>::push_back()'
   19 |         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:23:20: error: no matching function for call to 'std::vector<int>::push_back()'
   23 |         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
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
#include <utility>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
using namespace std;
using int64 = long long;
using vint = vector<int>;
using vint64 = vector<int64>;
#define ForInt(i, n) for (int i = 0; i < (n); ++i)
#define ForLong(i, n) for (int64 i = 0; i < (n); ++i)
#define ForIntInit(i, begin, end) for (int i = (begin); i < (end); ++i)
#define ForItr(it, itBegin, itEnd) for (auto it = (itBegin); it != (itEnd); ++it)
#define Min(a, b) ((a) < (b) ? (a) : (b))
#define Max(a, b) ((a) > (b) ? (a) : (b))



int main()
{
	int n, k;
	cin >> n >> k;
	vint v(n);
	ForInt(i, n)
	{
		cin >> v[i];
	}

	int max = INT_MIN;
	ForInt(a, n)
	{
		ForInt(b, n - a)
		{
			if (a + b > k) break;

			vint take(a + b);
			copy(v.begin(), v.begin() + a, take.begin());
			copy(v.rbegin(), v.rbegin() + b, take.begin() + a);
			int sum = 0;
			ForInt(i, take.size())
			{
				sum += take[i];
			}
			int restK = k - a - b;
			if (restK > 0)
			{
				sort(take.begin(), take.end());
				for (int i = 0; i < restK && i < take.size() && take[i] < 0; ++i)
				{
					sum -= take[i];
				}
			}
			//cout << "a = " << a << ", b = " << b << ", sum = " << sum << endl;
			max = Max(max, sum);
		}
	}

	// a + b = n
	if (k >= n)
	{
		int sum = 0;
		ForInt(i, n)
		{
			sum += v[i];
		}
		int restK = k - n;
		if (restK > 0)
		{
			sort(v.begin(), v.end());
			for (int i = 0; i < restK && i < n && v[i] < 0; ++i)
			{
				sum -= v[i];
			}
		}
		max = Max(max, sum);
	}
	cout << max << endl;

	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:35:19: error: 'INT_MIN' was not declared in this scope
   35 |         int max = INT_MIN;
      |                   ^~~~~~~
a.cc:12:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   11 | #include <unordered_set>
  +++ |+#include <climits>
   12 | using namespace std;
Language: C++

#include <bits/stdc++.h>
using namespace std;
int n;
long long a[51],mem[51][51][101];
long long dp(int l,int r,int k)
{
    if(k<0){return INT_MIN;}
    if(k==0 || l>r)return 0;
    long long &ret=mem[l][r][k];
    if(ret!=-1){return ret;}
    long long x=max(dp(l+1,r,k-1)+a[l] , dp(l,r-1,k-1)+a[r]);
    long long y=max(dp(l+1,r,k-2) , dp(l,r-1,k-2));
    return ret=max(x,max(y,0));

}
int main()
{
    int k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>a[i];
    memset(mem,-1,sizeof mem);
    long long ans=dp(1,n,k);
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'long long int dp(int, int, int)':
a.cc:13:25: error: no matching function for call to 'max(long long int&, int)'
   13 |     return ret=max(x,max(y,0));
      |                      ~~~^~~~~
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:13:25: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   13 |     return ret=max(x,max(y,0));
      |                      ~~~^~~~~
/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:13:25: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |     return ret=max(x,max(y,0));
      |                      ~~~^~~~~
Language: C++

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 111;

int N, K;
int V[MAX];

int query(int left, int right) {
    if (left+right > K) return -1;
    vi v;
    int ans = 0;
    REP (i, left) {
        v.PB(V[i]);
        ans += V[i];
    }
    REP (i, right) {
        v.PB(V[N-1-i]);
        ans += V[N-1-i];
    }
    sort(ALL(v));
    REP (i, K-left-right) if (v[i] < 0){
        ans -= V[i];
    }
    return ans;
}

int solve() {
    int ans = 0;
    RPE (l, N) REP (r, N-l) {
        ans = min(ans, query(l, r));
    }
    return ans;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> V[i];
    cout << solve() << endl;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:50:10: error: 'l' was not declared in this scope; did you mean 'll'?
   50 |     RPE (l, N) REP (r, N-l) {
      |          ^
      |          ll
a.cc:50:5: error: 'RPE' was not declared in this scope; did you mean 'REP'?
   50 |     RPE (l, N) REP (r, N-l) {
      |     ^~~
      |     REP
a.cc:50:21: error: 'r' was not declared in this scope
   50 |     RPE (l, N) REP (r, N-l) {
      |                     ^
a.cc:13:33: note: in definition of macro 'REP'
   13 | #define REP(i,n) for (ll i = 0; i < n; ++i)
      |                                 ^
Language: C++

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (int i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()

const int MAX = 111;

int N, K;
int V[MAX];

int query(int left, int right) {
    if (left+right > K) return -1;
    vi v;
    int ans = 0;
    REP (i, left) {
        v.PB(V[i]);
        ans += V[i];
    }
    REP (i, right) {
        v.PB(V[N-1-i]);
        ans += V[N-1-i];
    }
    sort(ALL(v));
    REP (i, K-left-right) if (v[i] < 0){
        ans -= V[i];
    }
    return ans;
}

int solve() {
    REP (i, N) {
        dp1[i+1][i+1] = dp1[i][i] + A[i];
        dp2[i+1][i+1] = dp2[i][i] + A[N-1-i];
    }

    int ans = 0;
    RPE (l, N) REP (r, N-l) {
        ans = min(ans, query(l, r));
    }
    return ans;
}

int main() {
    cin >> N >> K;
    REP (i, N) cin >> V[i];
    cout << solve() << endl;
}

Compiler output:
a.cc: In function 'int solve()':
a.cc:50:9: error: 'dp1' was not declared in this scope
   50 |         dp1[i+1][i+1] = dp1[i][i] + A[i];
      |         ^~~
a.cc:50:37: error: 'A' was not declared in this scope
   50 |         dp1[i+1][i+1] = dp1[i][i] + A[i];
      |                                     ^
a.cc:51:9: error: 'dp2' was not declared in this scope; did you mean 'dup2'?
   51 |         dp2[i+1][i+1] = dp2[i][i] + A[N-1-i];
      |         ^~~
      |         dup2
a.cc:55:10: error: 'l' was not declared in this scope; did you mean 'll'?
   55 |     RPE (l, N) REP (r, N-l) {
      |          ^
      |          ll
a.cc:55:5: error: 'RPE' was not declared in this scope; did you mean 'REP'?
   55 |     RPE (l, N) REP (r, N-l) {
      |     ^~~
      |     REP
a.cc:55:21: error: 'r' was not declared in this scope
   55 |     RPE (l, N) REP (r, N-l) {
      |                     ^
a.cc:13:33: note: in definition of macro 'REP'
   13 | #define REP(i,n) for (ll i = 0; i < n; ++i)
      |                                 ^
Language: C++

#include <iostream>
#include <string>
#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];
    }

    long long res = 0;    
    for (int i = 0; i <= min(K, N); i++){
        for (int j = 0; j <= min(K, N) - i; j++){
            vector<long long> q;
            long long cur = 0;
            for (int k = 0; k < i; k++) q.push_back(v[k]), cur += v[k];
            for (int l = 0; l < j; l++) q.push_back(v[N-l-1]), cur += v[N-l-1];
            
            sort(q.begin(), q.end());

            for (int m = 0; m < min(K-i-j, (int)q.size()); m++){
                if(q[m] < 0) cur -= q[m];
            }
            res = max(res, cur);
        }
    }
    cout << res << endl;
}

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

#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;
signed main(){
    int n,k;
    cin>>n>>k;
    int v[50];
    for(int i=0;i<n;i++)cin>>v[i];
    int f[51];
    f[0]=0;
    for(int i=1;i<=n;i++){
        f[i]=f[i-1]+v[i-1];
    }
    int b[51];
    b[0]=0;
    for(int i=1;i<=n;i++){
        b[i]=b[i-1]+v[n-i];
    }
    int ans=-INF;
    for(int i=0;i<101;i++)m[i]=-INF;
    priority_queue<int,vector<int>,greater<int> > que;
    priority_queue<int,vector<int>,greater<int> > memo;
    for(int i=0;i<=n;i++){
        que=memo;
        if(i>0)que.push(v[i-1]);
        memo=que;
        for(int j=0;j<=n;j++){
            if(j>0)que.push(v[n-j]);
            if(i+j>n||i+j>k)break;
            else {
                int a=f[i]+b[j];
                priority_queue<int,vector<int>,greater<int> > s;
                s=que;
                for(int l=0;l<k-i-j;l++){
                    if(s.empty())break;
                    if(s.top()>0)break;
                    else a-=s.top();
                    s.pop();
                }
                if(a==105){
                    cout<<i<<j<<endl;
                }
                ans=max(ans,a);
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:40:27: error: 'm' was not declared in this scope
   40 |     for(int i=0;i<101;i++)m[i]=-INF;
      |                           ^
Language: C++

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

int n,k,v[55],ans,sum[55],goukei;

int main(){
    cin>>n>>k>>v[0];
    sum[0]=v[0];
    goukei=v[0];
    for(int i=1;i<n;i++){
        cin>>v[i];
        sum[i]=sum[i-1]+v[i];
        goukei+=v[i];
    }
    for(int i=0;i<min(n,k);i++){
		for(int j=0;j<min(n,k)-i;j++){
			vector<int> h;
			int karians=0;
			for(int l=0;l<n;l++){
				if(l<i||n-j-1<l){
					h.push_back(v[l]);
					karians+=v[l];
				}
				
				
			}
			sort(h.begin(),h.end(),greater<int>());
			
			int kai=0;
			for(int l=0;l<k-i-j&&h.size()>0;l++){
				if(h.back()<0){
					karians+=0-h.back();
					h.pop_back();
				}
				else{
					break;
				}
				kai++;
			}
			
			ans=max(ans,karians);
		}
	}
    cout<<ans<<endl;
    
}


Compiler output:
a.cc:2:18: error: declaration does not declare anything [-fpermissive]
    2 | #define int long long;
      |                  ^~~~
a.cc:5:1: note: in expansion of macro 'int'
    5 | int n,k,v[55],ans,sum[55],goukei;
      | ^~~
a.cc:5:5: error: 'n' does not name a type
    5 | int n,k,v[55],ans,sum[55],goukei;
      |     ^
a.cc:2:18: error: declaration does not declare anything [-fpermissive]
    2 | #define int long long;
      |                  ^~~~
a.cc:7:1: note: in expansion of macro 'int'
    7 | int main(){
      | ^~~
a.cc:7:5: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | int main(){
      |     ^~~~
a.cc: In function 'int main()':
a.cc:8:10: error: 'n' was not declared in this scope; did you mean 'yn'?
    8 |     cin>>n>>k>>v[0];
      |          ^
      |          yn
a.cc:8:13: error: 'k' was not declared in this scope
    8 |     cin>>n>>k>>v[0];
      |             ^
a.cc:8:16: error: 'v' was not declared in this scope
    8 |     cin>>n>>k>>v[0];
      |                ^
a.cc:9:5: error: 'sum' was not declared in this scope
    9 |     sum[0]=v[0];
      |     ^~~
a.cc:10:5: error: 'goukei' was not declared in this scope
   10 |     goukei=v[0];
      |     ^~~~~~
a.cc:2:18: error: declaration does not declare anything [-fpermissive]
    2 | #define int long long;
      |                  ^~~~
a.cc:11:9: note: in expansion of macro 'int'
   11 |     for(int i=1;i<n;i++){
      |         ^~~
a.cc:11:13: error: 'i' was not declared in this scope
   11 |     for(int i=1;i<n;i++){
      |             ^
a.cc:11:20: error: expected ')' before ';' token
   11 |     for(int i=1;i<n;i++){
      |        ~           ^
      |                    )
a.cc:11:21: error: 'i' was not declared in this scope
   11 |     for(int i=1;i<n;i++){
      |                     ^
a.cc:2:18: error: declaration does not declare anything [-fpermissive]
    2 | #define int long long;
      |                  ^~~~
a.cc:16:9: note: in expansion of macro 'int'
   16 |     for(int i=0;i<min(n,k);i++){
      |         ^~~
a.cc:16:27: error: expected ')' before ';' token
   16 |     for(int i=0;i<min(n,k);i++){
      |        ~                  ^
      |                           )
a.cc:45:11: error: 'ans' was not declared in this scope; did you mean 'abs'?
   45 |     cout<<ans<<endl;
      |           ^~~
      |           abs
Language: C++

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

int n,k,v[55],ans,sum[55],goukei;

int main(){
    cin>>n>>k>>v[0];
    sum[0]=v[0];
    goukei=v[0];
    for(int i=1;i<n;i++){
        cin>>v[i];
        sum[i]=sum[i-1]+v[i];
        goukei+=v[i];
    }
    for(int i=0;i<min(n,k);i++){
		for(int j=0;j<min(n,k)-i;j++){
			vector<int> h;
			int karians=0;
			for(int l=0;l<n;l++){
				if(l<i||n-j-1<l){
					h.push_back(v[l]);
					karians+=v[l];
				}
				
				
			}
			sort(h.begin(),h.end(),greater<int>());
			
			int kai=0;
			for(int l=0;l<k-i-j&&h.size()>0;l++){
				if(h.back()<0){
					karians+=0-h.back();
					h.pop_back();
				}
				else{
					break;
				}
				kai++;
			}
			
			ans=max(ans,karians);
		}
	}
    cout<<ans<<endl;
    
}


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

void ABC128D()
{
	int N, K;
	cin >> N >> K;
	vector<int> V(N);
	for (int i = 0; i < N; ++i)
		cin >> V[i];

	int maxSum = 0;
	for (int i = 0; i <= min(N,K); ++i)
	{
		vector<int> X;
		for (int j = 0; j <= i; ++j)
		{
			X.assign(V.begin(), V.begin() + j);
			X.insert(X.end(), V.rbegin(), V.rbegin() + (i - j));
			sort(X.begin(), X.end());
			int m = distance(X.begin(),lower_bound(X.begin(), X.end(), 0));
			int k = min(i, K - i);
			m = min(k, m);
			int sum = accumulate(X.begin() + m, X.end(), 0);
			maxSum = max(sum, maxSum);
		}
	}
	cout << maxSum << endl;
}
int main()
{
	ABC128D();
	return 0;
}

Compiler output:
a.cc: In function 'void ABC128D()':
a.cc:4:9: error: 'cin' was not declared in this scope
    4 |         cin >> N >> K;
      |         ^~~
a.cc:5:9: error: 'vector' was not declared in this scope
    5 |         vector<int> V(N);
      |         ^~~~~~
a.cc:5:16: error: expected primary-expression before 'int'
    5 |         vector<int> V(N);
      |                ^~~
a.cc:7:24: error: 'V' was not declared in this scope
    7 |                 cin >> V[i];
      |                        ^
a.cc:10:30: error: 'min' was not declared in this scope
   10 |         for (int i = 0; i <= min(N,K); ++i)
      |                              ^~~
a.cc:12:24: error: expected primary-expression before 'int'
   12 |                 vector<int> X;
      |                        ^~~
a.cc:15:25: error: 'X' was not declared in this scope
   15 |                         X.assign(V.begin(), V.begin() + j);
      |                         ^
a.cc:15:34: error: 'V' was not declared in this scope
   15 |                         X.assign(V.begin(), V.begin() + j);
      |                                  ^
a.cc:17:25: error: 'sort' was not declared in this scope; did you mean 'short'?
   17 |                         sort(X.begin(), X.end());
      |                         ^~~~
      |                         short
a.cc:18:52: error: 'lower_bound' was not declared in this scope
   18 |                         int m = distance(X.begin(),lower_bound(X.begin(), X.end(), 0));
      |                                                    ^~~~~~~~~~~
a.cc:18:33: error: 'distance' was not declared in this scope
   18 |                         int m = distance(X.begin(),lower_bound(X.begin(), X.end(), 0));
      |                                 ^~~~~~~~
a.cc:21:35: error: 'accumulate' was not declared in this scope
   21 |                         int sum = accumulate(X.begin() + m, X.end(), 0);
      |                                   ^~~~~~~~~~
a.cc:22:34: error: 'max' was not declared in this scope
   22 |                         maxSum = max(sum, maxSum);
      |                                  ^~~
a.cc:25:9: error: 'cout' was not declared in this scope
   25 |         cout << maxSum << endl;
      |         ^~~~
a.cc:25:27: error: 'endl' was not declared in this scope
   25 |         cout << maxSum << endl;
      |                           ^~~~
Language: C++

# include <bits/stdc++.h>

typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k; cin >> n >> k;
    vector<int> q(n);
    for (int i = 0; i < n; i++) cin >> q[i];
    ll 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 cur = 0;
            vector<int> s;
            for (int i = 0; i < l; i++) {
                cur += q[i];
                s.push_back(q[i]);
            }
            for (int i = n-r; i < n; i++) {
                cur += q[i];
                s.push_back(q[i]);
            }
            sort(s.begin(), s.end());
            for (int i = 0; i < d; i++) {
                if (i >= s.size()) break;
                if (s[i] > 0) break;
                cur -= s[i];
            }
            ans = max(ans, cur);
        }
    }
    cout << ans << endl;
    return 0;
}


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

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define all(in) in.begin(), in.end()
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
signed main(){
    int n,k; cin >> n >> k;
    vector<int>v(n);
    for(auto & e : v) cin >> e;
    auto dp = vectors(n,n,k,-INF);
    if(k == 1 or n == 1){
        cout << max({v.front(),v.back(),0LL}) << endl;
        return 0;
    }
    dp[1][n - 1][k -  1] = v.front();
    dp[0][n - 2][k -  1] = v.back();
    if(v.front() < 0 and k >= 2){
        dp[1][n - 1][k - 2] = 0LL;
    } else if(v.back() < 0 and k >= 2){
        dp[0][n - 2][k - 2] = 0LL;
    }
    auto valid = [&](int l,int r){ return (l < r and 0 <= l and  r <= n-1);};
    for(int l = 0; l < n; ++l){
        for(int r = n - 1; r >= 0; --r){
            for(int cst = 1; cst < k; ++cst){
                if( dp[l][r][cst] == -INF and not valid(l,r)) continue;
                int now = dp[l][r][cst];
                if(l + 1 < n)
                    cmax(dp[l + 1][r][cst - 1],now + v[l]);
                if(r - 1 >= 0)
                    cmax(dp[l][r - 1][cst - 1],now + v[r]);
                if(v[l] < 0 and l + 1 < n and cst >= 2)
                    cmax(dp[l + 1][r][cst - 2],now);
                if(v[r] < 0 and r - 1 >= 0 cst >=2)
                    cmax(dp[l][r - 1][cst - 2],now);
            }
        }
    }
    int ans = 0LL;
    for(auto vv : dp)for(auto v : vv)for(auto e : v) cmax(ans,e);
    cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:41:43: error: expected ')' before 'cst'
   41 |                 if(v[r] < 0 and r - 1 >= 0 cst >=2)
      |                   ~                       ^~~~
      |                                           )
Language: C++

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

int main(int argc, char *argv[]){
    int N, K;
    std::cin >> N >> K;
    std::deque<long int> V;
    long int v;
    for(int i=0; i<N; ++i){
        std::cin >> v;
        V.push_back(v);
    }

    std::vector<long int> sumValue;
    std::vector<long int> subsequent;
    int left,right;
    int lSubsequent;
    long int sumSubsequent;
    int dequeIdx;
    int R = N < K ? N : K;
    for(lSubsequent=0; lSubsequent<=R; ++lSubsequent){
        subsequent.clear();
        sumSubsequent = 0;

        for(dequeIdx=0; dequeIdx<lSubsequent; ++dequeIdx){
            subsequent.emplace_back(V[dequeIdx]);
        }
        std::sort(subsequent.begin(),subsequent.end());
        for(dequeIdx=0; dequeIdx<lSubsequent; ++dequeIdx){
            if(dequeIdx<K-lSubsequent && subsequent[dequeIdx]<0){
                continue;
            }
            sumSubsequent += subsequent[dequeIdx];
        }

        sumValue.emplace_back(sumSubsequent);

        if(lSubsequence == N){break;}

        for(dequeIdx=1; dequeIdx<=lSubsequent; ++dequeIdx){
            right = lSubsequent - dequeIdx;
            auto rightIter = std::lower_bound(subsequent.begin(),subsequent.end(),V[right]);
            if(std::distance(subsequent.begin(),rightIter) >= K-lSubsequent || V[right]>=0){
                sumSubsequent -= V[right];
            }
            subsequent.erase(rightIter);

            left = N - dequeIdx;
            auto leftIter = std::lower_bound(subsequent.begin(),subsequent.end(),V[left]);
            if(std::distance(subsequent.begin(),leftIter) >= K-lSubsequent || V[left]>=0){
                sumSubsequent += V[left];
            }
            subsequent.insert(leftIter,V[left]);

            sumValue.emplace_back(sumSubsequent);
        }        
    }

    std::cout << *std::max_element(sumValue.begin(),sumValue.end()) << std::endl;
    return 0;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:40:12: error: 'lSubsequence' was not declared in this scope; did you mean 'lSubsequent'?
   40 |         if(lSubsequence == N){break;}
      |            ^~~~~~~~~~~~
      |            lSubsequent
Language: C++

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n, k;
  cin >> n >> k;
  vi v(n);
  rep(i, n) {
    cin >> v[i];
  }

  int ans = 0;
  rep(i, n+1) {
    for (int j = 0; i+j <= n && i+j <= k; j++) {
      int cnt = 0;
      priority_queue<int> q;

      rep(ii, i) {
        cnt += v[ii];
        q.push(-v[ii]);
        }
      }
      rep(ii, j) {
        cnt += v[n-1-ii];
        q.push(-v[n-1-ii]);
      }

      rep(ii, k-i-j) {
        if (q.size() && q.top() > 0) {
          cnt += q.top();
          q.pop();
        }
      }

      cmax(ans, cnt);
    }
  }

  cout << ans << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:33:15: error: 'j' was not declared in this scope
   33 |       rep(ii, j) {
      |               ^
a.cc:7:36: note: in definition of macro 'rep'
    7 | #define rep(i, n) for(ll i = 0;i < n;i++)
      |                                    ^
a.cc:34:9: error: 'cnt' was not declared in this scope; did you mean 'int'?
   34 |         cnt += v[n-1-ii];
      |         ^~~
      |         int
a.cc:35:9: error: 'q' was not declared in this scope
   35 |         q.push(-v[n-1-ii]);
      |         ^
a.cc:38:19: error: 'j' was not declared in this scope
   38 |       rep(ii, k-i-j) {
      |                   ^
a.cc:7:36: note: in definition of macro 'rep'
    7 | #define rep(i, n) for(ll i = 0;i < n;i++)
      |                                    ^
a.cc:39:13: error: 'q' was not declared in this scope
   39 |         if (q.size() && q.top() > 0) {
      |             ^
a.cc:40:11: error: 'cnt' was not declared in this scope; did you mean 'int'?
   40 |           cnt += q.top();
      |           ^~~
      |           int
a.cc:45:17: error: 'cnt' was not declared in this scope; did you mean 'int'?
   45 |       cmax(ans, cnt);
      |                 ^~~
      |                 int
a.cc: At global scope:
a.cc:49:3: error: 'cout' does not name a type
   49 |   cout << ans << endl;
      |   ^~~~
a.cc:50:1: error: expected declaration before '}' token
   50 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
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 maxSum = INT_MIN;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= k; j++) {
			if (i + j > k || i + j > n) continue;
			
			vector<int> ex;
			ex.insert(ex.end(), v.begin(), v.begin() + i);
			ex.insert(ex.end(), v.end() - j, v.end());
			sort(ex.begin(), ex.end());
			int sum = accumulate(ex.begin(), ex.end(), 0);
			int cnt = k - i - j;
			for (auto x : ex) {
				if (cnt-- > 0 && x < 0) {
					sum -= x;
				}
			}
			maxSum = max(maxSum, sum);
		}
	}
	cout << maxSum << endl;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:14:22: error: 'INT_MIN' was not declared in this scope
   14 |         int maxSum = INT_MIN;
      |                      ^~~~~~~
a.cc:5:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
    4 | #include <numeric>
  +++ |+#include <climits>
    5 | using namespace std;
Language: C++

#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/math/common_factor.hpp>

#define rep_ui(k,n)      for(ui  i = (k); i < (n); ++i)
#define rep_si(k,n)      for(int i = (k); i < (n); ++i)
#define rep_ul(k,n)      for(ul  i = (k); i < (n); ++i)
#define rep_sl(k,n)      for(ll  i = (k); i < (n); ++i)
#define rep_ui_down(k,n) for(ui  i = (k); i > (n); --i)
#define rep_si_down(k,n) for(int i = (k); i > (n); --i)
#define rep_ul_down(k,n) for(ul  i = (k); i > (n); --i)
#define rep_sl_down(k,n) for(ll  i = (k); i > (n); --i)

#define rep_uj(k,n)      for(ui  j = (k); j < (n); ++j)
#define rep_sj(k,n)      for(int j = (k); j < (n); ++j)
#define rep_uj_down(k,n) for(ui  j = (k); j > (n); --j)
#define rep_sj_down(k,n) for(int j = (k); j > (n); --j)

#define rep(k,n)         rep_ui(k,n)

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

template<class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vc)
{
  boost::for_each(vc, [&os, &vc](T value) {
    os << value;
    if (value != vc.back())
      os << '\n';
    });
  return os;
}

template<class T1, class T2>
inline
std::ostream&
operator<<(std::ostream& os, const std::pair<T1, T2>& p)
{
  return os << p.first << ' ' << p.second;
}

void solve(void)
{
  using std::string;
  using std::vector;
  using std::map;
  using std::pair;
  using std::cin;
  //string S{}; std::cin >> S;

  ui N{}, K{}; cin >> N >> K;
  vector<ll> V(N);
  rep(0, N) cin >> V[i];

  ll ans{INT64_MIN};
  for (ui numA = 0; numA < K + 1; ++numA)
  {
    if (numA > N) break;
    for (ui numB = 0; numA + numB < K + 1; ++numB)
    {
      if (numB > N) break;
      if (!numA && !numB) continue;

      vector<ll> has{};
      has.reserve(N);
      rep(0, numA) has.push_back(V[i]);
      rep(0, numB) has.push_back(V[(V.size() - 1) - i]);

      std::priority_queue<ll, vector<ll>, std::greater<ll>> res(std::greater<ll>(), has);

      auto sum = boost::accumulate(has, 0LL);
      auto inf = K - (numA + numB);
      while (inf != 0
        && !res.empty()
        && res.top() < 0)
      {
        sum -= res.top();
        res.pop();
        --inf;
      }
      ans = std::max(sum, ans);
    }
  }

  using std::cout;
  cout << ans << '\n';
  
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Compiler output:
a.cc:2:10: fatal error: boost/range/algorithm.hpp: No such file or directory
    2 | #include <boost/range/algorithm.hpp>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <numeric>
#include <cstdint>

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 max_sum = INT_MIN;
  for (int i = 0; i <= k; i++) {
    for (int j = 0; j <= k; j++) {
      if (i+j > k || i+j > n) continue;
      vector<int> extracted;
      extracted.insert(extracted.end(), v.begin(), v.begin()+i);
      extracted.insert(extracted.end(), v.end()-j, v.end());
      sort(extracted.begin(), extracted.end());
      int sum = accumulate(extracted.begin(), extracted.end(), 0);
      int cnt = k-i-j;
      for (auto x : extracted) {
        if (cnt-- > 0 && x < 0) {
          sum -= x;
        }
      }
      max_sum = max(max_sum, sum);
    }
  }
  cout << max_sum << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:21:17: error: 'INT_MIN' was not declared in this scope
   21 |   int max_sum = INT_MIN;
      |                 ^~~~~~~
a.cc:11:1: note: 'INT_MIN' is defined in header '<climits>'; this is probably fixable by adding '#include <climits>'
   10 | #include <cstdint>
  +++ |+#include <climits>
   11 |
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> a;

    rep(l, k+1) {
        rep(r, k-l+1) {
            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());

            rep(i, d) {
                if(i >= s.size()) {
                    break;
                }
                if(s[i] > 0) {
                    break;
                }
                now -= s[i];
            }

            ans = max(ans, now);
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:26:28: error: no matching function for call to 'std::vector<int>::push_back()'
   26 |                 s.push_back();
      |                 ~~~~~~~~~~~^~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:6:
/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:30:28: error: no matching function for call to 'std::vector<int>::push_back()'
   30 |                 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
Language: C++

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> a(n);

    rep(l, k+1) {
        rep(r, k-l+1) {
            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());

            rep(i, d) {
                if(i >= s.size()) {
                    break;
                }
                if(s[i] > 0) {
                    break;
                }
                now -= s[i];
            }

            ans = max(ans, now);
        }
    }

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

Compiler output:
a.cc: In function 'int main()':
a.cc:26:28: error: no matching function for call to 'std::vector<int>::push_back()'
   26 |                 s.push_back();
      |                 ~~~~~~~~~~~^~
In file included from /usr/include/c++/14/vector:66,
                 from a.cc:6:
/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:30:28: error: no matching function for call to 'std::vector<int>::push_back()'
   30 |                 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
Language: C++

#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>

using namespace std;

typedef long long ll;

long long GCD(long long a, long long b){if(b==0)return a;return GCD(b,a%b);}

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

    ll res = 0;
    for (int i = 0; i < K; ++i) {
        for (int j = 0; i + j < K; ++j) {
            vector<ll> h;
            for (int k = 0; k < i; ++k) h.push_back(v[k]);
            for (int k = 0; k < j; ++k) h.push_back(v[N-k-1]);
            sort(h.begin(), h.end());
            for (int k = 0; k < K - i - j && k < h.size(); ++k) {
                if (h[k] < 0) h[k] = 0;
            }
            res = max(res, accumulate(h.begin(), h.end(), 0LL));
        }
    }
    cout << res << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:15: error: 'cin' was not declared in this scope
   16 |     int N, K; cin >> N >> K;
      |               ^~~
a.cc:8:1: note: 'std::cin' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
    7 | #include <numeric>
  +++ |+#include <iostream>
    8 | 
a.cc:32:5: error: 'cout' was not declared in this scope
   32 |     cout << res << endl;
      |     ^~~~
a.cc:32:5: note: 'std::cout' is defined in header '<iostream>'; this is probably fixable by adding '#include <iostream>'
a.cc:32:20: error: 'endl' was not declared in this scope
   32 |     cout << res << endl;
      |                    ^~~~
a.cc:8:1: note: 'std::endl' is defined in header '<ostream>'; this is probably fixable by adding '#include <ostream>'
    7 | #include <numeric>
  +++ |+#include <ostream>
    8 |
Language: C++

#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main() {

	
	
	int n, m;
	cin >> n >> m;

	vector<int>p;
	for (int i = 0; i < n; i++) {
		int x;
		cin >> x;
		p.push_back(x);
	
	
	}
	long long int ans = 0;

	for (int i = 0; i <= m; i++) {
		
		
		
		for (int j = 0; j+i <= m ; j++) {
			
			for (int k = 0; k+i+j <= m ; k++) {
		//		if (i + j + k != m)continue;

				long long int z = 0;
				vector<int>a;
			
				
		

				for (int I = 0; I < i; I++) {
					if (I == n)break;
					a.push_back(p[I]);
					z += p[I];
					ans = max(ans, z);
				//	cout << a[a.size() - 1] << " ";
				}
				for (int J = 0; J < j; J++) {
					if (I + J == n)break;
					a.push_back(p[n - 1 - J]);
					z += p[n - 1 - J];
					ans = max(ans, z);
					//cout << a[a.size() - 1] << " ";
				}
				sort(a.begin(), a.end());
				for (int K = 0; K < min(k,(int)a.size()); K++){
					if (a[K] > 0)break;
					z -= a[K];
					ans = max(ans, z);
				}
				ans = max(ans, z);
	//			cout << ans << endl;
			}
		}
	}

	cout << ans << endl;
	return 0;



}

Compiler output:
a.cc: In function 'int main()':
a.cc:66:45: error: 'I' was not declared in this scope
   66 |                                         if (I + J == n)break;
      |                                             ^
Language: C++

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

#define len(x) ((int)(x).size())
#define log(x) cout << (x) << endl
#define rrep(i,a,b) for(int i=(int)(a);i>=(int)(b);--i)
#define rep(i, n) for(int i=0;i<(int)(n);++i)

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define max(a,b,c,d) max(a,max(b,max(c,d)))
ll dp[55][55][105];
ll solve(vi& a, int K) {
  int n = len(a);
  rrep (i,n-1,0) {
    rep (j, n) {
      rep (k, K+1) {
        if (k==0 or i>=j) {
          dp[i][j][k] = 0;
          if (i>=j) dp[i][j][k]=(k>0)?a[i]:0;
          continue;
        }
        dp[i][j][k] = max(
          a[i] + dp[i+1][j][k-1],
          a[j] + dp[i][j-1][k-1],
          (k>1) ? dp[i+1][j][k-2]:0,
          (k>1) ? dp[i][j-1][k-2]:0
        );
      }
    }
  }
  return dp[0][n-1][K];
}

int main() {
  int n,k;
  cin>>n>>k;
  vll a(n);rep(i,n)cin>>a[i];
  log(solve(a,k));
}



Compiler output:
a.cc: In function 'int main()':
a.cc:41:13: error: invalid initialization of reference of type 'vi&' {aka 'std::vector<int>&'} from expression of type 'vll' {aka 'std::vector<long long int>'}
   41 |   log(solve(a,k));
      |             ^
a.cc:5:25: note: in definition of macro 'log'
    5 | #define log(x) cout << (x) << endl
      |                         ^
a.cc:15:14: note: in passing argument 1 of 'll solve(vi&, int)'
   15 | ll solve(vi& a, int K) {
      |          ~~~~^
Language: C++

#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


void max_u(int&m, int v)
{
	if(m<v) m=v;
}


int main(void)
{
	int n, k;
	while(scanf("%d%d", &n, &k)==2)
	{
		vi v(n);
		vi l(n*2+1), r(n*2+1);

		for(int i=0;i<n;i++)
		{
			scanf("%d", &v[i]);
		}

		vi tl, tr;
		for(int i=0;i<n;i++)
		{
			tl.push_back(v[i]);
			tr.push_back(v[n-1-i]);

			sort(tl.begin(), tl.end());
			sort(tr.begin(), tr.end());

			int sl=accumulate(tl.begin(), tl.end(), 0);
			int sr=accumulate(tr.begin(), tr.end(), 0);

			max_u(l[i], sl);
			max_u(r[i], sr);
			for(int j=0;j<=i;j++)
			{
				sl-=tl[j];
				sr-=tr[j];
				max_u(l[i+j+1], sl);
				max_u(r[i+j+1], sr);
			}
		}

//for(int m:l) printf("%d ", m); printf("\n");

		int ans=0;
		for(int i=0;i<=n;i++)
		{
			for(int j=0;j<k-i && j<=n;j++)
			{
				max_u(ans, l[i]+r[j]);
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:43:32: error: 'accumulate' was not declared in this scope
   43 |                         int sl=accumulate(tl.begin(), tl.end(), 0);
      |                                ^~~~~~~~~~