akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

using namespace std;

int main() {
  int N;
  cin >> N;
  vector<int> V(N), C(N);
  for (int i = 0; i < N; i++) cin >> V[i];
  for (int i = 0; i < N; i++) cin >> C[i];
  int ret = 0;
  for (int i = 0; i < N; i++) {
    int d = V[i] - C[i];
    if (0 < d) ret += d;
  }
  cout << ret << endl;
}


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

char s[10][10];
int main() {
	int h, w; scanf("%d%d", &h, &w);
	rep(i, h)scanf("%s", s[i]);
	puts(count(s[0], s[10], '#') == h + w - 1 ? "Possible" : "Impossible");
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	long int D,c[26],i,j;
	scanf("%ld",&D);
	for(i=0;i<26;i++){
		scanf("%ld",&c[i]);
	}
	long int s[D][26];
	for(i=0;i<D;i++){
		for(j=0;j<26;j++){
			scanf("%ld",&s[i][j]);
		}
	}
	
	long int v[D],w[26],t[D],score=0,day[26],k,temp[26],l;
	for(i=0;i<26;i++){
	day[i]=-1;
	}
	
	for(i=0;i<D;i++){
		v[i]=0;
		for(j=0;j<26;j++){
			for(l=0;l<26;l++){
				temp[l]=day[l];
			}
			w[j]=0;
			w[j] += s[i][j];
			temp[j] = i;
			for(k=0;k<26;k++){
				w[j] -= c[k]*(i - temp[k]);
			}
			if(v[i]<w[j]){
			v[i]=w[j];
			t[i]=j;
			}
		}
		day[t[i]]=i;
		score += v[i];
		printf("%d\n",++t[i]);
	}
	return 0;
}

Measured memory_bytes: 1812
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
 
#define rng(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
 
int main() {
  int n, a, b, c, k, ans = 0;
  cin >> a >> b >> c >> k;
  //vector<int> v(n), c(n)
  if(a + b >= k){
    cout << min(a, k) << endl;
  }
  else{
    cout << a - (k - a - b) << endl;
  }
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    unordered_map<string,int> m;
    string temp;
    for(int i=0;i<n;i++){
        cin>>temp;
        m[temp]=1;
    }
    cout<<m.size()<<"\n";
    return 0;
}

Measured memory_bytes: 17664
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;

int main(){
  string S;cin >>S;
  cout << S.substr(0,S.length()-8) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N, x[500];
int a[250000];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", x + i), x[i]--;
	
	memset(a, -1, sizeof(a));
	
	priority_queue<pii> pq;
	REP(i, N) {
		pq.push(pii(-x[i], i));
		a[x[i]] = i;
	}
	
	bool ok = true;
	
	int p = 0;
	while (!pq.empty() && ok) {
		int last = -pq.top().fi;
		int num = pq.top().se;
		pq.pop();
		int cnt = num;
		
		while (p < last && cnt > 0) {
			while (p < last && a[p] != -1) p++;
			if (p >= last) break;
			a[p] = num;
			cnt--;
		}
		if (cnt > 0) ok = false;
	}
	
	REP(i, N) pq.push(pii(x[i], i));
	
	p = N * N - 1;
	while (!pq.empty() && ok) {
		int last = pq.top().fi;
		int num = pq.top().se;
		pq.pop();
		int cnt = N - num - 1;
		
		while (p > last && cnt > 0) {
			while (p > last && a[p] != -1) p--;
			if (p <= last) break;
			a[p] = num;
			cnt--;
		}
		if (cnt > 0) ok = false;
	}
	
	
	if (ok) {
		puts("Yes");
		REP(i, N * N) printf("%d%c", a[i] + 1, i == N * N - 1 ? '\n' : ' ');
	}
	else {
		puts("No");
	}
	
	return 0;
}

Measured memory_bytes: 2176
import java.util.*;
public class Main {
public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	String str = sc.next();
  	int len = str.length();
  	char[] c = new char[len];
	char c1 = str.charAt(0);
  	char c2 = str.charAt(1);
  	char c3 = str.charAt(2);
  	
  	if((c1=='A')&&(c2=='A')&&(c3=='A')){
      System.out.println("No");
    }else if((c1=='B')&&(c2=='B')&&(c3=='B')){
      System.out.println("No");
    }else{
      System.out.println("Yes");
    }
	}
}

Measured memory_bytes: 23764
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<vector>
#define SF scanf
#define PF printf
#define MAXN 60
#define MOD 1000000007
using namespace std;
typedef long long ll;
ll dp[MAXN][MAXN],c[MAXN][MAXN]; 
int n;
int main(){
	SF("%d",&n);
	for(int i=0;i<=n;i++)
		for(int j=0;j<=i;j++){
			if(j==0)
				c[i][j]=1;
			else
				c[i][j]=(c[i-1][j-1]+c[i-1][j])%MOD;
		}
	dp[1][n]=1;
	dp[1][n-1]=1;
	for(int i=1;i<n;i++)
		for(int j=-i;j<=i;j++){
			for(int sum=max(1,abs(j));sum<=n;sum++){
				if(i+sum>n||(sum+j)%2)
					continue;
				for(int pos=0;pos<=sum;pos++){
					int t=sum-pos;
					int val=(j+pos-t)/2;
					if(val<-n||val>n)
						continue;
					dp[i+sum][val+n]+=dp[i][j+n]*c[i+sum][sum]%MOD*c[sum][pos]%MOD;
					dp[i+sum][val+n]%=MOD;
				}
			}
		}
	PF("%lld\n",dp[n][n]);
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

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

        int MAX = 10000001;
        int[] p = new int[MAX];
        for(int i=2; i<p.length; i++) p[i] = 1;
        for(int i=2; i<Math.sqrt(MAX)+1; i++){
            for(int j=i*2; j<MAX; j+=i){
                p[j] = 0;
            }
        }

        int[] num = {2,6,8};

        while(true){
            int n = sc.nextInt();
            if(n==0) break;

            int ans = 0;
            for(int i=n; i>=0; i--){
                if(p[i]==0) continue;
                boolean boo = true;
                for(int j=0; j<3; j++){
                    if(p[i-num[j]]==0){
                        boo = false;
                        break;
                    }
                }
                if(boo){
                    ans = i;
                    break;
                }
            }
            
            System.out.println(ans);
        }
    }

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

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

int a, b, c, k, s;
int main() {
	cin >> a >> b >> c >> k;
	s = min(a, k);
	if(a+b < k) s -= min(c, k - a - b);
	cout << s;
	return 0;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
*/
#define TRACE
#ifdef TRACE
#define trace(...) { cerr<<"[ "; __trace__(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.first<<","<<x.second<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
void __trace__(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void __trace__(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    __trace__(names.substr(1+(int)name.size()), args...);
}
#else
    #define trace(args...)
#endif
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vll;
typedef vector<vl> vvl;
//typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
#define fori(i,n) for(int i=0;i<n;i++)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repd(i,a,b) for(int i=a;i>=b;i--)
#define ford(i,n)  for(int i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define pb push_back
#define endl '\n'
#define sz(a) (int)a.size()
#define fi first
#define se second
clock_t time_p=clock();
void time_taken()
{
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
//const ll mod=998244353;
const ll mod=1e9+7;
const ll INF=1e18;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    cout.precision(12);cout << fixed;
    int m[2],d[2];
    fori(i,2) cin >> m[i] >> d[i];    
    int ans;
    if(m[0] == m[1]) ans = 0;
    else ans = 1;
    cout << ans << endl;



    time_taken();
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char s[101];
int main()
{
    scanf("%s", s);
    int res=0;
    int n=strlen(s);
    for (int i=0;i<n;i++) {
        if(s[i]!=s[n-1-i])
            res++;
        }
    printf("%d\n",res/2);
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <climits>
using namespace std;

using Int = long long int;
using UInt = unsigned long long int;

int main(void) {
    Int n;
    cin >> n;
    Int sq = sqrt(n);

    Int ans = INT_MAX;
    for (Int i = 1; i <= sq; ++i) {
        if (n % i != 0) {
            continue;
        }
        Int len = to_string(max(i, n / i)).length();
        ans = min(ans, len);
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;
using ll = long long;
using ull = unsigned long long;

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

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

  ull N;
  cin >> N;
  if (N%2) {
    cout << N*2 << '\n';
  } else {
    cout << N << '\n';
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>

int main(void)
{
    uint32_t H, W;
    uint32_t i;
    uint32_t min = 0, max;
    uint32_t possible = 1;
    scanf("%u %u\n", &H, &W);
    max = W-1;

    for (i = 0; i < H; i++) {
        char c;
        uint32_t found = 0;
        uint32_t found_then_not_found = 0;
        uint32_t x = 0;
        while ((c = getchar()) != '\n') {
            if (!possible) continue;
            if (c == '#') {
                max = x;
            }
            if (found == 0 && c == '#') {
                found = 1;
                if (x < min) {
                    possible = 0;
                } 
            } else if (found_then_not_found == 1 && c == '#') {
                possible = 0;
            } else if (found == 1 && c == '.') {
                found_then_not_found = 1;
            }
            x++;
        }
        min = max;
    }

    if (possible) {
        printf("Possible\n");
    } else {
        printf("Impossible\n");
    }
    return 0;
}



Measured memory_bytes: 128
def calc_intersection(z1, z2, R):
  d2 = (z1[0]-z2[0])**2 + (z1[1]-z2[1])**2
  d = d2 ** 0.5
  if R < d/2:
    return None
  else:
    m = [(z1[0]+z2[0])*0.5, (z1[1]+z2[1])*0.5]
    l = (R**2/d2 - 0.25)**0.5
    v = [l*(z2[1]-z1[1]), l*(z1[0]-z2[0])]
    return [[m[0]+v[0], m[1]+v[1]], [m[0]-v[0], m[1]-v[1]]]


def check(R):
  intersections = []
  for i in range(N):
    for j in range(i+1, N):
      points = calc_intersection(xy[i], xy[j], R)
      if points is None:
        return False
      else:
        intersections.extend(points)
  
  for px, py in intersections:
    res = True
    for x, y in xy:
      res *= ((x-px)**2 + (y-py)**2 <= R**2+0.000001)
      if not res:
        break
    if res:
      return True
  return False


N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
left = 0 # False
right = 500 * 2**0.5 # True
while right - left > 0.000001:
  mid = (left + right) / 2
  if check(mid):
    right = mid
  else:
    left = mid

print(right)

Measured memory_bytes: 3572
def main(a, b, c, d):
    if abs(a - c) <= d:
        print('Yes')
        exit()

    if abs(a - b) <= d and abs(b - c) <= d:
        print('Yes')
        exit()

    print('No')

if __name__ == '__main__':
    a, b, c, d = list(map(int, input().split(' ')))
    main(a, b, c, d)

Measured memory_bytes: 3060
n = int(input())
A = list(map(int, input().split()))

def partition(A, p, r):
    x = A[r]
    i = p-1
    for j in range(p, r):
        if A[j] <= x:
            i += 1
            A[i], A[j] = A[j], A[i]
    A[i+1], A[r] = A[r], A[i+1]
    return i+1

p = partition(A, 0, n-1)
for i in range(n):
    if i != 0:
        print(" ", end="")
    if i == p:
        print(f"[{A[i]}]", end="")
    else:
        print(A[i], end="")
print()


Measured memory_bytes: 16396
#include<bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<vector>
using namespace std;
int main()
{
    long long n,x,t; cin>>n>>x>>t;
    long long a = (n/x);
    if(n%x!=0)
        a++;
    cout<<a*t;
    return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
int main(){
    const long double pi = 3.14159265358979323846264338327950288419716939937510;
  	long double angle, hangle, mangle, a, b, h, m;
    cin >> a >> b >> h >> m;
    //times pi/180 for angle in radians
    mangle = 6*m;
    hangle = (h*60+m)/2;
    angle = abs(hangle - mangle);
  	cout << fixed << setprecision(10) << sqrt(pow(a,2)+pow(b,2)-2*a*b*cos(angle*pi/180)) << endl;
}

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

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

#define BR "\n"
#define SP " "

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  rep0(i, N) cin >> A[i];

  int M;
  cin >> M;
  vector<int> B(M);
  rep0(i, M) cin >> B[i];

  int ans = -1;
  rep0(i, min(N, M)) {
    if (ans != -1) break;
    if (A[i] < B[i]) ans = 1;
    if (A[i] > B[i]) ans = 0;
  }
  if (ans == -1) {
    if (N < M) ans = 1;
    else ans = 0;
  }

  cout << ans << BR;
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    map<int, int> m;
    int ansl = 0, ansm = 0;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        if (3200 <= a) ansm++;
        else if (++m[a / 400] == 1) ansl++;
    }
    cout << (!ansl ? 1 : ansl) << " " << ansl + ansm << endl;
}


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

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int[] x = cin.arrayInt();

        Array.Sort(x);

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

class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 11476
#include <bits/stdc++.h>
#define PI 3.14159265358979323846264338327950L
using namespace std;

int main(void) {
	double a, b, h, m;
	cin >> a >> b >> h >> m;

	h = 30 * h + (30*m/60);
	m *= 6;
	double nk = max(h, m) - min(h, m);
	if (nk > 180) nk = 360 - nk;
	nk = PI * nk / 180;

	double rsq = a * a + b * b - 2 * a * b * cos(nk);

	double ans = sqrt(rsq);
	cout << fixed << setprecision(20) << ans << endl;
}

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

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

using namespace std;

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

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

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

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

  ll n;
  cin >> n;
  vll as(n);
  ll asum = 0;
  rep(i, n) {
    cin >> as[i];
    asum += as[i];
  }

  vll difs(n);
  ll bsum = 0;
  rep(i, n) {
    ll b;
    cin >> b;
    difs[i] = b - as[i];
    bsum += b;
  }
  if(bsum > asum){
    puts("-1");
    return 0;
  }
  Sort(difs);

  ll idx = n - 1;
  ll fuso = 0;
  while (difs[idx] > 0) {
    fuso += difs[idx];
    idx--;
  }
  ll ans = n - 1 - idx;

  ll sum = 0;
  idx = 0;
  while (sum < fuso) {
    sum += -difs[idx];
    idx++;
  }
  ans += idx;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
N,D,A=map(int,input().split())
XH=[]
for _ in range(N):
  x,h=map(int,input().split())
  XH.append([x,h])
XH=sorted(XH, key=lambda x:x[0])
X=[XH[i][0] for i in range(N)]
H=[XH[i][1] for i in range(N)]
from math import ceil
from bisect import bisect_right
imos=[0]*(N+1)
hit=0
ans=0
for i in range(N):
  hit+=imos[i]
  restH=H[i]-hit*A
  if restH>0:
    ans+=ceil(restH/A)
    hit+=ceil(restH/A)
    ind=bisect_right(X,X[i]+2*D)
    imos[ind]-=ceil(restH/A)
print(ans)

Measured memory_bytes: 108320
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <iomanip>
#include <cmath>
using namespace std;

int main(){
	int a,b;
	string s,t,u;
	cin>>s>>t>>a>>b>>u;
	if(s==u){
		cout<<a-1<<" "<<b<<endl;
	}else{
		cout<<a<<" "<<b-1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
ostream& operator<<(ostream &out, string str) {
	for(char c : str) out << c;
	return out;
}
 
template<class L, class R> ostream& operator<<(ostream &out, pair<L, R> p) {
	return out << "(" << p.first << ", " << p.second << ")";
}
 
template<class T> auto operator<<(ostream &out, T a) -> decltype(a.begin(), out) {
	out << "{";
	for(auto it = a.begin(); it != a.end(); it = next(it))
		out << (it != a.begin() ? ", " : "") << *it;
	return out << "}";
}
 
void dump() { cerr << "\n"; }
template<class T, class... Ts> void dump(T a, Ts... x) {
	cerr << a << ", ";
	dump(x...);
}

#ifdef DEBUG
#  define debug(...) cerr << "[" #__VA_ARGS__ "]: ", dump(__VA_ARGS__)
#else
#  define debug(...) false
#endif
 
#define REP(i, n) for(int i = 0; i < n; i++)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define ST first
#define ND second
 
template<class T> int size(T && a) { return a.size(); }
 
using LL = long long;
using PII = pair<int, int>;

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

	int n;
	cin >> n;

	vector<int> in(n);
	REP(i, n) {
		char c;
		cin >> c;
		in[i] = c - '0';
	}

	bool any_2 = false;
	REP(i, n)
		if(in[i] == 2)
			any_2 = true;

	int ans = 1;
	if(!any_2) {
		ans = 2;
		REP(i, n) {
			if(in[i] == 3)
				in[i] = 1;
			else
				in[i] = 0;
		}
	}
	else {
		REP(i, n) in[i] %= 2;
	}

	vector<int> cnt(n);

	REP(i, n) {
		int x = i;
		while(x /= 2)
			cnt[i] += x;

		debug(i, cnt[i]);
	}

	auto choose_2 = [&](int k) {
		if(cnt[n - 1] > cnt[k] + cnt[n - 1 - k])
			return 0;
		else
			return 1;
	};

	int sum = 0;
	REP(i, n)
		sum += choose_2(i) * in[i];

	cout << (sum % 2 ? ans : 0) << "\n";

}


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

int main()
{
    lld N;
    cin >> N;

    for(lld i = 1; i <= 9; i++) {
        if(N % i == 0) {
            lld div = N / i;
            if(div >= 1 && div <= 9) {
                cout << "Yes\n";
                return 0;
            }
        }
    }
    cout << "No\n";
}

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

int N,A,X[51];

int main(){
	cin >> N >> A;
	int ma = A;
	for(int i=1;i<=N;i++){
		cin >> X[i];
		ma = max(A,X[i]);
		X[i] -= A;
	}
	long long dp[N+1][2*N*ma+1] = {{0}};
	for(int j=0;j<=N;j++){
		for(int t=0;t<=2*N*ma;t++){
			dp[j][t] = 0;
		}
	}
	dp[0][N*ma] = 1;
	//for(int t=0;t<=2*N*ma+1;t++) dp[0][t] = 1;
	//for(int j=0;j<=N;j++) dp[j][N*ma] = 1;
	for(int j=1;j<=N;j++){
		for(int t=0;t<=2*N*ma;t++){
			if(0<=t-X[j] && t-X[j]<=2*N*ma) dp[j][t] = dp[j-1][t]+dp[j-1][t-X[j]];
			else if(0<=t-X[j] || t-X[j]<=2*N*ma) dp[j][t] = dp[j-1][t];
		}
	}
	cout << dp[N][N*ma]-1 << endl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>
#include <fstream>
#include <cmath>
const int mod=1e9+7;
using LL=long long;
using std::cout;using std::endl;using std::cin;
using std::vector;using std::string;using std::set;using std::multiset;
using std::pair;using std::map;
using std::min;using std::max;
using std::make_pair;using std::swap;
std::ostream& operator<<(std::ostream& os,std::map<int,int>& obj){for(std::map<int,int>::iterator itr=obj.begin();itr!=obj.end();itr++){os<<itr->first<<"^"<<itr->second<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::map<int,int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<int>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<" ";}return os;}
std::ostream& operator<<(std::ostream& os,std::vector<std::vector<int>>& obj){for(auto itr=obj.begin();itr!=obj.end();itr++){os<<*itr<<std::endl;}return os;}

namespace ndifix{
template<class T> void sort(T &v){std::sort(v.begin(),v.end());}
template<class T> void rsort(T &v){std::sort(v.rbegin(),v.rend());}

}


int main(){
  int b;
  while(cin>>b){
    if(b==0)return 0;
    b*=2;
    vector<int> div;
    for(int i=1;i*i<=b;i++)if(b%i==0){div.push_back(i);div.push_back(b/i);}
    ndifix::rsort(div);
    for(int i=0;i<div.size();i++){
      int buf=b/div[i] - div[i]+1;
      if(buf>=2 && buf%2==0){cout<<buf/2<<" "<<div[i]<<endl;break;}
    }
  }
  return 0;
}



Measured memory_bytes: 3108
n,d=map(int,input().split())
x=[[int(i) for i in input().split()]for i in range(n)]

cnt=0
for i in range(n-1):
    for j in range(i,n):
        if i==j:
            pass

        else:
            ans=0

            for y,z in zip(x[i],x[j]):
                ans+=(y-z)**2
            if pow(ans,1/2) == ans//pow(ans,1/2):
                cnt+=1

print(cnt)

Measured memory_bytes: 3064
h, w, k = list(map(int, input().split()))

c = [list(input()) for _ in range(h)]
#print(c)


black = []
a = 0

for i in range(h):
    for j in range(w):
        if c[i][j] == "#":
            black.append((i, j))


for i in range(2 ** (h+w)):
    total = 0
    row = []
    col = []
    for j in range(h + w):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            if j < h:
                row.append(j)
            else:
                col.append(j - h)
    #print(row, col)

    #print(black)
    s = 0
    for r, c in black:
        #print(r, c, row, col)
        if (r not in row) and (c not in col):
            s += 1
        #print(s)

    if s == k:
        a += 1

print(a)




Measured memory_bytes: 9256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
multiset<ll> st;
#define rep(i,n) for(ll i=0;i<(ll)n;i++)

int main() {
  ll n,k,t;
  cin>>n>>k;
  vector<ll> a,b;
  rep(i,n){
    cin>>t;
    if(t<0){
      b.push_back(-t);
    }else{
      a.push_back(t);
    }
  }
  reverse(b.begin(),b.end());
  
  ll m1=a.size(),m2=b.size();
  ll min=10000000000,c;
  
  if(m1!=0&&m2!=0){
  for(ll i=1;i<k;i++){
    if(i-1<m1&&k-i-1<m2){
   		c=2*a[i-1]+b[k-i-1];
        if(c<min) min = c;
    }
  }
  
  for(ll i=1;i<k;i++){
    if(i-1<m2&&k-i-1<m1){
   		c=2*b[i-1]+a[k-i-1];
        if(c<min) min = c;
    }
  }
  }else{
    if(m1==0){
      min = b[k-1];
    }else{
	  min = a[k-1];
    }
  }
  
  
  cout<<min<<endl;
}
  	
  
  
  
    
    
    
    




Measured memory_bytes: 1656
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <math.h>
#include <utility>
#include <algorithm>
#include <functional>
#include <vector>
#include <numeric>
#include <bits/stdc++.h>

#define int long long

struct edge {
    int to;
    int cost;
};

using namespace std;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vb = vector<bool>;
using qi = queue<int>;
using P = pair<int, int>;
using graph = vector<vector<edge>>;
// using graph = vector<vector<int>>;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define REP(i,n) for(int i=0;i<n;i++)
#define delim(i, n) cout << (i == n-1 ? "\n" : " ");

const int inf = 1LL << 60;
// const int inf = 100000000;
const int mod = 1000000007;

const int maxn = 300000;
int h, w, m;
vi hh(maxn), ww(maxn);
set<P> bomb, nobomb;
vii table(maxn);

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

    cin >> h >> w >> m;
    hh.assign(h, 0);
    ww.assign(w, 0);
    REP(i, m) {
        P p; cin >> p.first >> p.second;
        p.first--; p.second--;
        hh[p.first]++; ww[p.second]++;
        bomb.insert(p);
    }
    int hmax = 0;
    int hcnt = 0;
    vi hmaxs(h);
    REP(i, h) {
        if (hh[i] > hmax) {
            hmaxs[0] = i;
            hcnt = 1;
            hmax = hh[i];
        } else if (hh[i] == hmax) {
            hmaxs[hcnt] = i;
            hcnt++;
        }
    }

    int wmax = 0;
    int wcnt = 0;
    vi wmaxs(w);
    REP(i, w) {
        if (ww[i] > wmax) {
            wmaxs[0] = i;
            wcnt = 1;
            wmax = ww[i];
        } else if (ww[i] == wmax) {
            wmaxs[wcnt] = i;
            wcnt++;
        }
    }

    int cnt = 0;
    if (hcnt * wcnt <= m) {
        for (auto b : bomb) {
            if(binary_search(hmaxs.begin(), hmaxs.begin()+hcnt, b.first) && binary_search(wmaxs.begin(), wmaxs.begin()+wcnt, b.second)) cnt++;
        }
    }
    if (cnt == hcnt*wcnt) wmax--;

    cout << hmax + wmax << "\n";
}

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

#pragma GCC optimize "O3"
#define rep(i,a,n) for(long long i=a; i<n; i++)
typedef long long ll;
typedef pair<int,int> P;
const ll MOD = (int)1e9+7;
const ll INF = MOD*MOD;
const double EPS = 1e-9;
const ll powll = 1LL<<1;

/*
while(!frag && cin >> a >>b, a|b)
*/

int main(void){
    int N,W; cin >> N >> W;
    int w[N], v[N];
    rep(i,0,N){
        cin >> w[i] >> v[i];
    }

    ll dp[N+1][W+1];
    rep(i,0,W+1){
        rep(j,0,N+1){
            dp[j][i] = 0;
        }
    }
    rep(i,0,N){
        rep(j,0,W+1){
            if(j -w[i] >= 0)
                dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
            else
                dp[i+1][j] = dp[i][j];
            //cout << dp[i+1][j] << " ";
        }
        //cout << "\n";
    }
    ll ans = 0;
    rep(i,0,W+1){
        ans = max(ans, dp[N][i]);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 82340
#include <stdio.h>
#include <algorithm>
#define SIZE 200005

  long long int tree[SIZE];
  int h[SIZE],a[SIZE];

  void update(int n, int x, long long int val) {
        while(x<=n) {
                tree[x] = std::max(tree[x], val);
                x += (x & -x);
        }
  }

  long long int query(int x) {
        long long int max = 0;

        while(x>0) {
                max = std::max(max, tree[x]);
                x -= (x & -x);
        }

        return max;
  }


  int main(void) {
        int n;
        scanf("%d",&n);

        for(int i=0; i<n; i++) scanf("%d",&h[i]);
        for(int i=0; i<n; i++) scanf("%d",&a[i]);

        for(int i=0; i<n; i++) update(n, h[i], query(h[i]-1) + a[i]);

        long long int ans = query(n);
        printf("%lld", ans);
        return 0;
  }










Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k,c;cin>>n>>k>>c;
  string s;cin>>s;
  lvector A,B;
  ll apos=0,bpos=n-1;
  while(A.size()<k&&apos<n) {
    if(s[apos]=='x') {apos++;continue;}
    if(A.size()==0||A.back()+c<apos) A.emplace_back(apos);
    apos++;
  }
  while(B.size()<k&&bpos>-1) {
    if(s[bpos]=='x') {bpos--;continue;}
    if(B.size()==0||B.back()-c>bpos) B.emplace_back(bpos);
    bpos--;
  }
  reverse(ALL(B));
  rep(i,k) if(A[i]==B[i]) print(A[i]+1);
  return 0;
}

Measured memory_bytes: 5128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
string alp="abcdefghijklmnopqrstuvwxyz";
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);


int main(){
    ll n,T;cin>>n>>T;
    ll t[n];rep(i,0,n-1)cin>>t[i];
    ll itumade=0;
    ll ans=0;
    rep(i,0,n-1){
        
        if(itumade<=t[i]){
            ans+=T;
            itumade=t[i]+T;
        }else{
            ans+=(T-(itumade-t[i]));
            itumade=t[i]+T;
        }
    }
    cout<<ans<<endl;
    
    return 0;
}






Measured memory_bytes: 1792
H, W = map(int, input().split())

def get_ans(A, B):
    ans = A * B
    for A1 in range(1, A):
        A2 = (A - A1) // 2
        A3 = A - A1 - A2
        S = [A1 * B, A2 * B, A3 * B]
        ans = min(ans, max(S) - min(S))

    for A1 in range(1, A):
        B2 = B // 2
        B3 = B - B2
        S = [A1 * B, (A - A1) * B2, (A - A1) * B3]
        ans = min(ans, max(S) - min(S))

    return ans

print(min(get_ans(H, W), get_ans(W, H)))


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    abc086(args)
    //tutorial(args)
}

fun abc086(args: Array<String>) {
    val (a, b) = readLine()!!.split(" ").map(String::toInt)

    if ((a * b) % 2 == 0) {
        println("Even")
    } else {
        println("Odd")
    }
}


Measured memory_bytes: 35948
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int kinds = IntStream.range(0, scanner.nextInt())
                .mapToObj(i -> scanner.nextInt())
                .collect(Collectors.groupingBy(k -> k))
                .size();

        System.out.println(kinds % 2 == 0 ? kinds - 1 : kinds);
    }
}


Measured memory_bytes: 66656
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.second < secondElof.second;
}
ll nod(ll F) { return log10(F) + 1; }
//**定義場所**//
//gcd, isPrime, eratos, modinv, bitSearch, dfs, bfs, dijkstra, UnionFind//
ll i, j, k, l, m, n; ll N, M, K, H, W, L; string S;
ll MOD = 1000000007; ll ans = 0; ll INF = 9999999999999;
vl flag, color; vll path;
//***********//
int main() {
	string S, T;
	cin >> S >> T;
	ll A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (S == U) {
		cout << A - 1 << " " << B;
	}
	else {
		cout << A << " " << B - 1;
	}
}


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

#define debug(var)  do{std::cerr << #var << " : ";view(var);}while(0)
template<typename T> void view(T e){std::cerr << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cerr << e << " "; } std::cerr << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }
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; }
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<ll> v1;
typedef vector<v1> v2;
typedef vector<v2> v3;

typedef unordered_map<ll, unordered_map<ll, ll>> graph;

const ll INF = 1ll << 50;
const ll mod = 1000000007;

ll t;
ll n;
ll a,b,c,d;

void add(ll y, ll cost, unordered_map<ll,ll>& m, priority_queue<ll>& pq){

    if(m.find(y) == m.end()){
        m[y] = cost;
        pq.push(y);
    }else{
        chmin(m[y], cost);
    }
}

void move(ll x, ll cost, ll k, ll a, ll d, unordered_map<ll,ll>& m, priority_queue<ll>& pq){
    if(x%k == 0){
        ll y = x/k;
        add(y, cost+a, m, pq);
    }else{
        ll y = x/k;
        ll diff = abs(x-y*k);
        add(y, cost+a+d*diff, m, pq);
        y = x/k+1;
        diff = abs(x-y*k);
        add(y, cost+a+d*diff, m, pq);
    }
}

void solve(ll n, ll a, ll b, ll c, ll d){
    unordered_map<ll,ll> m;
    priority_queue<ll> pq;
    pq.push(n);
    m[n] = 0;
    ll ans = INF;
    while(!pq.empty()){
        ll x = pq.top();
        ll cost = m[x];
        pq.pop();
        // debug(x);
        // debug(cost);
        if(x < 2000000000) chmin(ans, cost+x*d);
        move(x, cost, 2, a, d, m, pq);
        move(x, cost, 3, b, d, m, pq);
        move(x, cost, 5, c, d, m, pq);

    }
    cout << ans << endl;


}

int main(){
    cin >> t;
    for(ll i = 0;i < t;i++){
        cin >> n >> a >> b >> c >> d;
        solve(n, a, b, c, d);
    }
}


Measured memory_bytes: 4016
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long ll;
int main(void){
  int a;
  cin >> a;
  int ans;
  ans = a + (a*a) + (a*a*a);
  cout << ans << endl; 
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
S = [input() for _ in range(N)]
M = int(input())
T = [input() for _ in range(M)]
res = {}
for i in S:
    if i in S:
        if i in T:
            res[i] = S.count(i) - T.count(i)
        else:
            res[i] = S.count(i)
if max(res.values()) <= 0:
    print(0)
else:
    print(max(res.values()))

Measured memory_bytes: 3064
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 100011
#define ll long long
#define endl '\n'
int a[MAX],dp[MAX];

int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	
	cin>>n;
	for(int i = 0 ; i < n ; i++)cin>>a[i];

	dp[0] = 0;
	for(int i = 1;  i < n ; i++){
		dp[i] = dp[i - 1] + abs(a[i] - a[i-1]);
		if(i > 1)dp[i] = min(dp[i],dp[i-2] + abs(a[i] - a[i-2])); 
	}	
	cout<<dp[n-1];
	return 0; 
} 

Measured memory_bytes: 1024
#include<stdio.h>
#include<string.h>
int main(){
  int n,i,k,a,b,q;
  char str[1000];
  char order[10];
  scanf("%s",str);
  scanf("%d",&q);
  for(n=0;n<q;n++){
    scanf("%s",order);
    scanf("%d %d",&a,&b);
    if(strcmp(order,"print")==0){
      for(i=a;i<=b;i++){
        printf("%c",str[i]);
      }
      printf("\n");
    }
    if(strcmp(order,"reverse")==0){
      char work[1000]={0};
      k=b;
      for(i=a;i<=b;i++){
        work[i]=str[k];
        k--;
      }
      for(i=a;i<=b;i++){
        str[i]=work[i];
      }
    }
    if(strcmp(order,"replace")==0){
      char p[b-a+1];
      scanf("%s",p);
      k=0;
      for(i=a;i<=b;i++){
        str[i]=p[k];
        k++;
      }
    }
  }
  return 0;
}

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

#define st first
#define nd second

using namespace std;

typedef pair<int, int> PII;
typedef long long ll;

const int MXM = 1e5 + 10;

struct node
{
	int id;
	int p, y;
}city[MXM];

bool cmp(node a, node b)
{
	if (a.p != b.p)
		return a.p < b.p;
	return a.y < b.y;
}

ll ans[MXM];

int main ()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++)
	{
		city[i].id = i;
		scanf("%d%d", &city[i].p, &city[i].y); 
	}
	sort(city, city + m, cmp);
	int x;
	for (int i = 0; i < m; i++)
	{
		if (!i || city[i - 1].p != city[i].p)
			x = 0;
		x++;
		ans[city[i].id] = 1ll * city[i].p * ll(1e6) + 1ll * x;
	}
	for (int i = 0; i < m; i++)
		printf("%012lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

struct UnionFind {  
  vector<int> par,sizes;                     // par[i]:iの親の番号(ex)par[3]=2 : 3の親が2
  UnionFind(int n) : par(n),sizes(n,1)  {    //最初は全てが根であるとして初期化
    for(int i=0; i<n; i++){ par[i]=i; }  
  }
  int root(int x) {                       //xが属する木の根を再帰で得る:root(x)={xの木の根}
    if(par[x]==x){ return x; }
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {                 // xとyの木を併合
    int rx = root(x);                        //xの根をrx
    int ry = root(y);                        //yの根をry
    if(rx == ry){ return; }                  //xとyの根が同じ(=同じ木にある)時はそのまま
    if(sizes[rx]<sizes[ry]){ swap(rx, ry); } //xの木をおおきくする
    par[ry] = rx; 
    sizes[rx] += sizes[ry];                  //sizes[ry]はもう使わない
  }
  bool check(int x, int y) {                 // x,yが属する木が同じならtrueを返す
    return root(x) == root(y);
  }
  int size(int x){                           //xが含まれる木の大きさを返す
    return sizes[root(x)];
  }
};

int main(){
  int n;
  cin >> n;
  UnionFind uf(mx);
  rep(i,n){
    int x,y; cin >> x >> y; y +=(mx/2);
    uf.unite(x,y);
  }
  vector<ll> a(mx,0), b(mx,0);
  rep(i,mx/2){
    a[uf.root(i)]++;
    b[uf.root(i+mx/2)]++;
  }
  ll ans = 0;
  rep(i,mx) ans += a[i]*b[i];
  ans -= n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

ll gcd(ll a,ll b){
  if(a>b)swap(a,b);
  ll ans=b;
  while(ans%a!=0){
    ans+=b;
  }
  return ans;
}

int main(){
  int n;
  ll t[105];
  cin>>n;
  ll ans=1;
  rep(i,n){
    cin>>t[i];
    ans=gcd(ans,t[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

#define rep(i,n) for(int i=0;i<(int)(n);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)

#define lf double
#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;

int main(void)
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	ll n;
	while(cin>>n, n!=0){
		vll a(n);
		ll asum=0;
		double ave;
		rep(i, n){
			cin >> a[i];
			asum += a[i];
		}
		ave = (double)asum/n;
		ll ans=0;
		rep(i, n){
			if (a[i] <= ave) ans++;
		}
		cout << ans << "\n";
	}
	return 0;
}


Measured memory_bytes: 3236
module MakeBinaryHeap (M : sig type t val compare : t -> t -> int end) = struct
  type t = { node : M.t array; mutable size : int }

  let make n (init : M.t) = { node = Array.make n init; size = 0 }

  let empty_p t = if t.size = 0 then true else false

  let pop t =
    let ret = t.node.(1) in
    t.node.(1) <- t.node.(t.size);
    t.size <- t.size - 1;
    let rec max_heapify i =
      let l = 2*i in
      let r = 2*i + 1 in
      let m = if l <= t.size && M.compare t.node.(l) t.node.(i) > 0 then l else i in
      let m = if r <= t.size && M.compare t.node.(r) t.node.(m) > 0 then r else m in
      if m <> i then begin
        let tmp = t.node.(i) in t.node.(i) <- t.node.(m); t.node.(m) <- tmp;
        max_heapify m
      end in
    max_heapify 1;
    ret

  let push x t =
    t.size <- t.size + 1;
    t.node.(t.size) <- x;
    let parent i = int_of_float (floor (float_of_int i) /. 2.) in
    let rec doit i =
      if i > 1 && M.compare t.node.(parent i) t.node.(i) < 0 then begin
        let tmp = t.node.(i) in t.node.(i) <- t.node.(parent i); t.node.(parent i) <- tmp;
        doit (parent i)
      end in
    doit t.size
end

module H = MakeBinaryHeap(struct type t = (int * int) let compare x y = fst x - fst y end)

let dijkstra g n =
  let h = H.make 100000 (0, 0) in
  let d = Array.make n max_int in
  let b = Array.make n false in
  d.(0) <- 0;
  b.(0) <- true;
  H.push (0, 0) h;
  let rec doit () =
    if not (H.empty_p h) then begin
      let (x, u) = H.pop h in
      b.(u) <- true;
      if d.(u) >= (-x) then duduwa u g.(u);
      doit ()
    end
  and duduwa u = function
    | [] -> ()
    | (v, _) :: tl when b.(v) = true -> duduwa u tl
    | (v, c) :: tl when d.(v) <= d.(u) + c -> duduwa u tl
    | (v, c) :: tl ->
      begin
        d.(v) <- d.(u) + c;
        H.push ((-d.(v)), v) h;
        duduwa u tl
      end in
  doit ();
  d

let rec make_pair acc = function
  | [] -> acc
  | f :: t :: tl -> make_pair ((f, t) :: acc) tl
  | _ -> exit 1

let () =
  let n = read_int () in
  let g = Array.make n [] in
  let rec read i =
    if i < n then
      match List.map int_of_string (Str.split (Str.regexp " ") (read_line ())) with
      | u :: _ :: l -> (g.(u) <- make_pair [] l; read (i + 1))
      | _ -> exit 1
  in read 0;
  Array.iteri (fun i e -> Printf.printf "%d %d\n" i e) (dijkstra g n)

Measured memory_bytes: 30692
#include <iostream>
#include <string.h>

using namespace std;

int main()
{
    int a,b;
    char s[205];
    cin>>s;
    for(int i=1;2*i<strlen(s);i++)
    {
        b=1;
        for(int j=0;j<strlen(s)/2-i;j++)
        {
            if(s[j]!=s[(strlen(s)-2*i)/2+j])
            {
                b=0;
                break;
            }
            a=j;
        }
        if(b)
        {
            break;
        }
    }
    cout<<++a*2<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <iostream>
#include <set>
using namespace std;
typedef long long ll;

string str;

int main(int argc, char const *argv[]) {
	cin >> str;
	reverse(str.begin(), str.end());
	cout << str << endl;
	return 0;
}

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

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

  vector<vector<uint>> vertex(N);

  for(int i = 0; i < N - 1; i++) {
    uint a;
    uint b;
    cin >> a >> b;
    a--; // index starts with zero
    b--;
    vertex[a].push_back(b);
    vertex[b].push_back(a);
  };

  vector<uint> counter(N, 0);

  for(int i = 0; i < Q; i++) {
    uint p;
    uint x;
    cin >> p >> x;
    p--;
    counter[p] += x;
  }

  vector<bool> visited(N, false);
  stack<uint> s;
  s.push(0);
  while(s.size() > 0) {
    const auto next = s.top();
    s.pop();
    visited[next] = true;
    for(const auto &e : vertex[next]) {
      if(visited[e]) continue;
      counter[e] += counter[next];
      s.push(e);
    }
  }

  for(const auto &e : counter) cout << e << " ";
}


Measured memory_bytes: 15604