akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
int mx(int x,int y,int z)
{
    if(x >= y && x >= z) return x;
    else if(y >= z && y >= x) return y;
    else return z;
}
void lz(int &x, int &y, int &z, int &cnt)
{
    if((x%2 == 0 && y%2 == 0 && z%2 == 0) || (x%2 != 0 && y%2 != 0 && z%2 != 0))
    {
        cnt--;
    }
    else if((x%2 == 0 && y%2 == 0) || (x%2 != 0 && y%2 != 0))
    {
        x++;
        y++;
    }
    else if((x%2 == 0 && z%2 == 0) || (x%2 != 0 && z%2 != 0))
    {
        x++;
        z++;
    }
    else if((y%2 == 0 && z%2 == 0) || (y%2 != 0 && z%2 != 0))
    {
        y++;
        z++;
    }
}
int main()
{
    int x,y,z;
    cin >> x >> y >> z;
    int cnt = 1;
    //cout << Max;
    lz(x, y, z, cnt);
    int Max = mx(x,y,z);
    cnt += (Max-x + Max-y + Max-z)/2;
    cout << cnt;
    return 0;
}

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

using namespace std;

const ll inf=1000000007;

inline int read()
{
    int x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9')
    {
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}

string s;

int main()
{
    cin >> s;
    int k=0;
    for(int i=0;i<s.length();i++)
    {
        k=k+s[i]-48;
    }
    if(k%9==0)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}


Measured memory_bytes: 3760
"""
author : halo2halo
date : 15, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

d = {'A': 'T', 'T': 'A', 'G': 'C', 'C': 'G'}
b = readline().decode('utf8').split()
print(d[b[0]])


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

int main(){
int H,W;
  cin>>H>>W;
char C[H][W];
  for(int i=0;i<H; i++){
   for(int j=0; j<W; j++){
    cin>>C[i][j]; }}
  
  for(int i=0; i<H; i++){
   for(int j=0; j<W; j++){
    cout<<C[i][j];
   }
    cout<<endl;
    
   for(int j=0; j<W; j++){
    cout<<C[i][j];
   }
    cout<<endl;
  }
  
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string s,k;
  cin>>s>>k;
  int f=0;
  for(int i=0;i<s.size();i++){
	  if(s[i]!=k[i]){
		 f=1;
		 break;  
	  }  
  }
  if(f==1)cout<<"No\n";
  else cout<<"Yes\n";
  
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5005; 
const int MOD = 1e9 + 7; 

int dp [MAXN][2*MAXN]; 
int num_op; 
main(){
    ios_base::sync_with_stdio(0); 
    cin >> num_op; 
    int n = 0; 
    
    char t; while (cin >> t) n++; 
    
    dp[0][0] = 1; 
    
    for (int i=1; i<=num_op; i++){
        for (int j=0; j<=n+num_op; j++){
            dp[i][j] = (dp[i-1][max(0,j-1)]); 
            dp[i][j] = (dp[i][j] + 2ll * dp[i - 1][j + 1]) % MOD;
        }
    }
    cout << dp[num_op][n] << '\n'; 
    return 0; 
}

Measured memory_bytes: 195712
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <math.h>
#include <string.h>
using namespace std;

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

    int cnt = 0;
    
    for(int i = 1; i <= n; i++){
        string s = to_string(i);
        if(s.length() % 2 == 1){
            cnt++;
        }
    }

    cout << cnt << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define int long long
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
#define MOD 1000000007
#define INF 1000000000000000007
#define MAXN 300005

// it's swapnil07 ;)
priority_queue<int> pq;
vector<pii> vect;

signed main(){
    fast
    #ifdef SWAPNIL07
        freopen("/home/swapnil/Desktop/c++/input.txt","r",stdin);
        freopen("/home/swapnil/Desktop/c++/output.txt","w",stdout);
    #endif
    int n, m; cin>>n>>m;
    For(i, 0, n){
        int a, b; cin>>a>>b;
        vect.pb({a, b});
    }
    sort(all(vect));
    int j = 0;
    int ans = 0;
    for(int i=1; i<=m; i++){
        for(j; j<vect.size(); j++){
            int x = vect[j].F;
            int y = vect[j].S;
            if(x > i){
                break;
            }
            pq.push(y);
        }
        if(!pq.empty()){
            int v = pq.top();
            ans += v;
            pq.pop();
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3568
#include <iostream>
#include <sstream>
#include <cstdio>
#include <stdlib.h>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

char ans[5];
int i;
void toa(long long n){
  if(n<=0)return;
  int th = n % 26;
  th = (th ==0 ) ? 26:th;
  char c = (char)(96+th);
  ans[i++]=c;
  if (th == n ){
    return;
  }
  toa((n-th)/26);
}
int main(){
  long long n;
  cin>>n;
  toa(n);
  for(i--;i>=0;i--){
    cout<<ans[i];
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define INF 999999999
#define mod 10e9+7

#define rep(i,n) for(int i=1;i<=n;i++)
int main(){
   ll a,b,mini=INF,all=0;
   cin >> a>>b;
   
   cout << a+b/2 << endl;

   
  }



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,x,n1,n2;
	cin>>k>>x;
	n1=max(-1000000,x-k+1);
	n2=x+k-1;
	if(n2>1000000) n2=1000000;
	for(int i=n1;i<=n2;i++){
		cout<<i<<" ";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<algorithm>
#include<cmath>
#include<set>
using namespace std;
int64_t B[5001][201];
int64_t ans[5001][5001]={};
void solv(int i,int j,int x){//i~j,xというチケットについて考える。
    if(i<j){
        int ma=0;
        int nma;
        for(int k=i;k<j;k++){
            if(B[k][x]>ma){
                ma=B[k][x];
                nma=k;
            }
        }
        ans[i][nma]+=ma;
        ans[i][j]-=ma;
        ans[nma+1][nma]-=ma;
        ans[nma+1][j]+=ma;
        solv(i,nma,x);
        solv(nma+1,j,x);
    }
}



int main(){
    int64_t N,M;
    int64_t A[5001]={};
    cin>>N>>M;
    for(int i=1;i<=N-1;i++){
        cin>>A[i];
        A[i]=A[i]+A[i-1];
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>B[i][j];
        }
    }
    for(int i=0;i<M;i++){
        solv(0,N,i);
    }
    int64_t res=0;
    for(int i=0;i<N;i++){
        for(int j=0;j<N;j++){
            if(i!=0 && j!=0){
                ans[i][j] += ans[i][j-1]+ans[i-1][j]-ans[i-1][j-1];
            }
            if(i==0 && j!=0){
                ans[i][j] += ans[i][j-1];
            }
            if(i!=0 && j==0){
                ans[i][j] += ans[i-1][j];
            }
        }
    }
    for(int i=0;i<N;i++){
        for(int j=i;j<N;j++){
            res = max(res,ans[i][j] - (A[j]-A[i]));
        }
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 203520
#include<bits/stdc++.h>
#include<time.h>
#include<stdlib.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long
#define pll pair<ll,ll>
#define vll vector<ll,ll>
#define all(a) (a).begin(),(a).end()
#define ff first
#define ss second
#define sz(x) (ll)x.size()
#define hell 1000000007
#define repf(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>b;i--)
#define lbnd lower_bound
#define ubnd upper_bound
#define bs binary_search
#define gcd(a,b) __gcd((a),(b))
#define EPS 1e-12
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sqrt sqrtl
#define cbrt cbrtl
using namespace std;
ll h,w,a1,b;
char a[1005][1005];
void check()
{
	ll i,j;
	for(i=1;i<=h;i++)
		for(j=1;j<=w;j++)
			a[i][j]='0';
	j=1;
	i=1;
	   	while(i<=h && j<=w)
		{
			ll si=i;
			ll sj=j;
			
			while(si<min(h+1,i+h-b))
			{
				while(sj<min(w+1,j+w-a1))
				{
					a[si][sj]='1';
					sj++;
				}
				si++;
				sj=j;
			}
			i+=h-b;
			j+=w-a1;
		}
	
  for(i=1;i<=h;i++)
  {
  	 ll cnt1=0,cnt0=0;
  	 for(j=1;j<=w;j++)
  	 	if(a[i][j]=='1')
  	 		cnt1++;
  	 	else
  	 		cnt0++;
  	 if(min(cnt1,cnt0)!=a1)
  	 	{
  	 		
  	 		cout<<-1;
  	 		exit(0);
  	 	}
  }
  for(j=1;j<=w;j++)
  {
  	 ll cnt1=0,cnt0=0;
  	 for(i=1;i<=h;i++)
  	 	if(a[i][j]=='1')
  	 		cnt1++;
  	 	else
  	 		cnt0++;
  	 if(min(cnt1,cnt0)!=b)
  	 {
  	 	cout<<-1;
  	 	exit(0);
  	 }	
  }
  for(i=1;i<=h;i++)
  {
  	for(j=1;j<=w;j++)
  		cout<<a[i][j];
  	cout<<"\n";
  }
}
int main()
{
  IOS
  cin>>h>>w>>a1>>b;
  
  ll i,j;
  for(i=1;i<=h;i++)
  	for(j=1;j<=w;j++)
  		a[i][j]='0';
  j=1;
  i=1;
  while(i<=h)
  {
  	 ll cnt=0;
  	 while(cnt<a1)
  	 {
  	 	cnt++;
  	 	a[i][j]='1';
  	 	j++;
  	 	if(j>w)
  	 		j=1;
  	 }
  	 i++;	
  }
  j=1;i=1;
  ll ss=1;
  while(j<=w)
  {
  	    ll cnt0=0,cnt1=0;
  		for(i=1;i<=h;i++)
  			if(a[i][j]=='0')cnt0++;
  			else
  				cnt1++;
  		if(min(cnt1,cnt0)!=b)
  		{
  			ll diff=b-min(cnt1,cnt0);
  			while(diff>0)
  			{
  				ll k=1;
  				for(;k<=w;k++)
  					a[ss][k]='1';
  				diff--;
  				ss++;
  				if(ss>h)
  					ss=1;
  			}
  		}
  		j++;
  }
  for(i=1;i<=h;i++)
  {
  	 ll cnt1=0,cnt0=0;
  	 for(j=1;j<=w;j++)
  	 	if(a[i][j]=='1')
  	 		cnt1++;
  	 	else
  	 		cnt0++;
  	 if(min(cnt1,cnt0)!=a1)
  	 	{
  	 		check();
  	 		exit(0);
  	 	}
  }
  for(j=1;j<=w;j++)
  {
  	 ll cnt1=0,cnt0=0;
  	 for(i=1;i<=h;i++)
  	 	if(a[i][j]=='1')
  	 		cnt1++;
  	 	else
  	 		cnt0++;
  	 if(min(cnt1,cnt0)!=b)
  	 {
  	 	check();
  	 	return 0;
  	 }	
  }
  for(i=1;i<=h;i++)
  {
  	for(j=1;j<=w;j++)
  		cout<<a[i][j];
  	cout<<"\n";
  }
  return 0;
}                   

Measured memory_bytes: 2176
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int t = sc.nextInt();
		int[] imos = new int[t + 2];
		for (int i = 0; i < n; i++) {
		    imos[sc.nextInt()]++;
		    imos[sc.nextInt()]--;
		}
		int max = imos[0];
		for (int i = 1; i <= t; i++) {
		    imos[i] += imos[i - 1];
		    max = Math.max(max, imos[i]);
		}
		System.out.println(max);
	}
}



Measured memory_bytes: 70376
d, g = (int(i) for i in input().split())
p = [[int(i) for i in input().split()] for i in range(d)]
ans = 1000

for i in range(1 << d): # 4
    score = 0
    num = 0
    rest = 0
    for j in range(d): # 2
        if ((i >> j) & 1) == 1: # 0 1  2=10
            score += p[j][0] * 100 * (j + 1) + p[j][1]
            num += p[j][0]
        else:
            rest = j
    if score < g:
        need = (g - score - 1) // (100*(rest+1)) + 1
        if need > p[rest][0] - 1: # 0だったところの中で一番大きいところの問題数-1よりも必要手数が多かったら初めに戻る
            continue
        else:
            num += need
    ans = min(ans, num)
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>

int main(){
  int i,n,m,x=0,y=0,z=0;
  scanf("%d %d",&n,&m);
  for(i=0;i<n;i++){
    x+=z;
    z++;
  }
  z=0;
  for(i=0;i<m;i++){
    y+=z;
    z++;
  }
  printf("%d\n",x+y);
  return 0;
}


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

int main(){
    int a;
    bool ada = false;
    cin >> a;
    for(int i=1;i<=9;i++){
        for(int k=1;k<=9;k++){
            if(i*k == a){
                ada = true;
            }
        }
    }
if(ada == true){
    cout << "Yes" << endl;
}else if (ada == false){
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3640
#if 0

#endif

#include <iostream>
#include <cmath>
using namespace std;

int mycount = 0; // ambigous??¨???????????????????????????
int solve(int E) {
 // ?????´????±???????
	int ans = 1000000; // ?????§???
	for (int z=0; z*z*z<=E; ++z)
		for (int y=0; y*y<=E; ++y){
			int x = E-z*z*z-y*y;
				++mycount; 
				if (x>=0 && x+y*y+z*z*z == E){
					if (x+y+z<=ans){
						ans = x+y+z;
					}
				}
			}
	return ans;
}
int main() {
	int E;
	while (cin >> E && E>0)
		cout << solve(E) << endl;
}

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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

class UnionFind {
protected:
  int size;
  vector<int> _leader;
  vector<int> _rank;
  
public:
  UnionFind(int s);
  int leader(int i);
  int merge(int i, int j);
};

UnionFind::UnionFind(int s) {
  size = s;
  _leader = vector<int>(size);
  for (int i = 0; i < size; i++) { _leader.at(i) = i; }
  _rank = vector<int>(size, 1);
}

int UnionFind::leader(int i) {
  int cur = i;
  int nxt = _leader.at(cur);
  vector<int> seen;
  while (cur != nxt) {
    seen.push_back(cur);
    cur = nxt;
    nxt = _leader.at(cur);
  }
  for (auto j : seen) _leader.at(j) = cur;
  return cur;
}

int UnionFind::merge(int i0, int j0) {
  int li = leader(i0);
  int lj = leader(j0);
  if (li == lj) return li;
  int ri = _rank.at(li);
  int rj = _rank.at(lj);
  if      (ri < rj)  return _leader.at(li) = lj;
  else if (ri > rj)  return _leader.at(lj) = li;
  else {
    (_rank.at(lj))++;
    return _leader.at(li) = lj;
  }
}

ll N;
// vector<ll> x;
// vector<ll> y;
constexpr ll maxXY = 1e5 + 1;
vector<vector<ll>> ysForX(maxXY);
vector<vector<ll>> xsForY(maxXY);
vector<set<ll>> yset(maxXY);
vector<ll> grpSize(maxXY);

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif
  cout << setprecision(20);

  cin >> N;
  // x.resize(N);
  // y.resize(N);
  for (ll i = 0; i < N; i++) {
    ll xx, yy;
    cin >> xx >> yy;
    // x.at(i) = xx;
    // y.at(i) = yy;
    ysForX.at(xx).push_back(yy);
    xsForY.at(yy).push_back(xx);
  }
  UnionFind uf(maxXY);
  for (ll y = 1; y < maxXY; y++) {
    auto xs = xsForY.at(y);
    if (xs.size() <= 1) continue;
    for (size_t i = 1; i < xs.size(); i++) {
      uf.merge(xs.at(0), xs.at(i));
    }
  }
  for (ll x = 0; x < maxXY; x++) {
    ll ld = uf.leader(x);
    grpSize.at(ld) ++;
    for (ll y : ysForX.at(x)) {
      yset.at(ld).insert(y);
    }
  }
  ll numP = 0;
  for (ll x = 1; x < maxXY; x++) {
    if (uf.leader(x) != x) continue;
    numP += yset.at(x).size() * grpSize.at(x);
  }
  cout << numP - N << endl;

  return 0;
}



Measured memory_bytes: 17152
n,m=map(int,input().split())
a=[int(input()) for _ in range(m)]
def fb(num):
    a,b = 1,0
    for _ in range(num+1):
        a,b = a+b,a
    return b
if m==0:
    print(fb(n)%(10**9+7))
    exit()
if m>1:
    for i in range(m-1):
        if a[i+1]-a[i]==1:
            print(0)
            exit()
c=0
for i in range(m):
    if i==0 and a[0]==1:
        c+=1
    elif i==0:
        c+=fb(a[0]-1)
    else:
        c*=(fb(a[i]-a[i-1]-2)%(10**9+7))
c*=fb(n-a[-1]-1)%(10**9+7)
print(c%(10**9+7))

Measured memory_bytes: 49112
//#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <utility>
#include <climits>

using namespace std;
using ll=long long;

void solve(){
  string s,t;
  cin >> s >> t;
  int ct=0;
  for(int i=0;i<3;i++)
    ct+=s[i]==t[i];
  cout << ct << endl;
}

int main(){
  solve();
  return 0;
}


Measured memory_bytes: 256
//start of jonathanirvings' template v3.0.3 (BETA)

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

typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pll;
typedef pair<string,string> pss;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vii;
typedef vector<LL> vl;
typedef vector<vl> vvl;

double EPS = 1e-9;
int INF = 1000000005;
long long INFF = 1000000000000000005LL;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};

#ifdef TESTING
  #define DEBUG fprintf(stderr,"====TESTING====\n")
  #define VALUE(x) cerr << "The value of " << #x << " is " << x << endl
  #define debug(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DEBUG 
  #define VALUE(x)
  #define debug(...)
#endif

#define FOR(a,b,c) for (int (a)=(b);(a)<(c);++(a))
#define FORN(a,b,c) for (int (a)=(b);(a)<=(c);++(a))
#define FORD(a,b,c) for (int (a)=(b);(a)>=(c);--(a))
#define FORSQ(a,b,c) for (int (a)=(b);(a)*(a)<=(c);++(a))
#define FORC(a,b,c) for (char (a)=(b);(a)<=(c);++(a))
#define FOREACH(a,b) for (auto &(a) : (b))
#define REP(i,n) FOR(i,0,n)
#define REPN(i,n) FORN(i,1,n)
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define SQR(x) ((LL)(x) * (x))
#define RESET(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define ALLA(arr,sz) arr,arr+sz
#define SIZE(v) (int)v.size()
#define SORT(v) sort(ALL(v))
#define REVERSE(v) reverse(ALL(v))
#define SORTA(arr,sz) sort(ALLA(arr,sz))
#define REVERSEA(arr,sz) reverse(ALLA(arr,sz))
#define PERMUTE next_permutation
#define TC(t) while(t--)

inline string IntToString(LL a){
  char x[100];
  sprintf(x,"%lld",a); string s = x;
  return s;
}

inline LL StringToInt(string a){
  char x[100]; LL res;
  strcpy(x,a.c_str()); sscanf(x,"%lld",&res);
  return res;
}

inline string GetString(void){
  char x[1000005];
  scanf("%s",x); string s = x;
  return s;
}

inline string uppercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'a' && s[i] <= 'z') s[i] = s[i] - 'a' + 'A';
  return s;
}

inline string lowercase(string s){
  int n = SIZE(s); 
  REP(i,n) if (s[i] >= 'A' && s[i] <= 'Z') s[i] = s[i] - 'A' + 'a';
  return s;
}

inline void OPEN (string s) {
  #ifndef TESTING
  freopen ((s + ".in").c_str (), "r", stdin);
  freopen ((s + ".out").c_str (), "w", stdout);
  #endif
}

//end of jonathanirvings' template v3.0.3 (BETA)

string s;

int main()
{
  s = GetString();
  REP(i,SIZE(s)-1) if(s[i] == 'A' && s[i+1]=='C') 
  {
    puts("Yes");
    return 0;
  }
  puts("No");
  return 0;
}










Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>

using namespace std;

int n;
string s;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	cin >> s;
	int n = s.length();

	for (int i = 0; i < n; ++i)
		s[i] -= '0';

	int ans = 1000;
	for (int i = 0; i < n-2; ++i) {
		int cur = abs(s[i]*100 + s[i+1]*10 + s[i+2] - 753);
		// printf("%d: %d\n", i, cur);
		if (cur < ans)
			ans = cur;
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
    int n;
    cin >> n;
    set<int> A;

    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        A.insert(x);
    }
    if (A.size() == n)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;

}

Measured memory_bytes: 9600
N=int(input())
A=list(map(int,input().split()))
A=[a-i for i,a in enumerate(A,1)]
A.sort()
A_posi=[0 for i in range(N)]
A_posi[0]=A[0]
for i in range(1,N):
    A_posi[i]=A_posi[i-1]+A[i]
value=[0 for i in range(N)]
value[0]=A_posi[N-1]-N*A[0]
for i in range(1,N):
    value[i]=A_posi[N-1]-A_posi[i]-(N-i-1)*A[i]-A_posi[i-1]+(i)*A[i]
print(min(value))


Measured memory_bytes: 29748
#include<iostream>
#include<vector>
#include<algorithm>

using ull = unsigned long long;
int main() {
	int n;
	std::cin >> n;

	ull ans{};
	for (int i{}; i < n; ++i) {
		ull t;
		std::cin >> t;
		ans += t;
	}

	std::cout << ans - n << "\n";


}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d)
    cout << "Yes" << endl;
  else if (abs(a - b) <= d && abs(b - c) <= d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <vector>
#include <math.h>
using namespace std;

#define debug(x) cout<<#x<<": "<<x<<endl
#define rep(i,a,b) for(int i=a;i<b;i++)
#define PB push_back
#define putn(x,n) cout<< fixed<< setprecision(n)<< x << endl;
typedef long long ll;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;

	int ans = k*pow(k - 1, n - 1);
	cout << ans;





	return 0;
}


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

struct StTrgLen
{
  StTrgLen() : m_nLenA(0), m_nLenB(0), m_nLenC(0) { }

  int m_nLenA;
  int m_nLenB;
  int m_nLenC;
};

struct StMatrl
{
  StMatrl() : m_nLenA(0), m_nLenB(0), m_nLenC(0) { }

  int m_nLenA;
  int m_nLenB;
  int m_nLenC;
};

void fnInput(StTrgLen& roTrgLen, vector<int>& rvnMatLen)
{
  int nMatLenSiz;
  cin >> nMatLenSiz >> roTrgLen.m_nLenA >> roTrgLen.m_nLenB >> roTrgLen.m_nLenC;
  rvnMatLen.resize(nMatLenSiz);

  for (int& rnMatLen : rvnMatLen)
    cin >> rnMatLen;
}

int fnDfs(int nDpth, StTrgLen oTrgLen, StMatrl& roMatrl, const vector<int>& cnrvnMatLen)
{
  if (nDpth == cnrvnMatLen.size())
    if ( roMatrl.m_nLenA && roMatrl.m_nLenB && roMatrl.m_nLenC )
      return  abs(oTrgLen.m_nLenA - roMatrl.m_nLenA)
            + abs(oTrgLen.m_nLenB - roMatrl.m_nLenB) 
            + abs(oTrgLen.m_nLenC - roMatrl.m_nLenC);
    else
      return 1 << 30; 

  int nMinMp = 0; 
  int nAddMp;

  nMinMp = fnDfs(nDpth + 1, oTrgLen, roMatrl, cnrvnMatLen);

  StMatrl oMatrlA(roMatrl);
  nAddMp = oMatrlA.m_nLenA ? 10 : 0;
  oMatrlA.m_nLenA += cnrvnMatLen[nDpth];
  nMinMp = min(nMinMp, fnDfs(nDpth + 1, oTrgLen, oMatrlA, cnrvnMatLen) + nAddMp);

  StMatrl oMatrlB(roMatrl);
  nAddMp = oMatrlB.m_nLenB ? 10 : 0;
  oMatrlB.m_nLenB += cnrvnMatLen[nDpth];
  nMinMp = min(nMinMp, fnDfs(nDpth + 1, oTrgLen, oMatrlB, cnrvnMatLen) + nAddMp);

  StMatrl oMatrlC(roMatrl);
  nAddMp = oMatrlC.m_nLenC ? 10 : 0;
  oMatrlC.m_nLenC += cnrvnMatLen[nDpth];
  nMinMp = min(nMinMp, fnDfs(nDpth + 1, oTrgLen, oMatrlC, cnrvnMatLen) + nAddMp);

  return nMinMp;
}

int fnMinCostTrgLen(StTrgLen oTrgLen, const vector<int>& cnrvnMatLen)
{
  StMatrl oMatrl;

  return fnDfs(0, oTrgLen, oMatrl, cnrvnMatLen);
}
 
int main()
{
  StTrgLen oTrgLen;
  vector<int> vnMatLen;

  fnInput(oTrgLen, vnMatLen);
  cout << fnMinCostTrgLen(oTrgLen, vnMatLen) << endl;

  return 0;
}

Measured memory_bytes: 3564
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;


fn main() {
    proconio::input! {
        n: usize,
        mut p: [isize;n],
        }
    let mut q= vec![0;100000000];
    q[1]=(p[1]-p[0]).abs();
    for i in 0..n-2 {
        q[i+1]=min((p[i+1]-p[i]).abs()+q[i],q[i+1]);
        q[i+2]=(p[i+2]-p[i]).abs()+q[i];
    }
    q[n-1]=min((p[n-2]-p[n-1]).abs()+q[n-2],q[n-1]);
    println!("{}",q[n-1]);

    // g[i] = min( g[i-1] + f[i-1], g[i-2] + f[i-2])
    //
    // g[i+1] = min( g[i+1], g[i] + f[i+1],)
    //
}

Measured memory_bytes: 3960
#include <bits/stdc++.h>
using namespace std;
const int N=1e6;
char p[N];
int S[N],P[N],n;
int main()
{
	scanf("%d",&n);
	scanf("%s",p);
	int i,j;
	for(i=0;p[i];i++)
	{
		if(p[i]=='o') P[i+1]=0;
		else P[i+1]=1;
	}
	P[n+1]=P[1];
	for(i=0;i<8;i++)
	{
		S[0]=i&1;
		S[1]=(i>>1)&1;
		S[2]=(i>>2)&1;
		for(j=2;j<=n+1;j++)
		{
			S[j+1]=S[j-2]^P[j];
		}
		if(S[0]^S[n]^S[1]^S[n+1] || S[1]^S[n+1]^S[2]^S[n+2]) continue;
		for(j=1;j<=n;j++)
		{
			printf("%c",(S[j]^S[j-1])?'W':'S');
		}
		return 0;
	}
	printf("-1\n");
	return 0;
}

Measured memory_bytes: 6912
#include<iostream>
#include<stdio.h>
#include<cmath> 
#include<stack> 
#include<algorithm> 
#include <string.h>
using namespace std;
typedef long long  ll;
int main() {
	int a[100001]={0};
	for(int i=1;i<=100;i++){
        for(int j=1;j<=100;j++){
            for(int k=1;k<=100;k++){
                a[((i+j)*(i+j)+(i+k)*(i+k)+(j+k)*(j+k))/2]++;
            }
        }
    }
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){
    	cout<<a[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 4020
#include<cstdio>
#include<algorithm>
#include<cstring>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t,o;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef pair<int,int> par;
typedef double dob;
/*
0:
1:0
2:00
3:1
4:10
5:100
6:11
*/
const int N=300010,P=1000000007;
int n,g[7],f[7],h[7];
char s[N];
void add(int &x,int y){x=(x+y)%P;}
void tran(int k){
	memset(g,0,sizeof(g));
	memset(h,0,sizeof(h));
	add(g[1],f[0]);
	add(g[2],f[1]);
	add(g[1],f[2]);
	add(g[4],f[3]);
	add(g[5],f[4]);
	add(g[4],f[5]);
	add(g[6],f[6]);
	
	add(h[3],f[0]);
	add(h[0],f[1]);
	add(h[1],f[2]);
	add(h[6],f[3]);
	add(h[3],f[4]);
	add(h[4],f[5]);
	add(h[6],f[6]);
	if (k==0) swap(f,g); else
	if (k==1) swap(f,h); else{
		rep(i,0,6) add(g[i],h[i]);
		swap(f,g);
	}
}
int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	f[0]=1;
	rep(i,1,n) tran(s[i]=='?'?2:s[i]-'0');
	LL ans=f[6]+f[3];
	ans=(ans%P+P)%P;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 512
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	int N;
	set<int>S;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		int s;
		cin >> s;
		S.insert(s);
	}
	cout << S.size() << endl;
	return 0;
}


Measured memory_bytes: 764
N = int(input())
n = N
alpha = "abcdefghijklmnopqrstuvwxyz"

for i in range(1,12):
    
    if n <= 26 ** i:
        digits = i
        break
    else:
        n -= 26 ** i
#print("桁数は{0}桁".format(digits))
n -= 1
output = ""
for j in range(digits-1):
    amari = n % 26
    n //= 26
    output = alpha[amari] + output
output = alpha[n] + output
print(output)

Measured memory_bytes: 61712
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define REP(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define pb(a) push_back(a)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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

int main(){
  int n,x;
  cin >> n >> x;
  int l;
  int sum = 0;
  int res;
  REP(i,n){
    cin >> l;
    sum += l;
    if(sum>x){
      cout << i+1 << endl;
      return 0;
    }
  }
  cout << n+1 << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

fun main (args : Array<String>) {
  val input = Scanner(System.`in`)
  
  while (input.hasNext()) {
    val N = input.nextInt()
	val A = IntArray(N)
	val count = LongArray(200_000 + 1)
	
	for (i in A.indices) {
	  A[i] = input.nextInt()
	  ++count[A[i]]
	}
	
	var ways = 0L
	for (i in count.indices) {
	  if (count[i] > 0) {
	    ways += (count[i] * (count[i] - 1)) / 2
	  }
	}
	
	for (i in A.indices) {
	  var k = ways -  (count[A[i]] * (count[A[i]] - 1)) / 2 + ((count[A[i]] - 1) * (count[A[i]] - 2)) / 2
      println(k)
	}
  }
}

Measured memory_bytes: 64900
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
    int n;
    cin >> n;
    vector<int> a(n+1), b(n);
    for(int i = 0; i <= n; ++i){
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i){
        cin >> b[i];
    }
    
    ll ans = 0;
    for(int i = 0; i < n; ++i){
        if(b[i] <= a[i]){
            ans += b[i];
        }
        else{
            ans += a[i];
            b[i] -= a[i];
            
            if(b[i] <= a[i + 1]){
                ans += b[i];
                a[i + 1] -= b[i];
            }
            else{
                ans += a[i + 1];
                a[i + 1] = 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    string str;
    int N;

    cin>>N;
    cin>>str;
    
    if(str.length()<=N)
        cout<<str;
    else{
        cout<<str.substr(0,N)+"...";
    }
        
   
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

//素因数分解
map<ll, ll> prime_factor(ll n)
{
	map<ll, ll> ret;
	for (ll i = 2; i * i <= n; i++)
	{
		while (n % i == 0)
		{
			ret[i]++;
			n /= i;
		}
	}
	if (n != 1)
		ret[n] = 1;
	return ret;
}

int main() {
	int n;cin>>n;
	string s;cin>>s;
	int ans = 0;
	char c;
	rep(i,n){
		if(i==0){
			ans = 1;
			c = s[i];
			continue;
		}
		if(c==s[i])
			continue;
		c = s[i];
		ans++;
	}
	cout << ans << endl;
}


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

using namespace std;
#define EB emplace_back
#define MP make_pair
typedef long long ll;
#define rep(i, a, b) for(ll i = a; i < b; ++i)

int main() {

    ll h , a, count = 0;
    cin >> h >> a;

    while(true){

        if(h - a <= 0){
            count++;
            break;
        }
        h -= a;
        count ++;
    }

    cout << count ;

    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;--i)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);--i)
#define rep0(i,n) for(i=0;i<(n);++i)
#define repd0(i,n) for(i=(n)-1;i>=0;--i)
#define repn0(i,m,n) for(i=(m);i<=(n);++i)
#define repnd0(i,m,n) for(i=(n)-1;i>=(m);--i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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



int main() {
	Int n,a,b,c;
	cin>>n>>a>>b>>c;
	priority_queue<int> que;
	rep(i,n)que.push(in());
	Int aa=a,cc=c;
	rep(i,n){
		if((cc)*(aa+b)>(cc+que.top())*aa){
			break;
		}
		aa+=b;
		cc+=que.top();
		que.pop();
	}
	cout<<cc/aa<<endl;
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#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--)
int a[200*200];
int b[200][200];
int main(){
    int h,w;
    scanf("%d%d",&h,&w);
    int n;
    scanf("%d",&n);
    REP(i,n)
        scanf("%d",a + i);
 
    int now = 0;
 
    REP(i,h){
        if(i % 2 == 0){
            REP(j,w){
                if(a[now] <= 0)
                    now++;
                b[i][j] = now + 1;
                a[now]--;
            }
        }else{
            RREP(j,w){
                if(a[now] <= 0)
                    now++;
                b[i][j] = now + 1;
                a[now]--;
            }
        }
    }
    REP(i,h){
        REP(j,w)
            printf("%d ",b[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
    int a,sum = 0,memo = 0;
    
    while(1){
       cin >> sum;
       if(!sum) return 0;
       memo = 0;
        
        rep(i,0,9){
            cin >> a;
            memo += a;
        }
        
    cout << sum - memo << endl; 
    }
    
    
    
    return 0;
}


Measured memory_bytes: 3016
import java.util.*;
 
class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[][] c = new int[3][3];
		for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				c[i][j] = sc.nextInt();
			}
		}
		int[] a = new int[3];
		int[] b = new int[3];
		for(int i = 0; i < 3; i++){
			a[i] = Math.min(c[i][0],Math.min(c[i][1],c[i][2]));
		}
		for(int i = 0; i < 3; i++){
			b[i] = Math.min(c[0][i],Math.min(c[1][i],c[2][i]));
		}
		boolean flag = false;
		for(int i = a[0]; i > -1; i--){
			for(int j = a[1]; j > -1; j--){
				for(int k = a[2]; k > -1; k--){
					int l = c[0][0] - i;
					int m = c[1][1] - j;
					int n = c[2][2] - k;
					if(i+l==c[0][0] && i+m==c[0][1] && i+n==c[0][2] && j+l==c[1][0] && j+m==c[1][1] && j+n==c[1][2] && k+l==c[2][0] && k+m==c[2][1] && k+n==c[2][2]){
					   flag = true;
					   break;
					}
				}
			}
		}
		/*for(int i = 0; i < 3; i++){
			for(int j = 0; j < 3; j++){
				System.out.print(c[i][j]);
			}
			System.out.println();
		}
		for(int i = 0; i < 3; i++){
			System.out.print(a[i]);
		}
		for(int i = 0; i < 3; i++){
			System.out.print(b[i]);
		}*/
		if(flag){
			System.out.print("Yes");
		}else{
			System.out.print("No");
		}
	}
}

Measured memory_bytes: 23124
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int ,int> P;
const int maxn=100011;
vector<P> G[maxn];
bool visit[maxn];
int d[maxn];
int n,m;
bool flag;
void dfs(int s){
  visit[s]=true;
  for(int i=0;i<G[s].size();i++){
    int from=G[s][i].first,cost=G[s][i].second;
    if(!visit[from]){
      d[from]=d[s]+cost;
      dfs(from);
    }
    else{
      if(d[from]!=d[s]+cost){
        flag=false;
        return ;
      }
    }
  }
}
int main(){
  
  cin>>n>>m;
  for(int i=0;i<m;i++){
    int a,b,c;
    cin>>a>>b>>c;
    G[a].push_back(P(b,c));
    G[b].push_back(P(a,-c));
  }
  for(int i=0;i<=n;i++){
    if(!visit[i]){
      flag=true;
      dfs(i);
      if(flag==false){
        cout<<"No"<<endl;
        return 0;
      }
    }
  }
  cout<<"Yes"<<endl;
  return 0;
}


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

using namespace std;
#define all(x) (x).begin(),(x).end()

void solve(){
    int n,m;
    cin >> n >> m;
    vector<int> p(m),y(m);
    vector<vector<int>> data(n + 1);
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> y[i];
        data[p[i]].push_back(y[i]);
        //cout << "data[p[i]][i]=" << typeid(data[p[i]][0]).name() << endl;
    }

    for (int i = 0; i < n+1; i++) {
        sort(all(data[i]));
    }

    for (int i = 0; i < m; i++) {
        /*
        vector<int> &d = data[p[i]];
        int k = lower_bound(all(d), y[i]) - d.begin();
        */
        int k = lower_bound(all(data[p[i]]), y[i]) - data[p[i]].begin();

        printf("%06d%06d\n", p[i], k + 1);
    }

}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 7808
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var S = cin.Read;
            var ans = 0;
            var prev = ' ';
            var chars = S.ToCharArray();
            for (int i = 0; i < N; i++)
            {
                var c = chars[i];
                if (prev != c)
                {
                    ans++;
                    prev = c;
                }
            }
            Console.WriteLine(ans);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13920
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

int main(void)
{
  double l,x1,y1,x2,y2;

  cin >> x1 >> y1 >> x2 >> y2;
  l = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
  cout << fixed << setprecision(5) << l << endl;
   
  return 0;
}

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

typedef unsigned long long ULL;
int n;
ULL x;
ULL pat[52];
ULL siz[52];

int main(){
    //freopen("in.txt", "r", stdin);
	cin >> n;
	pat[0] = 1;
	siz[0] = 1;
	for(int i = 1; i <= n+1; ++i){
		pat[i] = pat[i-1]*2 + 1LL;
		siz[i] = siz[i-1]*2 + 3LL;
	}
	cin >> x;
	ULL ans = 0;
	for(int i = n; i >= 0; --i){
		if(x == 0) break;
		if(x == siz[i]){
			ans += pat[i];
			break;
		}
		if(x == 1){
			break;
		}
		if(x <= 1ll + siz[i-1]){
			x--;
		}else{
			ans += 1ll + pat[i-1];
			x -= 1ll + siz[i-1] + 1ll;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String []args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String n=br.readLine();
        int sum=0;
        for (int i = 0; i < n.length(); i++) {
            sum+=Integer.parseInt(n.charAt(i)+"");
        }
        if(sum%9==0)
            System.out.println("Yes");
        else
            System.out.println("No");
    }
}


Measured memory_bytes: 46248
#include <iostream>
 
int main(int argc, char *argv[])
{
  int n;
  int p[100];
  scanf("%d", &n);
  
  for(int i = 0; i < n; ++i)
  {
    scanf("%d", &p[i]);
  }
  
  int c = 0;
  for(int i = 0; i < n-2; ++i)
  {
    if((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) ||
       (p[i] > p[i + 1] && p[i + 1] > p[i + 2]))
      {
        ++c;
      }
  }
  printf("%d", c);
}

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

int main(){
    int n;
    cin>>n;
    int t,a;
    cin>>t>>a;
    int ans;
    double tmp;
    for(int i=1;i<=n;i++){
        if(i==1){
            int h;
            cin>>h;
            tmp=t-h*0.006;
            ans=1;
        }else{
            int h;
            cin>>h;
            double tmp2=t-h*0.006;
            if(abs(tmp-a)>abs(tmp2-a)){
                tmp=tmp2;
                ans=i;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}
    

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

signed main() {
  int n,x,m;
  cin >> n >> x >> m;

  vector<int> mod_last(m);
  vector<int> x_arr;
  x_arr.push_back(x);
  int idx = 1;
  int val = x;
  mod_last[x] = idx;
  while(true) {
    idx++;
    x = x * x;
    x %= m;
    if(mod_last[x] != 0) {
      val = x;
      break;
    }
    x_arr.push_back(x);
    mod_last[x] = idx;
  }

  int before = 0;
  int before_sum = 0;
  int N = (int)x_arr.size();
  for (int i = 0; i < N; i++) {
    if(x_arr[i] == val) {
      idx = i;
      break;
    }
    before_sum += x_arr[i];
    before++;
  }

  int loop = 0;
  int loop_sum = 0;
  for (int i = idx; i < N; i++) {
    loop_sum += x_arr[i];
    loop++;
  }

  int ans = 0;
  for (int i = 0; i < min(before,n); i++) {
    ans += x_arr[i];
  }
  n -= before;
  if(n > 0) {
    ans += loop_sum * (n/loop);
    for (int i = 0; i < (n%loop); i++) {
      ans += x_arr[idx + i];
    }
  }
  cout << ans << '\n';
}




Measured memory_bytes: 4688
#include<iostream>
#include<cmath>
using namespace std;
const long long m=1000000007;
int main()
{
    long long a,b;
    cin>>a>>b;
    if(abs(a-b)>1)
    {
    	cout<<0<<endl;
	}
	else
	{
		long long s=1;
		if(a==b)
		{
			s=2;
		}
		else
		{
			s=1;
		}
		for(int i=1;i<=a;i++)
		{
			s=s*i%m;
		}
		for(int i=1;i<=b;i++)
		{
			s=s*i%m;
		}
		cout<<s;
	}
    return 0;
}

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

int main()
{
  int n, a;
  cin >> n >> a;
  
  int amari;
  amari = n % 500;

  if (a >= amari)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
    
  return 0;
}

Measured memory_bytes: 256
(let* ((n (read))
       (a (read))
       (li (sort (loop :repeat n collect (cons (read) (read))) #'< :key #'car))
       (ans 0))
  (block r
    (mapcar (lambda (q)
              (setq a (- a (cdr q)))
              (if (<= a 0)
                  (progn (setq ans (car q))
                         (return-from r (car q)))
                  nil)) li))
  (princ ans))

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

int main(int, char**) {
        long n, m, d;
        cin >> n >> m >> d;
        long double ninv = 1.0/n;
        int par = 2;
        if (d==0) par = 1;
        long double p = par * (1 - d * ninv) * ninv * (m - 1.0);
        cout << setprecision(13) << p << endl;
        return 0;
}


Measured memory_bytes: 384
from copy import copy

n = int(input())
cards = [(s[0],int(s[1])) for s in input().split()]

cards_1 = copy(cards)
cards_2 = copy(cards)

need_to_sort = True
while need_to_sort:
    need_to_sort = False
    for index in range(len(cards_1) - 1, 0, -1):
        if cards_1[index][1] < cards_1[index-1][1]:
            cards_1[index], cards_1[index-1] = cards_1[index-1], cards_1[index]
            need_to_sort = True

print(" ".join([s[0]+ str(s[1]) for s in cards_1]))
print("Stable")

for idx1 in range(len(cards_2)):
    mins = idx1
    for idx2 in range(idx1, len(cards_2)):
        if cards_2[idx2][1] < cards_2[mins][1]:
            mins = idx2
    
    if mins != idx1:
        cards_2[idx1], cards_2[mins] = cards_2[mins], cards_2[idx1]

print(" ".join([s[0]+ str(s[1]) for s in cards_2]))

is_stable = True
for index in range(n):
    if cards_1[index] != cards_2[index]:
        is_stable = False
        break

print("Stable" if is_stable else "Not stable")


Measured memory_bytes: 6348
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

typedef long long ll;

int main (void) {

  std::vector<int> A(3); std::cin >> A[0] >> A[1] >> A[2];
  std::sort(A.begin(), A.end(), std::greater<>());

  std::cout << A[0]*10+A[1]+A[2] << std::endl;
  return 0;
}


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

#define ll long long
#define pb push_back

const int maxn = 1e5 + 20;

vector<int> adj[2 * maxn];

int ta , tb;

bool visited[maxn * 2];

void dfs(int v)
{
	if(v < maxn)
		ta++;
	else
		tb++;
	visited[v] = 1;

	for(auto u : adj[v])
		if(!visited[u])
			dfs(u);
}

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

	int n;
	cin >> n;

	for(int i = 0; i < n; i++)
	{
		int x , y;
		cin >> x >> y;
		y += maxn;

		adj[x].pb(y);
		adj[y].pb(x);
	}

	ll res = -n;
	for(int i = 0; i < 2 * maxn; i++)
		if(!visited[i])
		{
			ta = tb = 0;
			dfs(i);
			res += 1LL * ta * tb;
		}

	cout << res << endl;
}










 


Measured memory_bytes: 10240
n=int(input())
A=list(map(int,input().split()))
ans=float('INF')
sa=[0]
for i,a in enumerate(A):
    sa.append(sa[i]+a)
for i in range(n+1):
    ans=min(ans,abs(sa[i]-(sa[-1]-sa[i])))
print(ans)

Measured memory_bytes: 31532
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<ll> a(n+1);
	rep(i,n+1) cin >> a[i];
	ll ans = 0;
	rep(i,n){
		ll b;
		cin >> b;
		if(b >= a[i]){
			ans += a[i];
			b -= a[i];
		}
		else{
			ans += b;
			b = 0;
		}
		if(b >= a[i+1]){
			ans += a[i+1];
			a[i+1] = 0;
		}
		else{
			ans += b;
			a[i+1] -= b;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] d = new int[n];
		int ans = 0;
		
		//美味しさ配列
		for(int i = 0; i < n; i++) {
			d[i] = sc.nextInt(); 
		}

		for(int i = 0; i < n-1; i++) {
			for(int j = i+1; j < n; j++){
				ans += d[i] * d[j];
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 21844