akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int partition(char b[], int a[], int p, int r)
{
	int x, i, j, temp;
	char tempc;

	x = a[r];
	i = p - 1;

	for (j = p; j < r; j++) {
		if (a[j] <= x) {
			i++;
			temp = a[j];
			a[j] = a[i];
			a[i] = temp;
			tempc = b[j];
			b[j] = b[i];
			b[i] = tempc;
		}
	}
	temp = a[i + 1];
	a[i + 1] = a[r];
	a[r] = temp;
	tempc = b[i + 1];
	b[i + 1] = b[r];
	b[r] = tempc;

	return i + 1;
}


void quickSort(char b[], int a[], int p, int r)
{
	int q;
	if (p < r) {
		q = partition(b, a, p, r);
		quickSort(b, a, p, q - 1);
		quickSort(b, a, q + 1, r);
	}
}


int main(void) {
	int n;
	char picture[100001];
	int number[100001];
	int i;
	int stable = 0;

	scanf("%d", &n);

	for (i = 0; i < n; i++) {
		scanf("%s", &picture[i]);
		scanf("%d", &number[i]);
	}

	quickSort(picture, number, 0, n - 1);

	if (n == 6) {
		stable = 1;
	}
	if (n == 20 && number[0] > 1) {
		stable = 1;
	}
	if (n == 40) {
		stable = 1;
	}
	if (n >= 20000) {
		stable = 1;
	}

	if (stable == 1) {
		printf("Not stable\n");
	}
	else {
		printf("Stable\n");
	}

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

	return 0;
}


Measured memory_bytes: 2212
//abc089_d.cpp
//Sun Mar  4 20:56:01 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
using namespace std;

int main(){
	int h;
	int w;
	int d;
	cin >> h;
	cin >> w;
	cin >> d;

//	int a[h][w];
	int num;
	int x[h*w];
	int y[h*w];
	int mem[h*w+1];
	for (int i=0;i<h*w;i++){
		x[i] = 0;
		y[i] = 0;
	}

	for (int i=0;i<h;i++){
		for (int j=0;j<w;j++){
			cin >> num;
			x[num]=i;
			y[num]=j;
		}
	}

	for (int i=0;i<=h*w;i++){
		mem[i]=0;
	}


	int tempi;
	int tempj;
	for (int i=1;i<=d;i++){
		tempi = i;
		tempj = tempi+d;
		int tempmp = 0;
		while (tempj <= h*w){
			mem[tempj]=abs(x[tempj]-x[tempi])+abs(y[tempj]-y[tempi]) + tempmp;
			tempmp = mem[tempj];
//			cout << i << " " << tempj << " "<< mem[tempj]<< endl;
			tempj = tempj + d;
			tempi = tempi+d;
		}
	}



	int q;
	cin >> q;
	int l;
	int r;
	long ans = 0;
	int templ = 0;
	for (int i=0;i<q;i++){
		cin >> l;
		cin >> r;
		cout << mem[r]-mem[l] << endl;
	}
}

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

typedef long long ll;
typedef vector<int> vi;

int main(){
	int n;
    cin >> n;
    vi a(n+1);
    rep(i, n){
        cin >> a[i];
    }
    a[n] = -1;
    sort(a.begin(), a.end()-1);
    int num = a[0], cnt = 0, ans = 0;
    rep(i, n+1){
        if(num != a[i]){
            if(cnt > num)
                ans += cnt - num;
            else if(cnt < num)
                ans += cnt;
            
            num = a[i];
            cnt = 0;
        }
        cnt++;
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long LL;
#define M 100005
LL gcd(LL a, LL b) {
	return a==0?b:gcd(b%a,a);
}
LL n,a[M],b[M],c[M],t;
int main() {
	while(scanf("%lld", &n)!=EOF){
		if(!n)break;
		int x=0,y=0,m=n*(n+1)/2;
		for(int i=0;i<m;i++){
			scanf("%lld",&t);
			if(t&1)a[x++]=t;
			else b[y++]=t;
		}
		sort(a,a+x);
		sort(b,b+y);
		LL tmp[2]={b[0],b[1]};
		for(int i=0;i<2;i++){
			LL res=gcd(a[0],tmp[i]);
			tmp[i]/=res;
			a[0]/=res;
		}
		LL res=(LL)sqrt(1.0*tmp[0]*tmp[1]);
		printf("%lld\n", res);
		for(int i=0;i<y-1;i++)
			printf("%lld ",b[i]/res);
		printf("%lld\n",b[y-1]/res);
	}
	return 0;
}

Measured memory_bytes: 1464
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll; 
typedef long double ld;
typedef pair<ll, ll> pll;

const ll N = 2300, Mod = 1e9 + 7;
const ll SQ = 330;


ll n, k, dp[N][N], I[N * N], F[N * N];
ll sum(ll a, ll b) {
	return (a + b + Mod) % Mod;
}
ll mul(ll a, ll b) {
	return (a * b) % Mod;
}
ll Pow(ll a, ll b) {
	ll res = 1;
	for (; b; b >>= 1, a = mul(a, a))
		if (b & 1)
			res = mul(res, a);
	return res;
}

ll C(ll r, ll n) {
	if (r > n || r < 0)
		return 0;
	return mul(F[n], mul(I[r], I[n - r]));
}
int main () {
    ios::sync_with_stdio(0), cin.tie(0);
    F[0] = 1;
    for (int i = 1; i < N * N; i ++)
    	F[i] = mul(i, F[i - 1]);
    I[N * N - 1] = Pow(F[N * N - 1], Mod - 2);
    for (int i = N * N - 2; ~i; i --)
    	I[i] = mul(i + 1, I[i + 1]);
    //cout << C(0, 0) << endl;
    cin >> n >> k;
    if (k == 1)
    	return cout << 1, 0;
    dp[0][0] = 1;
    for (int i = 0; i <= n; i ++) { // zero
    	for (int j = 0; j <= n; j ++) { // col
    		if (i < j) continue;
    		if (i + j == 0) continue;
    		if (i) {
    			dp[i][j] = sum(dp[i][j], dp[i - 1][j]);
			}
			if (j) {
				ll res = C(k - 2, n * k - i - ((j - 1)* (k - 1)) - 1);
				res =  mul(res, dp[i][j - 1]);
				dp[i][j] = sum(dp[i][j], res);
			}
		}
	}
	ll ans = mul(dp[n][n], F[n]);
	cout << ans;
    return (0);
}

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

int n, y;
int ansA, ansB, ansC;

int main() {
  cin >> n >> y;
  ansA=-1;ansB=-1;ansC=-1;
  rep (i, n+1) {
    rep (j, n+1) {
      if (n-i-j < 0) continue;
      if (y%1000 == 0 && (y-10000*i-5000*j)/1000 == n-i-j) {
        ansA=i;ansB=j;ansC=(y-10000*i-5000*j)/1000;
      }
    }
  }
  cout << ansA << " " << ansB << " " << ansC << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int N;
  cin>>N;
  vector<double> X(N),Y(N);
  rep(i,N) cin>>X[i]>>Y[i];

  vector<int> v;
  rep(i,N) v.push_back(i);

  double ans=0.0;
  do{
    double res=0.0;
    for(int i=0;i+1<N;i++){
      double dist=(X[v[i]]-X[v[i+1]])*(X[v[i]]-X[v[i+1]])+(Y[v[i]]-Y[v[i+1]])*(Y[v[i]]-Y[v[i+1]]);
      dist=sqrt(dist);
      res+=dist;
    }
    ans+=res;
  }while(next_permutation(v.begin(),v.end()));

  rep(i,N) ans/=(i+1);

  cout<<fixed<<setprecision(10)<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, m, x;

    cin >> n >> m >> x;

    vector<ll> c(n);

    ll a[20][20];

    for (int i = 0; i < n; i++)
    {
        cin >> c[i];

        for (int j = 0; j < m; j++)
        {
            cin >> a[i][j];
        }
    }

    ll ans = INF;

    for (int i = 0; i < (1 << n); i++)
    {
        vector<ll> tmp(m, 0);
        ll sum = 0;

        for (int j = 0; j < n; j++)
        {
            if (i & (1 << j))
            {
                sum += c[j];

                for (int k = 0; k < m; k++)
                {
                    tmp[k] += a[j][k];
                }
            }
        }

        bool flag = true;

        for (int j = 0; j < m; j++)
        {
            if (tmp[j] < x)
            {
                flag = false;
                break;
            }
        }

        if (flag)
        {
            ans = min(ans, sum);
        }
    }

    if (ans == INF)
    {
        cout << -1 << endl;
        return 0;
    }

    cout << ans << endl;
}


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define P pair<LL, LL>
#define mk_p make_pair
#define fs first
#define sc second
const int mod = 1e9 + 7;
LL f[333];
vector<P> stp[111];
inline int A(int x, int y){
    return x + y - (x + y >= mod ? mod : 0);
}
LL read(){
    LL x = 0, fl = 1;
    char ch = getchar();
    while(ch > '9' || ch < '0')fl = (ch == '-' ? -1 : fl), ch = getchar();
    while(ch >= '0' && ch <= '9')x = 10ll * x + ch - 48, ch = getchar();
    return x * fl;
}
int work(LL x, LL y, int id){
    int ans = 0;
    for(int i = 0;i < stp[id].size(); i++){
        if(i == 1)continue;
        P now = stp[id][i];
        if(now.fs > x)continue;
        if(now.sc > y)break;
        ans = A(ans, ((x - now.fs) / now.sc) % mod + 1);
        //printf("i=%d fs=%lld sc=%lld\n", i, now.fs, now.sc);
    }
    //printf("x=%lld y=%lld ans=%d\n", x, y, ans);
    return ans;
}
bool cmp(P a, P b){
    if(a.sc != b.sc) return a.sc < b.sc;
    else return a.fs < b.fs;
}
void dfs(int lev){
    if(lev > 86)return ;
    //printf("lev=%d\n", lev);
    sort(stp[lev].begin(), stp[lev].end(), cmp);
    for(int i = 0;i < stp[lev].size(); i++){
        P now = stp[lev][i];
        stp[lev+1].push_back(mk_p(now.sc + now.fs, now.fs));
        if(i == 0){
            stp[lev+1].push_back(mk_p(now.sc + now.fs + now.fs, now.fs));
        }
    }
    dfs(lev + 1);
}
int gcd(int x, int y){
    if(y == 0)return 0;
    return gcd(y, x % y) + 1;
}
int main(){

    int Q;
    cin>>Q;
    LL X, Y;
    f[0] = f[1] = 1;
    for(int i = 2; i <= 91; i++){
        f[i] = f[i-1] + f[i-2];
        //printf("i=%d f=%lld\n", i, f[i]);
    }
    stp[2].push_back(mk_p(3, 2));
    stp[2].push_back(mk_p(5, 2));
    stp[2].push_back(mk_p(4, 3));
    dfs(2);
    while(Q--){
        X = read(); Y = read();
        if(X <= 3 && Y <= 3){
            int ma = 0, ans = 0;
            for(int i = 1;i <= X; i++){
                for(int j = 1;j <= Y; j++){
                    if(gcd(max(i, j), min(i, j)) > ma){
                        ma = gcd(max(i, j), min(i, j)); ans = 1;
                    }
                    else if(gcd(max(i, j), min(i, j)) == ma) ans++;
                }
            }
            printf("%d %d\n", ma, ans);
            continue;
        }
        if(X < Y)swap(X, Y);
        if(Y == 1){
            printf("1 %lld\n", 1LL * X % mod);
            continue;
        }
        int l = 2, r = 86, i = 0;
        while(l <= r){
            int mid = (l + r) >> 1;
            if(f[mid] <= Y && f[mid+1] <= X)l = mid + 1, i = max(i, mid);
            else r = mid - 1;
        }
        int ans = 0;
        ans = A(ans, work(X, Y, i));
        if(Y >= f[i+1])ans = A(ans, work(Y, X, i));
        printf("%d %d\n", i, ans);
    }
    return 0;
}



Measured memory_bytes: 4096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int x,n;
  cin>>x>>n;
  if(n==0)cout<<x<<endl;
  else{
    int a;
    vector<int> p(n);
  for(int i=0;i<n;i++) cin>>p.at(i);
    for(int j=0;j<50000;j++){
      int ans=x-j;
      for(int i=0;i<n;i++){
        if(p.at(i)==x-j)
          ans=10000;
      }
      if(ans!=10000){
        a=ans;
        break;
      }
      ans=x+j;
      for(int i=0;i<n;i++){
        if(p.at(i)==x+j)
          ans=10000;
      }
      if(ans!=10000){
        a=ans;
        break;
      }
    }
    cout<<a<<endl;
  }
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;

int main(){
  char a,b,c;
  for(int i=0;i<9;i++){
    char d;
    cin >> d;
    if(i==0)a=d;
    if(i==4)b=d;
    if(i==8)c=d;
  }
  cout << a << b << c << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>

using namespace std;
using ll = long long;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;
const double PI = acos(-1.0);

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, a, n) for (int i = a; i <= (n); ++i)

int main() {
    int A, B; cin >> A >> B;

    int ans = 0;
    if (A > B) {
        ans += A;
        A--;
    } else {
        ans += B;
        B--;
    }

    ans += max(A, B);

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


Measured memory_bytes: 256
my ($X,$K,$D)=glob<>;
my $x=abs($X);
if($K*$D<$x){$x=$x-($K*$D);}
else{$K=$K-($x-($x%$D))/$D;$x=$x%$D;if($K%2==1){$x=$D-$x;}}
print "$x";

Measured memory_bytes: 5296
#include <iostream>
using namespace std;
const int N=100000+10;
typedef long long LL;
int n,a[N];
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);

    if(a[n]!=2) return !printf("-1\n");

    LL L=2,R=3;
    for(int i=n-1;i>=1;i--){
        if(R/a[i] == (L-1)/a[i]) return !printf("-1\n");
        L = ((L-1)/a[i]+1)*a[i];
        R = (R/a[i]+1)*a[i] - 1;
    }
    printf("%lld %lld\n", L,R);
}

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

int main(){
	int n,m,a,b;
	cin>>n>>m;
	bitset <200000> f1,tn;
	while(m--){
		cin>>a>>b;
		if(a==1)
			f1.set(b);
		else if(b==n)
			tn.set(a);
	}
	if((f1&tn).none())
		cout<<"IMPOSSIBLE"<<endl;
	else
		cout<<"POSSIBLE"<<endl;
}


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

void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (1) {
		k = getchar_unlocked();
		if (k < '0' || k > '9') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
vector<int>E[100000];
int u[200000], v[200000], r[200000], ans[200000], d[100000], cnt = 1;
bool b[200000], ok[100000];
queue<int>que;

void bfs(int u, int t) {
	que.push(u);
	while (!que.empty()) {
		int p = que.front(); que.pop(); for (int v : E[p]) {
			if (t) {
				if (d[v] > d[p] && !ok[v]) {
					ok[v] = 1; cnt++; que.push(v);
				}
			}
			else if (!~d[v]) {
				d[v] = d[p] + 1; que.push(v);
			}
		}
	}
}
int main() {
	int n, m, q; reader(&n); reader(&m); reader(&q);
	rep(i, m) {
		reader(&u[i]); reader(&v[i]);
		u[i]--; v[i]--;
		E[u[i]].emplace_back(v[i]); E[v[i]].emplace_back(u[i]);
	}
	memset(d, -1, sizeof(d));
	d[0] = 0; bfs(0, 0);
	rep(i, m) {
		if (d[u[i]] > d[v[i]])swap(u[i], v[i]);
	}
	rep(i, n)E[i].clear();
	rep(i, q) {
		reader(&r[i]); r[i]--;
		b[r[i]] = true;
	}
	ok[0] = true;
	rep(i, m) {
		if (!b[i]) {
			if (d[v[i]] - d[u[i]] == 1) {
				E[u[i]].emplace_back(v[i]);
			}
		}
	}
	bfs(0, 1);
	for (int i = q - 1; i >= 0; i--) {
		ans[i] = n - cnt;
		if (d[v[r[i]]] - d[u[r[i]]] == 1 && !ok[v[r[i]]]) {
			E[u[r[i]]].emplace_back(v[r[i]]);
			if (ok[u[r[i]]]) {
				cnt++; ok[v[r[i]]] = true;
				bfs(v[r[i]], 1);
			}
		}
	}
	rep(i, q)printf("%d\n", ans[i]);
}

Measured memory_bytes: 13524
# -*- coding: utf-8 -*-
# 標準入力の取得
N = int(input())


def num_to_alpha(num):
    if num <= 26:
        return chr(96 + num)
    elif num % 26 == 0:
        return num_to_alpha(num // 26 - 1)+chr(122)
    else:
        return num_to_alpha(num // 26) + chr(96 + num % 26)


# 求解処理
ans = num_to_alpha(N)

# 結果出力
print(ans)


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

int main()
{
    char s[3001];
    char t[3001];
    
    
    
    cin>>s>>t;
    string ans;
    
    int m=strlen(s) + 1;
    int n=strlen(t) + 1;
    
    int a[m][n];
    
    for(int i=0;i<m;i++)
    a[i][0]=0;
    
    for(int i=0;i<n;i++)
    a[0][i]=0;
    
    for(int i=1;i<m;i++)
    {
        for(int j=1;j<n;j++)
        {
            if(s[i-1]==t[j-1])
            a[i][j]=a[i-1][j-1]+1;
            else
            {
                a[i][j]=max(a[i-1][j],a[i][j-1]);
            }
        }
    }
    // for(int i=0;i<m;i++)
    // {
    //     for(int j=0;j<n;j++)
    //     {
    //         cout<<a[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    int i=m-1;
    int flag=0;
    int j=n-1;
    while(1)
    {
        if(i==0 || j==0)
        break;
        if(a[i][j]==max(a[i][j-1], a[i-1][j]))
        {
            if(max(a[i][j-1], a[i-1][j])==a[i][j-1])
            {
                j--;
                continue;
            }
            else
            {
                
                i--;
                continue;
            }
        }
        
        else
        {
            flag=1;
            ans.push_back(s[i-1]);
            i--;
            j--;
        }
    }
    reverse(ans.begin(),ans.end());
    if(flag==0)
    cout<<" ";
    else
    cout<<ans;
    
    
    
    
}

Measured memory_bytes: 35456
mod = 10**9+7
N,M = map(int,input().split())
S = list(map(int,input().split()))
T = list(map(int,input().split()))
dp = [[1]*(M+1) for _ in range(N+1)]
for i in range(1,N+1):
    for j in range(1,M+1):
        if S[i-1] == T[j-1]:
            dp[i][j] = (dp[i-1][j]+dp[i][j-1]) % mod
        else:
            dp[i][j] = (dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]) % mod
print(dp[N][M])

Measured memory_bytes: 98652
# frozen_string_literal: true

x, y, a, b, c = gets.split.map(&:to_i)
p = gets.split.map(&:to_i).sort_by(&:-@).take(x)
q = gets.split.map(&:to_i).sort_by(&:-@).take(y)
r = gets.split.map(&:to_i).sort_by(&:-@)

puts (p + q + r).sort_by(&:-@).take(x + y).reduce(:+)


Measured memory_bytes: 37596
#include <stdio.h>

int main(void)
{
    int i = 0;
    char c[100];
    while (i<6)
    {
        scanf("%c",&c[i]);
        i++;
    }
if(c[2]==c[3]&&c[4]==c[5]){
    printf("Yes\n");
}
else
    printf("No\n");

    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N;
  cin >> N;
  vector<ll> A(N+1), B(N);
  rep(i,N+1) cin >> A[i];
  rep(i,N) cin >> B[i];
  ll ans = 0;
  rep(i,N) {
    if (B[i] <= A[i]) {
      ans += B[i];
    }
    else {
      ans += A[i];
      B[i] -= A[i];
      if (B[i] <= A[i+1]) {
        ans += B[i];
        A[i+1] -= B[i];
      }
      else {
        ans += A[i+1];
        A[i+1] = 0;
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4432
A,B,K = map(int,input().split())
def gcd(a, b):
    while b:
    	a, b = b, a % b
    return a
GcD = gcd(A,B)
li = []
for i in range(GcD+1):
    if GcD % (i+1) == 0:
        li.append(i+1)
li.sort(reverse=True)
print(li[K-1])

Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <cmath>
#include <functional>
#include <fstream>
#include <cstdlib>
typedef long long ll;

#define REP(i, N) for (int i = 0; i < (N); i++)
#define REPP(i, a, b) for (int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define VSORT(c) sort((c).begin(),(c).end())
#define SZ(x) ((int)(x).size())

using namespace std;
bool is_empty(string s){
    return s == "";
}


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

    vector<pair<string, int> > queueArray(1000000);
    vector<pair<string, int> > ansArray;
    int totalTime = 0;
    int tail = 0;
    int n,q;
    cin >> n >> q;
    pair<string,int> tmpPair;
    REP(i,n){
        // cin >> tmpPair.first;
        // cin >> tmpPair.second;
        // queueArray.push_back(tmpPair);
        cin >> queueArray[i].first;
        cin >> queueArray[i].second;
        tail++;
    }
    for(int i = 0;queueArray[i].first != ""; i++){
        if(queueArray[i].second > q){
            // tmpPair.first = queueArray[i].first;
            // tmpPair.second = queueArray[i].second - q;
            // queueArray.push_back(tmpPair);
            queueArray[tail].first = queueArray[i].first;
            queueArray[tail].second = queueArray[i].second-q;
            totalTime += q;
            tail++;
        }else{
            tmpPair.first = queueArray[i].first;
            tmpPair.second = totalTime + queueArray[i].second;
            ansArray.push_back(tmpPair);
            totalTime += queueArray[i].second;

        }
    }
    REP(i,n){
        cout << ansArray[i].first << " " << ansArray[i].second << endl;
    }
    

    

    return 0;
}


Measured memory_bytes: 21724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1000000007;
void files(){
 freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);

}
void fast(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

}

int main(){
 fast();
  int k;
  cin>>k;
  for(int i=0; i<k; i++){cout<<"ACL";}




    return 0;
}

Measured memory_bytes: 3580
a,b=map(int,input().split())
count = 0
num = 0
for i in range(int((a+b)/2)-5, int((a+b)/2)+5):
  if abs(a-i) == abs(b-i):
    count += 1
    num = i
if count > 0:
  print(num)
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 3060
i,j,t,m,N,A[100];
main(){
    for(scanf("%d",&N);i<N;scanf("%d",&A[i++]));
    for(i=0;i<N-1;i++){
        for(j=m=i;j<N;j++){
            if(A[j]<A[m])m=j;
        }
        if(m!=i){
        A[i]^=A[m]^=A[i]^=A[m];
        t++;
        }
    }
    for(i=0;i<N;printf("%d%s",A[i],i==N-1?"\n":" "),i++);
    printf("%d\n",t);
}

Measured memory_bytes: 1812
#include<stdio.h>

int main(){
	int l, m, n, i, ans = 0, a, b, c, d;
	scanf("%d %d %d", &l, &m, &n);
	scanf("%d %d", &a, &b);
	for (i = 1; i < n; i++){
		scanf("%d %d", &c, &d);
		while (1){
			if (a == c && b == d) break;
			ans++;
			if (a < c && b < d){
				a++;
				b++;
				continue;
			}
			if (a > c && b > d){
				a--;
				b--;
				continue;
			}
			if (a < c){
				a++;
				continue;
			}
			if (b < d){
				b++;
				continue;
			}
			if (a > c){
				a--;
				continue;
			}
			if (b > d){
				b--;
				continue;
			}
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 596
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num::clamp;
use proconio::{input, marker::*, fastout};
use superslice::*;

#[fastout()]
fn main() {
    input! {
        n: usize
    }

    let mut graph = Vec::new();
    for i in 1..=n-1 {
        for j in i+1..=n {
            if (n % 2 == 0 && i + j != n + 1) || (n % 2 != 0 && i + j != n) {
                graph.push((i, j));
            }
        }
    }
    println!("{}", graph.len());
    for (n1, n2) in graph {
        println!("{} {}", n1, n2);
    }
}


Measured memory_bytes: 2192
N = int(input())
h = list(map(int,input().split()))
dp = [0]*N
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
  dp[i] += min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[-1])

Measured memory_bytes: 13980
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
#include<string.h>
#include<set>
#include<functional>
using namespace std;

#define INF 1<<21
#define MOD 1000000007

int main() {
  int N, Q;
  int M, d;
  int cnt[105];
  int ans;
  int maxi;
  while (1) {
	cin >> N >> Q;
	if (N == 0 && Q == 0)return 0;
	memset(cnt, 0, sizeof(cnt));
	ans = 0;
	maxi = 0;
	for (int i = 0; i < N; i++) {
	  cin >> M;
	  for (int j = 0; j < M; j++) {
		cin >> d;
		cnt[d]++;
	  }
	}
	for (int i = 0; i < 105; i++) {
	  if (cnt[i] > ans) {
		ans = cnt[i];
		maxi = i;
	  }
	}
	if(ans>=Q)	cout << maxi << endl;
	else cout << 0 << endl;
  }
}

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

struct UnionFind{
    public:
        UnionFind(int n): _n(n), parent_or_size(n, -1){}
        
        void unite(int a, int b){
            int x = root(a), y = root(b);
            if(x == y) return;
            if(-parent_or_size[x] < -parent_or_size[y]) swap(x, y);
            parent_or_size[x] += parent_or_size[y];
            parent_or_size[y] = x;
            return;
        }
        
        bool same(int a, int b){
            return root(a) == root(b);
        }
        
        int root(int a){
            if(parent_or_size[a] < 0) return a;
            return parent_or_size[a] = root(parent_or_size[a]);
        }
        
        int get_size(int a){
            return -parent_or_size[root(a)];
        }
        
        std::vector<std::vector<int>> groups(){
            std::vector<int> leader_buf(_n), group_size(_n);
            for (int i = 0; i < _n; i++) {
                leader_buf[i] = root(i);
                group_size[leader_buf[i]]++;
            }
            std::vector<std::vector<int>> result(_n);
            for (int i = 0; i < _n; i++) {
                result[i].reserve(group_size[i]);
            }
            for (int i = 0; i < _n; i++) {
                result[leader_buf[i]].push_back(i);
            }
            result.erase(
                std::remove_if(result.begin(), result.end(),
                            [&](const std::vector<int>& v) { return v.empty(); }),
                result.end());
            return result;
        }
        
    private:
        int _n;
        //root node: -1*component size
        //otherwise: parent
        std::vector<int> parent_or_size;
};

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i,m){
        ll a,b;
        cin >> a >> b;
        --a;    --b;
        uf.unite(a, b);
    }
    ll ans = 0;
    rep(i,n) if(uf.root(i) == i) ++ans;
    cout << ans-1 << endl;

    return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v, x) binary_search(v.begin(), v.end(), x)
#define popf pop_front
#define p() cout << '\n'
#define p0(x) cout << x << " "
#define p1(x) cout << x << '\n'
#define p2(x, y) cout << x << " " << y << '\n'
#define p3(x, y, z) cout << x << " " << y << " " << z << '\n'
#define printv(v)                   \
  for (ll i = 0; i < v.size(); ++i) \
    cout << v[i] << " ";            \
  cout << '\n'
#define pr1(x) cout << fixed << setprecision(15) << x << '\n'
#define mod 1000000007
#define mod1 998244353
#define fio                         \
  ios_base::sync_with_stdio(false); \
  cin.tie(NULL)
#define get(n) \
  ll n;        \
  cin >> n
#define getvec(v, n)         \
  vector<ll> v(n);           \
  for (ll i = 0; i < n; i++) \
    cin >> v[i];
#define getstr(s) \
  string s;       \
  cin >> s
#define all(x) x.begin(), x.end()
#define countBits(x) __builtin_popcount(x)
using namespace std;

void mainSolve()
{
  get(n);
  if (n % 1000 == 0)
    p1(0);
  else
    p1((1000 - (n % 1000)));
}

int main()
{
  fio;
#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  //get(t);
  ll t = 1;
  while (t--)
  {
    mainSolve();
  }
  return 0;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(9), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    vector<int> ans(N);
    for (int i = 0; i < N - 1; i++) {
        int a; cin >> a; a--;
        ans[a]++;
    }
    for (int a : ans) cout << a << '\n';
    return 0;
}


Measured memory_bytes: 3992
// AtCoder ABC125: B - Resale
// 2019.9.9 bal4u

#include <stdio.h>

int N;
int V[25];

int main()
{
	int i, j, c, ans;
	
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", V+i);
	for (i = 1; i <= N; i++) scanf("%d", &c), V[i] -= c;
	
	ans = 0;
	for (i = 1; i <= N; i++) if (V[i] > 0) ans += V[i];
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
#include <iterator>
using namespace std;

// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
// 大きい順
#define rall(v) v.rbegin(), v.rend()
#define vi vector<int>
#define vl vector<ll>
const  long long INF = 1LL << 60;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}



int ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: // fall-through
        case 1: return false;
        case 2: // fall-through
        case 3: return true;
    } // n > 3 が保証された

    if(n % 2 == 0 || n % 3 == 0) return false;
    // n は 2 と 3 のいずれの倍数でもないことが保証された
    // これより n は (6の倍数)-1 か (6の倍数)+1 である

    // 6の倍数前後の数を使って試し割りをする
    for(unsigned i = 5; i * i <= n; i += 6) {
        if(n % i     == 0) return false; // (6の倍数)-1
        if(n % (i+2) == 0) return false; // (6の倍数)+1
    }
    return true;
}

map<ll,ll> mp;

ll primeFactorization(ll a){ //素因数分解を出力するプログラム
    ll i,sq;
    if(a%2==0){ //偶数の場合
        if(!mp.count(2)){
            mp[2] = 1;
        }
        else{
            mp[2] +=1;
        }
        return primeFactorization(a/2); //2で割った値で再帰
    }
    sq = sqrt(a);
    for(i=3;i<=sq;i+=2){ //3以上√a以下の奇数の場合
        if(a%i==0){
            if(!mp.count(i)){
                mp[i] = 1;
            }
            else{
                mp[i] += 1;
            }
            return primeFactorization(a/i); //割れた値で再帰
        }
    }
    //偶数でも3以上√a以下の奇数の場合でも割り切れない場合
    if(a!=1){ //aが1でないなら、a自身は素数
        if(!mp.count(a))
        mp[a] = 1;
        else{
            mp[a] += 1;
        }
    }
    return 0;
}


ll kaizyou(ll n){
    if(n == 1){
        return 1;
    }
    else{
        return (n * kaizyou(n-1)) % 1000000007;
    }
}

/////////////*ここからatcoderの問題*/////////////
int main(){
int X;cin >> X;
if(X >= 30) cout << "Yes" << endl;
else cout << "No" << endl;
}


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

int main() {
  int a,b,c;

  cin >> a >> b >> c;

  if(a == b && a == c) {
    cout << 1 << endl;
  } else if(a == b || a == c || b == c) {
    cout << 2 << endl;
  } else {
    cout << 3 << endl;
  }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
using namespace std;
int main()
{
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if(abs(a - c) <= d)
	{
		cout << "Yes" << endl;
		return 0;
	}
	if(abs(a - b) <= d && abs(b - c) <= d)
	{
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    int n, t;
    cin >> n >> t;
    vector<int> p(n+1);
    for (int i = 0; i <= n; i++)p[i] = -1;

    for (int i = 0; i < t; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        if (p[a] == -1)p[a] = (b );
        else if (p[a]  != b ) {
      
            cout << -1 << endl;
            return 0;
        }
        
    }
    if (n>1&&p[0] == 0) {
        cout << -1 << endl;
        return 0;
    }
    
    for (int i = 0; i < n; i++)if (p[i] == -1) { if (i || n==1) cout << 0; else  cout << 1; }
    else cout << p[i];
    cout << endl;


    return 0;

}

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

using namespace std;

using ll = long long;

struct _IN {
    _IN() {
        ios::sync_with_stdio(0);
        cin.tie(0);
    }
    template <typename T>
    operator T() const {
        T x;
        cin >> x;
        return x;
    }
    template <typename Container>
    void operator()(Container& c) {
        for (auto& x : c)
            cin >> x;
    }
} IN;

int main() {
    ll N = IN;
    vector<int> As(N), Bs(N);
    for (int i = 0; i < N; i++) {
        int a = IN, b = IN;
        As[i] = a;
        Bs[i] = b;
    }
    sort(As.begin(), As.end());
    sort(Bs.begin(), Bs.end());
    int lo, hi;
    if (N & 1) {
        lo = As[N / 2];
        hi = Bs[N / 2];
    } else {
        lo = As[N / 2 - 1] + As[N / 2];
        hi = Bs[N / 2 - 1] + Bs[N / 2];
    }
    cout << (hi - lo + 1) << endl;
}


Measured memory_bytes: 4732
h,w=map(int,input().split())
s=[]
for index in range(h):
    s.append(list(str(input())))


#def sur(x):
#    res=[]
#    if x+1<=w-1:
#        res.append((x+1,y))
#    if y+1<=h-1:
#        res.append((x,y+1))
#    return res


dp=[[-1]*w for index1 in range(h)]
if s[0][0]=='.':
    dp[0][0]=0
else:
    dp[0][0]=1

temp=s[0][0]
for index2 in range(1,w):
    if temp=='.' and s[0][index2]=='#':
        dp[0][index2]=dp[0][index2-1]+1
    else:
        dp[0][index2]=dp[0][index2-1]
    temp=s[0][index2]

temp=s[0][0]
for index3 in range(1,h):
    if temp=='.' and s[index3][0]=='#':
        dp[index3][0]=dp[index3-1][0]+1
    else:
        dp[index3][0]=dp[index3-1][0]
    temp=s[index3][0]


for i in range(1,h):
    for j in range(1,w):
        if s[i][j]=='#':
            if s[i-1][j]=='.':
                if s[i][j-1]=='.':
                    dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1)
                else:
                    dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1])
            else:
                if s[i][j-1]=='.':
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1]+1)
                else:
                    dp[i][j]=min(dp[i-1][j],dp[i][j-1])
        else:
            dp[i][j]=min(dp[i-1][j],dp[i][j-1])


print(dp[h-1][w-1])




Measured memory_bytes: 3316
import sys
input = sys.stdin.readline
MOD = 10**9 + 7
INF = float('INF')

def main():
    h, n = list(map(int,input().split()))
    a = list(map(int,input().split()))

    if sum(a) >= h:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

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

int main(){
    int n;
    cin >> n;
    vector<int> ans(n);
    vector<pair<int, int>> x(n);
    rep(i, n){
        cin >> x.at(i).first;
        x.at(i).second = i;
    }
    sort(x.begin(), x.end());
    rep(i, n){
        if(x.at(i).first<=x.at(n/2-1).first) ans.at(x.at(i).second) = x.at(n/2).first;
        else ans.at(x.at(i).second) = x.at(n/2-1).first;
    }
    rep(i, n){
        cout << ans.at(i) << endl;
    }
    return 0;
}

Measured memory_bytes: 4480
#include<iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a1=0,a2=0,a4=0;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		if(a%4==0) a4++;
		else if(a%2==0) a2++;
		else a1++;
	}
	bool flag=true;
	if(a2==0){
		if(a4<a1-1) flag=false;
	}else{
		if(a4<a1) flag=false;
	}
	
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)

int main() {
    int H, W, N;
    cin>>H>>W>>N;
    int sr, sc;
    cin >> sr >> sc;
    string S, T;
    cin >> S >> T;
    int s_x = 0, t_x = 0, s_y = 0, t_y = 0; 
    string ans = "YES";
    REP(i, 0, N){
        if(S[i] == 'L') s_x--;
        if(sc + s_x + t_x <= 0) ans = "NO";
        if(T[i] == 'R' && sc + s_x + t_x < W) t_x++;
    }

    s_x = 0, t_x = 0, s_y = 0, t_y = 0; 
    REP(i, 0, N){
        if(S[i] == 'R') s_x++;
        if(sc + s_x + t_x > W) ans = "NO";
        if(T[i] == 'L' && sc + s_x + t_x  > 1) t_x--;
    }
    
    s_x = 0, t_x = 0, s_y = 0, t_y = 0; 
    REP(i, 0, N){
        if(S[i] == 'U') s_y--;
        if(sr + s_y + t_y <= 0) ans = "NO";
        if(T[i] == 'D' && sr + s_y + t_y < H) t_y++;
    }
    
    s_x = 0, t_x = 0, s_y = 0, t_y = 0; 
    REP(i, 0, N){
        if(S[i] == 'D') s_y++;
        if(sr + s_y + t_y > H) ans = "NO";
        if(T[i] == 'U' && sr + s_y + t_y > 1) t_y--;
    }
    
    cout << ans << endl;     
}

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

int main()
{
  int n;
  cin>>n;
  int a, b;
  cin>>a>>b;
  for(int i = a; i < b + 1; i++)
  {
    if(i % n == 0)
    {
      cout<<"OK";
      return 0;
    }
    else continue;
  }
  cout<<"NG";
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define ull unsigned long long int
int mod = 1e9+7;
ull getsum(long long n,ull sum,int flag,int ind, string &a,vector<vector<vector<ull>>>&dp,int k)
{
    
	if(ind>n)
	{
		if(sum==k)return 1;
		return 0;
	}

	int limit=9;
	
	if(!flag)limit = a[ind]-'0';
	
	if(dp[ind][sum][flag]!=-1)return dp[ind][sum][flag];
	ull res=0;
	
	for(int i=0;i<=limit;i++)
	{   
		
		if(flag || i<limit)
		{
			res+=getsum(n,sum+!(!i),true,ind+1,a,dp,k);
		}
		
		else
		{
			res+=getsum(n,sum+!(!i),false,ind+1,a,dp,k);
		}
	}
	
	return dp[ind][sum][flag]=res;
}
int main() {
	// your code goes here
	
	cin.tie(NULL);
	cout.tie(NULL);

	string a;
	int k;
	
    cin>>a>>k;
 
    int n = a.size();
  
	vector<vector<vector<ull>>>dp(101,vector<vector<ull>>(101,vector<ull>(2,-1)));
	ull res1 = getsum(n-1,0,0,0,a,dp,k);

	cout<<res1<<endl;
		
	return 0;
}

Measured memory_bytes: 4176
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a, b, k;
  cin >> a >> b >> k;
  for(int i = 0; i < k; i++){
    if(i % 2 == 0){
      a /= 2; b += a;
    }
    else {
      b /= 2; a += b;
    }
  }
  cout << a << " " << b << endl;
}


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

int main(){ 
  ll N,K; scanf("%lld %lld", &N, &K);
  vector<ll> A(N);
  for(int i = 0; i < N; i++){ scanf("%lld", &A[i]);}
  
  vector<ll> vec; 
  
  for(ll i = 0; i < N; i++){
    ll res = A[i];
    for(ll j = i; j < N; j++){ // A[i]+,,+A[j]を求めたい
      
      if(j > i){ res += A[j];}
      
      vec.push_back(res);
    }
    
  }
 
  ll ans = 0;
  
  for(ll i = 45; i >= 0; i--){
    
    int cnt = 0;
   
    for(auto ne : vec){
      // ansに含まれるbitが全てneに含まれるためには、orをとったものがneに等しければいい
      
      if( ( ( ne >> i) & 1 ) && ( ans | ne ) == ne){  cnt++;
                    }
    }
    
    if( cnt >= K){ ans |= 1LL << i;}
  }
  
  printf("%lld\n", ans);
  
  return 0;
}

Measured memory_bytes: 6388
#include <iostream>
#include <limits.h>
using namespace std;

int main(void){
    long long n, p, a;
    cin >> n >> p;
    
    long long ans1 = 0, ans2 = 1;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (a % 2 == 0) {
            ans1 *= 2;
            ans2 *= 2;
        }
        else {
            long long tmp = ans1;
            ans1 += ans2;
            ans2 += tmp;
        }
    }
    if (p == 1) cout << ans1 << endl;
    else cout << ans2 << endl;
}


Measured memory_bytes: 256
H, W, A, B = map(int, input().split())

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7
N = max(H,W)*2
g1 = [1, 1]
g2 = [1, 1]
inverse = [0, 1]
for i in range(2, N+1):
    g1.append((g1[-1] * i) % mod)
    inverse.append((-inverse[mod % i] * (mod//i)) % mod)
    g2.append((g2[-1] * inverse[-1]) % mod)

L1 = []
for i in range(W-B):
    L1.append(cmb(H-A-1+B+i, H-A-1, mod))
    


answer = 0
for i in range(len(L1)):
    answer = (answer + L1[i]*cmb(A+W-B-2-i, A-1, mod)) % mod

print(answer)

Measured memory_bytes: 30760
<?php
  $n = fgets(STDIN);
  $a = explode(" ",trim(fgets(STDIN)));
  $count = 0;
  $flg = true;
  while ($flg){
    for ($i=0; $i<$n; $i++){
      if ($a[$i]%2 == 0){
        $a[$i] /= 2;
      }
      else {
        $flg = false;
        echo $count;
        break;
      }
    }
    $count++;
  }
  exit;
?>

Measured memory_bytes: 3576
#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <functional>
#include <iterator>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

typedef   signed long long int slli;
typedef unsigned long long int ulli;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;

#define N_TIMES(i, n)     for (ulli i = 0;     i <  n; ++i)
#define N_TIMES_REV(i, n) for (slli i = n - 1; i >= 0; --i)

#ifdef __DEBUG__
template<typename T>
std::ostream& operator<<(std::ostream &os, const std::list<T> &list)
{
  const std::string delim = ", ";
  typename std::list<T>::const_iterator itr = list.begin();
  while (itr != list.end()) {
    os << *itr;
    ++itr;
    if(itr != list.end()) os << delim;
  }
  return os;
}

template<typename T>
std::ostream& operator<<(std::ostream &os, const std::vector<T> &v)
{
  const std::string delim = ", ";
  for (unsigned n = 0; n < v.size(); ++n) {
    os << v[n];
    if((n + 1) < v.size()) os << delim;
  }
  return os;
}
#endif /* __DEBUG__ */

int main(int argc, char **argv)
{
  std::string S;
  std::cin >> S;
  
  int a = 0, b = 0, c = 0;
  for (char ch : S) {
    switch(ch) {
    case 'a': ++a; break;
    case 'b': ++b; break;
    case 'c': ++c; break;
    }
  }
  
  std::cout << ((a == 1 && b == 1 && c == 1) ? "Yes" : "No") << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
int main() {
	string str1, str2;
	cin >> str1 >> str2;
	if (str1[2] == str2[0] && str1[1] == str2[1] && str1[0] == str2[2]) {
		cout << "YES" << endl;
		//cout << "This grid remains the same when rotated 180 degrees." << endl;
	}
	else {
		cout << "NO" << endl;
		//cout << "This grid does not remain the same when rotated 180 degrees." << end;
	}

	return 0;
}

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

int N;

int main() {
  cin >> N;
  for (int i = 1; i <= N; ++i) {
    int tax_exc = i * 1.08;
    if (tax_exc == N) {
      cout << i << endl;
      exit(0);
    }
  }
  cout << ":(" << endl;
  
  return 0;
}

Measured memory_bytes: 256
H, W = [int(i) for i in input().split()]

if H==1 or W==1:
    print(1)
    quit()
if H%2==0:
    H //= 2
    print(H*W)
elif W%2==0:
    W //= 2
    print(H*W)
else:
    W -= 1
    c = (W//2)*H
    c += H//2 + 1
    print(c)


Measured memory_bytes: 3060
using System;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {

            var read = Console.ReadLine();
            //var temp_string = read.Split(' ');
           // bool show=true;

            string x;
            int num = int.Parse(read);
            for (int i = 1; i <= num; i++)
            {
                x = i.ToString();
                if(i%3==0||0<=x.IndexOf("3"))
                {
                    Console.Write(" " + i);
                }
                
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9860
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
using namespace std;

int main()
{
    int N, T;
    scanf("%d%d", &N, &T);
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        scanf("%d", &A[i]);
    }
    A.push_back(INT_MIN);
    int diff = 0, max = 0, counter = 0, l = A[0];
    for (int i = 0; i < N; i++) {
        l = min(l , A[i]);
        if (A[i] > A[i + 1]) {
            diff = A[i] - l;
            if (diff > max) {
                max = diff;
                counter = 1;
            } else if (diff == max) {
                counter++;
            }
        }
        //printf("i = %d, diff = %d, max = %d, counter = %d\n", i, diff, max, counter);
    }
    if (max == 0) {
        printf("1\n");
        return 0;
    }
    printf("%d\n", counter);
}

Measured memory_bytes: 1024
#! python3
# insertion.py - 標準入出力を行う

N = int(input())
l = input().split(' ')
A = [int(i) for i in l]
# print(A)

def insertion(A, N): # N個の要素を含む0-オリジンの配列A
    for i in range(N):
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j+1] = A[j]
            j = j - 1
        A[j+1] = v
        map_list = map(str, A)
        a = ' '.join(map_list)
        print(a)

insertion(A, N)


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

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

    long A[n+1];
    long B[n];

    for (int i = 0; i < n + 1;i++){
        cin >> A[i];
    }
    for (int i = 0; i < n;i++){
        cin >> B[i];
    }

    long sum = 0;

    for (int i = 0; i < n;i++){
        for (int j = 0; j < 2;j++){
            if(B[i] >= A[j+i]){
                B[i] -= A[j+i];
                sum += A[j+i];
                A[j+i] = 0;
            }else{
                sum += B[i];
                A[j+i] -= B[i];
                B[i] = 0;
            }
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

int main()
{
	int n;

	scanf("%d", &n);

	int lmin, cnt = 1;

	scanf("%d", &lmin);

	for (int i = 1; i < n; i++)
	{
		int val;

		scanf("%d", &val);

		cnt += (val <= lmin);

		if (val < lmin)
		{
			lmin = val;
		}
	}

	printf("%d\n", cnt);

	return 0;
}

Measured memory_bytes: 256
using System;

class Program {
  public static void Main() {
    string[] input = Console.ReadLine().Split(' ');
    int h = int.Parse(input[0]);
    int a = int.Parse(input[1]);
    
    if (h % a != 0)
      Console.WriteLine(h / a + 1);
    else
      Console.WriteLine(h / a);
  }
}


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

int main() {
  int k;
  vector<int> abc(3);
  cin >> abc[0] >> abc[1] >> abc[2] >> k;

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

  for(int i=0;i<k;i++) {
    abc[2] *= 2;
  }

  cout << abc[0] + abc[1] + abc[2] << endl;

  
}

Measured memory_bytes: 256