akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define fori(i, m, n) for(int i = m; i < (int)n; i++)
#define forl(i, m, n) for(ll i = m; i < (ll)n; i++)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string btos(bool ans){
  return (ans?"Three":"Four");
}
int main() {
  int n;cin>>n;
  set<char> hina;
  rep(i,n){
    char c;cin>>c;
    hina.insert(c);
  }
  cout << btos(hina.size()==3) << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

int dist(vi a,vi b){
    int ans=0;
    for(int i=0;i<a.size();i++){
        ans+=((a[i]-b[i])*(a[i]-b[i]));
    }
    return ans;
}

int main(){
    int N,D;
    cin>>N>>D;
    vvi X(N);
    for(int i=0;i<N;i++){
        vi temp(D);
        for(int j=0;j<D;j++){
            cin>>temp[j];
        }
        X[i]=temp;
    }
    int count=0;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            int d=dist(X[i],X[j]);
            int d1=sqrt(d);
            if(d1*d1==d){
                count++;
            }
        }
    }
    out(count);
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
const int M=100010;
int INF=1000000007;
using ll=long long;

int main(){
	int n,s[110],num[3]={};
	cin>>n;
	num[2]=INF;
	rep(i,0,n){
		cin>>s[i];
		//10で割り切れるものの中で最大となるものを
		//num[0]に代入;
		if(s[i]%10==0)num[0]+=s[i];
		//10で割り切れないものを足したものをnum[1];
		//num[1]自体が10の倍数となることがあるので
		//その中で最も小さい数字をnum[2]に入れて引く;
		if(s[i]%10){
			num[1]+=s[i];
			num[2]=min(num[2],s[i]);
		}
	}
	if(num[1]%10==0){
		//10で割った余りが0になるものがあるとき;
		if(num[2]!=INF)cout<<num[0]+num[1]-num[2]<<endl;
		//10で割った余りが0になるものがないとき;
		else cout<<"0"<<endl;
	}else cout<<num[0]+num[1]<<endl;
}

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

int main() {
  int A,B;
  char S;
  cin >> A >> S >> B;

  // ここにプログラムを追記
 if ( S == '+') {
 cout << A+B << endl;
}else if ( S == '-') {
cout << A-B << endl;
}else {
cout << "error" << endl;
}
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int main2() {
  string s; cin >> s;
  if (s <= "2019/04/30")
    cout << "Heisei" << endl;
  else
    cout << "TBD" << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <string>
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>

using namespace std;

void SolveA()
{
	string s;
	cin >> s;

	const char *ss = s.c_str();

	int bee = 0;
	for (int i = 0; i < s.length(); i++)
	{
		if (ss[i] == '1')
		{
			bee++;
		}
	}
	printf("%d\n", bee);
}

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

	vector<int> A;
	for (int i = 0; i < n; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		A.push_back(tmp);
	}

	int counter = 0;
	bool flagLoop = true;
	while (flagLoop)
	{
		bool flagAllEven = true;
		for (int i = 0; i < n; i++)
		{
			if (A[i] % 2 != 0)
			{
				flagAllEven = false;
				flagLoop = false;
			}
		}
		if (flagAllEven == true)
		{
			for (int i = 0; i < n; i++)
			{
				A[i] /= 2;
			}
			counter++;
		}
	}

	printf("%d\n", counter);
}

// 公式の解説版
void AtCoderSolveB()
{
	// 個数の入力
	int N;
	scanf("%d", &N);

	// 番犬かつ答えを保持する変数
	int dmin = INT_MAX;

	for (int i = 0; i < N; i++)
	{
		// 要素の入力
		int A;
		scanf("%d", &A);
		
		// 2で割る操作を行った回数
		int d = 0;

		// 要素が偶数の間
		while (A % 2 == 0)
		{
			// 要素を2で割る
			A /= 2;
			// 割った回数を保持する
			d++;
		}

		// 割った回数の最小を保持する
		dmin = min(dmin, d);
	}

	// 結果出力
	printf("%d\n", dmin);
}

//bool vector_finder(std::vector<int> vec, int number) {
//	auto itr = std::find(vec.begin(), vec.end(), number);
//	size_t index = std::distance(vec.begin(), itr);
//	if (index != vec.size()) { // 発見できたとき
//		return true;
//	}
//	else { // 発見できなかったとき
//		return false;
//	}
//}

void SolveC()
{
	int N, K;
	scanf("%d %d", &N, &K);

	//int *numKind = new int[N]();
	vector<int> numKind;
	numKind.resize(N + 1, 0);
	int clock = 0;
	vector<int> kind;
	
	for (int i = 1; i < N + 1; i++)
	{
		int tmp;
		scanf("%d", &tmp);
		//if (vector_finder(kind, tmp))
		//{
		//	numKind[tmp]++;
		//}
		//else
		//{
		//	kind.push_back(tmp);
		//	numKind[tmp]++;
		//	clock++;
		//}
		if (std::find(kind.begin(), kind.end(), tmp) != kind.end())
		{
			numKind[tmp]++;
		}
		else
		{
			kind.push_back(tmp);
			numKind[tmp]++;
			clock++;
		}
	}

	if (clock <= K)
	{
		printf("0\n");
		return;
	}

	int cntChange = 0;
	while (clock > K)
	{
		int minIdx = kind[0];
		for (int i = 0; i < kind.size(); i++)
		{
			if (numKind[minIdx] == 0)
			{
				minIdx = kind[i];
			}
			else
			{
				if (numKind[kind[i]] < numKind[minIdx])
				{
					minIdx = kind[i];
				}
			}
		}
		while (numKind[minIdx] > 0)
		{
			numKind[minIdx]--;
			cntChange++;
		}
		clock--;
	}

	printf("%d\n", cntChange);
}

int main()
{
	//SolveA();
	//SolveB();
	//SolveC(); // ✕

	AtCoderSolveB();
}



Measured memory_bytes: 256
//Weather Prediction
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    String m=sc.next();
    String s="Sunny";
    String c="Cloudy";
    String r="Rainy";

    if(m.equals(s)) System.out.println("Cloudy");
    if(m.equals(c)) System.out.println("Rainy");
    if(m.equals(r)) System.out.println("Sunny");
  }
}


Measured memory_bytes: 19668
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

ll dic(ll a, ll b, ll c) {
	return max(a,max(b,c)) - min(a, min(b,c));
}

void solve(int test_case) {//210
	ll h,w;
	cin>>h>>w;
	ll mn = LONG_MAX;
	for(ll h1=1;h1<=h;h1++) {
		ll a = h1*w, b = ((h-h1)/2)*w, c = w*((h-h1-((h-h1)/2)));
		mn = min(mn,dic(a,b,c));
		a = h1*w, b = ((h-h1))*(w/2);c=(w-(w/2))*((h-h1));
		mn = min(mn, dic(a,b,c));
	}
	for(ll w1=1;w1<=w;w1++) {
		ll a = w1*h, b = ((w-w1)/2)*h, c = h*((w-w1-((w-w1)/2)));
		mn = min(mn,dic(a,b,c));
		a = w1*h, b = ((w-w1))*(h/2);c=(h-(h/2))*((w-w1));
		mn = min(mn, dic(a,b,c));
	}
	cout<<mn;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


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

int main() {
    int a,b,m;
    cin >> a >> b >> m;
    int s[a],t[b];
    for(int i=0;i<a;i++) cin >> s[i];
    for(int i=0;i<b;i++) cin >> t[i];
    int ans=1e9;
    int x,y,c;
    for(int i=0;i<m;i++){
        cin >> x >> y >> c;
        ans=min(ans,s[x-1]+t[y-1]-c);
    }
    sort(s,s+a);
    sort(t,t+b);
    ans=min(ans,s[0]+t[0]);
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <assert.h>
#include <numeric>

using namespace std;

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

int main()
{
  double R;
  cin >> R;
  cout << setprecision(10) << 2 * 3.14159265358979 * R << endl;
}


Measured memory_bytes: 3788
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include <math.h>
using namespace std;
int main(){
    vector<vector<char>>a(1000,vector<char>(1000));
    int h,w;
    cin>>h>>w;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin>>a[i][j];
        }
    }
    for(int j=0;j<w+2;j++){
            cout<<'#'<<flush;
        }
        cout<<endl;
    for(int i=0;i<h;i++){
        cout<<'#'<<flush;
        for(int j=0;j<w;j++){
            cout<<a[i][j]<<flush;
        }
        cout<<'#'<<endl;
    }
    for(int j=0;j<w+2;j++){
            cout<<'#'<<flush;
        }
        cout<<endl;
    return 0;
}


Measured memory_bytes: 4528
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

llong h, a;
int main() {
    cin >> h >> a;

    cout << (h + a - 1) / a << endl;

    return 0;
}


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

int main() {
	int N;
	cin >> N;
	
	if(N < 3) cout << 0;
	else if(N%3 == 0) cout << N/3;
	else {
		cout << N/3;
	}
	
	cout << endl;
	
	return 0;
}

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

int n;
int a[100001]; // 0が狼、1が羊
string s;

int main(){
    cin>>n>>s;
    for(int a0=0;a0<=1;a0++){
        a[0]=a0;
        for(int a1=0;a1<=1;a1++){
            a[1]=a1;
            for(int i=1;i<n;i++){
                if(a[i]^s[i]=='o') a[i+1]=1-a[i-1];
                else a[i+1]=a[i-1];
            }
            if(a[n]==a[0]&&(a[0]^s[0]=='o'^a[1]==a[n-1])){
                for(int i=0;i<n;i++){
                    if(a[i]) cout<<'S';
                    else cout<<'W';
                }
                return 0;
            }
        }
    }
    cout<<-1;
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define Graph vector<vector<int>>
using namespace std;
 
int main() {
  int A,B;
  cin >> A >> B;
  
  if(B==1){
  cout<< 0<<endl; return 0;
  }
  
  int ans=1,C=B-A,D=A-1;
  
  if(C>0) ans+=(C+D-1)/D;
  
  cout << ans <<endl;
  
  return 0;
  
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
ll dp[305][305][305];//みている場所,スキップ、最後にみたindex場所
int main(){
    for(int i=0;i<305;i++)for(int j=0;j<305;j++)for(int k=0;k<305;k++)dp[i][j][k]=inf;
    ll n,d;
    cin>>n>>d;
    V<ll> a(n+1,0);
    for(int i=0;i<n;i++)cin>>a[i+1];
    dp[0][0][0]=0;
    n++;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            for(int k=0;k<n;k++){
                chmin(dp[i+1][j][i],dp[i][j][k]+max(0ll,a[i]-a[k]));
                chmin(dp[i+1][j+1][k],dp[i][j][k]);
            }
        }
    }
    ll ans=inf;
    for(int i=0;i<n;i++)for(int j=0;j<=d;j++)chmin(ans,dp[n][j][i]);
    cout<<ans<<"\n";

}

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

int main(){
  int a, b, c;
  cin >> a >> b >> c;
  
  for(int i = 1; i<=a*b; i++){
    if(i * a % b == c){
      cout << "YES" << endl;
      return 0;
    }
  }
  cout << "NO" << endl;
}
   

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL); 
 
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define mp make_pair
#define in insert
#define ld long double
 
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif
template<class T> ostream& operator<<(ostream &os, vector<T> V) {os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {return os << "(" << P.first << "," << P.second << ")";}
 
typedef long long int ll;
 
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
const ll mod =1e9+7;
const ll maxn =100001;
ll power(ll x, ll n) {
    ll res = 1;
    for (; n > 0; n >>= 1) {
    if (n & 1) res = (res * x) % mod;
    x = (x * x) % mod;
    }
    return res;
}
string s[401];
ll h,w;
bool isvalid(ll i,ll j)
{
  return (i<h&&i>=0&&j<w&&j>=0&&s[i][j]=='.');
}
ll g[401][401];

int main()
{
 
  IOS
  cin>>h>>w;
  for(ll i=0;i<h;i++)
  {
    cin>>s[i];
  }
  for(ll i=0;i<h*w;i++)
  {
    for(ll j=0;j<h*w;j++)
    {
      g[i][j]=1e17;
    }
  }
  for(ll i=0;i<h;i++)
  {
    for(ll j=0;j<w;j++)
    {
      for(ll ii=i-1;ii<=i+1;ii++)
      {
        for(ll jj=j-1;jj<=j+1;jj++)
        {
          if(abs(i-ii)+abs(j-jj)==1)
          {
            if(isvalid(i,j)&&isvalid(ii,jj))
            {
              g[i*w+j][ii*w+jj]=1;
            }
          }
        }
      }
    }
  }
  
  for(ll k=0;k<h*w;k++)
  {
    for(ll i=0;i<h*w;i++)
    {
      for(ll j=0;j<h*w;j++)
      {
        g[i][j]=min(g[i][j],g[i][k]+g[k][j]);
      }
    }
  }
  ll ans=0;
  for(ll i=0;i<h*w;i++)
  {
    for(ll j=0;j<h*w;j++)
    {
      if(i!=j&&g[i][j]<1e15)
      {
        ans=max(ans,g[i][j]);
      }
    }
  }
  cout<<ans<<endl;
  
  
  
}

Measured memory_bytes: 1536
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint& operator+=(const mint a) { if ((x += a.x) >= mod) x -= mod; return *this; }
    mint& operator-=(const mint a) { if ((x += mod-a.x) >= mod) x -= mod; return *this; }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint pow(ll t) const { if (!t) return 1; mint a = pow(t>>1); a *= a; if (t&1) a *= *this; return a; }
    // for prime mod
    mint inv() const { return pow(mod-2); }
    mint& operator/=(const mint a) { return (*this) *= a.inv(); }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
};

int main(){
  int n;
  cin >> n;
  int ans = 0;
  while(n>0){
    if(n%10==2) ans++;
    n/=10;
  }
  cout << ans << endl;
  return 0;  
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007,mod2 = 998244353;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int e_mx,e_mx_index,e_mx2,o_mx,o_mx_index,o_mx2;
vector<int> ecnt(100010),ocnt(100010);
int main() {
    int n;
    cin >> n;

    for (int i = 0; i < n; ++i) {
        int tmp;
        cin >> tmp;
        if(i%2 == 0) ecnt[tmp]++;
        else ocnt[tmp]++;
    }

    // Evenについて最頻と最頻-1
    for (int i = 0; i < 100010; ++i) {
        if(e_mx < ecnt[i]){
            e_mx = ecnt[i];
            e_mx_index = i;
        }
    }

    ecnt[e_mx_index] = 0;
    for (int i = 0; i < 100010; ++i) {
        if(e_mx2 < ecnt[i]) e_mx2 = ecnt[i];
    }

    // Oddについて最頻と最頻-1
    for (int i = 0; i < 100010; ++i) {
        if(o_mx < ocnt[i]){
            o_mx = ocnt[i];
            o_mx_index = i;
        }
    }

    ocnt[o_mx_index] = 0;
    for (int i = 0; i < 100010; ++i) {
        if(o_mx2 < ocnt[i]) o_mx2 = ocnt[i];
    }

    if(e_mx_index != o_mx_index){
        cout << n-e_mx-o_mx << endl;
    }else{
        cout << min(n-e_mx-o_mx2,n-o_mx-e_mx2) << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include<cstdio>
int d(int x,int y){
    return (x<y)?(y-x):(x-y);
}
int main(){
    int n,a[100],sum=0,dif=1e5,ans;
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(int i=0;i<n;i++){
        if(d(sum,n*a[i])<dif){
            dif=d(sum,n*a[i]);
            ans=i;
        }
    }
    printf("%d",ans);
    return 0;
}

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<ll> v(N);

    REP(i, N){
        cin >> v[i];
    }

    map<ll, ll> A;
    map<ll, ll> B;

    REP(i, N){
        if(i%2 == 0){
            A[v[i]]++;
        }
        else{
            B[v[i]]++;
        }
    }

    ll amax = 0;
    ll bmax = 0;

    ll atop = 0;
    ll asecond = 0;
    ll btop = 0;
    ll bsecond = 0;

    for(auto iter=A.begin(); iter!=A.end(); iter++){
        if(amax <= iter->second){
            amax = iter->second;
            atop = iter->first;
        }
    }
    amax = 0;
    for(auto iter=A.begin(); iter!=A.end(); iter++){
        if(iter->first == atop) continue;
        if(amax <= iter->second){
            amax = iter->second;
            asecond = iter->first;
        }
    }

    for(auto iter=B.begin(); iter!=B.end(); iter++){
        if(bmax <= iter->second){
            bmax = iter->second;
            btop = iter->first;
        }
    }
    bmax = 0;
    for(auto iter=B.begin(); iter!=B.end(); iter++){
        if(iter->first == btop) continue;
        if(bmax <= iter->second){
            bmax = iter->second;
            bsecond = iter->first;
        }
    }

    if(atop != btop){
        cout << N - A[atop] - B[btop] << endl;
        return 0;
    }
    if(A[atop] > B[btop]){
        cout << (N/2-A[atop]) + (N/2-B[bsecond]) << endl;
    }
    else if(A[atop] < B[btop]){
        cout << (N/2-A[asecond]) + (N/2-B[btop]) << endl;
    }
    else{
        cout << (N/2-A[atop]) + (N/2-max(A[asecond], B[bsecond])) << endl;;
    }
    return 0;
}

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

int main(){
  int h,w,k;
  int ans = 0;
  int sum = 0;
  int max = 0;
  
  cin >> h >> w >> k;
  char s;
  int mas[h+1][w+1];
  int hsum[h]={};
  int wsum[w] = {};
  
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin >> s;
      if(s == '.')
        mas[i][j] = 0;
      else{
        mas[i][j] = 1;
        hsum[i]++;
        wsum[j]++;
        max++;
      }
    }
  }
  
  /*for(int j=0;j<w;j++)
    cout << wsum[j] << endl;*/
  
  for(int bit=0;bit < (1<<h); ++bit){
    for(int bitb = 0;bitb < (1<<w);bitb++){
      for(int i=0;i<h;i++){
        if(bit & (1<<i)){
            sum = sum + hsum[i];
        }
        for(int j=0;j<w;j++){
          if(i==0){
            if(bitb & (1<<j)){
              sum = sum + wsum[j];
            }
          }
          if(bit & (1<<i) && bitb & (1<<j)){
            if(mas[i][j] == 1)
              sum--;
          }
        }
      }
      //cout << sum << endl;
      if((max-sum) == k)
         ans++;
      sum = 0;
    }
  }
  cout << ans;
} 

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

#define fi first
#define se second
#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define pb push_back;
#define int long long

const int N = 1e5 + 10;
const int oo = 1e9;

int n, maxn;
int a[N];
bool flag = true;

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> maxn;
    FOR(i, 1, n) cin >> a[i];
    sort(a + 1, a + n + 1);
    int cnt = 0;
    FOR(i, 1, n) {
        if(maxn >= a[i]) cnt ++, maxn -= a[i];
        else {
            flag = false;
        }
    }
    if(maxn > 0 && cnt > 0) cnt -= flag;
    cout << cnt;
}


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

// Sugar Water
int main() {
	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	int dp[32][3010];		// max_sugar[w][s] : density=100*s/(100w+s)<=E
	int W = 1;		// answer_water
	int S = 0;		// answer_sugar
	
	dp[0][0] = 0;
	for (int w_max=0; w_max<=F/100; w_max++) {
//cout << w_max << ": " << W << " " << S << endl;//debug
		int w = 0;		// now_water 
		for (int a=0; a*A<=w_max; a++)
			for (int b=0; a*A+b*B<=w_max; b++)
				w = max(w, a*A + b*B);
		
		int s_max = E * w;
//cout << s_max << endl;//debug
		for (int s=0; s<=F-100*w; s++) {
			if (w == 0 || s == 0) {dp[w][s] = 0; continue;}
			int now_max = 0;
			now_max = max(now_max, (w>=A)? dp[w-A][s]: 0);
			now_max = max(now_max, (w>=B)? dp[w-B][s]: 0);
			
			now_max = max(now_max, (s>=C)? dp[w][s-C] + 
			              ((s_max < dp[w][s-C] + C)? 0: C): 0);
			now_max = max(now_max, (s>=D)? dp[w][s-D] + 
			              ((s_max < dp[w][s-D] + D)? 0: D): 0);
//cout << s << ":: " << now_max << " ";//debug
			dp[w][s] = now_max;
			if ((float)S/(100*W+S) < (float)now_max/(100*w+now_max)) {
				W = w; S = now_max;
//cout << "::: "<< W << " " << S << endl;//debug
			}
		}
	}

	if (S == 0) {W = A;}	// case... max density is 0%
	// この場合 0 0 でも正解かと思ったのですが、違うようです。

	cout << 100*W+S << " " << S << endl;
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>

int main(void)

{
    int a,b;

    scanf("%d %d",&a,&b);

    if( a < b )
        printf( "a < b\n" );
    if( a > b )
        printf( "a > b\n" );
    if( a == b )
        printf( "a == b\n");

    return 0;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
using namespace std;
using ll=long long;
int main(){
    int n;
    cin>>n;
    vector<int>a(n);
    int ans=0;
    rep(i,n){
        cin>>a[i];
        while(a[i]%2==0){
            a[i]/=2;
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>

const int N=100005;

int f[N],cnt[N],n,m;

struct info{
	int l,r;
}a[N*3];

bool cmp(info a,info b){
	return a.r-a.l<b.r-b.l;
}

void add(int x,int y){
	for (;x<=m;x+=x&-x) f[x]+=y;
}

int sum(int x){
	int y=0;
	for (;x;x-=x&-x) y+=f[x];
	return y;
}

int main(){
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=n;i++){
		scanf("%d%d\n",&a[i].l,&a[i].r);
		cnt[a[i].r-a[i].l]++;
	}
	for (int i=m;i;i--) cnt[i]+=cnt[i+1];
	std::sort(a+1,a+n+1,cmp);
	for (int i=1,j=1;i<=m;i++){
		for (;j<=n && a[j].r-a[j].l<i;j++){
			add(a[j].l,1);add(a[j].r+1,-1);
		}
		int ans=cnt[i];
		for (int k=i;k<=m;k+=i) ans+=sum(k);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 3968
refN, renN, disN = map(int, input().split())
 
ref = list(map(int,input().split()))
ren = list(map(int,input().split()))
 
dis = [input().split() for _ in range(disN)]
 
minCost = 0
wake = 0
 
for kk in range(disN):
    cost = ref[int(dis[kk][0])-1] + ren[int(dis[kk][1])-1] - int(dis[kk][2])
    if wake == 0 or cost < minCost:
        wake = 1
        minCost = cost
 
ref.sort()
ren.sort()
 
cost = ren[0] + ref[0]
if cost < minCost:
    minCost = cost
 
print(minCost)

Measured memory_bytes: 46104
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


s = S()
print(s[:3])


Measured memory_bytes: 9040
from collections import Counter

n, k = map(int,input().split())
A = list(map(int,input().split()))

cnt = Counter(A)

s = len(cnt.keys())

ans = 0
kosu = sorted(cnt.values())
ind = 0
while s > k:
    s -= 1
    ans += kosu[ind]
    ind += 1

print(ans)

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

using namespace std;


int main() {
    int a,b,c,k;
    cin>>a>>b>>c;
    cin>>k;
    int m=max(a,max(b,c));
    cout<<a+b+c-m+m*pow(2,k)<<endl;
    return 0;
}

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

import static java.lang.Character.isUpperCase;

public class Main {

    public static void main(String[] args) {

        Scanner in = new Scanner(System.in);
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        int d = in.nextInt();
        int e = in.nextInt();

           if(a==0)
           {
               System.out.println(1);

           }
           else if(b==0)
           {
               System.out.println(2);

           }
           else if(c==0)
           {
               System.out.println(3);

           }
           else if(d==0)
           {
               System.out.println(4);

           }
           else
           {
               System.out.println(5);

           }
    }




    }




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

int main()
{
  bool rev = false;
  string s;
  int q, t, f;
  string c;
  cin >> s >> q;
  for (int i = 0; i < q; i++) {
    cin >> t;
    if (t == 1) {
      rev = !rev;
      continue;
    }
    cin >> f >> c;
    if ((f == 1 && !rev) || (f == 2 && rev)) {
      s.insert(0, c);
    } else {
      s.insert(s.size(), c);
    }
  }
  if (rev) reverse(s.begin(), s.end());
  cout << s << endl;

  return 0;
}


Measured memory_bytes: 900
#include <iostream>
#include <iomanip>
#include <stdlib.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	uint16_t H, W, h, w;
	cin >> H >> W >> h >> w;
	uint16_t Total = H * W;
	uint16_t Black = (h * W) + (H * w) - (h * w);
	cout << Total - Black << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;
	cin>>n;
	string s[n];
	for(int i=0;i<n;i++)
		cin>>s[i];
	ll m=0,a=0,r=0,c=0,h=0;
	for(int i=0;i<n;i++)
	{
		if(s[i][0]=='M')
			m++;
		else if(s[i][0]=='A')
			a++;
		else if(s[i][0] =='R')
			r++;
		else if(s[i][0]=='C')
			c++;
		else if(s[i][0]=='H')
			h++;

	}

	ll ways = m*a*r + m*a*c + m*a*h + m*r*c + m*r*h + m*c*h + a*r*c + a*r*h + a*c*h + r*c*h;
	cout<<ways<<"\n";
}


Measured memory_bytes: 6768
#include<iostream>
#include<cmath>
#define INF 10e9

using namespace std;
static const int MAX=100;
int main(void){
	int N;
		cin >> N;
	int A[MAX];
	double res=0;
	for(int i=0;i<N;i++){
		cin >> A[i];
		res+=A[i];
	}
	
	res/=N;
	int ans;
	double xmin=INF;
	for(int i=0;i<N;i++){
		if(abs(A[i]-res)<xmin){
			xmin=abs(A[i]-res);
			ans=i;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

plii getans(int a,ll m)
{
    if(m==1){
        return plii(a,0);
    }

    plii cur;
    plii nxt;

    if(m&1){
        cur = getans(a,(m^1));
        nxt.f = a+cur.f;
        nxt.s = cur.s+1;
        if(nxt.f>=10){
            nxt.f = (a+cur.f)/10+(a+cur.f)%10;
            nxt.s++;
        }
        return nxt;
    }

    cur = getans(a,m>>1);

    nxt.f = cur.f+cur.f;
    nxt.s = cur.s*2+1;
    if(nxt.f>=10){
        nxt.f = (cur.f+cur.f)/10+(cur.f+cur.f)%10;
        nxt.s++;
    }

    return nxt;
}
int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    ll res = 0;
    plii cur;
    int bef = 0;
    int tmp;

    for(int i=0;i<n;i++){
        cin>>x>>y;
        if(!x){
            res+=y;
            continue;
        }
        cur = getans(x,y);
        res+=cur.s;
        if(!bef){
            bef = cur.f;
            continue;
        }
        res++;
        bef+=cur.f;
        if(bef>=10){
            tmp = bef;
            bef = tmp/10+tmp%10;
            res++;
        }
        //cout<<cur.f<<" "<<cur.s<<"\n";
        //cout<<res<<"\n";
    }

    cout<<res<<"\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define fsp(x) fixed << setprecision(x)
#define xout cerr
const ll inf = LLONG_MAX;
const long double pi = acosl(-1);
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	//const ll p = 1e9 + 7;
	//const ll p = 998244353;

	ll p, q, r;
	cin >> p >> q >> r;
	cout << min({p + q, q + r, r + p}) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<queue>
using namespace std;
deque<int> Q;
int n,a;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;++i){
		scanf("%d",&a);
		if(i&1) Q.push_back(a);
		else Q.push_front(a);
	}
	if(n&1){
		while(!Q.empty()){
			printf("%d ",Q.back());
			Q.pop_back();
		}
	}
	else{
		while(!Q.empty()){
			printf("%d ",Q.front());
			Q.pop_front();
		}
	}
	return 0;
}
		


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

int main() {
  int n,m;
  cin>>n>>m;
  if(n!=2&&m!=2){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++){
        cin >> a[i];
    }
    long long sum = 0;
    long long ans = 0;

    for(int i = 0; i < N; i++){
        sum += a[i];

        if(i % 2 == 0){
            if(sum < 0){
                ans += -(sum) + 1;
                sum = 1;
            } else if(sum == 0){
                ans++;
                sum = 1;
            }
        } else {
            if(sum > 0){
                ans += sum + 1;
                sum = -1;
            } else if(sum == 0){
                ans++;
                sum = -1;
            }
        }
    }

    sum = 0;
    long long ans2 = 0;

    for(int i = 0; i < N; i++){
        sum += a[i];

        if(i % 2 != 0){
            if(sum < 0){
                ans2 += -(sum) + 1;
                sum = 1;
            } else if(sum == 0){
                ans2++;
                sum = 1;
            }
        } else {
            if(sum > 0){
                ans2 += sum + 1;
                sum = -1;
            } else if(sum == 0){
                ans2++;
                sum = -1;
            }
        }
    }

    cout << min(ans,ans2) << endl;




}

Measured memory_bytes: 640
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const H=input[0].split(' ')[0]-0;
  const N=input[0].split(' ')[1]-0;
  var memo=[0];
  var A=input.map(e=>{
    return e.split(' ')[0]-0;
  });
  A.shift();
  var B=input.map(e=>{
    return e.split(' ')[1]-0;
  });
  B.shift();
  var min;
  for(var i=1;i<=H;i++){
    min=Infinity;
    for(var j=0;j<N;j++){
      if(i<=A[j]){
        min=Math.min(min,B[j]);
      }else{
        min=Math.min(min,B[j]+memo[i-A[j]]);
      }
    }
    memo.push(min);
  }
  console.log(memo[H]);
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 33296
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define print(x) std::cout<<x<<"\n"
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define repd(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}
VI Bit2Vector(const ll bit, ll n) {	VI s;	rep(i,n) if (bit & (1 << i)) s.push_back(i); return s;}

VI bfs(VVI &ab,ll s=0){
	deque<ll> que;
	VI res(SZ(ab),-1);
	que.push_back(s);
	res[s]=s;
	while (!que.empty()) {
		ll now=que.front();que.pop_front();
		for(ll id:ab[now]){
			if(res[id]!=-1) continue;
			res[id]=now;
			que.push_back(id);
		}
	}
	return res;
}

void Main()
{
	ll n,m,l; ll res=0;
	string s,t,u; string sres="No or NO";

	cin>>n>>m;
	VVI ab(n);
	VI ress(n);
	rep(i, m) {
		ll a,b;
		cin >> a>>b;
		a--;b--;
		ab[a].emplace_back(b);
		ab[b].emplace_back(a);
	}
	print("Yes");
	ress=bfs(ab,0);
	rep(i,n-1) print(1+ress[i+1]);
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 13756
// import kotlin.comparisons.*
// import kotlin.math.*
import java.util.*

const val mod = 1000000007L

fun readI() = readLine()!!.toInt()
fun readL() = readLine()!!.toLong()
fun readD() = readLine()!!.toDouble()
fun readIs() = readLine()!!.split(' ').map(String::toInt)
fun readLs() = readLine()!!.split(' ').map(String::toLong)
fun readDs() = readLine()!!.split(' ').map(String::toDouble)

fun main(args: Array<String>) {
  val (a, b, c) = readIs().sorted()
  if ((a == b && b != c) || (a != b && b == c)) {
    println("Yes")
  } else {
    println("No")
  }
}


Measured memory_bytes: 38048
N,M = map(int,input().split())
X=[int(i) for i in input().split()]
X.sort()

Y=list()
for i in range(M)[1:]:
  Y.append(X[i]-X[i-1])

Y.sort()

if N==1:
  print(sum(Y))
else:
  print(sum(Y[:-(N-1)]))

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

#define rep(i,n) for(int i=0;i<n;i++)
#define strep(i,n) for(static int i=0;i<n;i++)
#define ll long long

int main(){
    char b ;
    cin >> b ;
    if(b=='A') cout << 'T' << endl ;
    else if(b=='T') cout << 'A' << endl ;
    else if(b=='G') cout << 'C' << endl ;
    else if(b=='C') cout << 'G' << endl ;
}

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

using namespace std;

int main(){
	int n, a, b, cash, h, k, j, ans;
	h = 0;
	k = 0;
	ans = 0;
	bool flag1 = false;
	bool flag2 = false;
	vector<int> list,first,second,third;

	cin >> n >> a >> b;
	for (int i = 0; i < n; ++i)
	{
		cin >> cash;
		list.push_back(cash);
	}

	for (int i = 0; i < n; i++)
	{
		if (list[i] <= a) {
			first.push_back(list[i]);
			flag1 = true;
		}
		if (list[i] >= b+1) {
			third.push_back(list[i]);
			flag2 = true;
		}
		if (list[i] >= a + 1 && list[i] <= b) {
			second.push_back(list[i]);
			if (flag1)
			{
				h += 1;
			}
			if (flag2) {
				k += 1;
			}
		}
		
		

		flag1 = false;
		flag2 = false;
	}

	int fl = first.size();
	int sl = second.size();
	int tl = third.size();

	while (h>0 || k>0)
	{
		if (fl>sl && h>0)
		{
			h--;
			fl--;
		}
		else {
			sl--;
			h--;
		}
		if (tl > sl && k > 0)
		{
			k--;
			tl--;
		}
		else {
			sl--;
			k--;
		}
	}

	if (fl<sl && fl<tl)
	{
		ans = fl;
	}
	else if (sl < fl && sl < tl) {
		ans = sl;
	}
	else {
		ans = tl;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
import collections
n = int(input())

dic = collections.defaultdict(int)
dic_tmp = collections.defaultdict(int)
for i in range(n):
    s = input()
    if i == 0:
        for j in range(len(s)):
            dic[s[j]] += 1
    else:
        for j in range(len(s)):
            dic_tmp[s[j]] += 1
        for j in dic.keys():
            dic[j] = min(dic[j],dic_tmp[j])
    dic_tmp.clear()

ls = list(dic.keys())
ls.sort()
ans = ""
for i in range(len(ls)):
    ans +=  ls[i] * dic[ls[i]]
print(ans)


Measured memory_bytes: 74812
n,d = map(int, input().split())


x = []
for i in range(n):
    x.append(list(map(int, input().split())))


result = 0

for i in range(n):
    for j in range(n):
        if i < j:
            dist = 0
            for k in range(d):
                dist += (x[i][k] - x[j][k]) ** 2
            dist = dist ** 0.5
            if dist.is_integer():
                result += 1
print(result)

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[222222];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[222222],b[222222];
pair<int,int>p[222222];
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i]>>b[i];
		p[i]={b[i],a[i]};
	}
	sort(p,p+n);
	int sum=0;
	rep(i,n){
		sum+=p[i].second;
		if(sum<=p[i].first)continue;
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}


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

using namespace std;
using ll = long long;

//container util
#define SORT(c) sort((c).begin(),(c).end())

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

const int INF = 1e9;

int main(void){


	int H, W; cin >> H >> W;
	char s[H][W];

	REP(i,H){
		REP(j,W){
			cin >> s[i][j];
		}
	}

	bool ans = true;
	//上下左右
	int dx[4] = {0, 0, -1, 1};
	int dy[4] = {1, -1, 0, 0};
	REP(i,H){
		REP(j,W){
			if(s[i][j] == '.') continue;
			int cnt = 0;
			REP(k,4){
				int y = i + dy[k];
				int x = j + dx[k];
				if(y > -1 and y < H and x > -1 and x < W){
					if(s[y][x] == '#') cnt++;
				}
			}
		if(cnt == 0) ans = false;
		}
	}

	if(ans) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;

}


Measured memory_bytes: 256
from math import gcd

N = int(input())
AB = [map(int, input().split()) for _ in range(N)]

t = set()
d = {}
d[0] = {}
d[0][0] = 0
for a, b in AB:
    i = gcd(a, b)
    if i != 0:
        a //= i
        b //= i
    t.add((a, b))
    d.setdefault(a, {})
    d[a].setdefault(b, 0)
    d[a][b] += 1
if (0, 0) in t:
    t.remove((0, 0))

used = set()
result = 1
for a, b in t:
    if (a, b) in used:
        continue
    used.add((a, b))
    i = d[a][b]
    j, k, l = 0, 0, 0
    if -a in d and -b in d[-a]:
        j = d[-a][-b]
        used.add((-a, -b))
    if -b in d and a in d[-b]:
        k = d[-b][a]
        used.add((-b, a))
    if b in d and -a in d[b]:
        l = d[b][-a]
        used.add((b, -a))
    result *= pow(2, i + j, 1000000007) + pow(2, k + l, 1000000007) - 1
    result %= 1000000007
result += d[0][0] - 1
result %= 1000000007
print(result)


Measured memory_bytes: 157944
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = 10**18
# ----------------------------------------------------------- #

n, x = Is()
Blen = [0]*(n+1)
P = [0]*(n+1)
Blen[0] = 1
P[0] = 1
for i in range(1, n):
    Blen[i] = Blen[i-1]*2 + 3
    P[i] = P[i-1]*2 + 1
def burger(i, y):
    if i == 0:
        return 0 if y <= 0 else 1
    if y <= Blen[i-1] + 1:
        return burger(i-1, y-1)
    else:
        return P[i-1] + 1 + burger(i-1, y-Blen[i-1]-2)
print(burger(n, x))


Measured memory_bytes: 63340
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    string s;cin>>s;
    int n = s.size();
    int cnt = 0;
    bool f = true;
    if(s[0] != 'A')f = false;
    else {
    REP(i,1,n-1){
        if(s[i] != 'C' && s[i]<'a')f = false;
        if(i < 2 || i > n-2)if(s[i] == 'C')f = false;
        if(i < n-1 && i > 1 && s[i] == 'C')cnt++;
    }
    }
    if(cnt == 1 && f)cout<<"AC";
    else cout<<"WA";
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string a,b;
    cin >> a >> b;
    int na = a.length();
    int nb = b.length();
    if(na > nb){
        cout << "GREATER" << endl;
    }else if(na < nb){
        cout << "LESS" << endl;
    }else{
        rep(i,na){
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }else if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>
#define T 500001
int hep[T];
int o;
void hen(int *i,int *m){
  int te;
  te =*i;
  *i=*m;
  *m=te;
}
void hepfy(int i){
  int max;
  int tem;
  if(i*2<= o &&hep[i*2]>hep[i]){
    max=i*2;
  }
  else max=i;
  
  if(i*2+1<=o &&hep[i*2+1]>hep[max]){
    max=i*2+1;
  }

  if(max !=i){
    tem= hep[i];
     
    hep[i]=hep[max];
    hep[max]= tem;
    hepfy(max); 
  }
}
void hep2(){
  int i;
  for(i=o/2;i>=1;i--){
    hepfy(i);
  }
}

int main(){
  int i;
  scanf("%d",&o);
  for(i=1;i<=o;i++){
    scanf("%d",&hep[i]);
  }

  hep2();
 
  for(i=1;i<=o;i++){
    printf(" %d",hep[i]);
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 3652
#include<stdio.h>

int main(void){
    int a[3],max=0,i,k,sum=0;
    for(i=0;i<3;i++){
        scanf("%d",&a[i]);
        sum+=a[i];
        if(a[i]>max){
            max=a[i];
        }
    }
    sum-=max;
    scanf("%d",&k);
    for(i=0;i<k;i++){
        max*=2;
    }
    printf("%d\n",sum+max);
    return 0;
}


Measured memory_bytes: 128
K = int(input())
r = [[] for _ in range(10)]
r[0] = list(range(1,10))

for i in range(9):
  for a in r[i]:
    s = str(a)
    d = a%10
    for j in range(d-1, d+2):
      if not 0 <= j <= 9: continue
      r[i+1].append(int(s+str(j)))

for i in range(10):
  if K >= len(r[i]):
    K -= len(r[i])
  else:
    print(r[i][K-1])
    break

Measured memory_bytes: 11016