akhauriyash/Code-Regression huggingface dataset:
n,k = map(int,input().split())

if k > 0.5*(n-2)*(n-1):
    print(-1)
else:
    print(int(0.5*(n-2)*(n-1) - k + (n-1)))
    hiku = 0.5*(n-2)*(n-1) - k
    for i in range(2,n+1):
        print(1,i)
    a = 1
    b = 0
    while hiku>0 :
        a+=1
        b=a+1
        while hiku>0 and b<=n:
            print(a,b)
            b+=1
            hiku-=1


Measured memory_bytes: 44656
N = int(input())
A = [int(input()) for _ in range(N)]
cnt = 0
if A[0]>1:
    cnt += A[0]-1
    A[0]=1
cur = 1
for i in range(1,N):
    if A[i]<=cur:continue
    if A[i]==cur+1:
        cur += 1
        continue
    a = A[i]
    n = (a-cur-2)//(cur+1)
    cnt += (n+1)
print(cnt)    

Measured memory_bytes: 49664
#define _USE_NATH_DEFINES
#include<cstdio>
#include <iostream>
#include<sstream>
#include<fstream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<complex>
#include <string>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<numeric>
#include<limits>
#include<climits>
#include<cfloat>
#include<functional>
#include<iterator>
using namespace std;

int main() {
	int n,sum=0;
	cin >> n;
	if (n > 0)
	{
		for (int i = 0; i < n+1; i++)
		{
			sum += i;
		}
	}
	else
	{
		sum = 1;
	}
	
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define boost ios_base::sync_with_stdio(0); cin.tie(); cout.tie()
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define endl '\n'
#define len(a) a.size()

using namespace std;

typedef long long ll;

int main()
{
    int x; cin >> x;
    if (x >= 400 && x < 600)
        cout << "8";
    else if (x >= 600 && x < 800)
        cout << "7";
    else if (x >= 800 && x < 1000)
        cout << "6";
    else if (x >= 1000 && x < 1200)
        cout << "5";
    else if (x >= 1200 && x < 1400)
        cout << "4";
    else if (x >= 1400 && x < 1600)
        cout << "3";
    else if (x >= 1600 && x < 1800)
        cout << "2";
    else if (x >= 1800 && x < 2000)
        cout << "1";
    return 0;
}


Measured memory_bytes: 3584
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int r=Integer.parseInt(sc.next());
int c=Integer.parseInt(sc.next());
int[][] rc=new int[r+1][c+1];
for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
    rc[i][j]=sc.nextInt();
   
    }
}
for(int i=0;i<r;i++){
    for(int j=0;j<c;j++){
 rc[i][c]+=rc[i][j];
    rc[r][j]+=rc[i][j];
   rc[r][c]+=rc[i][j];
    }
}

for(int j=0;j<r+1;j++){
    for(int i=0;i<c+1;i++){
    if(i!=c){System.out.print(rc[j][i]+" ");}else{System.out.println(rc[j][i]);}
    }
}

}
}


Measured memory_bytes: 42252
#include<bits/stdc++.h>
using namespace std;
int tab[2005];
const int mod=1e9+7;
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
    long long a,b,licz=0;
    cin>>a>>b;
    for(int x=0;x<a;x++)
        cin>>tab[x];
    for(int x=0;x<a;x++)
    {
        long long pom1=0,pom2=0;
        for(int y=0;y<a;y++)
            if(tab[y]<tab[x])
                pom1++;
        for(int y=x;y<a;y++)
            if(tab[y]<tab[x])
                pom2++;
        licz+=((b*(b-1)/2)%mod)*pom1+pom2*b;
        licz%=mod;
    }
    cout<<licz;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    string a,s,c; cin >> a >> s >> c;
    cout << a[0] << s[0] << c[0] << endl;
    return 0;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  if(s=="SUN")cout<<7<<endl;
  else if(s=="MON")cout<<6<<endl;
  else if(s=="TUE")cout<<5<<endl;
  else if(s=="WED")cout<<4<<endl;
  else if(s=="THU")cout<<3<<endl;
  else if(s=="FRI")cout<<2<<endl;
  else if(s=="SAT")cout<<1<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastt ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mx 200009
vector<ll> g[mx+10];
ll vis[mx+10];

ll dfs(ll nod){
	vis[nod]=1;
	ll cnt=1;
	for(ll it:g[nod]){
		if(vis[it]==0){
			cnt+=dfs(it);
		}
	}
	return cnt;
}

int main()
{
	fastt

	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		ll a,b;
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	ll ans=0;
	for(ll i=1;i<=n;i++){
		if(vis[i]==0){
			ll cnt=dfs(i);
			ans=max(ans,cnt);
		}
	}
	cout<<ans<<endl;

	return 0;
}



Measured memory_bytes: 25536
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1005;
int main()
{
    int n;
    string s;
    cin >> n >> s;
    if(n%2 == 1)return cout << "No", 0;
    string t = s.substr(0,n/2);
    if(s == t+t)cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	public class Program
	{
		static void Main(string[] args)
		{
			int[] dishes = new int[5];
			for (int i = 0; i < 5; i++) {
				dishes[i] = int.Parse(Console.ReadLine());
			}

			int ans = 0;
			int min = 0;
			for (int i = 0; i < 5; i++) {
				int m = dishes[i] % 10;
				ans += dishes[i];
				if (m > 0) {
					ans += 10 - m;
					if (min == 0 || min > m) {
						min = m;
					}
				}
			}
			if (min > 0) {
				ans -= (10 - min);
			}

			Console.WriteLine(ans);
		}
	}
}

Measured memory_bytes: 13140
import sys

l = [s.lower() for s_l in list(sys.stdin) for s in s_l if 65 <= ord(s) < 91 or 97 <= ord(s) < 123]
d = {chr(k): 0 for k in range(97, 123)}
for s in l:
    if d.get(s, None) is not None:
        d[s] += 1
for k in d:
    print('{} : {}'.format(k, str(d[k])))



Measured memory_bytes: 5576
def main():
    K = int(input())
    if K % 2 == 0:
        print(-1)
        exit()

    m = 7 % K
    for i in range(1000000):
        if m == 0:
            print(i + 1)
            break
        m += 7 * pow(10, i + 1, K)
        m %= K
    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 63248
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N = II()
    A= LI()
    ans = 0

    for i in range(N):
        if A[i] % 2 == 0:
            if A[i]%3!=0 and A[i]%5!=0:
                ans += 1
                break

    if ans == 0:
        print("APPROVED")
    else:
        print("DENIED")




if __name__ == "__main__":
	main()

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

#ifdef LOCAL
#include "../../dump.hpp"
#else
#define dump(...)
#endif

#define int ll
#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(int i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(int i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで降順
#define pb push_back
#define fst first
#define snd second
using ll  = long long;
using vi  = vector<int>;
using vvi = vector<vi>;
using vs  = vector<string>;
using pii = pair<int,int>;
constexpr ll inf = 1ll<<61;
constexpr ll mod = 1e9+7;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>T add(const T &a, const T &b){return (a+b)%mod;}

signed main(){
  int n; cin >> n;
  vi a(n); rep(i,n) cin >> a[i];
  sort(rall(a));
  priority_queue<int> qa; // 正
  priority_queue<int,vi,greater<int>> qb; // 負
  FOR(i,1,n-1){
    if(a[i] >= 0) qa.push(a[i]);
    else qb.push(a[i]);
  }
  dump(qa,qb);
  vector<pii> seq;
  int ans = a[n-1];
  while(not qa.empty()){
    seq.emplace_back(ans, qa.top());
    ans = ans - qa.top();
    qa.pop();
  }
  seq.emplace_back(a[0],ans);
  ans = a[0] - ans;
  while(not qb.empty()){
    seq.emplace_back(ans, qb.top());
    ans = ans - qb.top();
    qb.pop();
  }

  cout << ans << endl;
  rep(i,seq.size()){
    cout << seq[i].first << " " << seq[i].second << endl;
  }
}


Measured memory_bytes: 5872
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
int INF = INT_MAX / 2;
double EPS = 1e-10;

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

void add_edge(vector<vector<edge> >& G, int R, int C, int y, int x, int _y, int _x, int t) {
	edge e = {C * y + x, C * _y + _x, t};
	G[C * y + x].push_back(e);
}

vector<ll> dijkstra(int n, vector<vector<edge> >& G, int s) {
	vector<ll> d(n, LLONG_MAX); d[s] = 0;
	priority_queue<ll_i, vector<ll_i>, greater<ll_i> > q;
	q.push(ll_i(0, s));
	while (!q.empty()) {
		ll_i p = q.top(); q.pop();
		int u = p.second;
		if (p.first > d[u]) continue;
		for (int i = 0; i < G[u].size(); i++) {
			edge e = G[u][i];
			if (d[e.v] > d[u] + e.w) {
				d[e.v] = d[u] + e.w;
				q.push(ll_i(d[e.v], e.v));
			}
		}
	}
	return d;
}

int main() {
	int R, C; cin >> R >> C;
	vector<string> a(R);
	int s, t;
	for (int y = 0; y < R; y++) {
		cin >> a[y];
		for (int x = 0; x < C; x++) {
			if (a[y][x] == 'S') {
				a[y][x] = '.';
				s = C * y + x;
			}
			if (a[y][x] == 'G') {
				a[y][x] = '.';
				t = C * y + x;
			}
		}
	}
	vector<vector<edge> > G(R * C);
	for (int y = 0; y < R; y++)
		for (int x = 0; x < C; x++) {
			if (a[y][x] == '#') continue;
			for (int k = 0; k < 4; k++) {
				int _y = y + dy[k], _x = x + dx[k];
				if (_y >= 0 && _y < R && _x >= 0 && _x < C);
				else continue;
				char c = a[_y][_x];
				if (c == 'o') add_edge(G, R, C, y, x, _y, _x, 1);
				if (c == '.') add_edge(G, R, C, y, x, _y, _x, 2);
			}
			for (int k = 0; k < 4; k++) {
				int _y = y, _x = x;
				for (int i = 1; i <= 3; i++) {
					_y += dy[k]; _x += dx[k];
					if (_y >= 0 && _y < R && _x >= 0 && _x < C);
					else break;
					char c = a[_y][_x];
					if (c == '#') break;
					add_edge(G, R, C, y, x, _y, _x, 2 + i);
				}
			}
		}
	cout << dijkstra(R * C, G, s)[t] << endl;
}

Measured memory_bytes: 1368
#include <stdio.h>

int main(void)
{
	int i;
	int m,f,r,sum;
	
	for(;;){
		scanf("%d%d%d",&m,&f,&r);
		
		if(m==-1 && f==-1 && r==-1){
			break;
		}
		
		sum=m+f;
		
		if(m==-1 || f==-1){
			printf("F\n");
		}else if(sum>=80){
			printf("A\n");
		}else if(sum<80 && sum>=65){
			printf("B\n");
		}else if(sum<65 && sum>=50){
			printf("C\n");
		}else if(sum<50 && sum>=30 && r>=50){
			printf("C\n");
		}else if(sum<50 && sum>=30){
			printf("D\n");
		}else if(sum<30){
			printf("F\n");
		}
	}
	return 0;
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(a>b){a=b;return true;}return false;}
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    int n;
    cin>>n;
    vi vec(n+2);
    REP(i,n){
        cin>>vec[i+1];
    }
    int sum=0;
    REP(i,n+1){
        sum+=abs(vec[i+1]-vec[i]);
    }
    FOR(i,1,n+1){
        cout<<sum-(abs(vec[i-1]-vec[i])+abs(vec[i]-vec[i+1]))+(abs(vec[i-1]-vec[i+1]))<<endl;
    }
    return 0;
}

Measured memory_bytes: 1664
N,A,B = map(int,input().split())
S = input()

count_in = 0
count_out = 0
for s in S:
    if s == 'a':
        if count_in+count_out<A+B:
            print('Yes')
            count_in += 1
            continue

    if s == 'b':
        if count_out<B and count_in+count_out<A+B:
            print('Yes')
            count_out += 1
            continue
    print('No')



Measured memory_bytes: 9192
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

H, W, N = lr()
shift = ((0, 0), (0, 1), (1, 0), (0, -1), (-1, 0), (1, 1), (-1, -1), (-1, 1), (1, -1))

l = []

for n in range(N):
    a, b = lr()
    for s in shift:
        aa = a + s[0] - 1
        bb = b + s[1] - 1
        if aa < 1 or aa > H-2:
            continue
        if bb < 1 or bb > W-2:
            continue
        l.append((aa-1, bb-1))
if len(l) == 0:
    print((H-2) * (W-2))
    [print(0) for _ in range(9)]
    exit(0)
l.sort()
m = {i: 0 for i in range(10)}
pre = l[0]
c = 1
for ll in l[1:]:
    if pre == ll:
        c += 1
    else:
        m[c] += 1
        pre = ll
        c = 1
m[c] += 1
m[0] = (H-2) * (W-2) - sum(m.values())
for v in m.values():
    print(v)


Measured memory_bytes: 142680
#include<stdio.h>
int main()
{
  int x,y;
  while(1){
    scanf("%d%d",&x,&y);
    if(x==0&&y==0)break;
    else  if(x>=y){printf("%d %d\n",y,x);
    }else{printf("%d %d\n",x,y);
    }
  }
  return 0;
}



Measured memory_bytes: 2060
n, c, k, *t = map(int, open(0).read().split())
t.sort()
tmp = 0
cnt = 0
limit = t[0] + k
for time in t:
    if tmp == c or time > limit:
        limit = time + k
        tmp = 1
        cnt += 1
    else:
        tmp += 1
print(cnt + 1)

Measured memory_bytes: 19948
from math import ceil, floor

n = int(input())
x = list(map(int, input().split()))
tmin = float('inf')
for i in range(1, max(x) + 1):
	cur = 0
	for j in x:
		cur += (i - j) ** 2
	tmin = min(cur, tmin)
print(tmin)

Measured memory_bytes: 3060
#include "bits/stdc++.h"

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

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


signed main(){

	int A, B, Q;
	cin >> A >> B >> Q;
	int s[123456] = { 0 }, t[123456] = { 0 };
	rep(i, A)
		cin >> s[i];
	rep(i, B)
		cin >> t[i];

	rep(q, Q){
		int x;
		cin >> x;

		int sgi = lower_bound(s, s + A, x) - s;	// x以上の最初
		int sg;
		if (sgi >= A) sg = INF;
		else sg = s[sgi];
		int sl = -INF;
		if (sgi >= 1) sl = s[sgi - 1];

		int tgi = lower_bound(t, t + B, x) - t;	// x以上の最初
		int tg;
		if (tgi >= B) tg = INF;
		else tg = t[tgi];
		int tl = -INF;
		if (tgi >= 1) tl = t[tgi - 1];

		int ans = INF;
		// 左に2つ
		ans = min(ans, abs(x - min(sl, tl)));
		// 左から右
		ans = min(ans, abs(x - sl) + abs(tg - sl));
		ans = min(ans, abs(x - tl) + abs(sg - tl));
		// 右から左
		ans = min(ans, abs(x - sg) + abs(sg - tl));
		ans = min(ans, abs(x - tg) + abs(tg - sl));
		// 右に2つ
		ans = min(ans, abs(x - max(sg, tg)));
		cout << ans << endl;
	}
	
		return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
 
#define froop1(a,n) for(int i = a;i < n;i++)
#define froop2(a,n) for(int i = a;i > n;i--)
 
#define ll long long
 
#define pq(name,type) priority_queue<type> name
#define vec(name,type,length,value) vector<type> name(length,value)
#define vec2(name,type,length,width,value) vector<vector<type>> name(length,vector<type>(width,value));
 
int main(){
	int N;
  cin >> N;
	froop1(0,N){
cout << "ACL";
    }
  cout << endl;
return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    bool flag = true;
    int count=0;
    int tmp;
    while(flag){
        flag=false;
        for(int i=n-1;i>0;i--){
            if(a[i]<a[i-1]){
                tmp=a[i];
                a[i]=a[i-1];
                a[i-1]=tmp;
                flag=true;
                count++;
            }
        }
    }
    for(int i=0;i<n;i++){
        if(i!=n-1)cout << a[i] << ' ';
        else{
            cout << a[i] << endl;
            cout << count << endl;
        }
    }
}


Measured memory_bytes: 3116
#include<stdio.h>
#include<math.h>

double average(double *s, int i_n){
	double answer = 0.0;
	int i;
	for (i = 0; i < i_n; i++){
		answer = answer + *s;
		s++;
	}
	return answer / (double)i_n;
}

double deflection(double s[1000],int i_n){
	double answer = 0.0;
	int i;
	for (i = 0; i < i_n; i++){
		answer = answer + pow((s[i] - average(s, i_n)), 2.0);
	}
	answer = answer / (double)i_n;
	return pow(answer, 0.5);
}

int main(void){
	double s[1000][1000];
	int n[1000];

	int i = 0,i_n;
	for(i=0;i<1000;i++){
	   scanf("%d",&n[i]);
	   if(n[i]==0)
	    break;
	       
	    for(i_n=0;i_n<n[i];i_n++){
	        scanf("%lf",&s[i][i_n]);
	    }
	}

	for (i_n = 0; i_n < i;i_n++){
		printf("%.5f\n",deflection(s[i_n], n[i_n]));
	}


	return 0;
}


Measured memory_bytes: 2088
#include <stdio.h>

int main(void) {
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	printf("%d\n", a+b > a-b ? a+b > a*b ? a+b : a*b : a-b > a*b ? a-b : a*b);

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int bfs(int, int, int);
int a[11];
int main(){
	int n;
	cin >> n;
	for (int i = 0; i < n; i++){
		for (int i2 = 0; i2 < 10; i2++){
			cin >> a[i2];
		}
		a[10] = 0;
		int ans=bfs(0, 0, 0);
		if (ans == 0){
			cout << "NO" << endl;
		}
		else{
			cout << "YES" << endl;
		}
	}
	
}
int bfs(int i, int l, int r){
	int ans = 0;
	if (i == 10){
		ans = 1;
	}
	if (l < a[i]){
		ans = bfs(i + 1, a[i], r);
	}
	if (r < a[i]){
		ans = bfs(i + 1, l, a[i]);
	}
	return ans;
}

Measured memory_bytes: 1152
import Control.Applicative
import Control.Monad
import Control.Monad.ST
-- import qualified Data.ByteString as BS
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import qualified Data.Foldable as Foldable
import qualified Data.Set as Set
--import qualified Data.Sequence as Sequence
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
--import Data.Array.Unboxed
--import Data.Array.IArray
import Data.Array.MArray
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
import GHC.ST
-- import System.IO.Unsafe

-- templete
readInt = read :: String -> Int
readInteger = read :: String -> Integer
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getInteger = readLn :: IO Integer
getIntegers = map readInteger . words <$> getLine
getDouble = readLn :: IO Double
getDoubles = map readDouble . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
tjoin :: (Show a, Show b) => (a, b) -> String
tjoin (x, y) = show x ++ (' ' : show y)
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
apply4 :: (a -> a -> a -> a -> b) -> [a] -> b
apply4 f [x,y,z,w] = f x y z w
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
binMap :: (a -> a -> b) -> [a] -> [b]
binMap f (x:xs@(y:_)) = f x y : binMap f xs
binMap _ _ = []
splitRec :: Int -> [a] -> [[a]]
splitRec _ [] = []
splitRec n xs = let (y,ys) = splitAt n xs in y : splitRec n ys
infixl 7 `divCeil`
divCeil :: Integral a => a -> a -> a
x `divCeil` y = (x+y-1) `div` y
coverC :: Ord a => (a, a) -> a -> Bool
coverC (l,r) x = l<=x && x<=r
coverH :: Ord a => (a, a) -> a -> Bool
coverH (l,r) x = l<=x && x<r
ibsearch :: (Int -> Bool) -> (Int,Int) -> Int
ibsearch f (ok,ng) = if abs (ok-ng) <= 1 then ok else let mid = (ok + ng) `div` 2 in ibsearch f (if f mid then (mid,ng) else (ok,mid))
-- templete

check s = all (uncurry (==)) $ zip s [1..]

op s = osub 0 s
  where
    osub n [] = [n]
    osub n (1:xs) = osub (n+1) xs
    osub n (x:xs) = let r = osub (n+1) xs in (x-1) : r

f s = let g i xs = if check xs then i else if i==10000 then (-1) else g (i+1) (op xs) in g 0 s


main = do
    n <- getInt
    unless (n==0) $ getInts >>= print . f >> main


Measured memory_bytes: 76980
#!/usr/bin/env pypy3
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    a,b,c=MI()
    if a==b:
        print(c)
    else:
        print(a+b-c)

main()


Measured memory_bytes: 38256
#include<iostream>

using namespace std;

int get_max(int A,int B){

    int max;
    max = A+(A-1);
    if(A+B>max){
        max = A+B;
    }
    if(B+B-1>max){
        max = B+(B-1);
    }

    return max;

}

int main(){
    int A,B;
    int max_return;
    cin>>A>>B;

    max_return = get_max(A,B);

    cout<<max_return<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define llint long long

using namespace std;

llint n;
llint a[55];

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	
	llint ans = 0;
	for(int i = 1 ; i <= n; i++){
		for(int j = 1; j <= n; j++){
			if(i >= j) continue;
			ans += a[i]*a[j];
		}
	}
	cout << ans << endl;
	
	return 0;
}

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

  
  int main(){
    int n;
    string s;
    cin >> n;
    if (n >= 1200) cout << "ARC" << endl;
    else cout << "ABC" << endl;

    return 0;
  }


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstring>
#include <cmath>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using P = pair<int, int>;
const int INF = 1e9;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int k;
  cin >> k;
  vector<vector<int>> to(k), co(k);
  rep(i, k) {
    to[i].push_back((i+1)%k);
    co[i].push_back(1);
    to[i].push_back(i*10%k);
    co[i].push_back(0);
  }
  priority_queue<P, vector<P>, greater<P>> que;
  vector<int> node(k, INF);
  node[1] = 1;
  que.push({1, 1});
  while (!que.empty()) {
    int cost, now;
    tie(cost, now) = que.top();
    que.pop();
    if (cost > node[now])
      continue;
    rep(i, to[now].size()) {
      int next = to[now][i];
      int dist = co[now][i]+cost;
      if (chmin(node[next], dist))
        que.push({dist, next});
    }
  }
  cout << node[0] << endl;
  return 0;
}

Measured memory_bytes: 12288
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define clear(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

typedef long long ll;
typedef pair<int, int> pint;

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };



int w, h;
char s[32][32];

int counter = 0;
//map<int, int> states;
short pos[1 << 20];
int states[17777];
bool used_j[32];
void make_states(int p)
{
	if (p == w)
	{
		int s = 0;
		for (int i = 0; i < w; ++i)
			s |= used_j[i] << i;
		//int pos = states.size();
		//states[s] = pos;

		states[counter] = s;
		pos[s] = counter++;
	}
	else
	{
		make_states(p + 1);
		if (p == 0 || !used_j[p - 1])
		{
			used_j[p] = true;
			make_states(p + 1);
			used_j[p] = false;
		}
	}
}
int main()
{
	cin >> h >> w;
	rep (i, h)
		cin >> s[i];
	make_states(0);

	const int mod = 100000;
	static int dp[401][17777];
	dp[0][0] = 1;
	for (int i = 0; i < w * h; ++i)
	{
		int x = i % w, y = i / w;
		//foreach (it, states)
		for (int j = 0; j < counter; ++j)
		{
			//int S = it->first;
			//int cur = dp[i][it->second];
			int S = states[j];
			int cur = dp[i][j];

			int T = ((S >> 1) << 2) & ((1 << w) - 1);
			int J = S & 1;

			if (s[y][x] == 'J' || s[y][x] == '?')
			{
				(dp[i + 1][pos[T | (x < w - 1)]] += cur) %= mod;
			}

			if (s[y][x] == 'O' || s[y][x] == '?')
			{
				(dp[i + 1][pos[T | (J ? (1 << 1) : 0)]] += cur) %= mod;
			}

			if (s[y][x] == 'I' || s[y][x] == '?')
			{
				if (!(S >> (w - 1) & 1))
					(dp[i + 1][pos[T]] += cur) %= mod;
			}
		}
	}


	int hatena = 0;
	for (int i = 0; i < h; ++i)
		for (int j = 0; j < w; ++j)
			if (s[i][j] == '?')
				++hatena;
	int all_pattern = 1;
	for (int i = 0; i < hatena; ++i)
		(all_pattern *= 3) %= mod;

	int non_joi = 0;
	for (int i = 0; i < counter; ++i)
		(non_joi += dp[w * h][i]) %= mod;

	int res = (all_pattern - non_joi + mod) % mod;
	cout << res << endl;
	//cout << "all: " << all_pattern << endl;
	//cout << "non_joi: " << non_joi << endl;
}

Measured memory_bytes: 26000
import sys
sys.setrecursionlimit(10**9)

def main():
    n, m, k = map(int, input().split())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))

    a.insert(0, 0)
    b.insert(0, 0)

    a_sum = [0]*(n+1)
    a_sum[0] = a[0]
    for i in range(1, n+1):
        a_sum[i] = a_sum[i-1] + a[i]

    b_sum = [0]*(m+1)
    b_sum[0] = b[0]
    for i in range(1, m+1):
        b_sum[i] = b_sum[i-1] + b[i]

    b_sum = b_sum[::-1]

    i_b = 0
    ans = 0
    for i_a in range(n+1):
        while i_b <= m:
            if k < a_sum[i_a] + b_sum[i_b]:
                i_b += 1
                continue
            else:
                ans = max(ans, i_a+(m-i_b))
                break

    print(ans)
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Measured memory_bytes: 117792
/*
g++ -std=c++11 -o2 -Wall ABC097D.cpp -o ./out/ABC097D.out
./out/ABC097D.out
*/

#include <bits/stdc++.h>
using namespace std;

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define tr(c, i) for (iter(c) != (c).begin(); i != (c).end(); ++i)
#define pb push_back
#define mp make_pair

typedef long long ll;

class Union_Find{
private:
    vector<int> par, rank;

    int find(int x){
        if(par[x] == x){
            return x;
        }else{
            return par[x] = find(par[x]);
        }
    }
public:
    Union_Find(int Max_Node){
        par.resize(Max_Node);
        rank.resize(Max_Node);
    }

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

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

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

    bool same(int x, int y){
        return (find(x) == find(y));
    }
};

int main(){
//    freopen("./input/input.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> in(n);
    for(int i = 0; i < n; i++)cin >> in[i];
    Union_Find uf(n + 10);
    uf.init(n + 1);
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        uf.unite(a, b);
        uf.unite(b, a);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        if(uf.same(in[i], i+1)){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(), x.end()

int main() {
  ll n, r;
  cin >> n >> r;
  if (n > 10) {
    cout << r << endl;
  } else {
    cout << r + 100 * (10 - n) << endl;
  }
}

Measured memory_bytes: 256
#include<cmath>
#include <atcoder/all>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
using namespace atcoder;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    ll q;
    cin >> q;
    rep(i,q){
        ll n,m,a,b;
        cin >> n>> m>> a>> b;
        cout<<floor_sum(n,m,a,b)<<endl;
    }
    return 0;
}

Measured memory_bytes: 3668
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int n;
    while(cin >> n,n){
        vi a(2*n,0),b(2*n,1);
        rep(i,n){
            int t;
            cin >> t;
            t--;
            a[t]++;
            b[t]--;
        }
        //rep(i,2*n)cout << i << " " << a[i] << " " << b[i] << endl;
        int t = -1, turn = 0;
        int taro = n, hanako = n;
        while(taro && hanako){
            if(turn){
                int i = 0;
                while(i < 2*n){
                    if(b[i] && t < i){
                        b[i]--;
                        t = i;
                        hanako--;
                        //cout << "HANAKO " << i << endl;
                        break;
                    }
                    i++;
                }
                if(i == 2*n){
                    t = -1;
                }
                turn = 0;
            }else{
                int i = 0;
                while(i < 2*n){
                    if(a[i] && t < i){
                        a[i]--;
                        t = i;
                        taro--;
                        //cout << "TARO " << i << endl;
                        break;
                    }
                    i++;
                }
                if(i == 2*n){
                    t = -1;
                }
                turn = 1;
            }
        }
        cout << hanako << endl;
        cout << taro << endl;
    }
}



Measured memory_bytes: 3012
#include <stdio.h>

int main(void) {
    int r, D, x;

    scanf("%d%d%d", &r, &D, &x);

    int i;

    for (i = 0; i < 10; i++) {
        x = r * x - D;
        printf("%d\n", x);
    }

    return 0;
}

Measured memory_bytes: 128
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned lon long
///////////////////////////////////////////////////////////
int absolute(int n); double absolute(double n);
void input(vector<int>& vec);
void print(vector<int> vec); void print(vector<double> vec);
int sum(vector<int> vec); double sum(vector<double> vec);
void upsort(vector<int>& vec);
void downsort(vector<int>& vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    int n,k;
    cin >> n>>k;
    vector<int>h(n);
    input(h);
    int count=0;
    for(int i=0;i<n;++i){
        if(h.at(i)>=k){
            ++count;
        }
    }
    cout << count << endl;
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

double absolute(double n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

void input(vector<int>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void print(vector<int> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

void print(vector<double> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

int sum(vector<int> vec)
{
    int s = accumulate(vec.begin(), vec.end(), 0);
    return s;
}

double sum(vector<double> vec)
{
    double s = accumulate(vec.begin(), vec.end(), 0.0);
    return s;
}

void upsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end());
}

void downsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

int minvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 640
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#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 revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    int D; cin >> D;
    if (D == 25) cout << "Christmas";
    else if (D == 24) cout << "Christmas Eve";
    else if (D == 23) cout << "Christmas Eve Eve";
    else cout << "Christmas Eve Eve Eve";
    cout << endl;
}

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

using namespace std;

int ar[100000];

int main(){
    int N;
    cin >> N;
    for(int x = 1; x <= 100; x++){
        for(int y = 1; y <= 100; y++){
            for(int z = 1; z <= 100; z++){

                int val = x*x + y*y + z*z;
                val += x*y + x*z + y*z;
                if(val <= N)
                    ar[val]++;

            }
        }
    }
    for(int i = 1; i <= N; i++){
        cout << ar[i] << "\n";
    }

}


Measured memory_bytes: 3560
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int K,A,B;
  
  cin >> K >> A >> B;
  
  bool judge = true;
  
  for (int i=0;i<1000;i++){
    
    if (A<=i*K && i*K<=B){
      cout << "OK" << endl;
      judge = false;
      break;
    }
    
  }
  
  if (judge){
    cout << "NG" << endl;
  }
}
  


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

int main() {
  string s;
  cin >> s;
  bool ok = true;
  rep(i,s.size()) {
    if (i % 2 == 0) {
      if (s.at(i) == 'L') ok = false;
    } else {
      if (s.at(i) == 'R') ok = false;
    }
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<string>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);
	long long n,a=2,b=1,t;
	cin>>n;
	for(int i = 1;i < n;i++)
	{
		a = a+b;
		t = b;
		b = a;
		a = t;
		//cout<<a<<' '<<b<<'\n';
	}
	cout<<b;
	return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

typedef long long ll;
typedef pair<int, int> pi;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<vb> vmb;
typedef vector<vi> vmi;
typedef vector<vll> vmll;

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

    vi weight(n), value(n);
    for (int i = 0; i < n; ++i)
        cin >> weight[i] >> value[i];

    vll dp(w + 1, 0);
    for (int i = 0; i < n; ++i)
        for (int j = w; j >= weight[i]; j--)
            dp[j] = max(dp[j], value[i] + dp[j - weight[i]]);

    cout << dp[w];
    return 0;
}

Measured memory_bytes: 1024
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
        //MyDebugger.Test(process, "../TextFile2.txt");
        //MyDebugger.MakeTestCase("../TextFile2.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl   = input.ReadLine().Split(' ');
        var n     = int.Parse(spl[0]);
        var m     = int.Parse(spl[1]);

        var citys = new List<City>(m);
        var areas = new Dictionary<int, List<City>>(n);
        for(int i=0; i<n; i++) {
            areas.Add(i + 1, new List<City>());
        }

        for(int i=0; i<m; i++) {
            var c = new City();
            spl = input.ReadLine().Split(' ');
            c.p = int.Parse(spl[0]);
            c.y = int.Parse(spl[1]);
            citys.Add(c);
            areas[c.p].Add(c);
        }

        foreach(var a in areas.Values) {
            var i = 0;
            a.Sort((x, y) => x.y - y.y);
            foreach(var c in a) {
                i++;
                c.makecode(i);
            }
        }

        var buil = new StringBuilder();
        foreach (var i in citys) {
            buil.AppendLine(i.code);
        }
        return buil;
    }

    class City
    {
        public int p;
        public int y;
        public string code;

        public void makecode(int idx) {
            code = string.Format("{0:D6}{1:D6}", p, idx);
        }
    }

    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}

Measured memory_bytes: 46004
#include "bits/stdc++.h"

using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
constexpr ld EPS = 1e-12;
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr int MOD = 1e9 + 7;

template <typename T>
void printv(const vector<T> &v) {
  int sz = v.size();
  for (int i = 0; i < sz; i++) {
    cout << v[i] << " \n"[i == sz - 1];
  }
}

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

  ll t1, t2, a1, a2, b1, b2;
  cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
  if (a1 <= b1 && a2 <= b2) {
    cout << 0 << endl;
    return 0;
  }
  if (a1 >= b1 && a2 >= b2) {
    cout << 0 << endl;
    return 0;
  }
  ll d1 = a1 * t1 + a2 * t2, d2 = b1 * t1 + b2 * t2;
  if (a1 * t1 < b1 * t1 && d1 < d2) {
    cout << 0 << endl;
    return 0;
  }
  if (a1 * t1 > b1 * t1 && d1 > d2) {
    cout << 0 << endl;
    return 0;
  }
  if (d1 == d2) {
    cout << "infinity" << endl;
    return 0;
  }
  ll dif = abs(d1 - d2);
  ll dmax = abs(a1 * t1 - b1 * t1);
  bool touch = (dmax % dif == 0);
  cout << 1 + (dmax - 1) / dif * 2 + (touch ? 1 : 0) << endl;
}


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

int main() {
    int n;
    cin >> n;
    int a[n][n];
    bool isNecessary[n][n];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> a[i][j];
            isNecessary[i][j] = true;
        }
    }
    for (int k = 0; k < n; k++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                if (a[i][j] > a[i][k] + a[k][j]) {
                    cout << -1 << endl;
                    return 0;
                }
                if (a[i][j] == a[i][k] + a[k][j] && a[i][k] > 0 && a[k][j] > 0) {
                    isNecessary[i][j] = false;
                }
            }
        }
    }
    ll ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            if (isNecessary[i][j]) ans += a[i][j];
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define ll long long int 
#define MOD 1000000007
#define sc(a) scanf("%lld",&a)
#define f0(n) for(ll i=0;i<n;i++)
#define f1(n) for(ll i=1;i<=n;i++)
#define pb(v,a) v.push_back(a)
#define pbp(v,a,i) v.push_back(make_pair(a,i)) 
#define srt(v) sort(v.begin(),v.end());

int main()
{
	string s="ABC",ss="ARC",in;
	cin>>in;
	if(in==s)
		cout<<ss<<endl;
	else
		cout<<s<<endl;
}

Measured memory_bytes: 3632
#include <iostream>

using namespace std;
 
int main(){
    int sx, sy, tx, ty;

    cin >> sx >> sy >> tx >> ty;

    for(int i = 0; i < ty-sy; i++){
        cout << 'U';
    }
    for(int i = 0; i < tx-sx; i++){
        cout << 'R';
    }
    for(int i = 0; i < ty-sy; i++){
        cout << 'D';
    }
    for(int i = 0; i <= tx-sx; i++){
        cout << 'L';
    }
    for(int i = 0; i <= ty-sy; i++){
        cout << 'U';
    }
    for(int i = 0; i <= tx-sx; i++){
        cout << 'R';
    }
    cout << 'D';
    cout << 'R';
    for(int i = 0; i <= ty-sy; i++){
        cout << 'D';
    }
    for(int i = 0; i <= tx-sx; i++){
        cout << 'L';
    }
    cout << 'U' << endl;

    return 0;
}


Measured memory_bytes: 256
import numpy as np

n = int(input())
h_list = list(map(int,input().split()))
h = np.array(h_list)

can_see = 1  # 海の見える旅館の数  # 一番最初の旅館からは必ず見える
for i in range(1, n):
    if not np.any((h > h[i])[:i]):
        can_see+=1

print(can_see)

Measured memory_bytes: 14428
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include<stdio.h>
#include<math.h>
int main() {
	double r;
	scanf("%lf", &r);
	printf("%lf %lf\n",r*r*M_PI,2*r*M_PI);
	return 0;
}

Measured memory_bytes: 648
#include<stdio.h>

int W;
int H;
int x;
int y;
int r;

int main(){
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    if((x - r < 0 || x + r > W) || (y - r < 0 || y + r > H))
        printf("No\n");
    else
        printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1012
function Main(input) {
  input = input.trim()
  input = input.split(" ").map(Number);
  input[1]+=100;
  input[0]+=100;
  input[2]+=100;
if(input[0]<=input[2]&&input[1]>=input[2]){
console.log("Yes")
}else{
console.log("No")
}
}Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("filed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}


fn main() {
    let mut n:usize = read();
    n %= 100;
    n %= 10;
    match n {
        2| 4| 5| 7|9 => println!("hon"),
        0| 1| 6| 8 => println!("pon"),
        3 => println!("bon"),
        _ => panic!("")
    }
}


Measured memory_bytes: 2168
s = int(input())

l,r = False,False
if s%100 in range(1,12+1):
    r = True
if s//100 in range(1,12+1):
    l = True

f = {(False,False):'NA', (False,True):'YYMM', (True,False):'MMYY', (True,True):'AMBIGUOUS', }

print(f[(l,r)])


Measured memory_bytes: 3060
#include <stdio.h>
#define INFTY 2000000000
void merge(int*, int, int, int);
void mergeSort(int*, int, int);
int L[250002],R[250002];
int count;
 
int main(){
  int A[500000],n;
  int i;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  mergeSort(A,0,n);
 
  for(i = 0; i < n-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[i],count);
  return 0;
}
 
void merge(int* A, int left,int mid, int right){
  int n1,n2;
  int i,j,k;
  n1 = mid - left;
  n2 = right - mid;
 
  for(i = 0; i < n1; i++){
    L[i] = A[left + i];
  }
  for(i = 0; i < n2; i++){
    R[i] = A[mid + i];
  }
  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0; 
  j = 0;
  for(k = left; k < right; k++){
    count++;
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }
    else{
      A[k] = R[j];
      j = j + 1;
    }
  }
}
 
void mergeSort(int* A, int left, int right){
  int mid;
  if(left + 1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}

Measured memory_bytes: 4504
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;
long long combi(long long n, long long k) {
	if (n == k || k == 0)
		return 1;
	else {
		return combi(n - 1, k - 1) + combi(n - 1, k);
	}
}
int main() {
	string s;
	cin >> s;
	if (s == "Sunny")cout << "Cloudy" << endl;
	if (s == "Cloudy")cout << "Rainy" << endl;
	if (s == "Rainy")cout << "Sunny" << endl;
	return 0;
}

Measured memory_bytes: 256