akhauriyash/Code-Regression huggingface dataset:
N_str = input()
N_int = int(N_str)

l = len(N_str)
N_list = []
for k in range(l):
    N_list.append( int(N_str[k]) )

Sn = sum(N_list)

# print('l=',l)
# print('N_list=',N_list)
# print('Sn=',Sn)
# print('amari=',N_int%Sn)

if N_int%Sn==0:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
    using namespace std;
    typedef long long ll;

    void solve() {
        string s;
        cin >> s;
        s = '0'+s;
        ll cnt = 0, c = 0;
        for(ll i = s.length() - 1; i >= 0; i--){
            ll val = (s[i] - '0') + c;
            cnt+= min(val, 10 - val);
            c = (val > 5 || (val == 5 && s[i-1] >= '5'));
        }
        cout << cnt + c<< endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      //ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


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

int main(){
	/*input*/
	int n;	cin >> n;
	vector<char>s(n);
	for(int i = 0; i < n; i++){
		cin >> s[i];
	}
	/*calculation*/
	int ans = 0;
	for(int i = 0; i < n; i++){
		int tmp = 0;
		vector<char>x(1, s[0]);
		for(int j = 0; j <= i; j++){	//Xを決めていく
			bool flag = true;	//true:異なる
			for(int k = 0; k < x.size() && flag; k++){
				if(s[j] == x[k])flag = false;
			}
			if(flag)x.push_back(s[j]);
		}
		for(int j = 0; j < x.size(); j++){
			for(int k = i + 1; k < n; k++){
				if(x[j] == s[k]){
					tmp++;
					break;
				}
			}
		}
		if(ans < tmp)ans = tmp;
	}
	/*output*/
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define N 15000001
bool check(ll mid)
{
     ll temp = floor(log10(mid) + 1);
 return temp%2;
}
int main()
{
   ll n;
   cin>>n;
   ll ans=0;
   for(ll i=1;i<=n;i++)
   {
        if(check(i))  ans++;
   }
   cout<<ans;
}

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

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

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

  int ans = 0;
  int cnt[3] = {0, 1, 0};
  for (int i = 0; i < N;) {
    int val = a[i];
    while (i + 1 < N && a[i + 1] - val <= 1) {
      if (a[i + 1] == val) cnt[1]++;
      else cnt[2]++;
      i++;
    }
    ans = max(ans, cnt[0] + cnt[1] + cnt[2]);
    if (cnt[2] == 0) {
      cnt[0] = 0;
      cnt[1] = 1;
      i++;
    } else {
      cnt[0] = cnt[1];
      cnt[1] = cnt[2];      
    }
    cnt[2] = 0;
  }

  cout << ans << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define PI (acos(-1))

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;
}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e15;

template <class T>
T gcd(T a,T b) {
	if (b==0) return a;
	else return gcd(b,a%b);
}

template <class T>
T lcm(T a,T b){
	return a*(b/gcd(a,b));
}

ll I=1;

struct SegmentTree{
private:
	vector<ll> node;
	int n;

public:
	SegmentTree(){
		int sz=100010;
		n=1;
		//要素数を2のべき乗にする
		while(n<sz) n*=2;
		rep(i,2*n-1) node.push_back(I);//全ての要素をinfで初期化
	}

	//k番目の値をaに変更する
	void update(int k,ll a){
		k+=n-1;
		node[k]=a;
		while(k>0){
			k=(k-1)/2;
			node[k]=gcd(node[2*k+1],node[2*k+2]);
		}
	}

	//[a,b)の最小値を求める,find(a,b+1)でよぶ
	ll find(int a,int b,int k=0,int l=0,int r=-1){
		if(r<0) r=n;
		if(r<=a || b<=l) return I;
		if(a<=l && r<=b) return node[k];
		else{
			ll vl=find(a,b,2*k+1,l,(l+r)/2);
			ll vr=find(a,b,2*k+2,(l+r)/2,r);
			return gcd(vl,vr);
		}
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<ll> a(n);
	rep(i,n){
		cin>>a[i];
		I=lcm(I,a[i]);
	}
	SegmentTree seg;
	rep(i,n){
		seg.update(i,a[i]);
	}
	ll ans=0;
	rep(i,n){
		seg.update(i,I);
		chmax(ans,seg.find(0,n));
		seg.update(i,a[i]);
	}
	cout<<ans<<endl;
}

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

int x,y,z,ar[100005],n,m;
char tmp;
string s1;

int main() {
	cin >> s1;
	tmp = '#';
	for (char c : s1) {
		if (c != tmp) {
			tmp = c;
			n++;
		}
	}
	cout << n-1;
}

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

signed main() {
  int N;
  cin >> N;
  vector<int> p(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    p[i]--;
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (p[i] == i) {
      if (i == 0) {
        swap(p[i], p[i + 1]);
        ans++;
      } else if (i == N - 1) {
        swap(p[i], p[i - 1]);
        ans++;
      } else {
        if (p[i - 1] == i - 1) {
          swap(p[i], p[i - 1]);
          ans++;
        } else if (p[i + 1] == i + 1) {
          swap(p[i], p[i + 1]);
          ans++;
        } else {
          swap(p[i], p[i + 1]);
          ans++;
        }
      }
    }
  }

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

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,b,c;
    cin>>n>>a>>b>>c;
    vector<int> l(n);
    rep(i,n) cin>>l[i];
    int ans=1e5;
    rep(i,1<<n)rep(j,1<<n){
      int A=0,B=0,C=0;
      int mp=0;
      rep(k,n){
        if(i&(1<<k)){
          mp+=10;
          if(j&(1<<k)) A+=l[k];
          else B+=l[k];
        }else{
          if(j&(1<<k)){
            C+=l[k];
            mp+=10;
          }
        }
      }
      if(A==0 || B==0 || C==0) continue;
      mp+=abs(A-a)+abs(B-b)+abs(C-c)-30;
      //cout<<mp<<endl;
      ans=min(ans,mp);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e8;
const int MX = 100001; //check the limits, dummy

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

    ll h, n; cin >> h >> n;
    vector<int> a(n);
    vector<int> b(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
        cin >> b[i];
    }

    vector<ll> dp(h + 1, inf + 1);
    dp[0] = 0;
    for(int i = 0; i < n; i++)
        for(int j = 0; j <= h; j++)
            dp[j] = min(dp[j], b[i] + dp[max(0, j - a[i])]);

    cout << dp[h] << endl;
}

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

using namespace std;

#define llong long long 
#define len(v) ((int)v.size())
#define ii pair<int, int>
#define xx first
#define yy second
#define rep(i,n) for (int i = -1; ++i < n; )
#define rep1(i,n) for (int i = 0; ++i <= n;)

#define maxn 101010
int n, k;
int a[maxn];

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  cin >> n >> k;
  rep(i, n) cin >> a[i];
  int g = a[0];
  rep1(i, n - 1) g = __gcd(g, a[i]);

  rep(i, n) {
    if (a[i] >= k and (a[i] - k) % g == 0) {
      cout << "POSSIBLE";
      exit(0); 
    }
  }

  cout << "IMPOSSIBLE";

  return 0;
}


Measured memory_bytes: 640
extern crate core;

use std::io::{self, Read};

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = run(input.trim().to_string());
    println!("{}", output);
}

fn run(input: String) -> String {
    let mut iter = input.split("\n").map(|x| {
        let v = x.split_whitespace()
            .map(|x| x.parse::<i64>().unwrap())
            .collect::<Vec<_>>();
        (v[0], v[1])
    });
    let (_, k) = iter.next().unwrap();
    let mut list = iter.collect::<Vec<_>>();
    list.sort_by_key(|&(x, _)| x);
    list.into_iter()
        .scan((0, 0), |state, (a, b)| {
            *state = (a, (*state).1 + b);
            Some(*state)
        })
        .find(|&(a, b)| b >= k)
        .map(|(x, _)| x)
        .unwrap()
        .to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!(super::run($input.to_string()), $output.to_string());
                }
            )*
        }
    }
}

tests! {
    test1: "3 4
1 1
2 2
3 3" => "3",
    test2: "10 500000
1 100000
1 100000
1 100000
1 100000
1 100000
100000 100000
100000 100000
100000 100000
100000 100000
100000 100000" => "1",
}


Measured memory_bytes: 12540
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
const double pi=3.1415926535898;

int main()
{
    int a,b,n,m;
    cin>>a>>b>>n>>m;
    double x=0.5,y=6;
    int sum=n*60+m;
    double k=fabs(x*sum-y*sum);
    double c=sqrt(a*a+b*b-2*a*b*cos(k*pi/180));
    printf("%.12lf\n",c);
    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n;
  cin >> n;
  map<int, int> cnt;
  rep(i, n) {
    int a;
    cin >> a;
    cnt[a]++;
  }
  int ans = 0;
  for (auto it = cnt.begin(); it != cnt.end(); it++)
    if (it->second % 2) ans++;

  cout << ans << endl;
}


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

Measured memory_bytes: 384
N, K = map(int, input().split(" "))
V = list(map(int, input().split(" ")))

ans = -1e+7
for n_get in range(1, min(N, K) + 1):
    n_remove = min(n_get, K-n_get)
    for n_front in range(n_get + 1):
        got = V[:n_front] + V[N-n_get+n_front:]
        got.sort()
        if n_remove > 0:
            if got[n_remove-1] < 0:
                got = got[n_remove:]
            else:
                got = [g for g in got if g > 0]
        ans = max(ans, sum(got))
print(ans)

Measured memory_bytes: 3064
a, b, k = map(int, input().split())

nums = set()
for i in range(k):
    #print(a)
    nums.add(a)
    a += 1
    if a > b:
        break
for j in range(k):
    #print(b)
    nums.add(b)
    b -= 1
    if a > b:
        break

nums = sorted(nums)
for k in nums:
    print(k)


Measured memory_bytes: 3064
from copy import deepcopy
s = input()
length = len(s)

ans = 0
def solve(s_split, s, i):
    if i == length:
        # print(s_split)
        global ans
        ans += sum(list(map(int, s_split)))
    else:
        tmp1 = deepcopy(s_split)
        tmp1[-1] += s[0]
        solve(tmp1, s[1:], i+1)

        tmp2 = deepcopy(s_split)
        tmp2.append(s[0])
        solve(tmp2, s[1:], i+1)
        
solve([s[0]], s[1:], 1)
print(ans)

Measured memory_bytes: 3444
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int b = int.Parse(input[0]);
		int c = int.Parse(input[1]);
		//出力
		Console.WriteLine(b*c+" "+(2*(b+c)));
	}
}


Measured memory_bytes: 13836
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#from bisect import bisect_right #二分探索用のモジュール bisect_right(a_list,value)

#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = int(input())

# = map(int,input().split())

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

# = [list(map(int,input().split())) for _ in range(XXXX)]

n = int(input())

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

result = 1
overflg = 0

if min(a) == 0:
    print(0)
    exit()

for aa in a:
    result *= aa
    if result > 10**18:
        print(-1)
        exit()

print(result)


Measured memory_bytes: 88032
A = str(input())
if A == "a":
	print("b")
elif A == "b":
	print("c")
elif A == "c":
	print("d")
elif A == "d":
	print("e")
elif A == "e":
	print("f")
elif A == "f":
	print("g")
elif A == "g":
	print("h")
elif A == "h":
	print("i")
elif A == "i":
	print("j")
elif A == "j":
	print("k")
elif A == "k":
	print("l")
elif A == "l":
	print("m")
elif A == "m":
	print("n")
elif A == "n":
	print("o")
elif A == "o":
	print("p")
elif A == "p":
	print("q")
elif A == "q":
	print("r")
elif A == "r":
	print("s")
elif A == "s":
	print("t")
elif A == "t":
	print("u")
elif A == "u":
	print("v")
elif A == "v":
	print("w")
elif A == "w":
	print("x")
elif A == "x":
	print("y")
elif A == "y":
	print("z")


Measured memory_bytes: 3064
#include <iostream>
#include <cstring>
#include <cstdlib>
using namespace std;

typedef long long lnl;

#define MOD 2019

int pow (int a, int n) {
	if (n==0)
		return 1;
	if (n==1)
		return a;
	int tmp = pow (a, n/2);
	if (n%2==0)
		return tmp*tmp % MOD;
	return tmp*tmp*a % MOD;
}

int main () {
	string S;
	int T[200001] = {0};
	cin >> S;
	int cnt = 0, n = S.length ();
	int p = 10;
	T[n-1] = S[n-1] - '0';
	for (int i=n-2; i>=0; i--) {
		T[i] = T[i+1] + p*(S[i]-'0');
		T[i] %= 2019;
		p *= 10;
		p %= 2019;
	}
	for (int nm=0; nm<2019; nm++) {
		int m = 0;
		for (int i=0; i<=n; i++) {
			if (T[i] == nm)
				m ++;
		}
		cnt += m * (m-1) / 2;
	}
	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 4504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _0006
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] str = new string [s.Length];
            for (int i = 0; i < s.Length; i++)
            {
                str[i] = s.Substring(i, 1);
            }
            Array.Reverse(str);
            foreach (string item in str)
            {
                Console.Write(item);
            }
            Console.Write("\n");
        }
    }
}



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

using namespace std;

int main(){
	ll n, z, i;
	string s;
	
	cin>>n;
	cin>>s;
	
	z=0;
	for(i=0; i<n-1; i++){
		if(s[i]=='O' && s[i+1]=='X') z++, i++;
			else if(s[i]=='X' && s[i+1]=='O') z++, i++;
	}
	
	cout<<z<<endl;
}


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

const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)


int main() {
  int a,b;
  cin >> a >> b;
  int ans = max(max(a+b,a-b),a*b);
  cout << ans << endl;
}

Measured memory_bytes: 3552
using System;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		long X = long.Parse(Console.ReadLine());
        decimal deposit = 1e2m;
        long cnt = 0;
        while(deposit < (decimal)X)
        {
          deposit = Math.Floor(deposit * 1.01m);
          //Console.WriteLine(deposit);
          cnt++;
        }
		// スペース区切りの整数の入力
		//string[] input = Console.ReadLine().Split(' ');
		//int a = int.Parse(input[0]);
		//int b = int.Parse(input[1]);
        Console.WriteLine(cnt);
	}
}

Measured memory_bytes: 27552
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()



int main() {
    string s;
    cin >> s;
    rep (i, s.size()) {
        if (s[i] == '?') {
            s[i] = 'D';
        }
    }
    cout << s << endl;
}

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

using namespace std;
int dp[100005];
vector<int>v[100005];
int dfs(int x){
	if(dp[x]!=-1)return dp[x];
	if(v[x].size()==0)return dp[x]=0;
	for(int i=0;i<v[x].size();i++){
		dp[x]=max(dp[x],dfs(v[x][i])+1);
	}
	return dp[x];
}
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		v[a].push_back(b);
	}
	memset(dp,-1,sizeof(dp));
	for(int i=1;i<=n;i++)dfs(i);
	int ans=0;
	for(int i=1;i<=n;i++)ans=max(ans,dp[i]);
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 8192
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);
#define endl "\n"
#define MAXN 100123
#define ll long long
#define INF INT_MAX
#define FORE(i,m,n) for(int i=m;i<n;i++)
#define FOR(i,n) FORE(i,0,n)
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define ps(v) push_back(v)
#define ms(v,x) memset(v,x,sizeof(v)) 
#define PI M_PI
using namespace std;

// cout << fixed << setprecision(4);

int a,b,c,d;

string resp(){
    int contA=0, contT=0;
    while(a>0){
        a-=d;
        contA++;
    }
    while(c>0){
        c-=b;
        contT++;
    }

    if(contT<=contA) return "Yes";
    return "No";

}

int main(){_
    cin >> a >> b >> c >> d;
    cout << resp() << endl;
    return 0;
}

Measured memory_bytes: 3656
/**
 *    Coded by : lucky_21
 *               --------Lokesh Singh
**/

#include<bits/stdc++.h>
using namespace std;

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<class T> using oset=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define     F           first
#define     S           second
#define     pb          push_back
#define     lb          lower_bound
#define     ub          upper_bound
#define     pii         pair<int,int>
#define     all(x)      x.begin(),x.end()
#define     fix         fixed<<setprecision(10)
#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)
#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)
#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)

typedef double db;
typedef long long ll;

const int N=1e3+5;
const int mod=1e9+7;

char c[N][N];
int h,w,dp[N][N];
int rec(int i,int j){
    if(c[i][j]=='#' or i>h or j>w) return 0;
    if(i==h and j==w) return 1;
    int &cache=dp[i][j];
    if(cache!=-1) return cache;
    return cache=(rec(i+1,j)+rec(i,j+1))%mod;
}
signed main(){
    FastIO;
    cin>>h>>w;
    rep(i,1,h) rep(j,1,w) cin>>c[i][j];
    memset(dp,-1,sizeof dp);
    cout<<rec(1,1);
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <vector>
 
using namespace std;
 
using ll = long long;
 
vector<ll> fact;
vector<ll> ifact;
ll inv_2, inv_6;
const int mod = 1e9 + 7;
 
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll ret = (n & 1) ? x : 1;
  ll half = mod_pow(x, n / 2, mod);
  ret *= half * half % mod;
  return ret % mod;
}
 
void init(int f_max = 200000) {
  fact.resize(f_max + 1);
  ifact.resize(f_max + 1);
  fact[0] = 1;
  for(ll i = 1; i <= f_max; i++) {
    fact[i] = (fact[i - 1] * i) % mod;
  }
  ifact[f_max] = mod_pow(fact[f_max], mod - 2, mod);
  for(ll i = f_max - 1; i >= 0; i--) {
    ifact[i] = (ifact[i + 1] * (i + 1)) % mod;
  }
  inv_2 = mod_pow(2, mod - 2, mod);
  inv_6 = mod_pow(6, mod - 2, mod);
}

ll comb(ll n, ll k) {
  return fact[n] * ifact[n - k] % mod * ifact[k] % mod;
}
 
int main() {
  init();
  ll N, M, K;
  cin >> N >> M >> K;
  ll sum = 0;
  sum += (M * M % mod * N % mod * N % mod * (1 + N) % mod * inv_2 % mod + mod - M * M % mod * N % mod * (N + 1) % mod * (2 * N % mod + 1) % mod * inv_6 % mod)  % mod;
  sum %= mod;
  sum += (N * N % mod * M % mod * M % mod * (1 + M) % mod * inv_2 % mod + mod - N * N % mod * M % mod * (M + 1) % mod * (2 * M % mod + 1) % mod * inv_6 % mod) % mod;
  sum %= mod;
  cout << sum * comb(N * M - 2, K - 2) % mod << endl;
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define NUM 1000000009
#define MAX 100001
#define INF LLONG_MAX
double dp[301][301][301];
double solve(ll x, ll y, ll z,ll &n){
    if(x<0 || y<0 || z<0)
        return 0.0;
    if(x==0 && y==0 && z==0)
        return 0.0;
    if(dp[x][y][z]>0.0)
        return dp[x][y][z];
    ll eval = x+y+z;
    double ans = 1.0*n+1.0*x*solve(x-1,y,z,n)+1.0*y*solve(x+1,y-1,z,n)+1.0*z*solve(x,y+1,z-1,n);
    return dp[x][y][z]=1.0*ans/eval;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,tmp;
    cin>>n;
    ll one=0,two=0,three=0;
    for(int i=0;i<n;i++){
        cin>>tmp;
        if(tmp==1)
            one++;
        else if(tmp==2)
            two++;
        else if(tmp==3)
            three++;
    }
    memset(dp,-0.9,sizeof(dp));
    cout<<fixed<<setprecision(9)<<solve(one,two,three,n)<<endl;
    return 0;
}


Measured memory_bytes: 216892
#include <stdio.h>
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <map>

//#include <bits/stdc++.h>
using namespace std;
#define print(x) cout<<(x)<<endl
#define prints(x, y) cout<<(x)<<" "<<(y)<<endl
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long int
#define pb push_back

int main() {
  int N;
  cin >> N;
  int a = sqrt(N);
  print(a*a);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif

int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    fastRead;
    int k;
    cin >> k;
    ll sum = 0;
    for (int a = 1; a <= k; a++){
        for (int b = 1; b <= k; b++){
            for (int c = 1; c <= k; c++){
                sum += __gcd(a, __gcd(b, c));
            }
        }
    }
    cout << sum << endl;
    return 0;
}




Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int A, B, Q;
	cin >> A >> B >> Q;
	vector<ll> s(A + 2);
	vector<ll> t(B + 2);
	for (auto i = 0; i < A; ++i)
	{
		cin >> s[i + 1];
	}
	for (auto i = 0; i < B; ++i)
	{
		cin >> t[i + 1];
	}
	s[0] = LLONG_MIN / 3;
	s[A + 1] = LLONG_MAX / 3;
	t[0] = LLONG_MIN / 3;
	t[B + 1] = LLONG_MAX / 3;

	vector<ll> ans;
	for (auto i = 0; i < Q; ++i)
	{
		ll x;
		cin >> x;

		auto its = upper_bound(s.begin(), s.end(), x);
		auto itt = upper_bound(t.begin(), t.end(), x);

		auto temp = max(*its, *itt) - x;
		auto res = temp;

		temp = *its - *(itt - 1) + min(*its - x, x - *(itt - 1));
		res = min(res, temp);

		temp = *itt - *(its - 1) + min(*itt - x, x - *(its - 1));
		res = min(res, temp);

		temp = x - min(*(its - 1), *(itt - 1));
		res = min(res, temp);

		ans.push_back(res);
	}

	for (auto a : ans)
	{
		cout << a << endl;
	}

	return 0;
}

Measured memory_bytes: 3828
M,K=map(int,input().split())
if K==0:
    L=[i for i in range(2**M)]
    L=L+L
    L.sort()
    ans="0"
    for i in range(1,len(L)):
        ans+=" "+str(L[i])
    print(ans)
elif K<2**(M):
    if M==0 or M==1:
        print(-1)
    else:
        A="0 "+str(K)+" 0"
        for i in range(1,2**(M)):
            if i==K:
                pass
            else:
                A+=" "+str(i)
        A+=" "+str(K)
        for i in range(1,2**(M)):
            if (2**(M)-i)==K:
                pass
            else:
                A+=" "+str(2**(M)-i)
        print(A)
else:
    print(-1)

Measured memory_bytes: 14996
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")
//#define _GLIBCXX_DEBUG
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
//#define int ll
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll N;
  cin >> N;
  
  ll s = 0;
  for(int i=1; i<=N; i++) {
    if(i % 3 != 0 && i % 5 != 0) {
      s += i;
    }
  }
  
  fin(s);
}

Measured memory_bytes: 3648
import sys


def input():
    return sys.stdin.readline()[:-1]

# N = int(input())
# A = [int(x) for x in input().split()]
# a, b, c = map(int, input().split())
# name1 = str(input())
# alph = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5}
# b = list(map(lambda x: math.ceil(x/10)*10, a))


a, b, k = map(int, input().split())
ans = 0
for i in range(min(a, b)):
    j = min(a, b)-i
    if a % j == 0 and b % j == 0:
        ans += 1
    if ans == k:
        print(j)
        break


Measured memory_bytes: 3064
using System;

class Program
{
 static void Main(string[] args)
 {
   int num = int.Parse(Console.ReadLine());
   int cnt = 0;
   int pushNum = 0;
   int readPos = 0;
   
   string[] button = new string[num];
   
   for( cnt = 0; cnt < num; cnt++ )
   {
     button[cnt] = Console.ReadLine();
   }
   
   for( cnt = 0; cnt < num; cnt++ )
   {
     pushNum++;
     
     if( button[readPos] == "2" )
     {
		break;
     }
     else
     {
      readPos = int.Parse(button[readPos]) - 1;
     }
   }
   
   if( cnt == num )
   {
     pushNum = -1;
   }
   
   Console.WriteLine(pushNum);
 }
}

Measured memory_bytes: 15840
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int area = a*b;
		
		int perimeter = (a+b)*2;
				
		
		System.out.println(area +" "+ perimeter);
	}

}


Measured memory_bytes: 26212
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
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; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
ll func(ll k){
  ll res=0;
  switch (k%4) {
    case 0: res=k;
            break;
    case 1: res=1LL;
            break;
    case 2: res=k+1;
            break;
    case 3: res=0;
            break;
  }
  return res;
}
int main(){
  ll a,b; cin>>a>>b;
  if(a!=0) a--;
  ll ans = func(a)^func(b);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>

using namespace std;

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

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define F first
#define S second

// #define COMMENT

/*

const int NN = 200090;
ll fact[NN];
ll finv[NN];
ll inv[NN];

void inverse_modulao() {
  fact[0] = fact[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;

  for(int i = 2;i < NN;i++) {
    fact[i] = fact[i-1]*i%mod;
    inv[i] = mod-mod/i*inv[mod%i]%mod;
    finv[i] = finv[i-1]*inv[i]%mod;
  }
}

ll nCr(int n, int r) {
  return fact[n]*finv[r]%mod*finv[n-r]%mod;
}

*/

int n, m, k, xi, yi, xj, yj;
string s[1<<20];
int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};

#define dist_state pair<int,pair<pii, int>>

int dijkstra() {

  const ll INF = 1e15;
  vector<vector<vector<ll>>> dist =
  vector<vector<vector<ll>>>(n+3,
    vector<vector<ll>>(m+3,
      vector<ll>(6, INF)));

  set<pair<ll, pair<pii, int>>> pq;
  rep(i, 4) {
    pq.insert({0, {{xi, yi}, i}});
    dist[xi][yi][i] = 0;
  }

  while(!pq.empty()) {
    dist_state ds = *pq.begin();
    pq.erase(pq.begin());

    int dxs = 4;
    for(int i = 0;i < dxs;i++) {
      int x = ds.S.F.F + dx[i], y = ds.S.F.S + dy[i], dir = ds.S.S;
      ll cdist = ds.F;
      if(!(x >= 0 && y >= 0 && x < n && y < m && s[x][y] == '.')) continue;
      if(i == dir) cdist += 1;
      else if(cdist % k == 0) cdist += 1;
      else cdist = k*((cdist/k) + 1) + 1;
      if(cdist < dist[x][y][i]) {
        pq.erase({dist[x][y][i], {{x, y}, i}});
        pq.insert({cdist, {{x, y}, i}});
        dist[x][y][i] = cdist;
      }
    }
  }

  ll ans = INF;
  rep(i, 4) ans = min(ans, dist[xj][yj][i]);
  if(ans == INF) return -1;
  if(ans % k == 0) return ans / k;
  return (ans/k)+1;
}

int main() {

 // freopen("input.in","r",stdin);
 // freopen("output.out","w",stdout);
  cin>>n>>m>>k;
  cin>>xi>>yi>>xj>>yj;
  xi--;yi--;xj--;yj--;
  rep(i,n) cin>>s[i];

  cout << dijkstra() << endl;

  return 0;
}


Measured memory_bytes: 466748
#include<queue>
#include<stack>
#include<math.h>
#include<cmath>
#include<bitset>
#include<stdio.h>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<iostream>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  ll n,p,i,ans=1,a;
  scanf("%lld %lld\n",&n,&p);
  a=p;
  for(i=2;i*i<=p;i++){
    if(a%i!=0){
      continue;
    }
    ll res=0;
    while(a%i==0){
      res++;
      a=a/i;
    }
    if(res>=n){
      ans=ans*pow(i,res/n);
    }
  }
  if(a!=0 && n==1){
    ans=ans*a;
  }
  printf("%lld\n",ans);
  return 0;
}

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

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

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll n, p, b, w;

	cin >> n >> p;

	ll sum = 0;
	vector<ll> v;

	REP(i, n) {
		cin >> w >> b;
		sum += -b * p;
		v.push_back(b * p + (100 - p) * w);
	}

	sort(v.begin(), v.end(), greater<ll>());

	ll ans = 0;

	while (sum < 0) {
		sum += v[ans];
		ans++;
	}

	cout << ans << endl;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
main(){
  int a,b;cin>>a>>b;
  string s;
  cin>>s;
  int cnt=0;
  for(int i=0;i<a+b+1;i++){
  if(i==a){
  cnt+=(s[i]=='-');}
  else{
  for(char c='0';c<='9';c++)cnt+=(s[i]==c);}}
  cout<<(cnt==a+b+1?"Yes":"No");
}


Measured memory_bytes: 256
//Jai Shree Krishna
#include <vector>
#include <list>
#include <map>
#include <set>
#include "queue"
#include <deque>
#include <stack>
#include <numeric>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <complex>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include "fstream"
using namespace std;
#define PI acos(-1)
#define MOD (ll)1000000007
#define pii pair<long long ,long long >
#define ll  long long int
#define loop(i,n) for(ll i=0;i<n;i++)
#define loop2(i,n) for(ll i = 1;i<=n;i+=1)
#define pb push_back
#define mp make_pair
#define EPS 1e-8
void display(vector<ll> v1){loop(i,v1.size()){cout<<v1[i]<<" ";}cout<<endl;}
ll dx[8] = {0,1,0,-1,1,1,-1,-1};
ll dy[8] = {1,0,-1,0,1,-1,1,-1};

ll cost[100];
ll dp[50][511][511];
ll Ma,Mb;
ll n;
vector<pair<ll, ll> >v1;

bool check(ll x,ll y)
{
    if(x==0&&y==0)
    {
        return false;
    }
    return Mb*x == Ma*y;
}

ll solve(ll curr,ll wA,ll wB)
{
   // cout<<curr<<" "<<wA<<" "<<wB<<endl;
    if(curr==n)
    {
        if(check(wA, wB)==true)
        {
            return 0;
        }
        else{
            return (ll)1e16;
        }
    }
    if(dp[curr][wA][wB]!=-1)
        return dp[curr][wA][wB];
    ll ans = (ll)1e16;
    ans = min(ans,cost[curr] + solve(curr+1,wA+v1[curr].first, wB+v1[curr].second));
    ans = min(ans,solve(curr+1, wA, wB));
    return dp[curr][wA][wB] = ans;
    
    
}

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

    
    cin>>n>>Ma>>Mb;
    loop(i,n)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        v1.push_back({a,b});
        cost[i] = c;
    }
    memset(dp, -1, sizeof(dp));
    ll y = solve(0, 0, 0);
    if(y>(ll)1e10)
    {
        cout<<"-1";
    }
    else{
        cout<<y<<endl;
    }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return 0;
}


Measured memory_bytes: 102272
MOD = 1000000007
n,k = map(int,input().split())


fac = [0]*(n+1)
finv = [0]*(n+1)
inv = [0]*(n+1)
answer = 0
# テーブルを作る前処理
def COMinit(n, MOD):
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, n+1):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD
# 二項係数計算
def COM(n, k):
    if (n < k): return 0
    if (n < 0 or k < 0): return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


COMinit(n, MOD)

fac = tuple(fac)
finv = tuple(finv)
inv = tuple(inv)

a = n if n < k else k + 1

for i in range(a):
    answer += COM(n,i) * COM(n-1, n-i-1)
    # print(answer)
print(answer%MOD)


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

int main(){
  int n,c,x,y;
  cin >> n;
  y=0;
  c=1;
  x=0;
  bool a=false;
  bool b=true;
  
  for(int i=0;i<9;i++){
    y=(n/c)%10;
    x+=y;
    c*=10;
  }
  if(n%x == 0){
    a=true;
    b=false;
  }
  if(a)
    cout << "Yes" << endl;
  if(b)
    cout << "No" << endl;
}
  
  
  


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

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

const int INF = 1 << 29;
const ll LL_INF = 1LL << 61;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
ll N, K;
vector<pair<ll, ll>> WD;
bool ok1(ll val)
{
    ll res = 0;
    for (int i = 0; i < N; i++)
    {
        ll w = WD[i].first;
        ll d = WD[i].second;
        if (val < w)
        {
            continue;
        }
        res++;
        res += (val - w) / d;
        if (res >= K)
        {
            return true;
        }
    }
    return res >= K;
}

int main()
{
    cin >> N >> K;
    WD.resize(N);
    for (int i = 0; i < N; i++)
    {
        cin >> WD[i].first >> WD[i].second;
    }
    sort(WD.begin(), WD.end());
    ll left, right;
    left = 0;
    right = LL_INF;
    while (right - left > 1)
    {
        ll med = (right + left) / 2;
        if (med < 0)
        {
            left = med;
            continue;
        }
        if (ok1(med))
        {
            right = med;
        }
        else
        {
            left = med;
        }
    }
    cout << left + 1 << endl;

    // cout << right2 << endl;
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define f first
#define s second

typedef long long int ll;
typedef vector< pair<int,int> > vii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long int> vll;
typedef pair<int,int> pii;

const ll INF= ll (1e18);
const int MOD= 1e9+7;
const int N=200+10;

ll arr[N];
ll arr1[N];

ll C[N][N];

int main()
{
    ll n=55;
    for(int i=0;i<=n;i++)
        C[i][0]=C[i][i]=1;

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
            C[i][j]=C[i-1][j-1]+C[i-1][j];
    }

    std::ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll a,b;
    cin>>n>>a>>b;
    int flag=0;

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

        cin>>arr[i];
        arr1[i]=arr[i];

       }

    sort(arr+1,arr+n+1);
    reverse(arr+1,arr+n+1);

    sort(arr1+1,arr1+n+1);
    reverse(arr1+1,arr1+n+1);


    for(int i=2;i<=a;i++)
    {
        if(arr1[i]!=arr1[i-1])
            flag=1;
    }

    if(flag==0)
    {
        ll cnt1=a;
        ll prev=arr[a];
       for(int i=a+1;i<=n;i++)
       {
           if(arr[i]==prev)
            cnt1++;
           else
            break;
       }
       double mean=arr[1];
       cout<<fixed<<setprecision(10)<<mean<<endl;

       ll ans=0;
       for(int i=a;i<=min((ll)b,(ll)cnt1);i++)
       {
       ans+= C[cnt1][i];
       }

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

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

    double mean=0;

    mean=(double)(arr[a]/(double)a);
    cout<<fixed<<setprecision(10)<<mean<<endl;

    ll cnt=0;

    ll num=arr1[a];

    ll left,right;

    for(int i=1;i<=a;i++)
    {
        if(arr1[i]==arr1[a])
        {
            left=i;
            break;
        }
    }
     for(int i=n;i>=1;i--)
    {
        if(arr1[i]==arr1[a])
        {
             right=i;
            break;
        }
    }
    //cout<<left<<" "<<right<<endl;

    cnt=right-left+1;
    ll x=a-(left-1);

    cout<<C[cnt][x]<<endl;

    return 0;
}


Measured memory_bytes: 384
N=int(input())
A=list(map(int, input().split()))
counter=[0]*9

for a in A:
  cls=min(a//400, 8)
  #print(a, cls)
  if cls>=8:
    counter[8]+=1
  else:
    counter[cls]=1
#print(counter)

#min
print(max(1, sum(counter[0:8])), (sum(counter[0:8])+counter[8]))

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

using namespace std;


int main() {
	
	long long N,M;
	long long count = 0;
	cin >> N >> M;

	if (M >= N*2)
	{
		count += N;
		M -= N * 2;

		count += M / 4;
	}
	else
	{
		long long tmp =  M / 2;
		count += tmp;
	}


	cout << count << endl;
	return 0;

}


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

const int MAXN = 1010;
const double INF = 1e10;

struct circle {
	double x, y, r;
};
circle c[MAXN];

double xs, ys, xt, yt, d[MAXN], G[MAXN][MAXN];
int n;
bool used[MAXN];

double dist(circle a, circle b) {
	return sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)) - a.r - b.r;
}

void dijkstra(int s) {
	fill(d+1, d+1+n, INF);
	memset(used, false, sizeof(used));
	d[s] = 0;
	while (true) {
		int v = -1;
		for (int u=1; u<=n; u++)
			if (!used[u] && (v == -1 || d[u] < d[v])) v = u;
		if (v == -1) break;
		used[v] = true;
		for (int u=1; u<=n; u++)
			if (d[v] + G[v][u] < d[u]) d[u] = d[v] + G[v][u];
	}
}

int main() {
	cin >> xs >> ys >> xt >> yt;
	c[1] = circle{xs, ys, 0};
	c[2] = circle{xt, yt, 0};
	cin >> n;
	for (int i=1; i<=n; i++) cin >> c[i+2].x >> c[i+2].y >> c[i+2].r;
	n += 2;
	for (int i=1; i<=n; i++) {
		for (int j=1; j<=n; j++) {
			if (i == j) continue;
			G[i][j] = dist(c[i], c[j]);
			if (G[i][j] < 0) G[i][j] = 0;
		}
	}
	dijkstra(1);
	printf("%.10f\n", d[2]);
	return 0;
}

Measured memory_bytes: 8192
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
			String A = sc.nextLine();
	        char B = A.charAt(A.length() -1);

	        if(B == '3') {
	        	System.out.println("bon");
	        }else if(B=='0'|B=='1'|B=='6'|B=='8'){
	        	System.out.println("pon");
	        }else {
	        	System.out.println("hon");
		 }
		}
		

	}



Measured memory_bytes: 35700