akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

ll N, Ma, Mb;
vector<ll> a, b, c;

// i: 何個目？
// j: aのg数
// k: bのg数
// =: 最小cost 

ll dp[50][500][500];
int main() {
    cin >> N >> Ma >> Mb;
    a.resize(N);
    b.resize(N);
    c.resize(N);
    rep(i, N) cin >> a[i] >> b[i] >> c[i];

    rep(i, N + 1)rep(j, 40)rep(k, 40) {
        dp[i][j][k] = INF;
    }
    dp[0][0][0] = 0;

    rep(i, N)rep(j, 40)rep(k, 40) {
        // i個目を選んだ
        dp[i + 1][j + a[i]][k + b[i]] = min(dp[i + 1][j + a[i]][k + b[i]], dp[i][j][k] + c[i]);

        // i個目を選ばない
        dp[i + 1][j][k] = min(dp[i + 1][j][k], dp[i][j][k]);
    } 

    // 作れるかチェック
    ll ans = INF;
    for (int j = 1; j <= 400; j++) {
        for (int k = 1; k <= 400; k++) {
            if (dp[N][j][k] == INF) continue;
            if (dp[N][j][k] == 0) continue;

            if (j * Mb == k * Ma) {
                ans = min(ans, dp[N][j][k]);
            } 
            // cout << j << " " << k << " " << dp[N][j][k] << endl;
        }
    }
    if (ans == INF) {
        cout << -1 << endl;
    } else {
        cout << ans << endl; 
    }
}

Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<char>cvec;
typedef pair<ll, ll> LP;
typedef tuple<ll, ll, ll> LT;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
int main()	{
  int n;
  cin>>n;
  vector<int>p(n);
  vector<string>s(n);
  rep(i,n) {
    cin>>s[i]>>p[i];
    p[i]=-p[i];
  }
  vector<tuple<string,int,int>>mp;
  rep(i,n){
    mp.push_back(make_tuple(s[i],p[i],i));
  }
  sort(all(mp));
  rep(i,n){
    cout<<get<2>(mp[i])+1<<endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

typedef long long ll;
ll max(ll a, ll b){ return ( a > b )?a:b;}
ll min(ll a, ll b){ return ( a < b )?a:b;}

int main(){
        ll N, K;
        scanf("%lld %lld",&N,&K);
        if(N%K==0) puts("0");
        else  puts("1");
}

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

using namespace std;

int mod = 1e9 + 7, N, M, dp[5009][5009];
char sir[5009];

int add (int x, int y) {int ans = x + y; if (ans >= mod) ans -= mod; return ans;}
int substract (int x, int y) {if (x >= y) return x - y; return x - y + mod;}
int mul (int x, int y) {return 1LL * x * y % mod;}

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d\n%s", &N, sir + 1), M = strlen (sir + 1);
dp[0][0] = 1;
for (int i=0; i<N; i++)
    for (int j=0; j<=i; j++)
    {
        dp[i + 1][j + 1] = add (dp[i + 1][j + 1], 2 * dp[i][j]);
        int j2 = max (j - 1, 0);
        dp[i + 1][j2] = add (dp[i + 1][j2], dp[i][j]);
    }
int ans = dp[N][M];
while (M --) ans = mul (ans, (mod + 1) / 2);
printf ("%d\n", ans);
return 0;
}


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

int main(){
    int K, S;
    cin >> K >> S;
    int count = 0;
    for (int i = 0; i <= K; ++i){
        for (int j = 0; j <= K; ++j){
            int k = S - i - j;
            if (k >= 0 && k <= K) ++count;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  double N, K;
  cin >> N >> K;
  double a, ans;
  long count;
  for(int i = 1; i <= N; i++){
    a = i;
    count = 0;
    while(a < K){
      a *= 2;
      count++;
    }
    ans += 1.0 / pow(2, count);
  }
  ans /= N;
  cout << setprecision(20) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
int main(){

  int n,i;
  scanf("%d",&n);
  char s[n],t[n];
  scanf("%s",&s);
  scanf("%s",&t);
  
  for(i=0;i<n;i++)
    printf("%c%c",s[i],t[i]);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int n, x, c;
int main(){
	scanf("%d", &n);
	x = n - n/10*10;
	if(x==2||x==4||x==5||x==7||x==9){
		printf("hon");
	}
	else if(x==0||x==1||x==6||x==8){
		printf("pon");
	}
	else{
		printf("bon");
	}
	return 0;
}

Measured memory_bytes: 3752
#include <stdio.h>
#include <math.h>
int main(void){
  int p[8],not_ride[8];
  int pat[8][8]={0};
  int n=0,a=0,b=0,c,best,bestIndex,flag=0;
  int capacity[]={4,1,4,1,2,1,2,1};
  int i=0,j;

 
  while(1){
    for(i=0; i<8; i++){
      if(scanf("%d",&p[i])==EOF){
	flag = 1;
	break;
      }
    }
    if(flag)break;
    bestIndex = 0;
   long long int pattern[8] ={0};
  for(i=0; i<8; i++){
    for(j=a ,c =7; j<8+a; j++, c--){
      pattern[i] += capacity[j%8] * (int)pow(10.0,c);
      pat[i][b] = capacity[j%8];
    if(capacity[j%8] < p[b]){
      n += p[b] - capacity[j%8];
    }
    b++;
    }
    a = (j-1) % 8;
    b = 0;
    not_ride[i] = n;
    n = 0;
  }
  best = not_ride[0];
  for(i=1; i<8; i++){
    if(best > not_ride[i]){
      best = not_ride[i];
      bestIndex = i;
    }
    else if(best == not_ride[i]){
      if(pattern[bestIndex] > pattern[i])
	bestIndex = i;
    }
  }
  for(i=0; i<8; i++){
    if(i == 7)
      printf("%d\n",pat[bestIndex][i]);
    else
      printf("%d ",pat[bestIndex][i]);
  }
  }
  return 0;
}

Measured memory_bytes: 644
#include<stdio.h>

int A[1000000],n;

int binarySearch(int key){
  int left=0;
  int right=n;
  int mid;
  while(left<right){
    mid=(left+right)/2;
    if(key==A[mid]) return 1;
    if(key>A[mid]) left=mid+1;
    else if(key<A[mid]) right=mid;
  }
  return 0;
}

int main(){
  int i,q,k,sum=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&k);
    if(binarySearch(k)) sum++;
  }
  printf("%d\n",sum);
  
  return 0;
}



Measured memory_bytes: 2244
//58
#include<iostream>
#include<algorithm>
#include<iomanip>

using namespace std;

int main(){
  for(int ng,t,l,b;cin>>ng>>t>>l>>b,ng|t|l|b;){
    double n[101][101]={{1}};
    bool ls[101]={},bs[101]={};
    while(l--){
      int s;
      cin>>s;
      ls[s]=true;
    }
    while(b--){
      int s;
      cin>>s;
      bs[s]=true;
    }
    double lp[101]={};
    for(int i=0;i<t;i++){
      for(int k=0;k<ng;k++){
	for(int j=1;j<=6;j++){
	  n[i+1][min(k+j,k-j+2*(ng-k))]+=n[i][k]/6;
	}
      }
      for(int j=0;j<ng;j++){
	if(ls[j]){
	  swap(lp[j],n[i+1][j]);
	}else if(bs[j]){
	  n[i+1][0]+=n[i+1][j];
	  n[i+1][j]=0;
	}
      }
      n[i+1][ng]+=n[i][ng];
    }
    cout<<fixed<<setprecision(5)<<n[t][ng]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1324
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

#include <bits/stdc++.h>
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)

void solve() {
	long double d, t, s;
	cin >> d >> t >> s;
	long double x = (s * t);
	cout << (x >= d ? "Yes" : "No");
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    int tc = 1;
    // cin >> tc;
    while(tc--) {
        solve();
    }
    return 0;
}


Measured memory_bytes: 3740
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A,*B;
  int C[VMAX];
  int n,i,j;
  scanf("%d",&n);
  A=malloc(sizeof(short)*n+1);
  B=malloc(sizeof(short)*n+1);
  for(i=0;i<=VMAX;i++) C[i]=0;
  for(i=0;i<n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
  for(i=1;i<=VMAX;i++)C[i]=C[i]+C[i-1];
  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;
  }
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
    printf("%d",B[i]);
  }
  printf("\n");
  return 0;
}

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

int main(){
  string S;
  cin >>S;
  
  int len = S.size();
  
  int i = 0;
  int ans;
  bool flag = true;
  while(flag){
    S.erase(len-1,1);
    len = S.size();
    if(len%2==0){
      string s1 = S.substr(0,len/2);
      string s2 = S.substr(len/2,len/2);    
      if(s1==s2){
        ans = len;
        flag = false;
      }
    }
  }
  
  cout <<ans<< endl;
}

Measured memory_bytes: 256
s = input()
len(s)
ans = 0
for i in range(len(s)):
    for j in range(len(s) - i):
        part = s[i:j+i+1]
        # print("i", i)
        # print("j", j+i+1)
        # print("part=", part)
        for car in part:
            if car is not "A" and car is not "T" and car is not "C" and car is not "G":
                break
        else:
            if ans < len(part):
                ans = len(part)
                moji = part
            # print("car", car)
            # print("ans", ans)
            # print("moji", moji)

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
int main(int argc, char const *argv[]){
    string s;
    cin >> s;
    cout << s[0] << s[1] << s[2] << endl;
    return 0;
}




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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

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

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    cin >> n;
    cout << (180*(n-2)) << endl;
    return 0;
}


Measured memory_bytes: 3580
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
typedef long long LL;
using namespace std;
LL a , b , c , d , n;
int main()
{
	while(~scanf("%lld%lld%lld%lld%lld" , &n , &a , &b , &c , &d)){
		bool ok = 0;
		for(LL i = 0;i <= n - 2;i++){
			LL res = a + d * i - c * (n - 2 - i);
			LL tmp = a + c * i - d * (n - 2 - i);
			if(b >= tmp - c && b <= res - c) ok = 1;
			if(b >= tmp + c && b <= res + c) ok = 1;
			if(b >= tmp + d && b <= res + d) ok = 1;
			if(b >= tmp - d && b <= res - d) ok = 1;
		}
		if(ok) printf("YES\n");
		else printf("NO\n");
	}
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int n; cin >> n;
    int k; cin >> k;
    bitset<18> T(0);
    rep(i,k){
        int bi; cin >> bi;
        T.set(bi);
    }
    for(ll i=0; i<pow(2,n); i++){
        if(i == 0){
            if(k == 0) printf("0:\n");
            continue;
        }else{
            bitset<18> A(i);
            if((A & T) == T){
                printf("%d:", i);
                rep(j,18){
                    if(A.test(j)) printf(" %d", j);
                }
                cout << endl;
            }
        }
    }
}


Measured memory_bytes: 3412
from collections import deque

k = int(input())
q = deque()
for i in range(1,10):
    q.append(i)

for _ in range(k):
    a = q.popleft()
    d = a%10
    if d>0:
        q.append(10*a+d-1)
    q.append(10*a+d)
    if d<9:
        q.append(10*a+d+1)
print(a)

Measured memory_bytes: 11968
#include<iostream>
#include<vector>

#define ll long long
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR(i,k,n) for(int (i)=(k);(i)<(n);(i)++)

using namespace std;

int main(){
  ll K,X;cin >> K >> X;
  cout << (K*500>=X?"Yes":"No") << endl;
  return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    s = input()
    cnt = 0
    for i in range(n-2):
        if s[i]=='A' and s[i+1]=='B' and s[i+2] =='C':
            cnt +=1
    print(cnt)


if __name__ == "__main__":
    main()

Measured memory_bytes: 9024
#define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

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

static const double eps = 1e-8;

int main(){
	int q1;
	while(~scanf("%d",&q1)){
		if(q1==0) break;
		int b,c1,c2,q2;
		//1:aize chiken 2:normal chiken
		scanf("%d %d %d %d",&b,&c1,&c2,&q2);
		for(int i=q2;i>=1;i--){
			int cost = i*c1;

			int ub = 1000000;
			int lb = 0;

			for(int j=0;j<50;j++){
				int md = (ub+lb)/2;
				if(cost + md*c2 <=b) lb = md;
				else ub = md;
			}

			if(lb+i >= q1 && cost + lb*c2 <=b){
				printf("%d %d\n",i,lb);
				goto next;
			}
		}
		printf("NA\n");
next:;
	}
}

Measured memory_bytes: 880
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,m,x,y,in[100010],num[100010],ans[100010];
vector <int> g[100010],dg[100010],topo;
bool vis[100010];

void dfs(int pos)
{
	vis[pos]=true;
	rep(i,g[pos].size())
	{
		if(vis[g[pos][i]]) continue;
		dfs(g[pos][i]);
	}
	topo.pb(pos);
}

int main()
{
	cin>>n>>m;
	rep(i,m+n-1)
	{
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		dg[y].pb(x);
		in[y]++;
	}
	repn(i,n)
	{
		if(in[i]==0)
		{
			dfs(i);
			break;
		}
	}
	reverse(topo.begin(),topo.end());
	rep(i,n) num[topo[i]]=i;
	rep(i,n)
	{
		if(in[topo[i]]==0) continue;
		int opt=-1,par;
		rep(j,dg[topo[i]].size()) 
		{
			if(num[dg[topo[i]][j]]>opt)
			{
				opt=num[dg[topo[i]][j]];
				par=dg[topo[i]][j];
			}
		}
		ans[topo[i]]=par;
	}
	repn(i,n) cout<<ans[i]<<endl;
	rt0;
}
/*
6 3
2 1
2 3
4 1
4 2
6 1
2 6
4 6
6 5
*/

Measured memory_bytes: 16636
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
typedef long long int ll;
#define BIG_NUM 2000000000
using namespace std;

int main(){

	int sum=0,n,m,array[10],calc[10]={0,2,4,6,8,1,3,5,7,9},ans=0,which_index=0,num=0;
	char which[10];

	scanf("%d",&n);

	char* first = new char[n+1];
	char* buf = new char[n+1];

	scanf("%s",first);

	scanf("%d",&m);

	for(int i = 0; i < m; i++){
		scanf("%d",&array[i]);
	}

	for(int i = n-1,k = 0; i >= 0; i--,k++){
		buf[k] = first[i];
	}
	buf[n] = '\0';

	for(int i = 0;buf[i] != '\0';i++){
		if(buf[i] == '*'){
			num++;
			if(i%2 == 1){
				which[which_index++] = 'G';
			}else{
				which[which_index++] = 'K';
			}
		}else{
			if(i%2 == 1){
				sum += calc[buf[i]-'0'];
			}else{
				sum += buf[i]-'0';
			}
		}
	}

	int** dp = new int*[num+1];
	for(int i =1; i <=num; i++){
		dp[i] = new int[64];
		for(int k = 0; k <= 63; k++)dp[i][k] = 0;
	}

	for(int i = 0; i < m; i++){
		if(which[0] == 'G'){
			dp[1][calc[array[i]]] = 1;
		}else{
			dp[1][array[i]] = 1;
		}
	}

	for(int loop = 2; loop <= num; loop++){
		for(int i = 0; i <= 63; i++){
			if(dp[loop-1][i] != 0){
				for(int k = 0; k < m;k++){
					if(which[loop-1] == 'G'){
						dp[loop][i+calc[array[k]]] += dp[loop-1][i];
					}else{
						dp[loop][i+array[k]] += dp[loop-1][i];
					}
				}
			}
		}
	}

	for(int i = 0; i <= 63; i++){
		if((sum+i)%10 == 0){
			ans += dp[num][i];
		}
	}

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

	return 0;
}

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

int main() {
  int N , K;
  cin >> N >> K;
  vector<int> V(N);
  for (int i=0; i<N; i++) {
    cin >> V[i];
  }
  sort(V.begin(), V.end());
  reverse(V.begin(), V.end());
  int S=0;
  for (int i=0; i<K; i++) {
    S+=V[i];
  }
  cout << S << endl;
}


Measured memory_bytes: 3552
# D - Candidates of No Shortest Paths

MAXI = 999999999

# 入力
N, M = map(int, input().split())
cost = [[-1 for i in range(N)] for j in range(N)]

for i in range(M):
    a, b, c = map(int, input().split())
    cost[a - 1][b - 1] = c
    cost[b - 1][a - 1] = c

# iからjへの最短距離を表すテーブルの初期化
dist = [[MAXI for i in range(N)] for j in range(N)]

# iからjへの辺があったら、最短距離をその辺のコストで初期化
for i in range(N):
    for j in range(N):
        if i == j:
            dist[i][j] = 0
        elif cost[i][j] != -1:
            dist[i][j] = cost[i][j]
            dist[j][i] = dist[i][j]

# ワーシャルフロイドで各i,j間の最短距離を求めておく
for k in range(N):
    for i in range(N):
        for j in range(N):
            dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j])

ans = 0

for i in range(N):
    for j in range(i, N):
        # i,j間に辺があって、そこを通らない方が近道になるとき、全ての最短経路でその辺は使われない
        if cost[i][j] != -1 and cost[i][j] != dist[i][j]:
            ans += 1

print(ans)

Measured memory_bytes: 3444
#include <stdio.h>
#include <stdlib.h>

int main()
{
    char ch;

    scanf("%c",&ch);


    if(ch=='a'|| ch == 'e' || ch == 'i' || ch =='o' || ch =='u' )

        printf("vowel");

    else
        printf("consonant");



    return 0;
}


Measured memory_bytes: 128
#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;

int main()
{
    ll i,j;
    ll x,y,z,k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x);
    vector<ll> b(y);
    vector<ll> c(z);
    for(i = 0;i < x;++i){
        cin >> a.at(i);
    }
    for(i = 0;i < y;++i){
        cin >> b.at(i);
    }
    for(i = 0;i < z;++i){
        cin >> c.at(i);
    }
    vector<ll> ab;
    for(i = 0;i < x;++i){
        rep(j,y){
            ab.push_back(a.at(i) + b.at(j));
        }
    }
    sort(all(ab), greater<ll>());
    vector<ll> abc;
    for(i = 0;i < min(k,x*y);++i){
        rep(j,z){
            abc.push_back(ab.at(i) + c.at(j));
        }
    }
    sort(all(abc), greater<ll>());
    for(i = 0;i < k;++i){
        cout << abc.at(i) << endl;
    }

    return 0;
}

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

int main(){
  int a,b,k;
  cin >> a >> b >> k;
  
  int data[100];
    for ( int i = 0 ; i < 100 ; i++){
      data[i] = 1 + i;
    }
  int cnt = 0 ;
  for ( int i = 99 ; i >= 0 ; i-- ){
    if ( a % data[i] == 0 && b % data[i] ==0 ){
    	cnt++;
      	if ( cnt == k )
          cout << data[i] << endl;    
    }   
  }  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
   int a, b;
   cin >> a >> b;
   string s;
   cin >> s;
   for(int i = 0; i < a; i++){
       int m = s[i] - '0';
       if(m >= 10 || m < 0 ){
           cout << "No" << endl;
           return 0;
       }
   }
   if(s[a] != '-'){
       cout << "No" << endl;
       return 0;
   }
   for(int i = a + 1; i < a+1 + b; i++){
      int m = s[i] - '0';
      if(m >= 10 || m < 0 ){
           cout << "No" << endl;
           return 0;
       }
   }
   cout << "Yes" << endl;
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
const double pi = 3.141592653589793238462643383279;
using namespace std;
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long long, long long> PLL;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
 
 
//container util
//------------------------------------------
#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())
#define SQ(a) ((a)*(a))
#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())
 
 
//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007
 
 
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
 
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const double EPS = 1E-10;
 
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)


//ここから編集
ll GCD(ll a, ll b){
    
    if(b == 0) return a;
    return GCD(b, a%b);
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int a, b, k; cin >> a >> b >> k;
  
  for(int i=min(a, b); i>=1; i--){
      if(a%i == 0 && b%i == 0){
          k--;
          if(k == 0){
              cout  << i << endl;
              return 0;
          }
      }
  }

  return 0;
}


Measured memory_bytes: 3652
import java.io.*;
import java.util.*;
import java.util.function.IntPredicate;

class Main {
    static Scanner scanner = new Scanner();
    static long mod = 1000000007;

    public static void main(String[]$) {
        int n = scanner.nextInt();
        String s = scanner.next();
        int max = binarySearch(n, len -> {
            Map<String, Integer> map = new HashMap<>();
            for (int i = 0; i <= s.length() - len; i++) {
                String t = s.substring(i, i + len);
                if (map.containsKey(t)) {
                    if (map.get(t) + len <= i) {
                        return true;
                    }
                } else {
                    map.put(t, i);
                }
            }
            return false;
        });
        System.out.println(max);
    }

    static int binarySearch(int max, IntPredicate predicate) {
        int ok = -1, ng = max;
        while (ng - ok > 1) {
            int mid = (ok + ng) / 2;
            if (predicate.test(mid)) {
                ok = mid;
            } else {
                ng = mid;
            }
        }
        return ok;
    }

    static class Scanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 109140
import itertools

n=int(input())

def prime_decomposition(n):
    i = 2
    table = []
    while i * i <= n:
        while n % i == 0:
            n //= i
            table.append(i)
        i += 1
    if n > 1:
        table.append(n)
    return table

a=[]
for i in range(2,n+1):
    aa=prime_decomposition(i)
    a.extend(aa)
    
a.sort()

i75=0
i25=0
i15=0
i5=0
i3=0
gr = itertools.groupby(a)
for key, group in gr:
    ll=len(list(group))
#    print(ll)
    if ll>=74:
        i75+=1
    if ll>=24:
        i25+=1
    if ll>=14:
        i15+=1
    if ll>=4:
        i5+=1
    if ll>=2:
        i3+=1
ans=0
ans=ans+i75
ans=ans+i25*max(i3-1,0)
ans=ans+i15*max(i5-1,0)
ans=ans+i5*max(i5-1,0)*max(i3-2,0)//2
print(ans)


Measured memory_bytes: 62284
#include "bits/stdc++.h"
#define ll long long
using namespace std;

#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define rep(i,b) for(ll i=0;i<b;i++)

int m;

ll solve(string n) {
    ll L = n.size();
    vvvl dp(L + 1, vvl(2, vl(L + 1, 0)));
    dp[0][0][0] = 1;

    rep(i,L) {
        ll D = n[i] - '0';
        rep(j,2) {
            rep(k,L) {
                rep(d,(j?10:D+1)){
                    if(d != 0)dp[i+1][j || (d < D)][k + 1] += dp[i][j][k];
                    else dp[i+1][j || (d < D)][k] += dp[i][j][k];
                }
            }
        }
    }
    return dp[L][0][m] + dp[L][1][m];
}

int main(void) {
    string n;
    cin >> n >> m;
    cout<<solve(n)<<endl;
}

Measured memory_bytes: 384
using System;
using System.Collections.Generic;

namespace cswork {
    class Program {
        static void Main (string[] args) {
            List<string> s = ReadListStr();
            string x = s[1];

            Write("A" + x[0] + "C");
            Exit ();
        }

        public static void Write (string str) {
            Console.WriteLine (str);
        }

        public static void Write (int i) {
            Console.WriteLine (i);
        }

        public static void Write (double d) {
            Console.WriteLine (d);
        }

        public static string ReadStr () {
            return Console.ReadLine ();
        }

        public static int ReadInt () {
            return int.Parse (Console.ReadLine ());
        }

        public static long Read () {
            return long.Parse (Console.ReadLine ());
        }

        public static double ReadDouble () {
            return double.Parse (Console.ReadLine ());
        }

        public static void Exit () { }

        public static List<string> ReadListStr () {
            return new List<string> (ReadStr ().Split (" "));
        }

        public static List<long> ReadList () {
            return ReadListStr ().ConvertAll (x => long.Parse (x));
        }

        public static List<int> ReadListInt () {
            return ReadListStr ().ConvertAll (x => int.Parse (x));
        }
    }
}

Measured memory_bytes: 26056
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);

		int r = 0, D = 0, x2000 = 0;

		try {
			String[] s = scanner.nextLine().split(" ");
			r = Integer.parseInt(s[0]);
			D = Integer.parseInt(s[1]);
			x2000 = Integer.parseInt(s[2]);
		} catch (NumberFormatException e) {
		} catch (NullPointerException e) {
		}

		scanner.close();

		xip1(r, D, x2000, 2000);

	}
	static void xip1(int r, int D, int xi, int i) {
		i++;
    	int xip1 = xi * r - D;
    	System.out.println(xip1);
    	if(i >= 2010) {
			return;
		}
    	xip1(r, D, xip1, i);
	}

}


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

using namespace std;

using ll = long long;

#define MOD_NUMBER 1000000007

// ベクトル要素の列挙
template <class T> void vector_print(vector<T> vec) {
  for (unsigned int i = 0; i < vec.size(); i++) {
    cout << vec.at(i);
    if (i < vec.size()-1) {
      cout << " ";
    } else if (i == vec.size()-1) {
      cout << endl;
    }
  }
}
// エラトステネスの篩による素数配列の出力
vector<int> Eratosthenes(int N){
  vector<int> p = {2};
  int sqrtN = sqrt(N);
  for(int i = 3; i <= N; i++){
    p.push_back(i);
    for (int j = 0; p.at(j) <= sqrtN; j++) {
      if(i%p.at(j) == 0) {
        p.pop_back();
        break;
      }
    }
  }
  return p;
}

int main() {
  string s;
  int k;
  cin >> k >> s;
  if (s.size() <= k){
    cout << s << endl;
  } else {
    for (int i = 0; i < k; i++) {
      cout << s.at(i);
    }
    cout << "..." << endl;
  }
  return 0;
}


Measured memory_bytes: 3632
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.nextLine();

        if (s.charAt(0) != 'A') {
            System.out.println("WA");
            return;
        }

        boolean cFound = false;
        for (int i = 1; i < s.length(); i++) {
            if (!cFound && 2 <= i && i <= s.length() - 2 && s.charAt(i) == 'C') {
                cFound = true;
            } else if (s.charAt(i) < 'a' || 'z' < s.charAt(i)) {
                System.out.println("WA");
                return;
            }
        }

        if (cFound) {
            System.out.println("AC");
        } else {
            System.out.println("WA");
        }
    }
}


Measured memory_bytes: 23764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


typedef long long ll;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


int main(){
  int a, b;
  cin >> a >> b;
  int tmp = b;
  while(tmp != 0){
    tmp /= 10;
    a *= 10;
  }
  vector<int> heihou;
  for(int i = 1; ; ++i){
    int nijou = i * i;
    if(nijou >= 100100) break;

    heihou.push_back(nijou);
  }

  bool ans = false;
  a += b;

  for(int i = 0; i < heihou.size(); ++i){
    if(a == heihou[i]){
      ans = true;
    }
  }

  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;


}


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

int n, m, s, p, x, a[105];
int main() {
	int i;
	cin >> n;
	for(i=1; i<=n; i++) scanf("%d", &a[i]), s += a[i];
	cin >> m;
	while(m--) {
		scanf("%d%d", &p, &x);
		printf("%d\n", s - a[p] + x);
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
using namespace std;
#define endl '\n'
//#define for(i,s,n) for(int i=s;i<n;i++) 
#define vii vector<int>
int t = 1, n, OO = 1e14;
vii v, cum;
int dp[402][402];
int solve(int i, int j) {
	if (i + 1 == j) return v[i] + v[j];
	if (i == j) return 0;
	int& ret = dp[i][j];
	if (~ret) return ret;
	ret = OO;
	for (int k = i; k < j; k++) {
		ret = min(ret, (cum[j] - cum[i - 1]) + solve(i, k) + solve(k+1, j));
	}
	return ret;
}
signed main()
{
	fast;
	
	//cin>>t;
	while (t--)
	{
		cin >> n;
		v = vii(n+1);
		for (int i = 1; i <= n; i++) cin >> v[i];
		cum = vii(n + 1);
		for (int i = 1; i <= n; i++) cum[i] = cum[i - 1] + v[i];
		memset(dp, -1, sizeof dp);
		cout<<solve(1,n)<<endl;
	}
}

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

#define REP(i,k,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int prime[1000001];
int dp[1000001];

void CreatePrime()
{
	rep(i,1000001) prime[i] = 1;

	prime[0] = 0;

	for(int i=0;i<1000001;i++)
	{
		if(prime[i] == 1)
		{
			int num = i+1;
			for(int j=num*2-1;j <1000001;j += num)
			{
				prime[j] = 0;
			}
		}
	}
}

int main()
{
	CreatePrime();

	int a[31];
	int n,x,ans = 0;
	
	
	while(cin >> n >> x)
	{
		if(n == 0 || x == 0)
		{
			break;
		}

		memset(a,0,sizeof(a));
		memset(dp,0,sizeof(dp));

		ans = 0;
		rep(i,n) 
		{
			cin >> a[i];
			dp[a[i]] = 1;
		}

		rep(i,n)
		{
			rep(j,x+1)
			{
				if(dp[j] == 1 && j+a[i] <= x)
				{
					dp[j+a[i]] = 1;
				}
			}
		}

		rep(i,x+1)
		{
			if(dp[i] == 1 && prime[i-1] == 1)
			{
				ans = i;
			}
		}

		if(ans == 0)
		{
			cout << "NA" << endl;
		}
		else
		{
			cout << ans << endl;
		}


	}
	
	return 0;
}

Measured memory_bytes: 8980
N,K = gets.split.map &:to_i
H = gets.split.map &:to_i
DP = [0]
 
1.upto(N-1) do |i|
  min = Float::INFINITY
  [0, i-K].max.upto(i-1) do |j|
    cost = (H[i] - H[j]).abs + DP[j]
    min = cost if min > cost
  end
  DP[i] = min
end
 
p DP[-1]

Measured memory_bytes: 13340
#include<cstdlib>
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<cstring>
using namespace std;
const int MAXN = (int) 105;
const int INF = (int) 0x3f3f3f3f;
typedef long long LL;

int f[MAXN][MAXN*10];

void work(){
    int x,y,s;
    for(int i=1;i<100;i++){
        for(int j=1;j<=1000;j++){
            int p=j*(100+i)/100;
            if(p<=1000) f[i][p]=max(f[i][p],j);
        }
    }
    while(~scanf("%d%d%d",&x,&y,&s)&&x&&y&&s){
        int mx=0;
        for(int i=1;i<s;i++){
            int j=s-i;
            if(f[x][i]==0||f[x][j]==0) continue;
            int p=f[x][i]*(100+y)/100+f[x][j]*(100+y)/100;
            if(p>mx){
                mx=p;
            }
        }
        printf("%d\n",mx);
    }
}

int main(){
//    freopen("data.in","r",stdin);
    work();
    return 0;
}



Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long  ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rep0(i,n) for(int i=0;i<n;i++)
#define per0(i,n) for(int i=n-1;i>=0;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
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; }
 

void solve() {
    ll h; cin >> h;
    ll ans = 0;
    ll count = 1;
    while(h > 0){
        h = h >> 1;
        ans += count;
        count = count << 1;
    }
    cout << ans;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	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 n, m;
  cin >> n >> m;
  
  int l_lim = 1;
  int r_lim = n;
  
  for (int i = 1; i <= m; ++i) {
    int l, r;
    cin >> l >> r;
    l_lim = max(l_lim, l);
    r_lim = min(r_lim, r);
  }
  
  cout << max(r_lim - l_lim + 1, 0) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 998244353;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}

signed main(){
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i, n) cin >> h[i];
    vector<int> dp(n, inf);


    dp[0] = 0;
    dp[1] = abs(h[0]-h[1]);

    for (size_t i = 2; i < n; i++)
    {
        for (size_t j = 1; j < k+1; j++)
        {
            if(i>=j) {
                dp[i] = min(dp[i], dp[i-j]+abs(h[i]-h[i-j]));
                //cout << i << " " << j << " " << abs(h[i]-h[j])<< endl;
            }
        }
        
    }
    //for(auto d: dp) cout << d << endl;
    cout << dp[n-1] << endl;
    

    return 0;
}



Measured memory_bytes: 6528
#include <algorithm>
#include <bitset>
#include <cassert>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <sstream>
#include <stdio.h>
#include <string>
#include <vector>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define POW(n) ((n) * (n))
#define ALL(a) (a).begin(), (a).end()
#define dump(v) (cerr << #v << ": " << v << endl)
#define cerr                                                                   \
  if (true)                                                                    \
  cerr

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<unsigned long long> vull;

// ll n = to_T<ll>("114514")
template <class T> T to_T(const string &s) {
  istringstream is(s);
  T res;
  is >> res;
  return res;
}
template <class T> string to_s(const T &a) {
  ostringstream os;
  os << a;
  return os.str();
}

ll gcd(ll a, ll b) {
  if (a < b)
    swap(a, b);
  ll r = a % b;

  while (r) {
    a = b;
    b = r;
    r = a % b;
  }

  return b;
}

void solve(long long N, vector<long long> T) {
  sort(ALL(T));
  reverse(ALL(T));
  ll ans = T[0];

  FOR(i, 1, N) {
    ll g = gcd(ans, T[i]);
    ans = ans / g * T[i];
  }

  cout << ans << endl;
}

int main() {
  ios::sync_with_stdio(false);
  long long N;
  cin >> N;
  vector<long long> T(N - 1 + 1);
  for (int i = 0; i <= N - 1; i++) {
    cin >> T[i];
  }
  solve(N, T);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
string s, t;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> s >> t;
  map<char, set<int>> cs;

  REP(i, s.size()) {
    cs[s[i]].insert(i + 1);
  }

  ll ans = 0, p = 0;
  REP(i, t.size()) {
    if(cs[t[i]].size() > 0) {
      auto it = cs[t[i]].upper_bound(p);
      if(it == cs[t[i]].end()) {
        int np = *cs[t[i]].begin();
        ans += (s.size() - p) + np;
        p = np;
      } else {
        ans += *it - p;
        p = *it;
      }
    } else {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));

    cout <<abs(a[0]-a[n-1]) << '\n';

    return 0;
}


Measured memory_bytes: 3608
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let n: u32 = read();
    let mut numbers: Vec<i64> = Vec::with_capacity(n as usize);
    let mut counter: u32 = 0;
    let mut flag = true;

    for _ in 0..n {
        numbers.push(read());
    }

    while flag {
        let mut new_nubers: Vec<i64> = Vec::with_capacity(n as usize);

        for item in &numbers {
            if item % 2 == 0 {
                new_nubers.push(item / 2)
            } else {
                flag = false
            }
        }

        if flag {
            counter += 1;
            numbers = new_nubers
        }
    }

    println!("{}", counter);
}


Measured memory_bytes: 4352
def selections(N):
    count = 0
    for i in range(len(N)):
        mini = i
        for j in range(i+1, len(N)):
            if N[mini] > N[j]:
                mini = j
        if i != mini:
            N[mini], N[i] = N[i], N[mini]
            count += 1
    c = 1
    for i in N:
        print(i, end='')
        if c < len(N):
            print(' ', end='')
            c += 1
    print('')
    print(count)
    
n = int(input())
numbers = list(map(int, input().split()))

selections(numbers)

Measured memory_bytes: 7792
#include<bits/stdc++.h>
using namespace std;
const int mx=123456;
#define ll long long
#define p push_back
#define ff first
#define ss second
ll n ,cnt,temp;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++){
        temp=0;
        for(int j=1;j<=i;j++){
            if(i%j==0 && i%2==1){
                temp++;
            }
        }
        if(temp==8)cnt++;
    }
    cout<<cnt;
    return 0;
}



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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<long long> answers = {0, 0, 0, 61, 230, 865, 3247, 12185, 45719, 171531, 643550, 2414454, 9058467, 33985227, 127504505, 478366600, 794717734, 733354121, 261943303, 776803305, 580025381, 51688048, 44657419, 737209731, 604119499, 159693437, 858533109, 639056669, 549054109, 996291083, 531294469, 23314687, 783022045, 855462856, 649970414, 68697295, 409213624, 604356692, 88638656, 978442997, 534833116, 763737161, 785892908, 123883652, 639213333, 181836645, 998121103, 124885216, 501575626, 39816123, 113468411, 799008836, 775465589, 256852905, 664630886, 971550783, 751629411, 51018086, 702530485, 725438992, 696683714, 792638194, 221791721, 149602322, 414054379, 986519078, 981760191, 305799096, 515140586, 406959393, 975058685, 245601370, 324759692, 673385295, 191483611, 570246669, 427196161, 781042769, 569725155, 842176273, 25328739, 847501730, 206282374, 353770801, 323137024, 371653459, 940737264, 123820509, 915711339, 847205021, 252858375, 718889563, 866398347, 738390145, 133009077, 333099663, 170591295, 329869205, 616680192, 597534442, 388130742};
    cout << answers[n];
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <deque>
#include <iostream>
#include <map>
#include <tuple>
#include <vector>

#define rep(i, n) for (int i = 0; (i) < (n); (i)++)
using namespace std;
using ll = long long;

int Buildings[15];

int main(void) {
  int N, K;
  cin >> N >> K;
  rep(i, N) cin >> Buildings[i];

  ll min_fee = -1;
  for (int bit = 0; bit < (1 << N); ++bit) {
    vector<int> sel(N, 0);
    for (int i = 0; i < N; ++i) {
      if (((1 << i) & bit) != 0) {
        sel[i] = 1;
      }
    }

    ll tallest = Buildings[0];
    ll can_see = 1;
    ll fee = 0;
    for (int i = 1; i < N; ++i) {
      if (sel[i] && Buildings[i] <= tallest) {
        tallest++;
        fee += tallest - Buildings[i];
        can_see++;
      } 

      if (Buildings[i] > tallest) {
        tallest = Buildings[i];
        can_see++;
      }
    }
    if (can_see >= K) {
      if (min_fee == -1 || min_fee > fee) min_fee = fee;
    }
  }
  if(min_fee == -1)
    min_fee = 0;
  cout <<  min_fee << endl;

  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=1e5+9;
int main()
{
    FASTINOUT;
    int x,a;
    cin>>x>>a;
    x%=500;
    cout<<(x<=a?"Yes":"No");
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <queue>
#include <boost/tuple/tuple.hpp>
#include <boost/tuple/tuple_comparison.hpp>

#define REP(i,n) for(int i=0; i<(int)(n); i++)

inline int getInt(){ int s; scanf("%d", &s); return s; }

using namespace std;
using namespace boost;

int go[50][50];
int re[50][50];

int d[50];
int e[50];

bool memo[50][50];

int main(){
  while(true){
    int n = getInt();
    int m = getInt();

    if(n + m == 0) break;

    d[0] = d[n - 1] = 0;
    e[0] = 0; e[n - 1] = 1000;

    REP(i, n - 2){
      d[i + 1] = getInt();
      e[i + 1] = getInt();
    }

    REP(i,n) REP(j,n){
      memo[i][j] = false;
      go[i][j] = re[i][j] = 0;
    }

    REP(i, m){
      int a = getInt() - 1;
      int b = getInt() - 1;
      int c = getInt();

      if(e[a] >= e[b])
        re[b][a] = c;
      if(e[a] <= e[b])
        go[a][b] = c;
    }


    typedef boost::tuple<int, int, int, long long> data;
    const int COST = 0;
    const int POS_GO = 1;
    const int POS_RE = 2;
    const int FLAG   = 3;

    priority_queue<data, vector<data>, greater<data> > pq;
    bool ok = false;

    pq.push(make_tuple(0, 0, 0, 1));

    // puts("go"); REP(i,n){ REP(j,n) printf("%2d ", go[i][j]); puts("");}
    // puts("re"); REP(i,n){ REP(j,n) printf("%2d ", re[i][j]); puts("");}

    while(pq.size()){
      data dt = pq.top(); pq.pop();
      int cost  = dt.get<COST>();
      int posgo = dt.get<POS_GO>();
      int posre = dt.get<POS_RE>();
      long long flag = dt.get<FLAG>();

      if(memo[posgo][posre]) continue;
      memo[posgo][posre] = true;

      // printf("%d %d %d\n", cost, posgo, posre);

      if(posgo == n - 1 && posre == n - 1){
        ok = true;
        printf("%d\n", cost);
        break;
      }

      REP(i,n){
        bool gof = go[posgo][i] != 0;
        bool ref = re[posre][i] != 0;
        int cc = cost;
        long long ff = (flag | (1ll << i));

        if((flag & (1ll << i)) == 0){
          cc += d[i];
        }

        if(gof && !memo[i][posre])
          pq.push(make_tuple(cc + go[posgo][i], i, posre, ff));
        if(ref && !memo[posgo][i])
          pq.push(make_tuple(cc + re[posre][i], posgo, i, ff));
        if(gof && ref && !memo[i][i])
          pq.push(make_tuple(cost + d[i] + go[posgo][i] +
                             re[posre][i], i, i, ff));
      }
    }

    if(!ok) puts("-1");
  }
  return 0;
}

Measured memory_bytes: 0