akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<stdio.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define pb                  push_back
#define arr                 vector<ll>
#define mem(x,val)          memset(x,val,sizeof(x))
#define vp                 vector<pair<ll,ll>>
#define matrix              vector<vector<ll> >
#define digit(x)            floor(log10(x))+1
#define debug(x)            cerr << #x << " is " << x << endl;
#define all(a)              a.begin(),a.end()
#define fixed               setprecision(15)
// ll dx[]={-1,1,0,0},dy[]={0,0,-1,1}; 4 Sides
//ll dx[]={-1,1,-1,1,0,0,-1,1} , dy[]={-1,1,0,0,-1,1,1,-1};    8 Sides
using namespace std;
arr read(ll n){
    arr a;
    for (ll i=0;i<n;i++){
        ll x;
        cin>>x;
        a.pb(x);
    }
    return a;
}
  int main(){
       string s, t;
       cin >> s >> t;
       ll ans = 0;
       ll j=0;
       ll minx = INT_MAX;
       for (ll i=0;i<s.size()-t.size()+1;i++){
           ans = 0;
           for (ll j=0;j<t.size();j++){
                if (t[j] != s[i+j]){
                    ans++;
                }
            }
            minx = min(minx, ans);
       }
       cout<<minx<<endl;
        return 0;
}


Measured memory_bytes: 3584
import java.nio.charset.IllegalCharsetNameException;
import java.util.*;
import java.lang.*;


public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		boolean pos = false;
		for (int i = 1; i <= b; i++) {
			if (a * i % b == c) {
				pos = true;
				break;
			}
		}
		if (pos) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 23124
n,a,b = map(int,input().split())
nu = [str(i) for i in range(1,n+1)]
ans = []
for i in range(len(nu)):
  p = 0
  for j in range(len(nu[i])):
    p += int(nu[i][j])
  if a <= p <= b:
    ans.append(int(nu[i]))
    
print(sum(ans))

Measured memory_bytes: 41324
N = int(input())
A = list(map(int, input().split()))
assert 1 <= N and N <= 2*1e5
for a in A:
    assert a >= 1 and a <= 1e9
x = []
for i in range(len(A)-1):
    if A[i] > A[i+1]:
        d = A[i]-A[i+1]
        x.append(d)
        A[i+1] = A[i]
print(sum(x))

Measured memory_bytes: 32280
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define read(FILE)  freopen(FILE, "r", stdin);
#define out(FILE) freopen(FILE, "w", stdout);
#define clr(x, y) memset(x,y,sizeof(x));
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i, m, n) for(int i=m ; i<n ; i++)
#define forr(i, m, n) for(int i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N = 1e5 + 5;
const ll mod = 1e9 + 7;
using namespace std;
int main() {
    IO;
    int n; cin>>n;
    map<int,int>cnt;
    forr(i,1,n-1) {
        int x; cin>>x;
        cnt[x]++;
    }
    forr(i,1,n) cout<<cnt[i]<<endl;
}



Measured memory_bytes: 13028
x,n = map(int,input().split())
if n == 0: 
    print(x)
    exit()
p = list(map(int,input().split()))
p = sorted(p)
ans = 100000
for i in range(-10000,10000):
    ok = True
    for j in range(n):
        if i == p[j]: ok = False
    if ok:
        if(abs(ans - x) > abs(x - i)):
            ans = i
print(ans)

Measured memory_bytes: 9204
#include <bits/stdc++.h>
#include<math.h>
typedef long long ll;
using namespace std;
vector<vector<int>>comp;
vector<int>onecycle;
vector<int>clength;
vector<int>v9;
vector<int>v8;
int cycle_start;
int cycle_end;
vector<int>vbip1;
vector<int>vbip2;
#define FIO  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int l1=s1.length();
    int l2=s2.length();
    int dp[l1+1][l2+1];
    int i,j;
    int flag[l1+1][l2+1];
    for(i=0;i<l1+1;i++)
    {
        for(j=0;j<l2+1;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
                if(i==0)
                {
                    flag[i][j]=1;
                }
                else
                {
                    flag[i][j]=2;
                }
            }
            else
            {
                if(s1[i-1]==s2[j-1])
                {
                    dp[i][j]=dp[i-1][j-1]+1;
                    flag[i][j]=3;
                }
                else
                {
                    dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
                    if(dp[i-1][j]>dp[i][j-1])
                    {
                        flag[i][j]=2;
                    }
                    else
                    {
                        flag[i][j]=1;
                    }
                }
            }
        }
    }
    i=l1;
    j=l2;
    string s="";
    while(i!=0 && j!=0)
    {
        if(flag[i][j]==3)
        {
            s.push_back(s1[i-1]);
            i--;
            j--;
        }
        else if(flag[i][j]==2)
        {
            i--;
        }
        else
        {
            j--;
        }
    }
    reverse(s.begin(),s.end());
    cout<<s;
    
    
}


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

int main() {
  string s; cin >> s;
  int ans = 653;
  rep(i,s.size()-2) {
    int sn = stoi(s.substr(i,3));
    ans = min(ans, abs(753-sn));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3616
#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;
  if (S=="RRR"){
    cout<<3<<endl;
  }
  else if(S=="RRS"||S=="SRR"){
    cout<<2<<endl;
  }
  else if(S=="SSS"){
    cout<<0<<endl;
  }
  else{
    cout<<1<<endl;
  }
}

Measured memory_bytes: 3572
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const p = arg[1].split(" ").map(n=>parseInt(n));
    
    let answer = 0;
    
    for(let i=0; i<N-2; i++) {
        let left   = p[i];
        let middle = p[parseInt(i) + 1];
        let right  = p[parseInt(i) + 2];
        
        let array = [left, middle, right].sort((a,b)=>a-b);
        
        if(array[1] === middle) {
            answer++;
        }
    }
    
    console.log(answer);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 21192
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <bitset>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

class Point{
    public: 
    long double x,y,theta;
    Point(long double x = 0.0, long double y = 0.0): x(x), y(y), theta(atan2(y, x)) {}
    Point operator + (const Point &p) const { return Point(x+p.x, y+p.y); }
    Point operator - (const Point &p) const { return Point(x-p.x, y-p.y); }
    Point operator * (const long double &a) const { return Point(x*a, y*a); }
    Point operator / (const long double &a) const { return Point(x/a, y/a); }
    bool operator < (const Point &p) const { return theta<p.theta; }
    bool operator == (const Point &p) const { return fabsl(x - p.x) < EPS && fabsl(y - p.y) < EPS; }
    long double abs() const { return sqrt(norm()); }
    long double norm() const { return x*x + y*y; }
    long double dot(Point p) const { return x*p.x + y*p.y; }
    long double cross(Point p) const { return x*p.y - y*p.x; }   
};

typedef Point Vector;

int main() {
    std::ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    vector<Vector> v(2*n);
    for(int i=0;i<n;++i){
        cin >> v[i].x >> v[i].y;
        v[i].theta = atan2(v[i].y, v[i].x);
        if(v[i].theta < 0.0) v[i].theta += 2*M_PI;
        v[n+i].x = v[i].x;
        v[n+i].y = v[i].y;
        v[n+i].theta = v[i].theta + 2*M_PI;
    }
    sort(v.begin(), v.end());


    // for(int i=0;i<n;++i) {
    //     cerr << v[i].x << " " << v[i].y << endl;
    // }

    long double ans = 0.0;
    for(int i=0;i<n;++i) {
        Vector u = Vector();
        int j = i;
        while(j < 2*n && v[j].theta - v[i].theta < M_PI) {
            u = u + v[j];
            // cerr << i << " " << j%n << ": " << u.abs() << endl;
            ans = max(ans, u.abs());
            ++j;
        }

    }

    cout << fixed << setprecision(12) << ans << endl;
}


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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
typedef long long lint;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;

class SegmentTree {
private:
	int size__;
	Vec< int > data;
	
	inline int left_t(int k) { return (k << 1) + 1; }
	inline int right_t(int k) { return (k << 1) + 2; }
	inline int center(int l, int r) { return (l + r) >> 1; }
	
	int calc(int  d1, int  d2) { return min(d1, d2); }
	
	int query(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return 1e9;
		if (a <= l && r <= b) return data[k];
		return calc(query(a, b, left_t(k), l, center(l, r)),
					query(a, b, right_t(k), center(l, r), r));
	}
	
public:
	SegmentTree() {}
	
	SegmentTree(int n) {
		for (size__ = 1; size__ < n; size__ <<= 1);
		data.assign(2 * size__ - 1, 1e9);
	}
	
	void update(int k, int  a) {
		k += size__ - 1;
		data[k] = a;
		
		while (k > 0) {
			k = (k - 1) >> 1;
			data[k] = calc(data[left_t(k)], data[right_t(k)]);
		}
	}
	
	int query(int a, int b) { return query(a, b, 0, 0, size__); }
};

int N, perm[200010];
SegmentTree seg[2];

Vec< pii > piece;
Vec< Vec< int > > nxt;
map< pii , int > piece_to_id;

void divide(int l, int r, int par) {
	if (l >= r) return;
	
	int a = seg[l % 2].query(l, r-1);
	int b = seg[(l + 1) % 2].query(perm[a]+1, r);
	
	if (par != -1) nxt[par].push_back(piece.size());
	piece_to_id[pii(a, b)] = piece.size();
	piece.push_back(pii(a, b));
	
	int cur = piece.size() - 1;
	nxt.push_back(Vec< int >());
	if (l < perm[a]) divide(l, perm[a], cur);
	divide(perm[a] + 1, perm[b], cur);
	if (perm[b] + 1 < r) divide(perm[b] + 1, r, cur);
}

int main() {
	cin >> N;
	
	for_(i,0,2) seg[i] = SegmentTree(N);
	
	for_(i,0,N) {
		int p; cin >> p;
		perm[p] = i;
		seg[i % 2].update(i, p);
	}
	
	divide(0, N, -1);
	
	Vec< int > ans;
	priority_queue< pii, Vec< pii >, greater< pii > > que;
	que.push(piece[0]);
	
	while (!que.empty()) {
		pii p = que.top(); que.pop();
		ans.push_back(p.first);
		ans.push_back(p.second);
		
		int id = piece_to_id[p];
		for (int i : nxt[id]) que.push(piece[i]);
	}
	
	for_(i,0,N) cout << ans[i] << (i < N - 1 ? " " : "\n");
}

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

int main () {
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  double a = ((double) M / 60) * 2 * M_PI;
  double b = ((double) H / 12) * 2 * M_PI + ((double) M / (60 * 12)) * 2 * M_PI;

  double xm = A*cos(a);
  double ym = A*sin(a);
  double xh = B*cos(b);
  double yh = B*sin(b);
  printf("%.10f\n",sqrt(pow(xm-xh,2) + pow(ym-yh,2)));
}

Measured memory_bytes: 4112
def num_357(ls, i, num_l):
    l = ["3", "5", "7"]
    if i > 0:
        for c in l:
            i -= 1
            ls.append(c)
            num_l.append("".join(ls))
            num_357(ls, i, num_l)
            ls.pop(-1)
            i += 1
    else:
        return

num_l = []
ls = []
i =9 

num_357(ls, i, num_l)
num_new = []
for l in num_l:
    if "3" in l and "5" in l and "7" in l:
        num_new.append(int(l))
N = int(input())
import bisect

num_new.sort()
print(bisect.bisect(num_new, N))


Measured memory_bytes: 6260
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define MAX 1000000007
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	vector<vector<int> > tree(n);
	rep(i,n-1){
		int a,b;
		cin>>a>>b;
		tree[a-1].push_back(b-1);
		tree[b-1].push_back(a-1);
	}
	vector<int> visited(n,0);
	queue<int> q;

	visited[0]=1;
	ll ans=k;

	rep(i,tree[0].size()){
		q.push(tree[0][i]);
		visited[tree[0][i]]=1;
		ans*=(k-1-i);
		ans=ans%MAX;
	}
	while(!q.empty()){
		int id=q.front();
		q.pop();
		rep(i,tree[id].size()){
			if(visited[tree[id][i]] == 0){
				q.push(tree[id][i]);
				visited[tree[id][i]]=1;
			}
		}
		ll tmp=1;
		rep(i,tree[id].size()-1){
			tmp*=(k-2-i);
			tmp=tmp%MAX;
		}
		ans*=tmp;
		ans=ans%MAX;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 6904
while 1:
	try:
		N,M = map(int,raw_input().split())
		dp = [[0]*(M+1) for i in range(3)]
		for _ in range(N):
			name = raw_input()
			C,V,D,L = map(int,raw_input().split())
			VDL = [V,D,L]
			if C > M:
				continue
			for i in range(3):
				dp[i][C] = max(dp[i][C],VDL[i])
				for j in range(M-C+1):
					if dp[i][j]:
						dp[i][j+C] = max(dp[i][j+C],dp[i][j]+VDL[i])
		print max(max(dp[0]),max(dp[1]),max(dp[2]))
	except:
		break

Measured memory_bytes: 4268
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <cctype>
#include <iostream>
using namespace std;
typedef string::const_iterator State;

map<string,int> table;
bool flag;

int expression(State &begin);
int factor(State &begin);
int atom(State &begin);
int number(State &begin);

int number(State &begin){
	int ret=0;
	while(isdigit(*begin)){
		ret*=10;
		ret+=*begin-'0';
		begin++;
	}
	return ret;
}

int atom(State &begin){
	string name="";
	name+=*begin;
	begin++;
	if(*begin>='a' && *begin<='z'){
		name+=*begin;
		begin++;
	}
	if(table.find(name)==table.end()){
		flag=false;
		return -1;
	}
	int ret=table[name];
	if(isdigit(*begin))ret*=number(begin);
	return ret;
}

int factor(State &begin){
	if(*begin=='('){
		begin++;
		int ret=expression(begin);
		begin++;
		if(isdigit(*begin)){
			ret*=number(begin);
		}
		return ret;
	}else return atom(begin);
}

int expression(State &begin){
	if(!flag)return -1;
	int ret=factor(begin);
	while(1){
		if(*begin>='A' && *begin<='Z'){
			ret+=factor(begin);
		}else if(*begin>='a' && *begin<='z'){
			flag=false;
			return -1;
		}else if(isdigit(*begin)){
			ret*=factor(begin);
		}else if(*begin=='('){
			ret+=factor(begin);
		}else break;
	}
	return ret;
}


int main(void){
	while(1){
		string str;
		cin >> str;
		if(str=="END_OF_FIRST_PART")break;
		int x;
		scanf("%d",&x);
		table[str]=x;
	}
	while(1){
		string str;
		cin >> str;
		if(str=="0")break;
		State begin=str.begin();
		flag=true;
		int res=expression(begin);
		if(!flag)printf("UNKNOWN\n");
		else printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1268
//IOI 2021

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

#define pb push_back
#define ff first
#define ss second
typedef long long ll;
typedef pair<int, int> pii;

const int MAXSU = 1000 * 1000 + 17;

struct DSU {
	int par[MAXSU];
	DSU () {
		memset(par, -1, sizeof(par));
	}
	int find_root(int x) {
		return (par[x] == -1? x: par[x] = find_root(par[x]));
	}
	bool set_union(int x, int y) {
		int p1 = find_root(x), p2 = find_root(y);
		return (p1 == p2? false: (par[p1] = p2) | 1);
	}
};

const int MAXN = 100 * 1000 + 17;

int n, m, a[MAXN], cnt;
ll ans;
multiset<int> cmp[MAXN];
vector<int> t;
DSU gr;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	for (int i = 1; i <= m; i++) {
		int v, u;
		cin >> v >> u;
		v++;
		u++;
		gr.set_union(v, u);
	}
	if (m == n - 1)
		return cout << 0 << endl, 0;

	for (int i = 1; i <= n; i++)
		cmp[gr.find_root(i)].insert(a[i]);
	for (int i = 1; i <= n; i++) {
		if (cmp[i].size())
			cnt++;
		else
			continue;
		ans += (*cmp[i].begin());
		cmp[i].erase(cmp[i].begin());
		for (auto j : cmp[i])
			t.pb(j);
	}
	if ((int)t.size() < cnt - 2)
		return cout << "Impossible" << endl, 0;

	sort(t.begin(), t.end());
	for (int i = 0; i < cnt - 2; i++)
		ans += t[i];
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 16000
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int t=sc.nextInt();
		int[] x=new int[n];
		int[] m=new int[n];
		
		for(int i=0;i<n;i++){
			x[i] = sc.nextInt();
		}
		int profit = 0;
		for(int i=n-1;i>=0;i--){
			m[i] = x[i];
			if(i+1<n&&m[i+1]>x[i])
				m[i] = m[i+1];
			if(m[i]-x[i]>profit)
				profit = m[i]-x[i];
		}
		int sum = 0;
		for(int i=0;i<n;i++)
			if(m[i]-x[i]==profit)
				sum++;
		System.out.print(sum);
	}
}

Measured memory_bytes: 49956
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int[] N = new int[n];
        int count = 0;
        boolean check = true;

        for(int i = 0 ; i < n ; i++){
           N[i] = scan.nextInt();
        }

        while(check){

        for(int t : N ){
           if(t % 2 == 1){
             check = false;
             count --;
             break;
           }
        }
        for(int i = 0 ; i < n ; i++) {
        	N[i] /= 2;
        }
        count ++;
        }
      System.out.println(count);
    }

}

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

struct UnionFind {
  vector<int> r;

  UnionFind(int N){
    r = vector<int>(N, -1);
  }

  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x==y) return false;
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  int size(int x) {
    return -r[root(x)];
  }
};

int main(){
  int N,M;
  cin >> N >> M;

  UnionFind UF(N);
  for (int i=0; i<M; i++){
    int a,b;
    cin >> a >> b;
    UF.unite(a,b);
  }

  int ans=0;
  for (int i=0; i<N; i++){
    ans=max(ans, UF.size(i));
  }

  cout << ans << endl;
}

Measured memory_bytes: 3568
s = input()
 
a=int(s[0]+s[1])
b=int(s[2]+s[3])
 
if 0<a<=12 and 0<b<=12:
  print("AMBIGUOUS")
elif 0<=a<=99 and 0<b<=12:
  print("YYMM")
elif 0<a<=12 and 0<=b<=99:
  print("MMYY")
else:
  print("NA")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rint register int
#define IL inline
#define rep(i,h,t) for (rint i=h;i<=t;i++)
#define dep(i,t,h) for (rint i=t;i>=h;i--)
#define me(x) memset(x,0,sizeof(x))
#define mid ((h+t)>>1)
#define ll long long
const int N=2e5;
const int N2=2e7;
const int INF=1e9;
int a[N],b[N],n,m;
char ss[1<<24],*A=ss,*B=ss;
IL char gc()
{
  return A==B&&(B=(A=ss)+fread(ss,1,1<<24,stdin),A==B)?EOF:*A++;
}
template<class T>void read(T &x)
{
  rint f=1,c; while (c=gc(),c<48||c>57) if (c=='-') f=-1; x=(c^48);
  while (c=gc(),c>47&&c<58) x=(x<<3)+(x<<1)+(c^48); x*=f; 
}
struct sgt{
  int ls[N2],rs[N2],data[N2],cnt;
  void clear()
  {
 //   me(ls); me(rs); me(data); 
      cnt=0;
  }
  void insert(int &x,int h,int t,int pos,int k)
  {
    if (!x)
    { 
      x=++cnt;
      ls[x]=rs[x]=data[x]=0;
    }
    data[x]+=k;
    if (h==t) return;
    if (pos<=mid) insert(ls[x],h,mid,pos,k);
    if (pos>mid) insert(rs[x],mid+1,t,pos,k); 
  }
  int find(int x,int h,int t,int h1,int t1)
  {
    if (!x) return 0;
    if (h1<=h&&t<=t1) return(data[x]);
    int ans=0;
    if (h1<=mid) ans+=find(ls[x],h,mid,h1,t1);
    if (mid<t1) ans+=find(rs[x],mid+1,t,h1,t1);
    return(ans);
  }
}S;
IL int check(int x)
{
  S.clear();
  rint root=0;
  S.insert(root,-n,n,0,1);
  register ll cnt1=0,cnt2=0;
  rep(i,1,n)
  {
    if (a[i]>=x) b[i]=b[i-1]+1;
    if (a[i]<x) b[i]=b[i-1]-1;
    cnt2+=S.find(root,-n,n,-n,b[i]);
    cnt1+=S.find(root,-n,n,b[i]+1,n);
    S.insert(root,-n,n,b[i],1);
  }
  if (cnt1>cnt2) return(-1);
  else return(1);
}
int main()
{
  int maxa=-INF,mina=INF;
  read(n);
  rep(i,1,n)
  {
    read(a[i]);
    mina=min(mina,a[i]);
    maxa=max(maxa,a[i]);
  }
  int h=mina,t=maxa;
  while (h<t)
  {
    int mid2=(h+t+1)/2;
    int tmp=check(mid2);
    if (tmp>0) h=mid2;
    else t=mid2-1;
  }
  cout<<h<<endl;
  return 0;
}

Measured memory_bytes: 9088
package main

import "fmt"

func main() {
	var x int
	fmt.Scan(&x)

	ans := 1
	for i := 2; i*i <= x; i++ {
		j := i
		for {
			j *= i
			if j > x {
				break
			}
			ans = max(ans, j)
		}
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 512
n,m = gets.split.map(&:to_i)
ar = gets.split.map(&:to_i).sort
sets = []
m.times do
  sets << gets.split.map(&:to_i)
end

sets.sort_by!{|a,b| -b}

sets.each do |a,b|
  a.times do
    if ar[0] < b
      ar.shift
      ar << b
    else
      break
    end
  end
end

puts ar.inject(&:+)

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

#define ll long long int
#define INFTY (1<<21)

using namespace std;

int main(void){
    cin.sync_with_stdio(false);
    int N;
    cin>>N;
    bool ans = true;
    for(int i = 0; i < N; i++){
        int a;
        cin>>a;
        ans = ans & (a % 2 == 0);
    }
    cout<<(ans?"second":"first")<<endl;
    return 0;
}

Measured memory_bytes: 256
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string S = Console.ReadLine();
            char[] a = S.ToCharArray();
            Array.Sort(a);
            Console.WriteLine(a[0] == 'a' && a[1] == 'b' && a[2] == 'c' ? "Yes" : "No");
        }
    }
}

Measured memory_bytes: 13396
#!/usr/bin/env python3
S, T = input().split()
A, B = input().split()
U = input()

def main(x1, x2, y1, y2, z):
    if (z == x1):
        y1 = int(y1) - 1 
    elif(z == x2):
        y2 = int(y2) - 1
    else:
        pass
    print(str(y1) + " " + str(y2))

main(S, T, A, B, U)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    long long int d;
    cin>> n >> d;
    int ans=0;
    long long int x,y;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        if(x*x+y*y<=d*d)ans++;
    }
    cout << ans;
}

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

namespace NotFounds
{
    public class Program
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            new Program().Solve(new ConsoleInput(Console.In, ' '));
            Console.Out.Flush();
        }

        public void Solve(ConsoleInput cin)
        {
            checked
            {
                var A = cin.ReadInt;
                var B = cin.ReadInt;
                var C = cin.ReadInt;

                var set = new HashSet<int>();
                for (int i = A; i < Min(B, A + C); ++i)
                    set.Add(i);
                for (int i = Max(A, B - C + 1); i <= B; ++i)
                    set.Add(i);
                set.OrderBy(x => x).ToList().ForEach(WriteLine);
            }
        }
    }

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


Measured memory_bytes: 13536
#include<iostream>
#include<string>
#include<algorithm>
#include<functional>
#include<cmath>
#include<stack>
#include<vector>

using namespace std;

int L[109];

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

	sort(begin(L), begin(L) + N);
	
	for (int i = 0; i < N - 1; i++)
	{
		L[N - 1] -= L[i];
	}

	if (L[N - 1] < 0)
	{
		cout << "Yes" << endl;
	}
	else
		cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define MAX(X,Y) (*max_element(X,Y))
#define MIN(X,Y) (*min_element(X,Y))
#define NP(X,Y) next_permutation(X,Y)
#define setp(X,Y) cout<<fixed<<setprecision(Y)<<X;
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int B[110];
int A[110];

signed main(){
	cin>>N;
	REP(i,N-1){
		cin>>B[i];
	}
	A[0]=B[0],A[N-1]=B[N-2];
	for(int i=1;i<N-1;i++){
		A[i]=min(B[i-1],B[i]);
	}
	int ans=0;
	REP(i,N){
		ans+=A[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
w, h, n=gets.split.map &:to_i

i, j=0, 0
n.times do
    x, y, a=gets.split.map &:to_i
    case a
        when 1 then j=[[j, x].max, w].min
        when 2 then w=[[w, x].min, j].max
        when 3 then i=[[i, y].max, h].min
        when 4 then h=[[h, y].min, i].max
    end
end

puts [(w-j)*(h-i), 0].max

Measured memory_bytes: 1788
#include <stdio.h>
#include <algorithm>
#include <iostream>

using namespace std;

class Heap{
public:
	Heap(){
		array = new int[2000000];
		n = 0;
	}
	void insert(int data){
		array[n] = data;
		int tmp = n;
		while(tmp != 0 && array[tmp] > array[(tmp-1)/2]){
			std::swap(array[tmp], array[(tmp-1)/2]);
			tmp = (tmp-1)/2;
		}
		n++;
	}
	int extract(){
		int ret = array[0];
		n--;
		std::swap(array[0],array[n]);
		int tmp = 0;
		while(2*tmp+1 <= n-1){
			if(2*tmp+2 <= n-1){
				if(array[2*tmp+2] > array[tmp] && array[2*tmp+2] >= array[2*tmp+1]){
					std::swap(array[2*tmp+2],array[tmp]);
					tmp = 2*tmp+2;
				}else if(array[2*tmp+1] > array[tmp] && array[2*tmp+1] >= array[2*tmp+2]){
					std::swap(array[2*tmp+1],array[tmp]);
					tmp = 2*tmp+1;
				}else{
					break;
				}
			}else{
				if(array[tmp] < array[2*tmp+1]){
					std::swap(array[tmp],array[2*tmp+1]);
					tmp = 2*tmp+1;
				}else{
					break;
				}
			}
		}
		return ret;
	}

private:
	int* array;
	int n;
};

int main(){

	int insert_data;
	char buf[22];
	Heap heap;

	while(true){
		fgets(buf,22,stdin);
		if(buf[2] == 'd') break;
		if(buf[0] == 'i'){
			insert_data = 0;
			for(int i = 0; buf[i] != '\0';i++){
				if(buf[i] >= '0' && buf[i] <= '9'){
					insert_data = 10*insert_data + (buf[i] - '0');
				}
			}
			heap.insert(insert_data);
		}else{
			printf("%d\n",heap.extract());
		}
	}
}



Measured memory_bytes: 6924
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<climits>
#include<cassert>
#include<iostream>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<bitset>

#define rep(n) for(int i=0;i<n;i++)
#define repp(j, n) for(int j=0;j<n;j++)
#define reppp(i, m, n) for(int i=m;i<n;i++)
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define MOD 1000000007
#define EPS 1e-9
 
using namespace std;

typedef long long ll;
typedef pair<ll, ll> Pll;
typedef pair<int, int> Pii;
struct edge{int from, to; ll cost;};

int main(){
    int n; ll v, ans = 0;
    cin >> n >> v;

    ll a[4][n];
    rep(4) repp(j, n) cin >> a[i][j];
    vector<ll> vec;
    rep(n){
        repp(j, n){
            vec.push_back(a[0][i]+a[1][j]);
        }
    }

    sort(all(vec));

    rep(n){
        repp(j, n){
            ll x = v-a[2][i]-a[3][j];
            ans += (ll)(upper_bound(all(vec), x) - lower_bound(all(vec), x));
        }
    }

    cout << ans << endl;

}



Measured memory_bytes: 11148
#include <iostream>
using namespace std;
int main(void){
    int n,a[100] = {0}; //100個
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
    
    }
    
    for(int i = n-1; i >= 0; i--){
        if(i == n-1){
            cout << a[i];
        }
        else{
            cout << " " << a[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 3004
#include<bits/stdc++.h>
//by Davidshx
using namespace std;
int n;
long long k,a[200100],f[200100],le,ri,mx,kk,mi;
int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>f[i];
	sort(a+1,a+n+1);sort(f+1,f+n+1);reverse(f+1,f+n+1);
	for(int i=1;i<=n;i++) mx=max(a[i]*f[i],mx);
	le=0;ri=mx;
	while(le<ri){
		kk=k;mi=(le+ri)/2LL;
		for(int i=1;i<=n;i++) if(a[i]*f[i]>mi) kk-=(a[i]-mi/f[i]);
		if(kk<0LL) le=mi+1LL; else ri=mi; 
	}
	cout<<le<<endl;
	return 0;
}


Measured memory_bytes: 3328
H, W = map(int, input().split())
C = []
V = 10
ctr = [0 for _ in range(V)]

for _ in range(V):
	C.append(list(map(int, input().split())))
	
for _ in range(H):
	A = list(map(int, input().split()))
	for i in range(W):
		if A[i] != -1:
			ctr[A[i]] += 1
			
for k in range(V):
	for i in range(V):
		for j in range(V):
			if C[i][j] > C[i][k] + C[k][j]:
				C[i][j] = C[i][k] + C[k][j]
				
ans = 0
for i in range(V):
	ans += ctr[i] * C[i][1]
	
print(ans)

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

void maxHeapify(int H[],int n,int i){
    int largest=i;
    if(i*2<=n&&H[largest]<H[i*2])largest=i*2;
    if(i*2+1<=n&&H[largest]<H[i*2+1])largest=i*2+1;
    if(largest!=i){
        swap(H[i],H[largest]);
        maxHeapify(H,n,largest);
    }
    return;
}

void buildHeap(int H[],int n){
    for(int s=n/2;s>=1;s--)maxHeapify(H,n,s);
    return;
}

int main(){
    int n;cin>>n;
    int Heap[n+1];
    rep(i,n)scanf("%d",&Heap[i+1]);
    buildHeap(Heap,n);
    rep(i,n)printf(" %d",Heap[i+1]);
    printf("\n");
}


Measured memory_bytes: 5048
/*
 * main.c
 *
 *  Created on: 2020/03/28
 *      Author: family
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a > b ? b : a)
typedef long long int ll;
typedef unsigned long long int ull;

int sort_inc(const void *a, const void *b) { return (*(int*)a - *(int*)b);}
int sort_dec(const void* a, const void* b) { return (*(int*)b - *(int*)a);}
int sort_dec_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = -1; }
    else if (da == db) { val = 0; }
    else { val = 1; }
    return val;
}
int sort_inc_ll(const void *a, const void *b) {
    ll da = *(ll*)a, db = *(ll*)b;    int val = 0;
    if(da > db) { val = 1; }
    else if (da == db) { val = 0; }
    else { val = -1; }
    return val;
}
int sort_dic(const void *a, const void *b) {
    char *pa = (char *)a;    char *pb = (char *)b;    int i = 0, val = 0, N = 10;
    for (i = 0; i < N; i++) {
    	char da = pa[i], db = pb[i];
    	if (da == db) continue;
  		if (da > db) val = 1; else val = -1;
        break;
    }
    return val;
}

void yesno(int ans) {
	if (ans == 1) { printf("Yes\n");
	} else { printf("No\n"); }
	return;
}

int A[10001] = {0};

int main()
{
	int N = 0, M = 0, ans = -1;
	int i = 0, hw = 0;
	scanf("%d %d", &N, &M);
	for (i = 0; i < M; i++) {
		scanf("%d", &A[i]);
	}

	for (i = 0; i < M; i++) {
		hw += A[i];
	}

	if (hw <= N) {
		ans = N - hw;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1740
N,H=map(int,input().split())
a=[0]*N
b=[0]*N
for i in range(N):
    a[i],b[i]=map(int,input().split())

a.sort(reverse=True)
for i in range(N):
    if b[i]<=a[0]:
        b[i]=a[0]
b.sort(reverse=True)

ans=0
for g in range(N):
    H-=b[g]
    ans+=1
    if H<=0:
        print(ans)
        exit()

if H%a[0]==0:
    print(H//a[0]+ans)
else:
    print(H//a[0]+ans+1)

Measured memory_bytes: 11312
import java.util.Scanner;
import java.util.regex.*;
import java.math.*;

public class Main {
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		//int a = sc.nextInt();
		// スペース区切りの整数の入力
		//int b = sc.nextInt();
		//int c = sc.nextInt();
		// 文字列の入力
		//String s = sc.next();
		//1文字ずつ
		//s.atChar(i);
		// 出力
		//System.out.println("");
		//double countx=0;
		int n=sc.nextInt();
		
		for(int i=111;i<1000;i=i+111){
			if(n<=i){
				System.out.println(i);
				System.exit(0);
			}
		}
	}
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> h(N);
    for (int i = 0; i < N; i++) cin >> h[i];

    sort(h.begin(), h.end());

    int ans = 1001001001;
    for (int i = 0; i + K - 1 < N; i++) {
        ans = min(ans, h[i + K - 1] - h[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 640
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  k <- getInt
  [a, b] <- getIntList
  let x = (a + k - 1) `div` k
  if x * k <= b
    then putStrLn "OK"
    else putStrLn "NG"

Measured memory_bytes: 3744
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
#define MAXN 200100
#define ll long long
ll n, m, has[MAXN], p1 = 1009, p2 = 998244353, len[MAXN];
char s[110];
int main()
{
	scanf("%lld",&n);
	for(ll i=1;i<=n;i++)
	{
		scanf("%s",s+1);
		len[i] = strlen(s+1);
		for(ll j=1;j<=len[i];j++)
			has[i] = (has[i]*p1 + s[j]);
	}
	sort(has+1,has+n+1);
	int	ans = 1;
	for(int i=2;i<=n;i++)
	{
		if(has[i] != has[i-1]) ans++;
	}
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
#define fo(i,a,b) for(int i=(a);i<(b);i++)
#define MOD 1000000007
#define MP make_pair
#define PB push_back
typedef long long ll;

string s;

int main () {
        cin >> s;
        int N = (int) s.size();
        if (s[0] == s.back()) {
                //final state odd
                if (N&1) puts("Second");
                else puts("First");
        } else {
                //final state even
                if (N&1) puts("First");
                else puts("Second");
        }
        return 0;
}


Measured memory_bytes: 512
n, m = map(int, input().split())
h_list = list(map(int, input().split()))
min_list = [1] * n

for _ in range(m):
    a, b = map(lambda x : int(x) - 1, input().split())
    if h_list[a] <= h_list[b]:
        min_list[a] = 0
    if h_list[b] <= h_list[a]:
        min_list[b] = 0

print(sum(min_list))

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

string acgt = "ACGT";

bool check(char c) {
  for (int i = 0; i < 4; i++)
  {
    if (c == acgt[i]) return true;
  }
  return false;
}

int main(){
  int N;
  cin >> N;
  int cnt =0;
  for (int i = 1; i < N+1; i++)
  {
     if (to_string(i).size()%2!=0) {
       cnt ++;
     }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mod 1000000007
using namespace std;
int read();
void Add(int &x, int y) { (x += y) >= mod ? x -= mod : x; }
int f[302][302][302];
struct P {
    int l, x;
};
vector<P> p[302];

bool check(int a, int b, int c) {
    for (int i = 0; i < p[a].size(); ++i)
        if (1 + (b >= p[a][i].l) + (c >= p[a][i].l) != p[a][i].x) return 0;
    return 1;
}

int main() {
    int n = read(), m = read();
    for (int i = 1, l, r, x; i <= m; ++i) {
        l = read(), r = read(), x = read();
        if (r - l + 1 < x) return puts("0"), 0;
        p[r].push_back((P){l, x});
    }

    f[1][0][0] = 1;
    for (int i = 1; i < n; ++i) {
        if (check(i, 0, 0))
            Add(f[i + 1][0][0], f[i][0][0]), Add(f[i + 1][i][0], f[i][0][0]);
        for (int j = 1; j < i; ++j) {
            for (int k = 0, x; k < j; ++k) {
                if (!check(i, j, k)) continue;
                Add(f[i + 1][j][k], f[i][j][k]);
                Add(f[i + 1][i][k], f[i][j][k]);
                Add(f[i + 1][i][j], f[i][j][k]);
            }
        }
    }
    long long c[4];
    c[0] = 6, c[1] = 6;
    int res = 0;
    if (check(n, 0, 0)) res = 3ll * f[n][0][0] % mod;
    for (int j = 1; j < n; ++j)
        for (int k = 0; k < j; ++k)
            if (check(n, j, k)) Add(res, c[(!j) + (!k)] * f[n][j][k] % mod);
    printf("%d\n", res);
    return 0;
}

int read() {
    int x = 0, f = 1;
    char c = getchar();
    while (c < '0' || c > '9') f = (c == '-') ? -1 : f, c = getchar();
    while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
    return x * f;
}


Measured memory_bytes: 105472
local sheng = io.read("*n")
local shi = io.read("*n")

local tab = {}
local tab1 = {}
local t = {}

for i=1,shi do
	local s1 = io.read("*n")
	local s2 = io.read("*n")
	if not tab[s1] then
		tab[s1] = {}
	end
	table.insert(tab[s1], {s1, s2, i})
	tab1[s1] = true
end

for v,_ in pairs(tab1) do
	table.sort(tab[v], function(a,b)
		return a[2] < b[2]
	end)
	for i,v in ipairs(tab[v]) do
		t[v[3]] = string.format("%06d%06d", v[1], i)
	end
end

for i,v in ipairs(t) do
	print(v)
end

Measured memory_bytes: 36172
#include<stdio.h>

int main(){
  int a,b,re;
  char op;
  while(1){
    re = 0;
    scanf("%d %c %d",&a,&op,&b);
    if(op == '+'){
      re = a + b;
      printf("%d\n",re);
    }else if(op == '-') {
      re = a - b;
      printf("%d\n",re);
    }else if(op == '*'){
      re = a * b;
      printf("%d\n",re);
    }else if(op == '/'){
      re = a / b;
      printf("%d\n",re);
    }else if(op == '?'){
      break;
    }
  }
  return 0;
}

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

int main() {
	int m, f,r;
	while(true){
		cin>>m>>f>>r;
		if(m==-1 && f==-1 && r==-1) break;
		else if(m==-1 || f==-1) cout<<"F"<<endl;
		else if(m+f >= 80) cout<<"A"<<endl;
		else if(m+f >= 65 && m+f<80) cout<<"B"<<endl;
		else if(m+f >= 50 && m+f<65) cout<<"C"<<endl;
		else if(m+f >= 30 && m+f<50 && r>=50) cout<<"C"<<endl;
		else if(m+f >= 30 && m+f<50 && r<50) cout<<"D"<<endl;
		else if(m+f < 30) cout<<"F"<<endl;
		else cout<<"?"<<endl;
	}



	return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
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; }

ll gcd(ll x, ll y)
{
    ll temp;
    while (y != 0) {
        temp = y;
        y = x % y;
        x = temp;
    }
    return (x);
}

set<ll> v;

void decom(ll n)
{
    // 割る数の初期値
    ll a = 2;
    // √n ≧ a ( n ≧ a * a ) の間ループ処理
    while (n >= a * a) {
        // a で割り切れたら、a は素因数
        // そして、割られる数を a で割る
        // a で割り切れなかったら、 a を 1 増加させる
        if (n % a == 0) {
            v.insert(a);
            // cout << a << endl;
            n /= a;
        } else {
            a++;
        }
    }
    // 最後に残った n は素因数
    v.insert(n);
    // cout << n << endl;
}

int main() {
  ll a,b;
  cin >> a >> b;

  ll GCDab = gcd(a,b);

  decom(GCDab);

  v.insert(1);

  // cout << "test" << endl;

  cout << SZ(v) << endl;






}



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

int main(){
	int a,b;

	while(1){
		cin >> a >> b ;
		if ( a == 0 && b == 0 ) break;

		if ( a < b ){
			cout << a << " " << b << endl ;
		} else {
			cout << b << " " << a << endl ;
		}
	}

	return 0;
}

Measured memory_bytes: 3056
/////////////////////////////////////////////////
/////             Give me AC!!!!            /////
/////////////////////////////////////////////////
//↑これじゃ気合いが足りない！
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/////             お願いしますACをくださいそうじゃないと僕泣きますお願いしますACをくださいJudge様....            /////
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const int MOD = 1000000007;
const int MAX = 100000;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
ld rad(ld a) {return a * 180 / PI;}
const int dx[4] = {1, 0, -1, 0};//2次元グリッド上のx軸方向
const int dy[4] = {0, 1, 0, -1};//2次元グリッド上のy軸方向

struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};

map<ll,ll> factorize_list;

void prime_factorize(ll N) {
    for (ll a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        ll ex = 0; // 指数

        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }

        // その結果を push
        factorize_list[a] = ex;
    }

    // 最後に残った数について
    if (N != 1) factorize_list[N] = 1;
    return ;
}

//dpTable
vector<ll> dp(100,MAX);

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

ll mod(ll val, ll m) {
  ll res = val % m;
  if (res < 0) res += m;
  return res;
}

long long fac[MAX], finv[MAX], inv[MAX];

char upper(char c){
    if('a' <= c && c <= 'z'){
        c = c - ('a' - 'A');
    }
    return c;
}
char lower(char c){
    if('A' <= c && c <= 'Z'){
        c = c + ('a' - 'A');
    }
    return c;
}

const ll INF = 10000000000;
struct edge{ll to, cost;};

int main(){
    int N;
    cin >> N;
    vector<string> W(N);
    for (int i = 0; i < N; i++) cin >> W.at(i);
    bool ans = true;
    for (int i = 0; i < N - 1; i++) {
        if (W.at(i).at(W.at(i).size() - 1) != W.at(i + 1).at(0)) ans = false;
    }
    sort (W.begin(),W.end());
    for (int i = 0; i < N - 1; i++) {
        if (W.at(i) == W.at(i + 1)) ans = false;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for (int (i) = 0; (i) < (n); i++)
#define ll long long
using namespace std;
int main() {
  ll N = 0, M = 0;
  cin >> N >> M;
  if(N > 0){
    cout << "Positive";
  }
  else if(N == 0 || M == 0){
    cout << "Zero";
  }
  else if(N < 0 && M > 0){
    cout << "Zero";
  }
  else{
    if((M-N)%2 == 0){
      cout << "Negative";
    }
    else{
      cout << "Positive";
    }
  }
}

Measured memory_bytes: 3576
n,m=map(int,input().split())
l=list(map(int,input().split()))
count=0
if l[0]>m:
  count+=-m+l[0]
  l[0]=m
for i in range(1,n):
  if l[i-1]+l[i]>m:
    count+=l[i]+l[i-1]-m
    l[i]=m-l[i-1]   
print(count)


Measured memory_bytes: 14540
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>

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

void solve()
{
	long long int x, y, x_buf;
	cin >> x >> y;
	long long int ans = 1e10;
	x_buf = x;
	if (y >= x)
	{
		ans = min(ans, y - x);
	}
	x = -x;
	if (y >= x)
	{
		ans = min(ans, y - x + 1);
	}
	x = x_buf;
	y = -y;
	if (y >= x)
	{
		ans = min(ans, y - x + 1);
	}
	x = -x;
	if (y >= x)
	{
		ans = min(ans, y - x + 2);
	}
	cout << ans << endl;
}

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

Measured memory_bytes: 256
#include<cstdio>
#define MOD 1000000007
#define f(i,n) for(long long i=0;i<(long long)(n);i++)


int main(){
long long a,b,c,x,n;
scanf("%lld",&n);
a=1;
b=n;
c=n*n;
c=c%MOD;
if(n==1){
printf("1\n");
return 0;
}
f(i,n-2){
x=(2*c)-b+a-1;
x=(x+MOD)%MOD;
a=b;
b=c;
c=x;
}
printf("%lld\n",c);
return 0;
}

Measured memory_bytes: 128