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

/**
 * vector<int>ar(3);
 * for(auto&e:ar){
 *     scanf("%d",&e);
 * }
 * sort(ar.begin(),ar.end())
 * int sum=accumulate(ar.begin(),ar.end(),0);
 ***/

int main(){
    double pai=3.141592653589;
    int cnt[26];
    char c;
    for(int i=0;i<26;i++){
        cnt[i]=0;
    }
    while(scanf("%c",&c)!=EOF){
        if(isupper(c)){
            cnt[static_cast<int>(c)-65]+=1;
        }else if(islower(c)){
            cnt[static_cast<int>(c)-97]+=1;
        }
    }
    for(int i=0;i<26;i++){
        printf("%c : %d\n",static_cast<char>(i+97),cnt[i]);
    }
    return 0;
}

Measured memory_bytes: 1128
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

ll s[100010];

int main () {

    int q;cin>>q;

    ll cnt=2;

    s[0]=0;s[1]=0;s[2]=0;s[3]=1;s[4]=1;s[5]=2;s[6]=2;
    
    for (int i=7;i<100001;i++) {
        if (i%2!=0) {
            bool ok=true;
            for (int j=2;j*j<=i;j++) {
                if (i%j==0) ok=false;
            }
            for (int j=2;j*j<=(i+1)/2;j++) {
                if ((i+1)/2 % j == 0) ok=false;
            }
            if (ok) {
                cnt++;
                s[i]=cnt;
            } else {
                s[i]=cnt;
            }
        } else {
            s[i]=cnt;
        }
    }

    rep(i,q) {
        int l,r;cin>>l>>r;
        cout<<s[r]-s[l-1]<<endl;
    }

    // rep(i,100) {
    //     cout<<s[i]<<endl;
    // }

}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define ip pair<ll,ll>
#define ff first
#define ss second
#define MAX 2000005
const ll MOD = 1000000007;

inline ll addmod(ll a, ll b){
	return (a+b)%MOD;
}

inline ll mulmod(ll a, ll b){
	return (a*b)%MOD;
}

ll modexp(ll a, ll n){
	if(n == 0)
		return 1;
	ll p = modexp(a,n/2);
	p = mulmod(p,p);
	if(n&1)
		p = mulmod(p,a);
	return p;
}

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

	ll fact[MAX],invfact[MAX];
	fact[0] = 1;
	for(int i=1;i<MAX;i++)
		fact[i] = mulmod(fact[i-1],i);
	invfact[MAX-1] = modexp(fact[MAX-1],MOD-2);
	for(int i=MAX-2;i>=0;i--)
		invfact[i] = mulmod(invfact[i+1],i+1);

	string s;
	ll k;
	cin>>k;
	cin>>s;
	int n = s.length();

	// vector<int> v(26,n+1);
	// for(int i=0;i<n;i++)
	// 	--v[s[i]-'a'];
	// ll p = 0;
	// for(int i=0;i<26;i++)
	// 	p += v[i];
	

	ll p1 = 1;
	ll p2 = 1;
	for(int i=0;i<k;i++)
		p2 = mulmod(p2,25);
	ll inv = modexp(25,MOD-2);	

	ll ans = 0;
	for(ll r=0;r<=k;r++){
		// k+n-1-r => n-1 parts
		// cout<<"p1="<<p1<<" p2="<<p2<<endl;
		ans = addmod(ans,mulmod(mulmod(p1,p2),mulmod(fact[k-r+n-1],mulmod(invfact[k-r],invfact[n-1]))));
		p1 = mulmod(p1,26);
		p2 = mulmod(p2,inv);
	}

	cout<<ans<<endl;
}

Measured memory_bytes: 35484
// Last Change: 10/24/2019 19:53:03.
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

int main() {
  ll n, m;
  cin >> n >> m;
  vector<ll> ipt(m);
  for (auto &&e : ipt) {
    cin >> e;
  }
  vector<ll> val(n, 0);
  for (int i = m - 1; i >= 0; --i) {
    if (val[ipt[i] - 1] == 0) {
      val[ipt[i] - 1] = 1;
      cout << ipt[i] << endl;
    }
  }
  for (ll i = 0; i < n; ++i) {
    if (val[i] == 0) {
      cout << i + 1 << endl;
    }
  }
}



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

#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(),x.end()

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9+7;
const ll INF = 1e18;
const int MAX = 1e6;

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

struct edge {int to, cost;}; // 辺
// vector<edge> graph[MAX]; // 隣接リスト
// bool visit[MAX]; // 訪問の有無

int n, m; // 変数
string s, t;
int dp[3001][3001];
string ans;

void res(int i, int j) { // LCSの復元
    if (i == 0 || j == 0) return;
    if (s[i] == t[j]) {
        ans.push_back(s[i]);
        res(i-1, j-1);
    } else if (dp[i][j] == dp[i-1][j]) {
        res(i-1, j);
    } else if (dp[i][j] == dp[i][j-1]) {
        res(i, j-1);
    }
}

void dp_solve() {
    if (s.size() < t.size()) swap(s, t);
    s = ' ' + s;
    t = ' ' + t;
    n = s.size();
    m = t.size();
    rep(i, n) {
        rep(j, m) {
            if (i == 0 || j == 0) {
                dp[i][j] = 0;
            } else {
                if (s[i] == t[j]) {
                    dp[i][j] = dp[i-1][j-1] + 1;
                } else {
                    int x = dp[i-1][j];
                    int y = dp[i][j-1];
                    dp[i][j] = max(x, y);
                }
            }
        }
    }
    res(n-1, m-1);
    reverse(ALL(ans));
}


int main() {
// input
    cin >> s;
    cin >> t;
// solve
    dp_solve();
// output
    cout << ans << "\n";
}

Measured memory_bytes: 38824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=1LL<<61;

ll mpow(ll x, ll n) {
  ll ans=1;
  while(n>0) {
    if(n&1) {
      ans=ans*x%mod;
    }
    x=x*x%mod;
    n>>=1;
  }
  return ans;
}

vec tfact(1e7+1);
void fact(ll n) {
  for(ll i=0;i<=n;i++) {
    if(i==0) {
      tfact[i]=1;
    }
    else {
      tfact[i]=tfact[i-1]*i%mod;
    }
  }
}

ll comb(ll n, ll k) {
  return tfact.at(n)*mpow(tfact.at(k),mod-2)%mod*mpow(tfact.at(n-k),mod-2)%mod;
}

int main() {
  ll h,w,n;
  cin >> h >> w >> n;
  vector<pll> a(n+1);
  for(ll i=0;i<n;i++) {
    cin >> a[i].first >> a[i].second;
  }
  a[n]={h,w};
  fact(h+w);
  sort(a.begin(),a.end());
  vec dp(n+1);
  for(ll i=0;i<=n;i++) {
    ll y=a[i].first-1;
    ll x=a[i].second-1;
    dp[i]=comb(y+x,y);
    for(ll j=0;j<i;j++) {
      ll dy=a[i].first-a[j].first;
      ll dx=a[i].second-a[j].second;
      if(dx>=0) {
        dp[i]=(dp[i]-dp[j]*comb(dy+dx,dy)%mod+mod)%mod;
      }
    }
  }
  cout << dp[n] << endl;
}

Measured memory_bytes: 81140
#include <iostream>

using namespace std;

int main()
{
    int A , B ;
    cin>>A;
    cin>>B;
    while (B%2==0){
        if(A>=13){
            cout<<B;
            break;
        }
        else if (A>=6 && A<=12){
            cout<<B*0.5;
            break;
        }
        else{
            cout<<0;
            break;
        }

    }

    return 0;
}


Measured memory_bytes: 256
//============================================================================
// Name        : template.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <bits/stdc++.h>
using namespace std;
#define _CRT_SECURE_NO_DEPRECATE // suppress some compilation warning messages (for VC++ users)
// Shortcuts for "common" data types in contests
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef set<int> si;
typedef map<string, int> msi;
// To simplify repetitions/loops, Note: define your loop style and stick with it!
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define REP(i, a, b) \
for (int i = int(a); i <= int(b); i++) // a to b, and variable i is local!
#define forn(i,n) \
for (int i =0; i<(n); i++)
#define TRvi(c, it) \
for (vi::iterator it = (c).begin(); it != (c).end(); it++)
#define TRvii(c, it) \
for (vii::iterator it = (c).begin(); it != (c).end(); it++)
#define TRmsi(c, it) \
for (msi::iterator it = (c).begin(); it != (c).end(); it++)
#define INF 2000000000 // 2 billion
// If you need to recall how to use memset:
#define MEMSET_INF 127 // about 2B
#define MEMSET_HALF_INF 63 // about 1B
//memset(dist, MEMSET_INF, sizeof dist); // useful to initialize shortest path distances
//memset(dp_memo, -1, sizeof dp_memo); // useful to initialize DP memoization table
//memset(arr, 0, sizeof arr); // useful to clear array of integers

int main() {
	ios::sync_with_stdio(false);
 cin.tie(0);
 ll a,b,c, d;
 cin >> a >> b >> c >> d;
 ll one = a * c;
 ll two = a * d;
 ll three = b * c;
 ll four = b * d;
 ll ans = max(max(one, two), max(three, four));
 cout << ans<< "\n";
return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
// 1~9 9
// 100~999 900
// 10000~99999 900000
int main()
{
    int n, sum;
    scanf("%d", &n);
    if (n < 10)
        printf("%d\n", n);
    else if (n < 100)
        printf("9\n");
    else if (n < 1000)
        printf("%d\n", 9 + n - 100 + 1);
    else if (n < 10000)
        printf("909\n");
    else if (n < 100000)
        printf("%d\n", 909 + n - 10000 + 1);
    else
        printf("90909\n");
    return 0;
}

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

#define INF 1.1e9
#define LINF 1.1e18
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define BIT(x,n) bitset<n>(x)
#define PI 3.14159265358979323846

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

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

int n,d[300000];
int r;

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

	cin>>n;
	REP(i,n) {
		cin>>d[i];
	}
	REP(i,n) {
		if(r<i*10) {
			cout<<"no"<<endl;
			return 0;
		}
		r=max(r,i*10+d[i]);
	}
	r=(n-1)*10;
	for(int i=n-1;i>=0;i--) {
		if(r>i*10) {
			cout<<"no"<<endl;
			return 0;
		}
		r=min(r,i*10-d[i]);
	}
	cout<<"yes"<<endl;

	return 0;
}



Measured memory_bytes: 4300
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, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var M = cin.ReadInt;
            int[] L = new int[M];
            int[] R = new int[M];
            for (int i = 0; i < M; i++)
            {
                L[i] = cin.ReadInt;
                R[i] = cin.ReadInt;
            }

            var maxL = L.Max();
            var minR = R.Min();
            if(maxL <= minR)
            {
                Console.WriteLine(minR - maxL + 1);
            }
            else
            {
                Console.WriteLine("0");
            }
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    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: 17444
#include<stdio.h>

int main()
{
	int W,H,x,y,r,v1,v2,y1,y2;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	v1=x+r;
	v2=W-(x-r);
	y1=y+r;
	y2=H-(y-r);
	if(v1>W||v2>W||y1>H||y2>H){
		printf("No\n");
	}
	else{
		printf("Yes\n");
	}
}

Measured memory_bytes: 1012
#include <iostream>

#include <vector>

#include <queue>

using namespace std;

const int N = 1000 * 1000 * 1000 + 7;
vector<int> adj[200005];
int dis[200005];
queue<int> q;
int main()
{
	int n, m;
	cin >> n;
	cin >> m;
	for(int i = 0; i < m; i ++)
	{
		int x, y;
		cin >> x;
		cin >> y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	for(int i = 2; i <= n; i ++)
	{
		dis[i] = N;
	}
	dis[1] = 0;
	q.push(1);
	while(q.size())
	{
		int v = q.front();
		q.pop();
		for(int i = 0; i < adj[v].size(); i ++)
		{
			if(dis[adj[v][i]] == N)
			{
				dis[adj[v][i]] = dis[v] + 1;
				q.push(adj[v][i]);
			}
		}
	}
	if(dis[n] == 2)
	{
		cout << "POSSIBLE";
	}
	else
	{
		cout << "IMPOSSIBLE";
	}
	return 0;
}

Measured memory_bytes: 13168
//Don't have to see. start------------------------------------------
var read = require('readline').createInterface({
  input: process.stdin, output: process.stdout
});
var obj; var inLine = [];
read.on('line', function(input){inLine.push(input);});
read.on('close', function(){
  obj = init(inLine);
  console.error("\n");
  var start = Date.now();
  Main();
  var end = Date.now() - start;
  myerr("time : " + end + "ms");
  myerr("memory : " + Math.round(process.memoryUsage().heapTotal / 1024) + "KB");
});
function makeClone(obj){return JSON.parse(JSON.stringify(obj));}
function nextInt(){return myconv(next(),1);} function nextStrArray(){return myconv(next(),2);}
function nextIntArray(){return myconv(next(),4);} function nextCharArray(){return myconv(next(),6);}
function next(){return obj.next();} function hasNext(){return obj.hasNext();}
function init(input){  
  return {
    list : input, index : 0, max : input.length,
    hasNext : function(){return (this.index < this.max);},
    next : function(){if(this.hasNext()){return this.list[this.index++];}else{throw "ArrayIndexOutOfBoundsException ‚There is no more input";}}
  };
}
function myout(s){console.log(s);}
function myerr(s){console.error("debug:" + require("util").inspect(s,false,null));}
//param "no" is
//unknown or outlier : return i. 1: parseInt.
//2: split space. 4: split space and parseInt.
//6: split 1 character. 7: split 1 character and parseInt.
//8: join space. 9: join nextline. 0: join no character.
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map(Number);case 6:return i.split("");case 7:return i.split("").map(Number);case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}

//Don't have to see. end------------------------------------------
function Main(){
  var one = nextIntArray();
  var N = one[0];
  var K = one[1];
  var list = nextIntArray();
  var output = 0;
  for(var i = 0; i < N; i++){
    if(list[i] >= K){
      output++;
    }
  }
  myout(output);
}

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

typedef long long LL;

const int mod=1000000007;

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int add(int a,int b,int p=mod){return a+b>=p?a+b-p:a+b;}
int sub(int a,int b,int p=mod){return a-b<0?a-b+p:a-b;}
int mul(int a,int b,int p=mod){return (LL)a*b%p;}
void sadd(int &a,int b,int p=mod){a=add(a,b,p);}
void ssub(int &a,int b,int p=mod){a=sub(a,b,p);}
void smul(int &a,int b,int p=mod){a=mul(a,b,p);}
int Power(int a,int k,int p=mod){int res=1;for (;k;k>>=1,smul(a,a,p)) if (k&1) smul(res,a,p);return res;}

int n,m,t;

void into(){
  scanf("%d%d%d",&n,&m,&t);
}

int ans;

void Get_ans(){
  int n0=n/gcd(n,t),m0=m/gcd(m,t);
  sadd(ans,1);
  sadd(ans,sub(add(Power(2,n0),Power(2,m0)),2));
  sadd(ans,sub(Power(2,gcd(n0,m0)),2));
  ans=Power(ans,n/n0);
  ans=Power(ans,m/m0);
}

void work(){
  Get_ans();
}

void outo(){
  printf("%d\n",ans);
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3840
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 1e18;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, a, b) for (int i = b - 1; i >= a; i--)
#define int ll
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

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

signed main() {
    int a, b;
    cin >> a >> b;
    int sum = gcd(a, b);
    map<int, int> mp;
    for (int i = 2; i * i <= sum; i++) {
        while (sum % i == 0) {
            mp[i]++;
            sum /= i;
        }
    }
    if (sum != 1) mp[sum]++;
    cout << mp.size() + 1 << "\n";
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <numeric>
#include <iomanip>
#define ll long long
#define pi 3.14159265358979323846
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};
/*　BFS
 vector<vector<ll>> g(n+1);
    for(ll i = 0; i < m; i++){
        ll a, b;
        cin >> a >> b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> dist(n+1, -1);
    queue<ll> que;
    que.push(1);
    dist[1] = 0;
    while(!que.empty()){
        ll v = que.front();
        que.pop();
        for(ll nv : g[v]){
            if(dist[nv]!=-1) continue;
            dist[nv] = dist[v]+1;
            que.push(nv);
        }
    }
*/

int main(){
    ll n;
    cin >> n;
    ll first = n;
    map<ll, ll> I{};
    vector<ll> c;
    c.push_back(2);
    for(ll i = 3; i <= 1e+6; i+=2){
        bool ok = true;
        for(ll j = 3; j <= sqrt(i); j+=2){
            if(i%j==0){
                ok = false;
                break;
            }
        }
        if(ok==true) c.push_back(i);
    }
    ll count = 0;
    while(count != c.size()){
        ll a = c[count];
        if(n%a==0){
            n /= a;
            I[a]++;
        }
        else if(n%a!=0)
            count++;
    }
    //cout << n << endl;
    ll ans = 0;
    if(n!=1) ans++;
    for(auto &x : I){
        //cout << x.first << " " << x.second << endl;
        ll check = 0;
        for(ll i = 1; i <= 100; i++){
            check += i;
            if(check <= x.second) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4384
n=int(input())
l=list(map(int,input().split()))
dp=[float('inf') for i in range(n+1)]
dp[0]=0
for i in range(len(dp)):
    for j in range(i+1,i+3):
        if(j<len(l)):
      	    dp[j]=min(dp[j],dp[i]+abs(l[j]-l[i]))
print(dp[n-1])

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

int main(){
  string S;
  int N;
  cin >> N;
  cin >> S;
  vector<char> alp(26);
  alp={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
  for(int i=0; i<S.size(); i++){
    for(int j=0; j<26; j++){
      if(S.at(i)==alp.at(j)){
        S.at(i)=alp.at((j+N)%26);
        break;
      }
    }
  }
  cout << S << endl;
}

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

using namespace std;

constexpr static int MAXN = 1e6;
constexpr static int MOD = 1e9 + 7;

int N, M;
int A[MAXN];
int cnt[MAXN];
int filled[MAXN];

/*
int solve() {
    if (N > 200 || M > 200)
        return 0;

    vector <int> cnt(N + 1);
    for (int i = 0; i < N; i++)
        cnt[A[i]]++;

    //cout << "> ";
    //for (int i = 0; i < N; i++)
    //    cout << A[i] << ' ';
    //cout << endl;

    vector <int> filled(N + 1);
    for (int i = 1; i <= N; i++)
        for (int j = 0; j < cnt[i] && j < i; j++)
            filled[i - j]++;
    int added = 0;
    for (int i = 1; i <= N; i++)
        if (!filled[i])
            added++;
    return added;
}
*/

int main() {
    cin >> N >> M;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        cnt[A[i]]++;
    }

    for (int i = 1; i <= N; i++)
        for (int j = 0; j < cnt[i] && j < i; j++)
            filled[i - j]++;

    int added = 0;
    for (int i = 1; i <= N; i++)
        if (!filled[i])
            added++;

    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        int val = A[x - 1];
        cnt[val]--;
        if (cnt[val] < val) {
            if (--filled[val - cnt[val]] == 0)
                added++;
        }

        if (cnt[y] < y) {
            if (filled[y - cnt[y]]++ == 0)
                added--;
        }
        cnt[y]++;

        A[x - 1] = y;
        //cout << solve() << '\n';
        cout << added << endl;
    }
}


Measured memory_bytes: 10496
#include <cmath>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>

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

using namespace std;

typedef pair<int, int> P;

const int INF = 1e15;
const int MOD = 1e9+7;

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

    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int sum = 0;
    rep(i, n) sum ^= a[i];

    vector<bool> k(31, false);
    rep(i, n){
        int x = a[i] ^ (a[i]-1);
        rep(j, 31){
            if(x == (1 << j) - 1){
                k[j] = true;
            }
        }
    }

    int ans = 0;
    for(int i = 30; i >= 0; i--){
        if((sum >> i) == 0){
            continue;
        }

        if(k[i+1]){
            sum ^= (1 << (i+1)) - 1;
            ans++;
        }
    }

    if(sum == 0){
        cout << ans << endl;
        return 0;
    }
    cout << -1 << endl;

    return 0;
}


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

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);

            Console.WriteLine(N[0] * N[1] / 2);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int p,k = 0;string n , m,l,r;
	cin>>p>>n>>m;
	l = n;r = m;
	if(l == r)
	{
		cout<<p;
		return 0;
	}
	while(l != r)
	{
		l.erase(0,1);
		r.erase(r.size() - 1,1);
		k++;
	}
	if(l.size() == 0)
	{
		cout<<p * 2;
		return 0;
	}
	cout<<(p * 2) - (p - k);
}

Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int[][] num = new int[3][101];
        int[][] player = new int[n][3];

        for(int i=0; i<n; i++){
            for(int j=0; j<3; j++){
                int number = sc.nextInt();
                num[j][number]++;
                player[i][j] = number;
            }
        }

        int[] point = new int[n];
        for(int i=0; i<n; i++){
            for(int j=0; j<3; j++){
                if(num[j][player[i][j]]==1){
                    point[i] += player[i][j];
                }
            }
        }

        for(int i=0; i<n; i++){
            System.out.println(point[i]);
        }

    }

    public static void main(String[] args){
        new Main().solve();
    }
}

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

#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define REPR(i, n) for(int (i) = (n); (i) >= 0; --(i))
#define FOR(i, n, m) for(int (i) = (n); (i) <= (m); ++(i))

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};


int main(){
  int N, M, K;
  cin >> N >> M >> K;
  UnionFind uf(N);
  vector<int> ans(N, -1);
  REP(i, M){
    int a, b;
    cin >> a >> b;
    a--, b--;
    ans[a]--, ans[b]--;
    uf.merge(a, b);
  }
  REP(i, N){
    ans[i] += uf.size(i);
  }

  REP(i, K){
    int c, d;
    cin >> c >> d;
    c--, d--;
    if(uf.issame(c, d)){
      ans[c]--, ans[d]--;
    }
  }
  REP(i, N){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


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

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  vector<bool> chk(26, false);
  string s;
  cin >> s;

  rep(i, (ll)s.size()) chk[s[i] - 'a'] = true;

  rep(i, 26) if (!chk[i]) {
    printf("%c\n", ('a' + (char)i));
    return 0;
  };

  puts("None");

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}
 
ll gcd(ll a, ll b) {return (b == 0) ? a : gcd(b, a % b);}
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	ll n=s.length();
	ll rem=0;
	for(ll i=0;i<n;i++){
	    ll d=s[i]-'0';
	    rem=(rem*10+d)%9;
	}
	if(rem)
	    cout<<"No\n";
	else
	    cout<<"Yes\n";
}

Measured memory_bytes: 3736
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    return b;
}

int main(){
    ll n;cin>>n;
    ll x[n],y[n],h[n];
    ll j=-1;
    for(ll i=0;i<n;i++){
        cin>>x[i]>>y[i]>>h[i];
        if(h[i]>0 && j==-1 && i>0){
            j=i;
        }
    }
    ll ax,ay,ah;
    ll cx,cy,hh;
    bool b;
    if(j>0){
        ax=x[0];ay=y[0];ah=h[0];
        x[0]=x[j];y[0]=y[j];h[0]=h[j];
        x[j]=ax;y[j]=ay;h[j]=ah;
    }
    for(cx=0;cx<=100;cx++){
        for(cy=0;cy<=100;cy++){
            b=true;
            hh=h[0]+abs(x[0]-cx)+abs(y[0]-cy);
            if(hh>=1){
                for(ll i=1;i<n;i++){
                    if(h[i]!=0){
                        if(hh!=h[i]+abs(x[i]-cx)+abs(y[i]-cy)){
                            b=false;
                        }
                    }else{
                        if(hh>h[i]+abs(x[i]-cx)+abs(y[i]-cy)){
                            b=false;
                        }
                    }
                }
                if(b){
                    ax=cx;
                    ay=cy;
                    ah=hh;
                }
            }
        }
    }
    cout<<ax<<' '<<ay<<' '<<ah<<endl;
    return 0;
}



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

int main(){
    int h,w,n;
    vector<int> a;
    cin>>h>>w>>n;
    for(int i=0;i<n;i++){
        int tmp;
        cin>>tmp;
        a.push_back(tmp);
    }

 //   vector<vector<int>> c(h);
    int c[h][w];
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            //c[i].push_back(0);
            c[i][j]=0;
        }
    }

    int ith=0,itw=0;
    bool mode=true;
    for(int i=0;i<n;i++){
        for(int j=0;j<a[i];j++){
            c[ith][itw]=i+1;
            if(mode){
                if(itw<w-1) itw++;
                else if(itw==w-1){
                    ith++;
                    mode = !mode;
                }
            }else{
                if(itw>0) itw--;
                else if(itw==0){
                    ith++;
                    mode = !mode;
                }
            }
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << c[i][j];
            if(j==w-1) cout<<endl;
            else cout << " ";
        }
    }
}

Measured memory_bytes: 384
// Shift-JIS（シフトジス）

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

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main()
{
    int D, N;
    cin >> D >> N;
    int p = 1;
    for (int i = 0; i < D; i++)
    {
        p *= 100;
    }
    if (N != 100)
    {
        cout << N * p << endl;
    }
    else
    {
        cout << (N + 1) * p << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
#define FPEN freopen("in.txt", "r", stdin);
#else
#define FPEN
#endif
const int maxn = 200009;
typedef long long i64;
typedef pair<i64, i64> pi64;
typedef pair<int, int> pi;
const i64 MOD = 119 << 23 | 1;
class {
 public:
  long double a[maxn], E[maxn];
  int in[maxn];
  vector<int> V[666];
  int n, m;
  void solve() {
    cin >> n >> m;
    for (int i = 0; i < m; ++i) {
      int u, v;
      cin >> u >> v;
      V[u].push_back(v);
      in[v]++;
    }
    // ts();
    // E[n] = 0;
    // for (int i = n - 1; i >= 1; --i) {
    //   for (int j : V[i]) {
    //     E[i] += E[j];
    //   }
    //   E[i] = E[i] / V[i].size() + 1;
    // }
    // long double ans = E[1];
    // for (int i = 1; i < n; ++i) {
    //   if (V[i].size() != 1) {
    //     long double NE = (E[i] - 1) * V[i].size();
    //     for (int j : V[i]) {
    //       long double NEE = (NE - E[j]) / (V[i].size() - 1) + 1;
    //       long double del = NEE - E[i];
    //       ans = min(ans, E[1] + del * a[i]);
    //     }
    //   }
    // }
    // printf("%.10f\n", ans);
    long double ans = 1e18;
    for (int i = 1; i < n; ++i) {
      ans = min(ans, gao(i));
    }
    cout << fixed << setprecision(10) << ans << endl;
  }
  long double gao(int p) {
    E[n] = 0;
    for (int i = n - 1; i >= 1; --i) {
      E[i] = 0;
      long double cnt = V[i].size();
      long double Max = 0;
      for (int j : V[i]) {
        E[i] += E[j];
        Max = max(E[j], Max);
      }
      if (p == i && V[i].size() != 1) {
        E[i] -= Max;
        cnt--;
      }
      E[i] = E[i] / cnt + 1;
    }
    return E[1];
  }
  void ts() {
    a[1] = 1;
    vector<int> que;
    que.push_back(1);
    for (int i = 0; i < que.size(); ++i) {
      for (int j : V[que[i]]) {
        a[j] += a[que[i]] / V[que[i]].size();
        in[j]--;
        if (in[j] == 0) {
          que.push_back(j);
        }
      }
    }
  }
} NSPACE;
int main() {
  FPEN;
  ios_base::sync_with_stdio(false);
  cout.tie(0);
  cin.tie(0);
  NSPACE.solve();
}

Measured memory_bytes: 3456
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<ll, int> P; //cost to

#define max_V 100001
#define fs first
#define sc second

const int INF = 1 << 30;

vector<P> G[max_V];
bool used[max_V];

//出力：コスト
ll prim(){
  ll res = 0LL;
  priority_queue<P, vector<P>, greater<P>> que;

  //点0を集合Xに
  used[0] = true;
  for(int i = 0; i < (int)G[0].size(); i++){
    que.push(G[0][i]);
  }

  while(!que.empty()){
    P e = que.top();
    que.pop();
    int to = e.second;
    ll cost = e.first;

    if(!used[to]){
      used[to] = true;
      res += cost;
      for(int i = 0; i < (int)G[to].size(); i++){
        if(!used[G[to][i].second]){
          que.push(G[to][i]);
        }
      }
    }
  }

  return res;
}

bool cmp(const pair<pair<ll, ll>, int> &a, const pair<pair<ll, ll>, int> &b){
  return a.fs.sc < b.fs.sc;
}

int main(){
  int N;
  cin >> N;
  pair<pair<ll, ll>, int> p[N];
  for(int i = 0; i < N; i++){
    cin >> p[i].first.first >> p[i].first.second;
    p[i].second = i;
  }

  sort(p, p + N);
  /*for(int i = 0; i < N; i++){
    cout << p[i].fs.fs << " " << p[i].fs.sc << " " << p[i].sc << endl;
  }*/
  for(int i = 0; i < N - 1; i++){
    ll dist = min(abs(p[i].fs.fs - p[i+1].fs.fs), abs(p[i].fs.sc - p[i+1].fs.sc));
    G[p[i].sc].push_back(P(dist, p[i + 1].sc));
    G[p[i + 1].sc].push_back(P(dist, p[i].sc));
  }

  sort(p, p + N, cmp);
  /*for(int i = 0; i < N; i++){
    cout << p[i].fs.fs << " " << p[i].fs.sc << " " << p[i].sc << endl;
  }*/
  for(int i = 0; i < N - 1; i++){
    ll dist = min(abs(p[i].fs.fs - p[i+1].fs.fs), abs(p[i].fs.sc - p[i+1].fs.sc));
    G[p[i].sc].push_back(P(dist, p[i + 1].sc));
    G[p[i + 1].sc].push_back(P(dist, p[i].sc));
  }

  cout << prim() << endl;
  return 0;
}


Measured memory_bytes: 16116
import bisect

A, B, Q = map(int, input().split())
INF = 10**18
S = [-INF]
for i in range(A):
    S.append(int(input()))
S.append(INF)
T = [-INF]
for i in range(B):
    T.append(int(input()))
T.append(INF)
X = []
for i in range(Q):
    X.append(int(input()))

for x in X:
    a, b = bisect.bisect_right(S, x), bisect.bisect_right(T, x)
    print(min(abs(s-t) + min(abs(s-x), abs(t-x))
              for s in S[a-1:a+1] for t in T[b-1:b+1]))


Measured memory_bytes: 16160
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			//			solveA();
			solveB();
			// solveC();
			// solveD();
			// solveE();
			// solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numN = Integer.parseInt(next());

		switch (numN) {
		case 7:
		case 5:
		case 3:
			out.print("YES");
			break;
		default:
			out.print("NO");
			break;
		}

		out.println("");
	}

	private void solveB() {
		String strN = next();

		int res = 99999999;
		for (int i = 0; i < strN.length() - 2; i++) {
			String wk = strN.substring(i, i + 3);
			int wkNum = Integer.parseInt(wk);
			res = Math.min(res, Math.abs(wkNum - 753));
		}

		out.println(res);
	}

	private void solveC() {
		int numN = Integer.parseInt(next());

		out.println("");
	}

	private void solveD() {
		int numN = Integer.parseInt(next());

		out.println("");
	}

	private void solveE() {
		int numN = Integer.parseInt(next());

		out.println("");
	}

	private void solveF() {
		int numN = Integer.parseInt(next());

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
using ll = long long;
using P = pair<int, int>;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(), v.end()
#define sz(x) ((int) x.size())
#define pb push_back
#define mp make_pair
#define F first
#define S second
typedef vector<ll> vi;
const int MOD = 1000000007;
template<class T> void print(const T& t){ cout << t << endl; }
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(){
  ll n;
  cin >> n;
  if(n<1000){
    print("ABC");
  }
  else{
    print("ABD");
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
using namespace std;
const int N=100100;
int r,c,n;
vector<pair<int,int>> a[4];
stack<int> q;
int main()
{
    ios::sync_with_stdio(false);
    cin>>r>>c>>n;
    for(int i=1;i<=n;++i)
    {
        int x1,x2,y1,y2;
        cin>>x1>>y1>>x2>>y2;
        if((x1==0||x1==r||y1==0||y1==c)&&(x2==0||x2==r||y2==0||y2==c))
        {
            int cnt=0;
            if(x1>=0&&x1<=r&&y1==0)
                a[0].push_back(make_pair(x1,i)),cnt++;
            if(x1>=0&&x1<=r&&y1==c)
                a[2].push_back(make_pair(x1,i)),cnt++;
            if(y1>0&&y1<c&&x1==0)
                a[3].push_back(make_pair(y1,i)),cnt++;
            if(y1>0&&y1<c&&x1==r)
                a[1].push_back(make_pair(y1,i)),cnt++;
            if(x2>=0&&x2<=r&&y2==0)
                a[0].push_back(make_pair(x2,i)),cnt++;
            if(x2>=0&&x2<=r&&y2==c)
                a[2].push_back(make_pair(x2,i)),cnt++;
            if(y2>0&&y2<c&&x2==0)
                a[3].push_back(make_pair(y2,i)),cnt++;
            if(y2>0&&y2<c&&x2==r)
                a[1].push_back(make_pair(y2,i)),cnt++;
            if(cnt!=2) cout<<a[3][666].second;
        }
    }
    for(int i=0;i<=3;++i)  if(!a[i].empty())  sort(a[i].begin(),a[i].end());
    //for(int i=0;i<=3;++i) cout<<a[i].size()<<endl;
    if(!a[0].empty())
    for(auto i=a[0].begin();i<a[0].end();i++)
    {
        int t=(*i).second;
        if(!q.empty()&&q.top()==t) q.pop();
        else q.push(t);
    }
    if(!a[1].empty())
    for(auto i=a[1].begin();i<a[1].end();i++)
    {
        int t=(*i).second;
        if(!q.empty()&&q.top()==t) q.pop();
        else q.push(t);
    }
    if(!a[2].empty())
    for(auto i=a[2].end()-1;i>=a[2].begin();i--)
    {
        int t=(*i).second;
        if(!q.empty()&&q.top()==t) q.pop();
        else q.push(t);
    }
    if(!a[3].empty())
    for(auto i=a[3].end()-1;i>=a[3].begin();i--)
    {
        int t=(*i).second;
        if(!q.empty()&&q.top()==t) q.pop();
        else q.push(t);
    }
    if(!q.empty()) cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    return 0;
}

Measured memory_bytes: 2520
n,m = map(int,input().split())
l = []
s = ""
tmp = 1
for i in range(m):
  p,y = map(int,input().split())
  l.append([str(p).zfill(6),y,i+1])
  
l = sorted(l, key=lambda x:(x[0],x[1]))
#print(l)
for i in range(m):
  s = ""
  if i == 0 or l[i-1][0] != l[i][0]:
    tmp = 1
  else:
    tmp += 1
  s = l[i][0] + str(tmp).zfill(6)
  l[i].append(s)
    
l = sorted(l, key=lambda x:(x[2]))

for i in range(m):
  print(l[i][3])

Measured memory_bytes: 37536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

ll pow5(ll n)
{
    return n * n * n * n * n;
}

int main()
{
    ll x;
    cin >> x;
    for (ll i = 1; i < 200; i++)
    {
        ll now = x;
        if (now == pow5(i))
        {
            printf("%lld %lld\n", i, 0ll);
            return 0;
        }
        ll sub = now - pow5(i); // -(-j)^5 = x - i^5
        for (ll j = 1; j < 200; j++)
        {
            if (sub == pow5(j))
            {
                printf("%lld -%lld\n", j, i);
                return 0;
            }
        }
        ll add = now + pow5(i); // x + i^5 = -(j^5)
        for (ll j = 1; j < 200; j++)
        {
            if (add == pow5(j))
            {
                printf("%lld %lld\n", j, i);
                return 0;
            }
        }
    }

    return 0;
}

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

const int LOOP=100;

using ld=long double;
const ld EPS=1e-10;
const ld g=1.0;

int main(){
    int n,b;
    ld d;
    cin>>d>>n>>b;
    vector<ld> p(n),h(n);
    for(int i=0;i<n;i++) cin>>p[i]>>h[i];

    ld res=1e10;
    for(int c=1;c<=b+1;c++){
        ld l=d/c;
        vector<ld> px(n);
        for(int i=0;i<n;i++){
            px[i]=p[i]-floor(p[i]/l)*l;
        }
        auto isValidImpl=[&](ld Vx,ld Vy){
            if(isnan(Vx) || isnan(Vy)) return false;
            if(Vx<EPS || Vy<EPS) return false;
            bool res=true;
            for(int i=0;i<n;i++){
                ld t=px[i]/Vx;
                ld y=Vy*t-0.5*g*t*t;
                res = res && (h[i]<y);
            }
            return res;
        };
        auto isValid=[&](ld v){
            ld Y=g*l/2;
            ld X=sqrt(v*v+2*Y);
            ld x0=(X+sqrt(X*X-4*Y))/2;
            ld x1=(X-sqrt(X*X-4*Y))/2;
            return isValidImpl(x0,x1) || isValidImpl(x1,x0);
        };
        ld lb=0,ub=1e10;
        for(int i=0;i<LOOP;i++){
            ld v=(lb+ub)/2;
            if(isValid(v)){
                ub=v;
            }
            else{
                lb=v;
            }
        }
        res=min(res,lb);
    }
    cout<<fixed<<setprecision(10);
    cout<<res<<endl;
    return 0;
}


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

int main(){
    ll X;
    cin>>X;
    ll p=0;
    p = X/500;
    p*=1000;
    X=X%500;
    ll pp = 0;
    pp = X/5;
    pp*= 5;
    ll ans = 0;
    ans = p+pp;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
P = list(map(int, input().split()))
C = list(map(int, input().split()))

for i in range(N):
    P[i] -= 1

ans = -1 * 2 ** 30

if K <= N:
    for i in range(N):
        pos = i
        score = 0
        for j in range(K):
            score += C[pos]
            pos = P[pos]
            ans = max(ans, score)
    print(ans)
    exit(0)

for i in range(N):
    pos = i
    k = 0
    score = 0

    for j in range(N):
        score += C[pos]
        pos = P[pos]
        ans = max(ans, score)
        k += 1
        if pos == i:
            break

    score *= (K // k) - 1
    ans = max(ans, score)
    for j in range(k + (K % k)):
        score += C[pos]
        pos = P[pos]
        ans = max(ans, score)
print(ans)

Measured memory_bytes: 74120
#include <iostream>
#include <stdio.h>
#include <math.h>
using namespace std;

int main()
{
    int64_t a,b,c;
    cin>>a>>b>>c;
    int64_t x=b<=c?b-1:c;
    cout<<a*x/b<<endl;

    return 0;
}


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

n, k = map(int, readline().split())

z = [0] * n

for x in range(n):
    z[x] = x + 1

for i in range(k):
    d = int(input())
    a = list(map(int, input().split()))
    for j in range(d):
        if a[j] in z:
            z.remove(a[j])

print(len(z))


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

using namespace std;

typedef long long ll;

#define SIZE_SEG 100000

struct SegNode {
	int depth, id;
};

struct Node {
	int p, id, chsz, depth;
	vector<int> ch;
};
bool operator <(const SegNode& sn1, const SegNode& sn2) {
	return sn1.depth < sn2.depth;
}
bool operator >(const SegNode& sn1, const SegNode& sn2) {
	return sn2 < sn1;
}

int N, segSize;
vector<Node> G;
SegNode seg[SIZE_SEG*4];

int dfs(int n, int& id, int depth) {
	G[n].id = id++;
	G[n].depth = depth;

	int sz = 0;
	for (int i = 0; i < G[n].ch.size(); ++i) {
		sz += dfs(G[n].ch[i], id, depth+1);
	}
	G[n].chsz = sz;

	return sz+1;
}

void init(int sz) {
	for (segSize = 1; segSize < N; segSize <<= 1);
	for (int i = 0; i < segSize*2-1; ++i) {
		seg[i] = (SegNode){0, 0};
	}
}
void update(int n, int l, int r, int L, int R, SegNode& sn) {
	if (L <= l && r <= R) {
		if (sn > seg[n]) seg[n] = sn;
	}
	else if (r <= L || R <= l) {
		return;
	}
	else {
		int m = (l + r) / 2;
		update(n*2+1, l, m, L, R, sn);
		update(n*2+2, m, r, L, R, sn);
	}
}
void update(int L, int R, SegNode node) {
	update(0, 0, segSize, L, R, node);
}
SegNode get(int target) {
	SegNode ret = (SegNode){0, 0};
	int n = segSize+target-1;
//	cout << target << " : ";
	while (1) {
//		cout << n << " ";
		if (seg[n] > ret) ret = seg[n];
		if (n == 0) break;
		n = (n-1)/2;
	}
//	cout << endl;
	return ret;
}

int main() {
	int Q;
	while ( cin >> N >> Q, N || Q ) {
		G.clear(); G.resize(N);
		G[0].p = 0;
		for (int i = 1; i < N; ++i) {
			cin >> G[i].p; --G[i].p;
			G[G[i].p].ch.push_back(i);
		}

		{ int temp = 0; dfs(0, temp, 0); }

		init(N);

		ll ans = 0;
		for (int t = 0; t < Q; ++t) {
			char op; int id; cin >> op >> id; --id;
			if (op == 'M') {
				update(G[id].id, G[id].id+1+G[id].chsz, (SegNode){G[id].depth, id});
//				for (int i = 0; i < segSize*2-1; ++i) {
//					cout << seg[i].depth << " " << seg[i].id << endl;
//				}
//				cout << endl;
			}
			else { // Q
				ans += get(G[id].id).id+1;
//				cout << get(G[id].id).id+1 << endl;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 14928