akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
signed main(){
	int a;
	cin>>a;
	for(int i=1;i*i<=a;i++){
		if(a%i==0&&a/i<=9&&i<=9){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, '%d', $N);
$s1 = ['.', '.', '#', '#'];
$s2 = ['.', '#', '.', '#'];
$resS1 = '';
$resS2 = '';
$right = true;
while ($N) {
	$idx = 0;
	while ($idx < 4) {
		$_resS1 = ($right) ? $resS1.$s1[$idx] : $s1[$idx].$resS1;
		$_resS2 = ($right) ? $resS2.$s2[$idx] : $s2[$idx].$resS2;
		echo $_resS1."\n".$_resS2."\n";
		fscanf(STDIN, '%s', $R);
		if ($R === 'T') {
			$resS1 = $_resS1;
			$resS2 = $_resS2;
			break;
		}
		$idx++;
	}
	if ($idx === 4) {
		$right = !$right;
	} else {
		$N--;
	}
}


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

int main(){
    int N;
    scanf("%d", &N);
    char S[N + 1];
    for (int i = 0; i < N; i++) cin >> S[i];
    //for (int i = 0; i < N; i++) cout << S[i];
    
    stack<char> S2;
    for (int i = 0; i < N; i++) {
        if (i == 0) S2.push(S[0]);
        else {
            if (S2.top() != S[i]) S2.push(S[i]);
        }
    }
    
    printf("%d\n", S2.size());
    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

#define mp make_pair
#define pb push_back
#define ll long long

const int maxN = 200011;

int n, i, j, sum, xorsum;
int a[maxN], nxt[maxN];
ll ans;

int main()
{
   // freopen("test.in","r",stdin);

    scanf("%d", &n);
    for (i = 1; i <= n; i++) {
        scanf("%d", &a[i]);
    }

    nxt[n + 1] = n + 1;
    for (i = n; i >= 1; i--)
        nxt[i] = (a[i] == 0 ? nxt[i + 1] : i);

    for (i = 1; i <= n; i++) {
        sum = xorsum = a[i];
        ans++;

        for (j = i + 1; j <= n; j = nxt[j + 1]) {
            sum += a[j];
            xorsum ^= a[j];

            if (sum != xorsum) break;
            ans += 1LL * nxt[j + 1] - j;
        }
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 1792
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <cstdio>
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define SIZE 100000
#define MOD 1000000007
using namespace std;
typedef long long ll;

struct ModFact {
    ll sum[SIZE+1];
    ll fact[SIZE+1];
    constexpr ModFact() : fact(), sum() {
        ll f = 1;
        fact[0] = f;
        for (int i = 0; i <= SIZE; i++) {
            f = f*(i+1)%MOD;
            fact[i+1] = f;
        }
        f = power(f, MOD-2);
        for (int i = SIZE; i >= 0; i--) {
            sum[i] = fact[i] * f % MOD;
            f = f * (i+1) % MOD;
        }
        for (int i = 1; i <= SIZE; i++) {
            sum[i] = (sum[i] + sum[i-1]) % MOD;
        }
    }
    inline constexpr ll power(ll a, ll b) {
        ll r = 1;
        while (b>0) {
            if((b&1)!=0) r = (r*a)%MOD;
            a = (a*a)%MOD;
            b >>= 1;
        }
        return r;
    }
	inline ll operator[](int index) {
		return sum[index];
	}
	inline ll getfact(int index) {
		return fact[index];
	}
    
} fact;

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
    if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
    return *ci++;
}

inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
    return A;
}

int main() {
    ll ans = 0, d;
    int N, prev, now;
    N = getint();
    prev = getint();
    REP(i, N-1) {
        ans += fact[i] * ((now = getint()) - prev);
        prev = now;
    }
    printf("%lld\n", (ans%MOD)*fact.getfact(N-1)%MOD);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,e,x;
    cin>>a>>b;
    c=((a-1)+a);
    d=((b-1)+b);
    e=(a+b);
    x=max(c,d);
    cout<<max(x,e);
 
    return 0;
}

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

using namespace std;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
int main(void) {
    int sum=0;
    string S;
    cin>>S;

    for (int i=0;i<9;i++){
      sum += ctoi(S[i]);
    }
    if((atoi(S.c_str()))%sum== 0){
        cout<<"Yes"<<endl;
          return 0;
    }

    cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int n, m; string s;
int main() {
	while (cin >> n >> m, n) {
		vector<int> a(n + m), b(n + m), c(n + m), d(n + m);
		int da = 0, db = 0, dc = 0;
		for (int i = 0; i < n; i++) {
			cin >> s;
			a[i] = da, b[i] = db, c[i] = dc;
			for (int j = 0; j < s.size(); j++) {
				if (s[j] != '.') {
					d[i] = j; break;
				}
			}
			for (int j = 0; j < s.size(); j++) {
				if (s[j] == '(') da++;
				if (s[j] == '{') db++;
				if (s[j] == '[') dc++;
				if (s[j] == ')') da--;
				if (s[j] == '}') db--;
				if (s[j] == ']') dc--;
			}
		}
		vector<int> ra, rb, rc;
		for (int i = 1; i <= 20; i++) {
			for (int j = 1; j <= 20; j++) {
				for (int k = 1; k <= 20; k++) {
					bool flag = true;
					for (int l = 0; l < n; l++) {
						if (i * a[l] + j * b[l] + k * c[l] != d[l]) {
							flag = false; break;
						}
					}
					if (flag) {
						ra.push_back(i);
						rb.push_back(j);
						rc.push_back(k);
					}
				}
			}
		}
		for (int i = 0; i < m; i++) {
			if (i) cout << ' ';
			cin >> s;
			vector<int> x;
			for (int j = 0; j < ra.size(); j++) x.push_back(da * ra[j] + db * rb[j] + dc * rc[j]);
			sort(x.begin(), x.end());
			x.erase(unique(x.begin(), x.end()), x.end());
			if (x.size() != 1) cout << -1;
			else cout << x[0];
			for (int j = 0; j < s.size(); j++) {
				if (s[j] == '(') da++;
				if (s[j] == '{') db++;
				if (s[j] == '[') dc++;
				if (s[j] == ')') da--;
				if (s[j] == '}') db--;
				if (s[j] == ']') dc--;
			}
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 3224
function Main(input) {
	input = input.split("\n");
	var a = parseInt(input[0], 10);
	var b = parseInt(input[1], 10);
	var c = parseInt(input[2], 10);
	var d = parseInt(input[3], 10);
	//出力
	console.log((a < b ? a : b) + (c < d ? c : d));
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
//CODE_FESTIVAL2017qualB-D(101 to 010)
#include<bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define repr(i,a,b) for(int i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x),end()
typedef long long ll;

int N;
//「11...1101」と「1011...11」を選択していくDP
//dp[i]:i文字目まで見たときの操作回数のmax
int dp[500010];
//次に0が来るインデックス、前に0が来るインデックスを持っておく
int nex[500010],back[500010];

int main(){
    string S;
    cin>>N>>S;
    S+='#';//オーバーフロー防止
    
    int ba=-1;
    rep(i,0,N){
        back[i]=ba;//back[i]:i文字目の前を見たときに一番近い0の位置
        if(S[i]=='0')ba=i;
    }
    int ne=N;
    repr(i,N-1,0){
        nex[i]=ne;
        if(S[i]=='0')ne=i;
    }
    
    rep(i,0,N){
        dp[i+1]=max(dp[i+1],dp[i]);
        
        //1011...の時
        if(S[i]=='1'){
            //back[i]が1番目以上にないと「011...のようになるので不適
            //S[back[i]-1]が1でないと001...のようになるので不適
            if(1<=back[i] && S[back[i]-1]=='1'){
                //dp[前の0の1つ左の1(101の初め)]+(現段階での1のインデックス-前の0のインデックス)←追加される操作の数
                dp[i+1]=max(dp[i+1],dp[back[i]-1]+i-back[i]);//配るDP
            }
        }
        
        //...1101の時
        if(S[i]=='1'){
            //next[i]がN-1番目未満にないと...110」のようになるので不適
            //S[next[i]+1]が1でないと...100のようになるので不適
            if(nex[i]<N-1 && S[nex[i]+1]=='1'){
                //dp[次の0の1つ右の1(101の最後)]+(次の0のインデックス-現段階での1のインデックス)←追加される操作の数
                dp[nex[i]+2]=max(dp[nex[i]+2],dp[i]+nex[i]-i);//配るDP
            }
        }
    }
    cout<<dp[N]<<endl;
    
    return 0;
}

Measured memory_bytes: 6788
#include <iostream>

using namespace std;
int main()
{
 int x,y,N1,N2,keepn1,keepn2;
 cin>>x>>y;
 if(x<=y)
 {
  N1=y,N2=x;
 }else
 {
  N1=x,N2=y;
 } 
 
 //========================================================
 while(1){
   if(N1%N2==0){break;}
   keepn1=N1;
   keepn2=N2;
   //cout<<N1<<"/"<<N2<<"="<<N1/N2<<"_"<<N1%N2<<endl;
   N1=keepn2;
   N2=keepn1%keepn2;
  //cout<<N1<<" "<<N2<<endl;
 }
cout<<N2<<endl;
 
 return 0;
}



Measured memory_bytes: 3096
def list_pos(cnt,a,b,ans):
    if ans  >= b :
        return cnt-1
    else :

        ans += a[cnt][1]
        cnt += 1
        return list_pos(cnt,a,b,ans)
import sys
sys.setrecursionlimit(100000)
N,K = map(int,input().split())
para = {}
for i in range(N):
    a,b  = map(int,input().split())
    if not a in para.keys():
        para[a] = b
    else : para[a] += b

para = sorted(para.items(),key =lambda x:x[0])

p = list_pos(0,para,K,0)
print("{}".format(para[p][0]))


Measured memory_bytes: 68620
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <math.h>

#define P 1000000007

int comp(const void *a, const void *b){return *(int*)a-*(int*)b;}

int main(void){
	int n, k, i, j;
	int a[15];
	scanf("%d%d", &n, &k);
	for(i=0; i<n; i++){
		scanf("%d", &a[i]);
	}
	long ans=LONG_MAX;
	i=(1<<k)-1;
	while(i<1<<n){
		long now=0;
		int h=0;
		for(j=0; j<n; j++){
			if(i&1<<j && a[j]<=h){
				h++;
				now+=h-a[j];
			}
			if(a[j]>h){
				h=a[j];
			}
		}
		if(now<ans) ans=now;

		int x=i&-i, y=i+x;
		i=((i&~y)/x>>1)|y;
	}
	printf("%ld\n", ans);
}


Measured memory_bytes: 128
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<pair<lint, int>> drink(N);
	for (int i = 0; i < N; i++) cin >> drink[i].first >> drink[i].second;

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

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

		if (M - drink[i].second >= 0) {
			ans += drink[i].first * drink[i].second;
			M -= drink[i].second;
		}
		else {
			ans += drink[i].first * M;
			break;
		}
	}
	
	cout << ans << "\n";

	return 0;
}

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

namespace ABC
{
    class ProgramA
    {
        static void Main(string[] args)
        {
            var list = Console.ReadLine().Split(" ").Select(x => long.Parse(x)).Distinct().ToList();
            Console.WriteLine(list.Count);
        }
    }
}


Measured memory_bytes: 28100
#include <stdio.h>
#include <iostream>
#include <climits>
#include <map>
#include <cmath>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <vector>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <utility>
#include <queue>

using namespace std;

#define ll long long
#define sl(n) scanf("%lld", &n)
#define sf(n) scanf("%lf", &n)
#define si(n) scanf("%d", &n)
#define ss(n) scanf("%s", n)
#define pii pair <int, int>
#define pll pair <ll, ll>
#define plp pair <int, pll >
#define pb push_back


int main(){
    ll int n,y,j;

while(cin>>n>>y){
        bool yes=0;

        for(int i=0;i<=n;i++){

            for(int k=0;k<=n;k++){
                    if(i+k<=n){

j=n-(i+k);

if(i*10000+k*5000+j*1000==y){

    yes=1;

cout<<i<<" "<<k<<" "<<j<<endl;
break;
}
                    }

            }
            if(yes){
                break;
            }
        }




if(!yes){


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


}



}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <utility>
#define int long long
using namespace std;
const int MAX_N = 1LL << 17, mod = 1000000007LL;

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

int lcm(int a, int b){
  int d = gcd(a,b);
  return a/d*b;
}

int n;
int dat[2*MAX_N-1][2];

void init(int n_){
  n = 1LL;
  while(n < n_) n *= 2LL;
  for(int i = 0; i < 2*n-1; ++i){
    dat[i][0] = 1LL;
  }
}

void update(){
  for(int i = n-2; i >= 0; --i){
    int d = gcd(dat[i*2+1][0],dat[i*2+2][0]);
    dat[i][0] = dat[i*2+1][0]/d*dat[i*2+2][0];
    dat[i][1] = (((dat[i*2+2][0]/d)%mod*dat[i*2+1][1])%mod + ((dat[i*2+1][0]/d)%mod*dat[i*2+2][1])%mod)%mod;
  }
}

//[a, b)???lcm??¨ret??????????±??????????
pair<int,int> query(int a, int b, int k, int l, int r){
  if(r <= a || b <= l) return make_pair(1LL,0LL);
  if(a <= l && r <= b) return make_pair(dat[k][0],dat[k][1]);
  else{
    pair<int,int> vl = query(a,b,k*2+1,l,(l+r)/2);
    pair<int,int> vr = query(a,b,k*2+2,(l+r)/2,r);
    int d = gcd(vl.first,vr.first);
    int c = ((vr.first/d)%mod*vl.second%mod + (vl.first/d)%mod*vr.second%mod)%mod;
    return make_pair(vl.first/d*vr.first,c);
  }
}

signed main(){
  int N, Q;
  cin >> N >> Q;
  int P[N];
  for(int i = 0; i < N; ++i){
    cin >> P[i];
    --P[i];
  }
  init(N);
  for(int i = 0; i < N; ++i){
    int cur = P[i], t = 1, c = (i+1)%mod;
    while(cur != i){//??¶?´??????????40?????\?????§??¢??????
      c += (cur + 1)%mod;
      c %= mod;
      cur = P[cur];
      ++t;
    }
    dat[i+n-1][0] = t;
    dat[i+n-1][1] = c;
  }
  update();
  int l, r;
  for(int i = 0; i < Q; ++i){
    cin >> l >> r;
    --l;
    cout << query(l,r,0,0,n).second%mod << endl;
  }
  return 0;
} 

/*
int main(){
  int N, Q;
  cin >> N >> Q;
  int P[N];
  for(int i = 0; i < N; ++i){
    cin >> P[i];
    --P[i];
  }
  int LCM[N+1], GCD[N+1], T[N], C[N];
  for(int i = 0; i < N; ++i){
    int cur = P[i], t = 1, c = (i+1)%mod;
    while(cur != i){//??¶?´??????????40?????\?????§??¢??????
      c += (cur + 1)%mod;
      cur = P[cur];
      ++t;
    }
    T[i] = t;
    C[i] = c;
  }
  GCD[0] = T[0];
  LCM[0] = T[0];
  for(int i = 0; i < N-1; ++i){
    GCD[i+1] = gcd(GCD[i],T[i+1]);
    LCM[i+1] = lcm(LCM[i],T[i+1]);
  }
  int C_[N];
  C_[0] = C[0];
  for(int i = 1; i < N; ++i){
    C_[i] = LCM[i]/GCD[i]*C[i] + LCM[i]/LCM[i-1]*C_[i-1];
  }
  for(int i = 0; i < N; ++i){
    cout << C_[i] << " ";
  }cout << endl;
  
  int l, r;
  for(int i = 0; i < Q; ++i){
    cin >> l >> r;
    --l;--r;
    int ans, k;
    if(l == 0){
      k = LCM[r]*GCD[r];
      ans = C_[r]/LCM[r]*k - C_[l]/LCM[l]*k;
    }else{
      k = LCM[r]/LCM[l-1]*GCD[r];
      ans = C_[r]/LCM[r]*k - C_[l]/LCM[l]*k;
    }
    ans %= mod;
    cout << ans << endl;
  }

  return 0;
}
*/

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

using ll=long long;
using Hash=ll;
const Hash MOD=1e9+9;
const Hash A=124534;
int h,w;
int c;

int main(){
    cin>>h>>w;
    vector<string> s(h);
    for(int i=0;i<h;i++) cin>>s[i];
    
    c=(h+1)/2;
    int comb=(1<<c)-1;

    while(comb<1<<h){
        vector<string> f=s;
        int id=0;
        for(int i=0;i<h;i++){
            if((comb>>i)&1){
                swap(f[id],f[i]);
                id++;
            }
        }
        assert(id==c);
        vector<Hash> hob(w);
        vector<Hash> hrb(w);
        Hash pAnc=1;
        for(int i=c;i<h;i++) pAnc=pAnc*A%MOD;
        for(int j=0;j<w;j++){
            Hash x=1;
            for(int i=0;i<c;i++) x=x*A%MOD;
            for(int i=c;i<h;i++){
                hob[j]+=f[i][j]*x;
                hob[j]%=MOD;
                x=x*A%MOD;
            }
            x=1;
            for(int i=h-1;i>=c;i--){
                hrb[j]+=f[i][j]*x;
                hrb[j]%=MOD;
                x=x*A%MOD;
            }
        }
        vector<int> perm(c);
        iota(perm.begin(),perm.end(),0);
        do{
            unordered_set<ll> hs;
            for(int j=0;j<w;j++){
                Hash vo=hob[j];
                Hash x=1;
                for(int i=0;i<c;i++){
                    vo+=f[perm[i]][j]*x;
                    vo%=MOD;
                    x=x*A%MOD;
                }
                Hash vr=hrb[j];
                x=pAnc;
                for(int i=c-1;i>=0;i--){
                    vr+=f[perm[i]][j]*x;
                    vr%=MOD;
                    x=x*A%MOD;
                }
                
                if(hs.count(vr*MOD+vo)){
                    hs.erase(vr*MOD+vo);
                }
                else{
                    hs.insert(vo*MOD+vr);
                }
            }
            if(hs.size()==0 || hs.size()==1 && *hs.begin()/MOD==*hs.begin()%MOD){
                cout<<"YES"<<endl;
                return 0;
            }
        }while(next_permutation(perm.begin(),perm.end()));
        int x=comb&-comb,y=comb+x;
        comb=((comb&~y)/x>>1)|y;
    }
    cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin >> n >> m;
  vector<vector<char>> a(n,vector<char> (n));
  vector<vector<char>> b(m,vector<char> (m));
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cin >> a[i][j];
    }
  }
  for(int i=0;i<m;i++){
    for(int j=0;j<m;j++){
      cin >> b[i][j];
    }
  }
  bool c=false;
  for(int i=0;i<n-m+1;i++){
    for(int j=0;j<n-m+1;j++){
      bool ans=true;
      for(int k=0;k<m;k++){
        for(int l=0;l<m;l++){
          if(b[k][l]!=a[i+k][j+l]){
            ans=false;
          }
        }
      }
      if(ans){
        c=true;
      }
    }
  }
  if(c){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
   int A,B;
   while(1){
   scanf("%d%d",&A,&B);
   if(A == 0 && B == 0)
    {break;}
   else if(A>B)
   {
       printf("%d %d\n",B,A);
   }
   else if(A<B)
   {
       printf("%d %d\n",A,B);
   }
   else if(A==B)
   {
       printf("%d %d\n",A,B);

   }
   }
    return 0;
}



Measured memory_bytes: 2568
n, k = map(int, input().split())
s = input()
RLcnt = s.count("RL")
cnt = 0 + (s[0] == "L") + (s[-1] == "R")

res = RLcnt - k

if res >= 0:
  print(n - (res * 2 + cnt))
else:
  print(n - 1)
  

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

using namespace std;

int main()
{
//    freopen("in.txt","r",stdin);
    int b1[15][15];


    memset(b1,0,sizeof(b1));

    int n;
    cin>>n;

    int b,f,r,v;
    while(n--)
    {
        cin>>b>>f>>r>>v;
        b1[(b-1)*4+f-1][r-1]+=v;

    }
    for(int i =1;i<16;i++)
    {
        for(int j=0;j<10;j++)
        {
            if(i%4==0)
                cout<<"##";
            else
                cout<<" "<<b1[i-1][j];
        }
        cout<<endl;
    }



}



Measured memory_bytes: 3020
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define erep(i,a,n) for(int i = a;i<=n;i++)
typedef long long ll;
#define int long long
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define P pair<int,int>
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

signed main(){
  int a;
  cin >> a;
  double b;
  cin >> b;
  b *= 100;
  int c = round(b);
  a *= c;
  a /= 100;
  cout << a << endl;
}

Measured memory_bytes: 3764
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import *
from bisect import bisect_left, bisect_right
import sys
sys.setrecursionlimit(2147483647)
input = sys.stdin.readline
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def LS(): return list(map(list, input().split()))
def S(): return list(input().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = 1e10
input=lambda:sys.stdin.readline().rstrip()
#solve
def solve():

    n = int(input())
    edg = [[] for _ in range(n)]
    dp = [None] * n
    for i in range(1,n):
        u = int(input()) - 1
        edg[u].append(i)
        edg[i].append(u)

    def dfs(v,p=-1)->int:
        if (dp[v] is not None): return dp[v]
        if (edg[v] == [p]):
            dp[v] = 0
            return 0
        tmp = []
        for nv in edg[v]:
            if (nv == p): continue
            tmp.append(dfs(nv,v))
        dp[v] = max(1 + i + x for i, x in enumerate(sorted(tmp, reverse=1)))
        return dp[v]
    
    print(dfs(0))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 142768
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (int i = 0; i < n; i++)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ul N, A, B, C, D;
  string S;
  cin >> S;
  std::string target = "BC";      // 検索文字列
  std::string replacement = "D";  // 置換文字列
  if (!target.empty()) {
    std::string::size_type pos = 0;
    while ((pos = S.find(target, pos)) != std::string::npos) {
      S.replace(pos, target.length(), replacement);
      pos += replacement.length();
    }
  }
  ul a_count = 0;
  ul ans = 0;
  ul i = 0;
  ul goal = S.size();
  while (i != goal) {
    if (S[i] == 'A') {
      ++a_count;
    } else if (S[i] == 'D') {
      ans += a_count;
    } else {
      a_count = 0;
    }
    ++i;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout<<setprecision(7);
    
    ll n, k, x; cin>>n>>k;
    vector<double> p(n);
    loop(n){
        cin>>x;
        p[i] = (x+1)/2.0;
    }

    double sum = 0, t;
    loop(k) sum += p[i];
    t = sum;

    for(ll i = k; i<n; i++){
        t = t +p[i] - p[i-k];
        sum = max(t, sum);
    }
    cout<<sum<<"\n";
    return 0;
}

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

const char SEP[2] = {',','.'};

int main() {
  string str;
  getline(cin, str);
  for(int i = 0; i < 2; ++i)
    replace(str.begin(), str.end(), SEP[i], ' ');
  stringstream ss;
  ss << str;
  bool flag = false;
  while(ss >> str) {
    if(str.size() >= 3 && str.size() <= 6){
      if(flag) cout << " ";
      else flag = true;
      cout << str;
    }
  }
  cout << endl;
  return 0;
}

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

class UnionFind
{
private:
    vector<int> parents;

public:
    UnionFind(int n) : parents(n)
    {
        for (int i = 0; i < n; i++)
        {
            parents.at(i) = -1;
        }
    }

    bool is_root(int x)
    {
        return parents.at(x) < 0;
    }

    int size(int x)
    {
        return -parents.at(find(x));
    }

    int find(int x)
    {
        if (is_root(x))
            return x;
        parents.at(x) = find(parents.at(x));
        return parents.at(x);
    }

    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size(x) < size(y))
            swap(x, y);
        parents.at(x) -= size(y);
        parents.at(y) = x;
    }

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

class Edge
{
public:
    int u, v, cost;
    Edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
    bool operator<(const Edge &other) const
    {
        return cost > other.cost;
    }
};

int main()
{
    int N;
    cin >> N;
    vector<int> x(N), y(N);
    for (int i = 0; i < N; i++)
    {
        cin >> x.at(i) >> y.at(i);
    }

    vector<pair<int, int>> points(N);
    vector<pair<int, int>> points_by_x(N);
    vector<pair<int, int>> points_by_y(N);
    for (int i = 0; i < N; i++)
    {
        points.at(i) = make_pair(x.at(i), y.at(i));
        points_by_x.at(i) = make_pair(x.at(i), i);
        points_by_y.at(i) = make_pair(y.at(i), i);
    }
    sort(points_by_x.begin(), points_by_x.end());
    sort(points_by_y.begin(), points_by_y.end());

    priority_queue<Edge> q;
    int id_prev = points_by_x.at(0).second;
    pair<int, int> p_prev = points.at(id_prev);
    for (int i = 1; i < N; i++)
    {
        int id = points_by_x.at(i).second;
        pair<int, int> p = points.at(id);
        Edge e = Edge(id_prev, id, min(abs(p.first - p_prev.first), abs(p.second - p_prev.second)));
        q.push(e);
        id_prev = id;
        p_prev = p;
    }
    id_prev = points_by_y.at(0).second;
    p_prev = points.at(id_prev);
    for (int i = 1; i < N; i++)
    {
        int id = points_by_y.at(i).second;
        pair<int, int> p = points.at(id);
        Edge e = Edge(id_prev, id, min(abs(p.first - p_prev.first), abs(p.second - p_prev.second)));
        q.push(e);
        id_prev = id;
        p_prev = p;
    }

    int res = 0;
    UnionFind tree = UnionFind(N);
    while (!q.empty())
    {
        Edge e = q.top();
        q.pop();
        if (!tree.same(e.u, e.v))
        {
            res += e.cost;
            tree.unite(e.u, e.v);
        }
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 9524
<?php

    list($a, $b, $c) = explode(" ",trim(fgets(STDIN)));
    $count = 0;
    
    for($i = $a; $i <= $b; $i++){
        if($c % $i == 0) {
            $count++;
        }
    }     
    
    echo $count."\n";
 

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


int cmp(const void *a,const void *b){
    if(*(int*)a>*(int*)b){return 1;}
    else if(*(int*)a<*(int*)b){return -1;}
    else {return 0;}
}


int main(void){
int a,b,c,d;
scanf("%d %d %d %d",&a,&b,&c,&d);
for(;;){
    c=c-b;
    if(c<=0){printf("Yes");return 0;}
    a=a-d;
    if(a<=0){printf("No");return 0;}
}

}


Measured memory_bytes: 1732
#include <iostream>

using namespace std;

int main(){
    int N, K;
    long a[15];
    long ans = 1e+15;
    cin >> N >> K;
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 1; i <= (1<<N)-1; i++){
        int cnt = 0;
        for(int j = 0; j < N; j++){
            int m = 1<<j;
            if(i&m) cnt++;
        }
        if(cnt == K){
            sum++;
            long prev = 0;
            long tmp = 0;
            for(int j = 0; j < N; j++){
                int m = 1<<j;
                if(i&m) {
                    tmp += max(prev+1-a[j], (long)0);
                    //cout << max(prev+1-a[j], (long)0) << endl;
                    prev = max(prev+1, a[j]);
                }else{
                    prev = max(prev, a[j]);
                }
                
            }
            ans = min(tmp, ans);
            //cout << tmp << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 888
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<map>
#include<queue>
#include<cassert>
#include<cmath>
#define rep(i,n) for(int i=0;i<n;i++)
#define fr(i,c) for(__typeof (c.begin()) i=c.begin(); i!=c.end(); i++)
#define all(c) (c).begin(), (c).end()
#define mp make_pair
#define pb push_back
using namespace std;

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

int h,w,q;
int a[50000],b[50000],o[50000];
bool row[50000],col[50000];
int main(){
  while(cin>>h>>w>>q,h){
    rep(i,q)cin>>a[q-i-1]>>b[q-i-1]>>o[q-i-1];
    memset(row,0,sizeof(row)); memset(col,0,sizeof(col));
    ll ans=0;
    int nrow=0, ncol=0;
    rep(i,q){
      if(a[i]==0){
        if(row[b[i]])continue;
        row[b[i]]=1; nrow++;
        if(o[i])ans+=w-ncol;
      }
      else{
        if(col[b[i]])continue;
        col[b[i]]=1; ncol++;
        if(o[i])ans+=h-nrow;
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll X, Y;
  cin>>X>>Y;
  if(abs(X-Y)<=1) cout<<"Brown"<<endl;
  else cout<<"Alice"<<endl;
}


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

using namespace std;
typedef long long ll;

int main()
{
	int H,W,h,w;
	scanf("%d %d",&H,&W);
	scanf("%d %d",&h,&w);
	int ans=H*W-h*W-H*w+h*w;
	printf("%d\n",ans);
	return 0;
}



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

using namespace std;

int main(){
  char a, b;
  cin >> a >> b;

  if(a == 'H' && b == 'H'){
    cout << "H" << endl;

  }else if(a == 'H' && b == 'D'){
    cout << "D" << endl;

  }else if(a == 'D' && b == 'H'){
    cout << "D" << endl;

  }else if(a == 'D' && b == 'D'){
    cout << "H" << endl;

  }

}


Measured memory_bytes: 3496
#include <bits/stdc++.h>
using namespace std;
int main()
{
    long long n, m;
    cin >> n >> m;

    long long ans = 0;
    if(m >= n * 2)
    {
        m -= n * 2;
        ans += n;
        ans += m / 4;
    }
    else
    {
        ans = m / 2;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int main()
{
    int n;
    while (cin >> n, n) {
        int count = 0;
        bool lfoot = false;
        bool rfoot = false;
        bool before = false;
        for (int i = 0; i < n; i++) {
            string s;
            cin >> s;
            if (s == "lu")
                lfoot = true;
            if (s == "ru")
                rfoot = true;
            if (s == "ld")
                lfoot = false;
            if (s == "rd")
                rfoot = false;
            if (lfoot == rfoot && lfoot != before) {
                count++;
                before = lfoot;
            }
        }
        cout << count << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int main(){
  int N;
  while(cin >> N && N){
    const int H = 5010;
    const int W = 5;
    bool block[H][W] = {};
    int height[W] = {};
    int n_h = 0;
    REP(iter, N){
      int d, l, bx;
      cin >> d >> l >> bx;
      bx --;
      if(d == 1){
        // yoko
        int h = 0;
        for(int x = bx; x < bx + l; x++) h = max(h, height[x]);
        for(int x = bx; x < bx + l; x++) block[h][x] = true;
        bool line = true;
        for(int x = 0; x < W; x++) if(!block[h][x]) line = false;
        if(line){
          for(int x = 0; x < W; x++) block[h][x] = false;
        }
      }else if(d == 2){
        // tate
        for(int y = height[bx]; y < height[bx] + l; y++)
          block[y][bx] = true;
        for(int y = height[bx]; y < height[bx] + l; y++){
          bool line = true;
          for(int x = 0; x < W; x++) if(!block[y][x]) line = false;
          if(!line) continue;
          for(int x = 0; x < W; x++) block[y][x] = false;
        }
      }
      bool new_block[H][W] = {};
      int new_height[W] = {};
      int new_nh = 0;
      int curr = 0;
      /*
      for(int y = n_h + 5; y >= 0; y--){
        debug(block[y], block[y] + 5);
      }
      cout << endl;
      */
      for(int y = 0; y < n_h + 5; y++){
        bool clear = true;
        for(int x = 0; x < W; x++) if(block[y][x]) clear = false;
        if(clear) continue;
        for(int x = 0; x < W; x++)if(block[y][x]){
          block[y][x] = false;
          block[curr][x] = true;
          new_height[x] = curr + 1;
        }
        new_nh = ++curr;
      }
      //memcpy(block, new_block, sizeof(block));
      memcpy(height, new_height, sizeof(height));
      n_h = new_nh;
    }
    int ans = 0;
    REP(y, H)REP(x, W) ans += block[y][x];
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 1188
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(sx:i64 sy:i64 tx:i64 ty:i64));
    let w = (tx - sx) as usize;
    let h = (ty - sy) as usize;
    //(下)-[左]-[上]-(右)-(左)-[下]-[右]-(上)
    //座標の差をw/hとする
    //U*h、R*w、D*h、L*(w+1)、U*(h+1)、R*(w+1)、D*1、R*1、D*(h+1)、L*(w+1)、U*1
    //右:R、左:L、上:D、下:U
    std::iter::empty()
        .chain(std::iter::repeat('U').take(h))
        .chain(std::iter::repeat('R').take(w))
        .chain(std::iter::repeat('D').take(h))
        .chain(std::iter::repeat('L').take(w + 1))
        .chain(std::iter::repeat('U').take(h + 1))
        .chain(std::iter::repeat('R').take(w + 1))
        .chain(std::iter::repeat('D').take(1))
        .chain(std::iter::repeat('R').take(1))
        .chain(std::iter::repeat('D').take(h + 1))
        .chain(std::iter::repeat('L').take(w + 1))
        .chain(std::iter::repeat('U').take(1))
        .collect::<String>()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "0 0 1 2" => "UURDDLLUUURRDRDDDLLU",
    test2: "-2 -2 1 1" => "UURRURRDDDLLDLLULUUURRURRDDDLLDL",
}


Measured memory_bytes: 4352
s=input()
a=[]
b=[]
z=0
for i in range((len(s)-1)//2):
  a.append(s[i])
for i in range((len(s)-1)//2+2-1,len(s)):
  b.append(s[i])
for i in range((len(s)-1)//2):
  if a[i]==a[(len(s)-1)//2-1-i]:
    z+=1
for i in range((len(s)-1)//2):
  if b[i]==b[(len(s)-1)//2-1-i]:
    z+=1
for i in range(len(s)):
  if s[i]==s[len(s)-i-1]:
    z+=1
if z==len(s)-1+len(s):
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

const ll MOD = 1000000007LL;
const double PI = 3.14159265358979323846;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

// computational complexity: o(log(max(a, b))) 
inline ull get_gcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return get_gcd(b, a % b);
}

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

	ll N, X, D;
	cin >> N >> X >> D;

	if (D == 0) {
		if (X == 0) {
			cout << 1 << endl;
		}
		else {
			cout << N + 1 << endl;
		}
		return 0;
	}

	ll d = get_gcd(abs(X), abs(D));
	X /= d;
	D /= d;
	if (D < 0) {
		X *= -1;
		D *= -1;
	}

	ll res = 0;
	ll count, prev_val;
	vector<pair<ll, ll>> boundaries;
	for (ll i = 0; i <= N; ++i) {
		if (i >= D) break;
		boundaries = vector<pair<ll, ll>>();
		for (ll j = 0; i + D * j <= N; ++j) {
			boundaries.emplace_back(
				X * j + (i + D * j - 1) * (i + D * j) / 2, 1
			);
			boundaries.emplace_back(
				X * j + ((N - 1) + (N - 1 - (i + D * j - 1))) * (i + D * j) / 2 + 1, -1
			);
		}
		sort(boundaries.begin(), boundaries.end());

		count = 0;
		for (ll idx = 0; idx < boundaries.size(); ++idx) {
			if (count == 0) {
				prev_val = boundaries[idx].first;
			}
			count += boundaries[idx].second;
			if (count == 0) {
				res += boundaries[idx].first - prev_val;
			}
		}
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 9964
import fractions

A, B = list(map(int, input().split()))

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

l = sorted(list(set(make_divisors(A)) & set(make_divisors(B))))
#print(l)
i = 0
while i < len(l):
    v = l[i]
    if v == 1:
        i += 1
        continue
    l = l[0:i+1] + list(filter(lambda x: x % v != 0, l[i+1:]))
#    print(l)
    i += 1
print(len(l))


Measured memory_bytes: 7284
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long int gcd(long int a, long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long int lcm(long int a, long int b){
  return a * b / gcd(a, b);
}


// min
int main(void){
  long int n, k;
  long int ans = 0;
  long int a[100001];
  long int b[100001];
  long long int cnt[100001] = {0};

  // nとkを取得して
  scanf("%ld%ld", &n, &k);

  // a[], b[] も取得する
  for(long int i = 0; i < n; i++){
    scanf("%ld%ld", &a[i], &b[i]);
    // どの値が何個あるか格納しておく
    cnt[a[i]] += b[i];
  }

  /* 
  for(long int i = 0; i < n; i++){
    for(long int j = 0; j < b[i]; j++){
      cnt[a[i]]++;
    }
  } 
  */
  //  qsort(c, n, sizeof(long long int), compare_int);
  //  qsort(r, n, sizeof(long int), compare_int_small)  //  fprintf(stderr, "l[0] = %ld  r[0] = %ld\n", l[0], r[0]);

  long long int j = 0;
  while(k > 0){
      fprintf(stderr, "j = %lld\n", j);
    
      //    if(k - cnt[j] >= 0){
      fprintf(stderr, "if j = %lld\n", j);
      ans = j;
      k -= cnt[j];
      //    }else{
      //      ans = j;
      fprintf(stderr, "else j = %lld\n", j);
      //    }
    j++;
  }
  
  
  printf("%ld\n", ans);
  
  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    string a, b, c, str;
    cin >> a >> b >> c;
    str = "";
    transform(a.begin(), a.end(), a.begin(), ::toupper);
    transform(b.begin(), b.end(), b.begin(), ::toupper);
    transform(c.begin(), c.end(), c.begin(), ::toupper);
    cout << a[0] << b[0] << c[0];
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e7
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


int main(){
    int n,m;cin>>n>>m;
    vector<P>p;
    rep(i,m){
        int a,b;cin>>a>>b;
        //if(a==1 && b==0){cout<<-1;return 0;}
        p.emplace_back(a,b);
    }
    int res = INF;
    REP(i,pow(10,n-1)-1,pow(10,n)-1){
      if(n!=1 && i == pow(10,n-1)-1)continue;
        string s = to_string(i);
        bool f = true;
        for(auto x:p){
            x.first--;
                if(s[x.first]-'0'!=x.second){
                    f = false;
                    break;
                }
        
    }
    if(f){res = i;break;}
}
cout<<(res!=INF?res:-1);
}



Measured memory_bytes: 256
import static java.util.Arrays.deepToString;

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int m = sc.nextInt();
			int n = sc.nextInt();
			if (n == 0 && m == 0) break;
			int[] w = new int[n];
			for (int i = 0; i < n; i++) w[i] = sc.nextInt();
			int hi = 10000000;
			int lo = 1;
			while (hi - lo > 1) {
				int mid = (hi + lo) / 2;
				if (possible(mid, m, w)) hi = mid; else lo = mid;
			}
			System.out.println(hi);
		}
	}
	boolean possible(int W, int m, int[] w) {
		int need = 0;
		need++;
		int pos = 0;
		for (int i = 0; i < w.length; i++) {
			if (pos + w[i] > W) {
				need++;
				pos = w[i];
				if (w[i] > W) return false;
			} else {
				pos += w[i];
			}
		}
		return need <= m;
	}
}

Measured memory_bytes: 20960
#include<iostream>
#define MAX 100000
#define NIL -1
using namespace std;

int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int H,i,A[MAX+1];
  cin>>H;
  for(int i=1;i<H+1;i++)cin>>A[i];

  for(i=1;i<H+1;i++){
    cout<<"node "<<i<<": key = "<<A[i]<<", ";
    if(parent(i)>=1)cout<<"parent key = "<<A[parent(i)]<<", ";
    if(left(i)<=H)cout<<"left key = "<<A[left(i)]<<", ";
    if(right(i)<=H)cout<<"right key = "<<A[right(i)]<<", ";
    cout<<endl;
    }
    return 0;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> P(N + 1);
  int m = N + 10;
  int ans = 0;
  rep1(i, N) {
    cin >> P.at(i);
    m = min(m, P.at(i));
    if (m == P.at(i)) ans++;
  }

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


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <stdio.h>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    double S, L, h;
    double PI = acos(-1);
    double rad = c * PI / 180;
    h = b * sin(rad);
    S = a * h / 2;
    L = a + b + sqrt(a * a + b * b - 2 * a * b * cos(rad));
    printf("%f\n", S);
    printf("%f\n", L);
    printf("%f\n", h);
    return 0;
}



Measured memory_bytes: 3384
# ABC 062
import math
def getInt(): return int(input())
def getIntList(): return [int(x) for x in input().split()]
def getIntFromRows(n): return [int(input()) for i in range(n)]
def getIntMat(n):
    mat = []
    for i in range(n): mat.append(getIntList())
    return mat

def zeros(n): return [0 for i in range(n)]
def zeros2(n, m): return [[0 for i in range(m)] for j in range(n)]
N1097 = 10**9 + 7 
debug = True
def db(x): 
    if debug: print(x)

debug = True
h,w = getIntList()
a = ['#'*(w+2)]
for i in range(h):
    a.append('#'+input()+'#')
a.append('#'*(w+2))
for i in range(h+2):
    print(a[i])



Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=b-1; (ll)(a)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

vector<ll> a;
ll n, k;
bool chk(ll x){
    ll sum=0;
    rep(i, n)   sum += (a[i]-1)/x;
    return sum<=k;
}
int main(){
    cin >> n >> k;
    a.resize(n);
    ll lb=0, ub=LINF;
    rep(i, n) cin >> a[i];
    while(1<ub-lb){
        ll mid = (lb+ub)/2;
        if(chk(mid)) ub = mid;
        else lb = mid;
        //cout << lb << ' ' << ub << endl;
    }
    cout << ub << endl;
}


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

int main() {
	int n;
	int h[30];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < i; j++) {
			if (h[i] < h[j]) {
				goto LABEL;
			}
		}
		// cout << i << endl;
		ans++;
LABEL: ;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    rep(i, N) cin >> a.at(i);

    sort_g(a);
    int i = 0;
    int Alice = 0;
    int Bob = 0;
    while(i < N) {
        if(i % 2 != 1) Alice += a.at(i);
        else Bob += a.at(i);
        i++;
    }

    dump(Alice);
    dump(Bob);

    cout << Alice - Bob << endl;
}

Measured memory_bytes: 256