akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors


def main():
    N = int(input())
    V = make_divisors(N)
    if len(V) %2 == 1:
        # print(V)
        print(V[-1]*2-2)
        exit()
    # print(V,V[-2:])
    print(sum(V[-2:])-2)
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 3268
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;
  printf("%c%c%c\n",toupper(s1[0]),toupper(s2[0]),toupper(s3[0]));
}

  
  
  
  
  
  
  
  
  

  



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

int main(){
    //input
    long long n;
    cin >> n;
    vector<long long> S;
    long long sub;
    long long i;
    for(i = 0; i < n; i++){
        cin >> sub;
        S.push_back(sub);
    }
    long long q;
    cin >> q;
    vector<long long> T;
    for(i = 0; i < q; i++){
        cin >> sub;
        T.push_back(sub);
    }

    //calc
    long long counta = 0;
    vector<long long>::iterator pS, pT;
    for(pT = T.begin(); pT != T.end(); ++pT){
        pS = lower_bound(S.begin(), S.end(), *pT);
        if(*pS == *pT){
            counta++;
        }
    }

    //answer
    cout << counta << endl;
    return 0;
}


Measured memory_bytes: 4652
#include <cstdio>

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

    int ans;

    if(A < B){
        ans = A;
    }else{
        ans = B;
    }

    if(C < D){
        ans += C;
    }else{
        ans += D;
    }

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

    return 0;
}


Measured memory_bytes: 128
#include <iostream>

using namespace std;

bool dislikes(int N, bool D[])
{
    while (N)
    {
        if (D[N % 10])
            return true;

        N /= 10;
    }

    return false;
}

int main()
{
    int N, K, X;

    bool D[11];

    cin >> N >> K;

    for (int i = 0; i < 10; i++)
        D[i] = false;

    for (int i = 0; i < K; i++)
    {
        cin >> X;
        D[X] = true;
    }

    while (dislikes(N, D))
        N++;

    cout << N << endl;

    return 0;
}

Measured memory_bytes: 256
// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools

#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_dec_float.hpp>

using namespace std;

using i64 = long long;

const i64 MOD = 1e9 + 7;
const i64 INF = i64(1e18) + 7;

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

template <typename T>
bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

template <typename T>
bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}


void solve(long long a, long long b, long long c){
    boost::multiprecision::cpp_dec_float_100 aa = a;
    boost::multiprecision::cpp_dec_float_100 bb = b;
    boost::multiprecision::cpp_dec_float_100  cc= c;
    cout << (boost::multiprecision::sqrt(aa) + boost::multiprecision::sqrt(bb) < boost::multiprecision::sqrt(cc) ? "Yes" : "No") << endl;
}


signed 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: 384
// D - Dice in Line
#include <bits/stdc++.h>
using namespace std;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
int in(){int x;scanf("%d",&x);return x;}
int N,K;
vector<int> S(1);//累積和

int main(){
	cin>>N>>K;
	rp(i,0,N) S.push_back(S[i] + in()+1);
	int ans = 0;
	rp(i,0,N-K+1) ans = max(ans, S[i+K]-S[i]);
	printf("%.12f\n",ans/2.0);
}

Measured memory_bytes: 1400
#include <cstdio>
#include <iostream>

using namespace std;

int ans,n,a,b[9];

inline void check(int x) {
		 if(x >= 1 && x <= 399) b[1] = 1;
	else if(x >= 400 && x <= 799) b[2] = 1;
	else if(x >= 800 && x <= 1199) b[3] = 1;
	else if(x >= 1200 && x <= 1599) b[4] = 1;
	else if(x >= 1600 && x <= 1999) b[5] = 1;
	else if(x >= 2000 && x <= 2399) b[6] = 1;
	else if(x >= 2400 && x <= 2799) b[7] = 1;
	else if(x >= 2800 && x <= 3199) b[8] = 1;
	else if(x >= 3200 && x <= 4800) b[0]++;
}

int main() {
    cin >> n;
    for(int i = 1; i <= n; i++) {
    	cin >> a;
    	check(a);
    }
    for(int i = 1; i <= 8; i++) if(b[i]) ans++;
    if(!ans) cout << "1" << " " << ans+b[0];
    else cout << ans << " " << ans+b[0];
    return 0;
}


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

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(v) (v).begin(), (v).end()
#define sz(x) ( (int) (x).size() )
#define mset(x, v) memset((x), (v), sizeof (x) )

using namespace std;


vector<long long> v;

int main()
{

	int n,k;

	cin >> n >> k;

	for (int i = 0; i < n; ++i)
	{
		long long a;
		cin>>a;
		v.pb(a);
	}

	sort( all(v) );


	long long b = v[sz(v) - 1] + 1;
	long long a = 0;

	long long resp = -1;

	while( b-a > 1)
	{
		resp = (b+a)/2;

		int sum = 0;
		for(int i = 0 ; i<n; i++)
		{
			sum += (v[i]-1)/resp;
		}

		if(sum > k)
		{
			a = resp;
		}
		else
		{
			b = resp;
		}
	}

	if(a==resp)
		resp++;

	cout<<resp<<endl;

	return 0;
}


Measured memory_bytes: 5252
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
int main()
{
    int K, N;
    cin >> N >> K;
    vector<double> P(N);
    REP(i, N) cin >> P[i];
    REP(i, N) {
        P[i] = (1.0 + P[i]) / 2.0;
    }
    double sum = 0;
    double max = 0;
    int num = 0;
    REP(i, N) {
        sum += P[i];
        num++;
        if(num == K) {
            if(sum > max) max = sum;
            sum -= P[i-(K-1)];
            num--;
        }
    }
    cout << std::setprecision(10) << max << endl;
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,k;
    cin>>n>>k;
    vector<int> v(n);
        rep(i,n) cin>>v.at(i);
    int ans=0;

    vector<int> xx(n);
    xx[0]=v[0];
    rep(i,n-1) xx[i+1]=xx[i]+v[i+1];
    vector<int> yy(n);
    yy[0]=v[n-1];
    rep(i,n-1) yy[i+1]=yy[i]+v[n-i-2];

    vector<vector<int>> minx(n+1,vector<int>(0));
    if(v[0]<0) minx[1].emplace_back(v[0]);
    rep(i,n-1){
        minx[i+2]=minx[i+1];
        if(v[i+1]<0)minx[i+2].emplace_back(v[i+1]);
    }
    rep(i,n) sort(all(minx[i]));
    vector<vector<int>> miny(n+1,vector<int>(0));
    if(v[n-1]<0) miny[1].emplace_back(v[n-1]);
    rep(i,n-1){
        miny[i+2]=miny[i+1];
        if(v[n-i-2]<0) miny[i+2].emplace_back(v[n-i-2]);
    }
    rep(i,n) sort(all(miny[i]));

    for(int x=0;x<=n;x++){
        for(int y=0;y<=n-x;y++){
            if(x+y>k) break;
            int sum=0;
                if(x>0) sum=xx[x-1];
                if(y>0) sum +=yy[y-1];
            int z=k-x-y;
            int i=0,j=0;
                if(minx[x].empty()) i=-1;
                if(miny[y].empty()) j=-1;
            rep(mkoij,z){
                if(i<0 && j<0) break;
                else if(i<0){
                    sum -=miny[y][j];
                    j ++;
                    if(j>=miny[y].size()) j=-1;
                }
                else if(j<0){
                    sum -=minx[x][i];
                    i ++;
                    if(i>=minx[x].size()) i=-1;
                }
                else if(minx[x][i]<miny[y][j]){
                    sum -=minx[x][i];
                    i ++;
                    if(i>=minx[x].size()) i =-1;
                }
                else{
                    sum -=miny[y][j];
                    j ++;
                    if(j>=miny[y].size()) j=-1;
                }
            }
            ans=max(ans,sum);
            if(sum==3) cout<<x<<" "<<y<<endl;
        }
    }
    cout<<ans<<endl;
}
//./problem.exe

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

const int mod=1000000007;
inline void add(int &a,int b){
    a+=b;
    if(a>=mod)a-=mod;
}

const int INF=1001001001001001001ll;

int H,W;
int A[222][222];

int dp[222][222][222];
signed main(){
    cin>>H>>W;
    rep(i,H){
        rep(j,W)cin>>A[i][j+1],A[i][j+1]+=A[i][j];
    }
    fill_n(**dp,222*222*222,-INF);
    dp[0][0][0]=0;

    for(int i=0;i<H;i++){
        int max1=-INF;
        int max2[222]={};fill_n(max2,222,-INF);
        for(int j=0;j<W;j++){
            for(int k=0;k<=j;k++)chmax(max1,dp[i][k][j]-A[i][k]);
            for(int k=j+1;k<W;k++)chmax(max2[k],dp[i][j][k]-A[i][j]-A[i][k]);
            int max3=-INF;
            for(int k=j;k<W;k++){
                if(k!=j)chmax(max3,max2[k]);
                chmax(dp[i+1][j][k],max1+A[i][k+1]);
                chmax(dp[i+1][j][k],max3+A[i][k+1]+A[i][j+1]);
            }
        }
    }
    cout<<dp[H][W-1][W-1]<<endl;
    return 0;
}


Measured memory_bytes: 86016
/*----------------by syr----------------*/
/*
  -----  -----  -----
  |   |  |---|    _/
  |   |  | \_    /
  -----  |   \  -----

  |---\  \   /  |\  /|
  |   |   \_/   | \/ |
  |   |   / \   |    |
  |---/  /   \  |    |
*/
#include<bits/stdc++.h>

using namespace std;

#define PH push
#define MP make_pair
#define PB push_back
#define fst first
#define snd second
#define FOR(i,x,y) for(int i=(x);i<(y);++i)
#define REP(i,x,y) for(int i=(x);i<=(y);++i)
#define x0 x0123456789
#define y0 y0123456789
#define x1 x1234567890
#define y1 y1234567890
#define x2 x2345678901
#define y2 y2345678901
typedef double db;
typedef long long ll;
typedef long double ldb;
typedef pair<int,int> pii;

const int INF=1e9+7;
const int maxn=2e5+5;

struct Edge{
	ll w;
	int u;
	int v;
	Edge(ll w,int u,int v):w(w),u(u),v(v){}
	inline bool operator <(const Edge &b)const{return w<b.w;}
};

class Dsu{
private:
	int sz;
	int fa[maxn];
public:
	inline void init(int n){
		sz=n;
		FOR(i,0,sz) fa[i]=i;
		return;
	}
	inline int find(int x){return (x==fa[x])?(x):(fa[x]=find(fa[x]));}
	inline void combine(int x,int y){
		x=find(x);y=find(y);
		fa[x]=y;
		return;
	}
}dsu;

int n;
int a[maxn];
ll d,ans;
vector<Edge> vec;

inline void solve(int l,int r){
	if(l==r) return;
	int md=(l+r)>>1;
	solve(l,md);
	solve(md+1,r);
	int va=r,vs=l;
	REP(i,l+1,md) if(a[i]-d*i<=a[vs]-d*vs) vs=i;
	FOR(i,md+1,r) if(a[i]+d*i<=a[va]+d*va) va=i;
	REP(i,l,md)	vec.PB(Edge((va-i)*d+a[va]+a[i],va,i));
	REP(i,md+1,r) vec.PB(Edge((i-vs)*d+a[vs]+a[i],vs,i));
	return;
}

int main(){
	scanf("%d%lld",&n,&d);
	FOR(i,0,n) scanf("%d",a+i);
	solve(0,n-1);
	sort(vec.begin(),vec.end());
	dsu.init(n);
	FOR(i,0,vec.size()){
		int u=vec[i].u,v=vec[i].v;
		if(dsu.find(u)==dsu.find(v)) continue;
		//printf("u=%d v=%d\n",u,v);
		ans+=vec[i].w;
		dsu.combine(u,v);
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 68704
#include<stdio.h>
int main(void)
{
	int x[10000],i=0,n;

	while(1){
	scanf("%d",&x[i]);
	if(x[i]==0)
		break;
	i++;
	}
	for(n=1;n<=i;n++)
	printf("Case %d: %d\n",n,x[n-1]);
	
}

Measured memory_bytes: 1772
# 解けなかった
# SA = str(input())
# SB = str(input())
# SC = str(input())

# value_dict = {
#     'a' : SA,
#     'b' : SB,
#     'c' : SC
# }
# print(value_dict.values())
# ans = ''

# def solve(user, list_dict):
#     for j in ['a', 'b', 'c']:
#         if len(list_dict[j])-1 <= 0 and user == j:
#             return 0
#     list_dict[user] = list_dict[user][1:]
#     next_user = list_dict[user][0]
#     ans = user
#     solve(next_user, list_dict)

a, b, c = input(), input(), input()
req = a
a = a[1:]
ans = ""

while 1:
    if req[:1] == 'a':
        ans = "A"
        req = a
        a = a[1:]
    elif req[:1] == 'b':
        ans = "B"
        req = b
        b = b[1:]
    else:
        ans = "C"
        req = c
        c = c[1:]

    if not req:
        break

print(ans)


Measured memory_bytes: 3060
#include <stdio.h>

const int mod = 1e9 + 7;

int qpow(int a, int x) {
    int ans = 1;
    while (x) {
        if (x & 1) ans = 1ll * ans * a % mod;
        a = 1ll * a * a % mod;
        x >>= 1;
    }
    return ans;
}

int digit(int n) {
    int ans = 0;
    while (n) {
        ans += 1;
        n /= 10;
    }
    return ans;
}

int main() {
    int s;
    scanf("%d", &s);
    int ans = 0;

    for (int d = 8; d <= s; ++d) {
        if (s % d == 0) {
            ans += (qpow(10, d) - qpow(10, d - 1) - s / d + 1) % mod;
            ans %= mod;
        }
    }

    for (int t = 1; t <= s / 8; ++t) {
        if (s % t != 0) {
            ++ans;
            ans += mod;
            ans %= mod;
        }
    }

    long long r = 1;
    int f = 0;
    for (int l = 1; l < 1e7; ++l) {
        while (f < s) {
            f += digit(r);
            r++;
        }
        if (f == s) {
            ++ans;
            ans %= mod;
        }
        f -= digit(l);
    }

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

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
plus, minus = 0, 0
ans = 1
for i in range(n-1):
    if a[i]<a[i+1]: plus = 1
    elif a[i]>a[i+1]: minus = 1
    if plus==minus==1:
        plus, minus = 0, 0
        ans += 1
print(ans)


Measured memory_bytes: 14228
#include<stdio.h>
#include<math.h>
int main(void)
{
	double q, x, eq;
	while(scanf("%lf",&q),q>0)
	{
		x = q/2;
		eq = q*0.00001;
		while(fabs(x*x*x-q) >= eq)
			x -= (x*x*x-q)/(3*x*x);
		printf("%f\n", x);
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<algorithm>
#include<vector>

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

using namespace std;

const int INF = 0;

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

	vector<int> S(13, INF), H(13, INF), C(13, INF), D(13, INF);

	rep(i, N) {
		char c;
		int n;
		cin >> c >> n;

		--n;
		if (c == 'S') {
			S[n] = 1;
		}
		else if (c == 'H') {
			H[n] = 1;
		}
		else if (c == 'C') {
			C[n] = 1;
		}
		else {
			D[n] = 1;
		}
	}

	rep(i, 13) {
		if (S[i] == INF) {
			cout << "S " << i + 1 << endl;
		}
	}
	rep(i, 13) {
		if (H[i] == INF) {
			cout << "H " << i + 1 << endl;
		}
	}
	rep(i, 13) {
		if (C[i] == INF) {
			cout << "C " << i + 1 << endl;
		}
	}
	rep(i, 13) {
		if (D[i] == INF) {
			cout << "D " << i + 1 << endl;
		}
	}


	return 0;
}



Measured memory_bytes: 3096
//B
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e3+10;
ll raw[maxn];
int main(){
	ll n,m,s = 0;
	cin >> n >> m;
	for(int i = 1;i <= n;i++){
		cin >> raw[i];
		s += raw[i];
	}
	int cnt = 0;
	for(int i = 1;i <= n;i++)if(raw[i]*4*m >= s)cnt++;
	if(cnt >= m)cout << "Yes";
	else cout << "No";
	return 0;
}


Measured memory_bytes: 256
/*
I've been down this road once or twice before
through the open door
i come falling through it
there's a sign post up ahead
like a watershed
and it opens my eyes
ways, for me to begin
to be born again
and knowing for the first time
ways, all so differently
shine for me to see
the better man that I am

I've been places in my head
behind me worse than what's ahead
and on my path just like a dream
takes me from the inbetween
from out of nowhere you came strong as stone
and now I'll never have to be alone
what it is I know

you have always been my safe home
I walk, I run, I burn out into you
you have always been my safe home
my whole world has moved on

i know what i am and I'll always be
your reality, is better than I could dream
all my fears turn from black to white
and i'd stand and fight
the whole world for you
faith, and destiny
I never did believe
my only god is love and
faith, what I see in you
and I can hold it true
like a weight in my hand.
*/

#pragma GCC optimize("O3")
#define _CRT_SECURE_NO_WARNINGS
#include <fstream>
#include <iostream>
#include <string>
#include <complex>
#include <math.h>
#include <set>
#include <vector>
#include <map>
#include <queue>
#include <stdio.h>
#include <stack>
#include <algorithm>
#include <list>
#include <ctime>

#include <memory.h>
#include <assert.h>

#define y0 sdkfaslhagaklsldk

#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define norm asdfasdgasdgsd
#define have adsgagshdshfhds
#define ends asdgahhfdsfshdshfd

#define eps 1e-8
#define M_PI 3.141592653589793
#define bsize 512

#define ldouble long double
using namespace std;

#define bs 1000000007

const int N = 600031;

int n;
long long ans,mx,ar[N];

int main(){
//	freopen("apache.in","r",stdin);
//	freopen("apache.out","w",stdout);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(0);
//	cin.tie(0);

	cin>>n;
	for (int i=1;i<=n;i++){
		cin>>ar[i];
	}

	mx=-n;
	long long mn=-n;

	int flag=0;

	for (int i=n;i>=1;--i){
		if (i<n&&ar[i]<(ar[i+1])-1)
		{
			cout<<-1<<endl;
			return 0;
		}
		mn=min(mn,ar[i]-i);
		if (ar[i]-i>mx){
			ans+=ar[i];
			mx=ar[i]-i;
		}
	}

	if (mx>=0){
		cout<<-1<<endl;
	}
	else
		cout<<ans<<endl;

//	cin.get(); cin.get();
	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a[10000],b,i=0,j,c=0,s=100000;
    cin >> n;
    for(i=0;i<n;i++)
    {
        cin >> a[i];
        if(c<a[i])
        {
            c=a[i];
        }
        if(s>a[i])
        {
            s=a[i];
        }
        
    }
   
    cout << c-s << endl;
    return 0;

}


Measured memory_bytes: 3632
#include<stdio.h>
#pragma GCC optimize ("O2")
#define rep(i,N) for(int i=0;i<(int)N;i++)
const int MOD=998244353;
int Pow(int x,int y){int z=1;x%=MOD;while(y){if(y&1){z=(1ll*z*x)%MOD;}x=(1ll*x*x)%MOD;y>>=1;}return z;}
int main(void)
{
  int A,B,C,D,ans=0,sum,dp[3000]={0};
  if(!scanf("%d %d %d %d",&A,&B,&C,&D))return 0;
  if(A==C){return printf("%d\n",Pow(A,D-B)),0;}
  else if(B==D){return printf("%d\n",Pow(B,C-A)),0;}
  dp[A-1]=1;
  rep(i,D-B)
  {
    sum=0;
    rep(j,C)
    {
      sum=(1ll*sum*(B+i)%MOD+dp[j])%MOD;
      dp[j]=(1ll*j*dp[j]+sum)%MOD;
    }
  }
  rep(i,C){ans=(ans+1ll*dp[i]*Pow(D,C-i-1))%MOD;}
  return printf("%d\n",ans),0;
}

Measured memory_bytes: 1724
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int main(void){
    using P = pair<int, long long>;
    int n;
    cin >> n;
    vector<int> h(n+1, 0), a(n+1, 0);
    for(int i=1;i<=n;i++) cin >> h[i];
    for(int i=1;i<=n;i++) cin >> a[i];
    long long ans = 0;
    set<P> s;
    s.insert(P(0, 0));
    for(int i=1;i<=n;i++){
        auto itr = s.upper_bound(P(h[i], 0));
        --itr;
        P tmp = P(h[i], itr->second + a[i]);
        while(1){
            itr = s.upper_bound(P(h[i], 0));
            if(itr != s.end() && itr->second < tmp.second){
                // cout << "erase : h=" << (itr->first) << " a=" << (itr->second) << endl;
                s.erase(itr);
            }else{
                break;
            }
        }
        s.insert(tmp);
        ans = max(ans, tmp.second);
        // cout << "insert: h=" << (tmp.first) << " a=" << (tmp.second) << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 14336
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
from math import gcd
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]

dic=defaultdict(int)
zero=[0,0]
kasu=0
for i in range(n):
    a,b=ab[i]
    if a==0 and b==0:
        kasu+=1
    elif a==0:
        zero[0]+=1
    elif b==0:
        zero[1]+=1
    else:
        if a<0:
            a,b=-a,-b
        g=gcd(a,b)
        dic[(a//g,b//g)]+=1
# print(dic)
anslst=[]
lst=list(dic.items())
ans=1

for i in range(len(lst)):
    iwa,m=lst[i]
    a,b=iwa
    tmp=1
    ll=max(dic[(b,-a)],dic[(-b,a)])
    tmp=pow(2,dic[iwa],mod)-1+pow(2,ll,mod)-1+1
    # print(tmp)
    dic[(a,b)]=0
    dic[(b,-a)]=0
    dic[(-b,a)]=0
    ans*=tmp
    ans%=mod
    # print(dic)

# print(ans)
# print(zero)
ans*=pow(2,zero[0],mod)-1+pow(2,zero[1],mod)-1+1

ans=(ans-1+kasu)%mod
print(ans)

Measured memory_bytes: 205244
# coding: utf-8

import itertools

def array2d(dim1, dim2, init=None):
    return [[init for _ in range(dim2)] for _ in range(dim1)]

II = lambda: int(input())
MI = lambda: map(int, input().split())
MIL = lambda: list(MI())
MIS = lambda: input().split()


def main():
    N, M = MI()
    nb = array2d(N, N, False)
    for i in range(M):
        a, b = MI()
        a -= 1
        b -= 1
        nb[a][b] = nb[b][a] = True
    cnt = 0
    for perm in itertools.permutations(range(1, N)):
        p = [0] + list(perm)
        cnt += all([nb[p[i-1]][p[i]] for i in range(1, N)])
    return cnt

if __name__ == "__main__":
    print(main())


Measured memory_bytes: 3064
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD;
        x = (x * x) % MOD;
        n >>= 1;
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int solve(int M, int N) {
    vector<bool> flag(10000000);
    for (int i = M; i < 10000000 && N; i++) {
        if (!flag[i]) {
            for (int j = i; j < 10000000; j += i) {
                flag[j] = true;
            }
            N--;
        }
    }
    
    for (int i = M; i < 10000000; i++) {
        if (!flag[i]) {
            return i;
        }
    }
}


int main(void) {
    int M, N;
    vector<int> ans;
    while (1) {
        cin >> M >> N;
        if (!M & !N) break;
        ans.push_back(solve(M, N));
    }
    for (auto &i : ans) {
        cout << i << endl;
    }
}   





Measured memory_bytes: 4328
#include "bits/stdc++.h"
using namespace std;
using ll=long long;
#define print(n) cout<<n<<endl
int M=100111;
int mod=1000000007;
int main(){string l;cin>>l;ll top=1,below=0;int n=l.size();for(int i=0;i<n;i++){if(l[i]=='1'){below=(3*below+top)%mod;top=2*top%mod;}else	below=3*below%mod;}cout<<(top+below)%mod<<endl;;}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
typedef struct _data {
	int x;
	int y;
} data;

int  main()
{
	long N,a,b;
	cin >> N >> a >> b;
	long div,mod;
	long ans = 0;
	div = N / (a+b);
	ans += div * a;
	mod = N % (a+b);
	if (a <= mod)
		ans += a;
	else
		ans += mod;
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 256
#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>
using namespace std;
int main() {
	int a, b;
	cin >> a >> b;
	if (0 >= a && 0 <= b) {
		cout << "Zero" << endl;
	}
	else if (0 > a && 0 > b) {
		if ((abs(a) + abs(b)) % 2 == 0) {
			cout << "Negative" << endl;
		}
		else {
			cout << "Positive" << endl;
		}
	}
	else {
		cout << "Positive" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = list(input())
p = list(input())

def search_from(i):
    found = True
    for j in range(len(p)):
        k = (i + j) % len(s)
        if s[k] != p[j]:
            found = False
            break
    return found

found = False
for i in range(len(s)):
    found = search_from(i)
    if found:
        break
    
if found:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5564
b = list(map(int, input().split()))

x = (4*b[0] - b[1])/2
y = (b[1] - 2*b[0])/2
if x >= 0 and y >= 0 and (x - int(x)) == 0 and (y - int(y)) == 0:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9128
#123
s = input()
temp = 0
ans = 0
for i in range(len(s)):
    if(s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T'):
        temp += 1
        if(temp>ans):
            ans = temp
    else:
        temp = 0
print(ans)

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

int main() {
  int N,A,B;
  cin >> N >> A;
  
  B = N-(N/500*500);
  
  if (A >= B) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
using namespace std;

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

	cout << 48 - M << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<deque>
using namespace std;

int main() {

    int w, n;
    cin >> w >> n;

    vector<int> member(w);
    for (int m = 0; m < w; m++) {
        member[m] = m;
    }

    for (int t = 0; t < n; t++) {
        int a, b;
        char sep;
        cin >> a >> sep >> b;

        int tmp = member[b-1];
        member[b-1] = member[a-1];
        member[a-1] = tmp;
    }

    for (int m = 0; m < w; m++) {
        cout << member[m]  + 1 << endl;
    }
     
    return 0;
}

Measured memory_bytes: 0
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int ansMax = 999;
		for (int i = 0; i < N; i++) {
			int A = sc.nextInt();
			int cnt = 0;
			while (A % 2 == 0) {
				cnt++;
				A /= 2;
			}
			ansMax = Math.min(ansMax, cnt);
		}
		System.out.println(ansMax);
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <string>

using namespace std;

int main()
{
    string buff;
    cin >> buff;

    const char* cbuff = buff.c_str();
    string::size_type len = buff.size();

    string out;
    if (cbuff[len - 1] == 's')
    {
        out = buff + "es";
    }
    else
    {
        out = buff + "s";
    }

    cout << out << endl;

    return 0;
}


Measured memory_bytes: 3604
#include<stdio.h>
#include<math.h>
 
int main(void)
{
 double x,y,r;
 double x1,x2,x3,y1,y2,y3;
 double ecm[3][2]; //enlarged coefficient matrix:ツ拡ツ妥・ツ係ツ青板行ツ療ア
 double a,b,A;
 int i;
 int n;
 
 scanf("%d",&n);
 for(i = 0; i < n; i++)
 {
  scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
  ecm[0][0] = x1 - x2;
  ecm[0][1] = y1 - y2;
  ecm[0][2] = (x2*x2 + y2*y2) - (x1*x1 + y1*y1);
  ecm[1][0] = x1 - x3;
  ecm[1][1] = y1 - y3;
  ecm[1][2] = (x3*x3 + y3*y3) - (x1*x1 + y1*y1);
  A = (ecm[0][0]*ecm[1][1])-(ecm[0][1]*ecm[1][0]); 
  a = ((ecm[0][2]*ecm[1][1])-(ecm[0][1]*ecm[1][2]))/A+0;
  b = ((ecm[0][0]*ecm[1][2])-(ecm[0][2]*ecm[1][0]))/A+0;
  x = (a/-2.0);
  y = (b/-2.0);
  //c = -1 * (SQ(x1) + SQ(y1) + a * x1 + b * y1);
  r = sqrt(pow(x1-x,2)+pow(y1-y,2));
  printf("%.3f %.3f %.3f\n",x,y,r); 
 }
 return 0;
}
 

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using BitArray = System.Collections.BitArray;
using BigInteger = System.Numerics.BigInteger;

namespace AtCoderProject
{
    public class Program
    {
        public object Calc()
        {
            consoleReader.ReadLine();
            var As = consoleReader.ReadLineSplitInt32();

            bool evenMinus;
            int min = (evenMinus = (As[0] >= 0)) ? As[0] : -As[0];

            var res = new BigInteger();

            for (int i = 1; i < As.Length; i++)
            {
                int a = As[i];
                if(a < 0)
                {
                    evenMinus = !evenMinus;
                    a = -a;
                }


                if (a < min)
                {
                    res += min;
                    min = a;
                }
                else
                {
                    res += a;
                }
            }

            if (evenMinus)
            {
                res += min;
            } else
            {
                res -= min;
            }

            return res;
        }

        private readonly ConsoleReader consoleReader;
        public Program() : this(new ConsoleReader()) { }
        public Program(ConsoleReader consoleReader)
        {
            this.consoleReader = consoleReader;
        }
        static void Main() => Console.WriteLine(new Program().Calc());
    }

    public class ConsoleReader
    {
        public virtual string ReadLine() => Console.ReadLine();
        public int ReadLineInt32() => int.Parse(ReadLine());
        public long ReadLineInt64() => long.Parse(ReadLine());
        public ulong ReadLineUInt64() => ulong.Parse(ReadLine());
        public double ReadLineDouble() => double.Parse(ReadLine());
        public string[] ReadLineSplit() => ReadLine().Split().ToArray();
        public int[] ReadLineSplitInt32() => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public long[] ReadLineSplitInt64() => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public ulong[] ReadLineSplitUInt64() => ReadLine().Split().Select(s => ulong.Parse(s)).ToArray();
        public double[] ReadLineSplitDouble() => ReadLine().Split().Select(s => double.Parse(s)).ToArray();

        public IEnumerable<string> RepeatReadLines(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLine();
        }
        public IEnumerable<int> RepeatReadLinesInt32(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineInt32();
        }
        public IEnumerable<string[]> RepeatReadLinesSplit(int count)
        {
            for (int i = 0; i < count; i++)
                yield return ReadLineSplit();
        }
    }
    static class DicExt
    {
        public static double GetOrDefault(this Dictionary<int, double> dic, int key)
        {
            double val;
            return dic.TryGetValue(key, out val) ? val : 1;
        }
    }
}


Measured memory_bytes: 31448
// AOJ Vol-3 0312: Net Cafe
// 2017.9.30

#include <stdio.h>

#define MAX 200005
#define N 16

int m;
int w[MAX], t[MAX];;
int sw[MAX], st[MAX];
int c[N], b[N];
int dp[N][32770];		// 32768 = 2^15

int bsch(int *a, int l, int r, int x)
{
	int m;

    while (l < r) {
        m = (l + r) >> 1;
		if (a[m] == x) return m;
        if (a[m] < x) l = m + 1; else r = m;
    }
	return l-1;
}

int main()
{
	int n, i, j, k, x, y, lim, ans;

	scanf("%d%d", &m, &n); m++;
	for (sw[0] = st[0] = 0, i = 1; i < m; i++) {
		scanf("%d%d", w+i, t+i);
		sw[i] = sw[i-1] + w[i], st[i] = st[i-1] + t[i];
	}
	for (i = 0; i < n; i++) scanf("%d%d", c+i, b+i);

//	memset(dp, 0, sizeof(dp));
	for (i = 0; i < n; i++)	{
		x = bsch(sw, 1, m, c[i]);
		y = bsch(st, 1, m, b[i]);
		if (x > y) x = y;
		if (x == m-1) { ans = m-1; goto Done; }
		dp[0][1<<i] = x;
	}

	lim = 1 << n;
	for (k = 1; k < lim; k++) {
		for (i = 0; i < n; i++)	{			// this book shelf
			for (j = 0; j < n; j++) {		// last book shelf
				if (dp[j][k] && !(k & (1<<i))) {
					int ii = k | (1 << i);
					int t = dp[j][k];
					x = bsch(sw, t, m, sw[t] + c[i]);
					y = bsch(st, t, m, st[t] + b[i]);
					if (x > y) x = y;
					if (x == m-1) { ans = m-1; goto Done; }
					if (x > dp[i][ii]) dp[i][ii] = x;
				}
			}
		}
	}
	for (ans = 0, i = 0; i < n; i++) if (dp[i][lim-1] > ans) ans = dp[i][lim-1];
Done:
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

int main() {
	string a , b;
	cin >> a >> b;
	//cout << b.substr(0 , b.length() - 1) << "\n";
	if(b.substr(0 , b.length() - 1) == a) {
		
		cout << "Yes\n";
	}
	else cout << "No\n";
	
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <string.h>
#include <string>
#include <map>
#define rep(i,n) for(int i=0;i<(n);++i)
using namespace std;
typedef long long ll;

int main() 
{
  ll n; cin >> n;
  ll ans = 0;
  vector<ll> a(n+1);
  rep(i,n+1) cin >> a[i];
  vector<ll> b(n);
  rep(i,n) cin >> b[i];
  rep(i,n){
    ans += min(a[i], b[i]);
    b[i] -= min(a[i], b[i]);
    ans += min(a[i+1], b[i]);
    a[i+1] -= min(a[i+1], b[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scan = new Scanner(System.in);
    int A = scan.nextInt();
    int B = scan.nextInt();
    int C = scan.nextInt();
    int D = scan.nextInt();
    int E = scan.nextInt();
    int result = 0;

    Map<String, Integer> map = new HashMap<>();
    Map<String, Integer> map2 = new HashMap<>();
    int a = A % 10;
    if (a == 0) {
      result += A;
    } else {
      map.put("A", a);
      map2.put("A", A);
    }
    int b = B % 10;
    if (b == 0) {
      result += B;
    } else {
      map.put("B", b);
      map2.put("B", B);
    }
    int c = C % 10;
    if (c == 0) {
      result += C;
    } else {
      map.put("C", c);
      map2.put("C", C);
    }
    int d = D % 10;
    if (d == 0) {
      result += D;
    } else {
      map.put("D", d);
      map2.put("D", D);
    }
    int e = E % 10;
    if (e == 0) {
      result += E;
    } else {
      map.put("E", e);
      map2.put("E", E);
    }

    if (map.isEmpty()) {
      System.out.println(result);
      return;
    }

    String key = map.entrySet().stream().min((k, v) -> k.getValue() - v.getValue()).get().getKey();

    for (Map.Entry<String, Integer> entry : map.entrySet()) {
      if (!entry.getKey().equals(key)) {
        result += (map2.get(entry.getKey()) / 10 + 1) * 10;
      }
    }
    result += map2.get(key);
    System.out.println(result);
  }
}


Measured memory_bytes: 27220
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if i*500 + j*100 + k*50 == X:
                cnt+=1
print(cnt)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
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 (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()


int main(){
  int h,w;cin>>h>>w;
  int a[h][w];rep(i,h) rep(j,w)cin>>a[i][j];
  vector<P> ans;
  rep(i,h) rep(j,w-1){
    if(a[i][j]%2){
      a[i][j]=0;
      a[i][j+1]++;
      ans.push_back(P(i,j));
      ans.push_back(P(i,j+1));
    }
  }
  rep(i,h-1){
    if(a[i][w-1]%2){
      a[i][w-1]=0;
      a[i+1][w-1]++;
      ans.push_back(P(i,w-1));
      ans.push_back(P(i+1,w-1));
    }
  }
  int anssz=ans.size();
  cout<<anssz/2<<endl;
  rep(i,anssz/2){
    cout<<ans[i*2].first+1<<" "<<1+ans[i*2].second<<" "<<1+ans[i*2+1].first<<" "<<1+ans[i*2+1].second<<endl;
  }
}

Measured memory_bytes: 5232
#include <stdio.h> 
 
 #define MAX 100 
 
 
 int main(){ 
     int n; 
     int t_point=0, h_point=0; 
     char tarou[MAX], hanako[MAX]; 
 
 
     scanf("%d", &n); 
     for(;n>0;n--){ 
         scanf(" %s %s", tarou, hanako); 
         if(strcmp(tarou, hanako)>0){ 
             t_point+=3; 
         }else if(strcmp(tarou, hanako)==0){ 
             t_point+=1; 
             h_point+=1; 
         }else if(strcmp(tarou, hanako)<0){ 
             h_point+=3; 
         } 
     } 
     printf("%d %d\n", t_point, h_point); 
 
 
     return 0; 
 } 
 



Measured memory_bytes: 2036
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll k,a,b;
int main()
{
    scanf("%lld%lld%lld",&k,&a,&b);
    if(b<=a+2) cout<<k+1<<endl;
    else
    {
        ll ans=1;
        if(ans+k-2<a) cout<<ans+k<<endl;
        else
        {
            k=k-a+1;
            ans=b,k-=2;
            ans=ans-k/2*a+k/2*b;
            cout<<ans+k%2<<endl;
        }
    }
}


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

#define endl '\n'
#define ll long long
#define re register
#define pb(x) push_back(x)
#define ce(x) cout << x << '\n';

using db = long double;
using pll = pair < ll, ll >;

#define rep(i,x,n,inc) for(i=x ; i<n ; i+=inc)
#define repr(i,x,n,inc) for( i=x ; i>n ; i+=inc)
#define all(a)      (a).begin(),(a).end()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

#define mp(a,b) make_pair(a,b)
#define ff first
#define ss second
#define hell 1000000007
const db pi = acos(-1);
const long long infl = LLONG_MAX;

#define Foxen(i,s) for (i=s.begin(); i!=s.end(); i++)
#define Fill(s,v) memset(s,v,sizeof(s))
#define cout_p(x, p) cout << fixed << setprecision((p)) << x << endl     //print with precision

#define tc(tt) \
    ll tt;    \
    cin >> tt; \
    for (ll _tt = 0; _tt < tt; _tt++) // testcase 

int32_t main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

ll t=0,i,x,j,y,z=infl,k,n;
// For any integer j (1≤j≤i), Pi≤Pj.
	cin>>n;
	vector<pll>v;
	rep(i,0,n,1){
		cin>>x;
		if(i==0){
			t++;
			z=min(z,x);
		}else{
			if(z>x)	t++;
			z=min(z,x);
		}
	}
	ce(t)
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int main(){
	#define MAX (int)1e5
	bool sosu[MAX];
	memset(sosu,true,MAX);
	for(int i=4;i<MAX;i+=2)sosu[i]=false;
	for(int i=3;i<MAX;i+=2)
	for(int j=3*i;j<MAX;j+=2*i)sosu[j]=false;
	int n;
	while(cin>>n,n){
		int i;
		for(i=n;i>=2;i--)if(sosu[i]&&sosu[i-2])break;
		cout<<i-2<<" "<<i<<endl;
	}
}

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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30

char al[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

int main() {
    ll n; cin >> n;
    V<int> v;
    while(0 < n){
        v.push_back(n % 26);
        if(n % 26 == 0) n--;
        n /= 26;
    }
    reverse(ALL(v));
    for(auto i : v){
        if(i - 1 == -1) cout << 'z';
        else cout << al[i - 1];
    }
    cout << "\n";

    return 0;
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
   string str; cin>>str; int l=str.length(),c=0,d=0;
   for(int i=0;i<l/2;i++){
     if(str[i]==str[l-i-1])c++;
   } if(c==l/2)d++; c=0;
   for(int i=0;i<l/4;i++){
     if(str[i]==str[l/2-i-1])c++;
   } if(c==l/4)d++; c=0;
   for(int i=0;i<l/4;i++){
     if(str[i+l/2+1]==str[l-i-1])c++;
   }if(c==l/4)d++; if(d==3)cout<<"Yes"; else cout<<"No"; cout<<endl;
}


Measured memory_bytes: 3588
#include <iostream>
#include <string>
#include <vector>

using namespace std;
constexpr int64_t MOD = 1'000'000'007;

template< typename T >
T mod_pow(T x, T n) {
    T ret = 1;
    while(n > 0) {
        if(n & 1) (ret *= x) %= MOD;
        (x *= x) %= MOD;
        n >>= 1;
    }
    return ret;
}

int64_t modinv(int64_t a) {
    int64_t b = MOD, u = 1, v = 0;
    while (b) {
        int64_t t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= MOD;
    if (u < 0) u += MOD;
    return u;
}

int main(void) {
    int N;
    string s;
    cin >> N >> s;

    vector< vector<int64_t> > dp(N+1, vector<int64_t>(N+2));
    dp[0][0] = 1;
    for(int i=1; i<=N; i++) {
        dp[i][0] = (dp[i-1][0] + dp[i-1][1]) % MOD;
        for(int j=1; j<=N; j++) {
            dp[i][j] = (2*dp[i-1][j-1] + dp[i-1][j+1]) % MOD;
        }
    }

    cout << (dp[N][s.size()] * modinv(mod_pow(2L, (int64_t)s.size()))) % MOD << endl;
    return 0;
}


Measured memory_bytes: 198872
#include <iostream>

int main() {
    int a[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    std::cin >> k;

    std::cout << a[k - 1] << std::endl;

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
    #include <cmath>
    #include <string>
    #include <bits/stdc++.h>
    using namespace std;
    long long a[100010];
    int main(void)
    {
        int n;
        cin>>n;
        for(int i=0;i<n;i++)
        {
            cin>>a[i];
        }
        sort(a,a+n);
        int i=n;
        int cnt=0;
        long long len;
        long long wide;
        bool flag=false;
        while(i>=2)
        {
            if((a[i-1]==a[i-2]))
            {
                cnt++;
                if(cnt==1)
                {
                    len=a[i-1];
                    i--;
                }
                if(cnt==2)
                {
                    wide=a[i-1];
                    flag=true;
                    break;
                }
            }
            i--;
        }
        if(!flag)
        {
            cout <<0<<endl;
        }
        else
        {
            cout <<wide*len<<endl;
        }

        return 0;
    }


Measured memory_bytes: 1024
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <set>
#include <assert.h>
#include <sstream>
#include <string>
//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;



int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    int r = n-1;
    ll ans = a[0];
    int l = 1;
    while(l!=r){
        if (ans > 0){
            ans -= a[r];
            r--;
            //cout << r << endl;
        }
        else{
            ans += a[l];
            l++;
        }
    }
    cout << min(abs(a[l]- ans),abs(a[l]+ans));
    rn 0;
}


Measured memory_bytes: 1920
# -*- coding: utf-8 -*-
import sys


def main():
    N = int( sys.stdin.readline() )

    cnt = 0

    for a in range(1, N):
        if N % a == 0:
            cnt += (N // a - 1)
        else:
            cnt += (N // a )
    
    print(cnt)


if __name__ == "__main__":
    main()


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

using namespace std;

int main()
{

    int n, m, c, tmp, ans = 0;
    int Bs[21];
    int Ast[21][21];

    cin >> n >> m >> c;
    for (size_t i = 0; i < m; ++i)
    {
        cin >> tmp;
        Bs[i] = tmp;
    }
    for (size_t i = 0; i < n; ++i)
    {

        for (size_t j = 0; j < m; ++j)
        {
            cin >> tmp;
            Ast[i][j] = tmp;
        }
    }

    for (size_t i = 0; i < n; ++i)
    {
        int v = c;
        for (size_t j = 0; j < m; ++j)
        {
            v += Ast[i][j] * Bs[j];
        }

        if (v > 0)
            ans++;
    }

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

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

using namespace std;

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

    string s;
    cin >> s;
    string sr = s;
    reverse(sr.begin(), sr.end());
    if (s == sr) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}


Measured memory_bytes: 256
from itertools import accumulate

N,M=map(int,input().split())
A=[0 for i in range(N+1)]
for i in range(M):
  l,r=map(int,input().split())
  A[l-1]+=1
  A[r]-=1

A=list(accumulate(A))

ans=0
for a in A:
  if a==M:
    ans+=1
print(ans)

Measured memory_bytes: 8112
import sys
n,m = map(int,input().split())
a = [list(map(int,input().split())) for _ in range(m)]
start = a[0][0]
goal = n
tmp,ans = [],[]
for i in range(m):
	if a[i][1] == goal:
		tmp.append(a[i][0])
#print(tmp)
for j in range(m):
		if a[j][0] == start:
			ans.append(a[j][1])
if len(set(tmp)&set(ans)) > 0:
	print('POSSIBLE')
	sys.exit()
print('IMPOSSIBLE')

Measured memory_bytes: 54536
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (ll i = (ll)(a); i<(ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) begin(a), end(a)
#define TPL template
#define TNM typename

using ll = long long;
using ull = unsigned long long;
TPL<TNM T> using vec = vector<T>;
TPL<TNM T> using vec2 = vec<vec<T>>;
TPL<TNM T> using vec3 = vec<vec2<T>>;
TPL<TNM T> using vec4 = vec<vec3<T>>;
TPL<TNM T> using vec5 = vec<vec4<T>>;

TPL<TNM K, TNM V> using umap = unordered_map<K, V>;
TPL<TNM K, TNM V> using uset = unordered_set<K, V>;

TPL <class T = ll> inline T IN() { T x; cin >> x; return x; }
TPL<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
void bOUT(bool c, string s, string t) { OUT(c ? s : t); }
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(6); } } pre__;

TPL<TNM V, TNM H> void resize(vector<V>& v, const H h) { v.resize(h); }
TPL<TNM V, TNM H, TNM ... T> void resize(vector<V>& v, const H& h, const T ... t) { v.resize(h); for (auto& _v : v) resize(_v, t ...); }
TPL<TNM V, TNM T> void fill(V& x, const T& val) { x = val; }
TPL<TNM V, TNM T> void fill(vector<V>& vec, const T& val) { for (auto& v : vec) fill(v, val); }
TPL<TNM T> vector<T> make_v(size_t a) { return vector<T>(a); }
TPL<TNM T, TNM... Ts> auto make_v(size_t a, size_t b, Ts... ts) { return vector<decltype(make_v<T>(b, ts...))>(a, make_v<T>(b, ts...)); }

int main(void) {
	int A, B;
	cin >> A >> B;
	int ans = A - 1;
	if (A <= B) {
		ans++;
	}
	OUT(ans);
	return 0;
}

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


Measured memory_bytes: 256
using System;

namespace AtCoder0511
{
    class Program
    {
        static void Main(string[] args)
        {
            var lsweek = Console.ReadLine();

            if(lsweek == "ABC")
            {
                Console.WriteLine("ARC");
            }
            else if(lsweek =="ARC"){
                Console.WriteLine("ABC");
            }
            else
            {
                Console.WriteLine("invalid");
            }
        }
    }
}

Measured memory_bytes: 25772