Language: C++

#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> V(N);
    REP(i, N) { cin >> V[i]; }
    ll ans = 0;
    REP(i, min(K, N)) {
        //左からi-1番目まで穫る
        REP(j, min(N, N - i)) {
            //右からj-1番目まで穫る
            vector<int> tmp(i + j);
            REP(k, i) { tmp[k] = V[i]; }
            REP(l, j) { tmp[i + l] = V[N - l]; }
            int resop = K - i - j;
            if(resop > 0) {
                sort(tmp.begin(), tmp.end());
                REP(m, resop) {
                    if(tmp[m] < 0) {
                        tmp[m] = 0;
                    }
                }
                ans = max(ans, (long long)accumulate(tmp.begin(), tmp.end()));
            }
        }
    }
    cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:40:19: error: no matching function for call to 'min(int&, ll)'
   40 |         REP(j, min(N, N - i)) {
      |                ~~~^~~~~~~~~~
a.cc:2:41: note: in definition of macro 'REP'
    2 | #define REP(i, n) for(ll i = 0; i < (ll)n; i++)
      |                                         ^
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:40:19: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   40 |         REP(j, min(N, N - i)) {
      |                ~~~^~~~~~~~~~
a.cc:2:41: note: in definition of macro 'REP'
    2 | #define REP(i, n) for(ll i = 0; i < (ll)n; i++)
      |                                         ^
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:40:19: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   40 |         REP(j, min(N, N - i)) {
      |                ~~~^~~~~~~~~~
a.cc:2:41: note: in definition of macro 'REP'
    2 | #define REP(i, n) for(ll i = 0; i < (ll)n; i++)
      |                                         ^
a.cc:53:53: error: no matching function for call to 'accumulate(std::vector<int>::iterator, std::vector<int>::iterator)'
   53 |                 ans = max(ans, (long long)accumulate(tmp.begin(), tmp.end()));
      |                                           ~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/numeric:62,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:58:
/usr/include/c++/14/bits/stl_numeric.h:134:5: note: candidate: 'template<class _InputIterator, class _Tp> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp)'
  134 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init)
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:134:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_numeric.h:161:5: note: candidate: 'template<class _InputIterator, class _Tp, class _BinaryOperation> _Tp std::accumulate(_InputIterator, _InputIterator, _Tp, _BinaryOperation)'
  161 |     accumulate(_InputIterator __first, _InputIterator __last, _Tp __init,
      |     ^~~~~~~~~~
/usr/include/c++/14/bits/stl_numeric.h:161:5: note:   candidate expects 4 arguments, 2 provided