akhauriyash/Code-Regression huggingface dataset:
///بِسْمِ الّٰلهِ الرَّحْمٰنِ الرَحِيْمِ
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi acos(-1.0)
int main()
{
     ios_base::sync_with_stdio(false);cin.tie(NULL);
     ll int i,n,t,j=0,p,x,a=0,b,l=0,r=0,y,k,c,sum=0,m,d;
     cin>>n;
     for(i=1;i<n;i++){
        for(j=1;j*i<n;j++){
            l++;
        }
     }cout<<l<<endl;

     return EXIT_SUCCESS;
}


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

using namespace std;

int main() {
   ios::sync_with_stdio(false);
   cin.tie(0);
   int n;
   cin >> n;
   long long zmi = 1e18, wmi = 1e18;
   long long zma = -1e18, wma = -1e18;
   for(int i = 0; i < n; i++) {
       long long foo, bar;
       cin >> foo >> bar;
       zmi = min(zmi, foo + bar);
       zma = max(zma, foo + bar);
       wmi = min(wmi, foo - bar);
       wma = max(wma, foo - bar);
   }
   long long ans = max(zma - zmi, wma - wmi);
   cout << ans << endl;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main(){
  while(1){
	int n,x;
	cin >> n >> x;
	if(n==0 && x==0) break;

	int ans = 0;
	for(int a=1; a<=n; a++)
	  for(int b=a+1; b<=n; b++)
	    for(int c=b+1; c<=n; c++){
		if(a+b+c == x) ans++;
	    }
	cout << ans << endl;
  }
  return 0; 
}


Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい
// https://github.com/atcoder/live_library
// cppdbg: test.exeのterminalに標準入力を打てる

#define ALL(x) x.begin(),x.end()
#define get_tp(t,i) get<i>(t)
#define len(x) (ll)(x.size())
#define ub(a,x) (upper_bound(ALL(a),x)-a.begin())
#define lb(a,x) (lower_bound(ALL(a),x)-a.begin())
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef pair<long long,long long> pllll; //pair<ll,ll>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>
typedef priority_queue<ll, vector<ll>, greater<ll> > gpq; //逆順priority_queue
typedef priority_queue<ll> pq;

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const long double PI=3.1415926535897932;

int main(){
    ll W,H,x,y;cin>>W>>H>>x>>y;
    cout<<setprecision(10)<<W*H/2.0<<" ";
    cout<<((x*2==W && y*2==H)?1:0);
    cout<<endl;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define ll long long
#define mx 1000025
using namespace std;
//bool a[mx];
//ll prime[mx], j;
//void seive()
//{
//    ll i;
//    for(i = 2; i * i <= mx; i++)
//    {
//        if(!a[i])
//        {
//            for(ll j = i * i; j <= mx; j+=i)
//            {
//                a[j] = 1;
//            }
//        }
//    }
//    for(i = 2; i <= mx; i++)
//    {
//        if(!a[i])prime[j++] = i;
//    }
//}
bool is_prime(ll n)
{
    for(ll i = 2; i * i <= n; i++)
    {
        if(n%i==0)return 0;
    }
    return 1;
}
ll inf = 1e18;
int main()
{
    ll n, res = inf;
    cin>>n;
    if(is_prime(n)){cout<<n-1<<endl;return 0;}
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            ll d = n/i;
            res = min(res, ((d-1)+(i-1)));
        }
    }
    cout<<res<<endl;
}


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

using namespace std;

using ll = long long int;

#define REP(i, N) for (int i = 0; i < (N); ++i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(N);
    scanInt(A);
    if (N % 500 <= A){
        puts("Yes");
    }else{
        puts("No");
    }
}


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


void solve(std::string S){
    int ans = 0;
    REP(i, S.size() / 2){
        ans += S.at(i) != S.at(S.size() - 1 - i);
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


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

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int K=scan.nextInt();
		String S=scan.next();
		int S_length=S.length();
		if(K<S_length) {
			for(int i=0;i<K;i++) {
				System.out.print(S.charAt(i));
			}
			System.out.print("...");
		}
		else {
			System.out.print(S);
		}

	}

}

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

//使い方がよくわからない
#include<stack>
#include<queue>
#include<bitset>
#include<sstream>

#define rep(i,n) for(int i=0;i<(n);i++) 
#define rep1(i,n) for(int i=1;i<(n);i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "

using namespace std;
using ll = long long;

int main(int argc, const char *argv[]){
    ll n;
    cin >> n;
    ll o = ll(sqrt(n));
    for(ll i=o;i>0;i--){
        if(n%i==0){
            co(i+n/i-2);
            return 0;
        }
    }
    co(n-1);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

using namespace std;
using ll = long long;

int main(){
    ll n,a,b;
    cin>>n>>a>>b;
    ll ans;
    if(n < a+b) ans = min(n,a);
    else if(n % (a+b) == 0) ans = (n / (a+b)) * a;
    else ans = (n / (a+b)) * a + min(n % (a+b),a);

    cout<<ans<<endl;
}

Measured memory_bytes: 384
x = int(input())
if x <= 599:
    print(8)
elif x <= 799:
    print(7)
elif x <= 999:
    print(6)
elif x <= 1199:
    print(5)
elif x <= 1399:
    print(4)
elif x <= 1599:
    print(3)
elif x <= 1799:
    print(2)
else:
    print(1)

Measured memory_bytes: 9176
#include <queue>
#include<iostream>
using namespace std;
int n,a,s[2];
priority_queue<int> q;
int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a,q.push(a);
    for(int i=1;i<=n;i++){a=q.top();q.pop();s[i&1]+=a;}
    cout<<s[1]-s[0];
    return 0;
}


Measured memory_bytes: 256
## abc070d: Transit Tree Path
import sys
from collections import deque
input = sys.stdin.readline

n = int(input())

T = [{} for _ in range(n)]
for _ in range(n-1):
    v1,v2,d = map(int, input().split())
    v1,v2 = v1-1,v2-1
    T[v1][v2] = d
    T[v2][v1] = d

q,k = map(int, input().split())

depth = [-1]*n
que = deque()
que.append(k-1)
while que:
    p = que.popleft()
    if depth[p]<0: depth[p] = 0
    for c in T[p].keys():
        if depth[c]>=0: continue
        depth[c] = depth[p] + T[p][c]
        que.append(c)

for _ in range(q):
    v1,v2 = map(int, input().split())
    print(depth[v1-1]+depth[v2-1])

Measured memory_bytes: 52320
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

int n, m;
struct edge{
    int from, to, cost;
};

bool cmp(const edge& e1, const edge& e2){
//    if(p1.first == p2.first) return p1.second > p2.second;
   return e1.cost < e2.cost;
}

struct UF{
   vector<int> par;
   vector<int> sz;
   UF(){}
   UF(int n){
       par.resize(n);
       sz.resize(n, 1);
       rep(i, 0, n) par[i] = i;
   }
   int find(int x){
       if(x == par[x]) return x;
       return par[x] = find(par[x]);
   }
   void unite(int x, int y){
       x = find(x); y = find(y);
       if(x == y) return;
       if(sz[x] < sz[y]) swap(x, y);
       sz[x] += sz[y];
       par[y] = x;
   }
   bool same(int x, int y){
       return find(x) == find(y);
   }
};

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin >> n >> m){
        if(n == 0 && m == 0) break;
        vector<edge> es;
        rep(i, 0, m){
            int s, t, c;
            cin >> s >> t >> c;
            s--; t--;
            es.push_back((edge){s, t, c});
        }
        sort(all(es), cmp);
        int ans = INF;
        rep(i, 0, m){
            int MAX = -1;
            UF uf(n);
            rep(j, i, m){
                int s = es[j].from;
                int t = es[j].to;
                if(uf.same(s, t) == false){
                    uf.unite(s, t);
                    chmax(MAX, es[j].cost);
                }
            }
            // cout << i << " " << es[i].cost << " " << MAX << endl;            
            rep(j, 0, n){
                if(uf.same(0, j) == false) MAX = -1;
            }
            if(MAX != -1){
                // cout << i << " " << es[i].cost << " " << MAX << endl;
                chmin(ans, MAX - es[i].cost);
            }
        }
        if(ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }
}


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    string S;
    ll K;
    cin >> S;
    cin >> K;
    ll n = S.size();

    bool flag = true;
    REP(i, n - 1)
    {
        if (S[i] != S[i + 1])
        {
            flag = false;
            break;
        }
    }
    if (flag)
    {
        ll count = n * K;
        cout << count / 2 << endl;
        return 0;
    }

    ll countMono = 0;
    ll countSame = 1;
    for (ll i = 0; i < n - 1; ++i)
    {
        if (S[i] == S[i + 1])
        {
            countSame++;
        }
        else
        {
            countMono += countSame / 2;
            countSame = 1;
        }
    }
    countMono += countSame / 2;

    ll ans = 0;
    if (S[0] != S[n - 1])
    {
        ans = countMono * K;
    }
    else
    {
        ll countSameHead = 1;
        for (ll i = 0; i < n - 1; ++i)
        {
            if (S[i] == S[i + 1])
            {
                countSameHead++;
            }
            else
            {
                break;
            }
        }
        ll countSameTail = 1;
        for (ll i = n - 1; n > 1; --i)
        {
            if (S[i] == S[i - 1])
            {
                countSameTail++;
            }
            else
            {
                break;
            }
        }
        ans = countMono * K;
        ans -= (countSameHead / 2 + countSameTail / 2 - (countSameHead + countSameTail) / 2) * (K - 1);
    }
    

    cout << ans << endl;
}


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

using namespace std;

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

#define int ll

const ll mod = 1e9 + 7;


main(){
	ll x,k,d;

	cin >> x >> k >> d;

	if(x>=0){
		if(x/d>k){
			cout << x - d*k << endl;
		}else{
			if(k%2 == (x/d)%2){
				cout << x%d << endl;
			}else{
				cout << d - x%d << endl;
			}
		}
	}else{
		if(-x/d>k){
			cout << abs(x + d*k) << endl;
		}else{
			if(k%2 == (-x/d)%2){
				cout << (-x)%d << endl;
			}else{
				cout << d - (-x)%d << endl;
			}
		}
	}

	


	return 0;
}


Measured memory_bytes: 3668
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#include <time.h>
#include <chrono>
#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define REP(i,a,b) for(ll i=a;i>b;i--)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define repl(i,l,r) for(int i=(1);i<(r);i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 998244353;
const ll INF = (1LL << 31) - 1;
const ll mod = 1e9 + 7;



ll N;
ll M[200005];
ll ans[200005];
ll bitcnt;
string S;
ll num;


int init(int k) {
	if (M[k] != -1) {
		return M[k];
	}
	else {
		int cnt = __builtin_popcount(k);
		M[k] = 1 + init(k%cnt);
		return M[k];
	}
}


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

	FOR(i, 0, 200001)M[i] = -1;
	M[0] = 0;
	M[1] = 1;
	M[2] = 1;
	FOR(i, 3, 200001) {
		init(i);
	}


	cin >> N;
	cin >> S;
	FOR(i, 0, N) {
		if (S[N-1-i] == '1') {
			bitcnt++;
		}
	}


	ll bp = 1, bm = 1;

	ll modNp = 0;
	ll modNm = 0;

	FOR(i, 0, N) {
		if (S[N - 1 - i] == '1') {
			modNp = (modNp+bp) % (bitcnt + 1);
			if(bitcnt>1)modNm = (modNm+ bm) % (bitcnt - 1);
		}
		bp = (bp * 2) % (bitcnt + 1);
		if(bitcnt>1)bm = (bm * 2) % (bitcnt - 1);
	}

	bp = 1, bm = 1;
	FOR(i, 0, N) {
		ll cur = 0;
		if (S[N - 1 - i] == '1') {
			if (bitcnt == 1) {
				ans[N - 1 - i] = 0;
				continue;
			}
			cur = (modNm - bm + bitcnt - 1)%(bitcnt-1);
		}
		else {
			cur = (modNp + bp+ bitcnt + 1)%(bitcnt+1);
		}

		ans[N - 1 - i] = M[cur]+1;


		bp = (bp * 2) % (bitcnt + 1);
		if(bitcnt>1)bm = (bm * 2) % (bitcnt - 1);
	}


	FOR(i, 0, N)cout << ans[i] << endl;


}

Measured memory_bytes: 6848
#include <iomanip>
#include <iostream>
#include <string>

using namespace std;

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

    double sum = 0;
    for (int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;

        if (u == "JPY") {
            sum += x;
        } else {
            sum += 380000 * x;
        }
    }

    cout << setprecision(12) << fixed << sum << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 1000000000000000000LL
#define rep(i,x) for(int (i)=1;(i)<=(x);(i)++)
#define repp(i,x,y) for(int (i)=(x);(i)<=(y);(i)++)
#define forn(i,x) for(int (i)=0;(i)<(x);(i)++)
#define foreach(i,x) for(auto (i):(x))
using namespace std;
typedef pair<int,int>pii;
int v[100010],d[100010],col[100010];
int mx[100010],qq[100010],ans[100010];
int n,m,p;
vector<int>G[100010];
void go(int inp){
	int x=v[inp],dd=d[inp],cc=col[inp];
	if(dd<=mx[x])return;
	mx[x]=dd;
	qq[0]=x;
	int rr=1;
	for(int i=0;i<rr;i++){
		int x=qq[i];
		if(!ans[x])ans[x]=cc;
		if(!mx[x])continue;
		for(auto to:G[x]){
			int nxt=mx[x]-1;
			if(nxt>mx[to]){
				mx[to]=nxt;
				qq[rr++]=to;
			}
		}
	}
}
int main(){
	memset(mx,-1,sizeof(mx));
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		G[x].pb(y);
		G[y].pb(x);
	}
	cin>>p;
	for(int i=0;i<p;i++)cin>>v[i]>>d[i]>>col[i],v[i]--;
	for(int i=p-1;i>=0;i--)go(i);
	for(int i=0;i<n;i++)cout<<ans[i]<<endl;
	return 0;
}


Measured memory_bytes: 9856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int main(){
    ll n; cin>>n;
    vector<string> res={"a"};
    rep(i,n-1){
        vector<string> res_tmp={};
        for(string s:res){
            char c='a';
            rep(j,s.size()){
                if(c<s[j]) c=s[j];
            }
            for(char next='a'; next<=c+1; next++){
                res_tmp.push_back(s+next);
            }
        }
        res=res_tmp;
    }
    for(string s:res){
        cout<<s<<endl;
    }
}

Measured memory_bytes: 10908
from collections import defaultdict as dd
n, m = map(int, input().split())
Ways = dd(set)
for i in range(m):
    a, b = map(int, input().split())
    Ways[a].add(b)
    Ways[b].add(a)

visited = set([1])
Ans = [0] * (n+1)
stack = [1]
while stack != [] and len(visited) != n:
    temp = []
    for room in stack:
        for next_room in list(Ways[room] - visited):
            Ans[next_room] = room
            visited.add(next_room)
            temp.append(next_room)
    stack = temp

print("Yes")
for i in range(2, n+1):
    print(Ans[i])

Measured memory_bytes: 158920
#include<stdio.h>

int main()
{
    long long int n,i,ans=0,sum=0,mod=1000000007;
    scanf("%lld",&n);

    long long int a[n];

    for(i=0;i<n;i++)
    {
        scanf("%lld",&a[i]);

        sum=(sum+a[i])%mod;
    }

    for(i=0;i<n;i++)
    {
        sum=sum-a[i];

        if(sum<0)sum+=mod;

        ans = (ans +(a[i] * sum) ) % mod;
    }

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

}


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

int main(){
    int a,b;
    while(cin >> a >> b) {
        int c = a + b;
        int res = 1;
        while (c >= 10) {
            res++;
            c = c / 10;
        }
        cout << res << endl;
    }
    return 0;
}

Measured memory_bytes: 3000
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
struct UnionFind{
	vector<int> par;
	UnionFind(int N){
		par.assign(N,0);
		rep(i,N) par[i]=i;
	}
	int find(int x){
		if(par[x]==x) return x;
		return par[x]=find(par[x]);
	}
	bool same(int x,int y){
		return find(x)==find(y);
	}
	void unite(int x,int y){
		x=find(x),y=find(y);
		if(x==y) return;
		par[y]=x;
	}
};
struct Block{
	ll z,o;
	int v;
	Block(ll z,ll o,int v):z(z),o(o),v(v){}
	bool operator<(const Block& r) const {
		if(z*r.o == r.z*o) return v<r.v;
		return z*r.o > r.z*o;
	}
};

int main(){
	int N;
	cin>>N;
	V<int> p(N);
	rep1(i,N-1) cin>>p[i],p[i]--;
	p[0] = N;

	set<Block> blocks;
	V<Block> v2block;

	rep(i,N){
		int c;
		cin>>c;
		blocks.insert(Block(1-c,c,i));
		v2block.pb(Block(1-c,c,i));
	}
	UnionFind UF(N+1);

	ll ans = 0;
	ll sum1 = 0;
	rep(_,N){
//		cerr << " -------------- " << endl;
		Block b = *blocks.begin();
		blocks.erase(b);
		int r = UF.find(b.v);
		if(UF.find(p[r]) == N){
			ans += sum1 * b.z;
			sum1 += b.o;
//			cerr << "taken: " << "(" << b.z << "," << b.o << ")" << endl;
//			cerr << "contain: ";
//			rep(v,N) if(UF.find(v) == r) cerr<<v<<" ";
//			cerr<<endl;
		}else{
			int x = UF.find(p[r]);
			Block xb = v2block[x];
			blocks.erase(xb);
			ans += xb.o * b.z;
			Block nb(b.z+xb.z,b.o+xb.o,x);
			v2block[x] = nb;
			blocks.insert(nb);
		}
		UF.unite(p[r],r);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 20268
def main():
    from operator import itemgetter
    import sys
    input = sys.stdin.readline

    H, W, M = map(int, input().split())

    rows = [0] * H
    cols = [0] * W
    ps = set()
    for _ in range(M):
        r, c = (int(x) - 1 for x in input().split())
        rows[r] += 1
        cols[c] += 1
        ps.add((r, c))

    erows = sorted(enumerate(rows), key=itemgetter(1), reverse=True)
    ecols = sorted(enumerate(cols), key=itemgetter(1), reverse=True)

    ans = 0
    for r, cnt_r in erows:
        for c, cnt_c in ecols:
            s = cnt_r + cnt_c
            if ans >= s:
                break
            cond = (r, c) in ps
            ans = max(ans, s - int(cond))

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 173092
k = int(input())

def next(s):
	n = len(s)
	ind_to_check = n-1
	while ind_to_check != 0 and s[ind_to_check] == 9 or s[ind_to_check] - s[ind_to_check-1] == 1:
		ind_to_check -= 1

	if ind_to_check == 0 and s[ind_to_check] == 9:
		s = [1] + [0]*n
	else:
		s[ind_to_check] += 1
		for j in range(ind_to_check+1, n):
			s[j] = max(0, s[j-1] - 1)

	return s


s = [1]
for i in range(k-1):
	# print(s)
	s = next(s)

print("".join([str(item) for item in s]))


Measured memory_bytes: 43228
int D(const void *a, const void *b){return *(int*)b-*(int*)a;}
c[100];main(A,a,C,n,i,x,r,s){scanf("%d%d%d%d",&n,&A,&a,&C);for(i=0;i<n;i++)scanf("%d",c+i);qsort(c,n,4,D);for(r=C/A,x=i=0;i<n;i++){x+=c[i];s=(C+x)/(A+a*(i+1));if(s<r)break;r=s;}printf("%d\n",r);return 0;}

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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll A, V; cin >> A >> V;
  ll B, W; cin >> B >> W;
  ll T; cin >> T;
  if(A == B){
    cout << "YES" << endl;
    return 0;
  }
  if(V <= W){
    cout << "NO" << endl;
    return 0;
  }
  if(A < B){
    if(T*V+A >= T*W+B){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }else{
    if(A-T*V <= B-T*W){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
  }
}

Measured memory_bytes: 3640
///
//  Author : Author
// Created On : Mon Dec 18 2017
//  File : c.cpp
//
#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

int32_t main() {
  uint64_t N, M;
  cin >> N >> M;

  cout << (1900 * M + 100 * (N - M)) * pow(2, M) << endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;


    class Program
    {
        public int gcd(int a, int b)
          {
              if(b == 0){
                  return a;
              }
              return gcd(b, a % b);
          }
        
        static void Main(string[] args)
        {
          
          int Input = int.Parse(Console.ReadLine());
          long sum = 0;
          
          var p = new Program();
          
          for(int i = 1; i <= Input; i++){
              for(int j = 1; j <= Input; j++){
                for(int k = 1; k <= Input; k++){
                  int a = p.gcd(i,j);
                  int b = p.gcd(a,k);
                  sum += b;
                }
              }
          }
            Console.WriteLine(sum);
        }
    }



Measured memory_bytes: 17608
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
	static ArrayList<Integer>[] g;
	static int n;
	static int[] deg;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		g = new ArrayList[n];
		deg = new int[n];
		for (int i = 0; i < n; ++i) {
			g[i] = new ArrayList<>();
		}
		for (int i = 1; i < n; ++i) {
			int a = sc.nextInt() - 1;
			g[a].add(i);
			g[i].add(a);
		}
		dfs(0, -1);
		System.out.println(deg[0]);
	}

	static void dfs(int cur, int par) {
		if(cur!=0&&g[cur].size()==1){
			deg[cur]=0;
			return;
		}else if(g[cur].size()==0){
			deg[cur]=0;
			return;
		}
		ArrayList<Integer> v = new ArrayList<>();
		for (int dst : g[cur]) {
			if (dst == par)
				continue;
			dfs(dst, cur);
			v.add(deg[dst]);
		}
		Collections.sort(v, new Comparator<Integer>() {
			@Override
			public int compare(Integer o1, Integer o2) {
				return -Integer.compare(o1, o2);
			}
		});
		int max = 0;
		for (int i = 0; i < v.size(); ++i) {
			max = Math.max(max, i + v.get(i));
		}
		deg[cur] = max + 1;
	}

}


Measured memory_bytes: 82320
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n); for (int i=0; i<(n); i++)//第一引数の変数をカウンタ変数としてn回回す
using veci = vector<int>;
using vecl = vector<long long>;
using vecd = vector<double>;
using vecs = vector<string>;
int main(){//まず角度を計算し、それの差を絶対値付きでcos関数に渡し、余弦定理で長さの二乗を
  //求めた後、それの平方根を取り、printf関数で出力する
  int a, b, h, m;
  cin >> a >> b >> h >> m;
  double pi = 3.14159265358979323846;
  double alpha = (((30*h)+ (0.5 * m))*pi)/180;
  double beta = ((6*m)*pi)/180;
  double g = abs(beta - alpha);
  double c = cos(g);
  double ans = (a*a) + (b*b) - (2*a*b)*c;
  printf("%.9f", sqrt(ans));
}

Measured memory_bytes: 4156
#include<iostream>
#include<vector>
#include<algorithm>
#define ll long long 
using namespace std;
int main(){
	ll N;
	cin >> N;
	vector<ll> A(N),dum(N);
	for (ll i = 0; i < N; i++){
		cin >> A[i];
		dum[i] = A[i];
	}
	sort(A.begin(), A.end());
	for (ll i = 0; i < N; i++){
		if (dum[i] == A[N - 1]){
			cout << A[N - 2] << endl;
		}
		else cout << A[N - 1] << endl;
	}
	return 0;
}

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

int n, m;
vector<vector<int>> graph(8);
int dfs(int vertex,int count,int arrived){
  arrived += 1 << vertex;
  //cout << "arrived=" << arrived << " count=" << count << " vertex="<<vertex<<endl;
  if(count==n-1){
    bool flg = true;
    for (int i = 0; i < n;i++){
      if(arrived>>i&0){
        flg = false;
      }
    }
    if(flg){
      return 1;
    }else{
      return 0;
    }
  }
  int sum = 0;
  for (int i = 0; i < graph[vertex].size();i++){
    //cout << "graph="<<graph[vertex][i] << endl;
    if(((arrived>>graph[vertex][i])&1)==0){
      sum += dfs(graph[vertex][i], count + 1, arrived);
    }
  }
  return sum;
}

int main(){
  cin >> n >> m;
  for (int i = 0; i < m;i++){
    int a,b;
    cin >> a>>b;
    a--;
    b--;
    graph[a].emplace_back(b);
    graph[b].emplace_back(a);
  }
  cout << dfs(0, 0, 0) << endl;
  return 0;
}

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

namespace ConsoleApplication4
{
    class Program
    {
        static void Main(string[] args)
        {
            string W = Console.ReadLine();
            int count = 0;
            while (true)
            {
                string[] T = Console.ReadLine().Split(' ');
                if (T[0].Equals("END_OF_TEXT"))
                    break;
                for (int i = 0; i < T.Length; i++)
                {
                    if (string.Equals(W, T[i], StringComparison.OrdinalIgnoreCase)) 
                    count = count + 1;

                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 9140
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
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;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int q;
	cin>>q;
	while(q--){
		int n;
		cin>>n;
		vi in(n);
		rep(i,n)cin>>in[i];
		if(n<=2){
			cout<<in[n-1]<<endl;
			continue;
		}
		vvi dp(n+1,vi(400,-inf));
		dp[1][in[1]]=in[0];
		loop(i,1,n-1)rep(j,400)if(dp[i][j]+inf){
			cmax(dp[i+1][in[i+1]],j);
			if(j)cmax(dp[i+1][in[i+1]+dp[i][j]],j-1);
		}
		int out=0;
		rep(i,400)if(dp[n-1][i]+inf)out=max(out,i);
		cout<<out<<endl;
	}
}







Measured memory_bytes: 3216
def solve(a,b,c):
    return a + b + c - 3 * min([a,b,c])

a, b, c = map(int, raw_input().split())

ans = 1 << 30

for i in range(50):
    for j in range(50):
        for k in range(50):
            ans = min(ans, i + j + k + solve(a+i*2,b+j*2,c+k*2))

print ans

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

using namespace std;

typedef long long ll;
typedef pair <int,int> P;
typedef pair <P,P> PP;
typedef pair <int,PP> PPP;

static const double eps = 1e-8;

int main(){

	int b,r,g,c,s,t;
	while(~scanf("%d %d %d %d %d %d",&b,&r,&g,&c,&s,&t)){
		if(b==r && r==g && g==c && c==s && s==t && t==0) break;
		int big = -3 * b + 15 * b + (15 - 2) * b * 5;
		int bar = -3 * r + 15 * r + (15 - 2) * r * 3;
		int sum = 100 + big + bar -3 * g + 7 * g + (-3 * c + 2 * c) + (-3 * s)
			-3 * (t-(b+b*5)-(r+r*3)-g-c-(s*2));
		cout << sum << endl;
	}
}

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

int main() {
  int A1, A2, A3;
  cin >> A1 >> A2 >> A3;
  
  if ((A1 + A2 + A3) >= 22) {
    cout << "bust" << endl;
  } else {
    cout << "win" << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    char s[2000];
    cin>>s;
    int l=strlen(s);

    if(s[l-1]=='s')
       {
            cout<<s<<"es"<<endl;

       }
    else
    {
       cout<<s<<"s"<<endl;
    }

    return 0;
}


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

vector<string>ans;
string cur = "";
int n;

void solve(char c,int idx,char mx)
{
	if(idx==n-1){
		cur += c;
		ans.push_back(cur);
		cur.pop_back();
		return;
	}
	cur += c;
	for(char i='a';i<=mx+1;i++){
		solve(i,idx+1,max(mx,i));
	}
	cur.pop_back();
}
int main()
{
	cin >> n;
	solve('a',0,'a');
	sort(ans.begin(),ans.end());
	for(auto it:ans){
		cout << it << "\n";
	}
}


Measured memory_bytes: 7432
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        sc.close();
        int n = s.length();

        boolean[] stone = new boolean[s.length()];
        for(int i=0; i<s.length(); i++){
            if(s.charAt(i) == 'B'){
                stone[i] = true;
            }else{
                stone[i] = false;
            }
        }

        long ans = 0;
        for(int i=0; i<n; i++){
            if(stone[i]){
                long wnum = 0;
                for(int j=i+1; j<n; j++){
                    if(!stone[j]) wnum++;
                }
                for(int j=i+1; j<n; j++){
                    if(!stone[j]) ans += j-i;
                }
                if(wnum > 0) ans -= (wnum-1) * (wnum) / 2; 
                break;
            }
        }

        System.out.println(ans);
    }
}

Measured memory_bytes: 28100
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;


const int INF = 10000000;
const long long INFL = (1LL<<40);
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}

template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};



int main() {
    int n;cin>>n;vector<string>w(n);cin>>w;
    char moji = w[0][w[0].size()-1];
    set<string> st;
    st.insert(w[0]);
    repsg(i,1,n){
        if((moji != w[i][0]) || (st.count(w[i])==1)) {cout<<"No"<<endl; return 0;}
        moji = w[i][w[i].size()-1];
        st.insert(w[i]);
    }
    cout<<"Yes"<<endl;
    return 0;
}





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

int main(){
    string s;
    cin >> s;

    int now = 0;
    int maxd = 0;
    for(int i = 0; i < s.length(); i++){
        if (s[i] == 'S'){
            now = 0;
        }
        else{
            now++;
            maxd = max(maxd, now);
        }
    }
    cout << maxd << endl;
    return 0;
}

Measured memory_bytes: 3232
D, G = map(int, input().split())
S = [[0] for i in range(D + 1)]
B = [[0] for i in range(D + 1)]
sumP = 0
for i in range(D):
  p, c = map(int, input().split())
  S[i + 1] += [0] * (len(S[i]) + p - 1)
  B[i + 1] += [100 * (i + 1) * (x + 1) for x in range(p)]
  B[i + 1][-1] += c
for i in range(1, D + 1):
  for j in range(1, len(S[i])):
    for k in range(max(j - len(S[i - 1]) + 1, 0), min(len(B[i]), j + 1)):
      S[i][j] = max(B[i][k] + S[i - 1][j - k], S[i][j])
for i, s in enumerate(S[D]):
  if s >= G:
    print(i)
    break

Measured memory_bytes: 3316
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

string s;

int main()
{
    cin >> s;
    string t = "keyence";

    ll ans = 0;
    for (int i = 0; i < s.size(); i++)
    {
        for (int j = i; j < s.size() + 1; j++)
        {
            string ss = "";
            int cnt = 0;
            for (int k = 0; k < s.size(); k++)
            {
                if (k >= i && k < j)
                {
                    continue;
                }
                ss += s[k];
                cnt++;
            }
            if (ss == t)
            {
                cout << "YES" << endl;
                return 0;
            }
        }
    }
    cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "iomanip"
#include "cmath"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;
vector<bool>used;
vector<vector<pair<int, long long int>>>edge;

long long int flow(int v, int g, long long int f) {
	if (v == g) {
		return f;
	}
	used[v] = true;
	for (auto i = edge[v].begin(); i != edge[v].end(); ++i) {
		if (!used[(*i).first] && (*i).second > 0) {
			long long int box = flow((*i).first, g, min(f, (*i).second));
			if (box > 0) {
				(*i).second -= box;
				for (auto j = edge[(*i).first].begin(); j != edge[(*i).first].end(); ++j) {
					if ((*j).first == v) {
						(*j).second += box;
					}
				}
				return box;
			}
		}
	}
	return 0;
}

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

	cin >> N;
	edge.resize(N + 2);
	vector<int>num(N + 1);
	used.resize(N + 2);
	long long int ans = 0;
	for (int i = 1; i <= N; i++) {
		cin >> num[i];
		if (num[i] > 0) {
			ans += num[i];
			edge[i].push_back({ N + 1,num[i] });
			edge[N + 1].push_back({ i,0 });
		}
		else {
			edge[0].push_back({ i,-num[i] });
			edge[i].push_back({ 0,0 });
		}
		for (int j = i + i; j <= N; j += i) {
			edge[i].push_back({ j,LLONG_MAX / 2000 });
			edge[j].push_back({ i,0 });
		}
	}
	long long int bag = 0;
	while (1) {
		bag = flow(0, N + 1, LLONG_MAX);
		if (!bag) {
			break;
		}
		ans -= bag;
		for (int i = 0; i <= N + 1; i++) {
			used[i] = false;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
map<ll, ll> factorize(ll n){
  map<ll, ll> factor;
  while(n%2==0){
    ++factor[2];
    n >>= 1;
  }
  for(ll i = 3; i*i <= n; i += 2){
    while(n%i==0){
      ++factor[i];
      n /= i;
    }
  }
  if (n > 2)
    ++factor[n];
  return factor;
}
int main(){
  ll n;
  cin >> n;
  int cnt = 0;
  for(auto [x, y] : factorize(n)){
    ll z = x;
    while(n%z == 0){
      ++cnt;
      n /= z;
      z *= x;
    }
  }
  cout << cnt << '\n';
  return 0;
}

Measured memory_bytes: 3604
def main():
    from math import gcd

    K = int(input())

    result = 0
    for a in range(1, K + 1):
        for b in range(1, K + 1):
            t = gcd(a, b)
            for c in range(1, K + 1):
                result += gcd(t, c)
    print(result)


main()

Measured memory_bytes: 9120
while a = gets 
    b = gets
    a = a.split(" ")
    b = b.split(" ")
    hit = 0
    blow = 0
    for i in 0..3 do
        if a[i] == b[i]
            hit += 1
        else
            for j in 0..3 do
                if a[i] == b[j]
                blow += 1
                break
                end
            end
        end
    end
    puts hit.to_s + " " + blow.to_s
end



Measured memory_bytes: 6828
class Vertex:
    def __init__(self, p):
        self.p = p
        self.r = 0


class Edge:
    def __init__(self, s, t, w):
        self.s = s
        self.t = t
        self.w = w


def union(x, y):
    x = findSet(x)
    y = findSet(y)
    link(x, y)


def link(x, y):
    if V[x].r > V[y].r:
        V[y].p = x

    else:
        V[x].p = y
        if V[x].r == V[y].r: V[y].r = V[y].r + 1


def findSet(x):
    if x != V[x].p:
        V[x].p = findSet(V[x].p)

    return V[x].p


def same(x, y):
    return findSet(x) == findSet(y)



if __name__ == '__main__':
    n_V, n_E = map(int, input().split())

    #
    V = []
    for i in range(n_V):
        V.append(Vertex(i))

    #
    E = []
    for _ in range(n_E):
        s, t, w = map(int, input().split())
        E.append(Edge(s, t, w))

    #
    E.sort(key=lambda e : e.w)

    #
    sum_w = 0
    for e in E:
        if not same(e.s, e.t):
            union(e.s, e.t)
            sum_w += e.w

    print(sum_w)



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

int a[3];

int main(){
    int n,m; cin >> n >> m;
    bool na=false;
    for(int i=0;i<m;i++){
        int s,c; cin >> s >> c; s--;
        if(n!=1 && s==0 && c==0) na=true;
        if(a[s]!=0 && a[s]!=c) na=true;
        else a[s]=c;
    }
    if(n!=1 && a[0]==0) a[0]=1;
    if(na){
        cout << -1;
    }else{
        for(int i=0;i<n;i++){
            cout << a[i];
        }
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#define formula(a,b) a*a*a*a + a*a*a*b + a*a*b*b + a*b*b*b + b*b*b*b

using namespace std;

int main(void)
{
  int X, a, b1, b2;
  
  cin >> X;
  
  for(a=0;;++a)
  {
    for(b1=b2=0;b1<a;++b1,--b2)
    {
      if(X%(a-b1) == 0)
      {
      	if((X/(a-b1)) == formula(a,b1))
        {    
          printf("%d %d", a, b1, formula(a,b1));
          return 0;
        }
      }
      if(X%(a-b2) == 0)
      {
        if((X/(a-b2)) == formula(a,b2))
        {    
          printf("%d %d", a, b2, formula(a,b2));
          return 0;
        }
      }
    }
  }
  return 0;
}


Measured memory_bytes: 3588
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N):
    alp = 'abcdefghijklmnopqrstuvwxyz'
    number27 = []
    cnt = 26
    digit = 1
    while N > 0:
        if N <= cnt:
            break
        else:
            N -= cnt
            cnt *= 26
            digit += 1
    ans = list('a' * digit)
    N -= 1
    tmp = -1
    while N > 0:
        N, mod = divmod(N, 26)
        ans[tmp] = alp[mod]
        tmp -= 1
    print(''.join(ans))


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N)
    # for i in range(1, 100):
    #     # print(i)
    #     solve(i)


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    string str;
    cin>>str;
    if(str[2]==str[3]&&str[4]==str[5])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <list>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <stack>
#include <fstream>
#include <queue>
#include <iomanip>
#include <iterator>
#include <map>
#include <unordered_map>
#include <set>
#define fast ios_base::sync_with_stdio(false)
#define mxn (ll)1e5
#define mod (ll)(1e9+7)
#define mod1 (ll)(998244353)
#define ll long long
#define ld long double
#define vi vector<ll>
#define vvi vector<vi >
#define pi pair<ll,ll>
#define vvpi vector<vector<pi > >
#define vpi vector<pi >
#define vppi vector<pair<ll,pi > >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define eb emplace_back
#define mkp make_pair
#define fs first
#define se second
#define crz(v,n) v.clear(),v.resize(n+1,0)
#define print(v) for(ll it=0;it<v.size();it++) cout<<v[it]<<" ";cout<<endl
#define printp(v) for(ll it=0;it<v.size();it++) cout<<v[it].first<<" "<<v[it].second<<endl
using namespace std;
int main(){
	int n,m,i,j;string a,b,c;cin>>a>>b;n=a.size(),m=b.size();
	vvi d(n+1,vi(m+1,0));for(i=1;i<=n;i++) for(j=1;j<=m;j++){
		d[i][j]=max(d[i-1][j],d[i][j-1]);
		if(a[i-1]==b[j-1]) d[i][j]=max(d[i][j],d[i-1][j-1]+1);
	}i=n,j=m;
	while(i&&j){
		if(d[i][j]==d[i-1][j]) i--;
		else if(d[i][j]==d[i][j-1]) j--;
		else c.pb(a[i-1]),i--,j--;
	}reverse(all(c));cout<<c<<endl;
}


Measured memory_bytes: 70784
#include <bits/stdc++.h>
#ifdef __LOCAL
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
    #include <filesystem>
    namespace fs = std::filesystem;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);
static mt19937 _g(time(nullptr));
 
inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
vector<int> Cnt;
void input(){
    fast_io();
    #ifdef __LOCAL
        fs::path __p = __FILE__;
        fs::path __input, __output;
        __input = __output = __p.parent_path();
        __input += string("/input/") + string(__p.stem()) + string(".txt");
        __output += string("/output/") + string(__p.stem()) + string(".txt");
        freopen(__input.c_str(), "r", stdin);
        freopen(__output.c_str(), "w", stdout);
    #endif
    cin >> N;
    Cnt.assign(N,0);
    for (int i = 0; i < N-1; i++)
    {
        int a; cin >> a; Cnt[--a]++;
    }
}

int solve(){
    for (int i = 0; i < N; i++)
    {
        cout << Cnt[i] << endl;
    }
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}


Measured memory_bytes: 3960
/*--------------------------------------------------------------------------\
|1週間　= 7日																|
|曜日は7つ　=> x1,x2,x3,x4,x5,x6,x7とする									|
|日にちをxとすると、															|
|x % 7によって得られる値で曜日を定められる。									|
|9月9日は土曜日																|
|		↓																	|
|9 mod 7 = 2だから、x % 7 == 2になるような日にちxの曜日は土曜日				|
|			↓																|
|  |x % 7 | 0 | 1 | 2 | 3 | 4 | 5 | 6 |										|
|  |day   |thu|fri|sat|sun|mon|tue|wed|										|
|			↓																|
|上の表を参考に余りの値を対応させていく。										|
|if文を使ってもいいけど、今回はswitch文を使った方がスマート。					|
\--------------------------------------------------------------------------*/

#include <iostream>
using namespace std;

int main() {
	int x; cin >> x;
	//switch文を使った出力処理
	switch (x % 7) {
	case 0:
		cout << "thu" << endl;
		break;
	case 1:
		cout << "fri" << endl;
		break;
	case 2:
		cout << "sat" << endl;
		break;
	case 3:
		cout << "sun" << endl;
		break;
	case 4:
		cout << "mon" << endl;
		break;
	case 5:
		cout << "tue" << endl;
		break;
	case 6:
		cout << "wed" << endl;
		break;
	}
	return 0;
}


Measured memory_bytes: 3076
#include<bits/stdc++.h>
#define    ll      long long int
#define    Fori(a,b) for (ll i = a ; i<b ;i++ )
#define    Forj(a,b) for (ll j = a ; j<b ;j++ )
#define    Fork(a,b) for (ll k = a ; k<b ;k++ )
#define    W       while
#define    pb      push_back
#define    nl      cout<<endl
#define    mod     1000000007
#define    I       cin>>
#define    Out     cout<<
#define    DOD(i)  cout<<setprecision(i)<<fixed<<
#define    XXX     return 0
#define    Fast    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
using namespace std;
int main()
{
   Fast;
   ll n;I n;
   ll a[n-1];
   map<ll,ll> m;
   Fori(0,n){
       I a[i];
       m[a[i]]++;
   }
   Fori(1,n+1){
       cout<<m[i]<<"\n";
   }
   XXX;
}




Measured memory_bytes: 17724