akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int height(int);
//ST[1]は親はST[0]|は子の数
int ST[100000][2];
int ST2[100000][2];
int main(){
  int n,i,j,NN,MN,free;
  scanf("%d",&n);
  for(i=0;i<n;i++)ST2[i][1]=-1;
  for(i=0;i<n;i++){
    scanf("%d",&NN);
    MN=2;
    ST2[NN][0]=MN;
    for(j=0;j<MN;j++){
      scanf("%d",&free);
      ST[NN][j]=free;
      if(free==-1)continue;
      ST2[free][1]=NN;
    }
  }
  for(i=0;i<n;i++){
    j=i;
    free=0;
    printf("node %d: parent = %d,",i,ST2[i][1]);
    while(ST2[j][1]!=-1){
      j=ST2[j][1];
      free++;
    }
    printf(" sibling = ");
    if(ST2[i][1]==-1)printf("-1, ");
    else printf("%d, ",ST[ST2[i][1]][0]==i?ST[ST2[i][1]][1]:ST[ST2[i][1]][0]);
   
    printf("degree = ");
    if(ST[i][0]!=-1||ST[i][1]!=-1)
      if(ST[i][0]!=-1&&ST[i][1]!=-1)printf("2, ");
      else printf("1, ");
    else printf("0, ");
    printf("depth = %d, ",free);
    printf("height = %d, ",height(i)-1); 
    if(ST2[i][1]==-1)printf("root"); 
    else{
      if(ST[i][0]==-1&&ST[i][1]==-1)printf("leaf");
      else printf("internal node");
    }
    printf("\n");
  }
  return 0;
}
int height(int killme){
  int baby;
  if(killme==-1)return 0;
  baby=height(ST[killme][0]);
  killme=height(ST[killme][1]);
  baby=killme>baby?killme:baby;
  return baby+1;
}



Measured memory_bytes: 2148
#include <iostream>
#include <cstdio>
#include <cmath>

const int N = 1000;

int main(void) {
  int data[N] = {0};
  int n = 0;

  
  std::cin >> n;

  while (n != 0) {
    double sum = 0.0;

    for (int i = 0; i < n; i++) {
      std::cin >> data[i];

      sum += data[i];
    }

    double m = sum / n;

    sum = 0.0;

    for (int i = 0; i < n; i++) {
      sum += std::pow(data[i] - m, 2.0);
    }

    double sd = std::sqrt(sum / n);

    printf("%f\n", sd);

    std::cin >> n;
  }  
  
  return 0;
}

Measured memory_bytes: 1188
S=input()
l,len01,len10=2,0,0
for i in range(len(S)):
	if (l%2==0)&(S[i]=='1'):
		len10+=1
	elif (l%2==0)&(S[i]=='0'):
		len01+=1
	if (l%2==1)&(S[i]=='1'):
		len01+=1
	elif (l%2==1)&(S[i]=='0'):
		len10+=1
	l+=1
print(min(len01,len10))

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

int main(void) {
	int n, k, x, y, ans;

	cin >> n >> k >> x >> y;

	if (n <= k)
		ans = n * x;
	else
		ans = k * x + (n - k) * y;

	cout << ans << '\n';
	return 0;
}


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

int main() {
    int m = 1e9 + 7;
    int n, k;
    cin>>n>>k;
    int a[n];
    for(int i=0; i<n; i++) cin>>a[i];

    int dp[n+1][k+1];
    for(int i=0; i<=n; i++) dp[i][0] = 1;
    for(int i=0; i<=k; i++) dp[0][i] = 1;
    for(int i=1; i<=n; i++) {
        for(int j=1; j<=k; j++)
            dp[i][j] = (dp[i-1][j] + m - (j - a[i-1] > 0 ? dp[i-1][j - a[i-1] - 1] : 0)) % m;
        for(int j=1; j<=k; j++) dp[i][j] = (dp[i][j] + dp[i][j-1]) % m;
    }
    int ans = dp[n][k];
    if(k > 0) ans = (ans + m - dp[n][k-1]) % m;
    cout<< ans << endl;

    return 0;
}


Measured memory_bytes: 39680
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProblemSet
{
    class ProblemSet
    {
        static void Main(string[] args)
        {
            string strN = Console.ReadLine();

            string[] strD = Console.ReadLine().Split(' ');

            var intD = new List<int>();

            for (int i = 0; i < strD.Length; i++)
            {
                intD.Add(int.Parse(strD[i]));
            }

            string strM = Console.ReadLine();

            string[] strT = Console.ReadLine().Split(' ');

            var intM = new List<int>();

            for (int i = 0; i < strT.Length; i++)
            {
                intM.Add(int.Parse(strT[i]));
            }

            int intIdx = 0; // 検索開始位置
            var intDSorted = intD.OrderBy(x => x).ToList();
            var intMSorted = intM.OrderBy(x => x).ToList();
            for (int i =0; i < intMSorted.Count; i++)
            {
                //intIdx = intD.IndexOf(intM[i]);

                intIdx = intDSorted.IndexOf(intMSorted[i],intIdx); // 検索開始位置を指定し、検索する

                if (intIdx == -1)
                {
                    Console.WriteLine("NO");
                    return;
                }
                else
                {
                    intDSorted[intIdx] = 0;
                    intIdx += 1; // 検索開始位置をカウントアップ
                }
            }

            Console.WriteLine("YES");
            return;

        }
    }
}


Measured memory_bytes: 50004
#include <bits/stdc++.h>
using namespace std;
int main()
{
    string S; cin >> S;
    int N = S.size();
    vector<int> ans(N);
    char c = 'R';
    int n = 0;
    S.push_back('@');
    for (int i = 0; i <= N; i++) {
        if (i < N && c == S[i]) {
            n++;
        } else {
            if (c == 'R') {
                ans[i] += n / 2;
                ans[i-1] += n - n / 2;
            } else {
                ans[i-n-1] += n / 2;
                ans[i-n] += n - n / 2;
            }
            c = S[i];
            n = 1;
        }
    }
    for (auto a : ans) cout << a << ' ';
    cout << '\n';
    return 0;
}

Measured memory_bytes: 1024
n=int(input())
v=list(map(int, input().split()))
c=list(map(int, input().split()))
vc=[(v[i],c[i]) for i in range(n)]
vc=sorted(vc,key=lambda x:(x[0],x[1]))[::-1]
x=0
y=0
ans=0
for i in range(n):
    temp_x = x+vc[i][0]
    temp_y = y+vc[i][1]
    if ans<temp_x-temp_y:
        ans=temp_x-temp_y
        x+=vc[i][0]
        y+=vc[i][1]
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b)  for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n)    FOR(i,0,n)
#define RER(i,n)    FOR(i,0,(n+1))
#define pb          push_back
#define mp(a,b)     make_pair((a),(b))
#define mset(m,v)   memset(m,v,sizeof(m))
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pair<int, int> > vpii;
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<pair<ll, ll> > vpll;
typedef vector<string> vs;
typedef long double ld;
const double EPS    = 1e-10;
const int INF       = 1e+9;
const double PI     = acos(-1);


auto main() -> int
{
    int a, b;
    cin >> a >> b;
    cout << ceil((double)(a + b)/2.0) << endl;
    return 0;
}



Measured memory_bytes: 256
/**
 * Next Mayor
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

import static java.lang.Integer.parseInt;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;

		while ((line = br.readLine()) != null && !line.isEmpty()) {

			int n = parseInt(line.substring(0, line.indexOf(' ')));
			int p = parseInt(line.substring(line.indexOf(' ') + 1));
			if ((n | p) == 0) break;

			int bowl = p;
			int[] candidate = new int[n];
			int next = -1;

			for (int i = 0; ; i++) {
				if (i == n) i = 0;
				if (bowl > 0) {
					candidate[i]++;
					bowl--;
					if (candidate[i] == p) {
						next = i;
						break;
					}
				} else {
					bowl = candidate[i];
					candidate[i] = 0;
				}
			}
			System.out.println(next);
		} //end while
	} //end main
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int main() {
    ll n;
    cin >> n;
    vll nums(n);
    vll dp(n);
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
    }
    dp[0] = 0;
    dp[1] = abs(nums[1] - nums[0]);
    for (int i = 2; i < n; ++i) {
        dp[i] = min(dp[i - 1] + abs(nums[i] - nums[i - 1]), dp[i - 2] + abs(nums[i] - nums[i - 2]));
    }
    cout << dp[n - 1] << endl;
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();


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

int main() {
  int M, D;
  cin >> M >> D;
  int ans = 0;
  rep(p, M) {
    int month;
    month = p + 1;
    rep(i, D) {
      int j = i + 1;
      int ten;
      int one;
      ten = j / 10;
      one = j % 10;
      if (ten * one == month && ten >= 2 && one >= 2)
        ans++;
    }
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {  
	public static void main(String[] args) { 
		FastScanner I = new FastScanner(); //Input
		OutPut O = new OutPut(); //Output
		int R = I.nextInt();
		int C = I.nextInt();
		char[][] grid = new char[R][C];
		for (int i = 0; i < R; i++) grid[i] = I.next().toCharArray();
		for (int r = 0; r < R; r++) {
			for (int c = 0; c < C; c++) {
				if (grid[r][c]=='.') {
					O.p(check(grid,r,c));
				}else O.p(grid[r][c]);
			}
			O.p("\n");
		}
	}
	public static int check(char[][] grid, int r, int c) {
		int ret = 0;
		int R = grid.length;
		int C = grid[0].length;
		if (r>0&&grid[r-1][c]=='#') ret++;
		if (r<R-1&&grid[r+1][c]=='#') ret++;
		if (c>0&&grid[r][c-1]=='#') ret++;
		if (c<C-1&&grid[r][c+1]=='#') ret++;
		if (r>0&&c>0&&grid[r-1][c-1]=='#') ret++;
		if (r>0&&c<C-1&&grid[r-1][c+1]=='#') ret++;
		if (r<R-1&&c>0&&grid[r+1][c-1]=='#') ret++;
		if (r<R-1&&c<C-1&&grid[r+1][c+1]=='#') ret++;
		return ret;
	}
	public static long ceil(long num, long den) {long ans = num/den; if (num%den!=0) 
	ans++; return ans;}
	public static long GCD(long a, long b) {
		if (a==0||b==0) return Math.max(a,b);
		return GCD(Math.min(a, b),Math.max(a, b)%Math.min(a, b));
	}
	public static long FastExp(long base, long exp, long mod) {
		long ans=1;
		while (exp>0) {
			if (exp%2==1) ans*=base;
			exp/=2;
			base*=base;
			base%=mod;
			ans%=mod;
		}
		return ans;
	}
	public static long ModInv(long num,long mod) {return FastExp(num,mod-2,mod);}
	public static int pop(long x) { //Returns number of bits within a number
		int cnt = 0;
		while (x>0) {
			if (x%2==1) cnt++;
			x/=2;
		}
		return cnt;
	}
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {return Integer.parseInt(next());}
		long nextLong() {return Long.parseLong(next());};
		double nextDouble() {return Double.parseDouble(next());}
	}
	static class OutPut{
		PrintWriter w = new PrintWriter(System.out);
		void pln(double x) {w.println(x);w.flush();}
		void pln(boolean x) {w.println(x);w.flush();}
		void pln(int x) {w.println(x);w.flush();}
		void pln(long x) {w.println(x);w.flush();}
		void pln(String x) {w.println(x);w.flush();}
		void pln(char x) {w.println(x);w.flush();}
		void pln(StringBuilder x) {w.println(x);w.flush();}
		void pln(BigInteger x) {w.println(x);w.flush();}
		void p(int x) {w.print(x);w.flush();}
		void p(long x) {w.print(x);w.flush();}
		void p(String x) {w.print(x);w.flush();}
		void p(char x) {w.print(x);w.flush();}
		void p(StringBuilder x) {w.print(x);w.flush();}
		void p(BigInteger x) {w.print(x);w.flush();}
		void p(double x) {w.print(x);w.flush();}
		void p(boolean x) {w.print(x);w.flush();}
	}
}


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

int bubbleSort(int a[],int n){
    bool flag=1;
    int i,j;
    int count=0;
    for (i= 0; i < n&&flag; ++i) {
        flag=0;
        for (j = n-1; j >i ; --j) {
            if (a[j]<a[j-1]){
                swap(a[j],a[j-1]);
                flag=1;
                count++;
            }
        }
    }
    return count;
}

int main() {
    int i,j,n,a[150];
    int sw;
    cin>>n;
    for (i = 0; i < n; ++i) {
        cin>>a[i];
    }

    sw=bubbleSort(a,n);

    for (j = 0; j < n; ++j) {
        if (j>0)
            cout<<" ";
        cout<<a[j];
    }
    cout<<endl;
    cout<<sw<<endl;

    return 0;
}

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

using namespace std;
using ll = long long;
using P = pair<int,int>;
#define all(c) (c).begin(),(c).end()
const int INF = INT_MAX;
const ll LINF = LLONG_MAX;
const ll MOD = 1e9+7;

template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"[";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"]";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&p)
{o<<"{"<<p.first<<", "<<p.second<<"}";return o;}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj)
{o<<"{";for(auto itr=obj.begin();itr!=obj.end();++itr)o<<(itr!=obj.begin()?", ":"")<<*itr;o<<"}";return o;}
void dump() {}
template <class H, class... T>void dump(H&& head, T&&... tail)
{cout << head << (sizeof...(tail)==0 ? "\n" : " "); dump(forward<T>(tail)...);}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  vector<vector<int>> ans(h,vector<int>(w,0));


    for(int i = 0; i < h-b; ++i){
      for(int j = 0; j < a; ++j){
        ans[i][j] = 1;
      }
    }
    for(int i = h-b; i < h; ++i){
      for(int j = a; j < w; ++j){
        ans[i][j] = 1;
      }
    }

  for(int i = 0; i < h; ++i){
    for(int j = 0; j < w; ++j){
      cout << ans[i][j];
    }
    cout << endl;
  }
  
  return 0;
}


Measured memory_bytes: 5248
import java.util.*;

import static java.lang.System.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        long[] a = new long[N];
        for (int i = 0; i < N; i++) {
            a[i] = sc.nextLong();
        }

        int cnt2 = 0;
        int cnt4 = 0;
        int cntOthers = 0;
        for (int i = 0; i < N; i++) {
            if (a[i] % 4 == 0) {
                cnt4++;
            } else if (a[i] % 2 == 0) {
                cnt2++;
            } else {
                cntOthers++;
            }
        }

        if (cnt2 == 0) {
            if (cnt4 >= cntOthers - 1) {
                out.println("Yes");
                return;
            }
        } else {
            if (cnt4 >= cntOthers) {
                out.println("Yes");
                return;
            }
        }
        out.println("No");
    }
}

Measured memory_bytes: 62604
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

// template {{{  0 
// using {{{ 1
using ll = long long int;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vii = vector<pii>;
using vll = vector<pll>;
// }}} 1
// definition {{{ 1
// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)
#define Scll(x) scanf("%lld", &x)
#define Scll2(x,y) scanf("%lld%lld", &x, &y)
#define Scll3(x,y,z) scanf("%lld%lld%lld", &x, &y, &z)
#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2
// constants {{{ 2
#define EPS (1e-7)
#define INF (2e9)
#define PI (acos(-1))
// }}} 2
// systems {{{ 2
#define Repe(x,y,z) for(ll x = z; x < y; x++)
#define Rep(x,y) Repe(x,y,0)
#define RRepe(x,y,z) for(ll x = y-z-1; x >= 0; x--)
#define RRep(x,y) RRepe(x,y,0)
// }}} 2
// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n")
#define YESNO(a) (a)?printf("YES\n"):printf("NO\n")
// }}} 2
// }}} 1
// input {{{ 1
// }}} 1
// }}} 0

int main() {

    int N,K;
    Scd2(N,K);
    int a,b,c;
    Scd3(a,b,c);

    char s[123456];
    Scs(s);

    int ans = 0;

    Rep(i,K){
        if( s[i] == 's' ) ans += a;
        if( s[i] == 'p' ) ans += b;
        if( s[i] == 'r' ) ans += c;
    }
    Repe(i,N,K){
        if( s[i-K] == s[i] ) s[i] = -1;
        if( s[i] == 's' ) ans += a;
        if( s[i] == 'p' ) ans += b;
        if( s[i] == 'r' ) ans += c;
    }

    printf ("%d\n", ans );

    return 0;
}



Measured memory_bytes: 384
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  string x;
  sc.scan(x);

  int resNum;
  int min = to!int(x[0 .. 2]);

  foreach (i; 0 .. x.length - 2) {
    string res;
    res = x[i .. i + 3];
    int tmp = to!int(res);
    if (abs(tmp - 753) < abs(min - 753)) {
      min = tmp;
    }
  }

  writeln(abs(min - 753));
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int H, W, N; 
  cin >> H >> W >> N;


  int x1 = 0, x2 = H;
  int y1 = 0, y2 = W;
  REP(i, N){
    int x, y, a;
    cin >> x >> y >> a;
    if(a == 1) chmax(x1, x);
    if(a == 2) chmin(x2, x);
    if(a == 3) chmax(y1, y);
    if(a == 4) chmin(y2, y);
  }

  
  if(x2-x1 <= 0 || y2-y1 <= 0) cout << 0 << "\n";
  else cout << (x2-x1)*(y2-y1) << "\n";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int x[] = new int[n];
    int y[] = new int[n];
	int p = 0;
    int q = 0;
    int pc = 0;
    int qc = 0;
    int ans = 0;
    int z = 0;
    int cnt = 0;
    
    for (int i=0; i<n; i++) {
      x[i] = Integer.parseInt(sc.next());
      y[i] = Integer.parseInt(sc.next());
    }

    for (int i=0; i<n; i++) {
      for (int j=0; j<n; j++) {
        if( i==j ) { continue; }
      	p = x[i] - x[j];
        q = y[i] - y[j];
        
        cnt = 0;
        for (int k=0; k<n; k++) {
          for(int l=0; l<n; l++) {
            if (k==l) { continue; }
            pc = x[k] - x[l];
            qc = y[k] - y[l];
            if (pc == p && qc == q) { cnt++;}
          }
        }
        if ( cnt > ans ) { ans = cnt; }
      }
    }

    ans = n - ans;
    
    System.out.println(ans);
  }
}


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

int main(){
    int N;
    long long K;
    cin >> N >> K;
    long long A[N];
    long long sum = 0;
    rep(i, N){
        cin >> A[i];
        sum += A[i];
    }
    long long x = 1;
    long long cnt = 0;
    priority_queue<long long> que;
    while(x*x < sum){
        if(sum%x == 0){
            cnt += 2;
            que.push(x);
            que.push(sum/x);
        }
        x++;
    }
    if(x*x == sum){
        que.push(x);
        cnt++;
    }
    long long ans;
    rep(i, cnt){
        long long n = que.top();
        que.pop();
        long long s = 0;
        priority_queue<long long, vector<long long>, greater<long long> > q;
        rep(j, N){
            s += A[j]%n;
            q.push(A[j]%n);
        }
        long long S = 0;
        rep(k, N-s/n){
            S += q.top();
            q.pop();
        }
        if(S <= K){
            ans = n;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())

ans = 0
for a in range(1,k+1):
    for b in range(1,k+1):
        for c in range(1,k+1):
            if 1 in [a,b,c]: ans += 1
            else: ans += gcd(a,b,c)

print(ans)


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

using namespace std;
#define ll long long int

int main()
{
   ll t;
   t = 1;	
   //cin t;
   while(t--){
          ll n;
          cin >> n;
          ll x[n], y[n];
          for(int i = 0; i < n ; i ++)
          {
              cin >> x[i] >> y[i];
          }   
          sort(x , x + n);
          sort(y , y + n);
          if(n % 2 == 0)
          {
              cout << y[n / 2] + y[n /2 - 1] - x[n /2] - x[n /2 - 1] + 1 << endl;
          }
          else
          cout << y[n / 2] - x[n / 2] + 1 << endl;
   }
}


Measured memory_bytes: 6700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    ごちゃごちゃ場合分けを考える前に全探索は考えましたか？
*/

int main(){
    int c[3][3];
    for(int i=0; i<3; ++i) for(int j=0; j<3; ++j) cin >> c[i][j];

    int a[3], b[3];
    a[0] = 0;
    b[0] = c[0][0];
    b[1] = c[0][1];
    b[2] = c[0][2];
    a[1] = c[1][0] - b[0];
    a[2] = c[2][0] - b[0];

    bool flg = true;
    for(int i=0; i<3; ++i) for(int j=0; j<3; ++j) if(c[i][j] != a[i]+b[j]) flg = false;

    if(flg) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

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

  int ans = 1;
  char prev = s[0];

  for(int i=1;i<n;++i){
    if(prev==s[i]){
      continue;
    }
    else{
      ans++;
      prev=s[i];
    }
  }

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


Measured memory_bytes: 512
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

int N, M, K, H, W, L, R;
//long long int N, M, K, H, W, L, R;



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

	cin >> N >> M;
	string s;
	cin >> s;
	s = 'A' + s;
	vector<int>r(N+1, 0);
	for (int i = 0; i < M; i++) {
		cin >> L >> R;
		r[L] = max(r[L], R);
	}
	for (int i = 1; i <= N; i++)r[i] = max(r[i], i);
	R = 0;
	int zero = 0;
	vector<vector<long  long int>>dp(N + 1, vector<long long int>(N + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = R + 1; j <= max(R, r[i]); j++)if (s[j] == '0')zero++;
		R = max(R, r[i]);
		int mzero = zero - min(zero, (R - i));
		int Mzero = min(zero, i);
		//cout << i << " zero " << mzero << " " << Mzero << endl;
		for (int j = mzero; j <= Mzero; j++) {
			dp[i][j] += dp[i - 1][j];
			if (j)dp[i][j] += dp[i - 1][j - 1];
			dp[i][j] %= MOD;
		}
	}
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= N; j++) {
		//	cout << i << " " << j << " " << dp[i][j] << endl;
		}
	}
	cout << dp.back()[zero] << endl;
}

Measured memory_bytes: 70784
/*
 * Mysterious Dungeons
 * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2089
 */

 #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

char field[30][30];

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


struct P {
  int x, y, cost;
  long c;
};

int main() {
  int w, h;
  while(cin >> w >> h, w | h) {
    vector<vector<set<long>>> G(h, vector<set<long>>(w));
    // map<char, int> id;
    fill_n((char*)field, 30 * 30, '#');
    int sx, sy;
    int gx, gy;
    REP(y, h){
      REP(x, w){
        cin >> field[y][x];
        switch (field[y][x]) {
        case '<':
          gx = x;
          gy = y;
          break;
        case '@':
          sx = x;
          sy = y;
          break;
        case '.':
        case '#':
          break;
        default:
          // {
          //   char c = tolower(field[y][x]);
          //   if (!EXIST(id, c)) {
          //     id[c] = id.size();
          //   }
          // }
          break;
        }
      }
    }

    queue<P> que;
    G[sy][sx].insert(0);
    que.push({sx, sy, 0, 0});
    int res = -1;
    while(!que.empty()) {
      P p = que.front(); que.pop();
      // LOG("%d %d %d %d\n", p.x, p.y, p.c, p.cost);
      if (p.x == gx && p.y == gy) {
        res = p.cost;
        break;
      }

      REP(i, 4){
        int nx = p.x + dx[i];
        int ny = p.y + dy[i];
        int ncost = p.cost + 1;
        long nc = p.c;
        if (field[ny][nx] == '#') continue;
        if (islower(field[ny][nx])) {
          nc ^= 1 << (field[ny][nx] - 'a');
        } else if (isupper(field[ny][nx])) {
          if(!(nc & (1 << (field[ny][nx] - 'A')))) continue;
        }
        if (!EXIST(G[ny][nx], nc)) {
          G[ny][nx].insert(nc);
          que.push({nx, ny, ncost, nc});
        }
      }
    }

    cout << res << endl;
  }
}

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

namespace _0241
{
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int n = int.Parse(Console.ReadLine());
                if (n == 0) break;
                for (int i = 0; i < n; i++)
                {
                    int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    int[] a = new int[4];
                    a[0] = x[0] * x[4] - x[1] * x[5] - x[2] * x[6] - x[3] * x[7];
                    a[1] = x[0] * x[5] + x[1] * x[4] + x[2] * x[7] - x[3] * x[6];
                    a[2] = x[0] * x[6] - x[1] * x[7] + x[2] * x[4] + x[3] * x[5];
                    a[3] = x[0] * x[7] + x[1] * x[6] - x[2] * x[5] + x[3] * x[4];
                    Console.Write(a[0]);
                    for (int j = 1; j < 4; j++) Console.Write(" " + a[j]);
                    Console.WriteLine();
                }
            }
        }
    }
}

Measured memory_bytes: 9684
/*我是萌新*/
#include<iostream>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include <iomanip> 
#include<map>
typedef long long ll;
const int mod = 1e9+7;
const double PI=3.1415926535897932384626433;
using namespace std;
ll gcd(ll a, ll b){
    return b?gcd(b,a%b):a;
}
ll lcm(ll a, ll b){
    return a/gcd(a,b)*b;
}
int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    ll t;
    while (cin >> t)
    {
        cout<<fixed<< setprecision(6)<<2*PI*t<<'\n';
    }
}



Measured memory_bytes: 3800
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #整数1つinput
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii())
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #文字列1つinput
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

n,k = mii()
arr = limii()
dp = [0]*n
chk=True
cnt=1
while chk:
    q = cnt-k
    if q<0:q=0
    add =[]
    for i in range(q,cnt): 
        add.append(abs(arr[cnt]-arr[i])+dp[i])
    dp[cnt] = min(add)
    if cnt==n-1:
        chk=False
    cnt+=1

print(dp[-1])



Measured memory_bytes: 77276
#include <stdio.h>

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

void __print(int x) { cerr << x; }
void __print(long x) { cerr << x; }
void __print(long long x) { cerr << x; }
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename T, typename V>
void __print(const pair<T, V> &x) {
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename T>
void __print(const T &x) {
    int f = 0;
    cerr << '{';
    for (auto &i : x) cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename T, typename... V>
void _print(T t, V... v) {
    __print(t);
    if (sizeof...(v)) cerr << ", ";
    _print(v...);
}
#ifdef LOCAL
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif

#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll K, N;
    cin >> K >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];
    vector<ll> diff;
    diff.push_back(abs(K - A[N - 1] + A[0]));

    FOR(i, 1, N) { diff.push_back(abs(A[i] - A[i - 1])); }
    sort(diff.begin(), diff.end());
    debug(diff);
    ll ans = 0;
    REP(i, N - 1) { ans += diff[i]; }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>

using namespace std;

#define INF 		2000000007
#define MOD			1000003

#define MAX 		105

#define REP(i,n)	for(int i=0;i<(n);++i)
#define REPS(i,s,t)	for(int i=(s);i<(t);++i)

typedef unsigned int 			uint;
typedef unsigned long long int	ull;


int main(){
	int A,B,C;
	int K;

	scanf("%d %d %d",&A,&B,&C);
	cin >> K;

	if(A>B && A>C){
		REP(i,K) A*=2;
	}
	else if(B > C){
		REP(i,K) B*=2;
	}
	else{
		REP(i,K) C*=2;
	}
	cout << (A+B+C) << endl;

	return 0;
}

Measured memory_bytes: 256
n, k, q = map(int, input().split())
a = list(map(int, input().split()))

result = 100000000000
for j in range(n):
    li = [[]]
    for i in range(n):
        if a[j] <= a[i]:
            li[-1].append(a[i])
        else:
            li.append([])
    ans = []
    for li_ele in li:
        if len(li_ele) < k:
            continue
        else:
            tmp = sorted(li_ele)
            ans = ans + tmp[0:len(li_ele)-k+1]
    ans = sorted(ans)
    if len(ans) >= q:
        result = min(ans[q-1] - a[j], result)
print(result)

Measured memory_bytes: 69084
n, k = map(int, input().split())
A = tuple(map(int, input().split()))
A = sorted(A, reverse=True)

l = 0
r = max(A)+1
def cut(l, k):
    # 長さlの丸太を最大とすることができるかどうかを返す
    for a in A:
        if a > l:
            k -= (-(-a//l) - 1)
    return k >= 0

while r-l > 1:
    mid = (r+l)//2
    if cut(mid, k):
        r = mid
    else:
        l = mid
print(r)

Measured memory_bytes: 31104
#include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;

int main(){
  int m = 100000,n;
  cin >> n;
  for(int i = 0 ; i < n ; i++ ){
    m += m*0.05; 
    if(m%1000 != 0)m-=m%1000,m+=1000; 
  }
  cout << m << endl;
}

Measured memory_bytes: 1160
def main():
    MOD = 10**9 + 7
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    left_smaller = [0]*N
    right_smaller = [0]*N
    for i, a in enumerate(A):
        left_smaller[i] = sum(b < a for b in A[:i])
        right_smaller[i] = sum(b < a for b in A[i+1:])

    ans = sum((l*(K)*(K-1)//2%MOD + r*(K+1)*(K)//2%MOD)%MOD for l, r in zip(left_smaller, right_smaller))%MOD
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 9256
#include "iostream"
#include "vector"

using namespace std;

int main() {
    vector< int> d(5);
    int a, b;
    scanf("%d %d", &a, &b);
    d[a] ++;
    d[b] ++;
    scanf("%d %d", &a, &b);
    d[a] ++;
    d[b] ++;
    scanf("%d %d", &a, &b);
    d[a] ++;
    d[b] ++;
    a = 0, b = 0;
    for (int i = 1; i <= 4; ++i) if (d[i] == 1) a ++; else if (d[i] == 2) b ++;
    if (a == 2 and b == 2) puts("YES");
    else puts("NO");

}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>

int main()
{
	int N,ans = 0,r=0;
	std::cin >> N;
	std::string C;
	std::cin >> C;
	for (char x : C)
	{

		if (x == 'R')r++;
	}
	for (int i = 0; i < r; i++)
		if (C[i] == 'W')
			ans++;
	std::cout << ans << std::endl;
	return 0;
}

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

#define all(x) (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define ll long long
#define ld long double
#define pb push_back
#define MOD 1000000007
#define LLMN LONG_LONG_MIN
#define LLMX LONG_LONG_MAX
#define LDMX LDBL_MAX
#define LDMN LDBL_MIN
#define MAX 1000000
#define pll pair<ll, ll>
#define vl vector<ll>
#define vll vector< vector<ll> >
#define vb vector<bool>
#define vbb vector< vector<bool> >


ll mulmod(ll, ll);
ll fastpower(ll, ll);
void getprime(vector<bool>&);
void getfact(vector<ll>&, vector<ll>&);
ll ncr(ll, ll, vector<ll>&, vector<ll>&);

void solve()
{
    ll n, sum = 0;
    cin>>n;
    vl a(n);
    for(ll i = 0; i < n ; i++){
        cin>>a[i];
    }
    sort(all(a), greater<ll>());
    ll k = 0;
    for(ll i = 0; i < n && k < n-1; i++)
    {
        if(i == 0)
        {
            sum += a[i];
            k++;
        }
        else
        {
            sum += a[i];
            k++;
            if(k < n-1)
            {    sum += a[i];
                k++;
            }
        }
    }
    cout<<sum;

}

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

ll mulmod(ll a, ll b)
{
    ll res = 0; 
    a = a % MOD;
    while(b > 0)
    {
        if (b % 2 == 1)
            res = (res + a) % MOD;
 
        a = (a * 2) % MOD; 
        b /= 2;
    } 
    return res % MOD; 
}

ll  fastpower(ll a, ll n)
{
    ll res = 1;
    while(n > 0)
    {
        if(n % 2 != 0)
        {
            res = (res * a) % MOD;
        }
        n /= 2;
        a = (a * a) % MOD;
    }
    return res;
}

void getprime(vector<bool>&prime)
{
    prime[0] = false;
    prime[1] = false;
    
    for(ll i = 2;i <= MAX; i++)
    {
        if(prime[i])
        {
            for(ll j = i*i; j <= MAX; j += i)
                prime[j] = false;
        }
    }
}

void getfact(vector<ll> &fact, vector<ll> &ifact)
{
    fact[0] = 1;
    ifact[0] = 1;
    
    for(ll i = 1; i <= MAX; i++)
    {
        fact[i] = (fact[i-1] * i)%MOD;
        ifact[i] = (ifact[i-1] * fastpower(i, MOD -2) )%MOD;
    }
}

ll ncr(ll n, ll r, vector<ll>&fact, vector<ll>&ifact)
{
    ll res;
    res = (((fact[n] * ifact[r]) % MOD) * ifact[n-r]) % MOD;
    return res;
}


Measured memory_bytes: 4784
#include <cstdio>
#include <cstdint>
#include <map>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <utility>
#include <math.h>
#include <stack>

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const long long mod = 1e9+7;

void chmod(long long &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

long long modpow(long long x, long long n){
    if(n==0) return 1;
    long long res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };



/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

bool check(int p, int k, std::vector<int> const &w) {
    int n = w.size();
    int cnt = 1;
    int tmp = 0;
    
    for(int i=0; i<n; ++i) {
        if(w[i] > p) { return false; }
        else if(tmp + w[i] <= p) { tmp += w[i]; }
        else {
            cnt++;
            tmp = w[i];
        }
    }
    return cnt<=k;
}

int main() {
    
    int n, k;
    scanf("%d %d", &n, &k);
    std::vector<int> w(n);
    for(int i=0; i<n; ++i) { scanf("%d", &w[i]); }

    int left = 0;
    int right = 1e9+1;
    while(right-left > 1) {
        int mid = (left+right) / 2;
        if(check(mid, k, w)) { right = mid; }
        else { left = mid; }
    }
    printf("%d\n", right);
    
    

    return 0;
}



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

int main() {

	int K,S;
	cin >> K >> S;
 	int count = 0;
  
     for(int x=0; x<=K; x++){
        for(int y=0; y<=K; y++){
          int z=S-x-y;
          if (z>=0 && z<=K)count++;
        }
     }
  
    cout << count << 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[] X = new int[N];
		for(int i = 0; i < N; i++) {
			X[i] = sc.nextInt();
		}
		Arrays.sort(X);
		int min = X[N / 2 - 1];
		int max = X[N / 2];
		
		System.out.println(max-min);
	}
}

Measured memory_bytes: 51412
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;
    
    static void solve(InputReader in, PrintWriter out){
        int n = in.ni();
        int a = in.ni(), b = in.ni();
        int[] count = new int[3];
        for (int i = 0; i < n; i++) {
            int p = in.ni();
            if(p <= a) count[0]++;
            else if(p <= b) count[1]++;
            else count[2]++;
        }
        out.println(Math.min(Math.min(count[0], count[1]), count[2]));
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 21200
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int n,count=1;
	cin >> n;
	vi d(n);
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d.begin(), d.end());
	for (int i = 1; i < n; i++) {
		if (d[i] != d[i - 1])count++;
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pb push_back
#define mod 1000000007
#define mk make_pair
vector<vector<int>> bk;
vector<vector<ll> >dp;
int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     int n;
     cin>>n;
     int a[n+1][n+1];
     for(int i=1;i<=n;i++)
     {
         for(int j=1;j<=n;j++)
         {cin>>a[i][j];}
     }
    int t=pow(2,n);t--;
     vector<ll> v;
     
    v.resize(t+1,0);v[0]=1;
    if(a[1][1]==1)
    v[1]=1;
    for(int i=2;i<=t;i++)
    {
        int c=0;
        for(int j=1;j<=i;)
        {
            if((i&j)!=0)
            c++;
           // cout<<j<<" "<<c<<"   ";
            j=j<<1;
        }//cout<<c<<endl;
        for(int j=1;j<=i;)
        {
            int l=log2(j);l++;//cout<<c<<" "<<l<<" "<<(i&j);
            if((i&j)!=0&&a[c][l]==1)
            {
                v[i]+=v[i-j];//cout<<"asdfd";
                v[i]%=mod;
            }
            
            j=j<<1;
        }//cout<<endl;
    }
    cout<<v[t];
   // for(int i=0;i<=t;i++)
    //cout<<v[i]<<" ";
    return 0;
}

Measured memory_bytes: 16640
#include "bits/stdc++.h"

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

int main() {
	ll n;
	ll r = 0;
	ll l = 0;
	ll x = 0;
	string s;
	string ss = "";

	cin >> n >> s;

	REP(i, n) {
		if (s[i] == ')') {
			ss.push_back(')');
			l++;
		}
		else {
			ss.push_back('(');
			r++;
		}

		if (l - r > 0) {
			ss.insert(ss.begin(), '(');			
			l = 0;
		}
		else if (r - l == 0) {
			REP(j, r - l) {
				ss.push_back(')');
			}

			l = 0;
			r = 0;
		}
	}

	if (r > 0) {
		REP(j, r - l) {
			ss.push_back(')');
		}
	}

	cout << ss << endl;
}


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

int main(){
    int ans=0;
    int n;
    cin>>n;
    vector<int>s(n);
    for(int i=0;i<n;i++){
        cin>>s[i];
    }
    int q;
    cin>>q;
    vector<int>t(q);
    for(int i=0;i<q;i++){
        cin>>t[i];
    }
    for(int i=0;i<q;i++){
        for(int j=0;j<n;j++){
            if(t[i]==s[j]){
                ans++;
                break;
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3128