Language: C++

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

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

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

int main() {
    deque<ll> d;
    int n,k;
    cin>>n>>k;
    vector<ll> v(n);
    vector<ll> rui(n+2);
    rui[0]=0;
    rui[n]=0;
    ll sum=0;
    rep(i,n){
        cin>>v[i];
        d.push_back(v[i]);
        rui[i+1]=rui[i]+v[i];
        sum+=v[i];
    }

    ll ans=0;
    ll idou=0;
    vector<ll> t1;
    for(int l=0;l<=min(n,k);l++){
        if(l!=0) {
            t1.push_back(v[l - 1]);
            idou +=v[l-1];
        }

        ll idou2=idou;
        for(int r=0;r<=min(n,k)-l;r++){
           vector<ll> t2;
           t2=t1;

           if(r!=0) {
               t2.push_back(v[n - r]);
               idou2+=v[n-r];
           }

           sort(t2.begin(),t2.end());
           ll kari=sum-idou2;

           ll a=min(n,k)-(l+r);
           ll b=t2.size();
            for(int te=0;te<=min(a,b);te++){#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

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

                int main() {
                    deque<ll> d;
                    int n,k;
                    cin>>n>>k;
                    vector<ll> v(n);
                    vector<ll> rui(n+2);
                    rui[0]=0;
                    rui[n]=0;
                    ll sum=0;
                    rep(i,n){
                        cin>>v[i];
                        d.push_back(v[i]);
                        rui[i+1]=rui[i]+v[i];
                        sum+=v[i];
                    }

                    ll ans=0;
                    ll idou=0;
                    vector<ll> t1;
                    for(int l=0;l<=min(n,k);l++){
                        if(l!=0) {
                            t1.push_back(v[l - 1]);
                            idou +=v[l-1];
                        }

                        ll idou2=idou;
                        for(int r=0;r<=min(n,k)-l;r++){
                            vector<ll> t2;
                            t2=t1;

                            if(r!=0) {
                                t2.push_back(v[n - r]);
                                idou2+=v[n-r];
                            }

                            sort(t2.begin(),t2.end());
                            ll kari=sum-idou2;

                            ll a=min(n,k)-(l+r);
                            ll b=t2.size();
                            for(int te=0;te<=min(a,b);te++){
                                if(te!=0){kari+=t2[te-1];}
                                //cout<<l<<" "<<r<<" "<<sum-kari<<" "<<endl;
                               
                            }
                            ans=max(sum-kari,ans);

                        }
                    }

                    cout<<ans<<endl;







                    return 0;
                }

                if(te!=0){kari+=t2[te-1];}
                //cout<<l<<" "<<r<<" "<<sum-kari<<" "<<endl;
                ans=max(sum-kari,ans);
            }

        }
    }

    cout<<ans<<endl;







    return 0;
}


Compiler output:
a.cc:66:45: error: stray '#' in program
   66 |             for(int te=0;te<=min(a,b);te++){#include <iostream>
      |                                             ^
a.cc: In function 'int main()':
a.cc:66:46: error: 'include' was not declared in this scope
   66 |             for(int te=0;te<=min(a,b);te++){#include <iostream>
      |                                              ^~~~~~~
a.cc:66:63: error: expected primary-expression before '>' token
   66 |             for(int te=0;te<=min(a,b);te++){#include <iostream>
      |                                                               ^
a.cc:83:17: error: expected primary-expression before 'typedef'
   83 |                 typedef int long long ll;
      |                 ^~~~~~~
a.cc:91:25: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   91 |                 int main() {
      |                         ^~
a.cc:91:25: note: remove parentheses to default-initialize a variable
   91 |                 int main() {
      |                         ^~
      |                         --
a.cc:91:25: note: or replace parentheses with braces to value-initialize a variable
a.cc:91:28: error: a function-definition is not allowed here before '{' token
   91 |                 int main() {
      |                            ^