akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

long long cnt;
int l;
int A[1000000];
int n;
vector<int> G;

void insertion_sort(int A[], int n, int g)
{
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shell_sort(int A[], int n)
{
    for (int h = 1; ; ) {
        if (h > n) break;
        G.push_back(h);
        h = 3*h + 1;
    }

    for (int i = G.size() - 1; i >= 0; i--) {
        insertion_sort(A, n, G[i]);
    }
}


int main(int argc, char const *argv[])
{
    cin >> n;
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    cnt = 0;

    shell_sort(A, n);

    cout << G.size() << endl;
    for (int i = G.size() - 1; i >= 0; i--) {
        printf("%d", G[i]);
        if (i) printf(" ");
    }
    printf("\n");
    printf("%d\n", cnt);
    for (int i = 0; i < n; i++) {
        printf("%d\n", A[i]);
    }

    return 0;
}




Measured memory_bytes: 7176
from math import gcd

from math import factorial as f

from math import ceil, floor, sqrt
import math

import bisect
import re
import heapq

from copy import deepcopy
import itertools
from itertools import permutations

from sys import exit

ii = lambda: int(input())
mi = lambda: map(int, input().split())
li = lambda: list(map(int, input().split()))

yes = "Yes"
no = "No"


def main():
    a = ii()
    b = ii()
    c = ii()
    d = ii()
    print(min(a, b) + min(c, d))


main()


Measured memory_bytes: 9960
#include <bits/stdc++.h>
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
int n, ans;
int a[100010];
int main()
{
	n = read();
	for(int i = 1; i <= n; i ++)
		a[i] = read();
	int now = 0;
	for(int i = 2; i <= n; i ++)
	{
		if(a[i] == a[i - 1]) continue;
		if(a[i] > a[i - 1])
		{
			if(now == 0) now = 1;
			else if(now == 1) continue;
			else ans ++, now = 0;
		}
		else
		{
			if(now == 0) now = 2;
			else if(now == 2) continue;
			else ans ++, now = 0;
		}
	}
	cout << ans + 1;
	return 0;
}


Measured memory_bytes: 640
n, a, b, c = map(int, input().split())

ok = True

s_l = []

ans_s = []

for i in range(n):
    s_l.append(input())

for i in range(n):
    s = s_l[i]
    if i < n-1:
        nex = s_l[i+1]
    else:
        nex = 'NONO'

    if s == 'AB':
        if a < b:
            a += 1
            b -= 1
            ans_s.append('A')
        elif a > b:
            a -= 1
            b += 1
            ans_s.append('B')
        elif nex == 'BC':
            a -= 1
            b += 1
            ans_s.append('B')
        else:
            a += 1
            b -= 1
            ans_s.append('A')
    elif s == 'AC':
        if a < c:
            a += 1
            c -= 1
            ans_s.append('A')
        elif a > c:
            a -= 1
            c += 1
            ans_s.append('C')
        elif nex == 'BC':
            a -= 1
            c += 1
            ans_s.append('C')
        else:
            a += 1
            c -= 1
            ans_s.append('A')
    else:
        if b < c:
            b += 1
            c -= 1
            ans_s.append('B')
        elif b > c:
            b -= 1
            c += 1
            ans_s.append('C')
        elif nex == 'AB':
            c -= 1
            b += 1
            ans_s.append('B')
        else:
            c += 1
            b -= 1
            ans_s.append('C')

    if a < 0 or b < 0 or c < 0:
        ok = False
        break

if ok:
    print('Yes')
    for s_e in ans_s:
        print(s_e)
else:
    print('No')


Measured memory_bytes: 16832
import java.util.*;class Main{public static void main(String[]z){Scanner s=new Scanner(System.in);for(int t=s.nextInt();t-->0;System.out.println(z[0])){z=s.next().split("");Stack<String>l=new Stack<String>();l.add(z[1]);for(int i=2;i<z.length;i+=3)if(!l.contains(z[i+2]))l.insertElementAt(z[i+2],l.indexOf(z[i-1])+(z[i].equals("-")?1:0));for(String e:l)z[0]+=e;}}}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

string ReplaceString(string S,string Q,string R){
	string::size_type pos(S.find(Q));

	while(pos!=string::npos){
		S.replace(pos,Q.length(),R);
		pos = S.find(Q,pos+R.length());
	}

	return S;
}

int main(){
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	
	int N;
	scanf("%d\n",&N);
	LOOP(N){
		char str[1001];
		cin.getline(str,sizeof(str));
		string S(str);
		
		S = ReplaceString(S,"Hoshino","Hoshina");
		out(S);
	}
	
	return 0;
}


Measured memory_bytes: 3184
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
int main() {
	string s, t;
	cin >> s >> t;
	int n = s.size();
	if (t.substr(0, n) == s) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3600
#include<bits/stdc++.h>
#define sf1(n) scanf("%d",&n)
#define sf2(n,q) scanf("%d %d",&n,&q)
#define f first
#define ss second
#define pb push_back
#define lli long long
#define mem(ar,false) memset(ar,false,sizeof(ar))
#define mpr make_pair
#define endl "\n"
#define mod 1000000007
using namespace std;

vector<int>v[200005];
int vis[200005];
int num[200005];
lli mx= 0;
int cynd=-1,cynd2=-1;
int ans = -1;
 lli n,d;
 int indx[200005];
void dfs(int u,int k)
{
    vis[u]=true;
    num[k] = u;
    lli e = k;
    mx = max(mx,e);
    indx[u]=k;
    if(d==k)
    {
        ans = u;
        return ;
    }

    for(int i=0; i<v[u].size(); i++)
    {
        if(!vis[v[u][i]])
        {
            dfs(v[u][i],k+1);
        }
        else if(cynd==-1)
        {
            cynd = v[u][i];
            cynd2 = u;
        }
    }
    return;

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);



    cin >> n >> d;
    for(int i=1; i<=n; i++)
    {
        int a;
        cin >> a;
        v[i].pb(a);
    }
    dfs(1,0);
    if(ans!=-1)
    {
        cout << ans << endl;
    }
    else
    {
        d-= indx[cynd];
        d%=(indx[cynd2]-indx[cynd]+1);
        cout << num[d+indx[cynd]] << endl;
    }
    return 0;
}



Measured memory_bytes: 24164
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vii = vector<vi>;
using in6 = int64_t;
using ind = double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  int n;
  cin >> n;
  vi data(n);
  int ans;
  rep(i,n) cin >> data[i];
  sort(data.begin(), data.end());
  reverse(data.begin(), data.end());
  int high = data[0];
  rep(i,high * 2) {
    int hp = 0;
    rep(j,n) {
      int hpp = (data[j] - i) * (data[j] - i);
      hp += hpp;
    }
    if(i == 0) ans = hp;
    else ans = min(ans,hp);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<stack>
#include<cstdio>
using namespace std;

int main(){
    int n;cin>>n;
    vector<int> H(n);
    for(int i=0;i<n;i++) cin>>H[i];


    bool ok=true;
    for(int i=n-2;i>=0;i--){
        if(H[i]-H[i+1]>=2){
            ok=false;
            break;
        }
        else if(H[i]-H[i+1]==1) H[i]-=1;
        else continue;
    }

    if(ok) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




Measured memory_bytes: 640
x1, y1, x2, y2 = map(int, input().split())

y3 = y2 + (x2 - x1)
x3 = x2 - (y2 - y1)
y4 = y3 - (y2 - y1)
x4 = x3 - (x2 - x1)

print(x3, y3, x4, y4)


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

#define min(x, y) ((x) < (y) ? (x) : (y))
#define max(x, y) ((x) > (y) ? (x) : (y))

int64_t dp[301][301];

int main() {
    char s[301];
    scanf("%s", s);

    int64_t a[302];
    int64_t t = 0, n = 1;
    a[0] = 0;
    for (char* p = s; *p != 0; ++p) {
        if (*p == '0') {
            a[n++] = t;
        } else {
            ++t;
        }
    }
    a[n++] = t;

    int64_t k;
    scanf("%ld", &k);
    k = min(k, a[n - 1]);

    int64_t M = 998244353L;

    int64_t mk = 0;
    dp[0][0] = 1;
    for (int64_t i = 0; i < n - 1; ++i) {
        for (int64_t j = mk; j >= 0; --j) {
            int64_t r = min(k - j, a[i + 1] - a[i]);
            int64_t mc = a[n - 1]  - a[i + 1];
            for (int64_t b = 1; b <= mc + r; ++b) {
                for (int64_t c = max(0L, b - r); c < b && c <= mc; ++c) {
                    int64_t w = j + b - c;
                    dp[w][c] += dp[j][b];
                    if (dp[w][c] >= M) {
                        dp[w][c] -= M;
                    }
                }
            }

            for (int64_t c = 1; c <= a[n - 1] - a[i + 1]; ++c) {
                dp[j][c] += dp[j][c - 1];
                if (dp[j][c] >= M) {
                    dp[j][c] -= M;
                }
            }
        }
        mk = min(k, mk + a[i + 1] - a[i]);
    }

    int64_t ans = 0;
    for (int64_t i = 0; i <= mk; ++i) {
        ans += dp[i][0];
    }

    printf("%ld\n", ans % M);
}


Measured memory_bytes: 2352
using System;

namespace ConsoleApp1
{
	class Program
	{
		static void Main(string[] args)
		{
			var input = Console.ReadLine().Split(' ');
			int k = int.Parse(input[1]);
			string str = Console.ReadLine();
			string lower = str.ToLower();
			var output = str.ToCharArray();
			output[k - 1] = lower[k - 1];
			Console.WriteLine(output);
		}
	}
}


Measured memory_bytes: 11092
import sys
import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

A = np.array(read().split(), np.int32)[1:]

to = A.argsort()

n = (to[::2] & 1).sum() + ((to[1::2] ^ 1) & 1).sum()
print(n // 2)

Measured memory_bytes: 33508
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    vec a;
    if (s[0] == '0') a.push_back(0);

    int cnt = 1;
    rep(i, n) {
        if (i == 0) continue;
        if (s[i-1] != s[i]) {
            a.push_back(cnt);
            cnt = 1;
        }
        else {
            cnt++;
        }
    }
    a.push_back(cnt);
    if (s[n-1] == '0') a.push_back(0);

    int res = 0;
    int v = a.size();

    vec as(v+1);
    rep(i, v) as[i+1] = as[i] + a[i];

    bool update = false;
    for (int i = 0; i + 2 * k + 1 <= v; i+=2) {
        res = max(res, as[i+2*k+1] - as[i]);
        if (!update) update = true;
    }

    if (!update) res = n;

    cout << res << endl;
    return 0;
}

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

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

int main(){
    int n, q; cin >> n >> q;
    vector <vector<int>> G(n + 1);
    vector <int> point(n + 1);

    rep(i, n - 1){
        int a, b; cin >> a >> b;
        G.at(a).push_back(b);
        G.at(b).push_back(a);
    }
    rep(i, q){
        int x, p; cin >> x >> p;
        point.at(x) += p;
    }

    deque <int> d;
    vector <long long> ans(n + 1, 0);
    vector <int> seen(n + 1, -1);
    d.push_back(1);
    ans.at(1) += point.at(1);
    seen.at(1) = 1;

    while(!d.empty()){
        int v = d.front();
        d.pop_front();
        
        int v_child_cnt = G.at(v).size();
        for(int i = 0; i < v_child_cnt; i ++){
            int next = G.at(v).at(i);
            if(seen.at(next) != -1)continue;

            ans.at(next) += point.at(next) + ans.at(v);
            d.push_back(next);
            seen.at(next) = 1;
        }
    }

    for(int i = 1; i < n + 1; i ++){
        cout << ans.at(i) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 18904
n, m = map(int, input().split())
d = {}
res = [0, 0]
for i in range(m):
    a, b = map(str, input().split())
    d.setdefault(a, [0, 0])
    if b == "AC" and d[a][0] == 0:
        d[a][0] = 1
        res[0] += 1
        res[1] += d[a][1]
    else:
        d[a][1] += 1
print(res[0], res[1])


Measured memory_bytes: 25276
//Ruthless Coding 
#include <bits/stdc++.h>

#define uni(x)      (x).resize(unique(all(x)) - (x).begin())
#define fprint(v)   for(auto x : v) cout << x << ' '
#define ALL(x)      (x).begin(), (x).end()
#define MP(x, y)    make_pair(x, y)
#define PII         pair<int, int>
#define SZ(x)       int((x).size())
#define PB(x)       push_back(x)
#define ll          long long
#define S           second 
#define F           first
#define nl          '\n'

using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
mt19937_64 rnd;

const int N = 2e4 + 5;
int main() {
    ios_base::sync_with_stdio(0);cin.tie(0);
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans = 0;
    for(int i = 0; i <= a; i++){
        for(int j = 0; j <= b; j++){
            if(i * 500 <= x){
                int left = x - (500 * i);
                if(j * 100 <= left){
                    left -= (j * 100);
                    if(left % 50 == 0 && left / 50 <= c){
                        ans++;
                    }
                }
            }
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;
bool prime[1000001];
vector<int> ppp;

void p_init(){
	prime[0] = prime[1] = true;
	for(int i=0;i<=1000;i++){
		if(!prime[i])
			for(int j=i<<1;j<=1000000;j+=i){
				prime[j] = true;
		}
	}

	for(int i=0;i<=1000000;i++){
		if(!prime[i]){
			ppp.push_back(i);
		}
	}
}

int main(){
	p_init();
	int x,n,p,m;
	int ret;
	while(cin >> n && n){
		ret = 0;
		for(int i=0;i<n;i++){
			scanf("%d %d",&p,&m);
			int mi = p<m ? 0 : p-m;
			int mx = p+m>1000000?1000000:p+m;
			x = 0;
			for(int i=0;i<ppp.size();i++){
				if(ppp[i]>mx)break;
				if(ppp[i]>=mi){
					ret++;
				}
			}
			if(x){
				ret += x-1;
			}else{
				ret--;
			}
		}
		printf("%d\n",ret<0?0:ret);
	}
}

Measured memory_bytes: 2368
//
#include <vector>
#include <set>
#include <array>
#include <iostream>
#include <cstdio>
#include <cstdint>
//
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
void yes(bool cond) { cond ? puts("Yes") : puts("No"); }
//
int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    std::string S;
    cin >> S;
    yes((S[0] != S[1]) || (S[1] != S[2]));
}

Measured memory_bytes: 3028
#include<bits/stdc++.h>
using namespace std;
#define arep(i,x,n) for(int i=int(x);i<(int)(n);i++)
#define rep(i,n) for(long long i = 0;i < n;++i)
#define pi 3.141592653589793
#define eps 0.00000001
#define INF 1e9+7  
using ll = long long; 
using P=pair<int,int>;
using lP=pair<ll,ll>;
using fP=pair<double,double>;
ll const mod=1e9+7;


int main(){
    int k,a,b;
    cin>>k>>a>>b;
    bool ok=false;
    for(int i=a;i<=b;i++){
        if(i%k==0)ok=true;
    }
    if(ok)cout<<"OK"<<endl;
    else cout<<"NG"<<endl;
   
    return 0;
}

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

#define ll long long

int main()
{
    int button[2];
    scanf("%d%d", &button[0], &button[1]);
    int i = button[0] < button[1] ? 1 : 0;
    int sum = button[i];
    button[i]--;
    i = button[0] < button[1] ? 1 : 0;
    sum += button[i];
    printf("%d\n", sum);
    return 0;
}


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

#define MAX 10000

void trace(unsigned short a[], int size) {
    for (int i = 0; i < size; ++i) {
        if (i > 0) {
            printf(" ");
        }
        printf("%d", a[i]);
    }
    printf("\n");
}

void CountingSort(unsigned short A[], unsigned short B[], int n) {
    int C[MAX + 1];
    for (int i = 0; i < MAX + 1; ++i) C[i] = 0;
    for (int i = 0; i < n; ++i) C[A[i]] += 1;
    for (int i = 1; i < MAX + 1; ++i) C[i] += C[i-1];

    for (int i = n - 1; i >= 0; --i) {
        B[C[A[i]] - 1] = A[i];
        --C[A[i]];
    }
}

int main() {
    int n;
    unsigned short *A, *B;
    scanf("%d", &n);
    A = (unsigned short *) malloc(sizeof(short) * n + 1);
    B = (unsigned short *) malloc(sizeof(short) * n + 1);
    for (int i = 0; i < n; ++i) {
        scanf("%hu", &A[i]);
    }
    CountingSort(A, B, n);
    trace(B, n);

    return 0;
}

Measured memory_bytes: 10496
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
 
int main () {
  int K, N, ans, tmp, a;
  ans = tmp = a = 0;
  cin >> K >> N;
  int A[N];
  rep (i, N) cin >> A[i];
  ans = A[N-1] - A[0];
  tmp = K - ans;
  for (int i = 1; i < N; ++i) {
    if (tmp < A[i] - A[i-1]) {
      tmp = A[i] - A[i-1];
      a = i - 1;
    }
  }
  if (a != 0) {
    ans = A[a];
    ans += K - A[a+1];
  }
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 1024
public class Main {

    /**
     * ????????????????????????
     * @param args
     */
    public static void main(String[] args) {
        for(int i = 1; i < 10; i++) {
            for(int j = 1; j < 10; j++) {
                System.out.println(i + "x" + j + "=" + i*j);
            }
        }
    }

}

Measured memory_bytes: 24172
#include <tuple>
#include <vector>
#include <map>
#include <set>
#include <iostream>


template<class... Ts> using tuple_t = std::tuple<Ts...>;
template<class T, class U> using map_t = std::map<T, U>;
template<class T, class U> using pair_t = std::pair<T, U>;
template<class T> using vector_t = std::vector<T>;
template<class T> using set_t = std::set<T>;

uint64_t digit(uint64_t num, uint64_t base = 10)
{
	uint64_t i = 0;
	while(num)
	{
		++i;
		num /= base;
	}
	return i;
}

uint64_t digit_sum(uint64_t num, uint64_t base = 10)
{
	uint64_t i = 0;
	while(num)
	{
		i += num % base;
		num /= base;
	}
	return i;
}

int main()
{
	int S=0;
	char a,b,c,d;
	std::cin>>a>>b>>c>>d;
	if(a=='+')S+=1;else S-=1;
	if(b=='+')S+=1;else S-=1;
	if(c=='+')S+=1;else S-=1;
	if(d=='+')S+=1;else S-=1;
	std::cout<<S<<std::endl;
	return 0;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<string> s(n);
	vector<int> t(n);
	rep(i,n) cin >> s[i] >> t[i];
	string x;
	cin >> x;
	int ans = 0;
	bool flag = false;
	rep(i,n){
		if(flag) ans += t[i];
		if(s[i] == x) flag = true;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3640
import heapq as hq

n, m = map(int, input().split())
a = [-int(i) for i in input().split()]
hq.heapify(a)

for _ in range(m):
  hq.heappush(a, -(-hq.heappop(a) // 2))
  
print(sum(a) * -1)


Measured memory_bytes: 14180
#include<iostream>
#include<map>
#include<set>
using namespace std;
using ull = unsigned long long;

int N;
string S;
ull const hash_base = 1e9 + 7;


bool is_ok(int len){
  if(len == 0){
    return true;
  }
  map<ull, int> hashes;
  
  ull hash_base_pow = 1;
  ull hash = 0;
  for(int i = 0; i < len; i++){
    hash = hash_base * hash + S[i];
    hash_base_pow *= hash_base;
  }
  hashes[hash] = 0;
  
  for(int i = 1; i + len <= S.length(); i++){
    hash = hash_base * hash + S[i + len - 1] - hash_base_pow * S[i - 1];
    if(hashes.count(hash)){
      if(hashes.at(hash) <= i - len){
	return true;
      }
    }else{
      hashes[hash] = i;
    }
  }
  return false;
}

int main(){
  cin >> N;
  cin >> S;

  int ok = 0, ng = S.length();
  while(ng - ok > 1){
    int mid = (ok + ng) / 2;
    if(is_ok(mid)){
      ok = mid;
    }else{
      ng = mid;
    }
  }
  cout << ok << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iterator>
#include <math.h>
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define dd double
#define mp make_pair
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    // int T,p;
    // cin>>T;
    // for(p=1;p<=T;p++)
    // {
      ll N,M;
      cin>>N>>M;
      ll a,b,c,count=0,i,j,k;
      vector <vector <ll> > vect(N);
      bool x[N];
      for(i=0;i<M;i++)
      {
        cin>>j>>k;
        vect[j-1].pb(k-1);
        vect[k-1].pb(j-1);
      }
      memset(x,false,sizeof(x));
      // for(i=0;i<N;i++)
      // {
      //   for(j=0;j<vect[i].size();j++)
      //   // cout<<vect[i][j]<<" check ";
      //   cout<<"\n";
      // }
      queue <ll> q;
      count=0;
      for(i=0;i<N;i++)
      {
        if(x[i])
        continue;
        a=1;
        // BFS lagega i wale se;
        q.push(i);
        x[i]=true;
        // cout<<i<<" "<<vect[i].size()<<" aa\n";
        while(q.size()!=0)
        {
          b=q.front();
          q.pop();
          for(j=0;j<vect[b].size();j++)
          {
            // if(b==0)
            // {
            //   cout<<vect[b][j]<<"chec1\n";
            // }
            if(x[vect[b][j]]==false)
            {
              // if(b==0)
              // cout<<"jai\n";
              a++;
              q.push(vect[b][j]);
              x[vect[b][j]]=true;
            }
          }
          // cout<<b<<" "<<a<<"\n";
        }
        count=max(count,a);
      }
      cout<<count;
      return 0;
}

Measured memory_bytes: 17144
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef unsigned long long int ll;

const int INF = 1<<30;
const ll LINF = ll(1e18);
const ll MOD = ll(1e9+7);

int main(){
  int n;cin>>n;
  int minus=0;
  ll ans=0LL;
  int min_abs=INF;
  rep(i, n){
    int a;cin>>a;
    ans += abs(a);
    min_abs = min(min_abs, abs(a));
    if(a==0)min_abs=0;
    else if(a<0)minus++;
  }
  if(minus&1)ans -= 2*min_abs;
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    /* チェックリスト
     * 結果はintの範囲を超えていませんか？(必要な時以外はlongを使いましょう)
     * TLEしそうな処理はありませんか？
     */
    public static void main(String args[]){
        /*
         * for i j文で全てのパターンを精査するのは追いつかない
         *
         */
        Scanner s = new Scanner(System.in);
        long n = Integer.parseInt(s.nextLine());
        String[] in = new String[(int)n];
        for(int i = 0;i < n;i++){
            String input = s.nextLine();
            char[] c = input.toCharArray();
            Arrays.sort(c);
            in[i] = new String(c);
        }
        Arrays.sort(in);
        long r = 0;
        long c = 1;
        String prev = "";
        for(String now : in){
            if(now.equals(prev)){
                c++;
            }else{
                r += (c * (c-1)) / 2;
                c = 1;
            }
            prev = now;
        }
        r += (c * (c-1)) / 2;
        System.out.println(r);
    }
}

Measured memory_bytes: 102200
#include <bits/stdc++.h>
#define rep(i,a,b) for(ll i=ll(a);i<ll(b);i++)
#define irep(i,a,b) for(ll i=ll(a);i>=ll(b);i--)
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define F .first
#define S .second 
#define endl "\n"
using ll=long long;
using ld=long double;
using namespace std;
const ll mod=1e9+7;
ll a[220000],b[220000],c[220000];
main(){
  ll n,ans=1e16;
  cin>>n;
  rep(i,1,n+1){cin>>a[i];a[i]-=i;}
  sort(a+1,a+n+1);
  rep(i,1,n+1)b[i]=b[i-1]+a[i];
  irep(i,n,0)c[i]=c[i+1]+a[i];
  ll tmp=0,pos=1,l=(n+1)/2,r=(n+2)/2;
  rep(i,a[l],a[r]+1){
    while(a[pos]<i)pos++;
    tmp=labs(i*(pos-1)-b[pos-1])+labs(c[pos]-i*(n-pos+1));
    ans=min(ans,tmp);
    //cout<<tmp<<endl;
  }
 // rep(i,0,n+1)cout<<a[i]<<endl;
  cout<<ans;
}


Measured memory_bytes: 5120
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  if(s.find("R")!=-1) ans = 1;
  if(s.find("RR")!=-1) ans = 2;
  if(s.find("RRR")!=-1) ans = 3;
  cout << ans << endl;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     @hamayanhamayan0
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/














int X, Y, Z;
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> X >> Y >> Z;
	swap(X, Y);
	swap(X, Z);
	printf("%d %d %d\n", X, Y, Z);
}







Measured memory_bytes: 3664
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1LL << 60;
int main(){
    string s;
    cin >> s;
    if(s=="AAA"||s=="BBB") cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
int candies(vector<int>v,int n, int k){ 
   ll dp[n+2][k+2];
   for(int j=0; j<=k; j++){
        dp[1][j] = (j > v[1])? 0 : 1;
   }
    
   for(int i = 2; i<= n; i++)  {
      for(int j=0; j<=k; j++){
          if(j == 0)
            dp[i][j] = dp[i-1][j]; // set them to 0 from dp[i-1][0]
          else
            dp[i][j] = (MOD + dp[i-1][j] + dp[i][j-1] - ( (j-v[i]-1 >= 0) ? dp[i-1][j-v[i]-1]:0))%MOD;
      }
   }
  return dp[n][k];
    
}

void solve(){
   int n,k;
   cin >> n >> k;
   vector<int>v(n+1);
   for(int i=1; i<=n;i++){
       cin >> v[i];
   }

  cout <<  candies(v,n,k);
 }
int main(){
//  #ifndef ONLINE_JUDGE
//   freopen("input.txt", "r", stdin);
//   freopen("output.txt", "w", stdout);
// #endif 
solve();

return 0;
}

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

int main(){
    double a, b;
    cin >> a >> b;
    double ll=min((a*8),(b*10));
    double gg=0.08;
    double ggwp=0.1;
    for(double i=ll; i<11000; i++){
        if(floor((i)*gg) == a && floor((i)*ggwp) == b){
            cout << i;
            return 0;
        }
        else
            continue;
    }
    cout << "-1";
    return 0;
}

Measured memory_bytes: 256
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>

using namespace std;


int main() {
	int K, A, B;
	bool a = false;

	cin >> K >> A >> B;

	if (K == 1) {
		a = true;
	}

	else if ((A == B) && (A % K) == 0) {
		a = true;
	}
	else if ((A == K) || (B == K)) {
		a = true;
	}

	else {
		for (A; A < B+1; A++) {
			if ((A % K) == 0) {
				a = true;
				break;
			}
		}
	}

	if (a == true) {
		cout << "OK" << endl;
	}
	else {
		cout << "NG" << endl;
	}
}

Measured memory_bytes: 3124
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <tuple>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j

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

int main(){
	ll A, B, C, X;
	cin >> A >> B >> C >> X;
	ll cnt = 0;
	rep(i, 0, A + 1){
		rep(ii, 0, B + 1){
			rep(iii, 0, C + 1){
				if (i * 500 + ii * 100 + iii * 50 == X) cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


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

const int N = 1e5+5;

int n , a , b , c , dp[N][3];

int main(){

  cin >> n;

  cin >> dp[0][0] >> dp[0][1] >> dp[0][2];

  for(int i = 1 ; i < n ; i++){
    cin >> a >> b >> c;
    dp[i][0] = a+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = b+max(dp[i-1][0],dp[i-1][2]);
    dp[i][2] = c+max(dp[i-1][1],dp[i-1][0]);
  }

  cout << max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])) << "\n";

}


Measured memory_bytes: 4716
#include<iostream>
using namespace std;
int main()
{
    int A,B,C;
    cin >> A >> B >> C;

    string ans = "No";

    if ((A == B && A != C) || (A != B && A == C) || (B == C && B != A)) {
        ans = "Yes";
    }
    


    cout << ans << endl;


    
    return 0;
}

Measured memory_bytes: 256
N = int(input())
items = []
for i in range(N):
    items.append(tuple(map(int, input().split())))


res = []
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        x1, y1 = items[i]
        x2, y2 = items[j]
        res.append((x1-x2, y1 -y2))

ans = 0
tar = list(set(res))
for t in tar:
    cnt = 0
    for i in range(N):
        x, y = items[i]
        for j in range(N):
            if i == j:
                continue
            x2, y2 = items[j]
            if x - t[0] == x2 and y - t[1] == y2:
                cnt += 1
                break
    ans = max(ans, cnt)
print(N - ans)


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define Rep(i,N) for(int i = 0; i < N;i++)
typedef pair<int,int> Pi;
#define F first
#define S second
#define INF 1 << 28

inline void chmax(int &a,int b) {
  a = max(a,b);
}

inline void chmin(int &a,int b) {
  a = min(a,b);
}

int main()
{
  int A, B, C, N;
  while(cin >> A >> B >> C, A || B || C) {
    int data[1005][3], r[1005];
    int flag[305];
    fill(flag,flag + 305,2);
    
    cin >> N;
    Rep(i,N) {
      Rep(j,3) {
	cin >> data[i][j];
	data[i][j]--;
      }
      cin >> r[i];
      if(r[i]) {
	Rep(j,3)flag[data[i][j]] = 1;
      }
    }
    Rep(i,N) {
      if(r[i])continue;
      int cnt = 0;
      int f;
      Rep(j,3) {
	if(flag[data[i][j]] == 1)cnt++;
	else f = j;
      }
      if(cnt == 2)flag[data[i][f]] = 0;
    }
    Rep(i,A + B + C) {
      cout << flag[i] << endl;
    }
  }
  return 0;
}
    
      

Measured memory_bytes: 3000
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define   PI    acos(-1)
int fx[]= {0,1,0,-1};
int fy[]= {-1,0,1,0};
#define mx 100005
ll dp[mx];
int main()
{
    ll n,i,j,k=2;
    cin>>n;
    ll a[n];
    for(i=0; i<n; i++)
    {
        cin>>a[i];
    }
    for(i=1;i<=mx;i++)dp[i]=INT_MAX;
    for(i=0; i<n; i++)
    {
        for( j=i+1;j<=i+k;j++){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
    return 0;
}





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

const string YES = "Yes";
const string NO = "No";

void solve(long long a, long long b, long long c)
{
    cout<<(4*a*b<(c-a-b)*(c-a-b)&&(c>a+b)?YES:NO)<<endl;
}

int main()
{
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    long long c;
    scanf("%lld",&c);
    solve(a, b, c);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <set>
#include <math.h>
using namespace std;

int main(int argc, const char * argv[]) {
    int a, b, ave;
    cin >> a >> b;
    ave = (a + b + 1)/2;
    
    cout << ave << endl;
    return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	vector<int> a(N);
	rep(i, N) {
		cin >> a.at(i);	
	}

	sort(a.rbegin(), a.rend());

	int A = 0, B = 0;
	rep(i, N) {
		if (i % 2 == 0) {
			A += a.at(i);		
		}
		else {
			B += a.at(i);
		}
	}

	cout << A - B << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define rep(i, n) for(ll i=0; i<(ll)(n); i++)
#define repd(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a-1; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};


int main(){
    string s, t;    cin >> s >> t;
    vector<vector<ll>> dp(s.size()+1, vector<ll>(t.size()+1));
    rep(i, s.size()){
        rep(j, t.size()){
            dp[i+1][j+1] = dp[i][j] + (s[i]==t[j]);
            dp[i+1][j+1] = max(max(dp[i+1][j], dp[i][j+1]), dp[i+1][j+1]);
        }
    }
    ll sc=s.size(), tc=t.size();
    string res="";
    while(0<tc && 0<sc){
        if(dp[sc][tc]==dp[sc-1][tc]) sc -= 1;
        else if(dp[sc][tc]==dp[sc][tc-1]) tc -= 1;
        else{
            res += s[sc-1];
            sc -= 1, tc -= 1;
        }
    }
    reverse(ALL(res));
    cout << res << endl;
    
}


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

int main(void){
   vector<vector<int>> a(15,vector<int>(15,-1));
   int n;
   cin >> n;
   
   for(int i = 0;i < n;i++){
         int A;
         cin >> A;
         for(int j = 0;j < A;j++){
               int x,y;
               cin >> x >> y;
               x--;
               a[i][x] = y;
         }
   }
   int ans = 0;
   for(int i = 0;i < 1 << n;i++){
         vector<int> d(n);
         for(int j = 0;j < n;j++){
               if(i >> j & 1)d[j] = 1;
         }
         bool ok = true;
         
         for(int j = 0;j < n;j++){
               if(d[j]){
                     for(int k = 0;k < n;k++){
                           if(a[j][k] == -1)continue;
                           if(a[j][k] != d[k])ok = false;
                     }
               }
         }
         if(ok) ans = max(ans,__builtin_popcount(i));
   }
   cout << ans << endl;
   
}


Measured memory_bytes: 3564
a = Array.new
b = Array.new
a[0], b[0] = gets.split.map(&:to_i)
i = 0
while a[i] != 0 && b[i] != 0 do
	i += 1
	a[i], b[i] = gets.split.map(&:to_i)
end
i = 0
while a[i] != 0 && b[i] != 0 do
	for j in 1..a[i] do
		for k in 1..b[i] do
			print "#"
		end
		puts
	end
	puts
	i += 1
end

Measured memory_bytes: 8808
import bisect

n, m = [int(i) for i in input().split()]
a_list = [int(i) for i in input().split()]

new_cards_info = {}

for a in a_list:
    if a in new_cards_info:
        new_cards_info[a] += 1
    else:
        new_cards_info[a] = 1

for _ in range(m):
    b, c = [int(i) for i in input().split()]
    if c in new_cards_info:
        new_cards_info[c] += b
    else:
        new_cards_info[c] = b

new_cards_info = sorted(new_cards_info.items(), key=lambda x:x[0], reverse=True)

sum = 0
count = 0

for key, size in new_cards_info:
    sum += key * size
    over = count + size - n
    if over >= 0:
        sum -= key * over
        break
    count += size

print(sum)


Measured memory_bytes: 43168
#include <iostream>

int main()
{
    int a, b;
    while (std::cin >> a >> b) {
        int sum = a + b;
        int digit = 1;
        while ((sum /= 10) >= 1) {
            digit++;
        }
        std::cout << digit << std::endl;
    }

    return 0;
}

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

int N;
vector<vector<int>> A(3,vector<int> (3));
vector<vector<bool>> appear(3,vector<bool> (3));
vector<int> b(10);
int main(){
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++) cin >> A.at(i).at(j);
  }
  cin >> N;
  for(int i = 0; i < N; i++) cin >> b.at(i);
  for(int i = 0; i < 3; i++){
    for(int j = 0; j < 3; j++){
      appear.at(i).at(j) = false;
      for(int k = 0; k < N; k++){
        if(A.at(i).at(j)==b.at(k))appear.at(i).at(j)=true;
      }
    }
  }
  string ans = "No";
  for(int i = 0 ; i < 3; i++){
    if(appear.at(i).at(0) and appear.at(i).at(1) and appear.at(i).at(2)) ans = "Yes";
  }
  for(int i = 0 ; i < 3; i++){
    if(appear.at(0).at(i) and appear.at(1).at(i) and appear.at(2).at(i)) ans = "Yes";
  }
  if(appear.at(0).at(0) and appear.at(1).at(1) and appear.at(2).at(2)) ans = "Yes";
  if(appear.at(0).at(2) and appear.at(1).at(1) and appear.at(2).at(0)) ans = "Yes";  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
def pattern(word)
    word.each_char.each_cons(2).map {|a, b| (b.ord - a.ord) % 26}
end

$patterns = %w[the this that].map {|w| pattern(w)}

# Return: integer the number of shift
def get_key(enc)
    enc.scan(/[a-z]+/).each do |word|
        next if word.size < 3 or 4 < word.size

        if $patterns.include?(pattern(word))
            return ('t'.ord - word.ord) % 26
        end
    end
end

$<.each_line do |line|
    key = get_key(line)
    puts line.each_char.map {|c|
        next c unless c.match(/[a-z]/)
        ('a'.ord + (c.ord - 'a'.ord + key) % 26).chr
    }.join
end

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

abc=[chr(i) for i in range(97,123)]

N=int(input())

#for n in range(1,100):
#N=n
ans=""

L=0
for i in range(1,12):
    if N >= 26**i:
        N-=26**i
    else:
        L=i
        break
#print(L,N)

if N==0:
    for i in range(L-1):
        ans+="z"
else:
    for i in range(L,1,-1):
        if N <= 26**(i-1):
            ans+="a"
        else:        
            for j in range(1,26):
                if 26**(i-1)*j < N and 26**(i-1)*(j+1) >= N:
                    ans+=abc[j]
                    N-=26**(i-1)*j
                    break
    ans+=abc[N-1]
print(ans)

"""
re=0
L=len(ans)
for i in range(L):
    ind=abc.index(ans[L-i-1])+1
    re+=ind*26**i

print(re)

if n!=re:
    print(n)
    break
"""



Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> P3;
typedef pair<P ,P> PP;
constexpr ll MOD = ll(1e9) + 7;
constexpr int IINF = INT_MAX;
constexpr ll LLINF = LLONG_MAX;
constexpr int MAX_N = int(1e5) + 5;
constexpr double EPS = 1e-8;
constexpr int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define SORTR(v) sort((v).rbegin(), (v).rend())
#define ALL(v) (v).begin(), (v).end()

ll ans = 0;
vector<ll> x, y;
vector<bool> used;
map<P,ll> cnt;

ll gcd(ll p, ll q){
    if(q==0) return p;
    else return gcd(q, p%q);
}

P calc_line(int i, int j){
    ll dx, dy, g;
    dx = x[i] - x[j];
    dy = y[i] - y[j];
    if(dx < 0){
        dx *= -1;
        dy *= -1;
    }
    else if(dx == 0){
        dy = abs(dy);
    }
    g = gcd(abs(dx), abs(dy));
    return P(dx/g, dy/g);
}

void rec(int i){
    if(i<0){
        ll sum = 0;
        for(auto p : cnt){
            ll c = p.second;
            sum += c*(c-1)/2;
        }
        ans = max(ans, sum);
    }
    else if(used[i]) rec(i-1);
    else{
        used[i] = true;
        for(int j=i-1;j>=0;j--){
            if(used[j]) continue;
            P line = calc_line(i,j);
            used[j] = true;
            cnt[line]++;
            rec(i-1);
            used[j] = false;
            cnt[line]--;
        }
        used[i] = false;
    }
}

int main() {
    int m;
    cin >> m;
    x.resize(m);
    y.resize(m);
    used.resize(m);
    for(int i=0;i<m;i++){
        cin >> x[i] >> y[i];
    }
    rec(m-1);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3148
import sys 
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(10**6)
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))

def solve(table,ava,now):
    if not 1 in ava:
        global ans
        ans += 1
        return
    global N
    for i in range(N):
        if table[now][i] and ava[i]:
            bt,ba = deepcopy(table),deepcopy(ava)
            bt[now][i] = bt[i][now] = ba[i] = 0
            solve(bt,ba,i)
    return

if __name__=='__main__':
    tmp = deque(LI())
    N,M = tmp.popleft(),tmp.popleft()
    table = [[0]*N for _ in range(N)]
    for i in range(M):
        tmp = deque(LI())
        a,b = tmp.popleft()-1,tmp.popleft()-1
        table[a][b] = table[b][a] = 1
    ans = 0
    ava = [1]*N
    ava[0] = 0
    solve(table,ava,0)
    print(ans)

Measured memory_bytes: 3444
import sys
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20

def mint():
    return map(int,input().split())
def lint():
    return map(int,input().split())
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])

N,A = int(input()),lint()
S = [0]*(10**5+10)
for a in A:
    S[a-1] += 1
    S[a] += 1
    S[a+1] += 1
print(max(S))

Measured memory_bytes: 84444
#include <bits/stdc++.h>
using namespace std;
bool count_black(vector<vector<char>> &array,int k){
    int black = 0;
    for(int i=0;i<array.size();i++){
        for(int j=0;j<array.at(0).size();j++){
            if(array.at(i).at(j) == '#') black++;
        }
    }

    return black == k;
}

void show(vector<vector<char>> array){
    for(int i=0;i<array.size();i++){
        for(int j=0;j<array.at(0).size();j++){
            cout << array.at(i).at(j);
        }
        cout << endl;
    }
    cout << endl;
}


int main(){
    int h,w,k;
    cin >> h >> w >> k;
    vector<vector<char>> array(h,vector<char>(w));
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> array.at(i).at(j);
        }
    }
    int cnt = 0;
    for(int tmp=0; tmp < (1 << h+w);tmp++){
        bitset<12> b(tmp);
        vector<vector<char>> copy = array;
        for(int i=0;i<h+w;i++){
            if(b.test(i)){
                if(i<h){
                    for(int j=0;j<w;j++){
                        copy.at(i).at(j) = 'r';
                    }
                }else{
                    int yoko_idx = i - h;
                    for(int j=0;j<h;j++){
                        copy.at(j).at(yoko_idx) = 'r';
                    }
                }
            }
            
        }
        //show(copy);
            if(count_black(copy,k)){
                cnt++;
            }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <unordered_map>

typedef long long ll;
using namespace std;

string insertion_sort(string str) {
    for(int i=1; i<10; i++) {
        int j=i;
        while(j>0 && str[j-1]>str[j]) {
            char tmp = str[j-1];
            str[j-1] = str[j];
            str[j] = tmp;
            j--;
        }
    }
    return str;
}

int main() {
    int n;
    cin >> n;
    string s[n];
    unordered_map<string, ll> scores;
    for(int i=0; i<n; i++) {
        cin >> s[i];
        s[i] = insertion_sort(s[i]);
        if(scores.find(s[i])==scores.end()) scores[s[i]]=1;
        else scores[s[i]]++;
    }

    ll cnt = 0;
//  for(auto itr=scores.begin(); itr!=scores.end(); itr++) 
    for(auto x : scores) {
        cnt += x.second * (x.second-1) / 2;
    }
    cout << cnt << endl;

    return 0;
}



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

int main(){
  int n,k;
  cin >>n>>k;
  if(n==0){
    cout <<1<<endl;
    return 0;
  }
  int ans=0;
  while(n!=0){
    n/=k;
    ans++;
  }
  cout <<ans<<endl;
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
typedef long long  ll ;
typedef double db;
const double pi = 3.141592654;
#define pb         push_back
#define forab(i,a,b)       for(int i=(a);i<=(b);i++)
#define CIN	ios_base::sync_with_stdio(0); cin.tie(0)
#define pcase(z,x)     printf("Case %ld: %lld\n",z,x)
#define nw	 "\n"
#define mod 1000000007

int main(void)
{
	CIN;
	ll tc,l,k,sum=0,x=0,y,z=0,m=1,n=0,ans=0,cnt=0;
	cin>>n>>x>>y;
	n=(ll)ceil((db)n*1.0/x);
	n*=y;
	cout<<n;
	

}

Measured memory_bytes: 3756
#include<stdio.h>

int main(void)
{
    int s[99],t[99];
    int a,b;
    int u[99];

    scanf("%s %s",s,t);
    scanf("%d %d",&a,&b);
    scanf("%s",u);

    if(strcmp(s,u) == 0)
    {
        a--;
    }
    else if(strcmp(t,u) == 0)
    {
        b--;
    }

    printf("%d %d",a,b);

    return 0;
}

Measured memory_bytes: 128