akhauriyash/Code-Regression huggingface dataset:
import java.io.*;

public class Main {
  
  static int n, x, y;

  public static void main(String[] args) throws IOException {

    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    String[] in;
    in = br.readLine().split(" ");
    n = Integer.parseInt(in[0]);
    x = Integer.parseInt(in[1]);
    y = Integer.parseInt(in[2]);

    br.close();

    x--; y--;
    int c = (x + y + 1) / 2;
    int[] ans = new int[n];

    for(int i = 0; i < n-1; i++){
      for(int j = i+1; j < n; j++){
        int dist = Math.min(j - i, (Math.abs(x - i) + Math.abs(y - j) + 1));
        ans[dist]++;
      }
    }
    
    for(int i = 1; i < n; i++){
      System.out.println(ans[i]);
    }
  }
}

Measured memory_bytes: 23380
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define pb push_back
#define mk make_pair
#define ull unsigned long long
#define fastIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
int main()
{
    fastIO;
    ll n;
    cin>>n;
    string str;
    cin>>str;
    ll val,val1,x,y,ans;
    x=str.length();
    for(int i=0;i<x;i++)
    {
        val=str[i]-'A';
        val+=n;
        val=val%26;
        str[i]=(char)(val+65);
    }
    cout<<str<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  vector<int> ans;
  for(int i=min(A,B);i<=max(A,B);++i) if( abs(A-i)==abs(B-i) ) ans.push_back(i);
  if(ans.empty()) cout<<"IMPOSSIBLE"<<endl;
  else cout<<ans[0]<<endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;

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

	if( int(Str.size()) == 2 ) cout << Str << endl;
	else{
		reverse( Str.begin() , Str.end() );
		cout << Str << endl;
	}	

	return 0;
}

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

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


const long long INF = 1LL << 60;
const ll mod = 1000000007;

#define N_MAX 201010

ll f[N_MAX],rf[N_MAX];

ll pow(ll x,ll n, ll m){
    ll res = 1;
    if(n > 0){
        res = pow(x,n / 2,m);
        if(n % 2 == 0){
            res = (res * res) % m;
        }else{
            res = (((res * res) % mod) * x) % m;
        }
    }
    return res;
}


void init(){
    f[0] = 1;
    for(int i = 1; i < N_MAX; i++){
        f[i] = (i * f[i-1]) % mod;
    }
    for(int i = 0; i < N_MAX; i++){
        rf[i] = pow(f[i],mod-2,mod);
    }
}

ll com(ll n, ll k){
    ll a = f[n];
    ll b = rf[k];
    ll c = rf[n-k];

    ll bc = (b * c) % mod;

    return (a * bc) % mod;
}

ll c(ll n, ll k){
    ll a = 1;
    for(int i = n - k + 1; i <= n; i++){
        a *= i;
        a %= mod;
    }

    return (a * rf[k]) % mod;
}

int main()
{
    init();
    ll n,a,b;
    cin >> n >> a >> b;

    ll ans = pow(2,n,mod) - c(n,a) - c(n,b) - 1;

    ans %= mod;
    while(ans < 0){
        ans += mod;
    }
    cout << ans;
}


Measured memory_bytes: 3328
def value(x): return x*108//100
def bsearch(V,x_min,x_max):
    if x_max - x_min == 1: print(":(")
    else:
      x = (x_min + x_max) // 2
      v = value(x)
      if V>v: return bsearch(V,x, x_max)
      elif V<v: return bsearch(V,x_min,x)
      else: print(x)

N = int(input())
bsearch(N, 0,50000)

Measured memory_bytes: 3064
while True:
  a,b = map(int,input().split(" "))
  if a == 0 and b == 0: break  
  c,d = map(int,input().split(" "))
  e,f = map(int,input().split(" "))
  g,h = map(int,input().split(" "))
  i,j = map(int,input().split(" "))  

  listsum= [a+b,c+d,e+f,g+h,i+j]
  listsum.sort()
   
  if listsum[-1] == a+b:
    print("A",listsum[-1]) 
  elif listsum[-1] == c+d:
    print("B",listsum[-1]) 
  elif listsum[-1] == e+f:
    print("C",listsum[-1]) 
  elif listsum[-1] == g+h:
    print("D",listsum[-1]) 
  elif listsum[-1] == i+j:
    print("E",listsum[-1])



Measured memory_bytes: 5612
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> v(26, 0);
    for(int i=0; i<n; ++i){
        string s;
        cin >> s;
        ++ v[s[0]-'A'];
    }

    int ans = 0;
    for(;;){
        sort(v.rbegin(), v.rend());
        if(v[k-1] == 0){
            cout << ans << endl;
            return 0;
        }

        for(int i=0; i<k; ++i)
            -- v[i];
        ++ ans;
    }
}

Measured memory_bytes: 256
#include <cstdio>
int a[100000], N;
int main()
{
	scanf("%d", &N);
	for (int i = 0, x; i < N; i++)
	{
		scanf("%d", &x);
		a[x]++;
	}
#define check(x, y)\
	if (a[x] != y)\
	{\
		puts("0");\
		return 0;\
	}
	if (N & 1)
	{
		check(0, 1);
		for (int i = 2; i < N; i += 2)
			check(i, 2);
	}
	else
		for (int i = 1; i < N; i += 2)
			check(i, 2);
	int O = 1;
	for (int i = N >> 1; i--; )
		if ((O <<= 1) >= 1000000007)
			O -= 1000000007;
	printf("%d\n", O);
	return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MAX_N=110,MAX_M=17,MAX_L=17;

int N;
int M[MAX_N],L[MAX_N],S[MAX_N][MAX_M],E[MAX_N][MAX_M];
int dp[MAX_N][1<<(MAX_L)];

void solve(){
    for (int i=0;i<=N;++i)
        for (int mask=0;mask<(1<<MAX_L);++mask)
            dp[i][mask]=-1;
    dp[0][0]=0;
    for (int i=0;i<N;++i){
        for (int mask=0;mask<(1<<MAX_L);++mask){
            if (dp[i][mask]==-1) continue;
            dp[i+1][mask]=max(dp[i+1][mask],dp[i][mask]);
            int ok=1,nxt=mask;
            for (int j=0;j<M[i];++j){
                for (int k=S[i][j];k<E[i][j];++k){
                    if (mask&1<<k) ok=0;
                    nxt|=1<<k;
                }
            }
            if (ok) dp[i+1][nxt]=max(dp[i+1][nxt],dp[i][mask]+L[i]);
        }
    }
    int ans=0;
    for (int mask=0;mask<(1<<MAX_L);++mask) ans=max(ans,dp[N][mask]);
    cout << ans << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(cin >> N,N){
        for (int i=0;i<N;++i){
            cin >> M[i] >> L[i];
            for (int j=0;j<M[i];++j){
                cin >> S[i][j] >> E[i][j];
                S[i][j]-=6,E[i][j]-=6;
            }
        }
        solve();
    }
}


Measured memory_bytes: 54844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,a[20],b[20],f[40][262200],lim,cnt[262200];
int comp(int x){return (1<<(x+1))-1;}
int calc(int mask,int x){
    int w=comp(x);
    return cnt[mask&(comp(n)-w)];
}
int num(int x){
    if(x==2*n) return 0;
    if(x<n) return a[x];
    return b[x-n];
}
int main()
{
    scanf("%d",&n);
    rap(i,0,n) scanf("%d",a+i);
    rap(i,0,n) scanf("%d",b+i);
    lim=1<<n;
    rap(i,0,lim) cnt[i]=__builtin_popcount(i);
    rap(i,0,n*2) rap(j,0,lim) f[i][j]=inf;
    f[2*n][0]=0;
    rap(cc,0,n) rap(i,0,lim) if(cnt[i]==cc){
        int bound=(i==0?2*n:2*n-1);
        rep(j,0,bound){
            if(i==0&&j!=2*n) continue;
            if(f[j][i]==inf) continue;
            rap(k,0,n) if( ! ( (1<<k)&i ) ){
                int d=abs(cc-k);
                bool flg = (d &1 );
                int cur = (flg?b[k]:a[k]);
                //printf("%d %d\n",cur,num(j));
                if(cur < num(j)) continue;
                f[k+flg*n][i|(1<<k)] = min(f[k+flg*n][i|(1<<k)], f[j][i]+calc(i,k));
            }
        }
    }
    int ans=inf;
    rap(i,0,2*n) ans=min(ans,f[i][(1<<n)-1]);
    printf("%d\n",ans>=inf-20?-1:ans);
    return 0;
}

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

using namespace std;
typedef unsigned long long ull;
ull solve()
{
    ull k,a,b;
    cin >> k >> a >> b;
    if (a+1>=b)
    {
        return 1+k;
    }
    if (k+1<=a)
    {
        return 1+k;
    }
    k-=a+1;
    return b+k/2*(b-a)+(k&1);
}
int main()
{
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define inf 1000000000000
#define MOD 1000000007
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define for0(i, n) for (int i = 0; i < n; i++)
#define tc(t) int t; cin >> t; while (t--)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()
#define ps(x,y)         fixed<<setprecision(y)<<x
using namespace std;
int main()
{
	IOS
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	int n, k;
	cin >> n >> k;
	vi stones;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		stones.pb(a);
	}
	bool dp[k + 1];
	memset(dp, false, sizeof(dp));
	for (int i = 0; i <= k; i++)
	{
		for (int j = 0; j < stones.size(); j++)
		{
			if (stones[j] <= i && !dp[i - stones[j]])
			{
				dp[i] = true;
			}
		}
	}
	dp[k] ? cout << "First\n" : cout << "Second\n";
}


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

const ll INF = 1e18;

ll dp[200001][4];

int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    
    //解説動画より
    //i個目まで見て、これまでj個余分なxをはさんだときのmax
    //偶数の時 j=0,1
    //奇数の時 j=0,1,2
    
    
    int k = 1 + n%2;
    
    rep(i,n+1)rep(j,k+1)dp[i][j]=-INF;
    dp[0][0]=0;
    
    rep(i,n){
        rep(j,k+1){
            //いま余分なxを足した場合
            dp[i+1][j+1] = max( dp[i+1][j+1], dp[i][j] );
            
            //いま余計なxを足さない場合、次のoxはi+jの偶奇のみできまる
            ll now = dp[i][j];
            if((i+j)%2==0) now += a[i];
            
            dp[i+1][j] = max( dp[i+1][j], now);
        }
    }
    
    cout << dp[n][k] << endl;
    return 0;
    
}

Measured memory_bytes: 10388
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
typedef long long ll;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define REP(i,num,n) for(ll i=num, i##_len=(n); i<i##_len; ++i)
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; }
#define print(x) cout << (x) << endl;
#define pb push_back
#define mp make_pair
#define sz(x) int(x.size())
 
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
const int INF = 1e9;
const ll LLINF = 1e16;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}
 
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};

int main(void){
    cout.tie(0);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> s(n+1);
    rep(i,n) s[i+1] = s[i] + a[i];
    ll ans = LLINF;
    REP(i,1,n) {
      ll n1 = s[i] - s[0];
      ll n2 = s[n] - s[i];
      chmin(ans, abs(n1 - n2));
    }
    print(ans);
}


Measured memory_bytes: 3456
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
unordered_map<int, int> mp;

stack<ll> st;
ll N, R, C;

ll calc_z(int x, int y){
    if(x == 0){
        return y;
    }
    else if(x == R){
        return C + R + (C - y);
    }
    else if(y == 0){
        return C + R + C + (R - x);
    }
    else{
        return C + x;
    }
}

int main(){
    cin >> R >> C >> N;
    int x1, y1, x2, y2;
    vector<P> z;
    for(int i = 0; i < N; i++){
        cin >> x1 >> y1 >> x2 >> y2;
        if((x1 == 0 || x1 == R || y1 == 0 || y1 == C) &&
                (x2 == 0 || x2 == R || y2 == 0 || y2 == C)){
            z.emplace_back(P(calc_z(x1, y1), i));
            z.emplace_back(P(calc_z(x2, y2), i));
        }
    }

    sort(z.begin(), z.end());

    for(auto zz: z){
        if(st.empty() || st.top() != zz.sc){
            st.push(zz.sc);
        }
        else{
            st.pop();
        }
    }

    if(st.empty()){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }


    return 0;
}


Measured memory_bytes: 5872
#include<bits/stdc++.h>
#define STDIO
#define MOD 1000000007
#define testbit(mask,i) (((mask)>>(i))&1)
#define setbit(mask,i) ((mask)|(1<<i))
#define delbit(mask,i) ((mask)^(1<<i))
#define lowbit(x) ((x)&(-x))
#define INF MOD
using namespace std;
int a,b,m;
int pa[100100],pb[100100];
int x,y,c;
int main(){
	#ifndef STDIO
		freopen("input.in","r",stdin);
		freopen("output.out","w",stdout);
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>a>>b>>m;
	for(int i=1;i<=a;i++)
		cin>>pa[i];
	for(int i=1;i<=b;i++)
		cin>>pb[i];
	int res=2e9;
	for(int i=1;i<=m;i++){
		cin>>x>>y>>c;
		res=min(res,pa[x]+pb[y]-c);
	}
	sort(pa+1,pa+a+1);
	sort(pb+1,pb+b+1);
	res=min(res,pa[1]+pb[1]);
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 1024
<?php

fscanf(STDIN, "%d %d", $N, $M);
$IN = [];
for ($i = 0; $i < $N; ++$i) {
    fscanf(STDIN, "%d %d %d", $x, $y, $z);
    $IN[] = [$x, $y, $z];
}


$ans = PHP_INT_MIN;
for ($i = 0; $i < (1<<3); ++$i) {
    $q = new SplPriorityQueue();
    for ($j = 0; $j < $N; ++$j) {
        $tmp = [];
        $pri = 0;
        for ($k = 0; $k < 3; ++$k) {
            if ($i & (1<<$k)) {
                $tmp[] = (-1) * $IN[$j][$k];
                $pri += (-1) * $IN[$j][$k];
            } else {
                $tmp[] = $IN[$j][$k];
                $pri += $IN[$j][$k];
            }
        }
        $q->insert($tmp, $pri);
    }

    $res_x = 0;
    $res_y = 0;
    $res_z = 0;
    for ($j = 0; $j < $M; ++$j) {
        $tmp = $q->extract();
        $res_x += $tmp[0];
        $res_y += $tmp[1];
        $res_z += $tmp[2];
    }
    $ans = max($ans, abs($res_x) + abs($res_y) + abs($res_z));
}

echo (int)$ans, PHP_EOL;


Measured memory_bytes: 16912
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<queue>
#include<climits>
#define N 100010
#define M 400010
#define INF (INT_MAX/10-10)
#define build_edge(u,v,f) add_edge(u,v,f),add_edge(v,u,0)
#define debug(x) cerr<<#x<<"="<<x
#define sp <<" "
#define ln <<endl
using namespace std;
struct edges{
	int to,pre,resf;
}e[M];int h[N],etop,lev[N],cur[N],l[N],r[N],nc;
queue<int> q;char c[N];
inline int add_edge(int u,int v,int f)
{	return e[++etop].to=v,e[etop].pre=h[u],e[etop].resf=f,h[u]=etop;	}
inline int bfs(int s,int t)
{
	while(!q.empty()) q.pop();
	memset(lev,0,sizeof(int)*(nc+1));
	q.push(s),lev[s]=1;
	while(!q.empty())
	{
		int x=q.front();q.pop();
		for(int i=h[x],y;i;i=e[i].pre)
			if(e[i].resf&&!lev[y=e[i].to])
				lev[y]=lev[x]+1,q.push(y);
	}
	return lev[t];
}
int dfs(int s,int t,int a)
{
	if(s==t||!a) return a;int flow=0,f;
	for(int &i=cur[s],y;i;i=e[i].pre)
		if(lev[e[i].to]==lev[s]+1&&(f=dfs(e[i].to,t,min(a,e[i].resf)))>0)
		{	e[i].resf-=f,e[((i-1)^1)+1].resf+=f,a-=f,flow+=f;if(!a) break;	}
	return flow;
}
inline int dinic(int s,int t,int ans=0)
{	while(bfs(s,t)) memcpy(cur,h,sizeof(int)*(nc+1)),ans+=dfs(s,t,INF);return ans;	}
int main()
{
	int n,m,s=0,t=0;scanf("%d%d",&n,&m);
	int sx=0,sy=0,tx=0,ty=0;
	for(int i=1;i<=n;i++) l[i]=++nc;
	for(int i=1;i<=m;i++) r[i]=++nc;
	for(int i=1;i<=n;i++)
	{
		scanf("%s",c+1);
		for(int j=1,x,y;j<=m;j++)
		{
			if(c[j]=='o'||c[j]=='S'||c[j]=='T')
				x=++nc,y=++nc,
				build_edge(l[i],x,INF),
				build_edge(r[j],x,INF),
				build_edge(y,l[i],INF),
				build_edge(y,r[j],INF),
				build_edge(x,y,c[j]=='o'?1:INF);
			if(c[j]=='S') s=x,sx=i,sy=j;
			if(c[j]=='T') t=y,tx=i,ty=j;
		}
	}
	if(sx==tx||sy==ty) return !printf("-1\n");
	return !printf("%d\n",dinic(s,t));
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> //required
//#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long
#define lb long double
#define pb push_back
#define loop(i,start,n) for(ll i=start;i<n;i++)
#define rloop(i,n,start)for(ll i=n;i>=start;i--)
#define mod 1000000000007
#define endl "\n"
#define INF     1e15
#define NEG_INF -1e15
#define pll pair<ll,ll>
#define x first
#define y second
#define all(x) x.begin(),x.end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
//template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
//using namespace __gnu_pbds;
ll mpow(ll x, ll y) { 
    ll temp, f; 
    if( y == 0) 
        return 1; 
    temp = mpow(x, y/2); 
    if (y%2 == 0) 
        return (temp * temp) ; 
    else{   
        f = (x * temp) ;
        f = (f * temp) ;
        return f; 
    }
}  
int main(){
	IOS;
	ll n;
	cin >> n;
	ll len = 0, curr = 0;
	while(curr < n){
		len++;
		curr += mpow(26, len);
		//debug(curr);
	}
	debug(len, curr);

	string ans;
	rloop(i, len, 1){
		ll k = ( 26LL * (mpow(26, i - 1LL) - 1LL)) / 25LL;
		debug(k, n);
		rloop(j, 26, 1){
			ll sum = (j - 1) * mpow(26, i - 1) + k + 1;
			if(sum <= n){
				ans += char(j + 96);
				//debug(sum);
				n -=  j * mpow(26, i - 1);
				break;
			}
		}
	}

	cout << ans << endl;
	
}

//

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int x = sc.nextInt();
    int l[] = new int[n];
    for (int cnt = 0; cnt < n; cnt++) {
      l[cnt] = sc.nextInt();
    }
    int d = 0;
    int i = 0;
    for (int cnt = 0; cnt < n; cnt++) {
      d += l[cnt];
      if (d > x) {
        i = cnt + 1;
        break;
      } else {
        i = n + 1;
      }
    }
    System.out.println(i);
    sc.close();
  }
}

Measured memory_bytes: 35804
def main():
    N = int(input())
    M = []
    for _ in range(5):
        M.append(int(input()))
    x = min(M)
    if x > N:
        print(5)
    else:
        if N % x == 0:
            print(N // x - 1 + 5)
        else:
            print(N // x + 5)


main()


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

using namespace std;

int main()
{
    //system("chcp 65001");

    int a,b;
    cin >> a >> b;
    if(a > b)
    {
        cout << a - 1;
    }
    else
    {
        cout << a;
    }
    
    //cout << N;

    return 0;
}

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

using ll=long long;

int main() {
  int i,N,M,x;
  ll s=0;
  cin >> N >> M;
  priority_queue<int> A;
  for(i=0; i<N; i++) {
    cin >> x;
    A.push(x);
  }
  for(i=0; i<M; i++) {
    int mn = A.top();
    A.pop();
    A.push(mn/2);
  }
  while(!A.empty()) {
    s += A.top();
    A.pop();
  }
  cout << s << endl;
}

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

using namespace std;

const long long MOD = 1000000007;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}

vector<long long> arr;

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);

    int n, m, k;
    cin >> n >> m >> k;

    for(int rows = 0; rows <= n; ++rows){
        for(int cols = 0; cols <= m; ++cols){
            int target = rows * (m - cols) + cols * (n - rows);
            if(target == k){
                cout << "Yes";
                return 0;
            }
        }
    }
    cout << "No";

    return 0;
}


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

using namespace std;

#define EPS 1e-9

struct Point{
  double x,y;
  
  Point(){}
  Point(double x,double y) : x(x),y(y) {}
  
  Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
  Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
  Point operator * (const double &k)const{ return Point(x*k,y*k); }
  Point operator / (const double &k)const{ return Point(x/k,y/k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
double dist(const Point &a,const Point &b){
  return sqrt(pow(a.x-b.x,2) + pow(a.y-b.y,2));
}

istream &operator >> (istream &is,Point &p){
  return is >> p.x >> p.y;
}

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
  Vector a = p1 - p0;
  Vector b = p2 - p0;
  if(cross(a,b) > EPS){ return COUNTER_CLOCKWISE; }
  if(cross(a,b) < -EPS){ return CLOCKWISE; }
  if(dot(a,b) < -EPS){ return ONLINE_BACK; }
  if(norm(a) < norm(b)){ return ONLINE_FRONT; }
  return ON_SEGMENT;
}

struct Segment{
  Point s,t;
  Segment(){}
  Segment(Point s,Point t) : s(s),t(t) {}
};

bool isIntersectSS(const Segment &a,const Segment &b){
  Point s[2] = {a.s,a.t}, t[2] = {b.s,b.t};
  return (ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
          ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0);
}

Point crosspointSS(const Segment &a,const Segment &b){
  Vector va = a.t-a.s, vb = b.t-b.s;
  double d = cross(vb,va);
  return a.s+va*cross(vb,b.t-a.s)*(1.0/d);
}

struct P{
  int comp;
  int pos;
  double dist;

  bool operator < (const P &p)const{
    if(dist != p.dist){
      return dist < p.dist;
    }
  }
};

int solve(int idx,int p,vector<P> &v){
  if(idx == (int)v.size()){ return 0; }
  int res;
  if(v[idx].comp == 0){
    if(p == v[idx].pos){
      res = solve(idx+1,!p,v)+1;
    }else{
      res = solve(idx+1,p,v);
    }
  }else{
    if(p == v[idx].pos){
      res = solve(idx+1,p,v);
    }else{
      res = solve(idx+1,!p,v)+1;
    }
  }
  return res;
}

int main(){
  int Tc,N,comp,pos;
  cin >> Tc;
  while(Tc--){
    Segment s,line;
    cin >> s.s >> s.t >> N;
    vector<P> vec;
    for(int i = 0 ; i < N ; i++){
      cin >> line.s >> line.t >> comp >> pos;
      if(isIntersectSS(line,s)){
        Point p = crosspointSS(line,s);
        double d = dist(p,s.s);
        vec.push_back((P){comp,pos,d});
      }
    }
    sort(vec.begin(),vec.end());
    cout << min(solve(0,0,vec),solve(0,1,vec)) << endl;
  }
  return 0;
}

Measured memory_bytes: 1256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scan() string {
	sc.Scan()
	return sc.Text()
}
func iScan() int {
	n, _ := strconv.Atoi(Scan())
	return n
}
func fScan() float64 {
	n, _ := strconv.ParseFloat(Scan(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func SScan(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scan()
	}
	return a
}
func iSScan(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = iScan()
	}
	return a
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func sum(a []int) int {
	x := 0
	for _, v := range a {
		x += v
	}
	return x
}

var mod int = 1000000007

func main() {
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	r, g, b, n := iScan(), iScan(), iScan(), iScan()
	ans := 0
	for i := 0; i*r <= n; i++ {
		for j := 0; j*b <= n-i*r; j++ {
			x := n - i*r - j*b
			if x%g == 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1788
from sys import stdin
import sys
# sys.setrecursionlimit(10**8)

def nextLine(): return next(stdin)
def nextStrList(): return nextLine().split()
def nextIntList(): return [int(_) for _ in nextStrList()]

import numpy as np

def main():
	r=int(nextLine())
	
	print(2*r*np.pi)
				
	
if __name__=="__main__":
	main()


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

int main(){

    int n; cin >> n;
    vector<int> s(n);
    for(int i = 0; i < n; i++) cin >> s[i];
    vector<vector<bool> > dp(n + 1, vector<bool> (10110, false));
    dp[0][0] = true;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10110; j++){
            dp[i + 1][j] = dp[i][j] | dp[i + 1][j];
            dp[i + 1][j + s[i]] = dp[i][j] | dp[i + 1][j + s[i]];
        }
    }

    for(int i = 10010; i >= 0; i--){
        if(dp[n][i] && i % 10 != 0) return !printf("%d\n", i);
    }

    return !printf("0\n");
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <cassert>
typedef long long int ll;
using namespace std;


int main(int argc, char *argv[]) {
  // C-style stdio functions should not be used.
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int a1, a2, a3; cin >> a1 >> a2 >> a3;
  if (a1 + a2 + a3 >= 22) {
    cout << "bust\n";
  }else {
    cout << "win\n";
  }

  return 0;
}



Measured memory_bytes: 256
s = gets.chomp.split("")
t = gets.chomp.split("")
flag1 = false
(s.length - t.length).step(0, -1) do |i|
  s_part = s[i, t.length]
  flag2 = true
  t.each_with_index do |c, j|
    unless [c, "?"].include?(s_part[j])
      flag2 = false
      break
    end
  end
  if flag2
    s[i, t.length] = t
    flag1 = true
    break
  end
end

if flag1
  puts s.map { |e| e == "?" ? "a" : e }.join("")
else
  puts "UNRESTORABLE"
end


Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,k=map(int,input().split())
    if(k&1):
        s=n//k
        print(s**3)
    else:
        s=n//k
        t=(n//(k//2)+1)//2
        print(s**3+t**3)
resolve()

Measured memory_bytes: 38384
#include <iostream>
#include <map>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int N;
    long long T;
    long long maxa = -1, mina = -1;
    long long A;
    long long p;
    map<int, int> cnt;

    cin >> N >> T;

    for (int i = 0; i < N;i++)
    {
        cin >> A;
        if(mina == -1 || mina > A)
        {
            mina = A;
        }
        else if(mina < A) 
        {
            p = A - mina;
            if(cnt.find(p) == cnt.end())
            {
                cnt[p] = 1;
            }
            else
            {
                cnt[p]++;
            }
        }
    }

    int ans = cnt.rbegin()->second;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
# define ll long long int
#define mod 1000000007 
using namespace std;
int a[100005][3];
int dp[100005][3];
int n;
int fun(int x,int m){
	if (x==n){
		return 0;
	}
	if (dp[x][m]!=-1){
		return dp[x][m];
	}
	if (m==0){
		return dp[x][m]= a[x][m]+max(fun(x+1,1),fun(x+1,2));
	}
	else if (m==1){
		return dp[x][m]= a[x][m]+max(fun(x+1,0),fun(x+1,2));
	}
	else{
		return dp[x][m]= a[x][m]+max(fun(x+1,0),fun(x+1,1));
	}
}
int main(){
	cin>>n;
	
	for (int i=0;i<n;i++){
		for (int j=0;j<3;j++){
		cin>>a[i][j];
	}
	}
	memset(dp,-1,sizeof(dp));
	int A=fun(0,0);
	int B=max(A,fun(0,1));
	int C=max(B,fun(0,2));
	
	cout<<C<<endl;
}

Measured memory_bytes: 7296
n = int(input())
l = [int(i) for i in input().split()]

l.sort(reverse = True)

if len(l) == n:
  lm = l[0]

  del l[0]

  if int(lm) < sum(l):
    print('Yes')
  else:
    print('No')
else:
  print('No')


Measured memory_bytes: 2940
#include <stdio.h>

int judge(int a,int b,int c){
    if((a*a == b*b + c*c) || (b*b == a*a + c*c) || (c*c == a*a + b*b))return 1;
    else return 0;
}

int main(void){
    int n,a,b,c;
    scanf("%d",&n);
    for(int i=0;i < n;i++){
        scanf("%d %d %d",&a,&b,&c);
        if(judge(a,b,c) == 1)printf("YES\n");
        else printf("NO\n");
    }
    return 0;
}

Measured memory_bytes: 1008
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 20)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する
int dp[5001][5000];

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> a;
    int need = 0;
    rep(i,0,N){
        int tmp;
        cin >> tmp;
        if(tmp >= K){
            need++;
        }else{
            a.push_back(tmp);
        }
    }
    vector<int> rui;
    rui.push_back(0);
    sort(all(a));
    rep(i,0,a.size()-1){
        rui.push_back(*(rui.end()-1) + a[i]);
    }
    reverse(all(rui));

    reverse(all(a));

    dp[0][0] = 1;
    int ans = a.size();
    rep(i,0,a.size()){
        bool iscont = false;

        rep(j,0,5000){
            if(dp[i][j]){

                if(j+a[i] >= K){
                    iscont = true;
                }else{
                    dp[i+1][j+a[i]] = 1;
                }
                dp[i+1][j] = 1;
            }
        }
        rep(j,0,K){
            if(dp[i+1][j]){
                if(j+rui[i] >= K){
                    iscont = true;
                    break;
                }
            }
        }
        if(!iscont){
            break;
        }else{
            ans--;
        }
    }



    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 96768
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define F(i,a,b) for(int i=a;i<b;i++)
#define RF(i,a,b) for(int i=a;i>b;i--)
#define mp(a,b) make_pair(int a,int b)
#define ll long long
const int mxn=1e3+10,mxm=4e5+10,modl=1e9+7;
int nm,n,m,p,t,ans,sum;
int a[mxn],b[mxn],h[mxn];
//string s[mxn];
//bool in[mxn][mxn];
//int tr[][2]={{0,-1},{-1,0},{0,+1}};
//struct pos{
//    int x,y;
//    bool operator < (const pos b)const{
//        return h[x][y]>h[b.x][b.y];
//    }
//};
bool cmp(string a,string b){
    return a+b<b+a;
}
int main(){
    ios_base::sync_with_stdio(false);
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);
//    cin>>nm;
    string s,s1,s2;char c;
    while(cin>>s>>n){
//        priority_queue<int,vector<int>,greater<int>>q;
        F(i,0,n){
            cin>>p;
            if(p==1) {t++;continue;}
            cin>>p>>c;
            if(t+p&1) s1+=c;
            else s2+=c;
        }
        if(t&1){
            RF(i,s2.size()-1,-1) cout<<s2[i];
            RF(i,s.size()-1,-1) cout<<s[i];
            cout<<s1;
        }
        else {
            RF(i,s1.size()-1,-1) cout<<s1[i];
            cout<<s;
            cout<<s2;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 1104
import java.util.*;
public class Main {

  public static void main(String[] args) { 
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int left = 0, right = n - 1;

        System.out.println(left);
        String ansL = sc.next();
        if(ansL.equals("Vacant")) return;

        System.out.println(right);
        String ansR = sc.next();
        if(ansR.equals("Vacant")) return;

      while(true) {
        int mid = left + (right - left) / 2;
        System.out.println(mid);
        String ansM = sc.next();
        if(ansM.equals("Vacant")) return;
        if(ansM.equals(ansL) && (mid - left) % 2 == 1 || !ansM.equals(ansL) && (mid - left) % 2 == 0) {
          right = mid;
          ansR = ansM;
        } else {
          left = mid;
          ansL = ansM;
        }
      }
  }
}

Measured memory_bytes: 25760
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b,h;
  cin >> a >> b >> h;
  cout << (a+b)*h/2 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1LL<<60;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  int n;  cin>>n;
  map<string, int> ma;
  rep(i,0,n){
    string s; cin>>s;
    ma[s]++;
  }
  int man=0;
  for(auto j:ma){
    chmax(man, j.se);
  }
  for(auto j:ma){
    if(j.se==man){
      cout << j.fi << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 25216
# -*- coding: utf-8 -*-
"""
Created on Fri Mar 22 14:15:50 2019

@author: Yamazaki Kenichi
"""

n = int(input())
A = [list(map(int,input().split())) for i in range(n)]
B = [A[0][0]]
for c in A:
    B += [c[1]]

T = [[0 for i in range(n)] for i in range(n)]
for i in range(1,n):
    for j in range(n-i):
        if i == 1:
            T[i][j] = B[j]*B[j+1]*B[j+2]
            continue
        temp = 10**6
        for k in range(1,i+1):
             temp = min(temp,
                        T[i-k][j] + T[k-1][j+(i-k)+1] + B[j]*B[j+i-k+1]*B[j+i+1])
        T[i][j] = temp
print(T[n-1][0])



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

public class S
{

    private const long DP_INIT_MINUS1 = -1;
    private const double DP_INIT_DOUBLE_MINUS1 = -1.0;
	private const long MOD = 1000000007;


    //s
    private const int FIRST_WIN = 1;
    private const int SECOND_WIN = 0;

    private static long[,] dp;


    public static void Main()
	{
		/*
        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var M = input[1];
        */

        var input = Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        var N = input[0];
        var K = input[1];

        solver(N,K, Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse));
    }

    public static void solver(long N, long K, long[] candies){

        /*
            EDPC M Candies
            dp[N,K], K消費？   
            dp[N,K], N人目で合計K個のパターン？
            
            x人目で合計がy個になるのは・・・
            x-1人目で合計がy,y-1... y-Axまでの範囲が遷移してくる
            この遷移のために、累積和を取っておく必要はありそう
           
            飴を使い切らなきゃいけないから、回答は安心してdp[N,K]。
            。
         */

        dp = new long[N+1,K+1];
        var cSum = new long[N+1,K+1];
        long add;
        

        //for(int i = 1; i <= N; i++){
            for(int k = 0; k <= K; k++){
				if(candies[0] < k){
					dp[1,k] = 0;
					cSum[1,k] = cSum[1,k-1];
                    continue;
				}
				/*
                if(candies[0] == 0){
					if(k == 0){
                        dp[1,k] = 1;
						cSum[1,k] = 1;
						continue;
					}
                    cSum[1,k] = cSum[1,k-1];
                    continue;
                }*/
                dp[1,k] = 1; //K個取りのパターンは初回はすべて1
				if(k == 0){
					cSum[1,k] = 1;
					continue;
				}
                cSum[1,k] = cSum[1,k-1] + dp[1,k];
            }
        //}

        			/*
			for(int k = 0; k <= K; k++){
				Console.Write(cSum[1,k] + ",");
				
			}
			Console.WriteLine();
			*/

        for(int i = 2; i <= N; i++){

            for(int k = 0; k <= K; k++){

                add = ((k - candies[i-1] > 0) ? 
                            cSum[i-1,k] - cSum[i-1,k-candies[i-1]-1]
                            :
                            cSum[i-1,k]
                        );

                dp[i,k] += add;
				dp[i,k] %= 1000000007;
				if(k == 0){
					cSum[i,k] = dp[i,k];
					continue;
				}
				cSum[i,k] = cSum[i,k-1] + dp[i,k];

            }
			/*
			for(int k = 0; k <= K; k++){
				Console.Write(cSum[i,k] + ",");
				
			}
			Console.WriteLine();
			*/

            
        }

        Console.WriteLine(dp[N,K]);
		/*
		for(int i = 1; i <=N; i++){
			for(int k = 0; k <= K; k++){
				Console.Write(dp[i,k] + ",");	
			}
			Console.WriteLine();
		}
		*/
		
	}
}

Measured memory_bytes: 166872
#include <stdio.h>
#include <math.h>

double rnd(double a,int n) {
	double b;
	b=a*pow(10,n+1);
	b=(double)(int)(b+0.5);
	return b*pow(10,-n-1);
}

int main(void) {
	double a,b,c,d,e,f,D;
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF) {
		D=a*e-b*d;
		printf("%.3f %.3f\n",rnd((e*c-b*f)/(a*e-b*d),4),rnd((a*f-c*d)/(a*e-b*d),4));
	}
	return 0;
}

Measured memory_bytes: 696
#include <bits/stdc++.h>
#define int long long
#define all(a) (a).begin(),(a).end()
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

signed main(){
    ios_base::sync_with_stdio(false);

    int n ;
    cin >> n;

    int dp[n+1];
    for(int i=0;i<=n;i++)
        dp[i] = 0;

    dp[0] = 1;

    const int hell = 1e9 + 7;
    for(int i=0;i<=n;i++){
        for(int j=3;j<=n;j++){
            if(i+j>n) break;
            ( dp[i+j] += dp[i] )%= hell;
        }
    }

    cout << dp[n] << endl ;

    return 0;
}


Measured memory_bytes: 3648
def quickSort(A, p, r):
  if p < r:
    q = partition(A, p, r)
    quickSort(A, p, q-1)
    quickSort(A, q+1, r)


def partition(A, p, r):
  x = A[r]
  i = p -1

  for j in range(p, r):
    if A[j][1] <= x[1]:
      i += 1
      A[i], A[j] = A[j], A[i]
  A[i+1], A[r] = A[r], A[i+1]
  return i+1


deck = []
n = int(input())
for index in range(n):
  mark, number = input().split()
  card = [mark, int(number), index]

  deck.append(card)

quickSort(deck, 0, n-1)

ans = 'Stable'
for i in range(1, n):
  if deck[i-1][1] == deck[i][1]:
    if deck[i-1][2] > deck[i][2]:
      ans = 'Not stable'
      break
print (ans)
for v in deck:
  print ('{mark} {number}'.format(mark=v[0], number=v[1]))


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

using lint = long long;

lint mod, N, X, L, R, arr[100004], rec[100004];

int main() {
	cin >> N >> X >> mod;

	arr[1] = X;
	rec[X] = 1;

	for (int i=2; ; i++) {
		arr[i] = (arr[i-1] * arr[i-1]) % mod;
		if (rec[arr[i]]) {
			L = rec[arr[i]];
			R = i;
			break;
		}
		rec[arr[i]] = i;
	}

	lint ans = 0;

	for (int i=1; i<=N and i<R; i++) {
		if (i < L) ans += arr[i];
		else ans += arr[i] * (long long)((N-L) / (R-L) + ((N-L) % (R-L) >= i-L));
	}

	cout << ans << '\n';
}

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

int main()
{
	char s[20];
	scanf("%s", s);
	for(int i = 0; i < 19; i++)
	{
		if( s[i] >= 'a' && s[i] <= 'z')
			continue;
		else
		    s[i] = ' ';
	}
	printf("%s\n", s);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define pint pair<int, int>
#define F first
#define S second
const int MOD = 1000000007;
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; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

// dxdyは 0右 1下 2左 3上
vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,-1,0,1};

int main(){
    int H,W;cin >> H >> W;
    vector<vector<int>> maze(H+2,vector<int>(W+2,-1));     // -1 は未到達、0は壁
    int wall = 0;
    rep(i,H)rep(j,W){
        char t = '-';
        cin >> t;
        if(t == '#'){
            wall++;
            maze[i+1][j+1] = 0;
        }
    }

    maze[1][1] = 1;
    queue<pair<int,int>> q;
    q.push(pint(1,1));
    while(!q.empty()){
        pair<int,int> now = q.front();
        q.pop();
        int x = now.S;
        int y = now.F;
            rep(i,4){   // xyは行列表記
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(ny <= 0 || ny >= H+1 || nx <= 0 || nx >= W+1)continue;
            if(maze[ny][nx] == -1){
                maze[ny][nx] = maze[y][x] + 1;
                q.push(pint(ny,nx));
            }
        }
    }
 


    int ans = 0;
    ans = H*W - wall - maze[H][W];
    if(maze[H][W] == -1)cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<usize>();
    let k = read::<usize>();
    let mut seq = vec![0; n];
    for i in 0..n {
        seq[i] = read::<usize>();
    }
    seq.sort();
    seq.reverse();
    let ans = seq.iter().take(k).sum::<usize>();
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include<iostream>

using namespace std;


int a[100100];

int main()
{
	int n=0;
	int x=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x;
		a[x]=i;
		
	}
	for(int i=1;i<=n;i++)
	{
		cout<<a[i]<<" "; 
	 } 
	
	return 0;
} 

Measured memory_bytes: 1152
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
 
        int A1 = sc.nextInt();
        int A2 = sc.nextInt();
        int A3 = sc.nextInt();
        int X ;
        X = A1 + A2 + A3;
		if (X >= 22){
        System.out.println("bust");
		
		} else {
        System.out.println("win");
		
		}
 }
}


Measured memory_bytes: 22996
def gcd(x, y):
  if y != 0:
    return gcd(y, x % y)
  else:
    return x

def lcm(x, y):
  return (x // gcd(x, y)) * y

def calc(a, m):
  ans = 0
  for x in a:
    ans += m % x
  return ans

def resolve():
  n = int(input())
  a = list(map(int, input().split()))
  m = 1
  for i in range(n):
    m = lcm(a[i], m)
  m -= 1
  ans = calc(a, m)
  print(ans)
  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
#define ll long long

typedef pair<int,int> P;
const int INF = 500000000;

int main(){
    string s,t;
    cin >> s >> t;
    int ss = s.size();
    string ans = "No";
    if (t.size() == ss+1){
        if (s == t.substr(0,ss)){
            ans = "Yes";
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define INF 1e9

signed main()
{
    int a;
    int n[4];
    int op[2] = {1, -1};
    cin >> a;
    for (int i = 3; i >= 0; i--)
    {
        n[i] = a % 10;
        a = a / 10;
    }
    int ans[3];
    for (int i = 0; i < 2; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            if (7 - (n[0] + n[1] * op[i] + n[2] * op[j]) == n[3])
            {
                ans[0] = op[i];
                ans[1] = op[j];
                ans[2] = 1;
                break;
            }
            else if (7 - (n[0] + n[1] * op[i] + n[2] * op[j]) == -1 * n[3])
            {
                ans[0] = op[i];
                ans[1] = op[j];
                ans[2] = -1;
                break;
            }
        }
    }

    for (int i = 0; i < 3; i++)
    {
        cout << n[i];
        if (ans[i] == 1)
            cout << '+';
        else
            cout << '-';
    }
    cout << n[3] << "=7" << endl;
}

Measured memory_bytes: 256