akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
                                                                                   


int main(){
                                                                     

    int x, y, z, i;


    cin >> x >> y >> z;


    for( i = 1 ;  ; i = i + 1 ){

         if( z + y + z + ( i - 1 ) * ( y + z ) > x ) break;

         }


    cout << i - 1 << endl;
    

    return 0;

    }

Measured memory_bytes: 256
#include <bits/stdc++.h>

#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(v) int(v.size())
#define pii pair<int, int>
#define mp make_pair
#define f first
#define ll long long
#define ld long double
#define s second
#define vec vector<int>

using namespace std;

const int N = (int) 2000 + 10;
const int M = (int) 1e6 + 10;
const int K = (int) 500 + 10;
const int mod = (int) 1e9 + 7;
const ld EPS = 1e-9;
const ll LINF = (ll) 1e18;

int n, m;
vector<pii> g, e;
int ans;

vector<pii> solve(vector<pii> g, vector<pii> e) {
	vector<pii> cur;
	map<int, int> deg;
	for (auto it : g) {
		deg[it.f]++;
		deg[it.s]++;
	}
	int ver = -1;
	for (auto it : deg) {
		if (it.s == 1) { // degree = 1
			ver = it.f;
		}
	}
	int parent = -1;
	for (auto it : g) {
		if (it.f == ver || it.s == ver) {
			parent = (it.f ^ it.s ^ ver);
		}
	}
	if (ver == -1) {
		return e;
	}
	assert(ver != -1);
	vec leaf_paths;
	vector<pii> new_e;
	map<int, int> p;
	for (int i = 0; i < sz(e); i++) {
		if (e[i].f == e[i].s)
			continue;
		if (e[i].f == ver) {
			swap(e[i].f, e[i].s);
		}
		if (e[i].s == ver) {
			leaf_paths.pb(i);
		} else {
			new_e.pb(e[i]);
			p[sz(new_e) - 1] = i;
		}
	}
	vector<pair<pii, int> > relation;
	//ans += min(sz(leaf_paths), 2);
	while (sz(leaf_paths) >= 2) {
		int id_u = leaf_paths[sz(leaf_paths) - 1];
		int id_v = leaf_paths[sz(leaf_paths) - 2];
		leaf_paths.pop_back();
		leaf_paths.pop_back();
		new_e.pb(mp(e[id_u].f, e[id_v].f));
		relation.pb(mp(mp(id_u, id_v), sz(new_e) - 1));
	}
	if (sz(leaf_paths) == 1) {
		new_e.pb(mp(e[leaf_paths[0]].f, parent));		
		relation.pb(mp(mp(leaf_paths[0], leaf_paths[0]), sz(new_e) - 1));
	}
	vector<pii> new_g;
	for (auto it : g) {
		if (it.f != ver && it.s != ver) {
			new_g.pb(it);
		}
	}
	vector<pii> sub = solve(new_g, new_e);
	cur = e;
	for (auto it : p) {
		cur[it.s] = sub[it.f];
	}
	for (auto it : relation) {
		// it.f.f, it.f.s
		// it.f.f => (a -> ver)
		// it.f.s => (b -> ver)
		// it.s => (a -> b)
		if (it.f.f == it.f.s) {
			if (sub[it.s] != new_e[it.s]) { // parent -> a
				swap(cur[it.f.f].f, cur[it.f.f].s);
			}
			continue;
		}
		if (sub[it.s] == new_e[it.s]) { // a -> b
			// we should make a->ver, ver->b
			swap(cur[it.f.s].f, cur[it.f.s].s);
		} else { // b -> a
			// we should make b->ver, ver->a
			swap(cur[it.f.f].f, cur[it.f.f].s);
		}
	}
	return cur;
}

int p[N];
vec v[N];

void dfs(int ver, int par = -1) {
	for (auto it : v[ver]) {
		if (it != par) {
			p[it] = ver;
			dfs(it, ver);
		}
	}
}

pii f(int x, int y) {
	if (x > y)
		swap(x, y);
	return mp(x, y);
}

int main() {
	srand(time(0));
	cin >> n >> m;
	g.resize(n - 1);
	e.resize(m);
	for (int i = 0; i < n - 1; i++) {
		cin >> g[i].f >> g[i].s;
		v[g[i].f].pb(g[i].s);
		v[g[i].s].pb(g[i].f);
	}
	map<pii, int> cnt;
	for (int i = 0; i < m; i++) {
		cin >> e[i].f >> e[i].s;
		dfs(e[i].f);
		int x = e[i].s;
		while (1) {
			if (x == e[i].f) break;
			cnt[f(x, p[x])]++;
			x = p[x];
		}
	}
	for (auto it : cnt) ans += min(2, it.s);
	vector<pii> res = solve(g, e);
	cout << ans << "\n";
	for (auto it : res) {
		cout << it.f << ' ' << it.s << "\n";
	}
	return 0;
}


Measured memory_bytes: 273280
#include <bits/stdc++.h>

using namespace std;

#define SZ(x) (int)(x.size())

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const double eps = 1e-10;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;

template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}

template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  ll n, t; cin >> n >> t;
  vll a(n), b(n);
  for(int i=0;i<n;++i) {
    cin >> a[i] >> b[i];
  }
  vector<pair<ll, ll>> v1, v0;
  for(int i=0;i<n;++i) {
    if(a[i] == 0) {
      v0.push_back({a[i], b[i]});
    } else {
      v1.push_back({a[i], b[i]});
    }
  }

  sort(v1.begin(), v1.end(), [](pair<ll, ll> a, pair<ll, ll> b){return a.first / (a.second + 1.0) > b.first / (b.second + 1.0);});
  sort(v0.begin(), v0.end());
  //printv(v);

  int sz1 = SZ(v1), sz0 = SZ(v0);

  vvll dp(sz1+1, vll(30, LINF));
  dp[0][0] = 0;
  for(int i=0;i<sz1;++i) {
    for(int j=0;j<30;++j) {
      if(dp[i][j] == LINF) continue;
      dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

      ll nxt = dp[i][j] + 1;
      nxt += v1[i].first * nxt + v1[i].second;
      dp[i+1][j+1] = min(dp[i+1][j+1], nxt);
    }
    //printv(dp[i]);
  }
  //printv(dp[sz1]);

  int ma = 0;
  for(int j=0;j<=29;++j) {
    ll now = dp[sz1][j];
    if(now > t) continue;
    int cnt = j;
    ll su = 0;
    for(int k=0;k<sz0;++k) {
      su += v0[k].second;
      if(now + su + k+1 <= t) cnt++;
      else break;
    }
    ma = max(ma, cnt);
  }
  cout << ma << endl;


}


Measured memory_bytes: 61804
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
long long int MOD = 1000000007;


int main(){
	int n;
	ll L;
	cin>>n>>L;
	vector<ll> a;
	ll x;
	for(int i=0;i<n;i++){
		cin>>x;
		a.pb(x);
	}
	int check=0;
	ll ma=0;
	for(int i=0;i<n-1;i++){
		if(ma<a[i]+a[i+1]){				
			ma=a[i]+a[i+1];
			check=i;
		}
	}
	if(ma<L)cout<<"Impossible"<<endl;
	else{
		cout<<"Possible"<<endl;
		for(int j=0;j<check;j++){
			cout<<j+1<<endl;
		}
		for(int j=n-2;j>check;j--){
			cout<<j+1<<endl;
		}
		cout<<check+1<<endl;
	}
	
}


Measured memory_bytes: 1780
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <string.h>
using namespace std;

int main()
{
    int n, l, max = 0, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> l;
        sum += l;
        if (max < l)
            max = l;
    }
    cout << (max < sum - max ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
using namespace std;

int main() {
	int n;
	double s[1005];
	while(cin>>n && n!=0){
		double sum=0;
		for(int i=0;i<n;i++){
			cin>>s[i];
			sum +=s[i];
		}
		double avg=sum/n;
		sum=0;
		for(int i=0;i<n;i++){
			sum+=(s[i]-avg)*(s[i]-avg);
		}	
		if(sum==0){
			printf("%lf\n",sum);
		}else{
			printf("%lf\n",sqrt(sum/n));
		}

	}
	return 0;
}

Measured memory_bytes: 3276
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &t) {
	t=0; char ch=getchar(); int f=1;
	while (ch<'0'||ch>'9') { if (ch=='-') f=-1; ch=getchar(); }
	do { (t*=10)+=ch-'0'; ch=getchar(); } while ('0'<=ch&&ch<='9'); t*=f;
}
const int maxn=(2e5)+10;
char s[maxn],t[maxn];
int n,ans;
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%s",s+1);
	scanf("%s",t+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) if (s[i]!=t[i]) ans++;
	printf("%d\n",ans);
	return 0;
}
/*
  0. Enough array size? Enough array size? Enough array size? Interger overflow?
  
  1. Think TWICE, Code ONCE!
  Are there any counterexamples to your algo?
    
  2. Be careful about the BOUNDARIES!
  N=1? P=1? Something about 0?
    
  3. Do not make STUPID MISTAKES!
  Time complexity? Memory usage? Precision error?
*/

Measured memory_bytes: 4176
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    String[] strs = new String[n];
    for(int i = 0; i < n; i++) {
      strs[i] = sc.next();
    }
    String ans = "";
    for(char a = 'a'; a <= 'z'; a++) {
      int num = 100;
      for(int i = 0; i < n; i++) {
        int count = 0;
        for(int j = 0; j < strs[i].length(); j++) {
          if(a == strs[i].charAt(j)) count++;
        }
        num = Math.min(num, count);
      }
      String s = String.valueOf(a);
      for(int i = 0; i < num; i++) {
        ans += s;
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 21844
#include "iostream"
#include "vector"
#include "string"
#include "algorithm"
#include "math.h"
#include "cstring"
#include "stack"
#include "queue"

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<vector<ll> > mat;

int main()
{
  int a, b;
  char c;
  cin >> a >> c >> b;
  cout << (c == '+' ? a + b : a - b) << "\n";
}

Measured memory_bytes: 256
H, W = map(int, input().split())
a = [input() for _ in range(H)]
dp = [[0]*W for _ in range(H)]
dp[0][0] = 1

mod = 10**9+7

for w in range(1, W):
    if a[0][w]=='#': break
    dp[0][w] = 1
for h in range(1, H):
    if a[h][0]=='#': break
    dp[h][0] = 1
for h in range(1, H):
    for w in range(1, W):
        if a[h][w]=='#': continue
        dp[h][w] = (dp[h-1][w]+dp[h][w-1])%mod
print(dp[-1][-1])

Measured memory_bytes: 74432
N = int(input())
S = input()
E_count = 0
W_count = 0
lis = []
for s in S:
    lis.append(W_count)
    if s == 'W':
        W_count += 1
for index, s in enumerate(S[::-1]):
    lis[N-1-index] += E_count
    if s == 'E':
        E_count += 1
minimam = 3*10**5
for count in lis:
    minimam = min(minimam, count)
print(minimam)

Measured memory_bytes: 17404
#include<bits/stdc++.h>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N, A, B, C;
string S[101010];
char s[10];
ll i, j, k;
map<ll, ll> mp;
vector<ll> anss;



ll& getn(char c){
    if(c=='A')
        return A;
    if(c=='B')
        return B;
    if(c=='C')
        return C;
}

int main(){
    scanf("%lld%lld%lld%lld", &N, &A, &B, &C);
    fornum(i,0,N){
        cin >> S[i];
    }
    fornum(i,0,N){
        if(i<N-1&&getn(S[i][0])==1&&getn(S[i][1])==1){
            if(S[i][0]==S[i+1][0]||S[i][0]==S[i+1][1]){
                anss.push_back(S[i][0]);
                ++getn(S[i][0]);
                --getn(S[i][1]);
            }else{
                anss.push_back(S[i][1]);
                ++getn(S[i][1]);
                --getn(S[i][0]);
            }
            continue;
        }
        ll a = 0;
        if(getn(S[i][1])>getn(S[i][0]))
            a = 1;
        if(getn(S[i][a])==0){
            printf("No\n");
            return 0;
        }
        anss.push_back(S[i][!a]);
        ++getn(S[i][!a]);
        --getn(S[i][a]);
    }
    printf("Yes\n");
    fornum(i,0,N){
        printf("%c\n", anss[i]);
    }
    return 0;
}

Measured memory_bytes: 7580
#include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
using ll =long long;
using namespace std;
int main() {
	ll A, B;
	string a;
	cin >> A;
	
	cin >> a;
	cin >> B;
	if (a == "+") {
	
		cout << A + B;
	
	}
	else {
		cout << A - B;
	}

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define MOD 1000000007
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s, t;
	cin >> s >> t;
	cout << (t + s) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
const long INF=1000000000000000;
const long MOD=1000000007;

int main(){
    long a,b,c;
    cin>>a>>b>>c;
    if(b-a==c-b) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <fstream>
#include <algorithm>
using namespace std;

using ll = long long;

const int N = 2e5 + 10;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    int x, y;
    cin >> x >> y;
    for (int i = 0; i <= 100; ++i)
    for (int j = 0; j <= 100; ++j)
        if (i + j == x && i * 2 + j * 4 == y) {
            cout << "Yes";
            return 0;
        }

    cout << "No";
}


Measured memory_bytes: 3632
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N,x;
  cin >> N;
  ll ans=0;
  ll A[1001000];
  for(int i=1;i<=N;i++){
    cin >> A[i];
  }
  for(int i=1;i<=N;i++){
    if(A[i]%2==1 && A[i+1]>0){
      A[i]--;
      A[i+1]--;
      ans++;
    }
    ans+=A[i]/2;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3072
#include <stdio.h>
#include <string.h>
int main(){
	int n;
	char s[102]={};
	int ctr=0;
	scanf("%d", &n);
	scanf("%s", &s);
	if(n%2!=0){
		printf("No");
		return 0;
	}
	int half=n/2;
	for(int i=0;i<half;i++){
		if (s[i]==s[i+half]){
			ctr++;
		}
	}
	if(ctr==half){
		printf("Yes");
	}else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 1704
#pragma GCC optimize("Ofast",3,"inline")
#include<bits/stdc++.h>
using namespace std;
#define fir first
#define sec second
#define m_p make_pair
#define y1 ygftgfgcdtfgxffgx
#define y2 yfdsesgvtyghftfvv
#define x1 xvyr6cf6fgcfgf676
#define x2 xcr6rfc5r66y6r6fr
#define up_bound upper_bound
#define low_bound lower_bound
#define next_per next_permutation
#define pb push_back
#define i_to_s to_string
typedef priority_queue<int> p_queue;
typedef priority_queue<int, vector<int>, greater<int> > min_p_queue;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
int mon[20]={31,28,31,30,31,30,31,31,30,31,30,31};
ll gcd(ll x,ll y){return ((y==0)?x:gcd(y,x%y));}
ll a,b,c,k;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	cin>>a>>b>>c>>k;
	if(k<=a+b)cout<<min(k,a);
	else cout<<a-(k-a-b);
	return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>

using namespace std;
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {os << "["; for (const auto &v : vec) {os << v << ","; } os << "]"; return os;}
template <typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &p) {os << "(" << p.first << ", " << p.second << ")"; return os;}

void solve() {
    int N;
    cin >> N;
    vector<pll> Q(N);
    vector<ll> A(N), B(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i] >> B[i];
        Q[i] = {A[i] + B[i], i};
    }
    sort(all(Q), greater<pll>());
    ll ans = 0;
    for (int i = 0; i < N; i++) {
        if (i % 2 == 0) {
            ans += A[Q[i].second];
        } else {
            ans -= B[Q[i].second];
        }
    }
    cout << ans << endl;
}

int main() {
    #ifdef LOCAL_ENV
    cin.exceptions(ios::failbit);
    #endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    
    solve();

    #ifdef LOCAL_ENV
    assert(cin.rdstate() & ios_base::eofbit);
    #endif
}

Measured memory_bytes: 3456
#include <iostream>
using namespace std;
 
int visit[100],end[100],a[100][100];
int t,N,u,k,p;
 
void list(int N){
    for(int i=0;i<N;i++){
        cin>>u>>k;
        for (int j=0;j<k;j++){
            cin>>p;
            a[u-1][p-1]=1;
        }
    }
}
 
void sor(int cur,int N){
    t+=1;
    visit[cur]=t;
    for(int kyo=0;kyo<N;++kyo){
        if(a[cur][kyo]==1&&visit[kyo]==0){
            sor(kyo,N);
        }
    }
    t+=1;
    end[cur]=t;
}
 
int main(){
    cin >> N;
    list(N);
    for(int i=0;i<N;i++){
        if(visit[i] == 0) sor(i,N);
    }
    for(int i=0;i<N;i++){
        cout<<i+1<<' '<<visit[i]<<' '<<end[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
 
#define endl '\n'
#define f1 first
#define s2 second
#define pb push_back
#define mp make_pair
#define ll long long
#define fri(a) freopen(a,"r",stdin);
#define fro(a) freopen(a,"w",stdout);
const int N=2e5+5;

int x;

bool prime_checker(int a){
	for(int i=2;i<=sqrt(a);i++){
		if(a%i==0)return 0;
	}
	return 1;
}

int main(){
	//fri("in.txt");
	//fro("out.txt");
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>x;
	x--;
	while(x++){
		if(prime_checker(x)){
			cout<<x<<endl;
			return 0;
		}
	}

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll dp[20009];
ll n,m;
ll call(ll rem)
{
    if(rem==0)
    {
        return 1;
    }
    if(rem==1 || rem==2)
    {
        return 0;
    }
    if(dp[rem]!=-1)
    {
        return dp[rem];
    }
    ll i,x,y;
    x=0;
    for(i=3;i<=rem;i++)
    {
        y=call(rem-i);
        x=(x+y)%m;
    }
    return dp[rem]=x%m;
}
int main()
{
    ll a,b,c,d,e,i,j,k,l,x,y,t,p;
    m=(1e9)+7;
    cin>>n;
    if(n<3)
    {
        printf("0\n");
        return 0;
    }
    memset(dp,-1,sizeof(dp));
    x=call(n);
    x=x%m;
    cout<<x<<endl;
}


Measured memory_bytes: 3688
#include <iostream>
#include <string>
using namespace std;

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  int cookie = 0;
  bool poison = false;
  if(A + B + 1 >= C){
    cookie = C + B;
  }else{
    cookie = (A + B + 1) + B;
  }

  cout << cookie << endl;

  return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
p=list(map(int,input().split()))
s=sum(p[:k])
s_max=s
for i in range(k,n):
    s=s-p[i-k]+p[i]
    s_max=max(s_max,s)
print((s_max+k)/2)

Measured memory_bytes: 25060
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;
    int C[4] = {0, 0, 0, 0};
    string T[4] = {"AC", "WA", "TLE", "RE"};
    for (int i = 1; i <= N; i++)
    {
        string S;
        cin >> S;
        for (int j = 0; j < 4; j++)
        {
            if (S == T[j])
                C[j]++;
        }
    }
    for (int i = 0; i < 4; i++)
    {
        cout << T[i] << " x " << C[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3628
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1e9;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string n; cin >> n;
    rep(i,n.size()) {
        if (n[i]=='7') {
            ct("Yes");
            return 0;
        }
    }
    ct("No");
}



Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
ll dp[5005][5005];
ll a[500005];
vector<pair<ll,ll> >vp;
ll n;
ll recurse(ll pos,ll inpos,ll finpos){
    if(pos<0)
        return 0;
    if(dp[inpos][finpos]!=-1)
        return dp[inpos][finpos];
    ll maxi=max(vp[pos].fi*abs(inpos-vp[pos].se)+recurse(pos-1,inpos+1,finpos),vp[pos].fi*abs(finpos-vp[pos].se)+recurse(pos-1,inpos,finpos-1));
    return dp[inpos][finpos]=maxi;
}
int main(){
    fastread;
    ll i,j,k,l,m;
    for(i=0;i<2000;i++){
        for(j=0;j<=2000;j++)
            dp[i][j]=-1;
    }
    cin>>n;
    for(i=1;i<=n;i++){
        cin>>a[i];
        vp.pb({a[i],i});
    }
    sort(vp.begin(),vp.end());
    cout<<recurse(n-1,1,n);
}

Measured memory_bytes: 43072
using System;
using System.Collections.Generic;
using System.Linq;

namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            var ST = Console.ReadLine().Split();
            var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
            var U = Console.ReadLine();

            if (ST[0] == U) AB[0]--;
            else AB[1]--;

            Console.WriteLine(AB[0] + " " + AB[1]);
        }
    }
}

Measured memory_bytes: 13268
import java.util.Scanner;

//AtCoder Beginner Contest 134
//B	Golden Apple
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int D = sc.nextInt();
		sc.close();

		int mod = N % (D * 2 + 1);
		int ans = N / (D * 2 + 1);
		if (mod != 0) {
			ans++;
		}

		System.out.println(ans);
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <string>
#define INF 1000000000000000000
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> P;

int main() {

	int a;
	cin >> a;
	if (a % 2 == 1) {
		cout << a * 2 << endl;
	}
	else {
		cout << a << endl;
	}
	

	return 0;
}

Measured memory_bytes: 256
import sys 
def ordinary():
    n=int(input())
    p=list(map(int, input().split()))
    countour=0
    for i in range(1,n-1):
        if ((p[i-1] <p[i] ) & (p[i] < p[i+1])) or ((p[i-1] > p[i] )& (p[i] > p[i+1])):
            countour+=1
    
    print(countour)

ordinary()

Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
using ll = long long;
int main() {
  string s;
  cin >> s;
  int n = s.size();
  if(s[n - 1] == 's') {
    cout << s << "es\n";
  } else {
    cout << s << "s\n";
  }
  return 0;
}

Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint D, T, S;
	cin >> D >> T >> S;
	if (D <= T * S) {
		cout << "Yes" << enld;
	}
	else {
		cout << "No" << enld;
	}
}

Measured memory_bytes: 3632
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto s = readln.split.map!(to!int);
    auto N = s[0];
    auto M = s[1];
    auto PY = M.iota.map!(_ => readln.split.map!(to!int).array).array;

    auto X = new Tuple!(int, int)[][](N+1);
    foreach (i; 0..M) X[PY[i][0]] ~= tuple(i, PY[i][1]);
    foreach (i; 0..N+1) X[i].sort!"a[1] < b[1]";

    auto ans = new string[](M);
    foreach (j; 0..N+1) {
        foreach (i; 0..X[j].length.to!int) {
            ans[X[j][i][0]] = (format("%06d", j)) ~ (format("%06d", i + 1));
        }
    }

    ans.each!writeln;
}


Measured memory_bytes: 18300
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            // 文字列の入力
            string s = Console.ReadLine();

            // 整数の入力
            // long n = long.Parse(Console.ReadLine());

            // 文字列配列の入力
            //string[] inputStrArray = Console.ReadLine().Split(' ');

            // 整数配列の入力
            //var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

            bool
                a = false,
                b = false;

            for (int i = 0; i < s.Length; i++)
            {
                if (s[i] == 'A') a = true;
                if (s[i] == 'B') b = true;
            }

            string result = "";

            if (a && b) result = "Yes";
            else result = "No";

   

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000000)
#define MOD (1000000007)
#define MAX (500000)
#define pii pair<int, int>

/////////////////////////////////////////////////////////

class XY{
public:
  ll x, y;
  XY() {x = y = 0;}
  XY(ll u, ll v) {x = u; y = v;}
};

class e{
public:
  ll a, b;
  e() {a = b = -1;}
  e(ll u, ll v) {a = u; b = v;}
};

template<typename T1, typename T2>
void chmin(T1 &a, T2 b) {if(a > b) a = b;}
template<typename T1, typename T2>
void chmax(T1 &a, T2 b) {if(a < b) a = b;}

template<typename T1, typename T2>
ll mypow(T1 a, T2 n){
  if(n == 0) return 1;
  if(n == 1) return a;
  if(n % 2) return a * mypow(a, n - 1);
  ll tmp = mypow(a, n / 2);
  return tmp * tmp;
}

template<typename T>
int BS(vector<T> &V, int left, int right, T key){
  int mid = (left + right) / 2;
  if(V[mid] <= key) left = mid;
  else right = mid;
  if(right - mid == 1) return left;
  else return BS(V, left, right, key);
}

ll comb(ll n, ll r){
	ll res = 1;
  rep(i, 0, r){
    res *= n - i;
    res /= i + 1;
  }
  return res;
}

template<typename T>
T euclid(T a, T b){
  if(b == 0) return a;
  else return euclid(b, a % b);
}

vector<ll> fact(MAX, 0), fact_inv(MAX, 0);

ll pow_mod(ll a, ll b){
	ll res = 1;
	while(b > 0){
		if(b & 1) res = res * a % MOD;
		a = a * a % MOD;
		b >>= 1;
	}
	return res;
}

void prepare_comb_mod(ll n){
	fact[0] = 1LL;
	for(ll i = 0; i < n; i++) fact[i+1] = fact[i] * (i + 1) % MOD;
	fact_inv[n] = pow_mod(fact[n], MOD - 2);
	for(ll i = n - 1; i >= 0; i--) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
}

ll comb_mod(ll n, ll r){
	return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

/////////////////////////////////////////////////////////

class v3{
public:
  ll a, f, c;
  v3(ll x, ll y, ll z){
      a = x; f = y; c = z;
  };
};

bool check(vector<v3> &vv, ll K, ll x){
  rep(i, 0, vv.size()){
    if(vv[i].c - x < 0) continue;
    if((vv[i].c - x) % vv[i].f == 0) K -= max(0ll, (vv[i].c - x) / vv[i].f);
    else K -= max(0ll, (vv[i].c - x) / vv[i].f + 1);
  }
  if(K >= 0) return true;
  else return false;
}

ll BS(vector<v3> &vv, ll K, ll left, ll right){
  if(right - left == 1) return right;
  ll mid = (left + right) / 2;
  if(check(vv, K, mid)) right = mid;
  else left = mid;
  return BS(vv, K, left, right);
}

void Main() {
  ll N, K; cin >> N >> K;
  vector<ll> A(N);
  vector<ll> F(N);
  rep(i, 0, N) cin >> A[i];
  rep(i, 0, N) cin >> F[i];
  sort(all(A), greater<ll>());
  sort(all(F));
  vector<v3> vv;

  ll ma = 0;
  rep(i, 0, N){
    vv.push_back(v3(A[i], F[i], A[i] * F[i]));
    chmax(ma, A[i] * F[i]);
  }

  ll res = BS(vv, K, -1, ma);
  cout << res << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 19568
#include <iostream>
#include <stdio.h>
#include <map>
#include <queue>
#include <vector>
#include <utility>
#include <iomanip>
#include <algorithm>

using namespace std;

#define ull unsigned long long
#define ll long long
#define ff first
#define ss second
#define mod 1e9+7
ll gcd(ll a, ll b){ if ( a == 0 ) return b; return gcd(b%a, a); }
void tf(int b){ b == 1 ? cout<<"NO"<<endl : cout<<"YES"<<endl; }

int main(){
    string a;
    cin>>a;

    map <char, int> s;
    for (int i=0;i<a.size();i++){
        s[a[i]]++;
    }

    bool flag = true;
    for (char i='a';i<='z';i++){
        if ( s[i] == 0 ) continue;
        if ( s[i] % 2 == 1 ){
            cout<<"No"<<endl;
            return 0;
        }
    }

    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;class Main{public static void main(String[]z){Map<Integer,Map<Integer,Integer>>u=new HashMap<Integer,Map<Integer,Integer>>();int k,h,i,j,t,p,m;for(m=1;m<11;m++){Map<Integer,Integer>g=new HashMap<Integer,Integer>();long w,y,a,r,b,v;for(w=(1L<<m)-1;(w&~((1L<<10)-1))==0;){int[]l=new int[m],o;y=w;for(j=i=0;i++<10;y>>>=1)if((y&1)>0)l[j++]=i-1;a=w&-w;r=w+a;b=r&-r;v=((b/a)>>1)-1;w=r|v;o=new int[m+1];for(i=1;i<=m;o[i]=i++);for(k=0;k<m;o[k]--){t=l[k];l[k]=l[p=k%2<1?0:o[k]];l[p]=t;for(k=1;o[k]<1;o[k]=k++);for(h=i=0;i++<m;h+=i*l[i-1]);if(!g.containsKey(h))g.put(h,0);g.put(h, g.get(h)+1);}}u.put(m,g);}for(Scanner s=new Scanner(System.in);s.hasNext();){Integer x=u.get(s.nextInt()).get(s.nextInt());System.out.println(x==null?0:x);}}}

Measured memory_bytes: 12000
#include <iostream>

int main()
{
    int sec;
    std::cin >> sec;
    int h = sec / 3600;
    int m = sec % 3600 / 60;
    int s = sec % 3600 % 60 % 60;
    std::cout << h << ":" << m << ":" << s << std::endl;
}


Measured memory_bytes: 3096
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int a,b,c;cin>>a>>b>>c;
  cout << min(c, b/a) << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
//============================================================================
// Name        : d.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	int n,m;cin>>n>>m;
	vector<int> a(n);
	for(auto& x:a){
		cin>>x;
	}
	vector<pair<int,int>> v;
	for(int i=0;i<m;i++){
		pair<int,int> p;
		cin>>p.second>>p.first;
		v.push_back(p);
	}
	sort(v.begin(),v.end());
	sort(a.begin(),a.end());
	int j=-1;
	for(int i=m-1;i>=0;i--){
		int b=v[i].second;
		int c=v[i].first;
		int flag=0;
		for(int k=j+1;k<=j+b;k++){
			a[k]=max(a[k],c);
			if(k==n-1){
				flag=1;
				break;
			}
		}
		j+=b;
		if(flag)
			break;

	}
	long long ans=0;
	for(int i=0;i<n;i++){
//		cout<<a[i]<<endl;
		ans+=a[i];
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 1784
#include<bits/stdc++.h>
using namespace std;
int N,M,a[10005];
int main(){
	long long sum = 0;
	cin >> N >>M;
	for(int i=0;i<M;i++){
		cin>> a[i];
		sum += a[i];
	}
	if(sum>N){
		cout <<"-1" <<endl;
	}else{
		cout << N-sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


int main(void) {
    ios::sync_with_stdio(false);cin.tie(0);
    string s,t;
    cin>>s;
    ll ans=0;
    if(s.size()<3){
        fin(0);
        return 0;
    }
    rep(i,s.size()){
        if(s[i]=='A')t+='A';
        else if(i<s.size()-1&&s[i]=='B'&&s[i+1]=='C'){
            t+='D';
            i++;
        }
        else {
            t+=s[i];
        }
    }
    ll na=0;
    for(int i=0;i<t.size();i++){
        if(t[i]=='A'){
            na++;
        } else if(t[i]=='D'){
            ans+=na;
        }
        else {
            na=0;
        }
    }

    fin(ans);

}


Measured memory_bytes: 916
#include <bits/stdc++.h>
using namespace std;

int main()
{
	long long n, a[1005], b[1005], x = 1, y = 1;
	cin >> n;
	for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
	for (int i = 0; i < n; i++)
	{
		if (a[i] >= x && b[i] >= y) x = a[i], y = b[i];
		else
		{
			long long num = max(x/a[i], y/b[i]);
			while (!(x <= a[i]*num && y <= b[i]*num)) num++;
			x = a[i]*num, y = b[i]*num;
		}
	}
	cout << x+y << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LOCAL
using namespace std;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define int long long
using P = pair<int,int>;
//#########################################
const int INF = 1001001001001;
signed main(){
	int n,k;cin >> n >> k;
	vector<int> a(n);
	rep(i,n)cin >> a[i];
	vector<int> suf(n+1),pre(n+1);
	int ret = -INF;
	rep(i,n)suf[i+1] = suf[i] + a[i];
	for(int i = n-1;i >= 0;i--)pre[i] = pre[i+1] + a[i];
	for(int l = 0;l <= n;l++){
		for(int r = 0; l+r <= min(n,k);r++){
			int tmp = suf[l] + pre[n-r];
			int rest = k - (l+r);
			vector<int> res;
			rep(i,l)res.push_back(a[i]);
			rep(i,r)res.push_back(a[n-i-1]);
			// trace(l,r,res,tmp,rest);
			sort(res.begin(),res.end());
			ret = max(tmp,ret);
			rep(i,min(rest,(int)res.size())){
				
				tmp -= res[i];
				
				ret = max(tmp,ret);
			}

		}
	}
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 200010;

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int cnt[2][2019];
    rep(i, 2)rep(j, 2019) cnt[i][j] = 0;
    lint ans = 0;
    For(i, 1, n+1){
        rep(j, 2019) cnt[i%2][j] = 0;
        rep(j, 2019){
            cnt[i%2][(j*10+s[i-1]-'0')%2019] += cnt[(i-1)%2][j];
        }
        ++cnt[i%2][s[i-1]-'0'];
        ans += cnt[i%2][0];
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 3832
n=int(input())
hatsugen=[]
w=input()
hatsugen.append(w)
oshiri=w[-1]
Flag=True
for _ in range(n-1):
    w=input()
    if w[0]!=oshiri:
        Flag=False
        break
    if w in hatsugen:
        Flag=False
        break
    oshiri=w[-1]
    hatsugen.append(w)
if Flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9024
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <vector>
#include <map>
#include<cstdio>
#include<functional>
#include <bitset>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define ll long long
using namespace std;
template <typename T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <typename T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
const ll INF = 1000000000000000000;
const ll MOD = 1e9 + 7;

std::string substrBack(std::string str, size_t pos, size_t len) {
	const size_t strLen = str.length();

	return str.substr(strLen - pos, len);
}

int main()
{
	int n;
	cin >> n;
	vector<ll> al(n);
	vector<ll> bl(n);
	vector<ll> cl(n);
	rep(i, n) {
		cin >> al[i];
	}
	rep(i, n) {
		cin >> bl[i];
	}
	rep(i, n) {
		cin >> cl[i];
	}
	sort(al.begin(), al.end());
	sort(bl.begin(), bl.end());
	sort(cl.begin(), cl.end());

	ll ans = 0;
	/*rep(i, n) {
		auto lb = upper_bound(bl.begin(), bl.end(), al[i]);
		ll lbStart = lb - bl.begin();
		ll tmp = 0;
		for (int j = lbStart; j < cl.size(); j++)
		{
			auto cb = upper_bound(cl.begin(), cl.end(), bl[j]);
			tmp += cl.size() - (cb - cl.begin());
		}
		ans += tmp;
	}*/
	rep(i, n) {
		auto la = lower_bound(al.begin(), al.end(), bl[i]) - al.begin();
		auto lc = cl.size() - (upper_bound(cl.begin(), cl.end(), bl[i]) - cl.begin());
		ans += la * lc;
	}
	cout << ans << endl;
	//cout << fixed << setprecision(10) << ans << endl;
	system("pause");
}




Measured memory_bytes: 5612
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(int argc, const char * argv[]) {
    string s;
    cin >> s;
    
    bool easy = true;
    for (int i = 0; i < s.size(); i++) {
        if (i % 2 == 1) {
            easy = easy && (s[i] == 'L' || s[i] == 'U' || s[i] == 'D');
        } else {
            easy = easy && (s[i] == 'R' || s[i] == 'U' || s[i] == 'D');
        }
    }
    cout << (easy ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
T = []
XY = []


def f(x1, y1, x2, y2):
    return abs(x1 - x2) + abs(y1 - y2)


cx, cy = 0, 0
ct = 0
for _ in range(N):
    t, x, y = map(int, input().split())
    d = f(cx, cy, x, y)
    # print(f'{ct=}, {t=}, {d=}')
    if d > t - ct:
        print('No')
        exit()
    if (t - ct - d) % 2 != 0:
        print('No')
        exit()
    cx, cy = x, y
    ct = t
print('Yes')


Measured memory_bytes: 9184
#include<bits/stdc++.h>
 
#define fi first
#define se second
#define pb push_back
 
#define limit (int) (1e6 + 5) 
#define mod (long long int) (1e9 + 7)
 
using namespace std;
using lli = long long int;
using ulli = unsigned long long int;
using ld = long double;

int k;
int ans[limit];

int main()
{
	// ios_base::sync_with_stdio(false);cin.tie(NULL);   
    int x;
    cin >> x;

    cout << 1-x;

    return 0;
}




Measured memory_bytes: 3632
use std::io::*;

fn read<T: std::str::FromStr>() -> T {
    let stdin = stdin();
    let mut buf = String::new();
	stdin.lock().read_line(&mut buf);
	buf.trim().parse().ok().unwrap()
}

fn main() {
    let mut n = read::<usize>();
    let mut ans = if n % 10 == 0 { 9 } else { 0 };
    while n > 0 {
        ans += n % 10;
        n /= 10;
    }
    println!("{}",ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++)
    {
        int x = s[i] - 'A';
        x = (x + n) % 26;
        putchar('A' + x);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
var

  i,s:longint;

n:string;
begin
 
  read(n);
 
  for i:=1 to length(n) do
  
   if n[i]='C' then 
  
    for s:=i+1 to length(n) do
  
      if n[s]='F' then 
     
       begin
       
         writeln('Yes');
       
         halt;
      
       end;
    
  writeln('No');

end.

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define mod 1000000007LL
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = (res + m) * ( a + m) % m;
        a = a * a % m;
        b >>= 1;
    }
    return (res + m) % m;
}

long long mul(long long a, long long b){
    a = (a + mod) % mod;
    b = (b + mod) % mod;
    return ((a + mod) * (b + mod))%mod;
}
long long add(long long a, long long b){
    a += mod;
    b += mod;
    return (a + b)%mod;
}
ll inv(ll x){
    return binpow(x, mod - 2, mod);
}
ll fun(ll n)
{
    if(n == 0 || n == 1)
        return 0;
    //vector<ll> a(n);
    vector<ll> p(n), s(n);
    p[0] = 1;
    s[n - 1] = n;
    for (ll i = 1; i < n;i++)
    {
        p[i] = p[i - 1] + i + 1;
        s[n - i - 1] = s[n - i] + n - i;
    }
    ll ans = 0;
    // for(auto i: p)
    //     cout << i << " ";
    // cout << endl;
    // for(auto i: s)
    //     cout << i << " ";
    // cout << endl;
    for (ll i = 1; i < n  ;i++)
    {
        ll diff = s[i] - p[i - 1];
        if(diff < 0)
            break;
        if(diff % 2)
            continue;
        diff = diff / 2;
        if(diff + 1 > n)
            continue;
        if(diff == 0)
        {
            if(i > 1)
            ans += (i * (i - 1)) / 2;
            if(n - i > 1)
            ans += ((n - i) * (n - i - 1)) / 2;
        }else
        {
            //cout << " i = " << i << " diff =  " << diff << endl;
            ans += min(diff, min(i, n - i));
        }
    }
    return ans;
}ll f[1000010] = {0};
signed main()
{
    // freopen("output.txt", "w",stdout);
    // ll t;cin>>t;
    // while(t--)
    // {
    //     ll n;
    //     cin >> n;
    //     for (ll i = 1; i <= n;i++)
    //         cout << fun(i) << endl;
    // }
    ll n;cin>>n;
    vector<ll>a(n);
    for(auto &i: a)
        cin >> i;
    
    ll gcd = a[0];
    for(auto it: a)
        f[it]++, gcd = __gcd(it, gcd);
    
    if(gcd > 1)
    {
        cout << "not coprime";
        return 0;
    }
    for (ll i = 2; i <= 1000000;i++)
    {
        ll cnt = 0;
        for (ll j = i; j <= 1000000;j+=i)
        {
            cnt += f[j];
        }
        if(cnt > 1){
            cout<<"setwise coprime";
            return 0;
        }
    }
    cout << "pairwise coprime";
    return 0;
}

Measured memory_bytes: 18764