akhauriyash/Code-Regression huggingface dataset:
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstring>

using namespace std;

int h;
int w;
int k;
vector<string> a;
int b[320][320];

void scan(int sy, int sx, int col) {
	int ty = -1, tx = -1;
	for (int i = sy; i < h && ty < 0; ++i) {
		for (int j = sx; j < w; ++j) {
			if (b[i][j] > 0) {
				break;
			}
			if (a[i][j] != '.') {
				ty = i;
				tx = j;
				break;
			}
		}
	}
	for (int j = tx + 1; j < w; ++j) {
		int i;
		for (i = sy; i <= ty; ++i) {
			if (b[i][j] > 0 || a[i][j] != '.') {
				break;
			}
		}
		if (i <= ty) {
			break;
		}
		++tx;
	}
	for (int i = ty + 1; i < h; ++i) {
		int j;
		for (j = sx; j <= tx; ++j) {
			if (b[i][j] > 0 || a[i][j] != '.') {
				break;
			}
		}
		if (j <= tx) {
			break;
		}
		++ty;
	}
	for (int i = sy; i <= ty; ++i) {
		for (int j = sx; j <= tx; ++j) {
			b[i][j] = col;
		}
	}
}

int main(int argc, char* argv[]) {
	cout.precision(20);
#ifdef _MSC_VER
	while (true)
#endif
	{
		h = -1, w = -1, k = -1;
		cin >> h >> w >> k;
		if (h <= 0) return 0;
		a.resize(h);
		for (int i = 0; i < h; ++i) {
			cin >> a[i];
		}
		memset(b, -1, sizeof(b));
		int col = 0;
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (b[i][j] < 0) {
					scan(i, j, ++col);
				}
			}
		}
		for (int i = 0; i < h; ++i) {
			for (int j = 0; j < w; ++j) {
				if (j) cout << " ";
				cout << b[i][j];
			}
			cout << endl;
		}
	}
	return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define db double
#define mp make_pair
#define X first
#define Y second
#define vi vector<int>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<(a).size();++i)
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
#define gc getchar
inline ll rd()
{
	ll x=0,w=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();
	if(c=='-')c=gc(),w=-1;while(isdigit(c))x=x*10+c-48,c=gc();return x*w;
}
const int N=6005;
int n,P,nn,f[N][N*2];
int main()
{
	n=rd();P=rd();nn=n*3;f[0][nn]=1;
	rep(i,1,nn)rep(j,-nn,nn)
	{
		if(j>-nn)f[i][j+nn]=(f[i][j+nn]+f[i-1][j+nn-1])%P;
		if(j<nn&&i>=2)f[i][j+nn]=(f[i][j+nn]+1ll*(i-1)*f[i-2][j+nn+1])%P;
		if(i>=3)f[i][j+nn]=(f[i][j+nn]+1ll*(i-1)*(i-2)*f[i-3][j+nn])%P;
	}
	int ans=0;rep(i,0,nn)ans=(ans+f[nn][i+nn])%P;
	printf("%d\n",ans);return 0;
}


Measured memory_bytes: 285112
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

std::vector<int> prime;
void MakePrime(int n) {
	prime.emplace_back(2);
	for (int i = 3; i < n; i += 2) {
		bool a = false;
		for (int j = 3; j <= std::sqrt(i); j += 2) {
			if (i%j == 0) {
				a = true;
			}
		}
		if (a == false) {
			prime.emplace_back(i);
		}
	}
}

LL calc_opponent(LL x){
    LL ret = 1;
    for(auto p : prime){
        LL cnt = 0;
        while(x % p == 0) ++cnt, x /= p;
        if(cnt == 0)continue;
        else if(cnt == 1)ret *= p * p;
        else ret *= p;
    }
    LL l = 1, r = 1000000LL;
    while(r - l > 1){
        LL mid = (l + r)/2;
        if(mid * mid > x)r = mid;
        else l = mid;
    }
    if(l * l == x){
        ret *= l;
    }else{
        ret *= x * x;
    }
    return ret;
}

int n;
LL a[101010];

int main(){
    cin >> n;
    REP(i, n)cin >> a[i];
    int ans = 0;
    MakePrime(2155);
    map<LL, int>mp;
    REP(i, n){
        LL num = 1;
        for(auto p : prime){
            int cnt = 0;
            while(a[i] % p == 0)++cnt, a[i] /= p;
            cnt %= 3;
            REP(j, cnt)num *= p;
        }
        num *= a[i];
        if(num == 1)ans = 1;
        else mp[num]++;
    }
    for(auto it = mp.begin(); it != mp.end();++it){
        LL val = it->first;
        LL opponent = calc_opponent(val);
        int num = max(it->second, mp[opponent]);
        it->second = mp[opponent] = 0;
        ans += num;
    }
    cout << ans << endl;
}

Measured memory_bytes: 17920
n = gets.to_i

exist_words = []
exist_words.push(gets.chomp)

flag = true
for i in 2..n
  current_word = gets.chomp
  if exist_words.include?(current_word) || !exist_words.last.end_with?(current_word.chr)
    #p exist_words.include?(current_word)
    #p exist_words.last.end_with?(current_word)
    #p current_word
    flag = false
    break
  end
  
  exist_words.push(current_word)
end

puts 'Yes' if flag
puts 'No' if !flag


Measured memory_bytes: 3836
N = int(input())
s = list(input())
r = 0;g = 0;b= 0
for i in s:
    if i=="R":
        r += 1
    elif i=="G":
        g += 1
    else:
        b += 1
all = r*g*b
sub = 0
for i in range(N-1):
    for j in range(i+1,N):
        if s[i]==s[j]:
            continue
        k = 2*j - i
        if k >= N:
            continue
        else:
            if (s[k]!=s[i] and s[k]!=s[j]):
                sub += 1
print(all-sub)

Measured memory_bytes: 71928
#include <bits/stdc++.h> 
#include <time.h>
#define F(i,a,b) for(long long i=a;i<=(b);++i)
#define dF(i,a,b) for(long long i=a;i>=(b);--i) 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define maxnkp make_pair
#define fi first
#define se second
#define eps 1e-10
#define PI acos(-1.0)
using namespace std;
typedef long long ll;
const int mods = 1e9+7;
const int maxn = 3e5+10;
const int N = 1e5+10;
const int E = 1e6+10;  
double a,b,h,m;
double c,d,ans;
int main(){
	cin>>a>>b>>h>>m;
	d = m*6.0;
	c = m/2.0 + h*30.0;
	c = abs(c-d);
	if(c>=180.0){
		c = 360-c;
	}
	ans = sqrt(a*a + b*b -2*a*b*cos((c/180.0)*PI));
	printf("%.10lf\n",ans);
}

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

int n, m;
bool f[100010];
int a[100010];
int ans;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> m;
	for(int i=0; i<n; ++i)
		a[i] = 1;
	f[0] = true;
	for(int i=0; i<m; ++i){
		int x, y;
		cin >> x >> y;
		--x;
		--y;
		f[y] |= f[x];
		if(a[x] == 1 && f[x])
			f[x] = false;
		--a[x];
		++a[y];
	}
	for(int i=0; i<n; ++i)
		if(f[i] && a[i])
			++ans;
	cout << ans << "\n";
}

Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 100000
using namespace std;
ll v[LIM];
int main() {
  // int arr[10][3] = {{-5, -1, 4}, {-5, 0, 5}, {-5, 1, 5}, {0, 5, 5}, {1, 5, 4}, {-1, -5, 6}, {0, -5, 5}, {1, -5, 6}, {5, 0, 6}, {5, 1, 6}};
  ll a, b;
  cin >> a >> b;
  if ((a < 0 && b > 0) || (a > 0 && b < 0)) {
    cout << abs(abs(a) - abs(b)) + 1 << endl;
  } else if (a == 0 || b == 0) {
    if (a == b) {
      cout << 0 << endl;
    } else if (a < b) {
      cout << max(abs(a), abs(b)) << endl;
    } else {
      cout << max(abs(a), abs(b)) + 1 << endl;
    }
  } else {
    if (a < b) {
      cout << abs(abs(a) - abs(b)) << endl;
    } else {
      cout << abs(abs(a) - abs(b)) + 2 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
#include <fstream>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    //2 3 3 1 3 1
    //3 5 6 5 8 7
    //-1 -1 0 3 2 5
    //a[i]+a[j]=j-i
    //a[i]+i=j-a[j]
    int n, a[200005] = {};
    ll z = 0;
    map<int, int> m;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) {
        z += m[i - a[i]];
        m[i + a[i]]++;
    }
    cout << z;
}


Measured memory_bytes: 21364
#include <cstdio>
using namespace std;
int N; bool ok = false;
int main() {
  scanf("%d", &N);
  for(int i = 1; i <= 9; ++i) {
    for(int j = 1; j <= 9; ++j) {
      if(i*j == N) ok = true; 
    }
  }
  printf("%s", ok?"Yes":"No");
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		
		long []sumA = new long [n+1];
		long []sumB = new long [m+1];
		
		for(int i = 0 ; i < n ;i++) {
			int a = Integer.parseInt(sc.next());
			sumA[i+1] = (long)(sumA[i] + a);
		}
		
		for(int i = 0 ; i < m ;i++) {
			int b = Integer.parseInt(sc.next());
			sumB[i+1] = (long)(sumB[i] + b);
		}
		
		int max = 0;
		
		for(int i = 0 ; i <= n ;i++) {
			if(sumA[i] > k) {
				continue;
			}
			
			int b = LowerBound(k, sumA[i],sumB,m);
			max = Math.max(i+b, max);
		}
		
		System.out.println(max);
		
	}
	
	static int LowerBound(int k , long t, long []sumB , int m) {
		if(t >= k) {
			return 0;
		}
		if(t + sumB[m] <= k) {
			return m;
		}
		
		int l = 0;
		int r = m;
		
		while(r-l > 1) {
			int tmp = (l+r)/2;
			if(t + sumB[tmp] > k) {
				r = tmp;
			}
			else if(t + sumB[tmp] < k) {
				l = tmp;
			}
			else {
				return tmp;
			}
		}
		
		
		return l;
	}
}


Measured memory_bytes: 63416
#include <iostream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <iomanip>
#include <sstream>
#include <bitset>
#include <cstdlib>
#include <iterator>
#include <algorithm>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    int n = s.size();
    int sum = 0;
    for (int i = 0; i < n; i++)
    {
        sum += (s[i] - '0');
        sum = sum % 9;
    }
    if (sum)
        cout << "No";
    else
        cout << "Yes";
    return 0;
}

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

int main(){
 	int n;
 	cin >>n;
 	vector<int> a(n);
 	for(int i=0;i<n;i++){
 	    cin >> a.at(i);
 	}
 	sort(a.begin(),a.end());
 	cout << a.at(n-1)-a.at(0) << endl;
 	}


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

using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
signed main(){
  	int N;cin>>N;
  	int ans;ans=0;
  	int mt_w;
  	int mt_n;
  	mt_w=0;
  	rep(i,N){
    	cin>>mt_n;
      	if(mt_n>=mt_w){
        	ans=ans+1;
          	mt_w=mt_n;
        }
    }

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


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

#define int long long

const int maxn = 2e5 + 5;
int a[maxn];

signed main() {
    int n;
    cin >> n;
    for (int i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
    }
    sort(a + 1, a + 1 + n);
    int ans = 0;
    for (int i = 1; i <= n - 1; ++i) {
        ans += a[n - i / 2];
    }
    cout << ans << endl;
    return 0;

}

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

int main(){
    int n1,n2,n3;
    cin>>n1>>n2>>n3;
    if(n1==n2 && n2==n3){
    cout<<"No"<<endl;
    }else if(n1==n2 || n2==n3 || n1==n3){
    cout<<"Yes"<<endl;
    }else{
    cout <<"No"<<endl;
    }
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int ran(int x, int a, int b, int c){
	return (a*x+b) % c;
}

int main(){
	int N,A,B,C,X,Y;
	int count;

	while(cin >> N,N){
		cin >> A >> B >> C >> X;
		count = 0;
		for(int i=0;i<N;i++){
			cin >> Y;
			while(X != Y && count <= 10000){
				X = ran(X,A,B,C);
				count++;
			}
			X = ran(X,A,B,C);
			count++;
		}
		if(count-1 > 10000) count = 0;
		cout << count-1 << endl;
	}


	return 0;
}

Measured memory_bytes: 3008
unittest
{
	assert( [ "a", "4", "2 1 p", "1", "2 2 c", "1" ].parse.expand.solve == "cpa" );
	assert( [ "a", "6", "2 2 a", "2 1 b", "1", "2 2 c", "1", "1" ].parse.expand.solve == "aabc" );
	assert( [ "y", "1", "2 1 x" ].parse.expand.solve == "xy" );
}



import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto s = input.front.to!( dchar[] );
	input.popFront;
	auto q = input.front.to!( long );
	auto qss = new dchar[][][ q ];
	foreach( ref qs; qss )
	{
		input.popFront;
		qs = input.front.split.to!( dchar[][] );
	}
	return tuple( s, qss );
}

auto solve( dchar[] s, dchar[][][] qss )
{
	auto queue = DList!dchar( s );
	auto r = false;
	foreach( qs; qss )
	{
		final switch( qs[ 0 ] )
		{
			case "1":
				r = !r;
				break;
			
			case "2":
				if( ( !r && qs[ 1 ] == "1" ) || ( r && qs[ 1 ] == "2" ) ) queue.insertFront( qs[ 2 ] );
				else                                                      queue.insertBack( qs[ 2 ] );
				break;
		}
	}
	return r ? queue[].retro.array : queue[].array;
}


Measured memory_bytes: 81304
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define IINF 10e8
#define INF 1<<30
#define MOD 1000000007
#define mod 10007
#define REP(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp(pair<ll,ll>a,pair<ll,ll> b){
        if(a.se!=b.se)
        return a.se<b.se;
        else
        return a.fi<b.fi;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_time=clock();
    //------------------------------
    char s;
    map<char,int>m;
    while(scanf("%c",&s)!=EOF){
       
   
            if(isalpha(s)){
                m[tolower(s)]++;
            }

    }
    for(int c='a';c<='z';c++){
        printf("%c : %d\n",c,m[c]); 
    }
    //-------------------------------  
    //ll end_time=clock();cout<<"time="<<end_time-begin_time<<"ms"<<endl;
    //-------------------------------
    return 0;
}
//----------------------------------------------------------------------


































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

#define int long long

#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define fi first
#define se second
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint>PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;
int dx[]={0,0,1,-1};
int dy[]={-1,1,0,0};

string s;

signed main(){
    cin.tie(0);
	ios::sync_with_stdio(false);
    cin>>s;
    int cnt=0;
    rep(i,0,6){
        if(s[i]=='1')cnt++;
    }
    cout<<cnt<<"\n";
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
struct node{
	int p,l,r;
};
node T[10000];
int n,v,l,r,root;

void preParse(int u){
	if(u==-1){
		return;
	}
	cout<<" "<<u;
	preParse(T[u].l );
	preParse(T[u].r );
}

void inParse(int u){
	if(u==-1){
		return;
	}
	inParse(T[u].l );
	cout<<" "<<u;
	inParse(T[u].r );
}

void postParse(int u){
	if(u==-1){
		return;
	}
	postParse(T[u].l );
	postParse(T[u].r );
	cout<<" "<<u;
}

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		T[i].p =-1;
	}
	for(int i=0;i<n;i++){
		cin>>v>>l>>r;
		T[v].l =l;
		T[v].r =r;
		if(l!=-1){
			T[l].p=v; 
		}
		if(r!=-1){
			T[r].p =v;
		}
	}
	for(int i=0;i<n;i++){
		if(T[i].p ==-1){
			root=i;
		}
	}
	cout<<"Preorder"<<endl;
	preParse(root);
	cout<<endl;
	cout<<"Inorder"<<endl;
	inParse(root);
	cout<<endl;
	cout<<"Postorder"<<endl;
	postParse(root);
	cout<<endl;
	return 0;
}


Measured memory_bytes: 3108
/*  -*- coding: utf-8 -*-
 *
 * f.cc: F - Distinct Numbers
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 300000;

/* typedef */

typedef long long ll;

/* global variables */

int cs[MAX_N + 1], ds[MAX_N + 1];
int dss[MAX_N + 1], kdss[MAX_N + 1];
int fs[MAX_N + 1];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);

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

  for (int i = 1; i <= n; i++) ds[cs[i]]++;
  //for (int i = 1; i <= n; i++) printf("%d ", ds[i]); putchar('\n');

  dss[0] = kdss[0] = 0;
  for (int i = 1; i <= n; i++) {
    dss[i] = dss[i - 1] + ds[i];
    kdss[i] = kdss[i - 1] + i * ds[i];
  }

  for (int i = 1; i <= n; i++) {
    fs[i] = (kdss[i] + (ll)i * (dss[n] - dss[i])) / i;
    //printf("fs[%d] = (%d+%d*(%d-%d))/%d = %d\n",
    //i, kdss[i], i, dss[n], dss[i], i, fs[i]);
  }

  for (int i = 1, j = n; i <= n; i++) {
    while (j > 0 && fs[j] < i) j--;
    printf("%d\n", j);
  }
  return 0;
}


Measured memory_bytes: 6144
#include <stdio.h>
#define MAX 100

void DepthFirstSearch();
void roop(int );

int d[MAX],f[MAX],arr2[MAX];
int N,time;
#define MAX 100
#define IN -1
int a[MAX][MAX];

int main(){
  int i,j,count,num,arr;
  scanf("%d",&N);
  for(i=0;i<N;i++){
    for(j=0;j<N;j++){
      a[i][j]=0;
    }
    d[i]=0;
    f[i]=0;
    arr2[i]=0;
  }
  for(i=0;i<N;i++){
    scanf("%d%d",&num,&count);
    for(j=0;j<count;j++){
      scanf("%d",&arr);
      a[num-1][arr-1] = 1;
    }
  }
  DepthFirstSearch();
  for(i=0;i<N;i++){
    printf("%d %d %d\n",i+1,d[i],f[i]);
  }
  return 0;
}

void DepthFirstSearch(){
  int i;
  time = 0;

  for(i=0;i<N;i++){
    if(arr2[i]==0){
      roop(i);
    }
  }
}

void roop(int i){
  int j;

  arr2[i]=IN;
  d[i] = ++time;
  for(j=0;j<N;j++){
    if(a[i][j] == 0) continue;
    if(arr2[j]==0){
      roop(j);
    }

  }
  arr2[i]=1;
  f[i] = ++time;
}

Measured memory_bytes: 636
table=[2,3,4,5,6,7,8,9,10,11,12,13,1]
a,b=map(int,input().split())
if a == b :
    print("Draw")
elif table.index(a) < table.index(b):
    print("Bob")
elif table.index(a) > table.index(b):
    print("Alice")


Measured memory_bytes: 2940
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n;
int h[200001];
int a[200001];
int dp[200001];
int tree[800001];
void update(int node,int l,int r,int pos,int val)
{
    if(l==r){
    dp[pos]=val;
    tree[node]=val;
    }
    else{
        int mid=(l+r)/2;
        if(pos>=l&&pos<=mid)
        update(2*node,l,mid,pos,val);
        else
        update(2*node+1,mid+1,r,pos,val);
        tree[node]=max(tree[2*node],tree[2*node+1]);
    }
}
int query(int node, int start, int end, int l, int r)
{
    if(r < start or end < l)
    {
        return 0;
    }
    if(l <= start and end <= r)
    {
        return tree[node];
    }
    int mid = (start + end) / 2;
    int p1 = query(2*node, start, mid, l, r);
    int p2 = query(2*node+1, mid+1, end, l, r);
    return max(p1,p2);
}
main()
{
	ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
	cin>>n;
	for(int i=0;i<n;i++)
	cin>>h[i];
	for(int i=0;i<n;i++)
	cin>>a[i];
	int ans=0;
	for(int i=0;i<n;i++)
	{
		int maxi=query(1,0,n,1,h[i]-1);
		update(1,0,n,h[i],maxi+a[i]);
		/*for(int j=1;j<h[i];j++)
		maxi=max(maxi,dp[j]);
		dp[h[i]]=maxi+a[i];
		ans=max(ans,dp[h[i]]);*/
	}
	cout<<query(1,0,n,1,n);
	return 0;
}

Measured memory_bytes: 11264
(defun App ()
    (let ((x (read))
        (kingaku 100))
        (setq kingaku (floor (* kingaku (rationalize 1.01))))
        (loop for i from 1
        do (progn
            (if (<= x kingaku)
                (progn
                (format t "~D~%" i)
                (return)
                )
                (setq kingaku (floor (* kingaku (rationalize 1.01))))
            )
        )
        )
    )
)

(App)

Measured memory_bytes: 24720
// 課題：Sという秒数が与えられたらh:m:sに変換して表示する

#include<iostream>

int main()
{   
    int sec,h,m,s;
    std::cin >> sec;

    h = int(sec/3600);
    m = int((sec-h*3600)/60);
    s = int((sec-h*3600-m*60));
    std::cout << h << ":" << m << ":" << s << std::endl;
    return 0;
}


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


int main() {
    string s,t;
    cin >> s >> t;
    cout << t+s << endl;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 3007;

double dp[N][N];

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    int n;
    cin >> n;
    vector <double> p(n);
    for (int i = 0; i < n; ++i) cin >> p[i];
    dp[0][0] = 1;
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= i; ++j) {
            if (j) dp[i][j] += p[i - 1] * dp[i - 1][j - 1];
            dp[i][j] += (1 - p[i - 1]) * dp[i - 1][j];
        }
    }
    double ans = 0;
    for (int i = n / 2 + 1; i <= n; ++i) {
        ans += dp[n][i];
    }
    cout << ans << '\n';
}

Measured memory_bytes: 69120
#include <bits/stdc++.h>
using namespace std;
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
constexpr i64 INF = 1010000000000000017LL;
constexpr i64 MOD = 1000000007LL;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))
template<typename T, typename U, typename Comp=less<>>
bool chmax(T& xmax, const U& x, Comp comp={}) {
    if(comp(xmax, x)) xmax = x; return true;
    return false;
}
template<typename T, typename U, typename Comp=less<>>
bool chmin(T& xmin, const U& x, Comp comp={}) {
    if(comp(x, xmin)) xmin = x; return true;
    return false;
}
template<typename Val>
bool bitcheck(Val bit, size_t idx) {
    return bit & (1 << idx);
}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;
    ProconInit() {
        cin.tie(nullptr); ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH) cout << unitbuf;
    }
} PROCON_INIT;

void solve() {
    ll k; cin >> k;
    string s; cin >> s;
    if (s.size() <= k) cout << s << endl;
    else {
        string ret = s.substr(0, k);
        cout << ret + "..." << endl;
    }
}

signed main() {
    solve();
    return 0;
}

Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

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

int main(void) {
  int n;
  std::cin >> n;
  std::vector<int> p(n), q(n);
  rep(i, n) std::cin >> p[i];
  rep(i, n) std::cin >> q[i];
  std::vector<int> a(n);
  rep(i, n) a[i] = i + 1;

  std::map<std::vector<int>, int> mp;

  do {
    mp[a] = mp.size();
  } while (std::next_permutation(a.begin(), a.end()));

  std::cout << std::abs(mp[p] - mp[q]) << std::endl;

  return 0;
}


Measured memory_bytes: 5248
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int d, a;
  char gomi;
  double x = 0, y = 0, p = 0;
  while (cin >> d >> gomi >> a, d) {
    x += d * sin(p * PI / 180.0);
    y += d * cos(p * PI / 180.0);
    p += a;
  }
  cout << (int) x << '\n'
       << (int) y << endl;
}

Measured memory_bytes: 3296
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U & u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U & u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B, C, X;
	cin >> N >> A >> B >> C >> X;
	while (N != 0) {
		vi Y(N);
		REP(i, N) {
			cin >> Y[i];
		}
		int cnt = 0;
		int ind = 0;
		while (cnt <= 10000) {
			if (Y[ind] == X) {
				ind++;
			}
			if (ind == N) {
				cout << cnt << endl;
				break;
			}
			cnt++;
			X = (A * X + B) % C;
		}
		if (cnt == 10001)cout << -1 << endl;
		cin >> N >> A >> B >> C >> X;
	}
	return 0;
}



Measured memory_bytes: 3124
#include <bits/stdc++.h>
using namespace std;
#define mod 998244353
#define MOD 1000000007
#define inf 0x3f3f3f3f
#define linf 0x3f3f3f3f3f3f3f3fll
typedef long long ll;
typedef pair<int,int> pii;
typedef unsigned long long ull;
const int maxn=5e5+10;
vector<pii> g[maxn];
map<pii,int> mp;
int cnode,n,m;
inline int getid(int sta,int cpn)
{
	if(!mp.count(make_pair(sta,cpn)))
		mp[make_pair(sta,cpn)]=cnode++;
	return mp[make_pair(sta,cpn)];
}
int dist[maxn];
priority_queue<pii,vector<pii>,greater<pii> > pq;
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++)
		getid(i,0);
	for(int i=0;i<m;i++)
	{
		int p,q,c;
		scanf("%d%d%d",&p,&q,&c);
		int u=getid(p,c),v=getid(q,c);
		g[u].push_back(make_pair(v,0));
		g[v].push_back(make_pair(u,0));
		int su=getid(p,0),sv=getid(q,0);
		g[u].push_back(make_pair(su,1));
		g[su].push_back(make_pair(u,0));
		g[v].push_back(make_pair(sv,1));
		g[sv].push_back(make_pair(v,0));
	}
	memset(dist,0x3f,sizeof(dist));
	int x=getid(1,0);
	dist[x]=0;
	pq.push(make_pair(0,x));
	int T=getid(n,0);
	while(!pq.empty())
	{
		x=pq.top().second;
		int d=pq.top().first;
		pq.pop();
		if(d!=dist[x])continue;
		if(x==T)
		{
			printf("%d\n",dist[x]);
			return 0;
		}
		for(int i=0;i<g[x].size();i++)
		{
			int to=g[x][i].first;
			if(dist[to]>d+g[x][i].second)
			{
				dist[to]=d+g[x][i].second;
				pq.push(make_pair(dist[to],to));
			}
		}
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 64376
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ATakahashiCalendar {
public:
    static constexpr int kStressIterations = 0;
    static void generateTest(std::ostream& test) {
    }

    void solve(std::istream& cin, std::ostream& cout) {
        int M, D;
        cin >> M >> D;
        int res = 0;
        FOR(m, 1, M) {
            FOR(d, 1, D) {
                int d1 = d % 10;
                int d2 = d / 10;
                if (d1 == 1 || d2 == 1) continue;
                if (d1 * d2 == m) res++;
            }
        }
        cout << res << endl;
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ATakahashiCalendar solver;
    solver.solve(in, out);
    return 0;
}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
using ll = long long;

int main() {
    string S;
    cin >> S;
    rep(i, S.size()) cout << "x";
    cout << endl;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
vector<int> g[100000];
pair<long long, long long> dfs(int cur, int par) {
  long long x = 1, y = 1;
  for (int nbr : g[cur]) {
    if (nbr == par) continue;
    pair<long long, long long> res = dfs(nbr, cur);
    x *= (res.first + res.second);
    y *= res.first;
    x %= mod;
    y %= mod;
  }
  return make_pair(x, y);
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i + 1 < n; i++) {
    int u, v;
    cin >> u >> v;
    u--; v--;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  pair<long long, long long> ans = dfs(0, -1);
  cout << (ans.first + ans.second) % mod << endl;
	return 0;
}


Measured memory_bytes: 12672
#include<bits/stdc++.h>
#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 all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
#ifdef _MSC_VER
inline unsigned int __builtin_popcount(unsigned int x) { return __popcnt(x); }
#endif // _MSC_VER
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int N;
string X;
int cnt[201010];
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> X;

	rep(i, 1, 201010) {
		int pp = __builtin_popcount(i);
		cnt[i] = cnt[i % pp] + 1;
	}

	reverse(all(X));

	int cn = 0;
	rep(i, 0, N) if (X[i] == '1') cn++;

	int tot1 = 0, p1 = 1;
	int tot2 = 0, p2 = 1;
	rep(i, 0, N) {
		if (X[i] == '1') {
			tot1 = (tot1 + p1) % (cn + 1);
			if (2 <= cn) tot2 = (tot2 + p2) % (cn - 1);
		}

		p1 = (p1 * 2) % (cn + 1);
		if (2 <= cn) p2 = (p2 * 2) % (cn - 1);
	}

	vector<int> ans;
	p1 = 1;
	p2 = 1;
	rep(i, 0, N) {
		if (X[i] == '1') {
			if (cn == 1) {
				ans.push_back(0);
			}
			else {
				int x = (tot2 - p2 + cn - 1) % (cn - 1);
				ans.push_back(cnt[x] + 1);
			}
		}
		else {
			int x = (tot1 + p1 + cn + 1) % (cn + 1);
			ans.push_back(cnt[x] + 1);
		}

		p1 = (p1 * 2) % (cn + 1);
		if (2 <= cn) p2 = (p2 * 2) % (cn - 1);
	}

	reverse(all(ans));
	rep(i, 0, N) printf("%d\n", ans[i]);
}







Measured memory_bytes: 5244
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#define _USE_MATH_DEFINES
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0,1,0,-1 };
const ll dy[4] = { -1, 0, 1,0 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
double mysqrt(double x) {
	double l = 0, r = x;
	for (int i = 0; i < 64; ++i) {
		double m = (l + r) / 2.0;
		if (m*m < x)l = m;
		else r = m;
	}
	return l;
}
///////////////////////////////////////


int main() {
	ll N, K; cin >> N >> K;
	ll A[2010];
	REP(i, N)cin >> A[i];
	ll cnt[2010];
	REP(i, N)cnt[i] = 0;
	REP(i, N) {
		REP(j, N) {
			if (A[i] > A[j]) {
				cnt[i]++;
			}
		}
	}
	ll ans = 0;
	ll key = 0;
	for (int i = 0; i < N; ++i) {
		for (int j=i + 1; j < N; ++j) {
			if (A[i] > A[j]) {
				key++;
			}
		}
	}
	key *= K;
	ans += key;
	ll sum = 0;
	REP(i, N)sum += cnt[i];
	ll x = K * (K - 1) / 2;
	x %= INF;
	sum *= x;
	ans += sum;
	ans %= INF;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N, X = list(map(int,input().split()))

l = [1]
p = [1]
for i in range(N):
    l.append(2*l[i] + 3)
    p.append(2*p[i] + 1)

def f(N, X):
    if N == 0 and X > 0:
        return 1
    elif N == 0 and X <= 0:
        return 0
    elif X <= l[N-1] + 1:
        return f(N-1, X-1)
    else: # X > l[N-1] + 2:
        return p[N-1] + f(N-1, X - 2 - l[N-1]) + 1
    #elif X == l[N-1] + 2:
    #    return p[N-1] + 1

print(f(N, X))    


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    int n,d,x;
    cin >> n >> d >> x;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 1; j < d+1; j += a) {
            ans++;
        }
    }
    cout << ans + x << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int a, b;
    std::cin >> a >> b;
    if (a < b) std::cout << "a < b" << std::endl;
    if (a > b) std::cout << "a > b" << std::endl;
    if (a == b) std::cout << "a == b" << std::endl;
    return 0;
}


Measured memory_bytes: 3084
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let v: Vec<f64> = (0..n).map(|_| iter.next().unwrap().parse().unwrap()).collect();
    let mut ans: f64 = 0.0;
    for x in v {
        ans += 1.0 / x;
    }
    println!("{}", 1.0 / ans);
}


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

int main()
{
    string s,t;
    cin >> s >> t;
    int n = (int)s.length();
    vector<vector<int>> dic(26);
    for(int i = 0; i < n; ++i)
    {
        char c = s[i];
        dic[c - 'a'].push_back(i);
    }
    for(int i = 0; i < n; ++i)
    {
        char c = s[i];
        dic[c - 'a'].push_back(i+n);
    }

    long long int ans = 0;
    int p = 0;
    for(int i = 0; i < (int)t.length(); ++i)
    {
        char c = t[i];
        if((int)dic[c-'a'].size() == 0)
        {
            cout << -1 << endl;
            return 0;
        }
        p = *lower_bound(dic[c-'a'].begin(),dic[c-'a'].end(),p)+1;
        if(p >= n)
        {
            p -= n;
            ans += n;
        }
    }
    ans += p;
    cout << ans << endl;
}

Measured memory_bytes: 1724
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<stdbool.h>
#include<set>
#define N 1000000007
using namespace std;
typedef long long ll;

int main(void) {
	int a, b;
	cin >> a >> b;
	if ((a + b) % 2 == 0)cout << (a + b) / 2 << endl;
	else cout << (a + b) / 2 + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
main(c){
	int p=0,n=0,r;
	for(;c=getchar(),~c;){
		if(c!=p){
			if(p=='1')
				putchar("',.!?"[n%5]);
			else if(p>='2'&&p<='9'){
				r=p=='7'||p=='9'?4:3;
				putchar("adgjmptw"[p-'2']+n%r+(n/r%2==1?'A'-'a':0));
			}
			if(c=='\n')
				putchar(c);
			p=c;
			n=0;
		}else{
			n++;
			if(c=='0'&&n>=1)
				putchar(' ');
		}
	}
	exit(0);
}

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

struct node {
    node* child[2];
    long long depth;
    bool end = false;
    node(long long d, bool isEnd) {
        child[0] = NULL; child[1] = NULL;
        depth = d;
        end = isEnd;
    }
};

int main() {
    int n; long long l; cin >> n >> l;
    node* root = new node(0, false);
    for (int i = 0; i < n; i++) {
        string s; cin >> s;
        node* cur = root;
        for (int j = 0; j < s.size(); j++) {
            int t = s[j] - '0';
            if (cur->child[t] == NULL) {
                cur->child[t] = new node(cur->depth+1, false);
            }
            cur = cur->child[t];
        }
        cur->end = true;
    }
    long long ret = 0;
    queue<node*> q; q.push(root);
    while (!q.empty()) {
        node* cur = q.front(); q.pop();
        if (cur->depth == l) continue;
        if (cur->end) continue;
        for (int i = 0; i < 2; i++) {
            if (cur->child[i] == NULL) {
                long long c = l - cur->depth;
                ret ^= (c & -c); 
            } else q.push(cur->child[i]);
        }
    }
    if (ret != 0) cout << "Alice" << endl;
    else cout << "Bob" << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef double ld;

vector<pair<ll,ll>> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}

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

#define MAX_N 100010
#define MAX_H 310
#define MAX_W 310
struct edge{ll to,cost;};
bool x[MAX_N];
ll num[MAX_N];

ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    
    return p;
}

ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}


vector<edge> G[MAX_N];
ll color[MAX_N];

bool dfs(ll v,ll p,ll c){
    color[v]=c;
    for (auto e: G[v]){
        if (e.to==p)continue;
        if (e.cost & 1)dfs(e.to,v,1-c);
        else dfs(e.to,v,c);
    }
    return true;
}

int main(){
    ll v;
    cin >> v;
    ll s,t,w;
    for (ll i=0;i<v-1;i++){
        cin >> s >> t >> w;
        s--;
        t--;
        G[s].push_back(edge{t,w});
        G[t].push_back(edge{s,w});
    }
    dfs(0LL,-1,1);
    for (ll i=0;i<v;i++){
        cout << color[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 11008
fn read() -> String {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).ok();
    buf
}

fn gcd(a: usize, b: usize) -> usize {
    let mut x = a;
    let mut y = b;
    while y != 0 {
        let tmp = y;
        y = x % y;
        x = tmp;
    }
    x
}

fn main() {
    let (n, m) = {
        let v: Vec<usize> = read()
            .split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect();
        (v[0], v[1])
    };
    let s: Vec<char> = read().trim().chars().collect();
    let t: Vec<char> = read().trim().chars().collect();

    let gcd = gcd(n, m);
    if (0..gcd).all(|i| s[n / gcd * i] == t[m / gcd * i]) {
        println!("{}", n * m / gcd);
    } else {
        println!("-1");
    }
}


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

int main()
{
	long long n, a, b; cin >> n >> a >> b;

	long long ans = 0;
	long long sum = a + b;
	long long mo;

	ans += n / sum * a;

	mo = n % sum;

	if (a < mo) {
		ans += a;
	}
	else {
		ans += mo;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256