akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES

#include <cmath>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <limits>
#include <cstring>
#include <string>
#include <queue>
#include <map>
#include <set>
#include <bitset>

using namespace std;

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

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

class unionfind {
    int num;
    vector<int> par;
public:
    explicit unionfind(int n) : num(n), par(n, -1) {}

    int find(int x) {
        if (par[x] < 0) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        num--;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size() { return num; }

    int size(int x) { return -par[find(x)]; }
};

const int Maxn = 100010;
int n, m;
int p[Maxn];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> m;
    unionfind uf(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        p[i]--;
    }
    for (int i = 0; i < m; ++i) {
        int x, y;
        cin >> x >> y;
        x--, y--;
        uf.unite(x, y);
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        if (uf.same(p[i], i)) ++ans;
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> e(n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    vector<int> depth(n);
    function<void(int, int)> dfs = [&](int v, int p) {
        for (int u: e[v]) {
            if (u != p) {
                depth[u] = depth[v] + 1;
                dfs(u, v);
            }
        }
    };
    dfs(0, -1);
    int deepest = max_element(depth.begin(), depth.end()) - depth.begin();
    depth.assign(n, 0);
    dfs(deepest, -1);
    int diam = *max_element(depth.begin(), depth.end());
    if (diam % 3 == 1) {
        cout << "Second\n";
    } else {
        cout << "First\n";
    }
    return 0;
}


Measured memory_bytes: 27648
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <climits>
#include <cmath>
#include <vector>
#include <string>

#define REP(i, n) for (int i=0;i<(n);i++)
#define FOR(i, a, b) for (int i=(a);i<(b);i++)

using namespace std;

int N, C;
int D[31][31];
int c[501][501];

int main()
{
    scanf("%d %d ", &N, &C);
    FOR(i, 1, C+1) {
        FOR(j, 1, C+1)
            scanf(" %d ", &D[i][j]);
    }
    FOR(i, 1, N+1) {
        FOR(j, 1, N+1)
            scanf(" %d ", &c[i][j]);
    }

    int mod0[31];
    int mod1[31];
    int mod2[31];
    FOR(i, 1, C+1) {
        int tmp0 = 0;
        int tmp1 = 0;
        int tmp2 = 0;
        FOR(j, 1, N+1) {
            FOR(k, 1, N+1) {
                if((j+k)%3==0)
                    tmp0 += D[c[j][k]][i];
                else if((j+k)%3==1)
                    tmp1 += D[c[j][k]][i];
                else
                    tmp2 += D[c[j][k]][i];
            }
        }
        mod0[i] = tmp0;
        mod1[i] = tmp1;
        mod2[i] = tmp2;
    }
    int ans = 1000000000;
    FOR(i, 1, C+1) {
        FOR(j, 1, C+1) {
            FOR(k, 1, C+1) {
                if(i==j || i==k || j==k)
                    continue;
                ans = min(ans, mod0[i]+mod1[j]+mod2[k]);
            }
        }
    }
    printf("%d\n", ans);

    return 0;
}


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

int main() {
  int A, B, C, X, Y;
  cin >> A >> B >> C >> X >> Y;
  int ca, cb;
  if (X > Y) {
    swap(X, Y);
    swap(A, B);
  }
  int ans = 0;
  int pa = X, pb = Y;
  for (int i = 1; i <= pa; ++i) {
    ans += min(A + B, 2 * C);
    --X;
    --Y;
  }
  cout << ans + min(B, 2 * C) * Y << endl;
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

struct card {
	char s;
	int n;
};


int main(void)
{
	struct card a[200], b[200], c[200], tmt;
	int num, i, j, flag, minj;

	scanf("%d", &num);

	for (i = 0; i < num; i++) {
		scanf(" %c%d", &a[i].s, &a[i].n);
		b[i].s = a[i].s;
		c[i].s = a[i].s;
		b[i].n = a[i].n;
		c[i].n = a[i].n;
	}
	

	for (i = 0; i < num; i++) {
			for (j = num - 1; j > i; j--) {
				if (b[j].n < b[j - 1].n) {
					tmt = b[j];
					b[j] = b[j - 1];
					b[j - 1] = tmt;
				}
			}
		
	}

	for (i = 0; i < num; i++) {
		minj = i;
		for (j = i; j < num; j++) {
			if (c[j].n < c[minj].n) {
				minj = j;
			}
		}
		tmt = c[i];
		c[i] = c[minj];
		c[minj] = tmt;
	}

	for (i = 0; i < num; i++) {
		printf("%c%d", b[i].s, b[i].n);

		if (i != num - 1) {
			putchar(' ');
		}
		else {
			putchar('\n');
		}
	}

	printf("Stable\n");

	for (i = 0; i < num; i++) {
		printf("%c%d", c[i].s, c[i].n);

		if (i != num - 1) {
			putchar(' ');
		}
		else {
			putchar('\n');
		}
	}

	for (i = 0; i < num; i++) {
		if (b[i].s != c[i].s) {
			printf("Not stable\n");
			break;
		}
	}

	if (i == num) {
		printf("Stable\n");
	}

	return 0;	
}



Measured memory_bytes: 1928
#include <cstdio>
#include <algorithm>
using namespace std;
int par[100010];
int find(int x) {
	return x == par[x] ? x : (par[x] = find(par[x]));
}
void unite(int x, int y) {
	par[find(x)] = find(y);
}
int a[100010], c[100010];
int main() {
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
		par[i] = i;
		c[i] = i;
	}
	int k = n;
	for (int i = 0; i < m; i++) {
		int u, v;
		scanf("%d%d", &u, &v);
		if (find(u) == find(v)) {
			continue;
		}
		--k;
		unite(u, v);
	}
	if ((k - 1) * 2 > n) {
		puts("Impossible");
		return 0;
	}
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		int x = find(i);
		if (a[c[x]] > a[i]) {
			c[x] = i;
		}
	}
	int s = 2 * (k - 1);
	for (int i = 0; i < n; i++) {
		if (s <= 0) {
			break;
		}
		if (find(i) == i) {
			ans += a[c[i]];
			a[c[i]] = 1001001001;
			--s;
		}
	}
	sort(a, a + n);
	for (int i = 0; i < s; i++) {
		ans += a[i];
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1280
def GCD(x,y):
    r = x%y
    if r == 0:
        return y
    else:
        return GCD(y,r)


n = int(input())
list1 = list(map(int,input().split()))
result = list1[0]
for i in list1[1:]:
    result = result*i/GCD(i,result)

print(int(result))

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

int main()
{
    int N; cin >> N;
    vector<int> C(13);
    C[0] = 1;
    for (int i = 0; i < N; i++) {
        int d; cin >> d;
        C[d]++;
    }
    if (any_of(C.begin(), C.end(), [](int c){return c>=3;}) || C[0]==2 || C[12]==2) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 0;
    for (int b = 0; b < (1<<11); b++) {
        vector<int> D;
        for (int i = 1; i <= 11; i++) {
            if (C[i] == 2) {
                D.push_back(i);
                D.push_back(24-i);
            } else if (C[i] == 1) {
                if (b & (1 << (i-1))) {
                    D.push_back(24-i);
                } else {
                    D.push_back(i);
                }
            }
        }
        if (C[12] > 0) D.push_back(12);
        D.push_back(24);
        sort(D.begin(), D.end());
        vector<int> diffs(D.size());
        adjacent_difference(D.begin(), D.end(), diffs.begin());
        int mi = *min_element(diffs.begin(), diffs.end());
        ans = max(ans, mi);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
import math
def main(n, x, m):
    count = 0
    #消費量が少ない順に1つずつ作る
    m.sort()
    for i in range(len(m)):
        x -= m[i]
        if x >= 0:
            count += 1
        else:
            return count
    #消費量が最小のものをできるだけ多くつくる
    count += math.floor(x / min(m))
    return count

n, x = map(int, input().split())
m = [int(input()) for _ in range(n)]
print(main(n, x, m))

Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int main()
{
    int x,y;

    while(1){
        cin >> x >> y;
        if(x==0 && y==0){
            break;
        }
        if(x<y){
            cout << x << " " << y << endl;
        }else{
            cout << y << " " << x << endl;
        }
    }
    
    return 0;

}


Measured memory_bytes: 2976
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  ll a, b, x;
  cin >> a >> b >> x;
  ll ans = b / x - a / x;
  if(a % x == 0){
    ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int A, B, i, j;
  int s1,s2,s3,s4,s5;
  int a1,a2,a3,a4,a5;
  int s,a;
  cin >> A >> B;
  int sum=0;
  
  for(i=A;i<B+1;i++){
		
    s1=i/10;
    a1=i%10;
    s2=s1/10;
    a2=s1%10;
    s3=s2/10;
    a3=s2%10;
    s4=s3/10;
    a4=s3%10;
    s5=s4/10;
    a5=s4%10;
    
    if(a1==a5&&a2==a4){
      sum++;
    }
  }
  
  cout << sum << endl;
      
}


Measured memory_bytes: 256
N = int(input())
s = input()
SW_list = ["SS", "SW", "WS", "WW"]
check = False
for sw in SW_list:
    ans = [""] * N
    ans[0] = sw[0]
    ans[1] = sw[1]
    for i in range(1, N-1):
        if (ans[i] == "S" and s[i] == "o") or (ans[i] == "W" and s[i] == "x"):
            ans[i+1] = ans[i-1]
        else:
            ans[i+1] = "S" if ans[i-1] == "W" else "W"
    if (ans[0] == "S" and s[0] == "o") or (ans[0] == "W" and s[0] == "x"):
        if ans[1] == ans[-1]:
            check = True
    else:
        if ans[1] != ans[-1]:
            check = True
    if (ans[-1] == "S" and s[-1] == "o") or (ans[-1] == "W" and s[-1] == "x"):
        if ans[0] != ans[-2]:
            check = False
    else:
        if ans[0] == ans[-2]:
            check = False
    if check:
        print(*ans, sep="")
        break

if check == False:
    print(-1)

Measured memory_bytes: 55868
#pragma GCC optimize("Ofast")
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
	if (p == 0) return 1;
	if (p % 2 == 0) {
		int t = mod_pow(n, p / 2, m);
		return (t * t) % m;
	}
	return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	long long d = extGCD(b, a % b, y, x);
	y -= a / b * x;
	return d;
}
int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int digit(int x) {
	int cnt = 0;
	while (x > 0) {
		cnt += x % 10;
		x /= 10;
	}
	return cnt;
}
int read() {
	int tmp;
	cin >> tmp;
	return tmp;
}
int xor128() {
	static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
	int t = (x xor (x << 11));
	x = y; y = z; z = w;
	return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
	map<int, int>ans;
	int now = 2;
	while (now * now <= x) {
		if (x % now == 0) {
			x /= now;
			ans[now]++;
		}
		else now++;
	}
	if (x != 1) ans[x]++;
	return ans;
}

const int MAX = 510000;

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

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int Com(int n, int k) {
	int x=1, y=1;
	rep(i, k) {
		y *= i + 1;
		y %= MOD;
	}
	for (int i = n - k + 1; i <= n; i++) {
		x *= i;
		x %= MOD;
	}
	return x * modinv(y, MOD) % MOD;
}

signed main() {
	COMinit();
	int n, k;
	cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < min(n, k + 1);i++) {
		ans += COM(n, i) * COM(n - 1, n - 1 - i);
		ans %= MOD;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 12160
n = int(input())
P = list(map(int, input().split()))

cnt = 0
for i in range(n-2):
    i += 1
    L = [P[i-1], P[i], P[i+1]]
    L = sorted(L)
    if L[1] == P[i]:
        cnt += 1


print(cnt)

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

int main(){
  int A, B, C, K;
  cin >> A >> B >> C >> K;
  vector<int64_t> X(A);
  vector<int64_t> Y(B);
  vector<int64_t> Z(C);
  for(int i=0; i<A; i++){
    cin >> X.at(i);
  }
  for(int i=0; i<B; i++){
    cin >> Y.at(i);
  }
  for(int i=0; i<C; i++){
    cin >> Z.at(i);
  }
  sort(X.rbegin(),X.rend());
  
  vector<int64_t> sum(0);
  for(int i=0; i<B; i++){
    for(int j=0; j<C; j++){
      sum.push_back(Y.at(i) + Z.at(j));
    }
  }
  
  sort(sum.begin(), sum.end());
  
  vector<int64_t> ans(0);
  for(int i=B*C-1; i>=max(B*C-3000,0); i--){
    ans.push_back(sum.at(i) + X.at(0));
  }
  
  int64_t bottom = 0;
  if(ans.size() >= K){
    bottom = ans.at(ans.size()-1);
  }
  
  vector<int64_t>::iterator itr;
  int64_t idx;
  for(int i=1; i<A; i++){
    itr = lower_bound(sum.begin(),sum.end(),bottom - X.at(i));
    idx = distance(sum.begin(),itr);
    for(int j=idx; j<sum.size(); j++){
      ans.push_back(sum.at(j) + X.at(i));
    }
  }
  
  sort(ans.rbegin(),ans.rend());
  for(int i=0; i<K; i++){
    cout << ans.at(i) << endl;
  }

}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)

#define SORT(c) sort((c).begin(),(c).end())
#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
int gcd(int a,int b){return b?gcd(b,a%b):a;}

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int WHITE = 0;
const int GRAY = 1;
const int BLACK = 2;
const int MAX = 101;
int N;
VI pos[MAX];

struct init{
    init(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
} init;


void input(){
  std::cin >> N;
  int x, y, h;
  REP0( i, N ){
    std::cin >> x >> y >> h;
    pos[i].PB(x); pos[i].PB(y); pos[i].PB(h);
  }
}

void solve(){
  int H=-1;
  REP0( px, 101 ){
    REP0( py, 101 ){
      bool isAnswer = true;
      REP0( i, N ){
        if ( pos[i][2]!=0 ) {
          H = pos[i][2] + abs( pos[i][0] - px ) + abs( pos[i][1] - py );
        }
      }
      REP0( i, N ){
          int calced_h = max( H - abs( pos[i][0] - px ) - abs( pos[i][1] - py ), 0 );
          if ( pos[i][2] != calced_h ){  // h_i=0
            isAnswer = false;
          }
        }
      if ( isAnswer ) {
        std::cout << px << " " << py << " " << H << '\n';
        return;
      }

    }
  }
}


int main(int argc, char const *argv[]) {
  input();
  solve();

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner sc = new Scanner(System.in)) {
			String line = sc.nextLine();
			// String answer = "";
			int length = line.length();
			for (int i = 0; i < length; i++) {
				char ch = line.charAt(i);
				if (Character.isLowerCase(ch)) {
					// System.out.println("#");
					ch = Character.toUpperCase(ch);
					System.out.print(ch);
				} else {
					// System.out.println("&");
					ch = Character.toLowerCase(ch);
					System.out.print(ch);
				}
			}
			System.out.println();
		}
	}

}



Measured memory_bytes: 26788
// atcoder/abc074/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n, a;
  while (cin >> n >> a) {
    cout << n * n - a << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque, defaultdict
import itertools as ite
import sys
import math
import decimal

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

N = input()
S, T = raw_input().split()
S2 = ""
for i in range(N):
    S2 += S[i]
    S2 += T[i]
print S2

Measured memory_bytes: 4268
#include <stdio.h>

int main(void)
{
	int n, t, x = 0, i, a = 0, b = 0;
	
	int botan[200000];
	
	scanf("%d %d", &n, &t);
	scanf("%d", &a);
	for(i = 0; i < n - 1; i++){
		scanf("%d", &b);
		if(b - a <= t){
			x += b - a;
			
		}else{
			x += t;
			
		}
		a = b;
		
		
	}
	x += t;
	printf("%d\n", x);
	
	return 0;
}

Measured memory_bytes: 128
//Kaori Miyazono, did I reach you ?
//"I can't die because... I'm the one who will protect you." -Asuna Yuuki

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

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	long long int a, b, c, d, e;
	cin >> a >> b >> c >> d >> e;
	long long int ans = 4e18;
	if (d < e) {
		swap(a, b);
		swap(d, e);
	}
	for(int i = 0; i <= 2 * d; i += 2) {
		long long int cur = i * c + (d - i / 2) * a + max((e - i / 2), 0ll) * b;
		ans = min(ans, cur);
	}
	cout << ans << '\n';
	return 0;
}

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

int main() {
  int N, L;
  string out="";
  cin >> N >> L;

  vector<string> vec(N);

  for (int i=0; i<N; i++) cin >> vec.at(i);

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

  for (int i=0; i<N; i++) out += vec.at(i);

  cout << out <<endl;

}

Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
sys.setrecursionlimit(int(pow(10,6)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]
# @lru_cache(None)

a,b,x=l()
b=b//x
a=a//x-(a%x==0)
print(b-a)






Measured memory_bytes: 5124
#include <stdio.h>
#define N 2000
int n,i;
int A[N],m;
int q;
int solve(int, int);
int main(){
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0; i<q; i++){
    scanf("%d",&m);
    if( solve(0,m)==1 )
      printf("yes\n");
    else printf("no\n");
  }
  return 0;
}

int solve(int i, int m){
  int res=0;
  if(m==0)
    return 1;
  if(i>=n)
    return 0;
  res = solve(i+1, m) || solve(i+1, m-A[i]);
  return res;
}



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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/
    
    int n;cin>>n;
    vector<int> seg(2*n+5);
    for(int i=0;i<n;i++){
        cin>>seg[n+i];
    }
    for(int i=n-1;i>0;i--){
        seg[i]=__gcd(seg[i*2],seg[i*2+1]);
    }
    auto modify=[&](int pos,int e){
        for(seg[pos+=n]=e;pos>1;pos>>=1){
            seg[pos>>1]=__gcd(seg[pos],seg[pos^1]);
        }
    };
    int ans=0;
    for(int i=0;i<n;i++){
        int x=seg[n+i];
        if(i==0){
            modify(i,seg[n+1]);
        }
        else {
            modify(i,seg[n]);
        }
        ans=max(ans,seg[1]);
        modify(i,x);
    }
    cout<<ans;

    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<vector>
#define REP(i,n) for(int i = 0;i < (n);i++)
#define pb push_back
using namespace std;
typedef long long ll;

int main(){
  ll n,q;
  cin >> n >> q;

  int a[n+5]={0};
  int com[q],x[q],y[q];
  REP(i,q){

    //cin >> com[i] >> x[i] >> y[i];
    scanf("%d %d %d",&com[i],&x[i],&y[i]);

  }
  REP(i,q){
    if(com[i] == 0){
      a[x[i]] += y[i];
    }
    else{
      ll c = 0;
      for(int j = x[i];j < y[i]+1;j++){
	c += a[j];
      }
      printf("%d\n",c);
    }
  }
  
}

Measured memory_bytes: 4736
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)


struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        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の根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {

    int N, M;
    cin >> N >> M;
    vector<int> P;
    for (int i = 0; i < N; i++) {
        int tmp;
        cin >> tmp;
        P.push_back(tmp);
    }

    UnionFind tree(N+1);
    for (int i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        tree.unite(x, y);
    }

    int count = 0;
    for (int i = 0; i < N; i++){
        if (tree.same(i + 1, P[i])) count++;
    }

    cout << count << endl;

	return 0;
}


Measured memory_bytes: 1144
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	/*/TODO:!!!!!!!テスト用!!!!!!!!!
	sc = bufio.NewScanner(strings.NewReader(`

										`))
	//TODO:!!!!!!!テスト用!!!!!!!!!*/

	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush() // !!!!caution!!!! you must use Fprint(out, ) not Print()
	/* --- code --- */
	//fmt.Fprintln(out, "[DEBUG]", time.Now())

	a := nextInt()

	ans := a + a*a + a*a*a

	//fmt.Fprintln(out, "[DEBUG]", a)
	fmt.Fprintln(out, ans)

}

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

// -*-*-*-*-*-*-*-*-
// * I/O utilities *
// -*-*-*-*-*-*-*-*-

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextFloat64() float64 {
	a, _ := strconv.ParseFloat(next(), 64)
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}
func nextFloats(n int) []float64 {
	ret := make([]float64, n)
	for i := 0; i < n; i++ {
		ret[i] = nextFloat64()
	}
	return ret
}
func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}

func printArray(a []int) {
	for i := 0; i < len(a); i++ {
		if i >= 1 {
			fmt.Fprint(out, " ")
		}
		fmt.Fprint(out, a[i])
	}
	fmt.Fprintln(out)
}

func absInt(x int) int {
	return int(math.Abs(float64(x)))
}
func minInt(x, y int) int {
	if x < y {
		return x
	}
	return y
}
func maxInt(x, y int) int {
	if x > y {
		return x
	}
	return y
}
func log10(x int) float64 {
	return math.Log10(float64(x))
}

// 挿入ソート配列
type slist struct {
	l []int
}

func makeSlist() slist {
	return slist{[]int{}}
}

func (s *slist) add(a int) {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	if pos < len(s.l) {
		s.l = append(s.l[:pos+1], s.l[pos:]...)
		s.l[pos] = a
	} else {
		s.l = append(s.l, a)
	}
}
func (s slist) contains(a int) bool {
	pos := sort.Search(len(s.l), func(i int) bool { return s.l[i] >= a })
	return pos < len(s.l) && s.l[pos] == a
}


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

#define rep(i, n) for(int i=0; i < n; i++)
#define reps(i, n) for(int i=1; i <= n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
using ll=long long;


int main(){
  int N,M,p;
  cin >> N >> M;
  int k;
  int ans =0;
  vector<vector<int>> stol(11);


  rep(i,M){
    cin >> k;
    rep(j,k){
      int sw;
      cin >> sw;
      stol.at(sw).push_back(i+1);
      //cin >> s[i][j];
    }
  }

  //全部点灯条件
  bitset<10> lightall;
  rep(i,M){
    cin >> p;
    if(p)lightall.set(i);
  }

  rep(tmp,(1<<N)){
    bitset<10> s(tmp);
    bitset<10> light;
    //あるswitch pattern
    rep(i,N){
      if(s.test(i)){
        for(int l: stol.at(i+1))light.flip(l-1);
      }
    }
    if(light ==lightall)ans++;
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll n,a,b;
    cin >> n >> a >> b;
    char c[n];
    for(ll i=0;i<n;i++)
    {
        cin >> c[i];
    }
    ll sum;
    sum = a + b;
    for (ll i=0;i<n;i++)
    {
        if(c[i]=='c')
        {
            cout << "No" << endl;
        }
        else if(c[i] =='a' )
        {
            if(sum!=0)
            {printf("Yes\n");
            sum--;}
            else
                printf("No\n");
        }
        else if(c[i]== 'b'  )
        {
            if(sum!=0 && b!=0)
            {
                 printf("Yes\n");
                 sum--;
                 b--;
            }
            else
                printf("No\n");
        }
    }
}



Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;
class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		WUnionFindTree uft=new WUnionFindTree(N);
		for(int i=0; i<M; i++) {
			int L=sc.nextInt()-1;
			int R=sc.nextInt()-1;	//0 origin
			int D=sc.nextInt();
			if(uft.same(L,R)) {	//同じグループなら矛盾していないかを確認
				if(uft.diff(L,R)!=D) {
					pl("No");
					System.exit(0);
				}
				else {
					//
				}
			}
			else {	//同じグループでないならマージする。
				uft.union(L,R,D);
				if(uft.diff(L,R)!=D) {
					pl("No");
					System.exit(0);
				}
			}
		}
		pl("Yes");
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	public static class WUnionFindTree{
		int[] par; // 親の番号
		int[] ws;  // 親との重みの差
		public WUnionFindTree(int n){
			par = new int[n+1];
			ws  = new int[n+1];
			for(int i = 0; i <= n; i++){ par[i] = -1; }
		}
		public int find(int x){
			if(par[x] < 0){
				return x;
			}else{
				final int parent = find(par[x]);
				ws[x] += ws[par[x]];
				return par[x] = parent;
			}
		}
		public int weight(int x){
			find(x);
			return ws[x];
		}
		public boolean union(int x, int y, int w){ // x <-(w)- y (x + w = y)
			w += weight(x);
			w -= weight(y);
			x = find(x); y = find(y);
			if(x != y){
				if(par[y] < par[x]) {
					int tmp = x; x = y; y = tmp; w = -w;
				}
				par[x] += par[y]; par[y] = x;
				ws[y] = w;
				return true;
			}else{
				return false;
			}
		}
		public boolean same(int x, int y){
			return find(x) == find(y);
		}
		public Integer diff(int x, int y){ // y - x を求める. 比較不能ならnull.
			if(!same(x, y)){ return null; }
			return this.weight(y) - this.weight(x);
		}
		public int size(int x){
			return -par[find(x)];
		}
	}
}

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

int main()
{
    int n;
    cin >> n;
    P d[n];
    rep(i, n) cin >> d[i].first >> d[i].second;
    rep(i, n - 2)
    {
        if (d[i].first == d[i].second && d[i + 1].first == d[i + 1].second && d[i + 2].first == d[i + 2].second)
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3600
package main

import "fmt"

func main() {
	var N, M, cnt int
	fmt.Scan(&N, &M)
	if N > M {
		fmt.Println(M / 2)
		return
	}
	if M > N*2 {
		w := M - (N * 2)
		cnt = N + w/4
		fmt.Println(cnt)
		return
	} else {
		fmt.Println(M / 2)
		return
	}
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define INF (1LL<<50)
#define MOD 1000000007

int main(){
    int N,M;
    cin >> N >> M;
    vector<int>A;
    map<int,int> mp;
    rep(i,M){
        int a,b;
        cin >> a >> b;
        mp[a]++;
        mp[b]++;
        A.push_back(a);
        A.push_back(b);
    }
    for(int i=0;i<A.size();i++){
        if(mp[A[i]]%2==1){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}

Measured memory_bytes: 5108
import java.util.*; 
import java.math.*;
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();
  int sum=a+b;
  int sub=a-b;
  int mul=a*b;
  int ans = Math.max(sum,sub);
  System.out.println(Math.max(ans,mul));
  //System.out.println(ans);
  
}
}


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

int main(){
  int a,b;cin >> a >> b;
  if(a >= 13)cout << b << endl;
  else if(a >= 6)cout << b/2 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <complex>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define FORI(i,k,n) for(int i=k;i<(int)n;i++)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) begin(x),end(x)
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<":"<<x<<endl;
# define EPS 1e-12
#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#endif
typedef long long lint;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
//const int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }

int main()
{
	INT(n);
	int a[100010] = {1};
	FOR(i, n)
	{
		INT(l); INT(r);
		a[l]++;
		a[r + 1]--;
	}
	int ans = 0;
	FORI(i, 1, 100010)
	{
		a[i] += a[i - 1];
		if (a[i] >= i)ans = i;
	}
	cout << ans-1 << endl;

}

Measured memory_bytes: 3468
n = gets.to_i
s = gets.chomp.chars
MOD = 10**9+7

dic = Hash.new(0)
s.each do |c|
  dic[c] += 1
end

ans = 1
dic.values.each do |v|
  ans = ans * (v + 1) % MOD
end
puts ans - 1


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

int main(){
    int N; cin >> N;
    vector<int> A(N, 0);
    rep(i, N-1){
        int a; cin >> a;
        A[a-1]++;
    }
    for(auto x: A){
        cout << x << endl;
    }
 }


Measured memory_bytes: 4032
a,b,c=map(int,input().split())
k=int(input())
for i in range(1,k+1):
  if a>=b>=c or a>=c>=b:
    c=c*2
  elif b>=a>=c or b>=c>=a:
    c=c*2
  elif c>=b>a:
    c=c*2
  elif c>b==a:
    b=b*2
  elif c>a>=b:
    b=b*2
if c>b>a:
  print('Yes')
else:
  print('No')


Measured memory_bytes: 9096
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c,x;
	cin>>a>>b>>c>>x;
	int ans=0;
	for(int i=0;i<=a;i++){
		for(int j=0;j<=b;j++){
			for(int k=0;k<=c;k++){
				if(i*500+j*100+k*50==x){
					ans++;
				}
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 256
using System;

namespace B_CollatzProblem
{
    public class Program
    {
        const int MAX = 1000001;

        public static void Main(string[] args)
        {
            int[] a = new int[MAX];

            var s = int.Parse(Console.ReadLine());

            // 初項を入力
            a[0] = s;

            for (int i = 1; i < MAX; i++)
            {
                a[i] = f(a[i - 1]);

                for (int j = i - 1; j >= 0; j--)
                {
                    if (a[i] == a[j])
                    {
                        Console.WriteLine(i + 1);
                        return;
                    }
                }
            }

        }

        public static int f(int n)
        {
            if (n % 2 == 0)
            {
                // 偶数
                return n / 2;
            }
            else
            {
                // 奇数
                return 3 * n + 1;
            }
        }
    }
}


Measured memory_bytes: 11088
a = [1,2,3,4,5,6,7,8,9]
i = -1
N = int(input())

while True:
    if  len(a) >= N:
        print(a[N-1])
        break
    i = i + 1
    n = int(str(a[i])[-1])
    x = a[i]*10 + n-1
    y = a[i]*10 + n
    z = a[i]*10 + n+1
    if n != 9 and n != 0:
        w = (x,y,z)
        a.extend(w)
    elif n == 9:
        w = (x,y)
        a.extend(w)
    elif n == 0:
        w = (y,z)
        a.extend(w)


Measured memory_bytes: 7272
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>

using namespace std;

#define mod 1000000007

int main()
{
	int x;
	cin >> x;
	if(x >= 1200) cout << "ARC" << endl;
	else cout << "ABC" << endl;
	return 0;
}

Measured memory_bytes: 256
// atcoder/abc160/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  std::ios_base::sync_with_stdio(0);
  std::cin.tie(0);
  std::cout.setf(std::ios_base::fixed);
  std::cout.precision(15);

  lli n, x, y;
  while (cin >> n >> x >> y) {
    --x;
    --y;

    auto bfs = [&] (int src, vec<int>& cost){
      cost[src] = 0;
      queue<int> q;
      for (q.push(src); q.size(); q.pop()) {
        int curr = q.front();
        vec<int> v;
        v.push_back(curr - 1);
        v.push_back(curr + 1);
        if (curr == x) v.push_back(y);
        if (curr == y) v.push_back(x);
        each (next, v) {
          if (0 <= next && next < n && cost[next] == -1) {
            cost[next] = cost[curr] + 1;
            q.push(next);
          }
        }
      }
      return ;
    };

    vec<int> v(n, 0);

    for (int i = 0; i < n; ++i) {
      vec<int> c(n, -1);
      bfs(i, c);
      each (j, c) {
        ++v[j];
      }
    }
    for (int i = 1; i < v.size(); ++i) {
      cout << v[i] / 2 << endl;
    }
    // cout << endl;
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <numeric>
//#include "../cxx-prettyprint/prettyprint.hpp"

int main() {
    int N, K;
    std::cin >> N >> K;

    std::multiset<int> A;
    std::set<int> A_unique;
    for (int i = 0; i < N; i ++) {
        int a;
        std::cin >> a;
        A.insert(a);
        A_unique.insert(a);
    }

    std::vector<int> counts;
    for (int a : A_unique) {
        counts.push_back(A.count(a));
    }
    std::sort(counts.begin(), counts.end());

    if (K >= A_unique.size()) {
        std::cout << 0 << std::endl;
    } else {
        int n_rewrite = std::accumulate(counts.begin(), counts.begin() + A_unique.size() - K, 0);
        std::cout << n_rewrite << std::endl;
    }
}


Measured memory_bytes: 20092
def main():
    """
    問題が 3問出題され、
    1問目の配点は A点以下、
    2問目の配点は A+1点以上 B点以下、
    3問目の配点は  B+1点以上である。
    """
    N = int(input())
    A, B = map(int, input().split())
    *P, = map(int, input().split())

    n_a = 0
    n_ab = 0
    n_b = 0
    for p in P:
        if p > B:
            n_b += 1
        elif A < p <= B:
            n_ab += 1
        elif p <= A:
            n_a += 1

    ans = min([n_a, n_ab, n_b])
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <string.h>
 
#define rep(i,n)    for(ll i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(ll i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl "\n"
#define INF (ll)ll_MAX
 
typedef long long ll;
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector< ll > vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, ll > > vpp;
 
const ll N = 3*1e5 +5 ;
const long long MOD = 1000000007;
const long long MOD2 = 998244353;
const long long inf = 1e18;
 
using namespace std;

ll g[200000], ig[200000];

bool istrue(int perm[], int n){
    map <int,int> mm;
    for(int i=1;i<=n;i++){
        mm[i+perm[i]]++;
        if(mm[i+perm[i]]>1) return 0;
    }

    map <int,int> mm2;
    for(int i=1;i<=n;i++){
        mm2[i-perm[i]]++;
        if(mm2[i-perm[i]]>1) return 0;
    }

    return 1;
}

void findall(vector<string> &ans, string ptup, int left, int right, int n){
    
    if(ptup.size()==2*n){
        ans.push_back(ptup);
        // cout<<"yo";
        return;
    }
    if(left){
        ptup+='(';
        findall(ans,ptup,left-1,right,n);
        ptup.pop_back();
    }
    if(left!=right and right){
        ptup+=')';
        findall(ans,ptup,left,right-1,n);
        ptup.pop_back();        
    }
    
}


void solve()
{   

    ll n,d;
    cin>>n>>d;
    ll ctr = 0;

    while(n--){
        ll x,y;
        cin>>x>>y;
        if(x*x + y*y<=d*d) ctr++;
    }

    cout<<ctr;


}

int main() {

    g[1] = 1;
    ig[1] = 1;
    for (ll i = 2; i < 100000; ++i) {
        g[i] = 1 + g[i - g[g[i - 1]]];
        ig[i] = ig[i - 1] + i * g[i];
    }


    // #ifndef ONLINE_JUDGE
    //     // for getting input from input.txt
    //     freopen("input.txt", "r", stdin);
    //     // for writing output to output.txt
    //     freopen("output.txt", "w", stdout);
    // #endif


    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    ll t = 1;
    // cin>>t;
    ll ctr=0;
    while(t--)
    {   
        ctr++;
        // cout<<"Case #"<<ctr<<": ";
        solve();    
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
 
}

Measured memory_bytes: 5416
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
int A,B,C,K;
int main(){
	scanf("%d%d%d%d",&A,&B,&C,&K);
	if(K<=A)return 0*printf("%d\n",K);
	if(K<=A+B)return 0*printf("%d\n",A);
	printf("%d\n",A-(K-A-B));
	return 0;
}

Measured memory_bytes: 3840
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

const ll INF = 1000000000000000000LL;
const int MAX_N = 100005;

int n, k;
ll h[MAX_N];
ll dp[MAX_N];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for (int i = 0; i < n; i++)
		cin >> h[i];

	for (int i = 1; i < n; i++)
		dp[i] = INF;
	for (int i = 0; i < n; i++)
		for (int j = 1; j <= k && i + j < n; j++)
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));

	cout << dp[n - 1] << endl;
}

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


int main(void){
  int a,b; cin >> a >> b;
  int i = 1;
  while(i < 10000){
    if(i * 8 /100 == a && i * 10 /100 == b){
      cout << i << endl;
      return 0;
    }
    i++;
  }
  printf("%d",-1);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define inf 1001001001
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
P rotate_90(P a, P b) {
    P c = {b.first-a.first, b.second-a.second};
    return {-c.second+b.first, c.first+b.second};
}
int main(void) {
    P p1,p2;
    cin >> p1.first >> p1.second >> p2.first >> p2.second;
    P p3, p4;
    p3 = rotate_90(p1, p2);
    p4 = rotate_90(p2,p3);
    printf("%d %d %d %d\n",p3.first,p3.second,p4.first,p4.second);
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define M_PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int a[100];

int main()
{
	int N;
	int cost = 1e9, sum;

	cin >> N;
	rep(i, N) cin >> a[i];

	repc(target, -100, 100) {
		sum = 0;
		rep(i, N) {
			sum += (target - a[i]) * (target - a[i]);
		}
		cost = min(cost, sum);
	}

	cout << cost << endl;

	return 0;
}


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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<string> vs;
#define fo(i, a, b) for (int i = a; i < b; i++)
#define re(i, n) fo(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(s) s.begin(), s.end()
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { ll g = gcd(a, b); return a / g * b; }
int main()
{
  string a, b;
  cin >> a >> b;

  string ab, ba;
  re(i, stoi(b)) ab += a;
  re(i, stoi(a)) ba += b;

  if(ab < ba) cout << ab << endl;
  else cout << ba << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N,a;
  cin >> N;
  
for(int i=1; i<10; i++){
  if(N%i==0){
  a = N/i;
  }
}
if(a<10){
  cout << "Yes" <<endl;
}
else{
  cout<< "No" <<endl;
}
}

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

main(){

  ll n,m;
  cin>>n>>m;
  map<ll,vector<ll>> mp;
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    mp[a].push_back(b);
  }

  ll ans=0;
  priority_queue<ll> que;
  for(ll i=1;i<=m;++i){
    for(const auto& x:mp[i])que.push(x);
    if(que.empty())continue;
    ans+=que.top();
    que.pop();
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 10880
#include <iostream>
#include <string>
using namespace std;
using ll = long long;

int main() {
    string S;
    ll K;
    cin >> S >> K;
    
    // K文字目までをチェック
    for (ll i = 0; i < K; ++i) {
        if (S[i] != '1') {
            // 1以外が出たら答え
            cout << S[i] << endl;
            return 0;
        }
    }
    
    // K文字目まで全部1 -> 1が答え
    cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 384