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

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using ull = unsigned long long;
using vb = vector<bool>;
using vvb = vector<vb>;
using vd = vector<double>;
using vvd = vector<vd>;
using vvvd = vector<vvd>;
using vs = vector<string>;
using vvs = vector<vs>;
using vc = vector<char>;
using vvc = vector<vc>;
using ii = pair<int,int>;
using vii = vector<ii>;
using vvii = vector<vii>;
using dd = pair<double, double>;
using vdd = vector<dd>;
using vvdd = vector<vdd>;
using Mii = map<int,int>;
using vMii = vector<Mii>;

#define fi first
#define se second
#define INF INT_MAX
#define mod(a,m) (a%m+m)%m
#define PB push_back
#define MP make_pair

vvll memo;
vll v;
vll part;

ll dp(int i, int j) {
	ll& ans = memo[i][j];
	if(ans != -1) return ans;
	if(i == j) return ans = 0;
	if(i + 1 == j) return ans = v[i] + v[j];
	ans = 1e15;
	for (int k = i; k < j; ++k) {
		ans = min(ans, dp(i, k) + dp(k+1, j));
	}
	ans += part[j];
	if(i != 0) ans -= part[i-1]; 
	return ans;
}

int main(){
//	cout.setf(ios::fixed);
//	cout.precision(4);
	int n;
	while (cin >> n) {
		v = vll(n);
		for (int i = 0; i < n; ++i) cin >> v[i];
		part = vll(n);
		partial_sum(v.begin(), v.end(), part.begin());
		memo = vvll(n, vll(n, -1));
		cout << dp(0, n-1) << '\n';
	}
}




Measured memory_bytes: 1536
#include <cstdio>
#include <set>
#include <string>
#include <cstring>
using namespace std;

int main()
{
	char s[5001];
	int k;
	scanf("%s %d", s, &k);

	int len = strlen(s), idx = 0;
	set<string> lex;
	for (int i = 0; i < len; ++i)
	{
		string tmp;
		for (int j = 0; i + j < len && j < 5; ++j)
		{
			tmp.push_back(s[i + j]);
			lex.insert(tmp);
		}
	}

	auto it = lex.begin();
	for (; --k; ++it);
	puts(it->c_str());

	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;

int dp[4001],n,a,b,c,i;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,i;
    cin >> n;
    int a[n];
    for(i=0;i<n;i++) cin >> a[i];
    int count=1, minTillNow=a[0];
    for(i=1;i<n;i++) {
        if(a[i]<minTillNow) {
            count++;
            minTillNow = a[i];
        }
    }
    cout << count << "\n";
    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

int main(void) {
	string o,e;
	int x = 0,y=0;
	cin >> o >> e;
	REP(i, o.size()) {
		cout << o[i];
		if (i < e.size()) cout << e[i];
	}

	return 0;
}


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

bool is_prime(int n) {
  if (n < 2) { return false; } // 1 は素数ではない
  if (n == 2) { return true; } // 2 は素数である
  if (n % 2 == 0) { return false; } // 2 以外の偶数は素数ではない

  double square_root = sqrt(n);
  for (int i = 3; i <= square_root; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }

  return true;
}

bool is_similar_to_2017(int n) {
  bool cond1 = is_prime(n);
  bool cond2 = is_prime((n + 1) / 2);

  if (cond1 && cond2) {
    return true;
  } else {
    return false;
  }
}

int main() {
  int Q;
  cin >> Q;

  const int lim = 100000;

  // 条件を満たす N のリストを用意
  vector<int> pm(lim, false);
  for (int i = 0; i < lim; i++) {
    pm.at(i) = is_similar_to_2017(i + 1);
  }

  // 累積和を用意
  vector<int> s(lim + 1, 0);
  for (int i = 0; i < lim; i++) {
    s.at(i + 1) = s.at(i) + pm.at(i);
  }

  for (int i = 0; i < Q; i++) {
    int left, right;
    cin >> left >> right;
    cout << (s.at(right) - s.at(left - 1)) << endl;
  }

  return 0;
}


Measured memory_bytes: 4088
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <sstream>
#include <utility>
#include <cstdlib>
#include <cctype>
#include <climits>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef vector<pair<int, int> > vpii;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second
using namespace std;



int main(){
    int m,d;
    map <int,string> date;
    date[5] = "Monday";
    date[6] = "Tuesday";
    date[0] = "Wednesday";
    date[1] = "Thursday";
    date[2] = "Friday";
    date[3] = "Saturday";
    date[4] = "Sunday";
    while(1){
        cin>>m>>d;
        if(m==0)break;
        rep(i,m-1){
            if(i==1){
                d+=29;
            }else if(i==3||i==5||i==8||i==10){
                d+=30;
            }else{
                d+=31;
            }
        }
        cout<<date[d%7]<<endl;
    }
}

Measured memory_bytes: 3116
import java.util.*;

class Main{
	static int []segmentTree;

	static void build(int []nums) {
		int n = nums.length;
		for (int i=0; i<n; i++)
			segmentTree[n+i] = nums[i];
		for (int i=n-1; i>0; i--) {
			segmentTree[i] = segmentTree[2*i] + segmentTree[2*i+1];
		}
	}

	static int query(int l, int r, int n) {
		int sum = 0;
		for (l+=n, r+=n; l<r; l>>=1, r>>=1) {
			if ((l&1) == 1) {
				sum += segmentTree[l++];
			}
			if ((r&1) == 1) {
				sum += segmentTree[--r];
			}
		}
		return sum;
	}

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n;
		n = in.nextInt();
		int [][]nums = new int[n][3];
		for (int i=0; i<n; i++)
			for (int j=0; j<3; j++)
				nums[i][j] = in.nextInt();
		int [][]dp = new int[n+1][3];
		dp[0][0] = nums[0][0];
		dp[0][1] = nums[0][1];
		dp[0][2] = nums[0][2];
		for (int i=1; i<n; i++) {
			dp[i][0] = nums[i][0] + Math.max(dp[i-1][1], dp[i-1][2]);
			dp[i][1] = nums[i][1] + Math.max(dp[i-1][0], dp[i-1][2]);
			dp[i][2] = nums[i][2] + Math.max(dp[i-1][0], dp[i-1][1]);
		}
		// for (int i=0; i<n; i++) {
		// 	for (int j=0; j<3; j++)
		// 		System.out.println(dp[i][j]+" ");
		// 	System.out.println();
		// }
		System.out.println(Math.max(dp[n-1][1], Math.max(dp[n-1][0], dp[n-1][2])));
	}
}

Measured memory_bytes: 64084
import sys

target = int(sys.stdin.readlines()[0].strip())

value_cake = 4
value_donut = 7
flag = False

for num_cake in range(0, target // value_cake + 1):
  for num_donut in range(0, target // value_donut + 1):
    if num_cake * value_cake + num_donut * value_donut == target:
      flag = True

if flag:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>


typedef long long ll;
const double Eps = 1e-6;

using namespace std;

int main()
{
	int n;
	scanf("%d", &n);
	while (n--)
	{
		int h, m;
		scanf("%d:%d", &h, &m);
		double tm = 360.0 * m / 60.0;
		double th = 360.0 * (h / 12.0 + m/60.0/12.0);
		double t = abs(th - tm);
		if (t > 180)
			t = 360 - t;

		if (t < 30)
			puts("alert");
		else if (t < 90)
			puts("warning");
		else
			puts("safe");
	}

	return 0;
}

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

int main() {
    ll x;
    while(cin >> x, x){
        ll k, s=0;
        x *= 2;
        for(ll i = 1; i*i <= x; i++){
            if(x%i == 0){
                ll a = x/i, b = i;
                if((a+b)%2==0)continue;
                ll l = (a-b-1)/2, r = (a+b-1)/2;
                if(l >= 0 && r >= 0 && r-l > s){
                    k = l+1;
                    s = r-l;
                }
            }
        }
        cout << k << " " << s << endl;
    }
    return 0;
}



Measured memory_bytes: 3072
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long intS
#define rep(i,n) for(int i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define in(n) cin>>n>>
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
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;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    
    
    int a,b;
    
    in(a)b;
    
    if(a%2 != 0 && b%2 != 0){
    
    fin("Odd");
    
    }else{
    
    fin("Even");
    
    }
    
    
    
    
    

    
/////////////////////////////////////////////////////
return 0;}

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

namespace ABC156D
{
    class Program
    {
        static long ans = 1;
        static long mod = 1000000007;
        static void Main(string[] args)
        {
            string[] nab = Console.ReadLine().Split(' ');
            long n = long.Parse(nab[0]);
            long a = long.Parse(nab[1]);
            long b = long.Parse(nab[2]);

            string n2 = Convert.ToString(n, 2);
            int ln2 = n2.Length;
            long pow = 2;
            for(int i = ln2 - 1; i >= 0; i--)
            {
                if (n2[i].ToString() == "1")
                {
                    ans *= pow;
                    ans %= mod;
                }
                pow *= pow;
                pow %= mod;
            }
            ans += mod - 1;
            ans %= mod;

            long ansa = combination(n, a);
            long ansb = combination(n, b);

            ans += mod - ansa;
            ans %= mod;
            ans += mod - ansb;
            ans %= mod;
            
            Console.WriteLine(ans);
        }
        static long combination(long m,long n)
        {
            long bunbo = 1;
            for(long i = m; i > m-n; i--)
            {
                bunbo *= i;
                bunbo %= mod;
            }
            long bunsi = 1;
            for(long i = 1; i <= n; i++)
            {
                bunsi *= i;
                bunsi %= mod;
            }
            string p = Convert.ToString(mod - 2, 2);
            int l = p.Length;
            long gyakugen = 1;
            long pow = bunsi;
            for(int i = l - 1; i >= 0; i--)
            {
                if (p[i].ToString() == "1")
                {
                    gyakugen *= pow;
                    gyakugen %= mod;
                }
                pow *= pow;
                pow %= mod;
            }
            long temp = bunbo * gyakugen;
            temp %= mod;
            return temp;
        }
    }
}


Measured memory_bytes: 27568
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
template<class T> T gcd(T a,  T b) {return b ? gcd(b, a % b) : a;}
template<class U> U lcm( U m, U n ){if((0 == m )||( 0 == n ))return 0; return ((m / gcd(m, n)) * n); }
template<class T, class Func = function<T(T, T)>>
class segtree {
    vector<T> obj;
    int offset;
    Func updater;
    T e;
    int bufsize(int num) {
        int i = 1;
        for (; num + 1 >i; i <<= 1);
        offset = i - 1;
        return (i << 1) - 1;
    }
    T query(int a, int b, int k, int l, int r) {
        if (r <= a || b <= l)return e;
        if (a <= l && r <= b)return obj[k];
        else return updater(query(a, b, k * 2 + 1, l, (l + r) / 2), query(a, b, k * 2 + 2, (l + r) / 2, r));
    }
public:
    T query(int a, int b) {//[a,b)
        return query(a, b, 0, 0, offset + 1);
    }
    void updateall(int l = 0, int r = -1) {
        if (r < 0)r = offset + 1;
        l += offset, r += offset;
        do {
            l = (l - 1) >> 1, r = (r - 1) >> 1;
            for (int i = l; i < r; i++)obj[i] = updater(obj[i * 2 + 1], obj[i * 2 + 2]);
        } while (l);
    }
    void update(int k, T &a) {
        k += offset;
        obj[k] = a;
        while (k) {
            k = (k - 1) >> 1;
            obj[k] = updater(obj[k * 2 + 1], obj[k * 2 + 2]);
        }
    }
    segtree(int n, T e, const Func &updater = Func()) :obj(bufsize(n), e), e(e), updater(updater) {}
    segtree(vector<T> &vec, T e, const Func &updater = Func()) :obj(bufsize(vec.size()), e), e(e), updater(updater) {
        copy(vec.begin(), vec.end(), obj.begin() + offset);
        updateall();
    }
    typename vector<T>::reference operator[](int n) {
        return obj[n + offset];
    }
};

signed main(){
    int N; cin >> N;
    vector<int>v(N);
    for(auto& e : v) cin >> e;
    auto sgt = segtree<int>(v,0LL,[](int a, int b){return  gcd(a,b);});
    int ans = 1;
    for(int i = 0; i < N; ++i){
        ans = max(ans,gcd(sgt.query(0,i),sgt.query(i + 1,N)));
    }
    cout << ans << endl;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,a,n) for(ll i = a;i < n;i++)
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF 1e18
#define INF 1e9
using namespace std;

#define fs first
#define sc second

using P = pair<ll,ll>;
using Pll = pair<P,ll>;
using PQ = priority_queue<P,vector<P>,greater<P>>;

const ll MOD = 1e9+7;

signed main(){
    ll x,n;
    cin >> x >> n;
    bool is_used[200] = {false};
    rep(i,0,n){
        ll p;
        cin >> p;
        is_used[p] = true;
    }

    ll ans = 0,memo = x;
    rep(i,0,200){
        if(!is_used[i] && memo > abs(x-i)){
            memo = abs(x-i);
            ans = i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n;cin>>n;
	vector<int>a(n);
	for(auto&& w:a)cin>>w;
	int sm=0,tmp=0;

	for(int i=0;i<n;i++){
		if(a[i]!=0)tmp+=a[i];
		else {sm+=tmp/2;tmp=0;}
	}
	if(tmp>0)sm+=tmp/2;
	cout<<sm<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using lint = long;
using llint = long long;
using namespace std;

int main() {
    fastIO;
    int x;
    cin >> x;

    set<int> nums;
    for (int b = 1; b <= 32; b++) {
        for (int p = 2; p <= 10; p++) {
            int ex = pow(b, p);
            if (0 <= ex && ex <= 1000)
                nums.insert(ex);
        };
    }

    vector<int> exp;
    for (auto num : nums) exp.push_back(num);
    sort(exp.begin(), exp.end());

    rep(i, exp.size()) {
        if (exp.at(i) == x) {
            cout << exp.at(i) << endl;
            return 0;
        } else if (exp.at(i) > x) {
            cout << exp.at(i - 1) << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 4020
import math

NN = int(input())
AA = list(map(int,input().split()))
BB = list(map(int,input().split()))


AA_converted = 0
BB_converted = 0
LL = list(range(1,NN+1))
for ii in range(0,NN):
    AA_converted += math.factorial(NN-1-ii)*LL.index(AA[ii])
    LL.remove(AA[ii])
#    print(AA_converted)
#    print(LL)

LL = list(range(1,NN+1))
for ii in range(0,NN):
    BB_converted += math.factorial(NN-1-ii)*LL.index(BB[ii])
    LL.remove(BB[ii])
#    print(BB_converted)
#    print(LL)

print(abs(AA_converted-BB_converted))

Measured memory_bytes: 61644
#include <stdio.h>
#include <ctype.h>
int main(void){
	int x=0,l=0;
	char i[1200];
	while(1){
		scanf("%c",&i[x]);
		if(i[x]=='\n')break;
		x++;
		l++;
	}
	x=0;
	while(1){
		if(x==l)break;
		if(islower(i[x])){
			i[x]=toupper(i[x]);
			printf("%c",i[x]);
		}else if(isupper(i[x])){
			i[x]=tolower(i[x]);
			printf("%c",i[x]);
		}else{
			printf("%c",i[x]);
		}
		x++;
	}
	printf("\n");
	
	
	
	
	return 0;
}

Measured memory_bytes: 524
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define F first
#define S second

using namespace std;
typedef pair<int,int> P;
typedef vector<int> ivec;

const int MOD=1000000007;
int INF=100100100100100;

signed main(){
  int ans=0;
  int sa=0;
  rep(i,5){
    int x;cin>>x;
    ans+=(x+9)/10*10;
    int po=x%10;
    if(po>0)po=10-po;
    sa=max(sa,po);
  }
  ans-=sa;
  cout<<ans<<endl;
  return 0;
}


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

int main(){
  int N,K; cin >> N >> K;
  vector<long> h(N);
  for(int i=0; i<N; i++) cin >> h[i];
  vector<long> cost(N,10000000000);
  cost[0]=0;
  for(int i=1; i<N; i++){
    for(int j=max(0,i-K); j<i; j++){
      cost[i]=min(cost[i],cost[j]+abs(h[i]-h[j]));
    }
  }
  cout << cost[N-1] << endl;
}

Measured memory_bytes: 1792
N, W = map(int, input().split())
v = []
w = []
for i in range(N):
    vv, ww = map(int, input().split())
    v.append(vv)
    w.append(ww)

# dp[i]:重さiを超えないように選んだ時の最大価値合計
dp = [0] * (W+1)

for i in range(N):
    for j in range(W, w[i]-1, -1):
        dp[j] = max(dp[j], dp[j-w[i]]+v[i])

print(dp[W])




Measured memory_bytes: 5920
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>

#define int long long

using namespace std;

class Solver {
};

signed main() {
	int n, r, t;
	cin >> n >> r >> t;

	vector<int> pase(n, 0);
	vector<int> poses(n, 0);
	for (int i = 0; i < n; i++) {
		cin >> pase[i];
		poses[i] = pase[i]%r;
	}

	vector<vector<int>> bottles(r, vector<int>(3, 0));

	for (int i = 0; i < t; i++) {
		for (int j = 0; j < r; j++) {
			bottles[j][0] += bottles[j][1];
			bottles[j][1] = 0;
			bottles[j][1] += bottles[j][2];
			bottles[j][2] = 0;
		}

		for (int j = 0; j < n; j++) {
			if (bottles[poses[j]][0] > 0)bottles[poses[j]][0]--;
			poses[j] += pase[j];
			poses[j] %= r;
			bottles[poses[j]][2]++;
		}
	}

	int res = 0;
	for (int i = 0; i < r; i++) {
		res += bottles[i][0] + bottles[i][1] + bottles[i][2];
	}

	cout << res << endl;
}


Measured memory_bytes: 3212
N = int(input())
P = list(map(int, input().split()))
ans = 0
INF = 2 * 10 ** 5 + 1
Q = [INF] * N
Q[0] = P[0]

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

for i in range(N):
    if P[i] <= Q[i]:
        ans += 1

print(ans)

Measured memory_bytes: 24744
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[][] = new int[2][N];
        for(int i=0;i<2;i++){
            for(int j=0;j<N;j++){
                A[i][j] = sc.nextInt();
            }
        }
        int[][] dp = new int[2][N];
        for(int i=0;i<2;i++){
            for(int j=0;j<N;j++){
                if(i==0 && j==0) dp[0][0] = A[0][0];
                if(i==1 && j>0) {
                    dp[i][j] = Math.max(dp[i - 1][j], dp[i][j - 1]) + A[i][j];
                } else if(j>0 && i==0){
                    dp[i][j] = dp[i][j-1] + A[i][j];
                } else if(j==0 && i==1){
                    dp[i][j] = dp[i-1][j] + A[i][j];
                }
            }

        }
        System.out.println(dp[1][N-1]);
    }


}


Measured memory_bytes: 21972
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            string line = Console.ReadLine();

            string[] strs = line.Split(' ');

            int A = int.Parse(strs[0]);
            int B = int.Parse(strs[1]);

            int i;
            for(i = 0; i < 10000; i++)
            {
                var A_A = (int)(i * 0.08);
                var B_B = (int)(i * 0.10);

                if (A_A == A && B_B == B) break;
            }
            if (i != 10000)
            {
                Console.WriteLine(i);
            }
            else
            {
                Console.WriteLine(-1);
            }

        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include<vector>
#include<algorithm>
#include<climits>

#define max_n (1<<18)

using namespace std;

int dat[max_n],n;

int get(int k){return dat[k+n];}

void update(int k,int a){
  for(k+=n,dat[k]=a;k>1;k>>=1)
    dat[k>>1]=min(dat[k],dat[k^1]);
}

int rmq(int a,int b){
  int res=INT_MAX;
  for(a+=n,b+=n;a<=b;a=(a+1)>>1,b=(b-1)>>1){
    if(a&1)res=min(res,dat[a]);
    if((b&1)==0)res=min(res,dat[b]);
  }
    return res;
}

int main(void){
 
  fill(dat,dat+max_n,INT_MAX);
  int q;
  cin >> n >> q;
 
  while(q--){
    int com,x,y;
    cin >> com >> x >> y;
    if(com)cout << rmq(x,y) << endl;
    else update(x,y);
  }
  return 0;
}

Measured memory_bytes: 2184
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <stack>
#include <deque>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <iomanip>
using namespace std;

int main()
{
    array<char,4> arr;
    for(int i=0;i<4;i++){
        cin >> arr[i];
    }
    sort(arr.begin(),arr.end());

    if((arr[0]==arr[1])&&(arr[1]!=arr[2])&&(arr[2]==arr[3])){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
int a,b,c;
int main()
{
       cin>>a>>b>>c;
for (int i=1;i<=10000;i++)
{
	if (a*i%b==c) {
		cout<<"YES";
		return 0;
	}
}
cout<<"NO";
return 0;
} 

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strings"
)

func main() {
	var str string
	fmt.Scan(&str)

	s := strings.Split(str, "")
	var flg bool
	flg = true
	if s[0] != "A" || strings.Count(str, "C") != 1 {
		flg = false
	}

	s[0] = "a"
	if flg {
		flg = false
		for i := 2; i < len(s)-1; i++ {
			if s[i] == "C" {
				flg = true
				s[i] = "c"
			}
		}
	}
	if flg {
		for _, v := range s {
			if v >= "A" && v <= "Z" {
				flg = false
			}
		}
	}

	if flg {
		fmt.Println("AC")
	} else {
		fmt.Println("WA")
	}
}


Measured memory_bytes: 1844
#include <iostream>

using namespace std;
 int main(void) {
   long long N, D;
   cin >> N >> D;
   int ans = 0;
   
   for (int i = 0; i < N; i++) {
     long long x, y;
     cin >> x >> y;
     
     if (D*D >= x*x+y*y) {
       ans++;
     } 
   
   }
     cout << ans << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
int main() 
{ 
  lli n;
  cin>>n;
  lli a[n],b[n],c[n];
  for(lli i=0;i<n;i++)
  {
      cin>>a[i];  cin>>b[i];  cin>>c[i];
  }
  lli dp[n][3];
  memset(dp,-1,sizeof(dp));
  dp[n-1][0]=a[n-1],dp[n-1][1]=b[n-1],dp[n-1][2]=c[n-1];
  for(lli i=n-2;i>=0;i--)
  {
      dp[i][0]=a[i]+max(dp[i+1][1],dp[i+1][2]);
      dp[i][1]=b[i]+max(dp[i+1][0],dp[i+1][2]);
      dp[i][2]=c[i]+max(dp[i+1][0],dp[i+1][1]);
  }
  lli ans=max(max(dp[0][0],dp[0][1]),dp[0][2]);
  cout<<ans;
}


Measured memory_bytes: 8316
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

int main(){

    int n;
    cin >> n;

    map<ll, ll> m;
    vector<ll> v(n);
    for(int i = 0; i < n; i++){
        ll num;
        cin >> num;
        v[i] = num;
        m[num] ++;
    }

    ll ans_all = 0;
    for (auto it = m.begin(); it != m.end(); it++){
        ans_all += it->second * (it->second - 1) / 2;
    }
    
    vector<ll> ans(n);
    for(int i = 0; i < n; i++){
        ans[i] = ans_all - m[ v[i] ] * (m[ v[i] ] - 1 ) / 2 + (m[ v[i] ] - 2) * (m[ v[i] ] - 1 ) / 2 ;
    }     

    for(int i = 0; i < n; i++){
        cout << ans[i] << endl;
    }


    return 0;
}

Measured memory_bytes: 12672
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 100005

ll N;
ll P[SIZE],loc[SIZE];
set<ll> SET;

int main(){

	ll L[2],R[2],left[2],right[2];

	scanf("%lld",&N);

	for(int i = 0; i < N; i++){

		scanf("%lld",&P[i]);
		P[i]--;
		loc[P[i]] = i;
	}

	ll ans = 0;

	for(ll i = N-1; i >= 0; i--){

		ll tmp = loc[i];
		SET.insert(tmp);

		for(int k = 0; k < 2; k++){

			L[k] = -1;
			R[k] = N;
		}

		auto it = SET.find(tmp);

		for(int k = 0; k < 2; k++){
			if(it == SET.begin())break;

			it--;
			L[k] = *it;
		}

		it = SET.find(tmp);

		for(int k = 0; k < 2; k++){
			it++;
			if(it == SET.end())break;

			R[k] = *it;
		}

		left[0] = tmp-L[0],left[1] = L[0]-L[1];
		right[0] = R[0]-tmp,right[1] = R[1]-R[0];

		ans += (i+1)*(right[1]*left[0]+right[0]*left[1]);
	}

	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb(x) push_back(x)
#define mp make_pair
#define sz(x) ((int)(x).size())
#define endl "\n"
#define fastio ios_base::sync_with_stdio(false); cin.tie(nullptr);
#define all(x) x.begin(),x.end()
#define y1 omg
#define INF 1000000010
#define FOR(x, n) for(int x=0; x<n; x++)
#define ini(x, n) memset(x, n, sizeof(x));
#define MOD (int)1e9 + 7
#define atoi(x) ((x)-'0')
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;

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

int n, t, ans = 1;

int main() {
	cin >> n;
	t = n;
	while (1) {
		ans++;
		t = (t + n) % 360;
		if (t == 0) {
			cout << ans;
			return 0;
		}
	}
}

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

int main(){
    int x[5];
    int ans;
    for(int i=0;i<5;++i)cin>>x[i];
    for(int i=0;i<5;++i){
        if(x[i]==0)ans=i+1;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

struct bit {
	vector<long> t;
	bit(int n) :t(n + 1) {}
	void upd(int a, long n) {
		for (a++; a < t.size(); a += a & -a)
			t[a] = max(t[a], n);
	}
	long get(int a) const {
		long r = 0;
		for (; a; a &= a - 1)
			r = max(r, t[a]);
		return r;
	}
};
int h[222222];
int main() {
	int n;
	cin >> n;
	bit b(n);
	for (int i = 0; i < n; i++)
		scanf("%d", h + i);
	for (int i = 0; i < n; i++) {
		int a;
		scanf("%d", &a);
		b.upd(h[i] - 1, b.get(h[i]) + a);
	}
	cout << b.get(n) << endl;
	return 0;
}


Measured memory_bytes: 2688
n = gets.to_i
a = Array.new(n) { gets.to_i }
colors = [a[0]]

a[1..-1].each do |x|
  i = colors.bsearch_index{|y| y >= x}
  if i.nil?
    colors[-1] = x
  elsif i == 0
    colors.unshift(x)
  else
    colors[i-1] = x
  end
end

puts colors.length

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

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

fn main() {
    let x: i64 = read();
    let mut sum: i64 = 0;
    let mut cnt: i64 = 0;
    while sum < x {
        cnt += 1;
        sum += cnt;
    }
    println!("{}", cnt);
}


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

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

int main() {
    int n, m; cin >> n >> m;
    int sum = 0;
    vector<int> A(n);
    rep(i,n){
        cin >> A[i];
        sum += A[i];
    }

    sort(A.begin(), A.end(), greater<int>());

    if(4 * m * A[m - 1] < sum){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  char s[1005];
  char w[]={"w_kstnhmyr"};
  int i;
  scanf("%s",s);
  for(i=0;s[i];i++){
    if('0'<=s[i]&&s[i]<='9'){
      if(s[i]=='0'&&s[i+1]=='U'){
	printf("nn");
	i++;
	continue;
      }
      if(s[i]!='1')printf("%c",w[s[i]-'0']);
    }
    else{
      if     (s[i]=='T')printf("a");
      else if(s[i]=='L')printf("i"); 
      else if(s[i]=='R')printf("e");
      else if(s[i]=='D')printf("o");
      else              printf("u");
    } 
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 524
w,h,n=map(int,input().split())
b=c=0
for _ in range(n):
    x,y,a=map(int,input().split())
    if a==1:b=max(b,x)
    if a==2:w=min(w,x)
    if a==3:c=max(c,y)
    if a==4:h=min(h,y)
print(max(0,(w-b))*max(0,(h-c)))

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

namespace AtTest.ABC_154
{
    class E
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            string n = Read();
            int k = ReadInt();
            var dp = new long[n.Length, 2, k + 1];
            dp[0, 0, 0] = 1;
            dp[0, 0, 1] = n[0] - '1';
            dp[0, 1, 1] = 1;
            for (int i = 0; i < n.Length - 1; i++)
            {
                for(int j = 0; j < k; j++)
                {
                    if (n[i+1] == '0')
                    {
                        dp[i + 1, 1, j] += dp[i, 1, j];
                    }
                    else
                    {
                        dp[i + 1, 1, j + 1] += dp[i, 1, j];
                        dp[i + 1, 0, j + 1] += dp[i, 1, j] * (n[i+1] - '1');
                        dp[i + 1, 0, j] += dp[i, 1, j];
                    }
                    dp[i + 1, 0, j + 1] += dp[i, 0, j] * 9;
                    dp[i + 1, 0, j] += dp[i, 0, j];
                }
                if (n[i+1] == '0')
                {
                    dp[i + 1, 1, k] += dp[i, 1, k];
                }
                else
                {
                    dp[i + 1, 0, k] += dp[i, 1, k];
                }
                dp[i + 1, 0, k] += dp[i, 0, k];
            }
            WriteLine(dp[n.Length - 1, 0, k] + dp[n.Length - 1, 1, k]);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 11220
import sys


def main():
    n = int(sys.stdin.readline().strip())
    ds = sys.stdin.readline().strip()
    d = [int(s) for s in ds.split()]
    sorted_d = sorted(d)

    left = sorted_d[n // 2 - 1]
    right = sorted_d[n // 2]
    print(right - left)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14656
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

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

using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << min({A, B}) + min({C, D}) << endl;
  return 0;
}


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

int main(){
	string s;
	cin >> s;

	map<char, int> mp;
	rep(i, s.size()){
		mp[s.at(i)]++;
	}
	if(mp.size()==2 && mp[s.at(0)] ==2) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int > P;
const int INF = 1 << 30;
int Dijkstra(int s,int g,int r);

int m,n;

int min_cost[2][111];

typedef struct{
  vector<int>edge_to;
  vector<int>edge_cost[2];
}Node_data;

Node_data Graph[111];

priority_queue<P ,vector< P >, greater< P > >que;

int main(){
  int a,b,c,d,k;
  int s,g,r;
  while(1){
    for(int i = 0;i < 111;i++){
      Graph[i].edge_to.clear();
      Graph[i].edge_cost[0].clear();
      Graph[i].edge_cost[1].clear();
    }
    cin >> m >> n;
    if(m == 0 && n == 0)break;
    for(int i = 0;i < m;i++){
      scanf("%d %d %d %d",&a,&b,&c,&d);
      Graph[a - 1].edge_to.push_back(b - 1);
      Graph[a - 1].edge_cost[0].push_back(c);
      Graph[a - 1].edge_cost[1].push_back(d);
      Graph[b - 1].edge_to.push_back(a - 1);
      Graph[b - 1].edge_cost[0].push_back(c);
      Graph[b - 1].edge_cost[1].push_back(d);
    }
    cin >> k;
    for(int i = 0;i < k;i++){

      cin >> s >> g >> r;
      
      for(int j = 0;j < n;j++){
	min_cost[r][j] = INF;
      }
      cout << Dijkstra(s - 1,g - 1,r) << endl;
    }
  }
  return(0);
}

int Dijkstra(int s,int g,int r){
  int node,cost;
  int newnode,newcost;
  min_cost[r][s] = 0;
  P a;
  a.first = 0;
  a.second = s;
  que.push(a);
  while(!que.empty()){
    node = que.top().second;
    cost = que.top().first;
    que.pop();
    // if(node == g)return cost;
    if(cost > min_cost[r][node])continue;
    for(int i = 0;i < Graph[node].edge_to.size();i++){
      newnode = Graph[node].edge_to[i];
      newcost = cost + Graph[node].edge_cost[r][i];
      if(min_cost[r][newnode] > newcost){
	min_cost[r][newnode] = newcost;
	a.first = newcost;
	a.second = newnode;
	que.push(a);
      }
    }
  }
  return min_cost[r][g];
}

Measured memory_bytes: 1368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define xrep(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define vl vector<long long>
#define all(A) A.begin(), A.end()

int main() {
    ll n; cin >> n;
    vl l(n);
    rep(i, n) cin >> l[i];

    sort(all(l));

    ll ans = 0;
    rep(i,n){
        xrep(j,i+1,n){
            auto ite = upper_bound(l.begin() + j + 1, l.end(), abs(l[i] - l[j]));
            auto ite2 = lower_bound(l.begin() + j + 1, l.end(), l[i] + l[j]);
            ans += ite2 - ite;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3672
#include<iostream>
#include<string>
using namespace std;
int main() {
    int count=0;
    char c[3];
    char c1[3];
    for(int i=0; i<3; i++) {
        cin>>c[i];
    }
    for(int i=0; i<3; i++) {
        cin>>c1[i];
        if(c[i]==c1[i])
            count++;
    }
    cout<<count;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int a,b,c;
    cin >> a >> b >> c;
    if(a==b&&b==c&&c==a){
        cout<<1<<endl;
    }else if(a==b||b==c||c==a){
        cout<<2<<endl;
    }else{
        cout<<3<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
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;
}

#ifdef DEBUG
void debug() { cerr << "\n"; }
template <class T> void debug(const T &x) { cerr << x << "\n"; }
template <class T, class... Args> void debug(const T &x, const Args &... args) {
    cerr << x << " ";
    debug(args...);
}
template <class T> void debugVector(const vector<T> &v) {
    for(const T &x : v) {
        cerr << x << " ";
    }
    cerr << "\n";
}
#else
template <class T, class... Args>
void debug(const T &x, const Args &... args) {}
template <class T> void debugVector(const vector<T> &v) {}
#endif

using ll = long long;
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    ll sum = 0;
    for(int i = 0; i < s.size(); i++) {
        sum += (s[i] - '0');
    }
    cout << (sum % 9 == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3724
MOD = 998244353


def get_inv(n):
    inv = [0] * (n + 1)
    inv[1] = 1

    for i in range(2, n + 1):
        inv[i] = (-(MOD // i) * inv[MOD % i]) % MOD

    return inv


def get_cmb(n):
    inv = get_inv(n)
    cmb = [0] * (n + 1)
    cmb[0] = 1

    for i in range(1, n + 1):
        cmb[i] = (cmb[i - 1] * (n - i + 1) * inv[i]) % MOD

    return cmb


def solve(n, a, b, k):
    ans = 0
    cmb = get_cmb(n)
    for a_num in range(n + 1):
        b_num = (k - a * a_num) // b
        if (a * a_num + b * b_num == k) and (0 <= b_num <= n):
            ans += (cmb[a_num] * cmb[b_num]) % MOD
            ans %= MOD
    return ans


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


main()


Measured memory_bytes: 26720
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type_a,class Type_b> void chmax(Type_a &a,const Type_b &b){if(a<b)a=b;}
template<class Type_a,class Type_b> void chmin(Type_a &a,const Type_b &b){if(a>b)a=b;}
template<class Type> Type igcd(Type x,Type y){if(x==0||y==0)return (x>y)?x:y;return (y%x)?igcd(y%x,x):x;}
template<class Type> Type ilcm(Type x,Type y){return x/igcd(x,y)*y;}
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,k;
	cin>>n>>k;
	
	vi p(n);
	REP(i,n) cin>>p[i];
	
	int sum=0;
	int hoge;
	int pp=0;
	REP(i,k) sum+=p[i];
	hoge=sum;
	REP(i,n-k){
		sum=sum-p[i]+p[i+k];
		if(sum>hoge){
			hoge=sum;
			pp=i+1;
		}
	}
	
	double ans=0;
	for(int i=pp;i<pp+k;++i){
		ans+=double((1+p[i])*p[i]/2)/p[i];
	}
	
	printf("%.10f\n",ans);
}

Measured memory_bytes: 1024
import java.util.Scanner;
public class Main
{
    public static void main(String[]args)
    {
        Scanner laptm = new Scanner(System.in);
        int n = laptm.nextInt();
        String s = laptm.next();
        char[] arreglochar = s.toCharArray();
        for(int i=0;i<arreglochar.length;i++)
        {
           if(arreglochar[i]+n>90)
           {
               arreglochar[i]=(char)(arreglochar[i]-26+n);
           }
           else
           arreglochar[i]+=n;
           }
        for(int i=0; i<arreglochar.length;i++)
        System.out.print(arreglochar[i]);
    }
}

Measured memory_bytes: 24276
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();

        final Map<Integer, Integer> indexMap = new HashMap<>();
        final Map<Integer, List<Integer>> prefectureCityMap = new HashMap<>();

        for (int i = 0; i < m; i++) {
            final int prefecture = scanner.nextInt();
            final int city = scanner.nextInt();
            indexMap.put(city, i);
            prefectureCityMap.computeIfAbsent(prefecture, list -> new ArrayList<>())
                    .add(city);
        }

        final String[] answer = new String[m];

        for (final Map.Entry<Integer, List<Integer>> entry : prefectureCityMap.entrySet()) {
            Collections.sort(entry.getValue());
            for (int i = 0; i < entry.getValue().size(); i++) {
                final String id = String.format("%06d", entry.getKey()) + String.format("%06d", i + 1);
                answer[indexMap.get(entry.getValue().get(i))] = id;
            }
        }

        for (final String s : answer) {
            System.out.println(s);
        }
    }

    static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
            tokenizer = null;
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        long nextLong() {
            return Long.parseLong(next());
        }

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

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;

#define MAX_N 10000
#define MAX_M 10000

typedef pair<i64, i64> P;

i64 N, M;
priority_queue<i64, vector<i64>, greater<i64> > A;
priority_queue<P> CB;

void solve() {
  i64 a;
  P cb;
  while(!CB.empty()) {
    cb = CB.top(); CB.pop();
    while(!A.empty() && cb.S > 0) {
      a = A.top(); A.pop();
      if (a >= cb.F) {
        A.push(a);
        return;
      }

      if (a < cb.F) {
        A.push(cb.F);
        cb.S--;
      }
    }
    if (cb.S > 0) return;
  }
}

int main() {
  i64 sum = 0;

  cin >> N >> M;
  i64 a;
  REP(i, N) {
    cin >> a;
    A.push(a);
  }

  i64 b, c;
  REP(i, M) {
    cin >> b >> c;
    CB.push(mp(c, b));
  }

  solve();

  while(!A.empty()) {
    a = A.top(); A.pop();
    sum += a;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long c = sc.nextLong();

        if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
            System.out.println(0);
        } else {
            System.out.println(Math.min( a * b, Math.min(b * c, c * a)));
        }
    }

}


Measured memory_bytes: 21844
n,m,x = map(int,input().split())

l = list(map(int,input().split()))
ll = [0 for _ in range(n+1)]

for i in l:
    ll[i] = 1

mae = ll[:x + 1]
ato = ll[x + 1:]

print(min(sum(mae),sum(ato)))

Measured memory_bytes: 38256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> x(n),y(m),xl(n-1),yl(m-1);
    for(int i=0;i<n;i++) cin >> x[i];
    for(int i=0;i<m;i++) cin >> y[i];

    for(int i=0;i<n-1;i++) xl[i] = x[i+1]-x[i];
    for(int i=0;i<m-1;i++) yl[i] = y[i+1]-y[i];
    
    ll x_sum=0,y_sum=0;
    for(int i=0;i<n-1;i++){
        x_sum = ( x_sum + ((xl[i] * (i+1))%MOD * (n-1-i))%MOD)%MOD;
    }
    for(int i=0;i<m-1;i++){
        y_sum = ( y_sum + ((yl[i] * (i+1))%MOD * (m-1-i))%MOD)%MOD;
    }
    ll ans = (x_sum*y_sum)%MOD;
    cout << ans << endl;
    return 0;
}

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

typedef long long ll;
typedef long double ld;

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

    ll mod = pow(10, 9) + 7;

    int n, m;
    cin >> n >> m;

    vector<ll> x(n);
    vector<ll> y(m);

    for(int i = 0; i < n; i++) {
        cin >> x[i];
    }

    for(int i = 0; i < m; i++) {
        cin >> y[i];
    }

    vector<ll> xs(n - 1);
    vector<ll> ys(m - 1);

    ll xb = n - 1;
    xs[0] = xb;

    for(int i = 1; i < n - 1; i++) {
        xb -= 2;
        xs[i] = xb + xs[i - 1];
    }

    for(int i = 0; i < n - 1; i++) {
        xs[i] *= x[i + 1] - x[i];
        xs[i] %= mod;
    }

    ll yb = m - 1;
    ys[0] = yb;

    for(int i = 1; i < m - 1; i++) {
        yb -= 2;
        ys[i] = yb + ys[i - 1];
    }

    for(int i = 0; i < m - 1; i++) {
        ys[i] *= y[i + 1] - y[i];
        ys[i] %= mod;
    }

    ll sum_x = 0;
    ll sum_y = 0;

    for(int i = 0; i < n - 1; i++) {
        sum_x += xs[i];
        sum_x %= mod;
    }

    for(int i = 0; i < m - 1; i++) {
        sum_y += ys[i];
        sum_y %= mod;
    }

    ll ans = sum_x * sum_y;
    ans %= mod;

    cout << ans << endl;
}

Measured memory_bytes: 3456