akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner kb = new Scanner(System.in);
		int x1 = kb.nextInt();
		int x2 = kb.nextInt();
		int x3 = kb.nextInt();
		int x4 = kb.nextInt();
		int x5 = kb.nextInt();
		if (x1 == 0) {
			System.out.println(1);
		} else if (x2 == 0) {
			System.out.println(2);
		} else if (x3 == 0) {
			System.out.println(3);
		} else if (x4 == 0) {
			System.out.println(4);
		} else if (x5 == 0) {
			System.out.println(5);
		}
		kb.close();
	}

}


Measured memory_bytes: 27084
import math

N, K = map(int, input().split(' '))

def f(n):
	global K
	x = math.ceil(math.log(K/n, 2))
	if x < 0:
		x = 0
	if x > K:
		x = K
	return (0.5)**x

print('{:.10f}'.format(sum([f(n) for n in range(1, N+1)])/N))


Measured memory_bytes: 6216
arr = [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]

puts arr[gets.to_i - 1]

Measured memory_bytes: 1788
#include<cstdio>
#include<algorithm>
#include<cstring>
#define MN 4005
using namespace std;
typedef long long ll;
int n,a[200005],b[200005];
const int mod=1e9+7;
ll inv[MN<<1],fac[MN<<1],ans,f[MN][MN];
ll C(int x,int y){return fac[x]*inv[x-y]%mod*inv[y]%mod;}
int main(){
	fac[0]=fac[1]=inv[0]=inv[1]=1;
	for(int i=2;i<=8002;i++)fac[i]=fac[i-1]*i%mod,inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=2;i<=8002;i++)inv[i]=inv[i-1]*inv[i]%mod;scanf("%d",&n);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]),f[2001-a[i]][2001-b[i]]++;
	for(int i=1;i<=4002;i++)for(int j=1;j<=4002;j++)f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%mod;
	for(int i=1;i<=n;i++)ans=((ans+f[2001+a[i]][2001+b[i]]-C((a[i]+b[i])*2,b[i]*2)%mod)%mod+mod)%mod;
	printf("%lld\n",ans*inv[2]%mod);
}


Measured memory_bytes: 127104
# -*- coding: utf-8 -*-
n1 = int(input()) - 1
d = list(map(int, input().strip().split()))
mod = 998244353
if d[0] != 0 or 0 in d[1:]:
    print(0)
else:
    max_path = max(d)
    flag = True
    v = [0 for i in range(max_path)]
    for i in d[1:]:
        v[i-1] += 1

    if 0 in v:
        flag = False

    if flag:
        num = 1
        hh = 1

        def binpow(a, b):
            if b == 0:
                return 1
            elif a == 1:
                return 1
            elif b % 2 == 0:
                c = binpow(a, b // 2)
                return (c ** 2) % mod
            else:
                return (binpow(a, b - 1) * a) % mod


        for h in v:
            num *= binpow(hh, h)
            num = num % mod
            hh = h

        print(num)

    else:
        print(0)


Measured memory_bytes: 56812
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader s = new FastReader();
        long T = s.nextLong();
        long t =0;
        long amount=100;
        while(T>amount){
            amount*=Math.pow(1.01,1);
            t++;
        }
        System.out.println(t);
    }

    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

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

const double PI = 3.141592653589;

int main() {
	int n, a;
	int min = 10000000, max = -10000000;
	long long sum = 0;

	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> a;
		if (a < min){ min = a; }
		if (a > max){ max = a; }
		sum += a;
	}

	cout << min << " " << max << " " << sum << endl;

	return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <stdio.h>

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

typedef long long ll;

using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const double PI=3.14159265358979323846;

int main(){
  int H, A;
  cin >> H >> A;
  if(H%A!=0)
    cout << H/A+1 << endl;
  else
    cout << H/A << endl;
}


Measured memory_bytes: 256
import numpy as np
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n,m = map(int,input().split())
g=[[] for _ in range(n)]
for _ in range(m):
      x,y=map(int,input().split())
      g[x-1].append(y-1)
memo = [0]*n
visited = [False]*n
# dp(i):i=0,1,..,n-1:頂点iを始点とした最長のパスを返す
def dp(v):
      if visited[v]:
            return memo[v]
      else:
            res=0
            for u in g[v]:
                  res=max(res,dp(u)+1)
            memo[v]=res
            visited[v]=True
            return res
for i in range(n):
      dp(i)
print(max(memo))


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

const int NMAX = 10000;
const int AMAX = 9999999;

const int BLACK = 2;
const int GRAY = 1;
const int WHITE = 0;

vector<pair<int, int> > A[NMAX];
int c[NMAX];
int d[NMAX];
int n;

void dijkstra(int s) {
	for (int i = 0; i < n; i++) {
		c[i] = WHITE;
		d[i] = AMAX;
	}

	d[s] = 0;
	c[s] = GRAY;
	priority_queue<pair<int, int> > PQ;
	PQ.push(make_pair(d[s], s));

	while (!PQ.empty()) {
		pair<int, int> f = PQ.top(); PQ.pop();
		int minw, u;
		minw = f.first;
		u = f.second;

		c[u] = BLACK;

		if (d[u] < minw * (-1)) continue;

		for (int i = 0; i < A[u].size(); i++) {
			int v = A[u][i].first;
			int w = A[u][i].second;
			if (c[v] == BLACK) continue;

			if (d[v] > d[u] + w) {
				d[v] = d[u] + w;
				PQ.push(make_pair(d[v] * (-1), v));
				c[v] = GRAY;
			}
		}
	}
}

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

	for (int i = 0; i < n; i++) {
		int u, k;
		scanf("%d %d", &u, &k);

		for (int j = 0; j < k; j++) {
			int v, c;
			scanf("%d %d", &v, &c);
			A[u].push_back(make_pair(v, c));
		}
	}

	dijkstra(0);

	for (int i = 0; i < n; i++) {
		printf("%d %d\n", i, d[i]);
	}

	return 0;
}



Measured memory_bytes: 8088
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define sz size
#define eps 1e-7
#define fod find_by_order
#define fastio ios::base_sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ofk order_of_key
#define val(x) cout << "Value dari "<< #x << " adalah " << x  << "\n"
#define tr tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
typedef long long ll;
using namespace __gnu_pbds;
using namespace std;

void readf(string x){
	freopen((x+".in").c_str(),"r",stdin);
	freopen((x+".out").c_str(),"w",stdout);
}


int read()
{
	bool min = 0;
	int  result = 0;
	char ch;
	ch = getchar();
	while(1)
	{
		if(ch == '-') break;
		if(ch >='0' && ch <= '9') break;
		ch = getchar();
	}
	if(ch == '-') min = 1;else result = ch-'0';
	while(1)
	{
		ch =getchar();
		if(ch< '0' || ch>'9') break;
		result = result * 10 + (ch-'0');
	}
	if(min) return -result;
	return result;
}

int main(){
	ll N,T;
	cin >> N >> T;
	ll ans = 0,maks = -1;
	for(int i=1;i<=N;i++){
		int a;
		cin >> a;
		if(a > maks ){
			maks = a + T;
			ans = ans + T;
		}
		else{
			ans += a + T - maks;
			maks = a + T;
		}
	}
	cout << ans << "\n";
}


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

int main(){
    int n, q;
    cin >> n >> q;

    queue<pair<string,int>> queue;
    rep(i,n){
        string n;
        int t;
        cin >> n >> t;
        queue.push(make_pair(n,t));
        //cout << queue.front().first << endl;
    }

    int time = 0;
    while(!queue.empty()){
        if(queue.front().second <= q){
            time += queue.front().second;
            cout << queue.front().first << " " << time << endl;
        }
        else
        {
            time += q;
            queue.front().second -= q;
            queue.push(queue.front());

        }
        queue.pop();        
    }

    return 0;
}


Measured memory_bytes: 6276
#include <bits/stdc++.h>
#include <map> // pair
using namespace std;
int main(){
  int N;
  cin>>N;
  vector<int> H(N);
  int ans=0;
  for(int i=0;i<N;i++){
    cin>>H.at(i);
    int flag = 0;
    for(int j=0;j<i;j++){
      if(H.at(j)>H.at(i))flag++;
    }
    if(flag==0)ans++;
    flag=0;
  }
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include<stdio.h>

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

   int tmp = a;
   a=b;
   b=tmp;

   tmp=a;
   a=c;
   c=tmp;

   printf("%d %d %d\n",a,b,c);
   return 0;
}


Measured memory_bytes: 1708
<?php

function dfs($first, $last) {
    if (count($last) === 0) {
        return [$first];
    }

    $res = [];
    foreach ($last as $key => $val) {
        $next_f = $first;
        $next_l = $last;

        $next_f[] = $val;
        array_splice($next_l, $key, 1);
        $res = array_merge($res, dfs($next_f, $next_l));
    }

    return $res;
}

function next_permutation($start, $end) {
    return dfs([], range($start, $end));
}

fscanf(STDIN, "%d", $n);
$x_arr = [];
$y_arr = [];
for ($i = 0; $i < $n; ++$i) {
    $inputs = explode(' ', trim(fgets(STDIN)));
    $x_arr[] = $inputs[0];
    $y_arr[] = $inputs[1];
}

$perms = next_permutation(1, $n);

$sum = 0;
foreach ($perms as $perm) {
    for ($i = 0; $i < $n - 1; ++$i) {
        $a = $perm[$i] - 1;
        $b = $perm[$i + 1] - 1;

        $sum += sqrt(
            pow($x_arr[$a] - $x_arr[$b], 2)
            + pow($y_arr[$a] - $y_arr[$b], 2)
        );
    }
}

function factorial($n) {
    if ($n === 1) {
        return 1;
    }

    return $n * factorial($n - 1);
}


echo $sum / factorial($n);


Measured memory_bytes: 23416
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define uint unsigned
#define db long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define IT iterator
 
#define PB push_back
#define MK make_pair
#define LB lower_bound
#define UB upper_bound
#define EB emplace_back
#define fi first
#define se second
 
#define For(i,j,k) for (int i=(int)(j);i<=(int)(k);i++)
#define Rep(i,j,k) for (int i=(int)(j);i>=(int)(k);i--)
#define UPD(x,y) (((x)+=(y))>=mo?x-=mo:233)
#define CLR(a,v) memset(a,v,sizeof(a));
#define CPY(a,b) memcpy(a,b,sizeof(a));
 
#define LS3 k*2,l,mid
#define RS3 k*2+1,mid+1,r
#define LS5 k*2,l,mid,x,y
#define RS5 k*2+1,mid+1,r,x,y
#define GET pushdown(k);int mid=(l+r)/2
 
#define INF ((1ll<<60)-233)
#define sqr(x) ((x)*(x))
#define debug puts("wzpkking")
using namespace std;
const int mo=1000000007;
int n,m,t,cnt;
int a[100005],b[100005];
pii q[100005];
map<int,int> mp;
bool cmp(pii a,pii b){
	if (a.fi!=b.fi) return a.fi<b.fi;
	return a.se>b.se;
}
void change(int x,int v){
	for (;x<1e9+5;x+=x&(-x)) UPD(mp[x],v);
}
int ask(int x){
	int ans=0;
	for (;x;x-=x&(-x)) UPD(ans,mp[x]);
	return ans;
}
int main(){
	scanf("%d%d",&n,&m);
	For(i,1,n) scanf("%d",&a[i]);
	For(i,1,m) scanf("%d",&b[i]);
	For(i,1,n){
		for (;t<m&&b[t+1]<=a[i];t++);
		if (t>=1&&t<m&&a[i]!=b[t]&&a[i]!=b[t+1])
			q[++cnt]=pii(a[i]-b[t],b[t+1]-a[i]);
	}
	sort(q+1,q+cnt+1,cmp);
	change(1,1);
	For(i,1,cnt)
		if (i==1||q[i]!=q[i-1])
			change(q[i].se+1,ask(q[i].se));
	printf("%d",ask(1e9+5));
}

Measured memory_bytes: 55040
from operator import itemgetter, attrgetter

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

pym = [None] * m
for i in range(m):
    pym[i] = [i] + list(map(int, input().split(' ')))

pyms = sorted(pym, key=itemgetter(1, 2))

x = 1
pyms[0].append(x)

for i in range(1, m):
    if pyms[i - 1][1] != pyms[i][1]:
        x = 1
    else:
        x += 1
    pyms[i].append(x)
    
pym = sorted(pyms, key=itemgetter(0, ))

for i in range(m):
    city_id = str(pym[i][1]).zfill(6) + str(pym[i][3]).zfill(6)
    print(city_id)


Measured memory_bytes: 37512
N, Y = map(int, input().split())
flag = False

for i in range(0, N+1):  # 10000
    for j in range(0, N+1-i):  # 5000
        if 10000*i + 5000*j + 1000*(N-i-j) == Y:
            print(i, j, N-i-j)
            flag = True
            break
    if flag:
        break
else:
    if not flag:
        print("-1 -1 -1")


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

using namespace std;

#define int long long
#define pb push_back
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)

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

  int i=0;
  while(1) {
    if(s[i] == '1') {
      if(i+1 == k) {
        cout << 1 << endl;
        break;
      } else {
        i++;
      }
    } else {
      cout << s[i] << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
N, M, K = map(int,input().split())
if K%N==0 or K%M==0:
    print("Yes")
    exit()

for n in range(1,N):
    for m in range(1,M):
        if n*m + (N-n)*(M-m) == K:
            print("Yes")
            exit()
print("No")


Measured memory_bytes: 2940
# include <cstdio>
# include <iostream>
# include <algorithm>
using namespace std;
long long n,m;

int main () {
	scanf ("%lld%lld",&n,&m);
	if (n>=m) printf ("%lld\n",m/2);
	else printf ("%lld\n",n+(m-2*n)/4);
	return 0;
}
//By苍空的蓝耀


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll b[500000];
ll compute(ll n)
{
     return (n*(n-1))/2;
}
int main()
{
     ll i,j,n,sum=0;
     cin>>n;

     ll a[n];

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

     }
     for(i = 0; i < n+1; i++)
     {
          sum+=compute(b[i]);
     }
     for(i = 0; i < n; i++)
     {
          //cout<<b[a[i]]<<endl;
          cout<<sum-b[a[i]]+1<<endl;
     }

}


Measured memory_bytes: 4736
import sys
input=sys.stdin.readline
INF = 10**9

def main():
    d,g=map(int,input().split())
    P=[list(map(int,input().split())) for _ in range(d)]
    
    ans=INF
    for bit in range(1<<d):
        score=0
        p=0
        cnt=0
        for i in range(d):
            if (bit>>i)&1:
                score += P[i][0]*100*(i+1)+P[i][1]
                cnt += P[i][0]
            else:
                p = i
       
        if score >= g:
            ans=min(ans,cnt)
        
        else:
            for i in range(P[p][0]-1):
                score += 100*(p+1)
                cnt +=1
                if score >= g:
                    ans=min(ans,cnt)
                    break
    print(ans)
  
if __name__=='__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
using namespace std;
#define ll long long


int main() {
	int n, h[100010];
	bool flag = false;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}
  	h[0]--;
	for (int i = 1; i < n; i++) {
		if (h[i] > h[i - 1])h[i]--;
		if (h[i] < h[i - 1]) {
			flag = true;
			break;
		}
	}
	if (flag)cout << "No" << endl;
	else cout << "Yes" << endl;
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
int x, y, i, j;
int main(){
    scanf("%d %d",&x ,&y );
    while(!(x==0 && y==0)){
        for (i=1;i<=x;i++){
            for(j=1;j<=y;j++){
            	if ((i+j)%2==0){
                printf("#");}
                else{
                	printf(".");
				}
            }
            printf("\n");
        }
        printf("\n");
        scanf("%d %d",&x ,&y );
    }
}


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

using namespace std;
int a[30][30],b[30];

int main()
{
    int n,m,c;  cin >> n >> m >> c;
    for(int i = 0;i<m;i++)  cin >> b[i];
    for(int i = 0;i<n;i++){
        for(int j = 0;j<m;j++){
            cin >> a[i][j];
        }
    }
    int Ans = 0;
    for(int i = 0;i<n;i++){
        int Res = 0;
        for(int j = 0;j<m;j++){
            Res+=a[i][j] * b[j];
        }
        if(Res + c > 0)  Ans++;
    }
    cout << Ans;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAXN=1e6+5;
int tab[MAXN];

int main(){
    ios::sync_with_stdio(0);
    cout.tie(0);
    cin.tie(0);
    int a,b,c;
    cin >> a >> b >> c;
    cout << (a+b>=c ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
int MIN(int a,int b){return a<b?a:b;}
int main(){
  int n,m,i,j,h[100010],d[100010]={};
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++)scanf("%d",&h[i]);
  for(i=1;i<n;i++)d[i]=1e9;
  for(i=0;i<n;i++){
    for(j=0;j<m&&i+j+1<n;j++)d[i+j+1]=MIN(d[i+j+1],d[i]+abs(h[i]-h[i+j+1]));
  }
  printf("%d\n",d[n-1]);
  return 0;
}


Measured memory_bytes: 896
class Dice{
     
public:
    Dice(int top, int front, int right,
         int left, int back, int bottom); 
    int get_right();
    void roll_topfront(int top, int front);
    void roll(char r);
     
private:
     
    void roll_top(int top);
    void roll_front(int front);
    void roll_n();
    void roll_e();
    void roll_s();
    void roll_w();
    int m_top;
    int m_front;
    int m_right;
    int m_left;
    int m_back;
    int m_bottom;
    void show_all();
};
 
#include <iostream>
#include <vector>
using namespace std;
typedef vector<int> Dice_bec;
 
int main(void)
{
    Dice_bec dice_bec;
    int num;
    int q; 
     
    for(int i = 0; i < 6; i++){
        cin >> num;
        dice_bec.push_back(num);
    }
    cin >> q;
     
     
    Dice dice(dice_bec[0], dice_bec[1], dice_bec[2],
              dice_bec[3], dice_bec[4], dice_bec[5]);
               
     
    for(int i = 0; i < q; i++){
         
        int top, front;
        cin >> top
            >> front;
        dice.roll_topfront(top, front);
         
        cout << dice.get_right() << endl;
    }
     
    return 0;
     
}
 
Dice::Dice(int top, int front, int right,      
           int left, int back, int bottom) :
           m_top(top), m_front(front), m_right(right),
           m_left(left), m_back(back), m_bottom(bottom)
{
    
}
 
 
void Dice::roll_topfront(int top, int front)
{
    roll_front(front);
    roll_top(top);
}
 
void Dice::roll_front(int front)
{
    if(front == m_front){
    }
    //????????¢
    else if(front == m_top){
        roll_s();
    }
    else if(front == m_back){
        for(int i = 0; i < 2; i++){
            roll_s();
        }
    }
    else if(front == m_bottom){
        roll_n();
    }
    //?¨??????¢
    else if(front == m_right){
        roll_w();
        roll_s();
    }
    else if(front == m_left){
        roll_e();
        roll_s();
    }
}
 
void Dice::roll_top(int top)
{
    while(top != m_top){
        roll_e();
    }
     
}
 
void Dice::roll_n()
{
    int temp = m_back;
     
    m_back   = m_top;
    m_top    = m_front;
    m_front  = m_bottom;
    m_bottom = temp;
     
}
void Dice::roll_e()
{
    int temp = m_top;
     
    m_top    = m_left;
    m_left   = m_bottom;
    m_bottom = m_right;
    m_right  = temp;
     
}
 
void Dice::roll_s()
{
    int temp = m_front;
     
    m_front  = m_top;
    m_top    = m_back;
    m_back   = m_bottom;
    m_bottom = temp;
}
 
void Dice::roll_w()
{
    int temp = m_left;
     
    m_left   = m_top;
    m_top    = m_right;
    m_right  = m_bottom;
    m_bottom = temp;
}
 
int Dice::get_right()
{
    return m_right;
}
 
 
void Dice::show_all()
{
    cout << m_top << ' '
         << m_front << ' '
         << m_right<< ' '
         << m_left << ' '
         << m_back << ' '
         << m_bottom << ' ' << endl;
}
 
void Dice::roll(char r)
{
    switch(r){
    case 'N' :
         roll_n();
         break;
    case 'E' :
         roll_e();
         break;
    case 'S' :
         roll_s();
         break;
    case 'W' :
         roll_w();
         break;
    }
}


Measured memory_bytes: 3136
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    unused_imports,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::{fastout, input, marker::*};
use std::collections::*;
//use std::cmp::*;
//use std::num;
//use petgraph::unionfind::UnionFind;

#[fastout()]
fn main() {
    input! {
        N:usize,M:usize,
        PY:[(Usize1,usize);M]
    }
    let mut maps = vec![BTreeMap::new(); N];
    for (c, &(p, y)) in PY.iter().enumerate() {
        maps[p].insert(y, c);
    }
    let mut ans = vec![String::new(); M];
    for i in 0..maps.len() {
        for (j, (&y, &c)) in maps[i].iter().enumerate() {
            ans[c] = format!("{:>06}{:>06}", i + 1, j + 1);
        }
    }
    for i in 0..ans.len() {
        println!("{}", ans[i]);
    }
}


Measured memory_bytes: 33324
class MyQueue(object):
    """
    My Queue class

    Attributes:
        queue: queue
        head
        tail
    """

    def __init__(self):
        """Constructor
        """
        self.length = 50010
        self.queue = []
        counter = 0
        while counter < self.length:
            self.queue.append(Process())
            counter += 1
        self.head = 0
        self.tail = 0

    def enqueue(self, name, time):
        """enqueue method

        Args:
            name: enqueued process name
            time: enqueued process time

        Returns:
            None
        """
        self.queue[self.tail].name = name
        self.queue[self.tail].time = time
        self.tail = (self.tail + 1) % self.length

    def dequeue(self):
        """dequeue method

        Returns:
            None
        """
        self.queue[self.head].name = ""
        self.queue[self.head].time = 0
        self.head = (self.head + 1) % self.length

    def is_empty(self):
        """check queue is empty or not

        Returns:
            Bool
        """
        if self.head == self.tail:
            return True
        else:
            return False

    def is_full(self):
        """chech whether queue is full or not"""
        if self.tail - self.head >= len(self.queue):
            return True
        else:
            return False


class Process(object):
    """process class
    """

    def __init__(self, name="", time=0):
        """constructor
        Args:
            name: name
            time: time
        """
        self.name = name
        self.time = time

    def forward_time(self, time):
        """time forward method

        Args:
            time: forward time interval

        Returns:
            remain time

        """
        self.time -= time
        return self.time


def time_forward(my_queue, interval, current_time):
    """

    Args:
        my_queue: queue
        interval: time step interval
        current_time: current time
    """

    value = my_queue.queue[my_queue.head].forward_time(interval)
    if value <= 0:
        current_time += (interval + value)
        print my_queue.queue[my_queue.head].name, current_time
        my_queue.dequeue()

    elif value > 0:
        current_time += interval
        name, time = my_queue.queue[my_queue.head].name, \
                     my_queue.queue[my_queue.head].time
        my_queue.dequeue()
        my_queue.enqueue(name, time)

    return current_time


my_queue = MyQueue()
n, q = [int(x) for x in raw_input().split()]
counter = 0
while counter < n:
    name, time = raw_input().split()
    my_queue.enqueue(name, int(time))
    counter += 1

current_time = 0
while not my_queue.is_empty():
    current_time = time_forward(my_queue, q, current_time)

Measured memory_bytes: 26500
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <vector>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>
#include <unordered_set>
#include <stack>
#include <iomanip>
using namespace std;

#define ii pair<int, int>

int n, m, k;
vector<int> adj[100005];
ii block[100005];
int compo[100005], sz[100005], ans[100005];

void dfs(int u, int c) {
    compo[u] = c;
    sz[c]++;
    for(int i=0; i<adj[u].size(); i++) {
        int v = adj[u][i];
        if(compo[v]==-1)
            dfs(v, c);
    }

}

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

    cin >> n >> m >> k;
    for(int i=0; i<m; i++) {
        int a, b;
        cin >> a >> b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    for(int i=0; i<k; i++) {
        int c, d;
        cin >> c >> d;
        block[i] = {c, d};
    }
    for(int i=1; i<=n; i++)
        compo[i] = -1;
    memset(sz, 0, sizeof(sz));
    int c = 0;
    for(int i=1; i<=n; i++)
        if(compo[i]==-1) {
            c++;
            dfs(i, c);
        }
    for(int i=1; i<=n; i++)
        ans[i] = sz[compo[i]]-adj[i].size()-1;
    for(int i=0; i<k; i++) {
        int u = block[i].first, v = block[i].second;
        if(compo[u]==compo[v]) {
            ans[u]--;
            ans[v]--;
        }
    }
    for(int i=1; i<=n; i++)
        cout << ans[i] << " ";
    cout << "\n";

    return 0;
}

Measured memory_bytes: 9088
import java.util.Scanner;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int N = sc.nextInt();
   int X = sc.nextInt();
   String  ans ="No";
   if(500*N>=X) ans ="Yes";
       
     System.out.println(ans);
 }
}

Measured memory_bytes: 21460
/*
 * FileName:     model
 * CreatedDate:  2020-07-11 15:15:43 +0900
 * LastModified: 2020-07-11 15:23:37 +0900
 */

#include <stdio.h>

int main(void){
    int n;scanf("%d", &n);
    printf("%d:", n);
    for(int i=2;i*i<=n;i++){
        if(n%i==0){
            printf(" %d",i);
            n/=i--;
        }
    }
    printf(n==1?"\n":" %d\n",n);
    return 0;
}



Measured memory_bytes: 2148
import numpy as np
from scipy.sparse.csgraph import floyd_warshall
import itertools


def main():
    N, M, R = list(map(int, input().split(' ')))
    towns = list(map(lambda t: int(t) - 1, input().split(' ')))
    A = np.zeros((N, N), dtype=int)
    for _ in range(M):
        a, b, c = list(map(int, input().split(' ')))
        A[a-1][b-1] = c
        A[b-1][a-1] = c
    fw = floyd_warshall(A)
    d = fw[towns, :][:, towns]
    min_d = 10**12
    for trip in itertools.permutations(range(R)):
        min_d = min([min_d, sum([d[trip[i]][trip[i+1]] for i in range(len(trip) - 1)])])
    print(int(min_d))


if __name__ == '__main__':
    main()

Measured memory_bytes: 16380
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,p,sum=0,maxv=0;
  cin>>n;
  for(int i=0; i<n; i++){
    cin>>p;
    sum+=p;
    maxv=max(maxv,p);
  }
  sum=sum-maxv/2;
  cout<<sum<<'\n';
  return 0;
}


Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
while True:
    k = min(a)
    i = 0
    while i < len(a):
        if a[i] % k == 0:
            del a[i]
        else:
            a[i] = a[i] % k
            i += 1
    a.append(k)
    if len(a) == 1:
        print(min(a))
        exit()
print(min(a))


Measured memory_bytes: 14252
#include<stdio.h>
int main(int argc, char const *argv[])
{
  int A, B, C;
  long long int K, ans;
  scanf("%d%d%d%lld", &A, &B, &C, &K);
  if (K % 2)
  {
    ans = B - A;
  }else
  {
    ans = A - B;
  }
  printf("%lld\n",ans);
}


Measured memory_bytes: 128
def main():
    s = int(input())
    arr = [s]
    while True:
        tmp = 0
        if arr[-1] % 2 == 0:
            tmp = arr[-1] // 2
        else:
            tmp = arr[-1] * 3 + 1

        if tmp in arr:
            break
        arr.append(tmp)
    print(len(arr)+1)


main()

Measured memory_bytes: 2940
from collections import deque,defaultdict,Counter
from heapq import heapify,heappop,heappush,heappushpop
from copy import copy,deepcopy
from itertools import product,permutations,combinations,combinations_with_replacement
from bisect import bisect_left,bisect_right
from math import sqrt,gcd,ceil,floor,factorial
# from fractions import gcd
from functools import reduce
from pprint import pprint
from statistics import mean,median,mode
import sys
sys.setrecursionlimit(10 ** 6)

INF = float("inf")

def mycol(data,col):
    return [ row[col] for row in data ]

def mysort(data,col,reverse=False):
    data.sort(key=lambda x:x[col],reverse=revese)
    return data

def mymax(data):
    M = -1*float("inf")
    for i in range(len(data)):
        m = max(data[i])
        M = max(M,m)
    return M

def mymin(data):
    m = float("inf")
    for i in range(len(data)):
        M = min(data[i])
        m = min(m,M)
    return m

def mycount(ls,x):
    # lsはソート済みであること
    l = bisect_left(ls,x)
    r = bisect_right(ls,x)
    return (r-l)

def mydictvaluesort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[1] )

def mydictkeysort(dictionary):
    return sorted( dictionary.items(), key=lambda x:x[0] )

def myoutput(ls,space=True):
    if space:
        if len(ls)==0:
            print(" ")
        elif type(ls[0])==str:
            print(" ".join(ls))
        elif type(ls[0])==int:
            print(" ".join(map(str,ls)))
        else:
            print("Output Error")
    else:
        if len(ls)==0:
            print("")
        elif type(ls[0])==str:
            print("".join(ls))
        elif type(ls[0])==int:
            print("".join(map(str,ls)))
        else:
            print("Output Error")

def I():
    return int(input())

def MI():
    return map(int,input().split())

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

def CI(n):
    return [ int(input()) for _ in range(n) ]

def LI(n):
    return [ list(map(int,input().split())) for _ in range(n) ]

def S():
    return input()

def MS():
    return input().split()

def RS():
    return list(input())

def CS(n):
    return [ input() for _ in range(n) ]

def LS(n):
    return [ list(input()) for _ in range(n) ]

# ddict = defaultdict(lambda: 0)
# ddict = defaultdict(lambda: 1)
# ddict = defaultdict(lambda: int())
# ddict = defaultdict(lambda: list())
# ddict = defaultdict(lambda: float())

n = I()
mod = 10**9 + 7
ans = factorial(n)%mod
print(ans)

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

using namespace std;

using ll = long long;
constexpr int inf = 1<<30;
constexpr int mo = 1e9+7;
constexpr ll infl = 1ll<<60;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n,k;
    ll s;cin>>n>>k>>s;
    vector<ll> ret(n);
    for(int i=0;i<k;++i)ret[i] = s;
    for(int i=k;i<n;++i){
        if(s < 1000000000ll) ret[i] = s+1;
        else ret[i] = s-1;
    }
    
    for(int i=0;i<n;++i){
        if(i)cout << " ";
        cout << ret[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<cstring>
using namespace std;

int n, W;
int v[100], w[100];
long long dp[101][100001] = { 0 };
const long long INF = 1LL << 60;

int main()
{
	cin >> n >> W;
	for (int i = 0; i < n; i++) {
		cin >> w[i] >> v[i];
	}

	for (int i = 0; i < 101; i++) {
		for (int j = 0; j < 100001; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 100001; j++) {
			if (j < v[i])
				dp[i + 1][j] = dp[i][j];
			else {
				dp[i + 1][j] = min(dp[i][j], dp[i][j - v[i]] + w[i]);
			}
		}
	}
	long long ans;
	for (int i = 0; i < 100001; i++) {
		if (dp[n][i] <= W) {
			ans = i;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 79104
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
typedef long long ll;
using namespace std;
const int INF = 2e9;
int n, plus_cnt, minus_cnt; 
ll K;
auto nC2 = [](ll a) { return a*(a-1)/2; };
vector<ll> Po,Ne;

ll calc_count(ll X, vector<ll> &V, vector<ll> &W, bool posi) {
  ll ret = 0ll;
  // t以上のものはWに何個あるかを求める
  rep(i, V.size()) {
    ll t = (X+V[i]-1)/V[i];
    int idx = lower_bound(ALL(W), t)-W.begin();
    if (posi && i>=idx) ret += W.size()-i-1;
    else ret+=W.size()-idx;
  }
  return ret;
} 


int main() {
  INCANT;
  cin >> n >> K;
  ll a;
  rep(i, n) {
    cin >> a;
    if (a<0) Ne.push_back(-a); // 便宜上正にする
    else if (a>0) Po.push_back(a);
  }
  plus_cnt = Po.size();minus_cnt = Ne.size();
  sort(ALL(Ne)); sort(ALL(Po));
  ll negative_count = Ne.size()*Po.size();
  ll positive_count = nC2(Po.size())+nC2(Ne.size());

  if (negative_count<K && K < nC2(n)-positive_count) {
    cout << 0 << "\n";
    return 0;
  }

  ll ok = 0ll;
  ll ng = 1e18;
  ll base;
  while(ng-ok>1ll) {
    ll mid = (ok+ng)/2;
    ll r;
    if (K<=negative_count) {
      r = calc_count(mid, Ne,Po, false);
      base =K-1;
    } else if ( K >= nC2(n)-positive_count ) {
      r = calc_count(mid, Ne, Ne, true)+calc_count(mid,Po, Po, true);
      base = nC2(n)-K;
    }
    if (r<=base) ng = mid;
    else ok = mid;
  } 
  if (negative_count>=K) ok *= -1;

  cout << ok << "\n";
  return 0;
}


Measured memory_bytes: 2420
#include <iostream>
#include <string>
using namespace std;
int main(){
	string str;
	int a=0,c=0,i,s;

	while(cin >> str){
		s=str.size();
		for(i=0;i<s;i++){
			if(s==1){
				a=1;
				break;
			}else if(str[i]!=str[s-i-1]){
				a=0;
				break;
			}else{
				a=1;
			}
		}
		if(a){
			c++;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1184
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> pippi;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<61;
int iinf=1<<30;
double pi=3.141592653589793238462643383279L;
double eps=1e-8;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto& itr:mp)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
//#define endl "\n"
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<int,int,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    if(k<0)return 0;
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}


int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll dp[d+1][c+1];
    memset(dp,0,sizeof dp);
    dp[b][a]=1;
    rep(i,b+1,d+1){
        ll sum=0;
        rep(j,a,c+1){
            dp[i][j]=(sum+dp[i-1][j]*j)%mod2;
            (sum*=(i-1))%=mod2;
            (sum+=dp[i-1][j]*(i-1))%=mod2;
        }
    }
    /*rep(i,0,d+1){
        rep(j,0,c+1)cout<<dp[i][j]<<" ";
        cout<<endl;
    }*/
    ll ans=0;
    rep(i,a,c+1){
        ll now=dp[d][i]*beki(d,c-i,mod2)%mod2;
        (ans+=now)%=mod2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 73904
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a, b;
  cin >> a >> b;
  cout << (a - 1) * (b - 1) << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) {}
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if(par[x] < 0)
            return x;
        else
            return par[x] = root(par[x]);
    }

    bool issame(int x, int y) { return root(x) == root(y); }

    bool merge(int x, int y) {
        x = root(x);
        y = root(y);
        if(x == y)
            return false;
        if(par[x] > par[y])
            swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) { return -par[root(x)]; }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for(int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        uf.merge(a, b);
    }
    int ans = -INF;
    for(int i = 0; i < n; i++) {
        chmax(ans, uf.size(i));
    }
    cout << ans << endl;
}

Measured memory_bytes: 3988
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a,b,c,d;
	cin >> a >> b >> c >> d;
	while(1) {
		c-=b;
		if(a<=0) {
			cout << "No";
			return 0;
		}
		a-=d;
		if(c<=0) {
			cout << "Yes";
			return 0;
		}
	}
	return 0;
}



Measured memory_bytes: 3652
'''
Created on 2020/08/19

@author: harurun
'''
def main():
  import re
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write
  
  S=pin()[:-1]
  if re.fullmatch("A{0,1}KIHA{0,1}BA{0,1}RA{0,1}",S)==None:
    print("NO")
  else:
    print("YES")
  return 

main()

Measured memory_bytes: 9960
def selectionSort(A,N):
    n_swap = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if A[j] < A[minj]:
                minj = j
        if minj != i:
            A[i], A[minj] = A[minj], A[i]
            n_swap += 1
    return n_swap, A

def run():
    n = int(input())
    a = list(map(int, input().split()))
    c, a = selectionSort(a,n)
    print(' '.join([str(i) for i in a]))
    print(c)

if __name__ == '__main__':
    run()


Measured memory_bytes: 5608
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;
const int INF = 1001001001;

int main(void){
  ll n;
  cin >> n;
  ll a, b; 
  for(ll i = 1; i*i <= n; i++){
    if(n%i) continue;
    a = i;
    b = n/i;
  }
  auto keta = [](ll m){
    ll ret = 0;
    while(m != 0){
      m /= 10;
      ret++;
    }
    return ret;
  };
  cout << max(keta(a), keta(b)) << endl;
  return 0;
}

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

using namespace std;

string s;

int ans,l,r,n,k,cnt;

int main()
{
	cin>>n>>k>>s;
	for(;r < s.size();r++){
		if(s[r]=='0'){
			if(r==0 || s[r-1]=='1') 
                cnt++;
		}
		if(cnt > k){
			while(l < s.size() && s[l]=='1') 
                l++;
			while(l < s.size() && s[l]=='0') 
                l++;
			cnt--;
		}
		ans=max(ans,r-l+1);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(){
  int n, u, k, v;
  int i, j;
  int g[101][101];

  scanf("%d", &n);

  for(i = 0; i <= n; i++){
    for(j = 0; j <= n; j++){
      g[i][j] = 0;
    }
  }

  for(i = 1; i <= n; i++){
    scanf("%d", &u);
    scanf("%d", &k);

    for(j = 1; j <= k; j++){
      scanf("%d", &v);

      g[u][v] = 1;
    }
  }

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      printf("%d", g[i][j]);

      if(j != n) printf(" ");
    }

    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2088
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
using namespace std;
int C[3];
int main(){
    cin >> C[0] >> C[1] >> C[2];
    sort(C,C+3);
    if(C[0]==5){
        if(C[1]==5){
            if(C[2]==7){
                cout << "YES\n";
                return 0;
            }
        }
    }
    cout << "NO\n";
}

Measured memory_bytes: 3520
fn main() {
  let (x, a) = {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut ws = s.split_whitespace();
    let a: i64 = ws.next().unwrap().parse().unwrap();
    let b: i64 = ws.next().unwrap().parse().unwrap();
    (a, b)
  };

  print!("{}", if x < a {0} else {10});
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1LL<<62;
const int MAX = 1e5;

int main() {
    int a, b, c, d, e, f;
    cin >> a >> b >> c;
    cin >> d >> e >> f;
    double concent = -1;
    int ans_l, ans_r;
    for (int w = 0; 100*a*w <= f; w++) {
        for (int x = 0; 100*b*x <= f; x++) {
            for (int y = 0; c*y <= (a*w+b*x)*e; y++) {
                for (int z = 0; d*z <= (a*w+b*x)*e; z++) {
                    if (100*a*w+100*b*x+c*y+d*z > f) continue;
                    if (c*y+d*z > (a*w+b*x)*e) continue;
                    int water = 100*a*w + 100*b*x;
                    int sugar = c*y + d*z;
                    if (chmax(concent,(double)sugar/(water+sugar))) {
                        ans_l = water+sugar;
                        ans_r = sugar;
                    }
                }
            }
        }
    }
    if (concent != -1) cout << ans_l << " " << ans_r << endl;
    else cout << f << " " << 0 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
int n,H,d,sum=0,kk=0;
vector<int>t;
struct Node
{
	int a,b,id;
}k[100010];
bool cmp(Node n1,Node n2)
{
	return n1.a>n2.a;
}
int main()
{
	scanf("%d%d",&n,&H);
	for(int i=1;i<=n;i++)
	{
		k[i].id=i;
		scanf("%d%d",&k[i].a,&k[i].b);
	}
	sort(k+1,k+n+1,cmp);
	d=k[1].a;
	for(int i=1;i<=n;i++)
		if(k[i].b>d){sum+=k[i].b;kk++;t.push_back(k[i].b);}
	int ans=0;
	if(H-sum>0)
	{
		int tt=(H-sum)/d;
		if((H-sum)%d) tt++;
		ans+=tt;
		H-=tt*d;
	}
	sort(t.begin(),t.end(),greater<int>() );
	for(int i=0;i<t.size();i++)
	{
		if(H<=0) break;
		ans++;
		H-=t[i];
	}
	printf("%d\n",ans);

//	system("pause");
}

Measured memory_bytes: 2044
#include <iostream>
#include <algorithm>
#include <list>
#include <cstdio>
using namespace std;

int main() {
  int Tc;
  scanf("%d", &Tc);
  scanf("%*c");
  while(Tc--) {
    char c;
    list<char> v;
    list<char>::iterator it;
    scanf(" %c", &c);
    v.push_back(c);
    it = v.begin();
    while(scanf("%c", &c), c != '\n') {
      scanf("%c", &c);
      if(c == '>') {
        ++it;
        if(it == v.end()) it = v.insert(it, ' ');
      } else {
        if(it == v.begin()) it = v.insert(it, ' ');
        else --it;
      }
      scanf("%c", &c);
      *it = c;
    }
    for(it = v.begin(); it != v.end(); ++it) printf("%c", *it);
    puts("");
  }
  return 0;
}

Measured memory_bytes: 1172
H,W = map(int,input().split())
 
if (H == 1)or(W == 1):
    sum = 1
elif H % 2 == 0:
    sum = W * H // 2
elif W % 2 == 0:
    sum = (W * (H-1) // 2) + (W // 2)
else:
    sum = (W * (H-1) // 2) + ((W+1) // 2)
 
print(int(sum))

Measured memory_bytes: 3060
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    int answer = 0;
    int max = Integer.MIN_VALUE;
    for (int i = 0; i < n; i++) {
      int h = Integer.parseInt(sc.next());
      if (h >= max) {
        answer++;
        max = h;
      }
    }
    pw.println(answer);
  }
}


Measured memory_bytes: 21972
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>P;
typedef pair<ll,ll>LLP;
const int MAXN=2e5+20;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;
const ll LLINF=0x3f3f3f3f3f3f3f3f;
const double PI=acos(-1.0);
const double RATE=0.995;
const double eps=1e-15;
std::mt19937 rnd(time(0));
signed main()
{
    int n,k;
    scanf("%d%d",&n,&k);
    printf("%d\n",max(0,n-2*k));
    return 0;
}


Measured memory_bytes: 256