akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld double
#define vll vector<ll>
#define pll pair<ll,ll>
#define forA(i,a,n,x) for(auto i=a;i<n;i+=x)
#define forD(i,a,n,x) for(auto i=n-1;i>=0;i-=x)
#define ranit(it,n) for(auto it:n)
#define testCases ll t;cin>>t;while(t--)
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define init(a,x) memset(a,x,sizeof(a))

ld c[3003]; ld dp[3003][3003];

ld solve(ll n , ll heads , ll tails)
{
	if(n==0)
	{
		if(heads>tails)return 1.0;
		else return 0.0;
	}

	if(dp[n][heads]!=-1) return dp[n][heads];
	ld hp = c[n-1];  ld tp = 1.0-hp; 

	return dp[n][heads]= hp*solve(n-1,heads+1,tails) + tp*solve(n-1,heads,tails+1);
}

int main()
{
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	ll n; cin>>n; forA(i,0,n,1)cin>>c[i];
	forA(i,0,3003,1)forA(j,0,3003,1) dp[i][j]=-1;
	ld ans = solve(n,0,0);
	cout<<fixed<<setprecision(10)<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 74384
import sys
input = sys.stdin.readline

N, A, B = map(int, input().split())
# print(N, A, B)

if A == 0:
    print(0)

elif N % (A + B) == 0:
    print(N // (A + B) * A)

else:
    count = N // (A + B) * A
    rem = min(A, N % (A + B))
    print(count + rem)

Measured memory_bytes: 38448
#include<iostream>
using namespace std;
int main(){
    int money[4]={10,50,100,500};
    int n;
    bool flag = true;
    while(cin >> n,n){
        int coin[4];
        for(int i=0; i<4; i++){
            cin >> coin[i];
        }
        n = coin[0] * 10 + coin[1] * 50 + coin[2] * 100 + coin[3] * 500 - n;
        int num[4];
        for(int i=3; i>=0; i--){
            num[i] = n/money[i];
            n -= num[i]*money[i];
        }
        if(flag) flag = false;
        else cout << endl;
        for(int i=0; i<4; i++){
            if(coin[i]>num[i]) cout << money[i] << ' ' << coin[i] - num[i] << endl;
        }
    }
}




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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin >> n;
    long long a[n+1];
    long long ans = 0;
    a[0] = 0;
    for(int i = 1; i <= n; i++){
        cin >> a[i];
        if(a[i-1] <= a[i]){
            ans += a[i-1];
            a[i] -= a[i-1];
        }
        ans += a[i]/2;
        a[i] %= 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
using namespace std;
const int MOD = 1e9+7;
const int INF = 0x3f3f3f3f;
const double PI = 4*atan(1);
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<double,double> pdd;
// ll gcd(ll a, ll b) { 
//     if (a == 0) return b; 
//     return gcd(b % a, a); 
// }
// ll f(ll x) {
// 	x%=MOD;
// 	if(x<0)x+=MOD;
// 	return x;
// }
// ll power(int base, int power) {
// 	ll prod = 1;
// 	ll b = base;
// 	while(power) {
// 		if (power & 1) {
// 			prod = f(prod*b);
// 		}
// 		b = f(b*b);
// 		power/=2;
// 	}
// 	return prod;
// }
// struct line {
//     int m, c;
//     ll eval(int x) { return 1LL * m * x + c; }
//     double intersectX(line l) { return (double) (c - l.c) / (l.m - m); }
// };

int X;
const int MAX = 1000;
ll five[MAX+1];
int get(ll need) {
	int l = 0, r = MAX;
	while(l<=r) {
		int mid = (l+r)/2;
		if (five[mid]<need) {
			l=mid+1;
		} else if(five[mid]>need) {
			r=mid-1;
		} else {
			return mid;
		}
	}
	return -1;
}
void solve() {
	cin >> X;
	for (int i = 0; i <= MAX; i++) {
		five[i] = pow(i,5);
	}
	// A>0
	for (int i = 1; i <= MAX; i++) {
		if (five[i]>X) {
			ll need = five[i]-X;
			int ret = get(need);
			if (ret == -1) continue;
			cout << i << " " << ret << endl;
			return;
		} else if (five[i]<X) {
			ll need = X-five[i];
			int ret = get(need);
			if (ret == -1) continue;
			cout << i << " -" << ret << endl;
			return;
		} else {
			cout << i << " 0\n";
			return;
		}
	}
}
int main() {
	// int t;
	// cin >> t;
	// for (int i = 1; i <= t; i++) { 
		// cout << "Case #" << i << ": ";
		solve();
	// }
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
 
using namespace std;
using ll = long long;
 
int main() {
    ll d, n;
    cin >> d >> n;
    ll ans = n * pow(100, d);
    if (d == 0 && n == 100) {
        cout << 101 << endl;
    }
    else if (d == 1 && n == 100) {
        cout << 10100 << endl;
    }
    else if (d == 2 && n == 100) {
        cout << 1010000 << endl;
    }
    else {
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>

using namespace std;


int main()
{
	vector<int> a(5);
	int min_num = 0;
	int answer = 0;

	for (int i = 0; i < 5; i++) {
		cin >> a[i];
		if ((a[min_num]-1) % 10 > ( a[i]-1) % 10) min_num = i;
	}
	answer += a[min_num];
	a.erase(a.begin() + min_num);
	for (int i = 0; i < 4; i++) {
		if(a[i] % 10 > 0)a[i] = a[i] / 10 * 10 + 10;
		answer += a[i];
	}
	cout << answer;

    return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.ArrayList;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) throws IOException {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		ArrayList<Integer> a = new ArrayList<>();
		int temp;

		for(int i=0; i<n; i++){
			temp = in.nextInt();
			if(i==0){
				a.add(temp);
			}else if(i>0 && a.get(a.size()-1) != temp){
				a.add(temp);
			}
		}

		int count = 1;
		boolean con = false;
		for(int i=1; i<a.size()-1; i++){
			if(a.get(i-1) < a.get(i) && a.get(i) > a.get(i+1)){
				if(con == false){
					count++;
					con = true;
				}else{
					con = false;
				}
			}else if(a.get(i-1) > a.get(i) && a.get(i) < a.get(i+1)){
				if(con == false){
					count++;
					con = true;
				}else{
					con = false;
				}
			}else{
				con = false;
			}
		}

		System.out.println(count);

	}

}


Measured memory_bytes: 51012
#include <bits/stdc++.h>
#define INF 1023456789
#define rep(i,a,b) for(int i = a; i < b; ++i)
#define trav(it,v) for(typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
using namespace std;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long long ll;

int main(){
    int k;
    char s[105];
    scanf("%d%s",&k,s);
    rep(i,0,min(k,(int)strlen(s))){
        printf("%c",s[i]);
    }
    if (k < (int) strlen(s))
        printf("...");
}


Measured memory_bytes: 3788
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
    	Scanner scan = new Scanner(System.in);
    	int a,b,tmp;
        String op;
    	while(true){
	    	a = scan.nextInt();
	    	op = scan.next();
	    	b = scan.nextInt();
	    	if(op.equals("?")) break;
	    	System.out.println(solve(a,b,op));
    	}
    }
    
    public static int solve(int a,int b,String op){
    	if(op.equals("+")) return (a+b);
    	if(op.equals("-")) return (a-b);
    	if(op.equals("*")) return (a*b);
    	if(op.equals("/")) return (a/b);
    	return 1;
     }
}

Measured memory_bytes: 17248
import java.util.Scanner;

//20180508
//03

public class Main {
    public static void main(String[] args){
		Scanner scanner = new Scanner(System.in);

		double r = scanner.nextDouble();

		double area = (2 * r) * Math.PI;
		double length = Math.pow(r, 2) * Math.PI;

		System.out.println(String.format("%.6f", length) + " " + String.format("%.6f", area));

    	scanner.close();
    }
}



Measured memory_bytes: 28272
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <string.h>
 
using namespace std;
typedef long long ll;

int main()
{
	int N;
	int A[1000];
	scanf("%d", &N);
	for(int i = 0; i < N; i++){
		scanf("%d", &A[i]);
	}
	
	bool approved = true;
	for(int i = 0; i < N; i++){
		if(A[i] % 2 == 0 && (A[i] % 3 != 0 && A[i] % 5 != 0)){
			approved = false;
			break;
		}
	}
	
	if(approved){
		printf("APPROVED\n");
	}else{
		printf("DENIED\n");
	}
	
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define P pair<int,int>
using namespace std;
const int INF=1e17+5;
const int maxn=1e5+5;
int n,m,a[maxn],b[maxn],ans,sum;

int32_t main()
{
    IOS;
    int k;
    cin>>n>>k;

    int t=(n-1)*(n-2)/2;
    if(k>t){ cout<<-1;return 0; }
    cout<<n-1+t-k<<endl;
    fu(i,1,n-1)
    {
        cout<<n<<" "<<i<<endl;
    }
    if(!(t-k))return 0;
    fd(i,n-1,1)
    {
        fu(j,1,i-1)
        {
            cout<<j<<" "<<i<<endl;
            ans++;
            if(ans>=t-k){
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
const int N = 100000 + 5;
int fa[N], n, m, dis[N], fm[N];
vector<int> G[N];
int que[N], hd, tl;
int main()
{
	scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; ++i) {
		int x, y; scanf("%d%d", &x, &y);
		G[x].push_back(y), G[y].push_back(x);
	}
	memset(dis, 0x3f, sizeof dis);
	dis[1] = 0;
	que[hd = tl = 1] = 1;
	while (hd <= tl) {
		int u = que[hd++];
		// printf("%d\n", u);
		for(int i = 0; i < (signed)G[u].size(); ++i) {
			int v = G[u][i];
			if(dis[v] == 0x3f3f3f3f) {
				dis[v] = dis[u] + 1;
				fm[v] = u;
				que[++tl] = v;
			}
		}
	}
	printf("Yes\n");
	for(int i = 2; i <= n; ++i) printf("%d\n", fm[i]);
	return 0;
}

Measured memory_bytes: 11220
#include<iostream>
#include<vector>
#include<numeric>
#include<algorithm>
using namespace std;
typedef long long ll;

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

    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)  cin >> a[i];
    for(int i = 0; i < n; i++)  cin >> b[i];

    ll asum = accumulate(a.begin(), a.end(), 0ll);
    ll bsum = accumulate(b.begin(), b.end(), 0ll);

    if(asum < bsum){
        cout << -1 << endl;
        return 0;
    }

    int ans = 0;
    ll need = 0;
    vector<ll> excess;

    for(int i = 0; i < n; i++){
        if(a[i] > b[i]){
            excess.push_back(a[i]-b[i]);
        }else if(a[i] < b[i]){
            ans++;
            need += b[i]-a[i];
        }
    }

    sort(excess.rbegin(), excess.rend());

    if(ans == 0){
        cout << 0 << endl;
        return 0;
    }

    for(int i = 1; i < excess.size(); i++)  excess[i] += excess[i-1];

    ans += (lower_bound(excess.begin(), excess.end(), need)-excess.begin()+1);

    cout << ans << endl;

    return 0;
}

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

#define deb(var) cout << "[" << (#var) << " : " << var <<"]" << " "
#define debv(v) cout << "[" << (#v) << " : {";for(int i = 0; i < v.size() - 1; ++i)\
					cout << v[i] <<", ";cout << v.back() << "}] "
#define deba(a,n) cout << "[" << (#a) << " : {";for(int i = 0; i < n - 1; ++i)\
					cout << a[i] << ", ";cout << a[n - 1] << "}] "
#define debp(p) cout << "[" << (#p) << " : {" << p.first << ", " << p.second << "}] "
#define debs(s) cout << "[" << (#s) << " : {";auto _itr = s.begin();\
					for(int k = s.size(); k > 1; --k) {cout << *_itr << ", "; ++_itr;} cout << *_itr << "}] "

typedef long long ll;

/*LETS BEGIN WITH THE NAME OF LORD MAHADEV*/
const int mxN = 1e5;
int ar[mxN];

int main(){
	int x, y;
	cin >> x >> y;
	for(int i = 0; i <= x; ++i){
		int j = x - i;
		if(i * 2 + j * 4 == y){
			cout << "Yes" << endl;
			exit(0);
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<iostream>
#include<cstring>
int main (void){
  char s[3],t[3];
  scanf("%s",&s);
  scanf("%s",&t);
  int ans=0;
  for(int i=0;i<=2;i++){
    if(s[i]==t[i]){ans++;}
  }
  printf("%d",ans);
}

Measured memory_bytes: 256
s = input()

count0 = 0
count1 = 0
# 0101…の場合
for i in range(len(s)):
    if i % 2 == 0 and s[i] == '1':
        count0 = count0 + 1
    if i % 2 == 1 and s[i] == '0':
        count0 = count0 + 1

#1010…の場合
for i in range(len(s)):
    if i % 2 == 0 and s[i] == '0':
        count1 = count1 + 1
    if i % 2 == 1 and s[i] == '1':
        count1 = count1 + 1

if count0 < count1: print(count0)
else: print(count1)


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

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

fn main() {
    let f: Vec<char> = read::<String>().chars().collect();
    let s: Vec<char> = read::<String>().chars().collect();

    for i in 0..f.len() {
        if f[i] != s[s.len() - i - 1] {
            println!("NO");
            return;
        }
    }
    println!("YES")
}


Measured memory_bytes: 4352
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main(){

  int n,w,h,x,y,haba,i;
  pair <int,int> x1[100000],y1[100000];
  
  cin>>n>>w>>h;

  for(i=0;i<n;i++){

    cin>>x>>y>>haba;
    int a,b,c,d;
    a=x-haba;
    b=x+haba;
    c=y-haba;
    d=y+haba;
    if(a<0) a=0;
    if(b>w) b=w;
    if(c<0) c=0;
    if(d>h) d=h;
    x1[i]=make_pair(a,b);
    y1[i]=make_pair(c,d);

  }
  sort(x1,x1+n);
  sort(y1,y1+n);
  int wa=0,ha=0;
  int maxza=0;
  if(x1[0].first!=0) wa++;
  else{
    for(i=1;i<n;i++){
      if(x1[i-1].first!=x1[i].first){
        maxza=max(x1[i-1].second,maxza);
        if(maxza<x1[i].first){
          wa++;
          break;
        }
      }
    }
    if(max(maxza,x1[n-1].second)<w) wa++;
  }
  maxza=0;  
  if(y1[0].first!=0) ha++;
  else{
    for(i=1;i<n;i++){
      if(y1[i-1].first!=y1[i].first){
        maxza=max(y1[i-1].second,maxza);
        if(maxza<y1[i].first){
          ha++;
          break;
        }
      }
    }
    if(max(maxza,y1[n-1].second)<h) ha++;
  }      
    

  if(wa==0 || ha==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;

  return 0;

}

Measured memory_bytes: 4680
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
# mod = 10 ** 9 + 7
mod = 998244353 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]
def init_dp1(init, N): return [init for _ in range(N)]
def init_dp2(init, N, M): return [[init for _ in range(M)] for _ in range(N)]


def main():
    N, X = read_values()
    A = read_list()

    dp = [[[0 for _ in range(N * X + 1)] for _ in range(N + 1)] for _ in range(N + 1)]
    

    dp[0][0][0] = 1

    for i, a in enumerate(A):
        for j in range(N + 1):
            for k in range(N * X):
                if k + a <= N * X and j < N:
                    dp[i + 1][j + 1][k + a] += dp[i][j][k]
                dp[i + 1][j][k] += dp[i][j][k]
    
    res = 0
    for i in range(1, N + 1):
        res += dp[N][i][i * X]

    print(res)


if __name__ == "__main__":
    main()



Measured memory_bytes: 98264
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
 
typedef long long int lli;
typedef unsigned long long int ulli;
typedef long double ldb;
 
#define pb push_back
#define popb pop_back
#define si size()
#define be begin()
#define en end()
#define all(v) v.be, v.en
#define le length()
#define mp make_pair
#define mt make_tuple
#define F first
#define S second
 
#define forz(i, n) for (int i = 0; i < n; i++)
#define bui(i, m, n) for (int i = m; i < n; i++)
#define rforz(i, n) for (int i = n - 1; i >= 0; i--)
#define mui(i, m, n) for (int i = n - 1; i >= m; i--)
#define deci(n) fixed << setprecision(n)
#define high(n) __builtin_popcount(n)
#define parity(n) __builtin_parity(n)
#define ctz(n) __builtin_ctz(n)
#define lb lower_bound
#define ub upper_bound
#define er equal_range
#define maxe *max_element
#define mine *min_element
#define mod 1000000007
#define mod2 998244353
#define kira ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define endl "\n"
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
 lli power(lli x,lli y,lli p)
{
  lli res=1;
  x=x%p;
  while(y>0)
  {
    if(y&1)
      res=(res*x)%p;
    //y must be even now
    y=y>>1; //y=y/2
    x=(x*x)%p;
  }
  return res;
}
 
lli gcd(lli a, lli b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
lli lcm(lli a, lli b)
{ return a * b / gcd(a, b); }
lli max(lli a, lli b)
{
  if (a > b)
    return a;
  return b;
}
lli min(lli a, lli b)
{
  if (a < b)
    return a;
  return b;
}
using namespace std;

int main()
{  
    kira;
    //freopen("input.txt","r",stdin);
    lli a,b,c;
    cin>>a>>b>>c;
    lli p=a-b;
    if(c>=p)
      cout<<c-p<<endl;
    else
      cout<<0<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int total = 1;
        String s = sc.next();
        for (int i = 0; i < n-1; i++) {
            if (s.charAt(i) != s.charAt(i+1))
                total++;
        }
        System.out.println(total);
    }
}

Measured memory_bytes: 24888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,m;
vector<int>edge[100005];
int in[100005];
queue<int>que;
int ans[100005];
int main(){
	scanf("%d%d",&n,&m);
	m += n-1;
	rep(i,m){
		int a,b; scanf("%d%d",&a,&b);
		edge[a].pb(b);
		in[b]++;
	}
	repn(i,n) if(in[i]==0) que.push(i);
	while(!que.empty()){
		int q = que.front(); que.pop();
		for(int i=0;i<edge[q].size();i++){
			int to = edge[q][i];
			in[to]--;
			if(in[to] == 0) {ans[to] = q; que.push(to);}
		}
	}
	repn(i,n) printf("%d\n",ans[i]);
}

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

int main(){
  int n;
  int k,p;

  cin >> n;

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

    cin >> k >> p;
    
    if(k % p == 0) cout << p << endl;
    else cout << k%p << endl;
  }
  return 0;
}



Measured memory_bytes: 3128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int[] a = new int[n];
    
    for(int i=0; i<n; i++){
      a[i] = Integer.parseInt(sc.next());
    } 
    int res = 0;
    for(int j=0; j<n; j++){
      res += a[j];
    }

    int ans1=0, ans2=0;
    for(int k=0; k<n; k++){
      ans1 += a[k];
      ans2 += a[k];
      if(ans1 > res/2){
        ans2 -= a[k];
        break;
      }
    }

    System.out.println(Math.min(2*ans1-res, res-2*ans2));

  }
}

Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    long long X;
    cin >> X;

    bool vis[100001];
    vis[0] = true;
    for(int i=0; i<=5; i++){
        for(int j=0; j<=X; j++){
            int to = j + 100 + i;
            if(to > X) continue;
            if(vis[j]) vis[to] = true;
        }
    }
    cout << int(vis[X]) << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int arr[N],tmp[N];
vector<int> a,b;
ll ans=0;
void mergesort(int s,int e){
	if(s==e) return;
	int m=(s+e)/2;
	mergesort(s,m); mergesort(m+1,e);
	int t1=s,t2=m+1,p=s;
	int z=0;
	while(p<=e){
		if(t1>m){
			tmp[p++]=arr[t2++];
		}else if(t2>e){
			tmp[p++]=arr[t1++];
		}else if(arr[t1]<arr[t2]){
			tmp[p++]=arr[t1++];
		}else{
			//ans+=();
			tmp[p++]=arr[t2++];
		}
	}
	REPP(i,s,e+1) arr[i]=tmp[i];
}
int main(){
	int n; scanf("%d",&n);
	REP(i,n) {scanf("%d",&arr[i]);(i%2)?a.pb(arr[i]):b.pb(arr[i]);}
	sort(all(a)); sort(all(b));
	sort(arr,arr+n);
	int ans=0;
	REP(i,a.size()){
		int x=lower_bound(arr,arr+n,a[i])-arr;
		if(x%2==0) ans++;
	}
	REP(i,b.size()){
		int x=lower_bound(arr,arr+n,b[i])-arr;
		if(x%2==1) ans++;
	}
	assert(ans%2==0);
	printf("%d\n",ans/2);
	/*
	REP(i,b.size()){
		arr[i*2]=b[i];
	}
	REP(i,a.size()){
		arr[i*2+1]=a[i];
	}
//	REP(i,n) printf("%d ",arr[i]); printf("\n");
	mergesort(0,n-1);
	REP(i,n) printf("%d ",arr[i]); printf("\n");
	printf("%lld\n",ans);*/
	return 0;
}


Measured memory_bytes: 1276
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int h = sc.nextInt();
    int a = sc.nextInt();
    int count = 0;
    while (true) {
      h -= a;
      count++;
      if (h <= 0) {
        break;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 21844
def solve(n, k):
    if n > k:
        n = n % k
    return min(n, k - n)


def main():
    n, k = map(int, input().split())
    res = solve(n, k)
    print(res)


def test():
    assert solve(7, 4) == 1
    assert solve(2, 6) == 2
    assert solve(1000000000000000000, 1) == 0


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-10;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	string n; 
	while (cin >> n, n != "0") 
	{
		vi s(n.size());
		s[0] = n[0] - '0';
		FOR(i, 1, n.size())
		{
			int t = n[i] - '0';
			if (i % 2) s[i] = s[i - 1] - t;
			else s[i] = s[i - 1] + t;
			s[i] = (s[i] + 11) % 11;
		}
		vi v(11);
		REP(i, s.size()) v[s[i]]++;
		int ans = 0, tmp = 0;
		REP(i, n.size())
		{
			if (n[i] == '0')
			{
				v[s[i]]--;
				continue;
			}
			ans += v[tmp];
			v[s[i]]--;
			if(i%2==0) tmp = (tmp + n[i] - '0' + 11) % 11;
			else tmp = (tmp - n[i] + '0' + 11) % 11;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3372
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
// #define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=998244353;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }
  void add(int &x,int y)
  {
  	x+=y;
  	x%=mod;
  	if(x<0)x+=mod;
  }
  void solve()
  {

int n,k;
cin>>n>>k;
vpi v(n);
forn(i,k)cin>>v[i].fi>>v[i].se;
vi dp(n+100,0);
dp[1]=1;
int sum=0;
for1(i,n)
{
	add(sum,dp[i]);
	forn(j,k)
	{
		if(i+v[j].fi<=n)add(dp[i+v[j].fi],sum);
		int kk=n-i;
		kk=min(kk,v[j].se);


		if(kk>=v[j].fi&&kk<=v[j].se&&i+kk+1<=n)add(dp[i+kk+1],-sum);
	}
}
cout<<dp[n];

  }
  
  int main()
  {
ios::sync_with_stdio(false);
    cin.tie(nullptr);
    #ifndef ONLINE_JUDGE
// freopen("input.txt","r",stdin);
// freopen("output.txt","w",stdout);
    #endif
int t=1;
while(t--)
{
  solve();
}

    return 0;
  }


Measured memory_bytes: 5572
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <bitset>
#include<iomanip>//小数点以下を精度良く表示

#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define INF 2000000000
#define INF2 1000000000000000000
#define PI 3.1415926535
#define rep(i,n) for(int i=0;i<(n);i++)
typedef pair<int, int> P;
const ll MOD = 1000000007;
using Graph = vector<vector<int>>;



int main() {
    int s, w;
    cin >> s >> w;
    if (s <= w) {
        cout << "unsafe" << endl;
    }
    else {
        cout << "safe" << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack> //深さ優先
#include <queue> //幅優先
#include <set>

using namespace std;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

int N,M;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	string s[N];
	for(int i = 0;i < N;i++){
		cin >> s[i];
	}
	cin >> M;
	string t[M];
	for(int i = 0;i < M;i++){
		cin >> t[i];
	}
	int ans = 0;
	for(int i = 0;i < N;i++){
		string tmp = s[i];

		int count = 0;
		for(int j = 0;j < N;j++){
			if(tmp == s[j]) count += 1;
		}
		for(int j = 0;j < M;j++){
			if(tmp == t[j]) count -= 1;
		}
		ans = max(ans,count);
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <array>
#include <cstdint>
#include <climits>
#include <functional>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <stdlib.h>
#include <string>
#include <time.h>
#include <type_traits>
#include <utility>
#include <vector>

using int32 = std::int_fast32_t;
using int64 = std::int_fast64_t;
using uint32 = std::uint_fast32_t;
using uint64 = std::uint_fast64_t;
using intl32 = std::int_least32_t;
using intl64 = std::int_least64_t;
using uintl32 = std::uint_least32_t;
using uintl64 = std::uint_least64_t;



int main(void) {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	uint32 n;
	std::cin >> n;
	std::vector<uint32> a(n);
	for (uint32 i = 0;i < n;++i) {
		std::cin >> a[i];
	}
	std::sort(a.begin(), a.end(), std::greater<uint32>());
	uint32 ans = 0;
	if (n & 1) ans += a.back();
	a.pop_back();
	--n;
	for (uint32 i = 0;i < n;i+=2) {
		ans += a[i] - a[i + 1];
	}
	std::cout << ans << "\n";
	return 0;
}

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

bool p[101000];

void prime() {
  fill(p, p+101000, true);
  p[0] = false;
  p[1] = false;
  for(int i = 2; i < 101000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 101000; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n;
  prime();
  while(cin >> n, n) {
    int ans;
    for(int i = 0; i <= n; i++) {
      if(p[i] && p[i-2]) ans = i;
    }
    cout << ans-2 << ' ' << ans << endl;
  }
}

Measured memory_bytes: 1256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


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

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

int main()
{
#ifdef __DEBUG
    freopen("A.in", "r", stdin);
    freopen("A.out", "w", stdout);
#endif

    LL N, A, B;
    read(N); read(A); read(B);
    if (A > B || (N == 1 && A != B))
        puts("0");
    else if (N == 1)
        puts("1");
    else
        printf("%lld", ((N - 1) * B + A) - ((N - 1) * A + B) + 1);

    return 0;
}

// 苟利国家生死以，岂因祸福避趋之！
//     -- 《赴戍登程口占示家人·其二》 林则徐


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int a, ma = 0, mi = 1e+5, k;
	for (int i = 0; i < 5; ++i) {
		cin >> a;
		ma = max(ma, a);
		mi = min(mi, a);
	}
	cin >> k;
	if (ma - mi > k) cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*int a;
	string s;
	cin >> a >> s;
	if (a >= 3200)cout << s;
	else cout << "red";*/


	/*int n;
	cin >> n;
	double a, ans = 0;
	rep(i, n) {
		cin >> a;
		ans += 1 / a;
	}
	cout << setprecision(20) << 1 / ans;*/


	int n;
	cin >> n;
	vector<double>v(n);
	rep(i, n)cin >> v[i];
	sort(all(v));
	int i;
	for (i = 0; i < n - 1; i++) {
		v[i + 1] = (v[i + 1] + v[i]) / 2;
	}
	cout << v[n - 1];

	return 0;
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int d = n % 10;
	if (d == 2 || d == 4 || d == 5 || d == 7 || d == 9)
		cout << "hon" << endl;
	else if (d == 0 || d == 1 || d == 6 || d == 8)
		cout << "pon" << endl;
	else if (d == 3)
		cout << "bon" << endl;
	return 0;
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define int long long
int MOD = 1000000007;
vector<vector<int> >g;
vector<vector<int> >l;
vector<int> valid;
int root;
int mxlen;
int mxi;
void dfs(int a, int p, int len) {
	if (mxlen < len) {
		mxlen = len;
		mxi = a;
	}
	for (int i = 0; i < g[a].size(); i++) {
		if (g[a][i] != p && valid[g[a][i]] == 1) {
			dfs(g[a][i], a, len + l[a][i]);
		}
	}
}
int tooi(int root) {
	mxlen = -1;
	dfs(root, -1, 0);
	return mxlen;
}

signed main() {
	while (true) {
		int N;
		cin >> N;
		if (N == 0)break;
		g.clear();
		g.resize(N);
		l.clear();
		l.resize(N);
		vector<int> p(N - 1);
		vector<int> d(N - 1);
		for (int i = 0; i < N - 1; i++) {
			cin >> p[i]; p[i]--;
		}
		int sum = 0;
		for (int i = 0; i < N - 1; i++) {
			cin >> d[i];
			sum += d[i];
		}
		
		for (int i = 0; i < N - 1; i++) {
			g[i + 1].push_back(p[i]);
			g[p[i]].push_back(i + 1);
			l[i + 1].push_back(d[i]);
			l[p[i]].push_back(d[i]);
		}
		if (N == 2) {
			cout << sum << endl;
		}
		else {
			valid.clear();
			valid.resize(N, 1);
			int leaves = 0;
			for (int i = 0; i < N; i++) {
				if (g[i].size() == 1) {
					leaves += l[i][0];
					valid[i] = 0;
				}
			}
			for (int i = 0; i < N; i++) {
				if (valid[i] == 1) {
					tooi(i);
					int tyokkei = tooi(mxi);
					cout << sum + (sum - leaves) * 2 - tyokkei << endl;
					break;
				}
			}
		
		}
	}
}


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

int main(){
  int n,m;
  cin>>n>>m;
  vector <pair<int, int >> pair(n);
  rep(i,n){
    cin>>pair[i].first>>pair[i].second;
  }
    
  sort(pair.begin(), pair.end());   
  //cout<<pair[0].second;
  ll sum=0;     
  priority_queue<int> salary;
  int j=0;
  for(int i=1; i<m+1; i++){
    for( j; pair[j].first<=i; j++){
      salary.push(pair[j].second);
    }
    if(salary.empty()) continue;
    else{
      sum+=salary.top();
      salary.pop();
    }
  }
  
  cout<<sum;
}

Measured memory_bytes: 1660
import math
import sys

l, r = map(int, sys.stdin.readline().rstrip().split())

if math.ceil(l / 2019) * 2019 <= r:
    print(0)
else:
    # print(l * (l + 1) % 2019)
    ans = 2019
    for i in range(l, r+1):
        for j in range(i + 1, r+1):
            if ans > (i * j) % 2019:
                ans = (i * j) % 2019
    print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
#define COUT(x) cout << (x) << "\n"
#define COUTF(x) cout << setprecision(15) << (x) << "\n"
#define ENDL cout << "\n"
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SZ(x) (ll) x.size()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define MAX(x, y, z) max(a, max(b, c))
#define MIN(x, y, z) min(a, min(b, c))
#define ANS cout << ans << "\n"
#define RETURN(x)    \
  cout << x << "\n"; \
  return 0
clock_t CLOCK;
#define START_TIMER CLOCK = clock()
#define SHOW_TIMER cerr << "time: " << (ld)(clock() - CLOCK) / 1000000 << "\n"
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define LINE cerr << "[debug] line: " << __LINE__ << "\n";
#define debug(x) cerr << "[debug] " << #x << ": " << x << "\n";
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << "\n";
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using mll = map<ll, ll>;
using qll = queue<ll>;
using P = pair<ll, ll>;

constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

signed main() {
  init();
  ll N;
  cin >> N;

  vll ans(N + 10);
  ans[0] = 2;
  ans[1] = 1;
  rep(i, N + 1) {
    if (i <= 1) continue;
    ans[i] = ans[i - 1] + ans[i - 2];
  }

  COUT(ans[N]);

  return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

int main(){
	int x,y;
	char s[100];
	int stack[100];
	int num=0;

	while (scanf("%s", s) != EOF){
		if (s[0] == '+'){
			x = stack[--num];
			y = stack[--num];
			stack[num] = x + y; 
			num++;
		}
		else if (s[0] == '-'){
			x = stack[--num];
			y = stack[--num];
			stack[num] = -x + y;
			num++;

		}
		else if (s[0] == '*'){
			x = stack[--num];
			y = stack[--num];
			stack[num] = x * y;
			num++;

		}
		else {
			x = atoi(s);
			stack[num] = x;
			num++;
		}
	}
	printf("%d\n",stack[--num]);
	return 0;
}

Measured memory_bytes: 548
#include <bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
 
#define endl '\n'
#define loop(i, m, n) for (ll i = m; i < n; i++)
#define loope(i, m, n) for (ll i = m; i <= n; i++)
#define epool(i, m, n) for (ll i = m; i >= n; i--)
#define mod 1000000007
#define mod2 998244353
#define vi vector<ll>
#define fi first
#define se second
#define pb push_back
#define MP make_pair
#define empf emplace_front
#define empb emplace_back
#define ret(x) return cout << x,0;
#define all(v) v.begin(),v.end()
const ll INF=1e18;
const double PI=4*atan(1);

#define SpeedForce                    \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;

ll mpow(ll base,ll exp);
void solve();
ll POW(ll base,ll exp);
ll gcd(ll a,ll b);

ll modInverse(ll n) { 
    return mpow(n, mod-2); 
}
 
ll nCr(ll n, ll r){ 
   if (r==0) 
      return 1; 
    ll fac[n+1]; 
    fac[0] = 1; 
    for (int i=1 ; i<=n; i++) 
        fac[i] = (fac[i-1]*i)%mod; 
    return ((fac[n]* modInverse(fac[r]) % mod * 
            modInverse(fac[n-r]) % mod)%mod)%mod; 
}

int32_t main(){
    SpeedForce
    ll i = 0,j = 0;

    int t;
    t=1;
    //cin >> t;
    while (t--){
        //cout << fixed << setprecision(10);
        solve();
    }
}



void solve(){
    ll n,a,b;
    cin  >> n >> a>> b;
    ll ar[n];
    loop(i,0,n) cin >> ar[i];

    sort(ar,ar+n);
    ll p=0,q=0,r=0;
    loop(i,0,n){
        if(ar[i]<=a) p++;
        else if(ar[i]>=a+1 && ar[i]<=b) q++;
        else r++;
    }

    cout << min(p,min(q,r)) << endl;

}

ll POW(ll base,ll exp){
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base);
        base = ((ll)base * base);
        exp >>= 1;
    }
    return result;
}

ll mpow(ll base, ll exp){
    base %= mod;
    ll result = 1;
    while (exp > 0){
        if (exp & 1)
            result = ((ll)result * base) % mod;
        base = ((ll)base * base) % mod;
        exp >>= 1;
    }
    return result;
}

ll gcd(ll a, ll b){
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

using namespace std;

typedef long long  ll;

#define SIZ 1000000000
#define mod 1000000007

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	// D from 163
	ll n,k;
	cin >> n >> k;
	
	ll ans = 0;
	for(ll i = k - 1; i <= n; i++){
		ans += ((i + 1)*(n - i)) + 1;
		ans = ans%mod;
	}
	
	cout << ans << "\n";
}

Measured memory_bytes: 3620
#include<iostream> 
#include<iomanip> 
#include<vector> 
#include<map> 
#include<set> 
#include<algorithm> 
#include<numeric> 
#include<limits> 
#include<bitset> 
#include<functional> 
#include<type_traits> 
#include<queue> 
#include<stack> 
#include<array> 
#include<random> 
#include<utility> 
#include<cstdlib> 
#include<ctime>
//#define _LIBCPP_DEBUG 0
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define all(a) (a).begin(),(a),end()
#define rep(i,n) for (ll i = 0; i < (ll)(n); ++i)	

int max(ll a, ll b) {
	ll max;
	if (a > b) max = a;
	else max = b;
	return max;
}
int min(ll a, ll b) {
	ll min;
	if (a < b) min = a;
	else min = b;
	return min;
}


int main() {
	int n;
	string s;

	cin >> n;
	cin >> s;
	bool can = true;
	if (s.size() % 2 != 0) {
		cout << "No" << endl;
	}
	else {
		rep(i, n / 2) {
			if (s[i] != s[n / 2 + i]) {
				can = false;
			}
		}
		cout << (can ? "Yes" : "No") << endl;
	}
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/STACK:256000000")
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<string>
#include<stack>
#include<algorithm>
#include<cmath>
#include<set>
#include<queue>
#include<sstream>
#include<utility>
#include<map>
#include<ctime>
#include<cstdio>
#include<cassert>
#include<functional>
#include<unordered_map>
#include<deque>




using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<char, char> pcc;
typedef pair<double, double> pdd;

#define show(x) cerr << x
#define debug(x) show(#x << ": " << (x) << endl)

const long double PI = 3.14159265358979323846;
const long double eps = 1e-5;
const ll INF = numeric_limits<int>::max();
const ll LINF = numeric_limits<ll>::max();
const ll mod = 1000 * 1000 * 1000 + 7;



void solve() {
    int n, k;
    cin >> n >> k;
    cout << n + 1 - k << endl;



}


//#define LOCAL

int main() {
    ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
        solve();



#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif	
    return 0;
}


Measured memory_bytes: 256
import sys
N = int(input())
A = [int(input()) for _ in range(N)]
A.sort()
stack = A[0]
count_num = 1
ans = 0
for i in range(1,N):
        if A[i] == stack:
                count_num += 1
        else:
                if count_num % 2 == 1:
                        ans += 1
                count_num = 1
        stack = A[i]
if count_num%2 == 1:
        ans +=1
print(ans)

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

int main()
{
    int n,k;
    cin>>n>>k;
    map<int,int>mp;
    while(k--)
    {
        int a;
        cin>>a;
        while(a--)
        {
            int b;
            cin>>b;
            mp[b]++;
        }
    }
    int counter=0;
    for(int i=1;i<=n;i++)
    {
        if(mp[i]==0)counter++;
    }
    cout<<counter<<endl;
}


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

int abs(int i, int j) {
  if (i - j > 0) {
    return i - j;
  } else {
    return j - i;
  }
}
int main() {
  int N;
  cin >> N;
  vector<vector<int>> h(N, vector<int>(3));
  vector<vector<int>> cost(N, vector<int>(3));
  rep(i, N) { cin >> h.at(i).at(0) >> h.at(i).at(1) >> h.at(i).at(2); }
  rep(i, 3) { cost.at(0).at(i) = h.at(0).at(i); }
  for (int i = 1; i < N; i++) {
    cost.at(i).at(0) =
        h.at(i).at(0) + max(cost.at(i - 1).at(1), cost.at(i - 1).at(2));
    cost.at(i).at(1) =
        h.at(i).at(1) + max(cost.at(i - 1).at(0), cost.at(i - 1).at(2));
    cost.at(i).at(2) =
        h.at(i).at(2) + max(cost.at(i - 1).at(1), cost.at(i - 1).at(0));
  }
  cout << max(max(cost.at(N - 1).at(0), cost.at(N - 1).at(1)),
              cost.at(N - 1).at(2))
       << endl;
}


Measured memory_bytes: 11136
// AOJ 2838: A-Z-
// 2017.10.10 bal4u@uu

#include <stdio.h>

char s[102];

int main()
{
	int p, k, ans;
	char *t;

	scanf("%s", s);
	ans = 0, p = 0,	t = s;
	while (*t) {
		k = *t++ -'A';
		if (k <= p) ans++;
		p = k;
	}
	printf("%d\n", ans);
	return 0;
}

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

using namespace std;

const double PI = 3.141592;
const int MAX_N = 1e5+5;
const long long MOD = 1e9 + 7;
const long long INF = 1e9 + 7;

const bool dbgEnabled = true;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
typedef pair<string, ll> psi;
typedef pair<ll, string> pis;
typedef vector<pii> vpii;
typedef vector<psi> vpsi;
typedef vector<pis> vpis;
typedef vector<vi> vvi;

// Debug macros
#define dbg(x) do { \
	if (dbgEnabled) { cerr << #x << ": " << x << "\n"; } \
} while (0)

#define dbgv(x) do { \
	if (dbgEnabled) { cerr << #x << ": [ "; for (auto& _ : x) cerr << _ << " "; cerr << "]\n"; } \
} while (0)

#define dbgvv(x) do { \
	if (dbgEnabled) { cerr << #x << ":\n[\n"; for (auto& __ : x) dbgv(__); cerr << "]\n";} \
} while (0)

void dfs(ll i, ll p, vvi &adj, vector<bool> &seen, ll &cnt) {
	if (seen[i]) return;
	seen[i] = true;
	cnt++;
	
	for (auto child : adj[i]) {
		if (child != p) {
			dfs(child, i, adj, seen, cnt);
		}
	}
}

void solve() {
	ll n, m; cin >> n >> m;
	vvi adj(n);
	while (m--) {
		ll a, b; cin >> a >> b; a--, b--;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	ll ans = 0;
	vector<bool> seen(n, false);
	for (ll i = 0; i < n; i++)
		if (!seen[i]) {
			ll cnt = 0;
			dfs(i, -1, adj, seen, cnt);
			ans = max(ans, cnt);
		}
	
	cout << ans << endl;
}

int main() {
	if (!dbgEnabled) {
		ios_base::sync_with_stdio(false);
		cin.tie(nullptr); cout.tie(nullptr);
	}
	
	ll t = 1;
	//cin >> t;
	while(t--) {
		solve();
	}    
    return 0;
}



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

#define sp ' '
using namespace std;

string S;
int c;
bool b;

int main(){
	b = true;
	cin >> S;
	if (S[0] != 'A' ||('A' <= S[1] && S[1] <= 'Z')|| ('A' <= S.back() && S.back() <= 'Z'))
		b = false;
	for (int i = 2; i != S.size(); ++i) {
		if ('A' <= S[i] && S[i] <= 'Z') {
			if (S[i] == 'C') {
				++c;
			}
			else
				b = false;
		}
	}
	if (c != 1)
		b = false;
	if (b)
		cout << "AC" << endl;
	else
		cout << "WA" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main()
{
	int N;
	int box[100];
	int min_pos, count;
	int i, j;


	scanf("%d", &N);

	for(i = 0; i < N; i++)
		scanf("%d", &box[i]);


	count = 0;
	for(i = 0; i < N; i++){
		min_pos = i;
		for(j = i + 1; j < N; j++){
			if(box[j] < box[min_pos])
				min_pos = j;
		}
		if(i != min_pos){
			box[i] ^= box[min_pos];
			box[min_pos] ^= box[i];
			box[i] ^= box[min_pos];
			count++;
		}
	}

	for(i = 0; i < N; i++){
		printf("%d", box[i]);
		if(i != N - 1)
			printf(" ");
	}
	printf("\n%d\n", count);

	return 0;
}


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

int main() {
    int N = 0;
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i++){
        if(s.at(i) == '+' ){
            N++;
        }
        else if(s.at(i) == '-'){
            N -= 1;
        }
    }
    cout << N << endl;
}

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

int main(){
  int n,m,k,l,r;
  int a,b,c;
  double ans;
  string s1, s2;
  cin >> n;
  ans = 0;
  //map<char , int> M;M['0'] = 0;M['1']=1;M[]
  for(int i = 0 ; i < n; i++){
    cin >> s1 >> s2;
    double x = stod(s1.c_str());
    if(s2 == "JPY") ans += x;
    else ans += x*380000.0;
  }
  printf("%.9lf\n", ans);
}


Measured memory_bytes: 256