akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
	map<string, int> balls;
	string sa, sb;
	//
	cin >> sa; 	
	cin >> sb;
	//
	cin >> balls[sa];
	cin >> balls[sb];
	//
	string sc;
	cin >> sc;
	balls[sc]--;
	//
	cout << balls[sa] << " " << balls[sb];
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
using i64 = int64_t;
using f80 = __float80;
static const int dy[4] = {0,1,0,-1}, dx[4] = {1,0,-1,0};
constexpr i64 INF = 1'010'000'000'000'000'017LL;
constexpr i64 MOD = 1'000'000'007LL;
#define _overload3(_1,_2,_3,name,...) name
#define repi(i,start,end) for(i64 i=(start);i<(end);++i)
#define _rep(i,n) repi(i,0,n)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,start,end) for(i64 i=(start);i>end;--i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define v(T) vector<T>
#define vv(T) v(v(T))
typedef v(i64) vi;
typedef v(vi) vvi;
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;}
template<typename T> ostream &operator<<(ostream &os, const vector< T > &v){
  rep(i,v.size()) os << v[i] << (i + 1 != v.size() ? " " : "");
  return os;
}
template<typename T> istream &operator>>(istream &is, vector< T > &v){
  for(T &in : v) is >> in;
  return is;
}

void Main()
{
  i64 a, b;
  cin >> a >> b;
  if(0 < a){
    cout << "Positive\n";
    return;
  }
  if(0 <= b){
    cout << "Zero\n";
    return;
  }
  if((b - a + 1) & 1){
    cout << "Negative\n";
  }else{
    cout << "Positive\n";
  }
}

int main()
{
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  Main();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static int func(int[] b,int[] r,int[] g,int cnt,int col,int now){
		int a=cnt;
		if(col==0){
			if(b[now]>=3){
				b[now]-=3;
				a=Math.max(a,func(b,r,g,cnt+1,col,now));
				b[now]+=3;
			}
			if(now<=7)if(b[now]>=1 && b[now+1]>=1 && b[now+2]>=1){
				b[now]-=1;
				b[now+1]-=1;
				b[now+2]-=1;
				a=Math.max(a,func(b,r,g,cnt+1,col,now));
				b[now]+=1;
				b[now+1]+=1;
				b[now+2]+=1;
			}
			if(now!=9)a=Math.max(a,func(b,r,g,cnt,col,now+1));
			else a=Math.max(a,func(b,r,g,cnt,col+1,1));
		}
		if(col==1){
			if(r[now]>=3){
				r[now]-=3;
				a=Math.max(a,func(b,r,g,cnt+1,col,now));
				r[now]+=3;
			}
			if(now<=7)if(r[now]>=1 && r[now+1]>=1 && r[now+2]>=1){
				r[now]-=1;
				r[now+1]-=1;
				r[now+2]-=1;
				a=Math.max(a,func(b,r,g,cnt+1,col,now));
				r[now]+=1;
				r[now+1]+=1;
				r[now+2]+=1;
			}
			if(now!=9)a=Math.max(a,func(b,r,g,cnt,col,now+1));
			else a=Math.max(a,func(b,r,g,cnt,col+1,1));
		}
		if(col==2){
			if(g[now]>=3){
				g[now]-=3;
				a=Math.max(a,func(b,r,g,cnt+1,col,now));
				g[now]+=3;
			}
			if(now<=7)if(g[now]>=1 && g[now+1]>=1 && g[now+2]>=1){
				g[now]-=1;
				g[now+1]-=1;
				g[now+2]-=1;
				a=Math.max(a,func(b,r,g,cnt+1,col,now));
				g[now]+=1;
				g[now+1]+=1;
				g[now+2]+=1;
			}
			if(now!=9)a=Math.max(a,func(b,r,g,cnt,col,now+1));
		}
		return a;
	}
	public static void main(String args[]){
		Scanner sc=new Scanner(System.in);
		int t=sc.nextInt();
		int[] n;
		String[] s;
		n=new int[9];
		s=new String[9];
		for(int ttt=0;ttt<t;ttt++){
			int[] b,r,g;
			b=new int[10];
			r=new int[10];
			g=new int[10];
			for(int i=0;i<9;i++)n[i]=sc.nextInt();
			for(int i=0;i<9;i++){
				s[i]=sc.next();
				if(s[i].equals("B"))b[n[i]]++;
				if(s[i].equals("G"))g[n[i]]++;
				if(s[i].equals("R"))r[n[i]]++;
			}
			System.out.printf("%d\n",func(b,g,r,0,0,0)/3);
		}
	}
}

Measured memory_bytes: 20856
#include <iostream>

 

using namespace std;

 

int main() 
{
    int a, b, c;
    
    cin >> a >> b >> c;
    if (a <= b && b <= c)
        cout << a << " " << b << " " << c << endl;
    else if(a <= c && c <= b)
        cout << a << " " << c << " " << b << endl;
    else if(c <= a && a <= b)
       cout << c << " " << a << " " << b << endl;  
    else if(b <= c  && c  <= a )
     cout << b << " " << c << " " << a << endl;
    else if(b <= a  && a  <= c )
     cout << b << " " << a << " " << c << endl;
    else
         cout << c << " " << b << " " << a << endl;
}


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

int main() {
  char s[4];
  int n[4];
  int i = 0;
  scanf("%c%c%c%c", &s[0], &s[1], &s[2], &s[3]);
  while (i < 4) {
    n[i] = s[i] - '0';
    i++;
  }
  i = 0;
  while (i < 8) {
    int sum = n[0];
    bitset<3> op(i);
    for (int j=1; j <= 3;j++) {
      if (op.test(3 - j))  sum += n[j];
      else  sum -= n[j];
    }
    if (sum == 7) {
      printf("%d%c%d%c%d%c%d=7", n[0], op.test(2)?'+' : '-', n[1], op.test(1)?'+' : '-', n[2], op.test(0)?'+' : '-',n[3]);
      return 0;
    }
    i++;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int A, B, C, D, N, K, H, X, Y, ans=0;
    string S;
    cin >> N;

    ans = (1+N)*N/2;

    
    cout <<ans<<endl;
    
    // if(A<B)
    // 	cout << 0<<endl;
    // else
    // 	cout <<10<<endl;
    

    // string S;
    // cin >>S;
    // cout << S + "pp"<<endl;

    // if(S[0]==S[1] && S[1]==S[2] && S[2]==S[3])
    // 	puts("SAME");
    // else
    // 	puts("DIFFERENT");    
    	
}


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define MN 5100001
#define ll long long
using namespace std;

ll read_p,read_ca;
inline ll read(){
    read_p=0;read_ca=getchar();
    while(read_ca<'0'||read_ca>'9') read_ca=getchar();
    while(read_ca>='0'&&read_ca<='9') read_p=read_p*10+read_ca-48,read_ca=getchar();
    return read_p;
}
ll n,q,d,a,p[MN],w[MN];
ll ma[MN];
ll min(ll x,ll y){return x<y?x:y;}
ll _abs(ll x){return x<0?-x:x;}
int main(){
	register ll i;
	n=read();d=read();p[0]=d;
	for (i=1;i<=n;i++) w[i]=read();
	for (i=1;i<=n;i++) p[i]=min(p[i-1],_abs(p[i-1]-w[i]));
	ma[n+1]=0;
	for (i=n;i;i--)
	if (w[i]/2<=ma[i+1]) ma[i]=ma[i+1]+w[i];else ma[i]=ma[i+1];
	
	q=read();
	while (q--) a=read(),puts(p[a-1]>ma[a+1]?"YES":"NO");
}

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

int main()
{
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    rep(i, k)
    {
        if (a >= b)
            b *= 2;
        else
            c *= 2;
    }
    if (a < b && b < c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3612
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int a, b;
  cin >> a >> b;
  if (a <= 5) {
    cout << 0 << endl;
  } else if (a <= 12) {
    cout << b / 2 << endl;
  } else {
    cout << b << endl;
  }
  return 0;
}

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

using namespace std;
using ll = long long;



int main()
{
    int n,a,b;
    cin >> n >> a >> b;
    vector<int> p(n);
    vector<bool> seen(n);
    for(int i = 0; i < n; i++)cin >> p[i];
    int ans = 0;
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            for(int k = 0; k < n; k++){
                if(i == j || j == k || k == i)continue;
                if(seen[i] || seen[j] || seen[k]) continue;
                if(p[i] <= a && p[j] > a && p[j] <= b && p[k] > b){
                seen[i] = true;
                seen[j] = true;
                seen[k] = true;
                ans++;
                }
            }
        }
    }
    cout << ans << endl;

}

Measured memory_bytes: 256
/* author   : mpily :-()
title : Competing.cpp
time :Sat Apr 11 11:13:36 2020

*/
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long W,H,x,y;
	cin>>W>>H>>x>>y;
	long double area = W*H;
	area/=2.f;
	cout<<setprecision(5)<<fixed;
	cout<<area<<" ";
	if(W%2==0 && x == W/2 && H%2==0 && y == H/2){
		cout<<1<<"\n";
	}
	else cout<<0<<"\n";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>*/
 
#define pb push_back
#define mp make_pair
#define sz(s) ((int)(s.size()))
#define all(s) s.begin(), s.end()
#define rep(i, a, n) for (int i = a; i <= n; ++i)
#define per(i, n, a) for (int i = n; i >= a; --i)
#define onlycin ios_base::sync_with_stdio(false); cin.tie(0) 
using namespace std;
// using namespace __gnu_pbds;
typedef long long ll;
typedef unsigned long long ull;
/*typedef tree<
pair < int, int >,
null_type,
less< pair < int, int > >,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;*/
// find_by_order() order_of_key()
const int MAXN = (int)5e5+228;
const char nxtl = '\n';
const int mod = (int)1e9+7;
const double eps = (double)1e-7;
template<typename T> inline bool updmin(T &a, const T &b) {return a > b ? a = b, 1 : 0;}
template<typename T> inline bool updmax(T &a, const T &b) {return a < b ? a = b, 1 : 0;}

int n, c[MAXN], f[MAXN], s[MAXN];

int main() {
	#ifdef accepted
		freopen(".in", "r", stdin);
		freopen(".out", "w", stdout);
	#endif
	onlycin;
	cin >> n;
	rep(i, 1, n-1) cin >> c[i] >> s[i] >> f[i];
	rep(i, 1, n-1) {
		int cur = s[i] + c[i];
		rep(j, i + 1, n-1) {
			if(cur < s[j]) cur = s[j]+c[j];
			else {
				cur += (f[j] - cur % f[j]) % f[j];
				cur += c[j];
			}
		}
		cout << cur << nxtl;
	}
	cout << 0;
	
	return 0;
}

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

const int INF = 1000000;

using namespace std;

int main(){
    int N, T;
    cin >> N >> T;

    vector<pair<int, int>> routes;
    for(int i = 0; i < N; i++){
        int A, B;
        cin >> A >> B;
        routes.push_back(pair<int, int>(A, B));
    }

    int minTime = INF;
    for(int i = 0; i < N; i++){
        if(routes[i].second <= T){
            minTime = min(minTime, routes[i].first);
        }
    }

    if(minTime == INF){
        cout << "TLE" << endl;
    }else{
        cout << minTime << endl;
    }
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 1010, M = 1010;

int n, m;
map<int, int> f[2];

int main()
{
	scanf("%d%d", &n, &m);
	
	int t = 1;
	f[0][0] = 0;
	for (int i = 1; i <= n; i ++ , t ^= 1)
	{
		int w, v;
		scanf("%d%d", &v, &w);
		
		for (auto u : f[t ^ 1])
		{
			f[t][u.F] = max(f[t][u.F], u.S);
			if (u.F + v <= m) f[t][u.F + v] = max(f[t][u.F + v], u.S + w);
		}
	}
	
	int res = 0;
	for (auto u : f[t ^ 1]) res = max(res, u.S);
			
	printf("%d\n", res);
	return 0;
}

Measured memory_bytes: 512
import math
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

R = 10**9+7
n,k = inm()
q = int(math.sqrt(n))
a = [ [0]*(q+1) for j in range(k) ]
b = [ [0]*(q+1) for j in range(k) ]
c = [0]*(q+1)
c[1] = n - n//2
for i in range(2,q):
    c[i] = n//i - n//(i+1)
c[q] = n//q - q
for i in range(1,q+1):
    a[0][i] = 1
    b[0][i] = c[i]


for j in range(1,k):
    aacc = [0]*(q+2)
    bacc = [0]*(q+2)
    for i in range(1,q+1):
        aacc[i] = (aacc[i-1] + a[j-1][i])%R
    for i in range(q,0,-1):
        bacc[i] = (bacc[i+1] + b[j-1][i])%R
    for i in range(1,q+1):
        a[j][i] = (aacc[q]+bacc[i])%R
        b[j][i] = (aacc[i]*c[i])%R

print( (sum(a[k-1]) + sum(b[k-1])) % R )


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

class Program
{
    static void Main(string[] args)
    {
        string str = Console.ReadLine();

        char[] letter = str.ToCharArray();

        if (letter.Length == 2)
        {
            foreach (var c in letter)
            {
                Console.Write(c);
            }
        }

        else
        {
            Array.Reverse(letter);
            foreach (var c in letter)
            {
                Console.Write(c);
            }
        }
        Console.WriteLine();
    }
}

Measured memory_bytes: 11092
#include <stdio.h>
#include <ctype.h>
 
int main() {
 
  char ch[1200];
  int i,n;
  n=0;
  char a[1200];
 
  while(1) {
    scanf("%c",&a[n]);
    if(a[n] == '\n') {
      break;
    }
    ch[n] = a[n];
    if('A' <= a[n] && a[n] <= 'Z') {
      ch[n] = a[n] + 32;
    } else if(a[n] >= 'a' && a[n] <= 'z') {
      ch[n] = a[n] - 32;
 
    }
     
     
    n = n +1;
     
  }
   
  for(i=0; i<n ; i++) {
    printf("%c" ,ch[i]);
  }
  printf("\n"); 
  return 0;
   
}


Measured memory_bytes: 2048
#include<iostream>
#include<stack>
#include<cstdlib>
using namespace std;

int main(){
    stack<int> S;
    int a,b,x;
    string s;

    while(cin>>s){
        if (s[0] == '+'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a+b);
        }else if(s[0] == '-'){
            b = S.top(); S.pop();
            a = S.top(); S.pop();
            S.push(a-b);
        }else if(s[0] == '*'){
            a = S.top(); S.pop();
            b = S.top(); S.pop();
            S.push(a*b);
        }else{
            S.push(atoi(s.c_str()));
        }
    }
    cout << S.top() << endl;
    return 0;
}



Measured memory_bytes: 3152
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> p;

    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        p.push_back(tmp);
    }

    int resu_hu = x;
    int resu_sei = x;
    while (true) {
        if (find(p.begin(), p.end(), resu_hu) == p.end()) {
            break;
        }
        resu_hu--;
    }

    while (true) {
        if (find(p.begin(), p.end(), resu_sei) == p.end()) {
            break;
        }
        resu_sei++;
    }

    if (min(x - resu_hu, resu_sei - x) == x - resu_hu) {
        cout << resu_hu << endl;
    } else {
        cout << resu_sei << endl;
    }
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
//#define at(x,i) get<i>(x);//
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
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;
}
const int mod = 1000000007;
const int max_n = 200005;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
}comb(max_n);
int main(){
    ll n,k;cin >> n >>k;
    ll r=n-k+1;
    rep(i,k){
        ll c=i+1;
        mint ans=1;
        ans*=comb(r,c);
        ans*=comb(k-1,c-1);
        cout << ans <<endl;
    }
}

Measured memory_bytes: 3328
N, X, M = map(int, input().split())
A = [[0] * (10**5+1) for _ in range(34)]
B = [[0] * (10**5+1) for _ in range(34)]

for i in range(10**5+1):
    A[0][i] = B[0][i] = i**2 % M
for i in range(33):
    for j in range(10**5+1):
        A[i+1][j] = A[i][A[i][j]]
        B[i+1][j] += B[i][j] + B[i][A[i][j]]
now = X
ans = X
i = 0
N -= 1
while N > 0:
    if N & 1:
        ans += B[i][now] 
        now = A[i][now]
    N >>= 1
    i += 1
print(ans)

Measured memory_bytes: 119236
#include <stdlib.h>
#include <stdio.h>
#define MAX_ARR_SIZE 1024

static int count_lcs(char *x, char *y) {
  int i, j, m, n, max, mn[MAX_ARR_SIZE][MAX_ARR_SIZE];

  for (i = m = 0; x[i] != '\0'; ++i) ++m;
  for (j = n = 0; y[j] != '\0'; ++j) ++n;
  for (i = 0; i < m; ++i) mn[i][0] = 0;
  for (j = 0; j < n; ++j) mn[0][j] = 0;
  max = 0;
  for (i = 1; i < m + 1; ++i) {
    for (j = 1; j < n + 1; ++j) {
      if (x[i - 1] == y[j - 1]) {
        mn[i][j] = mn[i - 1][j - 1] + 1;
      } else {
        if (mn[i][j - 1] > mn[i - 1][j]) {
          mn[i][j] = mn[i][j - 1];
        } else {
          mn[i][j] = mn[i - 1][j];
        }
      }
      max = mn[i][j] > max ? mn[i][j] : max;
    }
  }
  return max;
}

int main(int argc, char **argv) {
  int q, i;
  char x[MAX_ARR_SIZE], y[MAX_ARR_SIZE];

  scanf("%d", &q);
  for (i = 0; i < q; ++i) {
    scanf("%s", x);
    scanf("%s", y);
    printf("%d\n", count_lcs(x, y));
  }
  exit(0);
}


Measured memory_bytes: 5736
#include <cstdio>
#include <cctype>
#include <cstring>

namespace quick {
#define tp template<typename Type>
	namespace in {
		inline char getc() {
			static char buf[1<<21],*p1=buf,*p2=buf;
			return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;
		}
		inline int read(char *s) {
			*s=getc();
			while(isspace(*s)) {*s=getc();if(*s==EOF) return 0;}
			while(!isspace(*s)&&*s!=EOF) {s++;*s=getc();}
			*s='\0'; return 1;
		}
		tp inline int read(Type &x) {
			x=0;bool k=false;char c=getc();
			while(!isdigit(c)) {k|=(c=='-');c=getc();if(c==EOF) return 0;}
			while(isdigit(c)) {x=(x<<1)+(x<<3)+(c^48);c=getc();}
			x*=(k?-1:1); return 1;
		}
		template <typename Type,typename... Args>
		inline int read(Type &&t,Args &&...args) {
			int res=0;
			res+=read(t);res+=read(args...);
			return res;
		}
	}
	using in::read;
	namespace out {
		char buf[1<<21];int p1=-1;const int p2=(1<<21)-1;
		inline void flush() {
			fwrite(buf,1,p1+1,stdout);
			p1=-1;
		}
		inline void putc(const char &c) {
			if(p1==p2) flush();
			buf[++p1]=c;
		}
		inline void write(char *s) {
			while(*s!='\0') putc(*s),s++;
		}
		inline void write(const char *s) {
			while(*s!='\0') putc(*s),s++;
		}
		tp inline void write(Type x) {
			static char buf[30];int p=-1;
			if(x<0) {putc('-');x=-x;}
			if(x==0) putc('0');
			else for(;x;x/=10) buf[++p]=x%10+48;
			for(;p!=-1;p--) putc(buf[p]);
		}
		inline void write(const char &c) {putc(c);}
		template <typename Type,typename... Args>
		inline void write(Type t,Args ...args) {
			write(t);write(args...);
		}
	}
	using out::write;
	using out::flush;
	tp inline Type max(const Type &a,const Type &b) {
		if(a<b) return b;
		return a;
	}
	tp inline Type min(const Type &a,const Type &b) {
		if(a<b) return a;
		return b;
	}
	tp inline void swap(Type &a,Type &b) {
		a^=b^=a^=b;
	}
	tp inline Type abs(const Type &a) {
		return a>=0?a:-a;
	}
#undef tp
}
using namespace quick;

typedef long long ll;
const ll Inf=0x3f3f3f3f3f3f3f3f;
const int maxn=2000+10,inf=0x3f3f3f3f;
int n;
char s[maxn];

struct Edge {
	int v,next;
	Edge(const int &v,const int &next) :v(v),next(next) {}
	Edge() {}
}e[maxn<<1];
int head[maxn],k;
inline void AddEdge(const int &u,const int &v) {
	e[++k]=Edge(v,head[u]);
	head[u]=k;
}

ll f[maxn];//表示以i为根的子树所消除的个数
ll sum[maxn];//表示以i为根的子树中dist(u,v)之和,其中u为当前节点，v为子树中有棋子的点
int cnt[maxn];
void dfs(const int &u,const int &fa) {
	int maxp=0;cnt[u]=s[u]-'0';
	for(int i(head[u]);i;i=e[i].next) {
		const int &v=e[i].v;
		if(v==fa) continue;
		dfs(v,u);
		cnt[u]+=cnt[v];
		sum[u]+=(sum[v]+=cnt[v]);//因为sum[maxp]要和sum[u]比大小，或者说当前转化为从u出发。所以要加上cnt[v]
		if(sum[v]>sum[maxp]) maxp=v;
	}
	if(!maxp) return;
	if(sum[u]>=2*sum[maxp]) f[u]=sum[u]/2;
	else f[u]=sum[u]-sum[maxp]+min(f[maxp],(2*sum[maxp]-sum[u])/2);
}

int main(void) {
#ifndef ONLINE_JUDGE
	freopen("cc.in","r",stdin);
#endif
	read(n,s+1);
	for(int i(1);i<n;i++) {
		int u,v;
		read(u,v);
		AddEdge(u,v);
		AddEdge(v,u);
	}
	ll ans=Inf;
	for(int i(1);i<=n;i++) {
		memset(f,0,sizeof f);
		memset(sum,0,sizeof sum);
		dfs(i,0);
		if(!(sum[i]&1)&&f[i]*2==sum[i]) ans=min(ans,f[i]);
	}
	if(ans==Inf) ans=-1;
	write(ans,'\n');
	flush();
	return 0;
}

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

int main(){
	int a,b,c;
	int ans;
	bool flg;
	int cnt=-1;
	
	while(cin>>a>>b){
		cnt++;flg=false;
		//-----test-----
		switch(cnt){
		case 0:
			if(a!=1000000) flg=true; 
			break;
		}
		
		if(flg) break;
		
		//--------------
		c=a+b;
		ans=1;
		while(10<=c){
			c/=10;
			ans++;
		}
		cout<<ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1160
fn main() {
    let scan = std::io::stdin();
    let mut line = String::new();
    let _ = scan.read_line(&mut line);
    let vec: Vec<&str> = line.split_whitespace().collect();
    let n: i32 = vec[0].parse().unwrap();

    let mut ans: i32 = 0;
    let mut data: Vec<i32> = Vec::new();

    for _ in 0..n{
        let mut line = String::new();
        let _ = scan.read_line(&mut line);
        let vec: Vec<&str> = line.split_whitespace().collect();
        data.push(vec[0].parse().unwrap());
    }

    'l1:loop{
        if data.len() == 0{
            break 'l1;
        }
        let n = data.pop().unwrap();
        data.retain(|&x| x != n);
        ans = ans + 1;
    }

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


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

int main()
{
  int n,k;
  cin>>n>>k;
  int p[n];
  for(int i=0;i<n;i++)
      {
        cin>>p[i];
      }
  
  sort(p,p+n);
  int sum=0;
  
  for(int i=0;i<k;i++){
    sum+=p[i];
  }
  cout<<sum<<endl;
  return 0;
}
      

Measured memory_bytes: 3644
def pow3(a):
    return 0 if a == -1 else p[a]

s = list(input())
n = len(s)
mod = pow(10, 9) + 7
x = [[0] * 2 for _ in range(n - 1)]
y = [[0] * 2 for _ in range(n - 1)]
p = [1] * n
ans = 0
for i in range(1, n):
    p[i] = 3 * p[i - 1] % mod
for i in range(n - 2):
    if s[i] == "A":
        x[i + 1][0] = 1
    elif s[i] == "?":
        x[i + 1][1] = 1
    for j in range(2):
        x[i + 1][j] += x[i][j]
    k = n - i - 1
    if s[k] == "C":
        y[i + 1][0] = 1
    elif s[k] == "?":
        y[i + 1][1] = 1
    for j in range(2):
        y[i + 1][j] += y[i][j]
for i in range(n - 2):
    j, k = i + 1, n - i - 2
    if s[j] == "B" or s[j] == "?":
        c1 = (x[j][0] * pow3(x[j][1]) + x[j][1] * pow3(x[j][1] - 1)) % mod
        c2 = (y[k][0] * pow3(y[k][1]) + y[k][1] * pow3(y[k][1] - 1)) % mod
        ans += c1 * c2
        ans %= mod
print(ans)

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

int main(){
	int a[101], b, i, max = 0;
	for(i = 1; i < 101; i++) a[i] = 0;
	while(scanf("%d", &b) != EOF){
		a[b]++;
		if(max < a[b]){
			max = a[b];
		}
	}
	for(i = 1; i < 101; i++){
		if(max == a[i]) printf("%d\n", i);
	}
	return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef unordered_set<int> si;
typedef pair<int, int> pp;
typedef vector<pp> vpp;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#define all(e) (e).begin(), (e).end()
#define pb push_back


template <typename T>
void printV(vector<T> A) {
    if (A.empty()) cerr << "EMTPY\n";
    else { 
        cerr << "[";
        for (int i = 0; i < A.size() -1 ; ++i) {
            cerr << A[i] << ", ";
        }
        if (A.size()) cerr << A.back() << "]\n";
    }
}


template <typename T>
void printVV(vector<vector<T>> A) {
    cerr << "[";
    for (auto v : A) {
        printV<T>(v);
    }
    cerr << "]";
}

template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cerr << name << ": " << arg1 << endl;
}

template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&& ...args) {
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << ": " << arg1 << " |";
    __f(comma + 1, args...);
}

int main(int argc, char **argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a, b; cin >> a >> b;
    if (max(a, b) > 8) cout << ":(\n";
    else cout << "Yay!\n";
    return 0;
}



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

int main()
{
    ll H, W, K; cin >> H >> W >> K;
    vector<vector<char>> V(H, vector<char>(W, 0));
    rep(i, H) {
        rep(j, W) {
            cin >> V[i][j];
        }
    }
    ll ans = 0;
    ll hnum = pow(2, H);
    ll wnum = pow(2, W);
    for (ll i = 0; i < hnum; ++i) {
        for (ll j = 0; j < wnum; ++j) {
            //cout << "i = " << i << ",j = " << j << endl;
            ll curr_sum = 0;
            for (ll k = 0; k < H; ++k) {
                for (ll l = 0; l < W; ++l) {
                    if ((i & (1 << k)) || (j & (1 << l))) continue;
                    else {
                        if (V[k][l] == '#') {
                            ++curr_sum;
                        }
                    }
                }
            }
            ans += (curr_sum == K);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 4068
fun main(args: Array<String>) {
    val (a, b, X) = listOfDouble()
    val r: Double
    val s = X / a
    if (a * b / 2 <= s) {
        val h = 2 * (a * b - s) / a
        r = Math.atan(h / a) * 180.0 / Math.PI
    } else {
        val w = 2 * s / b
        r = Math.atan(b / w) * 180.0 / Math.PI
    }
    println(r)
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfDouble() = listOfString().map { java.lang.Double.parseDouble(it) }

Measured memory_bytes: 38056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int INF = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

vector<int> memo(100010, -1);
int dfs(int N){
    if(N == 0) return 0;
    else if(memo.at(N) != -1) return memo.at(N);

    int ans = INF;
    for(int c6 = 1; c6 <= N; c6 *= 6){
        ans = min(ans, dfs(N - c6) + 1);
    }
    for(int c9 = 1; c9 <= N; c9 *= 9){
        ans = min(ans, dfs(N - c9) + 1);
    }

    return memo.at(N) = ans;
}

int main(){
    int N;
    cin >> N;
    cout << dfs(N) << endl;
}

Measured memory_bytes: 5376
from sys import stdin
from functools import lru_cache
N = int(stdin.readline().rstrip())
K = int(stdin.readline().rstrip())

@lru_cache(None)
def f(N, K):
    #大きい桁から小さい桁へ
    if K < 0:
        return 0
    if N < 10:
        if K == 0:
            # 0のみ
            return 1
        elif K == 1:
            # 例えばN=4 なら0でないものが1,2,3,4の合計4個存在
            return N
        else:
            return 0
    q, r = divmod(N, 10)
    ret = 0
    if K >= 1:
        # 1の位が0以外の場合Kを消費する
        ret += f(q, K-1) * r
        ret += f(q-1, K-1) * (9-r)
    # 1の位が0の場合
    ret += f(q, K)
    return ret

print(f(N, K))

Measured memory_bytes: 3940
n = int(input())
a = [int(i) for i in input().split()]
a = sorted(a)
a.append(-1)
cost = 0
target = a[0]
start = 0
# print(a)
for i in range(len(a)):
    # print("target:{} start:{} i:{}".format(target, start, i))
    localCost = 1000000
    if a[i] != target:
        if i - start == target:
            localCost = 0
        elif i - start > target:
            localCost = i - start - target
        cost += min(localCost, i - start)
        start = i
        target = a[i]
        # print("local:{} cost:{}".format(min(localCost, i - start), cost))
print(cost)

Measured memory_bytes: 14016
a='abcdefghijklmnopqrstuvwxyz';require("fs").readFileSync("/dev/stdin","utf8").split('\n').map(function(i){for(s=26;s--;)r=i.replace(/[a-z]/g,function(j){return a[(a.indexOf(j)+s)%26]}),r.match(/th(e|is|at)/)?console.log(r):0})

Measured memory_bytes: 9300
use std::cmp::{max, min};
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize);
    let mut a = vec![];
    let mut b = vec![];
    let mut ab = vec![];
    for _ in 0..n {
        parse!(it, x: usize, y: usize);
        a.push(x);
        b.push(y);
        ab.push((x, y));
    }
    if a == b {
        println!("{}", 0);
        return;
    }
    ab.sort();
    ab.reverse();
    let mut last = !0;
    let mut ret = 0;
    for &(a, b) in ab.iter() {
        ret += a;
        if a > b {
            last = min(last, b);
        }
    }
    ret -= last;
    println!("{}", ret);
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 6396
import sys
import math

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(N, D, inputs):
    points = list(map(lambda x: string_to_int(x), inputs))

    count = 0
    for i in range(0, len(points)-1):
        for j in range(i+1, len(points)):
            each_d_sum = 0

            for di in range(0, D):
                each_d_sum += (points[j][di] - points[i][di]) ** 2
            result = math.sqrt(each_d_sum)
            if result.is_integer():
                count += 1
    return count


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    [N, D] = string_to_int(input())

    ret = solve(N, D, inputs(N))
    print(ret)


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

int n,m,u,v,s,tt,i,j,used[300005]={0},co[300005]={0};
vector<int> d[300005];
queue<int> que;

int main() {
	// your code goes here
	cin >> n >> m;
	for(i=1;i<=m;i++){
		cin >> u >> v;
		d[u].push_back(n+v);
		d[n+u].push_back(2*n+v);
		d[2*n+u].push_back(v);
	}
	for(i=1;i<=3*n;i++){
			co[i]=100000000;
	}
	cin >> s >> tt;
	co[s]=0;
	used[s]=1;
	que.push(s);
	while(!que.empty()){
		u=que.front();
		que.pop();
		for(i=0;i<d[u].size();i++){
			used[d[u][i]]=1;
			if(co[d[u][i]]>co[u]+1){
				co[d[u][i]]=co[u]+1;
				que.push(d[u][i]);
			}
		}
	}
	if(used[tt]==0) cout << "-1" << endl;
	else if(co[tt]==100000000) cout << "-1" << endl;
	else cout << co[tt]/3 << endl;
	return 0;
}

Measured memory_bytes: 18944
#include <string>
#include <iostream>
#include <vector>
#include <algorithm> 
#include <bits/stdc++.h>

#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
using namespace std;
typedef unsigned long long int ull;
int main()
{
	int n;
	cin>>n;
	float s=0;
	vector <float> v(n);
	REP(i,0,n-1)
		cin>>v[i];
	
	REP(i,0,n-1)
	{
		s+=(1.0/v[i]);
	}
	
	cout<<(1.0/s);
	
	return 0;
}

Measured memory_bytes: 256
import           Control.Applicative
import           Control.Monad
import           Data.List

main :: IO ()
main = do
  [n,xs,ys] <- take 3 . map ( map (read::String->Double) . words) . lines <$> getContents
  putStr $ unlines $ map (show . minkowski xs ys) [1,2,3]
  print $ chebyshev xs ys
    where
      minkowski::[Double]->[Double]->Int->Double
      minkowski xs ys p = (sum $ zipWith (\x y -> (abs (x-y))^p ) xs ys)**(1.0/fromIntegral p)
      chebyshev xs ys = maximum $ zipWith (\x y -> abs (x-y)) xs ys


Measured memory_bytes: 4480
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod=1000000007;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main(){
    int n,m;cin>>n>>m;
    UnionFind uf(m*2);
    set<int> lset;
    rep(i,n){
        int k;cin>>k;
        int prev=-1;
        rep(j,k){
            int l;cin>>l;
            uf.unite(l-1,(l-1)+m);
            lset.insert(l-1);
            if(prev!=-1)uf.unite(prev,l-1);
            prev=l-1;
        }
    }
    int lssz=lset.size();
    if(uf.size(*(lset.begin()))==(2*lssz))cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3968
#include<bits/stdc++.h>
using namespace std;
using ll =long long;
ll dp[50];
ll fib(ll n){
    if(n==0)return dp[0]=1;
    else if(n==1)return dp[1]=1;
    else if(dp[n]!=-1)return dp[n];
    return dp[n]=fib(n-1)+fib(n-2);
}
int main(){
    ll n;
    cin>>n;
    for(int i=0;i<50;i++)dp[i]=-1;
    cout<<fib(n)<<endl;
    return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    int n,x;
    cin >> n >> x;
    int mi=INT_MAX;
    int m,sum=0;
    REP(i,n){
        cin >> m;
        x-=m;
        sum++;
        mi=min(mi,m);
    }
    sum+=(x/mi);
    cout << sum << endl;
}


Measured memory_bytes: 256
#coding:utf-8

M, D =map(int, input().split())

count = 0

for i in range(1, M+1):
    for j in range(1, D+1):
        d = '%02d'%(j)
        d_1 = int(d[1])
        d_10 = int(d[0])
        if d_1 >=2 and d_10 >=2 and d_1 * d_10==i:
            count += 1
print(count)


Measured memory_bytes: 3316
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

ll N, T;
ll t[200001];
ll res;

int main()
{
	cin >> N >> T;

	for (int i = 0; i < N; i++) {
		cin >> t[i];
	}

	res += T;
	for (int i = 1; i < N; i++) {
		if (t[i - 1] + T > t[i]) {
			res -= (t[i - 1] + T - t[i]);
			res += T;
		}
		else
			res += T;
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REPL(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
bool comp(pair<ll, ll>& p1, pair<ll, ll>& p2) {
  return p1.first+p1.second < p2.first+p2.second;
}
int main() {
  int N;
  cin >> N;
  vector<pair<ll, ll> > XL(N);
  rep(i, N) cin >> XL[i].first >> XL[i].second;
  sort(all(XL), comp);
  ll mx = -inf;
  int cnt = 0;
  rep(i, N) {
    if(XL[i].first-XL[i].second < mx) continue;
    else {
      mx = XL[i].first+XL[i].second;
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 1920
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<queue>
#include<climits> //INT_MIN/MAX


using namespace std;

#define FOR(i,s,e) for(int (i)=(s);(i)<(e);(i)++)
#define FORR(i,s,e) for(int (i)=(s);(i)>(e);(i)--)
#define MOD 1000000007
#define llong long long
#define debug(x) cout<<#x<<": "<<x<<endl

llong n;


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

    int h, w;
    cin >> h >> w;
    
    FOR(i, 0, h) {
        string s;
        cin >> s;
        cout << s << endl;
        cout << s << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
// typedef long long llong;
using llong = long long;
const int MOD=1000000007;

int main(int argc, char**argv){
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++){
        cin >> a[i];
    }

    int counter = 0;
    while(1){
       for(int i = 0; i < n; i++){
           if (a[i] % 2 != 0){
               cout << counter << endl;
               return 0;
           }
           a[i] /= 2;
       }
       counter++;
    }

    return 0;
}






Measured memory_bytes: 256
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,m,L=map(int,input().split())
    E=[[] for _ in range(n)]
    for _ in range(m):
        a,b,c=map(int,input().split())
        if(c>L): continue
        a-=1; b-=1
        E[a].append((b,c))
        E[b].append((a,c))
    A=[0]*n
    # pure Dijkstraを全ての始点で行う
    for u in range(n):
        dist=[(INF,INF)]*n # (補給回数,使用燃料)
        dist[u]=(0,0)
        calculated=[False]*n
        for _ in range(n-1):
            v=min((dist[v],v) for v in range(n) if(not calculated[v]))[1]
            calculated[v]=True
            now=dist[v]
            for nv,w in E[v]:
                if(now[1]+w<=L):
                    next=(now[0],now[1]+w)
                else:
                    next=(now[0]+1,w)
                if(dist[nv]>next):
                    dist[nv]=next
        A[u]=dist
    # output
    Q=int(input())
    for _ in range(Q):
        s,t=map(int,input().split())
        s-=1; t-=1
        ans=A[s][t][0]
        print(ans if ans!=INF else -1)
resolve()

Measured memory_bytes: 79964
from numpy import array, sum, sort

n, m = [int(i) for i in input().split()]
X, Y, Z = (array(i) for i in zip(*[[int(i) for i in input().split()] for j in range(n)]))

ans = []

for x in (X, -X):
  for y in (Y, -Y):
    for z in (Z, -Z):
      s = x + y + z
      ans.append(sum(sort(s)[::-1][:m]))

print(max(ans))


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

#define FORS(i, j, k, step) for (int i=j; i<k; i+=step)
#define FOR(i, j, k) for (int i=j; i<k; i++) 
#define RFORS(i, j, k, step) for (int i=j; i>=k; i-=step)
#define RFOR(i, j, k) for(int i=j; i>=k; i--)
#define REP(i, k) for(int i = (0); i < (k); i++ ) 
#define RREP(i, k) for(int i = (k); i >= (0); i-- )
 
#define ALL(cont) cont.begin(), cont.end()
#define RALL(cont) cont.begin(), cont.end()
#define FOREACH(it, l) for(auto it=l.begin(); it != l.end(); it++)
#define mp make_pair
#define pb push_back
#define RESET(a, b) memset(a, b, sizeof(a))
#define INF (int)MAX_INT
#define EPS (int)1e-9
#define PI acos(-1)
#define MOD 1000000007
#define run using
#define the namespace
#define prog std
 
run the prog;

typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef long long int32;
typedef unsigned long long uint32;
typedef long long int int64;
typedef unsigned long long int uint64;
 
template <class T>
    T sqr(T val) {
        return val * val;
    }
 
template<typename T, typename U> 
static inline void amin(T &x, U y) 
{ 
    if (y < x) 
        x = y; 
} 
  
// call by reference is used in x 
template<typename T, typename U> 
static inline void amax(T &x, U y) 
{ 
    if (x < y) 
        x = y; 
} 

/* To find max and min value in array.
for (auto const &val: array) 
  
        // Same as max_val = max (max_val, val) 
        // Same as min_val = min (min_val,val) 
        amax(max_val, val), amin (min_val, val);
//Then in main()
int max_val = 0, min_val = 1e5; 
 */
int32 gcd(int32 a, int32 b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b);
} 
void solve() {
    /* Solution code goes here */
    int n,k;
    cin>>n>>k;
    int p[n];
    int sum = 0;
    REP(i,n)
    {
        cin>>p[i];
    }
    sort(p,p+n);
    REP(i,k)
    {
        sum+= p[i];
    }
    cout<<sum;

}
 
int main() {
    std::ios_base::sync_with_stdio(false);
    int32 TC = 1;
    //cin >> TC;
    
    //cin.ignore();
    while(TC--)
    {
        solve();
    }
}

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

int main(int argc, char *argv[]) {
  int N;
  cin >> N;
  int x[N];
  int y[N];
  int h[N];
  for(int i = 0; i < N; i++) {
    cin >> x[i] >> y[i] >> h[i];
  }

  for(int cx = 0; cx <= 100; cx++) {
    for(int cy = 0; cy <= 100; cy++) {

      int H = h[0] + abs(x[0] - cx) + abs(y[0] - cy);
      for(int i = 0; i < N; i++) {
        if(h[i] + abs(x[i] - cx) + abs(y[i] - cy) <= H) {
          H = h[i] + abs(x[i] - cx) + abs(y[i] - cy);
        }
      }

      int flag = 0;
      for(int i = 0; i < N; i++) {
        if(h[i] != max(0, H - abs(x[i] - cx) - abs(y[i] - cy))) {
          flag = 1;
          break;
        }
      }

      if(flag == 0) {
        cout << cx << " " << cy << " " << H << endl;
        return 0;
      }

    }
  }
  return 0;
}


Measured memory_bytes: 256
//
// Created by moono on 2018/10/27.
//

#include <vector>
#include <iostream>
using namespace std;



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

    int M = N;
    int x = 0;
    while( M != 0){
        x += M % 10;
        M /= 10;
    }

//    cout << x << endl;
//    cout << N << endl;

    if(N % x == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll dp[100001][2];
vvi arr(100001);
void dfs(ll u,ll par)
{
    ll i;
    dp[u][0] = 1;
    dp[u][1] = 1;
    for(i=0;i<arr[u].size();i++)
    {
        ll v = arr[u][i];
        if(v!=par)
        {
            dfs(v,u);
            ll temp0 = dp[u][0]*(dp[v][1]+dp[v][0])%mod;
            ll temp1 = dp[u][1]*dp[v][0]%mod;
            dp[u][0] = temp0;
            dp[u][1] = temp1;
        }
    }
}
signed main()
{
    fast;
    ll n;
    cin>>n;
    ll i;
    for(i=0;i<n-1;i++)
    {
        ll u,v;
        cin>>u>>v;
        arr[u].pb(v);
        arr[v].pb(u);
    }
    dfs(1,0);
    cout<<(dp[1][0]+dp[1][1])%mod;
}

Measured memory_bytes: 14208
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

int A,B;

void solve(){
    if(B == 1) cout << 0 << endl;
    else cout << (B - 2)/(A-1) + 1 << endl;
}

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

    solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, s;
  in(n);
  vector<ll> c;
  a = 1;
  while(a * a <= n){
    if(n % a == 0){
      if(a != n / a){
        c.pb(a);
        c.pb(n / a);
      }
      else
        c.pb(a);
    }
    a++;
  }
  n--;
  a = 1;
  while(a * a <= n){
    if(n % a == 0){
      if(a != n / a){
        c.pb(a);
        c.pb(n / a);
      }
      else
        c.pb(a);
    }
    a++;
  }
  n++;
  sort(all(c));
  rep(i, c.size() - 1){
    if(c[i] == c[i + 1])
      c[i + 1] = n + 1;
  }
  ll m;
  a = 0;
  rep(i, c.size()){
    m = n;
    if(c[i] == 1){
      a++;
      continue;
    }
    while(m % c[i] == 0)
      m /= c[i];
    if(m % c[i] == 1)
      a++;
  }
  out(a - 1);
  memi;
}


Measured memory_bytes: 384
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())

s = set()
for i in range(N):
    A = int(input())
    if A in s:
        s.remove(A)
    else:
        s.add(A)

print(len(s))

Measured memory_bytes: 12524
N = int(input())
things = []
c = N
for i in range(2, c):
	if i*i > N:
		break
	count = 0
	if c%i == 0:
		while c%i == 0:
			c//=i
			count += 1
		things.append(count)
if c > 1:
	things.append(1)
final = 0
for x in things:
	count = 0
	start = 1
	step = 2
	while start <= x:
		start += step
		step += 1
		count += 1
	final += count

print(final)

Measured memory_bytes: 9212