akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <string>
#include <cstring>
using namespace std;

#define INF (1<<24)

bool cross(int l, int r)
{
	if(l==4 || r==4) return false;
	return ( (l%3 > r%3) ? true : false );
}

int main()
{
	//ifstream cin("B.txt");

	string step;
	while(cin >> step, step!="#")
	{
		int ans=INF;
		int   dp[2][9][9];
		int pleg[2][9][9];

		for(int l=0; l<9; l++)
		for(int r=0; r<9; r++)
		{
			dp[1][l][r] = INF;
		}
		dp[1][4][4] = 0;
		pleg[1][4][4] = 0;
		for(int i=0; i<step.size(); i++)
		{
			for(int l=0; l<9; l++)
			for(int r=0; r<9; r++)
			{
				dp[i&1][l][r] = INF;
			}

			for(int pl=0; pl<9; pl++)
			for(int pr=0; pr<9; pr++)
			{
				if(dp[(i+1)&1][pl][pr] != INF)
				{
					int st = step[i]-'1';

					// right
					if(!cross(pl,st))
					{
						if(pleg[(i+1)&1][pl][pr] == 0)
						{
							if(dp[i&1][pl][st] > dp[(i+1)&1][pl][pr])
							{
								dp[i&1][pl][st] = dp[(i+1)&1][pl][pr];
								pleg[i&1][pl][st] = 1;
							}
						}
						else
						{
							if(dp[i&1][pl][st] > dp[(i+1)&1][pl][pr]+1)
							{
								dp[i&1][pl][st] = dp[(i+1)&1][pl][pr]+1;
								pleg[i&1][pl][st] = 1;
							}
						}
					}

					// left
					if(!cross(st,pr))
					{
						if(pleg[(i+1)&1][pl][pr] == 0)
						{
							if(dp[i&1][st][pr] > dp[(i+1)&1][pl][pr]+1)
							{
								dp[i&1][st][pr] = dp[(i+1)&1][pl][pr]+1;
								pleg[i&1][st][pr] = 0;
							}
						}
						else
						{
							if(dp[i&1][st][pr] > dp[(i+1)&1][pl][pr])
							{
								dp[i&1][st][pr] = dp[(i+1)&1][pl][pr];
								pleg[i&1][st][pr] = 0;
							}
						}

					}

				}
			}
		}


		for(int l=0; l<9; l++)
		for(int r=0; r<9; r++)
		{
			ans=min(ans,dp[(step.size()+1)&1][l][r]);
		}



		for(int l=0; l<9; l++)
		for(int r=0; r<9; r++)
		{
			dp[1][l][r] = INF;
		}
		dp[1][4][4] = 0;
		pleg[1][4][4] = 1;
		for(int i=0; i<step.size(); i++)
		{
			for(int l=0; l<9; l++)
			for(int r=0; r<9; r++)
			{
				dp[i&1][l][r] = INF;
			}

			for(int pl=0; pl<9; pl++)
			for(int pr=0; pr<9; pr++)
			{
				if(dp[(i+1)&1][pl][pr] != INF)
				{
					int st = step[i]-'1';

					// right
					if(!cross(pl,st))
					{
						if(pleg[(i+1)&1][pl][pr] == 0)
						{
							if(dp[i&1][pl][st] > dp[(i+1)&1][pl][pr])
							{
								dp[i&1][pl][st] = dp[(i+1)&1][pl][pr];
								pleg[i&1][pl][st] = 1;
							}
						}
						else
						{
							if(dp[i&1][pl][st] > dp[(i+1)&1][pl][pr]+1)
							{
								dp[i&1][pl][st] = dp[(i+1)&1][pl][pr]+1;
								pleg[i&1][pl][st] = 1;
							}
						}
					}

					// left
					if(!cross(st,pr))
					{
						if(pleg[(i+1)&1][pl][pr] == 0)
						{
							if(dp[i&1][st][pr] > dp[(i+1)&1][pl][pr]+1)
							{
								dp[i&1][st][pr] = dp[(i+1)&1][pl][pr]+1;
								pleg[i&1][st][pr] = 0;
							}
						}
						else
						{
							if(dp[i&1][st][pr] > dp[(i+1)&1][pl][pr])
							{
								dp[i&1][st][pr] = dp[(i+1)&1][pl][pr];
								pleg[i&1][st][pr] = 0;
							}
						}

					}

				}
			}
		}

		for(int l=0; l<9; l++)
		for(int r=0; r<9; r++)
		{
			ans=min(ans,dp[(step.size()+1)&1][l][r]);
		}


		cout << ans << endl;
	}
}

Measured memory_bytes: 1140
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define VV vector
#define pb push_back
#define bitc  __builtin_popcountl
#define m_p make_pair
#define inf 200000000000000
#define MAXN 1000001
#define eps 0.0000000001
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
string char_to_str(char c){string tem(1,c);return tem;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

//////////////

#define S second
#define F first
#define int long long  

///////////// 

signed main()
{
	fastio;
	#ifdef ANIKET_GOYAL
		freopen("inputf.in","r",stdin);
		freopen("outputf.in","w",stdout);
	#endif
	int n;
	cin>>n;
	int a[n+1][3]={};
	for(int i=1;i<=n;++i)
	{
		cin>>a[i][0]>>a[i][1]>>a[i][2];
	}
	int ans[n+1][3]={};
	for(int i=1;i<=n;++i)
	{
		ans[i][0]=a[i][0]+max(ans[i-1][1],ans[i-1][2]);
		ans[i][1]=a[i][1]+max(ans[i-1][2],ans[i-1][0]);
		ans[i][2]=a[i][2]+max(ans[i-1][1],ans[i-1][0]);
	}
	cout<<max(ans[n][0],max(ans[n][1],ans[n][2]));
}

Measured memory_bytes: 4992
// https://atcoder.jp/contests/abc163/tasks/abc163_c

#include <iostream>
using namespace std;

int main(){
	int n, i, j;
	cin >> n;
	int a[n];
	for(i=0; i<n; ++i) a[i] = 0;
	for(i=1; i<n; ++i){
		cin >> j;
		a[j-1]++;
	}
	for(i=0; i<n; ++i) cout << a[i] << endl;
	return 0;
}

Measured memory_bytes: 3972
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
using namespace std;

#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define ldb ldouble

typedef tuple<int, int, int> t3;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

int IT_MAX = 1 << 18;
const ll MOD = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const db PI = acos(-1);
const db ERR = 1e-10;
#define szz(x) (int)(x).size()
#define rep(i, n) for(int i=0;i<n;i++)
#define Se second
#define Fi first

int main() {
	int N, A, B, i, j;
	scanf("%d %d %d", &N, &A, &B);
	
	int ans = 0;
	for (i = 1; i <= N; i++) {
		int s = 0, t = i;
		while (t) {
			s += t % 10;
			t /= 10;
		}
		if (A <= s && s <= B) ans += i;
	}
	return !printf("%d\n", ans);
}

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

int main()
{
    long n,m;
    int flag=0;
    scanf("%ld %ld", &n,&m);

    long s[m],c[m];
    for(int i=0;i<m;i++)
    {
        scanf("%ld %ld",&s[i],&c[i]);
    }

    long ans[3];
    for(int i=0;i<3;i++)
    {
        ans[i]=-1;
    }

    for(int i=0;i<m;i++)
    {
        if(ans[s[i]-1]==-1)
        {
            ans[s[i]-1]=c[i];
        }
        else if(ans[s[i]-1]!=c[i])
        {
            ans[s[i]-1]=-2;
        }
    }

    if(ans[0]==0&&n!=1)
    {
        flag=1;
    }
    for(int i=0;i<3;i++)
    {
        if(ans[i]==-2)
        {
            flag=1;
        }
        else if(i==0&&ans[i]==-1&&n!=1)
        {
            ans[i]=1;
        }
        else if(ans[i]==-1)
        {
            ans[i]=0;
        }
    }

    if(flag==0&&n==3)
    {
        printf("%ld",ans[0]*100+ans[1]*10+ans[2]);
    }
    else if(flag==0&&n==2)
    {
        printf("%ld",ans[0]*10+ans[1]);
    }
    else if(flag==0&&n==1)
    {
        printf("%ld",ans[0]);
    }
    else
    {
        printf("-1");
    }

    
    return 0;
}

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        MyScanner sc = new MyScanner();

        long a = sc.nextLong();
        String b = sc.next();

        int c = Integer.parseInt(b.substring(0,1)) * 100;
        c += Integer.parseInt(b.substring(2, 4));

        System.out.println(a * c / 100);
    }

    static class MyScanner {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in), 1 << 15);
        StringTokenizer tokenizer;

        String next() {
            try {
                while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                    tokenizer = new StringTokenizer(reader.readLine());
                }
            } catch (IOException ignored) {
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}

Measured memory_bytes: 32772
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		int p = Integer.parseInt(sc.next());
		int ans = (int) Math.ceil((a * 3 + p) / 2);
		System.out.println(ans);

	}

}


Measured memory_bytes: 23124
import sys
input = sys.stdin.readline
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
RB = B[::-1]

start = v = -1
seq = 0
for i,(a,b) in enumerate(zip(A,RB)):
    if a==b:
        v = a
        seq += 1
        if start == -1:
            start = i

if v == -1:
    print('Yes')
    print(*RB)
    exit()

if A.count(v) + B.count(v) > N:
    print('No')
    exit()

from bisect import bisect_left,bisect
al = bisect_left(A,v)
br = bisect(B,v)
rbl = N - br

m = min(seq,start,al,rbl)
RB[:m],RB[start:start+m] = RB[start:start+m],RB[:m]
seq -= m
start += m
if seq:
    RB[start:start+seq],RB[-seq:] = RB[-seq:],RB[start:start+seq]

assert all(a!=b for a,b in zip(A,RB))
print('Yes')
print(*RB)

Measured memory_bytes: 41724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;
struct UndirectedGraph
{
    using Pint = pair<int, int>;
    using Plint = pair<ll, int>;
    int V;
    int E;
    int dDefault;
    vector<ll> weights;
    vector<vector<Pint>> to;
    vector<Pint> edges;
 
    UndirectedGraph(int V, ll dDefault=-1) : V(V), E(0), dDefault(dDefault),
                             to(vector<vector<Pint>>(V)) {}
 
    void add_edge(int v1, int v2, ll w)
    {
        to[v1].push_back(Pint(v2, E));
        // to[v2].push_back(Pint(v1, E));
        edges.push_back(Pint(v1, v2));
        weights.push_back(w);
        E++;
    }
 
    vector<ll> dist;
    void dijkstra(int start)
    {
        dist = vector<ll>(V, dDefault);
        priority_queue<Plint, vector<Plint>, greater<Plint>> pq;
        pq.push(Plint(0, start));
 
        while (!pq.empty()) {
            Plint p = pq.top(); pq.pop();
            int v = p.second;
            if (dist[v] >= 0 && dist[v] <= p.first) continue;
            dist[v] = p.first;
            // cout << "dist[" << v << "] = " << p.first << endl;
            for (auto vnxt : to[v]) {
                ll dnxt = dist[v] + weights[vnxt.second];
                if (dnxt < dist[vnxt.first] || dist[vnxt.first] < 0) {
                    pq.push(Plint(dnxt, vnxt.first));
                }
            }
        }
    }
};

int main(){
    ll N;
    cin>>N;
    ll M;
    cin>>M;
    vl u(M);
    vl v(M);
    F0R(i,M){
        cin>>u[i]>>v[i];
    }
    ll s;
    cin>>s;
    ll t;
    cin>>t;
    UndirectedGraph graph(N*3+10);
    F0R(i,M){
        graph.add_edge(u[i]*3,v[i]*3+1,1);
        graph.add_edge(u[i]*3+1,v[i]*3+2,1);
        graph.add_edge(u[i]*3+2,v[i]*3,1);
    }
    graph.dijkstra(s*3);
    int ret=graph.dist[t*3];
    cout<<(ret>0?ret/3:-1)<<endl;
    return 0;
}


Measured memory_bytes: 27224
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int emax = ( (n-1)*(n-2) )/2;
        if( k>emax ) {
            System.out.println(-1);
            return;
        }
        System.out.println( (n-1) + emax - k );
        for( int i=1; i<n; i++ ){
            System.out.printf("%d %d\n",i,n);
        }
        int e1= 1;
        int e2= 2;
        for( int i=0; i<emax-k; i++){
            System.out.printf("%d %d\n",e1, e2);
            if(e2==n-1) {
                e1+=1;
                e2=e1+1;
            } else {
                e2++;
            }
        }
    }
}


Measured memory_bytes: 27804
def main():
  mod=1000000007
  n=int(input())
  a=sorted(list(map(int,input().split())))
  if n%2==0:
    if a==[x//2*2+1 for x in range(n)]:
      print(2**(n//2)%mod)
      return
  else:
    if a==[0]+[x//2*2+2 for x in range(n-1)]:
      print(2**(n//2)%mod)
      return
  print(0)

main()

Measured memory_bytes: 14008
N = int(input())
A = list(map(int, input().split()))

money =1000
idx = 0
tmp_id = 0

while(idx < N-1):
    if(A[idx] <= A[idx+1]):
        idx += 1
        if(idx >= N-1):
            min_a = min(A[tmp_id:(idx+1)])
            max_a = max(A[tmp_id:(idx+1)])
            if(min_a == max_a):
                break
            n = money//min_a
            money = money - n*min_a
            money += max_a*n
            break 
    else:
        min_a = min(A[tmp_id:(idx+1)])
        max_a = max(A[tmp_id:(idx+1)])
        
        if(min_a == max_a):
            idx += 1
            tmp_id = idx
            continue
        n = money//min_a
        money = money - n*min_a
        money += max_a*n
        
        tmp = A[idx]
        idx += 1
        tmp_id = idx
print(money)

Measured memory_bytes: 9240
//union find tree
#include<vector>
#include<iostream>
#define rep(i,j) for(int i=0;i<(j);i++)
using namespace std;

//Node 0 to n-1??§???1 to n??§???OK
class UnionFind{
public:
  int n;
  vector<int> p;

  UnionFind(int nn):n(nn+1){
      p.resize(n);
      rep(i,n)p[i]=i;
  }

  int root(int x){
    if(p[x] == x) return x;
    else return p[x] = root(p[x]);
  }

  void unite(int x,int y){
      x = root(x), y = root(y);
      if(x != y) p[y]=x;
  }
 
  bool query(int x,int y){
    return root(x) == root(y);
  }

};

int main(){
    int n,q; cin >> n >> q;
    UnionFind ut(n);
    rep(i,q){
        int c ,x,y; cin >> c >> x >> y;
        if(c) cout << ut.query(x,y) << endl;
        else ut.unite(x,y);
    }
    return 0;
}

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

int main()
{
    string s;
    while(cin>>s)
    {
        int flag=0;
        for(int i=0;i<s.length();i++)
        {
            if(s[i]=='A'&&s[i+1]=='C')
            {
                flag=1;
                break;
            }
        }
        flag?cout<<"Yes"<<endl:cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
#include <vector>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    int count[26] = {0};
    string word;
    while(getline(cin, word) != NULL) {
        REP(i, word.size()){
            char c = word[i];
            if((c-'a') >= 0 && (c-'z') <= 0)
                c -= 0x20;
            c -= 'A';
            if (0 <= c && c <= 25)
            count[c]++;
        }
    }

    REP(i, 26){
        char c = i + 'a';
        cout << c << " : " << count[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
int H, W, a[109];
int main() {
	scanf("%d%d", &H, &W);
	int ret = 0;
	for(int i = 0; i < H; i++) {
		for(int j = 0; j < W; j++) {
			scanf("%d", &a[j]), a[j] ^= (i ? 1 : 0);
			if(1 <= j && j <= W - 2) a[j] ^= 1;
		}
		if(W == 1) {
			ret += a[0];
			continue;
		}
		int cnt = 0;
		for(int j = 0; j < W; j++) {
			ret += a[j];
			if(a[j] == 0 && cnt++ == 0) ret++;
		}
		if(cnt == 0) ret--;
	}
	printf("%d\n", ret);
	return 0;
}

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

int main() {
  int d, t, s;
  cin >> d >> t >> s;

  if (d / (double)s <= t) {
  	cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <vector>
using std::endl;
using std::cin;
using std::cout;
using std::vector;
using std::pair;



int main(void)
{
    int32_t n,h,w;
    cin >> n>> h >> w;
    
    cout << (n-w+1)*(n-h+1) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 200001
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll a, b;

signed main(){
    cin >> a >> b;
    if(a == b) REP(i, a) cout << a ;
    else if(a > b) REP(i, a) cout << b;
    else REP(i, b) cout << a;
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a;
  int sum = 0;
  int add = 0;
  for(int i = 0;i < 5;i++){
    scanf("%d",&a);
    int m = a%10;
    if(m==0){
    }else{
      add = (add>10-m)?add:(10-m);
      a += (10-m);
    }
    sum += a;
  }
  printf("%d\n",sum-add);
}

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import java.util.Scanner;
import java.util.AbstractMap.SimpleEntry;
import java.util.HashSet;
import java.util.Iterator;

class Main {

    static final int MOD = 10000007;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[][] map = new int[H][W];
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                map[y][x] = sc.nextInt();
            }
        }
        for (int y = 0; y < H; y++) {
            for (int x = 0; x < W; x++) {
                map[y][x] = Math.abs(map[y][x] - sc.nextInt());
            }
        }
        boolean[][][] aval = new boolean[H][W][12800];
        aval[0][0][map[0][0]] = true;
        for (int x = 1; x < W; x++) {
            int y = 0;
            for (int i = 0; i < 12800; i++) {
                if (aval[y][x - 1][i]) {
                    if (i + map[y][x] < 12800)
                        aval[y][x][i + map[y][x]] = true;
                    if (Math.abs(i - map[y][x]) < 12800)
                        aval[y][x][Math.abs(i - map[y][x])] = true;
                }
            }
        }
        for (int y = 1; y < H; y++) {
            int x = 0;
            for (int i = 0; i < 12800; i++) {
                if (aval[y - 1][x][i]) {
                    if (i + map[y][x] < 12800)
                        aval[y][x][i + map[y][x]] = true;
                    if (Math.abs(i - map[y][x]) < 12800)
                        aval[y][x][Math.abs(i - map[y][x])] = true;
                }
            }
        }
        for (int y = 1; y < H; y++) {
            for (int x = 1; x < W; x++) {
                for (int i = 0; i < 12800; i++) {
                    if (aval[y][x - 1][i]) {
                        if (i + map[y][x] < 12800)
                            aval[y][x][i + map[y][x]] = true;
                        if (Math.abs(i - map[y][x]) < 12800)
                            aval[y][x][Math.abs(i - map[y][x])] = true;
                    }
                }
                for (int i = 0; i < 12800; i++) {
                    if (aval[y - 1][x][i]) {
                        if (i + map[y][x] < 12800)
                            aval[y][x][i + map[y][x]] = true;
                        if (Math.abs(i - map[y][x]) < 12800)
                            aval[y][x][Math.abs(i - map[y][x])] = true;
                    }
                }
            }
        }
        int ans = Integer.MAX_VALUE;
        for (int i = 0; i < 12800; i++) {
            if (aval[H - 1][W - 1][i]) {
                System.out.println(i);
                return;
            }
        }
        // for (int y = 0; y < H; y++) {
        // for (int x = 0; x < W; x++) {
        // System.out.print(Arrays.toString(aval.get(y).get(x).toArray()) + " ");
        // }
        // System.out.println();
        // }
    }
}

Measured memory_bytes: 118476
let bubbleSorted;

const largerThan = (a, b) => {
  let an = a.slice(1);
  let bn = b.slice(1);
  return an > bn;
};

const bubbleSort = (n, a) => {
  let isChanged = true;
  let index = 0;
  while (isChanged) {
    isChanged = false;
    for (let j = n - 1; j > index; j--) {
      if (largerThan(a[j - 1], a[j])) {
        let tmp = a[j - 1];
        a[j - 1] = a[j];
        a[j] = tmp;
        isChanged = true;
      }
    }
    index += 1;
  }
  console.log(a.join(" "));
  console.log("Stable");
  return a.join(" ");
};

const selectionSort = (n, a) => {
  for (let i = 0; i < n; i++) {
    minIndex = i;
    for (let j = i; j < n; j++) {
      if (largerThan(a[minIndex], a[j])) {
        minIndex = j;
      }
    }
    if (minIndex != i) {
      let tmp = a[minIndex];
      a[minIndex] = a[i];
      a[i] = tmp;
    }
  }
  console.log(a.join(" "));
  const stable = bubbleSorted === a.join(" ");
  console.log(stable ? "Stable" : "Not stable");
};

// bubbleSorted = bubbleSort("5", "H4 C9 S4 D2 C3".split(" "));
// selectionSort("5", "H4 C9 S4 D2 C3".split(" "));

// bubbleSorted = bubbleSort("2", "S2 D1".split(" "));
// selectionSort("2", "S2 D1".split(" "));

process.stdin.resume();
process.stdin.setEncoding("utf8");
let input_string = "";

process.stdin.on("data", chunk => {
  input_string += chunk;
});

process.stdin.on("end", () => {
  const lines = input_string.split("\n").filter(v => {
    return v !== "";
  });
  bubbleSorted = bubbleSort(lines[0], lines[1].split(" "));
  selectionSort(lines[0], lines[1].split(" "));
});



Measured memory_bytes: 15560
#-*-coding:utf-8-*-

def main():
    x = int(input())
    y = x % 11
    if y == 0:
        print((x // 11) * 2)
    elif 1 <= y <= 6:
        print((x // 11) * 2 + 1)
    else:
        print((x // 11) * 2 + 2)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
   
#include <x86intrin.h>
#include <bits/stdc++.h>   
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

template<typename T> using ordered_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
     
#define F first
#define S second           
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair                                     
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)3e5 + 123;
const ll inf = (ll)1e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;                  
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, m, dp[1001][1001];
char a[1001][1001];

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   return a;
}

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> m;
   for (int i = 1; i <= n; i ++)
      for (int j = 1; j <= m; j ++)
         cin >> a[i][j];
   dp[1][1] = 1;
   for (int i = 1; i <= n; i ++)
      for (int j = 1; j <= m; j ++) {
         for (int z = 1; z <= 4; z ++) {
            int x = i + dx[z];
            int y = j + dy[z];
            if (x < 1 || y < 1 || x > n || y > m || a[x][y] == '#') continue;
            dp[x][y] = add (dp[x][y], dp[i][j]);
         }
      }
   cout << dp[n][m];
}

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
   //cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}
                          

Measured memory_bytes: 5120
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,k;
	cin>>n>>k;
	
	vi h(n);
	REP(i,n) cin>>h[i];
	sort(ALL(h),greater<int>());
	
	llong ans=0;
	REP(i,n){
		if(i<k){}
		else ans+=h[i];
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main {
	
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		
		int min = Integer.MAX_VALUE;
		int sum = 0;
		int[] map = new int[N];
		for (int i = 0; i < N; i++) {
			int s = sc.nextInt();
			map[i] = s;
			
			sum += s;
			
			min = Math.min(min, s % 10 == 0 ? Integer.MAX_VALUE: s);
		}
		
		if (sum % 10 == 0 && Integer.MAX_VALUE == min) {
			System.out.println(0);
		} else if (sum % 10 == 0) {
			System.out.println(sum - min);
		} else {
			System.out.println(sum);
		}
	}
	
}

Measured memory_bytes: 23124
def calculate(A, B, C):
    if B == '+':
        print(A + C)
    elif B == '-':
        print(A - C)
    elif B == '*':
        print(A * C)
    elif B == '/':
        print(A // C)


while True:
    formula = input().split()
    a = int(formula[0])
    b = formula[1]
    c = int(formula[2])
    if b == '?':
        break
    calculate(a, b, c)
    


Measured memory_bytes: 5600
import sys
sys.setrecursionlimit(10**6)
N,A,B,C = map(int,input().split())
Q = []
ans = []
f = 0
def dfs(f,a,b,c):
    if f == N:return True
    if Q[f] == 'AB':
        if a+b == 0:return False
        if b>0 and dfs(f+1,a+1,b-1,c):
            ans.append('A')
            return True
        if a>0 and dfs(f+1,a-1,b+1,c):
            ans.append('B')
            return True
        
        return False
    if Q[f] == 'BC':
        if c+b == 0:return False
        if c>0 and dfs(f+1,a,b+1,c-1):
            ans.append('B')
            return True
        if b>0 and dfs(f+1,a,b-1,c+1):
            ans.append('C')
            return True
        
        return False
    if Q[f] == 'AC':
        if a+c == 0:return False
        if c>0 and dfs(f+1,a+1,b,c-1):
            ans.append('A')
            return True
        if a>0 and dfs(f+1,a-1,b,c+1):
            ans.append('C')
            return True
        
        return False
    

for i in range(N):
    s = input()
    Q.append(s)
dfs(0,A,B,C)
# print(ans)
if len(ans) == N:
    print('Yes')
    ans = ans[::-1]
    for i in ans:
        print(i)
else:
    print('No')


Measured memory_bytes: 109964
n = int(input())
l = sorted(map(int, input().split()))
c = 0
for i in range(n):
    for j in range(i + 1, n):
        for k in range(j + 1, n):
            if l[i] != l[j] != l[k] and l[i] + l[j] > l[k]:
                c += 1
print(c)


Measured memory_bytes: 9116
#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 main(void){
	int n,d,i,j,k,ans,tmp,l,r;
	bool f[22],flag;
	cin >> n >> d;
	ans = n;
	for(i=0; i<(1<<n); ++i){
		for(j=0; j<n; ++j){
			f[j] = false;
		}
		tmp = 0;
		for(j=0; j<n; ++j){
			if(!(i&(1<<j))){
				continue;
			}
			++tmp;
			l = max((j-d),0); r = min((j+d),n-1);
			for(k=l; k<=r; ++k){
				f[k] = true;
			}
		}
		flag = true;
		for(j=0; j<n; ++j){
			if(!f[j]){
				flag = false;
				break;
			}
		}
		if(flag){
			ans = min(ans,tmp);
		}
	}
	cout << ans << endl;
	return 0;
}


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

def main():
    N = int(input())
    A = [None for _ in range(N)]
    INF = 10**12
    for i in range(N):
        A[i] = list(map(int, input().split()))

    adj = [[0]*N for _ in range(N)]
    for i in range(N):
        for j in range(N):
            flag = True
            for k in range(N):
                if k == i or k == j:
                    continue
                if A[i][j] > A[i][k] + A[k][j]:
                    print(-1)
                    exit()
                elif A[i][j] == A[i][k] + A[k][j]:
                    flag = False
                    break
            if flag:
                adj[i][j] = A[i][j]
    ans = 0
    for i in range(N):
        ans += sum(adj[i])
    print(ans//2)

if __name__ == "__main__":
    main()


Measured memory_bytes: 43612
#include <iostream>
using namespace std;
int main(void){
    int n,b=0,c=0,d=0;
    cin>>n;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        if(a%4==0){
            b++;
        }else if(a%2==0){
            c=1;
        }else{
            d++;
        }
    }
    string s="No";
    if(b>=c+d-1){
        s="Yes";
    }
    cout<<s<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main () {
  string s;
  cin >>s;
  if(s[0]==s[1] ||s[1]==s[2] || s[2]==s[3]){
    cout <<"Bad"<<endl;
  } else{
    cout <<"Good"<<endl;
  }
return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
h = list(map(int,input().split()))

graph = [[] for _ in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())
    graph[a].append(b)
    graph[b].append(a)

ans = 0
for i in range(1,n+1):
    hi = h[i-1]
    gr = graph[i]
    tmp = 1
    for j in gr:
        hj = h[j-1]
        if(hj >= hi):
            tmp=0
    ans += tmp

print(ans)

Measured memory_bytes: 89352
import java.util.Scanner;
public class Main{
	private static boolean check(int number){
		if(number==2){	
			return true;
		}
		else if(number%2==0 || number<2){
			return false;
			}
		else
			for(int j = 3; j <=Math.sqrt(number);j+=2){
				if(number%j==0){
					return false;
				}
			}
		return true;
				
	}
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int count = 0;
		int[] number = new int[n]; 
		for(int i = 0 ; i < n ; i++){
			number[i]=scan.nextInt();
		}
		for(int i = 0; i < n ; i++){
			if(check(number[i])){
				count++;
			}
		}	
		System.out.println(count);
	}
}

Measured memory_bytes: 36200
#define _USE_MATH_DEFINES
 
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long long;
 
constexpr ll MOD = 1000000007;
 
#ifndef ONLINE_JUDGE
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " (" << x.first << " : " << x.second << ")" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "["; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "]"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "(" << obj.first << ", " << obj.second << ")"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print_sim_py(void) {cout << endl;}
template <class Head> void print_sim_py(Head&& head) {cout << head;print_sim_py();}
template <class Head, class... Tail> void print_sim_py(Head&& head, Tail&&... tail) {cout << head << " ";print_sim_py(forward<Tail>(tail)...);}
 
#define print(...) print_sim_py(__VA_ARGS__);
#else
#define print(...);
#endif

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

	string ans;
	ll n;

	cin >> n;
	//vector<ll> a(n);
	map<ll,ll> cnt;
	bool pair_coprime = true;

	for (ll i = 0; i < n; i++){
		ll a;
		cin >> a;

		if(a==1)
			continue;
		

		for (ll j = 2; j * j <= a; j++){
			if(a%j==0){
				if(cnt.find(j)==cnt.end()){
					cnt[j]=1;
				}else{
					pair_coprime = false;
					cnt[j]++;
				}
				while(a%j==0){
					a/=j;
				}
			}
		}

		if(a!=1){
			if(cnt.find(a)==cnt.end()){
				cnt[a]=1;
			}else{
				pair_coprime = false;
				cnt[a]++;
			}
		}
	}

	bool set_coprime = true;
	for(auto&& c : cnt){
		if(c.second==n){
			set_coprime=false;
		}
    }

	if(pair_coprime){
		ans = "pairwise coprime";
	}else if(set_coprime){
		ans = "setwise coprime";
	}else{
		ans = "not coprime";
	}
    
    cout << ans << endl;
 
    return 0;
}


Measured memory_bytes: 8532
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
    cin >> N;
    int x;
    cin>> x;
    int i = 0;
    int k = 0;    
  while (true){
    if (x%2==1)
      break;
    x /= 2;
    i++;
  }
  while (k < (N-1)){
      int j = 0;
      int y;
      cin >> y;
  while (j < i){  
    if (y%2==1){
      i = j;
      break;
    }
    y /= 2;
    j++;
  }
    k++;
  }
  cout << i << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
#define bit(n) (1LL << (n))
#define sz(x) ((ll)(x).size())
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;


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

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

template <class T>
T find_max(T l, T r, bool f(T)) {
  T c;
  while (r - l > 1) {
    c = (r + l) / 2;
    if (f(c)) {
      l = c;
    } else {
      r = c;
    }
  }
  return l;
}

ll N, M;
vector<ll> A;
ll CNT;


bool f(ll sub) {
  ll cnt = 0;
  rep(i, N) {
    ll res = sub - A[i];
    auto iter = lower_bound(all(A), res);
    ll pos = distance(A.begin(), iter);
    cnt += (N - pos);
  }
  if (cnt >= M) {
    CNT = cnt;
    return true;
  } else {
    return false;
  }
}


int main() {
  cin >> N >> M;
  A = vector<ll>(N);


  rep(i, N) {
    cin >> A[i];
  }
  sort(all(A));


  ll sub = find_max(0LL, (ll)(INF), f);

  auto B = A;
  reverse(all(B));

  vector<ll> sum(N);
  sum[0] = B[0];
  rep(i, N - 1) {
    sum[i + 1] = sum[i] + B[i + 1];
  }

  ll ans = 0;
  rep(i, N) {
    ll res = sub - A[i];
    auto iter = lower_bound(all(A), res);
    ll pos = distance(A.begin(), iter);
    ll cnt = (N - pos);
    if (cnt > 0)
      ans += sum[cnt - 1] + cnt * A[i];
  }
  ans -= sub * (CNT - M);
  cout << ans << endl;
}

Measured memory_bytes: 2560
/*input

*/

#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <math.h>
#include <iomanip>
#include <utility>
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <algorithm>

using namespace std;
using ll = long long;
using ld = long double;

ll MOD = 1000000007;
const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define inv(a)      powr((a), (MOD - 2))
#define all(c)      (c).begin(),(c).end()
#define rep(i,a,b)  for(ll i = (a); i < (b); i ++)
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

template<typename T> void toInt(string s, T &a) { istringstream(s) >> a; }
ll gcd(ll a, ll b) { ll t; while(a) { t = a; a = b%a; b = t; } return b; }
ll sub(ll a, ll b) { a -= b; a = (a + MOD) % MOD; return a; }
ll mul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }
ll add(ll a, ll b) { a += b; a %= MOD; return a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }

ll powr(ll a, ll b) {
  ll x = 1LL;
  while(b) {
    if(b & 1) x = mul(x, a);
    a = mul(a, a), b >>= 1;
  }
  return x;
}

bool check(ll n)
{
  if(n == 1) return 0;
  if(n == 2 or n == 3) return 1;
  if(n%2 == 0 or n%3 == 0) return 0;
  for(ll i = 5; i*i <= n; i += 6) if(n%i == 0 or n % (i+2) == 0) return 0;
  return 1;
}

/*********************************START**********************************/
const int N = 100005;

int main()
{
  ifalse;
  string s1, s2;
  cin >> s1 >> s2;
  int cnt= 0;
  for(int i = 0; i < 3; i++) {
    if(s1[i] == s2[i]) {
      cnt ++;
    }
  }
  cout << cnt;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
	int N;
	cin >> N;
	int P[N],Q[N];
	for (int i = 0; i < N; i++) { cin >> P[i];}
  	if(N == 2){
      if(P[0] > P[1]) cout << 1 << endl;
      else cout << 0 << endl;
      return 0;
    }
	for (int i = 0; i < N; i++) {
		Q[P[i]-1] = i + 1;
	}
	int cnt, max;
	cnt = max = 1;
	for (int i = 1; i < N; i++) {
		if (Q[i] > Q[i-1]) {
			cnt++;
			if (cnt >= max) max = cnt;
		}
		else {
			cnt = 1;
		}
	}
	cout << (N-max) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    string s; cin >> s;
    int ans = 0;
    for(int i = 0; i < s.size(); i++){
        if(s[i] == '1') ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1e9;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

void solve() {
  string s;
  cin >> s;
  int n = s.size();
  int ans = 0;
  rep(i,n/2-1) {
    string s1 = s.substr(0, i+1);
    string s2 = s.substr(i+1, i+1);
    if (s1 == s2) ans = 2 * (i + 1);
  }
  cout << ans << endl;
}

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

Measured memory_bytes: 3616
import math

def main():
    A,B = list(map(int,input().split()))

    flag = True

    for i in range(1,1010):
        if(math.floor(i*0.08) == A and math.floor(i*0.1) == B):
            print(i)
            flag = False
            break

    if(flag):
        print(-1)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include<stdio.h>

int main(){
  int n,m,i,b;
  int a[100000];
  scanf("%d %d",&n,&m);
  b=n;
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
    b=b-a[i];
  }
 if(b>=0){
   printf("%d",b);
 }else{
   printf("-1");
}
}

Measured memory_bytes: 1772
#include <stdio.h>
#define N 10
int heights[N];

int change_flag;
int tempo;

int main(){
  int index;
  
  for (index = 0; index < N; ++index) {
    scanf("%d", &heights[index]);
  }

  change_flag = -1;

  while (change_flag != 0) {
    change_flag = 0;
    for (index = 0; index < N - 1; ++index){
      if (heights[index] < heights[index + 1]){
        tempo = heights[index];
        heights[index] = heights[index + 1];
        heights[index + 1] = tempo;
        ++change_flag;
      }
    }
  }
  for (index = 0; index < 3; ++index) {
    printf("%d\n", heights[index]);
  }
  return(0);
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}void pr(){ln;}
template<class A,class...B>void pr(const A &a,const B&...b){cout<<a<<(sizeof...(b)?" ":"");pr(b...);}
template<class A>void PR(A a,ll n){rep(i,n)cout<<(i?" ":"")<<a[i];ln;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[8]={-1,0,1,0,-1,-1,1,1},dy[8]={0,1,0,-1,-1,1,1,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  cin >> n;
  n--;
  string s="";
  while(1) {
    s=(char)('a'+n%26)+s;
    if(n<=25) break;
    n/=26;
    n--;
  }
  pr(s);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 3604
n = int(input())
k = int(input())

def c(n, k):
    if n < k:
        return 0
    else:
        x = 1
        for i in range(k):
            x *= (n - i)
            x //= (i + 1)
        return x

ans = 0
for i in range(k):
    temp1 = len(str(n)) - 1
    temp2 = n // (10 ** temp1)
    check = k - i
    if check == 1:
        ans += temp2 + temp1 * 9
    else:
        ans += c(temp1, check) * (9 ** check) + (temp2 - 1) * c(temp1, check - 1) * (9 ** (check - 1))
    n %= 10 ** temp1
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<vector>
#include<cstring>
#include <math.h>
#include<algorithm>
#include <stack>
#include <string>
#define ll long long int
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    int t;
    t=n/m;
    int s=n%m;
    if(s!=0)
    {
        t++;
    }
    cout<<t;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

constexpr double EPS = 1e-7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
#define PI (acos(-1))

constexpr int MOD = 1e9 + 7;

vector<ll> a;

ll gcd(ll a, ll b) {
	if (a < b) {
		return gcd(b, a);
	}

	ll r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

ll lcm(ll x, ll y) {
	return (x * y) / gcd(x, y);
}

int main(int argc, char const *argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	ll N, M;
	cin >> N >> M;
	a.resize(N);

	ll l = 1;
	for (int i = 0; i < N; i++) {
		cin >> a[i];
		l = l = lcm(l, a[i] / 2);
	}

	for (int i = 0; i < N; i++) {
		if (l % a[i] == 0) {
			cout << 0 << endl;
			return 0;
		}
	}

	cout << (M / l + 1) / 2 << endl;

	return 0;
}


Measured memory_bytes: 1024
r, c = map(int, input().split())
data = [list(map(int, input().split())) for i in range(r)]
for i in range(r):
    data[i].append(sum(data[i]))
data.append([sum(data[j][i] for j in range(r)) for i in range(c + 1)])
for i in range(r + 1):
    for j in range(c + 1):
        print(data[i][j], end='')
        if j != c:
            print(' ', end='')
    print('')

Measured memory_bytes: 8800
def insertingSort(a, n):
    for i in range(1, n):
        v = a[i]
        j = i - 1
        while j >= 0 and v < a[j]:
            a[j+1] = a[j]
            j -= 1
        a[j+1] = v 
        print(' '.join(list(map(str, a))))        

n = int(input().strip())
a = list(map(int, input().strip().split()))
print(' '.join(list(map(str, a))))
insertingSort(a, n)


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
using namespace std;

int main(){
  int d,n,m; // length
  while(1){
    cin >> d;
    if(d==0)break;
    cin >> n >> m;

    vector<int> store,order;
    store.push_back(0);
    store.push_back(d);
    for(int i=0;i<n-1;i++){
      int tmp;
      cin >> tmp;
      store.push_back(tmp);
    }
    for(int i=0;i<m;i++){
      int tmp;
      cin >> tmp;
      order.push_back(tmp);
    }
    sort(store.begin(),store.end());
    sort(order.begin(),order.end());

    int ans=0;
    int j=0;
    for(int i=0;i<order.size();i++){
      while(order[i] > store[j+1]) j++;
      ans += min(abs(order[i] - store[j]),
		 abs(order[i] - store[j+1]));
    }
    cout << ans << "\n";
  }
}

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

using namespace std;

#define ll long long
#define fo(i,b,n) for(int i=(b); i<(n) ; i++)
#define xx first
#define yy second
#define pb push_back
#define sz(n) int(n.size())
#define pii pair
#define MP make_pair

#define read(x) scanf("%d",&x)
#define read2(x,y) scanf("%d%d",&x,&y)
#define readl(x) scanf("%lld",&x)
#define readl2(x,y) scanf("%lld%lld",&x,&y)
#define readd(x) scanf("%lf",&x)
#define readd2 scanf("%lf%lf",&x,&y)

#define pr(n) printf("%d",n)
#define prn(n) printf("%d\n",n)
#define prl(n) printf("%lld",n)
#define prln(n) printf("%lld\n",n)
#define prd(x) printf("%lf",x)
#define prdn(x) printf("%lf\n",x)


int main()
{
    ll x;
    vector<ll>v;
    bool flag=false;
    fo(i,0,3)
    {
        readl(x);
        v.pb(x);
        if(!(x%2))
        flag=true;
    }
    if(flag)puts("0");
    else{
        sort(v.begin(),v.end());
        ll com=v[0]*v[1];
        ll ans=(((v[2]/2)+1)*com) - (( v[2]/2 )*com);
        prln(ans);
    }
    return 0;
}

















Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
priority_queue <int> A;
int main(){
    int n, m, k;
    long long int cou=0;
    cin >> n >> m;
    k=n;
    while(n--){
        int a;
        cin >> a;
        A.push(a);
    }
    while(m--){
        int a;
        a= A.top();
        a /= 2;
        A.pop();
        A.push(a);
    }
    while(k--){
        cou += A.top();
        A.pop();
    }
    cout << cou;
    return 0;
}

Measured memory_bytes: 892
n = int(input())
money = []
sum = 0

for i in range(n):
    x, u = list(map(str, input().split()))
    x = float(x)
    money.append([x,u])

for i in range(n):
    if money[i][1] == 'JPY':
        sum += money[i][0]
    else:
        sum += money[i][0] * 380000

print(sum)

Measured memory_bytes: 3060
def is_even(arr)
  xs = arr.take(arr.length/2).zip(arr.drop(arr.length/2))
  while (! xs.empty?)
    x, *xs = xs
    if (x[0] != x[1])
      return false
    end
  end
  return true
end

def solve(s)
  x1, x2, *xs = s.split("").reverse
  while (! is_even(xs))
    x1, x2, *xs = xs
  end
  return xs.length
end

puts solve(STDIN.gets.chomp)


Measured memory_bytes: 2044