akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <queue>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    string s;
    cin >> s;
    int n = s.size();
    rep(i,n-2){
        s.erase(s.size()-1);
        if (i%2 == 0) continue;
        else {
            //cout << s << endl;
            bool f = true;
            for (int j = 0;j < s.size()/2;j++){
                if(s[j] != s[j+(s.size())/2]){
                    f = false;
                }
            }
            if (f) {
                cout << s.size() << endl;
                return 0;
            }
        }
    }
    
    return 0;
}

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define ALL(V) (V).begin(),(V).end()
#define endl "\n"

using namespace std;
typedef long long ll;

const double PI = 3.1415926535897932384626;
const ll MODN = 1000000007;
const ll MODN2 = 998244353;
const double EPS = 1e-10;

int main(){

    int a,b,c, k;
    cin >> a >> b >> c;
    cin >> k;

    int count = 0;

    while(a >= b){
        b = b * 2;
        count++;
    }

    while(b >= c){
        c = c * 2;
        count++;
    }

    if(count <= k){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>
#include <stdlib.h>

#if 1
int main(void) {
	int M, K;
	if (scanf("%d%d", &M, &K) != 2) return 1;
	if (K == 0) {
		int i;
		printf("0 0");
		for (i = 1; i < (1 << M); i++) printf(" %d %d", i, i);
		putchar('\n');
	} else if (M > 1 && K < (1 << M)) {
		int i;
		printf("%d", K);
		for (i = (1 << M) - 1; i >= 0; i--) {
			if (i != K) printf(" %d", i);
		}
		printf(" %d", K);
		for (i = 0; i < (1 << M); i++) {
			if (i != K) printf(" %d", i);
		}
		putchar('\n');
	} else {
		puts("-1");
	}
	return 0;
}
#else
/* {1,2,3} -> ... -> {3,2,1} */
int next_permutation(int arr[],int n) {
	int target;
	int i;
	int temp;
	for (i = n - 2; i >= 0; i--) {
		if (arr[i] < arr[i + 1]) break;
	}
	if (i < 0) return 0;
	target = i;

	for (i = 0; target + i + 1 < n - i - 1; i++) {
		temp = arr[target + 1 + i];
		arr[target + 1 + i] = arr[n - 1 - i];
		arr[n - i - 1] = temp;
	}

	for (i = target + 1; i < n; i++) {
		if (arr[i] > arr[target]) break;
	}
	temp = arr[i];
	arr[i] = arr[target];
	arr[target] = temp;
	return 1;
}

int main(void) {
	int* a;
	int M;
	int size;
	int ai;
	if (scanf("%d", &M) != 1) return 1;
	size = 1 << M;
	a = malloc(sizeof(*a) * (size * 2));
	if (a == NULL) return 2;
	for (ai = 0; ai < size; ai++) a[ai * 2] = a[ai * 2 + 1] = ai;
	size *= 2;
	do {
		int i, j;
		int tomatu = -1;
		int ng = 0;
		for (i = 0; !ng && i < size; i++) {
			for (j = i + 1; !ng && j < size; j++) {
				if (a[i] == a[j]) {
					int k;
					int sumipe = 0;
					for (k = i; k <= j; k++) sumipe ^= a[k];
					if (tomatu < 0) {
						tomatu = sumipe;
					} else {
						if (tomatu != sumipe) ng = 1;
					}
					break;
				}
			}
		}
		if (!ng && tomatu != 0) {
			for (i = 0; i < size; i++) printf("%d ", a[i]);
			printf("-> %d\n", tomatu);
		}
	} while (next_permutation(a, size));
	free(a);
	return 0;
}
#endif


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

int main() {
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> py[n];
  rep(i,m) {
    int p, y;
    cin >> p >> y;
    p--;
    py[p].push_back({y,i});
  }


  rep(i,n) {
    sort(py[i].begin(), py[i].end());
  }
  pair<int, int> ans[m];
  rep(i,n) {
    rep(j,py[i].size()) {
      ans[py[i][j].second] = {i+1, j+1};
    }
  }
  rep(i,m) {
    cout << setw(6) << setfill('0') << ans[i].first;
    cout << setw(6) << setfill('0') << ans[i].second << "\n";
  }
  return 0;
}

Measured memory_bytes: 7680
#include <bits/stdc++.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n, v) rep(i, n) cin >> v[i]

using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1, 0, -1, 0}, y_pos[4] = {0, 1, 0, -1};
int ctoi(char c)
{
	if (c >= '0' && c <= '9')
	{
		return c - '0';
	}
	return 0;
}

char upper(char c)
{
	return c - 0x20;
}

char lower(char c)
{
	return c + 0x20;
}

void unique_vector(vector<int> &v)
{
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

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

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y)
{
	if (y == 0)
		return x;
	return gcd(y, x % y);
}

//最小公倍数
ll lcm(ll x, ll y)
{
	ll g = gcd(x, y);
	return x / g * y;
}

ll myPow(ll x, ll n, ll m)
{
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

//k!
ll facctorialMethod(ll k)
{
	ll sum = 1;
	for (ll i = 1; i <= k; ++i)
	{
		sum *= i;
		sum %= MOD;
	}
	return sum;
}

//nCr
ll permutationMethod(ll n, ll r)
{
	ll n_sum, r_sum;
	r = n - r;
	n_sum = facctorialMethod(n);
	r_sum = facctorialMethod(r);
	return n_sum / r_sum;
}

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

ll pow_kai(int a, int n)
{ //aのn乗を計算します。
	ll x = 1;
	while (n > 0)
	{ //全てのbitが捨てられるまで。
		if (n & 1)
		{ //1番右のbitが1のとき。
			x = (x * a) % MOD;
		}
		a = (a * a) % MOD;
		n >>= 1; //bit全体を右に1つシフトして一番右を捨てる。
	}
	return x % MOD;
}

int main()
{
	int n;
	cin >> n;
	int ans = 1;
	bool isUp = true;
	bool isFirst = true;
	ll before = 0;
	rep(i, n)
	{
		int a;cin>>a;
		if(i==0){
			before = a;
			continue;
		}
		if(before == a){
			continue;
		}
		if(isFirst){
			isUp = before < a ? true : false;
			before = a;
			isFirst = false;
			continue;
		}
		if((isUp && before > a)||
		(!isUp && before < a)){
			ans++;
			isFirst = true;
		}
		before = a;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
import heapq
def prim_heap():
    used = [True] * n #True:不使用
    edgelist = []
    for e in edge[0]:
        heapq.heappush(edgelist,e)
    used[0] = False
    res = 0
    while len(edgelist) != 0:
        minedge = heapq.heappop(edgelist)
        if not used[minedge[1]]:
            continue
        v = minedge[1]
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,e)
        res += minedge[0]
    return res

#########################
n = int(input())
zahyo = []
for i in range(n):
    x,y = map(int,input().split())
    zahyo.append((x,y,i))
xza = sorted(zahyo)
yza = sorted(zahyo,key=lambda x: x[1])
edge = [[] for i in range(n)]
#隣接リスト edge[i]:[コスト,行先]
for i in range(n-1):
    c = abs(xza[i][0]-xza[i+1][0])
    edge[xza[i][2]].append((c,xza[i+1][2]))
    edge[xza[i+1][2]].append((c,xza[i][2]))
for i in range(n-1):
    c = abs(yza[i][1]-yza[i+1][1])
    edge[yza[i][2]].append((c,yza[i+1][2]))
    edge[yza[i+1][2]].append((c,yza[i][2]))
print(prim_heap())

Measured memory_bytes: 118360
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

// 二項係数計算
long long com(ll n){
    ll k = 2;
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return n*(n-1)/2;
}

int main()
{

    ll N;
    cin >> N;
    vector<ll> A;
    int same[200005] = {};
    int done[200005] = {};

    for(ll i=0; i<N; ++i)
    {
        ll tmp;
        cin >> tmp;
        A.push_back(tmp);
        ++same[tmp];
    }

    ll all = 0;
    for(ll i=0; i<N; ++i)
    {
        if(done[A[i]]==1) continue;
        else
        {
            done[A[i]] = 1;
            all += com(same[A[i]]);
        }
    }

    for(ll i=0; i<N; ++i)
    {
        cout << all - com(same[A[i]]) + com(same[A[i]]-1) << endl;
    }

    return 0;
}


Measured memory_bytes: 5872
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <iomanip> 

using ll = long long;
using ull = unsigned long long;
using namespace std;

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i = 0;(i) < ((int)(n));++(i))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

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

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

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;} // 桁数
template<typename T>inline void print(T&& x){cout<<x<<endl;}// 改行付き出力
template<typename T>inline T SUM(vector<T> vec){return accumulate(all(vec),(T)0);} // vectorの中身を全部足す
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);} // 最大公約数
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;} // 最小公倍数
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;} // 累乗
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int ctoi(char c){return c-'0';}


// TODO: write
int main() {
  int n;cin>>n;
  vector<int> a(n);rep(i,n)cin>>a[i];
  sort(all(a));
  
  ll ans = 0;
  rep(i,n-1){
    ans += a[n-1 - (i/2+i%2)];
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 4024
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n;
int a[100010];
int dp[100010];

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

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

    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for(int i=2;i<n;i++)
        dp[i]=min(dp[i-1]+abs(a[i-1]-a[i]),dp[i-2]+abs(a[i]-a[i-2]));

    cout<<dp[n-1];


	return 0;
}


Measured memory_bytes: 1024
x, y = map(int, input().split())
score = 0
if x == 3:
    score += 100000
elif x == 2:
    score += 200000
elif x == 1:
    score += 300000
if y== 3:
    score += 100000
elif y== 2:
    score += 200000
elif y== 1:
    score += 300000
if x == 1 and y == 1:
    score += 400000
print(score)

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

int main(void) {
	int N, W;
	cin >> N >> W;
	vector<vector<int>> dp(N+1, vector<int>(W+1, 0));
	//用意していた配列の大きさが足りずセグフォになってた...
	for (int i = 1; i <= N; i++) {
		int v, w;
		cin >> v >> w;
		// Wまでとしていた為にセグフォ
		// Wと最大値だがどう出すか
		for (int j = 0; j <= W; j++) {
			if (j - w < 0) {
				dp[i][j] = dp[i-1][j];
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v);
			}
		}
	}
	cout << dp[N][W] << endl;
}



Measured memory_bytes: 6848
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  int n;
  cin >> n;
  vi x(n), y(n);
  rep(i, n) {
    cin >> x[i] >> y[i];
  }

  vi a(n);
  iota(all(a), 0);

  double ans = 0;
  do {
    rep(i, n-1) {
      ans += sqrt(pow(x[a[i]]-x[a[i+1]], 2) + pow(y[a[i]]-y[a[i+1]], 2));
    }
  } while (next_permutation(all(a)));

  int tmp = 1;
  rep(i, n) {
    tmp *= i+1;
  }

  printf("%.7lf\n", ans/tmp);
}


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

int main(void)
{
	int N, D, X;
	cin >> N >> D >> X;
	double *A = new double[N];
	int sum = X;
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
		sum += ceil(D / A[i]);
	}

	cout << sum << endl;

	return 0;
}

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

int main() {
  char A[15];
  cin >> A;

  int ans = 1 << 30;
  int N = strlen(A);
  for (int i = 2; i < N; ++i) {
    int num = A[i-2]*100 + A[i-1]*10 + A[i] - 111 * '0';
    ans = min(ans, abs(753 - num));
  }

  cout << ans;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"

using namespace std;
typedef long long ll ;
typedef pair <ll,ll>  pii;
priority_queue <ll> pq;
ll v[1000001];
int  main() {
    ll n,i,k,sum = 0;
    cin >> k >> n;
    for(i = 1;i <= n;i++){
        cin >> v[i];
        if(i > 1){
        pq.push(v[i] - v[i - 1]);
        sum += (v[i] - v[i - 1]);
        }
    }
    pq.push(k - v[n] + v[1]);
    sum += k - v[n] + v[1];
    cout << sum - pq.top();
    return 0;
}


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

const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll l, r; cin >> l >> r;
	ll cnt = 1001001001001001;
	if(r - l < 2019){
		for(ll i = l; i < r; i++){
			for(ll j = i + 1; j <= r; j++){
				cnt = min(cnt, i * j % 2019);
			}
		}
		cout << cnt << endl;
	}
	else cout << 0 << endl;
} 

Measured memory_bytes: 256
#include<map>
#include<iostream>
using namespace std;
int main(){
    map<string,int> sm;
    string in,freq,len;
    int maxfreq=0,maxlen=0;
    while(!cin.eof()){
       cin>>in;
       sm[in]++;
    }
    sm[in]--;
    for(map<string,int>::iterator it=sm.begin();it!=sm.end();it++){
        if(it->second>maxfreq){
            maxfreq=it->second;
            freq=it->first;
        }
        if(it->first.size()>maxlen){
            maxlen=it->first.size();
            len=it->first;
        }
    }
    cout<<freq<<" "<<len<<endl;
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <limits>
using namespace std;

int main(void){
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    int ans = a*x + b*y;
    int MIN = min(x,y);
    int MAX = max(x,y);
    ans = min(ans, c*MIN*2 + a*(x-MIN) + b*(y-MIN));
    ans = min(ans, c*MAX*2);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{

  public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();


      int[] remainder = new int[4];
      for(int i = 0; i < n; i++)
        remainder[sc.nextInt() % 4]++;

      int cnt = remainder[0] + remainder[2] / 2;
      if(cnt >= n / 2)
        System.out.println("Yes");
      else
        System.out.println("No");
  }
}


Measured memory_bytes: 48092
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctype.h>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;

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

//4方向ベクトル→↑←↓
int dx[] ={1,0,-1,0};
int dy[] ={0,-1,0,1};
//参考http://d.hatena.ne.jp/cos65535/20111204/1322960615 
int n,k;//構成するべき数列の長さn,カードの枚数k
int seq[1010];
int card[1010][1010];

int main()
{
  srand(time(NULL));
  while(scanf("%d %d",&n,&k) >0){
    for(int i = 0;i < k;i++){
      for(int j = 0;j <n/2;j++){
	scanf("%d",&card[i][j]);//カードi(<k)番目の
	card[i][j]--;
      }
    }
    while(true){

      bool flag =true;
      for(int i = 0;i < n;i++){
	seq[i] =rand()%2;//ランダムに数列を生成、適当な数を2で割りその余りを求めるので0or1が生成される
      }
      for(int i = 0;i <k;i++){//seqカードk枚
	int sum = 0;

	for(int j = 0;j <n;j++){
	  sum +=seq[card[i][j]];
	}

	if(sum <n/8 || sum >3*n/8)
	  flag =false;
	if(!flag)
	  break;
      }
      if(flag)
	break;//カードk枚成功したら無限ループを抜け出す
    }
    for(int i =0 ;i < n;i++){
      printf("%d",seq[i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define int long long
using namespace std;
struct que {
    int x,num;
    friend bool operator<(que a,que b) {
        return a.x<b.x;
    }
};
priority_queue<que> q;
int n,m,cnt,ans;
signed main() {
    int x,y;
    scanf("%lld%d",&n,&m);
    for(register int i=1; i<=n; i++) {
        scanf("%lld",&x);
        q.push(que {x,1});
    }
    for(register int i=1; i<=m; i++) {
        scanf("%lld%lld",&x,&y);
        q.push(que {y,x});
    }
    while(!q.empty()) {
        que u=q.top();
        q.pop();
        if(cnt+u.num>=n) {
            ans+=(n-cnt)*u.x;
            //cout<<n-cnt<<' '<<u.x<<endl;
            break;
        }
        cnt+=u.num;
        ans+=u.num*u.x;
        //cout<<u.num<<' '<<u.x<<endl;
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 7452
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int mod = 1e9+7;

// ll factorial(int x) {
//     if (x==0) return 1;
//     return x*factorial(x-1)%mod;
// }

ll factorial(ll x) {
    ll ans = 1;
    rep(i,x) {
        ans *= i+1;
        ans %= mod;
    }
    return ans;
}

ll power(ll x, ll n) {
    ll ans = 1;
    while (n > 0) {
        if ((n&1) == 1) {
            ans *= x;
            ans %= mod;
        }
        x *= x;
        x %= mod;
        n >>= 1;
    }
    return ans;
}

int main() {
    int x, y;
    cin >> x >> y;

    if ((x+y)%3) {
        cout << 0 << endl;
        return 0;
    }

    int n, m;
    n = (2*y-x)/3;
    m = (2*x-y)/3;

    if (n<0 || m<0) {
        cout << 0 << endl;
        return 0;
    }

    ll inv1 = power(factorial(n),mod-2)%mod;
    ll inv2 = power(factorial(m),mod-2)%mod;

    ll ans = factorial(n+m)*inv1%mod*inv2%mod;
    cout << ans << endl;

}

Measured memory_bytes: 256
X, Y, Z, K = map(int, input().split())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]

AB = sorted([a + b for a in A for b in B], reverse=True)[:K]
ABC = sorted([ab + c for ab in AB for c in C], reverse=True)[:K]
for a in ABC:
    print(a)


Measured memory_bytes: 138864
n,m = map(int,input().split())
P = list(map(int,input().split()))

uf = {i:i for i in range(1,n+1)}

def get_parent(i):
  lst = []
  while uf[i] != i:
    lst.append(i)
    i = uf[i]
  for l in lst[:-1]:
    uf[l] = i
  return i

def unite(i,j):
  p = get_parent(i)
  uf[get_parent(j)] = p

def same(i,j):
  return get_parent(i) == get_parent(j)

for _ in range(m):
  x,y = map(int,input().split())
  unite(x,y)

ans = 0
for i in range(1,n+1):
  ans += int(same(P[i-1],uf[i]))
print(ans)



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

long long k;
string s;

int main() {
  cin >> k >> s;
  if (s.size() <= k)
    cout << s << endl;
  else {
    cout << s.substr(0, k) << "..." << endl;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3632
N = int(input())
H = list(map(int, input().split()))
 
for i in range(1, N):
    if H[i] < H[i - 1]:
        H[i] += 1
for i in range(1, N):
    if H[i] < H[i - 1]:
        print('No')
        exit(0)
print('Yes')

Measured memory_bytes: 14396
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#include<cassert>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 998244353;
const long long inf = 1ll << 61;
const double eps = 0.000000000001;
typedef pair<int, int> P;
typedef pair<P, int>PP;
struct edge { int to; int cost; };

double det(double x11,double x12,double x21,double x22) {
	return x11*x22 - x12*x21;
}

signed main() {
	double x[4],y[4];
	while (~scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf",&x[0],&y[0],&x[1],&y[1],&x[2],&y[2],&x[3],&y[3])) {
		double ans[4];
		rep(i, 4) {
			ans[i] = det(x[(i + 1) % 4] - x[i], y[(i + 1) % 4] - y[i], x[(i + 2) % 4] - x[i], y[(i + 2) % 4] - y[i]);
		}
		rep(i, 3)ans[0] *= ans[i + 1];
		if (ans[0] > 0)puts("YES");
		else puts("NO");
	}
}



Measured memory_bytes: 3180
import java.util.*

fun main(args: Array<String>) {
    val scanner = Scanner(System.`in`)
    val W = scanner.nextLine()
    var count = 0
    while(scanner.hasNextLine()) {
        val line = scanner.nextLine()
        if (line == "END_OF_TEXT") break
        count += line.split(" ")
            .count { w -> w.toLowerCase() == W.toLowerCase() }
    }
    println(count)
}


Measured memory_bytes: 33336
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys


def max_heapify(index):
    left, right, largest = 2 * index, 2 * index + 1, -1

    if left <= array_length and array[left] > array[index]:
        largest = left
    else:
        largest = index

    if right <= array_length and array[right] > array[largest]:
        largest = right

    if largest != index:
        array[index], array[largest] = array[largest], array[index]
        max_heapify(largest)

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    array_length = int(_input[0])
    array = list(map(int, _input[1].split()))
    # assert len(array) == array_length

    array.insert(0, None)
    for j in range(array_length // 2, 0, -1):
        max_heapify(j)
    print('', end=' ')
    print(*array[1:])

Measured memory_bytes: 62520
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
struct UnionFind{
    vector<int> par;
    UnionFind(int n) : par(n){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int root(int x){
        if(par[x]==x) return x;
        return par[x] = root(par[x]);
    }
    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
    }
    bool same(int x, int y){
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    vector<int> x(m),y(m),z(m);
    for(int i=0; i<m; i++){
        int a,b,c;
        cin>>a>>b>>c;
        x[i]=a-1;
        y[i]=b-1;
        z[i]=c-1;
    }
    vector<bool> a(n,false);
    UnionFind tree(n);
    for(int i=0; i<m; i++){
        tree.unite(x[i],y[i]);
    }
    ll ans=0;
    for(int i=0; i<m; i++){
        if(!a[tree.root(x[i])]){
            a[tree.root(x[i])]=true;
            ans++;
        }
    }
    for(int i=0; i<n; i++){
        if(!a[tree.root(i)]){
            a[tree.root(i)]=true;
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 2560
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,s=1,a[100005];
LL P(LL x,LL y)
{
	for(;x%y<1;)x/=y;
	return x%y<2;
}
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(i=1;++i*i<n;)
	{
		if(n%i<1)
		{
			s+=P(n,i);
			s+=P(n,n/i);
		}
	}
	if(i*i==n)s+=P(n,i);
	m=n-1;
	for(i=1;++i*i<m;)
	{
		if(m%i<1)
		{
			s+=2;
		}
	}
	if(i*i==m)s++;
	if(n>2)s++;
	cout<<s;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int b[1000000001];
int main()
{
	int n;
	int a;
	int c = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a;
		if (b[a] == 0) {
			c++;
			b[a] += 1;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 42140
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const int nmax = 8;

bool graph[nmax][nmax];  //グラフの隣接行列

int dfs(int v, int N, bool visited[nmax]) {  // vはdfsを開始する頂点、Nはグラフの頂点数
    
    bool all_visited = true;  //全ての頂点を訪れたかどうか

    //未訪問の頂点があればall_visitedはfalse
    rep(i, N) {
        if(!visited[i]) {
            all_visited = false;
        }
    }

    //すべての頂点を訪れている場合は1を返す
    if(all_visited) {
        return 1;
    }

    int ret = 0;
    //頂点vに隣接する未訪問の頂点を全探索
    rep(i, N) {
        //vと隣接していなかったらダメ
        if(!graph[v][i]) {
            continue;
        }
        //訪問済みだったらダメ
        if(visited[i]) {
            continue;
        }
        //頂点iを訪問済みにする
        visited[i] = true;

        ret += dfs(i, N, visited);
        visited[i] = false;
    }

    return ret;
}

int main() {
    int n;  //頂点数
    int m;  //辺数
    cin >> n >> m;

    //無向グラフの入力
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        graph[a-1][b-1] = graph[b-1][a-1] = true;
    }

    bool visited[nmax];  // visited[i] : 頂点iを訪問したかどうか
    //全頂点を未訪問にする
    rep(i, n) {
        visited[i] = false;
    }
    //スタート位置の頂点0を訪問済みにする
    visited[0] = true;

    cout << dfs(0, n, visited) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>

using namespace std;

#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque



#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>

#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>

#define vi vector<ll>
#define vs vector<string>

#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator


#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define F first
#define S second
#define pi 2*acos(0.0)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT_ count()
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second

#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT_ getline
#define NL_   "\n"

#define fr(i, n) for(i = 0; i < n; i++)
#define fe(i, n) for(i = 1; i <= n; i++)

#define ul unsigned long long int
#define ll long long int
#define  MAX 250000

ll N, T = 0, tC = 0, i, j, k;

vector<ul> v;


void lulu(ll i, ll n)
{

    if(i==1 && v.size() <= 10000010)
    {
//        if(n%10 - 1 >=0)
//        {
//            n  = (n*10)+(n%10-1);
//            cout << n<<" ";
//            arr[T++] = n;
//        }
//        arr[T++] = n*10 + (n%10);
//        if(n%10 +1 < 10)
//        {
//            n = (n*10)+(n%10+1);
//            arr[T++] = n;
//        }
               v.PB((ul)n);

        return ;
    }
    else if(v.size()< 100010)
    {
          if(n%10 - 1 >=0)
        {
            lulu(i-1, (n*10)+(n%10-1));
        }
        lulu(i-1, (n*10)+(n%10));
        if(n%10 +1 < 10)
        {
           lulu(i-1, (n*10)+(n%10+1));
        }
    }
}




int main()
{
    FAST;
    fr(i,10) v.PB((ul)i);
    for(ll i = 2; i <= 15 && T < 100000; i++)
    {
        for(int j = 1; j <= 9; j++)
        {
            lulu(i,j);
        }
    }
    int n ;
    cin >> n;
    n;
    cout << v[n];

    return 0;
}



Measured memory_bytes: 1400
k=int(input())
ans=0
import itertools
import math
from functools import reduce
s=list(range(1,k+1))
s=s+s+s
def gcd(*numbers):
    return reduce(math.gcd, numbers)
from  itertools import combinations
q=[]
for i in range(1,k+1):
    for j in range(1,k+1):
        q.append(gcd(i,j))
for i in q:
    for j in range(1,k+1):
        ans+=gcd(i,j)
    
print(ans)

Measured memory_bytes: 70700
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;

int main() 
{

    fast();
      
    // #ifndef ONLINE_JUDGE
    //         freopen("input.txt", "r", stdin);
    //         freopen("output.txt","w",stdout);
    // #endif
    ll k,n;
    cin>>k>>n;
    
    f(i,n-k+1,n)
    {
        cout<<i<<" ";
    }
    f(i,n,n+k)
    {
        cout<<i<<" ";
    }

    
    





  

    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int number[9];
bool open[9];

int zahyou(int i, int j){
	int wakaru = 3 * i + j;
	return wakaru;
}

int main(){
	for(int i = 0; i < 9; i++){
		cin >> number[i];
		open[i] = false;
	}

	int n;
	cin >> n;

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

		for(int f = 0; f < 9; f++){
			if(number[f] == tmp)
				open[f] = true;
		}
	}

	bool bingostat = false;

//列ビンゴ
	for(int i = 0; i < 3; i++){
		if(open[zahyou(i, 0)] && open[zahyou(i, 1)] && open[zahyou(i, 2)])
			bingostat = true;
	}

//行ビンゴ
	for(int i = 0; i < 3; i++){
		if(open[zahyou(0, i)] && open[zahyou(1, i)] && open[zahyou(2, i)])
			bingostat = true;
	}

//斜めビンゴ
	if(open[zahyou(0, 0)] && open[zahyou(1, 1)] && open[zahyou(2, 2)])
		bingostat = true;
	else if(open[zahyou(0, 2)] && open[zahyou(1, 1)] && open[zahyou(2, 0)])
		bingostat = true;

	if(bingostat)
		cout << "Yes";
	else
		cout << "No";
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define deb(x) cout << #x << " = "<< x << "\n";
#define bs binary_search
#define all(a) (a).begin, (a).end()
int h, w, k;
vector<string> v(7), temp(7);
vector<vector<int>> row, col;
 
int check() {
    int cnt = 0;
    for(int i = 0; i < h; i++) {
	    for(int j = 0; j < w; j++) {
	        cnt += temp[i][j] == '#';
	    }
	}
	return (cnt == k);
}  

signed main() {
	//freopen("in.txt", "r",stdin);
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	cin >> h >> w >> k;
	
	for(int i = 0; i < h; i++) {
	    cin >> v[i];
	}
	for(int i = 1; i < (1 << h); i++) {
        vector<int> v;    
        int temp = i, j = 0;
        while(temp > 0) {
            if(temp & 1) v.push_back(j);
            j++;
            temp /= 2;
        }
        row.push_back(v);
    }
	for(int i = 1; i < (1 << w); i++) {
        vector<int> v;    
        int temp = i, j = 0;
        while(temp > 0) {
            if(temp & 1) v.push_back(j);
            j++;
            temp /= 2;
        }
        col.push_back(v);
    }
    
	int ans = 0;
	int cnt = 0;
	for(int i = 0; i < h; i++) {
	    for(int j = 0; j < w; j++) {
	        cnt += v[i][j] == '#';
	    }
	}
	ans += (cnt == k);
	
	for(vector<int> a : row) {
        for(vector<int> b : col) {
    	    for(int i = 0; i < h; i++) temp[i] = v[i];
    	    for(int i = 0; i < h; i++) {
    	        for(int j = 0; j < w; j++) {
    	            if(bs(a.begin(), a.end(), i) || bs(b.begin(), b.end(), j))
    	                temp[i][j] = 'T';
    	        }
    	    }
    	   ans += check();
    	}
	}
	
	
	for(vector<int> a : row) {
	    for(int i = 0; i < h; i++) temp[i] = v[i];
	    for(int x : a) {
	        for(int i = 0; i < w; i++) {
	            temp[x][i] = 'T';
	        }
	    }
	    ans += check();
	}
	for(vector<int> a : col) {
	    for(int i = 0; i < h; i++) temp[i] = v[i];
	    for(int x : a) {
	        for(int j = 0; j < h; j++) {
	            temp[j][x] = 'T';
	        }
	    }
	    ans += check();
	}
	cout << ans << "\n";
	
}


Measured memory_bytes: 3564
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bits/stdc++.h>
#include<cmath>
#include<bitset>
#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,0,n)
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define INF ((1LL<<62)-(1LL<<31))
#define MOD 1000000007
using namespace std;

int main(){
  int N,M,ans=0,cnt=0;
  cin>>N;
  string S[N];
  REP(i,N) cin>>S[i];
  cin>>M;
  string T[M];
  REP(i,M) cin>>T[i];
  
  REP(i,N){
    cnt=0;
    string L=S[i];
    REP(j,N){
      if(S[j]==L) cnt++; 
    }
    REP(j,M){
      if(T[j]==L) cnt--;
    }
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;

int main(){
    int n,m;
    cin >> n >> m;
    vector<int> c(m);
    rep(i,m) cin >> c[i];
    vector<int> dp(n+1,INF);
    dp[0] = 0;
    rep(i,m){
        for(int j=1;j<=n;j++){
            if(j - c[i] >= 0){
                dp[j] = min(dp[j],dp[j-c[i]] + 1);
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}



Measured memory_bytes: 3156
#include <cstdio>
#include <functional>
#include <algorithm>
#include <vector>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>

#define INF (1ll<<60)
#define MOD 1000000007
#define BOUND 27182818284

typedef long long ll;
typedef long long int lli;

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

template<class T>bool umax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool umin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using namespace std;

// gcd
template<typename T>
T gcd(T a, T b){
    if(a==0)
        return b;
    return gcd(b%a,a);
}
// gcd array
int findGCD(int arr[], int n){
    int result = arr[0];
    for (int i=1; i < n; i++)
        result = gcd(arr[i], result);

    return result;
}
template<typename T>
T lcm( T m, T n )
{
    // 引数に0がある場合は0を返す
    if ( ( 0 == m ) || ( 0 == n ) )
        return 0;

    return ((m/gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

// sort big to small
// sort(A,A+N, greater<int>());

// v.front() = -BOUND;
// v.back() = BOUND;

// Iterator
// v.begin
// v.end

int main() {
    long long H,W;
    long long S;
    long long ans=1<<30;
    long long block1, block2, block3;

    cin >> H >> W;
    S=H*W;

    for(long long i=1; i<H; i++){
        block1=W*i;
        block2=(H-i)/2 * W;
        block3=S-block1-block2;
        if(block2 !=0 && block3 != 0) {
            ans = min(max({block1, block2, block3}) - min({block1, block2, block3}), ans);
        }

        block2=W/2 * (H-i);
        block3=S-block1-block2;
        if(block2 !=0 && block3 != 0) {
            ans = min(max({block1, block2, block3}) - min({block1, block2, block3}), ans);
        }
    }

    for(long long i=1; i<W; i++) {
        block1 = H * i;
        block2 = (W - i) / 2 * H;
        block3 = S - block1 - block2;
        if (block2 != 0 && block3 != 0) {
            ans = min(max({block1, block2, block3}) - min({block1, block2, block3}), ans);
        }

        block2 = H / 2 * (W - i);
        block3 = S - block1 - block2;
        if(block2 !=0 && block3 != 0) {
            ans = min(max({block1, block2, block3}) - min({block1, block2, block3}), ans);
        }
    }

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



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define flush fflush(stdout)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef pair<ll, ll> Pl;
const int mod = (int)1e9 + 7, INF = (int)1e9;
const int di[4] = { 1,0,-1,0 }, dj[4] = { 0,1,0,-1 };


int main(void) {
	int n, i, bin;
	vector<int> b, ans;
	bool end;

	scanf("%d", &n);
	for (i = 0; i < n; i++) {
		scanf("%d", &bin);
		b.push_back(bin);
	}

	end = false;
	while (!end && !b.empty()) {
		end = true;
		for (i = b.size() - 1; i >= 0; i--) {
			if (b[i] == i + 1) {
				ans.push_back(b[i]);
				b.erase(b.begin() + i);
				end = false;
				break;
			}
		}
	}

	if (b.empty()) {
		for (i = n - 1; i >= 0; i--) {
			printf("%d\n", ans[i]);
		}
	}
	else {
		printf("-1\n");
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (long long  i=a;i<n;i++)
#define sz(A) (int)(A.size())
#define all(x) (x).begin(),(x).end()
#define get(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
typedef long long ll;
typedef pair<int, int> PII;
typedef vector<int> VI;

void solve() {
	ll n;
	cin >> n;
	vector<ll> a(n);
	rep(i, 0, n)cin >> a[i];
	ll sum = 0;
	ll pre = a[0];
	rep(i, 1, n) {
		sum += max(pre - a[i], 0LL);
		pre = max(pre, a[i]);
	}
	cout << sum << endl;
}
int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int T_ = 1;
	//cin >> T_;
	for (int i = 0; i < T_; i++)solve();
	return 0;
}



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

using namespace std;

int main (){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  cin.ignore();

  int t_cnt, a_cnt;
  t_cnt = c / b + ((c % b != 0) ? 1 : 0);
  a_cnt = a / d + ((a % d != 0) ? 1 : 0);

  if(t_cnt <= a_cnt){
    cout << "Yes" << endl;
    return 0;
  } else {
    cout << "No" << endl;
    return 0;
  }
  return 0;
}


Measured memory_bytes: 3624
A = int(input())
B = int(input())
C = int(input())
X = int(input())

ans = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if X == (500 * i) + (100 * j) + (50 * k):
                ans += 1
print(ans)


Measured memory_bytes: 9168
#include<stdio.h>

int main(void){
    int i,N,counter = 0;
    scanf("%d",&N);
    int a[N];
    for(i=0;i<N;i++){
        scanf("%d",&a[i]);
        counter = counter + a[i] + -1;
    }
    printf("%d\n",counter);
    return 0;

}

Measured memory_bytes: 128
from collections import Counter
import numpy as np
h, w = list(map(int, input().split()))
s = np.array([list(input()) for i in range(h)])

cnt = 0
ans = [[] for i in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == ".":
      xm = max(0, j-1)
      ym = max(0, i-1)
      xp = min(w-1, j+1)
      yp = min(h-1, i+1)
      temp = s[ym:yp+1, xm:xp+1].reshape(-1).tolist()
      ans[i].append(str(Counter(temp)["#"]))
     
    else:
      ans[i].append("#")
      
for ai in ans:
  print("".join(ai))

Measured memory_bytes: 12504
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		StringBuilder sb = new StringBuilder();
		Set<Integer> set1 = new TreeSet<>();
		Set<Integer> set2 = new HashSet<>();
		for (int i = 0; i < n; i++) {
			set1.add(sc.nextInt());
		}
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			set2.add(sc.nextInt());
		}
		set2.retainAll(set1);
		set1.removeAll(set2);
		for (int num : set1) {
			sb.append(num);
			sb.append('\n');
		}
		System.out.print(sb.toString());
	}
}



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



int main(){

  int a[10000]={};
  int n,s,l;
  cin>>s>>l;
  a[s]++;
  a[l]--;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s>>l;
      a[s]++;
      a[l]--;
  }

  bool j=true;
  int count=0;
  for(int i=0;i<1010;i++){
    count+=a[i];
    if(count>1){j=false; break;}
  }
  if(j){cout<<"0"<<endl;}
  else{cout<<"1"<<endl;}
  

  
  return 0;
}



Measured memory_bytes: 3140
import java.util.Scanner;

public class Main {
	private static Scanner sc;
	
	public static void main(String[] args) {
		sc =  new Scanner(System.in);
		//case : 入力された数値を取得するとき
		int n = Integer.parseInt(sc.next());
		//case : 入力された文字列を取得するとき
		String str = sc.next();
		String[] strArr = str.split("");
		
		int result = 0;
		int max = 0;
		for (int i=0; i<n; i++) {
			if(strArr[i].equals("I")) {
				result++;
			} else {
				result--;
			}
			if (max < result) {
				max=result;
			}
		}
		
		System.out.println(max);
	}
	

}


Measured memory_bytes: 35572
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define RREP(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s; cin >> s;
    string t = "";
    ll idx = 0;
    while(idx < s.size()){
        if(s[idx] == 'A'){
            t += 'A'; idx++;
        }
        else if(idx < s.size()-1 && s[idx] == 'B' && s[idx+1] == 'C'){
            t += 'X'; idx += 2;
        }
        else{
            t += 'Z'; idx++;
        }
    }
    
    ll l = 0, r = 0, ans = 0;
    while(l < t.size()){
        ll xcnt = 0, acnt = 0;
        while(r < t.size()){
            if(t[r] == 'A'){
                acnt++; r++;
            }
            else if(t[r] == 'X'){
                xcnt += acnt; r++;
            }
            else{
                break;
            }
        }
        ans += xcnt;
        l = r+1; r = l;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 916
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try(Scanner sc = new Scanner(System.in)) {
			int n = sc.nextInt();
			long[] S = new long[n];
			for(int i=0; i<n; i++) {
				S[i] = sc.nextLong();
			}
			
			long q = sc.nextLong();
			int ans = 0;
			for(int i=0; i<q; i++) {
				long T = sc.nextLong();
				for(int j=0; j<n; j++) {
					if(T == S[j]) {
						ans++;
						break;
					}
				}
			}
			System.out.println(ans);
		}
	}	
}



Measured memory_bytes: 39916
#define _CRT_SECURE_NO_WARNINGS

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define SREP(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTF(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9
#define NMAX 1e9

typedef long long ll;
int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int x[200000];
int tmp[200000];

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
int Max(int a, int b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int x[], int i, int j)
{
	int temp;

	temp = x[i];
	x[i] = x[j];
	x[j] = temp;
}
void QSort(int x[], int left, int right, int n) {
	int i, j;	//左端,右端
	int pivot;	//軸

	i = left;
	j = right;
	pivot = x[(left + right) / 2];

	while (1) {
		if (n > 0) {				//n>0なら昇順、n<=0なら降順
			while ((x[i] < pivot) && (i <= right))i++;	//軸値より大きい要素
			while ((pivot < x[j]) && (i <= right))j--;	//軸値より小さい要素
		}
		else {
			while ((x[i] > pivot) && (i <= right))i++;	//軸値より小さい要素
			while ((pivot > x[j]) && (i <= right))j--;	//軸値より大きい要素
		}
		if (i >= j)	break;
		Swap(x, i, j);
		i++; j--;
	}
	//ShowData(x, left, right);

	if (left < i - 1)QSort(x, left, i - 1, n);
	if (j + 1 <  right)QSort(x, j + 1, right, n);
}

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

	int a[100000];
	REP(i, n) {
		scanf("%d", &a[i]);
	}
	QSort(a, 0, n - 1, 1);

	int tmp = a[n - 1]/2;
	int m=10000000001;
	REP(i, n - 1) {
		if (a[i] <= tmp) {
			if (tmp - a[i] < abs(tmp - m))m = a[i];
		}
		else {
			if (a[i] - tmp < abs(tmp + 1 - m))m = a[i];
		}
	}
	printf("%d %d\n", a[n-1],m);
}

Measured memory_bytes: 512
n, k = [int(i) for i in input().split()]
c = [0 for i in range(100000)]
for i in range(n):
    a, b = [int(i) for i in input().split()]
    c[a-1] += b
cnt = 0
for i in range(len(c)):
    cnt += c[i]
    if cnt >= k:
        print(i+1)
        break

Measured memory_bytes: 5896