akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <stdio.h>
using namespace std;

#define MAX_NUM 2000000
#define MAX_VALUE 10000

void print_array(int A[], int n) {
  for(int i=0; i<n; i++) {
    printf("%d", A[i]);
    if(i != n-1) {
      printf(" ");
    }
  }
}

void counting_sort(int A[], int n) {
  int cnt[MAX_VALUE];
  for(int i=0; i<MAX_VALUE; i++) {
    cnt[i] = 0;
  }

  for(int i=0; i<n; i++) {
    cnt[A[i]]++;
  }

  int ptr=0;
  for(int i=0; i<MAX_VALUE; i++) {
    if(cnt[i] != 0) {
      for(int j=0; j<cnt[i]; j++) {
        A[ptr] = i;
        ptr++;
      }
    }
  }
}

int main() {
  int n;
  int A[MAX_NUM];
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> A[i];
  }

  counting_sort(A, n);

  print_array(A, n);
  printf("\n");

  return 0;
}

Measured memory_bytes: 10920
#include<iostream>
#include<cassert>
#include<map>

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

using namespace std;

#define MAX 100010
int par[MAX];

int find(int x) {
  if( par[x] == x ) return x;
  return par[x] = find(par[x]);
}

void unit(int x,int y) {
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}

int main() {
  int N,M,K;
  cin >> N >> M >> K;
  rep(i,N+1) par[i] = i;
  int ans = -1;
  map<int,int> mp;
  rep(i,K) {
    int a,b,c;
    cin >> a >> b >> c;
    if( ans != -1 ) continue;
    if( a == 1 ) {
      if( mp.count(find(b)) && mp.count(find(c)) ) {
	if( mp[find(b)] != mp[find(c)] ) {
	  ans = i + 1;
	  continue;
	}
	unit(b,c);
      } else if( !mp.count(find(b)) && !mp.count(find(c)) ) {
	unit(b,c);
      } else {
	int id = ( mp.count(find(b)) ? mp[find(b)] : mp[find(c)]);
	unit(b,c);
	mp[find(b)] = id;
	mp[find(c)] = id;
	assert( find(b) == find(c));
      }
    } else {
      if( mp.count(find(b)) ) {
	if( mp[find(b)] != c ) {
	  ans = i + 1;
	  continue;
	}
      }
      mp[find(b)] = c;
    }
  }
  cout << ((ans==-1)?0:ans) << endl;
  return 0;
}

Measured memory_bytes: 8140
import math
a, b, c, x, y = map(int, input().split(' '))
ans = float('inf')
c = c*2
for i in range(max(x, y)+1):
    if i > x:
        price = b*(y-i) + c*i
    elif i > y:
        price = a*(x-i) + c*i
    else:
        price = a*(x-i) + b*(y-i) + c*i

    if ans > price:
        ans = price
print(ans)

Measured memory_bytes: 9068
#include<stdio.h>
#define N 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int g[N][N],n;
int color[N],d[N],f[N],time;

void visit(int u){
  int v;

  color[u]=GRAY;
  d[u]=++time;
  for(v=0;v<n;v++){
    if(g[u][v]==0) continue;
    if(color[v]==WHITE){
      visit(v);
    }
  }
  color[u]=BLACK;
  f[u]=++time;
}
void dfs(void){
  int u;
  for(u=0;u<n;u++) color[u]=WHITE;
  time=0;
  for(u=0;u<n;u++){
    if(color[u]==WHITE) visit(u);
  }
  for(u=0;u<n;u++) printf("%d %d %d\n",u+1,d[u],f[u]);
}
int main(){
  int i,j,k,a,b;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) g[i][j]=0;
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&a,&k);
    a--;
     for(j=0;j<k;j++){
       scanf("%d",&b);
       b--;
       g[a][b]=1;
     }
  }

  dfs();

  return 0;

}


Measured memory_bytes: 2108
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

long long int f(int n, const vector<int>& v) {
	long long int res = 0;
	int s = 0;
	vector<int> nums;
	for (auto num : v) {
		int m1 = abs(num % n), m2 = n - abs(num % n);
		s += m1;
		nums.push_back(m1);
	}
	sort(nums.begin(), nums.end());
	return accumulate(nums.begin(), nums.end() - s / n, 0);
}

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> v(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	int s = accumulate(v.begin(), v.end(), 0);
	int res = 1;
	for (int i = 1; i * i <= s; i++) {
		if (s % i == 0) {
			long long int ret = f(i, v);
			if (ret <= k) {
				res = max(res, i);
			}
			if (s != i * i) {
				ret = f(s / i, v);
				if (ret <= k) {
					res = max(res, s / i);
				}
			}
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef pair<ll,ll> P;
typedef pair<ll,P> PP;
const ll MOD = 1e9+7;

int main(){
  ll b;
  while(cin>>b,b){
	int mi,sum;
	for(int i=1;;i++){
	  if(i*(i+1)/2>b)break;
	  if((b-i*(i+1)/2)%i==0){
		mi=1+(b-i*(i+1)/2)/i;
		sum=i;
	  }
	}
	cout<<mi<<" "<<sum<<endl;
  }
  return 0;
}



Measured memory_bytes: 2976
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#include<queue>
#define int long long
using namespace std;

const int INF = 1e10;
const int ZERO = 0;

signed main() {
	int A,B,C;
	cin >> A >> B >> C;
	int cnt = A + B + C;
	int count = max(A,max(B,C));
	if(3 * count % 2 == cnt % 2) {
		cout << (3 * count - cnt) / 2 << endl;
	}
	else {
		cout << (3 * count + 3 - cnt) / 2 << endl;
	}
}	



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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define LCM(a, b) (a) / __gcd((a), (b)) * (b)
#define CEIL(a, b) (a)/(b)+(((a)%(b))?1:0)
#define log_2(a) (log((a)) / log(2))
#define ln '\n'

using namespace std;
using LL = long long;
using ldouble = long double;
using P = pair<int, int>;
using LP = pair<LL, LL>;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1e9 + 7;
static const int SIZE = 200005;

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

vector<LL> Div(LL n) {
    vector<LL> ret;
    for(LL i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);
            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    LL N, M;
    cin >> N >> M;
    if(llabs(N - M) > 1) {
        cout << 0 << endl;
        return 0;
    }

    LL res = 0;
    LL t = 1;
    for(int i = 2; i <= N; ++i) {
        t *= i;
        t %= MOD;
    }
    res = t;

    t = 1;
    for(int i = 2; i <= M; ++i) {
        t *= i;
        t %= MOD;
    }

    res *= t;
    res %= MOD;
    if(N == M) res *= 2;
    cout << res % MOD << endl;
    return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

const int MAX = 510000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


map<ll,ll> Prime_Factorization(ll N){
    map<ll,ll> PF;
    for(ll i = 2; i * i <= N; i++) while(!(N%i)) PF[i]++, N /= i;
    if(N != 1) PF[N] = 1;
    return PF;
}

ll solve(ll N, ll M){
    COMinit();
    map<ll,ll> PF = Prime_Factorization(M);
    ll ans = 1;
    for(auto itr = PF.begin(); itr != PF.end(); itr++){
        ll r = itr-> second;
        ans *= COM(N+r-1,r);
        ans %= MOD;
    }
    return ans;
}

int main(){
    ll N, M; cin >> N >> M;
    pr(solve(N,M));
    return 0;
}

Measured memory_bytes: 12160
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << endl;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
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;}

// 0 false, 1 true 
// stringの数字をint型にしてアスキーコードになったら -48する
// 切り上げ　ceil(a)


int main() {
    char c;
    cin >> c;
    printf("%c\n",c+1);
    

}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;



/**
 * Created by santa on 2016/10/16.
 */

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int a = scanner.nextInt();
        int[] map = {1,2,4,8,16,32,64,122};


        if(a == 1){
            System.out.println(1);
        }else{
            for (int i = 0; i < 8; i++) {
                if(a < map[i]){
                    System.out.println(map[i - 1]);
                    break;
                }
            }
        }



    }


} // MainClass


Measured memory_bytes: 23764
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <bitset>
#include <numeric> //lcm
#include <iomanip> //double精度 setprecision

//#include <atcoder/all>

using namespace std;
//using namespace atcoder;

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)
#define rrep1(i,n) for(int i = (n); i >= 1; --i)
#define REP(i,n,m) for(int i = (n); i < (m); ++i)
#define all(vec) (vec).begin(),(vec).end()

#define debug(vec) for(auto v : vec) cerr << v << " "; cerr << endl;
#define debug2D(vec2D, w) for(auto vec : vec2D) { for (auto v : vec) cerr << setw(w) << v << " "; cerr << endl; } 
#define debugP(vec) for(auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl;
#define debug2DP(vec2D) for(auto vec : vec2D) { for (auto v : vec) cerr << "(" << v.first << "," << v.second << ") "; cerr << endl; } 

const char en = '\n';

typedef long long ll;

constexpr ll INF = 1000000000; //10^10
//const ll MOD = 998244353;
constexpr ll MOD = 1000000007;

typedef vector<vector<int>> Graph;
void add_edge(Graph& g, int from, int to, bool isDirected) {
	g[from].push_back(to);
	if (!isDirected) g[to].push_back(from);
}

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } else return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } else return false; }

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

	string x; cin >> x;

	cout << x;
	if (x.back() == 's') cout <<"es" << endl;
	else cout << "s" << endl;
}



Measured memory_bytes: 3664
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}


long long power(long long x, long long n){
	long long ans = 1;
	for(;n;){
		if(n&1)ans*=x;
		n>>=1;
		x*=x,ans%=MOD,x%=MOD;
		// cout<<ans<<" n = "<<n<<endl;
	}
	
	// cout<<"<> "<<endl;
	return ans%MOD;
}


long long combination(long long n, long long r){
	int fac = 1, mmi = 1, t = min(r, n - r);
	for(int i = 0; i < t; i++){
		fac *= (n-i);
		fac %= MOD;
	}
	for(int i = 1; i <= t; i++){
		mmi *= i;
		mmi %= MOD;
	}
	mmi = power(mmi, MOD-2);
	return fac * mmi % MOD;
	// return n < r ? 0 :fac[n]*(mmi[r]*mmi[n-r]%MOD)%MOD;
}
signed main(){
	// cin.tie(nullptr);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	int n, a, b;
	int ans = 0;
	
	cin>>n>>a>>b;
	
	
	// factorial_mod();
	// modular_multiplicatibe_inverse();
	
	// cout<<"<><> "<<endl;
	ans = power(2ll, n);
	// cout<<"<><> "<<endl;
	ans %= MOD;
	
	ans -= combination(n, a);
	ans += MOD;
	ans %= MOD;
	// cout<<"<><> "<<endl;
	ans -= combination(n, b);
	ans += MOD;
	ans %= MOD;
	// cout<<"<><> "<<endl;
	ans -= combination(n, 0);
	ans += MOD;
	ans %= MOD;
	
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys

h, w = map(int, input().split())
if h == 1 or w == 1:
  print(1)
  sys.exit()

if h % 2 == 1 and w % 2 == 1:
  print(int(h*w//2 + 1))
else:
  print(int(h*w//2))


Measured memory_bytes: 2940
//DP3
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n), b(n), c(n);
	vector<vector<int>> dp(n, vector<int>(3));
	for(int i=0;i<n;i++){
		cin >> a.at(i) >> b.at(i) >> c.at(i);
		dp.at(i).at(0) = 0;
		dp.at(i).at(1) = 0;
		dp.at(i).at(2) = 0;
	}
	dp.at(0).at(0) = a.at(0);
	dp.at(0).at(1) = b.at(0);
	dp.at(0).at(2) = c.at(0);
	for(int i=1;i<n;i++){
		dp.at(i).at(0) = max(dp.at(i-1).at(1),dp.at(i-1).at(2)) + a.at(i);
		dp.at(i).at(1) = max(dp.at(i-1).at(0),dp.at(i-1).at(2)) + b.at(i);
		dp.at(i).at(2) = max(dp.at(i-1).at(0),dp.at(i-1).at(1)) + c.at(i);
	}
	int ans = max({dp.at(n-1).at(0),dp.at(n-1).at(1),dp.at(n-1).at(2)});
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 6912
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N, M, L, A, B, counter = 0;
	cin >> N >> A >> B;
	for (int i =1; i <= N; i++) {
		M = 0, L = i;
		for (int j = 0; j < 5; j++) {
			M += L % 10;
			L /= 10;
		}
		if (A <= M && M <= B) {
			counter += i;
		}
	}
	cout << counter << endl;
}

Measured memory_bytes: 256
//
// Created by 李青坪 on 2018/11/23.
//

//
// Created by 李青坪 on 2018/11/22.
//

#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include <queue>
#define MAXN 100000
#define INFINITY 1<<30
#define NIL -1
using namespace std;

int n, e;
vector<int> graph[MAXN];
vector<int> tree[MAXN];
set<int> result;
int preOrder[MAXN];
int parent[MAXN];
int lowestOrder[MAXN];
bool visited[MAXN];
int orderCount = 0;

void init(){
    fill(visited, visited+n, false);
    fill(preOrder, preOrder+n, INFINITY);
    fill(parent, parent+n, NIL);
    fill(lowestOrder, lowestOrder+n, INFINITY);
}

void dfsTree(int node){
    preOrder[node] = ++orderCount;
    visited[node] = true;
    vector<int>::iterator it;
    for (it = graph[node].begin(); it != graph[node].end(); ++it){
        if (!visited[*it]){
            tree[node].push_back(*it);
            parent[*it] = node;
            dfsTree(*it);
        }
    }
}

int dfs(int node){
    int prt = parent[node];
    int minBack = preOrder[node];
    vector<int>::iterator it1;
    for (it1 = graph[node].begin(); it1 != graph[node].end(); ++it1){ //对node中每条不属于tree的边
        if (prt == NIL) break;
        if (*it1 != prt && preOrder[prt] < minBack){
            minBack = preOrder[*it1];
        }
    }
    vector<int>::iterator it;
    for (it = tree[node].begin(); it != tree[node].end(); ++it){ //对node的每个子结点
        minBack = min(minBack, dfs(*it));
    }
    return lowestOrder[node] = minBack;
}

void getArtiPoint(int node){
    if (node == 0){
        if (tree[node].size() >= 2){
            result.insert(node);
        }
    } else{
        int prt = parent[node];
        if (preOrder[prt] <= lowestOrder[node] && prt != 0){  //注意prt为根结点的时候这里不适用
            result.insert(prt);
        }
    }
    vector<int>::iterator it;
    for (it = tree[node].begin(); it != tree[node].end(); ++it){ //对node的每个子结点
        getArtiPoint(*it);
    }
}

int main(){
    scanf("%d %d", &n, &e);
    init();
    int u, v;
    for (int i = 0; i < e; ++i) {
        scanf("%d %d", &u, &v);
        graph[u].push_back(v);
        graph[v].push_back(u);
    }
    dfsTree(0);
    dfs(0);
    getArtiPoint(0);
    set<int>::iterator it;
    for (it = result.begin(); it != result.end(); ++it){
        printf("%d\n", *it);
    }
}
/*
4 4
0 1
0 2
1 2
2 3

6 6
0 1
1 2
3 1
3 4
4 5
5 2
 */


Measured memory_bytes: 9036
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
int n,a[101],dp[100001];
int solve(int i,int j){
	if (dp[i]!=-1)return dp[i];
    int res=0;
	for(int k=0;k<n;k++){
		if (a[k]<=i){
			if (!solve(i-a[k],j)){
				res=1;
				break;
			}
		}
	}
	return dp[i]=res;
}

int main(){
	int k;
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,-1,sizeof(dp));
	cout <<(solve(k,0)?"First":"Second")<<std::endl;
	return 0;
}


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

using namespace std;

int main(){
    string *s;
    int N;
    cin >> N;
    s = new string[N];
    unordered_map<string, int> mp;
    long long int c = 0;

    for (int i = 0; i < N; i++)
    {
        cin >> s[i];
        sort(s[i].begin(), s[i].end());
        auto itr = mp.find(s[i]);
        if(itr != mp.end()){
            itr->second++;
            c += itr->second;
        }else{
            mp[s[i]]=0;
        }
    }
    
    cout << c << endl;

    return 0;
}

Measured memory_bytes: 17700
n=int(input())
A=map(int,input().split())
count={}
ziyuu=0
for a in A:
    if 1<=a<=399:
        count['灰色']=1
    elif 400<=a<=799:
        count['茶色']=1   
    elif 800<=a<=1199:
        count['緑色']=1 
    elif 1200<=a<=1599:
        count['水色']=1 
    elif 1600<=a<=1999:
        count['青色']=1 
    elif 2000<=a<=2399:
        count['黄色']=1 
    elif 2400<=a<=2799:
        count['橙色']=1 
    elif 2800<=a<=3199:
        count['赤色']=1 
    elif 3200<=a:
        ziyuu+=1
mi=max(1,len(count))
ma=len(count)+ziyuu
print(mi,ma)


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

int main(){
    string s;
    cin>>s;
    
    
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdio>
using namespace std;
using ll = long long;

int main(){
  int n, m, d; cin >> n >> m >> d;
  int cnt = (d == 0)? 1: 2;
  double ans = (m-1) * ((n-d)*cnt / pow(n, 2));

  printf("%.10lf\n", ans);
  return 0;
}

Measured memory_bytes: 256
def main():
    n, T = map(int, input().split())
    ans = None
    for _ in range(n):
        c, t = map(int, input().split())
        if t <= T and (ans is None or c < ans):
            ans = c
        # print(c, t, ans)
    if ans is None:
        print('TLE')
    else:
        print(ans)


if __name__ == '__main__':
    main()

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

int gcd(int a, int b);

int main()
{
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}

int gcd(int a, int b)
{
    if (a < b) {
        int tmp = b;
        b = a;
        a = tmp;
    }
    int r;
    do {
        r = a % b;
        a = b;
        b = r;
    } while (r != 0);
    return a;
}

Measured memory_bytes: 1160
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <unordered_map>
#include <vector>

using namespace std;

typedef long long lint;

int modpow(int x, int y, int mod) {
  int ret = 1 % mod, x2p = x;
  while (y > 0) {
    if (y % 2) ret = (lint)ret * x2p % mod;
    y /= 2;
    x2p = (lint)x2p * x2p % mod;
  }
  return ret;
}

const int maxn = 300000;
const int mod = 998244353;

int inv(int a, int p) {
  return modpow(a, p - 2, p);
}

int main() {
  vector<int> fact(maxn + 1);
  fact[0] = 1;
  for (int i = 1; i <= maxn; ++i)
    fact[i] = (lint)i * fact[i - 1] % mod;
  vector<int> inv_fact(maxn + 1);
  inv_fact[maxn] = inv(fact[maxn], mod);
  for (int i = maxn - 1; i >= 0; --i)
    inv_fact[i] = (lint)inv_fact[i + 1] * (i + 1) % mod;
  auto binom = [&](int a, int b) -> int {
    if (!(0 <= b && b <= a)) return 0;
    return (lint)fact[a] * inv_fact[a - b] % mod * inv_fact[b] % mod;
  };

  int n, a, b;
  lint k;
  scanf("%d %d %d %lld", &n, &a, &b, &k);

  int result = 0;
  for (int na = 0; na <= n; ++na) {
    if ((lint)na * a > k) continue;
    lint remain = k - (lint)na * a;
    if (remain % b != 0) continue;
    lint nb = remain / b;
    if (nb < 0 || nb > n) continue;
    result = (result + (lint)binom(n, na) * binom(n, nb)) % mod;
  }
  printf("%d\n", result);

  return 0;
}


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

int main(){
long long N,a; a=1; cin>>N; vector<string>S(N);
rep(i,N){cin>>S.at(i);}
  sort(S.begin(),S.end());
  Rep(i,1,N){
  if(S.at(i)!=S.at(i-1)){a++;}}
  cout<<a<<endl;
}

Measured memory_bytes: 9524
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
  int n, *l, acc;
  cin >> n;

  l = new int[n];

  for (int i = 0; i < n; i++) {
    cin >> l[i];
  }

  sort(l, l+n);

  acc = 0;
  for (int i = 0; i < n-2; i++) {
    for (int j = i+1; j < n-1; j++) {
      for (int k = j+1; k < n && l[k] < l[i] + l[j]; k++) {
        //cout << l[i] << ' ' << l[j] << ' ' << l[k] << endl;
        if (l[i] < l[j] + l[k] && l[j] < l[k] + l[i]) {
          acc++;
        }
      }
    }
  }

  delete [] l;

  cout << acc << endl;
  return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
a = [[0 for j in range(W)] for i in range(H)]

for i in range(H):
    a[i] = [int(x) for x in input().split()]

x1 = []
y1 = []
x2 = []
y2 = []


for i in range(H-1):
    for j in range(W-1):
        if a[i][j] % 2 == 0:
            continue

        else:
            a[i][j] -= 1
            a[i][j+1] += 1
            x1.append(i)
            y1.append(j)
            x2.append(i)
            y2.append(j+1)

        # elif a[i][j+1] % 2 != 0:
        #     a[i][j] -= 1
        #     a[i][j+1] += 1
        #     x1.append(i)
        #     y1.append(j)
        #     x2.append(i)
        #     y2.append(j+1)

        # elif a[i+1][j] % 2 != 0:
        #     a[i][j] -= 1
        #     a[i+1][j] += 1
        #     x1.append(i)
        #     y1.append(j)
        #     x2.append(i+1)
        #     y2.append(j)

    if a[i][W-1] % 2 == 0:
        continue

    else:
        a[i][W-1] -= 1
        a[i+1][W-1] += 1
        x1.append(i)
        y1.append(W-1)
        x2.append(i+1)
        y2.append(W-1)

for j in range(W-1):
    if a[H-1][j] % 2 != 0:
        a[H-1][j] -= 1
        a[H-1][j+1] += 1
        x1.append(H-1)
        y1.append(j)
        x2.append(H-1)
        y2.append(j+1)

# for _ in a:
    # print(_)

print(len(x1))

y1 = [i+1 for i in y1]
x1 = [i+1 for i in x1]
y2 = [i+1 for i in y2]
x2 = [i+1 for i in x2]


for i in range(len(x1)):
    print(x1[i], y1[i], x2[i], y2[i])


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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

typedef unsigned int  UI;
typedef vector<UI>    VUI;
typedef vector<VUI>   VVUI;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP(x) cerr << #x << " = " << (x) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

template<typename T=int> inline void dump(vector<T> vs, bool ent=false) { rep(i, vs.size()) cout << vs[i] << (i+1==vs.size() ? '\n' : ' '); if (ent) cout << endl; }
template<typename T = int> inline void dump(vector<vector<T>> vs, bool ent=false) { rep(i, vs.size()) dump<T>(vs[i]); if (ent) cout << endl; }

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);

template<typename T = int> inline T in() { T x; cin >> x; return x; }
template<typename T = int> inline vector<T> in(int n) { vector<T> xs(n); rep(i, n) cin >> xs[i]; return xs; }
template<typename T = int> inline vector<vector<T>> in(int n, int m) { vector<vector<T>> xs(n, vector<T>(m)); rep(i, n) rep(j, m) cin >> xs[i][j]; return xs; }

int main(void) {
    string s = in<string>();
    int i = 0;
    string t(100, '_');
    for (auto c : s) {
        if (c == 'B') {
            i = max(0, i - 1);
        } else {
            t[i++] = c;
        }
    }
    string ans(t.begin(), t.begin() + i);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#define rep(i,n) for (int i=0; i < (n); ++i)
#define all(a) a.begin(), a.end()
using ll = long long;
using namespace std;

int main() {
  int x,a,b; cin >> x >> a >> b;

  int ans = x-a;
  cout << ans % b << endl;
  return 0;
}

Measured memory_bytes: 256
# C - Otoshidama
N,Y= map(int,input().split())
for i in range(N+1):
    for j in range(N-i+1):
        k = N-i-j
        if i * 10000 + j *5000 + k *1000 ==Y:
            print(str(i)+" "+str(j)+" "+str(k))
            exit()
print("-1 -1 -1")


Measured memory_bytes: 3064
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) {
	// write your code here
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    ArrayList<Integer> ar = new ArrayList<>();

    for(int i = 0; i < N; i++){
        ar.add(sc.nextInt());
    }

    int count = 1;
    int max = ar.get(0);
    for(int i = 1;i < N;i++){
        if(ar.get(i) >= max){
            count++;
            max = ar.get(i);
        }
    }

    System.out.println(count);
    }










    public static Integer min(List<Integer> ar){
        int min = 10000;
        int index = 0;
        for(int i = 0; i< ar.size();i++){
            if(min > ar.get(i)){
                min = ar.get(i);
                index = i;
            }
        }
        return min;
    }
}


Measured memory_bytes: 23124
n = int(input())
s = list(input())
for i in range(n - 1):
    s1 = list(input())
    s2 = []
    for j in s1:
        if j in s:
            s2.append(s.pop(s.index(j)))
    s = s2
s.sort()
print("".join(s))

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

int main() {
  int A,B,count=0;
  cin >> A >> B;
  for(int i=A;i<=B;i++){
    if((i%10)==(i/10000)&&(i/10)%10==(i/1000)%10) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 3624
double s[2],t,v;i;main(m){for(;scanf("%d",&m)*m;s[i]+=sin(t),t=++i>1?*s=s[1]=i=!puts(*s>s[1]+1e-8?"1":*s+1e-8<s[1]?"2":"0"):0)for(;--m;t-=v)scanf("%lf",&v),s[i]+=sin(v*=asin(1)/90);}

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

int main (void) {
  int A, B, ans = -1;
  cin >> A >> B;
  for (int i = 1 ; i < 10000; i++) {
    if (int(i * 0.08) == A && int(i * 0.1) == B) { ans = i; break;}
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n,k = [int(x) for x in input().split()]
r,s,p = [int(x) for x in input().split()]
t = input()

def w(z):
    if z=="r":
        return p
    if z=="s":
        return r
    else:
        return s

ans = 0
li = [0]*len(t)
for i in range(len(t)):
    if i+k<len(t):
        if li[i]==1:
            continue
        if t[i]==t[i+k]: 
            ans += w(t[i])
            li[i+k] = 1
        else:
            ans += w(t[i])
    else:
        if li[i]==0:
            ans+=w(t[i])
print(ans)

Measured memory_bytes: 4084
#include <iostream>
using namespace std;
#define fi first
#define se second

#define pb push_back
#define es erase
#define in insert

#define pii pair<ll, ll>
#define ll long long
#define lb long double

#define ios                      \
    ios::sync_with_stdio(false); \
    cin.tie(0);                  \
    cout.tie(0);
#define m_p(i, j) make_pair(i, j)
#define mem(a, x) memset(a, x, sizeof(a))
#define fcout(i) cout << setprecision(i) << fixed
#define endl "\n"
ll n, k;
int main()
{
    char c = getchar();
    if(c>='A'&&c<='Z')
        cout << "A" << endl;
    else
        cout << "a" << endl;
    return 0;
}


Measured memory_bytes: 3028
#include <cstdio>
#include <algorithm>
#define LL long long
#define maxn 200010
#define mod 1000000007
using namespace std;
int a[maxn];
LL ans=1,x,y;
int main(){
	int n,k,i,l,r;
	scanf("%d%d",&n,&k);
	for(i=1;i<=n;i++)scanf("%d",&a[i]);
	sort(a+1,a+1+n);
	if(a[1]>=0){
		for(i=n;i>=n-k+1;i--)ans=ans*a[i]%mod;
	}else if(a[n]<0){
		if(k&1){
			for(i=n;i>=n-k+1;i--)ans=ans*a[i]%mod;
			ans=(ans%mod+mod)%mod;
		}else
			for(i=1;i<=k;i++)ans=ans*a[i]%mod;
	}else{
		int cnt1=0,cnt2=0;
		for(i=1;i<=n;i++)
			if(a[i]<0)cnt1++;
			else break;
		cnt2=n-cnt1;
		if(cnt1/2*2+cnt2<k){
			for(i=1;i<=n;i++)ans=ans*a[i]%mod;
			ans=(ans%mod+mod)%mod;
		}else{
			if(k&1) ans=a[n],n--,k--;
			l=1,r=n;
			while(k){
				x=(LL)a[l]*a[l+1],y=(LL)a[r]*a[r-1];
				if(x>y)x%=mod,ans=ans*x%mod,l+=2;
				else y%=mod,ans=ans*y%mod,r-=2;
				k-=2;
			}
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 2480
# A
k = int(input())

l = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(l[k-1])

Measured memory_bytes: 3060
// Sakhiya07 - Yagnik Sakhiya
 
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long int
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define all(x) x.begin(),x.end()
 
#define mp make_pair
#define bp __builtin_popcountll
#define MOD  1000000007
const int N = 10000;
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);srand(time(NULL));
 
void solve()
{
    ll n;
    cin >> n;
    ll ans = 1;
    ll a[n];
    for(ll i=0,x;i<n;i++)
    {
        cin >> a[i];
        if(a[i]==0)  
        {
            cout<<0;
            return;
        }
    }
    for(ll i=0;i<n;i++)
    {
        ld temp = (1e18)/(ld)a[i];
        if(ans>temp)   
        {   
            cout<<-1;
            return;
        }
        ans *= a[i];
    }
    cout<<ans;
}

int main()
{
     FAST;
     ll t = 1;
   //  cin >> t;
     while(t--)
     {
          solve();
     }
}

Measured memory_bytes: 4444
import java.util.Scanner;
class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int a=stdIn.nextInt();
		int b=stdIn.nextInt();
		int c=stdIn.nextInt();
		int d=stdIn.nextInt();
		if(Math.abs(a-c)<=d||(Math.abs(b-c)<=d&&Math.abs(a-b)<=d)){
			System.out.println("Yes");
		}
		else
			System.out.println("No");
		}

	}



Measured memory_bytes: 23252
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){

  int A, B, C;
  cin >> A >> B >> C;
  if(A == B){
    cout << C;
  }else if(A == C){
    cout << B;
  }else{
    cout << A;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Scanner sc) {
		int x = sc.nextInt();
		BigInteger v = BigInteger.valueOf(x);
		if (v.isProbablePrime(100)) {
			System.out.println(x);
		} else {
			System.out.println(v.nextProbablePrime());
		}
	}
}

class Main {
	public static void main(String... args) {
		Scanner in = new Scanner(System.in);

		Solver.INSTANCE.solve(in);

		in.close();
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for( ll i = (a); i < (ll)(b); i++ )
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort( (x).begin(),(x).end() )
#define REVERSE(x) reverse( (x).begin(),(x).end() )
#define UNIQUE(x) (x).erase( unique( ALL( (x) ) ) , (x).end() )
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())
#define SHOW(x) cout << #x << " = " << x << endl
#define SHOWA(x,n) for( int yui = 0; yui < n; yui++ ){ cout << x[yui] << " "; } cout << endl

#define pb emplace_back
#define fi first
#define se second

using namespace std;

typedef long double ld;
typedef long long int ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<vpl> gr;
typedef vector<vl> ml;
typedef vector<vd> md;
typedef vector<vi> mi;
     
const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ld EPS = 1e-12;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> inline T sq( T a ){ return a * a; }

ll in(){ long long int x; scanf( "%lld" , &x ); return x; }
char yuyushiki[1000010]; string stin(){ scanf( "%s" , yuyushiki ); return yuyushiki; }

// head

int n;
ll T, e;
ll x[100010];

ll dp[100010];

deque<pl> deq;
ll be;

int main(){

  n = in();
  e = in();
  T = in();
  REP( i , n ){
    x[i] = in();
  }
  x[n] = e;

  dp[0] = x[0];

  deq.emplace_back( T , x[0] );
  be = INFLL;
  
  FOR( i , 1 , n+1 ){
    while( not deq.empty() and ( x[i-1] - deq.front().se ) * 2 > T ){
      chmin( be, deq.front().fi - T - 2 * deq.front().se );
      deq.pop_front();
    }
    ll a = INFLL;
    if( not deq.empty() ){
      a = x[i-1] + deq.front().fi;
    }
    ll b = 3 * x[i-1] + be;
    dp[i] = min( a, b ) + x[i] - x[i-1];
    ll nde = dp[i] + T - x[i];
    while( not deq.empty() and deq.back().fi >= nde ){
      deq.pop_back();
    }
    deq.emplace_back( nde, x[i] );
  }

  printf( "%lld\n" , dp[n] );
  
  return 0;
}


Measured memory_bytes: 2560
#include<iostream>
using namespace std;
int main(){
  int i,j,k;
  int r,c;
  int b;
  cin >> r >> c;
  int rsum[100]={};
  int csum[100]={};
  int sum=0;
  for(i=0;i<r;i++){
    cin >> b;
    cout << b;
    rsum[i]+=b;
    csum[0]+=b; 
    for(j=1;j<c;j++){
      cin >> b;
      cout <<" " << b;
      rsum[i]+=b;
      csum[j]+=b; 
    }
    cout << " " << rsum[i] << endl;
    sum+=rsum[i];
  }
  cout << csum[0];
  for(j=1;j<c;j++){
    cout << " " << csum[j];    
  }
  cout << " " << sum <<  endl;
  return 0;
}



Measured memory_bytes: 3000
import re
def f(s):
    global a
    r = p.subn('',s)
    if r[1]!=0:
        return f(r[0])[0]
    else:
        a = r[0]
        return '0'
N = raw_input()
p = re.compile('\dB')
q = re.compile('^B*')
f(N)
print q.sub('',a)


Measured memory_bytes: 2820
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL -1
using namespace std;
const int64_t MOD = 1e9 + 7;

int main() {
	string A, B, C;
	cin >> A >> B >> C;

	char a, b, c, d;
	a = A.at(A.size() - 1);
	b = B.at(0);
	c = B.at(B.size() - 1);
	d = C.at(0);

	if ((a == b) && (c == d)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 3640
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main () {
	int N;
	vector <string> v;
	cin >> N;
	for (int i=0; i<N; i++) {
		char tmp[11];
		cin >> tmp;
		vector<char> vtmp (tmp, tmp+10);
		sort (vtmp.begin(), vtmp.end());
		string stmp;
		for (int i=0; i<vtmp.size(); i++)
			stmp += vtmp.at(i);
		v.push_back (stmp);
	}
	sort (v.begin(), v.end());
	long long sum = 0, c = 1;
	for (int i=1; i<v.size(); i++) {
		if (v.at(i).compare (v.at(i-1))==0) {
			c++;
		} else {
			sum += c*(c-1)/2;
			c = 1;
		}
	}
	sum += c*(c-1)/2;
	printf ("%lld\n", sum);
	return 0;
}

Measured memory_bytes: 7284
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int	max(int a, int b)
{
  if (a > b)
    return (a);
  else
    return (b);
}

int	main(void)
{
  int	n;
  char	*s;
  int	i;
  int	nR;
  int	nW;
  char	*cR;
  char	*cW;
  char	*tmp;
  int	count;
  int	m;
  
  if (scanf("%d", &n) == EOF)
    return (-1);
  if (!(s = (char *)malloc((n + 1) * sizeof(char))))
    return (-1);
  s[n] = '\0';
  if (scanf("%s", s) == EOF)
  {
    free(s);
    return (-1);
  }
  i = 0;
  nR = 0;
  nW = 0;
  while (s[i])
  {
    if (s[i] == 'R')
      nR++;
    else if (s[i] == 'W')
      nW++;
    i++;
  }
  if (nR == 0 || nW == 0)
    printf("0\n");
  else
  {
    m = max(nR, nW);
    count = 0;
    while (count < m)
    {
	  	cW = strchr(s, 'W');
      	cR = strrchr(s, 'R');
      	if (cW > cR)
          break ;
      	else
        {
          *cW = 'R';
          *cR = 'W';
          count++;
        }
    }
    printf("%d\n", count);
  }
  free(s);
  return (0);
}

Measured memory_bytes: 1732
import java.io.*;
import java.util.*;
import java.util.function.*;

final class Solver {
	static final Solver INSTANCE = new Solver();

	void solve(Supplier<String> sc) {
		int N = Integer.parseInt(sc.get());
		int K = Integer.parseInt(sc.get());
		Integer[] V = new Integer[N];
		Arrays.setAll(V, $ -> Integer.parseInt(sc.get()));
		List<Integer> view = Arrays.asList(V);

		int ops = Math.min(N, K);

		int max = 0;
		for (int f = 0; f <= ops; f++) {
			for (int l = 0; l <= ops - f; l++) {
				PriorityQueue<Integer> jewel = new PriorityQueue<>(view.subList(0, f));
				jewel.addAll(view.subList(N - l, N));
				int sum = 0;
				for (int r = 0; !jewel.isEmpty(); r++) {
					int next = jewel.remove();
					if (r < K - (f + l) && next < 0) continue;
					sum += next;
				}
				max = Math.max(max, sum);
			}
		}
		System.out.println(max);
	}
}

class Main {
	public static void main(String... args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		Solver.INSTANCE.solve(new Supplier<String>() {
			StringTokenizer line;

			public String get() {
				while (line == null || !line.hasMoreTokens()) try {
					line = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
				return line.nextToken();
			}
		});
	}
}

Measured memory_bytes: 26448
N = int(input())
P = 10**9 + 7

S = list([0]*2001 for _ in range(670))
for i in range(3, 2001):
    S[1][i] = 1

for i in range(2, 670):
    tmp = 0
    for j in range(i*3, 2001):
        tmp += S[i-1][j-3]
        tmp %= P
        S[i][j] = tmp

ans = 0
for i in range(670):
    ans += S[i][N]
    ans %= P
print(ans)


Measured memory_bytes: 40392
#include<bits/stdc++.h>
#include <ctime>
using namespace std;
#define ll long long
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define N 101
#define mod 1000000007
#define f(i,n) for(int i=0;i<n;i++)
#define f1(i,n) for(int i=1;i<n;i++)
#define in(i,arr) for(auto &i:arr)cin>>i;
#define all(x) (x).begin(), (x).end()   // sort(all(v)) instead sort(v.begin(),v.end())
#define vpii vector<pair<int,int>>
#define vpll vector<pair<ll,ll>>
#define vi vector<int>
#define vl vector<int>
#define pb push_back
#define eb empalce_back
int main()
{   fast;
    int t=1;
    //cin>>t;
    while(t--){
        int n;
        cin>>n;
        ll sum=0;
        int arr[n];in(i,arr);
        f1(i,n){
            if(arr[i]<arr[i-1])
                sum+=arr[i-1]-arr[i],arr[i]+=arr[i-1]-arr[i];
        }
        cout<<sum;

}

}

Measured memory_bytes: 4388
fun main(args: Array<String>){
    val (n, a, b) = readLine()!!.split(' ').map(String::toInt)
    print((1..n).filter {i -> calc(i) in a..b}.sum())
}

fun calc(a : Int): Int{
    var i = a
    var ret = 0
    while(i != 0){
        ret += i % 10
        i /= 10
    }
    return ret
}

Measured memory_bytes: 38380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int n,m;
  cin >>n>>m;
  vector<int> ad(n);
  rep(i,m){
    int a,b;
    cin >>a>>b;
    ad[a-1]++;
    ad[b-1]++;
  }
  rep(i,n){
    cout << ad[i] << endl;
  }
}

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

void outPut(int H[3][10]){
	for(int i=0;i<3;i++){
		for(int j=0;j<10;j++){
			printf(" %d", H[i][j]);
		}
		printf("\n");
	}
}

int main(){
	int H1[3][10],H2[3][10],H3[3][10],H4[3][10],n,a,b,c,d;
	for(int i=0;i<3;i++){
		for(int j=0;j<10;j++){
			H1[i][j]=H2[i][j]=H3[i][j]=H4[i][j]=0;  //全てに0を格納
		}
	}
	scanf("%d", &n);
	for(int i=0;i<n;i++){
		scanf("%d %d %d %d", &a,&b,&c,&d);
		switch(a){
			case 1:
				H1[b-1][c-1] += d;
				break;
			case 2:
				H2[b-1][c-1] += d;
				break;
			case 3:
				H3[b-1][c-1] += d;
				break;
			case 4:
				H4[b-1][c-1] += d;
				break;
		}
	}
	outPut(H1);
	printf("####################\n");
	outPut(H2);
	printf("####################\n");
	outPut(H3);
	printf("####################\n");
	outPut(H4);
}



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

long table[128][128];
static int M = 1;

int main(void) {
	int n;
	int ans = -1000000;
	int in[128][128];

	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> in[i][j];

	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			table[i + M][j + M] = table[i - 1 + M][j + M] + table[i + M][j - 1 + M] - table[i - 1 + M][j - 1 + M] + in[i][j];

	for(int i= 0; i < n; i++) {
		for(int j = 0; j < n; j++) {
			for(int k = i; k < n; k++) {
				for(int l = j; l < n; l++) {
					int tmp;
					tmp = table[k + M][l + M] - table[i - 1 + M][l + M] - table[k + M][j - 1 + M] + table[i - 1 + M][j - 1 + M];
					if(tmp > ans)
						ans = tmp;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1316
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pr pair<int,int>
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e3+10;

    char str[N];
    bool ask(int l1,int r1,int pos=0,int l2=1,int r2=0){
        printf("? ");fo(i,l1,r1)write1(i);fo(i,l2,r2)write1(i);if(pos)write1(pos);
        puts("");fflush(stdout);scanf("%s",str);if(str[0]=='-') assert(0);return str[0]=='R';
    }
    char a[N];
    void main()
    {
        int n=qread();
        int fl=1,fr=n,left=ask(1,n);
        while(fl+1<fr)
        {
            int mid=(fl+fr)/2;
            if(ask(mid,mid+n-1)==left) fl=mid; else fr=mid-1;
        }
        if(n==1) a[1]=left,a[2]=left^1;
        else
        {
            int pos=fl;if(fl<fr and ask(fl,fl+n-1)==ask(fl+1,fl+n)) pos++;a[pos]=left,a[pos+n]=left^1;
            fo(i,1,pos-1) a[i]=ask(pos+1,pos+n-1,i);fo(i,pos+n+1,n+n) a[i]=ask(pos+1,pos+n-1,i);
            fo(i,pos+1,pos+n-1) a[i]=ask(1,pos-1,i,pos+n+1,n+n);
        }
        printf("! ");fo(i,1,n+n) putchar(a[i]?'R':'B');puts("");fflush(stdout);
    }
};//(ans+MOD)%MOD
signed main()
{
    // freopen("a.in","r",stdin);
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 724
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;

#define mp make_pair

int h, w;
char m[21][21];
queue< pair<int, int> > path;
int dx[4] = { 0,0,1,-1 };
int dy[4] = { -1,1,0,0 };
int cache[21][21];

int solv(int idx1,int idx2) {
	int max(0);
	path.push(mp(idx1,idx2));
	cache[idx1][idx2] = 1;
	while (!path.empty())
	{
		int r = path.front().first;
		int c = path.front().second;
		path.pop();
		for (int i = 0; i < 4; i++) {
			int ny = r + dy[i];
			int nx = c + dx[i];
			if (0 <= ny && ny < h && 0 <= nx && nx< w 
				&& cache[ny][nx]==0 && (ny!=idx1||nx!=idx2)) {
				if (m[ny][nx] == '.') {
					path.push(mp(ny,nx));
					cache[ny][nx] = cache[r][c] + 1;
				}
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (cache[i][j] > max)
				max = cache[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		memset(cache[i], 0, w * sizeof(int));
	}
	return max-1;
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
	cin >> h >> w;
	int maximum(0);
	for(int i=0;i<h;i++)
		for (int j = 0; j < w; j++) {
			cin >> m[i][j];
		}
	for (int i = 0; i < h; i++) {
		memset(cache[i], 0, w * sizeof(int));
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (m[i][j] == '.') {
				int tmp = solv(i, j);
				maximum = max(tmp,maximum);
			}
		}
	}
	cout << maximum;
	return 0;
}

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

using namespace std;

int main() {
  int n,v[30],c[30],ans[30];
  cin >> n;
  for(int i = 0; i < n; i++)
    cin >> v[i];
  for(int i = 0; i < n; i++)
    cin >> c[i];
  
  int sum = 0;
  for(int i = 0; i < n; i++) {
    ans[i] = v[i] - c[i];
    if(ans[i] > 0) sum += ans[i];
  }
  cout << sum << endl; 
}

Measured memory_bytes: 3580
#!/usr/bin/env python3
from itertools import accumulate
L, N = map(int, input().split())
X = [0] + [int(input()) for _ in range(N)]
Y = [0] + [L - x for x in X[1:]][::-1]

sx = list(accumulate(X))
sy = list(accumulate(Y))

ans = 0
for i in range(1, N + 1):
    j = N - i

    mn = min(i - 1, j)
    now = X[i]
    now += 2 * (sx[i - 1] - sx[i - 1 - mn]) + 2 * (sy[j] - sy[j - mn - (j > mn)])
    ans = max(ans, now)

for i in range(N):
    j = N - i

    mn = min(i, j - 1)
    now = Y[j]
    now += 2 * (sx[i] - sx[i - mn - (i > mn)]) + 2 * (sy[j - 1] - sy[j - 1 - mn])
    ans = max(ans, now)

print(ans)



Measured memory_bytes: 41044