akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 
using namespace std; 
int gi() { 
	int res = 0, w = 1; 
	char ch = getchar(); 
	while (ch != '-' && !isdigit(ch)) ch = getchar(); 
	if (ch == '-') w = -1, ch = getchar(); 
	while (isdigit(ch)) res = res * 10 + ch - '0', ch = getchar(); 
	return res * w; 
} 
typedef long long LL; 
const int MAX_N = 1e5 + 5;
void Fail() { puts("NO"); exit(0); } 
struct Graph { int to, next; } e[MAX_N << 1]; 
int fir[MAX_N], e_cnt; 
void clearGraph() { memset(fir, -1, sizeof(fir)); e_cnt = 0; } 
void Add_Edge(int u, int v) { e[e_cnt] = (Graph){v, fir[u]}, fir[u] = e_cnt++; } 
int N, a[MAX_N], deg[MAX_N]; 
int rt = 1; 
LL f[MAX_N]; 
void dfs(int x, int fa) { 
	if (deg[x] == 1) return (void)(f[x] = a[x]); 
	LL sum = 0, mx = 0; 
	for (int i = fir[x]; ~i; i = e[i].next) { 
		int v = e[i].to; if (v == fa) continue; 
		dfs(v, x), sum += f[v], mx = max(mx, f[v]); 
	} 
	f[x] = 2 * a[x] - sum; 
	if (mx > 1ll * a[x] || f[x] > 1ll * a[x] || f[x] < 0ll) Fail(); 
} 
int main () { 
#ifndef ONLINE_JUDGE 
    freopen("cpp.in", "r", stdin); 
#endif 
	clearGraph(); 
	N = gi(); 
	for (int i = 1; i <= N; i++) a[i] = gi();
	if (N == 2) return puts(a[1] == a[2] ? "YES" : "NO") & 0; 
	for (int i = 1; i < N; i++) { 
		int u = gi(), v = gi(); 
		Add_Edge(u, v), Add_Edge(v, u); 
		++deg[u], ++deg[v]; 
	} 
	while (deg[rt] == 1) ++rt; 
	dfs(rt, 0); 
	puts(f[rt] ? "NO" : "YES"); 
    return 0; 
} 

Measured memory_bytes: 13500
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 1000000000
#define MOD 1000000007
#define ll long long int

using namespace std;

int main(){
	string s; cin>>s;
	int size = s.size();
	s += "#########";

	ll ans = 0;
	if(size < 3) {cout<<0<<endl;return 0;}

	ll cntA = 0;
	
	for(int i=0;i<size+1;i++){
		if(s[i] == 'A') {cntA++;continue;}
		if(s[i] == 'B' and s[i+1] == 'C') {i++;ans += cntA;continue;}

		cntA = 0;

	}

cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 640
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        new Main().compute();
    }

    void compute() {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        int ans=1;
        for(int i=0;i<N;i++){
            ans=Math.min(ans+K,ans*2);
        }
        System.out.println(ans);
    }
}


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

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

// rep
//------------------------------------------
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(x) cerr << #x << ": " << x << '\n'


int n, m;
VI a(10010);
VP p(10010);

signed main()
{
    cin >> n >> m;
    a.resize(n);

    REP(i, n){
        cin >> a[i];
    }
    sort(ALL(a));

    p.resize(m);
    REP(i, m){
        cin >> p[i].first >> p[i].second;
    }

    sort(ALL(p),[](PII a, PII b) { return a.second > b.second; });
    
    int index = 0;

    // 2分探索で、p[i].second以下になるものを探す。
    // だんだんheadを右にずらす

    /*
    REP(i, m){
        REP(j, p[i].first){
            if (a[index] < p[i].second) {
                a[index] = p[i].second;
                //DEBUG(a[index]);
                index++;
                if (index >= n) break;
            }
        }
        if (index >= n)break;
    }*/

    int sum = 0;

    REP(i, m){
        int x = lower_bound(a.begin()+index, a.end(), p[i].second) - (a.begin()+index);
        //DEBUG(x);
        //DEBUG(index);
        if (x < p[i].first){// もうこれ以上変化しない
            sum += x * p[i].second;
            index += x;
            break;
        } else {
            sum += p[i].second * p[i].first;
            index += p[i].first;
        }
    }

    FOR(i, index, n){
        sum += a[i];  
    }

    cout << sum << endl;
}

Measured memory_bytes: 2816
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

s = readline().decode().rstrip()

ans = float('inf')
for i in range(len(s) - 2):
    x = int(s[i]) * 100 + int(s[i + 1]) * 10 + int(s[i + 2])
    res = abs(753 - x)
    ans = min(ans, abs(753 - x))
print(ans)


Measured memory_bytes: 9216
using System;

namespace APC2019_A
{
	internal class Program
	{
		public static void Main(string[] args)
		{
			int n = int.Parse(Console.ReadLine());
			int h = int.Parse(Console.ReadLine());
			int w = int.Parse(Console.ReadLine());

			int count = 0;
			count += (n - h + 1) * (n - w + 1);
			
			Console.WriteLine(count);
		}
	}
}

Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define IO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
const LL LINF = 0x3f3f3f3f3f3f3f3f; 
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const int mod = 1e9+7;
const ULL P = 131;
const int N = 2e5+7;


int main()
{
	int k;
	cin>>k;
	string s;
	cin>>s;
	int w=0,r=0;

	for(int i=0;i<k;i++){
		if(s[i]=='W') w++;
		else r++;
	}
	int tt = r;
	for(int i=0;i<tt;i++) if(s[i]=='R') r--;
	if(w==0||tt==0) cout<<"0\n";
	else cout<<r<<"\n";
	return 0;
}

Measured memory_bytes: 3720
#include <iostream>
#include <stack>
#include <string>
#include <sstream>

using namespace std;

int main()
{
  int n, q;
  int op[3];
  string line;
  stack<int> s[1000];
  
  cin >> n >> q;
  cin.ignore();
  
  for (int i = 0; i < q; i++) {
    getline(cin, line);
    stringstream ss;
    ss << line;
    int a;
    int j = 0;
    while (ss >> a) {
      op[j] = a;
      j++;
    }
    if (op[0] == 0) {
      s[op[1]].push(op[2]);
    } else if (op[0] == 1) {
      if (!s[op[1]].empty()) {
	cout << s[op[1]].top() << endl;
      }
    } else if (op[0] == 2) {
      if (!s[op[1]].empty()) {
	s[op[1]].pop();
      }
    }
  }
}



Measured memory_bytes: 4456
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,x,y) for(int i=(x);i<=(y);++i)
inline int read(){
	char ch=getchar();int x=0,f=1;
	while(ch<'0'||ch>'9'){
		if(ch=='-')f=-1;
		ch=getchar();
	}
	while('0'<=ch&&ch<='9'){
		x=x*10+ch-'0';
		ch=getchar(); 
	}
	return x*f;
}
int w[110],c[110],t[110],fa[110];
int b[110],f[500010];
inline bool cmp(int x,int y){
	return w[x]*c[y]>w[y]*c[x];
}
signed main() {
	int n=read(),X=read(),D=read();
	c[1]=read();
	t[1]=n;
	rep(i,2,n){
		c[i]=read(),fa[i]=read();
		t[i]=min(D,n);
	}
	rep(i,1,n)w[i]=1;
	for(int i=n;i>=2;--i){
		w[fa[i]]+=w[i];
		c[fa[i]]+=c[i];
	}
	int lim=0;
	rep(i,1,n)lim+=w[i]*t[i];
	rep(i,1,lim)f[i]=1e12;
	rep(i,1,n){
		for(int j=lim;j>=0;--j){
			rep(k,1,min(t[i],j/w[i])){
				f[j]=min(f[j],f[j-k*w[i]]+k*c[i]);
			}
		}
	}
	for(int j=lim-1;j>=0;--j){
		f[j]=min(f[j],f[j+1]); 
	}
	rep(i,1,n){
		if(i==1)t[i]=1e12;
		else t[i]=D-t[i];
	}
	rep(i,1,n){
		b[i]=i;
	}
	sort(b+1,b+n+1,cmp);
	int ans=0;
	rep(j,0,lim){
		int Y=X-f[j];
		if(Y<0)break;
		int res=0;
		rep(i,1,n){
			int x=b[i];
			int s=min(t[x],Y/c[x]);
			Y-=s*c[x],res+=s*w[x];
		}
		ans=max(ans,res+j);
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 768
N = int(input())
A = [int(i) for i in input().split()]

count = {}
for i in A:
    if i not in count:
        count[i] = 1
    else:
        count[i] += 1

ans = 0
for i, j in count.items():
    if i > j:
        ans += j
    elif i < j:
        ans += j - i

print(ans)

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

int n, a, x[50];
long long dp[51][2501] = { 1 }, ans = 0;

int main() {
	cin >> n >> a;
	for (int i = 0; i < n; i++)
		cin >> x[i];
	for (int i = 0; i < n; i++)
		for (int j = i; j >= 0; j--)
			for (int k = 0; k <= 50 * i; k++)
				dp[j + 1][k + x[i]] += dp[j][k];
	for (int i = 1; i <= n; i++)
		ans += dp[i][a * i];

	cout << ans << endl;
}


Measured memory_bytes: 1280
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int N;
int d[100010];

int main()
{
  scanf( "%d", &N );
  rep( i, N )
    scanf( "%d", d+i );

  std::sort( d, d+N );

  int ans = 0;
  rep( K, 100001 )
  {
    int p = std::lower_bound( d, d+N, K )-d;
    
    if( p == N-p )
      ++ans;
  }

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

  return 0;
}

Measured memory_bytes: 512
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
mod = 1000000007


#A
"""
a = LI()
i = a.count(5)
j = a.count(7)
if i == 2 and j == 1:
    print("YES")
else:
    print("NO")
"""

#B
n,l = LI()
s = SR(n)
s.sort()
for i in s:
    for j in i:
        print(j,end = "")
print()
#C
"""
def check(n):
    n = list(map(int,list(str(n))))
    s = 0
    for i in n:
        s += f[i]
    return s == 0
n,k = LI()
d = LI()
f = [0 for i in range(10)]
for i in d:
    f[i] = 1
while 1:
    if check(n):
        print(n)
        quit()
    n += 1
"""
#D
"""
def f(x,y):
    return fact[x-1+h-y]*fact[y-1+w-x]*inv_fact[x-1]*inv_fact[y-1]*inv_fact[w-x]*inv_fact[h-y]%mod
h,w,a,b = LI()
fact = [1]*(h+w+1)
for i in range(h+w):
    fact[i+1] = fact[i]*(i+1)%mod
inv_fact = [0]*(h+w+1)
inv_fact[h+w] = pow(fact[-1],mod-2,mod)
for i in range(h+w)[::-1]:
    inv_fact[i] = inv_fact[i+1]*(i+1)%mod
ans = 0
for i in range(1,min(w-b,h-a)+1):
    ans += f(b+i,a+i)
    ans %= mod
print(ans)
"""


#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 43496
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#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) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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

	int N;
	cin >> N;
	int H[100][101] = {};
	rep(i, N) {
		int h;
		cin >> h;
		rep1(j, h) H[i][j] = 1;
	}

	int kotae = 0;
	rep1(i, 100) {
		int mae = 0;
		rep(j, N) {
			if (H[j][i]) {
				if (mae == 0) {
					mae = 1;
					kotae++;
				}
			}
			else mae = 0;
		}
	}

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	vector<int> vi;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		vi.push_back(s[i]-'0');
	}
	int mi = 100000000;
	for(int i=0;i<vi.size()-2;i++)
	{
		int k;
		k=0;
		k+=vi[i+2];
		k+=vi[i+1]*10;
		k+=vi[i]*100;
		mi = min(abs(k-753),mi);
	}
	cout<<mi<<endl;
 } 

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

void turn(int *DICE,char com);

int main(void){
int i,j,q,top,front;
int DICE1[6],DICE2[6];
char com[105];
for(i=0;i<6;i++){scanf("%d",&DICE1[i]);}
for(i=0;i<6;i++){scanf("%d",&DICE2[i]);}
top=DICE1[0];front=DICE1[1];
i=0;
strcpy(com,"SSSSESSSS");
while(DICE2[1]!=front){
	if(com[i]=='\0'){printf("No\n");return 0;}
	turn(&DICE2[0],com[i]);
	i++;
	}
i=0;
strcpy(com,"EEEE");
while(DICE2[0]!=top){
	if(com[i]=='\0'){printf("No\n");return 0;}
	turn(&DICE2[0],com[i]);
	i++;
	}
for(i=0;i<6;i++){
	if(DICE1[i]!=DICE2[i]){printf("No\n");return 0;}
	}
printf("Yes\n");
return 0;
}

void turn(int *DICE,char com){
int temp;
switch(com){
	case 'N':
		temp     =*DICE;
		*DICE    =*(DICE+1);
		*(DICE+1)=*(DICE+5);
		*(DICE+5)=*(DICE+4);
		*(DICE+4)=temp;
		break;
	case 'S':
		temp     =*DICE;
		*DICE    =*(DICE+4);
		*(DICE+4)=*(DICE+5);
		*(DICE+5)=*(DICE+1);
		*(DICE+1)=temp;
		break;
	case 'E':
		temp     =*DICE;
		*DICE    =*(DICE+3);
		*(DICE+3)=*(DICE+5);
		*(DICE+5)=*(DICE+2);
		*(DICE+2)=temp;
		break;
	case 'W':
		temp     =*DICE;
		*DICE    =*(DICE+2);
		*(DICE+2)=*(DICE+5);
		*(DICE+5)=*(DICE+3);
		*(DICE+3)=temp;
		break;
	}
}

Measured memory_bytes: 580
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define SORT(x) sort((x).begin(),(x).end())
int main(void){
    
    int N;
    cin >>N;
    
    if(N<=999){
        cout <<"ABC";
    }else{
        cout <<"ABD";
    }
    
}


Measured memory_bytes: 256
X,K,D=map(int,input().split())
X=abs(X)
L=X//D
ans=0
if L>=K:
    ans=X-D*K
else:
    m=K-L
    if m%2==0:
        ans=X%D
    else:
        ans=abs(X%D-D)
print(ans)

Measured memory_bytes: 9128
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
using namespace std;
 
struct edge {int /*from,*/to,cost;};
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
typedef vector<edge> VE;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define np next_permutation
#define pq priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define MAX(a,b,c) max((a),max((b),(c)))
#define MIN(a,b,c) min((a),min((b),(c)))
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
//#define int ll

signed main(){
    int a[26]={},b[26]={};
    string s,t;
    cin >> s >> t;
    SORT(s);
    SORT(t);
    reverse(all(t));
    if(s<t) puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cassert>
#include<cmath>
#include<queue>
#include<cstring>
#include<climits>
#include<sstream>
#include<deque>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<bitset>

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

using namespace std;

typedef long long ll;

const ll mod = 1000000007LL;

ll n,m,x[100010], y[100010];

void compute() {
  ll sumX = 0;
  REP(i,1,n+1) {
    ll v1 = ( x[i] * (ll)(i-1) ) % mod;
    ll v2 = ( x[i] * (ll)(n-i) ) % mod;
    ll v  = ( v1 - v2 ) % mod;
    ( sumX += v ) %= mod;
  }
  ll sumY = 0;
  REP(i,1,m+1) {
    ll v1 = ( y[i] * (ll)(i-1) ) % mod;
    ll v2 = ( y[i] * (ll)(m-i) ) % mod;
    ll v  = ( v1 - v2 ) % mod;
    ( sumY += v ) %= mod;
  }
  ll ans = ( sumX * sumY ) % mod;
  while( ans < 0LL ) ans += mod;
  cout << ans % mod << endl;
}

int main() {
  cin >> n >> m;
  REP(i,1,n+1) cin >> x[i];
  REP(i,1,m+1) cin >> y[i];
  compute();
  return 0;
}


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

using namespace std;

typedef long long int ll;
 
template<class T> inline bool chmax(T& a,T b){ if(a<b){ a=b; return true;} return false; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){ a=b; return true;} return false; }
 
typedef pair<int,int> pair;

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

    ll max=a-1;

    if(n<=b || b==1){
        max=0;
        for(int i=0;i<=(a-1);i++){
            ll base=n-i;
            ll num=floor(a*base/b)-a*floor(base/b);
            //cout << floor(a*base/b) << " " << floor(base/b) << endl;
            if(num>max) max=num;
        }
    }

    cout << max << endl;
    
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m,a;
    long long res =0;
    cin>>n>>m;
    priority_queue<int> pp;
    for(int i = 0;i<n ;i++){
        cin>>a;
        pp.push(a);
        res+=a;
    }
    for(int i=0;i<m;i++){
        a = pp.top();
        res = res - (a-a/2);
        pp.pop();
        pp.push(a/2);
    }
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 892
n = int(input())
s = list(input())
max_word = 0
for i in range(1, n):
    set_s1 = set(s[:i])
    set_s2 = set(s[i:])

    sorted(set_s1)
    sorted(set_s2)
    
    cnt = 0
    for r in set_s1:
        for t in set_s2:
            if r == t:
                cnt += 1
                max_word = max(cnt, max_word)
    
print(max_word)

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

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

    int res = 0, cnt = 0;
    cnt += K; res++;
    while (cnt < N){
        cnt += K - 1;
        res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vll vector<ll>
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;
int main(int argc, char const *argv[]) {
  ll n, k;std::cin >> n >> k;
  std::cout << (2*k-1<=n?"YES":"NO") << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  ll n, k;
  cin >> n >> k;
  vector<pair<ll, ll>> v(n);
  rep(i, n) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());
  ll count = 0;
  rep(i, n) {
    count += v[i].second;
    if (count >= k) {
      cout << v[i].first << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 4744
import random

D = int(input())
C = list(map(int, input().split()))  # (#cty,)
S = [list(map(int, input().split())) for _ in range(D)]  # (D, #cty)


class Scorer:

    def __init__(self, c, s):
        n_cty = len(c)
        self.c = c  # (#cty,)
        self.s = s  # (D, #cty)
        self.elapsed_time = {cty: 0 for cty in range(n_cty)}

        self.score = 0

    def update_score(self, d, cty):
        # update elapsed time
        for cty_ in self.elapsed_time:
            if cty_ == cty:
                self.elapsed_time[cty_] = 0
            else:
                self.elapsed_time[cty_] += 1

        cur_score = self.s[d][cty]
        for cty_ in self.elapsed_time:
            cur_score -= self.c[cty_] * self.elapsed_time[cty_]
        self.score += cur_score
        return self.score


N_REPLACE = 5
EPS = 0.5
ATT = 0.8

T = [random.randint(1, 26) for _ in range(D)]
best_score = -1
for _ in range(500):
    scorer = Scorer(C, S)

    T_ = T[:]

    # replace N elements
    for i in range(N_REPLACE):
        T_[random.randint(0, D - 1)] = random.randint(1, 26)

    for d in range(D):
        cty = T_[d] - 1
        scorer.update_score(d, cty)
    if best_score <= scorer.score:
        best_score = scorer.score
        T = T_
    elif random.random() < EPS:
        best_score = scorer.score
        T = T_
    EPS *= ATT

for t in T:
    print(t)


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

int main(){
bool unti[1000000];
fill(unti,unti+1000000,0);
for(int n = 2;n < 1000000;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 1000000;a++)
{
	unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
	}
return 0;
}

Measured memory_bytes: 4032
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define ll long long
#define vi vector<int>
#define pi pair<int, int>
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define int ll

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const int N = 1e5 + 667;

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

    int n;
    cin >> n;
    int cnt = n / 500;
    int ans = cnt * 1000;
    n -= cnt * 500;
    cnt = n / 5;
    ans += cnt * 5;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
MOD = 10**9+7
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
def m_add(a,b): return (a+b) % MOD

S = input()

ans = ''
for _ in range(len(S)):
    ans += 'x'
print(ans)

Measured memory_bytes: 5684
#include<iostream>
#include <cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


int main(){
  int N; cin >> N; int ans[N] = {};
  for(int i=1; i<=100; i++){
    for(int j=1; j<=100; j++){
      for(int k=1; k<=100; k++){
        if(i*i+j*j+k*k+i*j+j*k+i*k<=N){
          ans[i*i+j*j+k*k+i*j+j*k+i*k-1]++;
        }
      }
    }
  }
  rep(i, N){
    cout << ans[i] << endl;
  }
}

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

string s;

int main() {
	long long int n;
	string ans = "";
	cin >> n;
	while (1) {
		if (n == 0) break;
		if (n % 26 == 0) {
			ans += 'z';
			n -= 1;
		}
		else ans += (char)(((n - 1) % 26) + 'a');
		n /= 26;
	}
	for (int i = ans.size() - 1; i >= 0; i--) cout << ans[i];
	cout << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>    
//#include <ext/pb_ds/assoc_container.hpp> 
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//using namespace __gnu_pbds; 
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define pb  push_back
#define show(x) cout<<(#x)<<" : "<<x<<endl;
#define ll  long long
#define ld  long double
#define fill(a,val) memset(a,val,sizeof(a))
#define mp  make_pair
#define ff  first
#define ss  second
#define pii pair<ll,ll>
#define sq(x) ((x)*(x))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define endl "\n"
#define int long long 
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
const ll MOD     = 1000*1000*1000+7;
const ll INF     = 1ll*1000*1000*1000*1000*1000*1000 + 7;
const ll MOD2    = 998244353;
const ll N       = 1000 * 100 + 10;
const ll N2      = 70;
const ld PI  = 3.141592653589793;
//template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);} 
ll power(ll x,ll y,ll p = LLONG_MAX ){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
ll lcm(ll a , ll b){return (a*b)/gcd(a,b);}
void solve(){
  #ifndef ONLINE_JUDGE    
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
  #endif
}
struct ans{
ll c,nn;
vector<ll> b; 
};
bool chmin(ll &a,ll b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
signed main()
{
    fastio();
    //cout<<fixed<<setprecision(20);
    //CHECK for LONG LONG and LONG DOUBLE
    //*comment for all except cc/cf   
    ll n,m;
    cin>>n>>m; 
    struct ans x[m];
    set<ll> p; 
    for(ll i=0;i<m;i++){
      cin>>x[i].c>>x[i].nn;
      for(ll j=0;j<x[i].nn;j++){
        ll a; 
        cin>>a; 
        x[i].b.pb(a);
        p.insert(a);
      } 
    }
    if(p.size()<n){
      cout<<-1;
      exit(0);
    }
    else{
     ll M=1e9;
     vector<ll> u(5000,M); 
     u[0]=0;
     for(ll i=0;i<m;i++){
       ll ans=0;
       for(ll j=0;j<(x[i].nn);j++){
         ans|=1<<(x[i].b[j]-1);
       }
       for(ll j=0;j<(1<<n);j++){
         chmin(u[ans|j],u[j]+x[i].c);
       }
     }
     cout<<u[(1<<n)-1]<<endl; 
    }
    //printclock;
    return 0;
}
    

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

#define fast ios_base::sync_with_stdio; cin.tie(0); cout.tie(0)
#define ll          long long
#define ull         unsigned long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)      (a).rbegin(),(a).rend()
#define ff           first
#define ss           second
#define sz(x)       (int)x.size()
//#define endl        '\n'
#define mod        1000000007
//#define mod        998244353
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define INF         numeric_limits<ll>::max();
#define NINF        numeric_limits<ll>::min();
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))
const long double pi=3.14159265359;

int main()
{fast;
 #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
 #endif
 ll t=1,n;
 //cin>>t;
 while(t--)
 {cin>>n;
  ll l,r,f=0;
  rep(i,0,151){
    rep(j,i,151){
        ll a=pow(i,5);
        ll b=pow(j,5);
        if(b-a==n){
            l=j;
            r=i;
            f=1;
            break;
        }
        if(b+a==n){
            l=j;
            r=-i;
            f=1;
            break;
        }
    }
    if(f){
        break;
    }
  }
  cout<<l<<" "<<r;
 }
 return 0;
}


Measured memory_bytes: 4068
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const int INF = (1<<30);
const ll INFLL = (1ll<<60);
const ll MOD = (ll)(1e9+7);

#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	a = (a<MOD)?a:(a-MOD);
	b = (b<MOD)?b:(b-MOD);
	a += b;
	a = (a<MOD)?a:(a-MOD);
}

int ufr[225816],ufp[225816];
ll a[225816],b[225816];

void ufinit(int n){
	int i;
	for(i=0; i<n; ++i){
		ufp[i] = i;
		ufr[i] = 1;
	}
}

int ufind(int x){
	if(x == ufp[x]){
		return x;
	}
	ufp[x] = ufind(ufp[x]);
	return ufp[x];
}

void unionf(int x, int y){
	x = ufind(x);
	y = ufind(y);
	if(x==y){
		return;
	}
	if(ufr[x] < ufr[y]){
		swap(x,y);
	}
	ufp[y] = x;
	ufr[x] += ufr[y];
}

int main(void){
	int n,m,u,v,i;
	ll ans = 0ll;
	cin >> n >> m;
	ufinit(n*2);
	for(i=0; i<m; ++i){
		cin >> u >> v;
		--u; --v;
		unionf(u,v+n); --ans;
		unionf(v,u+n); --ans;
	}
	for(i=0; i<n; ++i){
		++a[ufind(i)];
		++b[ufind(i+n)];
		if(ufind(i)==ufind(i+n)){
			--ans;
		}
	}
	for(i=0; i<n; ++i){
		ans += a[i]*b[i];
		ans += a[i+n]*b[i+n];
	}
	cout << (ans>>1) << endl;
	return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>

int main(){
    int N,count=0;
    std::cin >> N;
    std::vector<int> A(N);
    for(int i=0;i<N;i++){
        std::cin >> A[i];
    }
    while(1){
        for(int i=0;i<N;i++){
            if(A[i]%2!=0){
                std::cout << count <<std::endl;
                return 0;
            }
            A[i]=A[i]/2;
        }
        count++;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String str = in.nextLine();
        in.close();
        int ans = 0;
        for (int i = 0; i < 4; i++) {
            if (str.charAt(i) == '+') {
                ans++;
            } else {
                ans--;
            }
        }
        System.out.println(ans);
    }
}

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

int main(){
 int y, m, d;
 char c;
 cin >> y >> c >> m >> c >> d;
 if(m <= 4){
     cout << "Heisei" << endl;
 }
 else{
     cout << "TBD" << endl;
 }
 
}

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

typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define int ll
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 500001

string str;
vector <pair <char,int> > A;

int ans[maxn];
int N;
int32_t main(){
	fast;
	
	cin>>str;

	N = str.size() + 1;
	mem(ans,-1);
	
	if (str[0] == '<') ans[0] = 0;
	if (str.back() == '>') ans[N-1] = 0;
	FOR(i,0,str.size()-2){
		if (str[i] == '>' && str[i+1] == '<'){
			ans[i+1] = 0;
			//cout<<i+1<<'\n';
			DEC(j,i,0){
				if (ans[j] != -1 || str[j] != str[j-1]) break;
				
				ans[j] = ans[j+1] + 1;
			}
		}
	}
	

	
	//FOR(i,0,N-1) cout<<ans[i]<<' ';
	//cout<<'\n';
	//return 0;
	FOR(i,0,N-1){
		if (ans[i] == -1){
			int idx;
			FOR(j,i,N-1){
				if (ans[j] != -1){
					idx = j-1;
					break;
				}
				if (j == N-1) idx = j;
				
				ans[j] = ans[j-1] + 1;
			}
			//cout<<idx<<'\n';
			if (ans[idx] <= ans[idx+1]){
				ans[idx] = ans[idx+1] + 1;
				DEC(i,idx-1,0){
					if (ans[i] != -1) break;
					ans[i] = ans[i+1] - 1;
				}
			}
		}
	}
			
	
	int legit_ans = 0;
	FOR(i,0,N-1){
		legit_ans += ans[i];
		//cout<<ans[i]<<' ';
	}
	//cout<<'\n';
	cout<<legit_ans;
}
	
	

		
	
	




Measured memory_bytes: 4764
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	set<int> s;
	int a, b, c;
	cin >> a >> b >> c;
	s.insert(a); s.insert(b); s.insert(c);
	cout << s.size() << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)

int A, B;
char fld[101][101];

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

  rep( i, 50 ) rep( j, 100 )
  {
    fld[j][i] = '.';
    fld[j][50+i] = '#';
  }

  --A; --B;

  rep( i, B )
  {
    int c = i % 24, r = i / 24;

    fld[1+r*2][1+2*c] = '#';
  }

  rep( i, A )
  {
    int c = i % 24, r = i / 24;

    fld[1+r*2][50+1+2*c] = '.';
  }

  puts("100 100");
  rep( i, 100 )
  {
    rep( j, 100 )
      putchar( fld[i][j] );
    
    puts("");
  }

  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <random>
#include <cassert>
#include <algorithm> 
#include <iostream>
#include <chrono>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <cstring>
#include <cmath>
#include <bitset>
#define pb push_back
#define mk make_pair
#define eb emplace_back
#define eps 1e-8
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
typedef long double ld;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef tuple<int, int, int> tiii;
typedef vector<int> vii;
typedef vector<long double> vd;
const int inf = 1e9;
const long long INF = 1e18;
const int M = 1e9 + 7;
int vec[66];

bool ins(int x) {
    for(int i = 60; i >= 0; --i) {
        if(x >> i & 1) {
            if(!vec[i]) {
                vec[i] = x;
                return 1;
            } else {
                x ^= vec[i];
            }
        } 
    }
    return 0;
}

bool chk(int x) {
    for(int i = 60; i >= 0; --i) {
        if(x >> i & 1) {
            if(!vec[i]) {
                return 1;
            } else {
                x ^= vec[i];
            }
        } 
    }
    return 0;
}


signed main() {
    int T;
    cin >> T;
    while(T--) {
        memset(vec, 0, sizeof(vec));
        int n;
        cin >> n;
        vector<int> a, b;
        vector<int> A(n);
        for(int i = 0; i < n; ++i) {
            cin >> A[i];
        }
        string s;
        cin >> s;
        bool ok = 1;
        for(int i = n - 1; i >= 0; --i) {
            if(s[i] == '0') {
                ins(A[i]);
            } else {
                if(chk(A[i])) {
                    puts("1");
                    ok = 0;
                    break;
                }
            }
        }
        if(ok) {
            puts("0");
        }
    }
    return 0;
}

Measured memory_bytes: 3484
// スタックサイズ: 100MB

#include <iostream>
#include <fstream>
#include <vector>
#include <map>
#include <unordered_map>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <numeric>
#include <iomanip>
#include <queue>
#include <list>
#include <set>
using namespace std;

typedef int64_t ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
const ll INF = 1000000000000000000;
#define fori(i, a, b) for (ll i = (a); i < (b); ++i)
#define ford(i, a, b) for (ll i = (b - 1); (a) <= i; --i)
#define rep(i, n) fori(i, 0, n)
#define all(v) (v).begin(), (v).end()


int main() {

	ll D, N;
	cin >> D >> N;

	ll dict[5] = { 1, 100, 10000, 1000000, 100000000 };
	ll counter = 0;
	fori(i, 1, INF) {
		if (i % dict[D] == 0 && i % dict[D + 1] != 0 && i % dict[D + 2] != 0) ++counter;
		if (counter == N) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main()
{
	int m, n;
	while (scanf("%d %d",&m,&n)!= EOF)
	{
		int a = m, b = n;
		while (m%n != 0)
		{
			int temp = m%n;
			m = n;
			n = temp;
		}
		printf("%d %d\n",n,(a/n)*b);
	}
	return 0;
}

Measured memory_bytes: 596
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iostream>
#include <iostream>
#include <fstream>
#include <numeric>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <cmath>
#include <set>
#include <map>
#include <functional>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
using namespace std;
#define     loop(n,i,a)     for(int i=a;i<n;i++)
#define     loopR(n,i,a)    for(int i=n-1;i>=a;i--)
#define     all(arr,n)      arr,arr+n
#define     allv(v)         (v).begin(),(v).end()
#define     rallv(v)        (v).rbegin(),(v).rend()
#define     m_p             make_pair
#define     ll              long long
#define     pii             pair<ll,ll>
#define     vi              vector<int>
#define     vll             vector<ll>
#define     vii             vector<pair<ll,ll>>
#define     sz(x)           (int)x.size()
#define     pb              push_back
#define     endl            "\n"
#define     Endl            "\n"
#define     f               first
#define     s               second
#define     mem(dp,n)       memset(dp,n,sizeof dp)
int dx[] = { 1 , 0 ,-1 , 0 ,-1 ,-1 , 1 , 1 };
int dy[] = { 0 , 1 , 0 ,-1 ,-1 , 1 ,-1 , 1 };
void fast(){
    std::ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
}
vector<string> vec_splitter(string s) {
    s += ',';
    vector<string> res;
    while(!s.empty()) {
        res.push_back(s.substr(0, s.find(',')));
        s = s.substr(s.find(',') + 1);
    }
    return res;
}
void debug_out(
        vector<string> __attribute__ ((unused)) args,
        __attribute__ ((unused)) int idx,
        __attribute__ ((unused)) int LINE_NUM) { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(vector<string> args, int idx, int LINE_NUM, Head H, Tail... T) {
    if(idx > 0) cerr << ", "; else cerr << "Line(" << LINE_NUM << ") ";
    stringstream ss; ss << H;
    cerr << args[idx] << " = " << ss.str();
    debug_out(args, idx + 1, LINE_NUM, T...);
}
#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
const ll mxN=2e6+10,oo=0x3f3f3f3f,MOD=998244353;
const double PI = acos(-1);

void solve(){
    ll n;
    cin>>n;
    string res;
    while(n--){
        res+=('a'+(n%26));
        n/=26;
    }
    reverse(allv(res));
    cout<<res<<Endl;
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    fast();
    solve();
}

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

int main(){
    int N;
    std::cin >> N;
    
    std::vector< int > cnt(N+1, 0);
    for(int i=2; i<=N; i++){
        int cur = i;
        for(int j=2; j*j<=N; j++){
            while(cur % j == 0){
                cur /= j;
                cnt[j]++;
            }
            if(cur == 1){
                break;
            }
        }
        cnt[cur]++;
    }
    cnt[1] = 1;
    
    int ans = 0;
    
    std::deque< int > num;
    std::deque< int > next;
    num.push_back(1);
    next.push_back(2);
    
    while(!num.empty()){
        int cur_num = num[0];
        int cur_next = next[0];
        num.pop_front();
        next.pop_front();
        if(cur_num == 75){
            ans++;
        }
        if(cur_num >= 75){
            continue;
        }
        if(cur_next > N){
            continue;
        }
        
        for(int i=0; i<=cnt[cur_next]; i++){
            int tmp = cur_num * (i+1);
            if(tmp > 75){
                break;
            }
            num.push_back(cur_num * (i+1));
            next.push_back(cur_next+1);
        }
    }
    
    std::cout << ans << std::endl;;
    
    return 0;
    
}


Measured memory_bytes: 12180
Module Atcorder2

        Sub Main(ByVal args() As String)

            Dim ReadWords As String = String.Empty
            Dim i As Integer = 0
            Dim Cnt As Integer = 0

            ReadWords = Console.ReadLine()

            For i = 0 To ReadWords.Length - 1
                If ReadWords(i) = "1" Then
                    Cnt += 1
                End If
            Next

            Console.WriteLine(Cnt)

        End Sub

    End Module

Measured memory_bytes: 19792
// 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 a, b, c;
  cin >> a >> b >> c;
  b += a;
  for (int i = c; i <= b * c; i += 60) {
    if (i % b <= a) {
      cout << i << endl;
      return;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 3060
/*よくばりセット2019/07/13 */
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#define MOD 1000000007
typedef long long int ll;
void llswap(ll *x,ll *y){ll temp;temp=*x;*x=*y;*y=temp;}
void swap(int *x,int *y){int tmp;tmp=*x;*x=*y;*y=tmp;}
int max(int x,int y){return x>y?x:y;}
int min(int x,int y){return x>y?y:x;}
ll llmax(ll x,ll y){return x>y?x:y;}
ll llmin(ll x,ll y){return x>y?y:x;}
int asc(const void *a,const void *b){return *(int*)a-*(int*)b;}
int desc(const void *a,const void *b){return *(int*)b-*(int*)a;}

int main(){
    int w;
    scanf("%d",&w);
    printf("%d\n",w*32);
    return 0;
}


Measured memory_bytes: 2112
#include<iostream>

int main(void){
    std::string s, t;
    std::cin >> s >> t;
    int cnt = 0;
    for(int i = 0; i < s.size(); i++){
	if(s[i] != t[i]) cnt++;
    }
    std::cout << cnt << std::endl;
    return 0;
}


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

typedef long long ll;

int n, dis[105][105], d[105];
vector<int> g[105];

void dfs(int rt, int u, int p) {
	for (int v : g[u])
		if (v != p) {
			dis[rt][v] = dis[rt][u] + 1;
			dfs(rt, v, u);
		}
}

ll calc(int u) {
	int mx = *max_element(d + 1, d + 1 + n);
	vector<int> x(mx);
	for (int i = 1; i <= n; ++i)
		if (d[i] < mx) x[d[i]] = max(x[d[i]], (int)g[i].size() - 1 + (i == u));
	ll ans = 1;
	for (int y : x) ans *= y;
	return ans;
}
ll solve(int u) {
	for (int i = 1; i <= n; ++i) d[i] = dis[u][i];
	return calc(u);
}
ll solve(int u, int v) {
	for (int i = 1; i <= n; ++i) d[i] = min(dis[u][i], dis[v][i]);
	return calc(-1) * 2;
}

int main() {
	scanf("%d", &n);
	for (int i = 1, a, b; i < n; ++i) {
		scanf("%d%d", &a, &b);
		g[a].push_back(b), g[b].push_back(a);
	}
	for (int i = 1; i <= n; ++i)
		dfs(i, i, 0);
	int d = 0;
	for (int i = 1; i <= n; ++i)
		d = max(d, *max_element(dis[i] + 1, dis[i] + 1 + n));
	if (d % 2 == 0) {
		int u;
		ll ans = 0;
		for (int i = 1; i <= n; ++i)
			if (*max_element(dis[i] + 1, dis[i] + 1 + n) == d / 2) {
				ans = solve(u = i);
				break;
			}
		for (int v : g[u])
			ans = min(ans, solve(u, v));
		printf("%d %lld\n", d / 2 + 1, ans);
	} else {
		int u = 0, v = 0;
		for (int i = 1; i <= n; ++i)
			if (*max_element(dis[i] + 1, dis[i] + 1 + n) == (d + 1) / 2) {
				if (!u) u = i;
				else v = i;
			}
		printf("%d %lld\n", (d + 1) / 2, solve(u, v));
	}
	return 0;
}


Measured memory_bytes: 256
nd = gets.chomp.split
n = nd[0].to_i
d = nd[1].to_i

count = 0
n.times do
    xy = gets.chomp.split
    x = xy[0].to_i
    y = xy[1].to_i
    if Math.sqrt(x ** 2 + y ** 2) <= d
        count += 1
    end
end

puts count


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

int main() {
    int h, w, n;
    cin >> h >> w >> n;
    int table[h * w], i = 0;
    for (int j = 1; j <= n; j++) {
        int a;
        cin >> a;
        for (int k = 0; k < a; k++, i++) {
            table[i] = j;
        }
    }
    for (int i = 0; i < h; i++) {
        if (i & 1) {
            for (int j = w - 1; j > 0; j--) {
                cout << table[i * w + j] << ' ';
            }
            cout << table[i * w] << endl;
        } else {
            for (int j = 0; j < w - 1; j++) {
                cout << table[i * w + j] << ' ';
            }
            cout << table[i * w + w - 1] << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 384
n = int(input())
s = []
for i in range(n):
    s += [int(input())]
s = sorted(s)
a = sum(s)
if a % 10 != 0:
    print(a)
    exit()
else:
    for i in range(n):
        if s[i] % 10 != 0:
            a -= s[i]
        if a % 10 != 0:
            print(a)
            f = 0
            exit()
        else:
            f = 1
if f:
    print(0)

Measured memory_bytes: 9176
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstring>
#include <cmath>
#define ll long long
using namespace std;
int main()
{
  ios_base::sync_with_stdio(0);
  ll arr[3];
  for(ll i=0;i<3;i++)
    cin >> arr[i];
  sort(arr,arr+3);
  ll ans = arr[0]+arr[1];
  cout << ans << endl;
  return 0;
}


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

using ll = long long;
#define REP(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}

int main() {
  double N, M; cin >> N >> M;

  double cnt = (1900 * M + 100 * (N - M)) * pow(2, M);

  cout << cnt << endl;
}

Measured memory_bytes: 256
N = int(input())
L = list(map(int, input().split()))
num=0
if N<3:
   num=0
else:   
   for i in range(N-2):
       for j in range(i+1, N-1):
          for k in range(j+1, N):
             if not(L[i]==L[j] or L[j]==L[k] or L[k]==L[i]):
                if (L[i]-L[j] < L[k]) and (L[j]-L[i]<L[k])and(L[k]<L[j]+L[i]):
                   num=num+1
print(num)

Measured memory_bytes: 9208
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>

using namespace std;

vector<int> graph[100001];
bool avisited[100001] = { 0, };
bool bvisited[100001] = { 0, };
int dist[100001];
int bdist[100001];
int lmax = 0;

void mark(int cur, int curdist)
{
	dist[cur] = curdist;

	for (int i = 0; i < graph[cur].size(); i++)
	{
		int next;

		next = graph[cur][i];

		if (!avisited[next])
		{
			avisited[next] = true;

			mark(next, curdist + 1);
		}
	}
}

void dfs(int cur, int curdist)
{
	bdist[cur] = curdist;

	if (dist[cur] - 1 > lmax)
	{
		lmax = dist[cur] - 1;
	}

	if (curdist < dist[cur])
	{
		for (int i = 0; i < graph[cur].size(); i++)
		{
			int next;

			next = graph[cur][i];

			if (!bvisited[next])
			{
				bvisited[next] = true;

				dfs(next, curdist + 1);
			}
		}
	}
}

int main()
{
	int n;
	int u, v;

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

	scanf("%d %d %d", &n, &u, &v);

	for (int i = 0; i < n - 1; i++)
	{
		int a, b;

		scanf("%d %d", &a, &b);

		graph[a].push_back(b);
		graph[b].push_back(a);
	}

	avisited[v] = true;
	mark(v, 0);

	bvisited[u] = true;
	dfs(u, 0);

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

	return 0;
}


Measured memory_bytes: 10496