akhauriyash/Code-Regression huggingface dataset:
def divide_the_problems(n, dli):

    dli.sort()

    n = int(n/2)
    ans = dli[n] - dli[n-1]

    return ans

def main():
    n = int(input())
    dli = list(map(int, input().split()))
    print(divide_the_problems(n, dli))

if __name__ == '__main__':
    main()

Measured memory_bytes: 13992
a=int(input())
b=int(input())
c=int(input())
x=int(input())

cnt=0
for a in range(0,a+1):
    for b in range(0,b+1):
        for c in range(0,c+1):
            if a*500+b*100+c*50==x:
                cnt+=1
print(cnt)


Measured memory_bytes: 3060
# -*- coding: utf-8 -*-
d, g = map(int,input().split())
p = [list(map(int, input().split())) for _ in range(d)]
# 点数の大きい順にソート
p.reverse()

ans = float('inf')

for i in range(1 << d):
    total = 0
    count = 0
    # ボーナスあり
    for j in range(d):
        if (i >> j) & 1:
            total += 100*(d-j)*p[j][0] + p[j][1]
            count += p[j][0]
    if total >= g:
        ans = min(ans, count)
        continue
    # ボーナスなし
    for j in range(d):
        if not (i >> j) & 1:
            for k in range(p[j][0]):
                total += 100*(d-j)
                count += 1
                if total >= g:
                    ans = min(ans, count)
                    break
            break

print(ans)


Measured memory_bytes: 9184
import sys
input = sys.stdin.readline
from math import sqrt
from itertools import combinations

N = int(input())
xy = [[int(i) for i in input().split()] for _ in range(N)]
E = 1e-9

def vnrm(v) :
  d = sqrt(v[0]*v[0] + v[1]*v[1] + v[2]*v[2])
  for i in range(3) :
    v[i] /= d

  return d

def vrot90(v) :
  v0 = v[0]
  v[0] = -v[1]
  v[1] =  v0

def calc(x1, y1, x2, y2, x3, y3) :
  c = [0] * 3
  v123 = (x2-x1)*(x3-x2) + (y2-y1)*(y3-y2)
  v231 = (x3-x2)*(x1-x3) + (y3-y2)*(y1-y3)
  v312 = (x1-x3)*(x2-x1) + (y1-y3)*(y2-y1)

  if v123 < 0 and v231 < 0 and v312 < 0 :
    x12 = (x1+x2)/2
    y12 = (y1+y2)/2
    v12 = [x2-x1, y2-y1, 0.]
    vnrm(v12)
    vrot90(v12)
    x13 = (x1+x3)/2
    y13 = (y1+y3)/2
    v13 = [x3-x1, y3-y1, 0.]
    vnrm(v13)
    vrot90(v13)
    d = -(v12[0]*v13[1] - v12[1]*v13[0])
    ds = -(x13-x12)*v13[1] + (y13-y12)*v13[0]
    s = ds/d
    c[0] = x12 + s*v12[0]
    c[1] = y12 + s*v12[1]
    c[2] = sqrt((x1-c[0])*(x1-c[0]) + (y1-c[1])*(y1-c[1]))
  
  else :
    if v123 >= 0 :
      c[0] = (x1+x3)/2
      c[1] = (y1+y3)/2
      c[2] = sqrt((x1-x3)*(x1-x3) + (y1-y3)*(y1-y3))/2
    elif v231 >= 0 :
      c[0] = (x1+x2)/2
      c[1] = (y1+y2)/2
      c[2] = sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2))/2
    else :
      c[0] = (x2+x3)/2
      c[1] = (y2+y3)/2
      c[2] = sqrt((x2-x3)*(x2-x3) + (y2-y3)*(y2-y3))/2

  return c

ret = float('inf')
for (i, j, k) in combinations(range(N), 3) :
  cx, cy, cr = calc(xy[i][0], xy[i][1], xy[j][0], xy[j][1], xy[k][0], xy[k][1])
  for x, y in xy :
    if sqrt((cx - x) ** 2 + (cy - y) ** 2) > cr + E :
      break
  else :
    ret = min(ret, cr)
    
if N == 2 :
  r = sqrt((xy[0][0] - xy[1][0]) ** 2 + (xy[0][1] - xy[1][1]) ** 2)
  print(r / 2)

else :
  print(ret)

Measured memory_bytes: 58732
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll M=1000000007;
ll beki(ll n){
  if(n==0)return 1;
  return (2*beki(n-1))%M;
}
int main(){
  ll n;cin>>n;
  ll c[n];
  for(ll i=0;i<n;i++)c[i]=0;
  ll a[n];for(ll i=0;i<n;i++){
    cin>>a[i];
    c[a[i]]++;
  }
  if(n%2==1){
    ll j=0;
    if(c[0]!=1)j=1;
    for(ll i=2;i<n;i+=2){
      if(c[i]!=2){
        j=1;
        break;
      }
    }
    if(j==1){
      cout<<0<<endl;
      return 0;
    }
    else {
      cout<<beki((n-1)/2)<<endl;
      return 0;
    }
  }
  else{
    ll j=0;
    for(ll i=1;i<n;i+=2){
      if(c[i]!=2){
        j=1;
        break;
      }
    }
    if(j==1){
      cout<<0<<endl;
      return 0;
    }
    else{
      cout<<beki(n/2)<<endl;
      return 0;
    }
  }
}

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

int main(){
    int d,n,a;
    double f;
    int i;
    long long x,y;
    //double a,b;
    int count = 0;
    scanf("%d",&n);
    scanf("%d",&d);
    for(i=0; i < n;i++){
        scanf("%lld",&x);
        scanf("%lld",&y);
        //a=pow(x,2);
        //b=pow(y,2);
        f=sqrt((pow(x,2)+pow(y,2)));
        if(f <= d){
            count+=1;
        }        
    }
    printf("%d\n",count);

    return EXIT_SUCCESS;
}


Measured memory_bytes: 2116
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

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;
}
ll kaijo(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll yakusu_num(ll n){
  vl yakusu(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      yakusu[i]++;
    }
  }
  if(n!=1)yakusu[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=yakusu[i];
  }
  return num;
}

int H,W;
vs s(50);
vi dv ={-1,0,1,0};vi du={0,-1,0,1};
int cnt=1;
int dfs(int u,int v){
  s[u][v]='.';
  
  rep(i,4){
   
      int nu =u +du[i],nv=v+dv[i];
      if(nu<0||nu>=H||nv<0||nv>=W)continue;
      if(s[nu][nv]=='.')continue;
      cnt ++;
      dfs(nu,nv);
    
  }
  return cnt;

}

//vc alp(26) ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//cout<<""<<endl;
int main(){
  ll N;cin>>N; vc S(N);rep(i,N)cin>>S[i]; 
  bool bp =false ,bw=false,bg=false,by=false;
  rep(i,N){
    if(S[i]=='P')bp =true;
    if(S[i]=='W')bw =true;
    if(S[i]=='G')bg=true;
    if(S[i]=='Y')by=true;
    
  }
  if(bp&&bw&&bg&&by)cout<<"Four"<<endl;
  else cout<<"Three"<<endl;
  
}







Measured memory_bytes: 256
#coding:utf-8
import sys,os
from collections import defaultdict, deque
from fractions import gcd
from math import ceil, floor
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    N,K = LMIIS()
    #1がひとつでもある：gcd(A) ==1
    #1を含む数列のパターン数：K**N - (K-1)**N

    #最低が2,全部偶数：gcd(A) == 2
    #そのような数列のパターン数p2：(K//2)**N - (K//2-1)**N

    #最低が3,全部3の倍数：gcd(A) == 3
    #p3:(K//3)**N - (K//3-1)**N



    #1<=d<=K
    #gcd(A)==dとなるようなパターン数：(K//D)**N-(K//D*2)**N-...
    ans = 0
    P = {}
    for i in range(K,0,-1):
        t = 2
        p = pow((K//i),N,MOD)
        while i*t<=K:
            p -= P[t*i]
            t += 1
        P[i] = p
        ans += p*i
        ans %= MOD
    print(ans)





    # ans = 0
    # notgcd1 = 0 
    # for i in range(1,K+1):
    #     p = pow((K//i),N,MOD) - pow((K//i-1),N,MOD)
    #     notgcd1 += pow((K//i),N,MOD) - p
    #     notgcd1 %= MOD
    #     ans += p*i
    #     ans %= MOD
    # ans += pow(K,N,MOD)-notgcd1
    # ans %= MOD
    # print(ans)



if __name__ == '__main__':
    main()

Measured memory_bytes: 87616
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
	public static void main(String[] args){
		FastScanner sc = new FastScanner();
		String s = sc.nextToken();

		System.out.println(s.indexOf("AC") != -1 ? "Yes" : "No");
	}

	public static class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(String s) {
			try {
				br = new BufferedReader(new FileReader(s));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String nextToken() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(nextToken());
		}

		long nextLong() {
			return Long.parseLong(nextToken());
		}

		double nextDouble() {
			return Double.parseDouble(nextToken());
		}
	}
}

Measured memory_bytes: 21332
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<vector>
#include<queue>
#include<set>
#include<algorithm>
#define INF 0x3f3f3f3f
#define mod 1000000009
#define e  2.718281828459045
#define eps 1.0e18
#define PI acos(-1)
#define lowbit(x) (x&(-x))
#define memset(x,y) memset(x,y,sizeof(x))
#define lson i << 1,l,m
#define rson i << 1 | 1,m + 1,r
#define ll long long
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	ll n,k;
	cin>>n>>k;
	if(n<10){
		cout<<k+(10-n)*100;
	} 
	else cout<<k<<endl;
	return 0;
}


Measured memory_bytes: 256
//Zory-2018
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<stack>
using namespace std;

namespace mine
{
	const int MAX_N=60;
	const int INF=0x3f3f3f3f;
	typedef long long ll;

	struct LJB
	{
		int hou[MAX_N];
		struct Edge{int y,g;}e[MAX_N];
		int ln;void ins(int x,int y) {e[++ln]=(Edge){y,hou[x]};hou[x]=ln;}
		LJB() {ln=0;memset(hou,0,sizeof hou);}
	}E;

	struct Nod
	{
		ll w,v;
		ll num;
	}p[MAX_N];
	bool cmp(Nod a,Nod b) {return a.w*b.v>b.w*a.v;}
	//规避除法，已知都是非负数

	void dfs(int x,int fa)
	{
		p[x].w=1;
		for(int k=E.hou[x];k>0;k=E.e[k].g)
		{
			int y=E.e[k].y;if(y==fa) continue;
			dfs(y,x);
			p[x].w+=p[y].w;p[x].v+=p[y].v;
		}
	}

	ll f[MAX_N*MAX_N*MAX_N];
	void main()
	{
		int n;ll mxV,D;scanf("%d%d%d",&n,&mxV,&D);
		scanf("%lld",&p[1].v);
		for(int i=2;i<=n;i++)
		{
			int fa;scanf("%lld%d",&p[i].v,&fa);
			E.ins(fa,i);
		}
		dfs(1,0);

		memset(f,63,sizeof f);f[0]=0;
		for(int i=1;i<=n;i++)
		{
			ll num=mxV/p[i].v;
			if(i>1) num=min(num,(ll)D);

			if(num>n) p[i].num=num-n,num=n;
			else p[i].num=0;

			ll now=1;
			while(num>0)
			{
				ll w=now*p[i].w,v=now*p[i].v;
				for(int ww=n*n*n;(ll)ww>=w;ww--) f[ww]=min(f[ww],f[ww-w]+v);
				num-=now;
				now=min(now<<1,num);
			}
		}

		sort(p+1,p+n+1,cmp);
		ll ans=0;
		for(int ww=0;ww<=n*n*n;ww++)
		{
			if(f[ww]>mxV) continue;
			ll ret=ww,left=mxV-f[ww];
			for(int i=1;i<=n;i++)//debug 注意此时不是原编号
			{
				ll num=min(left/p[i].v,p[i].num);
				left-=num*p[i].v;ret+=num*p[i].w;
			}
			ans=max(ans,ret);
		}
		printf("%lld",ans);
	}
};

int main()
{
	mine::main();
}


Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
int ar[100003];
int main() {
	long long int i=1,ev,k,od,j,n;
	scanf("%lld",&n);
	n=n-1;
  	if(n%2==0){
  		ev=n;
  		od=n+1;
  	}
  	else{
  		od=n;
  		ev=n+1;
  	}
    j=od*(ev/2);
	cout<<j<<'\n';
	return 0;
}

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

using namespace std;
#define sqr(x) ((x)*(x))
#define cube(x) ((x)*(x)*(x))
#define GCD(a, b) __gcd(a, b)
#define LCM(a, b) ((a)*(b)/GCD(a,b))
#define PI (3.141592653589793238462643383279502884197169399375105820974944)
#define MP make_pair
#define n1 first
#define n2 second
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define PDB pair<db,db>
#define SI set<int>
#define SL set<ll>
#define MS multiset
#define MSI multiset<int>
#define MSLL multiset<ll>
#define PB push_back
#define PF push_front
#define VI vector<int>
#define VPI vector<pair<int,int>>
#define VLL vector<ll>
#define VS vector<string>
#define SZ(x) ((int)x.size())

typedef long long ll;

typedef unsigned long long ull;
typedef long double ld;
typedef double db;
const int INF = 1000000007;
const ll LINF = 1000000000000000555;
const int N = 650555;
const int L = 21;
const int M = 2155;
const int K = 555;

void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;

    set <int> R,G,B;
    for (int i = 0; i < n; i++){
        if (s[i] == 'R') R.insert(i+1);
        if (s[i] == 'G') G.insert(i+1);
        if (s[i] == 'B') B.insert(i+1);
    }

    ll sum = 0;
    for (auto x : R){
        for (auto y : G){
            int cnt = SZ(B);
            if (x > y){
                int a = x-y;
                if (B.count(x+a)) cnt--;
                if (B.count(y-a)) cnt--;
            }
            if (x < y){
                int a = y-x;
                if (B.count(y+a)) cnt--;
                if (B.count(x-a)) cnt--;
            }
            if ((x+y) % 2 == 0 && B.count((x+y)/2)) cnt--;
            sum += max(0, cnt);
        }
    }

    cout << sum;

}

int main() {
    ios_base::sync_with_stdio(false);
#ifdef dxz05
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else

#endif

    int T = 1;
    //cin >> T;

    while (T--) {
        solve();
    }

    return 0;
}

Measured memory_bytes: 3808
#include<bits/stdc++.h>
#define X first
#define Y second
#define pb emplace_back
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define EFOR(i,a,b) for(int (i)=(a);i<=(b);++(i))
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define REP rep
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define all(X) (X).begin(),(X).end()
#define eb emplace_back

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef ll LL;
typedef pii PII;
typedef pll PLL;
const ll MOD=1e9+7;

#define rall(X) (X).rbegin(),(X).rend()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rreps(X,S,Y) for (int (X) = (Y)-1;(X) >= (S);--(X))
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}

int N, K;

signed main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  cin >> N >> K;
  if (K == 1) cout << "0\n";
  else cout << N-K << endl;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

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

    vector<int> A(N + 1);
   for(int i = 1; i <= N;i++) {
       cin >> A.at(i);
   }

   int sum = 0,i = 0,button = A.at(1);
   while(i < N) {

       if(button == 2) {
           cout << ++sum << endl;
           return 0;
       }

       sum++;

       button = A.at(button);
       i++;
   }

   cout << -1 << endl;
   return 0;

}



Measured memory_bytes: 640
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


target = list(map(int, list(input())[:-1]))
k = inp()
# dp[digits][notzeros][smaller]
# dp[digits+1][notzeros][smaller]上からi桁目までで条件を満たす数の総数

dp = [[[0] * 2 for _ in range(k + 2)] for i in range(len(target) + 1)]
dp[0][0][0] = 1
for i in range(len(target)):
    for j in range(k + 1):
        for smaller in range(2):
            for x in range(10 if smaller else target[i] + 1):  # 未満なら10進数全て探索
                conditions = 1 if x != 0 else 0  # 条件

                dp[i + 1][j + conditions][smaller or x < target[i]]\
                    += dp[i][j][smaller]
    # print(dp)

ans = sum(dp[len(target)][k])
print(ans)
# print(dp)


Measured memory_bytes: 40944
# ABC139c
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

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

ans = 0
count = 0

for i in range(1, n):
    if (h[i] <= h[i - 1]):
        count += 1
    else:
        ans = max(count, ans)
        count = 0
ans = max(count, ans)
print(ans)

Measured memory_bytes: 14252
N,K=map(int,input().split())
A=list(map(int,input().split()))
def f(L):
    res=0
    for x in A:
        res+=(x-1)//L
    return res
l=0
r=max(A)
while r-l>1:
    M=(r+l)//2
    if f(M)>K:
        l=M
    else:
        r=M
print(r)


Measured memory_bytes: 93900
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  string s;
  cin >> s;
  if(s == "zyxwvutsrqponmlkjihgfedcba") {
    cout << -1 << endl;
  } else if(s.size() < 26) {
    vb b(26, false);
    rep(i, s.size()) b[s[i] - 'a'] = true;
    char c;
    rep(i, 26) {
      if(!b[i]) {
        c = i + 'a';
        break;
      }
    }
    cout << s + c << endl;
  } else {
    string t = s;
    ll i = 0;
    do {
      if(i == 1) {
        rep(i, s.size()) {
          cout << t[i];
          if(s[i] != t[i]) break;
        }
        cout << endl;
        return 0;
      }
      i++;
    } while(next_permutation(all(t)));
  }
}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()

void YN(bool flg){if(flg) cout << "YES" << endl; else cout << "NO" << endl;}
void Yn(bool flg){if(flg) cout << "Yes" << endl; else cout << "No" << endl;}
void yn(bool flg){if(flg) cout << "yes" << endl; else cout << "no" << endl;}

int main()
{
    int n;
    cin >> n;
    vll cnt(100005);
    rep(i, n) {
        int a;
        cin >> a;
        cnt[a]++;
    }
    ll sum = 0;
    rep(i, 100005) sum += i*cnt[i];

    int q;
    cin >> q;
    rep(i, q) {
        ll b, c;
        cin >> b >> c;
        if(cnt[b] != 0) {
            sum += (c-b)*cnt[b];
            cnt[c] += cnt[b];
            cnt[b] = 0;
        }
        cout << sum << endl;
    } 

    return 0;
}


Measured memory_bytes: 3976
x = int(input())
y = x
a = []
while y:
    a.append(y%10)
    y = y//10
if len(a)<=3:
    print(abs(x-753))
else:
    ans = 1000000
    ll = len(a)
    for i in  range(0,ll-2):
        ans=min(ans,abs(a[i]+a[i+1]*10+a[i+2]*100-753))
        #print(a[i]*100+a[i+1]*10+a[i+2])
    print(ans)

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

int main(){
    int n,m;cin>>n>>m;
    int sum=0;
    for(int i=0;i<m;i++){
        int a;cin>>a;
        sum+=a;
    }
    n-=sum;
    cout<<max(n,-1)<<endl;
}

Measured memory_bytes: 3660
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>

int main() {
	int X, Y; std::cin >> X >> Y;
	for (auto i{ 0 }; i <= X; ++i) {
		int ans = ((X - i) * 2) + (4 * i);
		if (ans == Y) {
			std::cout << "Yes" << std::endl;
			return 0;
		}
	}
	std::cout << "No" << std::endl;
	return 0;
}

Measured memory_bytes: 3580
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			String str1 = br.readLine();
			String str2 = br.readLine();
			if(str1.length() > str2.length()) {
				System.out.println("GREATER");
			}else if(str1.length() < str2.length()) {
				System.out.println("LESS");
			}else {
				for(int i = 0;i < str1.length();i++) {
					if(str1.charAt(i) > str2.charAt(i)) {
						System.out.println("GREATER");
						break;
					}else if(str1.charAt(i) < str2.charAt(i)) {
						System.out.println("LESS");
						break;
					}

					if(i == str1.length()-1) {
						System.out.println("EQUAL");
					}
				}
			}
//			long max  = 1000000007;
		}catch (Exception e) {
			System.exit(0);
		}
	}
}


Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define LL long long int
#define FAST ios_base::sync_with_stdio(false);
#define INPT cin.tie(NULL);
#define OUTPT cout.tie(NULL);
#define fori(i,a,b) for(i=a;i<b;i++)
#define forireverse(i,a,b) for(i=a;i>=b;i--)
#define full(x) x.begin(),x.end()
#define sortV(x) sort(full(x))
#define sortVgr(x) sort(full(x),greater<LL>()) // x -> vector
#define reverse(x) reverse(full(x)) // x -> string
#define go(t) while(t--)
#define endl cout<<"\n"
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define mp make_pair
#define M 1e9+7

LL gcd(LL a, LL b)
{
	if(a==0) return b;
	else return gcd(b%a,a);
}

int main()
{
	/*#ifndef ONLINE_JUDGE
	freopen("inputAtC.txt","r",stdin);
	freopen("outputAtC.txt","w",stdout);
	#endif*/
	FAST INPT OUTPT
	LL t=1;
	//cin>>t;
	go(t)
	{
		LL n,x,p,sum=0;
		cin>>n>>x>>p;
		while(n>0)
		{
			sum+=p;
			n-=x;
		}
		cout<<sum;
	}
	return 0;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    int n, a, b;
    scanf("%d%d%d", &n, &a, &b);
    if((a%2==0 && b%2==0) || (a%2!=0 && b%2!=0)){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"container/heap"
	"fmt"
	"os"
	"strconv"
)

type IntHeap []int

func (h IntHeap) Len() int           { return len(h) }
func (h IntHeap) Less(i, j int) bool { return h[i] < h[j] }
func (h IntHeap) Swap(i, j int)      { h[i], h[j] = h[j], h[i] }

func (h *IntHeap) Push(x interface{}) {
	*h = append(*h, x.(int))
}

func (h *IntHeap) Pop() interface{} {
	old := *h
	n := len(old)
	x := old[n-1]
	*h = old[0 : n-1]
	return x
}

func main() {
	n := readInt()
	m := readInt()

	jobs := map[int][]int{}
	for i := 0; i < n; i++ {
		a := readInt()
		b := readInt()
		jobs[a] = append(jobs[a], b)
	}

	result := 0
	candidates := &IntHeap{}
	heap.Init(candidates)
	for i := 1; i < m+1; i++ {
		_, ok := jobs[i]
		if ok {
			for _, j := range jobs[i] {
				heap.Push(candidates, -j)
			}
		} else {
			if candidates.Len() == 0 {
				continue
			}
		}
		result += -heap.Pop(candidates).(int)
	}
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 13056
n = int(input())
a = 0
b = 0
c = 0
d = 0
for i in range(n):
  s = input()
  if s == "AC":
    a = a + 1
  elif s == "WA":
    b = b + 1
  elif s == "TLE":
    c = c + 1
  else:
    d = d + 1
print("AC x " + str(a))
print("WA x " + str(b))
print("TLE x " + str(c))
print("RE x " + str(d))


Measured memory_bytes: 9024
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n,m;
  cin >> n >> m;
  if(n%m) pr(1);
  else pr(0);

}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 892
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	n <- readInt
	as <- readInts
	bs <- readInts
	print $ maximum $ solve ( sum bs ) as bs 

solve s [] [] = [s]
solve s (a:as) (b:bs) = s + a : solve ( s + a - b ) as bs


Measured memory_bytes: 1020
#include<iostream>
#include<algorithm>
#include<map>
#include<vector>
using namespace std;
typedef pair<int, int> P;
int main(){
    int n, p, d1, d2;
    while(cin >> n, n){
	vector<P> patient;
	for(int i = 0;i < n;i++){
	    cin >> p >> d1 >> d2;
	    patient.push_back(P(d1 + d2, p));
	}
	sort(patient.begin(), patient.end());
	cout << patient[n - 1].second << " " << patient[n - 1].first << endl;
    }
    return 0;
}

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

int main(){
	int a[5];
	for(int i=0;i<5;i++){
		cin>>a[i];
		}
		
		for(int i=0;i<5;i++){
			if(a[i]<40)
			a[i]=40;
			}
			int f=a[0]+a[1]+a[2]+a[3]+a[4];
				cout<<f/5<<endl;
	return 0;
	}

Measured memory_bytes: 3092
import sys;input=sys.stdin.readline
mod = pow(10, 9) + 7
sys.setrecursionlimit(pow(10, 8))
def mul(a, b):
    return ((a % mod) * (b % mod)) % mod
def div(a, b):
    return mul(a, modinv(b))
def modinv(a):
    b, u, v = mod, 1, 0
    while b:
        t = a//b
        a, u = a-t*b, u-t*v
        a, b, u, v = b, a, v, u
    u %= mod
    return u
def cmb(n, r):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod
NNN = (2*10**5)
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range( 2, NNN + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

N, = map(int, input().split())
d = [list() for _ in range(N+1)]
for _ in range(N-1):
    a, b = map(int, input().split())
    d[a].append(b)
    d[b].append(a)

vs = set([1])
stack = [1]
vs_bfs = list()
parents = [0] * (N+1)
while stack:
    v = stack.pop()
    vs_bfs.append(v)
    for u in d[v]:
        if u in vs:
            continue
        parents[u] = v
        vs.add(u)
        stack.append(u)

dp1 = [0 for _ in range(N+1)]
sss = [0 for _ in range(N+1)]
for v in vs_bfs[::-1]:
    t = 1
    ts = []
    for u in d[v]:
        if u == parents[v]:
            continue
        t = mul(dp1[u], t)
        ts.append(sss[u])
    st = sum(ts)
    sss[v] = st + 1
    for tt in ts:
        t = mul(cmb(st, tt), t)
        st -= tt
    dp1[v] = t

for v in vs_bfs:
    if v == 1:
        continue
    p = parents[v]
    dp1[v] = mul(
            mul(dp1[p], sss[v]),
            inverse[N-sss[v]]
            )

for x in dp1[1:]:
    print(x)


Measured memory_bytes: 131076
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll  long long
#define PR  pair<int, int>

const int N = 3e5 + 10;
const int MOD = 1e9 + 7;
const long long INF = 5e18;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, nulong long_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

PR a[N], b[N];
vector<int> g[N];
map<int, int> cnt;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> a[i].first >> a[i].second;
    }
    for (int i = 1; i <= n; i++) {
        cin >> b[i].first >> b[i].second;
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (a[i].first < b[j].first && a[i].second < b[j].second) {
                g[i].push_back(n + j);
                cnt[n + j]++;
            }
        }
    }
    vector<int> go;
    for (int i = 1; i <= n; i++) {
        go.push_back(i);
        sort(g[i].begin(), g[i].end(), [](int &x, int &y) {
            return cnt[x] < cnt[y];
        });
    }
    sort(go.begin(), go.end(), [](int &x, int &y) {
        return g[x].size() < g[y].size();
    });
    int ans = 0;
    map<int, int> vis;
    for (auto i : go) {
        for (auto v : g[i]) {
            if (vis[v] == 0) {
                ans++;
                vis[v] = 1;
                break;
            }
        }
    }
    cout << ans << '\n';
    return 0;
}


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

using namespace std;

int arr[105];
int n;

void InsertionSort(int *arr,int n)
{
    int cost = 0;
    for(int i=1; i<n; i++)
    {
        int key = arr[i];
        int j = i-1;
        while(j>=0 && arr[j]>key)
        {
            cost++;
            arr[j+1] = arr[j--];
        }
        arr[j+1] = key;
    }
}


int main()
{
  cin >> n;
  for(int i = 0; i < n; i++) {
    cin >> arr[i];
  }
  int t = n;
  int cost = 0;
  cout << arr[0];
  for(int i = 1; i < n; i++) {
    cout << " "<< arr[i];
  }
  cout << endl;
  for(int i=1; i<n; i++)
  {
    int key = arr[i];
    int j = i-1;
    while(j>=0 && arr[j]>key)
    {
      cost++;
      arr[j+1] = arr[j--];
      //cout << arr[j] << " ";
    }
    arr[j+1] = key;
    cout << arr[0];
    for(int k = 1; k < t; k++) {
      cout << " "<< arr[k];
    }
    cout << endl;
  }
  return 0;
}



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

namespace ConsoleApp3 {
    class Program {
        static void Main(string[] args) {
            string s = Console.ReadLine();

            var X = s.Split(' ').Select(a => int.Parse(a)).ToArray();

            int A = X[0];
            int P = X[1];

            int sum = 3 * A + P;

            Console.WriteLine(sum / 2);
        }
    }
}


Measured memory_bytes: 13268
import sys
input = sys.stdin.readline
from collections import *

def bfs():
    q = deque([0])
    dist = [-1]*n
    dist[0] = 0
    a = [-1]*n
    a[0] = 0
    
    while q:
        v = q.popleft()
        
        for nv, w in G[v]:
            if dist[nv]==-1:
                dist[nv] = dist[v]+1
                a[nv] = w-a[v]
                q.append(nv)
    
    return dist, a
                
n, m = map(int, input().split())
G = [[] for _ in range(n)]
edges = []

for _ in range(m):
    u, v, s = map(int, input().split())
    G[u-1].append((v-1, s))
    G[v-1].append((u-1, s))
    edges.append((u-1, v-1, s))

dist, a = bfs()
ts = set()

for u, v, s in edges:
    if dist[u]%2!=dist[v]%2:
        if a[u]+a[v]!=s:
            print(0)
            exit()
    else:
        if dist[u]%2==0:
            if s-a[u]-a[v]>=2 and (s-a[u]-a[v])%2==0:
                ts.add((s-a[u]-a[v])//2)
            else:
                print(0)
                exit()
        else:
            if a[u]+a[v]-s>=2 and (a[u]+a[v]-s)%2==0:
                ts.add((a[u]+a[v]-s)//2)
            else:
                print(0)
                exit()

if len(ts)>=2:
    print(0)
    exit()

l = 1
r = 10**18
    
for i in range(n):
    if dist[i]%2==0:
        l = max(l, -a[i]+1)
    else:
        r = min(r, a[i]-1)

if len(ts)==1:
    if l<=list(ts)[0]<=r:
        print(1)
    else:
        print(0)
else:
    print(max(0, r-l+1))

Measured memory_bytes: 83504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define out(a) cout<<fixed<<setprecision((a))

pair<double,double> cross(vector<int> x){
	// x = {x0,y0,x1,y1,u0,v0,u1,v1};
	double t0,t1,a,b,c,d;
	pair<double,double> res;
	a = x[6]-x[4]; b = x[0]-x[2];
	c = x[7]-x[5]; d = x[1]-x[3];
	if(a*d-c*b == 0){
		cout << "No cross" << endl;
		return res;
	}
	t1 = (d*(x[0]-x[4])-b*(x[1]-x[5]))/(a*d-c*b);
	res = make_pair((double)x[4]+(double)t1*(x[6]-x[4]) , (double)x[5]+(double)t1*(x[7]-x[5]));
	return res;
}


int main(){
	int q;
	cin >> q;
	vector<int> x(8);
	while(q--){
		for(int i=0;i<8;i++){
			cin >> x[i];
		}
		auto p = cross(x);
		out(10) << p.first << " " << p.second << endl;
	}
}



Measured memory_bytes: 3292
#include <bits/stdc++.h>
 
#include <fstream>
using namespace std;
 
#define MAX 1001
 
long long H, W;
long long Sx, Sy, Gx, Gy;
vector<vector<char>> maze(MAX, vector<char>(MAX));
vector<vector<int>> saitan(MAX, vector<int>(MAX, -1));
queue<int> qya, qyb, qxa, qxb;
int cnt = 0;
 
void warp(int ny, int nx) {
  for (int i = -2; i <= 2;  i++) {
    for (int j = -2; j <= 2 ; j++) {
      if(i + ny >= H || i + ny < 0 || j + nx >= W || j+nx < 0) continue;
      int toY = i + ny;
      int toX = j + nx;
      if (maze[toY][toX] == '.' && saitan[toY][toX] == -1) {
        qyb.push(toY);
        qxb.push(toX);
      }
    }
  }
}
 
void DFS(int ny, int nx) {
  saitan[ny][nx] = cnt;
  qyb.push(ny);
  qxb.push(nx);
  if (ny > 0 && maze[ny - 1][nx] == '.' && saitan[ny - 1][nx] == -1) {
    DFS(ny - 1, nx);
  }
  if (ny < H - 1 && maze[ny + 1][nx] == '.' && saitan[ny + 1][nx] == -1) {
    DFS(ny + 1, nx);
  }
  if (nx > 0 && maze[ny][nx - 1] == '.' && saitan[ny][nx - 1] == -1) {
    DFS(ny, nx - 1);
  }
  if (nx < W - 1 && maze[ny][nx + 1] == '.' && saitan[ny][nx + 1] == -1) {
    DFS(ny, nx + 1);
  }
}
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  cin >> H >> W >> Sy >> Sx >> Gy >> Gx;
  Sy--;
  Sx--;
  Gy--;
  Gx--;
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      cin >> maze[i][j];
    }
  }
  qyb.push(Sy);
  qxb.push(Sx);
  saitan[Sy][Sx] = 0;
  while (!qxb.empty()) {
    qya.swap(qyb);
    qxa.swap(qxb);
    while (!qya.empty()) {
      DFS(qya.front(), qxa.front());
      qya.pop();
      qxa.pop();
    }
    qya.swap(qyb);
    qxa.swap(qxb);
    while (!qya.empty()) {
      warp(qya.front(), qxa.front());
      qya.pop();
      qxa.pop();
    }
    cnt++;
  }
  cout << saitan[Gy][Gx];
}

Measured memory_bytes: 10780
#include<stdio.h>
#define N 100
#define INFTY (1<<21)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define NON -1

void dijkstra();

int M[N][N],d[N];
int n;

int main(){
  int i,j,u,k,v;
  
  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++) M[i][j]=INFTY;
  }

  
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&M[u][v]);
    }
  }

  dijkstra();
  
  for(i=0;i<n;i++){
    printf("%d %d\n",i,d[i]);
  }
  
  return 0;
}



void dijkstra(){
  int u,min;
  int i;
  int color[N];

  //初期化
  for(i=0;i<n;i++){
    d[i]=INFTY;
    color[i]=WHITE;
  }
  
  d[0]=0;
  color[0]=GRAY;

  while(1){
    min=INFTY;
    u=NON;
    //進路決め
    for(i=0;i<n;i++){
      if(min>d[i] && color[i]!=BLACK){
        u=i;
        min=d[i];
      }
    }
    if(u==NON) break;
    color[u]=BLACK;
    //次の節点の設定
    for(i=0;i<n;i++){
      if(color[i]!=BLACK && M[u][i]!=INFTY)
      if(d[i]>M[u][i]+d[u]){
        d[i]=M[u][i]+d[u];
        color[i]=GRAY;
      }
    }
  }

}



Measured memory_bytes: 2044
a = int(input())
b = int(input())
c = int(input())
x = int(input())
res = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if (i*500 + j * 100 + k*50) == x:
                res += 1
print(res)

Measured memory_bytes: 39536
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  int x, y, z;
  cin >> x >> y >> z;
  cout << z << ' ' << x << ' ' << y << '\n';
}


Measured memory_bytes: 888
#include <stdio.h>
#include <iostream>

void change(int x, int y){

    if(x>y)
    {
        printf("%d %d\n",y,x);
    }

    if(x<y)
    {
        printf("%d %d\n",x,y);
    }

    if(x==y)
    {
        printf("%d %d\n",y,x);
    }
    
    

}


int main(){

    int x=0,y=0;

    for(;;)
    {
    scanf("%d %d",&x,&y);
    if(x==0&&y==0)  return 0;
    change(x,y);
    }

    return 0;
   
}


Measured memory_bytes: 3216
#include <stdio.h>
#include <string.h>
#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch == 'A') return 1;
  else if(ch == 'C') return 2;
  else if(ch == 'G') return 3;
  else if(ch == 'T') return 4;
  else return 0;
}

/* convert a string into an integer value */
long long getKey(char str[]){
  long long sum = 0, p = 1, i;
  for ( i = 0; i < strlen(str); i++ ){
    sum += p*(getChar(str[i]));
    p *= 5;
  }
  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M - 1)); }

int find(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i=0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key = getKey(str);
  for(i=0; ; i++){
    h = (h1(key) + i * h2(key)) % M;
    if(strcmp(H[h], str) == 0) return 1;
    else if(strlen(H[h]) == 0){
      strcpy(H[h], str);
      return 0;
}
}
return 0;
}

int main(){
  int i, n, h;
  char str[L], com[9];
  for ( i = 0; i < M; i++ ) H[i][0] = '\0';

  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s %s", com, str);

    if ( com[0] == 'i' ){
      insert(str);
    } else {
      if (find(str)){
        printf("yes\n");
      } else {
        printf("no\n");
      }
    }
  }

  return 0;
}

Measured memory_bytes: 14916
import java.io.*;
import java.util.ArrayList;
public class Main{
	public static void main(String args[]){
    int a=0,b=0;
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    while(true){
    try{
          String line = reader.readLine();
          b = Integer.parseInt(line);
          a++;
          if (b == 0) break;
          System.out.println("Case " + a + ": " + b);
		}catch(Exception e){
      break;
    }
  }

	}
}


Measured memory_bytes: 32280
#include<cstdio>
using namespace std;
int main(){
    int x,y;
    while(scanf("%d%d",&x,&y),x,y){
        int data=0;
        int q = 0;
        data = x+y;
        for(int i = 1;i <= 4; i++){
            scanf("%d%d",&x,&y);
            if(data < x+y){
                data = x+y;
                q = i;
            }
        }
        printf("%c %d\n",q+65,data);
    }
    return 0;
}

Measured memory_bytes: 1028
console.log((args=>{
  const [[H,W],,a] = args.trim().split`\n`.map(r=>r.split` `.map(v=>v|0));
  let c = Array.from({length:H},_=>Array(W).fill(0)), k = 0;
  for ( let i = 0; i < H; i++ ) {
    for ( let j = 0; j < W; j++ ) {
      c[i][i&1?W-j-1:j] = k+1;
      if ( !--a[k] ) k++;
    }
  }
  return c.map(r=>r.join` `).join`\n`;
})(require('fs').readFileSync('/dev/stdin', 'utf8')));


Measured memory_bytes: 30976
import java.util.ArrayDeque;
import java.util.HashMap;
import java.util.Queue;
import java.util.Scanner;

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

        int n = scanner.nextInt();
        int[] data = new int[n];

        for (int i = 0; i < n; ++i) {
            data[i] = scanner.nextInt();
        }

        for (int i = n - 1; i >= 0; --i) {
            if (i == 0) System.out.println(data[i]);
            else System.out.print(data[i] + " ");
        }
    }
}


Measured memory_bytes: 26120
n=int(input())
a=list(map(int,input().split()))
ans=0
count=n
while count==n:
    count=0
    for i in range(n):
        if a[i]%2==0:
            k=a[i]//2
            a.pop(i)
            a.insert(i,k)
            count+=1
    if count==n:
        ans+=1
    
print(ans)

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

int main(){
  int H,N;
  cin >> H >>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  sort(A.begin(),A.end());
  int sum=0;
  for(int i=0;i<N;i++){
    sum+=A.at(i);
    if(sum>=H){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
    
}

Measured memory_bytes: 640
package main

import (
	"fmt"
	"math"
	"strconv"
)

func eval(n int) bool {
	num := strconv.Itoa(n)
	var a, b, c bool = false, false, false
	for i := 0; i < len(num); i++ {
		if num[i] == '3' {
			a = true
		} else if num[i] == '5' {
			b = true
		} else if num[i] == '7' {
			c = true
		}
	}
	return a && b && c
}

func convert(num int, d int) int {
	k := 1
	convertNum := [3]int{3, 5, 7}
	res := 0
	a := num
	for i := 0; i < d; i++ {
		res += convertNum[a%3] * k
		a = a / 3
		k *= 10
	}
	return res
}

func main() {
	var num int
	converted := 0
	count := 0
	fmt.Scan(&num)
	for d := 1; d < 10; d++ {
		im := int(math.Pow(3, float64(d)))
		for i := 0; i < im; i++ {
			converted = convert(i, d)
			if converted > num {
				break
			}
			if eval(converted) {
				count++
			}
		}
	}
	fmt.Println(count)
}

Measured memory_bytes: 896
#include <iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

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

	int l, r;
	l = r = -1;
	const int dbl = s.size() - 1;
	const int tri = s.size() - 2;
	for(int i=0; i<s.size(); i++)
	{
		if(i < dbl && s[i] == s[i+1])
		{
			l = i;
			r = i + 1;
			l++;
			r++;
			break;
		}

		if(i < tri && s[i] == s[i+2])
		{
			l = i;
			r = i + 2;
			l++;
			r++;
			break;
		}
	}

	cout << l << " " << r << endl;

	return 0;
}


Measured memory_bytes: 512
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val arr = Array(n){0}
    repeat(n) {
        val a = sc.nextInt()
        arr[a - 1] = it + 1
    }
    repeat(n) {
        print(arr[it])
        print(" ")
    }


}

Measured memory_bytes: 66596
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<LL,LL>
#define x first
#define y second
#define N 131072
#define pi acos(-1)
#define sqr(x) ((x)*(x))
#define pdd pair<double,double>
#define MEMS(x) memset(x,-1,sizeof(x))
#define MEM(x) memset(x,0,sizeof(x))
int mod=1e9+7;
/*
LL f_pow(LL a,LL b){
    LL res=1,temp=a;
    while(b){
        if(b&1)res=res*temp%mod;
        temp=temp*temp%mod;
        b>>=1;
    }
    return res;
}
LL fra[100005];
LL rev[100005];
void build(){
    fra[0]=1;
    for(int i = 1;i<=100002;i++)
        fra[i]=fra[i-1]*i%mod;
    rev[100000]=f_pow(fra[100000],mod-2);
    for(int i = 99999;i>=0;i--)
    rev[i]=rev[i+1]*i%mod;
}
LL C(int a,int b){
    return fra[a]*rev[b]%mod*rev[a-b]%mod;
}*/
vector<int> v[100005];
vector<int> stk;
void dfs(int x,int f){
    stk.pb(x);
    for(auto it:v[x]){
        if(it!=f)
            dfs(it,x);
    }
}
int main(){

    int n;
    scanf("%d",&n);
    for(int i = 1;i<n;i++){
        int x,y;
        scanf("%d %d",&x,&y);
        v[x].pb(y);
        v[y].pb(x);
    }
    dfs(1,0);
    int c[100005];
    for(int i =0;i<n;i++)
        scanf("%d",&c[i]);
    sort(c,c+n);
    reverse(c,c+n);
    LL ans=0;
    for(int i = 1;i<n;i++)
        ans+=c[i];
    printf("%lld\n",ans);
    int res[100005];
    for(int i = 0;i<n;i++)
    res[stk[i]]=c[i];
    for(int i=1;i<=n;i++)
    printf("%d ",res[i]);
    printf("\n");
}
/*
1 4 2 3
1 3 6 12
k(a+b) = a*b;
k*a+k*b = a*b;
b= (k*a)/(a-k);

k*(k+i)/i
*/

Measured memory_bytes: 3584
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))
#define each(i, map) for (auto& i : map)

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

    cout << a + pow(a, 2) + pow(a, 3) << endl;
}


Measured memory_bytes: 4124
#include <iostream>
using namespace std;
int x;
bool p[1000000];
void findPrime(){
    for (int i=2;i<=100005;i++){
        p[i] = 1;
    }
    for (int i=2;i*i<=100005;i++){
        if (p[i]){
            for (int j=i*i;j<=100005;j+=i){
                p[j] = 0;
            }
        }
    }
}
int main(){
    findPrime();
    scanf("%d", &x);
    for (int i=x;i<=100005;i++){
        if (p[i]){
            printf("%d\n", i);
            return 0;
        }
    }
}

Measured memory_bytes: 384
#include <iostream>
#include <iterator>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
    string line;
    getline(cin, line);
    getline(cin, line);
    istringstream iss(line);
    vector<int> v;
    copy(istream_iterator<int>(iss), {}, back_inserter(v));

    int min = *min_element(v.begin(), v.end());
    int max = *max_element(v.begin(), v.end());
    long long sum = accumulate(v.begin(), v.end(), static_cast<long long>(0));

    cout << min << ' ' << max << ' ' << sum << endl;

    return 0;
}

Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
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 (b<a) {a=b; return 1;} return 0;}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using pint = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int n;

void dfs(string s, char mx) {
    if (s.size() == n) {
        cout << s << endl;
        return;
    }
    else {
        for (char c = 'a'; c <=mx; c++) {
            dfs(s + c, c == mx ? mx+1 : mx);
        }
    }
}

int main() {
    cin >> n;
    dfs("", 'a');
    return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define Rep(i,a,n)for(int i=(int)(a);i<(int)(n);i++)
#define rep(i,n)Rep(i,0,n)
typedef long long ll;
typedef long double ld;
#define Ma(x,y) ((x)>(y)?(x):(y))
#define mi(x,y) ((x)<(y)?(x):(y))

int main() {
	char s[11],t[11];
	scanf("%s %s", s, t);
	rep(i, strlen(s)) {
		if (s[i] != t[i]) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");
}

Measured memory_bytes: 1732