akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
using namespace std;
struct box{
	int id,bel,acc,pen;
};
bool cpm(const box &a,const box &b){
	if(a.acc!=b.acc)
	return a.acc>b.acc;
	else if(a.pen!=b.pen)
	return a.pen<b.pen;
	else
	return a.id<b.id;
}
int main(){
	int n;
	while(cin>>n,n){
		int now=0;
		map<int,int> mp;
		vector<box> tab;
		box e;
		for(int i=0;i<n;i++){
			cin>>e.id>>e.bel>>e.acc>>e.pen;
			tab.push_back(e);
		}
		sort(tab.begin(),tab.end(),cpm);
		for(int i=0;i<n;i++){
			if(now<10){
				if(mp[tab[i].bel]<3){
					mp[tab[i].bel]++;
					now++;
					cout<<tab[i].id<<endl;
				}
			}else if(now<20){
				if(mp[tab[i].bel]<2){
					mp[tab[i].bel]++;
					now++;
					cout<<tab[i].id<<endl;
				}
			}else if(now<26){
				if(mp[tab[i].bel]==0){
					mp[tab[i].bel]++;
					now++;
					cout<<tab[i].id<<endl;
				}
			}else break;
		}
	}
	return 0;
}

Measured memory_bytes: 0
A = [x for x in input()]
B = [x for x in input()]
C = [x for x in input()]
next = 'a'
while True:
    if next == 'a':
        if len(A) == 0:
            print('A')
            break
        next = A.pop(0)
    elif next == 'b':
        if len(B) == 0:
            print('B')
            break
        next = B.pop(0)
    elif next == 'c':
        if len(C) == 0:
            print('C')
            break
        next = C.pop(0)

Measured memory_bytes: 3064
s = input()
l = list('abcdefghijklmnopqrstuvwxyz')
for s_ in s:
    l.remove(s_)
if l==[]:
    l.append(s[-1])
    for i in range(len(s)-2,-1,-1):
        if s[i]<max(l):
            for k in l:
                if k>s[i]:
                    print(s[:i]+k)
                    exit()
        l.append(s[i])
    print(-1)
else:
    print(s+l[0])

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    ll N;
    cin >> N;
    vec a(N), b(N), ans(N, 0);
    ll s = 0;
    Rep (i, N) {
        cin >> a[i];
        s += a[i];
    }
    iota(b.begin(), b.end(), 0);
    sort(b.begin(), b.end(), [&](ll x, ll y){return a[x] > a[y];});

    ll tmp = b[0];
    Rep (i, N-1) {
        if (a[b[i]] == a[b[i+1]]) {
            chmin(tmp, b[i+1]);
        } else {
            ans[tmp] += (a[b[i]] - a[b[i+1]]) * (i+1);
            s -= (a[b[i]] - a[b[i+1]]) * (i+1);
            chmin(tmp, b[i+1]);
        }
    }
    
    ans[tmp] += s;

    Rep (i, N) {
        cout << ans[i] << "\n";
    }
}

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

int a[100010],n;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	sort(a,a+n);
	int count=unique(a,a+n)-a;
	printf("%d\n",count-(count%2==0?1:0));
	return 0;
}

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

using namespace std;
using ll =long long;
using db = double;
using vll = vector<long long>;

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; }
#define che(a,string) cout<<"//"<<string <<"=="<<(a)<<"//" <<endl;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define leftunique(a) {SORT(a);(a).erase(unique((a).begin(),(a).end()),(a).end());}
//leftuniqueは配列から同じ要素のものを取り除く 例 4 6 2 1 3 4 1 2 なら 1 2 3 4 6 になる
#define debug(x)  cout << #x << " = " << (x) << endl;
bool IsInt(double a){int b = a/1;if(a==b){return true;}else {return false;}}
bool coY() {cout <<"Yes"<<endl;}
bool coN(){cout <<"No"<<endl;}
const int mod = 1e9 + 7;
const ll INF = 1LL << 60;
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//グラフ用
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};	
//ここから書き始める

ll combination(ll n, ll i){
	ll count = 0;
	ll multi = 1;
	ll div =1;
	int limit = i;
	while(count < limit){
		multi *= n;
		n--;
		multi/= count+1;
		count ++ ;
	}
	return multi / div;
}

int main()
{
	cout <<setprecision(10);
	ll N ; cin >> N;
	vector<ll> a(N);
	rep(i,N) cin >> a[i];

	//ソートは出来ない。
	ll S = 0;
	rep(i,N){
		S += a[i];
	}
	//一番好ましいのは、 S / 2 にすること
	ll prefer = S / 2 ;
	ll sunuke = 0;
	ll ans = INF;
	rep(i,N-1){
		sunuke += a[i];
		if(sunuke < S / 2){
			chmin(ans,abs(sunuke - (S -sunuke)));
		}else{
			chmin(ans,abs(sunuke - (S - sunuke)));
		}
	}
	cout << ans << endl;


}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  bool judge=true;
  for(int i=0; i<s.size();){
    if(s[i]=='L'){
      judge=false;
    }
    i+=2;
  }
  for(int i=1; i<s.size();){
    if(s[i]=='R'){
      judge=false;
    }
    i+=2;
  }    
  if(judge){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
      

}
   

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define double long double
#define p pair<double,double>
#define P pair<p,double>
using namespace std;

P f[1005];
double rinsetu[1005][1005];
double mincost[1005];
signed main(){
 int a,b,c,d,e;cin>>a>>b>>c>>d>>e;
 f[0]=P(p(a,b),0);
 f[1]=P(p(c,d),0);
 for(int g=0;g<e;g++){
     int h,i,j;scanf("%d%d%d",&h,&i,&j);
     f[g+2]=P(p(h,i),j);
     }
     for(int g=0;g<e+2;g++){
	 for(int h=0;h<e+2;h++){
	     rinsetu[g][h]=max((double)0,sqrt((f[g].first.first-f[h].first.first)*(f[g].first.first-f[h].first.first)+(f[g].first.second-f[h].first.second)*(f[g].first.second-f[h].first.second))-f[g].second-f[h].second);
	     }
	 }
	 fill(mincost,mincost+1005,-1);
     priority_queue<p,vector<p>,greater<p>>Q;
     mincost[0]=0;
     Q.push(p(0,0));
     while(Q.size()){
	 p t=Q.top();Q.pop();
	 if(t.first>mincost[(int)t.second])continue;
	 for(int i=0;i<e+2;i++){
	     if(mincost[i]==-1||mincost[i]>t.first+rinsetu[(int)t.second][i]){
		 mincost[i]=t.first+rinsetu[(int)t.second][i];
		 Q.push(p(mincost[i],i));
		 }
	     }
	 }	 
	 printf("%.10Lf\n",mincost[1]);
    }


Measured memory_bytes: 24300
s = gets.chomp.split("").map(&:to_s)
len = s.length
count = len / 2 - 1
i_max = len - 1

ans = 0
0.upto(count) do |i|
  j = i_max - i
  if s[i] != s[j]
    ans += 1
  end
end
if len == 1
  ans = 0
end

p ans

Measured memory_bytes: 1788
#include <iostream>
#include <algorithm> 
using namespace std;
const int MAX=2e5;
int main(){
	int n,R[MAX];
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>R[i];
	int maxv=R[1]-R[0];//设最大差值
	int minv=R[0];//设最小买入值
	for(int i=1;i<n;i++){
		maxv=max(maxv,R[i]-minv);//更新最大差值
		minv=min(minv,R[i]);//更新最小买入值 
	}
	cout<<maxv<<endl;
	return 0; 
}


Measured memory_bytes: 3860
#include <iostream>
#include <string>
using namespace std;
#define REP(i,to) for(i=0;i<(to);i++)

int main() {
	int i;
	string S;
	long long K; 
	cin >> S >>  K;

	REP(i, S.size())
		if (S[i] != '1') break;
	
	if (i >= K) cout << 1 << endl;
	else cout << S[i] << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <string>
#include <time.h>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
//#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,b) for(int i=(a);i<(b);++i)


#define huge 1000000007
typedef long long ll;

int main(void) {

	ll N = 0;
	ll A = 0;
	ll B = 0;
	ll K = 0;
	ll Y = 0;
	ll Q = 0;
	//ll x[10000] = {};
	//ll c[10000] = {};
	//ll d[10000] = {};
	ll *x, *c, *d;
	//string w;
	ll count = 0;
	ll sum = 0;
	ll i = 0;
	cin >> A >> B >> Q;
	
	count += B / Q;

	count -= (A-1) / Q;

	if (A == 0 && Q > 1)count++;

	cout << count << endl;
	return 0;

}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int n, a, b, c, d, count;

	while(scanf("%d", &n) != EOF){
		count = 0;
		for(a = 0;a < 10;a++){
			for(b = 0;b < 10;b++){
				for(c = 0;c < 10;c++){
					for(d = 0;d < 10;d++){
						if(a + b + c + d == n){
							count++;
						}
					}
				}
			}
		}

		printf("%d\n", count);
	}

	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <algorithm>
#include <cstring>
#define ll long long
using namespace std;

ll a[10];

int main() {
    ll n;
    scanf("%lld", &n);
    for (int i = 1; i <= 5; i++) {
        scanf("%lld", &a[i]);
    }
    int pos = min_element(a + 1, a + 6) - a;
    ll ans = (n + a[pos] - 1) / a[pos] + 4;
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <vector>
#include <numeric>

using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;

const int INF = INT_MAX / 2;

struct Edge{
	int from, to, cost;

	Edge( int f, int t, int c ) : from( f ), to( t ), cost( c )
	{
		return;
	}
};

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

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		int V = 0;
		vector< Edge > E;

		for ( int i = 0; i < n; i++ )
		{
			int f, t, c;
			cin >> f >> t >> c;

			V = max( V, max( f, t ) );

			E.push_back( Edge( f, t, c ) );
		}

		V++;

		VVI G( V, VI( V, INF ) );

		for ( int i = 0; i < V; i++ )
		{
			G[i][i] = 0;
		}

		for ( int i = 0; i < n; i++ )
		{
			Edge &e = E[i];

			G[ e.from ][ e.to ] = e.cost;
			G[ e.to ][ e.from ] = e.cost;
		}

		for ( int k = 0; k < V; k++ )
		{
			for ( int i = 0; i < V; i++ )
			{
				for ( int j = 0; j < V; j++ )
				{
					G[i][j] = min( G[i][j], G[i][k] + G[k][j] );
				}
			}
		}

		int num, res = INT_MAX;

		for ( int i = 0; i < V; i++ )
		{
			int sum = accumulate( G[i].begin(), G[i].end(), 0 );

			if ( sum < res )
			{
				num = i;
				res = sum;
			}
		}

		cout << num << ' ' << res << endl;
	}	

	return 0;
}

Measured memory_bytes: 1220
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		final long N = sc.nextLong();
		final int K = sc.nextInt();
		
		for(int i = 0; i < K; i++){
			long x = sc.nextLong() - 1;
			long y = sc.nextLong() - 1;
			
			if(N/2 < x){
				x = (N - 1) - x;
			}
			
			if(N/2 < y){
				y = (N - 1) - y;
			}
			
			System.out.println(Math.min(x, y) % 3 + 1);
		}
		
	}

}

Measured memory_bytes: 12000
S = input()
K = int(input())
N = len(S)

# 全部同じ文字の場合。Sが1文字の場合もここ
if len(set(S)) == 1:
    print((N*K) // 2)
    exit()

# Sの両端の文字が異なるので、Sの中の文字を置き換える回数 * K の場合
if S[0] != S[-1]:
    change = 0
    cnt = 1
    for i in range(1,N):
        if S[i] != S[i-1]:
            change += cnt // 2
            cnt = 1
        else:
            cnt += 1


    if cnt != 1:
        change += cnt // 2

    ans = change * K
    print(ans)
# 両端の文字が同じなので、Kこ並べた時の結合部分について考えなければならない場合
else:
    
    head = 1
    tail = 1
    # 先頭の重複を調べる
    for i in range(1,N):
        if S[i] == S[i-1]:
            head += 1
        else:
            break
    # 後ろの重複を調べる
    for i in range(N-2,-1,-1):
        if S[i] == S[i+1]:
            tail += 1
        else:
            break
    change = 0
    cnt = 1
    # 間の部分の変更するべき個数を調べる
    for i in range(head+1, N-tail+1):
        #print("--", i, S[i], S[i-1])
        if S[i] == S[i-1]:
            cnt += 1
        else:
            change += cnt // 2
            cnt = 1
    
    if cnt != 1:
        change += cnt // 2

        

    ans = ((head + tail) // 2) * (K - 1) + head // 2 + tail // 2 + change * K
    #print(head, tail, change)
    print(ans)

    

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



int main(){

	int a, b, c;
	int key;

	cin >> a >> b >> c;
	if (a > b){
		key = a;
		a = b;
		b = key;
	}
	if (b > c){
		key = b;
		b = c;
		c = key;
	}
	if (a > b){
		key = a;
		a = b;
		b = key;
	}

	cout << a << " " << b << " " << c << endl;


	return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<vector>
#include<map>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};




int main(){
    int n;cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    auto f = [&](int k){
        map<int,int> ma;
        int bf=0;
        for (int i = 0; i < n; i++) {
            if(a[i] <= bf){
                int t = a[i];
                ma[t]++;
                ma.erase(++ma.find(t),ma.end());
                while(ma[t] >= k){
                    ma[t]=0;
                    ma[t-1]++;
                    t--;
                    if(t<=0||k==1) return false;
                }
            }
            bf=a[i];
        }
        return true;
    };
    int l = 0, r = INF;
    while(abs(r - l) > 1){
        int m =  l + (r - l) / 2;
        if(f(m)) r = m;
        else l = m;
    }
    cout << r << endl;
    return 0;
}


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

using namespace std;

//pair<string,int> p;
map<string,int> st;
map<string,int> sd;

int main(){
	string s1;
	string s2;
	cin>>s1>>s2;
	int n,m;
	cin>>n>>m;
	st[s1] = n;
	sd[s2] = m;
	string ss;
	cin>>ss;
	st[ss]++;
	sd[ss]++;
	int len1 = st.size();
	int len2 = sd.size();
	if(len1 == 2){
		cout<<n<<" "<<m-1<<endl;
	}
	if(len2 == 2){
		cout<<n-1<<" "<<m<<endl;
	} 
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    map<string, ll> d;
    
    while (n--) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        d[s]++;
    }
    
    ll ans = 0;
    for (auto e : d) {
        ans += e.second * (e.second - 1) / 2;
    }
    
    cout << ans;
    







}

Measured memory_bytes: 11264
class BIT:
  ini = 0
  def __init__(s, num):
    s.N = 1
    while s.N <= num:
      s.N *= 2
    s.T = [s.ini] * s.N
  def set(s, L):
    for i in range(len(L)):
      s.update(i, L[i])
  def update(s, x, n):
    k = x + 1
    s.T[k - 1] += n
    k += k & -k
    while k <= s.N:
      s.T[k - 1] += n
      k += k & -k
  def getV(s, x):
    if x <= 0: return 0
    ans = s.T[x - 1]
    x -= x & -x
    while x != 0:
      ans += s.T[x - 1]
      x -= x & -x
    return ans

N = int(input())
S = list(input())
Q = int(input())
Query = [list(input().split()) for _ in range(Q)]

B = []
R = {}

def add(i, s):
  global cnt
  if s not in R:
    b = BIT(N)
    b.update(i, 1)
    R[s] = cnt
    cnt += 1
    B.append(b)
  else:
    t = R[s]
    B[t].update(i, 1)

def minus(i, s):
  global cnt
  t = R[s]
  B[t].update(i, -1)

cnt = 0
for i in range(N):
  s = S[i]
  add(i, s)

for i in range(Q):
  q = Query[i]
  q[0] = int(q[0])
  q[1] = int(q[1])
  if q[0] == 1:
    n = q[1] - 1
    s = S[n]
    add(n, q[2])
    minus(n, s)
    S[n] = q[2]
  else:
    ans = 0
    q[2] = int(q[2])
    x, y = q[1] - 1, q[2]
    for i in range(cnt): 
      if B[i].getV(x) != B[i].getV(y):
        ans += 1
    print(ans)
    

Measured memory_bytes: 178600
long long l,i;main(r,x){for(;scanf("%lld",&l),l;printf("%d\n",(l>1?3*r:r)/2+1))for(i=r=1;++i*i<=l;r*=2*x+1)for(x=0;!(l%i);l/=i)x++;exit(0);}

Measured memory_bytes: 600
import java.util.*;
import java.math.*;
import java.lang.String;
import java.lang.System;
import java.lang.reflect.Array;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int[] arr = new int[n];
		int count = 0;
		for (int i = 0; i < n; i++) {
		arr[i] = sc.nextInt();
		if (!(arr[i] >= a && arr[i] < b)) {
		count++;
		}
		}
		System.out.println(count);


	}
}

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

int main() {
  int n, k; cin >> n >> k;
  vector<int> a(n); rep(i, n) cin >> a[i];
  for (int i = 0; i < n-k; i++) {
    if (a[i] < a[i+k])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 4052
input1 = raw_input().replace("\n", "")
input2 = raw_input().replace("\n", "")

if len(input1) != len(input2):
    print "No"
else:
    n_len = len(input1)

result = "No"
for i in xrange(n_len):
    input1_new = input1[i:] + input1[:i]
    if input1_new == input2:
        result = "Yes"
        break
print result

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rrep(i, n) for (ll i = (n - 1); i >= 0; --i)
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define mt(p, q, r) make_tuple(p, q, r)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<ll> vll;
typedef vector<ld> vd;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<str> vs;
typedef vector<vector<ll>> vvll;
typedef vector<vector<ld>> vvd;
typedef vector<vector<bool>> vvb;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;
typedef vector<pair<ll, ll>> vpll;
typedef vector<tuple<ll, ll, ll>> vtlll;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

template <typename T>
void fin(T a)
{
  cout << a << endl;
  exit(0);
}

bool IsPrime(ll num)
{
  if (num < 2)
    return false;
  else if (num == 2)
    return true;
  else if (num % 2 == 0)
    return false;
  ld sqrtNum = sqrt(num);
  for (ll i = 3; i <= sqrtNum; i += 2)
  {
    if (num % i == 0)
      return false;
  }
  return true;
}

void Main()
{
  str s; cin >> s;
  ll n; cin >> n;
  if(s[0] != s[s.size() - 1])
  {
    ll flag = 1;
    ll ans = 0;
    for(ll i = 1;i < s.size();i++)
    {
      if(s[i - 1] == s[i]) flag++;
      else
      {
        ans += (flag / 2) * n;
        flag = 1;
      }
    }
    ans += (flag / 2) * n;
    fin(ans);
  }
  else
  {
    ll flag = 1;
    ll ans = 0;
    vll K;
    ll h = 0;
    for(ll i = 1;i < s.size();i++)
    {
      if(s[i - 1] == s[i]) flag++;
      else
      {
        K.pb(flag);
        flag = 1;
        h = i;
      }
      if(i == s.size() - 1&&i != h)
      {
        K.pb(flag);
      }
    }
    if(s.size() == 1) K.pb(1);
    if(K.size() != 1)
    {
      ans += (K[0] / 2);
      ans += (K[K.size() - 1] / 2);
      K[0] = K[0] + K[K.size() - 1];
      K.pop_back();
      ans += (K[0] / 2 * (n - 1));
      for(ll i = 1;i < K.size();i++)
      {
        ans += (K[i] / 2 * n);
      }
      fin(ans);
    }
    else
    {
      ans += K[0] * n / 2;
      fin(ans);
    }
  }
}

//前処理
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}

/*
//test時
  g++ test.cpp -o test;./test
*/


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>

int main(void){
    std::cin.tie(nullptr); std::ios_base::sync_with_stdio(false); 
    
    int n; std::cin >> n;
    std::vector<int> A(n); for(int i = 0; i < n; ++i) std::cin >> A[i];
    long long int res = 0;
    long long int height = 0;
    for(int i = 0; i < n; ++i){
        if(height <= A[i]) height = A[i];
        else res += height - A[i];
    }
    std::cout << res << '\n';
    
    return 0;
}

Measured memory_bytes: 3944
#include<stdio.h>
int main(){
	
	int n,x=0,max=0;
	char str[255];
	
	scanf("%d", &n);
	scanf("%s", str);
	
	for(int i=0; i<n; i++){
		if (str[i]=='D') x--;
		else if (str[i]=='I') x++;
		if(x>max) max=x;
	}
	printf("%d", max);
	
}

Measured memory_bytes: 1720
#include <stdio.h>

int main() {
    int i, n;
    long data[10000];
    long min, max, sum;
    scanf("%d\n", &n);
    for(i = 0; i < n; i++) scanf("%ld", &data[i]);
    max = data[0];
    min = data[0];
    sum = data[0];
    for(i = 1; i < n; i++) {
        if(data[i] < min) min = data[i];
        else if(data[i] > max) max = data[i];
        sum += data[i];
    }
    printf("%ld %ld %ld\n", min, max, sum);
    return 0;
}

Measured memory_bytes: 1860
import heapq

n = int(input())
v = list(map(int,input().split()))

heapq.heapify(v)

for i in range(n-1):
	a = heapq.heappop(v)
	b = heapq.heappop(v)
	heapq.heappush(v,(a+b)/2)

print(heapq.heappop(v))


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
using vll = vector<vl>;
using Pll = pair<ll, ll>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
const int MOD = 1e9+7;
const ll INF = 2e15;
template<class T> void print(const T& t){ cout << t << endl; }
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; }
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

int main(){
  ll n;
  cin >> n;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  vl b;
  if (n % 2 == 0){
    for (ll i = n - 1; i >= 0;i-=2){
      b.pb(a[i]);
    }
    for (ll i = 0; i < n;i+=2){
      b.pb(a[i]);
    }
  }
  else{
    for(ll i = n - 1; i >= 0;i-=2){
      b.pb(a[i]);
    }
    for (ll i = 1; i < n;i+=2){
      b.pb(a[i]);
    }
  }
  rep(i,n){
    cout << b[i]<<" ";
  }
  cout << endl;
}


Measured memory_bytes: 6840
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <string>
#include <map>
using namespace std;

#define FOR(i,n) for (int i = 0; i < n; i++)

int main() {
  int n;
  scanf("%i", &n);
  int k;
  FOR(i,n) {
    scanf("%i", &k);
    if (k % 2 == 0 && k % 3 != 0 && k % 5 != 0) {
      printf("DENIED\n");
      exit(0);
    }
  }
  printf("APPROVED\n");
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,i,j,temp=INT_MAX;
    cin>>a>>b;
    if(b-a>=2019){
        cout<<"0"<<endl;
        return 0;
    }
    for(i=a;i<=b;i++){
        for(j=i+1;j<=b;j++)
            temp=min(temp,(i*j)%2019);
    }
    cout<<temp<<endl;
    return 0;
}


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

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

int n;
vector<int> G[100001];
int dp[100001];
bool used[100001];
int cnt[100001];

int dfs(int v,int p){
	int res=0;
	for(int i=0;i<G[v].size();i++){
		if(G[v][i]!=p){
			res^=(dfs(G[v][i],v)+1);
		}
	}
	return res;
}

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int f,t;
		scanf("%d%d",&f,&t);
		f--;
		t--;
		G[f].push_back(t);
		G[t].push_back(f);
	}
	memset(dp,-1,sizeof(dp));
	memset(used,false,sizeof(used));
	printf("%s\n",dfs(0,-1)!=0?"Alice":"Bob");
	return 0;
}

Measured memory_bytes: 12416
s=input()
if s[0]==s[1] and s[1] !=s[2] and s[2]==s[3]:
  print("Yes")
elif s[0]!=s[1] and s[1] == s[2] and s[0]==s[3]:
  print("Yes")
elif s[0]!=s[1] and s[0] == s[2] and s[1]==s[3]:
  print("Yes")
else:
  print("No")

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

int main() {
  int n, m;
  cin >> n >> m;
  if(n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

int main(void) {
    ll N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;

    vector<ll> dists(5);
    dists[0] = A;
    dists[1] = B;
    dists[2] = C;
    dists[3] = D;
    dists[4] = E;

    vector<ll> divs(5);
    ll max_div = 0;
    for (int i = 0; i < 5; i++) {
        divs[i] = (N + dists[i] - 1) / dists[i];
        if (max_div < divs[i]) {
            max_div = divs[i];
        }
    }

    cout << 4LL + max_div << endl;

    return 0;
}


Measured memory_bytes: 256
'''
自宅用PCでの解答
'''
import math
#import numpy as np
import itertools
import queue
import bisect
from collections import deque,defaultdict
import heapq as hpq
from sys import stdin,setrecursionlimit
#from scipy.sparse.csgraph import dijkstra
#from scipy.sparse import csr_matrix
ipt = stdin.readline
setrecursionlimit(10**7)
mod = 10**9+7
alp = "abcdefghijklmnopqrstuvwxyz"

def main():
    n,q = map(int,ipt().split())
#    n = 5*10**5
#    q = 5*10**5
#    c = [int(i)+1 for i in range(n)]
    c = [int(i) for i in ipt().split()]
    qi = []
    for i in range(q):
        l,r = map(int,ipt().split())
        qi.append(r*((10**6+1)**2)+l*(10**6+1)+i)

    qi.sort()

    ans = [0]*q
    ln = [-1]*(n+1)
    bq_al = [0]*(n+1)

    #Bit_Indexed_Tree
    #A1 ... AnのBIT(1-indexed)
    BIT = [0]*(n+1)

    #A1 ~ Aiまでの和 O(logN)
    def BIT_query(idx):
        res_sum = 0
        while idx > 0:
            res_sum += BIT[idx]
            idx -= idx&(-idx)
        return res_sum

    #Ai += x O(logN)
    def BIT_update(idx,x):
        while idx <= n:
            BIT[idx] += x
            idx += idx&(-idx)
        return

    pr = 0
    for ist in qi:
        i = ist%(10**6+1)
        l = (ist//(10**6+1))%(10**6+1)
        r = ist//(10**6+1)**2
        for j in range(pr,r):
            cj = c[j]
            ij = ln[cj]
            if ij != -1:
                BIT_update(ij,-1)
            ln[cj] = j+1
            BIT_update(j+1,1)
        pr = r

        ans[i] = BIT_query(r)-BIT_query(l-1)


    for i in ans:
        print(i)

    return None

if __name__ == '__main__':

    main()


Measured memory_bytes: 161240
#define _USE_MATH_DEFINES // M_PI
#include<cmath>
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define rREP(i,a,n) for(int (i)=(n)-1; (i)>=(a);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 2147483647;
constexpr ll mod = 1000000007;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N; cin >> N;
	vector<int>A(N);
	rep(i, N)cin >> A[i];
	int ans = 0;
	rep(i, N) {
		ans += A[i] - 1;
	}
	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n,j, a[200600], ans;
bool cond;
char c;
string s;
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> s;
    n = s.size();
    for(i=0;i<n;i++)
    {
        j = s[i]-'0';
        ans += j;
    }
    if(ans%9==0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3760
package main

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

var (
	read  = bufio.NewReader(os.Stdin)
	write = bufio.NewWriter(os.Stdout)
)

func min(a, b int) int {
	if a <= b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a >= b {
		return a
	}
	return b
}

func yesno(result bool) {
	if result {
		fmt.Fprintln(write, "Yes")
	} else {
		fmt.Fprintln(write, "No")
	}
}

func printansStr(result bool, a, b string) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func printansInt(result bool, a, b int) {
	if result {
		fmt.Fprintln(write, a)
	} else {
		fmt.Fprintln(write, b)
	}
}

func main() {
	defer write.Flush()

	var n, k int
	fmt.Fscan(read, &n, &k)

	cnt := 0
	for i := 0; i < n; i++ {
		var h int
		fmt.Fscan(read, &h)
		if h >= k {
			cnt++
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 2176
#include <stdio.h>

int main(){
	int N,count=0;
	char S[300001];
	scanf("%d",&N);
	scanf("%s",S);
	int min;
	for(int i=1;i<N;i++){
		if(S[i]=='E')count++;
	}
min=count;
	for(int i=1;i<N;i++){
		if(S[i]=='E')count--;
		if(S[i-1]=='W')count++;
		if(min>count)min=count;
	}

	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

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;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

string S;
ll com[100010];//0~i-1桁の組み合わせ
ll dp[100010];
vector<int>v;
ll func(int n) {
	if (dp[n] != 0) {
		return 0;
	}
	auto itr = lb(v, n);
	if (itr == v.begin()) {
		ll res = add(2, com[n]);
		return dp[n] = res;
	}
	else {
		itr--; 
		ll res = add(com[n], mult(2, func(*itr)));
		return dp[n] = res;
	}
}

signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	cin >> S;
	com[0] = 1;
	REP(i, 100009) {
		com[i + 1] = mult(com[i], 3);
	}
	int N = S.size();
	VREVERSE(S);
	REP(i, N) {
		if (S[i] == '1') {
			v.pb(i);
		}
	}
	VSORT(v);
	int M = v.size();
	ll ans = func(v[M - 1]);
	print(ans);

}


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

using namespace std;

int		main(void)
{
	int N, X;

	cin >> N >> X;
	int sum = 0;
	int i;

	for (i = 0; i < N; i++)
	{
		int L;

		cin >> L;
		sum += L;
		if (sum > X)
			break ;
	}
	cout << i + 1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
const int inf = INT_MAX;
const ll INF = 1LL >> 60;
const ll mod = 1e9+7;

int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];
    sort(h.begin(), h.end());
    ll ans = 1e9;
    rep(i, n-k+1){
        ll tmp = h[i+k-1]-h[i];
        chmin(ans, tmp);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int main(){
  vector<int> v;
  int n,a;
  cin>>n;
  rep(i,n){
    cin>>a;
    if(i%2==0)v.pb(a); //pb = push_back
    else v.insert(v.begin(),a);
  }
  if(n%2==1)reverse(all(v));
  rep(i,v.size())cout<<v[i]<<" ";
  cout<<endl;
}

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int i,j,flag,sum=0,sum1=0,cnt=0,ans,lo,mo,n,m;
    vector<long long int>vec;
    list<long long int>mylist;
    vector<long long int>::iterator it1;
    list<long long int>::iterator it2;
    cin>>n>>m;

    cout<<min(n%m,abs(n%m-m))<<endl;

}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
from math import floor, sqrt, factorial, hypot, log  # log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter, defaultdict, deque
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from copy import deepcopy
from fractions import gcd
from random import randint


def ceil(a, b): return (a + b - 1) // b


inf = float('inf')
mod = 10 ** 9 + 7


def pprint(*A):
    for a in A:     print(*a, sep='\n')


def INT_(n): return int(n) - 1


def MI(): return map(int, input().split())


def MF(): return map(float, input().split())


def MI_(): return map(INT_, input().split())


def LI(): return list(MI())


def LI_(): return [int(x) - 1 for x in input().split()]


def LF(): return list(MF())


def LIN(n: int): return [I() for _ in range(n)]


def LLIN(n: int): return [LI() for _ in range(n)]


def LLIN_(n: int): return [LI_() for _ in range(n)]


def LLI(): return [list(map(int, l.split())) for l in input()]


def I(): return int(input())


def F(): return float(input())


def ST(): return input().replace('\n', '')


def main():
    D = I()
    c = LI()
    s = LLIN(D)
    for i in range(D):
        l = s[i]
        print(l.index(max(l)) + 1)




if __name__ == '__main__':
    main()

Measured memory_bytes: 78376
/*
    飲んだ魔剤で家が建つ。
    created at: 2020-04-12 18:15:27
*/

#include <bits/stdc++.h>
using namespace std;

#define all(x) (x).begin(),(x).end()
#define rev(x) greater<x>()
#define MOD 1000000007
#define INF 1000000000

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

LL modpower(LL n, LL m, LL mod)
{
    if (m == 0) {
        return 1;
    } else if (m % 2 == 0) {
        LL p = modpower(n, m/2, mod);
        return p*p % mod;
    } else {
        return n*modpower(n, m-1, mod) % mod;
    }
}

LL modinv(LL n, LL mod)
{
    return modpower(n, mod-2, mod);
}

LL modcombination(LL n, LL r, LL mod)
{
    LL ret = 1;

    for (int i = 0; i < r; i++) {
        ret *= (n-i);
        ret %= mod;
        ret *= modinv(i+1, mod);
        ret % mod;
    }

    return ret % mod;
}

int gcd(int k, int l)
{
    if (l > 0) return gcd(l, k%l);
    else return k;
}

struct UnionFind
{
    vector<int> par;

    UnionFind(int n) : par(n) {
        for (int i = 0; i < n; i++) par[i] = i;
    }

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

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

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

    int n = s.length();
    for (int i = 0; i < n; i += 2) {
        cout << s[i];
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 512
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()
ll pw(ll x, ll y) { ll r = 1;  rep(i, y) { r *= x; }; return r; }


int main() {

	ll N, Q;
	cin >> N >> Q;
	string s;
	cin >> s;
	vll acc(N, 0);
	fori(i, 1, N) {
		if (s[i - 1] == 'A' && s[i] == 'C') acc[i] = acc[i - 1] + 1;
		else acc[i] = acc[i - 1];
	}


	rep(i, Q) {
		ll l, r;
		cin >> l >> r;
		l -= 1, r -= 1;
		cout << acc[r] - acc[l] << endl;
	}
}

Measured memory_bytes: 1792
H, W = map(int, input().split())

S = []
for _ in range(H):
	S.append([0 if x == '.' else x for x in list(input())])



dx = [-1, -1, 0, 1, 1, 1, 0, -1]
dy = [0, 1, 1, 1, 0, -1, -1, -1]

for i in range(H):
	for j in range(W):
		if S[i][j] == '#':
			for k in range(8):
				x = i + dx[k]
				y = j + dy[k]
				if x >= 0 and y >= 0 and x < H and y < W:
					if S[x][y] != '#':
						S[x][y] += 1

for i in range(H):
	for j in range(W):
		print(S[i][j],end='')
	print()

Measured memory_bytes: 44524
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for(int i = (s); i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
typedef long long ll;
const int INF = 1001001001;
const int mod = 1000000007;

int main() {
    int N;
    cin >> N;
    vector<vector<int>> o(N), cost(N);
    vector<int> ans(N, -1);
    ans[0] = 0;
    rep(i, N - 1) {
        int a, b, w;
        cin >> a >> b >> w;
        a--;
        b--;
        o[a].push_back(b);
        cost[a].push_back(w);
        o[b].push_back(a);
        cost[b].push_back(w);
    }
    queue<int> q;
    q.push(0);
    while(!q.empty()) {
        int v = q.front();
        q.pop();
        rep(i, o[v].size()) {
            int u = o[v][i];
            int w = cost[v][i];
            if(ans[u] != -1)
                continue;
            ans[u] = (ans[v] + w) % 2;
            q.push(u);
        }
    }
    for(int aa : ans) {
        cout << aa << endl;
    }
}

Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <cstdio>
#include <set>
#include <map>
#include <list>
#include <cstdlib>
#include <queue>
#include <stack>
#include <bitset>

using namespace std;

#define MOD 1000000007
#define PI 3.1415926535897932
#define rep(i, n) for (int i = 0; i < n; i++)
#define repe(i, j, n) for (int i = j; i < n; i++)
#define repi(i, n) for (int i = 0; i <= n; i++)
#define repie(i, j, n) for (int i = j; i <= n; i++)
#define all(x) x.begin(), x.end()
#define println() cout << endl
#define P pair<int, int>
#define fi first
#define se second

typedef long long ll;

long long modinv(long long a, long long m)
{
    long long b = m, u = 1, v = 0;
    while (b)
    {
        long long t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0)
        u += m;
    return u;
}



void solve1()
{
    string s; cin >> s;
    string ans = s;
    if(s[s.size()-1] != 's') {
        ans +=  "s";
    } else {
        ans += "es";
    }

    cout << ans << endl;
}

int main()
{
    solve1();
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <math.h>
#include <utility>
#define INF 0x7FFFFFFF

using namespace std;

int main(void){
	int w, h, minh, minc, i, j;
	pair<int,int> ans;
	while(1){
		scanf("%d%d",&h,&w);
		if(h == 0 && w == 0)
			break;
		minh = minc = INF;
		for(i = 1;i <= 150;i++){
			for(j = i + 1;j <= 150;j++){ // 入力値以上 答えはより小さく
				if(!(i == h && j == w) && (i * i + j * j > h * h + w * w || (i * i + j * j == h * h + w * w && i > h)) && ((i * i + j * j == minc && minh > i) || i * i + j * j < minc)){
					minh = i;
					minc = i * i + j * j;
					ans = pair<int,int>(i,j);
				}
			}
		}
		printf("%d %d\n",ans.first,ans.second);
	}
	return 0;
}

Measured memory_bytes: 1028
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(){

  int a, b, c, d, e, f, g, h, i, j, k, l, m, n;
  int N[100];

  scanf("%d %d %d %d", &a, &b, &c, &d);
  i = c - a;
  j = d - b;
  k = -j;
  l = i;
  m = -i;
  n = -j;
    e = c + k;
    f = d + l;
    g = e + m;
    h = f + n;
  printf("%d %d %d %d\n", e, f, g, h);

  return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ITP1_4D
{
    class Program
    {
        //static void Main(string[] args)
        //{
        //    string inputText = Console.ReadLine();
        //    int n = int.Parse(inputText);

        //    inputText = Console.ReadLine();
        //    string[] words = inputText.Split(' ');

        //    if (words.Length < n)
        //    {
        //        return;
        //    }

        //    int[] intArray = new int[n];
        //    for (int i = 0; i < n; ++i)
        //    {
        //        intArray[i] = int.Parse(words[i]);
        //    }

        //    int minIndex = 0;
        //    int maxIndex = 0;
        //    long sum = 0;
        //    for (int i = 0; i < intArray.Length; ++i)
        //    {
        //        sum += intArray[i];
        //        if (intArray[i] < intArray[minIndex])
        //        {
        //            minIndex = i;
        //        }
        //        if (intArray[maxIndex] < intArray[i])
        //        {
        //            maxIndex = i;
        //        }
        //    }

        //    Console.WriteLine("{0} {1} {2}", intArray[minIndex], intArray[maxIndex], sum);
        //}

        static void Main(string[] args)
        {
            var text = Console.ReadLine();
            var count = int.Parse(text);

            text = Console.ReadLine();
            var min = int.MaxValue;
            var max = int.MinValue;
            var sum = 0L;

            var words = text.Split(' ');
            for (var i = 0; i < count; ++i)
            {
                var value = int.Parse(words[i]);
                min = value < min ? value : min;
                max = max < value ? value : max;
                sum += value;
            }

            Console.WriteLine("{0} {1} {2}", min, max, sum);
        }
    }
}

Measured memory_bytes: 19880
def input_li():
    return list(map(int, input().split()))

def input_int():
    return int(input())

H, W = input_li()
board = [input() for _ in range(H)]
# dp[x][y] ... マス(x, y)時点で実行した操作の最小回数
dp = [[10 ** 9] * W for _ in range(H)]
dp[0][0] = 1 if board[0][0] == '#' else 0
for h in range(H):
    for w in range(W):
        is_now_black = board[h][w] == '#'
        if h == 0 and w != 0:
            dp[h][w] = dp[h][w - 1] + (1 if is_now_black and board[h][w - 1] == '.' else 0)
        elif h != 0 and w == 0:
            dp[h][w] = dp[h - 1][w] + (1 if is_now_black and board[h - 1][w] == '.' else 0)
        elif h != 0 and w != 0:
            from_w = dp[h][w - 1] + (1 if is_now_black and board[h][w - 1] == '.' else 0)
            from_h = dp[h - 1][w] + (1 if is_now_black and board[h - 1][w] == '.' else 0)
            dp[h][w] = min(from_h, from_w)
print(dp[-1][-1])


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

typedef pair<int, int> pii;
typedef long long ll;
template<class T> using V = vector<T>;
template<class T> using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()
#define dump(x) cerr << #x << " = " << (x) << endl
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

template<class T, class U> void chmin(T& t, const U& u) { if (t > u) t = u; }
template<class T, class U> void chmax(T& t, const U& u) { if (t < u) t = u; }

template<class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os<<"("<<p.first<<","<<p.second<<")";
	return os;
}

template<class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os<<"{";
	rep(i, v.size()) {
		if (i) os<<",";
		os<<v[i];
	}
	os<<"}";
	return os;
}

const int maxn = 2010;

V<int> g[maxn];
bool one[maxn];
int a[maxn], dep[maxn];

int dfs(int v, int d) {
	int num = 0;
	dep[v] = d;
	for (int to : g[v]) {
		int res = dfs(to, d + 1);
		num += res; 
	}
	if (num == 0 && a[v] != v) ++num;
	if (num == 1) one[v] = 1;
	return num;
}

int main() {
	int N; cin >> N;
	V<int> p(N, -1);

	for (int i = 1; i < N; ++i) {
		cin >> p[i];
		g[p[i]].pb(i);
	}

	rep(i, N) cin >> a[i];

	V<int> ope;

	auto rot = [&](int v) {
		ope.pb(v);
		V<int> vec;
		while (v != -1) {
			vec.pb(v);
			v = p[v];
		}
		reverse(ALL(vec));
		int sz = vec.size();

		int x = a[0];
		rep(i, sz-1) {
			a[vec[i]] = a[vec[i+1]];
		}
		a[vec.back()] = x;

		reverse(ALL(vec));
		for (int v : vec) {
			bool t = (a[v] != v);
			for (auto to : g[v]) {
				if (one[to]) t = 1;
			}
			if (!t) {
				one[v] = 0;
			}
		}
	};

	while (true) {
		bool ok = 1;
		rep(i, N) if (i != a[i]) ok = 0;
		if (ok) {
			break;
		}

		memset(one, 0, sizeof(one));
		dfs(0, 0);

		V<int> cmp(N, -1);
		V<int> la(N, -1);
		{
			V<int> cand(N, 1);
			rep(i, N) cand[i] = one[i];
			rep(i, N) if (one[i] && p[i] != -1) cand[p[i]] = 0;
			int now = 0;
			rep(i, N) if (cand[i]) {
				int v = i;
				la[now] = v;
				while (v != -1 && one[v]) {
					cmp[v] = now;
					v = p[v];
				}
				now++;
			}
		}

		V<int> used(N, -1);
		rep(i, N) if (one[i]) used[a[i]] = 0;

		while (true) {
			{
				bool en = 1;
				rep(i, N) if (one[i]) {
					en = 0;
				}
				if (en) break;
			}
			int x = a[0];
			if (used[x] == 1) break;
			if (one[x]) {
				int v = la[cmp[x]];
				dump(v);
				while (v != -1) {
					int av = a[v];
					if (used[av] != 1 || (cmp[av] != cmp[x] || cmp[av] == cmp[x] && dep[av] < dep[x])) {
						used[x] = 1;
						rot(v);
						break;
					}
					v = p[v];
				}
			} else {
				int mdep = -1, cand = -1;
				rep(i, N) {
					int x = a[i];
					if (one[x] && used[x] != 1) {
						if (mdep < dep[i]) {
							mdep = dep[i];
							cand = i;
						}
					}
				}
				if (cand == -1) break;
				rot(cand);
			}
		}
 	}

 	cout << ope.size() << endl;
 	for (int x : ope) {
 		cout << x << endl;
 	}

	return 0;
}

Measured memory_bytes: 640