akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<map>
#include<deque>
#include<algorithm>
#include<string>
using namespace std;
#define REP(i,b,e) for(int i=(int)b;i<(int)e;i++)
#define Rep(i,n) REP(i,0,n)
#define rep(i,n) REP(i,1,n+1)
typedef long long ll;

int A[4];
int main(){
    int n;
    cin>>n;
    cout<<(n*(n+1))/2<<endl;

    return 0;
}

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

int main() {
	int a, b, c;

	cin >> a >> b;

	if (a>0) {
		cout << "Positive" << endl;
	}

	else if (a<0 && 0<b) {
		cout << "Zero" << endl;
	}

	else {
		c = b - a + 1;
		if (c % 2 == 1) {
			cout << "Negative" << endl;
		}
		else {
			cout << "Positive" << endl;
		}
	}

	return 0;
}

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

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int>> vii;
typedef vector<pair<int, int>> vpii;

#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(x) (x).begin(),(x).end()
#define INF 1000000000 //4*10^9
#define MOD 1000000007 //10^9+7

int main()
{
    int N;
    cin >> N;
  
    rep(i, 3500)rep(j, 3500) {
        ll h = i + 1;
        ll n = j + 1;
        if ((4 * h * n) > N * (h + n) && (N * h * n)%((4*h*n)-N*(h+n))==0){
            cout << h<<" " << n<< " "<< (N * h * n)/((4 * h * n) - N * (h + n)) << endl;
            return 0;
        }
    }
    
}

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

/*
隣接している個数が偶数こなら裏になる
中心　裏
辺　　オモテ
角　　オモテ
*/


int main(void){
    long long n,m;
    scanf("%lld %lld",&n,&m);

    if(m==1&&n!=1){
        printf("%lld\n",n-2);
    }else if(n==1&&m!=1){
        printf("%lld\n",m-2);
    }else if(m==1&&n==1){
        printf("1\n");
    }else{
        printf("%lld\n",n*m-(n+m)*2+4);
    }

    return 0;
}

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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

using D=double;

int N,M;
vint G[666];

D p[666];
D ex[666];
signed main(){
	cin>>N>>M;
	rep(i,M){
		int a,b;
		cin>>a>>b;
		a--;b--;
		G[a].pb(b);
	}

	p[0]=1;
	rep(i,N-1){
		for(auto u:G[i])p[u]+=p[i]/G[i].size();
	}


	for(int i=N-2;i>=0;i--){
		for(auto u:G[i]){
			ex[i]+=(1+ex[u])/G[i].size();
		}
	}

	D ans=ex[0];
	for(int i=0;i<N-1;i++){
		if(G[i].size()==1)continue;
		for(auto u:G[i]){
			D tmp=ex[0];
			tmp-=p[i]*ex[i];
			for(auto w:G[i]){
				if(u==w)continue;
				tmp+=p[i]*(1+ex[w])/(G[i].size()-1);
			}
			chmin(ans,tmp);
		}
	}
	printf("%.20f\n",ans);
	return 0;
}

Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<int> data(n + 2);
	vector<int> ans(n);
	data[0] = data[n + 1] = 0;
	rep(i, 1, n + 1) {
		cin >> data[i];
	}

	int orians = 0;
	rep(i, 0, n + 1) {
		orians += abs(data[i + 1] - data[i]);
	}

	rep(i, 0, n) {
		ans[i] = orians - abs(data[i + 1] - data[i]) - abs(data[i + 2] - data[i + 1]) + abs(data[i + 2] - data[i]);
	}

	rep(i, 0, n) {
		
		cout << ans[i] << endl;
	}
	
	
 
}

Measured memory_bytes: 2048
#include<stdio.h>
int main()
{
    long long int i,s,n,a[102],b[102];
    scanf("%lld",&n);
    for(i=0;i<n-1;i++){
        scanf("%lld",&b[i]);
    }
    a[0]=b[0];
    a[n-1]=b[n-2];
    for(i=1;i<n-1;i++){
        if(b[i-1]<b[i]){
            a[i]=b[i-1];
        }
        else{
            a[i]=b[i];
        }
    }
    s=0;
    for(i=0;i<n;i++){
        s=s+a[i];
    }
    printf("%lld\n",s);
    return 0;
}


Measured memory_bytes: 128
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A

#B

#C
n = I()
a = LI()
b = [None for i in range(n)]
k = n//2
if n%2:
    for i in range(n):
        if i%2:
            b[k+(i+1)//2] = a[i]
        else:
            b[k-i//2] = a[i]
else:
    for i in range(n):
        if i%2:
            b[k-(i+1)//2] = a[i]
        else:
            b[k+i//2] = a[i]
print(*b)
#D

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


Measured memory_bytes: 93520
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=105;i<=n;i+=2)
	{
		int t=0;
		for(int j=1;j<=i;j++) if(i%j==0) t++;
		if(t==8) ans++;	
	}	
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n,x;
  cin>>n>>x;
  if(x==1 || x==2*n-1){
    puts("No");
    return 0;
  }
  if(n==2){
    if(x==2){
      puts("Yes");
      puts("1");
      puts("2");
      puts("3");
    }else{
      puts("No");
    }
    return 0;
  }
  if(x==2*n-2){
    puts("Yes");
    int it = 1;
    REP(i,2*n-1){
      if(i==n-1){
        printf("%d\n",2*n-1);
      }else if(i==n){
        printf("%d\n",2*n-2);
      }else{
        printf("%d\n",it++);
      }
    }
    return 0;
  }
  puts("Yes");
  vi ans(2*n-1,0);
  REP(i,2*n-1)ans[i]=i+1;
  int y;
  y = find(ALL(ans),x)-ans.begin(); swap(ans[n-1],ans[y]);
  y = find(ALL(ans),x-1)-ans.begin(); swap(ans[n],ans[y]);
  y = find(ALL(ans),x+1)-ans.begin(); swap(ans[n-2],ans[y]);
  y = find(ALL(ans),x+2)-ans.begin(); swap(ans[n+1],ans[y]);
  REP(i,2*n-1){
    printf("%d\n",ans[i]);
  }
  return 0;
}


Measured memory_bytes: 2304
def main():
	s = str(input())
	q = int(input())
	shiji = 1
	rcount = 0
	from collections import deque
	s = deque(s)
	for i in range(q):
		qu = list(map(str,input().split()))
		if qu[0] != '1':
			if shiji == 1:
				if qu[1] == '1':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
			else:
				if qu[1] == '2':
					s.appendleft(qu[2])
				else:
					s.append(qu[2])
		else:
			shiji *= -1
			rcount += 1
	if rcount % 2 == 0:
		print(''.join(map(str,s)))
	else:
		s.reverse()
		print(''.join(map(str,s)))

if __name__ == '__main__':
	main()

Measured memory_bytes: 95064
#include<bits/stdc++.h>
using namespace std;
int main(){
  double a,b,c,d,e,f,t=0,ans,s;
  cin>>a>>b>>c>>d>>e>>f;
  for(int i=0;100*a*i<=f;i++){
    for(int j=0;100*b*j+100*a*i<=f;j++){
      for(int k=0;100*b*j+100*a*i+k*c<=f;k++){
	for(int l=0;100*b*j+100*a*i+k*c+l*d<=f;l++)
	  if(100*(k*c+l*d)/(100*b*j+100*a*i+k*c+l*d)<=100*e/(100+e)){
	    if(100*(k*c+l*d)/(100*b*j+100*a*i+k*c+l*d)>=t){
	      t=100*(k*c+l*d)/(100*b*j+100*a*i+k*c+l*d);
	      ans=100*b*j+100*a*i+k*c+l*d;
	      s=k*c+l*d;
	    }
	  }
      }
    }
  }
  cout<<(long long)ans<<" "<<(long long)s<<endl;
  return 0;
}

Measured memory_bytes: 256
def main():
    a, b, c, d = list(map(int, input().split()))
    ans = max([a*c, a*d, b*c, b*d])
    if a <= 0 <= b or c <= 0 <= d:
        ans = max(ans, 0)
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9172
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 100000000000000000
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int ka[100010];

int comb(int x, int y) {
	if (y > x)return 0;
	return ka[x] * mod_pow(ka[x - y], mod - 2, mod) % mod * mod_pow(ka[y], mod - 2, mod) % mod;
}

int n, k, a[100010];
int cnt1, cnt2;

signed main() {
	cin >> n >> k;
	ka[0] = 1;
	for (int i = 1; i <= n; i++) {
		ka[i] = ka[i - 1] * i%mod;
	}
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	for (int i = 0; i < n; i++) {
		cnt1 += a[i] * comb(i, k - 1);
		cnt2 += a[i] * comb(n - i - 1, k - 1);
		cnt1 %= mod;
		cnt2 %= mod;
	}
	cout << (cnt1 + mod - cnt2) % mod << endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

class Myon
{
    public Myon() { }
    public static int Main()
    {
        new Myon().run();
        return 0;
    }

    void run()
    {
        Scanner cin = new Scanner();
        while (true)
        {
            int m = cin.nextInt();
            if (m == 0) break;
            int[] a = new int[m];
            int[] b = new int[m];
            int sum = 0;
            for (int i = 0; i < m; i++)
            {
                a[i] = cin.nextInt();
                b[i] = cin.nextInt();
                sum += a[i] * b[i];
            }
            sum += 2000;

            int[] dp = new int[sum];
            dp[0] = 1;

            for (int i = 0; i < m; i++)
            {
                int[] nextdp = new int[sum];
                for (int j = 0; j <= b[i]; j++)
                {
                    for (int k = sum - a[i] * j - 1; k >= 0; k--)
                    {
                        nextdp[k + a[i] * j] += dp[k];
                    }
                }
                dp = nextdp;
            }

            int n = cin.nextInt();
            for (int i = 0; i < n; i++)
            {
                Console.WriteLine(dp[cin.nextInt()]);
            }
        }

    }

}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

}

Measured memory_bytes: 5808
using System;
using System.Linq;

namespace ABC138B
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = CIN.Int();

            double ans = 0;
            
            double[] a = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();;
            for (int i = 0; i < n; i++)
            {
                
                ans += 1 / a[i];
            }
            
            Console.WriteLine(1/ans);
        }
    }

    internal static class CIN
    {
        public static string String()
        {
            return Console.ReadLine();
        }

        public static int Int()
        {
            return int.Parse(Console.ReadLine());
        }

        public static int[] IntArray()
        {
            return Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
        }

        public static long Long()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] LongArray()
        {
            return Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] DoubleArray()
        {
            return Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
        }
    }
}

Measured memory_bytes: 11348
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log,gcd
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')

#Pythonを用いる場合
#numpy 1.18.0, scipy 1.4.1, scikit-learn 0.22, numba 0.47.0, networkx 2.4
 
import numpy as np
from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson
from scipy.sparse import csr_matrix

 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n=ii()

for i in range(1,11):
    if i*1000>=n:
        print(i*1000-n)
        exit()
        


Measured memory_bytes: 37600
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int k;
vector<P> G[100001];
int dist[100001];

int bfs(int s,int t){
	memset(dist,-1,sizeof(dist));
	queue<int> que[2];
	que[0].push(s);
	dist[s]=0;
	int now=1,prev=0;
	int cnt=1;
	while(1){
		if(que[prev].size()==0)break;
		while(que[prev].size()){
			int v=que[prev].front();
			que[prev].pop();
			if(v==t)return cnt;
			if(dist[v]!=(cnt-1))continue;
			for(int i=0;i<G[v].size();i++){
				if(G[v][i].second==1){
					if(dist[G[v][i].first]==-1){
						dist[G[v][i].first]=dist[v]+1;
						que[now].push(G[v][i].first);
					}
				}else{
					if(dist[G[v][i].first]==-1 || dist[G[v][i].first]==dist[v]+1){
						dist[G[v][i].first]=dist[v];
						que[prev].push(G[v][i].first);
					}
				}
			}
		}
		cnt++;
		swap(now,prev);
	}
	return -1;
}

int main(void){
	scanf("%d",&k);
	for(int i=0;i<k;i++){
		G[i].push_back(P((i+1)%k,1));
		G[i].push_back(P((i*10)%k,0));
	}
	printf("%d\n",bfs(1,0));
	return 0;
}

Measured memory_bytes: 6272
#include<cstdio>
#include<cstring>
const int M=500009,INF=100000000;
int n,i,j,q,l,r,a[M],f[M][20],dp[M][30];
char s[M];

int read()
{
	int x=0; char ch=getchar();
	while (ch<48 || ch>57) ch=getchar();
	while (ch>=48 && ch<=57) x=(x<<1)+(x<<3)+ch-48,ch=getchar();
	return x;
}

int main()
{
	scanf("%s",s+1),n=strlen(s+1);
	for (i=1;i<=n;++i) a[i]=s[i]-96,dp[i][a[i]]=i;
	for (i=0;i<27;++i) dp[n+1][i]=INF;
	for (i=n;i;--i)
	{
		for (j=a[i]+1;j<27;++j)
			if (dp[i][j-1]>n) dp[i][j]=INF;
			else dp[i][j]=dp[dp[i][j-1]+1][j-1];
		if (dp[i][26]>n) dp[i][0]=INF;
		else dp[i][0]=dp[dp[i][26]+1][26];
		for (j=1;j<a[i];++j)
			if (dp[i][0]>n) dp[i][j]=INF;
			else dp[i][j]=dp[dp[i][0]+1][j];
		if (dp[i][0]>n) f[i][0]=INF;
		else f[i][0]=dp[i][0]+1;
	}
	for (f[n+1][0]=INF,i=1;i<19;++i)
		for (j=1;j<=n+1;++j)
			if (f[j][i-1]==INF) f[j][i]=INF;
			else f[j][i]=f[f[j][i-1]][i-1];
	for (q=read();q;--q)
	{
		l=read(),r=read();
		for (i=18;~i;--i)
			if (f[l][i]<r+2) l=f[l][i];
		if (l==r+1) puts("Yes"); else puts("No");
	}
	return 0;
}

Measured memory_bytes: 100608
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;
int N;
vector<int>G[701];
void answer(int x){
	cout<<"Yes"<<endl;
	cout<<x+1<<endl;
	int now=1;
	REP(i,x){
		REP(j,x-i){
			G[i].push_back(now);
			G[i+1+j].push_back(now);
			now++;
		}
	}
	REP(i,x+1){
		cout<<x<<" ";
		REP(j,x){
			cout<<G[i][j];
			if(j!=x-1){
				cout<<" ";
			}else{
				cout<<endl;
			}
		}
	}
}

int main(){
	cin>>N;
	REP(i,N+1){
		if(2*N==i*(i+1)){
			answer(i);
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 2304
#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    let v = read_vec::<i32>();
    let a = v[0];
    let b = v[1];
    let c = v[2];
    let d = v[3];

    yn((a-c).abs() <= d || ((c-b).abs() <= d && (b-a).abs() <= d));
}


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

int main(){
	int n;
	cin>>n;
	int count=0;
	bool j=true;
	for(int i=0;i<n;i++){
		char c;
		int num;
		cin>>c>>num;
		if(c=='('){
			count+=num;
		}else{
			count-=num;
			if(count<0){
				j=false;
			}
		}
	}
	if(j&&count==0){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < n; ++i)
ll dx[4] = { 0, 1, 0, -1 };
ll dy[4] = { 1, 0, -1, 0 };
const ll INF = LLONG_MAX;
const ll MOD = 1e9 + 7;

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

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

    z = (Node*)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;

    // 根から葉まで見る
    while (x != NIL) {
        y = x;
        if (z->key < x->key) {
            x = x->left;
        } else {
            x = x->right;
        }
    }
    // 葉まで行ったら葉の子にzを指定する
    z->parent = y;
    // 葉がNILなら根なしなので根にする
    // 葉がNIL根でないなら葉の右か左かを判断する
    if (y == NIL) {
        root = z;
    } else {
        if (z->key < y->key) {
            y->left = z;
        } else {
            y->right = z;
        }
    }
}

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

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, x;
    string com;
    cin >> n;
    rep(i, n)
    {
        cin >> com;
        if (com == "insert") {
            cin >> x;
            insert(x);
        } else if (com == "print") {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }

    return 0;
}


Measured memory_bytes: 26716
#include<stdio.h>
  #define NUMBER 10000
  int main(void){
      int a,b,c,i,count=0;
      scanf("%d %d %d",&a,&b,&c);
      for(i=a;i<=b;i++){
         if(c%i==0)
           count++;
      }
      printf("%d\n",count);
      return 0;
  }


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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define ALL(a) (a).begin(),(a).end()

using namespace std;
using ll = long long;

const double PI = 3.14159265358979;

void solve()
{
  int a, b;
  cin >> a >> b;
  cout << (((a * b) & 1) ? "Odd" : "Even");
}

int main()
{
  fastio;
  solve();

  return 0;
}

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

int main() {
	long int N,ans=0;
	cin >> N;

	for(int i=1;i<=N;i++){
		if(!(i%3)){
			continue;
		}else if(!(i%5)){
			continue;
		}else{
			ans+=i;
			continue;
		}
	}

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


Measured memory_bytes: 3612
S = input()

for i in range(len(S)):
    #i+1が奇数
    if i % 2==0:
        if S[i] == "L":
            print("No")
            break;
    else:
        if S[i] == "R":
            print("No")
            break;
    if(i==len(S)-1):
        print("Yes")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define PI  3.14159265358979323846
#define lp(i,n) for(int i = 0; i <n;i++)
#define rlp(i,n) for(int i = int(n);i >= 0;i--)
#define range1(i,a,b,c) for(int i = int(a);i <= int(b);i+=int(c))
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define fr first
#define sc second
#define sz(v) ((int)((v).size()))
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1, v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1, v2, v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1, v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1, v2, v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef pair<int, int> pii;
template<class T> using ordered_set=tree<T,
null_type,
less<T>,
rb_tree_tag,
tree_order_statistics_node_update>;
const ll MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)200005;
int dx[] = {0,0,-1,1};
int dy[] = {1,-1,0,0};
void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int mult(int a,int b){
    int res = (a%MOD * b%MOD)%MOD;
    return res;
}
vector<int>adj[N];
int vis[N],vid, n,m;
bool f = false;
void dfs(int node,int cnt =0){
    vis[node]=1;
    
    if(node==n&&cnt==2){
        f = true;
        return;
    }else if(cnt==2){
        return ;
    }
    for(int child : adj[node]){
        if(!vis[child]){
            dfs(child,cnt+1);
        }
    }
}
void _run(){

  cin>>n>>m;
  for(int i=0;i<m;i++){
      int x,y;
      cin>>x>>y;
      adj[x].pb(y);
  }
  for(int i=1;i<=n;i++){
      if(!vis[i]){
          dfs(i);
          if(f){
              puts("POSSIBLE");
              return ;
          }
      }
  }
  puts("IMPOSSIBLE");
}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    int t=1;
    // scanf("%d",&t);
    while(t--)_run();
    
    return 0;
}

Measured memory_bytes: 12412
#include<bits/stdc++.h>
using lint=long long;
int main(){
    std::cin.tie(nullptr);std::ios_base::sync_with_stdio(false);
    std::cout.setf(std::ios_base::fixed);std::cout.precision(15);
    std::map<std::string,lint>map;
    lint n;std::cin>>n;
    while(n--){
        std::string s;std::cin>>s;
        map[s]++;
    }
    std::cin>>n;
    while(n--){
        std::string s;std::cin>>s;
        map[s]--;
    }
    lint ans=0;
    for(auto&&p:map){
        if(ans<p.second)ans=p.second;
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <stack>
#include <vector>
#include <algorithm>
#include<iostream>
#define MAXN 1000
using namespace std;
int n,k,mins;
int main () {
   cin>>n>>k;
   mins=n%k;
   if(mins==0){
   	cout<<"0";
   }else{
   	cout<<"1";
   }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using namespace std::literals::chrono_literals;
using namespace std::literals::string_literals;
using ll = long long;

#define repi(i, s, n) for (long long i {s}, i##_len{n}; i < i##_len; ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) std::begin(x), std::end(x)

namespace xmaho
{
inline namespace input
{
template<typename T>
T get_value(std::istream& is = std::cin);
template<typename C>
C get_container(std::istream& is = std::cin, typename C::size_type length = std::numeric_limits<typename C::size_type>::max());
}
}
namespace xmaho
{
inline namespace integer
{
template<typename C>
constexpr auto ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type;
template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t ssize(const T (&)[N]) noexcept;
}
}
using namespace xmaho;

int main()
{
  const auto x {get_value<uintmax_t>()};
  const auto limit {x*2};
  valarray<bool> prims(true, limit + 1);

  const std::uintmax_t search_limit {static_cast<std::uintmax_t>(std::floor(std::sqrt(static_cast<long double>(limit)))) + 1};
  for (std::uintmax_t i {2}; i < search_limit; ++i)
    if (prims[i])
      prims[std::slice(i*i, limit / i - (i - 1), i)] = false;

	cout << distance(begin(prims), find(next(begin(prims), x), end(prims), true)) << '\n';
  return 0;
}

class initalization
{
  class custom_numpunct: public std::numpunct<char>
  {
  public:
    using numpunct::numpunct;
  protected:
    std::string do_truename() const override { return "Yes"; }
    std::string do_falsename() const override { return "No"; }
  };

public:
  initalization()
  {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.imbue(std::locale(std::cout.getloc(), new custom_numpunct{}));
    std::cout << std::boolalpha << std::fixed << std::setprecision(15);
  }
} initalize;

template<typename T>
T xmaho::input::get_value(std::istream& is)
{ T v {}; is >> v; return v; }

template<typename C>
C xmaho::input::get_container(std::istream& is, typename C::size_type length)
{
  C v {};
  if (length != std::numeric_limits<typename C::size_type>::max())
    v.reserve(length);
  typename C::value_type e {};
  for (auto i {length}; i != 0 && is >> e; --i)
    v.push_back(std::move_if_noexcept(e));
  return v;
}

template<typename C>
constexpr auto xmaho::integer::ssize(const C& c) noexcept(noexcept(c.size()))
  -> typename std::common_type<std::ptrdiff_t, typename std::make_signed<decltype(c.size())>::type>::type
{ return c.size(); }

template <class T, ptrdiff_t N>
constexpr std::ptrdiff_t xmaho::integer::ssize(const T (&)[N]) noexcept
{ return N; }


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n;
vector<p> cost, c;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        ll temp, temp1;
        cin >> temp >> temp1;
        c.push_back(make_pair(temp,temp1));
        cost.push_back(make_pair(temp + temp1, i));
    }
    ll anst = 0;
    ll ansa = 0;
    sort(ALL(cost));
    int countt = n-1;
    int counta = 0;
    for (int i = 0; i < n; i++)
    {
        if(i%2==0){
            anst += c[cost[countt].second].first;
            countt--;
        }
        else{
            ansa += c[cost[countt].second].second;
            countt--;
        }
    }
    cout<<anst-ansa<<"\n";
}


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

int main() {
  int a, b;
  cin >> a >> b;
  
  if (a * b % 2 == 0) {
    cout << "Even" << endl;
  }
  
  else {
    cout << "Odd" << endl;
  }
    
}


Measured memory_bytes: 3588
import sys
input = sys.stdin.readline
INF = float("inf")


def main():
    N = int(input())
    P = list(map(float, input().split()))

    dp = [[0]*(N+1) for _ in range(N+1)]
    dp[0][0] = 1.0
    for i in range(N):
        for j in range(i+1):
            dp[i+1][j+1] += dp[i][j] * P[i]
            dp[i+1][j] += dp[i][j] * (1 - P[i])
    
    ans = 0.0
    for n in range((N+1)//2, N+1):
        ans += dp[N][n]

    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 263048
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
  vector<string> s(3);
  cin>>s[0]>>s[1]>>s[2];
  int cur = 0;
  while(1){
    if(s[cur].empty()){
      cout << (char)('A' +cur)<< endl;
      return 0;
    }
    char tmp = s[cur][0];
    s[cur].erase(s[cur].begin());
    cur = tmp - 'a';
  }
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
    int K;
    int odd;
    int gu;
    scanf("%d", &K);
    
    if(K%2==0){
        odd = K/2;
        gu = K/2;
    }
    else{
        odd = K/2+1;
        gu = K/2;
    }
    printf("%d\n", odd*gu);
}

Measured memory_bytes: 128
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    from collections import defaultdict
    N, *S = read().split()
    d = defaultdict(int)
    for s in S:
        d[s] += 1
    print(len(d))
    return

if __name__ == '__main__':
    main()



Measured memory_bytes: 37720
#include<bits/stdc++.h>
 
#define INF 1000000007
#define LINF 1000000000000000007
 
using namespace std;
 
typedef long long ll;
typedef pair<ll, ll> P;


string s;

int main(){
	cin >> s;
	
	bool a = 0, b = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'C') a = 1;
		if(s[i] == 'F' && a) b = 1;
	}
	
	if(a && b) cout << "Yes" << endl;
	else cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<bitset>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
#define ll long long
using namespace std;
int main() {
     int n, z, w, a[2005];
     cin >> n >> z >> w;
     for (int i = 0; i < n; i++) cin >> a[i];
     if (n == 1)cout << abs(w - a[0]);
     else cout << max(abs(w - a[n - 1]), abs(a[n - 1] - a[n - 2]));
     return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define ft first
#define sd second
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<long long,long long> pll;

int main() {
    fastIO;
    int n, l, aux, rta = 0;
    cin >> n >> l;
    vector<pii> data;
    for(int i = 1; i <= n; i++){
        aux = i + l - 1;
        rta += aux;
        if(aux < 0) data.pb({abs(aux),-1});
        else data.pb({aux, 1});
    }
    pii inicio;
    sort(data.begin(), data.end());
    inicio = data[0];
    rta -= inicio.ft * inicio.sd;
    cout << rta << endl;
    return 0;
}



Measured memory_bytes: 3600
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
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 };



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

	double x[20];
	char u[20][10];

	double ans = 0;

	for (int i = 0; i < N; i++) {
		scanf("%lf%s", &x[i], &u[i]);
		if (u[i][0] == 'B' &&u[i][1] == 'T' &&u[i][2] == 'C' )x[i] *= 380000.0;
		ans += x[i];
	}

	printf("%lf", ans);

}





/*         提出前の確認事項

・デバッグ用の関数は＜＜コメント化＞＞しているか？
・すべての＜＜入力例＞＞は試したか？
・＜＜限界値分析＞＞はしたか？
・＜＜出力の改行＞＞の有無は確認したか？
・文字列の＜＜スペル＞＞は確認したか？
　　　　　　　　↓
	 ＜＜提出先＞＞に注意して提出！！
*/

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<cmath>
#include <iomanip>
using namespace std;
int main()
{
	long long A, B, H, M;
	cin >> A >> B >> H >> M;
	long double a, b, angle = 0, num;
	long double const pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899863;

	b = M * 6;

	a = H * 30;
	a += M * 0.5;

	if (a > b)
	{
		a -= b;
		b = 0;
		angle = a;
	}
	else if (a < b)
	{
		b -= a;
		a = 0;
		angle = b;
	}
	if (angle > 160)
	{
		angle -= 360;
		angle *= -1;
	}
	num = A * A + B * B - 2 * A * B * cos(angle * pi / 180);
	num = sqrt(num);

	cout << fixed << setprecision(100) << num << endl;

}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

int gcd(int a, int b) {
    while (b > 0) { int t = a % b; a = b; b = t; }
    return a;
}

int main() {
    int p, q;
    cin >> p >> q;
    int g = gcd(p, q);
    q /= g;
    int ans = 1;
    for (int i = 2; i * i <= q; ++i) {
        if (q % i == 0) {
            ans *= i;
            while (q % i == 0)
                q /= i;
        }
    }
    ans *= q;
    cout << max(ans, 2) << "\n";
    return 0;
}

Measured memory_bytes: 3092
#include <iostream>

char c[3][3];

int main() {
    for (int i=0; i<3; i++) {
        for (int j=0; j<3; j++) {
            std::cin >> c[i][j];
        }
    }
    for (int i=0; i<3; i++) std::cout << c[i][i];
    std::cout << '\n';
    return 0;
}


Measured memory_bytes: 256
const main = (lines: string) => {
  const data = lines.split("\n");
  const N = parseInt(data[0]);
  const weights = data[1].split(" ").map(str => parseInt(str));
  let sumOfWeights: number;
  let calculateWeights: number = 0;
  let answer: number | null = null
  let temp: number;

  sumOfWeights = weights.reduce((a, x) => a += x, 0)

  weights.forEach(weight => {
    sumOfWeights -= weight
    calculateWeights += weight

    temp = Math.abs(sumOfWeights - calculateWeights)
    if (answer === null || answer > temp) {
      answer = temp
    }
  });

  console.log(answer)
};

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7500
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define INF 1e9;
using namespace std;
typedef long long ll;
int main() {
  ll n;
  cin >> n;
  vector<ll> h(n);
  REP(i, n) { cin >> h[i]; }
  ll ans = 0;
  while (true) {
    bool f = false, c = false;
    REP(i, n) {
      if (h[i] == 0) {
        if (c) {
          ans++;
          c = false;
        }
      } else {
        h[i]--;
        c = true;
        f = true;
      }
    }
    if (c) ans++;
    if (!f) break;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
count=0
for i in range(0,10):
    for j in range(0,10):
        for k in range(0,10):
            look=0
            check=0
            while N-1>=look:
                if check==0:
                    if S[look]==str(i):
                        check=1
                elif check==1:
                    if S[look]==str(j):
                        check=2
                elif check==2:
                    if S[look]==str(k):
                        check=3
                look+=1
            if check==3:
                count+=1

print(count)

Measured memory_bytes: 46812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(void){
    int a,b,c; cin>>a>>b>>c;
    if(b-a==c-b){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
    
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define int long  long 

using namespace std ;

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

	int n ;
	cin >> n ;
	vector<int> a(n) ;
	for(int i = 0 ; i < n ; ++i)
		cin >> a[i] ;
	int mx = 0 , ans = 0 ;
	for(int i =  0 ; i < n ; ++i)
	{
		if(a[i] < mx)
		{
			ans += mx - a[i] ; 

		}
		else if(a[i] > mx)
			mx= a[i] ; 
	}    
	cout << ans  ;
}
                                      






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

using namespace std;

std::array<bool, 3> calc(const std::array<int, 4>& abcd) {
  std::array<bool, 3> ret;
  for (int bits = 0; bits < 8; bits++) {
    int sum = abcd[0];
    int mask = 1;
    for (int i = 1; i < 4; i++) {
      if (bits & mask) {
        sum += abcd[i];
      } else {
        sum -= abcd[i];
      }
      mask <<= 1;
    }
    if (sum != 7) {
      continue;
    }
    mask = 1;
    for (auto& r : ret) {
      r = bits & mask;
      mask <<= 1;
    }
    return ret;
  }
}

int main() {
  std::array<int, 4> abcd;
  for (auto& a : abcd) {
    char ch;
    std::cin >> ch;
    a = ch - '0';
  }
  auto ret = calc(abcd);
  for (int i = 0; i < 4; i++) {
    std::cout << abcd[i];
    if (i < 3) {
      std::cout << (ret[i] ? "+" : "-");
    }
  }
  std::cout << "=7" << std::endl;
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
Cities = [list(map(int,input().split())) for i in range(m)]
city = 0
for City in Cities:
  City += [city]
  city += 1
Cities.sort()
Cities[0][1] = 1
order = 1
for i in range(1,m):
  if Cities[i][0] == Cities[i-1][0]:
    order += 1
  else:
    order = 1
  Cities[i][1] = order
Cities.sort(key=lambda x:x[2])
for City in Cities:
  print(str(City[0]).zfill(6) + str(City[1]).zfill(6))

Measured memory_bytes: 32492
object Main {
  def main(args: Array[String]): Unit = {
    val Seq(n, w): Seq[Int] = io.StdIn.readLine().split(' ').map(_.toInt)
    val (ws, vs) = (for(i <- 0 until n) yield {val Seq(w, v): Seq[Int] = io.StdIn.readLine().split(' ').map(_.toInt); (w, v)}).unzip
    val offset = ws.head - 1
    val reducedWs = ws.map(_ - offset)

    val dp: Array[Array[Array[Long]]] = Array.fill(n)(Array.fill(n + 1)(Array.fill(n * 4 + 1)(0)))

    if(ws(0) <= w) {
      dp(0)(1)(reducedWs(0)) = vs(0)
    }

    for(item <- 1 until n) {
      for(num <- 1 to n) {
        for(weight <- 0 to 4 * n) {
          val sub = weight - reducedWs(item)
          if(0 <= sub && (num - 1 == 0 || 0 < dp(item - 1)(num - 1)(sub)) && weight.toLong + offset.toLong * num.toLong <= w) {
            dp(item)(num)(weight) = dp(item - 1)(num)(weight) max (dp(item - 1)(num - 1)(sub) + vs(item))
          } else {
            dp(item)(num)(weight) = dp(item - 1)(num)(weight)
          }
        }
      }
    }

    var ans = 0.toLong
    for(num <- 1 to n) {
      for(weight <- 0 to 4 * n) {
        ans = ans max dp(n - 1)(num)(weight)
      }
    }

    println(ans)
  }
}

Measured memory_bytes: 79368
// B.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>

using namespace std;

int main()
{
    int n;
    int p[21];
    int cnt = 0;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }


    for (int i = 1; i < n - 1; i++) {
        if (p[i - 1] < p[i] && p[i] < p[i + 1]) {
            cnt++;
        }
        else if (p[i - 1] > p[i] && p[i] > p[i + 1]) {
            cnt++;
        }
    }
    cout << cnt << endl;

    return 0;
}



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

int main()
{
  string s;
  int a, k = 0;
  cin >> s;
  for (int i = 0; i < 3; i++)
  {
    if (i % 2 == 0)
      a = 5;
    else
      a = 7;
    for (int j = 0; j < a; j++)
    {
      cout << s[k];
      k++;
    }
    if (i != 2)
    {
      cout << ' ';
      k++;
    }
  }
  cout << '\n';
}


Measured memory_bytes: 256
#include<cstdio>
main(){
int n;
while(scanf("%d",&n),n){
int j=0,s=32,t=1,a[25];
for(int i=0;i<n;i++)scanf("%d",a+i);
while(s){
t++ % 2?s-=(s-1)%5:s-=a[j++%n];
if(s<0)s=0;
printf("%d\n",s);
}
}
}

Measured memory_bytes: 0
int main()
{
	int t[4][14];
	int n, i, j, c;
	char m, d;
	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < 14; j++)
		{
			t[i][j] = 0;
		}
	}
	scanf("%d", &c);
	for (i = 0; i < c; i++)
	{
		scanf("%c", &d);
		scanf("%c %d", &m, &n);
		if (m == 'S')
		{
			t[0][n] = 1;
		}
		else if (m == 'H')
		{
			t[1][n] = 1;
		}
		else if (m == 'C')
		{
			t[2][n] = 1;
		}
		else if (m == 'D')
		{
			t[3][n] = 1;
		}
	}
	for (j = 1; j < 14; j++)
	{
		if (t[0][j] != 1)
		{
			printf("S %d\n", j);
		}
	}

	for (j = 1; j < 14; j++)
	{
		if (t[1][j] != 1)
		{
			printf("H %d\n", j);
		}
	}

	for (j = 1; j < 14; j++)
	{
		if (t[2][j] != 1)
		{
			printf("C %d\n", j);
		}
	}

	for (j = 1; j < 14; j++)
	{
		if (t[3][j] != 1)
		{
			printf("D %d\n", j);
		}
	}
	return 0;
}


Measured memory_bytes: 2056
def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    if N >= M:
        print(0)
        return
    X.sort()
    distance = []
    for i in range(M-1):
        distance.append(X[i+1] - X[i])
    distance.sort()
    for _ in range(N-1):
        distance.pop()
    ans = sum(distance)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 13968
#!/usr/bin/env python3

from collections import deque

K = int(input())
cnt = 0
q = deque()

for i in range(1, 10):
    q.append((str(i), i))
    cnt += 1
    if cnt == K:
        print(str(i))
        exit()

while q:
    lun, num = q.popleft()
    
    for i in range(num - 1, num + 2):
        if  i < 0 or i > 9:
            continue
        temp = lun + str(i)
        q.append((temp, i))
        cnt += 1
        if cnt == K:
            print(temp)
            exit()
        

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

int dp[100000];
int main() {
	memset(dp, 0x3f, sizeof(dp));
	int n; scanf("%d", &n);
	rep(i, n) {
		int a; scanf("%d", &a);
		*lower_bound(dp, dp + n, a) = a;
	}
	printf("%d\n", lower_bound(dp, dp + n, 0x3f3f3f3f) - dp);
}

Measured memory_bytes: 3608
n = int(input())
a = []
b = []
for i in range(n):
    s,t = map(int,input().split())
    a.append(s)
    b.append(t)
a.sort()
b.sort()
if n%2 == 0:
    am = (a[n//2-1]+a[n//2])/2
    bm = (b[n//2-1]+b[n//2])/2
    print(int((bm-am)*2+1))
else:
    am = a[(n-1)//2]
    bm = b[(n-1)//2]
    print(bm-am+1)

Measured memory_bytes: 25272
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <queue>
#include <stack>
#include <string>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <array>
#include <set>
#include <climits>
#include <cassert>
#include <bitset>
#include <numeric>
using namespace std;
#define mod 1000000007



int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

#ifdef HELL_JUDGE
    freopen("input","r",stdin);
    freopen("output","w",stdout);
    freopen("error","w",stderr);
#endif 
    set<int>a;
    for(int  i=0;i<3;++i){
        int x; cin>>x;
        a.insert(x);
    }
    if(a.size()==2){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		// get numbers
		Scanner sc = new Scanner(System.in);     
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int x = 0, y = 0;

        x = a * b;
        y = c * d;

        if (x >= y) {
            System.out.println(x);
        } else {
            System.out.println(y);
        }

        sc.close();
	}
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int V,E,ans;
ll edge[64];
ll sum_edge[64];
void MDS(int cur,int cost,ll mask){
	if(cost>=ans)return;
	if(mask==(1LL<<V)-1){
		ans=cost;
		return;
	}
	if(cur>=V)return;
	if((mask|sum_edge[cur])!=(1LL<<V)-1)return;
	MDS(cur+1,cost+1,mask|edge[cur]);
	MDS(cur+1,cost,mask);
}
int main(){
	while(cin>>V>>E,V){
		memset(edge,0,sizeof(edge));
		memset(sum_edge,0,sizeof(sum_edge));
		for(int i=0;i<V;i++)edge[i]|=(1LL<<i);
		for(int i=0;i<E;i++){
			int A,B;
			cin>>A>>B;
			edge[A]|=(1LL<<B);
			edge[B]|=(1LL<<A);
		}
		for(int i=V-1;i>=0;i--) sum_edge[i] |= edge[i];
		for(int i=V-2;i>=0;i--) sum_edge[i] |= sum_edge[i+1];
		ans=1e9;
		MDS(0,0,0);
		cout<<ans<<endl;
	}
}


Measured memory_bytes: 3088
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main()
{
	int h, w;
	cin >> h >> w;
	string s[26][26];
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> s[i][j];
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (s[i][j] == "snuke") {
				printf("%c%d", 'A' + j, i + 1);
			}
		}
	}
}

Measured memory_bytes: 256
m;
main(n,p,d,e,b)
{
  for(;;)
    {
      m=scanf("%d",&n);
      if(!n)exit(0);
      for(;n--;)
	{
	  scanf("%d%d%d",&p,&d,&e);
	  if(m<d+e)
	    m=d+e,b=p;
	}
      printf("%d %d\n",b,m);
    }
}

Measured memory_bytes: 412