akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
    static final long MOD=1000000007;
 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        int tmpa;
        int tmpb;
        List<Integer> list1=new ArrayList<>();
        List<Integer> listn=new ArrayList<>();
        for(int i=0;i<m;i++){
            tmpa=sc.nextInt();
            tmpb=sc.nextInt();
            if(tmpa==1){
                list1.add(tmpb);
            }else if(tmpa==n){
                listn.add(tmpb);
            }else if(tmpb==1){
                list1.add(tmpa);
            }else if(tmpb==n){
                listn.add(tmpa);
            }
        }
        Collections.sort(list1);
        Collections.sort(listn);
        int i=0;
        int j=0;
        int tmp1;
        int tmpn;
        while(i<list1.size()&&j<listn.size()){
            tmp1=list1.get(i);
            tmpn=listn.get(j);
            if(tmp1==tmpn){
                System.out.println("POSSIBLE");
                return;
            }else if(tmp1<tmpn){
                i++;
            }else{
                j++;
            }
        }
        System.out.println("IMPOSSIBLE");
    }
}

Measured memory_bytes: 94980
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;

int N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
    const ll INF = 10000000000;
    cin>>N>>W;
    vector<int> we(N+1,0), va(N+1,0);
    reps(i,1,N+1) cin>>we.at(i)>>va.at(i);
    vector<vector<ll>> dp(N+1,vector<ll>(100001,INF));
    dp[0][0] = 0;
    int ans = 0;
    reps(i,1,N+1){
        rep(j,100001){
            dp[i][j] = dp[i-1][j];
            if(j>=va.at(i) && dp[i-1][j-va.at(i)] != INF) {
                dp[i][j] = min(dp[i][j],dp[i-1][j-va.at(i)]+we.at(i));
                if(dp[i][j] > W) dp[i][j] = INF;
            }
            if(dp[i][j] != INF) ans = max(ans,j);
        }
    }
    cout<<ans<<endl;
    /*rep(i,N+1){
        rep(j,W+1){
            cout << dp[i][j] << ' ';
        }
        cout << endl;
    }*/
}

Measured memory_bytes: 80256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
#include <climits>
#include <cstdio>
#define int long long
#define pb push_back
#define mp make_pair
#define INF 0x3f3f3f3f
#define Inf 100000000000000000LL
#define F first
#define S second
using namespace std;
typedef pair<int,int>pii;
int n,W;
long long dp[100010];
int w[110],v[110];
signed main(){
	// for(int i=1;i<=100000;i++)dp[i]=Inf;
	cin>>n>>W;
	for(int i=1;i<=n;i++)cin>>w[i]>>v[i];
	dp[0]=0;
	for(int i=1;i<=n;i++){
		for(int j=W;j>=w[i];j--)dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
	}
	cout<<dp[W]<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
using namespace std;
static const int MAX = 20;

int main(void){
    int n;
    cin >> n;
    int abc[3][MAX];
    for(int i=0; i<3; i++){
        for(int j=0; j<n; j++){
            if(i==2 && j==n-1) continue;
            cin >> abc[i][j];
        }
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        ans += abc[1][i];
    }
    for(int i=0; i<n-1; i++){
        if(abc[0][i]+1 == abc[0][i+1]){
            ans += abc[2][abc[0][i]-1];
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
//BISMILLAHIR RAHMANIR RAHEEM
                                      //ALLAH IS WATCHING ME

//█▀█─█──█──█▀█─█─█
//█▄█─█──█──█▄█─█▄█
//█─█─█▄─█▄─█─█─█─█


#include<bits/stdc++.h>

#define ull    unsigned long long
#define ll   long long
#define ses   "\n"

using namespace std;

//main function is here........
int main(){
         ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll a,b;
cin>>a>>b;
if(a>9 || b>9){cout<<-1;}
else cout<<a*b;
}

//Alhamdulillah


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
static class Program{
	const int mod=1000000007;
	static string[] c;
	static int[] s;
	static string t;
	static void Main(){
		Sc sc=new Sc();
		s=sc.Ia;
		t=" "+sc.S+" ";
		c=new string[s[1]];
		int ans=0;
		for(int i = 0;i<s[1];i++) {c[i]=sc.S;}
		Fu(1);
		int lb=0,ub=s[0]+1,mid=0;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			if(Fu(mid)!=0){ub=mid;}
			else{lb=mid;}
		}
		ans+=ub-1;
		lb=0;ub=s[0]+1;mid=0;
		while(ub-lb>1){
			mid=(ub+lb)/2;
			if(Fu(mid)==s[0]+1){ub=mid;}
			else{lb=mid;}
		}
		Console.WriteLine(s[0]-(ans+s[0]-ub+1));
	}
	static int Fu(int n){
		for(int i = 0;i<s[1]&&n!=0&&n!=s[0]+1;i++) {
			if(t[n]==c[i][0]){n+=c[i][2]=='L'?-1:1;}
		}
		return n;
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()).Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
}

Measured memory_bytes: 28240
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size,n=1,init=nil) #nに配列の次元数、sizeに配列の大きさ、initに初期値を投げることでその配列を返す
  if n==1
    return Array.new(size){init}
  else
    return Array.new(n).map{Array.new(size){init}}
  end
end

class UnionFindTree
  attr_accessor:par,:rank
  def initialize(n)
    @par=Array.new(n){|i| i}
    @rank=array(n,1,0)
  end

  def find(x)
    return x if @par[x]==x
    @par[x]=find(@par[x])
    return @par[x]
  end

  def union(x,y)
    x=find(x)
    y=find(y)
    return if x==y
    if @rank[x]<@rank[y]
      @par[x]=y
    else
      @par[y]=x
      @rank[x]+=1 if @rank[x]==@rank[y]
    end
  end

  def same?(x,y)
    return find(x)==find(y)
  end
end

n,q=get_i
uft=UnionFindTree.new(n)
q.times do
  c,x,y=get_i
  if c.zero?
    uft.union(x,y)
  else
    puts yn_judge(uft.same?(x,y),1,0)
  end
end


Measured memory_bytes: 8928
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(v) ((int)v.size())
#define all(v) v.begin(), v.end()
#define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

ll mod=1e9+7;
void io(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);    
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
}
const int N=2e5+5;
int a[N],v[N];
int main() {
	//io();
	string s;
	int n,k,q;
	cin>>n>>k>>q;
	int qq=q;
	for(int i=1;i<=n;i++)
			a[i]=k;
	while(q--){
		int x;
		cin>>x;
		a[x]++;

	}
	int cnt=0;
	for(int i=1;i<=n;i++){
			a[i]=a[i]-qq;
		if(a[i]>0)
			cout<<"Yes\n";
		else	cout<<"No\n";
	}
}
 

 

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

using namespace std;

int main()
{
	int N;
	double inpx;
	string inpu;
	vector<double> x;
	vector<string> u;
	double res = 0.0;

	cin >> N;

	for (int i = 0; i < N; i++)
	{
		cin >> inpx >> inpu;
		x.push_back(inpx);
		u.push_back(inpu);

		if (u[i] == "BTC")
		{
			res += x[i] * 380000;
		}
		else
		{
			res += x[i];
		}
	}

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
A.sort()
a,b,i=0,1,0
mod=10**9+7
ans=1
while i<K-1:
  if A[a]*A[a+1]>A[-b]*A[-b-1]:
    ans*=A[a]*A[a+1]
    ans%=mod
    a+=2
    i+=2
  else:
    ans*=A[-b]
    ans%=mod
    b+=1
    i+=1
if i==K-1:
  ans*=A[-b]
  ans%=mod
if A[-1]<0 and K%2==1:
  ans=1
  for i in A[N-K:]:
    ans*=i
    ans%=mod
print(ans%mod)

Measured memory_bytes: 31692
#include <iostream>
#include <algorithm>
#include <utility>

using namespace std;

int main(){
  int h,w,i,j,k,q,d;
  pair<int,int>a[300*300+1];
  int sum[300*300+1]={};
  cin >> h >> w >> d;
  for(i=1;i<=h;i++){
    for(j=1;j<=w;j++){
      cin >> k;
      a[k].first = i;
      a[k].second = j;
    }
  }

  for(i=1;i<=h*w-d;i++){
    sum[i+d] = sum[i];
    sum[i+d] += abs(a[i].first-a[i+d].first);
    sum[i+d] += abs(a[i].second-a[i+d].second);
  }

  cin >> q;
  for(i=0;i<q;i++){
    cin >> j >> k;
    cout << sum[k]-sum[j] << endl;
  }
  return 0;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

const int N = 1000;
int a[N][N];

int main(){
    int n;
    scanf(" %d", &n);
    rep(i,n)rep(j,n-1){
        scanf(" %d", &a[i][j]);
        --a[i][j];
    }

    vector<int> cand;
    rep(i,n) cand.pb(i);

    vector<int> x(n);
    int ans = 0;
    while(1){
        bool upd = false;

        vector<int> nx;
        vector<bool> used(n);
        for(int i:cand)if(!used[i] && x[i]<n-1){
            int e = a[i][x[i]];
            if(!used[e] && x[e]<n-1 && a[e][x[e]]==i){
                // dbg(((pair<int,int>){i,e}));
                used[i] = used[e] = true;
                ++x[i];
                ++x[e];
                nx.pb(i);
                nx.pb(e);
                upd = true;
            }
        }

        if(!upd) break;
        cand = nx;
        ++ans;
    }

    rep(i,n)if(x[i]!=n-1) ans = -1;

    printf("%d\n", ans);
    return 0;
}


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


int cmp(const int *a,const int *b){

return *a > *b ? -1 : *a < *b ? 1 : 0 ;
}
//qsort(pa,n,sizeof(int),(int(*)(const void* ,const void*))cmp);
//syoujiyunn



int main(void){
  int n;
  int k;
  scanf("%d%d",&n,&k);
  long long int h[n];
  int i,j;
  for(i=0;i<n;i++){
    scanf("%lld",&h[i]);
  }
  long long int ans=0;
  qsort(h,n,sizeof(long long int),(int(*)(const void* ,const void*))cmp);
for(i=k;i<n;i++){
  ans+=h[i];
}
printf("%lld",ans);

  return 0;
}


Measured memory_bytes: 3324
#include <bits/stdc++.h>
//#include "all_headers.h"
using namespace std;
int main()
{
    int mx = 1e6;
    bool prime[mx];

    memset(prime , 1 , sizeof(prime));
 
    
    prime[1] = 0 ;

    for(int i = 2 ; i*i < mx; i++)
    {
        //cout << i << " = "<<endl;
        if(!prime[i])
        {
            continue;
        }
        else{
            
            for(int j = i*i ; j < mx  ; j += i)
            {
                    prime[j] = 0;
                    //cout << "  j = "<<j<<endl;
            }
        }
    }

    

    int x ;
    cin >> x;

    for(int i = x ; i < INT_MAX ; i++)
    {
        if(prime[i])
        {
            cout << i << endl;
            return 0;
        }
    }

    return 0;   
}

Measured memory_bytes: 1280
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
Mod = 1000000007



def main(): #startline--------------------------------------------
    N,Q = map(int,input().split())
    S = input()
    LR = [list(map(int,input().split())) for i in range(Q)]
    accum = [0]
    keep = "start"
    S += "D"

    for i in S:
        if i == "C":
            if keep == "A":
                accum.append(accum[-1]+1)
                keep = ""
            else:
                keep = ""
                accum.append(accum[-1])
        elif i == "A":
            keep = "A"
            accum.append(accum[-1])
        else:
            keep = ""
            accum.append(accum[-1])
    accum = accum[1:]
    for i in range(Q):
        print(accum[LR[i][1]-1]-accum[LR[i][0]-1])

if __name__ == "__main__":
    main() #endline===============================================




def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n < 2 is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))):
        if prime[i] == 1:
            for j in range(2*i,n):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n):
        if prime[i] == 1:
            res.append(i)
    return res

class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py

    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)

Measured memory_bytes: 32944
import bisect
import collections
import heapq
from collections import defaultdict
import sys

sys.setrecursionlimit(100000)
input = sys.stdin.readline
ACMOD = 1000000007
INF = 1 << 32


def lmi():
    return list(map(int, input().split()))


def llmi(n):
    return [lmi() for _ in range(n)]


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

MAX_VAL = 10 ** 20
uvab = llmi(m)
jpy_cost = defaultdict(dict)
snuke_cost = defaultdict(dict)


def dijkstra2_scipy(adj, start, n=None, limit=None):
    """
    caution!  add 10**-10 to avoid 0 cost
    """
    from scipy.sparse import csr_matrix
    from scipy.sparse.csgraph._shortest_path import dijkstra
    if limit:
        limit += 0.5
    cost, row_ind, col_ind = [], [], []
    for k1, _v in adj.items():
        for k2, _cost in _v.items():
            row_ind.append(k1)
            col_ind.append(k2)
            cost.append(_cost + 10 ** -10)
    cost_matrix = csr_matrix((cost, (row_ind, col_ind)))
    return dijkstra(cost_matrix, indices=[start])[0]


def dijkstra2(adj, start, n):
    MAX_VAL = float('inf')
    INF = MAX_VAL
    dist = [INF for _ in range(n)]
    dist[start] = 0
    pq = []
    heapq.heappush(pq, [dist[start], start])
    while pq:
        u_dist, u_id = heapq.heappop(pq)  # u is a tuple [u_dist, u_id]
        if u_dist == dist[u_id]:
            for v in adj[u_id]:
                w_uv = adj[u_id][v]
                if dist[u_id] + w_uv < dist[v]:
                    dist[v] = dist[u_id] + w_uv
                    heapq.heappush(pq, [dist[v], v])
    return dist


for u, v, a, b in uvab:
    u = u - 1
    v = v - 1
    jpy_cost[u][v] = a
    jpy_cost[v][u] = a
    snuke_cost[u][v] = b
    snuke_cost[v][u] = b

jpy_dijk = dijkstra2(jpy_cost, start=s - 1, n=n)
snuke_dijk = dijkstra2(snuke_cost, start=t - 1, n=n)
res = []
min_val = MAX_VAL
for i in reversed(range(n)):
    # 都市  i で両替
    val = jpy_dijk[i] + snuke_dijk[i]
    assert val < MAX_VAL
    min_val = min(min_val, val)
    res.append(min_val)
for x in reversed(res):
    print(10 ** 15 - int(x))


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

#define int long long

using namespace std;

int n;
int a[200001];
int sum[200001];

bool bin_check(int x) {

    int p1 = 0, p2 = 0;
    int sum1 = 0, sum2 = 0;

    // Shakutori
    for(int i = 0; i < n; ++i) {

        // 1
        while(sum1 < x) {
            sum1 += a[p1];
            if(p1 < p2) sum2 -= a[p1];
            ++p1;
        }

        // 2
        if(!i) p2 = p1;
        while(sum2 < x) {
            sum2 += a[p2];
            ++p2;
        }

        // 3
        if(sum[n + i] - sum[p2] >= x) {
            return true;
        }

        sum1 -= a[i];
    }

    return false;

}

main() {

    cin >> n;

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

    sum[0] = 0;
    for(int i = 1; i <= 2 * n; ++i) {
        sum[i] = sum[i - 1] + a[i - 1];
    }

    int l = 0, m, r = sum[n + n] / 3;
    while(l + 1 < r) {
        m = (l + r) / 2;
        if(bin_check(m)) {
            l = m;
        } else {
            r = m;
        }
        //cout << l << " " << r << endl;
    }

    cout << l << endl;

}

Measured memory_bytes: 6188
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, M;
    cin >> N >> M;
    vector<bool> red(N, false);
    vector<int>  ball(N, 1);

    red[0] = true;
    rep(i, M) {
        int x, y;
        cin >> x >> y;
        x--; y--;
        ball[x]--;
        ball[y]++;
        if (red[x]) {
            if (ball[x] == 0) red[x] = false;
            red[y] = true;
        }
    }

    int ans = 0;
    rep(i, N) {
        if (red[i]) ans++;
    }

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

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

int main()
{
    string s1, s2;
    getline(cin, s1);
    getline(cin, s2);
    int count = 0;
    
    for(int i=0; i<3; i++){
        if(s1.at(i) == s2.at(i))
            count++;
    }
    cout << count << endl;

    return 0;
}

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

#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long ll;
typedef long double ld;
using namespace std;
#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace __gnu_pbds;
const int N=2e5+5;
int mod=100000000;
/*int k1, k2;
ll dp[10][10][100][100];
ll solve(int n1, int n2, int last1, int last2)
{
    if(n1==0&&n2==0)
        return 1;
    if(dp[last1][last2][n1][n2]!=-1)
        return dp[last1][last2][n1][n2];

    ll &ans=dp[last1][last2][n1][n2];
    ans=0;
    if(last1<k1&&n1)
    {
        ans=(ans+solve(n1-1,n2,last1+1,0))%mod;

    }
    if(last2<k2&&n2)
    {
         ans=(ans+solve(n1,n2-1,0,last2+1))%mod;
    }
    // cout<<n1<<" "<<n2<<" "<<last1<<" "<<last2<<" "<<ans<<endl;
    return ans;

}*/
    ll n,arr[N], co[N], ans=0;

int main()
{
    FIO
    int k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
        cin>>arr[i];
        int ans=((n-1)/(k-1));
        if((n-1)%(k-1)!=0)
            ans++;
        cout<<ans;
return 0;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forx(i, n) for(int i = 1 ; (i) <= (n) ; ++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x) * (x)
#define debug(x) cout << #x <<" = " << x << endl
#define printvpair(v) for(auto x : v) cout << x.first  <<" " << x.second;
#define printv(v) for(auto x : v) cout << x << " "; cout << endl;
 
const int N = 505;
int a[N][N];
int n,m;
 
vector<pair<int,int> > ans;
void print(pair<int,int> p){
    ans.push_back(p);
}
void doit(pair<int,int> p){
    cout << p.first << " "<<p.second;
}
 
int main() {
    cin >> n >> m;
    forx(i,n) forx(j,m) cin >> a[i][j];
 
    forx(i,n)
        forx(j,m){
            if (a[i][j] % 2 == 1){
                if (i + 1 <= n){
                    ans.emplace_back(i,j);
                    ans.emplace_back(i + 1,j);
                    a[i + 1][j]++;
                }else if (j + 1 <= m){
                    ans.emplace_back(i,j);
                    ans.emplace_back(i,j + 1);
                    a[i][j + 1]++;
                }
            }
        }
    cout << ans.size() / 2 << endl;
 
    for (int i = 0; i < ans.size(); i += 2) {
        doit(ans[i]);
        cout<<" ";
        doit(ans[i+1]);
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 5232
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<long long> vll, vLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vint n(3);
    cin >> n[0] >> n[1] >> n[2];
    sort(ALL(n));
    cout << n[2]*10+n[1]+n[0]<<endl;
    

    return 0;
}

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

using namespace std;

int main()
{
    long long a,b;
    scanf("%lld",&a);
    b=sqrt(a);
    while(1)
    {
        if(a%b==0)
        {
            printf("%lld",b+a/b-2);
            break;
        }
        b--;
    }
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    unsigned long long int n,m,ans=0;
    cin>>n;
    if(n&1)
        cout<<0;
    else
    {
        m=n>>1;
        while(m>0)
        {
            ans+=m/5;
            m/=5;
        }
        cout<<ans;
    }
    return 0;

}


Measured memory_bytes: 256
#include<iostream>
#include<vector>

using namespace std;

int main(){
  int n,p;
  cin >> n >> p;
  vector<int> win;
  while(n){
    vector<int> may(n);
    int cal = p;
    int flag = 1;
  while(flag){
    for(int i = 0; i < n; i++){
      if(cal){
        cal--;
        may[i]++;
        if(may[i] == p){
          win.push_back(i);
          flag = 0;
        }
      }
      else if(may[i]){
        cal = may[i];
        may[i] = 0;
      }
    }
  }
  cin >> n >> p;
}
for(int i = 0; i < win.size();i++)
  cout << win[i] << endl;
}



Measured memory_bytes: 3140
// CppPractice.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n, L[5000], ans;
	ans = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> L[i];
	}
	sort(L, L + n);
	for (int i = 0; i < n; i++)	{
		for (int j = i + 1; j < n; j++) {
			int tmp;
			int a = L[i] + L[j];
			int idl = lower_bound(L, L + n, L[i] + L[j]) - L;
			if (0 <= idl) {
				ans += (idl - j - 1);
			}
		}
	}
	cout << ans << endl;
}

// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー

// 作業を開始するためのヒント: 
//    1. ソリューション エクスプローラー ウィンドウを使用してファイルを追加/管理します 
//   2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
//   3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
//   4. エラー一覧ウィンドウを使用してエラーを表示します
//   5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード ファイルを作成するか、[プロジェクト] > [既存の項目の追加] と移動して既存のコード ファイルをプロジェクトに追加します
//   6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] > [プロジェクト] と移動して .sln ファイルを選択します


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int H,W;
    cin>>H>>W;
    char a[H][W];
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cin>>a[i][j];
        }
    }
    char checkrow[H];
    char checkcol[W];
    for(int i=0;i<H;i++){
        checkrow[i]=1;
    }
    for(int i=0;i<W;i++){
        checkcol[i]=1;
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(a[i][j]=='#'){break;}
            if(j==W-1){checkrow[i]=0;}
        }
    }
    for(int i=0;i<W;i++){
        for(int j=0;j<H;j++){
            if(a[j][i]=='#'){break;}
            if(j==H-1){checkcol[i]=0;}
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(checkrow[i]==1&&checkcol[j]==1){cout<<a[i][j];}
        }
        if(checkrow[i]==1){puts("");}
    }
}

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

if s == t:
    ans = "No"
else:
    s = "".join(sorted(s))
    t = "".join(sorted(t)[::-1])
    if sorted([s,t])[0] == s:
        ans = "Yes"
    else:
        ans = "No"
print(ans)

Measured memory_bytes: 38256
use std::str::FromStr;
use std::io::stdin;
use std::cmp::min;
use std::process::exit;

fn main() {
    let (l, r) = {
        let vec: Vec<u64> = read_vec();
        (vec[0], vec[1])
    };
    if r - l >= 2019 {
        println!("{}", 0);
        exit(0);
    }
    let mut v = 2020 as u64;
    for i in l..(r + 1) {
        for j in (i + 1)..(r + 1) {
            v = min(v, (i * j) % 2019);
        }
    }
    println!("{}", v);
}

fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).ok();
    line.trim().split_whitespace()
        .map(|i| i.parse().ok().unwrap()).collect()
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0; i<N; i++){
    cin >> d.at(i);
  }
  int count = 0;
  sort(d.begin(), d.end());
  for(int i=0; i<N-1; i++){
    if(d.at(i) < d.at(i+1)){
    count++;
    }
  }
  cout << count+1 << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>
#include <string>
#include <vector> 
#include <numeric>
#include <cmath>
#include <queue>
#include <iomanip>
#include <functional>

#define CHMAX(a,b) a = std::max(a,b)
#define CHMIN(a,b) a = std::min(a,b)
#define MAXMIN(a,b,c) std::max(a,min(b,c))
#define CHABS(a) a = std::abs(a) 
#define COUT(a) std::cout << a << std::endl
#define CERR(a) std::cerr << a << std::endl
#define FOR(n) for(lli i = 0; i < n; i++)

using namespace std;
using lli = long long int;
using pll = pair<lli, lli>;
using tlll = tuple<lli, lli, lli>;
using vll = vector<lli>;

lli mod197 = 1000000007LL;
lli INF = 10000000000000;

// ax + by = gcd(a,b) 最大公約数
template< typename T >
T extgcd(T a, T b, T& x, T& y) {
	T d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1;
		y = 0;
	}
	return d;
}

int a[20][20], b[20];

int main(void) {


	int a, b, k;
	cin >> a >> b >> k;

	for (int i = min(a, b); i >= 1; i--) {
		if (a % i == 0 && b % i == 0) {
			k--;
			if (k == 0) {
				COUT(i);
				return 0;
			}
		}
	}


	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    ll sum = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        sum += a[i];
    }
    ll numonce = n * (n+1) / 2;
    if(sum % numonce != 0){
        cout << "NO" << endl;
        return 0;
    }
    ll k = sum / numonce;
    vector<ll> dif(n);
    for(int i = 0; i < n-1; i++){
        dif[i] = a[i+1] - a[i];
    }
    dif[n-1] = a[0] - a[n-1];
    ll count = k;
    for(int i = 0; i < n; i++){
        dif[i] -= k;
        if(dif[i] < 0){
            if(dif[i] % n != 0){
                cout << "NO" << endl;
                return 0;
            }else{
                count += dif[i] / n;
            }
        }else if(dif[i] != 0){
            cout << "NO" << endl;
            return 0;
        }
    }
    if(count == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 1792
def resolve():
  N, M = map(int, input().split(" "))
  AB_map = [[] for i in range(N)]
  for m in range(M):
    AB = [int(x) - 1 for x in input().split(" ")]
    AB_map[AB[0]].append(AB[1])
    AB_map[AB[1]].append(AB[0])

  not_finished = set(range(1, N+1))
  rooms = [None] * N
  rooms[0] = 0
  room_depths = [0] * N

  recent_rooms = [0]
  depth = 1
  while len(not_finished) != 0 and depth < N:
    temp_recent = set()
    for r in recent_rooms:
      for target in AB_map[r]:
        if target in not_finished:
          temp_recent.add(target)
          not_finished.remove(target)
          rooms[target] = r
          room_depths[target] = depth
    depth += 1
    recent_rooms = list(temp_recent)

  print("Yes")
  for r in rooms[1:]:
    print(r + 1)

if __name__ == "__main__":
    resolve()

Measured memory_bytes: 45240
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >>s;
	// coffee
	if(s[2] == s[3] && s[4] == s[5]) {
		cout <<"Yes";
	}
	else {
		cout <<"No";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200010;
vector <int> e[N];
int read() {
	int ans = 0;
	char ch = getchar();
	while(ch > '9' || ch < '0') ch = getchar();
	while(ch >= '0' && ch <= '9') {ans = ans * 10 + ch -'0'; ch = getchar();}
	return ans;
}
char str[N];
int in[N][2];
bool vis[N];
queue <int> q;
int main() {
	int n = read() , m =read();
	scanf("%s" , str + 1);
	for(int i = 1 ; i <= m ; ++ i) {
		int x = read() , y = read();
		e[x].push_back(y);
		e[y].push_back(x);
		if(str[y] == 'A') ++ in[x][0];
		else ++ in[x][1];
		if(str[x] == 'A') ++ in[y][0];
		else ++ in[y][1];
	}
	int ans = n;
	for(int i = 1 ; i <= n ; ++ i)
		if(!in[i][0] || !in[i][1]) {
			q.push(i);
			-- ans;
			vis[i] = 1;
		}
	while(!q.empty()) {
		int x = q.front(); q.pop();
		auto l = e[x].begin() , r = e[x].end();
		for(auto i = l ; i != r ; ++ i) {
			if(vis[*i]) continue;
			if(str[x] == 'A')
				-- in[*i][0];
			else
				-- in[*i][1];
			if(!in[*i][0] || !in[*i][1]) {
				q.push(*i);
				-- ans;
				vis[*i] = 1;
			}
		}
	}
	if(ans) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 12544
import java.util.*;


public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextInt();
        }

        int t = f(a[0]);
        boolean ok = true;
        for (int i = 1; i < N; i++) {
            if (f(a[i]) != t) {
                ok = false;
                break;
            }
        }
        if (!ok) {
            System.out.println(0);
            return;
        }

        long l = 1;
        for (int i = 0; i < N; i++) {
            l = lcm(l, a[i]/2);
            if (l > M) {
                System.out.println(0);
                return;
            }
        }
        //System.out.println(lcm);

        System.out.println((M/l+1)/2);
    }

    private static long gcd(long a, long b) {
        if (a < b) {
            long tmp = a;
            a = b;
            b = tmp;
        }
        if (b == 0) {
            return a;
        }

        return gcd(b, a%b);
    }

    private static long lcm(long a, long b) {
        return a/gcd(a,b)*b;
    }

    private static int f(int x) {
        int ret = 0;
        while (x%2 == 0) {
            ret++;
            x /= 2;
        }

        return ret;
    }
}


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

int main() {
    ios_base::sync_with_stdio(0); cin.tie(NULL);
    
    int N, M;
    cin >> N >> M;
    int sum = 0;
    for (int i = 0; i < M; ++i) {
       int x;
        cin >> x;
        sum += x;
    }
    if (sum > N)
        cout << "-1" << endl;
    else
        cout << N - sum << endl;

    
    return 0;
}

Measured memory_bytes: 3656
#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;
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> oset;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
using ll = long long;

	
void test_case(){
	int n , m; cin >> n >> m;
	vector<int> h(n);
	vector<bool> ok(n,true);
	for(auto &x : h)
		cin >> x;
	while(m--){
		int a , b;
		cin >> a >> b;
		a--;b--;
		if(h[a] <= h[b])
			ok[a] = false;
		if(h[b] <= h[a])
			ok[b] = false;
	}
	int good = 0;
	for(int i = 0 ; i < n ; i++)
		if(ok[i])
			good++;
	cout<<good<<"\n";
}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int T=1;
	while(T--){
		test_case();
	}
	return 0;
}


Measured memory_bytes: 3680
package main

import (
	"fmt"
)

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	if H == 1 {
		fmt.Println(1)
	} else if W == 1 {
		fmt.Println(1)
	} else if (H*W)%2 == 0 {
		fmt.Println(H * W / 2)
	} else {
		fmt.Println(H*W/2 + 1)
	}
}


Measured memory_bytes: 512
x1, x2, x3, x4, x5 = map(int,input().split())
if (x1 == 0):
    print ("1")
elif (x2 == 0):
    print ("2")
elif (x3 == 0):
    print ("3")
elif (x4 == 0):
    print ("4")
elif (x5 == 0):
    print ("5")


Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define int long long
using namespace std;
int dp[100020][2];
int32_t main()
{
    string s,s1,s2;
    cin >> s;
    int n = s.length();
    int cnt1=0,cnt2=0;int t=0;
    for(int i=0;i<n;i++)
    {
        s1+=to_string(t);
        s2+=to_string(t^1);
        t=t^1;

    }
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]!=s1[i])cnt++;
        if(s[i]!=s2[i])cnt1++;
    }
    cout<<min(cnt,cnt1)<<"\n";
}


Measured memory_bytes: 768
// ayy
// ' lamo
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef long double ld; //CARE
typedef complex<ld> pt;
#define fi first
#define se second
#define pb push_back
const ld eps=1e-8;
const int inf=1e9+99;
const ll linf=1e18+99;
const int P=1e9+7;









int32_t main() {
	ll n,a,b; cin>>n>>a>>b;
	ll mn=a*(n-1)+b;
	ll mx=a+b*(n-1);
	if(mn>mx) return cout<<0<<endl,0;
	cout<<mx-mn+1<<endl;
}









Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize1
    }
    let v = vec![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];
    println!("{}", v[n]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

int panel[6][8][8];
int h,w,c;
int counting;
int maximum;
int ans;

void roll(int num,int x,int y,int a){
	int dx[]={0,0,-1,1};
	int dy[]={-1,1,0,0};

	int b=panel[num][y][x];
	panel[num][y][x]=a;
	if(a==0) counting++;
	for(int i=0;i<4;i++){
		int nextx=x+dx[i];
		int nexty=y+dy[i];
		if(nextx>=0&&nextx<w&&nexty>=0&&nexty<h&&panel[num][nexty][nextx]==b)
			roll(num,nextx,nexty,a);
	}
}
/*
int change(int num){
	int i,j;

	cout<<"colored times="<<num<<endl;

	if(num==4){
		roll(num+1,0,0,c);
		counting=0;
		roll(num+1,0,0,0);

		return counting;
	}else{

		int ii,jj;
		for(ii=0;ii<h;ii++){
			for(jj=0;jj<w;jj++){
				panel[num+1][ii][jj]=panel[num][ii][jj];
			}
		}
		int numsame;
		for(i=1;i<7;i++){
			if(panel[num][0][0]!=i){
				roll(num+1,0,0,i);
				cout << i << endl;
				for(ii=0;ii<h;ii++){
					for(jj=0;jj<w;jj++){
						cout<<panel[num+1][ii][jj];
					}
					cout<<endl;
				}
				for(ii=0;ii<h;ii++){
					for(jj=0;jj<w;jj++){
						panel[num+1][ii][jj]=panel[num][ii][jj];
					}
				}
				numsame=change(num+1);
				if(numsame>maximum) maximum=numsame;
				cout<<"numsame="<<numsame<<"\n max="<<maximum<<endl;
			}
		}
		return maximum;
	}
}*/

void cpyArray(int num){
	for(int j=0;j<h;j++){
		for(int k=0;k<w;k++){
			panel[num+1][j][k] = panel[num][j][k];
		}
	}
}

void change(int num){
	if(num==4){
		if(panel[num][0][0]==c) return;
		cpyArray(num);
		roll(num+1,0,0,c);
		counting = 0;
		roll(num+1,0,0,0);
		if(ans<counting){
			ans = counting;
		}
		return;
	}
	for(int i=1;i<7;i++){
		if(panel[num][0][0]==i)continue;
		cpyArray(num);
		roll(num+1,0,0,i);
		change(num+1);
	}
}

int main(){
	int i,j,k;
	int numsame;

	while(1){
		cin>>h>>w>>c;
		if(h==0&&w==0&&c==0)break;
		for(i=0;i<h;i++){
			for(j=0;j<w;j++){
				cin>>panel[0][i][j];
			}
		}
		maximum=1;
		ans = 0;
		change(0);

		cout<< ans <<endl;

	}

	return 0;
}

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

using namespace std;
using ll = long long;

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	ll now = 1;
	for (int len = 1;; len++) {
		now *= 26;
		if (n > now) {
			n -= now;
			continue;
		}
		n--;
		string ans = "";
		for (int i = 0; i < len; i++) {
			ans.push_back('a' + n % 26);
			n /= 26;
		}
		reverse(ans.begin(), ans.end());
		cout << ans;
		return 0;
	}
}

Measured memory_bytes: 3636
/*input
5
1 2 3 4 5
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;

#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
#define PI 3.14159265
#define endl '\n'
#define debug(x) cout << #x << " = " << x << endl;

template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
    int x = 1 % mod;
    while(b){
        if(b & 1) x = mul(x, a);
        a = mul(a, a);
        b >>= 1;
    }
    return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

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

  int r, g, b, n;
  cin >> r >> g >> b >> n;
  map <int, int> mp;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= n; j++) {
      mp[r * i + g * j]++;
    }
  }
  ll ans = 0;
  for (int i = 0; i <= n; i++) {
    ans += mp[n - (b * i)];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 260992
#include<bits/stdc++.h>
// iteration and input/output stream
#define rep(i,a,b) for(int i = int(a);i<=int(b);i++)
#define srep(i, begin, end) for (__typeof(end) i = begin; i != end; i++)
#define printarr(x) rep(i,0,x.size()-1) cout<<x[i]<<" "; cout<<endl;
#define all(v) v.begin(),v.end()
 
#define si(x) int x; scanf("%d", &x)
#define sll(x) ll x; scanf("%lld", &x)
#define pi(x) printf("%d", x)
#define pll(x) printf("%lld", x)
#define nl printf("\n")
#define tr(cont,it) \
for(decltype(cont.begin()) it = cont.begin(); it!= cont.end() ; it++)
 
#define endl "\n"
#define tc() int t; cin >> t ; while (t--)
//STL shortcuts
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define F first
#define S second
#define MP make_pair
 
// Error detection
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
 
using namespace std;
 
typedef long long int ll; // 64 bit integer
typedef unsigned long long int  ull; // 64 bit unsigned integer
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef pair<int,ll> pill;
 
inline void smax(int &x , int y) { x = max(x , y) ; }
inline void smin(int &x , int y) { x = min(x , y) ; }
 
#define MOD 1000000007
#define inf 4000000000000000000LL
#define SYNC std::ios::sync_with_stdio(false);  cin.tie(NULL);
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    freopen("err.txt","w",stderr);
    #endif
    SYNC
    int x;
    cin>>x;
    for(ll i =-1000;i<=1000;i++)
    {
        for(ll j=-1000;j<=1000;j++)
        {
            if(ll(pow(i,5))-ll((pow(j,5)))==x)
            {
                cout<<i<<" "<<j<<"\n";
                return 0;
            }
        }
    }
    
    return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL) 
#define ll long long 
#define int long long 
#define vll vector<long long>
#define pii pair<long long ,long long > 
#define vvi vector< vector<long long > > 
#define vpii vector<pair<int,int>> 
#define pll  pair<long long ,long long > 
#define pb  push_back
#define ff  first 
#define sec second  
#define SORT(a) sort(a.begin(),a.end())
#define SORTR(a) sort(a.rbegin(),a.rend()) 
#define m_p make_pair
#define all(x)   (x.begin(),x.end()) 
#define sz(v)     ((int)(v.size()))
#define INF 1e9+7
typedef vector< long long > vi ;
const int MOD=1e9 +7 ;
int size=10000000; 


int32_t main(){
	fast; 

	int x,y,z; 
	cin>>x>>y>>z; 

	cout<<z<<" "<<x<<" "<<y<<endl; 

	
	return 0; 

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        char c = s.charAt(s.length()-1);
        if (c=='2'||c=='4'||c=='5'||c=='7'||c=='9')
             System.out.println("hon");
        else if(c=='0'||c=='1'||c=='6'||c=='8')
             System.out.println("pon");
        else System.out.println("bon");
    }
}


Measured memory_bytes: 35616
#include <stdio.h>

int main(void)

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


	if ( (a < b) && (b < c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;

}

Measured memory_bytes: 1008
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		// TODO Auto-generated method stub
		String []w = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
		String s = stdIn.next();
		
		for(int i = 0; i < w.length; i++){
			if(s.equals(w[i])){
				System.out.println(7-i);
				System.exit(0);
			}
		}
		
		
		
	}

}


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

typedef long long ll;
typedef pair<ll, ll> P;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, n) for(int i = a; i < (n); i++)
#define mod (ll)(1e9+7)
#define int ll

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

signed main() {
	ll x, y, count;
  cin >> x >> y;
  while (x <= y) {
    x *= 2;
    count++;
  }
  cout << count << endl;
}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	string s; cin >> s;
	for (int i = 0; i < s.length(); i++) if (s[i] == '?') s[i] = 'D';
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<int> X(N);
  double sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> X.at(i);
    sum += X.at(i);
  }
  int memo = sum / N;
  double memo2;
  sum += 0.0;
  memo2 = sum / N;
  int ans;
  if (memo2 - memo > 0.5) {
    ans = memo + 1;
  }
  else {
    ans = memo;
  }
  int ans2 = 0;
  for (int i = 0; i < N; i++) {
    ans2 += (ans - X.at(i)) * (ans - X.at(i));
  }
  cout << ans2 << endl;
}
    

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7



int main() {

	int N, K;
	scanf("%d%d", &N, &K);

	ll ans = K;

	for (int i = 0; i < N - 1; i++) {
		ans *= K - 1;
	}

	printf("%lld", ans);










}


Measured memory_bytes: 256