akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N=INT()
T=LIST()
A=LIST()

# 累積MAXが変化するところは確定と言える
Hs1=[0]*N
Hs1[0]=T[0]
fixed=[False]*N
fixed[0]=True
for i in range(1, N):
    if T[i-1]!=T[i]:
        Hs1[i]=T[i]
        fixed[i]=True
Hs2=[0]*N
Hs2[-1]=A[-1]
fixed[-1]=True
for i in range(N-2, -1, -1):
    if A[i+1]!=A[i]:
        Hs2[i]=A[i]
        fixed[i]=True

for i in range(N):
    # 両者の確定箇所について矛盾がないか確認
    if Hs1[i]!=0 and Hs2[i]!=0 and Hs1[i]!=Hs2[i]:
        print(0)
        exit()
    if Hs1[i]!=0:
        if Hs1[i]>A[i]:
            print(0)
            exit()
    if Hs2[i]!=0:
        if Hs2[i]>T[i]:
            print(0)
            exit()
ans=1
for i in range(N):
    if not fixed[i]:
        # 未確定の場所について、低い方の数だけ可能性がある
        ans=(ans*min(T[i], A[i]))%MOD
print(ans)


Measured memory_bytes: 18752
#!/usr/bin/env python3

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, D = map(int, input().split())

count = 0
for i in range(N):
    x, y = map(int, input().split())
    if x ** 2 + y ** 2 <= D ** 2:
        count += 1

print(count)





Measured memory_bytes: 9188
def solve(string):
    n, *h = map(int, string.split())
    s = "".join(["1" if h0 >= h1 else "0" for h0, h1 in zip(h, h[1:])])
    return str(max(map(len, s.split("0"))))


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))


Measured memory_bytes: 15172
/*      Chill raho be kuch nhi rakha sadness me. 
               Author: Maskman_lucifer                   */
               
#include <bits/stdc++.h>   
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long 
#define pll pair<ll,ll>
#define pb push_back
#define M 1000000007
#define lc '\n'
using namespace std;
int main()
{
    IO
    ll n;
    cin>>n;
    ll a[n+1],dp[n+1];
    for(ll i=1;i<=n;i++)
    {
        cin>>a[i];
        dp[i]=0;
    }
    dp[1]=0;
    dp[2]=abs(a[2]-a[1]);
    for(ll i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n]<<lc;
    return 0;
}

Measured memory_bytes: 5188
#include<stdio.h>
int main(void){
  long long int n;
  scanf("%lld",&n);
  long long int a[n],i,j,b=0,s=0;
  for(i=0;i<n;i++){
  	scanf("%lld",&a[i]);
	b+=a[i];
  }
  b=b%1000000007;
  for(i=0;i<n;i++){
	b=b-a[i];
    b=(b+1000000007)%1000000007;
	s+=(a[i]*b)%1000000007;
    s=s%1000000007;
  }
  printf("%lld\n",s);
  
  return 0;
  
}


Measured memory_bytes: 3280
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int[] a = nextIntArray(sc, N);

		sc.close();

		Arrays.sort(a);
		int ans = 0;
		int p = 0;
		while (p < N) {
			int x = a[p];

			int q = p + 1;
			while (q < N && a[q] == x) {
				q++;
			}

			if (q < 0) {
				q = (-q) - 1;
			}

			if (x > q - p) {
				ans += (q - p);
			} else if (x < q - p) {
				ans += (q - p) - x;
			}

			p = q;
		}

		out.println(ans);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

	@SuppressWarnings("unused")
	private int[] nextIntArray(Scanner sc, int n) {
		int[] result = new int[n];
		for (int i = 0; i < n; i++) {
			result[i] = sc.nextInt();
		}
		return result;
	}
}


Measured memory_bytes: 49572
import java.util.*;
import java.math.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		long n = sc.nextLong();
		long a = sc.nextLong();
		long b = sc.nextLong();
		long c = sc.nextLong();
		long d = sc.nextLong();
		long e = sc.nextLong();

		long bottleNeck = 1000000000000000l;
		bottleNeck = Math.min(bottleNeck,a);
		bottleNeck = Math.min(bottleNeck,b);
		bottleNeck = Math.min(bottleNeck,c);
		bottleNeck = Math.min(bottleNeck,d);
		bottleNeck = Math.min(bottleNeck,e);


		System.out.println(5 + (n-1)/bottleNeck);

	}
}


Measured memory_bytes: 23764
n,m,x = map(int,input().split())

t = list(map(int,input().split()))

count1 = 0

count2 = 0

for i in range(x,n+1):
    if i in t:
        count1 += 1

for j in range(x, 0, -1):
    if j in t:
        count2 += 1
print(min(count1,count2))

Measured memory_bytes: 38384
n,m = map(int, input().split())

min_ = 1
max_ = 10**5
for i in range(m):
    l,r = map(int, input().split())
    min_ = max(min_, l)
    max_ = min(max_, r)

ans = max(0, max_ - min_ + 1)
print(ans)

Measured memory_bytes: 3060
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A + 1):
  for b in range(B + 1):
    q = (X - (a * 500 + b * 100)) / 50
    if q >= 0 and q <= C:
        ans += 1
print(ans)

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

const int INF = 1001001001;

int main(){
    int n, x, y;
    cin >> n >> x >> y;
    --x, --y;
    vector<int> ans(n);
    rep(sv, n){
        vector<int> dist(n, INF);
        queue<int> q;
        auto push = [&](int v, int d){
            if(dist[v] != INF) return;
            dist[v] = d;
            q.push(v);
        };
        push(sv, 0);
        while (!q.empty())
        {
            int v = q.front();
            q.pop();
            int d = dist[v];
            if(v - 1 >= 0) push(v - 1, d + 1);
            if(v + 1 < n) push(v + 1, d + 1);
            if(v == x) push(y, d + 1);
            if(v == y) push(x, d + 1);
        }
        rep(i, n) ans[dist[i]]++;
    }
    rep(i, n) ans[i] /= 2;
    for(int i = 1; i <= n - 1; i++){
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort(ALL(V)) //小さい方からソート
#define REV(V) reverse(ALL(V)) //リバース
#define RSORT(V) SORT(V);REV(V) //大きい方からソート
#define NPN(V) next_permutation(ALL(V)) //順列
#define pb(n) push_back(n)
#define endl '\n'
#define Endl '\n'
#define DUMP(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define RAPID cin.tie(0);ios::sync_with_stdio(false)
#define IN(n) cin >> n
#define IN2(a,b) cin >> a >> b
#define IN3(a,b,c) cin >> a >> b >> c 
#define VIN(V) for(int i = 0; i < (V).size(); i++) {cin >> (V).at(i);}
#define OUT(n) cout << n << endl
#define VOUT(V) REP(i, (V).size()) {cout << (V)[i] << endl;}
#define VOUT2(V) REP(i, (V).size()) {cout << (V)[i] << " ";} cout<<endl;

// 型マクロ定義
#define int long long
#define P pair<ll,ll>
#define Vi vector<ll>
#define Vd vector<double>
#define Vs vector<string>
#define Vc vector<char>
#define M map<ll,ll>
#define S set<ll>
#define PQ priority_queue<ll>
#define PQG priority_queue<ll,V,greater<ll>
//

const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);

int gcd(int a,int b){return b?gcd(b,a%b):a;} //最小公倍数

// デフォルト変数定義
int n,m,a,b,c,x,y,z;
double d,e,f;
string s,t;
//

signed main() {
  RAPID;
  IN(n);
  Vi A(n);
  VIN(A)
  Vi maxAr(n);
  maxAr = A;
  RSORT(maxAr);
  REP(i,n){
    if(maxAr.at(0) == A.at(i)) OUT(maxAr.at(1));
    else OUT(maxAr.at(0));
  }
}

Measured memory_bytes: 4736
#include <stdio.h>

int n,A[50];

int solve(int i , int m){
	if(m == 0)return 1;
	if(i >= n) return 0;
	int res = solve(i+1,m) || solve(i+1,m-A[i]);
	return res;
}

int main(void)
{
	int q , M , i;
	scanf("%d",&n);
	for( i = 0; i < n; i++) scanf("%d",&A[i]);
	scanf("%d",&q);
	for( i = 0; i < q; i++)
	{
		scanf("%d",&M);
		if(solve(0,M))printf("yes\n");
			else printf("no\n");
	}
		return 0;
}


Measured memory_bytes: 2036
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int main(void)
{
    string S, T;
    cin >> S >> T;

    int ans = 0;
    for (int i = 0; i < (int)S.size(); i++)
        if (S[i] == T[i])
            ans++;

    cout << ans << endl;

    return 0;
}


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

using namespace std;

int main()
{
	int x[15][15];
	int n,d;
	cin>>n>>d;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=d;j++)
		{
			cin>>x[i][j]; 
		}
	}
	int ans=0;
	for(int i=1;i<n;i++)
	{
		for(int k=i+1;k<=n;k++)
		{
			int dis=0;
			for(int j=1;j<=d;j++)
			{
				dis+=(x[i][j]-x[k][j])*(x[i][j]-x[k][j]);
			}
			if(sqrt(dis)==floor(sqrt(dis)))ans++;
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
    int n, q; cin >> n >> q;
    vector<vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int a, b; cin >> a >> b; a--, b--;
        g[a].emplace_back(b);
        g[b].emplace_back(a);
    }
    vector<int> val(n);
    while (q--) {
        int p, x; cin >> p >> x; p--;
        val[p] += x;
    }
    auto dfs = [&](auto dfs, int u, int p) -> void {
        for (int v: g[u]) if (v != p) {
            val[v] += val[u];
            dfs(dfs, v, u);
        }
    };
    dfs(dfs, 0, -1);
    for (int i = 0; i < n; i++) cout << val[i] << endl;
    return 0;
}

Measured memory_bytes: 21120
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 100000001;
ll t[100010][50];
const ll mod = 1000000007;
void ChocolateBar() {
	
	ll h, w;
	cin >> h >> w;
	if (h % 3 == 0 || w % 3 == 0) {
		cout << 0 << endl;
		return;
	}

	ll thh = h / 3;
	
	ll res = (thh + 1) * w - (thh) * w;

	ll whh = w / 3;
	res = min((whh + 1) * h - (whh) * h, res);


	ll minh = h / 2;
	for (ll i = 1; i < w; i++)
	{
		ll first = minh * (w - i);
		ll second = (h - minh) * (w - i);
		ll thr = i * h;

		res = min(res, max(first,max(thr,second)) - min(first , min(thr,second )));
	}

	ll minw = w / 2;
	for (ll i = 1; i < h; i++)
	{
		ll first = minw * (h - i);
		ll second = (w - minw) * (h - i);
		ll thr = i * w;
		res = min(res, max(first, max(thr, second)) - min(first, min(thr, second)));
	}
	cout << res << endl;
}

int main() {
	ChocolateBar();

	return 0;
}



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

int main(){
    ll N,K;
    string S;
    cin >> N >> K;
    ll x;
    if(N >= K){
        x = N;
    }else{
        x = K - N;
    }
    //vector<ll> A(N);
    ll q = x/K;
    ll r = x%K;
    cout << min(r, abs(K-r)) <<endl;;
}

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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int n ; cin >> n ;
    string a , b ;
    cin >> a >> b ;

    for ( int i=0 ; i < n ; i ++ )
        cout << a[i] << b[i] ;

    line
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int cnt = 0;

void insertionSort(int A[], int n, int g) {
  int i, j, v;

  for(i = g;i < n;i++) {
    v = A[i];
    j = i - g;

    while(j >= 0 && A[j] > v) {
      A[j + g] = A[j];
      j -= g;
      cnt++;
    }

    A[j + g] = v;
  }
}

void shellSort(int A[], int n) {
  int i, j, G[n], H[n];
  G[0] = 1;

  for(i = 1;G[i - 1] * 3 + 1 < n / 2;i++)
    G[i] = G[i - 1] * 3 + 1;

  for(j = 0;j < i;j++)
    H[j] = G[i - j - 1];

  for(j = 0;j < i;j++) {
    insertionSort(A, n, H[j]);
  }

  printf("%d\n", i);
  for(j = 0;j < i - 1;j++)
    printf("%d ", H[j]);
  printf("%d\n", H[j]);
  printf("%d\n", cnt);
  for(j = 0;j < n;j++)
    printf("%d\n", A[j]);
}

int main() {
  int n, i, A[1000000];

  scanf("%d", &n);
  for(i = 0;i < n;i++)
    scanf("%d", &A[i]);

  shellSort(A, n);
}



Measured memory_bytes: 5648
#include "iostream"
#include "algorithm"
#include "string"
#include "vector"
#include "cmath"
#include "bitset"
#include "queue"
#include "functional"
#include "map"
#include "unordered_map"
#include "set"
#include "stack"

#define lp(n) for (int i = 0; i < n; i++)
#define LP(n,i) for (int i = 0; i < n; i++)
#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nya_n "(=^･ω･^=)"
typedef long long ll;
using namespace std;

int n;
pair<int, int>x[100000], y[100000];
priority_queue<pair<int, pair<int, int>>, vector<pair<int, pair<int, int>>>, greater<pair<int, pair<int, int>>>>q;
pair<int, int>g[100000];
ll cnt;
pair<int, pair<int, int>>m;
int mf, ms;

int uf(int x) {
	while (g[x].first != x)
		x = g[x].first;
	return x;
}


int main() {
	cin >> n;
	lp(n) {
		cin >> x[i].first >> y[i].first;
		x[i].second = y[i].second = i;
	}
	sort(x, x + n);
	sort(y, y + n);
	lp(n - 1) {
		q.push(make_pair(x[i + 1].first - x[i].first, make_pair(x[i].second, x[i + 1].second)));
		q.push(make_pair(y[i + 1].first - y[i].first, make_pair(y[i].second, y[i + 1].second)));
	}
	lp(n) {
		g[i] = make_pair(i, 1);
	}
	cnt = 0;
	lp(n - 1) {
		do {
			m = q.top();
			q.pop();
			mf = uf(m.second.first);
			ms = uf(m.second.second);
		} while (mf == ms);
		cnt += m.first;
		if (g[mf].second >= g[ms].second) {
			g[mf].second += g[ms].second;
			g[ms].first = mf;
		}
		else {
			g[ms].second += g[mf].second;
			g[mf].first = ms;
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 6388
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(n); ++i)
#define repr(i, a, b) for (int i=a; i<(b); ++i)
#define reprev(i, n) for (int i=n-1; i>=0; --i)
#define reprrev(i, a, b) for (int i=b-1; i>=(a); --i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int N;
int ans = 0;
int sgs[3] = {3, 5, 7};

void dfs (ll S, vector<int> exist) {
    // Sを受け取って、自分が7, 5, 3を満たしていればans +=1
    // あとは下に3と5と7を足して、再帰
    // cout << S << endl;
    // rep(i, 3) cout << exist[i] << " ";
    // cout << endl;
    if (S > N) {
        // cout << S << " " << N << "return" << endl;
        return ;
    }
    if (accumulate(exist.begin(), exist.end(), 0) >= 3) {
        // cout << S << endl;
        // cout << endl;
        ans += 1;
    }

    rep(i, 3) {
        ll tS = S*10 + sgs[i];
        vector<int> texist = exist;
        texist[i] = 1;
        dfs(tS, texist);
    }
    return ;
}

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

    ll S = 0;
    vector<int> exist(3, 0);
    dfs(S, exist);

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

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer


object Main {

  def read() = {
    val sc = new Scanner(System.in)

    val n = sc.nextInt()
    val b = for (i <- 0 until n) yield sc.nextInt()
    (n, b)
  }


  def solve(n: Int, b: IndexedSeq[Int]): Option[IndexedSeq[Int]] = {
    val arrb = ArrayBuffer.empty[Int]
    arrb.append(-100)//ダミー (1originにするため)
    for (be <- b){
      arrb.append(be)
    }
    val removingIdxArr = ArrayBuffer.empty[Int]
    for(i <- 0 until n){
      val removableIdxList = (1 until arrb.length).filter(k => arrb(k) == k)
      if(removableIdxList.isEmpty){
        return None
      }
      val removingIdx = removableIdxList.max
      arrb.remove(removingIdx)
      removingIdxArr.append(removingIdx)
    }
    Some(removingIdxArr.reverse.toIndexedSeq)
  }

  def output(result: Option[IndexedSeq[Int]]): Unit ={
    result match{
      case Some(seq) => seq.foreach(println)
      case None => println(-1)
    }
  }

  def main(args: Array[String]): Unit = {
    val (n, b) = read()
    output(solve(n,b))
  }
}

Measured memory_bytes: 25412
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#include <cstdio>
#include <vector>
#include <string>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>
using namespace std;

#define eps 1e-8
#define pb push_back
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define clr(a,b) memset(a,b,sizeof(a)
#define FAST_IO ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

const int N=1e5+10;
typedef long long ll;
typedef unsigned long long ull;
ll a[N];

int main(){
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%lld",&a[i]);
    sort(a+1,a+1+n);
    int l=1,r=n;
    ll ans1=0,ans2=0;
    for(int i=1;i<n-1;i++){
        ans1+=abs(a[r]-a[l]);
        if(i%2) r--;
        else l++;
    }
    l=1;r=n;
    for(int i=1;i<n-1;i++){
        ans2+=abs(a[r]-a[l]);
        if(i%2) l++;
        else r--;
    }
    if(n%2){
        int id=n/2+1;
        ans1=ans1+max(abs(a[n]-a[id]),abs(a[id-1]-a[id]));
        ans2=ans2+max(abs(a[1]-a[id]),abs(a[id+1]-a[id]));
    }
    else{
        int id=n/2;
        ans1=ans1+max(abs(a[n]-a[id]),abs(a[id+1]-a[id]));
        id++;
        ans2=ans2+max(abs(a[1]-a[id]),abs(a[id-1]-a[id]));
    }
    printf("%lld\n",max(ans1,ans2));
    return 0;
}


Measured memory_bytes: 1024
def main():
    A, B, C, X, Y = list(map(int, input().split(' ')))
    p1 = A * X + B * Y
    p2 = 2 * C * X + B * max([0, Y - X])
    p3 = 2 * C * Y + A * max([0, X - Y])
    p4 = 2 * C * max([X, Y])
    print(min([p1, p2, p3, p4]))


if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using pll = pair<long long, long long>;

int main(){
    int N,M; cin >> N >> M;
    vector<long long> A(N),B(M),C(M);
    for(int i = 0; i < N; i++) cin>> A[i];
    sort(A.begin(),A.end());
    for(int i = 0; i < M; i++) cin >> B[i] >> C[i];
    
    // Cをソート(Bをまとめて)
    vector<int> id(M);
    iota(id.begin(),id.end(),0);
    sort(id.begin(),id.end(),[&](int i, int j){return C[i] > C[j];});
    
    //A(小さい順)とC(大きい順)とを比べて大きい方を足していく
    long long sum = 0;
    long long K = 0;
    for(auto i:id){
        for(int j = 0; j < B[i]; j++){
            if(K >= N)break;
            sum += max(A[K++],C[i]);
        }
    }
    for(int i = K; i < N; i++) sum += A[i];
    cout << sum << endl;
    
    
    
}


Measured memory_bytes: 5876
N, K = map(int, input().split())
A = map(int, input().split())
dic = {}
for a in A:
    if a in dic:
        dic[a] += 1
    else:
        dic[a] = 1

dic_sort = sorted(dic.values(), reverse=True)
cnt = 0
result = 0
for v in dic_sort:
    cnt += 1
    if cnt <= K:
        continue
    result += v

print(result)


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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define chmin(a,b) (a)=min((a),(b));
#define chmax(a,b) (a)=max((a),(b));
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(v) cout<<(#v)<<":";for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;
#define printVS(vs) cout<<(#vs)<<":"<<endl;for(auto(s):(vs)){cout<<(s)<< endl;}
#define printVV(vv) cout<<(#vv)<<":"<<endl;for(auto(v):(vv)){for(auto(x):(v)){cout<<" "<<(x);}cout<<endl;}
#define printP(p) cout<<(#p)<<(p).first<<" "<<(p).second<<endl;
#define printVP(vp) cout<<(#vp)<<":"<<endl;for(auto(p):(vp)){cout<<(p).first<<" "<<(p).second<<endl;}

inline void output(){ cout << endl; }
template<typename First, typename... Rest>
inline void output(const First& first, const Rest&... rest) {
    cout << first << " "; output(rest...);
}

using ll = long long;
using Pii = pair<int, int>;
using TUPLE = tuple<int, int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
const int inf = 1ll<<60;
const int mod = 1e9 + 7;
using Graph = vector<vector<int>>;

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

    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];

    vi s(n + 1), p(n + 1);
    rrep(i, n) {
        s[i] += a[i] + s[i + 1];
        p[i] += max(0ll, a[i]) + p[i + 1];
    }

    int ans = -inf;
    rep(i, n - k + 1) {
        chmax(ans, p[0] - p[i] + p[i + k] + max(0ll, s[i] - s[i + k]));
    }

    cout << ans << endl;
}


Measured memory_bytes: 2560
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    sort(h.begin(), h.end());
    int ans = 1e9;
    rep(i,n-k+1){
        chmin(ans, h[i+k-1] - h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define mod 1000000007
#define inf 1e18+42
#define endl "\n"
#define pi 3.1415926535897932384626433832795028841971693993751058
#define maxn 100005

#define out1(a) cout<<#a<<" "<<a<<endl
#define out2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define out3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl

#define rep(i,a,b) for(int i=a;i<b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#define fori(it,A) for(auto it=A.begin();it!=A.end();it++)

#define ft first
#define sd second
#define pb push_back
#define mp make_pair
#define pq priority_queue
#define all(x) (x).begin(),(x).end()
#define zero(x) memset(x,0,sizeof(x));
#define ceil(a,b) (a+b-1)/b
 
using namespace std;

int binpow(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

//START OF CODE ->->->->->->->

void solve()
{
    int a,b,c;
    cin>>a>>b>>c;
    int k;
    cin>>k;
    int cnt = 0;
    while ( b <= a ){
        b *= 2;
        cnt++;
    }
    if ( k < cnt ){
        cout<<"No"<<endl;
    }
    else{
        k -= cnt;
        cnt = 0;
        while ( c <= b ){
            c *= 2;
            cnt++;
        }
        if ( k < cnt ){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
}

//END OF CODE ->->->->->->->->

signed main()
{
    fast;
    int t = 1;
    // cin>>t;

    while(t--)
    {
        solve();
    }
    return 0;
}



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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long

int main() {
    fastio;
    int n;
    cin >> n;
    if (n < 2) cout << 1;
    else if (n < 4) cout << 2;
    else if (n < 8) cout << 4;
    else if (n < 16)cout << 8;
    else if (n < 32) cout << 16;
    else if (n < 64) cout << 32;
    else cout << 64;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  
  int p[n],i,A=0,B=0,C=0;
  for(i+0;i<n;i++) {
    scanf("%d",&p[i]);
if(p[i]<=a) A++;
  else if((a+1<=p[i]) && (p[i]<=b)) B++;
  else C++;
  }
  
  if((A<=B)&&(A<=C)) printf("%d",A);
  else if((B<=A)&&(B<=C)) printf("%d",B);
  else printf("%d",C);
}


Measured memory_bytes: 128
N,M = map(int, input().split())
H = list(map(int, input().split()))

highest = [0] * N

for i in range(M):
    a, b = map(int, input().split())
    highest[a-1] = max(highest[a-1], H[b-1])
    highest[b-1] = max(highest[b-1], H[a-1])

ans = 0
for i in range(N):
    if H[i] >highest[i]:
        ans += 1


print(ans)

Measured memory_bytes: 20116
#include "bits/stdc++.h"
using namespace std;
typedef tuple<double,double,double> T;
int main() {
	int N,M;
	scanf("%d %d",&N,&M);
	vector<T> v;
	for(int i=0;i<N;i++) {
		double L,a,b;
		scanf("%lf %lf %lf",&L,&a,&b);
		v.push_back(make_tuple(L,a,b));
	}
	double ans=0;
	for(int i=0;i<(1<<N);i++) {
		int bit=0;
		double sum=0;
		for(int j=0;j<N;j++) if(i&(1<<j)) bit++;
		if(bit!=M) continue;
		for(int j=0;j<N;j++) {
			if(!(i&(1<<j))) continue;
			for(int k=j+1;k<N;k++) {
				if(!(i&(1<<k))) continue;
				sum+=pow(get<0>(v[j])-get<0>(v[k]),2)+pow(get<1>(v[j])-get<1>(v[k]),2)+pow(get<2>(v[j])-get<2>(v[k]),2);
			}
		}
		ans=max(ans,sum);
	}
	printf("%.15lf\n",ans);
}

Measured memory_bytes: 3220
function main(arg) {
	arg  = arg.split("\n")
	var s = arg[0]
	var t = arg[1]

	while (1) {
		if (s === "") {
			break
		} 

		s = s.split(s[0]).join("")
		t = t.split(t[0]).join("")

		if (s.length !== t.length) {
			console.log('No')
			return;
		}
	}
	console.log('Yes')
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 24780
#include <vector>
#include <iostream>
#include <string>
#include <map>
#include <algorithm>
#include <set>
#include <queue>
#include <cstdio>
#include <utility>
#include <bitset>
#include <complex>
#include <stack>
#include <tuple>

using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const ll INF = 1e7;
int main(){
	ll N,Ma,Mb;
	cin >> N >> Ma >> Mb;
	vector<vector<ll>> dp(N*10+1,vector<ll>(N*10+1,INF));
	dp[0][0]=0;
	for(int i=0;i<N;i++){
		ll a,b,c;
		cin >> a >> b >> c;
		for(int l=(ll)dp.size()-a-1;l>=0;l--){
			for(int r=dp[l].size()-b-1;r>=0;r--){
				dp[l+a][r+b]=min(dp[l+a][r+b], dp[l][r]+c);
			}
		}
	}
	ll ans=INF;
	for(ll i=1;i*Ma<dp.size() && i*Mb<dp.size();i++)
		ans=min(ans,dp[i*Ma][i*Mb]);
	if(ans==INF)
		cout << -1 << endl;
	else
		cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1536
n = int(input())
p = list(map(float, input().split()))
q=[]
q.append([1])
for i in range(n):
    q[0].append(0)
prod = 1.0
for i in range(1,n+1):
    prod*=p[i-1]
    q.append([prod])

for i in range(1,n+1):
    for j in range(1,n+1):
        try:
            q[i].append(p[i-1]*q[i-1][j] + (1-p[i-1])*q[i-1][j-1])
        except:
            print(i)
            print(j)
        #print(q)
ans = 0.0
for i in range(0,(n-1)//2+1):
    ans+=q[n][i]
print(ans)


Measured memory_bytes: 113244
#include <stdio.h>

int main()
{
    int n;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    int i;
    int E = 0;
    for(i=0;i<n;i++) if(s[i]=='E') E += 1;
    int e_array[n];
    e_array[0] = 0;
    for(i=1;i<n;i++){
        e_array[i] = e_array[i-1];
        if(s[i-1]=='E') e_array[i] += 1;
    }
    int count[n];
    if(s[0]=='E') count[0] = E - 1;
    else count[0] = count[0] = E;
    if(s[n-1]=='E') count[n-1] = n - E;
    else count[n-1] = n - E - 1;
    for(i=1;i<n-1;i++){
        if(s[i]=='E') count[i] = (i - e_array[i]) + (E - e_array[i] - 1);
        else count[i] = (i - e_array[i]) + (E - e_array[i]);
    }
    int min = count[0];
    for(i=1;i<n;i++) if(min>count[i]) min = count[i];
    printf("%d", min);
    // for(i=0;i<n;i++) printf("%d,", count[i]);
    
    return 0;
}

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

#define ln                 '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fm, to)    for (int i = fm; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 2e3;
const int inf = 0x3f3f3f3f;
int n, a[3 * nsz + 5], f[nsz + 5][nsz + 5], mx[nsz + 5], maxi, ans;

struct value {
	int a, b, val;
	
	value() {}
	value(int a, int b, int val) {
		this->a = a, this->b = b, this->val = val;
	}
};
vector<value> dat;

bool inline all_same(int a, int b, int c) {
	return a == b && b == c;
}

void inline upd(int a, int b, int val) {
	dat.push_back({a, b, val});
}

void inline upd_all() {
	for (auto&[a, b, val] : dat) {
		f[a][b] = max(f[a][b], val);
		f[b][a] = max(f[b][a], val);
		mx[a] = max(mx[a], val);
		mx[b] = max(mx[b], val);
		maxi = max(maxi, val);
	}
	dat.clear();
}

int main() {
	scanf("%d", &n);
	cont (i, n * 3) scanf("%d", &a[i]);
	memset(f, -inf, sizeof(f));
	memset(mx, -inf, sizeof(mx));
	maxi = -inf;
	upd(a[1], a[2], 0);
	upd_all();
	loop (rnd, n) {
		int i = rnd * 3 + 3;
		sort(a + i, a + i + 3);
		if (a[i] == a[i + 2]) { ans += 1; continue; }
		upd(a[i + 0], a[i + 1], maxi);
		upd(a[i + 0], a[i + 2], maxi);
		upd(a[i + 1], a[i + 2], maxi);
		cont (k, n) {
			upd(a[i + 0], a[i + 1], f[k][k] + all_same(k, k, a[i + 2]));
			upd(a[i + 0], a[i + 2], f[k][k] + all_same(k, k, a[i + 1]));
			upd(a[i + 1], a[i + 2], f[k][k] + all_same(k, k, a[i + 0]));
		}
		cont (k, n) {
			upd(k, a[i + 0], mx[k]);
			if (a[i + 1] == a[i + 2]) upd(k, a[i + 0], f[k][a[i + 1]] + 1);
			upd(k, a[i + 1], mx[k]);
			if (a[i + 0] == a[i + 2]) upd(k, a[i + 1], f[k][a[i + 0]] + 1);
			upd(k, a[i + 2], mx[k]);
			if (a[i + 0] == a[i + 1]) upd(k, a[i + 2], f[k][a[i + 0]] + 1);
		}
		upd_all();
	}
	ans += maxi;
	printf("%d\n", ans);
}

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

int main(){
	int n,k;
	cin >> n >> k;
	
	int snuke[n]={0};
	
	for(int i=0;i<k;i++){
		int d;
		cin >>d;
		for(int j=0;j<d;j++){
			int tp;
			cin>>tp;
			snuke[tp-1]++;
		}
	}
	
	int cnt=0;
	for(int i=0;i<n;i++){
		if(snuke[i]==0) cnt++;
	}
	cout << cnt << endl;
	
}

Measured memory_bytes: 3588
import java.util.*;

public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        boolean[] sosu = new boolean[123456*2+1];
        Arrays.fill(sosu, true);
        sosu[0]=false;
        sosu[1]=false;
        for(int i=2;i<123456*2;i++){
            if(sosu[i]){
                for(int j=2;i*j<123456*2+1;j++){
                    sosu[i*j]=false;
                }
            }
        }
        while(true){
            int n = sc.nextInt();            
            if(n==0)break;
            int count=0;
            for(int i=n+1;i<n*2+1;i++){
                if(sosu[i]){
                    count++;
                }else{
                    continue;
                }
            }
            System.out.println(count);
        }
        
    }
}

Measured memory_bytes: 20808
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
constexpr int INF = 2000000000;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
# define ALL(x)     (x).begin(),(x).end()
# define UNIQ(c)    (c).erase(unique(ALL((c))), end((c)))
# define mp         make_pair
# define eb         emplace_back
# define FOR(i,a,b) for(int i=(a);i<(b);++i)
# define REP(i,n)   FOR(i,0,n)
# define INIT       std::ios::sync_with_stdio(false);std::cin.tie(0);

int trimos[5050][5050];

int main() {
	int n, m;
	cin >> n >> m;
	int a, b, c;
	for (int i = 0; i < m; i++) {
		cin >> a >> b >> c;
		c++;
		trimos[a][b]++;
		trimos[a][b + 1]--;
		trimos[a + c][b]--;
		trimos[a + c + 1][b + 1]++;
		trimos[a + c][b + c + 1]++;
		trimos[a + c + 1][b + c + 1]--;
	}
	for (int i = 1; i <= n + 1; i++) {
		for (int j = 1; j <= n + 1; j++) {
			trimos[i][j] += trimos[i][j - 1];
		}
	}
	for (int i = 1; i <= n + 1; i++) {
		for (int j = 1; j <= n + 1; j++) {
			trimos[i][j] += trimos[i - 1][j - 1];
		}
	}
	for (int i = 1; i <= n + 1; i++) {
		for (int j = 1; j <= n + 1; j++) {
			trimos[i][j] += trimos[i - 1][j];
		}
	}
	int ans = 0;
	for (int k = 0; k <= n; k++) {
		for (int j = 0; j <= n; j++) {
			//cout << trimos[k][j] << " ";
			if (trimos[k][j])ans++;
		}
		//cout << endl;
	}
	//system("pause");
	cout << ans << endl;
}

Measured memory_bytes: 101768
from itertools import product
N, M = map(int, input().split())
denkyu = [[int(x) for x in input().split()] for _ in range(M)]
P = [int(x) for x in input().split()]
L = list(product([0,1], repeat = N))
ans = 0
for i in L:
    den = 0
    for j in range(M):
        count = 0
        for k in range(denkyu[j][0]):
            if i[denkyu[j][k+1]-1] == 0:
                count += 1
        if count % 2 == P[j]:
           den += 1 
    if den == M:
        ans += 1
print(ans) 

Measured memory_bytes: 3188
class UnionFind(object):

    def __init__(self, n):
        # 親のnodeを表す
        self.par = [i for i in range(n)]

    def root(self, x):
        if self.par[x] == x:
            return x
        else:
            # 経路圧縮
            self.par[x] = self.root(self.par[x])
            return self.par[x]

    def same(self, x, y):
        return self.root(x) == self.root(y)

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        self.par[x] = y


class UnionFindRank(UnionFind):

    def __init__(self, n):
        UnionFind.__init__(self, n)

        self.rank = [0 for _ in range(n)]

    def union(self, x, y):
        x = self.root(x)
        y = self.root(y)
        if x == y:
            return

        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

def _abc049_d():
    """連結"""

    N, K, L = list(map(int, input().split(' ')))
    ur = UnionFindRank(N)
    for _ in range(K):
        p, q = list(map(int, input().split(' ')))
        p -= 1
        q -= 1
        ur.union(p, q)

    ut = UnionFindRank(N)
    for _ in range(L):
        r, s = list(map(int, input().split(' ')))
        r -= 1
        s -= 1
        ut.union(r, s)

    def _id(r, t):
        return r * 1e8 + t

    from collections import defaultdict
    d = defaultdict(int)

    ids = []
    for i in range(N):
        __id = _id(ur.root(i), ut.root(i))
        d[__id] += 1
        ids.append(__id)

    for i in range(N):
        print(d[ids[i]], end=' ')

_abc049_d()

Measured memory_bytes: 46432
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


n, k = MI()
if k == 1:
    print(0)
else:
    print(n - k)


Measured memory_bytes: 67180
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	var n, m = nextInt(), nextInt()
	m += n * 3
	fmt.Println(m / 2)
}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
#include<numeric>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);

ll mod_pow(ll a, ll n, ll m = mod) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }
const int max_n = 10000;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}

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

void solve() {
	int a, b, c, d; cin >> a >> b >> c >> d;
	int id = 0;
	while (true) {
		if (id == 0) {
			c -= b;
			if (c <= 0) {
				cout << "Yes\n"; return;
			}
		}
		else {
			a -= d;
			if (a <= 0) {
				cout << "No\n"; return;
			}
		}
		id ^= 1;
	}
}


signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init_f();
	//init();
	//experi();
	//int t; cin >> t; rep(i, t)solve();
	solve();
	stop
		return 0;
}

Measured memory_bytes: 3812
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;
using static System.Array;

class Program
{
    public static void Main()
    {
        var n = int.Parse(ReadLine());
        WriteLine(n * 800 - n / 15 * 200);
    }
}

Measured memory_bytes: 17544
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

s = input()

temp1 = int(s[0:2])
temp2 = int(s[2:4])

if temp1 >= 1 and temp1 <= 12:
    if (temp2 < 1 or temp2 > 12):
        print("MMYY")
    else:
        print("AMBIGUOUS")
else:
    if (temp2 >= 1 and temp2 <= 12):
        print("YYMM")
    else:
        print("NA")


Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    /* ll t;
    cin>>t;
    while(t--) */
    {
        ll i,j,k,l,m,n,a,b,c,d,cnt=0,p,q;
        cin>>n>>k;
        map <int,int> mp;
        for(i=0;i<k;i++)
        {
            cin>>m;
            for(j=0;j<m;j++)
            {
                cin>>a;
                mp[a]++;
            }


        }
        for(i=1;i<=n;i++)
        {
            if(mp[i]==0)
                cnt++;
        }
        cout<<cnt<<endl;



    }
}


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

int main() {

    int a, b, c, tmp;

    cin >> a >> b >> c;

    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }

    if (b > c) {
        tmp = b;
        b = c;
        c = tmp;
    }

    if (a > b) {
        tmp = a;
        a = b;
        b = tmp;
    }

   cout << a << " " << b << " " << c << endl;

}



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

#define int long long
typedef pair <int, int> pii;
const int maxn = 1e5 + 5, mod = 1e9 + 7, inf = 2e18;
int V[2 * maxn], U[2 * maxn], W[2 * maxn], ta[maxn], tb[maxn], dista[maxn], distb[maxn];
vector <int> adj[maxn];

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	int s, t;
	cin >> s >> t;
	s--;
	t--;
	for (int i = 0; i < m; i++) {
		cin >> V[i] >> U[i] >> W[i];
		V[i]--;
		U[i]--;
		adj[V[i]].push_back(i);
		adj[U[i]].push_back(i);
	}
	fill(dista, dista + maxn, inf);
	set <pii> S;
	S.insert(pii(0, s));
	dista[s] = 0;
	ta[s] = 1;
	while (S.size()) {
		pii P = *S.begin();
		S.erase(S.begin());
		int v = P.second;
		for (auto e: adj[v]) {
			int u = v ^ V[e] ^ U[e];
			if (dista[v] + W[e] > dista[u]) continue;
			if (dista[v] + W[e] == dista[u]) {
				ta[u] = (ta[u] + ta[v]) % mod;
			}
			else {
				S.erase(pii(dista[u], u));
				ta[u] = ta[v];
				dista[u] = dista[v] + W[e];
				S.insert(pii(dista[u], u));
			}
		}
	}
	fill(distb, distb + maxn, inf);
	S.insert(pii(0, t));
	distb[t] = 0;
	tb[t] = 1;
	while (S.size()) {
		pii P = *S.begin();
		S.erase(S.begin());
		int v = P.second;
		for (auto e: adj[v]) {
			int u = v ^ V[e] ^ U[e];
			if (distb[v] + W[e] > distb[u]) continue;
			if (distb[v] + W[e] == distb[u]) {
				tb[u] = (tb[u] + tb[v]) % mod;
			}
			else {
				S.erase(pii(distb[u], u));
				tb[u] = tb[v];
				distb[u] = distb[v] + W[e];
				S.insert(pii(distb[u], u));
			}
		}
	}
//	cout << dista[t] << ' ' << distb[s] << ' ' << ta[t] << ' ' << tb[s] << endl;
	int ans = ta[t] * tb[s] % mod;
	for (int i = 0; i < n; i++) {
		if (dista[i] == distb[i] && 2 * dista[i] == dista[t]) {
			ans = (ans - ta[i] * ta[i] % mod * tb[i] % mod * tb[i] % mod + mod) % mod;
		}
	}
	for (int i = 0; i < m; i++) {
		if (dista[V[i]] > dista[U[i]]) swap(V[i], U[i]);
		if (dista[V[i]] + W[i] != dista[U[i]]) continue;
		if (distb[U[i]] + W[i] != distb[V[i]]) continue;
		if (dista[V[i]] + W[i] + distb[U[i]] != distb[s]) continue;
		if (2 * dista[V[i]] < dista[t] && 2 * distb[U[i]] < dista[t]) {
			ans = (ans - ta[V[i]] * ta[V[i]] % mod * tb[U[i]] % mod * tb[U[i]] % mod + mod) % mod;
		}
	}
	cout << ans;
}


Measured memory_bytes: 25452
import java.util.*

fun main(args: Array<String>) {
    val scn = Scanner(System.`in`)
    val N = scn.nextInt()

    var result = true
    for(i in 1..N){
        val A = scn.nextInt()

        if(A%2==0){
            if(A%3!=0 && A%5!=0){
                result=false
            }
        }
    }

    if(result){
        println("APPROVED")
    }else{
        println("DENIED")
    }

}

Measured memory_bytes: 31392
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <ctime>
#include <algorithm>
#include <sstream>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <cstdlib>
#include <cstdio>
#include <iterator>
#include <functional>
#include <unordered_set>
#include <unordered_map>
#include <stdio.h>
#include <bitset>
using namespace std;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define pii pair<int, int>
#define vi vector<int>
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
 
typedef long long ll;
typedef short inth;
 
const int N = 1;
const int M = N + 7;
const int MOD = 1e9 + 7;
const ll INF = 1e16 + 17;

int rat[] = {1800, 1600, 1400, 1200, 1000, 800, 600, 400};
int ans[] = {1, 2, 3, 4, 5, 6, 7, 8};

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 0; i < 8; ++i) {
        if (n >= rat[i]) {
            printf("%d", ans[i]);
            return 0;
        }
    }
    return 0;
}

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

xi = [abs(xval - x) for xval in xi]

def gcd(a, b):
    if a == 0:
        return b
    elif b == 0:
        return a
    else:
        return gcd(b, a%b)

res = xi[0]
for i in range(1, len(xi)):
    res = gcd(res, xi[i])

print(res)

Measured memory_bytes: 19996
import java.util.Scanner;

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

	int N;   //経路数
	int T;   //最大時間

	N = scan.nextInt();
	T = scan.nextInt();

	int[] c = new int[N];   //コスト
	int[] t = new int[N];   //時間

	for(int i = 0; i < N; i++){
	    c[i] = scan.nextInt();
	    t[i] = scan.nextInt();
	}

	int min = 1001;   //最小コスト(初期値は境界の値)

	for(int i = 0; i < N; i++){
	    if(t[i] <= T){
		if(c[i] < min){
		    min = c[i];
		}
	    }
	}

	//最小経路が更新された場合
	if(min < 1001){
	    System.out.println(min);
	}else{
	    System.out.println("TLE");
	}
    }
}
	    


Measured memory_bytes: 25172
from collections import deque
n,m = map(int,input().split())
L =[list(map(int, input().split())) for _ in range(m)]
#print(L)
cnt = 0
for i in range(m):
    G = [[] for _ in range(n)]
    
    for j in range(m):
        if i == j:
            continue
        a,b = L[j][0],L[j][1]
        #print(a-1,b-1)
        G[a-1].append(b-1)
        G[b-1].append(a-1)
    #print(G)
    Q = deque()
    Q.append(0)
    visited = [0]*n
    visited[0] = 1
    while Q:
        q = Q.pop()
        for g in G[q]:
            if visited[g] == 0:
                visited[g] = 1
                #print(visited)
                Q.append(g)

    if 0 in visited:
        cnt +=1
print(cnt)

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

typedef long long ll;
typedef unsigned long long ull;
typedef string st;
typedef double db;
typedef vector<long long> vecll;
typedef vector<char> vechar;

int main(){
    st s;
    cin >> s;
    s.at(3) = '8';
    cout << s << endl;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
text=input()

num=0
f=1
for i in range(n):
  alp=text[i]
  if alp=='a' and num<(a+b):
    print("Yes")
    num+=1
  elif alp=='b' and num<(a+b) and f<=b:
    print("Yes")
    num+=1
    f+=1
  else:
    print("No")


Measured memory_bytes: 9168