Language: C++

/*
confirm 0LL and 1LL
confirm cornercases such as 0
confirm times of cin < 10^6
*/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using Pld = pair<ld, ld>;
using Vec = vector<ll>;
using VecP = vector<P>;
using VecB = vector<bool>;
using VecC = vector<char>;
using VecD = vector<ld>;
using VecS = vector<string>;
using VecVec = vector<Vec>;
using Graph = vector<VecP>;
template <typename T>
using Vec1 = vector<T>;
template <typename T>
using Vec2 = vector<Vec1<T> >;
#define REP(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define REPN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define REPR(i, m, n) for(ll (i) = (m)-1; (i) >= (n); --(i))
#define REPNR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) REP(i, 0, n)
#define repn(i, n) REPN(i, 1, n)
#define repr(i, n) REPR(i, n, 0)
#define repnr(i, n) REPNR(i, n, 1)
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
template <typename T>
bool chmax(T &a, const T& b){if(a < b){a = b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a > b){a = b; return true;} return false;}
template <typename T>
void co(const T n){cout << n << endl;}
template <typename T>
void cosp(const T n){cout << n << ' ';}
void coVec(const Vec &v){for(ll i : v) cosp(i); cout << endl;}
ll in(){ll x; cin >> x; return x;}
void sonic(){ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);}
void setp(const ll n){cout << fixed << setprecision(n);}
const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ld PI = acos(-1);
const ld EPS = 1e-11;

int main(void){
	ll n, k;
	cin >> n >> k;
	Vec v(n);
	rep(i, n) cin >> v[i];

	ll ans = 0;
	deque<ll> a(n);
	rep(l, min(n, k)+1){
		rep(r, min(n, k)-l+1){
			a.clear();
			rep(i, l) a.pb(v[i]);
			rep(i, r) a.pb(v[n-1-i]);
			sort(all(a));
			rep(i, min(k-l-r, l+r) if(a[0] < 0) a.pop_front();
			ll sum = 0;
			for(ll i : a) sum += i;
			chmax(ans, sum);
		}
	}
	co(ans);

	return 0;
}


Compiler output:
a.cc:79:2: error: unterminated argument list invoking macro "rep"
   79 | }
      |  ^
a.cc: In function 'int main()':
a.cc:70:25: error: 'rep' was not declared in this scope
   70 |                         rep(i, min(k-l-r, l+r) if(a[0] < 0) a.pop_front();
      |                         ^~~
a.cc:70:28: error: expected '}' at end of input
   70 |                         rep(i, min(k-l-r, l+r) if(a[0] < 0) a.pop_front();
      |                            ^
a.cc:65:38: note: to match this '{'
   65 |                 rep(r, min(n, k)-l+1){
      |                                      ^
a.cc:70:28: error: expected '}' at end of input
   70 |                         rep(i, min(k-l-r, l+r) if(a[0] < 0) a.pop_front();
      |                            ^
a.cc:64:28: note: to match this '{'
   64 |         rep(l, min(n, k)+1){
      |                            ^
a.cc:70:28: error: expected '}' at end of input
   70 |                         rep(i, min(k-l-r, l+r) if(a[0] < 0) a.pop_front();
      |                            ^
a.cc:56:15: note: to match this '{'
   56 | int main(void){
      |               ^