akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h> 

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

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

    int N, x;
    cin >> N >> x;

    vector<int> a(N);
    rep (i, N) {
        cin >> a[i];
    }

    ll ans = 0;
    if (a[0] > x) {
        ans += (a[0] - x);
        a[0] = x;
    }

    for (int i = 0; i < N-1; i++) {
        if (a[i]+a[i+1] > x) {
            ans += (a[i] + a[i+1] - x);
            a[i+1] = x - a[i];
        }
    }

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

Measured memory_bytes: 640
#include <iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define rep(i,j,n) for(ll (i)=(j);(i)<(n);(i)++)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define pb push_back
#define mp make_pair
typedef pair<ll, ll> P;
const long long INF = 1LL << 60;
const long long MOD = 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;



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

//グラフ関連
struct Edge {//グラフ
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

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

	ll n, k, s;
	cin >> n >> k >> s;

	REP(i, k) cout << s << endl;
	REP(i, n - k) cout << (s+1)%1000000000 << endl;

	return 0;
}


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

int main()
{
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);

    unsigned long long n, minimum;
    cin >> n;
    minimum = n - 1;

    for (unsigned long long i = 2; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            // if (((n / i) - 1) + (i - 1) < minimum)
            //     minimum = ((n / i) - 1) + (i - 1);
            minimum=min(((n / i) - 1) + (i - 1),minimum);
        }
    }
    cout << minimum;

    return 0;
}

Measured memory_bytes: 888
import bisect
N = int(input())
Ls = list(map(int, input().split()))

sls = sorted(Ls)
count = 0
for i in range(N - 1):
    for j in range(i+1, N):
        a, b = sls[i], sls[j]
        right = bisect.bisect_left(sls, b + a)
        count += right - j - 1
print(count)

Measured memory_bytes: 3188
<?php
$arr1 = explode(" ",trim(fgets(STDIN)));
  $arr2 = explode(" ",trim(fgets(STDIN)));
  $cnt = 0;
  for($i=0;$i<$arr1[0];$i++) {
      if($arr2[$i]>=$arr1[1]) {
          $cnt++;
      } 
  }
  echo $cnt;

Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  ll n,m;
  cin >> n >> m;
  ll a[n+1];
  rep(i,n) R a[i];
  a[n]=0;
  ll ans=0;
  rep(i,n) {
    ll y=a[i]+a[i+1];
    ll z=max(0LL,y-m);
    ans+=z;
    a[i+1]-=min(a[i+1],z);
  }
  pr(ans);
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}


Measured memory_bytes: 1024
N = int(input())
L = list(map(int,input().split()))
# ソートすることで k が三角形の長辺になるように出来る
L.sort()
ans = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        # 同じ長さであればcontinue
        if L[i]==L[j]:
            continue
        for k in range(j+1,N):
            # 同じ長さであればcontinue
            if L[i]==L[k] or L[j]==L[k]:
                continue
            # 長辺が他の2辺の長さの合計よりも短ければ
            # 三角形になる
            if L[k]<L[i]+L[j]:
                ans += 1
print(ans)

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

int main(){
  ll N,M;cin>>N>>M;
  priority_queue<ll,vll,greater<ll>> que;
  rep(i,N){
    ll a;cin>>a;que.push(a);
  }
  vector<pair<ll,ll>> p;
  rep(i,M){
    ll b,c;cin>>b>>c;
    p.push_back(make_pair(b,c));
  }
  sort(all(p),[&](auto const& a,auto const& b){return a.second>b.second;});
  bool flag=true;
  rep(i,M){
    pair<ll,ll> tmp = p[i];
    rep(j,tmp.first){
      ll q = que.top();
      if(q<tmp.second){
        que.pop();
        que.push(tmp.second);
      }
      else{ flag = false; break;}
    }
    if(flag==0) break;
  }

  ll ans=0;
  while(!que.empty()){
    ans += que.top();
    que.pop();
  }
  cout<<ans<<endl;
}

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


int main(){
    
    int n;
    cin>>n;
    long max=-1000000000,min=1000000000;
    for(int i=0;i<n;i++){
        long a;
        cin>>a;
        if(i!=0){
        if(max<a-min)max=a-min;
        }
        if(min>a)min=a;
    }
    cout<<max<<endl;
    
    return 0;
}


Measured memory_bytes: 3108
import java.util.Scanner;
import java.io.*;

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

       
        int str_B = scan_A.nextInt();

        
        int str_C = scan_A.nextInt();

        int ans;
        int E = str_A - str_B;
        if(E >str_C ){
            ans = 0;
        }else{
           
            ans = str_C -E;
        }
       
               
        System.out.println(ans);
    }

}

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

using namespace std;

#define int long long
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define mp make_pair
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define All(a) (a).begin(), (a).end()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CINT(...)                                                              \
    int __VA_ARGS__;                                                           \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Yes(a) cout << (a ? "Yes" : "No") << "\n"
#define YES(a) cout << (a ? "YES" : "NO") << "\n"
#define Printv(v)                                                              \
    {                                                                          \
        FOREACH(x, v) { cout << x << " "; }                                    \
        cout << "\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);
}

typedef long long ll;
typedef unsigned long long ul;
typedef vector<ll> VL;
typedef pair<ll, ll> PL;
typedef priority_queue<ll> PQ;
typedef priority_queue<ll, VL, greater<ll>> PQG;

const int INF = 1e9;
const int MOD = 1e9 + 7;
// const int MOD = 998244353;
const ll LINF = 1e18 + 1;
const ll dx[] = {1, -1, 0, 0};
const ll dy[] = {0, 0, 1, -1};

ll N;
map<ll, ll> sum;

map<ll, ll> primefact(ll n) {
    map<ll, ll> res;
    for(ll i = 2; i * i <= n; i++) {
        while(n % i == 0) {
            res[i]++;
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}

ll modmul(ll a, ll b) { return ((a % MOD) * (b % MOD)) % MOD; }

signed main() {
    cin >> N;
    FOR(i, 1, N + 1) {
        auto pr = primefact(i);
        FOREACH(x, pr) sum[x.first] += x.second;
    }
    ll ans = 1;
    FOREACH(s, sum) { ans = modmul(ans, s.second + 1); }
    cout << ans << "\n";
}


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

#define REP(i,n) for(int i=0;i<int(n);i++)
#define ALL(v) (v).begin(),(v).end()

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}	 

const ll mod=1e9+7;
const int INF=INT_MAX/2;
const int N_MAX=200020;

int n;
int a[200020];

int main(){
	cin>>n;
	REP(i,n)cin>>a[i];
	ll ans=0;
	if(a[0]>0){
		cout<<-1<<endl;
		return 0;
	}
	REP(i,n-1){
		if(a[i+1]-a[i]>1){
			cout<<-1<<endl;
			return 0;
		}else{
			if(a[i+1]-a[i]==1){
				ans++;
			}else{
				ans+=a[i+1];
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <map>
typedef long long ll;
using namespace std;
int mod = 1e9+7;

int main(){
	map<int, int> C;
	int N, M;
	cin >> N >> M;

	C[0] = 1;
	C[1] = 1;
	C[2] = 2;
	for (int i = 3; i <= N; i++) {
		C[i] = (C[i-1] + C[i-2]) % mod;
	}

	int tmp;
	int zendan = 0;
	int ans = 1;
	for (int i = 0; i < M; i++) {
		cin >> tmp;
		if (zendan == tmp) {
			ans = 0;
			break;
		}
		ll sa = tmp - zendan - 1;
		ans = ((ll)ans * C[sa]) % mod;
		zendan = tmp + 1;
	}

	ll sa = N - zendan;
	ans = ((ll)ans * C[sa]) % mod;
	cout << ans << endl;
	
	return 0;
}


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

#define rep(i,a,n) for (int i = a;i < n;i++)
#define per(i,n,a) for (int i = n-1;i >= a;i--)
 
typedef long long ll;
using namespace std;
 
int main(){
  int n,x,y;

  cin >> n;
  y = n;
  
  rep(i,0,8){
    x += n%10;
    n = n/10;
  }

  
  if(y%x == 0) printf("Yes\n");
  else printf("No\n");

  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n)  cin >> a[i];

  ll sum=0;

  rep(i,n-1){
    if(a[i]-a[i+1]>=0){
      int j= a[i] - a[i + 1];
      a[i + 1] += j;
      sum += j;
    }
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3956
#include<bits/stdc++.h>
using namespace std;
int n,s,i,j,p;
long long ans;
char c[200005];
int main()
{
	scanf("%s",c+1);
	for(i=1;c[i];++i)
		if(c[i]=='0')
			++s;
	for(i=1;c[i];++i)
	{
		if(c[i]=='0')
			break;
		if(i&1)
			ans+=s+1;
	}
	for(++i;c[i];++i)
	{
		++p;
		int s0=0,s1=0;
		for(j=i;c[j]=='1';++j)
		{
			if(j&1)
				++s1;
			else
				++s0;
		}
		if(s0<s1)
			ans+=(p+1)/2*s0+p/2*s1+1ll*s1*(s+1-p);
		else
			ans+=((p+1)/2-1)*s0+(p/2+1)*s1+1ll*s0*(s+1-p);
		i=j;
	}
	s=-1;
	for(i=1;c[i];++i)
		if(c[i]=='1')
			++s;
	while(s>0)
	{
		ans+=(s+1)/2;
		--s;
	}
	cout<<ans;
}


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

using namespace std;

#define INF 1e9
#define MAXN 100005
#define MAXM 100005
#define ll long long
#define vi vector<int>
#define vll vector<long long>
#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pii pair<int, int>

ll ans = 0;
int N, tmp;
vi pre, L;

void solve(){
    sort(L.begin(), L.end());

    rep(i, N){
        for(int j = i+1; j < N; ++j){
            // cout << i << " " << j << endl;
            // cout << L[i] << " and " << L[j] << endl;
            tmp = L[i] + L[j];

            auto itr = lower_bound(L.begin(), L.end(), tmp);
            ans += distance(L.begin(), itr) - 1 - j;
        }
    }

    cout << ans << endl;
}

int main(){
    cin >> N;
    L.resize(N);

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

    solve();
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n;
    scanf("%d",&n);
    int x[n],i,c=0;
    for(i=0;i<n;i++) scanf("%d",&x[i]);
    for(i=0;i<n;i++){
        if(i>0 && i<n-1) {
            if((x[i]>x[1+i]&& x[i]<x[i-1])|| (x[i]<x[1+i]&& x[i]>x[i-1])) c++;
        }
    }
    printf("%d\n",c);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

string s[50], t[50];

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i, 0, n) cin >> s[i];
    rep(i, 0, m) cin >> t[i];
    rep(i, 0, n - m + 1){
        rep(j, 0, n - m + 1){
            bool f = true;
            rep(k, 0, m){
                rep(l, 0, m){
                    if(s[i + k][j + l] != t[k][l]){
                        f = false;
                        k = m;
                        break;
                    }
                }
            }
            if(f){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using vb=vector<bool>;
using vvb=vector<vb>;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pll = pair<ll,ll>;
using vpii = vector<pii>;
using vpli = vector<pli>;
using vpll = vector<pll>;

#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++)
int INF=1e9+7;

int main() {
  int N;
  cin >> N;
  vector<double> v(N);
  rep(i,N) cin >> v[i];
  sort(v.begin(),v.end());
  
  double ans=v[0];
  rep2(i,1,N) ans=(ans+v[i])/2;
  
  cout << fixed << setprecision(5) << ans << endl;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
#define INF INT_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(ll i=0; i<n; ++i)
#define FOR(i, s, e) for(ll i=s; i<e; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S; cin >> S;
  int ans = 0;
  rep(i, S.size()/2) {
    char c1 = S[i], c2=S[S.size()-1-i];
    if(c1 != c2) ++ans;
  }
  cout << ans;
}

Measured memory_bytes: 256
def main():
  t = input().split(" ")
  Q, H, S, D = int(t[0]), int(t[1]), int(t[2]), int(t[3])
  N = int(input())
  if Q*4 < S:
    S = Q*4
  if H*2 < S:
    S = H*2
  if S*2 < D:
    D = S*2
  ans = (N//2) * D
  ans += (N%2) * S
  print(ans)
main()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i,j,n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(), i.rend()
#define INF 1e9
#define LINF 1e18
const int mod = 1e9 + 7;
 
typedef long long i64;
typedef pair<int, int> pi;
 
template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;
 
i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {1, 0, -1, 0};
int dy[] = {0, 1, 0, -1};

template <std::int_fast64_t MOD> class ModInt {
  private:
    std::int_fast64_t value;

  public:
    ModInt() : value(0) {}

    ModInt(std::int_fast64_t x) : value(x % MOD) {
      if(value < 0) value += MOD;
    }

    ModInt &operator+=(const ModInt &x) {
      value += x.value;
      if(value >= MOD) value -= MOD;
      return *this;
    }

    ModInt &operator-=(const ModInt &x) {
      if(value < x.value) value += MOD;
      value -= x.value;
      return *this;
    }

    ModInt &operator*=(const ModInt &x) {
      value = value * x.value % MOD;
      return *this;
    }

    ModInt &operator/=(const ModInt &x) {
      *this *= x.inverse();
      return *this;
    }

    ModInt operator-() const { return ModInt(-value); }

    ModInt operator+(const ModInt &x) const { return ModInt(*this) += x; }

    ModInt operator-(const ModInt &x) const { return ModInt(*this) -= x; }

    ModInt operator*(const ModInt &x) const { return ModInt(*this) *= x; }

    ModInt operator/(const ModInt &x) const { return ModInt(*this) /= x; }

    bool operator==(const ModInt *x) const { return value == x.value; }

    bool operator!=(const ModInt *x) const { return value != x.value; }

    ModInt inverse() const {
      std::int_fast64_t a = value, b = MOD, u = 1, v = 0, t;
      while(b > 0) {
        t = a / b;
        std::swap(a -= t * b, b);
        std::swap(u -= t * v, v);
      }
      return ModInt(u);
    }

    ModInt pow(int64_t n) const {
      ModInt ret(1), mul(value);
      while(n > 0) {
        if(n & 1) ret *= mul;
        mul *= mul;
        n >>= 1;
      }
      return ret;
    }

    friend std::ostream &operator<<(std::ostream &os, const ModInt &x) {
      return os << x.value;
    }

    friend std::istream &operator>>(std::istream &is, ModInt &x) {
      std::int_fast64_t t;
      is >> t;
      x = ModInt<MOD>(t);
      return is;
    }

    static std::int_fast64_t get_mod() { return MOD; }
};

using modint = ModInt<mod>;

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

  string k;
  int d;
  cin >> k >> d;

  int l = k.size();
  vvt<vt<modint>> dp(l + 1, vvt<modint>(2, vt<modint>(d + 1, 0)));
  dp[0][0][0] = 1;
  rep(i, 0, l) {
    int num = k[i] - '0';
    rep(smaller, 0, 2) {
      rep(j, 0, (smaller ? 9 : num) + 1) {
        rep(s, 0, d) {
          dp[i + 1][smaller || j < num][(s + j) % d] += dp[i][smaller][s];
        }
      }
    }
  }
  cout << dp[l][0][0] + dp[l][1][0] - modint(1) << endl;
}

Measured memory_bytes: 17024
from itertools import product

H, W = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(H)]

move = [(-1, 0), (0, -1), (0, 1), (1, 0)]

cord = []
# cord_prime = []
N = 0

# print(A)

for i, j in product(range(H), range(W)):
    # print(A[i][j])
    if A[i][j] % 2 == 0:
        continue
    else:
        # for di, dj in move:
        #     if j + dj < 0 or i + di < 0 or j + dj >= W or i + di >= H:
        #         continue

        #     if A[i + di][j + dj] % 2:  # 探索が奇数だったら
        #         N += 1
        #         cord.append((i + 1, j + 1, i + di + 1, j + dj + 1))
        #         A[i + di][j + dj] += 1
        #         A[i][j] -= 1
        #         continue

        # なかったら押し付ける
        A[i][j] -= 1
        if i == H - 1:
            # 最終行では隣に押し付ける
            if j != W - 1:
                A[i][j + 1] += 1
                N += 1
                cord.append((i + 1, j + 1, i + 1, j + 2))
            else:
                # 最終マスではなにもしない
                A[i][j] += 1
        else:
            # 基本的に下に押し付ける
            A[i + 1][j] += 1
            N += 1
            cord.append((i + 1, j + 1, i + 2, j + 1))

print(N)
for c in cord:
    print(*c)

# print(A)
# print(A)


Measured memory_bytes: 26708
program main
 implicit none
 integer*16 N,i,S
 integer*16, allocatable::A(:),B(:)
 read(*,*) N
 allocate(A(1:N), B(1:N))
 read(*,*) A
 S = 0D0
 do i=1,N
  S = S + A(i)
 end do
 do i=1,(N-1)/2
  S = S - 2*A(2*i)
 end do
 B(1) = S
 do i=2,N
  B(i) = 2*A(i-1) - B(i-1)
 end do
 write(*,*) B(1:N)
end program main

Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
#define M 998244353
typedef long long int LL;
int main(){
	int n,k;
	cin>>n>>k;
	pair<int,int> s[k];
	for(int i=0;i<k;i++) cin>>s[i].first>>s[i].second;
	sort(s,s+k);
	LL dp[n+1];
	for(int i=0;i<=n;i++) dp[i]=0LL;
	dp[n-1]=1LL;
	for(int i=n-2;i>=0;i--){
		for(int j=0;j<k;j++){
			if(i+s[j].first>=n) break;
			int up;
			up=min(i+s[j].second+1,n);
			dp[i]=(M+dp[i]+dp[i+s[j].first]-dp[up])%M;
		}
		dp[i]=(dp[i]+dp[i+1])%M;
	}
	cout<<(dp[0]-dp[1]+M)%M<<"\n";
}

Measured memory_bytes: 5192
#include <stdio.h>
#include <math.h>

int is_prime[123456 * 2 + 1];
int max_prime  = 123456 * 2 + 1;

void init_prime(void)
{
    int i, j;
    int square = sqrt(max_prime);

    for(i = 0; i <= max_prime; i++){
        is_prime[i] = 1;
    }

    for(i = 2; i <= square;){
        j = i * 2;
        while(j <= max_prime){
            is_prime[j] = 0;
            j += i;
        }
        i++;
        while(!is_prime[i])
            i++;
    }
}

int main(void)
{
    int n;
    int i;
    int num;
    init_prime();

    while(1){
        scanf("%d", &n);
        if(n == 0)
            break;
        num = 0;

        for(i = n + 1; i <= 2 * n; i++){
            if(is_prime[i])
                num++;
        }

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


    return 0;
}

Measured memory_bytes: 1564
from collections import deque

N, Q = map(int, input().split())
routings = [[] for _ in range(N+1)]

for _ in range(N-1):
  a, b = map(int, input().split())
  routings[a].append(b)
  routings[b].append(a)

points = [0 for _ in range(N+1)]
scores = [0 for _ in range(N+1)]

for _ in range(Q):
  p, x = map(int, input().split())
  points[p] += x

visited = [False for _ in range(N+1)]
  
edges = deque([1])
scores[1] = points[1]
visited[1] = True

while len(edges) > 0: 
  e = edges.pop()
  for c in routings[e]:
    if not visited[c]:
      scores[c] += scores[e] + points[c]
      visited[c] = True
      edges.append(c)
print(' '.join(map(str, scores[1:])))
  


Measured memory_bytes: 143780
function Main(input) {

	input = input.split(" ");
	var a = input[0];
	var b = input[1];
	var c = input[2];
	var d = input[3];
	
	if(Math.abs(b - a) <= d && Math.abs(c - b) <= d || Math.abs(a - c) <= d){
		console.log("Yes");
	} else {
		console.log("No");
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

public class Main
{
	public static void main(String [] Args)
	{
		Scanner in=new Scanner(System.in);
		int n=in.nextInt();
		int a=in.nextInt();
		int b=in.nextInt();
		System.out.println(Math.min(n*a,b));
	}
}
	

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

int N;
int C[21],V[21];
int main(){
    cin >> N;
    int ans = 0;
    for(int i=0;i<N;i++) cin >> V[i];
    for(int i=0;i<N;i++) cin >> C[i];
    for(int S=0;S<(1<<N);S++){
        int now = 0;
        for(int i=0;i<N;i++) if(S&(1<<i)) now += V[i]-C[i];
        ans = max(ans,now);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
int main() {
int A;
  int B;
  int C;
  int D;
  cin >>A>>B>>C>>D;
  
  int x=min(A,B);
  int y=min(C,D);
  int z=x+y;
  cout << z<< endl;
}
 

Measured memory_bytes: 256
import java.io.*;
import java.util.*;
public class Main {
	public static void main(String[] args) throws Exception {
		MScanner sc=new MScanner(System.in);
		PrintWriter pw=new PrintWriter(System.out);
		int max=(int)1e6+1;
		boolean[]p=new boolean[max];
		Arrays.fill(p, true);
		int x=sc.nextInt();
		for(int i=2;i<max;i++) {
			if(p[i]) {
				if(i>=x) {
					pw.println(i);
					pw.flush();
					return;
				}
				for(int j=i;j<max;j+=i) {
					p[j]=false;
				}
			}
		}
		pw.flush();
	}
	static class MScanner {
		StringTokenizer st;
		BufferedReader br;
		public MScanner(InputStream system) {
			br = new BufferedReader(new InputStreamReader(system));
		}
 
		public MScanner(String file) throws Exception {
			br = new BufferedReader(new FileReader(file));
		}
 
		public String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}
		public int[] takearr(int n) throws IOException {
	        int[]in=new int[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public long[] takearrl(int n) throws IOException {
	        long[]in=new long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public Integer[] takearrobj(int n) throws IOException {
	        Integer[]in=new Integer[n];for(int i=0;i<n;i++)in[i]=nextInt();
	        return in;
		}
		public Long[] takearrlobj(int n) throws IOException {
	        Long[]in=new Long[n];for(int i=0;i<n;i++)in[i]=nextLong();
	        return in;
		}
		public String nextLine() throws IOException {
			return br.readLine();
		}
 
		public int nextInt() throws IOException {
			return Integer.parseInt(next());
		}
 
		public double nextDouble() throws IOException {
			return Double.parseDouble(next());
		}
 
		public char nextChar() throws IOException {
			return next().charAt(0);
		}
 
		public Long nextLong() throws IOException {
			return Long.parseLong(next());
		}
 
		public boolean ready() throws IOException {
			return br.ready();
		}
 
		public void waitForInput() throws InterruptedException {
			Thread.sleep(3000);
		}
	}
}


Measured memory_bytes: 22996
#include <stdio.h>
#include <string.h>

char s[550000];
char str[1100000];

int main(void)
{
	int i, n, m, len, num;
	
	while (scanf("%d", &n), n){
		scanf("%d", &m);
		scanf("%s", str);
		
		s[0] = 'I';
		for (i = 1; i < 550000; i++){
			s[i] = '\0';
		}
		
		for (i = 0; i < n; i++){
			strcat(s, "OI");
		}
		
		len = strlen(str);
		num = 0;
		
		for (i = 0; i < len - 2 * n; i++){
			if (str[i] == 'I'){
				if (strncmp(&str[i], s, 1 + n * 2) == 0){
					num++;
				}
			}
		}
		
		printf("%d\n", num);
	}
	
	return (0);
}

Measured memory_bytes: 2140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // ABC149D - Prediction and Restrictionx

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();   // じゃんけん回数
        int k = sc.nextInt();   // この回目前と同じ手禁止
        int r = sc.nextInt();   // グーの点数
        int s = sc.nextInt();   // チョキの点数
        int p = sc.nextInt();   // パーの点数
        String t = sc.next();   // CPの手

        char[] ct = t.toCharArray();

        int ten = 0;

        for (int i = 0; i < n; i++) {
            if (i < k) {
                if (ct[i] == 'r') { // パーで勝つ
                    ten += p;
                } else if (ct[i] == 's') {  // グーで勝つ
                    ten += r;
                } else {    // チョキで勝つ
                    ten += s;
                }
            } else {
                if (ct[i - k] != ct[i]) {
                    if (ct[i] == 'r') { // パーで勝つ
                        ten += p;
                    } else if (ct[i] == 's') {  // グーで勝つ
                        ten += r;
                    } else {    // チョキで勝つ
                        ten += s;
                    }
                } else {
                    ct[i] = 'z';
                }
            }
        }

        System.out.println(ten);
    }
}


Measured memory_bytes: 27192
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a, b;
  cin >> a >> b;
  if(a == 'H')
    cout << b << endl;
  else{
    if(b == 'H')
      cout << "D" << endl;
    else
      cout << "H" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,ll>
const ll MOD=998244353;
const int INF=1e9;
const double PI=acos(-1);


int main() {
    ios_base::sync_with_stdio(false);

    int h,w,n;
    cin >> h >> w >> n;
    if (h<w) swap(h,w);
    int ans=n/h;
    if (n%h>0) ++ans;
    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3652
#include<stdio.h>
 int main()
 { 
    int a[100010],i,n,vis[100100]={0};
    int ind=0,c=0;
    scanf("%d",&n); 
    for(i=0;i<n;i++) 
        { 
        scanf("%d",&a[i]); 
        } 
    for(i=0;i<n-1;i++) 
        { 
        if(a[i]>=a[i+1]) 
        c++; 
        else 
            { 
            vis[ind]=c;
            //printf("%d#\n",c);
          //  printf("*%d\n",vis[ind]);
            ind++;
            c=0;
            
            }
         }
     vis[ind]=c;
    int min=0;
    for(i=0;i<=ind;i++) 
        { 
        //printf("%d\n",vis[i]);
        if(vis[i]>min)
         min=vis[i];
        //printf("%d\n",min);
        } 
    printf("%d\n",min);
     return 0; 
    }

Measured memory_bytes: 896
#include<iostream>
#include<cmath>

using namespace std;

static const int MAX_N = 1000000;
static const int MAX_M = 10000;

int N;
int M;
int A[MAX_M];

int main() {
    int sum;

    cin >> N >> M;
    for (int i = 0; i < M; i++) cin >> A[i];

    sum = 0;
    for (int i = 0; i < M; i++) {
        sum += A[i];
    }

    int ans = N - sum;

    if (ans >= 0) cout << ans << endl;
    else cout << -1 << endl;

    return 0;
}



Measured memory_bytes: 3624
/*  -*- coding: utf-8 -*-
 *
 * c.cc: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 100;

typedef long long ll;

const int INF = 1 << 30;
const ll LINF = 1LL << 60;

/* typedef */

typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

/* subroutines */

/* main */

int main() {
  int n, m, d;
  scanf("%d%d%d", &n, &m, &d);

  double p;
  if (d == 0) p = 1.0 / n;
  else p = 2.0 * (n - d) / n / n;

  printf("%.10lf\n", p * (m - 1));
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a,b,x;
    char op;

    for(;;){
        scanf("%d %c %d",&a,&op,&b);

        if(op == '+')x = a + b;
        else if(op == '-')x = a - b;
        else if(op == '*')x = a * b;
        else if(op == '/')x = a / b;
        else break;
        printf("%d\n",x);
    }

    return 0;
}



Measured memory_bytes: 2056
#include<stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r){
	int x, i, j, t;
	x = A[r];
	i = p - 1;
	for(j = p; j < r; j++){
		if(A[j] <= x){
			i++;
			t = A[i]; A[i] = A[j]; A[j] = t;
		}
	}
	t = A[i+1]; A[i+1] = A[r]; A[r] = t;
	return i + 1;
}

int main(){
	int i,q;
	
	scanf("%d", &n);
	for(i = 0; i < n; i++) scanf("%d", &A[i]);
	
	q = partition(0, n - 1);
	
	for(i = 0; i < n; i++){
		if(i) printf(" ");
		if(i == q) printf("[");
		printf("%d",A[i]);
		if(i == q) printf("]");
	}
	printf("\n");
	
	return 0;
}

Measured memory_bytes: 2100
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<list>
#include<iomanip>
#include<cmath>
#include<cstring>
#include<functional>
#include<cstdio>
#include<cstdlib>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
//#define MOD 998244353
#define LINF (long long)4e18
#define jck 3.141592

const double EPS = 1e-10;

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;

ll dp[3030][3030];
int N;
vector<int> a;

ll solve(int l, int r){
    if(r-l == 1) return dp[l][r] = a[l];
    if(dp[l][r] != -1) return dp[l][r];

    ll res = max(a[l]-solve(l+1,r),a[r-1]-solve(l,r-1));
    return dp[l][r] = res;
}

int main(){
    cin >> N;
    a.resize(N);
    rep(i,N) cin >> a[i];
    rep(i,3030)rep(j,3030) dp[i][j] = -1;
    cout << solve(0,N) << endl;
    
}



Measured memory_bytes: 72064
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	string s;
	long long  k;
	cin >> s >> k;
	for (int i = 0; i < min((long long)s.size(), k); i++){
		if (s[i] >='2'){
			cout << s[i] << endl;
			return 0;
		}
	}
	cout << '1' << endl;
	return 0;
}

Measured memory_bytes: 256
revPolRun :: [String] -> Double
revPolRun = iter [] where
    iter (n:_) [] = n
    iter (n:m:s) ("+":e) = iter ((m+n):s) e
    iter (n:m:s) ("-":e) = iter ((m-n):s) e
    iter (n:m:s) ("*":e) = iter ((m*n):s) e
    iter (n:m:s) ("/":e) = iter ((m/n):s) e
    iter stack (n:e) = iter (read n : stack) e

main = getContents >>= mapM_ (print . revPolRun . words) . lines

Measured memory_bytes: 4348
#include <iostream>
#include <algorithm>
#include <complex>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <cstdlib>

#define rep(i, b) for(int i = 0; i < b; i++)
#define repi(i, a, b) for(int i = a; i < b; i++)
#define all(c) c.begin(),c.end()
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define MAX_V 1001
#define MAX_E 401
#define INF INT_MAX
#define MOD 1000000007
#define EPS 1e-7
typedef long long ll;
inline int toInt(std::string s) { int v; std::istringstream sin(s); sin >> v; return v; }
template<class T> inline std::string toString(T x) { std::ostringstream sout; sout << x; return sout.str(); }
using namespace std;

typedef double D;      // 座標値の型。doubleかlong doubleを想定
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
#define X real()
#define Y imag()
typedef pair<int, int> pii;

int h, w;
int mov[2] = { 1, -1};

int bfs_dis(vector<string> s)
{
	queue<pii> que;
	que.push(make_pair(0, 0));
	s[0][0] = 'o';
	vector<vector<int>> d(h, vector<int>(w, 0));
	rep(i, h)
	{
		rep(j, w)
		{
			d[i][j] = -1;
		}
	}
	d[0][0] = 1;
	while (!que.empty())
	{
		pii point = que.front();
		que.pop();
		rep(i, 2)
		{
			int y = point.first + mov[i];
			if (0 <= y && y < h)
			{
				if (s[y][point.second] == '.')
				{
					que.push(make_pair(y, point.second));
					s[y][point.second] = 'o';
					d[y][point.second] = d[point.first][point.second] + 1;
				}
			}
		}
		rep(i, 2)
		{
			int x = point.second + mov[i];
			if (0 <= x && x < w)
			{
				if (s[point.first][x] == '.')
				{
					que.push(make_pair(point.first, x));
					s[point.first][x] = 'o';
					d[point.first][x] = d[point.first][point.second] + 1;
				}
			}
		}
	}
	return d[h-1][w-1];
}

int main()
{
	cin >> h >> w;
	vector<string> s(h);
	rep(i, h)
	{
		cin >> s[i];
	}

	int space = 0;
	rep(i, h)
	{
		rep(j, w)
		{
			if (s[i][j] == '.')
				space++;
		}
	}

	int dis = bfs_dis(s);

	if (dis == -1)
	{
		cout << -1 << endl;
	}
	else {
		cout << space - dis << endl;
	}
	return 0;
}

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

const int INF = 1e9;

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    if ((A == B && B == C) || (A != C && A != B && B != C)) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    return 0;
}





Measured memory_bytes: 256
n = int(input())
x = list(map(int, input().split()))

mi = -1
for i in range(min(x), max(x)+1):
	hp = 0
	for j in range(n):
		hp += (x[j]-i)**2
	if mi == -1:
		mi = hp
	else:
		mi = min(mi, hp)
print(mi)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	ll R,G,B,N;
	cin>>R>>G>>B>>N;
	ll ans=0;
	FDS(r,3001){
		FDS(g,3001){
			ll sub=r*R+g*G;
			if (sub==N){
			    ans++;
			    break;
			}
			if((N-sub)%B==0&&(N-sub>0))ans++;
		}
	}
	cout<<ans<<endl;
}

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

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

  int N;
  cin >> N;
  int A, B;
  cin >> A >> B;

  VI cnt(3);
  REP(i,N){
    int x;
    cin >> x;
    if(x <= A) ++cnt[0];
    else if(x <= B) ++cnt[1];
    else ++cnt[2];
  }

  cout << *min_element(ALL(cnt)) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <atcoder/all>
using namespace std;
// using namespace atcoder;
typedef long long ll;
/* clang-format off */
#define MOD 2019
#define INF 1000000000000000000ll
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
//#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
/* clang-format on */

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  ll n = s.size();
  vector<ll> t(n + 1), a(n);
  REP(i, n) a[i] = s[i] - '0';
  t[n] = 0;
  vector<ll> pow10_mod(n);
  pow10_mod[0] = 1;
  for (ll i = 1; i < n; i++) pow10_mod[i] = pow10_mod[i - 1] * 10 % MOD;

  for (ll i = n - 1; i >= 0; i--) {
    t[i] = (t[i + 1] + a[i] * pow10_mod[10, n - i - 1]) % MOD;
  }
  vector<ll> cnt(2019, 0);
  REP(i, n + 1) cnt[t[i]]++;
  ll ans = 0;
  REP(i, 2019) ans += cnt[i] * (cnt[i] - 1) / 2;
  DEBUGS(t);
  DEBUGS(a);
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 8304
#include <stdio.h>
#define min(x, y) ((x)>(y) ? (y) : (x))
#define abs(x) ((x)<0 ? -(x) : (x))

int main(){
  int n;  scanf("%d", &n);
  long a[200005] = {0};
  for(int i=1; i<=n; i++){
    long t;  scanf("%ld", &t);
    a[i] = a[i-1] + t;
  }
  long ans = 20000000000000000;
  for(int i=1; i<n; i++){
    long left = a[i];
    long right = a[n] - a[i];
    ans = min(ans, abs(left-right));
  }

  printf("%ld\n", ans);
  return 0;
}


Measured memory_bytes: 1664
#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
#define mr make_pair
#define N 100010
using namespace std;
vector<int> a[N];
int d[N],n,x,y,su,dp[N][2],s[N],vi[N],ans,g[N];
void jb(int x,int y){a[x].pb(y);d[x]++;}
void dfs(int x,int fa){
	s[x]=vi[x];
	for (auto y:a[x])
		if (y!=fa){dfs(y,x);s[x]+=s[y];}
	int so=0;
	for (auto y:a[x])if (s[y]>0&&y!=fa)so++;
	if (s[x]!=su)so++;
	if (so>1||vi[x]){
		ans+=so+((so+vi[x])%2);
		if ((so+vi[x])%2)g[x]=2;else g[x]=0;
	}
}
void dfs1(int x,int fa){
	dp[x][0]=dp[x][1]=max(0,g[x]);
	for (auto y:a[x]){
		if (y!=fa){
			dfs1(y,x);
			dp[x][0]=max(dp[x][0],max(dp[y][0],dp[y][1]+dp[x][1]));
			dp[x][1]=max(dp[x][1],dp[y][1]+g[x]);
		}
	}
}
int main(){
	cin>>n;
	for (int i=1;i<n;i++){cin>>x>>y;jb(x,y);jb(y,x);}
	for (int i=1;i<=n;i++){char ch=getchar();while (ch!='B'&&ch!='W') ch=getchar();vi[i]=(ch=='W');su+=vi[i];}
	dfs(1,0);dfs1(1,0);
	cout<<abs(ans-dp[1][0])<<endl;
	return 0;
}

Measured memory_bytes: 15360
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a > b){
    printf("a > b\n");
  }else 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++)
//#define int long long
using namespace std;

vector<vector<int> > ms;

void pf(int n,int max,vector<int> &a) {
    if (n == 0) {
        ms.push_back(a);
        return;
    }
    for (int i=min(n,max); i>0; --i) {
        a.push_back(i);
        pf(n-i, i, a);
        a.erase(a.end()-1);
    }
}

void print_vi(vector<int> a) {
    rep(i,a.size()) {
        cout << a[i];
        if (i != a.size()-1) cout << " ";
    }
    cout << endl;
}

void part_int_sub(int n, int k, vector<int> &a) {
    if (n == 0) {
        print_vi(a);
    } else if (n == 1) {
        vector<int> b = a;
        b.push_back(1);
        print_vi(b);
    } else if (k == 1) {
        vector<int> b = a;
        rep(i,n) b.push_back(1);
        print_vi(b);
    } else {
        if (n >= k) {
            vector<int> b = a;
            b.push_back(k);
            part_int_sub(n-k, k, b);
        }
        part_int_sub(n, k-1, a);
    }
}

int n;

signed main() {
    while (true) {
        cin >> n;
        if (n == 0) break;

        /*
        ms.clear();

        vector<int> temp;
        pf(n, n, temp);

        rep(i,ms.size()) {
            rep(j,ms[i].size()) {
                cout << ms[i][j];
                if (j != ms[i].size() - 1) cout << " ";
            }
            cout << endl;
        }
        */

        vector<int> a;
        part_int_sub(n, n, a);
    }
}

Measured memory_bytes: 1228
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[3][100010];
    rep(i, 3) rep(j, N) cin >> A[i][j];
    rep(i, 3) sort(A[i], A[i] + N);
    int ans = 0;
    rep(i, N) {
        auto itr1 = lower_bound(A[0], A[0] + N, A[1][i]);
        auto itr2 = lower_bound(A[2], A[2] + N, A[1][i] + 1);
        int idx1 = distance(A[0], itr1);
        int idx2 = distance(A[2], itr2);
        ans += idx1 * (N - idx2);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 5956
def kei(a,i,x,y):
	if a[i]=="+":
		st=x+y
		#print("+")
	elif a[i]=="-":
		st=y-x
		#print("-")
	elif a[i]=="*":
		st=x*y
		#print("*") 
	return st


a=[]
stac=[]
a=list(input().split())
for i in range(len(a)):
	if a[i].isdigit():
		stac.append(int(a[i]))
		#print(stac)
	else:
		x=stac.pop()
		y=stac.pop()
		stac.append(kei(a,i,x,y))
		
print(stac[0])
		



Measured memory_bytes: 5604
#include <iostream>
#include <vector>
using namespace std;
int main() {
    vector<char> v;
    char c;
    while (cin >> c) {
        v.push_back(c);
    }
    for (auto it = v.rbegin(); it < v.rend(); it++) {
        cout << *it;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define P pair<int, int>
#define F first
#define S second
#define mod 1000000007
#define INF 90000000000000000
signed main(){
    int n;string s;cin>>n>>s;
    if(n%2==1){
        cout<<"No"<<endl;
        return 0;
    }
    bool ans=true;
    rep(i,n/2){
        ans&=(s[i]==s[n/2+i]);
    }
    if(ans)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}
        

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

using namespace std;

int N, K, sh;
char sir[1000009];

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d %d\n", &N, &K);
scanf ("%s", sir + 1), sh = 0;
for (int i=1; i<=N; i++)
    sir[i] -= 'A';
while (K && sh < N)
{
    K --;
    if ((sir[1 + sh] ^ (sh & 1)) == 0) sir[1 + sh] ^= 1;
    else sh ++;
}
if (K == 0)
{
    for (int i=1; i<=N - sh; i++)
        if (sir[i + sh] ^ (sh & 1)) printf ("B");
        else printf ("A");
    for (int i=N - sh + 1; i<=N; i++)
        if ((N - i) & 1) printf ("B");
        else printf ("A");
    printf ("\n");
    return 0;
}
if (N & 1)
{
    if (K & 1) printf ("B");
    else printf ("A");
    for (int i=2; i<=N; i++)
        if ((N - i) & 1) printf ("B");
        else printf ("A");
    printf ("\n");
    return 0;
}
for (int i=1; i<=N; i++)
    if (i & 1) printf ("B");
    else printf ("A");
printf ("\n");
return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n,h,w;  cin>>n>>h>>w;
    int ans=0;
    while(n--)
    {
        int a,b;  scanf("%d%d",&a,&b);
        if(a>=h&&b>=w)
            ans++;
    }
    cout<<ans;
}


Measured memory_bytes: 256