akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main() {
    vector<pair<int, int> > hw;
    for (int i = 0; ; i++) {
        int h, w;
        scanf("%d%d", &h, &w);
        if (h == 0 && w == 0) {
            break;
        }
        pair<int, int> p(h, w);
        hw.push_back(p);
    }
    
    for (int i = 0; i < hw.size(); i++) {
        for (int j = 0; j < hw.at(i).first; j++) {
            for (int k = 0; k < hw.at(i).second; k++) {
                if (j != 0 && j != hw.at(i).first-1 && k != 0 && k != hw.at(i).second-1) {
                    printf(".");
                } else {
                    printf("#");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 3152
a,b,c=map(int, input().split())
if a<=b<=c:
     print(str(a)+" "+str(b)+" "+str(c))
elif a<=c<=b:
     print(str(a)+" "+str(c)+" "+str(b))
elif b<=a<=c:
     print(str(b)+" "+str(a)+" "+str(c))
elif b<=c<=a:
     print(str(b)+" "+str(c)+" "+str(a))
elif c<=b<=a:
     print(str(c)+" "+str(b)+" "+str(a))
else:
     print(str(c)+" "+str(a)+" "+str(b))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;

int main() {
    int N, ans = 0;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        a--;
        if (a < N) {
            A.at(a)++;
        }
        else {
            ans++;
        }
    }
    for (int i = 0; i < N; i++) {
        if (A.at(i) >= i + 1) {
            ans += A.at(i) - (i + 1);
        }
        else {
            ans += A.at(i);
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 640
open Printf
open Scanf

let id x = x

let x, y, z, w = scanf "%d %d %d %d" (fun x y z w -> x, y, z, w)

let a = z - x
let b = y - w

let () =
  let x' = z + b in
  let y' = w + a in
  let z' = x + b in
  let w' = y + a in
  printf "%d %d %d %d\n" x' y' z' w'
 

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

ll nextLong() { ll x; scanf("%lld", &x); return x;}

int main2() {
  int N = nextLong();
  vector<ll> a(N), S(N+1);
  REP(i, N) a[i] = nextLong();
  REP(i, N) S[i+1] = S[i] + a[i];

  ll ans = 0;
  map<ll, ll> count;

  count[0] += 1;
  for (int i = 1; i <= N; i++) {
    ans += count[S[i]];
    count[S[i]]++;
  }
  
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 18584
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define f first
#define s second
#define pb push_back
#define pp push
#define RETURN exit(0)
#define pow(x,y) (int)(pow(x,y))
#define ceil(x) (int)(ceil(x))
#ifndef ONLINE_JUDGE
#define debug(x) cout<<x<<endl;
#else
#define debug(x) 42
#endif
const int MAX=1e7;
const int MOD=1e9+7;
const int MAAX=1e15;
const long double EPS=1e-6;
const int N=1e6;
int power(int x,int y)
{
    if (y == 0)
        return 1;
    int a=power(x,y/2)%MOD;
    if (y % 2 == 0)
        return a * a % MOD;
    else
        return x * a % MOD * a % MOD;
}
long double sq(int x){
    long double s=0,e=x,mid;
    while(e-s>=EPS){
        mid=(s+e)/2;
        if(mid*mid<=x){
            s=mid;
        }
        else{
            e=mid-EPS;
        }
    }
    return s;
}
vector<int> primes;
bool visted[N+5];
void sieve(){
    visted[0]=visted[1]=1;
    for(int i=2;i*i<=N;i++){
        if(visted[i]==0){
            primes.pb(i);
            for(int j=i*i;j<=N;j+=i){
                visted[j]=1;
            }
        }
    }
    for(int i=sqrt(N)+1;i<=N;i++){
        if(visted[i]==0)
            primes.pb(i);
    }
    return;
}



in main()
{
    //freopen("in.in","r",stdin);
    //freopen("out.out","w",stdout);
    int tc=1;
    //sieve();
    //scanf("%lld",&tc)
    while(tc--)
    {
        int a,b;
        cin>>a>>b;
        if(a<=5)
            cout<<"0\n";
        else if(a<=12)
            cout<<b/2<<endl;
        else
            cout<<b<<endl;
    }
    RETURN;
}


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

namespace B
{
    class Program
    {
        static void Main(string[] args) {
            int N = int.Parse(Console.ReadLine());
            var A = Console.ReadLine().Split(' ').Select(x => int.Parse(x));

            int max = A.Max();
            int min = A.Min();

            Console.WriteLine(max - min);
        }
    }
}


Measured memory_bytes: 11348
using System;

namespace AOJapps
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int R = int.Parse(Console.ReadLine());
            int min = R;
            int ans = -1000000000;
            for (int i=1; i < n; i++)
            {
                R = int.Parse(Console.ReadLine());
                ans = Max2(ans, R - min);
                min = Min2(min, R);
            }
            Console.WriteLine(ans);
        }

        static int Min2(int a, int b)
        {
            if (a < b) { return a; } else { return b; }
        }

        static int Max2(int a, int b)
        {
            if (a < b) { return b; } else { return a; }
        }
    }
}

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
signed main(void){
    string s; cin>>s;
    string t="";
    char mae = '?';
    rep(i,s.size()){
        if(s[i] == mae) continue;
        else{
            t.push_back(s[i]);
            mae = s[i];
        }
    }
    cout<<t.size()-1<<endl;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

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

	vvi k(m);
	rep(i, m) {
		int num;
		cin >> num;
		rep(j, num) {
			int val;
			cin >> val;
			val--;
			k[i].push_back(val);
		}
	}
	vi p(m);
	rep(i, m) cin >> p[i];

	int cnt = 0;
	for (int bit = 0; bit < (1 << n); ++bit) {
		bool flg = true;

		for (int i = 0; i < m; ++i) {
			int u = 0;
			for (int j = 0; j < k[i].size(); ++j) {
				if (bit & (1 << k[i][j])) {
					u++;
				}
			}
			if (u % 2 != p[i]) {
				flg = false;
				break;
			}
		}
		if (flg) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <bits/stdc++.h>

using namespace std;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(long long i=(a),i##Len_=(b);i<i##Len_;i++)
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;

int main() {

    ll S;
    cin >> S;
    ll res = -1;

    ll x1 = 1000000000;
    ll y1 = 1;

    ll x2,y2;

    //abs(x1*y2 - x2*y1)/2 = S/2

    x2 = (x1 - S%x1)%x1;
    y2 = (S+x2)/x1; 

    //S==29なら、x2を999999971にする
    //S==10^18なら、x2を10^9にする
    //10^10なら、10^1にする

    cout << "0 0 " << x1 << " " << y1 << " " << x2 << " " << y2 << endl;

    return 0;
}

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

ll n;
deque<int> dq;
int main() {
	ios::sync_with_stdio(false);
	cin >> n;
	for(int l = 62 - __builtin_clzll(n+1), i = 1; l >= 0; l--, i++) {
		dq.push_back(i);
		if(n+1 & 1ll << l) dq.push_front(++i);
		assert(i <= 100);
	}
	cout << dq.size()*2 << endl;
	for(int i = 1; i <= dq.size(); i++) cout << i << ' ';
	for(int x: dq) cout << x << ' ';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int k;
    string s;
    cin >> s >> k;
 
    vector<string> list;
 
    for (int i = 0; i < s.length(); i++)
    {
        for (int j = 1; j < 6; j++)
        {
            string q = s.substr(i, j);
            int c = count(list.begin(), list.end(), q);
            if (c == 0)
            {
                list.push_back(q);
            }
        }
    }
    sort(list.begin(), list.end());
    cout << list[k - 1] << endl;
}


Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N+1];
		int[] B = new int[N+1];
		int[] r1 = new int[N+1];
		int[] r2 = new int[N+1];
		for(int i=1; i<=N; i++)
		{
			A[i]=sc.nextInt();
		}
		for(int i=1; i<=N; i++)
		{
			B[i]=sc.nextInt();
		}
		for(int i=1; i<=N; i++)
		{
			int count=0;
			for(int j=i+1; j<=N; j++)
			{
				if(A[j]<A[i])
				{
					count++;
				}
			}
			r1[i]=count;
		}
		for(int i=1; i<=N; i++)
		{
			int count=0;
			for(int j=i+1; j<=N; j++)
			{
				if(B[j]<B[i])
				{
					count++;
				}
			}
			r2[i]=count;
		}
		int sum=0;
		
		for(int i=1;i<=N; i++)
		{
			//System.out.println("r1: "+r1[i]);
		}
		
		for(int i=1; i<=N; i++)
		{
			//System.out.println("hii "+ (N-i));
			sum+=factorial(N-i)*r1[i];
			
		}
		int sum1=0;
		for(int i=1; i<=N; i++)
		{
			//System.out.println("byee");
			sum1+=factorial(N-i)*r2[i];
			
		}
		System.out.println(Math.abs(sum-sum1));
	}
	static int factorial(int n) 
    { 
        int res = 1, i; 
        for (i=2; i<=n; i++) 
            res *= i; 
        return res; 
    } 
	
}


Measured memory_bytes: 22740
def 解():
    iN,iK = [int(_) for _ in input().split()]
    aA = [int(_) for _ in input().split()]
    dA = {}
    def addD(d,a):
        if a in d:
            d[a] += 1
        else:
            d[a] = 1
    for a in aA:
        addD(dA,a)
    aList = sorted(list(dA.items()),key=lambda x:x[1])
    print(sum(map(lambda x:x[1],aList[0:len(aList)-iK])))
解()


Measured memory_bytes: 40576
function Main(input) {
    lines = input.split('\n')
    l = lines.shift().split(' ')
    n = l[0] * 1
    m = l[1] * 1
    cs = lines.shift().split(' ').sort(function (a, b) { return a - b })
    lines.pop()
    ls = lines.sort(function(a, b) { return b.split(' ')[1] - a.split(' ')[1] })
    idx = 0
    for (i = 0; i < ls.length; i++) {
        l = ls[i].split(' ')
        b = l[0] * 1
        c = l[1] * 1
        while (b--) {
            if (cs[idx] === undefined) break;
            if (cs[idx] < c) {
                cs[idx] = c
            } else {
                break;
            }
            idx++
        }
        if (cs[idx] === undefined) break;
    }
    ans = cs.reduce(function(a, c) { return a + c * 1}, 0)
    console.log(ans)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 55448
#include<stdio.h>

int main(){

   int a, b;
   char op;

   scanf("%d %c %d", &a, &op, &b);
   
   while(op != '?'){
      if(op == '+') printf("%d\n", a+b);
      else if(op == '-') printf("%d\n", a-b);
      else if(op == '*') printf("%d\n", a*b);
      else if(op == '/') printf("%d\n", a/b);
      else{}

      scanf("%d %c %d", &a, &op, &b);
   }

   return 0;
}

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

#define fastio        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll            long long
#define fl            long double
#define pll           pair<ll,ll>
#define onebits(x)    __builtin_popcountll(x)
#define pb            push_back
#define mk            make_pair
#define endl          "\n"
#define ff            first
#define ss            second
#define mt            make_tuple
#define np            next_permutation
#define pi            3.141592653589793238
#define deb(x)        cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define vll           vector<ll>
#define vp            vector<pair<ll,ll>>
#define all(x)        x.begin(),x.end()
#define revpq         priority_queue <int, vector<int>, greater<int>>
#define ps(x,y)       fixed<<setprecision(y)<<x
const ll mod = 1e9 + 7;
const ll INF = 1e18;
ll power(ll a, ll b) {ll res = 1; a %= mod; assert(b >= 0); for (; b; b >>= 1) {if (b & 1)res = res * a % mod % mod; a = a * a % mod;} return res;}
int main()
{
    fastio;
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll i, j, t , n , m, l;
    fl k;
    cin >> n;
    cin >> k;
    fl x[n], y[n];
    for (i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }
    fl dis[n];
    ll ans = 0;
    for (i = 0; i < n; i++)
    {
        dis[i] = sqrt(x[i] * x[i] + y[i] * y[i]);
        if (dis[i] <= k)
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 13236
import numpy as np

s = input()

text = "abcdefghijklmnopqrstuvwxyz"
count = np.zeros(len(text), dtype=np.int)

if(len(s) != len(text)):
    for i in s:
        for j in range(len(text)):
            if(i == text[j]):
                count[j] = 1
                break

    for i in range(len(text)):
        if(count[i] == 0):
            print((s + text[i]))
            exit()
else:
    for i in range(1, len(text) + 1, 1):
        count = np.zeros(len(text), dtype=np.int)
        for j in s[0:-i]:
            for k in range(len(text)):
                if(j == text[k]):
                    count[k] = 1
                    break

        for j in range(len(text)):
            if(s[-i] == text[j]):
                num = j
                break
        for j in range(num+1, len(text), 1):
            if(count[j] == 0):
                print((s[0:-i] + text[j]))
                exit()

print("-1")

Measured memory_bytes: 12648
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
#define INF (1<<30)-1
#define MOD 1000000007
using namespace std;
typedef long long ll;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}

int a, b, c, d;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> a >> b >> c >> d;
    int ans1 = min(a+c, a+d);
    int ans2 = min(b+c, b+d);
    cout << min(ans1, ans2) << endl;
    return 0;
}


Measured memory_bytes: 256
n = map(int, input())
data = list(map(int, input().split()))
 
ans = 1
flag = 1
flag2 = 0
 
for d in data:
  if d == 0:
    flag2 = 1
 
for d in data:
  ans = ans * d
  if ans > 1e18:
    flag = 0
    break
 
if(flag2):
  print(0)
elif(flag):
  print(ans)
else:
  print(-1)

Measured memory_bytes: 21584
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(long long i=0;i<n;++i)
#define REPR(i,n) for(long long i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define MOD 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair
#define SV(v) {for(long long sitr=0;sitr<v.size();++sitr){cin>>v[sitr];}}

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

using namespace std;

typedef pair<int,int> pii;

int main(){

  int x, a;
  cin >> x >> a;
  if(x < a) cout << 0 << endl;
  else cout << 10 << endl;
  return 0;
}



Measured memory_bytes: 1016
N,M = map(int,input().split())
A = [0] * (N+2)
for _ in range(M):
  l,r = map(int,input().split())
  A[l] += 1
  A[r+1] -= 1

for i in range(N):
  A[i+1] += A[i]

print(A.count(M))

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

using namespace std;


int main(){
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    vector<vector<int>> path(N);
    for(int i=0; i<N; i++){
        int h;
        cin >> h;
        H.at(i) = h;        
    }
    for(int i=0; i<M; i++){
        int a,b;
        cin >> a >> b;
        path.at(a-1).push_back(b);
        path.at(b-1).push_back(a);
    }

    int ans = 0;
    for(int i=0; i<N; i++){
        bool highest = true;
        int my_hight = H.at(i);
        for(auto& p: path.at(i)){
            if(H.at(p-1)>=my_hight){
                highest = false;
            }
        }
        if(highest){
            ans++;
        }
    }
    
    
    cout << ans << endl;
        
    return 0;
}



Measured memory_bytes: 8752
#define _GIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double EPS = 1e-10;


ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}


int main(void) {
  ll N;
  cin >> N;

  if (N == 1) {
    cout << 0 << endl;
    return 0;
  } else if (N == 2) {
    cout << 2 << endl;
    return 0;
  }

  const ll mod7 = 1000000000 + 7;
  ll ans = modpow(10, N, mod7);
  ans -= modpow(9, N, mod7);
  ans -= modpow(9, N, mod7);
  ans += modpow(8, N, mod7);

  ans %= mod7;
  ans = (ans+mod7) % mod7;
 
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define FORR(i, a, b) for (int i = a; i <= b; i++)
#define REP(i, a, b) for (int i = b - 1; i >= a; i--)
#define FORI(i, a, b, inc) for (int i = a; i <= b; i += inc)
#define FORRI(i, a, b, inc) for (int i = a; i < b; i += inc)
#define REPD(i, a, b, dec) for (int i = b - 1; i >= a; i -= dec)
#define SORT(a, n) sort(a, a + n, greater<int>())
#define PREC(n) cout << fixed << setprecision(n)
#define ULL unsigned long long
#define FT first
#define SN second
#define Vsort(v) sort(v.begin(), v.end())
#define FORV(it, l) for (auto it : l)
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define RESET(a, b) memset(a, b, sizeof(a))
#define PI acos(-1)
#define VSE(v) v.begin(), v.end()
#define S " "
typedef vector<int> VC;
typedef vector<long long> VCL;
typedef vector<VC> VCC;
typedef pair<int, int> PR;
typedef vector<PR> VPR;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef set<PR> STP;
int isPrime(LL n)
{
    for (LL i = 2; i * i <= n; i++)
        if (n % i == 0)
            return 0;
    return 1;
}
void solve()
{
    /*Md. Bokhtiar Nadeem Shawon
    Institute of Information Technology
    Jahangirnagar University
    */
    int n,x,sum=0;
    cin>>n;
    FOR(i,0,n)
    {
        cin >> x;
        sum += x;
    }
    cout << sum - n << endl;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /*int t;
    cin >> t;
    while (t--)*/
        solve();
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint mod = 998244353;
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcountl((lint)(n))
#define fcout cout << fixed << setprecision(15)
#define highest(x) (63 - __builtin_clzl(x))
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T = string, class U = char>int character_count(T text, U character){ int ans = 0; for(U i: text){ ans += (i == character); } return ans; }
lint power(lint base, lint exponent, lint module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ lint root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position mv[4] = {{0, -1}, {1, 0}, {0, 1}, {-1, 0}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class T, class U> string to_string(pair<T, U> x){ return to_string(x.first) + "," + to_string(x.second); } string to_string(string x){ return x; }
template<class itr> void array_output(itr start, itr goal){ string ans; for(auto i = start; i != goal; i++) ans += to_string(*i) + " "; if(!ans.empty()) ans.pop_back(); cout << ans << endl; }
template<class itr> void cins(itr first, itr last){ for(auto i = first; i != last; i++){ cin >> (*i); } }
template<class T> T gcd_calc(T a, T b){ if(b){ return gcd_calc(b, a % b); }else{ return a; }}
template<class T> T gcd(T a, T b){ if(a < b) swap(a, b); return gcd_calc(a, b); }
template<class T> T lcm(T a, T b){ return a / gcd(a, b) * b; }
struct combination{ vector<lint> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2, mod); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } lint C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };
template<class itr> bool next_sequence(itr first, itr last, int max_bound){ itr now = last; while(now != first){ now--; (*now)++; if((*now) == max_bound){ (*now) = 0; }else{ return true; } } return false; }
inline int at(int x, int k){ return (x >> k) & 1; }
random_device rnd;

int main(){
    int N, K;
    cin >> N >> K;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int A;
        cin >> A;
        ans += (A >= K);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         fozubaoyou    pass System Test!
*/


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#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 <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main(){
    LL n,a,b;
    cin >> n >> a >> b;
    LL ans = (n / (a+b)) * a;
    LL r = n % (a+b);
    ans += min(a,r);
    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char *argv[])
{
  for(;;) {
    vector<int> as;
    int n, m;
    cin >> n >> m;
    if(n == 0) break;
    for(int i = 0; i < n; i++) {
      int p;
      cin >> p;
      as.push_back(p);
    }
    int mx = -1;
    for(int i = 0; i < n; i++) {
      for(int j = 0; j < n; j++) {
        if(j == i) continue;
        int d = as[i] + as[j];
        if(d > m) continue;
        if(d > mx) mx = d;
      }
    }
    if(mx < 0) {
      cout << "NONE" << endl;
    } else {
      cout << mx << endl;
    }
  }
  return 0;
}

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

int main(){
    vector<int> A = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    
    int K;
    cin >> K;

    cout << A.at(K - 1) << endl;
}

Measured memory_bytes: 256
use std::cmp::max;
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let s = scan!().chars().collect::<Vec<_>>();
    let a = s.iter().position(|&c| c == 'A').unwrap();
    let b = s.iter().rposition(|&c| c == 'Z').unwrap();

    println!("{}", b - a + 1);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 10000000
#define mod 1000000007
#define INF2 1000000000000000000

typedef pair<int, int> P;

char mapd[2000][2000];
int N, M;
int sx, sy;
int gx, gy;

int d[2000][2000];

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

int bfs() {
    queue<P> que;
    
    rep(i, N) rep(j, M) d[i][j] = INF;
    que.push(P(sx, sy));
    d[sx][sy] = 0;

    while(que.size()) {
        P p = que.front(); que.pop();
        if (p.first == gx && p.second == gy) break;
        rep(i, 4) {
            int nx = p.first + dx[i], ny = p.second + dy[i];

            if (0 <= nx && nx < N && 0 <= ny && ny < M && mapd[nx][ny] != '#' && d[nx][ny] == INF) {
                que.push(P(nx, ny));
                d[nx][ny] = d[p.first][p.second] + 1;
                //cout << "d[" << nx << "][" << ny << "] = " << d[nx][ny] << endl;
            }
        }
    }
    return d[gx][gy];
}

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    rep(i, N) rep(j, M) cin >> mapd[i][j];
    int point = 0;
    rep(i, N) rep(j, M) {
        if (mapd[i][j] == '.') point++;
    }
    sx = 0;
    sy = 0;
    gx = N-1;
    gy = M-1;
    if (bfs() == INF) {
        cout << -1 << endl;
        return 0;
    }
    cout << point-bfs()-1 << endl;



    return 0;
}


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

#define x first
#define y second
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define REP(i, a) FOR(i, 0, a)
#define TRACE(x) cout << #x << " = " << x << endl
#define _ << " _ " <<

using namespace std;

#define task "c"

struct Pt { double x, y; };

const int MAXN = 1010;

int N;
double va, vb;
Pt A[MAXN];
double dp[MAXN];

double sqr(double x) {
  return x * x;
}

double dist(Pt a, Pt b) {
  return sqrt(sqr(a.x - b.x) + sqr(a.y - b.y));
}

void popravi_naprijed(int i) {
  int j = i + 1;
  while (j < N && A[j].y > A[i].y) ++j;
  if (j == i + 1) return;
  if (j == N) return;
    
  double d = dist(A[j], A[j - 1]);
  double omj = (A[j-1].y - A[i].y) / (A[j-1].y - A[j].y);
  double dravno = A[j-1].x - A[i].x + (A[j].x - A[j-1].x) * omj;
    
  dp[j] = min(dp[j], dp[i] + (d * (1 - omj) / va) + dravno / vb);
}

void popravi_natrag(int i) {
  int j = i - 1;
  while (j >= 0 && A[j].y > A[i].y) --j;
  if (j == i - 1) return;
  if (j == -1) return;

  double d = dist(A[j], A[j + 1]);
  double omj = (A[j+1].y - A[i].y) / (A[j+1].y - A[j].y);
  double dravno = A[i].x - A[j+1].x + (A[j+1].x - A[j].x) * omj;
  
  dp[i] = min(dp[i], dp[j] + (d * (1 - omj) / va) + dravno / vb);
}

int main() {

  //freopen(task ".in", "r", stdin);
  //freopen(task ".out", "w", stdout);

  while (scanf("%d", &N) && N) {
    scanf("%lf%lf", &va, &vb);

    REP(i, N) scanf("%lf%lf", &A[i].x, &A[i].y);

    REP(i, N) dp[i] = 1e10;
    dp[0] = 0;
  
    REP(i, N) {
      popravi_natrag(i);
      dp[i + 1] = min(dp[i + 1], dp[i] + dist(A[i], A[i + 1]) / va);
      popravi_naprijed(i);
    }
  
    printf("%lf\n", dp[N-1]);
  }
  
  return 0;
}

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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

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

int H, W, D;
vector<vector<int>> A;
using P = pair<int, int>;
vector<P> pos;
using Int = long long;
vector<Int> xs, ys;
int main() {
    cin >> H >> W >> D;
    pos.resize(H * W);
    A.resize(H);
    rep(i, H) {
        A[i].resize(W);
        rep(j, W) cin >> A[i][j];
    }
    rep(i, H) rep(j, W) pos[A[i][j] - 1] = P(i, j);
    // rep(i, H * W) cout << i << ": " << pos[i].first << ", " << pos[i].second
    // << endl;
    ys.resize(H * W);
    xs.resize(W * H);
    rep(i, H * W) if (i>=D) {
        // cout << i << ": " << pos[i].first << ", " << pos[i - 1].first <<
        // endl;
        Int d = abs(pos[i].first - pos[i - D].first);
        ys[i] = ys[i - D] + d;
        d = abs(pos[i].second - pos[i - D].second);
        xs[i] = xs[i - D] + d;
    }
    // rep(i, H * W) cout << i << ": " << ys[i] << endl;
    int Q;
    cin >> Q;
    rep(i, Q) {
        int L, R;
        cin >> L >> R;
        L--, R--;
        Int ans = ys[R] - ys[L];
        ans += xs[R] - xs[L];
        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

using namespace std;

const int MAX_SOSU=(2<<15)+1;

bool sosu[MAX_SOSU];//true?´???°???false
vector<int> sosu2;

int main(){

  sosu[0]=true;
  sosu[1]=true;
  for(int i=2;i<MAX_SOSU;i++){
    if(sosu[i]) continue; 
    sosu[i]=false;
    sosu2.push_back(i);
    for(int j=2;j*i<MAX_SOSU;j++){
      sosu[j*i]=true;   
    }
  }

  while(1){
    int n,cnt=0;
    cin >> n; 
    if(n==0) break;
    
    rep(i,sosu2.size()){
      int sum=0;
      for(int j=i;j<sosu2.size();j++){
        sum+=sosu2[j];
        if(sum>n) break;
        else if(sum==n) cnt++;
      }
    }

    cout << cnt << endl;
  }

 }

Measured memory_bytes: 3196
/*
author : seryu
title : ABC174D_"Alter Alter"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
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; }

void solve()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r_cnt = 0;
    rep(i, n)if(s[i] == 'R')r_cnt++;
    int ans = r_cnt;
    rep(i, r_cnt)if(s[i] == 'R')ans--;
    cout << ans << endl;
    return;	
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
    return 0;
}


Measured memory_bytes: 3756
import sys
S = input()
maxer = 0
count = 0
for i in range( len(S) ):
    if S[i] == "A" or S[i] == "C" or S[i] == "G" or S[i] == "T":
        count += 1
        if maxer < count:
            maxer = count
    else:
        count = 0
print( maxer )

Measured memory_bytes: 61760
N_,Y_=input().split()
N=(int)(N_)
Y=(int)(Y_)

count = 0
a_ = Y//10000
if a_>N:
    a_ = N
for a in range(a_+1):
    Y_ = Y-a*10000
    N_ = N-a
    b_ = Y_//5000
    if b_>N_ and b_>=0:
        b_ = N_
    for b in range(b_+1):
        Y__ = Y_-b*5000
        N__ = N_-b
        c_ = Y__//1000
        if Y__%1000==0:
            if c_==N__ and c_>=0:
                print((str)(a)+" "+(str)(b)+" "+(str)(c_))
                exit(0)
print("-1 -1 -1")


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

int main() {
  int N, P;
  cin >> N >> P;
  int m = 0;
  for (int i = 0; i < N; ++i) {
    int A;
    cin >> A;
    if (A % 2 == 1)
      ++m;
  }
  // 奇数が一個もないのでP=1のケースは存在しない
  if (m == 0)
    cout << (P == 0 ? (1LL << N) : 0) << endl;
  else
    // 奇数・偶数によらず2^(N-1)で解ける．
    // 直感的には，N個のうち奇数1個を除外して考えると，それ以外のN-1個の選び方に対して
    // 除外した奇数を足すか足さないかで偶奇を調整できる．
    // N-1個を適当に選んでその合計が偶数の場合，除外したやつを足すと奇数に，足さなければ偶数．
    // 合計が奇数の場合は足すと偶数に，足さなければ奇数に，といった具合に調整できてしまう．怖すぎでしょ．
    // よってPの値に関係なく2^(N-1)で解ける．こんなん分かるの天才ぐらいでしょ．．
    cout << (1LL << (N - 1)) << endl;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	ll A,B; cin>>A>>B;
	if(A<=8 && B<=8) cout<<"Yay!";
	else cout<<":(";
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#define maxn 100010
#define LL long long
using namespace std;
int a[maxn];
LL sum[maxn];
int main(){
	int i,n;
	LL num=1,ans=0;
	scanf("%d",&n);
	for(i=0;i<=n;i++)scanf("%d",&a[i]);
	for(i=n;i>=0;i--)sum[i]=sum[i+1]+a[i];
	for(i=0;i<=n;i++){
		if(num<a[i]){printf("-1\n");return 0;}
		ans+=num;//此时的num表示此层的节点数
		num-=a[i];
		num=min(num<<1,sum[i+1]);//此时的num表示下一层的节点数。
	}
	printf("%lld\n",ans);
	return 0;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)

using LL  = long long;
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int a, b;cin >> a >> b;
    string ans = "Impossible";
    if(a%3 == 0) ans = "Possible";
    if(b%3 == 0) ans = "Possible";
    if((a+b)%3 == 0) ans = "Possible";
    cout << ans << endl;
    return 0;
}


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

#define ll long long int
#define mp make_pair
#define ff first
#define ss second
#define fr(i,l,r) for (long long int i = l; i < r; ++i)
#define frr(i,l,r) for (long long int i = r; i >= l; --i) 
#define sortarr sort(arr,arr+n) //sorts array in asc order
#define sortarr_r sort(arr, arr+n, greater<long long int>()) //sorts array in desc order
#define make_set set<long long int>s //Set arranges in asc order
#define make_set_r set<long long int, greater <long long int>>s ////Set arranges in desc order
#define make_vector vector<long long int>v; 
#define pb push_back


// string size = str.size()

// stack <int> s; 
// queue <int> gquiz; 
// __gcd(m, n) 

// ll arr[10e5 + 5];
// char arr[10e5 + 5];


bool compare(string &s1,string &s2) 
{ 
    return s1.size() < s2.size(); 
} 
void yes()
{
    cout << "YES" << endl;
}
void no()
{
    cout << "NO" << endl;
}


int main(void)
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    ll t;
    // cin >> t;
    // while(t--)
    // {
        // ll n;
        // cin >> n;
    // }
    string str;
    cin >> str;
    if(str[1] == 'R')
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ARC" << endl;
    }
    
    return 0;
}   

Measured memory_bytes: 3624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;


public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 * @throws NumberFormatException 
	 */
	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		String[] tmpArray = br.readLine().split(" ");
		
		int n = Integer.parseInt(tmpArray[0]);
		int m = Integer.parseInt(tmpArray[1]);
		
		City cities[] = new City[m];
		City cities2[] = new City[m];
		
		for(int i = 0; i < m; i++){
			tmpArray = br.readLine().split(" ");
			
			int p = Integer.parseInt(tmpArray[0]);
			int y = Integer.parseInt(tmpArray[1]);
			
			cities[i] = new City(p, y);
			cities2[i] = cities[i];
		}
		
		Arrays.sort(cities);
		
		for(int i = 0; i < m; i++){
			if(i == 0 || cities[i].pref != cities[i - 1].pref){
				cities[i].idInPref = 1;
			}
			else {
				cities[i].idInPref = cities[i - 1].idInPref + 1;
			}
		}
		
		for(int i = 0; i < m; i++){
			System.out.printf("%06d%06d\n", cities2[i].pref, cities2[i].idInPref);
		}
	}

}

class City implements Comparable<City>{

	int id;
	private static int idSeed = 0;
	int pref;
	int year;
	int idInPref = 0;
	
	City(int pref, int year){
		id = idSeed++;
		this.pref = pref;
		this.year = year;
	}
	public int compareTo(City c1) {
		// TODO Auto-generated method stub
		return this.pref == c1.pref ? 
			(this.year - c1.year) : this.pref - c1.pref;
	}
	
}

Measured memory_bytes: 114644
# -*- coding: utf-8 -*-
import numpy as np

K,N = map(int, (input().split()))
A = np.array(list(map(int, input().split())))
B = [0]*N
sortA=np.sort(A)
for i in range(N):
    B[i]=sortA[(N-1+i)%N]-sortA[i]
    if i>0:
        B[i]=K+sortA[(N-1+i)%N]-sortA[i]


print("{}".format(min(B)))


Measured memory_bytes: 36188
A, B, C, D = map(int, input().split())

if A <= C <= B <= D:
    print(B-C)
elif A <= C & D <= B:
    print(D-C)
elif C <= A <= D <= B:
    print(D-A)
elif A <= C <= B <= D:
    print(B-C)
elif C <= A <= B <= D:
    print(B-A)
else:
    print(0)


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

int main() {
    ll A, V, B, W, T;
    cin >> A >> V >> B >> W >> T;
    ll d = abs(A-B);
    if((V - W) * T >= d) cout << "YES" << endl;    
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 3612
N, W = map(int, input().split())
w, v = [0] * N, [0] * N
for i in range(N):
	w[i], v[i] = map(int, input().split())

V = sum(v)
dp = [[float("inf")] * (V + 1) for _ in range(N + 1)]
"""
for j in range(V + 1):
	dp[0][j] = 0
"""
dp[0][0] = 0
# dp[i][j]:i番目までの品物から価値がj以上になるよう選んだときの重さの総和の最小値
for i in range(N):
	for j in range(V + 1):
		# i+1番目を選ぶ場合
		if j - v[i] >= 0:
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j - v[i]] + w[i])
		# i+1番目を選ばない場合
		dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])

# print(dp)

# dp[N][j]がW以下であるようなjの最大値が答えになる
ans = 0
for j in range(V + 1):
	if dp[N][j] <= W:
		ans = j

print(ans)


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

typedef long long ll;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl
#define YesNo(x)      cout << ((x) ? "Yes" : "No") << endl
#define YESNO(x)      cout << ((x) ? "YES" : "NO") << endl
#define absi(x)       ( ((x) >= 0) ? (x) : (-(x)) )

int main(int argc, const char* argv[]) {
	ll s;
	cin >> s;

	/*
	 *  editorial の通りに実装
	 *  x1 = y1 = 0 の時、S = |x2 * y3 - x3 * y2|
	 *  更に、x2 = 1000000000 、y2 = 1 の時、S = 1000000000 * y3 - x3
	 */
	ll x1 = 0;
	ll y1 = 0;
	ll x2 = 1000000000;
	ll y2 = 1;
	ll x3 = (s % 1000000000 == 0) ? 0 : (1000000000 - (s % 1000000000));
	ll y3 = (s % 1000000000 == 0) ? (s / 1000000000) : (s / 1000000000 + 1);

	cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;

	return 0;
}


Measured memory_bytes: 256
s = input()
ans = 0
for i in range(2 ** (len(s) - 1)):
    f = s[0]
    for j in range(len(s) - 1):
        if ((i >> j) & 1) == 1:
            f += "+"
        f += s[j + 1]
    ans += sum(map(int, f.split("+")))
print(ans)

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

int main() {
  int H,W,i,j,p,q;
  cin >> H >> W;
  int x[H+2][W+2];
  for(i=0;i<W+2;i++) {
	x[0][i]=0;
	x[H+1][i]=0;
  }
  for(i=0;i<H+2;i++) {
	x[i][0]=0;
	x[i][W+1]=0;
  }

  for(i=1;i<=H;i++) {
	for(j=1;j<=W;j++) {
		char k;
		cin >> k;
		if(k=='.') x[i][j]=0;
		else x[i][j]=1;
	}
  }

  for(i=1;i<=H;i++) {
	for(j=1;j<=W;j++) {
	  if(x[i][j]==1) cout<<"#";
	  else {
	    int hole=0;
	    for(p=-1;p<=1;p++) {
		for(q=-1;q<=1;q++) {
		  hole+=x[i+p][j+q];
		}
	    }
	    cout <<hole;
	  }
	}
  cout <<endl;
  }
  return 0;

}

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

int main(){
    long long sum = 0;
    long long x;
    cin >> x;

    int i = 0;
    while(sum < x){
        //sum = 0;
        i += 1;
        sum += i;
    }

    cout << i << endl;
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif

// -------------------------------------Code starts here---------------------------------------------------------------------     

   int n;
   cin>>n;
   string a;
   cin>>a;
   int cnt=0;
   for(int i=0;i<n-2;i++)
   {
      if(a[i]=='A' && a[i+1]=='B' && a[i+2]=='C')
         cnt++;
   }
   cout<<cnt;

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 200000 + 5;

ll a[maxn];

int main() {
	int n;
	ll sum = 0;
	scanf("%d", &n);
	for(int i=0; i<n; i++) 
		scanf("%lld", &a[i]),
		sum += a[i];
		
	ll s2 = a[0];
	ll ans = fabs(sum-2*a[0]);
	for(int i=1; i<n-1; i++) {
		s2 += a[i];
		ll ss = fabs(sum-2*s2);
		ans = min(ans, ss);
	}
	
	printf("%lld\n", ans);
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
typedef long long ll;
int main(){
    string s; cin >> s;
    if(s == "SUN") cout << "7" << endl;
    if(s == "MON") cout << "6" << endl;
    if(s == "TUE") cout << "5" << endl;
    if(s == "WED") cout << "4" << endl;
    if(s == "THU") cout << "3" << endl;
    if(s == "FRI") cout << "2" << endl;
    if(s == "SAT") cout << "1" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	char c;
	int count[26] = {};
	int i;

	while((c = getchar()) != EOF)
	{
		if((c >= 'a') && (c <= 'z'))
			count[c - 'a']++;
		else if ((c >= 'A') && (c <= 'Z'))
			count[c - 'A']++;
	}
	for(i = 'a';i <= 'z';i++)
		printf("%c : %d\n", i, count[i - 'a']);

	return 0;
}

Measured memory_bytes: 524