akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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





int main(int argc, const char * argv[]) {
    
    

    cin.tie(0);
    ios::sync_with_stdio(false);
   
    
    int H,W; cin >> H >> W;
    vector<string> field(H);
    rep(i,H) cin >> field[i];
     
    int U[H][W];
    int D[H][W];
    int R[H][W];
    int L[H][W];
    
    int seenL[H][W];
    int seenU[H][W];
    int seenR[H][W];
    int seenD[H][W];
    memset(seenL, false, sizeof(seenL));
    memset(seenU, false, sizeof(seenU));
    memset(seenR, false, sizeof(seenR));
    memset(seenD, false, sizeof(seenD));
    
    
    int Ans = 0;
    int ans = 0;
    
    
    
    
    rep(i,H){
        rep(j,W){
            
            
            
            
            if(field[i][j]=='#') {
                L[i][j] = 0;
                seenL[i][j] = true;
            }
            if(field[i][j]=='#') {
                U[i][j] = 0;
                seenU[i][j] = true;
            }
            if(field[i][W-1-j]=='#') {
                R[i][W-1-j] = 0;
                seenR[i][W-1-j] = true;
            }
            if(field[H-1-i][j]=='#') {
                D[H-1-i][j] = 0;
                seenD[H-1-i][j] = true;
            }
            
            
            
            
            
            if(j==0 && seenL[i][j]==false) {
                L[i][j] = 1;
                seenL[i][j] = true;
            }
            if(i==0 && seenU[i][j]==false) {
                U[i][j] = 1;
                seenU[i][j] = true;
            }
            if(j==0 && seenR[i][W-1-j]==false) {
                R[i][W-1-j] = 1;
                seenR[i][W-1-j] = true;
            }
            if(i==0 && seenD[H-1-i][j]==false) {
                D[H-1-i][j] = 1;
                seenD[H-1-i][j] = true;
            }
            
            
            
            
            if(seenL[i][j]==false) L[i][j] = L[i][j-1] + 1;
            if(seenU[i][j]==false) U[i][j] = U[i-1][j] + 1;
            if(seenR[i][W-1-j]==false) R[i][W-1-j] = R[i][W-j] + 1;
            if(seenD[H-1-i][j]==false) D[H-1-i][j] = D[H-i][j] + 1;
            
            
            
            
        
            
        }
        
    }
    
    rep(i,H){
        rep(j,W){
            ans = L[i][j]+U[i][j]+R[i][j]+D[i][j]-3;
            Ans = max(ans,Ans);
        }
    }
    
    cout << Ans << endl;
    
    
    
    
    
    
}


Measured memory_bytes: 129536
N,K=map(int,input().split())
a=[]
for i in range(N):
    c,d=map(int,input().split())
    a.append((c,d))
a.sort()
count = 0
for x,y in a:
    if y>=K:
        print(x)
        exit()
    else:
        K -= y

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

int main() {
    int ans = 0;
    int n, k;
    int d[100];
    int a[100][100];
    bool sunuke[100] = {false};
    cin >> n >> k;
    for(int i=0; i<k; i++)
    {
        cin >> d[i];
        for(int j=0; j<d[i]; j++)
        {
            cin >> a[i][j];
            sunuke[a[i][j] - 1] = true;
        }
    }

    for(int i=0; i<n; i++)
    {
        if(sunuke[i] == false) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3680
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main(void) {
	int N;
	scanf("%d", &N);
	int p[10];
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
	}
	sort(p, p + N);
	int ans = 0;
	for (int i = 0; i < N - 1; i++) {
		ans += p[i];
	}
	ans += p[N - 1] / 2;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3808
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String s = in.next();
		String t = in.next();
		for(int i=0;i<s.length();i++) {
			String rotated = rotate(s,i);
			if(rotated.equals(t)) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");

	}
	
	public static String rotate(String s,int i) {
		StringBuilder sb = new StringBuilder();
		sb.append(s.substring(i, s.length()));
		sb.append(s.substring(0,i));
		return sb.toString();
	}

}


Measured memory_bytes: 21844
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

template<class T>
vector<T> make_vec(size_t s, T val) { return vector<T>(s, val); }
template<class... Size>
auto make_vec(size_t s, Size... tail) {
	return vector<decltype(make_vec(tail...))>(s, make_vec(tail...));
}

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

int main() {

	int N;
	cin >> N;

	vector<pair<lint, int>> A(N);
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		A[i] = { a, i };
	}
	sort(A.begin(), A.end(), greater<>());

	auto dp = make_vec(N + 1, N + 1, 0LL);
	lint ans = 0;
	for (int l = 0; l < N; l++) {
		for (int r = 0; l + r < N; r++) {
			const auto& [a, i] = A[l + r];

			chmax(dp[l][r + 1], dp[l][r] + a * abs(N - 1 - r - i));
			chmax(dp[l + 1][r], dp[l][r] + a * abs(l - i));
			if (l + r == N - 1) chmax(ans, max(dp[l + 1][r], dp[l][r + 1]));
		}
	}

	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 34608
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#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 Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};


int main(){
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cout << fixed << setprecision(10);
    int n,m;
    cin>>n>>m;
    vector<vector<int>> a(n,vector<int>(0));
    int x,y;
    rep(i,m){
        cin>>x>>y;
        x --,y --;
        a[x].emplace_back(y);
        a[y].emplace_back(x);
    }
    queue<int> que;
    vector<int> sign(n,-1);
    que.emplace(0);
    sign[0]=0;
    while(!que.empty()){
        x=que.front();
        que.pop();
        for(auto b:a[x]){
            if(sign[b]>-1) continue;
            sign[b]=x;
            que.emplace(b);
        }
    }
    Yes;
    for(int i=1;i<n;i++){
        cout<<sign[i]+1<<endl;
    }
}/*
./problem.exe
*/

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
bool ok = true;
void dfs(vvi& g, vi &visited,int i) {
	if (!ok)return;
	if (visited[i])ok = false;
	visited[i] = 1;
	REP(j, g[i].size())dfs(g, visited, g[i][j]);
	visited[i] = 0;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	while (cin >> n, n) {
		vector<string> v(n);
		REP(i, n)cin >> v[i];
		vvi g(26);
		ok = true;
		REP(i, n - 1) {
			bool done = false;
			REP(j, min(v[i].size(), v[i + 1].size())) {

				if (v[i][j] != v[i + 1][j]) {
					done = true;
					g[v[i][j] - 'a'].push_back(v[i + 1][j] - 'a');
					break;
				}
			}
			if (!done) {
				if (v[i].size() > v[i + 1].size())ok = false;
			}
		}
		REP(i, 26) {
			sort(ALL(g[i]));
			UNIQUE(g[i]);
		}
		vi visited(26, 0);
		REP(i, 26) {
			REP(j, 26)visited[j] = 0;
			dfs(g, visited, i);
		}
		if (ok)cout << "yes" << endl;
		else cout << "no" << endl;
	}
}


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<int, int> Pi;
typedef vector<ll> Vec;
typedef vector<int> Vi;
typedef vector<string> Vs;
typedef vector<P> VP;
typedef vector<vector<ll>> VV;
typedef vector<vector<int>> VVi;

#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
const ll INF=1e18+18;
const ll MAX=100005;
const ll MOD=1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;
#define ALL(v) v.begin(), v.end()
#define rALL(v) v.rbegin(), v.rend()
#define pb(x) push_back(x)
#define mp(a, b) make_pair(a,b)
#define Each(a,b) for(auto &a :b)
#define REPM(i, mp) for (auto i = mp.begin(); i != mp.end(); ++i)
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbgmap(mp) cerr << #mp << ":"<<endl; for (auto i = mp.begin(); i != mp.end(); ++i) { cerr << i->first <<":"<<i->second << endl;}
#define dbgarr(n,m,arr) rep(i,n){rep(j,m){cerr<<arr[i][j]<<" ";}cerr<<endl;}
#define dbgdp(n,arr) rep(i,n){cerr<<arr[i]<<" ";}cerr<<endl;
#define dbgmint(n,arr) rep(i,n){cerr<<arr[i].x<<" ";}cerr<<endl;
#define out(a) cout<<a<<endl
#define out2(a,b) cout<<a<<" "<<b<<endl
#define vout(v) rep(i,v.size()){cout<<v[i]<<" ";}cout<<endl
#define Uniq(v) v.erase(unique(v.begin(), v.end()), v.end())
#define fi first
#define se second

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

template<typename T1, typename T2>
ostream &operator<<(ostream &s, const pair<T1, T2> &p) { return s<<"("<<p.first<<", "<<p.second<<")"; }

template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,v.size())i>>v[j];return i;}

// vector
template<typename T>
ostream &operator<<(ostream &s, const vector<T> &v) {
    int len=v.size();
    for(int i=0; i<len; ++i) {
        s<<v[i];
        if(i<len-1) s<<"	";
    }
    return s;
}

// 2 dimentional vector
template<typename T>
ostream &operator<<(ostream &s, const vector<vector<T> > &vv) {
    int len=vv.size();
    for(int i=0; i<len; ++i) {
        s<<vv[i]<<endl;
    }
    return s;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<std::setprecision(10);

    ll n;
    cin>>n;
    Vec x(n);
    cin>>x;
    ll ans=INF;
    rep(i,101){
        //iで開く
        ll sum = 0;
        rep(j,n){
            sum += (x[j]-i)*(x[j]-i);
        }
        chmin(ans,sum);
    }
    cout<<ans<<endl;
    return  0;
}


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

int main() {
    int r;

    // 変数aで入力を受け取る
    cin >> r;

    if (r<1200){
        cout << "ABC";
    }
    else if (r<2800){
        cout << "ARC";
    }
    else{
        cout << "AGC";
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
using namespace std;
double dp[3100][3100]{};
int main()
{

    int n; cin>>n;
    double arr[n]{};
    for(int i = 0 ; i<n ; i++)
    {cin>>arr[i];}



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

            if(j)dp[i][j] = dp[i-1][j-1]*arr[i-1];
            dp[i][j] += dp[i-1][j] * (1.0-arr[i-1]);
        }
    }



    double ans = 0;
    for(int i = 0 ; i<=n ; i++)
    {
        if(i>n-i)ans+=dp[n][i];
    }

    cout<<fixed<<setprecision(12);
    cout<<ans<<endl;


    return 0;
}


Measured memory_bytes: 72320
X, Y = map(int, input().split())

max = X * 4

if Y > max:
    print('No')
elif Y % 2 != 0:
    print('No')
else:
    for i in range(2*X, 4*X+1, 2):
        if i == Y:
            print('Yes')
            break
    else:
        print('No')


Measured memory_bytes: 9172
{- SPDX-License-Identifier: X11
 -
 - Copyright 2020 Elias Yuan <a@jthv.ai>, MIT/X11 License
 -   https://jthv.ai/LICENSE/X11.txt
 -
 - ANU-CPC Observation Workshop - B: Sorted Arrays
 -   2020-05-06
 -}

module Main where

import System.IO (print)

solve :: String -> Int
solve = sol . unDup . strToInts
  where
    strToInts :: String -> [Int]
    strToInts = map (read :: String -> Int) . words

    unDup :: [Int] -> [Int]
    unDup (x:y:ys)
      | x == y    = unDup (y:ys)
      | otherwise = x:unDup (y:ys)
    unDup x = x

    sol :: [Int] -> Int
    sol []  = 0
    sol [_] = 1
    sol (x:y:ys)
      | x < y     = s 1 True (y:ys)
      | x > y     = s 1 False (y:ys)
      | otherwise = error "sol: That shouldn't have been possible"
      where
        s :: Int -> Bool -> [Int] -> Int
        s acc fl (a:b:c:cs)
          | fl && a < b || not fl && a > b = s acc fl (b:c:cs)

          | fl     && a > b = if b < c
                                then s (acc + 1) fl (b:c:cs)
                                else s (acc + 1) (not fl) (b:c:cs)
          | not fl && a < b = if b > c
                                then s (acc + 1) fl (b:c:cs)
                                else s (acc + 1) (not fl) (b:c:cs)

          | otherwise = error "s: That shouldn't have been possible"

        s acc fl [a,b]
          | fl && a < b || not fl && a > b = acc
          | fl && a > b || not fl && a < b = acc + 1
          | otherwise                      = error "s: That shouldn't have been possible"

        s acc _ _ = acc


main :: IO ()
main = getLine >> getLine >>= \x -> print $ solve x


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

int main() {

    int n;

    cin >> n;

    long long int  a[n];

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

    long long int ans = 0;

    long long int sums = 0;

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

        if(i%2 == 0){

            sums += a[i];
            if(sums < 1){
                ans += 1 - sums;
                sums = 1;
            }

        }
        else if(i%2 == 1){

            sums += a[i];
            if(sums > -1){
                ans += sums + 1;
                sums = -1;
            }

        }

    }

    long long int tmp_ans = 0;
    sums = 0;

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

        if(i%2 == 0){

            sums += a[i];
            if(sums > -1){
                tmp_ans += sums + 1;
                sums = -1;
            }

        }
        else if(i%2 == 1){

            sums += a[i];
            if(sums < 1){
                tmp_ans += 1 - sums;
                sums = 1;
            }

        }

    }

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

    return 0;
}

Measured memory_bytes: 1024
nn,ww=map(int,input().split())
value=[0]*nn
weight=[0]*nn
for i in range(nn):
    value[i],weight[i]=map(int,input().split())    
    
dp=[[0]*(ww+1) for i in range(nn+1)]
for w in range(ww+1):
    dp[0][w]=0
    
for i in range(nn):
    for w in range(ww+1):
        if weight[i]<=w:
            dp[i+1][w]=max(dp[i][w-weight[i]]+value[i],dp[i][w])
        else:
            dp[i+1][w]=dp[i][w]

print(dp[nn][ww])


Measured memory_bytes: 41888
#include <stdio.h>

int main(void)
{

	int i;
	int join_time[9], leave_time[9], ans[9];

	for(i = 0; i < 3; i++) {
		scanf("%d %d %d", &join_time[i], &join_time[i + 3], &join_time[i + 6]);
		scanf("%d %d %d", &leave_time[i], &leave_time[i + 3], &leave_time[i + 6]);
	}

	for(i = 0; i < 3; i++) {
		if(join_time[i + 6] > leave_time[i + 6]) {
			ans[i + 6] = leave_time[i + 6] + (60 - join_time[i + 6]);
			if(leave_time[i + 3] - 1 < 0) {
				leave_time[i + 3] = 59;
				leave_time[i]--;
			}
			else {
				leave_time[i + 3]--;
			}
		}
		else {
			ans[i + 6] = leave_time[i + 6] - join_time[i + 6];
		}
		if(join_time[i + 3] > leave_time[i + 3]) {
			ans[i + 3] = leave_time[i + 3] + (60 - join_time[i + 3]);
			leave_time[i]--;
		}
		else {
			ans[i + 3] = leave_time[i + 3] - join_time[i + 3];
		}
		ans[i] = leave_time[i] - join_time[i];
	}

	for(i = 0; i < 3; i++) {
		printf("%d %d %d\n", ans[i], ans[i + 3], ans[i + 6]);
	}

	return 0;

}

Measured memory_bytes: 600
#include<stdio.h>
int main()
{
	int a,b,c,d;
	scanf("%d%d%d",&a,&b,&c);
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	if(b>c){
		d=b;
		b=c;
		c=d;
	}
	if(a>b){
		d=a;
		a=b;
		b=d;
	}
	printf("%d %d %d\n",a,b,c);
	
	return 0;
}

Measured memory_bytes: 596
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

int readint() {
    return readln.chomp.to!int;
}

int[] readints() {
    return readln.split.map!(to!int).array;
}

void main() {
    int n = readint;
    for (int i = 0; i < n; i++) {
        auto s = readln.chomp;
        auto t = s.replace("Hoshino", "Hoshina");
        writeln(t);
    }
}

Measured memory_bytes: 2352
x,y,a,b,c=map(int,input().split())
re=list(map(int,input().split()))
gr=list(map(int,input().split()))
mu=list(map(int,input().split()))
re.sort(reverse=1)
gr.sort(reverse=1)
mu.sort(reverse=1)
re=re[:x]
gr=gr[:y]
app=mu[:]
app.extend(re)
app.extend(gr)
app.sort(reverse=1)
app=app[:x+y]


print(sum(app))

Measured memory_bytes: 22720
def solve(n, P, Q):
    facts = [1] * n
    for i in range(2, n):
        facts[i] = facts[i - 1] * i

    def count_order(X):
        cands = [True] * n
        num = 0
        for i, x in enumerate(X):
            num += sum(cands[:x - 1]) * facts[n - i - 1]
            cands[x - 1] = False
        return num

    return abs(count_order(P) - count_order(Q))

_n = int(input())
_P = list(map(int, input().split()))
_Q = list(map(int, input().split()))
print(solve(_n, _P, _Q))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K,A=1;
  cin >> N >> K;
  for(int i = 0; i < N; i++){
    if(A < K){
      A = A * 2;
    }
    else{
      A += K;
    }
  }
  cout << A << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main()
{
  int A, B, K;
  cin >> A >> B >> K;

  int k=0;
  for(int i=min(A,B); i>=1; --i)
  {
    if(A%i==0 && B%i==0)
    {
      ++k;
      if(k==K)
      {
        cout << i << endl;
        break;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  int n;
  ll a, b;
  scanf("%d %lld %lld", &n, &a, &b);
  ll ab = a - b;
  vll hp(n);
  rep (i, n) {
    scanf("%lld", &hp[i]);
  }
  int l = 0;
  int r = 1e9+10;
  while (r - l > 1) {
    int mid = (l + r) / 2;
    ll cnt = 0;
    rep (i, n) {
      ll remain = hp[i] - b * mid;
      if (remain > 0) {
        cnt += (remain + ab - 1) / ab;
      }
    }
    if (cnt <= (ll)mid) {
      r = mid;
    } else {
      l = mid;
    }
  }
  printf("%d\n", r);

  return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    int ans = 0;
    rep (i, n) {
        int a, b;
        cin >> a >> b;
        if (a >= h && b >= w) ans++;
    }
    cout << ans << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	long long int n; cin >> n;
	long long int ans = 0LL;
	for(long long int i=1;i*i<=n;i++){
		long long int c = n/i;
		long long int m = i-1;
		long long int mm = c-1;
		//iがnの約数のとき
		if(n%i==0){
			//m = i-1のため
			if(i!=1){
				if(n%m==n/m){
					ans += m;
					//cout << m << endl;
				}
			}
			//mm = c-1のため
			if(c!=1){
				if(n%mm==n/mm){
					ans += mm;
					//cout << mm << endl;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define INF 1e9
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll x=0,y=0,k,n,m,h,w,sum=0,ans=0,Max=1,Min=1e9+1;
  string s,t,u;
  bool ok = true;
  cin >> n;
  double z = n%2;
  if(z >0)
    cout << n/2 +1 << endl;
  else 
    cout << n/2 << endl;
  return 0;
}

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

ll MOD = 1000000007;
vector<vector<int>> g;
vector<vector<ll>> dp;

void dfs(int pre, int crt)
{
  dp[crt].resize(2);
  dp[crt][0] = dp[crt][1] = 1;
  for (int nxt : g[crt])
  {
    if (nxt == pre)
      continue;
    dfs(crt, nxt);
    dp[crt][0] = dp[crt][0] * (dp[nxt][0] + dp[nxt][1]) % MOD;
    dp[crt][1] = dp[crt][1] * dp[nxt][0] % MOD;
  }
}

int main()
{
  int n;
  cin >> n;
  g.resize(n);
  rep(i, n - 1)
  {
    int x, y;
    cin >> x >> y;
    x--;
    y--;
    g[x].push_back(y);
    g[y].push_back(x);
  }
  dp.resize(n);
  dfs(-1, 0);
  cout << (dp[0][0] + dp[0][1]) % MOD << endl;
  return 0;
}

Measured memory_bytes: 18176
import java.util.Scanner;

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

        long n = scn.nextLong();
        long ans = 1000 * (n / 500);
        n %= 500;
        ans += 5 * (n / 5);
        System.out.println(ans);

    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <bits/stdc++.h>
#include <utility>
#include <iomanip>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;

#define ld long double
#define ll long long

map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int N,K;
  cin >> N >> K;
  bool used[101000]={0};
  vector<pair<int,int>> v;
  ll ans=0;
  int t,d;
  for(int i=0;i<N;i++){
    cin >> t >> d;
    v.push_back(make_pair(d,t));
  }
  sort(v.rbegin(),v.rend());
  priority_queue<int,vector<int>,greater<int>> que;
  ll cnt=0;
  for(int i=0;i<K;i++){
    ans+=v[i].first;
    if(!used[v[i].second]){
      cnt++;
      used[v[i].second]=true;
    }else{
      que.push(v[i].first);
    }
  }
  ll point =ans+cnt*cnt;

  for(int i=K;i<N;i++){
    if(cnt==K)break;
    if(!used[v[i].second]){
      cnt++;
      ans=ans-que.top()+v[i].first;
      que.pop();
      used[v[i].second]=true;
      point=max(point,ans+cnt*cnt);
    }else{
      continue;
    }
  }
  cout << point << endl;
  return 0;
}


Measured memory_bytes: 1528
n, m = map(int, input().split())
a_list = list(map(int, input().split()))

a_list.sort(reverse=True)
if len(a_list) < m:
    print('No')
all_vote = sum(a_list)
a_list = a_list[:m]
if a_list[-1] < (all_vote / (4 * m)):
    print('No')
else:
    print('Yes')

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  if (B % A == 0) {
    cout << A + B << endl;
  } else {
    cout << B - A << endl;
  }

  return 0;
}


Measured memory_bytes: 256
# f=open('in','r')
# input=lambda:f.readline().strip()

n=int(input())
r=list(map(int,input().split()))
mod=1000000007
s=sum(r)%mod
x=0
for u in r:
  x+=u**2
x%=mod
t=500000004
print((s**2-x)*t%mod)

Measured memory_bytes: 31388
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int i = 0;
    ll count = 0;
    int tmp = 0;
    ll ans = 0;
    for(int i = 0; i < n; i++)
    {
        if(s[i] == 'B')
        {
            tmp++;
        }
        else
        {
            count += tmp;
            tmp = 0;
            ans += count;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
ll N;
int main(){
    cin>>N;
    VL X(N+1);
    rep(i,1,N+1){
        cin>>X[i];
    }
    ll sum=1000000000000;
    ll now=0;
    rep(i,1,101){
        now=0;
        rep(j,1,N+1){
            now += pow(fabs(X[j]-i),2);
        }
        sum=min(now,sum);
    }
    cout<<sum;
    return 0;
}


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

using namespace std;

// Repetitions
#define FOR(i,a,n) for(ll i = ((ll) a); i < ((ll) n); ++i)
#define FORR(i, s, g) for(ll i = ((ll)s - 1); i >= ((ll) g); --i)
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) FORR(i, n, 0)

// Container Utils
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define SORTALL(v) sort(ALL(v))
#define SZ(a) int((a).size())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

// For Debug
#define DMP(x)  cerr << #x << " = " << (x) << endl
#define DBG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

// Aliases
#define PB push_back
#define MP make_pair
typedef long long ll;
typedef string str;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;

// Constant variables
const long double PI = (acos(-1));
const long long MOD = 1000000007;


// I/O Asynchronizing
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

long double distance(const int x, const int y) {
    return sqrt(x * x + y * y);
}

int main() {
    int n;
    cin >> n;
    vpii c(n);
    REP(i, n) {
        cin >> c[i].first >> c[i].second;
    }
    vi v(n);
    REP(i, n) {
        v[i] = i;
    }
    long double ans = 0;
    int cnt = 0;
    do {
        REP(i, n - 1) {
            ans += distance(c[v[i]].first - c[v[i + 1]].first, c[v[i]].second - c[v[i + 1]].second);
        }
        cnt++;
    } while(next_permutation(ALL(v)));

    cout << ans / cnt << endl;

    return 0;
}


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

int main(){
  string s,ans="";
  cin >> s;
  for(int i=0;i<s.size();i++){
    if(s[i]=='B'&&ans.size()!=0) ans.pop_back();
    else if(s[i]=='0') ans.push_back('0');
    else if(s[i]=='1') ans.push_back('1');
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

#[allow(unused_imports)]
use std::io::Write;

fn main() {
    input!{
      n1: usize,
      n2: usize,
      n3: usize,
      n4: usize,
    }

    let mut a = [n1, n2, n3, n4];
    a.sort();

    if a[0] == 1 && a[1] == 4 && a[2] == 7 && a[3] == 9 {
        println!("{}", "YES");
    } else {
        println!("{}", "NO");
    }
}


Measured memory_bytes: 4352
n,m=gets.split.map(&:to_i)
h=gets.split.map(&:to_i)
list=Array.new(n){[]}
m.times do
  a,b=gets.split.map(&:to_i)
  a-=1
  b-=1
  list[a] << b
  list[b] << a
end
ans=0
list.each_with_index do |l,i|
  flag=true
  l.each do |t|
    flag=false if h[i]<=h[t]
  end
  ans+=1 if flag
end
p ans


Measured memory_bytes: 26548
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstdlib>
#include<queue>

using namespace std;

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


int main(){
    int n;
    cin >> n;
    int ans = 0;
    rep(i, n){
        ans += i + 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

using namespace std;
using lint = long long;

#pragma GCC optimize ("Ofast", "unroll-loops")
#pragma GCC target ("arch=ivybridge")

constexpr int nmax = 204800, block = 4096, unrl = 16;
int a[nmax], b[nmax];

int main() {

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

	int ans = 0;
	for (int i = 0; i + unrl <= N; i += unrl) {
		for (int j = 0; j + block <= N; j += block) {
			for (int k = j; k < block + j; k++) {

				ans ^= (a[i + 0] + b[k]) ^ (a[i + 1] + b[k]);
				ans ^= (a[i + 2] + b[k]) ^ (a[i + 3] + b[k]);
				ans ^= (a[i + 4] + b[k]) ^ (a[i + 5] + b[k]);
				ans ^= (a[i + 6] + b[k]) ^ (a[i + 7] + b[k]);
              	ans ^= (a[i + 8] + b[k]) ^ (a[i + 9] + b[k]);
				ans ^= (a[i + 10] + b[k]) ^ (a[i + 11] + b[k]);
				ans ^= (a[i + 12] + b[k]) ^ (a[i + 13] + b[k]);
				ans ^= (a[i + 14] + b[k]) ^ (a[i + 15] + b[k]);

			}
		}
	}

	for (int i = 0; i < N / unrl * unrl; i++) {
		for (int j = N / block * block; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}	
	for (int i = N / unrl * unrl; i < N; i++) {
		for (int j = 0; j < N; j++) {
			ans ^= a[i] + b[j];
		}
	}

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

	return 0;
}


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

using namespace std;

long long evaluate(vector<char> &formula) {
	long long result = 0, acc = 0;
	for (char c : formula) {
		if (c == '.') {
			continue;
		}
		else if (c == '+') {
			result += acc;
			acc = 0;
		}
		else {
			acc *= 10;
			acc += c - '0';
		}
	}
	return result;
}

long long solve(string &s) {
	if (s.size() == 1) {
		return s[0] - '0';
	}
	vector<char> formula;
	for (char c : s) {
		formula.push_back(c);
		formula.push_back('.');
	}
	formula.back() = '+';
	int lim = (1 << (s.size()-1));
	long long result = 0;
	for (int i = 0; i < lim; i++) {
		int tmp = i;
		for (int j = 0; j < s.size()-1; j++, tmp /= 2) {
			if (tmp % 2) {
				formula[2*j+1] = '.';
			}
			else {
				formula[2*j+1] = '+';
			}
		}
		result += evaluate(formula);
	}
	return result;
}

int main() {
	ios_base::sync_with_stdio(false);
	string s;
	cin >> s;
	cout << solve(s) << '\n';
	return 0;
}

Measured memory_bytes: 256
use std::io::Read;

pub fn read_stdin() -> String {
    let mut s = String::new();
    ::std::io::stdin().read_to_string(&mut s).unwrap();
    s
}

pub trait Parse {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr;
}

impl<'a> Parse for std::str::SplitWhitespace<'a> {
    fn to<T>(&mut self) -> T
    where
        T: std::str::FromStr,
    {
        let word = self.next().unwrap();
        word.parse().ok().unwrap()
    }
}

fn main() {
    let source = read_stdin();
    let mut iter = source.split_whitespace();
    let r: u32 = iter.to();
    println!("{}", r * r);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define pb push_back
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}

int main(){
    int n, m;
    cin >> n >> m;
    vi x(m);
    rep(i, m) cin >> x[i];

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

    vi dif(m-1);
    rep(i, m-1) dif[i] = x[i+1] - x[i]; 
    
    sort(dif.begin(), dif.end());

    int ans = 0;

    rep(i, m-1-(n-1)) ans += dif[i];
    cout << ans << endl;
    


    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:
    int N, K;

    void input() {
        cin >> N >> K;
    }

    void solve() {
        input();
        int ans = ((N - 1) / (K - 1)) + ((N - 1) % (K - 1) != 0);
        cout << ans << endl;

    }
};


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

    Solve().solve();


    return 0;
}


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


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

    int A[5];
    rep(i,5){
    cin >> A[i];
    }
    
    int k=0;
    int time=10;
    int sum=0;
    rep(i,5){
        int x=A[i]%10;
        if(x!=0 && x<time){
            time=x;
            k=i;
        }

        if(x==0){
            sum+=A[i];
        }
        else{
            sum+=A[i]-x+10;
        }
    }
    int ans=sum-10+time;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
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=200010;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;

//snuke
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;
  }
};
 


void mod_build(int n=211010){  
  fact.resize(n+1);
  inv.resize(n+1);
  invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1;
  inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
  k%=mod-1;
  if(k<0)k+=mod-1;
  ll ret=1;
  while(k){
    if(k&1)ret=ret*n%mod;
    n=n*n%mod;
    k>>=1;
  }
  return ret;
}

int main(){  
  mod_build();
  int h,w,a,b;
  cin >> h >> w >> a >> b;
  mint ans=0;
  
  rep(i,h-a){
    mint tmp=comb(b+i-1,b-1);
    tmp *= comb(h-1-i+w-b-1,h-1-i);
    ans += tmp;
  }
  
  
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 5248
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  string a,b,s;
  cin >> a >> b;
  s = a + b;
  int n = atoi(s.c_str());
  rep(i,1000){
    if(i*i == n){
      cout << "Yes" << endl;
      return 0;
    }
    if(i*i > n) break;
  }
  cout << "No" << endl;  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <numeric>
typedef long long ll;
using namespace std;
const int MOD = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
#define int long long
#define all(vec) vec.begin(), vec.end()
#define dbg(x) cerr << #x << " = " << (x) << endl
#define yn(b) cout << ((b) ? "Yes" : "No") << endl
#define YN(b) cout << ((b) ? "YES" : "NO") << endl
#define isEven(t) t % 2 == 0

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

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

	int a,b,x;
	cin>>a>>b>>x;

	YN(a <= x && a + b >= x);

	return 0;
}

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

using namespace::std;



int main()
{
	string N;
	cin >> N[0];

	string A = "A";
	string T = "T";
	string C = "C";
	string G = "G";

	if (N[0] == A[0]) {
		cout << "T" << endl;
	}
	if (N[0] == T[0]) {
		cout << "A" << endl;
	}
	if (N[0] == C[0]) {
		cout << "G" << endl;
	}
	if (N[0] == G[0]) {
		cout << "C" << endl;
	}

	
	return 0;

}


Measured memory_bytes: 256
def tax(p,x):
    return p*(100+x)//100

def solve(X,Y,S):
    best = 0
    for a in range(1,S):
        for b in range(1,S):
            sum = tax(a,X) + tax(b,X)
            if sum == S:
                tmp = tax(a,Y) + tax(b,Y)
                if tmp > best:
                    best = tmp
            if sum > S:
                break
    return best

while True:
    X,Y,S = map(int, input().strip().split(' '))
    if X == 0:
        break
    print(solve(X,Y,S))



Measured memory_bytes: 5596
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	int A[210];

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

	while(1){
		bool exist=false;
		for(int i=0;i<N;i++){
			if(A[i]%2!=0) exist=true;
		}

		if(exist) break;

		for(int i=0;i<N;i++){
			A[i]/=2;
		}
		cnt++;
	}
	cout<<cnt<<endl;
	return 0;
	}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define itrep(i, a) for (auto i = (a).begin(); i != (a).end(); i++)
#define REP(i, a, n) for (int i = (a); i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define mp(a, b) make_pair((a), (b))

using namespace std;

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

template<class T> void inputVector(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < v.size(); i++) cin >> v[i];
}

signed main() {
	int N, M, K;
	cin >> N >> M >> K;

	rep(i, N + 1) rep(j, M + 1) {
		int num = M * i;
		num += ((N - i) - i) * j;
		if (num == K) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <array>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>
#include <stack>
#include <utility>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <bitset>
#include <random>
#include <functional>
#include <sstream>
#include <iomanip>

using namespace std;

#define rep(i, n) for(int i=0; i<(n); i++)
#define FOR(i, m, n) for(int i=(m);i<(n);i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define REVE(x) reverse((x).begin(),(x).end())
#define mp make_pair
#define pb push_back
#define F first
#define S second


typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef long long LL;

int main() {
	int n, Q;
	cin >> n >> Q;
	vector<priority_queue<int>> q(n);
	VI print;
	rep(i, Q) {
		int cos; cin >> cos;
		if (cos == 0) {
			int t, x; cin >> t >> x;
			q[t].push(x);
		}
		else if (cos == 1) {
			int t; cin >> t;
			if (!q[t].empty())print.pb(q[t].top());
		}
		else if (cos == 2) {
			int t; cin >> t;
			if (!q[t].empty())q[t].pop();
		}
	}
	for (auto a : print) {
		cout << a << endl;
	}
}


Measured memory_bytes: 4120
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N;
    cin >> N;
    cout << setprecision(12) << ((N + 1) / 2) / (double)N << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
long long read()
{
    long long f=1,x=0;
    char ss=getchar();
    while(ss<'0'||ss>'9'){if(ss=='-')f=-1;ss=getchar();}
    while(ss>='0'&&ss<='9'){x=x*10+ss-'0';ss=getchar();}
    return f*x;
}
int a[2019];
int main()
{
    int c,d,n,ans=0;cin>>n;
    for(int i=1;i<=n;i++)cin>>a[i];
    sort(a+1,a+1+n);
    for(int i=1;i<=n;i++)
    for(int j=i+1;j<=n;j++)
    {
        c=a[i]+a[j];
        for(int k=j+1;k<=n;k++)
        {
            if(c>a[k])ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long int ll;
#define T int t,i; scanf("%d",&t); for(i=1;i<=t;i++)

int main(){
 ll n ,m ,k;
 cin >> n >> m;
 if((n*500)>=m)
 cout << "Yes" << endl;
 else cout << "No" << endl;	

}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long d=sc.nextLong();
		int ans=0;
		
		
		for(int i=0;i<n;i++) {
			long x=Math.abs(sc.nextLong());
			long y=Math.abs(sc.nextLong());
			if(Math.sqrt(Math.pow(x, 2)+Math.pow(y, 2))<=d)ans++;
			//System.out.println(Math.sqrt(Math.pow(x, 2)+Math.pow(y, 2)));
		}
		
	 System.out.println((int)ans);
		
	}

}


Measured memory_bytes: 60640