akhauriyash/Code-Regression huggingface dataset:
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline--------------------------------------------
    n,m = map(int,input().split())
    ab = [list(map(int,input().split())) for i in range(m)]
    ab.sort(key = lambda x:x[1],reverse = True)
    l = ab[0][0]
    r = ab[0][1]
    ans = 1
    for i in range(1,m):
        if r <= ab[i][0] or ab[i][1]<= l:
            ans += 1
            l = ab[i][0]
            r = ab[i][1]
        else:
            l = max(ab[i][0],l)
            r = ab[i][1]
    
    print(ans)

if __name__ == "__main__":
    main() #endline===============================================
    

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

int main(){
    int n, i;
    cin >> n;
    int a[n], m[n];
    int c = 0;
    for(i = 0; i < n; i++){
        cin >> a[i];
        if(i % 2 == 0){
            c += a[i];
        }
        else{
            c -= a[i];
        }
    }
    m[0] = c;
    cout << m[0];
    for(i = 1; i < n; i++){
        m[i] = 2 * a[i-1] - m[i - 1];
        cout << " " << m[i];
    }
    cout << endl;
}

Measured memory_bytes: 2048
// AC 0.065
#include <bits/stdc++.h>
using namespace std;
#define N 200000
int n, k;
int cnt[N+5];
vector<pair<int, int>> v;
int in;
int main(int argc, char *argv[])
{
    while(cin >> n >> k && (n||k))
    {
        memset(cnt, 0, sizeof(cnt));
        v.clear();
        //
        for(int i = 0; i < n && cin >> in; i++)
            cnt[in]++;
        for(int i = 0; i <= N; i++)
            if(cnt[i])
                v.push_back(make_pair(cnt[i], i));
        sort(v.begin(), v.end());
        int d = v.size() - k, ans = 0;
        for(int i = 0; i < d; i++)
        {
            ans += v[i].first;
        }
        printf("%d\n", ans);
    }
}

Measured memory_bytes: 5940
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define fi first
#define se second
#define endl "\n"
using namespace std;

constexpr int inf = 2147483647;
constexpr int64_t inf64 = 9223372036854775807;
constexpr int mod = 1e9+7;

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

  int n;
  cin >> n;
  map<int, int> nums;

  rep(i,n) {
    int a;
    cin >> a;
    nums[a]++;
  }

  int res = -1;
  rep(i,100001) {
    res = max(res, nums[i-1]+nums[i]+nums[i+1]);
  }

  cout << res << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};

int main(){
  ll n;
  cin >> n;
  string s, t;
  cin >> s >> t;
  rep(i, 0, n) cout << s[i] << t[i];
  cout << endl;
    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
#include <vector>
#include <string>
#include <math.h>
#include <algorithm>
#include <set>
#include <iomanip>
#include <stdio.h>
#include <sstream>
#include <bits/stdc++.h>
using namespace std;
vector<long long int> dis;
vector<bool> vis;
vector<long long int> a;
vector<long long int> hoge;
long long int saiki(long long int now,long long int count){
  if(vis.at(now-1)==true){
    return now;
  }
  vis.at(now-1)=true;
  dis.at(now-1)=count;
  hoge.push_back(now);
  return saiki(a.at(now-1),count+1);
}

int main(void){
  long long int n,k;
  cin>>n>>k;
  a.resize(n);
for (long long int i = 0; i < n; i++)
{
  cin>>a.at(i);
}

  dis.resize(n);
  vis.resize(n);

  long long int start=saiki(1,0);
  if(k<=dis.at(start-1)){
    cout<<hoge.at(k)<<endl;
  }else{
    k-=dis.at(start-1);
    k%=hoge.size()-dis.at(start-1);
    cout<<hoge[k+dis.at(start-1)]<<endl;
  }
}

Measured memory_bytes: 14040
class Dice
  #   1
  # 4 2 3 5
  #   6
  attr_reader :pips
  def initialize(*pips)
    @pips = pips
  end

  def rotate_s!
    pips = [5, 1, 3, 4, 6, 2].map { |i| i - 1 }
    @pips = @pips.values_at(*pips)
    self
  end

  def rotate_e!
    pips = [4, 2, 1, 6, 5, 3].map { |i| i - 1 }
    @pips = @pips.values_at(*pips)
    self
  end

  def rotate_n!
    pips = [2, 6, 3, 4, 1, 5].map { |i| i - 1 }
    @pips = @pips.values_at(*pips)
    self
  end

  def rotate_w!
    pips = [3, 2, 6, 1, 5, 4].map { |i| i - 1 }
    @pips = @pips.values_at(*pips)
    self
  end

  def rotate_to_top!(pip)
    case @pips.index(pip) + 1
    when 1
      return self
    when 2
      return self.rotate_n!
    when 3
      return self.rotate_w!
    when 4
      return self.rotate_e!
    when 5
      return self.rotate_s!
    when 6
      return self.rotate_n!.rotate_n!
    end
  end
end

pips = gets.split.map(&:to_i)
q = gets.to_i
q.times do
  dice = Dice.new(*pips)
  p1, p2 = gets.split.map(&:to_i)

  dice.rotate_to_top!(p1)
  until dice.pips[1] == p2 do
    dice.rotate_s!.rotate_e!.rotate_n!
  end

  p dice.pips[2]
end

Measured memory_bytes: 6120
import java.util.Scanner;
import java.io.PrintWriter;

class Main {
    static String blackjack(int a1, int a2, int a3) {
        if (a1 + a2 + a3 <= 21) {
            return "win";
        }
        return "bust";
    }


    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        PrintWriter out = new PrintWriter(System.out);

        int a1 = Integer.parseInt(sc.next());
        int a2 = Integer.parseInt(sc.next());
        int a3 = Integer.parseInt(sc.next());

        out.println(blackjack(a1, a2, a3));
        out.flush();
    }
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
class Ho{
  static void Main(){
   var zen = Console.ReadLine().Split();
    var a = int.Parse(zen[0]);
    var b = int.Parse(zen[1]);
    if(a < 10){
      Console.WriteLine(100*(10-a)+b);
    }
    else {Console.WriteLine(b);}
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef long double ld;
 
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    string a,b;
    cin >> a >> b;
    vector <vector<ll>> arr(a.size(),vector<ll>(b.size(),0));
    ll n = a.size();
    ll m = b.size();
    arr[0][0] = 0;
    for (int z=0;z<m;z++){
    	if (b[z] == a[0]){
    		arr[0][z] = 1;
    	}
    	if (z - 1 >= 0)
    	arr[0][z] = max(arr[0][z],arr[0][z-1]);
    }
    for (int z=0;z<n;z++){
    	if (a[z] == b[0]){
    		arr[z][0] = 1;
    	}
    	if (z - 1 >= 0)
    	arr[z][0] = max(arr[z][0],arr[z-1][0]);
    }
    for (int z=1;z<n;z++){
    	for (int x=1;x<m;x++){
    		if (a[z] == b[x]){
    			arr[z][x] = arr[z-1][x-1]+1;
    		}
    		arr[z][x] = max(arr[z][x],max(arr[z][x-1],arr[z-1][x]));
    	}
    }
    string ans;
    ll z=n-1,x=m-1;
    while(z >= 0 && x >=0){
    	if (a[z] == b[x]){
    		z--;
    		x--;
    		ans += a[z+1];
    	} else if (z > 0 && arr[z-1][x] == arr[z][x]){
    		z--;
    	} else{
    		x--;
    	}
    }

    for (int z=ans.size()-1;z>-1;z--){
    	cout << ans[z];
    }
    cout << endl;
    cin >> a;
}

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

#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))
#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)   __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)   __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)   __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define ll long long
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
int main()
{
     IOS
     int n,m,i,cnt=0,res=0;
     double ans,mmd;

     cin>>n>>m;
     int a[n];
     mmd = (1.0)/(4.0*m);
     for(i = 0; i < n; i++)
     {
          cin>>a[i];
          res+=a[i];
     }
     for(i = 0; i < n; i++)
     {
          ans = (a[i]*1.0)/(res*1.0);

          if(ans<mmd)
               cnt=cnt;
          else
               cnt++;
     }
     if(cnt>=m)
          cout<<"Yes\n";
     else
          cout<<"No\n";


     return 0;
}



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

int main() {
	int N ,W, T;
	cin >> N;
	int total = 0;
	int total2 = 0;
	vector<int> vec(N);
	vector<int> absolute(N);
	for (int i = 0; i < N; i++) {
		cin >> W;
		vec.at(i) = W;
	}
	for (int j = 0; j < N; j++) {
		total = 0;
		total2 = 0;
		for (int k = 0; k < j + 1; k++) {
			total += vec.at(k);
		}
		for (int l = j + 1; l < N; l++) {
			total2 += vec.at(l);
		}
		absolute.at(j) = abs(total - total2);
	}
	sort(absolute.begin(), absolute.end());
	cout << absolute.at(0) << endl;
}

Measured memory_bytes: 3656
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<functional>
#include<cmath>
#include<algorithm>
#define INF 999999999
typedef  long long ll;
 
int main() {
	ll a = 0, b = 0, c = 0, n = 0;
	int ar[1000] = {};
	std::cin >> n;
	if (n % 2 == 0) {
		std::cout << n << std::endl;
	}
	else {
		std::cout << 2 * n << std::endl;
	}
		return 0;
	
}

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

int main(){
    string S;
    cin >> S;
    if(S[0] != 'A') cout << "WA" << endl;
    else if(*(S.c_str()+1) < 97 || *(S.c_str()+1) > 122) cout << "WA" << endl;
    else{
        int C = 0, Cidx;
        for(int i=2; i<S.length()-1; ++i){
            if(S[i] == 'C') { ++C; Cidx = i;}
        }
        if(C != 1) cout << "WA" << endl;
        else{
            for(int i=2; i<S.length(); ++i){
                if(i == Cidx) continue;
                if(*(S.c_str()+i) < 97 || *(S.c_str()+i) > 122) {
                    cout << "WA" << endl;
                    return 0;
                }
            }
            cout << "AC" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstdlib>
#include <ctime>
#include <string>
#include <iostream>
#include <bitset>
#define PII pair <int, int>
#define PPI pair <PII, int>
#define x first
#define y second
#define P 998244353

using namespace std;

typedef long long ll;

int N, X;

int F[2][6010][2][3], G[3010][6010], C[6010][6010];

void add(int &x, int y) {
    x = (x + y) % P;
}
int main() {
    scanf("%d%d", &N, &X);
    G[0][0] = 1;
    int ans = 0;
    for(int i = 0; i < N; i++)
        for(int j = 0; j < X; j++) {
            add(G[i + 1][j], G[i][j]);
            add(G[i + 1][j + 1], G[i][j]);
            add(G[i + 1][j + 2], G[i][j]);
        }
    if(X % 2 == 1) {
        for(int i = 0; i <= N; i++)
            for(int j = 0; j <= i; j++)
                C[i][j] = !j ? 1 : (C[i - 1][j - 1] + C[i - 1][j]) % P;
        for(int i = X; i <= N; i++)
            add(ans, C[N][i]);
    }
    for(int i = 0; i < X; i++) add(ans, G[N][i]);
    int a = 0, b = 1;
    memset(F, 0, sizeof F);
    F[a][0][0][1] = 1;
    for(int i = 0; i < N - 1; i++, swap(a, b)) {
        memset(F[b], 0, sizeof F[b]);
        for(int o = 0; o < X; o++)
            for(int s = 0; s < 2; s++)
                for(int k = 1; k < 3; k++)
                    for(int l = 0; l + k < 3; l++) {
                        add(F[b][o + l][s][k + l], F[a][o][s][k]);
                        if(l) add(F[b][o + l][!s][l], F[a][o][s][k]);
                    }
        for(int o = 1; o < X; o++)
            for(int k = 1; k < 3; k++)
                for(int l = 1; l + k < 3; l++)
                    add(ans, 1LL * F[b][o][1][k] * G[N - i - 2][X - 1 - o - l] % P);
    }
    printf("%d\n", (ans % P + P) % P);
    return 0;
}

Measured memory_bytes: 142848
#include <iostream>
#include <queue>

using ll = long long;
using namespace std;
int n, A[100][100];
int d[100];
/* initialize */

void bfs(int s){
    queue<int> q;
    q.push(s);
    for (int i = 0; i < n; ++i) d[i] = 1<<30;
    d[s] = 0;
    int u;
    while(!q.empty()){
        u = q.front(); q.pop();
        for (int i = 0; i < n; ++i) {
            if ( A[u][i] == 0 ) continue;
            if (d[i] != 1<<30) continue;
            d[i] = d[u] + 1;
            q.push(i);
        }
    }
    for (int i = 0; i < n; ++i) {
        cout << i+1 << " " << ( (d[i] == 1<<30) ? -1 : d[i]) << "\n";
    }
}
/* main */
int main() {
    int u, k, v;
    cin >> n;
    for (int i = 0; i < n; ++i) for (int j = 0; j < n; ++j) A[i][j] = 0;
    for (int i = 0; i < n; ++i) {
        cin >> u >> k;
        for (int j = 0; j < k; ++j) {
            cin >> v;
            A[u-1][v-1] = 1;
        }
    }
    bfs(0);
    return 0;
}


Measured memory_bytes: 3132
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll mod=1e9+7;
struct dsu{
       vector<ll>par;
       vector<ll>si;
       void init(ll n)
       {
            par.resize(n+1);
            si.resize(n+1);
            for(ll i=0;i<=n;i++)
            {
                par[i]=i;
                si[i]=1;
                
            }
       }
       ll find(ll a)
       {
           if(par[a]==a)
           return a;
           
           return par[a]=find(par[a]);
       }
       void un(ll a,ll b)
       {
           a=find(a);
           b=find(b);
           if(a!=b)
           {
               if(si[a]<si[b])
               swap(a,b);
               
               si[a]+=si[b];
               par[b]=a;
           }
       }
       ll get_size(ll a)
       {
           return si[a];
       }
};
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,m;
    cin>>n>>m;
    dsu Dsu;
    Dsu.init(n);
    ll max_size=0;
    for(ll i=0;i<m;i++)
    {
        ll u,v;
        cin>>u>>v;
        if(Dsu.find(u)!=Dsu.find(v))
        {
            Dsu.un(u,v);
            
        }
    }
    for(ll i=1;i<=n;i++)
    {
        max_size=max(max_size,Dsu.get_size(i));
    }
    
    cout<<max_size<<'\n';
    
    
    return 0;
}

Measured memory_bytes: 6324
h, w = map(int, input().split())
array = ["."*(w+2)]
for i in range(h):
    array.append("." + input() + ".")
array.append("."*(w+2))

for i in range(1, h+1):
    for j in range(1, w + 1):
        if array[i][j] == "#" and array[i-1][j] == "." and array[i+1][j] == "." and array[i][j-1] == "." and array[i][j+1] == ".":
            print("No")
            exit()
print("Yes")

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

int main ()
{
    int n;
    cin >> n;
    
    vector <int> height(n);
    
    for (auto& i:height){
        cin >> i;
    }
    
    vector <int> dp(n, 1e9);
    dp[0] = 0;
    
    for (int i=0; i<n; i++){
        for (int j=i; j<=i+2; j++){
            if (j<n){
                dp[j] = min(dp[j], dp[i] + abs(height[j] - height[i]));
            }
        }
    }
    
    cout << dp[n-1] << endl;
    
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(100000 + 1, 0);
  ll sum = 0;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    sum += a;
    A[a]++;
  }
  int Q;
  cin >> Q;

  for (int i = 0; i < Q; i++) {
    int b, c;
    cin >> b >> c;
    sum += c * A[b] - b * A[b];
    A[c] += A[b];
    A[b] = 0;
    cout << sum << '\n';
  }
}


Measured memory_bytes: 3748
import java.util.*;

class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int a,b,c,n;
n=0;
a=sc.nextInt();
b=sc.nextInt();
c=sc.nextInt();
for(int i=a; i<=b; i++){
	if(c%i==0) n++;
}
System.out.println(n);
}
}

Measured memory_bytes: 17324
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(){
	string s;
	cin >> s;
	vector<int> v;
	v.resize(26);
	for(int i=0; i<26; i++) v[i]=0;
	for(int i=0; i<s.size(); i++){
		v[s[i]-'a'] += 1;
	}
	char c;
	for(int i=0; i<26; i++){
		if(v[i]==0){
			c = 'a'+i;
			cout << c << endl;
			return 0;
		}
	}
	
	cout << "None" << endl;
	
	return 0;			
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;

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

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


Measured memory_bytes: 3624
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int q = sc.nextInt();
		int[] l = new int[q];
		int[] r = new int[q];
		for(int i = 0 ; i < q ; i++) {
			l[i] = sc.nextInt();
			r[i] = sc.nextInt();
		}
		// エラトステネスの篩で素数を調べる
		boolean[] isPrime = new boolean[100010];
		for(int i = 0 ; i < 100010 ; i++) isPrime[i] = true;
		isPrime[0] = isPrime[1] = false;
		for(int i = 2 ; i < 100010 ; i++) {
			if(isPrime[i]) {
				for(int j = i * 2 ; j < 100010 ; j += i) {
					isPrime[j] = false;
				}
			}
		}
		int[] imos = new int[100010];
		for(int i = 3 ; i < 100000 ; i++) {
			if(i % 2 == 1 && isPrime[i] && isPrime[(i + 1) / 2]) {
				imos[i]++;
				imos[100000]--;
			}
		}
		for(int i = 0 ; i < 100000 ; i++) imos[i + 1] += imos[i];
//		for(int i = 0 ; i < 70 ; i++) {
//			System.out.println(imos[i] + " " + i);
//		}
		for(int i = 0 ; i < q ; i++) {
			System.out.println(imos[r[i]] - imos[l[i] - 1]);
		}
	}

}


Measured memory_bytes: 69528
#include<stdio.h>

int main(){
	int N, K, X, Y, z;
	scanf("%d %d %d %d",&N, &K, &X, &Y);
	if(N>=K){
	z=K*X+Y*(N-K);
	printf("%d",z);
	}else {
	z=N*X;
	printf("%d",z);
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
int main(){
	int a[4],b[4],i,n,hit,blow;
	
		while(std::cin>>a[0]){
		hit=0;
		blow=0;
		for(i=1;i<4;i++){
			std::cin>>a[i];
			}
		for(i=0;i<4;i++){
			std::cin>>b[i];
			}
		
		for(i=0;i<4;i++){
			for(n=0;n<4;n++){
				if(a[i]==b[n]){
					if(i==n){
						hit++;
						}
					else blow++;
					}
				}
			}
		
		std::cout<<hit<<" "<<blow<<std::endl;
		}
	return 0;
	
	
	}

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

#define debug(x) cout<<#x<<"="<<x<<endl
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int) (x).size())
#define pii pair<int,int>
#define PQ priority_queue
#define sqr(x) (x)*(x)
#define ll long long
#define pb push_back
#define mp make_pair
#define re return

const int INF=0x7fffffff;

ll ans,al;
int a[3][100005];
int v[100005];
int n;

int main(){
	cin>>n;
	int x=0;
	for (int i=0;i<3;i++){
		for (int j=0;j<n;j++){
			cin>>a[i][j];
		}
	}
	sort(a[0],a[0]+n);
	sort(a[1],a[1]+n);
	sort(a[2],a[2]+n);
	for (int i=0;i<n;i++){
		while (a[2][x]<=a[1][i] && x<n) x++;
		v[i]+=n-x;
		al+=v[i];
	}
	x=0;
	for (int i=0;i<n;i++){
		while (a[1][x]<=a[0][i] && x<n){
			al-=v[x++];
		}
		ans+=al;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 2304
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
template<typename T> void cmin(T &a, T b) { a = min(a, b); }
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
int n, x;
int beef[100], sum[100];
int f(int l, int x) {
  int res = 0;
  if (x <= 0) return 0;
  if (x >= sum[l]) return beef[l];

  res += f(l - 1, x - 1);

  if (x > sum[l - 1] + 1) res++;
  res += f(l - 1, x - sum[l - 1] - 2);
  return res;
}

signed main() {
  cin >> n >> x;
  beef[0] = 1;
  sum[0] = 1;
  rep(i, n + 1) {
    beef[i + 1] = beef[i] * 2 + 1;
    sum[i + 1] = sum[i] * 2 + 3;
  }
  cout << f(n, x) << endl;
  return 0;
}


Measured memory_bytes: 256
# coding: utf-8

class UnionFind:
    # 同一グループに入る番号について、根源の番号を記録するテーブルを初期化して作成する
    def __init__(self, size):
        # テーブルが負の値の場合、そのグループの根源となる番号で、負の値の大きさはメンバーの数
        # 正の値は所属するグループの根源の番号を指す
        self.table = [-1 for _ in range(size)]

    # グループの根源を探索する
    def find(self, x):
        if self.table[x] < 0:
            return x
        else:
            # 同一グループとなる番号を辿り、大本の根源となる番号まで探索する
            self.table[x] = self.find(self.table[x])
            return self.table[x]

    # 同一グループに属する場合、根源となる番号にまとめて管理する(大きなグループに併合する)
    def union(self, x, y):
        s1 = self.find(x)
        s2 = self.find(y)
        if s1 != s2:
            # 根源となる番号については、マイナス符号を付けてメンバー数を記録しているため、小さいほうが所属メンバーが多い
            if self.table[s1] <= self.table[s2]:
                self.table[s1] += self.table[s2]
                self.table[s2] = s1
            else:
                self.table[s2] += self.table[s1]
                self.table[s1] = s2

            return True
        return False


N, M = map(int, input().split())
p = list(map(int, input().split()))

s = UnionFind(N)

for i in range(M):
    a, b = map(int, input().split())
    s.union(a-1, b-1)

ans = 0
for i in range(N):
    # 初めから番号と位置が合っている場合
    if p[i] == i+1:
        ans += 1
    # 順列の番号と位置の番号が同一の根源になる場合、入れ替えが可能
    elif s.find(p[i]-1) == s.find(i):
        ans += 1

print(ans)



Measured memory_bytes: 13812
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        char[] S = sc.next().toCharArray();
        int count=0;
        
        for(int i=0; i<N-2; i++){
            if(S[i]=='A' && S[i+1]=='B' && S[i+2]=='C'){
                  count++;
            }
        }

        
        
        
        
        
        
        
        
        
        
        
        
          System.out.println(count);
        }
    }

Measured memory_bytes: 35788
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let s: Vec<char> = iterator.next().unwrap().chars().collect();

    return format!("{}{}{}", s.first().unwrap(), s.len() - 2, s.last().unwrap());
}


Measured memory_bytes: 2108
import sys
from collections import Counter
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    B = list(map(int, readline().split()))

    counterA = Counter(A)
    counterB = Counter(B)

    for i in range(1, N + 1):
        if counterA[i] + counterB[i] > N:
            print('No')
            return

    C = [0] * (N + 1)
    D = [0] * (N + 1)
    for a in A:
        C[a] += 1
    for b in B:
        D[b] += 1

    C = list(accumulate(C))
    D = list(accumulate(D))

    x = max(C[i] - D[i - 1] for i in range(1, N + 1))

    ans = [0] * N
    for i in range(N):
        ans[i] = B[(i - x) % N]

    print('Yes')
    print(*ans)

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 183372
#include "stdio.h"
#include "stdlib.h"
#include <iostream>
#include <vector>

using namespace std;

template <class T>
class mpq
{
private:
	int* st;
	int si;
	int stb;
	T* d;
	void kou(int a);
public:
	mpq();
	int size();
	T top();
	void push(T a);
	void pop();
	void del();
	void reset();
	~mpq();
};

template <class T>
void mpq<T>::kou(int now)
{
	if(now < 0)
	{
		return;
	}
	while(1)
	{
		int min = now;
		if(now * 2 + 1 < stb)
		{
			if(d[st[now * 2 + 1]] < d[min])
			{
				min = st[now * 2 + 1];
			}
			if(now * 2 + 2 < stb)
			{
				if(d[st[now * 2 + 2]] < d[min])
				{
					min = st[now * 2 + 2];
				}
			}
		}
		st[now] = min;
		if(now == 0)
		{
			break;
		}
		now = (now - 1) / 2;
	}
}

template <class T>
mpq<T>::mpq()
{
	si = 10000;
	stb = 0;
	st = (int*)malloc(si * sizeof(int));
	d = (T*)malloc(si * sizeof(T));
}

template <class T>
int mpq<T>::size()
{
	return stb;
}

template <class T>
T mpq<T>::top()
{
	return d[st[0]];
}

template <class T>
void mpq<T>::push(T a)
{
	if(stb >= si)
	{
		si += 10000;
		st = (int*)realloc(st,si * sizeof(int));
		d = (T*)realloc(d,si * sizeof(T));
	}
	d[stb] = a;
	st[stb] = -1;
	stb++;
	kou(stb - 1);
}

template <class T>
void mpq<T>::pop()
{
	if(stb > 1)
	{
		if(st[0] != stb - 1)
		{
			d[st[0]] = d[stb - 1];
			int w = st[0];
			st[w] = -1;
			stb--;
			kou(w);
			kou((stb - 1) / 2);
		}
		else
		{
			stb--;
			kou((stb - 1) / 2);
		}
	}
	else
	{
		stb = 0;
	}
}

template <class T>
void mpq<T>::del()
{
	if(si != 0)
	{
		free(st);
		free(d);
		si = 0;
		stb = 0;
	}
}

template <class T>
void mpq<T>::reset()
{
	del();
	si = 10000;
	stb = 0;
	st = (int*)malloc(si * sizeof(int));
	d = (T*)malloc(si * sizeof(T));
}

template <class T>
mpq<T>::~mpq()
{
	del();
}



int main()
{
	while(1)
	{
		vector<pair<int,int> > ten[100];
		int n,k;
		scanf("%d %d",&n,&k);
		if(n == 0 && k == 0)
		{
			break;
		}
		for(int i = 0; i < k; i++)
		{
			int w;
			scanf("%d",&w);
			if(w == 0)
			{
				int a,b;
				scanf("%d %d",&a,&b);
				a--;
				b--;
				int e[100];
				for(int i = 0; i < n; i++)
				{
					e[i] = (2e9);
				}
				mpq<pair<int,int> > q;
				q.push(make_pair(0,a));
				while(q.size() > 0)
				{
					if(e[q.top().second] > q.top().first)
					{
						e[q.top().second] = q.top().first;
						if(q.top().second == b)
						{
							break;
						}
						for(int ii = 0; ii < ten[q.top().second].size(); ii++)
						{
							q.push(make_pair(q.top().first + ten[q.top().second][ii].second,ten[q.top().second][ii].first));
						}
					}
					q.pop();
				}
				if(e[b] == (2e9))
				{
					printf("-1\n");
				}
				else
				{
					printf("%d\n",e[b]);
				}
			}
			else
			{
				int a,b,c;
				scanf("%d %d %d",&a,&b,&c);
				a--;
				b--;
				ten[a].push_back(make_pair(b,c));
				ten[b].push_back(make_pair(a,c));
			}
		}
	}
}

Measured memory_bytes: 1296
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <cmath> 
using namespace std;

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;



    if(abs(c-a)<=d){
        cout << "Yes" << '\n';
        return 0;
    }

    if(abs(c-b)<=d && abs(b-a)<=d){
        cout << "Yes" << '\n';
        return 0;        
    }
    

    cout << "No" << '\n';
    return 0;
}

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


using ll = long long;

//~ const int INF = 1e9 + 5;


//ITERATIVE:
int main()
{
    int n;
    scanf("%d", &n);
    vector<int> dp(3);
    // dp[i] - the total cost such that we did activity i on the last considered day
    for(int day = 0; day < n; ++day) 
    {
        vector<int> new_dp(3, 0); //final result till this day i is stored in this from previous dp table, later dp is updated with new_dp
        vector<int> c(3);   // cost of all three activities this day

        for(int i = 0; i < 3; ++i) 
        {
            scanf("%d", &c[i]);
        }

        // int a, b, c - a lot of implementation
        for(int i = 0; i < 3; ++i) 
        //i represents dp state from previous day: activity chosen from previous day
        {
            for(int j = 0; j < 3; ++j) // activity present day
            {
                if(i != j) //obviously activity from present day != activity past day
                {
                    new_dp[j] = max(new_dp[j], dp[i] + c[j]);
                }
            }
        }
        dp = new_dp;// reassign states for next iteration, it will become past day
    }
    printf("%d\n", max({dp[0], dp[1], dp[2]}));
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, l, r) for(int i = (l), _end_ = (int)(r); i <= _end_; ++i)
#define Fordown(i, r, l) for(int i = (r), _end_ = (int)(l); i >= _end_; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
	int x = 0, fh = 1; char ch = getchar();
	for (; !isdigit(ch); ch = getchar() ) if (ch == '-') fh = -1;
	for (; isdigit(ch); ch = getchar() ) x = (x<<1) + (x<<3) + (ch ^ '0');
	return x * fh;
}

typedef long long ll;
const int N = 200000 + 100;
char str[N];
ll cnt[26];
ll ans = 0;
ll cost = 0;

int main () {
	scanf ("%s", str);
	int len = strlen(str);
	For (i, 0, len - 1) {
		cost += cnt[str[i] - 'a'];
		++cnt[str[i] - 'a'];
	}
	len = 2 * len - 1;
	For (i, 2, len - 1) {
		int now_len = min(i - 1, len - i) + 1;
		now_len /= 2;
		ans += now_len;
	}
	//cout << ans << ' ' << cost << endl;
	ans -= cost;
	printf ("%lld\n", ans + 1);
    return 0;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
#include <cmath>
#include <ctime>
#define f(x,y) for(int x=0;x<y;x++)

typedef long long unsigned int llu;
llu cloc[101];
llu gcd(llu a,llu b){
    llu t;
    if(b>a){
        t=a;
        a=b;
        b=t;
    }
    if(b==0)return a;
    return gcd(b,a%b);
}
int main() {
    int n;
    llu c=1;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%llu",&cloc[i]);
    }
    for(int i=0;i<n;i++){
        if(gcd(cloc[i],c)==c||gcd(cloc[i],c)==cloc[i]){
            if(cloc[i]>=c)
                c=cloc[i];
        }
        else c=cloc[i]*(c/gcd(cloc[i],c));
    }
    printf("%llu\n",c);


    return 0;}


Measured memory_bytes: 128
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

// n 文字目までに k 種類の文字を使っているなら
// n+1 文字目は k+1 種類の文字が使える
void calc(int n) {
    void rec(int[] cs, int p, int k) {
        if (p == n) {
            string s = cs.map!(c => text(cast(char)(c + 'a'))).join("");
            writeln(s);
            return;
        }

        foreach (i; 0..k+1) {
            cs[p] = i;
            rec(cs, p+1, i == k ? k+1 : k);
        }
    }

    auto cs = new int[n];
    rec(cs, 0, 0);
}

void main() {
    int n; scan(n);
    calc(n);
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;


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

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

fn main() {
    let n: u32 = read();
    let k: u32 = read();
    let x: u32 = read();
    let y: u32 = read();
    if  n >= k {
        println!("{}", x*k + y*(n-k));
    } else {
        println!("{}", x * n);
    }
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

struct State{
    State(){}
    State(int rev, string need):rev(rev),need(need){}
    int rev; string need;
    bool operator<(const State &a) const {
        return tie(rev,need)<tie(a.rev,a.need);
    }
};

bool isPal(const string &s)
{
    int N = s.size();
    rep(i,N)if(s[i]!=s[N-i-1]) return false;
    return true;
}

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

const ll INF = 1e18;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin>>N;
    vector<string> S(N);
    vll C(N);
    using P = pair<ll,State>;
    priority_queue<P,vector<P>,greater<P> > que;
    map<State,ll> dist;

    auto update = [&](State s, ll cost){
        if (dist.count(s)){
            chmin(dist[s],cost);
        }else{
            dist[s] = cost;
        }
        que.push(P(cost,s));
    };

    rep(i,N){
        cin>>S[i]>>C[i];
        string T=S[i];
        reverse(all(T));
        update(State(0,T),C[i]);
    }
    ll ans=INF;
    while(!que.empty()){
        ll cost; State s;
        tie(cost,s) = que.top(); que.pop();
        if (dist[s]<cost) continue;
        if (isPal(s.need)){
            chmin(ans,cost);
            continue;
        }
        rep(i,N){
            int rev = s.rev;
            string need = s.need;
            string input = S[i];
            if (rev) reverse(all(need)), reverse(all(input));
            if (need.size()<input.size()) swap(need,input), rev=1-rev;
            int sz = input.size();
            if (need.substr(0,sz)==input.substr(0,sz)){
                string next = need.substr(sz);
                if (rev) reverse(all(next));
                update(State(rev,next),cost+C[i]);
            }
        }
    }
    cout<<(ans==INF?-1:ans)<<endl;
    return 0;
}


Measured memory_bytes: 3768
import java.util.*;
public class Main
{
  public static void main(String args[])
  {
    Scanner in=new Scanner(System.in);
    int  n=in.nextInt();
    if(n>=400 && n<=599)
    {
      System.out.println("8");
    }
    else if(n>=600 && n<=799)
    {
      System.out.println("7");
    }
    else if(n>=800 && n<=999)
    {
      System.out.println("6");
    }
    else if(n>=1000 && n<=1199)
    {
      System.out.println("5");
    }
    else if(n>=1200 && n<=1399)
    {
      System.out.println("4");
    }
    else if(n>=1400 && n<=1599)
    {
      System.out.println("3");
    }
    else if(n>=1600 && n<=1799)
    {
      System.out.println("2");
    }
    else if(n>=1800 && n<=1999)
    {
      System.out.println("1");
    }
  }
}
    

Measured memory_bytes: 35896
#include<iostream>
#include<cmath>
#include<vector>
#include<algorithm>
#include<stack>
using namespace std;

int main()
{
	string s;
	int a;

	cin >> a >> s;

	if (a >= 3200)
	{
		cout << s;
	}
	else
	{
		cout << "red";
	}
}


Measured memory_bytes: 3588
/*
	Name:
	Author: xiaruize
	Date:
*/

#include<bits/stdc++.h>
using namespace std;
#define ull unsigned long long
#define MOD 1000000007
#define ALL(a) (a).begin(), (a).end()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define ll long long
#define form(i,j,n) for(int i=int(j);i<=int(n);i++)
#define pb push_back
#define mk make_pair
#define pii pair<int,int>
#define pis pair<int,string>
#define sec second

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

int main()
{
 	ios::sync_with_stdio(false);
	cin.tie(0);
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	ll h,w;
	cin>>h>>w;
	if(h==1||w==1)
	{
		cout<<"1"<<endl;
		return 0;
	}
	cout<<(h*w+1)/2<<endl;
	return 0;
}

Measured memory_bytes: 256
N = int(input())
ans = 0
c1 = 0
c2 = 0
c3 = 0
ans = 0
for _ in range(N):
    s = input()
    ans += s.count("AB")
    if (s[0]=="B") & (s[-1]=="A"):
        c1 += 1
    elif s[0] == "B":
        c2 += 1
    elif s[-1]=="A":
        c3 += 1

if c1== 0:
    print(ans + min(c2, c3))
elif (c1 > 0) & (max(c2, c3) == 0):
    print(ans + c1 - 1)
elif (c1 > 0) & (max(c2, c3) > 0):
    print(ans + c1 + min(c2, c3))

Measured memory_bytes: 3188
// ~maqsat~

// #pragma GCC target ("avx2")
// #pragma GCC optimize ("Ofast")
// #pragma GCC optimize ("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>

#define F first
#define S second
#define in insert
#define pb push_back
#define eb emplace_back
#define sz(x) int(x.size())
#define all(x) x.begin(), x.end()
#define count1 __builtin_popcountl
#define debug(x) cerr << (#x) << " = " << (x) << "\n"
#define ACCELERATE ios_base::sync_with_stdio(false),cin.tie(nullptr)
#define fre(f) if(fopen(f".in", "r")) freopen(f".in", "r", stdin),freopen(f".out", "w", stdout)
#define ever ;;

using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;

using ll = long long;
using ull = unsigned long long;
// using big = __int128_t; // -10^38...10^38
using db = double;
using ld = long double;
typedef pair<int,int> ii;
typedef pair<ll,ll> pll;

template <class T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <class T> inline void cmin(T &a, T b) { a = min(a, b); }
template <class T> inline void cmax(T &a, T b) { a = max(a, b); }

const int oo = 0x3f3f3f3f;
const ll N = 1e5 + 123;
const ll MOD = 1e9 + 7;
const ll INF = 1e15 + 9;
const db EPS = 1e-9;
const db PI = acos(-1); // 3.14159265358979323846
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};

main() {
#ifdef ZVER
	cerr << "Ready\n";
#endif
	fre("");
	ACCELERATE;
	
	ll h, w;
	cin >> h >> w;
	
	if (h == 1 || w == 1) return !(cout << 1);
	
	cout << (h * w + 1) / 2;
	
	return 0;
}


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

int main() {
  int n,m; cin>>n>>m;
  vector<pair<pair<int,int>,int>> bigpa(m);
  
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    bigpa[i].first.first=a;//県
    bigpa[i].first.second=b;//年
   bigpa[i].second=i;
  }
  
  vector<vector<int>> ans(m,vector<int>(2));
  sort(bigpa.begin(),bigpa.end());//pairのなかのpairを基準にソートされる
  
  int jun=1;
  
  for(int i=0;i<m;i++){
    
   if(i>0){
      if(bigpa[i-1].first.first==bigpa[i].first.first)//県が同じなら
      jun++;
    else jun=1;
    }
   ans[bigpa[i].second][0]=bigpa[i].first.first;
   ans[bigpa[i].second][1]=jun;

  }
   
  for(int i=0;i<m;i++){
    printf("%06d",ans[i][0]);
    printf("%06d\n",ans[i][1]);
  }
}

Measured memory_bytes: 8192
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

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

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, _begin, _end) for (__typeof(_end) end = _end, begin = _begin,  i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0, _len = (end); i < (_len); i += 1)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define F first
#define S second
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define bit(n) (1LL<<(n))
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class AABCARC {
public:

void solve(std::istream& cin, std::ostream& cout) {
    int x;
    cin >> x;
    cout << (x < 1200? "ABC":"ARC") << endl;

}
};


#undef int
int main() {
	AABCARC solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	in.tie(0); ios::sync_with_stdio(0); out<<fixed<<setprecision(20);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

char a, b, c;

int main(){
  rep(i, 9){
    char tmp; cin >> tmp;
    if(i == 0) a = tmp;
    if(i == 4) b = tmp;
    if(i == 8) c = tmp;
  }
  cout << a << b << c << endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	//????????£?????????????????????
	Scanner sc = new Scanner(System.in);
	//??°?????????
	while(true){
		//H ??????????????????
		int H = sc.nextInt();
		//W ?¨????????????????
		int W = sc.nextInt();
		//????????????H??¨W???0?????´?????????
		if(W ==0&& H==0){
			break;
		}
		//??????????????¨???
		for(int i = 0; i< H; i++){
				//?¨????????????¨???
				for(int j = 0; j <W; j++){
					//i??¨???????¶?????????¶??°????????°??????????\???°????????°???.???
					if((i + j ) % 2 ==0 ){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				//???????????????
				System.out.println();
			}
		//???????????????
		System.out.println();
		}
	}
}

Measured memory_bytes: 35424
/* Nurgazy Zhandos */

#include <bits/stdc++.h>

#define F first
#define S second

#define pf push_front
#define pb push_back
#define mp make_pair
#define pp pop_back
#define in insert

#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define sz(a) a.size()
#define STOP return 0

#define nl '\n'

#define int long long

using namespace std;

typedef pair <long long, long long> pll;
typedef pair <int, long long> pil;
typedef pair <long long, int> pli;
typedef unsigned long long ull;
typedef pair <int, int> pii;
typedef long double ld;
typedef long long ll;

const int MAX_N = 1e5 + 123;
const int inf = 1e9 + 123;
const ll INF = 1e18 + 123;
const int NN = 2e6 + 123;
const double eps = 1e-9;
const int mod = 1e9 + 7;

/*void random() {
 		unsigned int FOR;
 		asm("rdtsc" : "=A" (FOR));
	srand(FOR);
}*/

inline void fre() {
	#ifdef TEZZY
//	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
	#endif
}

inline void boost() {
	ios_base :: sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
}

main () {
	fre();
	boost();

	int a, b, c;
	cin >> a >> b >> c;
	
	int mx = max(a, max(b, c));
	int k = 0;
	k += (mx - a) / 2;
	k += (mx - b) / 2;
	k += (mx - c) / 2;
	a += (mx - a) / 2 * 2;
	b += (mx - b) / 2 * 2;
	c += (mx - c) / 2 * 2;

	if(a == b && b == c) cout << k, exit(0);

	if(a == b && a > c) {
	 	cout << k + 2;
	}
	else if(a == c && a > b) {
	 	cout << k + 2;
	}
	else if(b == c && b > a) {
	 	cout << k + 2;
	}
	else if(a == b && a < c) {
	 	cout << k + 1;
	}
	else if(a == c && a < b) {
	 	cout << k + 1;
	}
	else if(b == c && b < a) {
	 	cout << k + 1;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<set>
#include<map>
#include<queue>
#include<list>
#include<iostream>
#include <bitset>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define rep2(i, a)for(auto i : a)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x, std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
#define vec_unique(_a) _a.erase(std::unique(all(_a)), _a.end());
#define vvec vector<vector<ll>>
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
#define INF 1 << 30
const int mod = 1000000007;
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }
ll mpower(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x = x * x % mod; p /= 2; } else { a = a * x % mod; p--; } }return a; }
ll co(ll n, ll k) { ll a = 1; rep(i, 1ll, k) { a *= n - i + 1; a /= i; }return a; }
ll mc(ll n, ll m) { ll k = 1, l = 1; rep(i, n - m + 1, n + 1) k = k * i % mod; rep(i, 1, m + 1) l = l * i % mod; l = mpower(l, mod - 2); return k * l % mod; }

int main(void) {
	int n;
	cin >> n;
	vector<pair<ll, ll>> p(n);
	rep(i, 0, n)cin >> p[i].first >> p[i].second;
	sort(all(p));
	vector<ll> t, t2;
	rep(i, 0, n) {
		t.push_back(p[i].first + p[i].second);
	}
	sort(all(t));
	rep(i, 0, n) {
		t2.push_back(p[i].first - p[i].second);
	}
	sort(all(t2));
	printf("%lld\n", max(t.back() - t.front(), t2.back() - t2.front()));
	return 0;
}


Measured memory_bytes: 11060