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

using namespace std;
#include <bits/stdc++.h>
#define rep(i, s) for (int i = 0; i < s; ++i)
#define repr(i, n) for(int i = n-1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define all(v) (v.begin(), v.end())
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define VEC(a, n) vector<int>a(n)
#define PQ(a) priority_queue<int>a
#define PQmin(a) priority_queue< int, :vector<int>, greater<int> >a
#define PAIR pair<int, int>
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define EPS (1e-7)
#define INF (1e10)
#define PI (acos(-1))
const ll mod = 1000000007;
bool f(string s){
  bool ans=true;
  rep(i,s.size()/2){
    if(s[i]!=s[s.size()/2+i]){
      ans=false;
      break;
    }
  }
  return ans;
}
ll a[55];
ll dfs(ll l,ll r){
    ll s;
	vector<ll> vec;
	for(int i=0;i<=l;i++) vec.push_back(a[i]);
	for(int i=r;i<n;i++) vec.push_back(a[i]);
	sort(vec.begin(),vec.end());
	ll maxs;
	maxs=k-vec.size();          
	if(maxs<0) return 0;
	s=0;
	for(int i=0;i<vec.size();i++){
		if(vec[i]<0&&maxs>0){
        	maxs--;
		}
		else{
			s+=vec[i];
		}
	}
	return s;




int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;
  cin>>n>>k;
  rep(i,n){
    cin>>a[i];
  }
  ll ans=0;
  for(int i=-1;i<n;i++){
		for(int j=i+1;j<=n;j++){
        	ans=max(ans,dfs(i,j));
		}
	}
	cout<<ans<<endl;
	return 0;
}
  
  


Compiler output:
a.cc: In function 'll dfs(ll, ll)':
a.cc:34:23: error: 'n' was not declared in this scope
   34 |         for(int i=r;i<n;i++) vec.push_back(a[i]);
      |                       ^
a.cc:37:14: error: 'k' was not declared in this scope
   37 |         maxs=k-vec.size();
      |              ^
a.cc:53:9: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   53 | int main(){
      |         ^~
a.cc:53:9: note: remove parentheses to default-initialize a variable
   53 | int main(){
      |         ^~
      |         --
a.cc:53:9: note: or replace parentheses with braces to value-initialize a variable
a.cc:53:11: error: a function-definition is not allowed here before '{' token
   53 | int main(){
      |           ^
a.cc:69:2: error: expected '}' at end of input
   69 | }
      |  ^
a.cc:30:18: note: to match this '{'
   30 | ll dfs(ll l,ll r){
      |                  ^
Language: C++

//#include <bits/stdc++.h>                          //include all library
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>
#include <sstream>
#include <vector>
#include <stack>
#include <queue>
#include <string.h>
#include <functional> // greater<int> はfunctionalヘッダ
using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)          //REP(i, 10){...} //i=0～i=9までのループ
#define REPR(i, n) for(int i = n;i >= 0;i--)        //REPR(i, 10){...} //i=10～i=0までのループ
#define FOR(i, m, n) for(int i = m;i < n;i++)       //FOR(i, 3, 10){...} //i=3～i=9までのループ
#define FORR(i, m, n) for(int i = m;i >= n;i--)     //FORR(i, 10, 3){...} //i=10～i=3までのループ
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
#define PI 3.141592653589
#define npos -1


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

	//高速化のために和をあらかじめ計算しておく
	int sum[N+1];
	sum[0]=0;
	for(int i=0; i<N; i++) sum[i+1]=sum[i]+v[i];

	int maxi=0;

	//a,bはそれぞれA,Bの試行回数を表す
	for(int a=0; a<min(N, K); a++){
		for(int b=0; b<min(N, K); b++){
			if(a+b > min(N, K)) break;
			int total = sum[a] + (sum[N]-sum[N-b]);

			vector<int> minus(0);
			if(a!=0) for(int k=0; k<a; k++) if(v[k]<0) minus.pb(v[k]);
			if(b!=0) for(int k=0; k<b; k++) if(v[N-1-k]<0) minus.pb(v[N-1-k]);
			sort(minus.begin(), minus.end());

			if(K-a-b!=0 and (int)minus.size!=0) for(int k=0; k<min(K-a-b, (int)minus.size()); k++) total-=minus[k];

			maxi = max(maxi, total);
		}
	}
	cout << maxi << endl;
}



Compiler output:
a.cc: In function 'int main()':
a.cc:53:52: error: invalid use of member function 'std::vector<_Tp, _Alloc>::size_type std::vector<_Tp, _Alloc>::size() const [with _Tp = int; _Alloc = std::allocator<int>; size_type = long unsigned int]' (did you forget the '()' ?)
   53 |                         if(K-a-b!=0 and (int)minus.size!=0) for(int k=0; k<min(K-a-b, (int)minus.size()); k++) total-=minus[k];
      |                                              ~~~~~~^~~~
      |                                                        ()
Language: C++

#include <bits/stdc++.h>

#define int ll
#define rep(i,a,b) for(ll i=(a);i<=(b);i++)
#define END(x) do{cout<<(x)<<endl;exit(0);}while(0)
#define debug(x)  do{cerr<<#x<<": "<<x<<"\n";}while(0)
#define debugv(x) do{cerr<<#x<<": ";for(auto&e: x)cerr<<e<<" ";cerr<<"\n";}while(0)
#define exp2(x)  (1LL<<(x))

using namespace std;
using ll=long long;

signed main() {
  ios_base::sync_with_stdio(false); cin.tie(nullptr);
  int N, K; cin >> N >> K;
  int V[N];rep(i,0,N-1) cin >> V[i];

  int ans=0;
  rep(i, 0, K) rep(j, 0, K-i) {
      debug(i); debug(j);
      if(i>=N or j>=N) continue;
      if(i+j>=N) continue;
      int rem = K-i-j;
      vector<int> v; int t=0;
      rep(l,0,i-1) {t+= V[l]; v.push_back(V[l]);}
      rep(r,0,j-1) {t+= V[N-1-r]; v.push_back(V[N-1-r]);}
      //debugv(v);
      sort(v.begin(), v.end());
      rep(ii,0,min(rem,int(v.size()))-1) {
          if (v[ii]<0) t -= v[ii]; else break;
      }

      ans=max(ans,t);
  }
  END(ans);


Compiler output:
a.cc: In function 'int main()':
a.cc:35:12: error: expected '}' at end of input
   35 |   END(ans);
      |            ^
a.cc:13:15: note: to match this '{'
   13 | signed main() {
      |               ^
Language: C++

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

int main() {
    int64_t N, K, V[50], ans = 0;
    cin >> N >> K;
    rep(i, N) cin >> V[i];

    int len = min(N, K);
    vector<long long> As;
    for (int A = 0; A <= len; A++) {
        if (A) As.push_back(V[A-1]);
        vector<long long> Bs;
        for (int B = 0; A + B <= len; B++) {
            if (B) Bs.push_back(V[N-B]);

            vector<long long> ABs = As;
            ABs.insert(ABs.end(), Bs.begin(), Bs.end());
            sort(ABs.begin(), ABs.end(), greater<long long>());
            rep(i, len - (A + B)) {
                if (!ABs.size()) break;
                if (ABs[ABs.size()-1] >= 0) break;
                ABs.pop_back();
            }
            ans = max(ans, accumulate(ABs.begin(), ABs.end(), 0LL));
        }
    }
    cout << ans << endl;
}

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

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

int main() {
    int64_t N, K, V[50], ans = 0;
    cin >> N >> K;
    rep(i, N) cin >> V[i];

    int len = min(N, K);
    vector<long> As;
    for (int A = 0; A <= len; A++) {
        if (A) As.push_back(V[A-1]);
        vector<long> Bs;
        for (int B = 0; A + B <= len; B++) {
            if (B) Bs.push_back(V[N-B]);

            vector<long> ABs = As;
            ABs.insert(ABs.end(), Bs.begin(), Bs.end());
            sort(ABs.begin(), ABs.end(), greater<int>());
            rep(i, len - (A + B)) {
                if (!ABs.size()) break;
                if (ABs[ABs.size()-1] >= 0) break;
                ABs.pop_back();
            }
            ans = max(ans, accumulate(ABs.begin(), ABs.end(), 0LL));
        }
    }
    cout << ans << endl;
}

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

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

int main() {
    int64_t N, K, V[50], ans = 0;
    cin >> N >> K;
    rep(i, N) cin >> V[i];

    int len = min(N, K);
    vector<int64_t> As;
    for (int A = 0; A <= len; A++) {
        if (A) As.push_back(V[A-1]);
        vector<int64_t> Bs;
        for (int B = 0; A + B <= len; B++) {
            if (B) Bs.push_back(V[N-B]);

            vector<int64_t> ABs = As;
            ABs.insert(ABs.end(), Bs.begin(), Bs.end());
            sort(ABs.begin(), ABs.end(), greater<int>());
            rep(i, len - (A + B)) {
                if (!ABs.size()) break;
                if (ABs[ABs.size()-1] >= 0) break;
                ABs.pop_back();
            }
            ans = max(ans, accumulate(ABs.begin(), ABs.end(), 0LL));
        }
    }
    cout << ans << endl;
}

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

#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
const int INF=1e9;
int a[105];
int ma[105];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int res=0;
	for(int st=0;st<n;st++){
		for(int ed=st;ed<n;ed++){
			vector<int> tmp;
			for(int i=0;i<st;i++) tmp.push_back(a[i]);
			for(int i=ed+1;i<n;i++) tmp.push_back(a[i]);
			sort(tmp.begin(),tmp.end());
			if((int)tmp.size()>k) continue;
			long long cnt=0;
			for(int i=0;i<tmp.size();i++) cnt+=1ll*tmp[i];
			for(int i=0;i<min((int)tmp.size(),k-(int)tmp.size());i++) if(tmp[i]<0) cnt-=1ll*tmp[i];
			res=max(res,cnt);
		}
	}
	cout<<res;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:37:32: error: no matching function for call to 'max(int&, long long int&)'
   37 |                         res=max(res,cnt);
      |                             ~~~^~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:37:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   37 |                         res=max(res,cnt);
      |                             ~~~^~~~~~~~~
/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,
                 from a.cc:2:
/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:37:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   37 |                         res=max(res,cnt);
      |                             ~~~^~~~~~~~~
Language: C++

#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() 
  int N, K;
  cin >> N >> K;
  vector<int> V(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  int ans = 0;
  
  for (int l = 0; l <= min(N, K); l++) {
    for (int r = 0; l+r <= min(N, K); r++) {
      if (l+r==0)continue;
      
      vector<int> v;
      int tmp = 0;
      for (int i = 0; i < l; i++) {
        v.push_back(V[i]);
        tmp += V[i];
      }
      for (int i = 0; i < r; i++) {
        v.push_back(V[N-1-i]);
        tmp += V[N-1-i];
      }
      
      sort(v.begin(), v.end());
      for (int i = 0; i < min((int)v.size(), K-l-r); i++) {
        if (v[i] >= 0) break;
        tmp -= v[i];
      }
      
      ans = max(ans, tmp);
    }
  }
  cout << ans << endl;
}



Compiler output:
a.cc:2:13: error: expected initializer before 'long'
    2 | #define int long long
      |             ^~~~
a.cc:7:3: note: in expansion of macro 'int'
    7 |   int N, K;
      |   ^~~
a.cc:8:3: error: 'cin' does not name a type
    8 |   cin >> N >> K;
      |   ^~~
a.cc:9:17: error: 'N' was not declared in this scope
    9 |   vector<int> V(N);
      |                 ^
a.cc:10:3: error: expected unqualified-id before 'for'
   10 |   for (int i = 0; i < N; i++) cin >> V[i];
      |   ^~~
a.cc:10:19: error: 'i' does not name a type
   10 |   for (int i = 0; i < N; i++) cin >> V[i];
      |                   ^
a.cc:10:26: error: 'i' does not name a type
   10 |   for (int i = 0; i < N; i++) cin >> V[i];
      |                          ^
a.cc:13:3: error: expected unqualified-id before 'for'
   13 |   for (int l = 0; l <= min(N, K); l++) {
      |   ^~~
a.cc:13:19: error: 'l' does not name a type
   13 |   for (int l = 0; l <= min(N, K); l++) {
      |                   ^
a.cc:13:35: error: 'l' does not name a type
   13 |   for (int l = 0; l <= min(N, K); l++) {
      |                                   ^
a.cc:37:3: error: 'cout' does not name a type
   37 |   cout << ans << endl;
      |   ^~~~
a.cc:38:1: error: expected declaration before '}' token
   38 | }
      | ^
Language: C++

#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#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 maxv = INT_MIN;
  for (int i = 0; i < K; i++) {
    for (int j = K - i; j >= 0; j--) {
      if (i == 0 && j == 0)
        break;
      vector<int> left(V.begin(), V.begin() + i);
      vector<int> right(V.end() - j, V.end());
      left.insert(left.end(), right.begin(), right.end());
      sort(left.begin(), left.end());
      int sum = accumulate(left.begin(), left.end(), 0);
      for (int k = 0; k < min({i + j, K - i - j}); k++) {
        int x = left[k];
        if (x < 0) {
          sum -= x;
        } else {
          break;
        }
      }
      maxv = max(sum, maxv);
    }
  }
  cout << maxv << endl;
  return 0;
}


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

#include"stdafx.h"
#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#define B L-A

using namespace std;

int ValCheckF(vector<int>::iterator begin, vector<int>::iterator end, int i) {
	if (i <= 0 || end - begin < 0) return 0;
	int sum = 0;
	if (*begin >= 0) {
		sum += *begin;
		sum += ValCheckF(begin + 1, end, i - 1);
		return sum;
	}
	else {
		int suma = sum + *begin;
		int sumb = sum;
		suma += ValCheckF(begin + 1, end, i - 1);
		sumb += ValCheckF(begin + 1, end, i - 2);
		if (suma > 0 || sumb > 0) return suma > sumb ? suma : sumb;
		else return 0;
	}
}

int ValCheckB(vector<int>::iterator begin, vector<int>::iterator end, int i) {
	if (i <= 0 || end - begin < 0) return 0;
	int sum = 0;
	if (*end >= 0) {
		sum += *end;
		sum += ValCheckB(begin, end - 1, i - 1);
		return sum;
	}
	else {
		int suma = sum + *end;
		int sumb = sum;
		suma += ValCheckB(begin, end - 1, i - 1);
		sumb += ValCheckB(begin, end - 1, i - 2);
		if (suma > 0 || sumb > 0) return suma > sumb ? suma : sumb;
		else return 0;
	}
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> V(N);
	for (auto &x : V) cin >> x;
	int A;
	vector<int> M;
	int L;
	L = N < K ? N : K;
	for (A = 0; A <= L; A++) {
		M.push_back(ValCheckF(V.begin(), V.end(), A) + ValCheckB(V.begin(), V.end()-1, B));
	}
	cout << (*max_element(M.begin(), M.end())) << endl;
}

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

#include <iostream>
#include <algorithm>
#include <iterator>
#include <vector>
#define B K-A

using namespace std;

int ValCheckF(vector<int>::iterator begin, vector<int>::iterator end, int i) {
	if (i <= 0 || distance(begin, end)<0) return 0;
	int sum = 0;
	if (*begin >= 0) {
		sum += *begin;
		sum += ValCheckF(begin + 1, end, i - 1);
		return sum;
	}
	else {
		int suma = sum + *begin;
		int sumb = sum;
		suma += ValCheckF(begin + 1, end, i - 1);
		sumb += ValCheckF(begin + 1, end, i - 2);
		return max(0, suma, sumb);
	}
}

int ValCheckB(vector<int>::iterator begin, vector<int>::iterator end, int i) {
	if (i <= 0 || distance(begin, end)<0) return 0;
	int sum = 0;
	if (*end >= 0) {
		sum += *end;
		sum += ValCheckB(begin, end - 1, i - 1);
		return sum;
	}
	else {
		int suma = sum + *end;
		int sumb = sum;
		suma += ValCheckB(begin, end - 1, i - 1);
		sumb += ValCheckB(begin, end - 1, i - 2);
		return max(0, suma, sumb);
	}
}

int main() {
	int N, K;
	cin >> N >> K;
	vector<int> V(N);
	for (auto &x : V) cin >> x;
	int A;
	vector<int> M;
	for (A = 0; A <= K; A++) {
		M.push_back(ValCheckF(V.begin(), V.end(), A) + ValCheckB(V.begin(), V.end()-1, B));
	}
	cout << (*max_element(M.begin(), M.end())) << endl;
}

Compiler output:
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h: In instantiation of 'constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare) [with _Tp = int; _Compare = int]':
a.cc:22:13:   required from here
   22 |                 return max(0, suma, sumb);
      |                        ~~~^~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:306:17: error: '__comp' cannot be used as a function
  306 |       if (__comp(__a, __b))
      |           ~~~~~~^~~~~~~~~~
Language: C++

#include <iostream>
#include <stack>
#include <string>
#include <algorithm>
#include <vector> 

using namespace std;
int n, k; 
long long a[51];
long long d[51][51][101];
long long go(int x, int y, int k) {
	if (d[x][y][k] != -1)return d[x][y][k];
	d[x][y][k] = 0;
	if (k > 0) {
		if (x + 1 < y) d[x][y][k] = max(d[x][y][k], go(x + 1, y, k - 1) + a[x]);
		if (y - 1 > x)d[x][y][k] = max(d[x][y][k], go(x, y - 1, k - 1) + a[y]);
	}
	if (k > 1) {
		if (x + 1 < y)d[x][y][k] = max(d[x][y][k], go(x + 1, y, k - 2));
		if (y - 1 > x)d[x][y][k] = max(d[x][y][k], go(x, y - 1, k - 2));
	}
	return d[x][y][k];
}


int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	memset(d, -1, sizeof(d));
	cout << go(0, n - 1, k) << '\n';
	


}

Compiler output:
a.cc: In function 'int main()':
a.cc:30:9: error: 'memset' was not declared in this scope
   30 |         memset(d, -1, sizeof(d));
      |         ^~~~~~
a.cc:6:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    5 | #include <vector>
  +++ |+#include <cstring>
    6 |
Language: C++

#include <iostream>
#include <stack>
#include <string>
#include <algorithm> // 모음뒤에는 자음 1개 또는 2개 까지 가능
#include <vector> // 자음 모음 자음 자음 모음 
#include <queue>
using namespace std;
int n, k; 
long long a[51];
long long d[51][51][101];
long long go(int x, int y, int k) {
	if (d[x][y][k] != -1)return d[x][y][k];
	d[x][y][k] = 0;
	if (k > 0) {
		if (x + 1 < y)d[x][y][k] = max({ d[x][y][k], go(x + 1, y, k - 2), go(x + 1, y, k - 1) + a[x] });
		if (y - 1 > x)d[x][y][k] = max({ d[x][y][k], go(x, y - 1, k - 2),go(x,y - 1,k - 1) + a[y] });
	}
	return d[x][y][k];
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	memset(d, -1, sizeof(d));
	cout << go(0, n - 1, k) << '\n';
	


}

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

#include "pch.h"
#include "bits/stdc++.h"

typedef long long int lli;

using namespace std;

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

	int N, M,ans=0; cin >> N >> M;
	vector<int> ver(N);
	for (int i = 0; i < N; i++) { cin >> ver[i]; }

	for (int A = 0; A <= N; A++) {
		for (int B = 0; B <= N; B++) {
			if (A + B > N || A + B > M) { continue; }
			vector<int> S;
			for (int i = 0; i < A; i++) { S.push_back(ver[i]); }
			for (int i = 0; i < B; i++) { S.push_back(ver[N - i - 1]); }
			sort(S.begin(), S.end());
			int sum = 0;
			for (int i = 0; i < S.size(); i++) { sum += S[i]; }
			int cnt = M - (A + B);
			for (int i = 0; i < S.size(); i++) {
				if (S[i] >= 0) { break; }
				if (cnt) {
					cnt--;
					sum -= S[i];
				}
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;
}

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

#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#define rep(i,s,n)for(int i = s;i<n;i++)
#define repe(i,s,n)for(int i = s;i<=n;i++)
using namespace std;
typedef long long ll;

ll v[50];
ll s[51];
int main() {
	ll n, k; cin >> n >> k;
	rep(i, 0, n) cin >> v[i];

	ll L = 0, R = 0;
	ll sumMax = 0;

	rep(l, 0, n)rep(r, 0, n) {
		vector<ll>  sum;
		ll sumV = 0;
		ll K = k;

		if (l + r <= min(n, K)) {
			rep(p, 0, l) {
				if (K < 0)break;
				K--;
				sum.push_back(v[p]);
			}
			rep(q, n - r, n) {
				if (K < 0)break;
				K--;
				sum.push_back(v[q]);
			}
		}
		sort(sum.begin(), sum.end());

		for (vector<ll>::iterator it = sum.begin(); it != sum.end(); it++) {
			if (*it < 0 && K > 0) {
				K--;
			}
			else {
				sumV += *it;
			}
		}

		sumMax = max(sumV, sumMax);
	}

	cout << sumMax << endl;

	return 0;
}

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

#include <iostream>
#include <vector>
#include <numeric>

using namespace std;

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

    vector<int> gems;
    for (int i = 0; i < N; ++i) {
        int g; cin >> g;
        gems.push_back(g);
    }

    int max_score = 0;

    for (int A = 0; A <= K && A <= N; ++A) {
        for (int B = 0; A + B <= K && A + B <= N; ++B) {
            int rest = std::max(0, K - A - B);

            vector<int> vs;
            for (int a = 0; a < A; ++a) {
                vs.push_back(gems[a]);
            }
            for (int b = 0; b < B; ++b) {
                vs.push_back(gems[N - b - 1]);
            }

            sort(vs.begin(), vs.end(), std::greater<int>());
            while (rest > 0 && !vs.empty()) {
                if (vs.back() < 0) {
                    vs.pop_back();
                    --rest;
                }
            }

            int score = accumulate(vs.begin(), vs.end(), 0);
            if (score > max_score) {
                max_score = score;
            }
        }
    }

    cout << max_score << endl;
}


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

//↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const long long SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) {
	for (auto &e : t) fill_v(e, v);
}

//↑template↑


int a, b;
vector<ll>v(a);
ll dp(ll a, ll b, ll c);



int main() {
	cin >> a >> b;
	v.resize(a);
	for (int i = 0; i < a; ++i) { cin >> v[i]; }
	auto m = make_v<ll>(a, a, b + 1);
	cout << dp(0, a - 1, b) << endl;
}


ll dp(ll a, ll b, ll c) {
	if (a < b || c < 0) { return -INF; }
	if (c == 0) { return 0; }
	if (a == b) { return max(0ll, v[a]); }

	ll aa = dp(a + 1, b, c - 1) + v[a], bb = dp(a + 1, b, c - 2), cc = dp(a, b - 1, c - 1) + v[b], dd = dp(a, b - 1, c - 2);

	return m[a][b][c] = max({ aa,bb,cc,dd });
}

Compiler output:
a.cc: In function 'll dp(ll, ll, ll)':
a.cc:82:16: error: 'm' was not declared in this scope
   82 |         return m[a][b][c] = max({ aa,bb,cc,dd });
      |                ^
Language: Java

import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 
 
 
public class Main {
 
	public static void main(String[] args) {
 
		Solve s= new Solve();
		s.solve();
 
	}
}
 
 
class Solve{
 
 
	 public void solve() {
		 Scanner sc = new Scanner(System.in) ;
		 int N = sc.nextInt();
		 int K = sc.nextInt();
		 int[] a = new int[N];
		 int res =0;
		 
 
		 
		 for(int i=0;i<N;i++) {
			 a[i]=sc.nextInt();
		 }
		 
		 for(int l=0;l<=K;l++) {
			 for(int r=0;r<=K-l;r++) {
				 
				 if(l+r>N) {
					 continue;
				 }
				 ArrayList<Integer> now = new ArrayList<>();
				 int d=K-l-r;
				 int score=0;
				 for(int i=0;i<l;i++) {
					 score+=a[i];
					 now.add(a[i]);
				 }
				 for(int i =N-r;i<N;i++) {
					 score+=a[i];
					 now.add(a[i]);
				 }
				// Collections.sort(now);
				 
				 for(int i=0;i<=d;i++) {
					 if(i>=now.size())break;
					 if(now.get(i)>0)break;
					 score-=now.get(i);
				 }
				 
					 res=Math.max(res, score);
					 
				 
			 }
			 
		 }
		 System.out.println(res);
 
		
	 }
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;



public class Main {

	public static void main(String[] args) {

		Solve s= new Solve();
		s.solve();

	}
}


class Solve{


	 public void solve() {
		 Scanner sc = new Scanner(System.in) ;
		 int N = sc.nextInt();
		 int K = sc.nextInt();
		 int[] a = new int[N];
		 int res =0;
		 

		 
		 for(int i=0;i<N;i++) {
			 a[i]=sc.nextInt();
		 }
		 
		 for(int l=0;l<=K;l++) {
			 for(int r=0;r<K-l;r++) {
				 
				 if(l+r>N) {
					 continue;
				 }
				 ArrayList<Integer> now = new ArrayList<>();
				 int d=K-l-r;
				 int score=0;
				 for(int i=0;i<l;i++) {
					 score+=a[i];
					 now.add(a[i]);
				 }
				 for(int i =N-r;i<N;i++) {
					 score+=a[i];
					 now.add(a[i]);
				 }
				// Collections.sort(now);
				 
				 for(int i=0;i<d;i++) {
					 if(i>=now.size())break;
					 if(now.get(i)>0)break;
					 score-=now.get(i);
				 }
				 
					 res=Math.max(res, score);
					 
				 
			 }
			 
		 }
		 System.out.println(res);

		
	 }
}

Compiler output:
Main.java:70: error: class, interface, enum, or record expected
import java.util.ArrayList;
^
Main.java:71: error: class, interface, enum, or record expected
import java.util.Collections;
^
Main.java:72: error: class, interface, enum, or record expected
import java.util.Scanner;
^
3 errors
Language: C++

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#define repp(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define repm(i,a,b) for(int i=(int)a;i>(int)b;--i)
using ll=long long;
static const ll mod = 1e9 + 7;
static const ll INF = 1LL << 50;
using namespace std;

int main() {
	int n, k;
	int maxv = 0;//何も操作しなければ0であるため
	cin >> n >> k;
	vector<int>v(n);
	repp(i, 0, n)cin >> v[i];
	repp(l, 0, k + 1) {//lは左から取り出す物
		repp(r, 0, k - l + 1) {//rは右から取り出す物
			int d = k - l - r;//dは捨てる物
			int now = 0;//現在の価値
			vector<int>s;//取り出した物を入れる空配列
			for (int i = 0; i < l; ++i) {//順番に追加
				now += v[i];
				s.push_back(v[i]);
			}
			for (int i = N - r; i >= 0; --i) {
				now += v[i];
				s.push_back(v[i]);
			}
			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];
			}
			maxv = max(maxv, now);
		}
	}
	cout << maxv << endl;
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:31:38: error: 'N' was not declared in this scope
   31 |                         for (int i = N - r; i >= 0; --i) {
      |                                      ^
Language: C++

#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int maxn = 3e5+5;
const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll inv (int b){
	if (b==1) return 1;
	return inv(mod%b) * (mod - mod/b) %mod;
}

ll pow(ll a, ll n, ll mod = 1e9+7){ 
	ll re=1;
	while (n>0){
		if (n&1) re = re*a % mod;
		a = a*a %mod;
		n>>=1;
	}
	return re;
}



main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, k; cin>>n>>k;
    vector<int> v;
    REP(i,n){
        int in; cin>>in;
        v.push_back(in);
    }
    ll re = 0;
    REP(tl,min(k+1,n+1){
        REP(tr, min(k+1, n+1)){
            if (tl+tr>k || tl + tr > n) break;
            vector<int> took;
            REP(i, tl) took.pb(v[i]);
            FOR(j, n-tr, n) took.pb(v[j]);
            int cc = k-tl-tr;
            sort(ALL(took), greater<int>());
            REP(i, cc){
                if (!took.size()) break;
                if (took.back()<0) took.pop_back();
            }
            ll ans = 0;
            for (int x : took){
                ans+=x;
            }
            MXTO(re, ans);
        }
    }
    cout<<re<<endl;
}	

Compiler output:
a.cc:75:9: error: unterminated argument list invoking macro "REP"
   75 | }
      |         ^
a.cc:46:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   46 | main(){
      | ^~~~
a.cc: In function 'int main()':
a.cc:55:5: error: 'REP' was not declared in this scope
   55 |     REP(tl,min(k+1,n+1){
      |     ^~~
a.cc:55:8: error: expected '}' at end of input
   55 |     REP(tl,min(k+1,n+1){
      |        ^
a.cc:46:7: note: to match this '{'
   46 | main(){
      |       ^
Language: C++

#include <iostream>
#include <queue>

using namespace std;

int N, K;
int V[100];

int priority_queue<int> que;

int main()
{
    cin >> N >> K;
    for(int i = 0;i < N; i++)
    {
        cin >> V[i];
    }
    for(int i = 0;i < K;i++)//iは取り出す個数
    {
        if(i >= K / 2){
            for(int j = 0;j < i + 1;j++)//jは左から取り出す個数
            {
                for(int k = 0; k < i;k++)
                {
                    if(k <= j)
                    {
                        que.push(V[k])
                    }
                    else 
                    {

                    }
                }
            }
        }
    }

    return 0;
}

Compiler output:
a.cc:9:25: error: invalid declarator before 'que'
    9 | int priority_queue<int> que;
      |                         ^~~
a.cc: In function 'int main()':
a.cc:27:25: error: 'que' was not declared in this scope
   27 |                         que.push(V[k])
      |                         ^~~
Language: C++

#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll=long long;  
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k;
	cin >> n >> k;
	vector<int> vec(n);
	vector<bool> can_get(n,true);
	for(int i=0;i<n;++i){
		cin >> vec[i];
	}
	
	int c=k,ans=0;
	vector<int> get;
	for(int i=0;i<=k;++i){
		if(i!=0){
			get_left.push_back(vec[i-1]);
			can_get[i-1]=false;
		}
		vector<int> get_right;
		
		for(int j=0;j<=k-i;++j){
			int sum=0;
			if(j!=0&&can_get[n-j]!=false){
				get_right.push_back(vec[n-j]);
				can_get[n-j]=false;
			}
			c=k-j-i;
			if(j==0)get_right.insert(get_right.end(),get_left.begin(),get_left.end());
			SORT(get_right);
			for(int l=0;l<=min(c,(int)get_right.size());++l){
				if(get_right[l]<0){
					get_right[l]=0;
				}
			}
			for(size_t l=0;l<get_right.size();++l){
				sum+=get_right[l];
			}
			ans=max(ans,sum);
			can_get[n-j]=true;
		}	
	}
	cout << ans <<endl;
    return 0;
	
}


Compiler output:
a.cc: In function 'int main()':
a.cc:46:25: error: 'get_left' was not declared in this scope
   46 |                         get_left.push_back(vec[i-1]);
      |                         ^~~~~~~~
a.cc:58:66: error: 'get_left' was not declared in this scope
   58 |                         if(j==0)get_right.insert(get_right.end(),get_left.begin(),get_left.end());
      |                                                                  ^~~~~~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
int dfs(int i,int j,int k,vector<int>v,int sum){
  if(k==0){
    return 0;
  }
  if(k==1)return sum+max(dfs(i+1,j,k-1,v,sum+v[i]),max(dfs(i,j+1,k-1,v,sum+v[j]),0));
  return sum+max(dfs(i+1,j,k-1,v,sum+v[i]),dfs(i+1,j,k-2,v,sum),dfs(i,j-1,k-1,v,sum+v[j]),dfs(i,j-1,k-2,v,sum));
}
int main(){
  int n,k;cin>>n>>k;
  vector<int>v(n);
  for(int i=0;i<n;i++)cin>>v[i];
  int sum=0;
  cout<<dfs(0,n,k,v,sum)<<endl;
}

Compiler output:
a.cc: In function 'int dfs(int, int, int, std::vector<int>, int)':
a.cc:8:17: error: no matching function for call to 'max(int, int, int, int)'
    8 |   return sum+max(dfs(i+1,j,k-1,v,sum+v[i]),dfs(i+1,j,k-2,v,sum),dfs(i,j-1,k-1,v,sum+v[j]),dfs(i,j-1,k-2,v,sum));
      |              ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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:   candidate expects 2 arguments, 4 provided
/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, 4 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, 4 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:   candidate expects 2 arguments, 4 provided
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define sorted(vector) sort(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)


int main(void){
    int n,k,tmp;
    vector<int> v,motimono,ans;
    cin>>n>>k;
    for(int i=0  ;i<n  ;i++){
        cin>>tmp;
        v.push_back(tmp);
    }
    
    
    if (k>=n){
        k-=n;
        ans.append(vsum(v));
        sorted(v);
        for(int i=0  ;i< min<unsigned long>(k,n) ;i++){
            v[i]=0;
            ans.append(vsum(v));
            }
        }
    }else{
        for(int i=0  ;i<n  ;i++){
            v.append(v[i]);
        }
        for(int j=1  ;j<k+1  ;j++){  //長さ
            for(int i=n-j  ;i<n+1  ;i++){ //開始index
                vector<int> motimono;
                for(int r=i  ;r<i+j  ;r++){
                    motimono.append(v[r]);
                }
                ans.append(vsum(motimono));
                sorted(motimono);
                for(int i=0  ;i< min<unsigned long>(k-j,motimono.size())  ;i++){
                    motimono[i]=0;
                    ans.append(vsum(motimono));
                }
            }
        }
    }
    cout<<vmax(ans)<<endl;
}


Compiler output:
a.cc:30:6: error: expected unqualified-id before 'else'
   30 |     }else{
      |      ^~~~
a.cc:49:5: error: 'cout' does not name a type
   49 |     cout<<vmax(ans)<<endl;
      |     ^~~~
a.cc:50:1: error: expected declaration before '}' token
   50 | }
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define sorted(vector) sort(vector.begin(),vector.end())
#define vmax(vector) *max_element(vector.begin(),vector.end())
#define vsum(vector) accumulate(vector.begin(),vector.end(),0)
#define append(a) push_back(a)
#define int(a) stoi(a)
#define str(a) to_string(a)


int main(void){
    int n,k,tmp;
    vector<int> v,motimono,ans;
    cin>>n>>k;
    for(int i=0  ;i<n  ;i++){
        cin>>tmp;
        v.push_back(tmp);
    }
    
    
    if (k>=n){
        k-=n;
        ans.append(vsum(v));
        sorted(v);
        for(int i=0  ;i<k  ;i++){
            for(int j=0  ;j<min<unsigned long>(k,v.size()  ;i++){
                v[j]=0;
                ans.append(vsum(v));
            }
        }
    }else{
        for(int i=0  ;i<n  ;i++){
            v.append(v[i]);
        }
        for(int j=1  ;j<k+1  ;j++){  //長さ
            for(int i=n-j  ;i<n+1  ;i++){ //開始index
                vector<int> motimono;
                for(int r=i  ;r<i+j  ;r++){
                    motimono.append(v[r]);
                }
                ans.append(vsum(motimono));
                sorted(motimono);
                for(int i=0  ;i< min<unsigned long>(k-j,motimono.size())  ;i++){
                    motimono[i]=0;
                    ans.append(vsum(motimono));
                }
            }
        }
    }
    cout<<vmax(ans)<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:58: error: expected ')' before ';' token
   26 |             for(int j=0  ;j<min<unsigned long>(k,v.size()  ;i++){
      |                                               ~          ^ ~
      |                                                          )