akhauriyash/Code-Regression huggingface dataset:
x = int(input())
tmp = 0

if x == 2:
  print(2)
  exit()
for i in range(x,10**111):
  for j in range(2,(i//2)+2):
    tmp += 1
    if i%j == 0:
      tmp = 0
      break
    elif tmp == (i//2):
      print(i)
      exit()

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

int main()
{
        int d, i;
        int x, y;
        int space = 0;

        while ( scanf( "%d", &d ) != EOF )
        {
                space = 0;
                for ( i = 0 ; i < 600  ; i = i + d )
                {
                        y = i * i;
                        space = space + d*y;
                }
                fprintf( stdout, "%d\n", space );
        }

        return 0;
}

Measured memory_bytes: 596
#include <stdio.h>          
#include <math.h>           
 
typedef struct point_tbl
{
    double x;
    double y;
} point;
 
void koch(int n, point p, point q)
{
    point a, b, c;
 
    if (n == 0)
        return;
 
    double T = M_PI * 60.0 / 180.0;
 
    a.x = (2.0 * p.x + 1.0 * q.x) / 3.0;
    a.y = (2.0 * p.y + 1.0 * q.y) / 3.0;
    b.x = (1.0 * p.x + 2.0 * q.x) / 3.0;
    b.y = (1.0 * p.y + 2.0 * q.y) / 3.0;
    c.x = (b.x - a.x) * cos(T) - (b.y - a.y) * sin(T) + a.x;
    c.y = (b.x - a.x) * sin(T) + (b.y - a.y) * cos(T) + a.y;
 
    koch(n - 1, p, a);
    printf("%.8f %.8f\n", a.x, a.y);
    koch(n - 1, a, c);
    printf("%.8f %.8f\n", c.x, c.y);
    koch(n - 1, c, b);
    printf("%.8f %.8f\n", b.x, b.y);
    koch(n - 1, b, q);
}
 
int
main(int argc, char** argv)
{
    point aa, bb;
    int i;
 
    scanf("%d", &i);
    aa.x = 0, aa.y = 0;
    bb.x = 100, bb.y = 0;
 
    printf("%.8f %.8f\n", aa.x, aa.y);
    koch(i, aa, bb);
    printf("%.8f %.8f\n", bb.x, bb.y);
 
    return 0;
}


Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
   ll n;cin>>n;
   map<ll,ll> mp;
   rep(i,n){
       ll a;cin>>a;
       mp[a]++;
   }
   vector<ll> a;
   for(auto& p:mp){
       a.push_back(p.second);
   }
   sort(a.begin(),a.end());
   ll sz=a.size();
   rep(i,sz-1){
       a[i+1]-=(a[i]-1);
       a[i]=1;
   }
   if(a[sz-1]%2==0)sz--;
   cout<<sz<<endl;
}


Measured memory_bytes: 10416
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;

typedef long long LL;

const int N=2005;
const int MOD=1000000007;

int n,k,f[N][N],jc[N*N+N*2],ny[N*N+N*2];

void updata(int &x,int y)
{
    x+=y,x-=x>=MOD?MOD:0;
}

int C(int n,int m)
{
    return (LL)jc[n]*ny[m]%MOD*ny[n-m]%MOD;
}

int main()
{
    scanf("%d%d",&n,&k);k--;
    if (!k) {puts("1");return 0;}
    jc[0]=jc[1]=ny[0]=ny[1]=1;
    for (int i=2;i<=n*k+n+k;i++) jc[i]=(LL)jc[i-1]*i%MOD,ny[i]=(LL)(MOD-MOD/i)*ny[MOD%i]%MOD;
    for (int i=2;i<=n*k+n+k;i++) ny[i]=(LL)ny[i-1]*ny[i]%MOD;
    f[0][0]=1;
    for (int i=0;i<=n;i++)
        for (int j=i;j<=n;j++)
        {
            if (i) updata(f[i][j],f[i-1][j]);
            if (j) updata(f[i][j],(LL)f[i][j-1]*C(i+(j-1)*k+k-1,k-1)%MOD);
        }
    printf("%d",(LL)f[n][n]*jc[n]%MOD);
    return 0;
}


Measured memory_bytes: 47360
from collections import defaultdict

#索引数
d = defaultdict(int)
 
n = int(input())

#数え上げ
for i in range(1, n+1):
    start = str(i)[0]
    end = str(i)[-1]
    d[(start, end)] += 1

#リスト化 
L = list(d.items())
 
ans = 0
 
for (start, end), i in L:
    ans += i * d[(end, start)]
 
print(ans) 

Measured memory_bytes: 3316
def main():
    s = input()
    prev = [0] * 26
    space = [0] * 26
    for i, c in enumerate(s):
        x = ord(c) - ord('a')
        space[x] = max(space[x], i - prev[x])
        prev[x] = i + 1
    for i in range(26):
        space[i] = max(space[i], len(s) - prev[i])
    ans = min(space)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 38384
o=input()
e=input()
a,b=len(o),len(e)
if a==b:
    print("".join([o[i]+e[i] for i in range(a)]))
elif a>b:
    print("".join([o[i]+e[i] for i in range(b)])+o[-1])
else:
    print("".join([o[i]+e[i] for i in range(a)])+e[-1])

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

using namespace std;

#define PB push_back
#define MP make_pair
#define f first
#define s second
#define FOR(i,a,b) for (int i = a; i < b; ++i)
#define RFOR(i, b, a) for (int i = b-1; i>=a; --i)
#define FILL(a, b) memset(a, b, sizeof a)
#define ALL(a) a.begin(), a.end()
#define SZ(a) ((int)a.size())
#define MAGIC0
mt19937 rnd(time(0)); //rnd()

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = 1LL * INF*INF;
const int MAX = 1e5 + 7;
const double PI = acos(-1.);
const double EPS = 1e-8;
const int MOD = 998244353;

#define int LL

main()
{
//	freopen("input.txt", "r", stdin);
	ios_base::sync_with_stdio(0);
	int n;
	cin >> n;
	VI a(n), b(n), c(n);
	LL sum = 0;
	FOR(i, 0, n)
	{
		cin >> a[i];
		sum += a[i];
	}
	FOR(i, 0, n)
	{
		cin >> b[i];
	}

	FOR(i, 0, n)
	{
		c[i] = b[i];
		sum -= c[i];
	}

	if (sum < 0)
	{
		cout << - 1;
		return 0;
	}

	vector<PII> vec;
	FOR(i, 0, n)
	{
		if (a[i] > c[i])
		{
			vec.PB({a[i] - c[i], i});
		}
	}

	sort(ALL(vec));
	FOR(i, 0, SZ(vec))
	{
		if (sum >= vec[i].f)
		{
			c[vec[i].s] += vec[i].f;
			sum -= vec[i].f;
		}
	}

	int ans = 0;
	FOR(i, 0, n)
	{
		if (a[i] != c[i])
		{
			++ans;
		}
	}

	cout << ans;

	return 0;
}
// 2 12 216 5280 190800 9344160


Measured memory_bytes: 2044
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define ld long double
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using P=pair<long long,long long>;
#define rep(i,n) for(long long i=0; i<(long long)n; i++)
#define req(i,n) for(long long i=n-1; i>=0; i--)
#define range(i,a,b) for(long long i=a; i<b; i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((long long)(x).size())
#define COUT(x) cout << x << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define onBoard(y,x) (y>=0 && y<h && x>=0 && x<w)
#define vint vector<int>
#define pri_que priority_queue
#define vvint vector<vector<int>>
#define vstr vector<string>
#define vvchar vector<vector<char>>
#define vchar vector<char>
#define vp vector<pair<int,int>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define show(x) cout<<#x<<"="<<x<<endl;
#define SUM(x) accumulate(x.begin(),x.end(),0)
#define MAX(x) *max_element(x.begin(),x.end())
#define MIN(x) *min_element(x.begin(),x.end())
#define couty cout<<"Yes"<<endl
#define coutn cout<<"No"<<endl
#define coutY cout<<"YES"<<endl
#define coutN cout<<"NO"<<endl
#define yn(x) cout<<(x?"Yes":"No")<<endl
#define YN(x) cout<<(x?"YES":"NO")<<endl
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}
long long lcm(long long a, long long b){return a/gcd(a,b)*b;}
const long long dx[8]={1,0,-1,0,1,-1,-1,1};
const long long dy[8]={0,1,0,-1,1,1,-1,-1};
const long long INF = 1e12;
const long long MOD = 1e9+7;

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(15);

    int h,w;cin>>h>>w;
    vvchar s(h+2,vchar(w+2,'.'));
    range(i,1,h+1)range(j,1,w+1)cin>>s[i][j];
    vvchar res(h+2,vchar(w+2,'.'));

    range(i,1,h+1){
        range(j,1,w+1){
            if(s[i][j]=='#'){
                res[i][j]='#'; continue;
            }
            int cnt=0;
            rep(k,8){
                if(s[i+dy[k]][j+dx[k]]=='#')cnt++;
            }
            res[i][j]=cnt+'0';
        }
    }
    range(i,1,h+1){
        range(j,1,w+1){
            cout<<res[i][j];
        }
        cout<<endl;
    }
}

Measured memory_bytes: 3652
# coding: utf-8
# hello worldと表示する
import sys
#import numpy
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,pi,factorial
from operator import itemgetter
from copy import deepcopy
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

def ceil(x,y):
    return (-1)*((-x)//y)
    
n=I()
pairs=[LI() for i in range(n)]
x,y=1,1
for i in range(n):
    a=pairs[i][0]
    b=pairs[i][1]
    k=max(ceil(x,a),ceil(y,b))
    x,y=a*k,b*k
print(x+y)





'''def pair_revise(x,y,a,b):
    global p
    global q
    i=max(ceil(x/a),ceil(y/b))
    p,q=a*i,b*i
    return p,q
u,v=1,1
for i in range(n):
    u,v=pair_revise(u,v,pairs[i][0],pairs[i][1])
    print(u,v)
print(u+v)'''

    
    
        





Measured memory_bytes: 39152
/*|In The Name Of Allah|*/

#include <bits/stdc++.h>

using namespace std;

const int N = 1e4+5;

int n;
int m;
int valid;
int mem[N];
int cost[10];

int go(int lft){
    if(lft == 0)
        return 0;
    if(~mem[lft])
        return mem[lft];
    int bst = -1e2;
    for(int i = 1; i <= 9; i++){
        if(valid & (1 << i) && lft >= cost[i]){
            int ret = go(lft - cost[i]);
            if(ret != -1e2)
                bst = max(bst , ret + 1);
        }
    }
    return mem[lft] = bst;
}

vector < int > mine;

void build(int lft){
    for(int i = 9; i >= 1; i--){
        if(valid & (1 << i) && lft >= cost[i] && go(lft) >= 0 && go(lft - cost[i]) >= 0 && go(lft) == go(lft - cost[i]) + 1){
            mine.push_back(i);
            build(lft - cost[i]);
            break;
        }
    }
}

int main(){
    memset(mem , -1 , sizeof mem);
    cost[1] = 2;
    cost[2] = 5;
    cost[3] = 5;
    cost[4] = 4;
    cost[5] = 5;
    cost[6] = 6;
    cost[7] = 3;
    cost[8] = 7;
    cost[9] = 6;
    scanf("%d%d" , &n , &m);
    for(int i = 1; i <= m; i++){
        int x;
        scanf("%d" , &x);
        valid |= 1 << x;
    }
    int sz = go(n);
    build(n);
    sort(mine.rbegin() , mine.rend());
    for(auto v : mine)
        printf("%d" , v);
}

Measured memory_bytes: 512
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <cstdio>
#include <climits>
#include <complex>
#include <cstdint>
#include <tuple>

#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
inline int readInt() { int x; scanf("%d", &x); return x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)
#define MOD 1000000007

vector<vector<pair<int, int>>> G(100010);
int dist[100010];
bool visited[100010];

bool bfs(int v, int d){
    if(visited[v] && d != dist[v]) return false;
    if(visited[v] && d == dist[v]) return true;
    
    visited[v] = true;
    dist[v] = d;
    
    REP(i, (int)G[v].size()){
        if( !bfs(G[v][i].first, d + G[v][i].second)) return false;
    }
    return true;
}

int main() {
    
    int N = readInt(), M = readInt();
    
    REP(i, M){
        int l = readInt(), r = readInt(), d = readInt();
        l--; r--;
        
        G[l].push_back(make_pair(r, d));
        G[r].push_back(make_pair(l, -d));
    }
    
    REP(i, 100010) visited[i] = false;
    REP(i, 100010) dist[i] = -1 * INT_MAX;
    REP(i, N){
        if(!visited[i]){
            if(!bfs(i, 0)){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
	return 0;
}

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


struct goods{
    int v;
    int w;
    goods(int vi,int wi):v(vi),w(wi){;}
    bool operator<(const goods& g) const{
        return double(v)/w > double(g.v)/(g.w);
    }
};

int main()
{
    int n,W;
    cin >> n >> W;
    int dp[n][W+1] = {0};

    vector<goods> vg;

    while(n--){
        int vi;
        int wi;
        cin >> vi >>wi;
        vg.push_back(goods(vi,wi));
    }

    sort(vg.begin(),vg.end());

    for(int j = 0; j <= W;j++){
        if(j >= vg[0].w) dp[0][j] = vg[0].v;
        else dp[0][j] = 0;
    }

    for(int i = 1; i < vg.size();i ++){
        for(int j = 0; j <= W;j++){
            if(j >= vg[i].w) dp[i][j] = max(dp[i-1][j-vg[i].w]+vg[i].v,dp[i-1][j]);
            else dp[i][j] = dp[i-1][j];
        }
    }

    printf("%d\n",dp[vg.size()-1][W]);
    return 0;
}



Measured memory_bytes: 7052
#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

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

    int cnt=0;
    for (int i=0; i<3; i++) {
        if (s[i] == t[i]) cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 256
num = int(input())
ans = []
a = [input() for i in range(num)]
a.sort()

cnt, tmp=0, 0
for i in range(len(a)-1):
  if a[i]==a[i+1]:
    tmp += 1
    if cnt == tmp:
      ans.append(a[i])
    elif cnt < tmp:
      ans.clear()
      ans.append(a[i])
      cnt = tmp
  else:
    tmp = 0

if len(ans)==0:
  a.sort()
  for i in range(len(a)):
    print(a[i])
else:
  for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 18956
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pli = std::pair<long long, int> ;

using namespace std;

const long long MOD = 1000000007;

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

	int n, m;
	cin >> n >> m;

	if (n == m) cout << "Yes" << "\n";
	else cout << "No" << "\n";

	return 0;
}


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

using namespace std;

const int inf = 1000000007;

int main(){
    int n,l;
    cin >> n >> l;
    int full = n*(l-1) + 0.5*n*(n+1);
    int sub = inf;
    int ans = 0;

    for(int i=0;i<n;i++){
        int eaten = l+i;
        if(sub > abs(full - (full - eaten))){
            ans = full - eaten;
            sub = abs(full - (full - eaten));
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
ans = abs(A[0]) + abs(A[N-1])
for i in range(N-1):
    ans+=abs(A[i+1]-A[i])
ans = [ans] * N
for i in range(N):
    A_1 = A[i]
    if i==0:
        A_0 = 0
        A_2 = A[i+1]
    elif i==N-1:
        A_0 = A[i-1]
        A_2 = 0
    else:
        A_0 = A[i-1]
        A_2 = A[i+1]
    ans[i] += -abs(A_1-A_0) - abs(A_1-A_2) + abs(A_2-A_0)
    print(ans[i])

Measured memory_bytes: 14168
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    class Program
    {
        static void Main(string[] args)
        {
            var nq = Console.ReadLine().Split(' ').ToArray();
            var N = int.Parse(nq[0]);
            var Q = int.Parse(nq[1]);
            var treeArray = new Node[N+1];
            for (var i = 0; i <= N; i++) treeArray[i] = new Node();
            for (var i = 0; i < N-1; i++)
            {
                var ab = Console.ReadLine().Split(' ').ToArray();
                var a = int.Parse(ab[0]);
                var b = int.Parse(ab[1]);
                treeArray[a].children.Add(treeArray[b]);
            }
            for (var i = 0; i < Q; i++)
            {
                var px = Console.ReadLine().Split(' ').ToArray();
                var p = int.Parse(px[0]);
                var x = int.Parse(px[1]);
                //treeArray[p].Add(x);
                treeArray[p].value += x;
            }
            treeArray[1].Update(0);
            Console.WriteLine(string.Join(" ", treeArray.Skip(1).Select(item=>item.value)) );
        }
    }

    class Node
    {
        public int value = 0;
        public List<Node> children = new List<Node>();
        public void Add(int x)
        {
            value += x;
            foreach (var child in children) child.Add(x);
        }
        public void Update(int x)
        {
            value += x;
            foreach (var child in children) child.Update(value);
        }
    }
}


Measured memory_bytes: 79692
/// kazuki08
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
//#define inf 1000000000
#define mod 1000000007
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
#define IOS ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
    return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
    o<<"{";
    for(const T& v:vc) o<<v<<",";
    o<<"}";
    return o;
}
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

signed main(){
IOS;
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);

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


return 0;
}
///....


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
	int p[8]={3,5,7,11,13,17,19,23};
	int n;cin>>n;
	int ans=0;
	for(int i=0;i<8;i++){
		for(int j=i+1;j<8;j++){
			for(int k=j+1;k<8;k++){
				int temp=p[i]*p[j]*p[k];
				if(temp<=n){ans++;}
				else{break;}
			}
		}
	}
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
				if(i==j){continue;}
				int temp=p[i]*p[i]*p[i]*p[j];
				if(temp<=n){ans++;}
				else{break;}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 3608
N,K = map(int,input().split())
ans = []
for i in range(N):
    ab = list(map(int,input().split()))
    ans.append(ab)
ans.sort()
l = 0
for i in range(N):
    l += ans[i][1]
    if l >= K:
        s = i
        break
print(ans[s][0])

Measured memory_bytes: 27540
#include <cstdio>
#include <utility>
#include <vector>
#include <complex>
#include <cmath>

using namespace std;

static const double EPS=1e-12;
static const double INF=1e24;

using Point=complex<double>;
using Plane=vector<Point>;
using Polygon=vector<Point>;

bool operator<(const Point &a, const Point &b) {
    return real(a)!=real(b)? real(a)<real(b) : imag(a)<imag(b);
}

double cross_prod(const Point &a, const Point &b) {
    return imag(conj(a)*b);
}

double dot_prod(const Point &a, const Point &b) {
    return real(conj(a)*b);
}

double get_area(const Polygon &g) {
    double res=0.0;
    for (size_t i=0; i<g.size(); ++i)
        res += cross_prod(g[i], g[(i+1)%g.size()]);

    return res/2.0;
}

int main() {
    size_t n;
    scanf("%zu", &n);

    Polygon g(n);
    for (size_t i=0; i<n; ++i) {
        double x, y;
        scanf("%lf %lf", &x, &y);
        g[i] = Point(x, y);
    }

    printf("%.1f\n", get_area(g));
    return 0;
}

Measured memory_bytes: 2724
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#include <cstring>

#define test(t) while(t--)
#define fo(i,k,n) for(int i=k;i<n;i++)
#define refl(a,x) for(auto& a:x)
#define MIN(a,b)  (a>b?b:a)
#define ll  long long int
#define MOD 1e9 + 7
#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define fi first
#define se second
#define fast()  ios_base::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
//typedef pair<int,int> pai;
//typedef pair<char,int> pac;



/*bool f(int x,int y){

return x>y;
}*/


using namespace std;


void solve()
{ ll n;
  in n;
  ll a[n-1];
  unordered_map<ll,ll>m;
  for(ll i=0;i<n-1;i++){
    cin>>a[i];
    m[a[i]]+=1;

  }
  for(ll i=1;i<=n;i++){
    out m[i]<<en;
  }
}

int main(){ fast()
             //freopen("input.txt","r",stdin);
	         //freopen("output.txt","w",stdout);
             ll t=1;
             //cin>>t;
            test(t){
            solve();
            }
return 0;}


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

int main() {
  
  vector<int> A;
  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;
  cin >> K;
  cout << A.at(K-1) << endl;
  
}


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

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long V, long long B, long long W, long long T){
  long long dist = abs(B - A);
  long long diff = (W - V) * T;

  cout << ((dist + diff <= 0) ? YES : NO) << endl;
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long A;
  scanf("%lld",&A);
  long long V;
  scanf("%lld",&V);
  long long B;
  scanf("%lld",&B);
  long long W;
  scanf("%lld",&W);
  long long T;
  scanf("%lld",&T);
    solve(A, V, B, W, T);
    return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define CS
using namespace std;
int main(){
    speed;
   int a,b;
   int check = 0;
   cin >> a >> b;
   vector<int>vc;
   for ( int i  = 0 ;i < a;i++){
        vc.push_back(b-i);
        }
    reverse(vc.begin(),vc.end());
    for ( int i  = 1 ;i < a;i++){
        vc.push_back(b+i);
    }
    for (int i = 0 ;i  < vc.size();i++){
        cout << vc[i] << " ";
    }

}






Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <cfloat>

using namespace std;

int n, m;

struct edge {
	int dist, lim;
};

struct P {
	int from, pos, v;
	double time;

	bool operator >(const P& p) const {
		return time > p.time;
	}
};

edge elist[31][31];
double G[31][31][31];

int main() {
	int s, g;
	while (cin >> n >> m, n|m) {
		for(int i=0; i<31; i++){
			for(int j=0; j<31; j++){
				elist[i][j] = {-1, -1};
			}
		}
		fill_n((double *)G, 31*31*31, DBL_MAX);
		cin >> s >> g;
		for(int i=0; i<m; i++){
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			elist[x][y] = {d, c};
			elist[y][x] = {d, c};
		}
		priority_queue<P, vector<P>, greater<P>> q;
		q.push({-1, s, 0, 0.0});
		bool goal = false;
		while(!q.empty()){
			P p = q.top(); q.pop();
			// goal
			if (p.pos == g && p.v == 1) {
				printf("%f\n", p.time);
				goal = true;
				break;
			}
			for(int i=1; i<=n; i++) {
				if(elist[p.pos][i].dist != -1 && p.from != i) {
					// v+1
					if(p.v + 1 <= elist[p.pos][i].lim) {
						double time = p.time + (double)elist[p.pos][i].dist / (double)(p.v+1);
						if(time < G[p.pos][i][p.v+1]){
							q.push({p.pos, i, p.v+1, time});
							G[p.pos][i][p.v+1] = time;
						}
					}
					// v
					if(p.v <= elist[p.pos][i].lim) {
						double time = p.time + (double)elist[p.pos][i].dist / (double)p.v;
						if(time < G[p.pos][i][p.v]){
							q.push({p.pos, i, p.v, time});
							G[p.pos][i][p.v] = time;
						}
					}
					// v-1
					if(p.v -1 <= elist[p.pos][i].lim && p.v-1 > 0) {
						double time = p.time + (double)elist[p.pos][i].dist / (double)(p.v-1);
						if(time < G[p.pos][i][p.v-1]){
							q.push({p.pos, i, p.v-1, time});
							G[p.pos][i][p.v-1] = time;
						}
					}
				}
			}
		}
		if (!goal) cout << "unreachable" << endl;
	}
	return 0;
}

Measured memory_bytes: 1992
// 素因数分解をするプログラム

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stdbool.h>

int search_next_primeNumber(int num);

int main(void)
{
    int num = 0, tmp_num = 0;
    int prime_factor = 2;

    scanf("%d", &num);
    printf("%d:", num);

    tmp_num = num;

    while( tmp_num != 1 )
    {
        if( tmp_num % prime_factor == 0 )
        {
            // 入力値を割っておく
            tmp_num /= prime_factor;
            printf(" %d", prime_factor);
        }
        else
        {
            // 素数を検索する
            prime_factor = search_next_primeNumber(prime_factor);

            if( prime_factor * prime_factor >= tmp_num
                && tmp_num == num )
            {
                // 自分自身でのみ割れる時
                tmp_num = 1;
                printf(" %d", num);
            }
        }
    }

    printf("\n");

    return 0;
}

// 引数:numの次の素数を検索する関数
int search_next_primeNumber(int num)
{
    bool judge = false;

    int prime_num = num + 1;

    while( judge == false )
    {
        judge = true;

        for(int i = 2; i * i <= prime_num; i++)
        {
            if( prime_num % i == 0 )
            {
                // 素数ではない
                judge = false;
                prime_num++;
                break;
            }
        }
    }

    return prime_num;
}



Measured memory_bytes: 2104
N, T = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

diff = Hash.new(0)
min = A.first

(1...N).each do |i|
  if A[i] <= min
    min = A[i]
  else
    diff[(A[i]) - min] += 1
  end
end

puts diff.sort_by {|k, v| k}.last[1]

Measured memory_bytes: 22400
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(int i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(int i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long A, long long B){
  cout<<max(max(A+B,A-B),A*B)<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var inputStr string
	fmt.Scan(&inputStr)

	input, _ := strconv.Atoi(inputStr)

	a := input / 1000
	input = input % 1000
	b := input / 100
	input = input % 100
	c := input / 10
	input = input % 10
	d := input

	n := 3
	v := []int{a, b, c, d}

	for bit := 0; bit < (1 << uint(n)); bit++ {
		ans := v[0]
		ansStr := fmt.Sprint(v[0])
		for i := 0; i < n; i++ {
			if bit&(1<<uint(i)) == (1 << uint(i)) {
				ans += v[i+1]
				ansStr = fmt.Sprintf("%s+%d", ansStr, v[i+1])
			} else {
				ans -= v[i+1]
				ansStr = fmt.Sprintf("%s-%d", ansStr, v[i+1])
			}
		}
		if ans == 7 {
			ansStr = fmt.Sprintf("%s=%d", ansStr, ans)
			fmt.Println(ansStr)
			return
		}
	}
}


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

ll mpower(ll a,ll b,ll c){
  int z;
  if(b==0){
    z=1;
    z%=c;
    return z;
  }
  if(b==1){
    z=a;
    z%=c;
    return z;
  }
  else{
    return (((mpower(a,b/2,c))*(mpower(a,b/2,c))%c)*mpower(a,b%2,c)%c);
  }
}

const int MAX = 10000500;
const int MOD = 998244353;
ll fac[MAX], finv[MAX], inv[MAX];
 
// テーブルを作る前処理
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
 
// 二項係数計算
ll COM(int n,int k){
    if(n<k) return 0;
    if(n<0||k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
 
int main(){
  COMinit();
  ll mod=998244353;
  ll x;
  cin>>x;
  ll ans=mpower(3,x,mod);
  ll p=0,q=1;
  ll mpow[x+1];//mpow[i]=2^x
  mpow[0]=1;
  for(int i=1;i<=x;i++){
    mpow[i]=mpow[i-1]*2;
    mpow[i]%=mod;
  }
  for(int i=x/2+1;i<=x;i++){
    q=COM(x,i);
    q*=mpow[x-i];
    q%=mod;
    p+=q;
    p%=mod;
  }
  ans-=2*p;
  while(ans<0){
    ans+=mod;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 312704
extern crate core;

use std::io::{self, Read};

#[macro_export]
macro_rules! input {
  ($s:expr=>$($t:tt)*) => {
    let mut lines=$s.split("\n");
    $(
        line_parse!(lines,$t);
    )*
  };
}

macro_rules! line_parse {
  ($lines:expr,($($name:ident:$t:tt)*)) => {
    let mut line=$lines.next().unwrap().split_whitespace();
    $(value_def!(line,$name,$t);)*
  };

  //複数行
  ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
    values_def!($lines,$n,$name,$t);
  };
}

macro_rules! value_def {
    ($line:expr, $name:ident, $t:tt) => {
        let $name = value!($line, $t);
    };
}

macro_rules! values_def {
    ($lines:expr, $n:expr, $name:ident, $t:tt) => {
        let $name = {
            let mut vec = Vec::new();
            for i in 0..$n {
                let mut next = $lines.next().unwrap().split_whitespace();
                vec.push(value!(next, $t));
            }
            vec
        };
    };
}

macro_rules! value {
  //配列
  ($line:expr,[$t:tt]) => {
    $line.map(|x|{
      let mut iter=::std::iter::once(x);
      value!(iter,$t)
    }).collect::<Vec<_>>()
  };
  //タプル
  ($line:expr,($($t:tt),*)) => {
    ($(value!($line,$t),)*)
  };
  //文字列
  ($line:expr,#) => {
    $line.next().unwrap()
  };
  //インデックス(-1)
  ($line:expr,@) => {
    $line.next().unwrap().parse::<usize>().unwrap()-1
  };
  //単一値
  ($line:expr,$t:ty) => {
    $line.next().unwrap().parse::<$t>().unwrap()
  };
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(x:i64 y:i64));
    (x + y / 2).to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "81 58" => "110",
    test2: "4 54" => "31",
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << (x) << endl;
#define MAX 999999999

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};

typedef long long ll;

bool comp(const pair<int, pair<int, int>> &a, const pair<int, pair<int, int>> &b){
    return a.first > b.first;
}

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

    int n;
    cin >> n;

    vector<pair<int, pair<int, int>>> dishes;
    rep(i, n){
        int a, b;
        cin >> a >> b;
        dishes.push_back(make_pair(a+b, make_pair(a, b)));
    }

    sort(all(dishes), comp);

    ll sum = 0LL;
    rep(i, n){
        if(i % 2 == 0){
            sum += dishes[i].second.first;
        }else{
            sum -= dishes[i].second.second;
        }
    }

    cout << sum << endl;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<vector<int>> v(m + 1);
  for (int i = 0; i < n; i++) {
    int a, b;
    cin >> a >> b;
    if (a <= m) v[a].push_back(b);
  }

  int r = 0;
  priority_queue<int> q;
  for (int i = 1; i <= m; i++) {
    for (auto e : v[i]) q.push(e);
    if (!q.empty()) {
      r += q.top();
      q.pop();
    }
  }
  cout << r << endl;
}


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define repk(i,m,n) for(ll i=m;i<n;i++)
#define IOS ios::sync_with_stdio(false);cin.tie(0);
#define F first
#define S second
typedef long long ll;
typedef long double ld;
using namespace std;
const int MOD1=1e9+7;
const int MOD2=998244353;
const int INF=2*1e9;
map<ll,ll> m;
int main()
{
    ll n,x,y,len;
    cin>>n>>x>>y;
    rep1(i,n-1)
    {
        for(ll j=i+1;j<=n;j++)
        {
            len=min(j-i,max(x,i)-min(x,i)+1+max(y,j)-min(y,j));
            m[len]++;
        }
    }
    rep1(i,n-1) cout<<m[i]<<"\n";
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<map>
#include<stack>
#include<queue>

using namespace std;

int main(){
	int n,t;
	while(scanf("%d",&n)){
		if(n==0) break;
		int d[7]={};
		for(int i=0;i<n;i++){
			scanf("%d",&t);
			if(t>=0&&t<=9) d[0]++;
			else if(t>=10&&t<=19) d[1]++;
			else if(t>=20&&t<=29) d[2]++;
			else if(t>=30&&t<=39) d[3]++;
			else if(t>=40&&t<=49) d[4]++;
			else if(t>=50&&t<=59) d[5]++;
			else d[6]++;
		}
		for(int i=0;i<7;i++) printf("%d\n",d[i]);
	}
}


Measured memory_bytes: 3212
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int gcd(int a, int b) {
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}
int main() {
	long long n, k, a, b = 0, sum = 0; cin >> n >> k;
	for (int h = 0; h < n; h++) {
		cin >> a;
		if (a >= k) {
			b = 1;
		}
		if (h == 0) {
			sum = a;
		}
		else if(sum != a){
			sum = gcd(sum, a);
		}
	}
	if (b == 0) {
		cout << "IMPOSSIBLE" << endl;
		cin >> n; return 0;
	}
	if (k%sum == 0) {
		cout << "POSSIBLE" << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
	cin >> n;
}

Measured memory_bytes: 256
// D - Grid Repainting
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using VC = vector<char>;
using VVC = vector<VC>;
using PII = pair<int,int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define rpz(i,e) rp(i,0,e)

int bfs(int H, int W, VVC &S){
	int dx[4]={0,-1,0,1}, dy[4]={-1,0,1,0};
	vvi dist(H+1, vi(W+1, -1));
	dist[1][1] = 0;
	S[1][1] = '_';
	queue<PII> q;
	q.push({1, 1});
	while(!q.empty()){
		int i,j; tie(i,j)= q.front(); q.pop();
		rpz(k, 4){
			int y = i + dy[k], x = j + dx[k];
			if(S[y][x] != '.') continue;
			dist[y][x] = dist[i][j] + 1;
			q.push({y, x});
			S[y][x] = '_';
		}
	}
	return dist[H][W];
}

int main(){
	int H,W; cin>>H>>W;
	VVC S(H+2,VC(W+2, '#'));
	int white = 0;
	rpz(i, H){
		string s; cin>>s;
		rpz(j, W){
			if(s[j] == '.') white++;
			S[i+1][j+1] = s[j];
		}
	}
	int dist = bfs(H, W, S);
	cout<< (dist<0? -1: white - dist - 1) <<endl;
}

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

int main() {
	int N, M;
	cin >> N;
	cin >> M;
	vector<int> a(M);
	vector<int> p(N, 0);
	vector<vector<int>> b(M, vector<int>(N));

	rep(m, M) {
		cin >> a.at(m);
	}
	rep(m, M) {
		rep(n, N) {
			cin >> b.at(m).at(n);
		}
	}

	rep(m, M) {			// Game
		int bp = 0;
		rep(n, N) {		// Friends
			if(b.at(m).at(n) == a.at(m)) {
				p.at(n)++;
			} else {
				bp++;
			}
		}
		p.at(a.at(m)-1) += bp;
	}

	rep(n, N) {
		cout << p.at(n) << endl;
	}
	return 0;
}



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

int main(){
    string s;cin >> s;
    if(s == "zyxwvutsrqponmlkjihgfedcba"){
        cout << -1 << endl;return 0;
    }
    string ans = "";
    bool a[26];
    for(int i=0;i<26;i++){
        a[i] = false;
    }
    for(int i=0;i<s.size();i++){
            a[s[i]-'a'] = true;
            ans += s[i];
    }
    if(s.size() != 26){
       
        for(int i=0;i<26;i++){
            if(!a[i]){
                ans += (char)('a'+i);
               break;
            }
        }
    }
    else{
        for(int i=s.size()-1;i>=0;i--){
            a[s[i]-'a'] = false;
            if(s[i-1] < s[i]){
                int tmp;
                for(int j=s[i-1]-'a';j<26;j++){
                    if(!a[j]){
                        tmp =j;
                        break;
                    }
                }
                ans = s.substr(0,i-1) +(char)('a'+tmp);
                break;
            }
        }
    }
     cout << ans << endl;
                return 0;
}

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

int main(){
int n;
cin>>n;
long long  a[n]={0};
long long sum1=0,sum2=0;
long long t=0;
long long min=3000000000;
for(int i=1;i<=n;i++)  {
cin>>a[i];
sum1+=a[i];
}
for(int j=n;j>1;j--){
	sum1-=a[j];
	sum2+=a[j];
	 t=abs(sum1-sum2);
	 if(t<min)  min=t;
}
cout<<min;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define free(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%lld %lld %lld", &a, &b, &c)
#define pfn(n) printf("%lld\n", n)
#define pfs(n) printf("%lld ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search
#define le length()
const ll max_i=1e16+7;
#define np(s) next_permutation(s.begin(),s.end())
const int dx[]={1,0,-1,0};
const int dy[]={0,1,0,-1};
//it gives the lexicographically smallest string//

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) res = res * a;
        a = a * a; b >>= 1;
    }
    return res;
}

void solve()
{
  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
  int t=1;
  //cin>>t;
  while(t--){
    ll n;
    cin>>n;
    char arr[26];
    arr[0]='a';
    for(int i=1;i<26;i++) arr[i]=arr[i-1]+1;
      ll x=0,y=26,count=0;
      while(x<n)
      {
        x+=y;
        y*=26;
        count++;
      }
      x-=binpow(26,count);
      n-=x;
      while(count>0)
      {
        for(int i=1;i<=26;i++)
        {
          if(i*binpow(26,count-1)>=n)
          {
            cout<<arr[i-1];
            n-=(i-1)*binpow(26,count-1);
            count--;
            break;
          }
        }
    }
 }
}

int main()
{
  #ifndef ONLINE_JUDGE
  freopen("input1.txt", "r",stdin);
  freopen("output1.txt","w",stdout);
  #endif
  solve();
  return 0;
}

Measured memory_bytes: 3528
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>()> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const lint di[]{0, -1, 0, 1, -1, -1, 1, 1};
const lint dj[]{1, 0, -1, 0, 1, -1, -1, 1};

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    string s;
    cin >> a >> b;
    cin >> s;
    string ans = "Yes";
    for (int i=0; i<a; ++i){
        if(!(0 <= s[i] - '0' && s[i] - '0' <= 9)){
            ans = "No";
            break;
        }
    }
    for (int i=a+1; i<a+b+1; ++i){
        if(!(0 <= s[i] - '0' && s[i] - '0' <= 9)){
            ans = "No";
            break;
        }
    }
    if(s[a] != '-'){
        ans = "No";
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 504
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
int keta(int n){
    int tmp=0;
    if(n==0){
        tmp=1;
    }
    else{
        while(n>0){
            n = n/10;
            //cout << n<<endl;
            tmp++;
        }
    }
    return tmp;
}
int main(){
    int n,m;
    cin >> n>>m;
    vector<tuple<int,int,int>> t(m);
    rep(i,m){
        int p,y;
        cin >> p>>y;
        t[i] = make_tuple(p,y,i);
    }
    sort(t.begin(),t.end());
    int i=0,j=0;
    bool end =false;
    while(1){
    i=i+j;
    j=0;
    while(get<0>(t[i]) ==get<0>(t[i+j])){
        get<1>( t[i+j])=j+1;
        j++;
        if(i+j>=m){
            end=true;
            break;
        }
    }
    if(end){
        break;
    }
    }
    //ここで要素を入れ替えて戻してソート
    rep(i,m){
        int a,b,c;
        tie(a,b,c)=t[i];
        t[i]=make_tuple(c,a,b);
    }
    sort(t.begin(),t.end());
    //あとは適当な数の0を足す
    for(int i = 0;i< m; i++){
        int a,b,c;
        tie(a,b,c) = t[i];
        int ketab,ketac;
        ketab = keta(b),ketac = keta(c);
        rep(i,6-ketab){
            cout <<'0';
        }
        cout <<b;
        rep(i,6-ketac){
            cout<<'0';
        }
    
        cout <<c<< endl;
    }

    
}

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

int main() {
    int s, ans = 1;
    cin >> s;
    while (!(s == 1 || s == 2 || s == 4)){
        if (s % 2 == 0) {
            s /= 2;
        }
        else {
            s = s * 3 + 1;
        }
        ans++;
    }
    cout << ans + 3 << endl;
}

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

signed main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) {
    cin >> A[i];
    A[i]--;
  }
  
  int cur = 0;
  int ans = 0;
  vector<bool> vis(N, false);
  bool ok = false;
  while (!vis[cur]) {
    vis[cur] = true;
    cur = A[cur];
    ans++;
    if (cur == 1) {
      ok = true;
      break;
    }
  }
  if (ok) cout << ans << endl;
  else cout << -1 << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>

const int INT_INF = 1000000000;                 // 10^9
const long long LONG_INF = 1000000000000000000; // 10^18

using namespace std;

int main()
{
    long long n;
    cin >> n;

    long long mini = n - 1;
    for (int i = 2; i <= sqrt(n); i++)
    {
        if (n % i == 0)
        {
            long long m = n / i;
            mini = min(mini, i + m - 2);
        }
    }

    cout << mini << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a,b,c;
    scanf("%d %d %d",&a,&b,&c);


    //printf("%d  %d  %d  \n",a,b,c);
    if(a+b==c||b+c==a||c+a==b){
        printf("Yes\n");
    }else{
        printf("No\n");
    }

return 0;

}

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

void insert(int );
void inorder(Node );
void preorder(Node );

Node root;

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

    while(x != NIL){
        y = x;
        if(z->key < x->key) x = x->left;
        else x = x->right;
    }
    z->parent = y;

    if(y == NIL) root = z;
    else if(z->key < y->key) y->left = z;
    else y->right = z;
}

void inorder(Node u){
    if(u != NIL){
        inorder(u->left);
        printf(" %d",u->key);
        inorder(u->right);
    }
}
void preorder(Node u){
    if(u != NIL){
        printf(" %d",u->key);
        preorder(u->left);
        preorder(u->right);
    }
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      /*
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
      */
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
        /*
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
      */
    }
  }

  return 0;
}



Measured memory_bytes: 25144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
int N;
int num[300050];
int maxi[300050];
int fraction[300050];
int ok[300050];
int ans[300050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    for(int i = 1; i <= N; i++) {
        int A;
        cin >> A;
        num[A]++;
    }
    for(int val = 1; val <= N; val++) {
        maxi[0]++;
        maxi[num[val]+1]--;
        fraction[num[val]+1] += num[val];
    }
    for(int i = 1; i <= N; i++) {
        maxi[i] += maxi[i-1];
        fraction[i] += fraction[i-1];
    }
    for(int timer = 1; timer <= N; timer++) {
        int total = maxi[timer] * timer + fraction[timer];
        ok[total / timer] = timer;
    }
    for(int i = N; i >= 1; i--) {
        ans[i] = max(ans[i+1], ok[i]);
    }
    for(int i = 1; i <= N; i++) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 6016