akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define CLR(a) memset((a), 0, sizeof(a))
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using LL = long long;
using namespace std;

const int dy[] = {0, 0, 1, -1};
const int dx[] = {1, -1, 0, 0};
const double EPS = 1e-10;
const double PI = acos(-1.0);

void print(vector<int> v){
    int size = v.size() - 1;
    REP(i, size)
    {
        if (i == v.size())
            cout << v[i];
        else
            cout << v[i] << " ";
    }
    cout << v[size] << endl;

}

void buble_Sort(vector<int> v, int n){
    bool flag = true;
    int count_exchange = 0;
    while(flag){
        flag = false;
        for(int j= n-1; j>=1; j--){
            if(v[j]<v[j-1]){
                count_exchange++;

                int temp = v[j];
                v[j] = v[j-1];
                v[j-1] = temp;
                flag = true;
            }
        }
    }

    print(v);
    cout << count_exchange << endl;
}

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

    int n;
    cin >> n;

    vector<int> v;
    REP(_, n)
    {
        int num;
        cin >> num;
        v.PB(num);
    }

    buble_Sort(v, n);
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

using namespace std;
using ll=long long;


int main() {
  char a,b;cin >> a >> b;
  string A,B;
  rep(i,a-'0') A.pb(b);
  rep(i,b-'0') B.pb(a);

  cout << min(A,B);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
template<class T> inline bool chmax(T& a, T b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b){ if(a>b){ a=b; return 1; } return 0; }

vector<int> G[100010];
int dp[100010];

int rec(int v){
    if(dp[v]!=-1) return dp[v];

    int res=0;
    for(int u:G[v]){
        chmax(res,rec(u)+1);
    }
    return dp[v]=res;
}

signed main()
{
    int N,M; cin>>N>>M;
    for(int i=0;i<M;i++){
        int x,y; cin>>x>>y;
        x--; y--;
        G[x].push_back(y);
    }

    for(int i=0;i<N;i++){
        dp[i]=-1;
    }

    int ans=0;
    for(int i=0;i<N;i++){
        chmax(ans,rec(i));
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 8576
a, b = map(int, input().split(" "))
if b == 1:
  print(0)
elif b <= a:
  print(1)
else:
  if (b - a)%(a-1) == 0:
    print((b - a)//(a-1) + 1)
  else:
    print((b - a)//(a-1) + 2)


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

int main(){
  int n,k;
  cin>>n>>k;
  k=min(k,41);
  int a[n],b[n];
  for(int i=0;i<n;i++)cin>>a[i];
  for(int j=0;j<k;j++){
    for(int i=0;i<n;i++)b[i]=0;
    for(int i=0;i<n;i++){
      b[max(0,i-a[i])]++;
      if(min(n-1,i+a[i])+1<n)b[min(n-1,i+a[i])+1]--;
    }
    for(int i=1;i<n;i++)b[i]+=b[i-1];
    for(int i=0;i<n;i++)a[i]=b[i];
  }
  for(int i=0;i<n;i++)cout<<a[i]<<endl;
}


Measured memory_bytes: 5120
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
vector<long long>Wx, Wy, Vx, Vy;
long long X1[2100], Y1[2100], X2[2100], Y2[2100], n, dp[4100][4100], sum;
int main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> X1[i] >> Y1[i] >> X2[i] >> Y2[i];
		Wx.push_back(X1[i]); 
		Wx.push_back(X2[i]);
		Wy.push_back(Y1[i]); 
		Wy.push_back(Y2[i]);
	}
	sort(Wx.begin(), Wx.end()); 
	sort(Wy.begin(), Wy.end());
	for (int i = 0; i < Wx.size(); i++) {
		if (i == 0 || Wx[i] != Wx[i - 1]) Vx.push_back(Wx[i]);
		if (i == 0 || Wy[i] != Wy[i - 1]) Vy.push_back(Wy[i]);
	}
	for (int i = 0; i < n; i++) {
		int pos1 = lower_bound(Vx.begin(), Vx.end(), X1[i]) - Vx.begin();
		int pos3 = lower_bound(Vx.begin(), Vx.end(), X2[i]) - Vx.begin();
		int pos2 = lower_bound(Vy.begin(), Vy.end(), Y1[i]) - Vy.begin();
		int pos4 = lower_bound(Vy.begin(), Vy.end(), Y2[i]) - Vy.begin();
		dp[pos1][pos2]++; dp[pos3][pos2]--; dp[pos1][pos4]--; dp[pos3][pos4]++;
	}
	for (int i = 0; i < 4100; i++) 
		for (int j = 1; j < 4100; j++) 
			dp[i][j] += dp[i][j - 1];
	for (int i = 1; i < 4100; i++) 
		for (int j = 0; j < 4100; j++) 
			dp[i][j] += dp[i - 1][j];
	for (int i = 0; i < Vx.size(); i++) 
		for (int j = 0; j < Vy.size(); j++) 
			if (dp[i][j] >= 1) 
				sum += (Vx[i + 1] - Vx[i]) * (Vy[j + 1] - Vy[j]);
		
	cout << sum << endl;
	return 0;
}


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

int main() {
  int N, M;
  cin >> N >> M;
  N++;
  
  vector<int> n(N);

  int a, b;
  
  for(int i=0; i<M; i++){
    cin >> a >> b;
    
    n.at(a) += 1;
    n.at(b) += 1;
  }
  
  for(int i=1; i<N; i++){
    cout << n.at(i) << endl;
  }
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	
	ll X;
	cin >> X;

	ll kotae = X / 11 * 2;
	X %= 11;
	if(X) kotae += 1 + X / 7;

	co(kotae);

	Would you please return 0;
}

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

int main(){
  int m,d,ans=0;cin>>m>>d;
  for(int i=22;i<=d;i++){
    int e=i%10,f=i/10;
    if(e*f<=m&&e>1&&f>1)ans++;
  }
  cout<<ans<<endl;
}

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

int l,r,ans;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin>>l>>r;ans=1e9;
    if(r-l>2019){
        cout<<0<<endl;
        return 0;
    }
    l%=2019;r%=2019;
    if(l>=r||l==0||r==0){
        cout<<0<<endl;
        return 0;
    }else{
        for(int i=l;i<r;i++){
            for(int j=i+1;j<=r;j++){
                ans=min(ans,i*j%2019);
            }
        }
    }
    cout<<ans<<endl;

    return 0;
}

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

int main(void){
    int n, q;
    string s;
    cin>>n>>s>>q;
    vector<set<int> > is(26);
    rep(i, s.size()){
        is[s[i]-'a'].insert(i);
    }
    rep(qi, q){
        int t;
        cin>>t;
        if(t==1){
            int i;
            char c;
            cin>>i>>c;
            --i;
            is[s[i]-'a'].erase(i);
            s[i]=c;
            is[s[i]-'a'].insert(i);
        }
        else{
            int l, r;
            cin>>l>>r;
            --l;--r;
            int ans=0;
            rep(i, 26){
                auto itr = is[i].lower_bound(l);
                if(itr!=is[i].end() && *itr<=r) ans++;
            }
            cout<<ans<<endl;
        }
    }
    return 0;

}


Measured memory_bytes: 24196
#include <stdio.h>

int main(){
  int mount[10], get;
  int i, j;
  for(i = 0; i < 10; i++){
    scanf("%d", &mount[i]);
  }
  
  for(i = 9; i >= 0; i--){
    for(j = 0; j<=i-1; j++){
      if(mount[j] > mount[j+1]){
	get = mount[j];
	mount[j] = mount[j+1];
	mount[j+1] = get;
      }
    }
  }
  for(i = 9; i >= 7; i--){
    printf("%d\n", mount[i]);
  }
  return 0;
}

Measured memory_bytes: 600
import itertools

def abc167c_skill_up():
    n, m, x = map(int, input().split())
    c = []
    a = []
    for _ in range(n):
        v = list(map(int, input().split()))
        c.append(v[0])
        a.append(v[1:])
    pattern = itertools.product([0,1], repeat=n)
    best = float('inf')
    for p in pattern:
        cost = 0
        skill = [0] * m
        for i, v in enumerate(p):
            if v == 1:
                cost += c[i]
                if cost > best: break
                check = True
                for j in range(m):
                    skill[j] += a[i][j]
                    if skill[j] < x:
                        check = False
                if check:
                    best = cost
                    break
    if best == float('inf'):
        print('-1')
    else:
        print(best)
abc167c_skill_up()

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

int main() {
  int H, W;
  cin >> H >> W;
  string wb = "";
  char A[H][W];
  
  int r[H];
  int c[W];
  
  for (int i = 0; i < H; i++) {
    r[i] = -1;
    for (int j = 0; j < W; j++) {
      c[j] = -1;
      char s;
      cin >> s;
      A[i][j] = s;
    }
  }
  
  for (int i = 0; i < H; i++) {
    int flag = 0;
    for (int j = 0; j < W; j++) {
      if (A[i][j] == '#') {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      r[i] = i;
    }
  }
  
  for (int j = 0; j < W; j++) {
    int flag = 0;
    for (int i = 0; i < H; i++) {
      if (A[i][j] == '#') {
        flag = 1;
        break;
      }
    }
    if (flag == 1) {
      c[j] = j;
    }
  }
  
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if(r[i] == i && c[j] == j)
        cout << A[i][j];
    }
    if (r[i] == i) cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <numeric>
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int n,ans=0;
    cin >> n;
    vector<int> v(n),c(n);
    for(int i=0;i<n;i++) cin >> v[i];
    for(int i=0;i<n;i++) cin >> c[i];
    for(int i=0;i<n;i++){
        if(v[i]>c[i]) ans+=v[i]-c[i];
    }
    cout << ans << endl;
}


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

int main(int argc, char *argv[]) {
  int n, a, b, in, i, cnt[3] = {0};
  scanf("%d %d %d", &n, &a, &b);
  for (i = 0; i < n; ++i) {
    scanf("%d", &in);
    if (in <= a) ++cnt[0];
    else if (a < in && in <= b) ++cnt[1];
    else ++cnt[2];
  }
  return !printf("%d\n", min(cnt[0], min(cnt[1], cnt[2])));
}

Measured memory_bytes: 128
#include<stdio.h>
int main(){
  int n,d[101],i,j,tmp=0,cnt=0;
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&d[i]);
  }
  for(i=0; i<n; i++){
    for(j=i+1; j<n; j++){
      if(d[i]>d[j]){
        tmp=d[i];
        d[i]=d[j];
        d[j]=tmp;
      }
    }
  }
  for(i=0; i<n; i++){
    j=i+1;
    if(d[i]==d[j]){
      cnt++;
    }
  }
  printf("%d\n",n-cnt);
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import collections

N = int(input().split()[0])
s_list = []

for _ in range(N):
    s = input()
    s_list.append(s)

counter = collections.Counter(s_list)

for item in ["AC", "WA", "TLE", "RE"]:
    print(f"{item} x {counter[item]}")


Measured memory_bytes: 16620
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long ll;
typedef long long ld;
int main() {
  ll l;
	cin>>l;
	cout <<std::fixed <<std::setprecision(12) << ((double)l/3)*((double)l/3)*((double)l/3)<<endl;
}

Measured memory_bytes: 3808
import collections
n = int(input())
lb = [input() for _ in range(n)]
m = int(input())
la = [input() for _ in range(m)]


cntb = collections.Counter(lb)
cnta = collections.Counter(la)
t_max = 0
cntb.subtract(cnta)

m = sorted(cntb.items(), key=lambda x: x[1], reverse=True)
print(max(0, m[0][1]))


Measured memory_bytes: 9296
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <tuple>
#include <numeric>
#include <cstdio>
#include <cmath>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int x, y; cin >> x >> y;
    bool isExsit = false;
    for (int i = 0; i <= x; i++) {
        if (2 * i + 4 * (x - i) == y) {
            isExsit = true;
            break;
        }
    }
    if (isExsit) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

Measured memory_bytes: 3124
require("fs").readFileSync("/dev/stdin","utf8").split('\n').some(function(i){z=i.split(' '),a=+z[0],b=+z[1],c=+z[2],d=+z[3],e=+z[4],f=+z[5],r=Math.sqrt((a-d)*(a-d)+(b-e)*(b-e));if(c)console.log(r>c+f?0:r<c-f?2:r<f-c?-2:1)})

Measured memory_bytes: 7648
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

ll r1,c1,r2,c2;
ll fact[SIZE],inv_fact[SIZE];
ll table[SIZE],ruiseki[SIZE];
map<ll,ll> MAP;

ll mod_pow(ll x,ll count, ll mod){

	if(count == 0)return 1;
	ll ret = mod_pow((x*x)%mod,count/2,mod);
	if(count%2 == 1){

		ret = (ret*x)%mod;
	}
	return ret;
}

ll extgcd(ll a,ll b,ll &x,ll &y){
	ll d = a;
	if(b != 0){
		d = extgcd(b,a%b,y,x);
		y -= (a/b)*x;
	}else{
		x = 1;
		y = 0;
	}
	return d;
}

ll mod_inverse(ll a,ll m){
    ll x,y;
    extgcd(a,m,x,y);
    return (m+x%m)%m;
}

ll nCk(ll n,ll k){

	ll ret = fact[n]*inv_fact[k];
	ret %= MOD;
	ret *= inv_fact[n-k];

	return ret%MOD;
}



int main(){

	fact[0] = 1;
	for(ll i = 1; i < SIZE; i++){
		fact[i] = i*fact[i-1];
		fact[i] %= MOD;
	}
	inv_fact[SIZE-1] = mod_inverse(fact[SIZE-1],MOD);
	for(ll i = SIZE-1; i >= 1; i--){

		inv_fact[i-1] = inv_fact[i]*i;
		inv_fact[i-1] %= MOD;
	}

	ll N,K;
	vector<ll> V,work;

	scanf("%lld %lld",&N,&K);

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

		scanf("%lld",&table[i]);
		V.push_back(table[i]);
	}

	sort(V.begin(),V.end());
	V.erase(unique(V.begin(),V.end()),V.end());

	for(ll i = 0; i < V.size(); i++){

		MAP[V[i]] = i;
	}

	for(ll i = 0; i < V.size(); i++){

		ruiseki[i] = 0;
	}

	for(ll i = 0; i < N; i++){

		ruiseki[MAP[table[i]]]++;
	}

	for(ll i = 1; i < V.size(); i++){

		ruiseki[i] += ruiseki[i-1];
	}

	ll minus = 0,plus = 0;

	//自分を下限とする数
	for(ll i = 0; i < V.size(); i++){
		//自分以上の数がK個以上なければbreak
		if(i > 0 && ruiseki[V.size()-1]-ruiseki[i-1] < K)break;

		ll num = 0;
		ll self;

		if(i == 0){

			self = ruiseki[0];
		}else{

			self = ruiseki[i]-ruiseki[i-1];
		}

		for(ll k = 1; k <= min(self,K); k++){ //k:自分を選ぶ個数

			ll rest = K-k;

			if(i == V.size()-1 && rest > 0)continue;
			if(i < V.size()-1 && rest > ruiseki[V.size()-1]-ruiseki[i])continue;

			ll tmp = nCk(self,k);
			if(rest == 0){

				num += tmp;
				num %= MOD;
			}else{

				tmp *= nCk(ruiseki[V.size()-1]-ruiseki[i],rest);
				num += tmp;
				num %= MOD;
			}
		}

		minus += (V[i]+MOD)%MOD*num;
		minus %= MOD;
	}

	for(int i = V.size()-1; i >= 0; i--){
		//自分以下の数がK個以上なければbreak
		if(ruiseki[i] < K)break;

		ll num = 0;
		ll self;
		if(i == 0){

			self = ruiseki[0];
		}else{

			self = ruiseki[i]-ruiseki[i-1];
		}

		for(int k = 1; k <= min(self,K); k++){

			ll rest = K-k;
			ll tmp = nCk(self,k);

			if(i == 0 && rest > 0)continue;
			if(i > 0 && ruiseki[i-1] < rest)continue;

			if(rest == 0){

				num += tmp;
				num %= MOD;
			}else{

				tmp *= nCk(ruiseki[i-1],rest);
				num += tmp;
				num %= MOD;
			}
		}

		plus += (V[i]+MOD)%MOD*num;
		plus %= MOD;
	}

	ll ans = (plus-minus+MOD)%MOD;

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 9844
N = int(input())
A = sorted([int(input()) for i in range(N)])
Ami = A[:N//2]
Ama = A[N//2:][::-1]
Ami2 = A[:(N+1)//2]
Ama2 = A[(N+1)//2:][::-1]

if N%2 == 1:
    ans = -2*sum(Ami)
    ans += 2*sum(Ama[:-2]) + Ama[-1]+Ama[-2]
    ans2 = -2*sum(Ami2[:-2]) - Ami2[-1]-Ami2[-2]
    ans2 += 2*sum(Ama2)
    print(max(ans2,ans))
else:
    ans = -2*sum(Ami[:-1]) - Ami[-1]
    ans += 2*sum(Ama[:-1]) + Ama[-1]
    print(ans)

Measured memory_bytes: 8900
# -*- coding: utf-8 -*-
import sys
import re
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    if re.match(r'[aeiou]',input()):
        print('vowel')
    else:
        print('consonant')
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
#define MOD 1000000007
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b


signed main(){
	ll n,a,b; cin>>n>>a>>b;
	--a; --b;
	vvl g(n,vl(0));
	rep(i,0,n-1){
		g[i].push_back(i+1);
		g[i+1].push_back(i);
	}
	g[a].push_back(b);
	g[b].push_back(a);
	vl ans(n+3);
	rep(i,0,n){
		queue<pair<ll,ll>> q;
		q.push(make_pair(i,0));
		vector<bool> seen(n);
		seen[i]=true;
		while(!q.empty()){
			pair<ll,ll> p=q.front(); q.pop();
			ll j,cost;
			tie(j,cost)=p;
			ans[cost]++;
			for(ll c:g[j]){
				if(seen[c])continue;
				seen[c]=true;
				q.push(make_pair(c,cost+1));
			}
		}
	}
	rep(i,1,n)cout<<ans[i]/2<<endl;
	return 0;
}

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

using namespace std;

#define LL long long 
#define ULL unsigned LL
#define LD long double 

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int d, t, s;
	cin>>d>>t>>s;
	int przejdzie = t*s;
	cout<<(przejdzie>=d?"Yes":"No");
}


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  int s = 0;
  rep(i, n) s += a[i];
  int c = 0;
  rep(i, n) if (a[i] * 4 * m >= s) ++c;
  if (c >= m) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3604
#include <iostream>
#include <typeinfo>
using namespace std;
typedef long long int ll;


ll return_luca(int n, ll luca[]){
    if(luca[n] == 0){
        luca[n] = return_luca(n-1, luca) + return_luca(n-2, luca);
        return luca[n];
    }else{
        return luca[n];
    }
}

int main(){

    ll luca[100] = {};
    luca[0] = 2;
    luca[1] = 1;

    int n;
    cin >> n;

    ll ans = return_luca(n, luca);
    cout << ans << endl;
    

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define float long double
#define f(i,a,b) for(int i = a;i < b;i++)
#define ff(i,a,b)  for(int i = a-1;i>=b;i--)
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false), cin.tie(NULL)
const int mod = 1e9+7;
//int to string -> to_string()
//string to int -> stoi()

int32_t main()
{
   IOS;
   int a,b;
   cin>>a>>b;
   string s1,s2;
   int i;
   f(i,0,a)
      s1 += to_string(b);
    f(i,0,b)
      s2+= to_string(a);
    if(s1<s2)
      cout<<s1<<endl;
    else
      cout<<s2<<endl;
   return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int N; cin >> N;
  if (N==1){
    cout << 1 << endl;
  }
  if (2<=N && N<=3){
    cout << 2 << endl;
  }
  if (4<=N && N<=7){
    cout << 4 << endl;
  }
  if (8<=N && N<=15){
    cout << 8 << endl;
  }
  if (16<=N && N<=31){
    cout << 16 << endl;
  }
  if (32<= N && N<= 63){
    cout << 32 << endl;
  }
  if (64 <= N){
    cout << 64 << endl;
  }
}

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

int n, a[1000005];
int main()
{
//    freopen("ciorna.in", "r", stdin);
    scanf("%d", &n);
    for(int i = 1; i <= n ; ++i)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    int x = 0, y = 0;
    for(int i = n; i > 1 ; --i){
        if(a[i] == a[i - 1] && x == 0) x = a[i], --i;
        else if(a[i] == a[i - 1]) {y = a[i]; break;}
    }
    long long Sol = 1LL * x * y;
    printf("%lld", Sol);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define mkp make_pair
#define pb push_back
#define clr(a,b) memset(a, b, sizeof(a))
using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vii;

void compute(){
    int n, m;
    cin>>n>>m;
    int a[m+1];
    clr(a, 0);
    for(int i=0; i<n; i++){
        int k;
        cin>>k;
        for(int j=0; j<k; j++){
            int x;
            cin>>x;
            ++a[x];
        }
    }
    ll res = 0;
    for(int i=1; i<=m; i++){
        if(a[i] == n)
            ++res;
    }
    cout<<res<<"\n";
}

int main(){
    compute();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(i=a;i<b;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define hell 1000000007
#define ios ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;

void solve()
{
ll int i,j=0,a,p,q,r,b[3],c=0,d=0,m,n,k=0,x=-5e18,y=-5e18,sum=0,flag=1,h;
cin>>n;
vector < pair < string, pair < int , int > > > v(n);
rep(i,0,n)
  {  string s;
      cin>>s>>a;
      v[i].F=s;
      v[i].S.F=a;
      v[i].S.S=i+1;
  }
  sort(all(v));

 vector < pair  < int , int > > vv(n);
 rep(i,0,n)
  {
      vv[i].F=v[i].S.F;
      vv[i].S=v[i].S.S;
  }
  c=0; //rep(i,0,n) cout<<v[i].F<<" ";
  //rep(i,0,n) cout<<vv[i].S<<" ";
  vector < int > z;
string s1=v[0].F;
c=0;k=0;
rep(i,0,n)
   {
       if(v[i].F==s1)
       {
           c++;
       }
       else
       { //cout<<k<<" "<<c<<endl;
           sort(vv.begin()+k,vv.begin()+k+c);
           reverse(vv.begin()+k,vv.begin()+k+c);
    rep(j,k,c+k)
      {
          z.pb(vv[j].S);
          //cout<<z[j]<<" ";
      }

      c=0;
      s1=v[i].F;
      k=i;
      i--;
   }
   }
   s1=v[n-1].F;
   c=0;
for(i=n-1;i>=0;i--)
{
    if(v[i].F==s1)
        c++;
        else break;
}
vector < pair < int , int > > qq(n);
//cout<<c<< " ";
j=0;
rep(i,n-c,n)
  {
      qq[j].F=vv[i].F;
      qq[j].S=vv[i].S;
      j++;
  }
   sort(qq.begin(),qq.begin()+c);
   reverse(qq.begin(),qq.begin()+c);

rep(i,0,z.size()) cout<<z[i]<<" ";
rep(i,0,c) cout<<qq[i].S<<" ";

   }





int main()
{ ios;
 int t=1;
 //cin>>t;
 while(t--)
  solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <numeric>

using namespace std;

typedef unsigned long ulong;

static unordered_map<ulong, unordered_map<ulong, ulong>> g_gcd_cache;
static unsigned long euclidean_gcd(unsigned long a, unsigned long b) {

    auto origA = a, origB = b;
    auto it1 = g_gcd_cache.find(a);
    if (it1 != g_gcd_cache.end())
    {
        auto it2 = it1->second.find(b);
        if (it2 != it1->second.end())
        {
            return it2->second;
        }
    }

    if (a < b)
    {
        auto v = euclidean_gcd(b, a);
        return v;
    }
    unsigned r;
    while ((r = a%b)) {
        a = b;
        b = r;
    }
    g_gcd_cache[origA][origB] = b;
    g_gcd_cache[origB][origA] = b;
    return b;
}

void problemA()
{
    char c;
    cin >> c;

    if (c == 'A') cout << "T" << endl;
    if (c == 'T') cout << "A" << endl;
    if (c == 'C') cout << "G" << endl;
    if (c == 'G') cout << "C" << endl;
}

int main()
{
    problemA();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, cnt[4] = {0};
  string s;
  cin >> n;
  while (n--) {
    cin >> s;
    if (s == "AC")
      cnt[0]++;
    else if (s == "WA")
      cnt[1]++;
    else if (s == "TLE")
      cnt[2]++;
    else
      cnt[3]++;
  }
  printf("AC x %d\nWA x %d\nTLE x %d\nRE x %d\n", cnt[0], cnt[1], cnt[2],cnt[3]);

  return 0;
}


Measured memory_bytes: 3720
N, M, C = map(int, input().split())
B = [int(i) for i in input().split()]
A = [[int(i) for i in input().split()] for i in range(N)]
ans = 0
for i in range(N):
    sum = 0
    for j in range(M):
        sum += A[i][j] * B[j]
    if sum + C > 0:
        ans += 1
print(ans)


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

using ll = long;

const ll mod = 1e9+7;

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

int main(){
    ll n; cin >> n;
    map<pair<ll,ll>,pair<ll,ll>> data; ll count = 0;
    for(int i = 0; i < n; i++) {
        ll a, b; cin >> a >> b;
        if(!a && !b) count++;
        else{
            ll div = GCD(abs(a),abs(b));
            a /= div; b /= div;
            if (b < 0) { a *= -1ll; b *= -1ll; }
            if (a > 0) data[make_pair(a,b)].first++;
            else data[make_pair(b,-a)].second++;
        }
    }
  
    ll ans = 1;
    
    for(auto P : data){
        auto p = P.second;
        ans *= (modpow(2,p.first) + modpow(2,p.second) - 1 + mod) % mod; ans %= mod;
    }

    cout << (ans - 1 + count + mod) % mod << endl;
    return 0;
}

Measured memory_bytes: 19060
from collections import deque
import numpy as np
from functools import lru_cache

nCr = {}


@lru_cache(maxsize=None)
def cmb(n, r):
    if r == 0 or r == n:
        return 1
    if r == 1:
        return n
    if (n, r) in nCr:
        return nCr[(n, r)]
    nCr[(n, r)] = cmb(n-1, r) + cmb(n-1, r-1)
    return nCr[(n, r)]


N, P = map(int, input().split())
A = np.array(list(map(int, input().split())))

li = list(np.mod(A, 2))
zero = li.count(0)
one = li.count(1)

if P == 0:
    combi = [0] + [2 * x for x in range(1, (one + 2) // 2)]
if P == 1:
    combi = [1] + [2 * x + 1 for x in range(1, (one + 1) // 2)]

q = deque(combi)

right = 0
while q:
    c = q.popleft()
    tmp = cmb(one, c)
    right += tmp

print(2**zero * right)

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

using namespace std;
int h,w;
char arr[1003][1003];
int f[1003][1003] = {0};
int a = 1000000007;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cin>>h>>w;
    f[1][1] = 1;
    for(int i = 1; i<= h; i++)
    {
        for(int j = 1 ; j<= w; j++)
        {
            cin>>arr[i][j];
        }
    }
    for(int i = 1; i<= h ; i++)
    {
        for(int j = 1; j<= w; j++)
        {
            if( (i != 1||j!= 1) && arr[i][j]=='.' ) f[i][j] = f[i-1][j] + f[i][j-1];
            if(f[i][j] >= a ) f[i][j] = f[i][j] % a;
        }
    }
    cout<<f[h][w];
    return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	ll n;cin>>n;
	if(n==1){
		cout<<1<<endl;
		return 0;
    }
	ll l0=2,l1=1;
	ll ans=0;
	rep(i,n-1){
		ans=l0+l1;
		l0=l1;l1=ans;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<(n);i++)
#define Rep(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define rev(i,n) for(int i=(n)-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define eb emplace_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
// const int mod=998244353;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int r;
    cin>>r;
    cout<<2*r*M_PI<<endl;
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;

double ans = 0,P,E,T;
int K;

void recursive(double R,double L,double probability,int count){

	if(L < T-E || R > T+E)return;

	if(count == K){
		if(fabs(T-(R+L)/2.0) <= E){
			ans += probability;
		}
		return;
	}else if(R >= T-E && L <= T+E){
		ans += probability;
		return;
	}

	double H = (R+L)/2.0;

	double right_R,right_L,wrong_R,wrong_L;

	if(H > T){

		right_R = R,right_L = H;
		recursive(right_R,right_L,probability*(1-P),count+1);

		wrong_R = H,wrong_L = L;
		recursive(wrong_R,wrong_L,probability*P,count+1);

	}else{

		right_R = H,right_L = L;
		recursive(right_R,right_L,probability*(1-P),count+1);

		wrong_R = R,wrong_L = H;
		recursive(wrong_R,wrong_L,probability*P,count+1);
	}
}

int main(){

	double first_R,first_L;

	scanf("%d %lf %lf",&K,&first_R,&first_L);
	scanf("%lf",&P);
	scanf("%lf",&E);
	scanf("%lf",&T);

	recursive(first_R,first_L,1.0,0);

	printf("%.6lf\n",ans);

	return 0;
}

Measured memory_bytes: 2744
a, b, c, d, e, f = gets.split.map(&:to_f)

dmax = 0
a1 = 0
a2 = 0
(0..30).each do |ac|
  (0..30).each do |bc|
    (0..60).each do |cc|
      (0..60).each do |dc|
        next if ac + bc + cc + dc == 0
        av = a * ac
        bv = b * bc
        cv = c * cc
        dv = d * dc
        sum = (av+bv)*100+(cv+dv)
        next if sum > f
        dense = 100*(cv+dv)/sum
        next if dense > 100*e/(100+e)
        if dense >= dmax
          dmax = dense
          a1 = sum
          a2 = cv + dv
        end
      end
    end
  end
end
puts "#{a1.to_i} #{a2.to_i}"

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

import java.util.Arrays;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

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);
	void run() {
		for (;;) {
			int n = sc.nextInt();
			if (n == 0) break;
			P[] ps = new P[n]; 
			for (int i = 0; i < n; i++) {
				ps[i] = new P();
				ps[i].id = sc.nextInt();
				ps[i].v = sc.nextInt() + sc.nextInt();
			}
			Arrays.sort(ps);
			System.out.println(ps[n-1].id + " " + ps[n-1].v);
		}
	}
	
	class P implements Comparable<P> {
		int v;
		int id;
		@Override
		public int compareTo(P o) {
			return v - o.v;
		}
	}
}

Measured memory_bytes: 164464
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <deque>
#include <queue>
#include <cmath>
#include <algorithm>
#include <utility>
#include <functional>
#include <fstream>
#define debug(x) cout << #x << " = " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define repr(i,n) for(int i = (n); i > -1; i--)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const int MOD = 1000000007;
const ll LINF = 1e18;
const double EPS = 1e-9;


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

  string s;
  cin>>s;
  int l = s.size();
  bool f = false;
  for(int i = 0; i <= l; i++) {
    for(int j = 0; j <= l; j++) {
      if(i + j <= l) {
        string ss = s.substr(0,i) + s.substr(l-j,j);
        if(ss == "keyence") f = true;
      }
    }
  }
  if(f) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
using ll = long long;
int main(){
  int a,b,h,m;
  cin >> a >> b >> h >> m;

  long double x,y;
  x = (long double)h/12*2*M_PI;
  y = (long double)m/60*2*M_PI;

  x += (long double)m/60/12*2*M_PI;

  long double angle;
  angle = max(x,y)-min(x,y);

  long double ans;
  //ans = (long double)a*a + (long double)b*b - (long double)2*a*b*cos(angle);
  ans = sqrt((long double)(-2*a*b*cos(angle)+a*a+b*b));
  printf("%.12Lf\n",ans);
}


Measured memory_bytes: 4108
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
  	int k=sc.nextInt();
    char[] s=sc.next().toCharArray();
    if(k>=s.length){
      for(int i=0;i<s.length;i++){
        System.out.print(s[i]);
      }
    }else{
      for(int i=0;i<k;i++){
        System.out.print(s[i]);
      }
      System.out.print("...");
    }
  }
}

Measured memory_bytes: 35744
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define int long long
#define inf (int)1e18+7

const int nmax = (int)2e5+10;
int n, h[nmax], a[nmax];
int tree[nmax];

set<pair<int, int > > myset;

void seekAndUpdate (int id ) {
  pair<int, int > pp = make_pair(h[id], a[id]);
  myset.insert(pp);
  auto it = myset.find(pp);
  if (it != myset.begin()) {
    it --;
    auto pre = it;
    it ++;
    pp.second += pre -> second;
    myset.erase(it);
    myset.insert(pp);
  }
  while (it != myset.end()) {
    it ++;
    auto tmp = it;
    if (tmp == myset.end()) break;
    it --;
    if (pp.second > tmp -> second) {
      myset.erase(tmp);
    } else {
      break;
    }
  }
}

signed main() {
  ios_base :: sync_with_stdio(false);
  cin.tie(0);

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

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

  myset.insert(make_pair(0, 0));
  for (int i = 1; i <= n; i ++) {
    seekAndUpdate(i);
  }
  auto it = myset.end();
  it --;
  cout << it -> second << endl;

  return 0;
}

Measured memory_bytes: 15872
#include <algorithm>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;

int main() {
  ll I, O, T, J, L, S, Z;
  cin >> I >> O >> T >> J >> L >> S >> Z;
  ll res = 0;
  res = max(res, 4 * (I / 2) + 4 * (J / 2) + 4 * (L / 2));
  if (I > 0 && J > 0 && L > 0) {
    res =
        max(res, 4 * ((I - 1) / 2) + 6 + 4 * ((J - 1) / 2) + 4 * ((L - 1) / 2));
  }
  res += O * 2;
  res /= 2;
  cout << res << endl;
  return 0;
}


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

using namespace std;

int main()
{
  double d; cin >> d;
  double ans = d*sqrt(2);
  for(double x = 0.0; x <= d; x += 1.0) {
    double y = max(sqrt(d*d - x*x), 1.0);
    ans = max(ans, x + y);
  }
  printf("%.10f\n", ans);
  
  return 0;
}

Measured memory_bytes: 1236
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

def main():
    N = int(readline())
    A = [[int(i) for i in readline().split()] for _ in range(N)]

    via_min = [[10**15] * N for _ in range(N)]

    for i in range(N):
        for j in range(N):
            for k in range(N):
                if k == i or k == j:
                    continue
                via_min[i][j] = min(via_min[i][j], A[i][k] + A[k][j]) 

    ans = 0
    for i in range(N):
        for j in range(i+1,N):
            if via_min[i][j] < A[i][j]:
                print(-1)
                exit()
            elif via_min[i][j] == A[i][j]:
                continue
            else:
                ans += A[i][j]
    
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 43484
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String s = sc.next();
            if(s.equals("0")) break;
            int ret = 0;
            for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
            System.out.println(ret);
        }
    }
}


Measured memory_bytes: 26060
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
 
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f3f3f3f3fLL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
 
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
ll N,M;
string str;
vi Gr[MAX_N];
bool used[MAX_N];
ll a[MAX_N];
ll GCD(ll x,ll y){
	if(x<y)swap(x,y);
	if(y==0)return x;
	return GCD(y, x%y);
	
}
int main(){
	cin>>N>>M;
	string S,T;
	cin>>S>>T;
	ll g = GCD(N,M);
	ll  hoge = (N*M)/g;
	if(g==1){
		if(S[0]==T[0])cout<<hoge<<endl;
		else cout<<-1<<endl;
	}else{
		bool flag=true;
		for(ll i=0;i<g;i++){
			if(S[(N/g)*i]!=T[(M/g)*i])flag=false;
		}
		if(flag)cout<<hoge<<endl;
		else cout<<-1<<endl;
	}
}

Measured memory_bytes: 5500
#include <stdio.h>

int main(){

  int n, a, ans, i, c;

  scanf("%d", &n);

  for(i=0;i<n;i++){
    c=0;
    scanf("%d", &a);
    while(a%2==0 && a>0){
      c++;
      a/=2;
    }
    if(ans>c || i==0) ans=c;
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 128
from collections import Counter

N = int(input())
s = [input() for _ in range(N)]

M = int(input())
t = [input() for _ in range(M)]

c1 = Counter(s)
c2 = Counter(t)
ans = max(v - c2[i] for i, v in c1.most_common())
print(max(0, ans))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,x,y,i,xx[200],yy[200];
    cin>>n>>m>>x>>y;
    for(i=0;i<n;i++)
        cin>>xx[i];
    for(i=0;i<m;i++)
        cin>>yy[i];
    sort(xx,xx+n);
    sort(yy,yy+m);
    for(i=x+1;i<=y;i++)
    {
        if(i>xx[n-1]&&i<=yy[0])
        {
            cout<<"No War"<<endl;
            return 0;
        }
    }
    cout<<"War"<<endl;
    return 0;
}


Measured memory_bytes: 3560
def val(num):
    print(num, flush=True)
    sex = input()
    if sex == "Vacant":
        exit(0)
    return 1 if sex == "Male" else 0


n = int(input())

l_sex = val(0)
r_sex = val(n - 1)

left = 0
right = n - 1

while left < right:
    mid = (left + right) // 2
    sex = val(mid)
    if (mid - left) % 2 == 0 and sex != l_sex:
        right = mid
        r_sex = sex
    elif (mid - left) % 2 == 1 and sex == l_sex:
        right = mid
        r_sex = sex
    else:
        left = mid
        l_sex = sex

Measured memory_bytes: 62156
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.Design;
using System.IO.Compression;
using System.Linq;
using System.Numerics;
using System.Runtime.CompilerServices;
using System.Security.Cryptography.X509Certificates;
using System.Text;
using System.Text.RegularExpressions;
using Console = System.Console;

namespace Atcoder
{

    class Program
    {
        private const long COMDIV = 1000000007;

        static void Main(string[] args)
        {
            var NHW = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int ret = 0;
            for (int i = 0; i < NHW[0]; i++)
            {
                var AB = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (NHW[1] <= AB[0] && NHW[2] <= AB[1])
                {
                    ret++;
                }
            }

            Console.WriteLine(ret);
        }
    }
}

Measured memory_bytes: 28292
N=int(input())
P=list(map(int,input().split()))
Q=list(map(int,input().split()))
L=[i for i in range(1,N+1)]
import itertools

a=0
b=0
k=0
for j in itertools.permutations(L):
    
    if list(j)==P:
        a=k
    if list(j)==Q:
        b=k
    k+=1

print(abs(a-b))

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>
#include <stack>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  map<ll,ll> mp;
  ll tot = 0;
  vector<ll> a(n);
  rep(i,n) {
    cin >> a[i];
    ++mp[a[i]];
    tot += a[i];
  }

  // Here, mp has all values
  // vector<P> ps; // pair of <value, count>
  // for (auto& p : mp) {
  //   ps.emplace_back(p.first, p.second

  ll q;
  cin >> q;
  while(q--) {
    ll b,c;
    cin >> b >> c;
    if (mp.find(b) != mp.end()) { // b is in mp
      // move cnt from b to c.
      ll cnt = mp[b];
      mp[c] += cnt;
      mp.erase(b);

      // update tot
      ll diff = (c-b)*cnt;
      tot += diff;
    }
    cout << tot << endl;
  }
}


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

int main(void){
    vector<int> A(3);
    for(int i=0; i<3; i++) cin >> A[i];
    sort(A.begin(), A.end());
    if((A[0]+A[1])==A[2]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int n, m;
int a[100000];
int ra[100001];

int calc(int x) {
	int i, j;
	int ret = 0;
	
	j = n - 1;
	for (i = 0; i < n; i++) {
		for (; j >= 0; j--) {
			if (a[i] + a[j] < x) break;
		}
		//(j, n-1]
		ret += n - 1 - j;
	}
	return ret;
}

int calcSum(int x) {
	int i, j;
	int ret = 0;
	
	j = n - 1;
	for (i = 0; i < n; i++) {
		for (; j >= 0; j--) {
			if (a[i] + a[j] < x) break;
		}
		//(j, n-1]
		ret += (n - 1 - j) * a[i];
		ret += ra[n] - ra[j + 1];
	}
	return ret;
}

signed main() {
	int i;
	
	cin >> n >> m;
	rep(i, n) cin >> a[i];
	sort(a, a + n);
	rep(i, n) ra[i + 1] = ra[i] + a[i];
	
	int st = 0, ed = 1e+6, mid;	//ooooxxxx, [st, ed)
	while (ed - st >= 2) {
		mid = (st + ed) / 2;
		if (calc(mid) > m) st = mid;
		else ed = mid;
	}
	int cnt = calc(st) - m;
	
	cout << calcSum(st) - st * cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
n = int(input())

for d in range(2 ** n):

    d_bin = "{:b}".format(d)

    list_e = []

    for cnt, bit in enumerate(reversed(d_bin)):
        if bit == "1":
            list_e.append(cnt)

    if list_e:
        print(f"{d}: ", end="")
        print(*list_e)
    else:
        print(f"{d}:")



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

int main() {
  int N;
  cin >> N;
  
  double ans = 0.0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    ans += (1.0 / a);
  }
  
  ans = 1.0 / ans;
  cout << setprecision(16) << ans << endl;
}

Measured memory_bytes: 3784
#include <iostream>
#include <vector>
#include <limits>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using namespace boost;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

int main() {
    uint count{0};
    for (auto &&i: irange(0U, 3U)){
        char c;
        cin >> c;
        if (c=='1'){
            count ++;
        }
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (W, H, x, y) = readLine()!!.split(" ").map { it.toLong() }
    val S = W * H / 2.0
    val frag = x * 2 == W && y * 2 == H
    println("$S ${if (frag) 1 else 0}")
}

Measured memory_bytes: 37740
def get_root(s):
    if s != root[s]:
        root[s] = get_root(root[s])
        return root[s]
    return s

def unite(s, t):
    global ans
    root_s = get_root(s)
    root_t = get_root(t)
    if not root_s == root_t:
        ans -= 1
        if rank[s] == rank[t]:
            root[root_t] = root_s
            rank[root_s] += 1
        elif rank[s] > rank[t]:
            root[root_t] = root_s
        else:
            root[root_s] = root_t

n, m = map(int, input().split())
root = [i for i in range(n)]
rank = [1 for _ in range(n)]
ans = n
for _ in range(m):
    x, y, z = map(int, input().split())
    unite(x - 1, y - 1)
print(ans)

Measured memory_bytes: 7856