akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int RT;

struct tr{
	int la[105],nt[205],en[205],owo;
	void adg(int x,int y) {
		en[++owo]=y; nt[owo]=la[x]; la[x]=owo;
	}
	void re() {
		memset(la,0,sizeof la); owo = 0;
	}
	int fa[105];
	void dfs(int x,int ba) {
		fa[x] = ba;
		for(int it=la[x];it;it=nt[it]) {
			int y = en[it];
			if(y==ba||y==RT) continue;
			dfs(y,x);
		}
	}
}A,B;
int en[205],la[105],nt[205],owo;
void adg(int x,int y) {
	en[++owo]=y; nt[owo]=la[x]; la[x]=owo;
}
bool vis[105];
bool inst[105];

int ANS;
int n,ds[105];
bool dds(int x) {
	inst[x] = 1;
	vis[x] = 1;
	for(int it=la[x];it;it=nt[it]) {
		int y = en[it];
		if(inst[y]) return 0;
		else if(!vis[y]){
			if(!dds(y)) return 0;
		}
	}
	inst[x] = 0;
	return 1;
}
int MKT;
int mark[105];
bool V[105];
void DC(int x,int ba) {
	V[x] = 1;
	int yo = ++MKT;
	for(int it=A.la[x];it;it=A.nt[it]) mark[A.en[it]] = yo;
	for(int it=B.la[x];it;it=B.nt[it]) {
		int y = B.en[it];
		if(y==ba||y==RT) continue;
		if(mark[y]==yo) DC(y,x);
	}
}
void rre() {
	memset(la,0,sizeof la); owo = 0;
	memset(vis,0,sizeof vis);
	memset(inst,0,sizeof inst);
	memset(V,0,sizeof V);
}
int orz(int xx) {
	RT = xx;
	for(int i=1;i<=n;i++) {
		A.fa[i] = B.fa[i] = 0;
	}
	A.dfs(xx,0); B.dfs(xx,0);
	rre();

	DC(xx,0);
	int cc = 0;
	for(int i=1;i<=n;i++) {
		if(V[i]) continue;
		if(!V[A.fa[i]]) adg(i,A.fa[i]);
		if(!V[B.fa[i]]) adg(B.fa[i],i);
		cc++;
	}
	for(int i=1;i<=n;i++) {
		if(vis[i]) continue;
		if(!dds(i)) return 0x3f3f3f3f;
	}
	return cc;
}
void solve() {
	scanf("%d",&n);
	A.re(); B.re();
	ANS = 0x3f3f3f3f;
	memset(ds,0,sizeof ds);
	for(int i=1;i<n;i++) {
		int x,y; scanf("%d%d",&x,&y);
		A.adg(x,y);A.adg(y,x);
		ds[x]++; ds[y]++;
	}
	for(int i=1;i<n;i++) {
		int x,y; scanf("%d%d",&x,&y);
		B.adg(x,y);B.adg(y,x);
	}
	for(int i=1;i<=n;i++) 
		ANS = min(ANS,orz(i));
	for(int i=1;i<=n;i++) {
		if(ds[i]==1) {
			int ff = A.en[A.la[i]];
			for(int j=1;j<=n;j++) {
				if(j!=i&&j!=ff) {
					A.en[A.la[i]] = j;
					ANS = min(ANS,orz(i)+1);
					A.en[A.la[i]] = ff;
				} 
			}
		}
	}
	if(ANS==0x3f3f3f3f) puts("-1");
	else printf("%d\n",ANS);
}

int main() {
	int T;
	scanf("%d",&T);
	while(T--) solve();
}

Measured memory_bytes: 256
N = int(input())
S1 = input()
S2 = input()
if S1[0] == S2[0]:
    ans = 3
    i = 1
else:
    ans = 6
    i = 2
MOD = 1000000007
while i < N:
    if S1[i - 1] == S2[i - 1]:
        ans = ans * 2 % MOD
        if S1[i] != S2[i]:
            i += 1
    else:
        if S1[i] != S2[i]:
            ans = ans * 3 % MOD
            i += 1
    i += 1
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const int maxn = 2e5 + 5 ;
map<string , int> num ;
int n ;
string s ;
int main()
{
	std::ios::sync_with_stdio(false) ;
    cin.tie(0) ;
    cin >> n ;
	for(int i = 1 ; i <= n ; i ++)  cin >> s , num[s] ++ ;
	int max1 = 0 ;
	for(auto x : num)  max1 = max(max1 , x.second) ;
	for(auto x : num)  if(x.second == max1)  cout << x.first << '\n' ;
	return 0 ;
}

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

using namespace std;

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

	if (n % 2 == 1) {
		cout << "No\n";
	}
	else {
		if (st.substr(0, n / 2) == st.substr(n / 2, n / 2)) {
			cout << "Yes\n";
		}
		else {
			cout << "No\n";
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	ll ACount[100100];
	int N;
	cin >> N;
	ll sum = 0;
	fill(ACount, ACount+100100, 0);
	for(int i = 0; i < N; i++){
		int A;
		cin >> A;
		ACount[A]++;
		sum += A;
	}
	ll ans[100100];
	int Q;
	cin >> Q;
	for(int q = 0; q < Q; q++){
		ll B, C;
		cin >> B >> C;
		sum -= ACount[B] * B;
		sum += ACount[B] * C;
		ACount[C] += ACount[B];
		ACount[B] = 0;
		ans[q] = sum;
	}
	
	for(int q = 0; q < Q; q++){
		cout << ans[q] << endl;
	}
	return 0;
}


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

int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (a + b < c + d){
    cout << "Right";
  }
  else if (a + b == c + d){
    cout << "Balanced";
  }
  else{
    cout << "Left";
  }
}

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

using namespace std;

#define LL long long
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    LL d,k,n,x;
    cin >> n >> k >> d;
    n=abs(n),x=n;
    n-=min(k,n/d)*d;
    k-=min(x/d,k);
    if(n <= abs(n-d))
    {
        if(k & 1)cout << abs(n-d);
        else cout << n;
    }
    else
    {
        --k,n-=d;
        if(k & 1)cout << abs(n+d);
        else cout << abs(n);
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int x3 = x2 + (y1 - y2);
  int y3 = y2 - (x1 - x2);
  int x4 = x1 + (y1 - y2);
  int y4 = y1 - (x1 - x2);
  cout << x3 << " " << y3 << " " << x4 << " " << y4;
}


Measured memory_bytes: 384
//from PKU1125
double dist[1001][1001],d;
next[1001][1001],x[1001],y[1001];
main(){
	int a,b,k,n,i,j;
	for(;scanf("%d",&n),n;){
		/*initialize*/
		for(i=1;i<=n;i++)scanf("%d",&a),scanf("%d%d",x+a,y+a);
		for(i=1;i<=n;i++)for(j=1;j<=n;next[i][j]=j,j++)
			dist[i][j]=(d=hypot(x[i]-x[j],y[i]-y[j]))<50.001?d:9999;

		{/*warshall-floyd*/
			int k,i,j;
			for(k=1;k<=n;k++)
				for(i=1;i<=n;i++)
					for(j=1;j<=n;j++){
						if(dist[i][j]>dist[i][k]+dist[k][j])
							dist[i][j]=dist[i][k]+dist[k][j],next[i][j]=next[i][k];
					}
		}

		{/*query*/
			for(scanf("%d",&k);k;k--){
				scanf("%d%d",&a,&b);
				if(dist[a][b]>9990)puts("NA");
				else{
					for(j=a;j!=b;j=next[j][b])printf("%d ",j);
					printf("%d\n",b);
				}
			}
		}
	}exit(0);
}

Measured memory_bytes: 5108
function Main(input) {
  input = input.trim()
  input = input.split(" ").map(Number);
  if(input[0]<input[2]){
  input[1] -= (input[2]-input[0]);
  input[0] = 0;
  }else{
  input[0] -= input[2];
  }
  if(input[1]<0) input[1]=0;
  console.log(input[0]+" "+input[1]);
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <functional>
#include <list>
#include <numeric>
#include <queue>
#include <sstream>
#include <utility>
#include <vector>

#define REP(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) (a).begin(), (a).end()
#define AALL(a, n) (a), (a) + (n)
#define FILL(a, n) memset((a), n, sizeof(a))
#define FILLZ(a) FILL(a, 0)

using namespace std;

typedef long long ll;

const double EPS = 1e-10;
const double PI = acos(-1.0);

inline int toInt(string s) {
	int v;
	istringstream sin(s);
	sin >> v;
	return v;
}

int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	priority_queue<int> a;
	REP(i, n) {
		int tmp;
		scanf("%d", &tmp);
		a.push(tmp);
	}

	REP(j, m) {
		bool flag = false;
		int tmp = a.top() / 2;
		a.pop();
		a.push(tmp);
	}

	ll result = 0;
	REP(i, n) {
		result += (ll)a.top();
		a.pop();
	}

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

	return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b) // assuming a,b >= 1
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b) // assuming a,b >= 1
{
	return  a * b / GCD(a, b);
}
//int COUNTDIV(int n) 素因数分解して+1してかける奴
int COUNTDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR (int x) {
	if (x ==1)
		return false;
	if (x == 2)
		return true;
	if (x%2==0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}

using namespace std;
#pragma endregion
signed main() {
	int N,ans=0;
	cin >> N;
	REP(i, N) {
		if (i % 2 == 1 && COUNTDIV2(i)==8)
			ans++;
	}
	cout << ans;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<limits.h>
#define MAX 100

void cul(int);

int m[MAX+1][MAX+1]; //m[i][j]は行列積Mi ... Mjのコストの最小値。1オリジンだからMAX+1
int p[MAX+1];

int main(){
  int n, r, c; //r行 c列
  int i;

  scanf("%d", &n);
  for(i=0;i<n;i++){
    scanf("%d %d", &r, &c);
    p[i] = r;
    p[i+1] = c;
  }

  cul(n);
  
  printf("%d\n", m[1][n]);
  
  return 0;
}

void cul(int n){
  int i, j, k, l; //iとjは対象の行列の最初の番号と最後の番号、kは積の計算を分割する、lは対象の行列の数
  int cost; //計算にかかるコスト
  
  //まずi=j(つまりl=1)の場合を処理
  for(i=1;i<=n;i++) m[i][i] = 0;

  //求めるのはl=nの時のコストの最小
  //l=1の場合は処理してあるので2からスタート
  //iは最初の番号なので1スタート、後から設定するjがnを超えないようにiを設定
  for(l=2;l<=n;l++){
    for(i=1;i<=n-l+1;i++){
      j = i + l - 1; //i+lだと対象の行列の数より、jが1だけ大きくなってしまう
      m[i][j] = INT_MAX;
      //i <= k < jなのでkはjを含まない
      for(k=i;k<j;k++){
	cost = m[i][k] + m[k+1][j] + p[i-1] * p[k] * p[j];
	if(m[i][j] >= cost) m[i][j] = cost;
      }
    }
  }
  
}



Measured memory_bytes: 2092
# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
alphasm=[chr(i) for i in range(97, 97+26)]
lis=[Counter(list(SI())) for i in range(n)]
alcount=[inf for i in range(26)]
for j in range(26):
    for i in range(n):
        alcount[j]=min(alcount[j],lis[i][alphasm[j]])
#print(alcount)
for i in range(26):
    for j in range(alcount[i]):
        print(alphasm[i],end="")
    
    
    




Measured memory_bytes: 70344
import sys
from fractions import gcd
input = sys.stdin.readline
A, B, C, D = map(int, input().split())
l = (A - 1) // C + (A - 1) // D - (A - 1) // (C * D // gcd(C, D))
r = B // C + B // D - B // (C * D // gcd(C, D))
print(B - A + 1 - (r - l))

Measured memory_bytes: 64364
#include <iostream>
#include <math.h>
using namespace std;
int main(void){
    // Here your code !
    double r;
    scanf("%lf",&r);
    double ans1 = M_PI*r*r;
    double ans2 = M_PI*2*r;
    printf("%lf %lf",ans1,ans2);
}

Measured memory_bytes: 3200
from collections import deque
def readinput():
    n,m,k=list(map(int,input().split()))
    a=list(map(int,input().split()))
    b=list(map(int,input().split()))
    return n,m,k,a,b

def main(n,m,k,a,b):
    qa=deque(a)
    qb=deque(b)
    count=0
    res=k
    while(len(qa)>0 and len(qb)>0):
        if qa[0] < qb[0]:
            res-=qa[0]
            qa.popleft()
        else:
            res-=qb[0]
            qb.popleft()
        if res<0:
            return count
        count+=1
    else:
        if len(qa)==0:
            while(len(qb)>0):
                res-=qb[0]
                qb.popleft()
                if res<0:
                    return count
                count+=1
            return count
        else:
            while(len(qa)>0):
                res-=qa[0]
                qa.popleft()
                if res<0:
                    return count
                count+=1
            return count

import sys
INFTY=sys.maxsize
def find(t,s):
    '''
    単調増加配列sからs[i]がtを超えない最大のiを返す
    '''
    ss=s[:]
    ss.append(INFTY)
    left=0
    right=len(ss)
    while(left<right):
        middle=(left+right)//2
        #print(left,middle,right,t,ss)
        if ss[middle]==t:
            #print(middle, ss)
            return middle
        if t<ss[middle]:
            right=middle
        else:
            left=middle+1
    else:
        return left-1

def main2(n,m,k,a,b):
    sa=[0]
    for i in range(1,n+1):
        sa.append(sa[i-1]+a[i-1])
    sb=[0]
    for i in range(1,m+1):
        sb.append(sb[i-1]+b[i-1])
    maxab=0
    nb=m+1
    for na in range(0,n+1):
        res=k-sa[na]
        if res>=0:
            nb=find(res,sb[:nb+1])
            #print(na,nb,sa,sb)
            maxab=max(maxab,na+nb)
    return maxab

from bisect import bisect_left
def main3(n,m,k,a,b):
    sa=[0]
    for i in range(1,n+1):
        sa.append(sa[i-1]+a[i-1])
    sb=[0]
    for i in range(1,m+1):
        sb.append(sb[i-1]+b[i-1])
    maxab=0
    nb=m+1
    for na in range(0,n+1):
        res=k-sa[na]
        if res>=0:
            nb=bisect_left(sb[:nb+1],res)
            #print(na,nb,sa,sb)
            maxab=max(maxab,na+nb)
    return maxab

def main4(n,m,k,a,b):
    sa=[0]
    for i in range(1,n+1):
        sa.append(sa[i-1]+a[i-1])
    sb=[0]
    for i in range(1,m+1):
        sb.append(sb[i-1]+b[i-1])
    maxab=0
    nb=m
    for na in range(0,n+1):
        res=k-sa[na]
        while res<sb[nb] and nb>=0:
            nb-=1
        else:
            if nb>=0:
                maxab=max(maxab,na+nb)
        #print(na,nb)
    return maxab

def readinput2():
    m=2*10**5
    n=2*10**5
    a=[10**9]*n
    b=[10**9]*m
    k=1
    return n,m,k,a,b

if __name__=='__main__':
    n,m,k,a,b=readinput()
    ans=main4(n,m,k,a,b)
    print(ans)


Measured memory_bytes: 49544
h, w = [int(i) for i in input().split()]
a = [[int(i) for i in input().split()] for j in range(h)]
count, ans = [0,""]
for i,ai in enumerate(a):
    for j,aij in enumerate(ai):
        if aij % 2 != 0:
            if j != w-1:
                count += 1
                a[i][j+1] += 1
                ans += "{} {} {} {}\n".format(i+1,j+1,i+1,j+2)
            elif i != h-1:
                count += 1
                a[i+1][j] += 1
                ans += "{} {} {} {}\n".format(i+1,j+1,i+2,j+1)
print(count)
print(ans)

Measured memory_bytes: 11040
#include <iostream>

using namespace std;

typedef long long LL;

const int N = 100010;

int n, k, w[N];

int check(LL p)
{
    int cnt = k;
    int i = 0;
    while (cnt--) {
        LL v = p;
        while (w[i] <= v) {
            v -= w[i];
            i++;
            if (i == n)
                return i;
        }
    }
    return i;
}

int main()
{
    int max_p = 0;
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &w[i]);
        max_p = max(max_p, w[i]);
    }
    
    LL l = 0, r = max_p * n;
    while (l < r) {
        int mid = l + r >> 1;
        if (check(mid) >= n)
            r = mid;
        else
            l = mid + 1;
    }
    printf("%lld\n", r);
    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
int main()
{
int R, G, B, N;
int some=scanf("%d %d %d %d",&R,&G,&B, &N);
int r, g;
int counter=0;

for(r=0;r*R<=N;r++)
for(g=0;g*G<=N-r*R;g++)
if((N-r*R-g*G)%B==0 && (N-r*R-g*G)>=0)
{
counter++;
//printf("%d %d %d\n",r,g,(N-r*R-g*G)/B);
}
printf("%d", counter);
return 0;
}

Measured memory_bytes: 128
#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() {
  int n;
  cin >> n;
  int ans = 0;
  for(int v=1; v<=n; v+=2){
    vector<int> m;
    for(int p=1; p*p<=v; ++p){
      if(v%p==0){
        m.push_back(p);
        if(p*p!=v) m.push_back(v/p);
      }
    }
    if(m.size()==8) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;
vi A, B;
string S, T;

void input() {
  int x, y, z;
  ;
}
void solve() {
  char a, b;
  cin >> a >> b;
  if ((a == 'H' && b == 'H') || (a == 'D' && b == 'D')) {
    cout << "H" << endl;
  } else
    cout << "D" << endl;
  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
int main()
{
    ///"In the name of Allah,most gracious and most merciful"///

        ll i,j,x,y,z,count=0,sum=0,n,ans=0;
        string a,b,c;
        cin>>a>>b;
        c=a+b;
        ll k=stoi(c);

        bool ok = true;

        for(i=1;i*i<=k;i++)
        {
            if((i*i)==k)
            {
                ok=false;
                break;
            }
        }

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


    return 0;
}





Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
  ll arr[1005];
  int n,tc,q,l,r;
  cin>>n;
  for(int i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  cin>>tc;
  while(tc--)
  {
    cin>>q;
    if(q==0)
    {
      cin>>l>>r;
      cout<<*min_element(arr+l,arr+r)<<endl;
    }
    else
    {
      cin>>l>>r;
      cout<<*max_element(arr+l,arr+r)<<endl;
    }
  }
}



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

int main(){
  int N;
  string S, T="ABC";
  cin >> N >> S;
  int count=0;
  for(int i=0; i<N-2; i++){
    bool f =true;
    for(int j=0; j<3; j++){
      if(S[i+j]==T[j]) continue;
      else f=false;
    }
    if(f) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 256
N, *A = map(int, open(0).read().split())

dp = [[-10 ** 10] * 3 for _ in range(N + 1)]
dp[0] = [0] * 3
dp[1][0] = A[0]
dp[2][1] = A[1]
for i in range(2, N):
    dp[i + 1][0] = dp[i - 1][0] + A[i]
    dp[i + 1][1] = max(dp[i - 1][1], dp[i - 2][0]) + A[i]
    dp[i + 1][2] = max(dp[i - 1][2], dp[i - 2][1], dp[i - 3][0]) + A[i]

if N % 2 == 1:
    print(max(dp[-3][0], dp[-2][1], dp[-1][2]))
else:
    print(max(dp[-2][0], dp[-1][1]))



Measured memory_bytes: 109304
import java.util.Scanner;

public class Main {
	static int MOD = 998244353;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int S = sc.nextInt();
		int[] A = new int[N + 1];
		for (int i = 0; i < N; i++) {
			A[i + 1] = sc.nextInt();
		}
		sc.close();

		int[][] dpa = new int[2][];
		dpa[0] = new int[S + 1];
		dpa[1] = new int[S + 1];
		int[][] dpl = new int[2][];
		dpl[0] = new int[S + 1];
		dpl[1] = new int[S + 1];
		dpl[0][0] = 0;
		dpa[0][0] = 0;
		for ( int r = 1 ; r <= N ; r++ ) {
			int curr = r % 2;
			int lastr = (r - 1) % 2;
			dpl[curr][0] = dpl[lastr][0] + 1;
			dpa[curr][0] = (dpl[curr][0] + dpa[lastr][0]) % MOD;
			for ( int s = 1 ; s <= S ; s++ ) {
				dpl[curr][s] = (s - A[r] >= 0) ? dpl[lastr][s - A[r]] : 0;
				if (s == A[r]) {
					dpl[curr][s]++;
				}
				dpl[curr][s] = (dpl[curr][s] + dpl[lastr][s]) % MOD;

				dpa[curr][s] = (dpl[curr][s] + dpa[lastr][s]) % MOD;
			}
		}
		System.out.println(dpa[N % 2][S]);
	}
}


Measured memory_bytes: 26140
#pragma GCC optimize("-O3")

#include <bits/stdc++.h>

#define ll long long

#define T 100
#define PI 3.1415926535897932384

const ll mod = (ll)1e9 + 7;

using namespace std;


int n;
pair<ll, ll> points[100];

ll calc_max(double theta) {
	ll x, y; x = y = 0;
	double xt = cos(theta);
	double yt = sin(theta);
	for (int i = 0; i < n; ++i) {
		double d =
			points[i].first * xt + points[i].second * yt;
		if (d >= 0) {
			x += points[i].first;
			y += points[i].second;
		}
	}
	return x * x + y * y;
}

signed main() {
	cin >> n;
	for (int i = 0; i < n; ++i) {
		ll xi, yi;
		cin >> xi >> yi;
		points[i] = make_pair(xi, yi);
	}

	ll ans = 0;

	for (double t = 0; t <= 2 * PI; t += (2 * PI / T)) {
		ans = max(ans, calc_max(t));
	}

	cout << setprecision(15) << pow(ans, 0.5) << endl;

	return 0;
}

Measured memory_bytes: 256
// c++include
#include <iostream>
#include <algorithm>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用<-namespace
using namespace std;

// define, typedef
#define rpt(i, n) for(ll i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	ll n, k, q;
	cin >> n >> k >> q;
	ll a[100000 + 1];
	for (ll i = 1; i <= n; i++) {
		a[i] = 0;
	}
	rpt(i, q) {
		ll tmp;
		cin >> tmp;
		a[tmp]++;
	}
	for(ll i = 1; i <= n; i++) {
		if (k - (q - a[i]) > 0)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    string s;
    cin >> s;
    cout << s[0] << s.size()-2 << s[s.size()-1] << endl;
}

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


class SegmentTree:
    def __init__(self, N, func, I):
        self.sz = 2**(N-1).bit_length()
        self.func = func
        self.I = I
        self.seg = [I] * (self.sz * 2)

    def assign(self, k, x):
        self.seg[k + self.sz] = x

    def build(self):
        for i in reversed(range(1, self.sz)):
            self.seg[i] = self.func(self.seg[2 * i], self.seg[2 * i + 1])

    def update(self, k, x):
        k += self.sz
        self.seg[k] = x
        while k > 1:
            k >>= 1
            self.seg[k] = self.func(self.seg[2 * k], self.seg[2 * k + 1])

    def query(self, a, b):
        L = self.I
        R = self.I
        a += self.sz
        b += self.sz
        while a < b:
            if a & 1:
                L = self.func(L, self.seg[a])
                a += 1
            if b & 1:
                b -= 1
                R = self.func(self.seg[b], R)
            a >>= 1
            b >>= 1
        return self.func(L, R)


def main():
    def gcd(a, b):
        while b:
            a, b = b, a % b
        return a
    N = int(readline())
    L = map(int, readline().split())
    seg = SegmentTree(N, gcd, 0)
    for i, n in enumerate(L):
        seg.assign(i, n)
    seg.build()
    ans = 1
    for i in range(N):
        ans = max(ans, gcd(seg.query(0, i), seg.query(i+1, N)))
    print(ans)


main()


Measured memory_bytes: 60528
#include <bits/stdc++.h>
#define loop(n) for (int ngtkana_is_a_genius = 0; ngtkana_is_a_genius < int(n); ngtkana_is_a_genius++)
#define rep(i, begin, end) for (int i = int(begin); (i) < int(end); i++)
#define all(v) v.begin(), v.end()
#define rand(l, r) std::uniform_int_distribution<>(l, r)(mt)
using lint = long long;
auto mt = std::mt19937_64(std::random_device{}());
auto cmn = [](auto& a, auto b){ if (a > b) {a = b; return true;} return false; };
auto cmx = [](auto& a, auto b){ if (a < b) {a = b; return true;} return false; };
void debug_impl() { std::cerr << std::endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { std::cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
#define debug(...)\
  do {\
    std::cerr << std::boolalpha << "[" << #__VA_ARGS__ << "]:";\
    debug_impl(__VA_ARGS__);\
    std::cerr << std::noboolalpha;\
  } while (false)
#else
#define debug(...) 0;
#endif

int main() {
  std::cin.tie(0); std::cin.sync_with_stdio(false);
  struct node_type {
    node_type * left;
    node_type * right;
    std::int32_t value;
  };
  node_type * top = nullptr;
  auto insert = [&] (std::int32_t x) {
    if (!top) {
      top = ::new node_type{ nullptr, nullptr, x };
    } else {
      node_type * node = top;
      while (true) {
        node_type * & next = (x <= node->value ? node->left : node->right);
        if (next) node = next;
        else {
          next = ::new node_type{ nullptr, nullptr, x };
          break;
        }
      }
    }
  };

  auto find = [&] (std::int32_t x) {
    assert(top);
    node_type * node = top;
    while (true) {
      if (x == node->value) return true;
      node_type * next = (x < node->value ? node->left : node->right);
      if (!next) return false;
      node = next;
    }
  };

  auto print = [&] {
    std::vector< int > pre;
    std::vector< int > mid;
    auto dfs = [&](auto&& dfs, node_type * now) -> void {
      pre.emplace_back(now->value);
      if (now->left) dfs(dfs, now->left);
      mid.emplace_back(now->value);
      if (now->right) dfs(dfs, now->right);
    };
    dfs(dfs, top);
    for (int x : mid) std::cout << " " << x;
    std::cout << std::endl;
    for (int x : pre) std::cout << " " << x;
    std::cout << std::endl;
  };

  int n; std::cin >> n;
  loop(n){
    std::string s; std::cin >> s;
    switch (s.front()) {
      case 'i' : {
        int x; std::cin >> x;
        insert(x);
        break;
      }
      case 'f' : {
        int x; std::cin >> x;
        bool ans = find(x);
        std::cout << (ans ? "yes" : "no") << std::endl;
        break;
      }
      case 'p' : {
        print();
        break;
      }
    }
  }
  return 0;
}


Measured memory_bytes: 18744
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let mut sum = 0_usize;

    for i in 1..N + 1 {
        if i % 3 != 0 && i % 5 != 0 {
            sum += i;
        }
    }

    println!("{}", sum)
}


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

typedef pair<ll, ll> pll;

int main() {
	int n;
	double d, t, s;
	cin >> d >> t >> s;
	
	double a = d / s;
	if(a <= t){
	    cout << "Yes" << endl;
	}else{
	    cout << "No" << endl;
	}
}


Measured memory_bytes: 3712
#include        "algorithm"
#include        "iostream"
#include        "numeric"
#include        "iomanip"
#include        "cstring"
#include        "math.h"
#include        "bitset"
#include        "string"
#include        "vector"
#include        "ctime"
#include        "queue"
#include        "stack"
#include        "map"
#include        "set"

#include        "ext/pb_ds/assoc_container.hpp" // Common file
#include        "ext/pb_ds/tree_policy.hpp" // Including tree_order_statistics_node_update
#include        "ext/pb_ds/detail/standard_policies.hpp"

using namespace std;
using namespace __gnu_pbds;


#define          f first
#define          lgn 25
#define          endl '\n'
#define          sc second
#define          pb push_back
#define          N (int)500+5
#define          PI acos(-1.0)
#define          int long long 
#define          vi vector<int>
#define          mod 1000000007
#define          ld long double
#define          eb emplace_back
#define          mii map<int,int>
#define          vpii vector<pii>
#define          pii pair<int,int>
#define          pq priority_queue
#define          BLOCK (int)sqrt(N)
#define          test(x) while(x--)
#define          all(x) begin(x),end(x)
#define          allr(x) x.rbegin(),x.rend()
#define          fo(i,a,n) for(int i=a;i<n;i++)
#define          rfo(i,n,a) for(int i=n;i>=a;i--)
#define          FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define          time() cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n"
#define 		 bug(...)       __f (#__VA_ARGS__, __VA_ARGS__)

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

template <typename Arg1>
void __f (const char* name, Arg1&& arg1) { cout << name << " : " << arg1 << endl; }
template <typename Arg1, typename... Args>
void __f (const char* names, Arg1&& arg1, Args&&... args)
{
     const char* comma = strchr (names + 1, ',');
     cout.write (names, comma - names) << " : " << arg1 << " | "; __f (comma + 1, args...);
}

const int inf = 0x3f3f3f3f;
const int INF = 0x3f3f3f3f3f3f3f3f;

int n,m,k,q;
string s;
vi adj[N];
int a[N] , dp[N][N] , pre[N];

int sum(int l ,int r ) 
{
	return pre[r] - pre[l-1];
}

void go()
{
	cin >> n;

	fo(i,1,n+1) cin >> a[i] , pre[i] = pre[i-1] + a[i];

	fo(i,0,n+1) fo(j,0,n+1) dp[i][j] = INF;

	fo(i,0,n+1) dp[i][i] = 0;

	for( int gap = 1; gap <= n; gap++)
	{
		for( int i = 1; i + gap <= n; i++)
		{
			int j = i + gap;

			for( int k = i; k < j; k++)
			{
				int now = sum(i,k) + sum(k+1,j);
				dp[i][j] = min( dp[i][j] , dp[i][k] + dp[k+1][j] + now );
			}
		}
	}

	cout << dp[1][n] << endl;


}

int32_t main()
{
	FAST;     
	int t=1; 
	// cin>>t;
	test(t) go();
}



Measured memory_bytes: 1920
class Tree
    def initialize(*args)
        @val, @parent = args
        @depth = (parent ? parent.depth + 1 : 1)
        @children = []
        @parent.children << self if @parent
    end
    def eval
        return @val.to_i if @val =~ /\d/
        @children.map {|c| c.eval}.inject(@val.to_sym)
    end
    attr_reader :parent, :children, :depth
end

loop do
    n = gets.to_i
    break if n == 0
    root = v = nil
    n.times do
        gets =~ /(\.*)(.+)/
        depth, x = $1.size, $2
        v = v.parent until !v || depth == v.depth
        v = Tree.new(x, v)
        root ||= v
    end
    p root.eval
end

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
struct UnionFind {
	vector <int> par;

	UnionFind( int n ) : par( n, -1 ) {
	}
	int root( int x ) {
		if (par[ x ] < 0) return x;
		else return par[ x ] = root( par[ x ] );
	}
	bool issame( int x, int y ) {
		return root( x ) == root( y );
	}
	bool merge( int x, int y ) {
		x = root( x ); y = root( y );
		if (x == y) return false;
		if (par[ x ] > par[ y ]) swap( x, y );	// merge technique
		par[ x ] += par[ y ];
		par[ y ] = x;
		return true;
	}
	int size( int x ) {
		return -par[ root( x ) ];
	}
};
int main( void ){
	// initialize();
	int N, M, K;
	cin >> N >> M >> K;
	vector <set <int> > nonpre_friend( N );
	UnionFind uf( N );
	rep(i,0,M){
		int a, b; cin >> a >> b; --a, --b;
		nonpre_friend[ a ].insert( b );
		nonpre_friend[ b ].insert( a );
		uf.merge( a, b );
	}
	rep(i,0,K){
		int c, d; cin >> c >> d; --c, --d;
		if (!uf.issame( c, d )) continue;
		nonpre_friend[ c ].insert( d );
		nonpre_friend[ d ].insert( c );
	}

	rep(i,0,N){
		printf("%d ", uf.size(i)-nonpre_friend[i].size()-1);
	}
	cout << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
	cin.tie( 0 );
	ios::sync_with_stdio( false );
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long int ll ;

ll max(ll a , ll b)
{
  return (a > b) ? a: b;
}
ll min(ll a , ll b)
{
  return (a < b) ? a : b;
}
void memset(ll *arr , int n , ll value)
{
    for(int i= 0; i<n ; i++)
    {
        arr[i] = value;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int n;
    cin>>n;
    int k;
    cin>>k;
    int *arr = new int[n];
    for(int i=0; i<n; i++)
    {
        cin>>arr[i];
    }
    ll *dp = new ll[n];
    memset(dp , n ,1e9+5) ;
    for(int i= 0; i<k ; i++)
    {
        dp[i] = abs(arr[i] - arr[0]) ;
    }
    for(int i= k; i< n ; i++)
    {
        for(int j=i-1 ; j>=i-k ; j--)
        {
            dp[i] = min(dp[i] , dp[j] + abs(arr[i] - arr[j])) ;
        }
    }
    /*dp[0] = 0;
    for(int i=0 ;i<n ; ++i)
    {
        for(int j = i+1 ; j<=i+k ; ++j)
        {
            if(j < n )
            {
                dp[j] = min(dp[j] , dp[i] + abs(arr[i] - arr[j])) ;
            }
        }
    }*/
    cout<<dp[n-1] ;
    return 0;
}


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

int x;

int main(){
    cin >> x;
    int ans = 0;

    for(int i = 1; i < 10000; i++){
        for(int j = 2; j < 10000; j++){
            int tmp = pow(i, j);
            if(tmp > x) break;
            ans = max(ans, tmp);
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
	int h1, h2, k1, k2, a, b, c, d, hiroshi = 0, kenjiro = 0;
	cin >> h1 >> h2 >> k1 >> k2 >> a >> b >> c >> d;
	hiroshi = h1*a + h2*b + (h1 / 10)*c + (h2 / 20)*d;
	kenjiro = k1*a + k2*b + (k1 / 10)*c + (k2 / 20)*d;
	if (hiroshi == kenjiro) cout << "even" << endl;
	else if (hiroshi > kenjiro) cout << "hiroshi" << endl;
	else cout << "kenjiro" << endl;
	return 0;
}

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

inline void swap(int *a, int *b){ int t = *a; *a = *b; *b = t; }

int main()
{
  int a, b, c;
  cin >> a >> b >> c;
  int t;
  if (a > b) swap(&a, &b);
  if (b > c) swap(&b, &c);
  if (a > b) swap(&a, &b);
  cout << a << ' ' << b << ' ' << c << endl;
  return 0;
}

Measured memory_bytes: 1160
using System;
class Program
{
	static void Main(string[] args)
	{
		// get a integer
		var input =Console.ReadLine().Split(' ');
		var K= int.Parse(input[0]);
		var X = int.Parse(input[1]);
		if(K*500>=X||X==0){
			Console.Write("Yes");
		}else{
			Console.Write("No");
		}
	}
}

Measured memory_bytes: 11092
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <stdio.h>
#include <string.h>
using ll = long long;

//LLONG_MAX
#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define LOWER_BOUND(v,a) (lower_bound((v).begin(), (v).end(), (a)))
#define UPPER_BOUND(v,a) (upper_bound((v).begin(), (v).end(), (a)))
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
using namespace std;

int W, H, X, Y;

signed main()
{
	cin >> W >> H >> X >> Y;

	double m = W * H / 2.0;
	int n = (X == W / 2.0 && Y == H / 2.0) ? 1 : 0;

	cout << m << " " << n << endl;
}











Measured memory_bytes: 256
from collections import Counter
N=int(input())
S=[input() for i in range(N)]
a=[0]*4
for i in range(N):
    if S[i]=='AC':
        a[0]+=1
    elif S[i]=='WA':
        a[1]+=1
    elif S[i]=='TLE':
        a[2]+=1
    else:
        a[3]+=1
print('AC','x',a[0])
print('WA','x',a[1])
print('TLE','x',a[2])
print('RE','x',a[3])

Measured memory_bytes: 16608
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef pair<ll , ll> lli;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;
typedef vector<lli> vlli;
 
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define in insert
#define f0(b) for(int i=0;i<(b);i++)
#define f00(b) for(int j=0;j<(b);j++)
#define f1(b) for(int i=1;i<=(b);i++)
#define f11(b) for(int j=1;j<=(b);j++)
#define f2(a,b) for(int i=(a);i<=(b);i++)
#define f22(a,b) for(int j=(a);j<=(b);j++)
#define sf(a) scanf("%lld",&a)
#define sff(a,b) scanf("%lld %lld", &a , &b)
#define pf(a) printf("%lld\n",a)
#define pff(a,b) printf("%lld %lld\n", a , b)
#define PI 3.14159265359
#define bug printf("**!\n")
#define mem(a , b) memset(a, b ,sizeof(a))
#define front_zero(n) __builtin_clzll(n)
#define back_zero(n) __builtin_ctzll(n)
#define total_one(n) __builtin_popcountll(n)

const ll mod = (ll)1e9+7;
const ll maxn = (ll)2e5+5;
const int nnn = 1048590;
const int inf = numeric_limits<int>::max()-1;
//const ll INF = numeric_limits<ll>::max()-1;
const ll INF = 1e18;

ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll dxx[]={0,1,0,-1,1,1,-1,-1};
ll dyy[]={1,0,-1,0,1,-1,1,-1};

void solve(){
	
	ll n;
	vector < char > v;
	cin >> n;
	while(n){
		if(n%26 == 0) v.pb('z') , n = (n-1)/26;
		else v.pb(n%26+'a'-1) , n/=26;
	}
	reverse(v.begin(), v.end());
	for(auto u : v) cout << u;
	return;
}


int main() {
   
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    ll T;
    T=1;
    //cin >> T;
    //scanf("%lld",&T);
    ll CT = 0;
    //work();
    while(T--){
    	//cout << "Case " << ++CT <<": " ;
    	//printf("Case %lld: ",++CT);
		solve();
	}
    
    return 0;
}


Measured memory_bytes: 3672
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const S = arg[0].split(" ")[0];
    
    const first = S.slice(0, 2);
    const last  = S.slice(2, 4);

    // 両方1~12
    if(
        (parseInt(first) > 0 && 12 >= parseInt(first)) &&
        (parseInt(last) > 0  && 12 >= parseInt(last))
    ) {
        console.log("AMBIGUOUS");
        return;
    }
    
    // YYMMだけアリエル
    if(
        (parseInt(first) <= 0 || 12 < parseInt(first)) &&
        (parseInt(last) > 0  && 12 >= parseInt(last))
    ) {
        console.log("YYMM");
        return;
    }
    
    // MMYY
    if(
        (parseInt(first) > 0 && 12 >= parseInt(first)) &&
        (parseInt(last) <= 0 || 12 < parseInt(last))
    ) {
        console.log("MMYY");
        return;
    }

    console.log("NA");
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

i64 MOD = 1e9+7;
//Eucli
i64 inv_mod( i64 a, i64 m = MOD )
{
  i64 b, x, u, q, abs_m, tmp; 

  abs_m = ( m < 0 ) ? -m : m;
  b = m; x = 1; u = 0; 
  while ( b > 0 ) {
    q = a / b; 
    tmp = u; u = x - q * u; x = tmp;
    tmp = b; b = a - q * b; a = tmp;
  }

  return ( x < 0 ) ? abs_m + x : x;
}

i64 fact[100010];

i64 nCr(int n,int r)
{
    if(n < r) return 1;
    return (fact[n] * inv_mod(fact[r]) % MOD * inv_mod(fact[n - r]) % MOD) % MOD;
}

//重複組み合わせ
i64 nHr(int n,int r)
{
    return (nCr(n + r - 1,r)) % MOD;
}



int n;



i64 imos[300010];

vector<P> vec;

int main()
{
    fact[0] = 1;

    rep(i,1,100009)
    {
        fact[i] = (fact[i - 1] * i) % MOD;
    }


    cin >> n;

    rep(i,0,n - 1)
    {
        int a;
        cin >> a;
        vec.push_back({a,0});
    }

    rep(i,0,n - 1)
    {
        int a;
        cin >> a;
        vec.push_back({a,1});
    }

    sort(vec.begin(),vec.end());
    vector<int> thing[2];
    int cou = 1;
    for(auto& p : vec)
    {
       thing[p.second].push_back(cou); 
       cou++;
    }

    rep(i,0,n - 1)
    {
        int l,r;
        l = min(thing[0][i] , thing[1][i]);
        r = max(thing[0][i] , thing[1][i]);

        imos[l]++;
        imos[r]--;
    }

    i64 result = 1;

    i64 MAX = 0;
    i64 temp = 1;

    rep(i,1,2 * n + 1)
    {
        imos[i] += imos[i - 1];

        temp = (temp * nCr(imos[i - 1],imos[i])) % MOD;

        /*

        MAX = max(MAX , imos[i]);

        if(imos[i] == 0)
        {
            temp = (temp * inv_mod(fact[MAX])) % MOD;
            MAX = 0;
            result = (temp * result) % MOD;
            temp = 1;
        }
        */
    }
    cout << temp << endl;

}

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

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

    if (s.size() <= k) {
        cout << s << endl;
    } else {
        cout << s.substr(0,k) << "..." << endl;
    }

    return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
int main(){
    string s;cin>>s;
    int ans=1;
    string now=s.substr(0,1);
    string r="";
    vector<string> v;
    v.push_back(now);
    rep(i,1,s.size()){
        r+=s.substr(i,1);
        if(now!=r){
            ans++;
            now=r;
            v.push_back(now);
            r="";
            
        }
    }
    
    
    cout<<ans<<endl;
}


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

class P
{
	public:
	int x,y;
	P(int X,int Y)
	{
		x=X;
		y=Y;
	}
};

int main()
{
	int w,h;
	while(cin>>w>>h)
	{
		if(w==0 && h==0)break;
		int ans=0;
		int field[52][52]={0};
		int flg[52][52]={0};

		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				cin>>field[i][j];		
			}
		}

		for(int i=1;i<=h;i++)
		{
			for(int j=1;j<=w;j++)
			{
				if(field[i][j]==0 || flg[i][j]==1)continue;
				ans++;
				stack<P> ST;
				ST.push(P(j,i));
				while(!ST.empty())
				{
					int x=ST.top().x;
					int y=ST.top().y;
					ST.pop();
					flg[y][x]=1;
					for(int y2=-1;y2<=1;y2++)
					{
						for(int x2=-1;x2<=1;x2++)
						{
							if(field[y+y2][x+x2]==0 || flg[y+y2][x+x2]==1)continue;
							ST.push(P(x+x2,y+y2));
							flg[y+y2][x+x2]=1;
						}
					}
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

typedef long long ll;

const int mod = (int) 1e9 + 7;
const int maxn = 22;
int dp[1 << 22];
int mp[maxn][maxn];
int n;

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

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            cin >> mp[i][j];
        }
    }

    dp[0] = 1;
    for (int mask = 1; mask < (1 << n); ++mask) {
        int cnt = __builtin_popcount(mask) - 1;
        for (int i = 0; i < n; ++i) {
            if ((mask & (1 << i)) && mp[cnt][i])
                dp[mask] = (dp[mask] + dp[mask ^ (1 << i)]) % mod;
        }
    }

    cout << dp[(1 << n) - 1] << endl;

    return 0;
}



Measured memory_bytes: 10496
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a,x=0,y=0;
    for(int i=0;i<n;i++){
        cin>>a;
        if(a&1) x++;
        if(!(a&3)) y++;
    }

    if(x+y==n && y+1>=x ) cout<<"Yes"<<endl;
    else if(y>=x) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
return 0;
}


Measured memory_bytes: 256
X, Y = map(int, input().split())

num_kame = (Y - 2*X)/2
num_tsuru = (4*X - Y)/2

if (num_kame >= 0) and (num_tsuru >= 0) and (num_kame.is_integer()) and (num_tsuru.is_integer()) and (X == num_kame+num_tsuru):
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9176
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;

using ll = long long;
using boost::irange;

int main(){
    int N;

    cin >> N;

    vector<int> A(N), B(N), C(N);

    int tmp;
    for (int i : irange(0,N)){
        cin >> tmp;
        A[i] = tmp - 1;
    }
    for (int i : irange(0,N)){
        cin >> B[i];
    }
    for (int i : irange(0,N)){
        cin >> C[i];
    }

    int prev = -10;
    int ans = 0;
    int n;
    for (int i : irange(0, N)){
        n = A[i];
        ans += B[n];
        if (prev == n - 1){
            ans += C[n-1];
        }
        prev = n;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256