akhauriyash/Code-Regression huggingface dataset:
from copy import deepcopy
from sys import exit,setrecursionlimit
import math
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac
import fractions
from functools import reduce
from operator import mul
import bisect
import sys
import logging
import heapq
import itertools

logging.basicConfig(level=logging.ERROR)

input = sys.stdin.readline

setrecursionlimit(1000000)


def main():
	print(int(input())**2)

def factorization(n):
	if n<2:
		return []

	arr = []
	temp = n
	for i in range(2, int(-(-n**0.5//1))+1):
		if temp%i==0:
			cnt=0
			while temp%i==0:
				cnt+=1
				temp //= i
			arr.append([i, cnt])

	if temp!=1:
		arr.append([temp, 1])

	if arr==[]:
		arr.append([n, 1])

	return arr

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(numbers):
	return reduce(fractions.gcd, numbers)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

class Queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class Stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

class PriorityQueue():
	def __init__(self):
		self.queue = []
	def push(self,i):
		heapq.heappush(self.queue,-i)
	def pop(self):
		return -1 * heapq.heappop(self.queue)
	def sum(self):
		return -sum(self.queue)

main()


Measured memory_bytes: 5716
#include<stdio.h>
int main() {
    int ans = 700;
    char a[4];
    scanf("%s", a);
    int i;
    for (i = 0; i < 3; i++)
    {
        if (a[i] == 'o')
            ans += 100;
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 128
from fractions import gcd

def factorization(n):
    arr = []
    temp = n
    for i in range(2,int(-(-n**0.5//1))+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i,cnt])
    if temp != 1:
        arr.append([temp,1])
    if arr == []:
        arr.append([n,1])
    return arr

a,b = map(int,input().split())

x = gcd(a,b)

ans = len(factorization(x))+1
if factorization(x) == [[1,1]]:
  ans -= 1
print(ans)


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

int main() {
	int	N;
	cin >> N;
	vector<int> vec;
	rep(i, N)
	{
		int a;
		cin >> a;
		vec.push_back(a);
	}
	int M;
	cin >> M;
	rep(i, M)
	{
		int op, bg, en;
		cin >> op >> bg >> en;
		vector<int>::iterator itb, ite;
		itb = next(vec.begin(), bg);
		ite = next(vec.begin(), en);
		if (op == 0)
			cout << *min_element(itb, ite) << endl;
		else if (op == 1)
			cout << *max_element(itb, ite) << endl;
	}
}



Measured memory_bytes: 3148
#!/usr/bin/env python3
def solve(n):
    used = set()
    for a in range(1, n + 1):
        b = n - a
        if a < b:
            used.add((a, b))
    return len(used)
def main():
    n = int(input())
    print(solve(n))
if __name__ == "__main__":
    main()


Measured memory_bytes: 84960
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<lint>;
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 lint INF = 1LL << 60;

struct Edge {
    int to, cost;
};

int main() {
    int n;
    cin >> n;
    vector<Edge> tree[100010];
    rep(i, n-1) {
        int a, b, c;
        cin >> a >> b >> c;
        a--; b--;
        tree[a].push_back((Edge){b, c});
        tree[b].push_back((Edge){a, c});
    }
    int q, k;
    cin >> q >> k;
    k--;

    vec dist(n, INF);
    dist[k] = 0;

    queue<int> que;
    que.push(k);

    while (!que.empty()) {
        int v = que.front();
        que.pop();

        for (auto&& e : tree[v]) {
            int to = e.to;

            if (dist[to] == INF) {
                dist[to] = dist[v] + e.cost;
                que.push(to);
            }
        }
    }

    // vec dbg;

    rep(i, q) {
        int x, y;
        cin >> x >> y;
        x--; y--;

        cout << dist[x] + dist[y] << endl;
    }
    return 0;
}

Measured memory_bytes: 10672
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int N;
i64 X;
vector<i64> a;

int main(){
  cin >> N >> X;
  a.resize(N);

  rep(i,0,N - 1){
    cin >> a[i];
  }

  i64 ans = 0;

  rep(i,1,N - 1){
    i64 sum = a[i] + a[i - 1];
    if(sum > X){
      i64 able = min(sum - X , a[i]);
      ans += able;
      a[i] -= able;
    }
  }

  {
    i64 sum = a[0] + a[1];

    if(sum > X){
      ans += sum - X;
    }
  }

  cout << ans << endl;
}


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


using ll = long long;
int X, Y, A, B, C;
vector<pair<int, int>> v;


void solve()
{
    sort(v.begin(), v.end());
    int c0 = 0, c1 = 0, c2 = 0;
    int idx, t0, t1, t2;
    for (int i = v.size() - 1; i >= 0; i--) {
        if (v[i].second == 0)
            c0++;
        else if (v[i].second == 1)
            c1++;
        else
            c2++;
        t0 = max(X - c1, 0) + max(Y - c2, 0);
        if (t0 <= c0) {
            idx = i;
            t1 = min(X, c1);
            t2 = min(Y, c2);
            break;
        }
    }

    ll ans = 0;
    for (int i = v.size() - 1; i >= idx; i--) {
        if (v[i].second == 0) {
            if (t0 > 0) {
                ans += v[i].first;
                t0--;
            }
        } else if (v[i].second == 1) {
            if (t1 > 0) {
                ans += v[i].first;
                t1--;
            }
        } else {
            if (t2 > 0) {
                ans += v[i].first;
                t2--;
            }
        }
    }
    cout << ans << endl;
}


int main()
{
    cin >> X >> Y >> A >> B >> C;
    int p, q, r;
    for (int i = 1; i <= A; i++) {
        cin >> p;
        v.emplace_back(p, 1);
    }
    for (int i = 1; i <= B; i++) {
        cin >> q;
        v.emplace_back(q, 2);
    }
    for (int i = 1; i <= C; i++) {
        cin >> r;
        v.emplace_back(r, 0);
    }
    solve();
    return 0;
}


Measured memory_bytes: 6512
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MOD 1000000007
#define pb emplace_back
#define mp make_pair
#define all(v) v.begin(),v.end()
#define sz(x) (ll)x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<=b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
typedef long long ll;
using namespace std;

int main(){
    IOS

    int n;
    cin >> n;
    while(n){
        if(n%10 == 7){
            cout << "Yes";
            return 0;
        }
        n /= 10;
    }
    cout << "No";
    return 0;
}

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

int main(void){
    long long n, h, a[100010], b[100010];
    cin >> n >> h;
    long long sum = 0, cnt = 0, max = 0;
    for(int i=0;i<n;++i){
        cin >> a[i] >> b[i];
        if(max < a[i]) max = a[i];
    }
    sort(b, b+n, greater<int>());
    for(int i=0;i<n;++i){
        if(max > b[i]) break;
        sum += b[i];
        ++cnt;
        if(sum >= h){
            cout << cnt << endl;
            return 0;
        }
    }
    cnt += (h-sum+max-1)/max;
    cout << cnt << endl;
}

Measured memory_bytes: 1792
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,k;
int a[200005];
int cnt0[45];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=0;i<=40;i++)for(int j=1;j<=n;j++)cnt0[i]+=((a[j]&(1ll<<i))==0);
	int ans=0,res=0;
	for(int i=1;i<=n;i++)res+=a[i];
	ans=max(ans,res);res=0;
	for(int i=1;i<=n;i++)res+=a[i]^k;
	ans=max(ans,res);
	for(int i=40;i>=0;i--)if(k&(1ll<<i)){
		res=0;
		for(int j=0;j<=40;j++){
			if(j>i)res+=((k&(1ll<<j))?cnt0[j]:n-cnt0[j])*(1ll<<j);
			else if(j==i)res+=(1ll<<j)*(n-cnt0[j]);
			else res+=(1ll<<j)*max(cnt0[j],n-cnt0[j]);
		}
		ans=max(ans,res);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;

int main() {
    string s;
    cin >> s;
    for(int i = 0;i < s.size();i++) cout << 'x';
    cout << endl;
}


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


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String input = br.readLine();
		int n = Integer.parseInt(input);
		
		boolean[][] open = new boolean[n][10];
		for(int i = 0; i < n; i++){
			String[] tmpArray = br.readLine().split(" ");
			for(int j = 0; j < 10; j++){
				if(tmpArray[j].equals("1")){
					open[i][j] = true;
				}
			}
		}
		
		
		int[][] profits = new int[n][11];
		
		for(int i = 0; i < n; i++){
			String[] tmpArray = br.readLine().split(" ");
			for(int j = 0; j < 10; j++){
				profits[i][j] = Integer.parseInt(tmpArray[j]);
			}
		}
		
		//ありえるのは1023通り
		int max = Integer.MIN_VALUE;
		for(int i = 0b1; i <= 0b11_1111_1111 ; i++){
//			System.out.println(i);
			
			int tmpProfit = 0;
			//店ごとにチェック
			for(int j = 0; j < n; j++){
				int sameTime = 0;
				int tmp = i;
				for(int k = 0; k < 10; k++){
					if(open[j][k] && tmp % 2 == 1){
						sameTime++;
					}
					tmp /= 2;
				}
				
				tmpProfit += profits[j][sameTime];
			}
			
			if(max < tmpProfit){
				max = tmpProfit;
			}
		}
		
		System.out.println(max);
	}

}


Measured memory_bytes: 22356
#include<stdio.h>

int main(){
  int n,m,i,j,a,cnt=0;
  int num[10000];
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&num[i]);
  scanf("%d",&m);
  for(i=0;i<m;i++){
    scanf("%d",&a);
    for(j=0;j<n;j++){
      if(a==num[j]){
	cnt++;
	break;
      }
    }
  }
  printf("%d\n",cnt);
  return 0;
}
  
    



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

struct UnionFind {
    vector<int> par;
    vector<int> sz;

    UnionFind(int n=0){
        if(n>0) initialize(n);
    }

    void initialize(int n){
        par.resize(n);
        sz.resize(n);
        for(int i=0; i<n; i++){
            par[i] = i;
            sz[i] = 1;
        }
    }

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

    void unite(int x, int y){
        x = find(x);
        y = find(y);
        if(x == y) return;
        if(sz[x] > sz[y]) swap(x, y);
        par[x] = y;
        sz[y] += sz[x];
    }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    int size(int x){
        return sz[find(x)];
    }
};

int nth_bit(int64_t num, int n){
    return (num >> n) & 1;
}

void chmax(double& a, double b){
	a = max(a, b);
}

int main(){
	int N, X[15], Y[15], A[15];
    cin >> N;
	for(int i=0; i<N; i++) cin >> X[i] >> Y[i] >> A[i];
	
	double D[15][15];
	for(int i=0; i<N; i++) for(int j=0; j<N; j++){
		double xd = X[i] - X[j], yd = Y[i] - Y[j];
		D[i][j] = sqrt(xd*xd + yd*yd);
	}

	int B = 1<<N;
	double dp[1<<15] = {0};
	dp[0] = 1e18;
	for(int b=1; b<B; b++){
		int num = 0;
		for(int i=0; i<N; i++) if(nth_bit(b, i)){
			num++;
			dp[b] += A[i];
		}

		vector<pair<double, pair<int, int>>> edges;
		for(int i=0; i<N; i++) for(int j=0; j<i; j++) if(nth_bit(b, i) && nth_bit(b, j)) edges.push_back({D[i][j], {i, j}});
		UnionFind uf(N);
		sort(edges.begin(), edges.end());
		for(auto& e : edges){
			int i = e.second.first, j = e.second.second;
			if(!uf.same(i, j)){
				uf.unite(i, j);
				dp[b] -= e.first;
			}
		}
		dp[b] /= num;
	}

	for(int b=1; b<B; b++){
		for(int b2=b; b2>0; b2=(b2-1)&b){
			chmax(dp[b], min(dp[b2], dp[b-b2]));
		}
	}

	cout << fixed << setprecision(20) << dp[B-1] << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <time.h>

int main(void){
	int i,j;
	
	int x,a;
	
	scanf("%d%d",&x,&a);
	
	if(x<a){
		printf("0\n");
	}else{
		printf("10\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int n;
long long dp[5];
int main()
{
	cin>>n;
	for(int i=1,a;i<=n;i++)
	{
		cin>>a;
		dp[0]+=a;
		dp[1]=min(dp[0],dp[1]+(a?a&1:2));
		dp[2]=min(dp[1],dp[2]+((a+1)&1));
		dp[3]=min(dp[2],dp[3]+(a?a&1:2));
		dp[4]=min(dp[3],dp[4]+a);
	}
	cout<<dp[4]<<'\n';
}


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

int main() {
  int n;cin>>n;
  vector<int> w(n);
  int cnt=0;
  rep(i,n){
    cin>>w[i];
    cnt+=w[i];
  }
  int a=0,ans=1e9;
  rep(i,n-1){
    a+=w[i];
    ans=min(ans,abs(cnt-a-a));
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3640
// inputに入力データ全体が入る
function Main(input) {
	//出力
	console.log(Number(input)*2*Math.PI);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 30128
n = int(input())
d, x = list(map(int, input().split()))
a_list = list()
for _ in range(n):
    a_list.append(int(input()))

ans = n
for a in a_list:
    i = 1
    tmp = i * a + 1
    while tmp <= d:
        ans += 1
        # 次の日
        i += 1
        tmp = i * a + 1


print(ans + x)


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

int main(){
    int n,m; cin >> n >> m;
    int left=0;
    int right=100010;
    rep(i,m){
        int l,r; cin >> l >> r;
        left = max(left,l);
        right = min(right,r);
    }
    if(right-left+1>=0) cout << right-left+1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
// Package main provides
//
// File:  c.go
// Author: ymiyamoto
//
// Created on Sun Dec  2 05:03:29 2018
//
package main

import "fmt"

var s, t string

func main() {
	fmt.Scan(&s, &t)

	for n := 0; n < 2; n++ {
		arr := make([]byte, 26)

		for i := range s {
			index := t[i] - 'a'
			if arr[index] == 0 {
				arr[index] = s[i]
			} else {
				if arr[index] != s[i] {
					fmt.Println("No")
					return
				}
			}
		}
		s, t = t, s
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define int long long
using namespace std;
int f(int k) { return k * k; }
signed main() {
	int x1, x2, x3, y1, y2, y3, xr, yr, r;
	while (cin >> x1 >> y1, x1, y1) {
		cin >> x2 >> y2;
		cin >> x3 >> y3;
		cin >> xr >> yr >> r;
		int i1 = f(x1 - xr) + f(y1 - yr) <= f(r);
		int i2 = f(x2 - xr) + f(y2 - yr) <= f(r);
		int i3 = f(x3 - xr) + f(y3 - yr) <= f(r);
		int tc = (
			((y1 - y2) * xr - (x1 - x2) * yr + x1 * y2 - x2 * y1) * ((y1 - y2) * x3 - (x1 - x2) * y3 + x1 * y2 - x2 * y1) >= 0 &&
			((y2 - y3) * xr - (x2 - x3) * yr + x2 * y3 - x3 * y2) * ((y2 - y3) * x1 - (x2 - x3) * y1 + x2 * y3 - x3 * y2) >= 0 &&
			((y3 - y1) * xr - (x3 - x1) * yr + x3 * y1 - x1 * y3) * ((y3 - y1) * x2 - (x3 - x1) * y2 + x3 * y1 - x1 * y3) >= 0);

		int p12 = (f((y1 - y2) * xr - (x1 - x2) * yr + x1 * y2 - x2 * y1) < f(r) * (f(y1 - y2) + f(x1 - x2)) && ((x1 - x2) * (xr - x1) + (y1 - y2) * (yr - y1)) * ((x1 - x2) * (xr - x2) + (y1 - y2) * (yr - y2)) <= 0);
		int p23 = (f((y2 - y3) * xr - (x2 - x3) * yr + x2 * y3 - x3 * y2) < f(r) * (f(y2 - y3) + f(x2 - x3)) && ((x2 - x3) * (xr - x2) + (y2 - y3) * (yr - y2)) * ((x2 - x3) * (xr - x3) + (y2 - y3) * (yr - y3)) <= 0);
		int p31 = (f((y3 - y1) * xr - (x3 - x1) * yr + x3 * y1 - x1 * y3) < f(r) * (f(y3 - y1) + f(x3 - x1)) && ((x3 - x1) * (xr - x3) + (y3 - y1) * (yr - y3)) * ((x3 - x1) * (xr - x1) + (y3 - y1) * (yr - y1)) <= 0);
		int ps12 = (f((y1 - y2) * xr - (x1 - x2) * yr + x1 * y2 - x2 * y1) <= f(r) * (f(y1 - y2) + f(x1 - x2)) && ((x1 - x2) * (xr - x1) + (y1 - y2) * (yr - y1)) * ((x1 - x2) * (xr - x2) + (y1 - y2) * (yr - y2)) <= 0);
		int ps23 = (f((y2 - y3) * xr - (x2 - x3) * yr + x2 * y3 - x3 * y2) <= f(r) * (f(y2 - y3) + f(x2 - x3)) && ((x2 - x3) * (xr - x2) + (y2 - y3) * (yr - y2)) * ((x2 - x3) * (xr - x3) + (y2 - y3) * (yr - y3)) <= 0);
		int ps31 = (f((y3 - y1) * xr - (x3 - x1) * yr + x3 * y1 - x1 * y3) <= f(r) * (f(y3 - y1) + f(x3 - x1)) && ((x3 - x1) * (xr - x3) + (y3 - y1) * (yr - y3)) * ((x3 - x1) * (xr - x1) + (y3 - y1) * (yr - y1)) <= 0);
		/*cout << "i1: " << i1 << endl;
		cout << "i2: " << i2 << endl;
		cout << "i3: " << i3 << endl;
		cout << "tc: " << tc << endl;
		cout << "p12: " << p12 << endl;
		cout << "p23: " << p23 << endl;
		cout << "p31: " << p31 << endl;*/
		if (i1 + i2 + i3 == 3)printf("b\n");
		else if (i1 + i2 + i3 > 0)printf("c\n");
		else if (p12 + p23 + p31 > 0)printf("c\n");
		else if (tc)printf("a\n");
		else if (ps12 + ps23 + ps31 > 0)printf("c\n");
		else printf("d\n");
	}
}


Measured memory_bytes: 3064
#include<stdio.h>
int main(){
  unsigned long long X;
  int i;
  unsigned long long Y=100;  
  scanf("%llu",&X);

  for(i=0;Y<X;i++){
    Y*=1.01;
    //printf("%2.3d\n",Y);
  }
  printf("%d",i);
  
  return 0;
}

Measured memory_bytes: 2140
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<bitset>
#include<stack>
#include<memory>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20);
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	//最小に最大をつなげる
	vector<string>sts;
	int a,b,c,i;cin>>a>>b>>c;
	while(a--){sts.pub("a");}
	while(b--){sts.pub("b");}
	while(c--){sts.pub("c");}
	while(sts.size()>1){
		int syox=0;
		int daix=0;
		for(i=1;i<sts.size();i++){
			if(sts[syox]>sts[i]){syox=i;}
			else if(sts[daix]<sts[i]){daix=i;}
			else if(syox==daix&&sts[daix]==sts[i]){daix=i;}
		}
		sts[syox]+=sts[daix];
		sts[daix]=sts.back();
		sts.pob();
		//for(auto it:sts){cout<<it<<" ";}cout<<endl;
	}
	cout<<sts[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main()
{
	string in;
	getline(cin,in);

	for(int i=0;i<in.size();i++)
	{
		if(i<in.size()-4&&in[i]=='a'&&in[i+1]=='p'&&in[i+2]=='p'&&in[i+3]=='l'&&in[i+4]=='e')
		{
			in[i]='p'; in[++i]='e'; in[++i]='a'; in[++i]='c'; in[++i]='h';
		}
		else if(i<in.size()-4&&in[i]=='p'&&in[i+1]=='e'&&in[i+2]=='a'&&in[i+3]=='c'&&in[i+4]=='h')
		{
			in[i]='a'; in[++i]='p'; in[++i]='p'; in[++i]='l'; in[++i]='e';
		}
	}
	cout<<in<<endl;

  return 0;
}

Measured memory_bytes: 1172
N, M = map(int, input().split())
INF = 2 ** 63 - 1
d = [(-1)*INF for i in range(N+1)]
d[1] = 0
data = []
for i in range(M):
    a, b, c = map(int, input().split())
    data.append([a, b, c])

for i in range(N):
    d_N = d[N]
    for j in range(M):
        a = data[j][0]
        b = data[j][1]
        c = data[j][2]
        d[b] = max(d[b], d[a]+c)
    if i == N-1:
        if d_N != d[N]:
            ans = "inf"
        else:
            ans = d[N]
print(ans)


Measured memory_bytes: 46952
#include <bits/stdc++.h>
using namespace std;
int a[100010], n;
pair<int, int> counter1[100010], counter2[100010];
int c1, c2;
int main()
{
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
		if (i%2)
		{
			counter1[a[i]].first++;
			c1++;
		}
		else
		{
			counter2[a[i]].first++;
			c2++;
		}
	}
	for (int i = 0; i <= 100000; i++) counter1[i].second = counter2[i].second = i;
	sort(counter1, counter1+100010);
	sort(counter2, counter2+100010);
	reverse(counter1, counter1+100010);
	reverse(counter2, counter2+100010);
	if (counter1[0].second != counter2[0].second)
	{
		int ans = c1-counter1[0].first + c2-counter2[0].first;
		printf("%d\n", ans);
	}
	else
	{
		int ans = c1-counter1[0].first + c2-counter2[0].first;
		ans += min(counter1[0].first - counter1[1].first, counter2[0].first - counter2[1].first);
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 2176
n = int(input())
s = input()

w = [0] * n
e = [0] * n

for i in range(n):
    if i == 0:
        if s[i] == 'W':
            w[i] = 1
            e[i] = 0
        else:
            w[i] = 0
            e[i] = 1
    else:
        if s[i] == 'W':
            w[i] = w[i - 1] + 1
            e[i] = e[i - 1]
        else:
            w[i] = w[i - 1]
            e[i] = e[i - 1] + 1

ans = 10 ** 10
for i in range(n):
    if i == 0:
        ans = min(ans, e[-1] - e[0])
    elif i == n:
        ans = min(ans, w[-1])
    else:
        right = e[-1] - e[i]
        left = w[i - 1]
        ans = min(ans, left + right)

print(ans)


Measured memory_bytes: 17616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
using namespace std;

typedef long long ll;


int main() {
  int N;
  cin >> N;
  vector<int> buttons(N + 1);
  buttons[0] = 0;
  for (int i = 1; i <= N; ++i) {
    cin >> buttons[i];
  }

  int count = 0, i = 1;
  for (;;) {
    if (i == 2) break;
    if (count > N) {
      count = -1;
      break;
    }
    ++count;
    i = buttons[i];
  }

  cout << count << endl;
  return 0;
}


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

// #define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif


#define ll long long 
#define ld long double
#define pb push_back
#define F first
#define S second
#define I insert
#define pll pair<ll,ll> 
#define vll vector<ll> 
#define vpll vector< pll >
const ll MAX_N=3*1e5+500;
ll fen[MAX_N];ll n1;
void update(ll p,ll val){
	for(ll i = p;i <= n1;i += i & -i)
		fen[i] += val;
}
ll sum(ll p){
	ll ans = 0;
	for(ll i = p;i;i -= i & -i)
		ans += fen[i];
	return ans;
}

int main() {
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll n,a,b,c,d,i,j,k;ll e,f;
	vll v;vll u;
	cin>>n;n1=2*n+1005;
	for(i=0;i<n;i++){
		cin>>a;v.pb(a);u.pb(a);
	}
	sort(u.begin(),u.end());
	ll hi=n-1;ll lo=0;ll mid;f=(n*(n+1))/2;
	while(lo<hi){
		mid=(hi+lo+1)/2;a=u[mid];
		d=0;b=n+3;
		for(i=0;i<2*n+52;i++)fen[i]=0;
		e=0;update(b,1);
		for(j=0;j<n;j++){
			if(v[j]>=a)b++;else b--;
			c=sum(b);e+=c;trace(b,c);
			update(b,1);
		}
		trace(mid,u[mid],e);
		if(2*e>=f){lo=mid;}else hi=mid-1;
	}
	cout<<u[lo];
	return 0;
}

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


typedef long long ll;
typedef vector<long long> VLL;
typedef vector<pair<int,int>> VP;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define MOD (1e9+7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
/*--------------------------------------------*/

int main(){
 //cout.precision(10);
 cin.tie(0);
 ios::sync_with_stdio(false);
  
  int N;
  cin >> N;
  
  int a = N / 1.08;
  
  if((int)(a*1.08) == N){
    cout << a << endl;
  }else if((int)((a+1)*1.08) == N){
    cout << a+1 << endl;
  }else{
    cout <<":(" << endl;
  }
  

}


Measured memory_bytes: 256
//https://algospot.com/judge/problem/read/CLOCKSYNC
#include <iostream>
#include <cstdio>
#include <functional>
#include <algorithm>
#include <climits>
#include <utility>
#include <string>
#include <stack>
#include <vector>
#include <queue>
#include <map>

#define LF '\n';
#define MOD 1000000007

typedef unsigned long long ull;
typedef long long ll;

using namespace std;

vector<string> strings;
map<string, int> mm;

void analysis(string & input, string & cnt) {
	for (auto ch : input) {
		int num = ch - 'a';
		cnt[num] += 1;
		if (cnt[num] == '9' + 1) cnt[num] = 'a';
	}
}

int main(void)
{
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int a = 0; a < n; a = a + 1) {
		string input, cnt;
		cin >> input;
		for (int a = 0; a < 26; a = a + 1) cnt.push_back('0');
		
		analysis(input, cnt);

		auto result = mm.find(cnt);
		if (result == mm.end()) mm[cnt] = 1;
		else mm[cnt] += 1;
	}
	ll ans = 0;

	for (map<string, int>::iterator it = mm.begin(); it != mm.end(); it++) {
		int num = it->second;
		if (num >= 2) ans += (ll)num * (num - 1) / 2;
	}

	cout << ans;
	return 0;
}	

Measured memory_bytes: 12800
a = input()
a = int(a)

if a % 10 == 2 or a % 10 == 4 or a % 10 == 5 or a % 10 == 7 or a % 10 == 9:
    print("hon")
elif a % 10 == 0 or a % 10 == 1 or a % 10 == 6 or a % 10 == 8:
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9052
while True:
    n = int(input())
    if n == 0:
        break
    sets = []
    for i in range(n):
        hokan = input().split()
        sets.append([hokan.count("0"),hokan.count("2"),n-i,hokan[0]])
    sets.sort(reverse = True)
    for i in range(n):
        print(sets[i][3])
    


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

#define F(i,a,b) for(long long  i =a; i<b; i++)
#define rF(i,a,b) for(long long i=a-1; i>=b;i--)
#define endl "\n"
#define min1(x,y,z) min(x, min(y,z))
#define max1(x,y,z) max(x, max(y,z))
#define input_vector(v,n,type) vector<type> v;for(int i=0;i<n;i++){type x;cin>>x;v.push_back(x);}
#define IOS ios_base::sync_with_stdio(false);  cin.tie(NULL);  cout.tie(NULL);
#define int long long
#define inf (1LL<<61)
typedef pair<int,int> ii;
typedef vector<pair<int,int>> vii;
typedef vector<int> vi;



int32_t main()
{
            IOS;

            
            int a, b;
            cin>>a>>b;

            for (int i = 1; i < 15000; i++) {
                  if (floor(i*0.08) == a && floor(i*0.10) == b) {
                        cout<<i<<endl;
                        return 0;
                  }
            }
            cout<<"-1"<<endl;



            



      


        
























            return 0;
}

Measured memory_bytes: 256
// AOJ 1201: Lattice Practices
// 2017.12.17 bal4u@uu

#include <stdio.h>
#include <string.h>

char a[10][6], b[10][6];
char *h[5], *v[5];
int diff[10];
int ans;

int check(int j)
{
	int i, k;
	for (k = 0; k <= j; k++) {
		for (i = 0; i <= j; i++) if (h[i][k] == v[k][i]) return 0;
	}
	return 1;
}

void solve(int k, int s)
{
	int i, x, y, bit;

	if (k == 10) { ans++; return; }
	x = k & 1, y = k >> 1;
	for (bit = 1, i = 0; i < 10; i++, bit <<= 1) {
		if (s & bit) continue;
		if (!x) {
			h[y] = a[i];
			solve(k+1, s | bit);
			if (diff[i]) {
				h[y] = b[i];
				solve(k+1, s | bit);
			}
		} else {
			v[y] = a[i];
			if (check(y)) solve(k+1, s | bit);
			if (diff[i]) {
				v[y] = b[i];
				if (check(y)) solve(k+1, s | bit);
			}
		}
	}
}

int main()
{
	int i, j;

	while(scanf("%s", a[0]) && a[0][0] != 'E') {
		for (i = 1; i < 10; i++) scanf("%s", a[i]);
		for (i = 0; i < 10; i++) {
			for (j = 0; j < 5; j++) b[i][j] = a[i][4-j];
			diff[i] = (memcmp(a[i], b[i], 5) != 0);
		}
		ans = 0;
		solve(0, 0);
		printf("%d\n", ans >> 3);
	}
	return 0;
}

Measured memory_bytes: 1812
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
/* #include <regex> */

using namespace std;

/* g++ -g -std=c++11 */

/* freopen("input.txt", "rt", stdin); */
/* freopen("output.txt", "wt", stdout); */

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }



const int mod = 1e9+7;
const int maxn = 1e5+100;
const int maxk = 50;
int C[maxn][maxk];

int main()
{
#ifdef foo_
    freopen("foo", "rt", stdin);
#endif
    ios::sync_with_stdio(false);
    FOR(i,0,maxn) {
        C[i][0] = 1;
        FOR(j,1,min(i+1,maxk)) {
            C[i][j] = C[i-1][j-1] + C[i-1][j];
            C[i][j] %= mod;
        }
    }
    int n,m;
    while (cin >> n >> m) {
        LL ans = 1;
        for (int i = 2; i*i <= m; i++) {
            int k = 0;
            while (m%i == 0) {
                k++; m /= i;
            }
            ans *= C[k+n-1][k];
            ans %= mod;
        }
        if (m != 1) {
            ans *= C[1+n-1][1];
            ans %= mod;
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 19840
#include <iostream>
#include <string>
#include <math.h>
#include <stdio.h>
#include <ctype.h>

using namespace std;

int main() {
    double ax,ay,bx,by,cx,cy,dx,dy;
    int n;
    cin>>n;
    
    while(cin>>ax>>ay>>bx>>by>>cx>>cy>>dx>>dy){
        if((ax-bx)==0&&(cx-dx)==0){
            cout<<"YES"<<endl;
        }else if((ax-bx)!=0.0 && (cx-dx)!=0.0){
            double a = (ay-by)/(ax-bx);
            double c = (cy-dy)/(cx-dx);
            if(a==c){
                cout<<"YES"<<endl;
            }else{
                cout<<"NO"<<endl;
            }
        }else{
            cout<<"NO"<<endl;
        }
        

    }
    return 0;
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
#include <vector>
using namespace std;
double a, b, c, d, e, f, x, y;
int main(){
	while(cin >> a >> b >> c >> d >> e >> f){
		x = (c*e - b*f)/(e*a - b*d);
		y = (c*d - a*f)/(d*b - a*e);
		if(x == -0)
			x = 0;
		if(y == -0)
			y = 0;
		cout << fixed << setprecision(3) << x << " " << y << "\n";
	}
	return 0;
}

Measured memory_bytes: 3176
#!/usr/bin/env python

import sys
import math
import itertools as it
from collections import deque

sys.setrecursionlimit(10000000)

q = input()

for loop in range(q):
    x0, y0, x1, y1, x2, y2, x3, y3 = map(int, raw_input().split())
    a1, b1 = [x1 - x0, y1 - y0]
    a2, b2 = [x3 - x2, y3 - y2]

    if a1 * b2 - b1 * a2 == 0:
        print 2
    elif a1 * a2 + b1 * b2 == 0:
        print 1
    else:
        print 0



Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

int main(){
  ll W,H,x,y;
  cin >> W >> H >> x >> y;
  double s = (double)((W * H) / 2.0);
  string flag = (H == 2*y && W == 2*x) ? " 1" : " 0";
  cout << s << flag << endl;
 }



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
using namespace std;
typedef pair<int,int> P;//Pでpair<-,->を表す。
typedef long long LL; 

int Ctoi(char c){
    return c-'0';
}
LL MOD=1000000007;

int main()
{ 
    string s;
    cin>>s;
    int n=s.size();
    LL dp[n][13];
    int d[n];
    for(int i=0;i<n;i++){
        for(int j=0;j<13;j++){
            dp[i][j]=0;
        }
    }
    for(int i=n-1;i>=0;i--){
        if(i==n-1){d[i]=1;}
        else{d[i]=(10*d[i+1])%13;}
    }

    for(int i=n-1;i>=0;i--){
        if(s[i]!='?'){
            int x=Ctoi(s[i]);
            for(int j=0;j<13;j++){
                if(i!=n-1){dp[i][(j+d[i]*x)%13]=dp[i+1][j];}
                else{dp[n-1][x]=1;}
            }
        }
        else{
            if(i==n-1){
                for(int j=0;j<10;j++){
                    dp[n-1][j]=1;
                }
            }
            else{
                for(int j=0;j<13;j++){
                    LL x=0;
                    for(int k=0;k<10;k++){
                        x=x+dp[i+1][(j+(13-((d[i]*k)%13)))%13];
                    }
                    dp[i][j]=x%MOD;
                }
            }
        }
    }

    cout<<dp[0][5]<<endl;
    return 0;
}

Measured memory_bytes: 11008
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using ld = long double;
const int INF = 1 << 29;
const ll LINF = 1l << 61;
const ld PI = abs(acos(-1));
#define pq priotity_queue
#define mp make_pair
#define P pair
#define rep(i, a, b) for (ll i = a; i < b; i++)
#define rrep(i, a, b) for (ll i = a; i >= b; i--)
#define cbuf(buf, init) memset(buf, init, sizeof(buf))
#define modp(x, y) (((y) + (x) % (y)) % (y))
#define divd(x, y) (static_cast<double>(x) / static_cast<double>(y))

ll N, a[200000];

int main()
{
    //
    cin >> N;
    rep(i, 0, N) { cin >> a[i]; }

    sort(a, a + N);
    ll cnt = 0, now = 0;
    ll ans = 0;
    rep(i, 0, N)
    {
        if (a[i] == now) {
            cnt++;
            continue;
        }
        if (cnt != 0) {
            if (cnt - now > 0) {
                ans += cnt - now;
            }
            else if (cnt - now < 0) {
                ans += cnt;
            }
        }
        now = a[i];
        i--;
        cnt = 0;
    }
    if (cnt != 0) {
        if (cnt - now > 0) {
            ans += cnt - now;
        }
        else if (cnt - now < 0) {
            ans += cnt;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    long long int r,d,x,i;
    scanf("%lld%lld%lld",&r,&d,&x);
    for(i=0; i<10; i++)
    {
        x = (r*x) - d;
        printf("%lld\n",x);
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>
#define NIL NULL

typedef struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
}* Node;

void treeDelete(Node);
void insert(int);
void inorder(Node);
void preorder(Node);

Node root;

Node treeMinimum(Node x){
  while(x->left != NIL)
    x = x->left;
  return x;
}

Node treeSearch(Node u, int k){
  while(u!=NIL && k!=u->key){
    if(u->key < k) u = u->right;
    else u=u->left;
  }
  return u;
}

Node treeSuccessor(Node x){
  Node y;
  if(x->right!=NIL)
    return  treeMinimum(x->right);
  y=x->parent;
  while(y!=NIL && x==y->right){
    x = y;
    y = y->parent;
  }
  return y;
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL)y=z;
  else y = treeSuccessor(z);

  if(y->left!=NIL)x = y->left;
  else x = y->right;

  if(x!=NIL)x->parent = y->parent;

  if(y->parent == NIL) root=x;
  else{
    if(y == y->parent->left)y->parent->left = x;
    else y->parent->right = x;
  }

  if(y!=z)z->key = y->key;
  free(y);
}

void insert(int key){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = key;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key < x->key){
      x = x->left;// 左の子へ移動
    }
    else x = x->right;// 右の子へ移動
  }
  z->parent = y;

  if(y==NIL){// T が空の場合
    root=z;
  }
  
  else if(z->key < y->key){// z を y の左の子にする
    y->left = z;
  }
  
  else y->right = z;// z を y の右の子にする


}

void inorder(Node u){
  if(u->left!=NIL)inorder(u->left);
  printf(" %d",u->key);
  if(u->right!=NIL)inorder(u->right);
			
}
void preorder(Node u){
  printf(" %d",u->key);
  if(u->left!=NIL)preorder(u->left);
  if(u->right!=NIL)preorder(u->right);
}






Measured memory_bytes: 20532
#include <stdio.h>

void gcd(int max, int min) {
  int w = 1;
  while (w) {
    w = max % min;
    if (w) {
      max = min;
      min = w;
    }
  }
  printf("%d\n", min);
}

int main() {
  int x, y, z;

  scanf("%d %d", &x, &y);
  if (x > y) {
    gcd(x, y);
  } else if (x < y) {
    gcd(y, x);
  } else {
    printf("%d\n", x);
  }
  return 0;
}



Measured memory_bytes: 2056
#!/usr/bin/ruby
# encoding: utf-8

R,D,X_2000 = gets.split.map(&:to_i)

def x(i)
  if i == 2000 then
    return X_2000
  end
  return R * x(i-1) - D 
end

(1..10).each do |i|
  puts x(2000+i)
end


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>
#include <cassert>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}

struct edge{
  int to, cost;
};
vector<vector<edge> >g;
vector<int> d;
int m;

void dfs(int now, int par){
    int ret = 1;
    for(auto e: g[now])if(e.to != par){
        dfs(e.to,now);
        ret *= d[e.to]+1;
        ret %= m;
    }
    d[now] = ret;
}

void dfs2(int now, int d_par, int par){
    vi d_child;
    for(auto e: g[now]){
        if(e.to == par){
            d_child.push_back(d_par+1);
        }else{
            d_child.push_back(d[e.to]+1);
        }
    }
    vi d_child_rev = d_child;
    rep(i,d_child.size()-1){
        d_child[i+1] *= d_child[i];
        d_child[i+1] %= m;
        d_child_rev[d_child.size()-i-2] *= d_child_rev[d_child.size()-i-1];
        d_child_rev[d_child.size()-i-2] %= m;
    }
    d[now] = d_child.back() % m;
    rep(i,g[now].size())if(g[now][i].to != par){
        edge e = g[now][i];
        int d_next = 1;
        if(i)d_next *= d_child[i-1];
        if(i+1 < g[now].size())d_next *= d_child_rev[i+1];
        d_next %= m;
        dfs2(e.to, d_next, now);
    }
}

signed main(void) {
    int n;
    cin >> n >> m;
    g.resize(n);
    d = vi(n,0);
    rep(i,n-1){
        int a,b,c;
        cin >> a >> b;
        a--,b--;
        edge e1 = {b,1};
        g[a].push_back(e1);
        edge e2 = {a,1};
        g[b].push_back(e2);
    }
    if(n == 1){
        cout << 1 << endl;
        return 0;
    }
    dfs(0,-1);
    //rep(i,n)cout << d[i] << endl;
    dfs2(0,0,-1);
    //rep(i,n)cout << d[i] << endl;
    rep(i,n){
        cout << d[i] << endl;
    }
}


Measured memory_bytes: 22912
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
const int MAX = 1e5 + 1;

ll f[1000100], finv[1000100];

ll modpow(ll a,ll n) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

ll modinv(ll a) {
  return modpow(a, mod - 2);
}

ll nCr(ll n, ll r) {
  if (r < 0 || r > n) return 0;
  return f[n] * finv[n - r] % mod * finv[r] % mod;
}

ll nHr(ll n, ll r) {
  return nCr(n + r - 1, r);
}

void init() {
  f[0] = 1, finv[0] = 1;
  FOR(i, 1, 1000100) {
    f[i] = i * f[i - 1] % mod;
    finv[i] = modinv(f[i]);
  }
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  init();

  ll n, x;
  cin >> n >> x;
  vector<ll> s(n);
  rep(i, n) cin >> s[i];

  sort(s.begin(), s.end(), greater<ll>());
  vector<ll> res(MAX, 0);
  res[x] = 1;
  rep(i, n) {
    vector<ll> nxt(MAX, 0);
    ll inv = modinv(n - i);
    rep(j, MAX) {
      nxt[j % s[i]] = (nxt[j % s[i]] + res[j] * inv) % mod;
      nxt[j] = (nxt[j] + res[j] * inv % mod * (n - i - 1)) % mod;
    }
    res = nxt;
  }
  rep(i, MAX) res[i] = res[i] * f[n] % mod;
  ll ans = 0;
  rep(i, MAX) ans = (ans + res[i] * i) % mod;
  cout << ans << '\n';


  




  
  return 0;
}

Measured memory_bytes: 17408
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main(){
	int a[N];
	int n, k;
	int x, y, z;
	long long s, ans;
	bool v = true;
	ans = 0;
	scanf("%d %d", &n,&k);


	if(n%k==0)printf("0\n");
	else printf("1\n");


	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
const int MOD = 1e9 + 7;
const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, 1, -1};
using namespace std;
typedef long long ll;
typedef pair<string, string> P;
string change(string s, string t, string r)
{
	vector<bool> flag(s.size(), false);
	for(int i = 0; i < s.size(); i++)
	{
		if(s.substr(i, t.size()) == t)
			flag[i] = true;
	}
	string ret;
	int pos = 0;
	while(pos < s.size())
	{
		if(flag[pos])
		{
			ret += r;
			pos += t.size();
		}
		else
		{
			ret += s[pos];
			pos++;
		}
	}
	return ret;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while(cin >> n, n)
	{
		string a[n + 1], b[n + 1];
		for(int i = 0; i < n; i++)
			cin >> a [i]>> b[i];
		string s, t;
		cin >> s >> t;
		map<string, int> mp;
		mp[s] = 0;
		queue<string> que;
		que.push(s);
		int ans = -1;
		while(!que.empty())
		{
			string tmp = que.front();
			que.pop();
			if(tmp.size() > t.size())
				continue;
			if(tmp == t)
			{
				ans = mp[tmp];
				break;
			}
			for(int i = 0; i < n; i++)
			{
				string x = change(tmp, a[i], b[i]);
				if(!mp.count(x))
				{
					mp[x] = mp[tmp] + 1;
					que.push(x);
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}





Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Rep(i, k, n) for (int i = k; i < (int)(n); i++)
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; }
const long long INF = 1LL << 60;
long long dp[100010];
long long h[100010];

int main()
{
    int n, a, b; cin >> n >> a >> b;
    int d = b - a;
    if (d % 2 == 0)
    {
        cout << "Alice" << endl; 
    }
    else
    {
        cout << "Borys" << endl;
    }
}

Measured memory_bytes: 256