akhauriyash/Code-Regression huggingface dataset:
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(rs())
def rs_(): return [_ for _ in rs().split()]
def ri_(): return [int(_) for _ in rs().split()]

N = ri()
A = ri_()
A.append(-1)
sell = set([])
buy = set([])
tmp = A[0]
f = 0
bf = False
for i in range(1, N + 1):
    if tmp < A[i]:
        if f == 0:
            f = 1
            buy.add(0)
        if f == 1:
            f = 1
        else:
            buy.add(i - 1)
            f = 1
    elif tmp > A[i]:
        if f == 0 or f == 2:
            f = 2
        else:
            sell.add(i - 1)
            f = 2
    tmp = A[i]
m = 1000
k = 0
L = max(sell) if sell else N - 1
for i in range(L):
    if i in buy:
        k = k + m // A[i]
        m = m % A[i]
    elif i in sell:
        m = m + k * A[i]
        k = 0
print( m + k * A[L])


Measured memory_bytes: 9276
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
#include <list>
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define int_INF 2147483647
#define pint_INF 2000000000
#define ll_INF 	9223372036854775807
#define MOD 1000000007
#define vi vector<int>
#define vvi vector<vector<int>>
#define vvll vector<vector<long long>>
#define vvc vector<vector<char>>
#define vll vector<long long>
#define pii pair<int,int>
#define vpii vector<pair<int,int>>
#define sysp system("PAUSE")
#define pno cout << "no" << endl
#define pyes cout << "yes" << endl
#define pYes cout << "Yes" << endl
#define pNo cout << "No" << endl
#define pNO cout << "NO" << endl
#define pYES cout << "YES" << endl
#define endl "\n"
#define pi 3.14159265358979
using namespace std;
using ll = long long;
#define int ll
int gcd(int a, int b) {
	if (a > b) {
		int c = a;
		a = b;
		b = c;
	}
	if (a == 0) {
		return b;
	}

	return gcd(b % a, a);
}

int gcd_of_all(vi v){
  int l = v.size();

  int temp = v[0];
  for(int i = 0; i < l ; i++){
    temp = gcd(temp,v[i]);
  }

  return temp;
}

signed main(){
    int N,K; cin >> N >> K;
    vi A(N); rep(i,N) cin >> A[i];
    int g = gcd_of_all(A);
    bool flag = false;
    for(int i = 0; i < N; i++){
        if(A[i] - K >= 0){
            if((A[i] - K)%g == 0){
                flag = true;
                break;
            }
        }
    }
    if(flag){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    sysp;
}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll inf = 1LL<<60;
const double eps = 1e-9;

int main()
{
    ll n, a, b, ans = 0;
    cin >> n >> a >> b;
    vector <ll> x(n);
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }

    for (int i = 1; i < n; i++) {
        ll dist = (x[i] - x[i-1]);
        ans += min(dist*a, b);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i <= (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
typedef pair<int, int> PII;
typedef long long int ll;

ll dp[110][100010];
ll wi[110];
ll vi[110];

int main(){
  int N,W;
  cin >> N >> W;
  rep(i,N) cin >> wi[i] >> vi[i];

  rep(i,W){
    dp[0][i] = 0;
  }

  rep(i,N){
    rep2(sumW,0,W){
      if(sumW - wi[i] >= 0){
        ll sel1 = dp[i][sumW - wi[i]] + vi[i];
        ll sel2 = dp[i][sumW];
        dp[i+1][sumW] = max(sel1,sel2);
      }else{
        dp[i+1][sumW] = dp[i][sumW];
      }
      //cout << dp[i+1][sumW] << " ";
    }
    //cout << endl;
  }
  

  ll ans = dp[N][W];
  cout << ans << endl;
  return 0;
}


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

class Dice {
public:
	int		top    = 1;
	int		value  = 1;
	
	void set_top(int x) {
		top = x;
		value = v[x]; 
	}
	
	void set_surface(int x[]) {
		for(int i=0; i<6; i++ )
			v[i+1] = x[i];
	}	 
	
	void dump() {
		for(int i=1; i<=6; i++) {
			cout << "S" << i << ":" << s[i] <<", ";
		}
		cout << endl;
	}	
		
	void flip(char c) {
		switch (c) {
			case 'N':
				flip_N();
				break;
			case 'S':
				flip_S();
				break;
			case 'E':
				flip_E();
				break;
			case 'W':
				flip_W();
				break;
			default:
				break;
		}
	}
	
	int flip_N() {
		// 面3,4変わらず、面1265 をローテ―トする
		int x = s[1];
		s[1] = s[2];
		s[2] = s[6];
		s[6] = s[5];
		s[5] = x;

		top = s[1];
		value  = v[top];
	}
	
	int flip_S() {
		// 面3,4変わらず、面1265 をローテ―トする
		int x = s[1];
		s[1] = s[5];
		s[5] = s[6];
		s[6] = s[2];
		s[2] = x;

		top = s[1];
		value  = v[top];
	}
	
	int flip_E() {
		// 面2,5変わらず、面1364 をローテ―トする
		int x = s[1];
		s[1] = s[4];
		s[4] = s[6];
		s[6] = s[3];
		s[3] = x;

		top = s[1];
		value  = v[top];
	}

	int flip_W() {
		// 面2,5変わらず、面1364 をローテ―トする
		int x = s[1];
		s[1] = s[3];
		s[3] = s[6];
		s[6] = s[4];
		s[4] = x;

		top = s[1];
		value = v[top];
	}

private:
	int     v[7] = {0, 1, 2, 3, 4, 5, 6};
	int 	s[7] = {0, 1, 2, 3, 4, 5, 6};
};




int main() {
	Dice d1;
	int ss[6];

	for(int i=0; i<6; i++) cin >> ss[i];
	d1.set_surface(ss);
	d1.set_top(1);
	
	string command;
	cin >> command;
	
	for(int i=0; i<command.size(); i++) {
		d1.flip(command[i]);
	}	
	cout << d1.value << endl;
	
	return 0;
}


Measured memory_bytes: 3164
# -*- coding: utf-8 -*-
n = int(input())

a = "abcdefghijklmnopqrstuvwxyz"
d = {}
for c in a:
    d[c] = 0

for i in range(n):
    dd = {}
    for c in list(input()):
        if c not in dd:
            dd[c] = 0
        dd[c] += 1

    if i==0:
        for c in dd.keys():
            d[c] = dd[c]
    else:
        for c in a:
            if c in dd and d[c]>0 and dd[c]<d[c]:
                d[c] = dd[c]
            elif d[c]>0 and c not in dd:
                d[c] = 0

ret = ""
for c in a:
    if d[c]!=100:
        ret += c*d[c]
print(ret)


Measured memory_bytes: 3064
#include <iostream> 
  
using namespace std; 
int a[100001],i,n,k,x,y,t; 
int main(int argc, char** argv) { 
      
    cin>>n; 
    if(n==1) 
    {   cin>>x; 
        cout<<1; 
        return 0; 
    } 
    if(n==2) 
    {   cin>>x>>y;  
        if(x!=y) 
           cout<<2; 
        else
            cout<<0; 
        return 0; 
    } 
    for(i=0;i<n;i++) 
    { 
        cin>>x; 
        a[x]++; 
    } 
      
      
    for(i=1;i<=100000;i++) 
        if(a[i]) 
        { 
            if(a[i]%2!=0) 
                k++; 
            else
                t++; 
        } 
    if(t%2==0) 
        k=k+t; 
    else
        k=k+t-1; 
    cout<<k; 
    return 0; 
} 

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <functional>
#include<iostream>
#include <string>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define fro(i,j,n) for(int i=j;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x;
	cin >> x;
    int ans;
    ans=int(x/500)*1000;
    x%=500;
    ans+=int(x/5)*5;
      cout << ans << endl;
}

Measured memory_bytes: 256
/*input
4
1 2
1 3
1 4
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

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

#define ll long long
#define N 100005
#define mod 1000000007
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll n,u,v;
vector<vector<ll>>g;
ll dp[N][2];

ll add(ll a,ll b)
{
    return (a%mod+b%mod)%mod;
}

ll mul(ll a,ll b)
{
    return (a%mod*b%mod)%mod;
}

ll dfs(ll v,ll p,ll f)
{
    if(g[v].size()==0)
        return 1;
    if(dp[v][f]!=-1)
        return dp[v][f];
    ll ans=1;
    for(auto to:g[v])
    {
        if(to!=p)
        {
            if(f)
                ans=mul(ans,dfs(to,v,0));
            else
                ans=mul(ans,add(dfs(to,v,0),dfs(to,v,1)));
        }
    }
    return dp[v][f]=ans;
}

int main() 
{
    off;
    cin>>n;
    g=vector<vector<ll>>(n+1);
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n-1;i++)
    {
        cin>>u>>v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    cout<<add(dfs(1,-1,0),dfs(1,-1,1));
    return 0;
}

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

using namespace std;
const int maxn=1e5+5;
int a[maxn];
double b[20];
int main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    double flag=1;
    int t=0;
    while(flag<k)
    {
        flag*=2;
        t++;
    }
    a[1]=t;
    for(int i=2;i<=n;i++)
    {
        if(i>=k)
        {
            a[i]=0;
            continue;
        }
        flag/=(i-1);
        flag*=i;
        while(flag>k)
        {
            flag/=2;
            t--;
        }
        if(flag<k)
        {
            t++;
            flag*=2;
        }
        a[i]=t;
    }
    double res;
    res=(k<=n?(double)(n-k+1)/(double)n:0.0);
    for(int i=1;i<=min(n,k-1);i++)
    {
        res+=(1/(n*pow(2,a[i])));
    }
    printf("%.12lf\n", res);
    return 0;
}


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

template<typename T, class F = std::plus<T>, class F_INV = std::minus<T>, const T I = 0>
struct WeightedUnionFindTree {
    const F op = F(); const F_INV op_inv = F_INV();
    vector<int> par, rnk; vector<T> wt;
    void build(int n) { par.assign(n, -1); rnk.assign(n, 0); wt.assign(n, I); }
    int find(int x) {
        if (par[x] < 0) return x;
        int r = find(par[x]);
        wt[x] = r == par[x] ? wt[x] : op(wt[par[x]], wt[x]);
        return par[x] = r;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -par[find(x)]; }
    T eval(int x) { find(x); return wt[x]; }
    T diff(int x, int y) { assert(same(x, y)); return op_inv(wt[y], wt[x]); }
    bool unite(int x, int y, T d) {
        d = op_inv(op(wt[x], d), wt[y]);
        if ((x = find(x)) == (y = find(y))) return 0;
        rnk[x] = max(rnk[x], rnk[y] + 1);
        wt[y] = d;
        par[x] += par[y];
        par[y] = x;
        return 1;
    }
    bool uniteByRank(int x, int y, T d) {
        return rnk[find(x)] < rnk[find(y)] ? unite(y, x, op_inv(I, d)) : unite(x, y, d);
    }
};

int main() {
    int n, q;
    cin >> n >> q;
    vector<int> x(q), y(q), z(q, -1);
    for (int i = 0; i < q; ++i) {
        int t;
        cin >> t;
        if (t == 0) cin >> x[i] >> y[i] >> z[i];
        else cin >> x[i] >> y[i];
    }

    WeightedUnionFindTree<int> wuf;
    wuf.build(n);

    for (int i = 0; i < q; ++i) {
        if (z[i] != -1) wuf.uniteByRank(x[i], y[i], z[i]);
        else if (wuf.same(x[i], y[i])) cout << wuf.diff(x[i], y[i]) << endl;
        else cout << "?" << endl;
    }
}


Measured memory_bytes: 6240
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
char mem[114514];
char t[114514];
char c[114514];
string s[114514];
int a[114514],b[114514];
signed main(){
	ic(n) 
	int nn=1;
	int sum=0;
	rep(0,i,100){
		sum+=nn;
		n=n/2;
		nn*=2;
		if(n<1)break;
	}
	c(sum)	
}		

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

int main() {
    int n;
    string s;
    cin>>n>>s;
    int S=s.size();
    
    for(int i=0; i<S; i++){
        cout<<(char)((s.at(i)-'A'+n)%26+'A');
    }

    cout<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

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

	double time = T + 0.5;

	int num = 0;

	for (int i = A; i < time; i+=A) {

		num += B;
	}

	cout << num << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <utility>
#include <algorithm>
using namespace std;


int main(void){
    // Your code here!
    int a, b, k;
    
    cin>>a>>b>>k;
    
    int c=0;
    int ans;
    
    for(int i=min(a,b); i>=1; i--){
        
        if((a%i==0)&&(b%i==0)){
            c++;
        }
        
        if(c==k){
            ans=i;
            break;
        }
    }
    
    cout<<ans<<endl;
    
}


Measured memory_bytes: 256
A,B,C,X,Y = (int(X) for X in input().split())
MINPrice = pow(10,9)
for ABP in range(0,2*max(X,Y)+1,2):
    Price = A*max(0,(X-ABP//2))+B*max(0,(Y-ABP//2))+C*ABP
    if Price<=MINPrice:
        MINPrice = Price
print(MINPrice)

Measured memory_bytes: 9196
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>

#ifndef U_L_LONG
typedef unsigned long long ULLONG;
#endif
#ifndef L_LONG
typedef long long LLONG;
#endif
template <class _T> static _T tp_abs(const _T& a) {
	//	usage:  tp_abs<type name>(a);
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void get1int(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void get2int(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void get3int(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
template <class _T> static void tp_swap(_T& right, _T& left) {
	//	usage:  tp_swap<type name>(a, b);
	_T tmp = right;
	right = left;
	left = tmp;
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}

typedef std::pair<int, int> IntPair;


static void ABC116A_RightTriangle();


#if 1
int main()
{
	ABC116A_RightTriangle();
	fflush(stdout);
	return 0;
}
#endif

static void ABC116A_RightTriangle()
{
	int AB, BC, CA;
	get3int(AB, BC, CA);

	printf("%d\n", AB * BC / 2);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdint>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <iomanip>

double area(const std::vector<std::tuple<double, double> > &vs, int64_t p, int64_t q) {
    auto n = vs.size();
    auto vx1 = std::get<0>(vs[(p+1) % n]) - std::get<0>(vs[p]);
    auto vy1 = std::get<1>(vs[(p+1) % n]) - std::get<1>(vs[p]);

    auto vx2 = std::get<0>(vs[(q+1) % n]) - std::get<0>(vs[q]);
    auto vy2 = std::get<1>(vs[(q+1) % n]) - std::get<1>(vs[q]);

    return vx1 * vy2 - vx2 * vy1;
}

double len2(const std::vector<std::tuple<double, double> > &vs, int64_t p, int64_t q) {
    auto dx = std::get<0>(vs[p]) - std::get<0>(vs[q]);
    auto dy = std::get<1>(vs[p]) - std::get<1>(vs[q]);

    return dx*dx + dy*dy;
}

int main() {
    int64_t n;

    std::cin >> n;
    
    std::vector<std::tuple<double, double> > vs(n);

    int64_t p = 0, q = 0;
    for (int64_t i = 0; i < n; ++i) {
        std::cin >> std::get<0>(vs[i]) >> std::get<1>(vs[i]);

        if (std::get<0>(vs[i]) < std::get<0>(vs[p])) {
            p = i;
        }
        if (std::get<0>(vs[i]) > std::get<0>(vs[q])) {
            q = i;
        }
    }

    double ans = len2(vs, p, q);
    for (int64_t i = 0; i < 2*n; ++i) {
        if (area(vs, p, q) > 0) {
            q = (q+1) % n;
        } else {
            p = (p+1) % n;
        }
        ans = std::max(ans, len2(vs, p, q));
    }

    std::cout << std::fixed << std::setprecision(12) << std::sqrt(ans) << std::endl;
    
    return 0;
}



Measured memory_bytes: 3968
INF = 10000000000
dx = [0, 0, 1, -1]
dy = [-1, 1, 0, 0]
 
def dfs(x, y, m):
    if y > N :
        return 0
    if mem[x][y][m] != INF:
        return mem[x][y][m]
    n = INF
    for j in range(2 if m > 0 else 1):
        for i, s in enumerate(st[y + 1 + j]):
            srip = max(0, st[y][x][1] + s[1])
            l = abs(st[y][x][0] - s[0])
            n = min(dfs(i, y + 1 + j, m - j) + srip * l, n)
    mem[x][y][m] = n
    return mem[x][y][m]
 
while True:
    N, M = map(int, raw_input().split())
    if N == 0:
        break
    st = [[[-INF, -INF]] for i in range(N + 3)]
    for s in st[1:-2]:
        v = list(map(int, raw_input().split()))
        del s[0]
        for i in range(1, len(v), 2):
            s.append([v[i], v[i + 1]])
    mem = [[[INF for i in range(M + 1)] for j in range(N + 1)] for k in range(N + 4)]
    print(dfs(0, 0, M))

Measured memory_bytes: 39388
import sys
import fractions
import math
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

H, N = IL()
a = IL()
num = sum(a)

if num >= H:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 16180
using System;

class D
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var a = Array.ConvertAll(Console.ReadLine().Split(), long.Parse);

		long c = 0, t = 0;
		for (int l = 0, r = 0; l < n; t ^= a[l++])
		{
			while (r < n && (t & a[r]) == 0) t ^= a[r++];
			c += r - l;
		}
		Console.WriteLine(c);
	}
}


Measured memory_bytes: 34652
#!/usr/bin/env python3



def rateToColor(rate):
  if 0 < rate < 400:
    return 0
  elif rate < 800:
    return 1
  elif rate < 1200:
    return 2
  elif rate < 1600:
    return 3
  elif rate < 2000:
    return 4
  elif rate < 2400:
    return 5
  elif rate < 2800:
    return 6
  elif rate < 3200:
    return 7
  else:
    return 8


def solve(n,a):
  flags = [False]*8
  numOfRainbow = 0
  for rate in a:
    color = rateToColor(rate)
    if color != 8:
      flags[color] = True
    else:
      numOfRainbow += 1
  if sum(flags):
    return sum(flags), sum(flags)+numOfRainbow
  else:
    return 1,numOfRainbow


def main():
  N = int(input())
  a = list(map(int,input().split()))
  print(*solve(N,a))
  return

if __name__ == '__main__':
  main()


Measured memory_bytes: 9156
f n k = maxSum - minSum + 1
  where minSum = (k - 1) * k `div` 2
        maxSum = (n - k + 1 + n) * k `div` 2

main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    let m = 10 ^ 9 + 7
    print $ foldl (\acc -> \i -> (acc + f n i) `mod` m) 0 [k..n + 1]


Measured memory_bytes: 18288
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<string>
using namespace std;

int main(void){
        int i;
        long long n,m;
        
        scanf("%lld", &n);
        i = 0;
        m = 100;
        for(i=1;true;i++){
      //        printf("%d ",i);
              m = m + m/100;
    // printf("m=%d\n",m);         
              if(m >= n){
                      printf("%d\n", i);
                      return 0;
              }
        }

}



Measured memory_bytes: 1728
fn main() {
    let n = read::<u64>();

    println!("{}", attack(n));
}

fn attack(x: u64) -> u64 {
    if x == 1 {
        1
    } else {
        let tmp = attack(x/2);
        tmp + tmp + 1
    }
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
package main

import (
	"fmt"
)

func main() {
	var n int
	var a int
	fmt.Scan(&n)
	sliceA := make([]int, n)
	sliceSum := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a)
		sliceA[i] = a
	}

	// 累積和
	sumsum := 0
	for i := 0; i < n; i++ {
		sumsum += sliceA[i]
		sliceSum[i] = sumsum
	}

	sumAll := 0
	mod := 1000000007
	for i := 0; i < n; i++ {
		sum := (sliceSum[n-1] - sliceSum[i]) % mod
		sumAll += sliceA[i] * sum
		sumAll %= mod
	}
	fmt.Print(sumAll)

	// sumAll := 0
	// mod := 1000000007
	// for i := 0; i < n; i++ {
	// 	sum := (sliceSum[n-1] - sliceSum[i]) % mod
	// 	sumAll += sliceA[i] * sum
	// 	sumAll %= mod
	// }
	// fmt.Print(sumAll)

	// 計算量多い
	// for i := 0; i < n; i++ {
	// 	sum := 0
	// 	for j := i; j < n; j++ {
	// 		if i == j {
	// 			continue
	// 		}
	// 		sum += sliceA[i] * sliceA[j]
	// 	}
	// 	sumAll += sum
	// }
}

func abc(value int) int {
	flag := 1000000007
	ans := 0
	if value < flag {
		ans = value
	} else {
		ans = value % flag
	}
	return ans
}


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


int main(void)
{
	//変数の宣言
	
	int a,b;
	
	//データの読み込み
	
	scanf("%d %d",&a,&b);
	
//	printf("nは%dです\n", n);
//	printf("データの読み込み終了\n");
	//実際の処理
	
	if(a<=8 && b<=8){
	  printf("Yay!");
	}else{
	  printf(":(");
	}
	
/*	for(i=0;i<n;i++){
		if(i!=0) printf(" ");
		printf("%d",a[i]);
	}
	
	printf("\n");
	
	for(i=0;i<n;i++){
		if(i!=0) printf(" ");
		printf("%d",b[i]);
	}
	printf("\n");
*/	
	
	
	
	
	
	
//	printf("計算部分終了\n");
	
	//出力
	
	
//	printf("結果の出力終了\n");
	
	return 0;
}

Measured memory_bytes: 128
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	b := make([]int, n)
	for i := range b {
		fmt.Scan(&b[i])
	}

	operation := make([]int, n)

	for i := n - 1; i >= 0; i-- {
		idx := -1
		for j := i; j >= 0; j-- {
			if b[j] == j+1 {
				idx = j
				operation[i] = b[j]
				break
			}
		}
		if idx == -1 {
			fmt.Println(-1)
			return
		}
		b = remove(b, idx)
	}

	for _, o := range operation {
		fmt.Println(o)
	}
}

func remove(b []int, i int) []int {
	if len(b) == 1 && b[0] == 1 {
		return nil
	}
	return append(b[:i], b[i+1:]...)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define i64 long long 

using namespace std;

int main()
{

    i64 n;
    cin>>n;
    n--;
    cout<<1LL*n*(n+1)/2;
}
/*
 
Code written by a random fan of Tokyo_Square 
gb_DH_VNU

 */


Measured memory_bytes: 256
import java.io.*;
class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str;
		
		int hishi = 0;
		int chouhou = 0;
		while((str = br.readLine()) != null) {
			int cPos = str.indexOf(",");
			int prevPos = cPos;

			int width = Integer.parseInt(str.substring(0, cPos));
			
			cPos = str.indexOf(",", cPos+1);
			int height = Integer.parseInt(str.substring(prevPos+1, cPos));
			if(width == height) {
				hishi++; continue;
			}
			int diagonal = Integer.parseInt(str.substring(cPos+1));
			
			if(width*width + height*height == diagonal*diagonal) chouhou++;
		}
		System.out.println(chouhou);
		System.out.println(hishi);
	}
}

Measured memory_bytes: 8820
#include<stdio.h>

int main(void){
  int a,b,t;
  scanf("%d %d %d",&a,&b,&t);
  int s=1,k=0;
  
  for(int i=0;i<t+0.5;i++){
    if(i==s*a){
      s++;
      k+=b;
    }
  }
  printf("%d",k);
return 0;
}
      


Measured memory_bytes: 1736
import math
from collections import defaultdict


def make_prime_list(num):
    if num < 2:
        return []

    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)

    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break

        for non_prime in range(2 * prime, num+1, prime):
            prime_list[non_prime] = 0

    return [prime for prime in prime_list if prime != 0]


num = int(input())
div_sum = defaultdict(int)

p = make_prime_list(num)
for j in range(2, num+1):

    div_num = defaultdict(int)

    for i in p:
        n = j
        while n % i == 0:
            div_num[i] += 1
            n //= i

    for k, v in div_num.items():
        div_sum[k] += v

ans = 1
for k, v in div_sum.items():
    ans *= (v + 1)
print(ans % (10**9 + 7))

Measured memory_bytes: 3316
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>

typedef long long int64;

static bool isPoor(int a, int b, int c) {
  if (a == b && b != c) {
    return true;
  }
  if (b == c && c != a) {
    return true;
  }
  if (c == a && a != b) {
    return true;
  }
  return false;
}

int main(void) {
  int a, b, c;
  std::cin >> a >> b >> c;
  std::cout << (isPoor(a, b, c) ? "Yes" : "No") << std::endl;
  return 0;
}


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

int main(){
  string s;
  bool f=false;
  cin>>s;
  for(int i=s.size()/2-1;i>0;i--){
    f=false;
    for(int j=0;j<i;j++){
		if(s[j]!=s[i+j]){
          	f=true;
			break;
        }
    }
    if(!f){
		cout<<i*2<<endl;
      	return 0;
    }
  }
}

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

#define MP make_pair
#define F first
#define S second

using namespace std;

const int N = 2e6;
long long int dp[N];

long long int wop(long long int x, long long int y) {
    long long int ret=1;
    for(;y>0;y/=2) {
        if(y&1)ret*=x;
        x*=x;
    }
    return ret;
}

long long int F(long long int x) {
    if(x==1)return 1;
    return 2*F(x/2)+1;
}

int main () {
    long long int n, ans=0;
    cin >> n;
    cout << F(n);
}


Measured memory_bytes: 256
import bisect
N=int(input())
num=list(map(int, input().split()))
c=0
num.sort()
for i in range(N-1,1,-1): 
    for j in range(i-1,0,-1):
        t=num[i]-num[j]
        k=bisect.bisect_right(num,t,0,j)
        c+=(j-k)
print (c)
       

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100001,INF=1<<30;

int main(){

    int N;cin>>N;
    vector<int> A(N);
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    int cnt=0;
    for(int i=0;i<N;i++){
        if(A[i]==i+1) cnt++;
    }
    if(cnt==N||cnt==N-2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}



Measured memory_bytes: 256
import java.util.Scanner;
import java.util.HashMap;
public class Main {

    public static void main(String[] args) {
        Scanner Ent = new Scanner(System.in);
        int a = Ent.nextInt();
        int b = Ent.nextInt();
        int c = Ent.nextInt();
        int suma1 = a + b;
        int suma2 = a + c;
        int suma3 = c + b;
        System.out.println(Math.min(suma1, Math.min(suma2, suma3)));
    }
    
}


Measured memory_bytes: 21844
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#include <climits>
#include <memory>
#include <numeric>
#include <utility>


#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
const ll LINF = 1e18 + 100;
using namespace std;
using Graph = vector<vector<int>>;



int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int D;
ll G;
vector<ll> P, C;

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

	int n;
	cin >> n;
	vector<string> data(n);
	rep(i, 0, n) {
		cin >> data[i];
	}

	bool ans = true;

	rep(i, 0, n - 1) {
		if (data[i].back() != data[i + 1].front()) {
			ans = false;

		}
	}
	sort(data.begin(), data.end());

	rep(i, 0, n - 1) {
		if (data[i] == data[i + 1]) {
			ans = false;
		}
	}

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

}
	

Measured memory_bytes: 256
<?php
$a = fgets(STDIN);
$array = explode(' ', $a);
$a = $array[0];
$b = $array[1];
$result = -1;

for($i = 1; $i <= 1000; $i++) {
  $is_a = false;
  $is_b = false;
  if(floor($i*0.08) == $a && floor($i*0.1) == $b) {
    $result = $i;
    break;
  }
}

echo $result;
?>

Measured memory_bytes: 4604
n = int(input())
s = input()

def check(a,b):
  c = [0] * 26
  d = [0] * 26
  for i in range(len(a)):
    c[ord(a[i])-97] = 1
  for i in range(len(b)):
    d[ord(b[i])-97] = 1
  ans = 0
  for i in range(26):
    if c[i] == 1 and d[i] == 1:
      ans += 1
  return ans

res = 0
for i in range(n):
  res = max(res,check(s[:i],s[i:]))
print(res)


Measured memory_bytes: 8940
#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(b<=a&&a<=c){
	cout<<b<<" "<<c<<" "<<a<<endl;
}
else if(b<=c&&c<=a){
	cout<<b<<" "<<c<<" "<<a<<endl;
}
else if(c<=a&&a<=b){
	cout<<c<<" "<<a<<" "<<b<<endl;
}
else if(c<=b&&b<=a){
	cout<<c<<" "<<b<<" "<<a<<endl;
}
return 0;
}


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

int main() {
  int a, b, c, d; cin >>a >>b >>c >>d;
  int s1=a*b, s2=c*d;
  int ans = 0;
  if (s1>s2) ans = s1;
  else ans = s2;
  cout <<ans <<endl;
}


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

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

 ll cnt=0;
 for(ll i=n-1;i>=0;i--){
   a[i]+=cnt;
   if(a[i]%b[i]!=0){
   cnt+=(b[i]-a[i]%b[i]);
   }
 }
 cout << cnt << endl;

}


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

using namespace std;

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	if(a==1 && b==2) printf("3");
	else if(a==2 && b==1) printf("3");
	else if(a==3 && b==1) printf("2");
	else if(a==1 && b==3) printf("2");
	else if(a==2 && b==3) printf("1");
	else if(a==3 && b==2) printf("1");
    return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <iostream>
#include <stdio.h>

typedef long long ll;

using namespace std;

int main() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll p = N / (A + B);
  ll q = N % (A + B);
  printf("%lld\n", A * p + min(A, q));
}

Measured memory_bytes: 3248
#include <iostream>
#include <bits/stdc++.h>
#include <cmath>
#include <vector>
#define ll long long int
#define mp make_pair
#define pb push_back
#define vi vector<int>
using namespace std;
void solve(){
    int n,x,y;
    cin>>n>>x>>y;
    ll ans[n]={0};
    vector<int> edge[n];
    edge[--x].pb(--y);
    edge[y].pb(x);
    for(int i=0;i<n-1;i++){
        edge[i].pb(i+1);
        edge[i+1].pb(i);
    }
    for(int i=0;i<n;i++){
        queue<pair<int,int>> tochk;
        bool found[n]={0};
        found[i]=1;
        tochk.push(mp(i,0));
        while(!tochk.empty()){
            for(int i=0;i<edge[tochk.front().first].size();i++){
                if(!found[edge[tochk.front().first][i]]){
                    found[edge[tochk.front().first][i]]=1;
                    tochk.push(mp(edge[tochk.front().first][i],tochk.front().second+1));
                }
            }
            ans[tochk.front().second]++;
            tochk.pop();
        }
    }
    for(int i=1;i<n;i++){
        cout<<ans[i]/2<<"\n";
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
}

Measured memory_bytes: 384
import sys
# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
# import heapq
import decimal
# import statistics
import queue

# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===
def main():
    n = ni()

    diver = 26
    ans = []
    while n > 0:
        n -= 1
        ans.append(chr(97 + n % diver))
        n //= diver

    ans.reverse()
    print(*ans, sep="")


if __name__ == '__main__':
    main()


Measured memory_bytes: 10772
DIR = {">": (0, 1), "<": (0, -1), "^": (-1, 0), "v": (1, 0)}

while True:
    w, h = map(int, raw_input().split())
    if w == 0 and h == 0:
        break

    m = [[] for i in range(w)]
    for i in range(w):
        m[i] = [c for c in raw_input().strip()]

    x = 0
    y = 0
    while m[x][y] != '.':
        i = m[x][y]
        if i == 'x':
            break
        m[x][y] = 'x'
        x += DIR[i][0]
        y += DIR[i][1]

    if m[x][y] == '.':
        print("{} {}".format(y, x))
    else:
        print("LOOP")

Measured memory_bytes: 4332
#include<stdio.h>

int main(){
  int n,q,S[10000],T[500];
  int i,j,count=0;
  
  scanf("%d",&n);
  for(i=0;i<n;i++)
    scanf("%d",&S[i]);
  scanf("%d",&q);
  for(i=0;i<q;i++)
    scanf("%d",&T[i]);
  
  for(i=0;i<q;i++){
    for(j=0;j<n;j++){
      if(T[i]==S[j]){
	count++;
	break;
      }
    }
  }
  
  printf("%d\n",count);
  
  return 0;
}



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

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

    for(int i = 1; i <= 10; i++){
        if(n <= i + i * 10 + i * 100){
            cout << i + i * 10 + i * 100 << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import defaultdict

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    S = [0] * N
    for i in range(N):
        S[i] = readline().strip()

    d = defaultdict(int)
    for s in S:
        d[''.join(sorted(s))] += 1

    ans = 0
    for n in d.values():
        if n > 1:
            ans += n * (n - 1) // 2

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 29544
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define N 312345
constexpr ll MOD = 1'000'000'007LL;
ll a[N];

int main(){
	int n; scanf("%d", &n);
	REP(i, n) scanf("%lld", a+i);
	ll ans = 0;
	REP(j, 60){
		ll m = 1LL<<j;
		ll k = 0;
		REP(i, n) if(a[i]&m) k++;
		ans += m % MOD * k % MOD * (n-k) % MOD;
	}
	printf("%lld\n", ans % MOD);
}


Measured memory_bytes: 2560
#include <stdio.h>
int main(){

  int i,last;
  char a[3][11];

  for(i = 0; i < 3; i++) scanf("%s",a[i]);

  for(i = 0; i < 11; i++){
    if(a[0][i] == '\0'){
      last=i-1;
      break;
    }
  }

  if(a[0][last] != a[1][0]){
    printf("NO\n");
    return 0;
  }

  for(i = 0; i < 11; i++){
    if(a[1][i] == '\0'){
      last=i-1;
      break;
    }
  }

  if(a[1][last] != a[2][0]){
    printf("NO\n");
    return 0;
  }

  printf("YES\n");
  return 0;

}

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

int main(){
	int n,k;
	cin >> n >> k;
	int high[n];
	for(int i = 0;i < n;i++){
		cin >> high[i];
	}
	int ans = 0;
	for(int i = 0;i < n;i++){
		if(high[i] >= k)ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std ;
#define ll long long
#define pb push_back
#define __ ios_base::sync_with_stdio(false); cin.tie(NULL);
const ll N = 1e7+7 ;


int main() {
//    __

    ll n , m , j , i  , k ;
    cin >> n >> m >> k ;
    vector<ll>a(n) , b(m) , v ;
    ll sum = 0 , x ;
    for (i = 0 ; i< n ; i++) {
        cin >> x ;
        sum+=x ;
        a[i] = sum ;
    }
    sum = 0 ;
    for (i = 0 ;i< m ; i++) {
        cin >> x ;
        sum+=x ;
        b[i] = sum ;
    }
    ll ans = 0 ;
    for (i = 0 ; i< n ; i++) {
            if (k<a[i]) break ;
        ll pos = upper_bound(b.begin(),b.end(),k - a[i]) - b.begin() ;
        ans = max(ans, (i+1) + pos) ;
    }
    for (i = 0 ; i< m ; i++) {
            if (k<b[i]) break ;
        ll pos = upper_bound(a.begin(),a.end(),k - b[i]) - a.begin() ;
        ans = max(ans, (i+1) + pos) ;
    }
    cout  << ans << endl ;



    return 0 ;
}





Measured memory_bytes: 6340
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

vector<int> G[200010];
int B[200010], nb[200010];
int col[3];

void dfs(int c, int v) {
	if (B[c] > 0)return;
	B[c] = v;
	col[v]++;
	for (int i : G[c]) {
		dfs(i, 3 - v);
	}
}

int main() {
	for (int i = 0;i < 200010;i++)B[i] = 0;
	int N, a, b;
	cin >> N;
	for (int i = 1;i < N;i++) {
		cin >> a >> b;
		a--;b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	dfs(0, 1);
	int c1 = N / 3;
	if (N % 3 > 0)c1++;

	int c2 = N / 3;
	if (N % 3 == 2)c2++;

	int c3 = N / 3;

	if (col[1] <= c3) {
		for (int i = 0;i < N;i++) {
			if (B[i] == 1)nb[i] = 0;
			else {
				if (c2 > 0)nb[i] = 2, c2--;
				else if (c1 > 0)nb[i] = 1, c1--;
				else nb[i] = 0;
			}
		}
	}
	else if (col[2] <= c3) {
		//2to0
		for (int i = 0;i < N;i++) {
			if (B[i] == 2) nb[i] = 0;
			else {
				if (c2 > 0)nb[i] = 2, c2--;
				else if (c1 > 0)nb[i] = 1, c1--;
				else nb[i] = 0;
			}
		}
	}
	else {
		//1や2から0を作る
		for (int i = 0;i < N;i++) {
			if (B[i] == 1) {
				if (c1 > 0)nb[i] = 1, c1--;
				else nb[i] = 0;
			}
			else {
				if (c2 > 0)nb[i] = 2, c2--;
				else nb[i] = 0;
			}
		}
	}

	c1 = 1, c2 = 2, c3 = 3;
	for (int i = 0;i < N;i++) {
		if (nb[i] == 1) {
			cout << c1 << " ";
			c1 += 3;
		}
		else if (nb[i] == 2) {
			cout << c2 << " ";
			c2 += 3;
		}
		else {
			cout << c3 << " ";
			c3 += 3;
		}
	}
	cout << endl;
}

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

int main()
{
  int n,c[4][14]={0},math;
  char card;
  cin >> n;
  
  for(int m=0;m<n;m++){
    int k=-1,l=-1;
    cin >> card >> math;
    l=math;
    if(card=='S'){
      k=0; // スペード⇒iに0代入
    }else if(card=='H'){
      k=1; // ハート⇒iに1代入
    }else if(card=='C'){
      k=2; // クラブ⇒iに2代入
    }else if(card=='D'){
      k=3; // ダイヤ⇒iに3代入
    }
    c[k][l]=1; // 記号iと数字jの配列に1を代入
  }
  
  for(int i=0;i<4;i++){
    if(i==0){
      card='S';
    }else if(i==1){
      card='H';
    }else if(i==2){
      card='C';
    }else if(i==3){
      card='D';
    }
    for(int j=1;j<=13;j++){
      if(c[i][j]!=1){ // 記号kとi、数字lとjのいずれか一方が一致しない場合
	cout << card << " " << j << endl;
      }
    }
  }
  return 0;
}

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

int main(){
  int N;
  cin >> N;
  int JPY=0;
  int64_t BTC=0;
  double x;
  string u;
  for(int i=0; i<N; i++){
    cin >> x >> u;
    if(u=="JPY"){
      JPY+=(int)x;
    }
    else{
      BTC+=(int64_t)(x*100000000);
    }
  }
  double BTCd;
  BTCd=BTC*380000;
  BTCd/=100000000;
  double JPYd=(double)JPY;
  cout << setprecision(8) << JPYd+BTCd << endl;
}
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>

using namespace std;
using namespace __gnu_pbds;

#define endl '\n'

typedef long long ll;
typedef pair<int, int> pii;
//typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int maxn = 1e5 + 5;

vector<int> g[maxn];
int n;

vector<int> bfs(int u){
	vector<int> d(n, -1);
	d[u] = 0;
	queue<int> Q;
	Q.push(u);
	while(!Q.empty()){
		u = Q.front();Q.pop();
		for(auto &v : g[u])
			if(d[v] == -1){
				d[v] = d[u] + 1;
				Q.push(v);
			}
	}
	return d;
}

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

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int x, y;

	cin >> n >> x >> y;
	
	x--, y--;
	
	for(int i = 1; i < n; i++){
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	
	auto d2 = bfs(y);
	
	vector<int> d(n, -1);
	d[x] = 0;
	queue<int> Q;
	Q.push(x);
	while(!Q.empty()){
		int u = Q.front();Q.pop();
		for(auto &v : g[u])
			if(d[v] == -1 && d[u] + 1 <= d2[v]){
				d[v] = d[u] + 1;
				if(d[v] < d2[v])
					Q.push(v);
			}
	}
	
	int ans = 0;
	for(int i = 0; i < n; i++)
		if(d[i] != -1){
			if(d[i] == d2[i])
				ans = max(ans, d[i]);
			else{
				int mn = n + 5;
				for(auto &v : g[i])
					mn = min(mn, d2[v]);
				ans = max(ans, mn);
			}
		}
	
	cout << ans << endl;
	
	return 0;
}

/*

13 9 1
1 2
2 13
2 3
3 4
4 12
12 11
4 10
4 5
5 6
5 9
9 7
9 8

*/


Measured memory_bytes: 6656
#include <iostream>
#include <cstring>
#include <stdio.h>
#include <algorithm>
#include <climits>

using namespace std;

int main(){
	int w, a, b;
	cin>>w>>a>>b;
	int y = max(a, b);
	int x = min(a, b);
	cout<<max(0, y-(x+w))<<endl;
	return 0;
}

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

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


using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    if (b == 1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    b -= a;
    while (b > 0) {
        b -= a - 1;
        ans++;
    }
    cout << ans << endl;
   
    return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
//#include <function>
using namespace std;
typedef long long unsigned int ll;

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

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


bool isok(int a, int b, int c, int d){
  bool ans = true;
  if ((b == 0 && c == 2 && d == 1) || (b == 0 && c == 1 && d == 2) || (b == 2 && c == 0 && d == 1) || (a == 0 && b == 2 && d == 1) || (a == 0 && c == 2 && d == 1)){
    ans = false;
  }
  return ans;
}

int main() {

  ll MOD = 1e9 + 7;
  int N;
  cin >> N;

  ll dp[110][4][4][4] = {0LL};

  dp[0][3][3][3] = 1;
  for(int i = 0; i < N; i++){
    REP(j, 4){
      REP(k, 4){
        REP(l, 4){

          REP(m, 4){
            if (isok(j, k, l, m)){
              dp[i+1][k][l][m] = (dp[i+1][k][l][m] + dp[i][j][k][l]) % MOD;
            }
          }
        }
      }
    }
  }
  ll ans = 0LL;
  REP(i, 4) REP(j, 4) REP(k, 4){
     ans += dp[N][i][j][k];
     ans %= MOD;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
class Main{
    public static void main(String[] a){
                int x = 0;
		int y = 0;
		int z = 0;
		
		for (x = 1; x <= 9; x++){
			for (y = 1; y <= 9; y++){
				z= x*y;
				System.out.println(x + "x" + y + "=" + z);
}
}

    }
}

Measured memory_bytes: 24080
n,*h=map(int,open(0).read().split())
dp=[0]*n
dp[0]=0
dp[1]=abs(h[0]-h[1])
for i in range(2,n):
	dp[i]=min(dp[i-2]+abs(h[i-2]-h[i]),dp[i-1]+abs(h[i-1]-h[i]))
print(dp[n-1])

Measured memory_bytes: 13876
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-01-31 15:24:57
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
#define i64 long long
i64 read()
{
	i64 r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=2010,mod=1000000007;
i64 n,m,f[N],x,s;
struct edge
{
	i64 u,v,w;
	edge(i64 U=0,i64 V=0,i64 W=0){ u=U; v=V; w=W; }
}e[N];
int operator<(edge a,edge b){ return a.w<b.w; }
void init(){ s=0; fr(i,1,n) f[i]=i; }
int getf(int u){ return u==f[u]?u:f[u]=getf(f[u]); }
void link(edge a)
{
	a.u=getf(a.u); a.v=getf(a.v);
	if(a.u!=a.v){ f[a.u]=a.v; s+=a.w; }
}
void calc(){ fr(i,1,m) link(e[i]); }
i64 power(i64 a,i64 b,i64 p)
{
	i64 r=1;
	for(;b;b>>=1,a=a*a%p) if(b&1) r=r*a%p;
	return r;
}
i64 power(i64 a){ return power(2,a,mod); }
int main()
{
	n=read(); m=read();
	x=read();
	fr(i,1,m)
	{
		i64 u=read(),v=read(),w=read();
		e[i]=edge(u,v,w);
	}
	std::sort(e+1,e+m+1);
	if(({ init(); calc(); s; })>x){ printf("0\n"); return 0; }
	else if(s==x)
	{
		i64 a=0,b=0;
		fr(i,1,m) if(({ init(); link(e[i]); calc(); s; })==x) a++;
		else b++;
		printf("%d\n",int((power(a)-2)*power(b)%mod));
	}
	else
	{
		i64 a=0,b=0,c=0;
		fr(i,1,m)
			if(({ init(); link(e[i]); calc(); s; })<x) a++;
			else if(s==x) b++;
			else c++;
		printf("%d\n",int(2*(power(b)-1)*power(c)%mod));
	}
	return 0;
}

Measured memory_bytes: 384
from collections import defaultdict
import math
SUPER_A=10**6+1
n=int(input())
a_array=list(map(int,input().split()))
a_array.sort()
div_dict=defaultdict(bool)
count=0
for i in range(n):
    a=a_array[i]
    if div_dict[a]:
        count+=1
    else:
        for j in range(1,math.ceil(SUPER_A/a)):
            div_dict[j*a]=True
        if i + 1 < n and (a_array[i]==a_array[i+1]):
            count+=1
print(n-count)

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

typedef long long ll;

struct edge {int to; ll cost;};
typedef pair<int, ll> ill;
ll INF=1e14+10;
int V;
vector<edge> G[100010];
ll d[100010];

void dijkstra(){
  priority_queue<ill, vector<ill>, greater<ill>> que;

  fill(d, d+V, INF);
  d[0]=0;
  que.push({0, 0});
  while(!que.empty()){
    ill p=que.top();que.pop();
    int v=p.second;
    if(d[v]<p.first) continue;
    for (int i=0;i<G[v].size();++i){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push({d[e.to], e.to});
      }
    }
  }
}

int main(){
  cin>>V;
  for (int i=0;i<V;++i){
    int u, v;cin>>u>>v;ll w;cin>>w;
    G[u-1].push_back((edge){v-1,w});
    G[v-1].push_back((edge){u-1,w});
  }
  dijkstra();
  for (int i=0;i<V;++i){
    if(d[i]%2==0){cout << '0' << endl;}
    else{cout << '1' << endl;}
  }
  return 0;
}

Measured memory_bytes: 8704
N = int(input())
A = list(map(int, input().split()))
num = len(A)

while num > 1:
    a = min(A)
    j = 0
    flag = True
    for n in range(num):
        if A[n] == a and flag:
            A[j] = a
            j += 1
            flag = False
        else:
            b = A[n] % a
            if b > 0:
                A[j] = b
                j += 1
    num = j

print(A[0])


Measured memory_bytes: 14228