akhauriyash/Code-Regression huggingface dataset:
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

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

    for (int i = 1; i < 100000; i++) {
        if (i * 108 / 100 == i + a && i * 11 / 10 == i + b) {
            cout << i << '\n';
            return 0;
        }
    }

    cout << -1 << "\n";
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ios::sync_with_stdio(0);
  ll n;
  cin >> n;
  cout << (n - 1) * n / 2;
  return 0;
}
/*
#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(0);

  return 0;
}
 */

Measured memory_bytes: 256
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias Ball = Tuple!(int, "x", int, "y");
Ball[50] BS;

void main()
{
    auto N = readln.chomp.to!int;
    foreach (i; 0..N) {
        auto xy = readln.split.to!(int[]);
        BS[i] = Ball(xy[0], xy[1]);
    }
    if (N == 1) {
        writeln(1);
        return;
    }

    sort(BS[0..N]);
    int r = int.max;
    foreach (a; 0..N) {
        foreach (b; a+1..N) {
            auto x = BS[a].x - BS[b].x;
            auto y = BS[a].y - BS[b].y;
            if (x == 0 && y == 0) continue;
            bool[] FS;
            FS.length = N;
            int rr;
            foreach (i; 0..N) {
                if (FS[i]) continue;
                FS[i] = true;
                ++rr;
                void search(int j, int p) {
                    foreach (k; 0..N) {
                        if (BS[j].x + x*p == BS[k].x && BS[j].y + y*p == BS[k].y && !FS[k]) {
                            FS[k] = true;
                            search(k, p);
                            break;
                        }
                    }
                }
                search(i, 1);
                search(i, -1);
            }
            r = min(r, rr);
        }
    }
    writeln(r);
}

Measured memory_bytes: 380
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

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

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

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

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

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
int main(){
  ll n,m;   cin>>n>>m;
  ll num = 1 << m;
  ll one = 100*(n-m) + 1900*m;
  cout << num * one << endl;
  return 0;
}   

Measured memory_bytes: 3592
from sys import exit
from collections import deque
K = int(input())
if K < 13:
    print(K)
    exit()

que = deque([i for i in range(1, 10)])
counter = 0

while True:
    counter += 1
    if counter == K:
        print(que.popleft())
        exit()
    val = que.popleft()
    before = val % 10
    if before - 1 >= 0:
        que.append(val*10+(before-1))
    que.append(val*10+before)
    if before + 1 <= 9:
        que.append(val*10+(before+1))


Measured memory_bytes: 40816
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int prev = sc.nextInt();
        int count = 0;
        for (int i = 1; i < n; i++) {
            int x = sc.nextInt();
            if (prev < x) {
                count++;
            }
            prev = x;
        }
        System.out.println(count);
    }
}



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

using namespace std;

typedef long long ll;

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

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

vector<int> as;

int main(void) {
    int N, M;
    cin >> N >> M;

    int sum = 0;
    as.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> as[i];
        sum += as[i];
    }

    // exclusive
    int border = (sum + (4 * M) - 1) / (4 * M);
    // printf("border: %d\n", border);

    int count = 0;
    for (int i = 0; i < N; i++) {
        if (as[i] >= border) {
            count++;
        }
    }

    if (count >= M) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> cnt(100000 + 1, 0);
  rep(i, n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  int res = 0;
  rep2(i, 1, cnt.size() - 1) {
    int sum3 = cnt[i - 1] + cnt[i] + cnt[i + 1];
    res = max(res, sum3);
  }
  cout << res << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector> //動的配列
#include <string>
#include <list> //双方向リスト
#include <map> //連想配列
#include <set> //集合
#include <stack>
#include <queue>
#include <deque>
#include <cmath>
#include <bitset>


//小さい順から取り出すヒープ
//priority_queue<ll, vector<ll>, greater<ll> > pque1;

typedef long long ll;


using namespace std;

typedef pair<int, ll> P;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)



ll fast_pow(ll x,ll n,ll mod){
    if (n==0) return 1;
    ll res=fast_pow(x*x %mod,n/2,mod);
    if (n&1) res=res*x%mod;
    return res;
}

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const ll mod=1e9+7;


int main(){
    int n;
    cin>>n;
    double a[n];
    rep (i,n){
        cin>>a[i];
    }
    double dp[n+1][n+1];
    fill(dp[0],dp[n+1],0.0);
    dp[0][0]=1.0;
    for (int i=0;i<n;i++){
        for (int j=0;j<=n;j++){
            if (dp[i][j]==0.0) continue;
            if (dp[i][j]!=0.0) {
                dp[i+1][j+1]+=a[i]*dp[i][j];
                dp[i+1][j]+=(1-a[i])*dp[i][j];
            }
        }
    }
    double ans=0.0;
    for (int i=n/2+1;i<=n;i++){
        ans+=dp[n][i];
    }
    printf("%.10f",ans);
}


Measured memory_bytes: 70656
#include<cstdio>
const int p=998244353;
int dp[90001],f[90001],s;
int main()
{
	int a,n,i,j,t=*dp=1,r=*f=1;
	scanf("%d",&n);
	for(i=0;i<n;i++,(t<<=1)>=p&&(t-=p),r=r*3ll%p)
	{
		scanf("%d",&a),s+=a;
		for(j=s;j>=a;j--)
			( dp[j]+=( (dp[j-a]&1?p:0)+dp[j-a] )>>1 )>=p&&(dp[j]-=p),
				( f[j]+=f[j-a] )>=p&&(f[j]-=p);
	}
	for(i=(s+1)/2,j=0;i<=s;i++)
		(j+=dp[i])>=p&&(j-=p);
	(r-=3ll*t*j%p)<0&&(r+=p);
	if(~s&1)(r+=f[s>>1]*3ll%p)>=p&&(r-=p);
	printf("%d\n",r);
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, col[100005];
vector<int> linker[100005];
void dfs(int x, int fa)
{
	int cnt = 0;
	for (int cur : linker[x])
		if (cur != fa) dfs(cur, x), cnt += col[cur] ^ 1;
	if (cnt > 1) puts("First"), exit(0);
	if (cnt) col[x] = 1;
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	if (n & 1) {return puts("First"), 0;}
	for (int i = 1; i < n; i ++)
	{
		int u, v; cin >> u >> v;
		linker[u].push_back(v);
		linker[v].push_back(u);
	}
	dfs(1, 0);
	puts("Second");
	return 0;
}

Measured memory_bytes: 6144
#include <bits/stdc++.h>
#include <queue>
#include <string>
#include <algorithm>

using namespace std;

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

int factorization(int n){
    int fac_ans = 1.0;
    for(int i=1;i<=n;i++) fac_ans *= i;
    return fac_ans;
}

#define rep(i, n) for (int i = 0; i < n; i++)
#define rep1(i, n) for (int i = 1; i < n + 1; i++)
#define repr(i, n) for (int i = n - 1; i >= 0; i--)
#define repr1(i, n) for (int i = n; i > 0; i--)
#define FOR(i, j, n) for (int i = j; i < n; i++)

typedef long long ll;
const ll MOD = 1000000007;
const ll INF = 100000000;

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

    vector<int> p(n);
    vector<int> q(n);

    rep(i,n) cin >> p[i];
    rep(i,n) cin >> q[i];

    vector<int> num(n);
    rep(i,n) num[i] = i+1;

    int a,b,cnt=1;
    do{
        if(p == num) a=cnt;
        if(q == num) b=cnt;
        cnt++;
    }while(next_permutation(num.begin(),num.end()));

    cout << abs(a-b) << endl;
    return 0;
}

Measured memory_bytes: 256
# ABC080C - Shopping Street
import sys
input = sys.stdin.readline

from itertools import product

def main():
    N = int(input())
    F = tuple(tuple(map(int, input().split())) for _ in range(N))
    P = tuple(tuple(map(int, input().split())) for _ in range(N))
    ans = []
    for b in product((0, 1), repeat=10):
        if 1 not in b:
            continue
        cnt = 0
        for f, p in zip(F, P):
            opening = sum(i & j for i, j in zip(b, f))
            cnt += p[opening]
        ans += [cnt]
    print(max(ans))


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
import sys,math
def input():
    return sys.stdin.readline()[:-1]
N,M = map(int,input().split(' '))
l = list(map(int, input().split()))

ANS = 0

for i in range(M):
    ANS += l[i]
if ANS>N:
    print(-1)
else:
    print(N-ANS)

Measured memory_bytes: 9884
#include<bits/stdc++.h>
#define ll long long int
#define pragi(a,b) for(ll i = a;i<b;i++)
#define pragj(a,b) for(ll j = a;j<b;j++)
#define pragk(a,b) for(ll k = a;k>=b;k--)
#define all(v) (v.begin(),v.end())
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define MP make_pair
#define MT make_tuple
#define F first
#define S second
#define KAKA ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
const int mod = 1e9 + 7;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef long double ld;
typedef pair<int, int> pii;
//typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef pair<ll, ll> pll;
ll dp[100005][2];
//Classic digit dynamic programming
string s;

ll recur(ll pos,ll flag)
{
  if(pos >= s.length())
  {
      return 1ll;
  }
  else if(dp[pos][flag] != -1)
  {
      return dp[pos][flag];
  }
  else
  {
      if(flag)
      {
          return dp[pos][flag] = ((recur(pos + 1,flag) % mod)*3)%mod;
      }
      else
      {
          ll limit = s[pos] - '0';
          if(limit == 0)
          {
              return dp[pos][flag] = recur(pos + 1,flag)%mod;
          }
          else
          {
              return dp[pos][flag] = ((((recur(pos + 1,flag)%mod)*2)%mod + (recur(pos + 1,1)))%mod)%mod;
          }
          
      }
      
  }
  
}
void Compute()
{
    KAKA
    memset(dp,-1,sizeof(dp));
    ll ways = 0;
    ways += recur(0,0);
    cout<<ways<<"\n";
}
int main()
{
    KAKA
   // string s;
    cin>>s;
    Compute();
}

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

int main() {
	using namespace std;
	ios_base::sync_with_stdio(false), cin.tie(nullptr);
	int N; cin >> N;
	struct constraint {
		bool z;
		uint64_t v;
	};
	vector<constraint> rows[2] = {vector<constraint>(N), vector<constraint>(N)};
	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			cin >> rows[d][i].z;
		}
	}

	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			cin >> rows[d][i].v;
		}
	}

	auto id = [](bool z) -> uint64_t { return z ? uint64_t(0) : ~uint64_t(0); };
	auto op = [](bool z, uint64_t a, uint64_t b) -> uint64_t { return z ? (a | b) : (a & b); };

	uint64_t accum[2][2] = {{id(0), id(1)}, {id(0), id(1)}};
	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			for (int z = 0; z < 2; z++) {
				accum[d][z] = op(z, accum[d][z], rows[d][i].v);
			}
		}
	}

	vector<bool> parity[2] = {vector<bool>(N), vector<bool>(N)};
	for (int d = 0; d < 2; d++) {
		bool cur_parity[2] = {true, true};
		for (int i = 0; i < N; i++) {
			parity[d][i] = (cur_parity[rows[d][i].z] ^= 1);
		}
	}

	auto get_cell = [&](int i, int j) -> uint64_t {
		if (rows[0][i].z == rows[1][j].z) {
			return op(!rows[0][i].z, rows[0][i].v, rows[1][j].v);
		} else {
			int d = parity[0][i] ^ parity[1][j];
			constraint c[2] = {rows[0][i], rows[1][j]};
			return op(!c[d].z, c[d].v, op(!c[!d].z, ~accum[!d][c[d].z], c[!d].v));
		}
	};

	vector<vector<uint64_t>> ans(N, vector<uint64_t>(N));
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans[i][j] = get_cell(i, j);
		}
	}

	vector<uint64_t> ansVal[2] = {vector<uint64_t>(N), vector<uint64_t>(N)};
	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			ansVal[d][i] = id(rows[d][i].z);
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ansVal[0][i] = op(rows[0][i].z, ansVal[0][i], ans[i][j]);
			ansVal[1][j] = op(rows[1][j].z, ansVal[1][j], ans[i][j]);
		}
	}
	for (int d = 0; d < 2; d++) {
		for (int i = 0; i < N; i++) {
			if (ansVal[d][i] != rows[d][i].v) {
				cout << -1 << '\n';
				exit(0);
			}
		}
	}

	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cout << ans[i][j] << " \n"[j+1==N];
		}
	}

	return 0;
}


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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'e' ||c == 'i' ||c == 'o' ||c == 'u')
    cout << "vowel" << endl;
  else
    cout << "consonant" << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <iostream>
#include <math.h>
#define rep(i,n) for(int i = 0; i <(n); i++)
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;

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



int main(void) {
	int i, j, k, tmp;
	int N;
	double ans = 0;
	vector<double> u;
	scanf("%d", &N);
	rep(i, N) {
		scanf("%d", &tmp);
		u.push_back(tmp);
	}
	sort(u.begin(), u.end());
	rep(i, N - 1) {
		u.at(i+1)= (double)(u.at(i) + u.at(i + 1)) / 2.0;
	}
	cout << u.at(N-1);


	return 0;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=input.split("\n");
var A=Arr[0].split(" ").map(Number);

gcd(A[0],A[1]);

function gcd(x,y){
    
    if(x>y){
        if((x % y) === 0){
            console.log(y);
        }else{
            gcd(y,x%y);
        }
    }else{
        if((y % x) === 0){
            console.log(x);
        }else{
            gcd(x,y%x);
        }
    }

}


Measured memory_bytes: 15140
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		boolean redable[] = new boolean[N];
		int balls[] = new int[N];
		for(int i=0;i<N;++i) balls[i] = 1;
		redable[0] = true;
		
		for(int i=0;i<M;++i){
			int x = sc.nextInt()-1;
			int y = sc.nextInt()-1;
			if(redable[x]) redable[y] = true;
			balls[x]--;
			balls[y]++;
			if(balls[x]==0) redable[x] = false;
		}

		int ans = 0;
		for(int i=0;i<N;++i) if(redable[i]) ans++;
		System.out.println(ans);
		return;
	}
}

Measured memory_bytes: 66520
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 100000;

struct V{
    V(int v,int w):v(v),w(w){};
    int v,w;
};

void solve(int color[],vector<V> G[],int v,int c){
    color[v] = c;
    for(int i = 0;i < G[v].size();i++){
        if(color[G[v][i].v] != 0)continue;
        if(G[v][i].w % 2)solve(color,G,G[v][i].v,-c);
        else solve(color,G,G[v][i].v,c);
    }
}

int main(){
    int N;
    int color[MAX] = {0};
    vector<V> G[MAX]; 

    cin >> N;
    for(int i = 0;i < N - 1;i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;v--;
        G[u].push_back(V(v,w));
        G[v].push_back(V(u,w));
    }

    solve(color,G,0,1);

    for(int i = 0;i < N;i++){
        if(color[i] > 0)cout << 1 << endl;
        else cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 9216
# Nの値
N = int(input())

# Hのリスト(文字列)
Hs_str_s = input().split()

# Hのリストを値に変換したリストHs_intの定義
Hs_int_s = []

# リスト内の文字列を１つ１つ数値に変換
for Hs_str in Hs_str_s:
    Hs_int_s.append(int(Hs_str))

def is_yes():
    max = 0
    for Hs_int in Hs_int_s:
        # print(Hs_int)
        if Hs_int >= max:
            max = Hs_int

        elif max - Hs_int >= 2:
            return False

    return True

if is_yes():
    print('Yes')

else:
    print('No')

Measured memory_bytes: 14252
#include <iostream>
#include <set>
#include <map>
using namespace std;

int N;
int X[60];
int Y[60];
map<pair<int, int>, int > mp;

int main(void){
    // Your code here!
    cin >> N;
    for(int i = 0; i < N; i++) cin >> X[i] >> Y[i];
    
    int p, q;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            if(i==j) continue;
            p = X[i] - X[j];
            q = Y[i] - Y[j];
            auto itr = mp.find(make_pair(p, q));        
            if( itr != mp.end() ) {
                mp[make_pair(p, q)] += 1;
            } else {
                mp[make_pair(p, q)] = 1;
            }
            
        }
    }
    
    int maxv = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        maxv = max(maxv, itr->second);
    }
    
    cout << (N - 1 -maxv) + 1 << endl;
    
    
}


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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007

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

//ａをbで割る
long long mod_div(long long a,long long b){
	if(a % b == 0)return a/b;
	long long tmp = MOD - 2,c = b,ret = 1;
	while(tmp > 0){
		if(tmp & 1){
			ret *= c;ret %= MOD;
		}
		c *= c;c %= MOD;tmp >>= 1;
	}
	return a*ret%MOD;
}

ll mi[222222];
ll seica[222222];
ll kaijo[222222];

int main(){

    REP(i,222222)mi[i] = LLINF;
    kaijo[0] = 1;
    REP(i,222221)kaijo[i+1] = (kaijo[i] * (i+1)) % MOD;

    ll n,x,y;cin >> n >> x >> y;
    vector<pair<ll,ll>> v;

    pair<ll,ll> minBall = MP(LLINF,-1);
    pair<ll,ll> secBall = MP(LLINF,-1);

    REP(i,n){
        ll a,b;cin >> a >> b;
        a--;
        secBall = min(secBall,max(minBall,MP(b,a)));
        minBall = min(minBall,MP(b,a));
        mi[a] = min(mi[a],b);
        v.PB(MP(a,b));
    }

    REP(i,n){
        if(mi[v[i].FI] + v[i].SE <= x){
            v[i].SE = mi[v[i].FI];
        }
    }

    ll sum = 0;
    REP(i,n){
        if(v[i].FI == minBall.SE){
            if(v[i].SE + secBall.FI <= y){
                seica[v[i].FI]++;
                sum++;
            }
        }
        else{
            if(v[i].SE + minBall.FI <= y){
                seica[v[i].FI]++;
                sum++;
            }
        }
    }

    ll ans = kaijo[sum];
    REP(i,n){
        ans = mod_div(ans,kaijo[seica[i]]);
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 11248
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#define ll int
#define mod 100000007
#define ln printf("\n");
#define mx 100001
using namespace std;
inline void in(ll &x){x=0;char c;bool f=0;while((c=getchar())>'9'||c<'0')if(c=='-')f=!f;x=c-48;while((c=getchar())<='9'&&c>='0')x=x*10+c-48;if(f)x=-x;}
inline void out(ll x){if(x<0){putchar('-');x=-x;}if(x>9)out(x/10);putchar(x%10+48);}
inline void outn(ll x){out(x);printf("\n");}
bool b[mx];
ll s[mx],q,l,r;
int main(){
	ll i,j;b[0]=b[1]=1;
	for(i=2;i<mx;i++)if(!b[i])for(j=2;j*i<mx;j++)b[i*j]=1;
	s[0]=s[1]=0;for(i=2;i<mx;i++){s[i]=s[i-1];if(!b[i]&&!b[(i+1)>>1])s[i]++;}
	in(q);
	while(q--){
		in(l);in(r);
		outn(s[r]-s[l-1]);
	}
}

Measured memory_bytes: 1152
x1,x2,x3,x4,x5 = map(int,input().split())

if x1 == 0:
    print("1")
if x2 == 0:
    print("2")
if x3 == 0:
    print("3")
if x4 == 0:
    print("4")
if x5 == 0:
    print("5")

Measured memory_bytes: 9176
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
#include <iomanip>
#include <limits>
#include <fstream>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
// 3倍しても2で割れる数は変わらない
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin>>n;
  int ans = 0;
  FOR(i,0,n){
	int a;
    cin>>a;
    while(a%2==0){
		a/=2;
      ans++;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll arr[60],k,l;
    cin>>k;
    for(ll i=0; i<50; i++)
        arr[i]=i+k/50;
    if(k%50)
    {
        ll rem=k%50;
        for(ll i=0; i<rem; i++)
            arr[i]+=(50)-(rem-1);
        for(ll i=rem; i<50; i++)
            arr[i]-=rem;
    }
    cout<<"50"<<endl;
    for(int i=0; i<49; i++)
        cout<<arr[i]<<" ";
    cout<<arr[49]<<endl;
    return 0;
}


Measured memory_bytes: 3652
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		while(true) {
			int sum=sc.nextInt();
			if(sum==0) {
				System.exit(0);
			}
			int a=0;
			for(int i=0; i<9; i++) {
				a+=sc.nextInt();
			}
			pl(sum-a);
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static void quick_sort(int[][] d, int left, int right) {
		if (left>=right) {
			return;
		}
		int p = d[(left+right)/2][0];
		int l = left, r = right;
		int tmp,tmp1,tmp2;
		while(l<=r) {
			while(d[l][0] < p) { l++; }
			while(d[r][0] > p) { r--; }
			if (l<=r) {
				tmp = d[l][0]; d[l][0] = d[r][0]; d[r][0] = tmp;
				tmp1=d[l][1]; tmp2=d[r][1]; d[l][1]=tmp2; d[r][1]=tmp1;
				l++; r--;
			}
		}
		quick_sort(d, left, r);
		quick_sort(d, l, right);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 24260
while True:
    h, w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for j in range(w):
            if i==0 or i==h-1 or j==0 or j==w-1:
                print('#', end="")
            else:
                print('.', end="")
            
        
        print('')
    print('')
 


Measured memory_bytes: 7012
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<queue>

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repn(i, n) for(int i = 1; i <= n; i++)
#define repr(i, n) for(int i = (n-1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define lint long long

int main(){
    int N, i; cin >> N >> i;
    cout << (N+1-i) << endl;
}

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

int main() {
  long long n;
  cin>>n;
  long long even;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(a%2==0) even++;
  }
  long long ans=1;
  for(long long i=0;i<n;i++) ans*=3;
  long long out=1;
  for(long long i=0;i<even;i++) out*=2;
  cout<<ans-out<<endl;
}


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

using namespace std;

int main(){
	string s; cin >> s;
	if(s=="SSS") cout << 0 << endl;
	else if(s=="RRR") cout << 3 << endl;
	else if(s[1] == 'S') cout << 1 << endl;
	else if(s[1] == 'R') {
		if(s[0] == 'R' or s[2] == 'R')
			cout << 2 << endl;
		else cout << 1 << endl;
	}
	
	return 0;
}


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

typedef pair<int,int> edge;

int N;
vector<vector<edge>> graph;
vector<int> ans;

void dfs(int v, int parent, int color){
    ans[v] = color;
    for (auto e : graph[v]){
        if (e.first == parent) continue;
        if (e.second % 2 == 1) dfs(e.first, v, 1-color);
        else dfs(e.first, v, color);
    }
}

int main(){
    cin >> N;
    graph = vector<vector<edge>>(N, vector<edge>());
    ans = vector<int>(N);
    for (int i = 0;i < N - 1; i++){
        int u,v,w;
        cin >> u >> v >> w;
        u--;
        v--;
        graph[u].push_back(edge(v, w));
        graph[v].push_back(edge(u, w));
    }
    dfs(0, -1, 0);
    for (auto v : ans) cout << v << endl;
}


Measured memory_bytes: 8192
#include <stdio.h>

int main(){

  int a,b,c,tmp,rec=0,loz=0;

  while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
    if(a!=b){
      tmp=a*a+b*b;
      if(tmp==c*c) rec++;
    }else if(a==b) loz++;
  }
  printf("%d\n%d\n",rec,loz);
  return 0;
}


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

using namespace std;

int main(){

  int i,j,c=1,p=0;
  cin>>i>>j;

  while (1){
    if ( c >= j){
      break;
    }
    c--;
    c +=i;
    p +=1;
  }
  cout<<p;

  return 0;
}


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main(){

  ios_base::sync_with_stdio (false);
  cin.tie(NULL);
  ll D, T, S;
  cin >> D >> T >> S;

  if(D<=T*S){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define int long long
#define _GLIBCXX_DEBUG

int hyd(int x,int y){
    if(x%y==0)return x/y;
    else return x/y+1;
}

signed main(){
    int N,A,B,C,D,E;
    cin>>N>>A>>B>>C>>D>>E;
    cout<<hyd(N,min(min(A,B),min(C,min(D,E))))+4<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

ll X[200010], N, XV;

ll f(ll v) {
	if (v < 1) {
		return LLONG_MAX;
	}
	ll t = 1, k = v, ans = 0;
	for (int i = N - 1;i >= 0;i--) {
		if (t == 1) {
			ans += X[i] * 5;
		}
		else {
			ans += X[i] * (t * 2LL + 1LL);
		}
		k--;
		if (k == 0)k += v, t++;
	}
	return ans + v * XV;
}

int main() {
	cin >> N >> XV;
	for (int i = 0;i < N;i++) {
		cin >> X[i];
	}
	
	ll lv = 0, rv = N + 1, l3, r3, ls, rs;
	for (int zz = 0;zz < 100;zz++) {
		ls = (lv * 2 + rv) / 3;
		rs = (lv + rv * 2) / 3;
		l3 = f(ls);
		r3 = f(rs);
		if (l3 < r3) {
			rv = rs;
		}
		else {
			lv = ls;
		}
	}
	cout << min(l3, r3) + XV * N << endl;
}

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

int main(){
	string a;
	int cnt=0,ans=0;
	int n=a.length();
	cin>>n>>a;
	for(int i=0;i<n;i++){
		if(a[i]=='I'){
			cnt++;
		}
		if(a[i]=='D'){
			cnt--;
		}
		ans=max(ans,cnt);
	}
	cout<<ans<<endl;
	return 0;
} 
 

Measured memory_bytes: 256
def main():
    from collections import deque
    import sys
    sys.setrecursionlimit(10**7)
    input = sys.stdin.readline
    n = int(input())
    X = sorted([list(map(int,input().split())) for i in range(n)])
    mod = 998244353
    e = [[] for i in range(n)]

    def dfs(x):
        count = 1

        for i in e[x]:
            count *= dfs(i)
            count %= mod
        return count+1

    q = deque([])

    for i in range(n-1,-1,-1):
        a,b = X[i]
        while q and q[0][0] < a+b:
            e[i].append(q[0][1]) 
            q.popleft()
        q.appendleft([a,i])

    ans = 1
    for i,j in q:
        ans *= dfs(j)
        ans %= mod
    print(ans)
if __name__ == "__main__":
    main()

Measured memory_bytes: 287632
N = int(input())
A = list(map(int, input().split()))
limit = 1000000000000000000
ans = 1
for i in range(N):
    if A[i] == 0:
        ans = 0

flag = False
for i in range(N):
    ans *= A[i]  
    if ans > limit:
        flag = True
        break
print(-1) if flag else print(ans)

Measured memory_bytes: 21412
(defun solve (n a b)
  (multiple-value-bind (div quot)
      (truncate n (+ a b))
    (+ (* div a)
       (if (< (- quot a) 0)
           quot
           a))))

#-swank
(let* ((n (read))
       (a (read))
       (b (read)))
  (format t "~A~%" (solve n a b)))


Measured memory_bytes: 12392
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

mod = 10**9+7

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

#互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m=mod):
    x = extgcd(a,m)[0]
    return (m+x%m)%m


N2 = [1]
n = 1
for _ in range(N+1):
    n = n*2 % mod
    N2.append(n)

Weight = [[] for _ in range(N)]
checked = [False]*N

def dfs(p):
    checked[p] = True
    downs = 0
    for np in graph[p]:
        if not checked[np]:
            downscore = dfs(np)
            Weight[p].append(N-downscore)
            Weight[np].append(downscore)
            downs += N-downscore
    
    return N-(downs+1)

dfs(0)

a = 0
for n in range(N):
    if len(Weight[n]) == 1:
        continue
    c = N2[N-1] - 1
    for w in Weight[n]:
        c = (c - N2[w] + 1) % mod
    a = (a + c) % mod

ans = (a * mod_inv(N2[N])) % mod
print(ans)

Measured memory_bytes: 198304
import java.util.Scanner;
import java.util.Arrays;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] a = new int[3];
    for(int j = 0; j < 3; j++)
      a[j] = sc.nextInt();
    Arrays.sort(a);
    System.out.println(a[1] - a[0] + a[2] - a[1]);
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H, W;
  cin >> H >> W;

  vector<vector<char>> table(H,vector<char>(W));
  vector<int> height(H,0), width(W,0); // 行・列に'.'がいくつ含まれるか
  int elih=0,eliw=0; // 消す行・列数
    
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
  	  cin >> table.at(i).at(j);
      if(table.at(i).at(j) == '.'){
        height.at(i)++;
        width.at(j)++;
      }
      if(j == W - 1 && height.at(i)==W){
        elih ++;
      }
      if(i == H - 1 && width.at(j)==H){
        eliw ++;
      }
    }
  }  
  
  H -= elih;
  W -= eliw;
  
  vector<vector<char>> ans(H, vector<char>(W));
  int ri=0, rj=0; //修正後の対応行列番号
  
  for (int i = 0; i < H + elih; i++) {
    if (height.at(i) == W + eliw){
      continue;
    }
    for (int j = 0; j < W + eliw; j++) {
      if (width.at(j) == H + elih){
        continue;
      }
      ans.at(ri).at(rj) = table.at(i).at(j);
      rj ++;
    }
    rj = 0;
    ri ++;
  }    
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
  	  cout << ans.at(i).at(j);
      if (j == W - 1) {
        cout << endl; // 末尾なら改行
      }
    }
  }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(ll i=a;i<b;i++)
#define bFor(i,a,b) for(ll i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;

int main(){
  ll N,ans=0,x,bf=0;
  cin>>N;
  vec v(N,0);
  rep(i,N){
    cin>>x;
    ans+=(x+bf)/2;
    if((x+bf)%2){
      bf=1;
    }else{
      bf=0;
    }
    if(!x)bf=0;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>

#include <memory>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>
using namespace std;

int main(int argc, char *argv[]) {
	unordered_map<int, unordered_map<int, int>> res;
	unordered_map<int, unordered_set<int>> um;
	vector<pair<int, int>> vp;
	int n;
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		vp.push_back(make_pair(a, b));
		um[a].insert(b);
		um[b].insert(a);
	}
	int k = 0;
	for (int i = 1; i <= n; i++) {
		k = max(k, (int)um[i].size());
	}
	cout << k << endl;

	vector<int> v;
	for (int i = 1; i <= n; i++) {
		if (um[i].size() == k) {
			int c = 1;
			for (auto s : um[i]) {
				res[i][s] = c;
				res[s][i] = c;
				c++;
				v.push_back(s);
			}
			break;
		}
	}
	while (v.size() > 0) {
		int s = *v.rbegin();
		v.pop_back();
		int used = 0;
		for (auto t : um[s]) {
			if (res[s].find(t) != res[s].end()) {
				used = res[s][t];
				break;
			}
		}
		int c = 1;
		if (c == used) c++;
		for (auto t : um[s]) {
			if (res[s].find(t) == res[s].end()) {
				res[s][t] = c;
				res[t][s] = c;
				c++;
				if (c == used) c++;
				v.push_back(t);
			}
		}
	}
	for (auto p :vp)
		cout << res[p.first][p.second] << endl;
}


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

typedef long long ll;

const int MAXN = 1e5 + 10;

int n, q, cnt[MAXN];
ll ans;

int main() {
    scanf("%d", &n);
    for (int i = 1, x; i <= n; ++i) scanf("%d", &x), cnt[x]++, ans += x;
    scanf("%d", &q);
    for (int i = 1; i <= q; ++i) {
        int a, b; scanf("%d %d", &a, &b);
        ans -= 1ll * cnt[a] * a, ans += 1ll * cnt[a] * b;
        cnt[b] += cnt[a], cnt[a] = 0;
        printf("%lld\n", ans);
    }
    return 0;
}

Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
typedef long long LL;
const int64_t INF=1e18+1;
const int mod = 1000000007;

int T;
map<LL,LL>s;
LL N,a,b,c,d;
LL dfs(LL n){
  	if(!n)return 0;
	if(s.count(n))return s[n];
	LL&ans=s[n];
	ans=(1e15)/n<d?1e15:n*d;
	ans=min(ans,dfs(n/2)+a+(n%2)*d);
	ans=min(ans,dfs(n/3)+b+(n%3)*d);
	ans=min(ans,dfs(n/5)+c+(n%5)*d);
	ans=min(ans,dfs(n/2+1)+a+(2-n%2)*d);
	ans=min(ans,dfs(n/3+1)+b+(3-n%3)*d);
	ans=min(ans,dfs(n/5+1)+c+(5-n%5)*d);
	return ans;
}

int main(){
  cin>>T;
  for(int i=0;i<T;i++){
    cin>>N>>a>>b>>c>>d;
    s.clear();
    cout<<dfs(N)<<endl;
  }
  return 0;                       
}

Measured memory_bytes: 4832
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>
using namespace std;
typedef unsigned long ul;
typedef pair<ul, ul> P;
const int INF = 1e9;
 
long long gcd(long long x, long long y){
			if (x==0)return y;
      if(y==0)return x;
      if(x<y){
				long long temp = x;
			x = y;
				y = temp;
			}
			long long r = x % y;
				while(r!=0){
					x = y;
					y = r;
				r = x % y;
	    		}
			return y;
	    }

   
int main(){
long long X,Y;
cin >> X >> Y;
int cnt = 1;
while (1)
{
X *= 2;
if(X<=Y)cnt++;
else break;
}
cout << cnt << endl;

}



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

using namespace std;
using ll = long long;

// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

int main () {
    int N, M;
    cin >> N >> M;
    vector<int> A(M), B(M), P(N);

    UnionFind p(N);

    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a -= 1;
        b -= 1;
        p.merge(a, b);
    }

    cout << *max_element(p.siz.begin(), p.siz.end()) << endl;

}

Measured memory_bytes: 8692
#include <iostream>
#include <vector>
#include <map>

#define PI 3.14159265359	

using namespace std;

int main(){
	int n, r;
	char s, ss[] = {'S', 'H', 'C', 'D'};
	map<char, map<int, bool> > card;
	cin >> n;
	for (int i = 0; i < 4; i++){
		for (int j = 1; j <= 13; j++){
			card[ss[i]][j] = false;
		}
	}
	for (int i = 0; i < n; i++){
		cin >> s >> r;
		card[s][r] = true;
	}
	for (int i = 0; i < 4; i++){
		for (int j = 1; j <= 13; j++){
			if (!card[ss[i]][j]) cout << ss[i] << " " << j << endl;
		}
	}
}

Measured memory_bytes: 3100
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/10;
    public static final int inf = Integer.MAX_VALUE/10;

    static void solve(InputReader in, PrintWriter out){
        long h = in.nl(), w = in.nl();
        int n = in.ni();
        int[] dx = new int[]{0,0,1,1,1,0,-1,-1,-1};
        int[] dy = new int[]{0,1,1,0,-1,-1,-1,0,1};
        HashMap<Point, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            int a = in.ni(), b = in.ni();
            for (int j = 0; j < 9; j++) {
                if(a+dx[j]<=1||a+dx[j]>=h||b+dy[j]<=1||b+dy[j]>=w) continue;
                Point p = new Point(a+dx[j], b+dy[j]);
                map.put(p, map.containsKey(p)?map.get(p)+1:1);
            }
        }
        long[] ans = new long[10];
        for(Point p: map.keySet()) ans[map.get(p)]++;
        ans[0] = (h-2)*(w-2)-map.size();
        for(long l: ans) out.println(l);
    }
    public static class Point{
        int x, y;
        public Point(int x, int y){
            this.x = x; this.y = y;
        }
        @Override
        public boolean equals(Object o){
            return ((Point)o).x==x&&((Point)o).y==y;
        }
        @Override
        public int hashCode(){
            long res = 1145148101919l;
            res *= x;
            res %= mod;
            res *= y;
            res %= mod;
            return (int)res;
        }
    }

    public static void main(String[] args) throws Exception{
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public Double nd(){
            return Double.parseDouble(ns());
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

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

using namespace std;

int main() {

	string s;
	cin >> s;

	long i = s.size()-1;
	while (i >=0) {
		if (i-6>=0 && s.substr(i-6, 7) == "dreamer") {
		i -= 7;
		}
		else if (i-5>=0 && s.substr(i-5, 6) == "eraser") {
			i -= 6;
		}
		else if (i-4>=0 && s.substr(i-4,5)=="dream"
			|| s.substr(i-4, 5) == "erase") {
			i -= 5;
		}
		else {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}

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

int N;
string S[110000];

int main(void){

    cin >> N;
    for (int i = 0;i <N;i++) cin >> S[i];

    int A = 0;
    int W = 0;
    int T = 0;
    int R = 0;

    for (int i = 0;i <N;i++){
        if (S[i] == "AC") A++;
        else if (S[i] == "WA") W++;
        else if (S[i] == "TLE") T++;
        else if (S[i] == "RE") R++;
    }
    

    cout << "AC x " << A << endl;
    cout << "WA x " << W << endl;
    cout << "TLE x " << T << endl;
    cout << "RE x " << R << endl;

    return 0;
}

Measured memory_bytes: 7076
import java.util.Scanner;
public class Main {
	public static void main(String[] args) throws java.io.IOException {
		Scanner scan = new Scanner(System.in);
		int a[]=new int [6];
		for(int i=0;i<6;i++){
			a[i]=scan.nextInt();
		}
		if(1000<=a[0]+a[1]*5+a[2]*10+a[3]*50+a[4]*100+a[5]*500){
			System.out.println(1);
		}
		else
			System.out.println(0);
	}
}

Measured memory_bytes: 17360
#include <stdio.h>
#define N 2000001
void CountingSort(short *,short *,int,int);

int main(){
  int max=-1,n,i;
  short A[N],B[N];
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%hd",&A[i]);
    if(max<A[i]) max=A[i];
  }
  CountingSort(A,B,max,n);
  for(i=1;i<=n;i++){
    if(i>1) printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;  
}
  
void CountingSort(short A[],short B[],int k,int n){
  int C[k+1],i,j;
  for (i = 0;i<=k;i++) C[i] = 0;
  
  /* C[i] に i の出現数を記録する */
  for (j = 1;j<=n;j++) C[A[j]]++;
  
  /* C[i] に i 以下の数の出現数を記録する*/
  for (i = 1;i<= k;i++) C[i] = C[i] + C[i-1];
  
  for (j = n;j>=1;j--){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }
}



Measured memory_bytes: 9568
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
int main()
{
    ll D;
    cin >> D;
    vector<ll> c(26);
    rep(i, 26) cin >> c.at(i);
    vector<vector<ll>> s(D, vector<ll>(26));
    rep(i, D){
        rep(j, 26){
            cin >> s.at(i).at(j);
        }
    }
    vector<ll> t(D);
    rep(i, D) cin >> t.at(i);
    rep(i, D){
        t.at(i)--;
    }
    ll sat = 0;
    vector<vector<ll>> last(D, vector<ll>(26, -1));
    rep(i, D){
        sat += s.at(i).at(t.at(i));
        last.at(i).at(t.at(i)) = i;
        if(i != 0){
            rep(j, 26){
                if(j == t.at(i)){
                    continue;
                }
                last.at(i).at(j) = last.at(i-1).at(j);
            }
        }
        rep(j, 26){
            sat -= c.at(j) * (i - last.at(i).at(j));    
        }
        cout << sat << endl;
    }
}

Measured memory_bytes: 3776