akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int sq = a*b;
		int ar = (a + b)*2;
		System.out.println(sq + " " + ar);
	}

}

Measured memory_bytes: 26152
#include<bits/stdc++.h>
using namespace std;
typedef struct 
{
    int from;
    int to;
}RANGE;
int main(){
    int K;
    vector<vector<RANGE>> range(1,vector<RANGE>(10));
    vector<string> num;
    vector<RANGE> addrange(10);
    long long base,level;
    int log10,n;
    cin >> K;
    for(int i=0; i<10; i++){
        num.push_back(to_string(i));
        range.at(0).at(i).from=i;
        range.at(0).at(i).to=i;
    }
    level=10;
    log10=1;
    n=9;
    while(1){
        for(int head=0; head<=9; head++){
            base=level*head;
            addrange.at(head).from=num.size();
            if(head==9){
                for(int i=range.at(log10-1).at(8).from; i<=range.at(log10-1).at(9).to; i++){
                    num.push_back(to_string(head)+num.at(i));
                    n++;
                }
            }else if(head==0){
                for(int i=range.at(log10-1).at(0).from; i<=range.at(log10-1).at(1).to; i++){
                    num.push_back(to_string(head)+num.at(i));
                }
            }else{
                for(int i=range.at(log10-1).at(head-1).from; i<=range.at(log10-1).at(head+1).to; i++){
                    num.push_back(to_string(head)+num.at(i));
                    n++;
                }
            }
            addrange.at(head).to=num.size()-1;
        }
        range.push_back(addrange);
        if(n>=K){
            break;
        }else{
            level*=10;
            log10++;
        }
    }
    for(int i=0; ; i++){
        if(num.at(i).at(0)!='0'){
            K--;
        }
        if(K==0){
            cout << num.at(i);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 11632
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
using namespace std;
#define ll long long

int d = 365;
int k = 0;
vector<vector<int>> s(d, vector<int>(26, 0));
vector<ll> c(26);

void init() {
    cin >> d;
    for(int i = 0; i < 26; i++) cin >> c[i];
    for(int i = 0; i < d; i++) {
        for(int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    return;
}

ll calc(vector<int> out) {
    ll score = 0;
    vector<ll> last(26, 0);
    for(int i = 0; i < out.size(); i++) {
        //cout << i << endl;
        last[out[i]] = i+1; // タイプ番号
        //cout << "out[" << i << "] " << out[i] << " ";
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i+1)-last[j]);
        }
        score += s[i][out[i]];
        //cout << "score : " << score << endl;
    }

    //int p = min(int(out.size()+k), int(d));
    //cout << p << endl;
    //if(out.size() >= d) return score;
    //cout << k << endl;
    //cout << out.size() << " " << d << endl;
    int p = min(int(out.size()+13), d);
    for(int i = out.size(); i < p; i++) {
        //cout << i << endl;
        for(int j = 0; j < 26; j++) {
            score -= c[j]*((i)-last[j]);
        }
        //cout << score << endl;
    }
    return score;
}

/*
vector<int> proc(int k) {
    vector<int> out;
    ll ans = 0;
    //ll tmp = 0;
    ll max_v = -1;
    //for(int k = 0; k < 26; k++) {
    //cout << "k: " << k << endl;
    //vector<int> out;
    for(int i = 0; i < d; i++) {
        //max_v = -100000000000;
        max_v = LLONG_MIN;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            ll tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            out.pop_back();
        }
        out.push_back(best);
    }
    //}
    return out;
}
*/

int main() {
    init();
    /*
    vector<int> out;
    vector<int> ans;
    for(int i = 0; i <= 26; i++) {
        out = proc(i);
        for(int j = 0; j < out.size(); j++) {

        }
    }
    */
    
    vector<int> out;
    ll ans = 0;
    ll max_v = -1;
    //for(int k = 0; k < 26; k++) {
        //cout << "k: " << k << endl;
        //vector<int> out;
    for(int i = 0; i < d; i++) {
        //max_v = -100000000000;
        max_v = LLONG_MIN;
        int best = 0;
        for(int j = 0; j < 26; j++) {
            out.push_back(j);
            ll tmp = calc(out);
            if(max_v < tmp) {
                max_v = tmp;
                best = j;
            }
            out.pop_back();
        }
        out.push_back(best);
    }
    //}
    
    for(int i = 0; i < d; i++) {
        cout << out[i]+1 << endl;
    }
    //cout << max_v << endl;
    return 0;
}

Measured memory_bytes: 3744
#include <stdio.h>
char s[200005];
int main(){
	int n,l,r,cnt;
	scanf("%d%s",&n,s);
	l=0,r=n-1,cnt=0;
	while(l<r){
		while(s[l]=='R')l++;
		while(s[r]=='W')r--;
		if(l<r)cnt++,s[l]='R',s[r]='W';
	}
	printf("%d\n",cnt);
	return 0;
}

Measured memory_bytes: 1856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

struct UnionFind {
    vector<int> par;

    UnionFind(int N) : par(N) {
        REP(i, N) par[i] = i;
    }

    int root(int x) {
        if (par[x] == x) return x;
        return par[x] = root(par[x]);   
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if (rx == ry) return;
        par[rx] = ry;
    }

    bool same(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

int main() {
    int n, q; cin >> n >> q;
    UnionFind tree(n);
    REP(i, q) {
        int com, x, y; cin >> com >> x >> y;
        if (com == 0) tree.unite(x, y);
        else {
            if (tree.same(x, y)) PRINT(1);
            else PRINT(0);
        }
    }
    return 0;
}


Measured memory_bytes: 3136
def Search(g,t):
    if t<= 0: return 100000000000
    n=min(int(g/(100*t)),p[t-1])
    s=100*t*n
    if n==p[t-1]:
        s=sum[t-1]
    if g>s:
        n+=Search(g-s,t-1)
    return min(n,Search(g,t-1))
d,g=map(int,input().split())
p=[]
c=[]
sum=[]
for i in range(d):
    a,b=map(int,input().split())
    p.append(a)
    c.append(b)
for i in range(d):
    sum.append((i+1)*100*p[i]+c[i])
print(Search(g,d))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
static const int INF = 0x3f3f3f3f; static const long long INFL = 0x3f3f3f3f3f3f3f3fLL;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
template<typename T, typename U> static void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> static void amax(T &x, U y) { if(x < y) x = y; }

int main() {
	char s[100001];
	while(~scanf("%s", s)) {
		int n = (int)strlen(s);
		pair<int, int> ans(-1, -1);
		rep(i, n - 1) if(s[i] == s[i + 1])
			ans = make_pair(i, i + 1);
		rep(i, n - 2) if(s[i] == s[i + 2])
			ans = make_pair(i, i + 2);
		if(ans.first == -1)
			puts("-1 -1");
		else
			printf("%d %d\n", ans.first + 1, ans.second + 1);
	}
	return 0;
}


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

#define ll long long
const int mx = 2e5;

int main(void){
  int N,A[mx],num[mx];
  ll wholeAns;
  cin >> N;
  for(int i=0; i<N; i++){//読み込み初期化
    cin >> A[i];
    num[i]=0;
  }
  for(int i=0; i<N; i++){//数を数える
    num[A[i]-1]++;
  }
  for(int i=0; i<N; i++){//Cを計算
    if(num[i]>1){
      ll x = num[i];
      ll y = x*(x-1)/2;
      wholeAns += y;
      
      //cout << "i:"<<i<<"num:" << num[A[i]-1]<<" y:" <<y<<"\n";
     }
  }
  for(int i=0; i<N; i++){//回答
    if(i!=0) cout << "\n";
    cout << wholeAns -num[A[i]-1] +1;
  }//*/
  
  return 0;
}

Measured memory_bytes: 4096
a = int(input())
b = int(input())
c = int(input())
x = int(input())

ans = 0

for i in range(c, -1, -1):#50
	for j in range(b, -1, -1):#100
		for k in range(a, -1, -1):#500
			if x == i*50 + j*100 + k*500:
				ans += 1
			
print(ans)


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

// 深さ優先探索
vector<bool> seen;
int N, M, a, b;
vector<vector<int>> G(2e5+100);
vector<int> ans(2e5+100, -1);
void bfs() {
    queue<int> q;
    q.push(1);
    while(!q.empty()){
	int v = q.front();
	q.pop();
	for(auto next_v: G[v]){
	    if(seen[next_v]==false){
		seen[next_v]=true;
		ans[next_v]=v;	    
		q.push(next_v);
	    }
	}
    }
}

int main(){
    cin >> N >> M;
    for(int i=0; i<M; i++){
	cin >> a >> b;
        G[a].push_back(b);
	G[b].push_back(a);
    }
    ans[1]=0;
    seen.assign(N+1, false); // 全頂点を「未訪問」に初期化
    seen[1]=true;
    bfs();

    for(int i=1; i<=N; i++){
	if(ans[i]==-1){
	    cout << "No" << endl;
	    return 0;
	}
    }
    cout << "Yes" << endl;

    for(int i=2; i<=N; i++){
	cout << ans[i] << endl;
    }




}


Measured memory_bytes: 12944
import java.util.*;

class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        //入力値を設定する
        Integer numSlime = sc.nextInt();
        String slimeColor = sc.next();
        //スライムの色を一匹ずつ格納する
        List<String> colors = Arrays.asList(slimeColor.split(""));
        
        // スライムの数。必ず1匹以上いる条件であるため初期値を1とする
        Integer cnt = 1;
        
        for (int i = 0; i < numSlime; i++) {
            //1つ前の文字（色）と同じでなければ融合しないため、スライム数のカウントを1増加させる
            if(i > 0 && !colors.get(i).equals(colors.get(i - 1))) {
                cnt++;
            }
        }
        
        //出力する
        System.out.println(cnt);
    }    
}

Measured memory_bytes: 32516
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64,i64> P;
#define rep(i,s,e) for(int i = (s);i <= (e);i++)

int n;

int a[202020];
int b[202020];

int main(){
	cin >> n;
	rep(i,0,n - 1) cin >> a[i];
	rep(i,0,n - 1) cin >> b[i];
	int ans = 0;
	for(int v = (1 << 28) ; v ; v >>= 1){
		rep(i,0,n - 1) a[i] &= (v * 2 - 1);
		rep(i,0,n - 1) b[i] &= (v * 2 - 1);
		sort(a,a + n);
		sort(b,b + n);
		int t = 0;
		for(int i = n - 1,j = 0,k = 0,l = 0;i >= 0;i--){
			while(j < n && a[i] + b[j] < v) j++;
			while(k < n && a[i] + b[k] < 2 * v) k++;
			while(l < n && a[i] + b[l] < 3 * v) l++;
			t += k - j + n - l;
			t &= 1;
		}
		if(t) ans |= v;
	}

	cout << ans << endl;
	return 0;
}


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

int main(){
	int n, m, c; cin >> n >> m >> c;
	vector<int> b(m);
	for(int i = 0; i < m; i++)
		cin >> b[i];
	vector<vector<int>> a(n, vector<int>(m));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++)
			cin >> a[i][j];
	}

	int res = 0;
	for(int i = 0; i < n; ++i){
		int tmp = 0;
		for(int j = 0; j < m; ++j)
			tmp += a[i][j] * b[j];
		if(tmp + c > 0)
			res++;
	}

	cout << res << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	int N;
	int a[200];
	int count = 0;
	cin >> N;


	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	while (true) {
		bool odd_flag = false;
		//奇数かどうかの判定
		for (int j = 0; j < N; j++) {
			if (a[j] % 2 != 0) {
				odd_flag = true;
			}
		}
		//flagがtrueならwhile文を抜ける
		if (odd_flag) break;
		//実際に2で÷処理をする
		for (int k = 0; k < N; k++) {
			a[k] /= 2;
		}
		count++;
	}
	printf("%d", count);
}


Measured memory_bytes: 3172
S=gets.chomp.split('').map(&:to_i)
#puts "S=#{S}"
N=S.size
total=0
(0...(1<<(N-1))).each{|mask|
    sum=0
    val=S[0]
    #puts "mask=#{mask}"
    (0...(N-1)).each{|i|
        #puts "  before: i=#{i} mask&(1<<i)=#{mask&(1<<i)} sum=#{sum} val=#{val}"
        if mask&(1<<i) !=0
            sum+=val
            val = S[i+1]
        else
            val *=10
            val +=S[i+1]
        end
        #puts "  after : i=#{i} mask&(1<<i)=#{mask&(1<<i)} sum=#{sum} val=#{val}"
    }
    sum+=val
    
    total += sum
    #puts "sum=#{sum} total=#{total}"
}
puts total


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

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

    int n;
    cin >> n;

    if(n == 1 or n == 0){
        cout << n << endl;
        return 0;
    }

    vector<int> Ans;
    while(true){
        if(n < 0){
            int r = abs(n) % 2;
            n = (abs(n) + 1) / 2;
            Ans.push_back(r);
        }else{
            int r = n % 2;
            n = -1 * (n / 2);
            Ans.push_back(r);
        }
        if(n == 1){
            Ans.push_back(1);
            break;
        }
    }

    reverse(Ans.begin(), Ans.end());

    for(auto x: Ans){
        cout << x;
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
typedef double ld;
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define PRECISION std::cout << std::fixed << std::setprecision(20);
  
using namespace std;
 
const ll inf = 1e18;
const ll N = 4e2+10;
const ll bits = 21;
const ll mod = 1e9+7;
const ld pi = 3.14159265358979323846;

ll dp[N][N],sum[N][N];

int main(){
    FASTIO;
    PRECISION;

    ll n,k,temp;
    cin>>n;

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            dp[i][j] = inf;
        }

        cin>>dp[i][i];
    }

    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=i;k<=j;k++){
                sum[i][j]+=dp[k][k];
            }
        }

    }

    for(int i=1;i<=n;i++){
        dp[i][i] = 0;
    }    

    for(int sz=2;sz<=n;sz++){
        for(int i=1;i+sz-1<=n;i++){
            int j = i+sz-1;
            for(int k=i;k+1<=j;k++){
                dp[i][j] = min(dp[i][j],dp[i][k]+dp[k+1][j] + sum[i][k] + sum[k+1][j]);
            }
            // cout<<i<<" "<<j<<" "<<dp[i][j]<<"\n";
        }

    }

    cout<<dp[1][n]<<"\n";
    

    

}

Measured memory_bytes: 2816
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

int asc(const void* a, const void* b) {
	return *(int*)a- *(int*)b;
}

int main()
{
	int d, n;
	cin >> d >> n;
	int f = 1;
	rep(i, d) f *= 100;
	if (d == 0 && f * n == 100) cout << f * n + 1 << endl;
	else if (d == 1 && f * n == 10000) cout << f * n + 100 << endl;
	else if (d == 2 && f * n == 1000000) cout << f * n + 10000 << endl;
	else cout << f * n << endl;
}

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

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

Measured memory_bytes: 256
import sys



n, ma, mb = map(int, input().split())
abc = []

for _ in range(n):
    a, b, cost = map(int, input().split())
    abc.append((a, b, cost))

def main():
    sa = 0
    sb = 0
    for i in range(n):
        sa += abc[i][0]
        sb += abc[i][1]

    res = [[float('infinity')] * (sb + 1) for _ in range(sa + 1)]
    res[0][0] = 0

    for a, b, c in abc:

        for j in range(sa, -1, -1):
            for k in range(sb, -1, -1):
                if j >= a and k >= b:
                    res[j][k] = min(res[j][k], res[j-a][k-b] + c)

    ans = float('infinity')
    for i in range(1, min(sa//ma, sb//mb) + 1):
        ans = min(ans, res[ma*i][mb*i])

    if ans == float('infinity'):
        return -1
    else:
        return ans

if __name__ == '__main__':
    ans = main()
    print(ans)

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

int N;
vector<int> A(101);

void solve(){
    bool ap = true;
    for(int i = 1; i <= N; ++i){
        if(A[i] % 2 == 0 && A[i] % 3 != 0 && A[i] % 5 != 0) ap = false;
    }
    if(ap) cout << "APPROVED";
    else cout << "DENIED";
}
int main(){
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> A[i];
    }
    solve();
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;

namespace ABC072_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine();
            var ch = new List<char>();
            for(var i=0;i<str.Length;i++)
            {
                if(i%2 == 0)
                {
                    ch.Add(str[i]);
                }
            }
            var ch2 = ch.ToArray();
            var ans = new String(ch2);
            Console.WriteLine(ans);
        }
    }
}


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

int main() {
    ll n;
    cin>>n;
    ll ans = 0;
    ll co = 0;
    for(ll i = 1;;i++){
        if(co==n){
            break;
        }
        co++;
        if(i%3!=0&&i%5!=0){
            ans+=i;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
const int M=501;
int n,k,A[M],ans,sum;
void Check(int x){
	long long res=0,cnt=0;
	int Q[M];
	for(int i=1;i<=n;i++)Q[i]=A[i]%x;
	sort(Q+1,Q+n+1);
	for(int i=1;i<=n;i++)cnt+=x-Q[i];
	for(int i=1;i<=n;i++){
		res+=Q[i];
		cnt-=x-Q[i];
		if(res==cnt)break;
	}
	if(res<=k)ans=max(ans,x);
}
int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&A[i]),sum+=A[i];
	int q=sqrt(sum);
	for(int i=1;i<=q;i++){
		int t=sum/i;
		if(t*i!=sum)continue;
		Check(i);
		Check(t);
	}
	printf("%d\n",ans);
}

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

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
const int INF = INT_MAX;
const ll MOD = 998244353;

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int N,A,B;
    cin >> N >> A >> B;
    int dif = A-B;
    vint h(N);
    repeat(i, N){
        cin >> h[i];
    }
    
    ll low = 0,high = 1e9+1;
    while(high-low>1){
        ll mid = (low+high)/2;
        ll cnt = 0;
        repeat(i, N){
            ll hleft = h[i]-B*mid;
            if(hleft<=0) continue;
            cnt += (hleft-1)/dif+1;
        }
        if(cnt <= mid){
            high = mid;
        }else{
            low = mid;
        }
    }
    cout << high << endl;
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

/*
1
1 0 0 1 0 0 0 0 0 1
3 4 5 6 7 8 9 -2 -3 4 -2
*/

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

  const int kPeriods = 10;

  vector<int> F(N);
  rep(i, N) {
    int f = 0;

    rep(i, kPeriods) {
      int tmp;
      cin >> tmp;
      f += tmp;
      if (i < kPeriods-1) {
        f <<= 1;
      }
    }

    F[i] = f;
  }

  vector<vector<int>> P(N);
  rep(i, N) {
    P[i].resize(kPeriods+1);
    rep(j, kPeriods+1) {
      cin >> P[i][j];
    }
  }

  bool first = true;
  long long mx;
  for (int i = 1; i < 1<<kPeriods; i++) {
    long long sum = 0;

    rep(j, N) {
      int count = 0;
      rep(k, kPeriods) {
        int tmp = i >> k;
        int tmp2 = F[j] >> k;

        if (tmp % 2 & tmp2 % 2) count++;
      }

      sum += P[j][count];
    }

    if (first || mx < sum) {
      mx = sum;
      first = false;
    }
  }

  cout << mx << endl;

  return 0;
}


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

/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
//#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define pb push_back


/* alias */


template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
const int inf = 1000100010010010;
const int mod = 1e9 + 7;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};
const string alpha = "abcdefghijklmnopqrstuvwxyz";

/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

bool exist(vec<int> v, int n){
	rep(i,0,v.size()) if(v[i] == n) return true;
	return false;
}


/* main */

template<typename T>
auto cut(T &a, int l, int r){
    return T(a.begin()+l, a.begin()+r);   
}

int n, m;
int len[100010];

vec<vi> edges(100010);

int dfs(int v){

	if(len[v] > -1) return len[v];

	int ans = 0;
	rep(i,0,edges[v].size()){
		chmax(ans, 1 + dfs(edges[v][i]));
	}

	return len[v] = ans;

}



signed main(){


    cin.tie(0);
    ios::sync_with_stdio(false);

	cin >> n >> m;
	memset(len, -1, sizeof(len));

	rep(i,0,m){
		int f, t; cin >> f >> t; f--; t--;
		edges[f].push_back(t);

	}

	int ans = 0;

	rep(i,0,n) chmax(ans, dfs(i));

	print(ans);
	


	
	


	




	




    



	








    



    





    


    

}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	double n, m, d;
	cin >> n >> m >> d;
	double res;
	if(d>0) res = ((1.0)*2*(n-d)*(m-1))/(n*n);
	else res = ((1.0)*(m-1))/(1.0*n);
	printf("%.15f\n", res);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int x,t=0,i=1;
  cin>>x;
  while(t+i<x){
    t+=i;
    i++;
  }
  cout<<i;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
using ll = long long;

int n, k, h[200010];
int main() {
	scanf("%d %d", &n, &k);
	for (int i = 0; i < n; i++)
		scanf("%d", h + i);
	sort(h, h + n);
	ll s = 0;
	for (int i = 0; i < n - k; i++)
		s += h[i];
	printf("%lld\n", s);
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <map>
#include <numeric>
#include <random>
#include <queue>
#include <deque>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;

const int INF = (1 << 30) - 1;
const ll INFLL= (1LL << 61) - 1;
const int MOD = 1000000007;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  int K,N;
  cin>>S>>K;
  N=S.length();
  vector<string> SS;
  SS.reserve(30000);

  for(int i=0;i<N;i++){
    SS.push_back(S.substr(i,1));
  }
  for(int i=0;i<N-1;i++){
    SS.push_back(S.substr(i,2));
  }
  for(int i=0;i<N-2;i++){
    SS.push_back(S.substr(i,3));
  }
  for(int i=0;i<N-3;i++){
    SS.push_back(S.substr(i,4));
  }
  for(int i=0;i<N-4;i++){
    SS.push_back(S.substr(i,5));
  }
  sort(ALL(SS));
  SS.erase(unique(SS.begin(),SS.end()),SS.end());
  cout<<SS[K-1]<<endl;
}


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

using namespace std;

bool isOK(auto &x, auto &y)
{
	if (x.size() != y.size())
	{
		return 0;
	}
	for (int i = 0; i < x.size(); ++i)
	{
		if (x[i] != y[i])
			return 0;
	}
	return 1;
}

int main()
{
	int n;
	while (cin >> n, n)
	{
		int m;
		cin >> m;
		vector<pair<int, int>> o(m - 1), p(m - 1), q(m - 1), r(m - 1);
		int prex, prey;
		cin >> prex >> prey;
		for (int i = 1; i < m; ++i)
		{
			int x, y, xx, yy;
			cin >> x >> y;
			xx = x;
			yy = y;
			x -= prex;
			y -= prey;
			o[i - 1] = {x, y};
			p[i - 1] = {-x, -y};
			q[i - 1] = {-y, x};
			r[i - 1] = {y, -x};
			prex = xx;
			prey = yy;
		}
		for (int i = 0; i < n; ++i)
		{
			cin >> m;
			vector<pair<int, int>> s(m - 1);
			cin >> prex >> prey;
			for (int i = 1; i < m; ++i)
			{
				int x, y, xx, yy;
				cin >> x >> y;
				xx = x;
				yy = y;
				x -= prex;
				y -= prey;
				s[i - 1] = {x, y};
				prex = xx;
				prey = yy;
			}
			if (isOK(o, s))
			{
				cout << i + 1 << endl;
				continue;
			}
			if (isOK(p, s))
			{
				cout << i + 1 << endl;
				continue;
			}
			if (isOK(q, s))
			{
				cout << i + 1 << endl;
				continue;
			}
			if (isOK(r, s))
			{
				cout << i + 1 << endl;
				continue;
			}
			reverse(s.begin(), s.end());
			if (isOK(o, s))
			{
				cout << i + 1 << endl;
				continue;
			}
			if (isOK(p, s))
			{
				cout << i + 1 << endl;
				continue;
			}
			if (isOK(q, s))
			{
				cout << i + 1 << endl;
				continue;
			}
			if (isOK(r, s))
			{
				cout << i + 1 << endl;
				continue;
			}
		}
		cout << "+++++" << endl;
	}
}


Measured memory_bytes: 3004
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;
const int MOD = (int)1e9 + 7;

int main(void){
	int X, A;
	cin >> X >> A;

	cout << (X < A ? 0 : 10) << '\n';

	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    sort(all(A));

    cout << accumulate(A.begin(),A.begin()+K,0) << ln;
}

Measured memory_bytes: 3608
#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	long long h,n,ai;
	cin>>h>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>ai;
		h-=ai;
	}
	if(h<=0)
	{
		cout<<"Yes";
	}
	else cout<<"No";
}

Measured memory_bytes: 256
import sys
import numpy as np
import numba
from numba import njit
i8 = numba.int64

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

@njit((i8[:], i8[:]), cache=True)
def f(X, P):
    INF = 10**18
    ind = np.argsort(X)
    X, P = X[ind], P[ind]
    N = len(X)
    if N == 0:
        return np.array([0], np.int64)
    # [0, i) から X[j] までのコストの和
    dp1 = np.zeros((N + 1, N), np.int64)
    for i in range(N):
        for j in range(N):
            dp1[i + 1, j] = np.abs(X[i] - X[j]) * P[i]
    for i in range(N):
        dp1[i + 1] += dp1[i]

    # [l, r]をひとまとめにするときのコストの最小値
    dp2 = np.empty((N, N), np.int64)
    for l in range(N):
        for r in range(l, N):
            dp2[l, r] = (dp1[r + 1] - dp1[l]).min()

    # [0,i] を j 件でとる場合のコストの最小値
    dp3 = np.full((N, N + 1), INF, np.int64)
    for i in range(N):
        dp3[i, 0] = np.sum(X[:i + 1] * P[:i + 1])
        dp3[i, 1] = dp2[0, i]
        for j in range(i):
            # [0,j] + (j,i]
            dp3[i, 1:] = np.minimum(dp3[i, 1:], dp3[j, :-1] + dp2[j + 1, i])
    return dp3[-1]

@njit((i8[:], i8[:]), cache=True)
def merge(A, B):
    LA, LB = len(A), len(B)
    INF = 10**18
    C = np.full(LA + LB - 1, INF, np.int64)
    for i in range(LA):
        C[i:i + LB] = np.minimum(C[i:i + LB], A[i] + B)
    return C

@njit((i8[:], ), cache=True)
def main(XYP):
    X, Y, P = XYP[::3], XYP[1::3], XYP[2::3]
    N = len(X)
    INF = 10**18
    ans = np.full(N + 1, INF, np.int64)
    full = (1 << N) - 1
    for x in range(1 << N):
        i_x = np.bool_([x & (1 << i) for i in range(N)])
        i_y = ~i_x
        dp = f(X[i_x & (X >= 0)], P[i_x & (X >= 0)])
        dp = merge(dp, f(-X[i_x & (X < 0)], P[i_x & (X < 0)]))
        dp = merge(dp, f(Y[i_y & (Y >= 0)], P[i_y & (Y >= 0)]))
        dp = merge(dp, f(-Y[i_y & (Y < 0)], P[i_y & (Y < 0)]))
        ans = np.minimum(ans, dp)
    return ans

N = int(readline())
XYP = np.array(read().split(), np.int64)

ans = main(XYP)
print('\n'.join(map(str, ans.tolist())))

Measured memory_bytes: 111880
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main{
    static MyReader in = new MyReader();
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args){
        int N, X, Y; {int[] a = in.ii(); N = a[0]; X = a[1]; Y = a[2];}
        int[] ans = new int[N];
        for(int i = 1; i < N; i++){
            for(int j = i+1; j <= N; j++){
                int tmp = Math.min(j - i, Math.abs(X - i) + 1 + Math.abs(Y - j));
                ans[tmp]++;
            }
        }
        for(int i = 1; i < N; i++){
            out.println(ans[i]);
        }
        out.flush();
    }

    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }

        String s(){
            try{return readLine();}catch(IOException e){return "";}
        }

        String[] ss(){
            return s().split(" ");
        }

        int i(){
            return Integer.parseInt(s());
        }

        int[] ii(){
            String[] ss = ss();
            int[] ii = new int[ss.length];
            for(int j = 0; j < ss.length; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }

        ArrayList<Integer> li(){
            String[] ss = ss();
            ArrayList<Integer> li = new ArrayList<>();
            for(int j = 0; j < ss.length; j++) li.add(Integer.parseInt(ss[j]));
            return li;
        }

        long l(){
            return Long.parseLong(s());
        }

        long[] ll(){
            String[] ss = ss();
            long[] ll = new long[ss.length];
            for(int j = 0; j < ss.length; j++) ll[j] = Long.parseLong(ss[j]);
            return ll;
        }
    }
}


Measured memory_bytes: 22740
N = int(input())
S = []
AC,WA,TLE,RE = 0,0,0,0

for _ in range(N):
    S.append(input())

for i in range(N):
    if S[i] == "AC":
        AC += 1
    elif S[i] == "WA":
        WA += 1
    elif S[i] == "TLE":
        TLE += 1
    else:
        RE += 1

print("AC x " + str(AC))
print("WA x " + str(WA))
print("TLE x " + str(TLE))
print("RE x " + str(RE))

Measured memory_bytes: 16184
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];puts("");}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
// int dx[]={0,1,0,-1};
// int dy[]={1,0,-1,0};//RDLU
#define yes puts("YES")
#define no puts("NO")

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

	string s;
	cin>>s;
	int c=0;
	rep(i,s.size())if(s[i]-'0')c++;
	else c--;
	cout<<s.size()-abs(c)<<endl;
}


Measured memory_bytes: 512
a,b,x = map(int,input().split())
ans = 0
# for i in range(a,b+1):
#     if i%x==0:
#         ans += 1

def f(n):
    count = 0
    if n == -1:
        return 0
    else:
        count = n//x + 1 #切り捨て除算　あまりを求める時のチップスtip
        # n以下の整数でxで割り切れるものは，整数nの中にxが何個入るか？という問題に置き換えられる．
        return count

ans = f(b)-f(a-1)

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  ll num[5];
  ll ans=0;
  ll mi=llINF;
  ll po=-1;
  for(int i=0;i<5;i++){
    cin>>num[i];
    if(mi>num[i]){
      mi=num[i];
      po=i;
    }
  }
  cout<<(n/mi+(n%mi!=0))+4<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <assert.h>
#include <stdio.h>
#include <string.h>

/*
	入力例：
	3
	1 1 3
*/
int main(){
	int i,j;
	int strInput[2];
	for(int i=0;i<2;i++){
	 scanf("%d", &strInput[i]);
	}
	int iFruitCnt;
	iFruitCnt= strInput[0];
	int iSelectNum;
	iSelectNum=strInput[1];
	int strInput2[iFruitCnt];
	for(int i=0;i<iFruitCnt;i++){
	 scanf("%d", &strInput2[i]);
	}
	int tmp;
	  for (i=0; i<iFruitCnt; ++i) {
	    for (j=i+1; j<iFruitCnt; ++j) {
	      if (strInput2[i] > strInput2[j]) {
		tmp =  strInput2[i];
		strInput2[i] = strInput2[j];
		strInput2[j] = tmp;
	      }
	    }
	  }
	int iRet;
	iRet = 0;
	for(i=0;i<iSelectNum;i++){
		iRet += strInput2[i];
	}

	printf("%d\n",iRet);
  return 0;
}

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

const int N = 1e5 + 100, inF = N;

int n, k, ans, out[N], dis[N];
bool mark[N];
vector<int> in[N];

void dfs(int v, bool change = false) {
	mark[v] = change;
	for (int u: in[v]) 
		if(mark[u] == false) {
			dis[u] = dis[v] + 1;
			dfs(u, change);
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> k;
	cin >> out[0];
	ans += (out[0] != 1);
	
	for (int i = 1; i < n; i++) {
		cin >> out[i];
		in[--out[i]].push_back(i);
	}
	dfs(0);
	vector<int> vec(n);
	iota(vec.begin(), vec.end(), 0);
	sort(vec.begin(), vec.end(), [](int a, int b) {
		return dis[a] > dis[b];
	});
	for (int u: vec) {
		if(mark[u] || dis[u] <= k)
			continue;
		for (int i = 0; i < k - 1; i++)
			u = out[u];
		ans++;
		dfs(u, true);
	}
	cout << ans;
	return 0;
}///////////////////////////////////////

Measured memory_bytes: 11648
#include"bits/stdc++.h"
using namespace std;

int main()
{
    int N;
    long Y;
    cin >> N;
    cin >> Y;

    if (Y < 1000 * N || 10000 * N < Y) {
        cout << "-1 -1 -1" << endl;
        return 0;
    }

    for (int man = 0; man <= N; man++) {
        for (int gosen = 0; gosen <= (N - man); gosen++) {
            int sen = N - man - gosen;
            long sum = man * 10000 + gosen * 5000 + sen * 1000;
            if (Y == sum) {
                cout << man << " " << gosen << " " << sen << endl;
                return 0;
            }
        }
    }

    cout << "-1 -1 -1" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int n;
    cin >> n;
    cout << 800*n - n / 15 * 200 <<endl;
    return 0;
}

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

using namespace std;

struct data_t {
	string name;
	double eff;

	bool operator<(const data_t& right) const {
		if (eff == right.eff) {
			return (name < right.name);
		}
		else {
			return (eff > right.eff);
		}
	}
};

int main(void) {
	int N;
	while (cin >> N, N) {
		vector<data_t> data(N);
		int p,temp,d,e,f,m,s;
		for (int i = 0; i < N; ++i) {
			cin >> data[i].name;
			cin >> p; 
			int time = 0;
			for (int i = 'A'; i <= 'C'; ++i) {
				cin >> temp;
				time += temp;
			}
			cin >> d >> e >> f >> s >> m;
			time += m * (d + e);
			data[i].eff = (double)((f * m * s) - p)/(double)time;
		}

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

		for (int i = 0; i < N; ++i) {
			cout << data[i].name << endl;
		}
		cout << "#" << endl;
	}
	return 0;
}

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

const int MAX_N = 10000 + 100;

int a[MAX_N];
int b[MAX_N];

int main() {
  
  int n;
  
  scanf ( "%d" , &n );
  
  for (int i=0 ; i < n ;i++ ){
    scanf("%d", &a[i] );
  }
  
  
  for (int i=0 ; i < n ;i++ ){
    scanf("%d", &b[i] );
  }
  
  
  long long free = 0;
  
  for ( int i = 0 ; i < n; i++ ) {
    
    if ( a[i] > b[i] ) {
      free -= ( a[i] - b[i] );
    }
    else if ( b[i] > a[i] ) {
      free += ( b[i] - a[i] ) / 2;
    }
      
  }
  
  if ( free >= 0 ) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  

  
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

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

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

  int fst = 0;
  int snd = 0;
  int trd = 0;
  for (int i = 0; i < n; i++) {
    if (p[i] <= a) {
      fst++;
    } else if (p[i] <= b) {
      snd++;
    } else {
      trd++;
    }
  }

  int ans = min({fst, snd, trd});

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
//#define opti
#ifdef opti
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast,unroll-loops,fast-math")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#endif

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

typedef long long int ll;
typedef long long int LL;
typedef unsigned long long int ull;
ll power(ll x,ll y,ll p){ll r=1; x=x%p; while(y){ if(y&1) r= r*x%p; y=y>>1; x=x*x%p; } return r; }
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;*/

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int csrand(int l=0, int r=1e9){
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}

#define IO              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define FILEIO          freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define all(v)          v.begin(),v.end()
#define PR(a)           cout<<"("<<a<<")";
#define ED              cout<<'\n';
#define endl            '\n'
#define loop(j,a,n)     for(int j=a;j<=n;j++)
#define loop1(j,a,n)    for(int j=a;j>=n;j--)
#define fr1(j,n)        for(int j=0;j<n;j++)
#define fr(n)           for(int i=0;i<n;i++)
#define trav(x,s)       for(auto x:s)
#define SC(n)           scanf("%d",&n)
#define PB              push_back
#define MP              make_pair
#define pii             pair<int,int>
#define pll             pair<long long int,long long int>
#define F               first
#define S               second 
#define binf            2000000000000000001
#define mod             1000000007

const int N=1e5+99;
ll m,n,in[N],out[N];
vector<ll> pf[N],sf[N],g[N];

void dfs1(int v,int p)
{
    in[v]=out[v]=1; 
    int sz=g[v].size();
    
    pf[v].resize(sz+2,1);
    sf[v].resize(sz+2,1);
    
    for(int i=0;i<g[v].size();i++)
    {
        int x=g[v][i];

        
        if(x==p)
           { (pf[v][i]=((i)?pf[v][i-1]:1))%=m;    continue;}

        dfs1(x,v);
        (pf[v][i]=(1+in[x])* ((i)?pf[v][i-1]:1))%=m;
        
        in[v]=(in[v]*(in[x]+1))%m;
    }

    for(int i=sz-1;i>=0;i--)
    {
        int x=g[v][i];  
        //if(v==5) {PR(x) ED}
        sf[v][i]=(sf[v][i+1]*((x==p)?1:(1+in[x])))%m;
        if(x==p) continue;
        out[x] = (1*sf[v][i+1]);
        //if(x==6)PR(out[x])
        if(i!=0) out[x]=(out[x]*pf[v][i-1])%m;        
        //if(x==6)PR(out[x])ED
    }
}

void dfs2(int v,int p)
{
    trav(x,g[v])
    {
        if(x==p) continue;
        out[x]=(out[x]*(out[v])+1)%m;
        dfs2(x,v);
    }
}


int main() 
{
    IO
    cin>>n>>m;
    fr(n-1)
    {
        int x,y,v;
        cin>>x>>y;
        g[x].PB(y);
        g[y].PB(x);
    }

    dfs1(1,1);
    dfs2(1,1);
   
    for(int i=1;i<=n;i++)
    {
        // PR(i) cout<<"   ";PR(in[i])PR(out[i])
        cout<<(1LL*in[i]*out[i])%m<<endl;
    }




}




 

Measured memory_bytes: 30976
#include <iostream>
#include <algorithm>
using namespace std;
int h;
int w=5;
int tbl[10][10];
int main(){
  while(cin>>h,h){
    for(int i=0;i<h;++i) for(int j=0;j<w;++j) cin >>tbl[h-i-1][j];
    int score=0;
    while(true){
      bool dis = false;
      for(int i=0;i<h;++i){
	int c = 1;
	int cur = tbl[i][0];
	for(int j=1;j<=w;++j){
	  if(tbl[i][j]==cur){
	    ++c;
	  }
	  else{
	    if(c>=3 && cur){
	      dis=true;
	      score+=cur*c;
	      for(int k=0;k<c;++k) tbl[i][j-k-1]=0;
	      break;
	    }
	    cur = tbl[i][j];
	    c=1;
	  }
	}
      }
      if(!dis) break;
      for(int j=0;j<w;++j){
	int tmp[10]={};
	int p=0;
	for(int i=0;i<h;++i) if(tbl[i][j]!=0) tmp[p++]=tbl[i][j];
	for(int i=0;i<h;++i) tbl[i][j]=tmp[i];
      }
    }
    cout << score << endl;
  }
  return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<stack>
#include<cmath>
#include<climits>
using namespace std;

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

int N, M;

struct Data{
	int y, x, cost;
	Data(){}
	Data(int _y, int _x, int _cost){
		y = _y; x = _x; cost = _cost;
	}
};

bool IsOutside(int y, int x){
	return y < 0 || N <= y || x < 0 || M <= x;
}

int main(){
	while(cin >> N >> M, N || M){
		swap(N, M);
		
		char fld[100][100];
		queue<Data> q;
		Data q_front;
		int cost[100][100];
		fill_n( (int*)cost, 100*100, INT_MAX );

		for(int i = 0; i < N; i++){
			for(int j = 0; j < M; j++){
				cin >> fld[i][j];
				if(fld[i][j] == '&') q.push( Data(i, j, 0) );
			}
		}

		int ans = INT_MAX;
		while( !q.empty() ){
			q_front = q.front(); q.pop();
			if(cost[q_front.y][q_front.x] <= q_front.cost) continue;
			cost[q_front.y][q_front.x] = q_front.cost;

			for(int i = 0; i < 4; i++){
				int ny = q_front.y + dy[i], nx = q_front.x + dx[i];
				
				if( IsOutside(ny, nx) ){
					ans = min(ans, q_front.cost);
				}
				else{
					int cnt = 0;
					if(fld[q_front.y][q_front.x] != '#' && fld[ny][nx] == '#')
						cnt = 1;
					q.push( Data(ny, nx, q_front.cost + cnt) );
				}
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1276
#pragma comment(linker, "/STACK:64000000")
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <ctime>
#include <sstream>
#include <algorithm>
#include <functional>
#include <numeric>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define y1 stupid_cmath
#define left stupid_left
#define right stupid_right
#define vi vector <int>
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))

const int inf = (int)1e9;
const int mod = inf + 7;
const double eps = 1e-9;
const double pi = acos(-1.0);

int n, k, a[100];

bool ok(int x) {
    while(x) {
        int d = x % 10;
        if (a[d]) return false;
        x /= 10;
    }
    return true;
}

int main() {

    cin >> n >> k;
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        a[x] = 1;
    }

    for (int i = n;; i++) {
        if (ok(i)) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 256