Language: C++

#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(ll (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(ll (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define Rall(a) (a).rbegin(), (a).rend()
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
const ll INF=1e10+1;
using namespace std;
#define NOT_EXIST -1

int dy[]={1,-1,0,0,1,1,-1,-1,0};
int dx[]={0,0,1,-1,1,-1,1,-1,0};

signed
main(){
		int N,K;
		cin >> N >> K;
		vector<ll> v(N);
		rep(i,N){
				cin >> v[i];
		}
		int ans = 0;

		for(int take = 0;take<=min(N,K);take++) {
				for(int left = 0;left <= take;left++) {
						vector<ll> tmp;
						int right = take - left;
						for(int i = 0;i < left;i++) {
								tmp.push_back(v[i]);
						}
						for(int i = 0;i < right;i++) {
								tmp.push_back(v[N-1-i]);
						}
						sort(All(tmp));
						int minus = K - take;
						ll t_sum = 0;
						for(int i = minus; i < tmp.size();i++) {
								t_sum += tmp[i];
						}
						ans = max(ans, t_sum);

				}
		}
		cout << ans << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:49:58: error: no matching function for call to 'max(int&, ll&)'
   49 |                                                 ans = max(ans, t_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:   template argument deduction/substitution failed:
a.cc:49:58: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'll' {aka 'long long int'})
   49 |                                                 ans = max(ans, t_sum);
      |                                                       ~~~^~~~~~~~~~~~
/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:49:58: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   49 |                                                 ans = max(ans, t_sum);
      |                                                       ~~~^~~~~~~~~~~~