akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void)
{
		int t,n,x[4],i,j;
		for(i=0;i<4;i++){
			scanf("%d %d",&t,&n);
		if(t==1){
			x[i]=n*6000;
			}
		if(t==2){
			x[i]=n*4000;
			}
		if(t==3){
			x[i]=n*3000;
			}
		if(t==4){
			x[i]=n*2000;
			}
		}	
		for(j=0;j<4;j++){
			printf("%d\n",x[j]);
			}
		return 0;
}

Measured memory_bytes: 1028
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>

using namespace std;
typedef long long ll;
typedef long long int llint;
typedef pair<ll, ll> pa;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define MAX_T 1001
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define INF (1 << 29) //536870912

const long double PI = acos(-1);
const ll DEP = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};
int GCD(int x,int y){
    return y ? GCD(y,x%y) : x;
}
int main(){
    int N; cin >> N;
    int a[100001],b[100001],c[100001];
    int A[100001],B[100001],C[100001];
    for(int i = 0; i < N; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    A[0] = a[0],B[0] = b[0],C[0] = c[0];
    for(int i = 1; i < N; i++){
        A[i] = max(B[i-1],C[i-1]) + a[i];
        B[i] = b[i] + max(A[i-1],C[i-1]);
        C[i] = c[i] + max(A[i-1],B[i-1]);
    }
    cout << max(A[N-1],max(B[N-1],C[N-1])) << endl;
    return 0;
}



Measured memory_bytes: 2560
import math
X = int(input())
x = 1
y = 0
p = math.pi
count = 1
while abs(x) > 1/100000000 or abs(y) > 1/100000000:
    x += math.cos(count*X*p/180)
    y += math.sin(count*X*p/180)
    count += 1
print(count)

Measured memory_bytes: 9492
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)

bool isSubstr(string &s, string &t){
    int p = 0;
    rep(i,s.size()){
        if(s[i]==t[p]){
            p++;
        }
        if(p==t.size())break;
    }
    
    if(p==t.size())return true;
    else return false;
}

int main(){
    string s,t;
    
    cin>>s>>t;
    
//    vector<string> vs(18,"");
//    vs[1] = t;
//    int l = t.size();
//    for(int i=2;i<18;i++){
//        l = (l+1)*t.size() + l;
//        if(l>s.size())break;
//        vs[i] = t;
//        rep(j,vs[i-1].size()){
//            vs[i]+=string(1,vs[i-1][j]);
//            vs[i]+=t;
//        }
//        assert(l==vs[i].size());
//    }
//
//    for(int i=1;i<18;i++)if(vs[i]=="")vs[i] = "*";
    
    vector<string> vs(2);
    vs[1] = t;
    int ok = 0;
    for(int i=1;i<18;i++){
        
        if(isSubstr(s,vs[i%2]))ok = i;
        else break;
        int l = (vs[i%2].size()+1)*t.size() + vs[i%2].size();
        
        if(l>s.size())break;
        vs[(i+1)%2] = t;
        rep(j,vs[i%2].size()){
            vs[(i+1)%2] += string(1,vs[i%2][j]);
            vs[(i+1)%2] += t;
        }
    }
    cout<<ok<<endl;
}




Measured memory_bytes: 3344
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(ll i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<ll, ll>;
#define debug(var) cerr << "[" << #var << "] " << var << endl
#define chmin(x, y) x = min(x, y)
const ll mod = 1000000007;
const int dx[] = {-1,0,1,0};
const int dy[] = {0,-1,0,1};



int main(){
    ll n;
    cin >> n;
    
    vector<ll> p(n*n);
    
    rep(i, n*n) {
        cin >> p[i];
        p[i]--;
    }
    ll ans = 0;

    vector<vector<bool>> empty(n, vector<bool>(n));
    vector<vector<ll>> cost(n, vector<ll>(n));

    rep(i, n) rep(j, n) {
        cost[i][j] = min(i, j);
        chmin(cost[i][j], n-1-i);
        chmin(cost[i][j], n-1-j);
    }
    
    
    rep(i, n*n) {
        ll x = p[i]/n;
        ll y = p[i]%n;
        empty[x][y] = true;
        ans += cost[x][y];
        queue<P> q;
        q.emplace(x, y);
        while (!q.empty()) {
            P now = q.front();
            q.pop();
            ll nx = now.first;
            ll ny = now.second;
            ll v = cost[nx][ny] + 1;
            if (empty[nx][ny]) v--;
            rep(j, 4) {
                ll ix = nx + dx[j];
                ll iy = ny + dy[j];
                if (ix<0 || ix>=n || iy<0 || iy>=n) continue;
                if (cost[ix][iy]>v) {
                    cost[ix][iy] = v;
                    q.emplace(ix, iy);
                }
            }
        }
    }
    
    cout << ans << endl;
    

    return 0;
}


Measured memory_bytes: 7016
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
int a,b,c,d,e,f,ansa=-1,ansb=1;
bool sugar[3010],water[3010];
int main()
{
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f);
    a*=100,b*=100;
    water[0]=sugar[0]=1;
    for(int i=0; i<f; i++)
    {
        if(water[i])
        {
            if(i+a<=f)
                water[i+a]=true;
            if(i+b<=f)
                water[i+b]=true;
        }
        if(sugar[i])
        {
            if(i+c<=f)
                sugar[i+c]=true;
            if(i+d<=f)
                sugar[i+d]=true;
        }
    }
    for(int i=100; i<=f; i+=100)
        if(water[i])
            for(int j=0; i+j<=f&&j<=e*i/100; j++)
                if(sugar[j])
                    if(j*ansb>ansa*(i+j))
                        ansa=j,ansb=i+j;
    printf("%d %d",ansb,ansa);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define NUM 200000

int main(void){
	int C[NUM];
	char c_i;
	int N;
	int count_R = 0;
	int count_W = 0;
	int act = 0;
	int k;

	scanf("%d", &N);
	for (k = 0; k <= N; k++) {
		scanf("%c", &c_i);
		if (c_i == 'R') {
			count_R++;
			C[k] = 0;
		} else if (c_i == 'W') {
			count_W++;
			C[k] = 1;
		}
//		printf("%d", C[k]);
	}
	puts("");

	for (k = 1; k <= count_R; k++) {
		act += C[k];
	}


//	printf("%d\n", count_R);
//	printf("%d\n", count_W);
	printf("%d\n", act);

	return 0;
}


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

int n,m,a[200005],b[200005];

int main()
{
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    cin>>m;
    for(int i=1;i<=m;i++)
        cin>>b[i];
    sort(a+1,a+n+1);
    sort(b+1,b+m+1);
    int tmp=1;
    for(int i=1;i<=n;i++)
        if(tmp<=m&&a[i]==b[tmp])
            tmp++;
    if(tmp>m)
        cout<<"YES";
    else
        cout<<"NO";
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1

struct Node { int p, l, r;};

Node T[MAX];
int n;

void preParse(int u) {
  if (u == NIL) return;
  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u) {
  if (u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u) {
  if (u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main() {
  int i, v, l, r, root;

  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    T[i].p = NIL;
  }
  for (i = 0; i < n; i++) {
    scanf("%d %d %d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if ( l != NIL) T[l].p = v;
    if ( r != NIL) T[r].p = v;
  }

  for ( i = 0; i < n;i++) if (T[i].p == NIL) root = i;
  printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");
}



Measured memory_bytes: 3212
#if 0

#endif
#include <vector>
#include <algorithm>
#include <iostream>
#include <iomanip>
#define MAX_M 105
#define MAX_N 105
#define INF (1 << 30)
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
using namespace std;

int M, N;
int X1[MAX_M], Y1[MAX_M];
int X2[MAX_N], Z2[MAX_N];

double width(int X[], int Y[], int n, double x) {
    double lb = INF, ub = -INF;
    rep(i, n) {
        // cout << X[i] << Y[i] << endl;
        double x1 = X[i], y1 = Y[i];
        double x2 = X[(i + 1) % n], y2 = Y[(i + 1) % n];
        if ((x1 - x) * (x2 - x) <= 0 && x1 != x2) {
            double a = (y1 - y2) / (x1 - x2);
            double b = (y1 * x2 - y2 * x1) / (x2 - x1);
            double y = a * x + b;
            lb = min(lb, y);
            ub = max(ub, y);
        }
    }
    // cout << max(0.0, ub - lb) << endl;
    // cout << "------------" << endl;
    return ub - lb;
}

void solve() {
    int min1 = *min_element(X1, X1 + M), max1 = *max_element(X1, X1 + M);
    int min2 = *min_element(X2, X2 + N), max2 = *max_element(X2, X2 + N);
    vector<int> xs;
    rep(i, M)
        xs.push_back(X1[i]);
    rep(i, N)
        xs.push_back(X2[i]);
    sort(xs.begin(), xs.end());

    double total = 0;
    rep(i, xs.size() - 1) {
        double a = xs[i], b = xs[i + 1], c = (a + b) / 2;
        if (min1 <= c && c <= max1 && min2 <= c && c <= max2) {
            double fa = width(X1, Y1, M, a) * width(X2, Z2, N, a);
            double fb = width(X1, Y1, M, b) * width(X2, Z2, N, b);
            double fc = width(X1, Y1, M, c) * width(X2, Z2, N, c);
            total += (b - a) / 6 * (fa + 4 * fc + fb);
        }
    }

    cout << fixed << setprecision(15) << total << endl;
}

int main() {
    while (cin >> M >> N) {
        if (M == 0 && N == 0)
            break;

        rep(i, M)
            cin >> X1[i] >> Y1[i];
        rep(i, N)
            cin >> X2[i] >> Z2[i];

        solve();
    }
}


Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
#define f1(a,b,c) for(int c=a;c<=b;c++)
#define f2(a,b,c) for(int c=a;c>=b;c--)
#define f3(a,b,c) for(int c=a;c;c=b)
#define so1(a,n) sort(a+1,a+n+1,mycmp);
#define so2(a,n) sort(a+1,a+n+1);
#define ll long long
#define itn int
#define ubt int 
const int twx=3e5+100;
const int inf=0x7fffffff;
const int MOD=1e9+7;
ll read()
{
    ll sum=0;
    ll flag=1;
    char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')
        {
            flag=-1;
        }
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        sum=((sum*10)+c-'0');
        c=getchar();
    }
    return sum*flag;
}
int ADD(int a,int b)
{
    return a+b>=MOD?a+b-MOD:a+b;
}
int SUB(int a,int b)
{
    return a-b<0?a-b+MOD:a-b;
}
int MUL(int a,int b)
{
    return 1LL*a*b%MOD;
}
int n,m,k;
int jc[twx<<2];
int inv[twx<<2];
int invj[twx<<2];
int p[twx<<2];
int ans(0);
int x=1;
void pre()
{
    p[0]=1;
    f1(1,twx*3,i)
    {
        p[i]=MUL(p[i-1],3);
    }
    jc[0]=1;
    f1(1,twx*3,i)
    {
        jc[i]=MUL(jc[i-1],i);
    }
    inv[1]=1;
    f1(2,twx*3,i)
    {
        inv[i]=MUL(SUB(MOD,MOD/i),inv[MOD%i]);
    }
    invj[0]=1;
    f1(1,twx*3,i)
    {
        invj[i]=MUL(invj[i-1],inv[i]);
    }
}
int C(int n, int m)
{
	return MUL(jc[n],MUL(invj[m],invj[n-m]));
}
void init()
{
	n=read();
    m=read();
    k=read();
}
void work()
{
	if(m<k)
    {
        swap(m,k);
    }
	--n;
    f1(0,m+k,i)
    {
        ans=ADD(ans,MUL(C(n+i,n),MUL(p[m+k-i],x)));
        if(i<k)
        {
            x=MUL(x,2);
        }
        else if(i<m)
        {
            x=SUB(MUL(x,2),C(i,k));
        }
        else   
        {
            x=SUB(MUL(x,2),ADD(C(i,m),C(i,k)));
        }
    }
}
void print()
{
	printf("%d\n",ans);
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
    init();
    pre();
    work();
    print();
	return 0;
}

Measured memory_bytes: 18688
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <numeric>
#include <regex>
#include <climits>

#define FOR(i, f, n) for(int (i) = (f); (i) < (n); (i)++)
#define RFOR(i, f, n) for(int (i) = (f); (i) >= (n); (i)--)
#define REP(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define RREP(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define forin(i, a) for(auto i: (a))
#define p(...) printf(__VA_ARGS__); cout << endl;
#define in(...) __VA_ARGS__; input__(__VA_ARGS__);
#define input(...) in(__VA_ARGS__)
#define out(...) output__(__VA_ARGS__);
#define output(...) out(__VA_ARGS__)
#define list_input(x, n) x[(n)]; for(int (i) = 0; (i) < (n); (i)++) cin >> x[i];
#define lambda(a, b, c) [](auto const &a, auto const &b){ return c ;}
#define key(t, x, compare) [](const t &a, const t &b){ return a x compare b x ;}
#define unless(a) if(!(a))

using namespace std;

using pii = pair<int, int>;

template <class... T>
void input__(T &...a) {
  for(auto v: {&a...}) {
    cin >> *v;
  }
}

void output__(){
  cout << endl;
}

template <class Head, class... T>
void output__(Head const &v, T const &...a) {
  if(sizeof...(a) == 0) {
    cout << v;
  } else {
    cout << v << " ";
  }
  output__(a...);
}

int main(){
  int in(a) out(a / 3);
}


Measured memory_bytes: 256
//スキャナークラスをインポート
import java.util.Scanner;


/**
 * 円の面積と円周の長さを求める
 */
 
 
class Main{
	
	public static void main (String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		
		//小数点を使うのでdoubleにする
		double r = sc.nextDouble();
		
		
		//Math.PIは円周率(3.14)
		System.out.printf("%.6f %.6f",r * r * Math.PI, (r + r) * Math.PI);
		 
		
	}
	
}	




Measured memory_bytes: 28388
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI 2*acos(0.0)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false

///................function.....................///
#define siz(s) (int)(s.size())
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define dbg(a) cout << #a << " = " << a << " ";
///...........knight moves.....................///
///int dx[] = {+1,+1,-1,-1,+2,+2,-2,-2};
///int dy[] = {+2,-2,+2,-2,+1,-1,+1,-1};
const ll mod=1000000007;
ll lcm(ll a, ll b)
{
    return (a*b)/(ll)(__gcd(a,b));
}
int main()
{
    FIO;

    string s,t;
    cin>>s>>t;
    int ns=siz(s),nt=siz(t),i,j;
    int res=INT_MAX;
    for(i=0; i+nt-1<ns; i++)
    {
        int cng=0;
        for(j=0; j<nt; j++)
            if(s[i+j]!=t[j])
                cng++;
        res = min(cng,res);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3624
use std::fmt::Write;
use std::io::*;

fn main() {
    let input = {
        let mut buf = vec![];
        stdin().read_to_end(&mut buf);
        unsafe { String::from_utf8_unchecked(buf) }
    };
    let mut lines = input.split('\n');

    let n = lines.next().unwrap().parse().unwrap();

    let mut pcs = Vec::with_capacity(n);
    let iter = lines.next().unwrap().split(' ').map(|s| s.parse::<u32>().unwrap());
    pcs.extend(iter);

    for s in lines.nth(1).unwrap().split(' ') {
        let i = s.parse::<usize>().unwrap() - 1;

        if pcs[i] != 2019 && !pcs.contains(&(pcs[i] + 1)) {
            pcs[i] += 1;
        }
    }

    let mut buf = String::new();
    for p in pcs {
        writeln!(buf, "{}", p);
    }
    print!("{}", buf);
}



Measured memory_bytes: 5032
a, b, k = map(int, input().split())

ans = []
for i in range(a, min(b, a + k)):
    if i in ans:
        continue
    else:
        ans.append(i)
for i in range(max(a, b - k + 1), b + 1):
    if i in ans:
        continue
    else:
        ans.append(i)

for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  int a[100];
  int n, temp, count = 0;
  int i, j, minj;

  scanf("%d", &n);

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

  for(i = 0; i < n - 1; i++) {
    minj = i;
    for(j = i; j < n; j++) {
      if(a[j] < a[minj]) {
	minj = j;
      }
    }
    if(a[i] > a[minj]) {
      temp = a[i];
      a[i] = a[minj];
      a[minj] = temp;
      count++;
    }
  }

  for(i = 0; i < n; i++){
    printf("%d", a[i]);
    if(i < n - 1) printf(" ");
  }
  printf("\n");
  printf("%d\n", count);

  return 0;
  
}

Measured memory_bytes: 604
from math import sqrt, ceil

def factors_set(number):
    factors = set()
    for i in range(1, ceil(sqrt(number))+1):
        if number % i == 0:
            factors.add(i)
            factors.add(number // i)
    return factors

N = int(input())

Ks = factors_set(N-1) | factors_set(N)
Ks.remove(1)

ans = 0
for K in Ks:
    N_tmp = N
    while N_tmp % K == 0:
        N_tmp //= K
    if N_tmp % K == 1:
        ans += 1

print(ans)


Measured memory_bytes: 3952
n = int(input())
a = list(map(int, input().split()))
b = list(map(int,input().split()))
c = list(map(int, input().split()))
ans = 0
for i in range(n):
  ans += b[a[i]-1]
  if i < n-1 and a[i] + 1 == a[i+1] :
    ans += c[a[i]-1]

print(ans)

Measured memory_bytes: 3064
# coding: utf-8
O = input()
E = input()
ans = ""
o_idx, e_iex = 0, 0
for i in range(len(O)+len(E)):
    if i % 2 == 1:
        ans += E[e_iex]
        e_iex += 1
    else:
        ans += O[o_idx]
        o_idx += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> A(N), B(N), C(N);
  for(int i=0; i<N; i++)cin>>A[i];
  for(int i=0; i<N; i++)cin>>B[i];
  for(int i=0; i<N-1; i++)cin>>C[i];

  int ans = 0;
  for(int i=0; i<N; i++)ans += B[i];

  for(int i=0; i<N-1; i++){
    if(A[i]+1 == A[i+1])ans += C[A[i]-1];
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979323846
#define mod 1000000007
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

int main(){
	fast;
	
	ll int a,b,k;
	cin>>a>>b>>k;
	
	if(k>a){
		k=k-a;
		a=0;
	}
	
	else{
		a=a-k;
		k=0;	
	}
	
	//cout<<k<<" ";
	if(a==0 && k!=0){
		ll int c=min(k,b);
		k=k-c;
		b=b-c;
	}
	
	cout<<a<<" "<<b;
	return 0;
}


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

using namespace std;
int main()
{
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	
	int f = 0;
	if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2])
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}



}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<string>
#include<complex>
#include<random>
#include<time.h>
#define INF 1000000000ll
#define MOD 1000000007ll
#define EPS 1e-8
#define REP(i, m) for(long long i = 0; i < m; ++i)
#define FOR(i, n, m) for(long long i = n; i < m; ++i)
#define ALL(v) v.begin(), v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<ll> vl;
typedef vector<vector<ll> > vll;
 
ll N = 100001;
ll bit[100001];
#define MAX_N 1000000
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	} else {
		x = 1; y = 0;
	}
	return d;
}
ll mod_inverse(ll a, ll m) {
	ll x, y;
	if(extgcd(a, m, x, y) == 1) return (m + x % m) % m;
	else return -1;
}
vector<ll> fact(MAX_N+1, INF);
ll mod_fact(ll n, ll& e) {
	if(fact[0] == INF) {
		fact[0]=1;
		if(MAX_N != 0) fact[1]=1;
		for(ll i = 2; i <= MAX_N; ++i) {
			fact[i] = (fact[i-1] * i) % MOD;
		}
	}
	e = 0;
	if(n == 0) return 1;
	ll res = mod_fact(n / MOD, e);
	e += n / MOD;
	if((n / MOD) % 2 != 0) return (res * (MOD - fact[n % MOD])) % MOD;
	return (res * fact[n % MOD]) % MOD;
}
ll mod_comb(ll n, ll k) {
	if(n < 0 || k < 0 || n < k) return 0;
	ll e1, e2, e3;
	ll a1 = mod_fact(n, e1), a2 = mod_fact(k, e2), a3 = mod_fact(n - k, e3);
	if(e1 > e2 + e3) return 0;
	return (a1 * mod_inverse((a2 * a3) % MOD, MOD)) % MOD;
}
 
 
int main() {
	ios::sync_with_stdio(false);
	string a;
	cin>>a;
	vector<ll> cnt(26,0);
	REP(i,a.size()) {
		++cnt[a[i]-'a'];
	}
	ll res=a.size()*(a.size()-1)/2;
	REP(i,26) {
		res-=cnt[i]*(cnt[i]-1)/2;
	}
	cout<<res+1<<endl;
}

Measured memory_bytes: 8528
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 998244353
typedef long long ll;

using namespace std;

#define Nmax 300010
class Cmod{
private:
    ll a[Nmax],b[Nmax],c[Nmax],m;
public:
    void Init(ll x){
	m=x,a[1]=b[0]=c[0]=1;
	for(int i=1;i<Nmax;i++){
	    if(i>1)a[i]=m-m/i*a[m%i]%m;
	    b[i]=b[i-1]*i%m,c[i]=c[i-1]*a[i]%m;
	}
    }
    ll C(int n,int k){
	return b[n]*c[k]%m*c[n-k]%m;
    }
};

int main(){
    class Cmod cmod;cmod.Init(mod);
    
    ll n,a,b,k;
    cin>>n>>a>>b>>k;
    ll ans=0;
    for(ll i=0;i<=n;i++){
	ll j=k-(a*i);
	if(j%b>0||j<0)continue;
	j/=b;
	if(j<0||n<j)continue;
	ans+=cmod.C(n,i)*cmod.C(n,j);
	//cout<<"#"<<i<<" "<<j<<endl;
	ans%=mod;
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;
int main(void) {
    long n;
    cin >> n;
    vector<vector<long>> a(n, vector<long>(n, -1));

    for(int i=0; i<n; i++) {
        for(int j=i+1; j<n; j++) {
            long t = 0, k = i^j;
            while((k&1) == 0) t++, k>>=1;
            cout << (t+1) << ' ';
        }
        cout << endl;
    }
}


Measured memory_bytes: 2432
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const long long infll = (long long) 1.01e18;
const ld eps = 1e-9;
const ld pi = acos((ld) -1);

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

void precalc() {
}

const int maxn = 5005, maxm = 205;
int n, m;
int a[maxn];
int b[maxn][maxm];

int read() {
  if (scanf("%d%d", &n, &m) < 2) {
    return false;
  }
  for (int i = 0; i < n - 1; i++) {
    scanf("%d", &a[i]);
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      scanf("%d", &b[i][j]);
    }
  }
  return true;
}

struct node {
  long long add, val;
};


node st[4 * maxn];

void buildst(int v, int tl, int tr) {
  st[v].add = 0;
  st[v].val = -infll;
  if (tl == tr - 1) {
    return;
  }
  int tm = (tl + tr) / 2;
  buildst(2 * v, tl, tm);
  buildst(2 * v + 1, tm, tr);
}

void push(int v) {
  if (!st[v].add) {
    return;
  }
  st[2 * v].add += st[v].add;
  st[2 * v].val += st[v].add;
  st[2 * v + 1].add += st[v].add;
  st[2 * v + 1].val += st[v].add;
  st[v].add = 0;
}

void add(int v, int tl, int tr, int l, int r, long long toadd) {
  if (tl == l && tr == r) {
    st[v].add += toadd;
    st[v].val += toadd;
    return;
  }
  push(v);
  int tm = (tl + tr) / 2;
  if (l < tm) {
    add(2 * v, tl, tm, l, min(r, tm), toadd);
  }
  if (r > tm) {
    add(2 * v + 1, tm, tr, max(l, tm), r, toadd);
  }
  st[v].val = max(st[2 * v].val, st[2 * v + 1].val);
}

vector< pair<int, int> > stck[maxm];

void solve() {
  for (int i = 0; i < m; i++) {
    stck[i].clear();
  }
  buildst(1, 0, n);
  long long res = -infll;
  for (int i = 0; i < n; i++) {
    long long cur = 0;
    for (int j = 0; j < m; j++) {
      cur += b[i][j];
      int lst = i;
      while (!stck[j].empty() && stck[j].back().second <= b[i][j]) {
        add(1, 0, n, stck[j].back().first, lst, b[i][j] - stck[j].back().second);
        lst = stck[j].back().first;
        stck[j].pop_back();
      }
      stck[j].push_back(make_pair(lst, b[i][j]));
    }
    if (i) {
      add(1, 0, n, 0, i, -a[i - 1]);
    }
    add(1, 0, n, i, i + 1, cur + infll);
    res = max(res, st[1].val);
  }
  printf("%lld\n", res);
}

int main() {
  precalc();
#ifdef LOCAL
  assert(freopen(TASK ".in", "r", stdin));
  assert(freopen(TASK ".out", "w", stdout));
#endif
  while (true) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 4608
import heapq
from sys import stdin
N, M = [int(_) for _ in stdin.readline().rstrip().split()]
A = [(-1)*int(_) for _ in stdin.readline().rstrip().split()]
heapq.heapify(A)
for i in range(M):
    tmp = heapq.heappop(A)
    heapq.heappush(A, (-1)*(-tmp//2))
print(-sum(A))

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

int main(){
  int N,L;
  cin>>N>>L;
  
  int A[N];
  int sum=0;
  int min=500;
  int min_a;
  for(int i=0;i<N;i++){
   A[i]=L+i; 
   sum+=A[i];
   if( abs(A[i]) < min ) {
     min=abs(A[i]);
     min_a=i;
   }
  }
  
  cout << sum-A[min_a] << endl;
  
  return 0;
}

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

using namespace std;

bool cmp(vector<int>& x, vector<int>& y) {
	return x[0] < y[0];
}

int main() {
	int n, d;
	long long a;
	cin >> n >> d >> a;
	vector<vector<int>> e(n, vector<int>(2));
	for (int i = 0; i < n; i++) {
		cin >> e[i][0] >> e[i][1];
	}
	sort(e.begin(), e.end(), cmp);
	queue<pair<int, int>> b;
	long long c = 0, ans = 0;
	for (int i = 0; i < n; i++) {
		while (b.size() > 0 && b.front().first < e[i][0] - d) {
			c -= b.front().second;
			b.pop();
		}
		int t = (max(1LL * e[i][1] - a * c, 0LL) + a - 1) / a;
		b.push(make_pair(e[i][0] + d, t));
		c += t;
		ans += t;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 12800
import java.util.Arrays;
import java.util.Scanner;
class Main{
	public static void main(String[]$){
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),a[]=new int[n];
		for(int i=0;i<n;++i)
			a[i]=s.nextInt();
		for(int i=0;i<32;++i) {
			int b=1<<i;
			if(Arrays.stream(a).anyMatch(o->o%b!=0)) {
				System.out.println(i-1);
				return;
			}
		}
	}
}

Measured memory_bytes: 26964
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        for(int i = 0; i<s.length(); i++){
            char c = s.charAt(i);
            if(c>=65 && c <= 90) System.out.printf("%c", c+32);
            else if(c>=97 && c<=122) System.out.printf("%c", c-32);
            else System.out.printf("%c", c);
        }
        System.out.printf("\n");
        sc.close();
    }
}


Measured memory_bytes: 29556
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<iostream>
//#include<random>
#include<functional>
#include<list>
#include<cstdlib>
#include<stdlib.h>
#include<vector>
#define lld long long int
#define INF 0x7fffffff
using namespace std;

typedef pair<int, int> P;
struct edge
{
	int v, d, c;
	edge(int _v = 0, int _d = 0, int _c = 0):v(_v),d(_d),c(_c){}
};

vector<edge>G[1005000];
int n, m;
int dis[1005000];


void dijsktra(int s)
{
	fill(dis, dis + 100000, INF);
	dis[s] = 0;
	priority_queue<P, vector<P>, greater<P> > q;
	q.push(P(dis[s], s));
	while (!q.empty())
	{
		int now = q.top().second;
		if (dis[now] < q.top().first)
		{
			q.pop();continue;
		}
		else q.pop();
		for (int i = 0;i < G[now].size();i++)
		{
			int d = G[now][i].d + dis[now];
			if (dis[G[now][i].v] > d)
			{
				dis[G[now][i].v] = d;
				q.push(P(dis[G[now][i].v], G[now][i].v));
			}
		}
	}
}

int main()
{
	while (~scanf("%d%d",&n,&m))
	{
		if (n == 0 && m == 0)break;
		for (int i = 0;i < n;i++)///
			G[i].clear();
		for (int i = 0;i < m;i++)
		{
			int a, b, c, d;
			scanf("%d%d%d%d", &a, &b, &c, &d);
			a--;b--;
			G[a].push_back(edge(b, c, d));
			G[b].push_back(edge(a, c, d));
		}
		dijsktra(0);
		int ans = 0;
		for (int i = 1;i < n;i++)
		{
			int min_cost = INF;
			for (int j = 0;j < G[i].size();j++)
				if ((dis[i] == dis[G[i][j].v] + G[i][j].d)&&min_cost>G[i][j].c)
				{
					min_cost = G[i][j].c;
				}
			ans += min_cost;
		}
		printf("%d\n", ans);
	}
}

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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, q;
  cin >> n >> q;
  vector<vector<int>> p(n);
  for (int i = 0; i < n - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  vector<ll> lz(n), ans(n);
  for (int i = 0; i < q; i++) {
    ll j, x;
    cin >> j >> x;
    j--;
    lz[j] += x;
  }
  function<void(int, int, ll)> dfs = [&](int i, int from, ll v) {
    ans[i] = lz[i] + v;
    for (auto &j : p[i]) {
      if (j == from) continue;
      dfs(j, i, lz[i] + v);
    }
  };
  dfs(0, -1, 0);
  cout << ans[0];
  for (int i = 1; i < n; i++) cout << " " << ans[i];
  cout << endl;
  return 0;
}


Measured memory_bytes: 35200
#include<bits/stdc++.h>
#define M 27
#define N 5
using namespace std;
int n,c[2][N][N][N],m1,m2,a[M],b[M],num=1;

int Count(int x,int y,int z,int t){
  int d[3]={-1,0,1},res=0;
  for(int i=0;i<3;i++)
    for(int j=0;j<3;j++)
      for(int k=0;k<3;k++){
	int nx=x+d[i],ny=y+d[j],nz=z+d[k];
	if(!d[i]&&i==j&&j==k)continue;
	if(nx<0||ny<0||nz<0)continue;
	if(N<=nx||N<=ny||N<=nz)continue;
	if(c[t][nx][ny][nz])res++;
      }
  return res;
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    if(num>=2)cout<<endl;
    cout<<"Case "<<num<<':'<<endl;
    string s;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++){
	cin>>s;
	for(int k=0;k<N;k++){
	  c[0][i][j][k]=s[k]-'0';
	}
      }
    cin>>m1;
    for(int i=0;i<m1;i++)cin>>a[i];
    cin>>m2;
    for(int i=0;i<m2;i++)cin>>b[i];
    for(int l=0;l<n;l++){
      int idx=l%2;
      for(int i=0;i<N;i++)
	for(int j=0;j<N;j++){
	  for(int k=0;k<N;k++){
	    int r=Count(i,j,k,idx),f=0;
	    if(!c[idx][i][j][k]){
	      for(int p=0;p<m1;p++)
		if(r==a[p])f=1;
	      if(f)c[!idx][i][j][k]=1;
	      else c[!idx][i][j][k]=0;
	    }else{
	      for(int p=0;p<m2;p++)
		if(r==b[p])f=1;
	      if(!f)c[!idx][i][j][k]=0;
	      else c[!idx][i][j][k]=1;
	    }
	  }
	}
    }
    for(int i=0;i<N;i++){
      for(int j=0;j<N;j++){
	for(int k=0;k<N;k++)
	  cout<<c[n%2][i][j][k];
	cout<<endl;
      }
      if(i!=N-1)cout<<endl;
    }
    num++;
  }
  return 0;
}

Measured memory_bytes: 1212
#include <stdio.h>

char a[111][111];

int main(void)
{
	int W, B, i, j;

	scanf("%d %d" ,&W, &B);

	/* . is white, # is black */

	for (i = 0; i < 100; i++)
		for (j = 0; j < 100; j++)
            a[i][j] = (i < 50 ? '.' : '#');

    for (i = 0; i < B - 1; i++)
		a[(i / 50) * 2][(i % 50) * 2] = '#';

	for (i = 0; i < W - 1; i++)
		a[(i / 50) * 2 + 55][(i % 50) * 2] = '.';

	puts("100 100");
	for (i = 0; i < 100; i++)
		puts(a[i]);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ


#define LEFT(i) (2*(i))
#define RIGHT(i) (2*(i)+1)
#define PARENT(i) ((i)/2)

//priorityに対してプライオリティキューを構築
typedef struct{
    double priority;
    double value;
}heapdata; //heapの構造体の中の要素を定義

//ヒープ二分木のポインタをheap型と定義
typedef struct{
    int max_size; //ヒープ二分木(配列A)の中に格納できる最大要素数
    int heap_size; //ヒープ二分木(配列A)の中に現在入っている要素の数
    heapdata* A; //要素を格納するための配列(ポインタ)
}* heap;

//ヒープH内の配列のA[i]とA[j]の値を入れ替える関数
void heap_swap(heap H,int i,int j){
    heapdata tmp;
    
    tmp=H->A[i];
    H->A[i]=H->A[j];
    H->A[j]=tmp;
    
    return;
}

//ヒープの削除
void free_heap(heap H){
    free(H);
    return;
}

//HEAPIFY O(nlogn)

//A[i]を根とする部分木がヒープになるように整序する関数
void heapify(heap H, int i){
    int l,r,largest,size;
    heapdata* A;
    
    l=LEFT(i); //iの左の子の添字
    r=RIGHT(i); //iの右の子の添字
    size=H->heap_size; //今のヒープHのサイズ
    A=H->A; //ヒープ二分木に格納されている要素の配列
    
    //以下largestを決めるコード
    if(l>size&&r>size){
        largest=i;
    }
    else if(l<=size&&r>size){
        if(A[l].priority>A[i].priority){
            largest=l;
        }
        else{
            largest=i;
        }
    }
    else{
        if(A[r].priority>A[l].priority){
            largest=r;
        }
        else{
            largest=l;
        }
        if(A[i].priority>A[largest].priority){
            largest=i;
        }
    }
    
    if(largest!=i){
        heap_swap(H,i,largest);
        heapify(H,largest);
    }
    
    return;
}

//BUILD_HEAP O(n)

//要素n個の配列A、max_sizeをもつヒープ木Hのメモリを確保し出力する関数
heap heap_build(int n, heapdata* A, int max_size){
    int i;
    heap H;
    NEW(H,1);
    
    H->max_size=max_size;
    H->heap_size=n;
    H->A=A;
    
    for(i=n/2;i>=1;i--){
        heapify(H,i);
    }
    
    return H;
}

//EXTRACT_MAX O(logn)

//ヒープ木の中の最大要素を削除し、その最大要素を除いたヒープ木を再構成する関数
heapdata extract_max(heap H){
    int n=H->heap_size;
    
    heap_swap(H,1,n);
    H->heap_size=n-1;
    heapify(H,1);
    
    return H->A[n];
}

//data xをヒープHに挿入する関数
void heap_insert(heap H,heapdata x){
    int n=H->heap_size;
    
    if(n==H->max_size){
        printf("ERROR　cannot insert anymore\n");
        return;
    }
    else{
        H->A[n+1]=x;
        H->heap_size=n+1;
        
        int i=n+1;
        while(PARENT(i)>=1&&H->A[i].priority>H->A[PARENT(i)].priority){
            heap_swap(H,i,PARENT(i));
            i=PARENT(i);
        }
        return;
    }
}


int main(void){
    int N, M;
    scanf("%d %d",&N, &M);

    heapdata* A;
    NEW(A,N+1); //A[1]~A[N]と思われ
    for(int i=1;i<=N;i++){
        scanf("%lf",&A[i].priority);
    }

    heap H = heap_build(N,A,N);
    while(M!=0){
        heapdata h = extract_max(H);
        h.priority=(h.priority)/2;
        heap_insert(H,h);
        M--;
    }

    long ans=0;
    for(int i=1;i<=N;i++){
        int tmp=A[i].priority;
        ans+=tmp;
    }
    printf("%ld\n",ans);

    return 0;
}


//400点
//プライオリティーキューってheap木のことね！！！

Measured memory_bytes: 1792
#include <stdio.h>
#include <stdint.h>

#ifdef DEBUG
#define DEBUG_LOG(fmt, ...)   printf(fmt, ##__VA_ARGS__)
#else
#define DEBUG_LOG(fmt, ...)
#endif

using namespace std;
int main()
{
    uint32_t m1, m2, d1, d2;
    scanf(" %u %u", &m1, &d1);
    scanf(" %u %u", &m2, &d2);
    if (m1 != m2)
        printf("1\n");
    else
        printf("0\n");
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int gcd( int x, int y){
    int r=min(x,y);
    while(r!=0){
        r=max(x,y)%min(x,y);
        if(r==0) return min(x,y);
        if(x>y) x=r;
        else y=r;
    }
    
}
int main(void){
    int n; cin>>n;
    vector <int> monster (n);
    for (int i=0;i<n;i++){
        cin>>monster[i];
        if(i>0) monster[i]=gcd(monster[i],monster[i-1]);
    }
    cout<<monster[n-1]<<endl;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define INF 2000000000
#define MOD 1000000007
#define EPS (1e-10)

using namespace std;

int main(int argc, char *argv[]) {

	int N; cin >> N;

	vector<int> A(N,0);

	for (int i = 0; i < N-1; i++) {
		int a; cin >> a;
		A[a-1]++;
	}

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



	return 0;
}


Measured memory_bytes: 4060
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n,m = map(int,input().split())
if n % 2 == 1:
  a = 1; b = n
  for i in range(m):
    print(a,b)
    a += 1;b -= 1
else:
  a = 1; b = n
  tmp = n
  while b-a > n//2:
    print(a,b)
    a += 1
    b -= 1
    count += 1
    if count >= m:exit()
  b-=1
  for i in range(m-count):
    print(a,b)
    a += 1
    b -= 1


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

const int MAXN = 2e5+4;
int a[MAXN];

//random_02
int main() {
    //freopen("c/in/random_20.in", "r", stdin);

    int k,n;
    cin>>k>>n;

    int maxx = 0;
    cin>>a[0];
    for (int i=1; i<n; i++) {
        cin>>a[i];
        maxx = max(maxx, a[i]-a[i-1]);
    }
    maxx = max(maxx, k+a[0]-a[n-1]);

    cout << k - maxx << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int A, B;
    cin >> A >> B;
    int ans = 0;
    int outlet = 1;
    while (outlet < B)
    {
        --outlet;
        outlet += A;
        ++ans;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define vi vector<int>
#define ppi pair<int,pi>
#define ld long double
#define pb push_back
#define eb emplace_back
#define F first
#define S second
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << end
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define f(i, begin, end) for (__typeof(end) i = (begin); i != (end) ; i += 1 - 2 * ((begin) > (end)))
#define nl cout<<"\n";
#define par(a,n) f(i,0,n) cout<<a[i]<<" "; nl
//void prt(int x) {cerr << x;}
#define vv(n,m) vector <vector <int> > v(n, vector <int> (m));

#define er(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... brgs>
void err(istream_iterator<string> it, T a, brgs... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);	
}
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
typedef pair<int,int> pii;
typedef vector<pii> vpii;
const int mod = 1000000007;
const int N = 3e5;

int kadane(int*a, int n);
bool isPrime(int n);
int mpow(int a, int b);


void solve(){
    int n;
    cin>>n;
    string s="";
    while(n>=1){
      int x=n%26;
     // er(x,n);
      n/=26;
      // if(x==0) s+='z';
      // else
      if(x==0) s+='z',n--;
      else
      s+=(char)(x+96);
    }
    reverse(all(s));
    cout<<s<<endl;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    // int t;
    // cin>>t;
    // while(t--)
    solve();
        
}

int mpow(int a, int b){ /* pow(a, b) % m */
  int m=mod;
  int x=1;
  while (b>0){
    if (b&1){
      x=(x * a) % m;
    }
    a=(a*a) % m; /* compute the next power of 2 */
    b>>=1; /* this is equivalent to b = floor(b / 2) */
  }
  return x;
}
bool isPrime(int n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
    return true; 
} 

int kadane(int*a, int n){
    int max_so_far = INT_MIN, max_ending_here = 0;
    f(i,0,n){
        max_ending_here+=a[i];
        max_so_far = max(max_so_far, max_ending_here);
        if(max_ending_here<0) max_ending_here=0;
    }
    return max_so_far;
}

Measured memory_bytes: 3648
// abc061_b
#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)
#define show1d(v) rep(i,v.size())cout<<" "<<v[i];cout<<endl<<endl;
#define show2d(v) rep(i,v.size()){rep(j,v[i].size())cout<<" "<<v[i][j];cout<<endl;}cout<<endl;
using namespace std;
typedef long long 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;
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;}
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 argc, char *argv[])
{
  int n,m,a,b;
  cin>>n>>m;
  int ans[50] = {0};
  rep(i,m) {
    cin >> a >> b;
    ans[a-1]++;
    ans[b-1]++;
  }

  rep(i,n) {
    cout<<ans[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    N = int(input())
    a = [int(x) for x in input().split()]
    apoints = 0
    bpoints = 0
    for i in range(N):
        if i%2 == 0:
            apoints += max(a)
        else:
            bpoints += max(a)
        a.remove(max(a))
    print(apoints - bpoints)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=100000000000000001;
struct edge{int to,cost;};
struct pos{
	int x,y,cost;
};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
ll gcd(ll a2,ll b2){
	int t;
	while(b2!=0){
		t=a2%b2;
		a2=b2;
		b2=t;
	}
	return a2;
}
int main() {

	int r[4001]={},g[4001]={},b[4001]={};
	int n;
	cin>>n;
	string s;
	cin>>s;
	rrep(i,s.size()){
		r[i]=r[i+1];
		g[i]=g[i+1];
		b[i]=b[i+1];
		if(s[i]=='R')r[i]++;
		if(s[i]=='G')g[i]++;
		if(s[i]=='B')b[i]++;
	}
	ll t=0;
	rep(i,n-2){
		for(int j=i+1; j<n-1; j++){
			if(s[j]==s[i])continue;
			if(s[j]=='R'&&s[i]=='G'){
				t+=b[j];
				if(s[j+(j-i)]=='B')t--;
			}
			if(s[j]=='R'&&s[i]=='B'){
				t+=g[j];
				if(s[j+(j-i)]=='G')t--;
			}
			if(s[j]=='G'&&s[i]=='R'){
				t+=b[j];
				if(s[j+(j-i)]=='B')t--;
			}
			if(s[j]=='G'&&s[i]=='B'){
				if(s[j+(j-i)]=='R')t--;
				t+=r[j];
			}
			if(s[j]=='B'&&s[i]=='R'){
				t+=g[j];
				if(s[j+(j-i)]=='G')t--;
			}
			if(s[j]=='B'&&s[i]=='G'){
				t+=r[j];
				if(s[j+(j-i)]=='R')t--;
			}
		}
	}
	cout<<t<<endl;
	return 0;
}


Measured memory_bytes: 3680
N = int(input())
Ns = []
for i in range(N):
    word = input()
    Ns.append(word)
M = int(input())
Ms = []
for i in range(M):
    word = input()
    Ms.append(word)
unique_words = list(set(Ns+Ms))
ans = 0
for word in unique_words:
    ans = max(ans,Ns.count(word)-Ms.count(word))
print(ans)

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

bool isNumberIncludedInArray(int *numArray,int num,int target){
	for(int i = 0; i < num; i++){
		if( target == numArray[i]) return true;
	}
	return false;
}

int main()
{

	//1. 入力を変数に格納
	int numS,numT;
	cin >> numS;
	int *arrayS = new int[numS];
	for(int i = 0; i < numS; i++){
		cin>> arrayS[i];
	}
	cin >> numT;
	int *arrayT = new int[numT];
	for(int i = 0; i < numT; i++){
		cin>> arrayT[i];
	}
	
	//2. arrayTのそれぞれの数字がarraySに含まれているかどうか。
	//含まれている場合、sumOfIncludedNumberをインクリメントする
	int sumOfIncludedNumber = 0;
	for(int i = 0; i < numT; i++){
		if( isNumberIncludedInArray(arrayS,numS,arrayT[i]) == true ) sumOfIncludedNumber++;
	}
	cout << sumOfIncludedNumber << endl;
	return 0;
}





Measured memory_bytes: 3096
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long n, long long m, vector<long long> x, vector<long long> y){
	ll sumx = 0, sumy = 0;
	rep(i, n) {
		sumx = (sumx + (2*i-n+1) * x[i]) % mod;
	}
	rep(i, m) {
		sumy = (sumy + (2*i-m+1) * y[i]) % mod;
	}
	cout << sumx * sumy % mod << endl;
}

int main(){	
	long long m;
	long long n;
	scanf("%lld",&n);
	vector<long long> x(n-1+1);
	scanf("%lld",&m);
	vector<long long> y(m-1+1);
	for(int i = 0 ; i <= n-1 ; i++){
		scanf("%lld",&x[i]);
	}
	for(int i = 0 ; i <= m-1 ; i++){
		scanf("%lld",&y[i]);
	}
	solve(n, m, x, y);
	return 0;
}



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

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

  int n, k;
  cin >> n >> k;
  int tot = 0;
  for (int i = 0; i < n; i++) {
    int x;
    cin >> x;
    tot += min(x, k - x) * 2;
  }
  cout << tot << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int,int>;
 
int main(){
  ll n,m;
  cin >> n >> m;
  priority_queue<ll> a;
  rep(i,n) {
    ll x;
    cin >> x;
    a.push(x);
  }

  rep(i,m){
    ll y;
    y = a.top();
    a.pop();
    y /= 2;
    a.push(y);
  }

  ll ans =0;
  while(!a.empty()){
    ans += a.top();
    a.pop();
  }
  cout << ans << endl;
}

Measured memory_bytes: 1400
#include <iostream>

int main() {
  int a, b, c;
  std::cin >> a >> b >> c;

  int colors = 0;
  bool ab = (a == b);
  bool bc = (b == c);
  bool ca = (c == a);
  if ( ab && bc ) {
    colors = 1;
  } else if ( ab || bc || ca ) {
    colors = 2;
  } else {
    colors = 3;
  }

  std::cout << colors << std::endl;

  return 0;
}


Measured memory_bytes: 256
#coding:utf-8
#1_5_B
def merge(array, left, mid, right):
    global cnt
    L = array[left:mid]  + [sentinel]
    R = array[mid:right] + [sentinel]
    i = j = 0
    for k in range(left, right):
        if L[i] <= R[j]:
            array[k] = L[i]
            i += 1
        else:
            array[k] = R[j]
            j += 1
    cnt += right - left

def merge_sort(array, left, right):
    if left + 1 < right:
        mid = (left + right) // 2
        merge_sort(array, left, mid)
        merge_sort(array, mid, right)
        merge(array, left, mid, right)


n = int(input())
S = list(map(int, input().split()))
cnt = 0
sentinel = 10 ** 9 + 1
merge_sort(S, 0, len(S))
print(*S)
print(cnt)

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll A,B,C,K;
    cin >> A >> B >> C >> K;
    ll ans = A - B;
    if(K%2) ans = B - A;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
def gcd(x, y):
    if x < y:
        x, y = y, x
    while y > 0:
        x, y = y, x % y
    return x

def lcm(a, b):
    return (a * b) // gcd(a, b)

a,b,c,d = map(int,input().split())

num_C = b // c - (a - 1) // c  #約数にCを持つものの個数
num_D = b // d - (a - 1) // d  #約数にDを持つものの個数
num_CD = b // lcm(c, d) - (a - 1) // lcm(c, d)
#print(num_C, num_D, num_CD)
ans = (b - a + 1) - num_C - num_D + num_CD
print(ans)


Measured memory_bytes: 3064