akhauriyash/Code-Regression huggingface dataset:
N, M, K = map(int, input().split())

class UnionFind():
    def __init__( self, n ):
        self.n = n
        self.parents = [ - 1 ] * n
        
    def find( self, x ):
        if self.parents[ x ] < 0:
            return x
        else:
            self.parents[ x ] = self.find( self.parents[ x ] )
            return self.parents[ x ]

    def union( self, x, y ):
        x = self.find( x )
        y = self.find( y )
        if x == y:
            return
        if self.parents[ x ] > self.parents[ y ]:
            x, y = y, x
        self.parents[ x ] += self.parents[ y ]
        self.parents[ y ] = x
        
    def size( self, x ):
      return -self.parents[ self.find( x ) ]
        
    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]
    def same( self, x, y ):
      return self.find( x ) == self.find( y )

uf = UnionFind( N + 1 )
not_use = [ 0 ] * ( N + 1 )
for i in range( M ):
  a, b = map( int, input().split() )
  uf.union( a, b )
  not_use[ a ] += 1
  not_use[ b ] += 1

block = [ [] for _ in range( N + 1 ) ]
for i in range( K ):
  c, d = map( int, input().split() )
  if uf.same( c, d ):
    not_use[ c ] += 1
    not_use[ d ] += 1

ans = str( uf.size( 1 ) - not_use[ 1 ] - 1 )
for i in range( 2, N + 1 ):
  ans += " " + str( uf.size( i ) - not_use[ i ] - 1 )
print( ans )

Measured memory_bytes: 16708
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
int vector_finder(std::vector<ll> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  ll N, K; cin >> N >> K;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  ll MOD = pow(10, 9) + 7;
  ll ans = 0;
  ll a = K * (K - 1) / 2;
  ll b, c = 0;
  REP(i, N) {
    REP(k, N) {
      if(A[i] > A[k]) b++;
    }
    for(int k = i + 1; k < N; ++k) {
      if(A[i] > A[k]) c++;
    }
  }
  ans += a % MOD * b % MOD;
  ans %= MOD;
  ans += c * K;
  ans %= MOD;
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef trie<string, null_type, trie_string_access_traits<>, pat_trie_tag, trie_prefix_search_node_update> pref_trie;
typedef unsigned long long BITMASK; typedef long long ll; typedef long double ld;
#define smallest_on_bit(bit_mask) (__builtin_ctzint((bit_mask) & (-(bit_mask))))
#define CLOCK_START clock_t chrono_clk_beg = clock()
#define CLOCK_END clock_t chrono_clk_end = clock(); cerr << (double(chrono_clk_end - chrono_clk_beg) / CLOCKS_PER_SEC) << " sec"
#define bug(args ...) cerr << __LINE__ << ">> ", err(new istringstream(string(#args)), args), cerr << '\n'
#define decToBin(name, num) string name = bitset<8>(num).to_string();
#define binToDec(name, binary) unsigned long name = bitset<8>(binary).to_ulong();
#define radToDeg(name, radians) double name = radians * 180 / M_PI;
#define all(x) x.begin(), x.end()
#define mapfind(mp, x) (mp.find(x) != mp.end())
#define arrfind(arr, x) (find(all(arr), x) != arr.end())
#define removeDuplicates(vec) sort(vec.begin(), vec.end()); vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define printMat(mat) for (auto &x : mat) { for (auto &y : x) cout << y << " "; cout << '\n'; }
#define printArr(arr) for (auto &x : arr) cout << x << " "; cout << '\n';
#define ceil(a, b) ((a+b-1)/b)
#define int ll
#define double ld
#define INF (1LL<<62)
#define M_PI 3.14159265358979323846
void err(istringstream *iss) {} template<typename T, typename ... Args> void err(istringstream *iss, const T &_val, const Args & ... args) { string _name; *iss >> _name; if (_name.back()==',') _name.pop_back(); cerr << _name << " = " << _val << "; ", err(iss, args ...); }
void str_replaceAll(string& str, const string& from, const string& to) { if(from.empty()) return; size_t start_pos = 0; while((start_pos = str.find(from, start_pos)) != std::string::npos) { str.replace(start_pos, from.length(), to); start_pos += to.length(); } }
#define MOD 1000000007

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n, a, b;
    cin >> n >> a >> b;
    int x = n / (a+b);
    int y = n % (a+b);
    int ans = x*(a);
    ans += (y > a) ? a : y;
    cout << ans << '\n';
    return 0;
}

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

int main() {
    int n, m; cin >> n >> m;
    int p = pow(2, m);

    cout << ((n-m)*100*p) + (1900*m)*p << endl;
}


Measured memory_bytes: 4108
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define vi vector<int>
#define vl vector<ll>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const ll mod = 1e9 + 7;

vl pw10(1000);
int main()
{
    pw10[0] = 1;
	for (int i = 1; i < pw10.size(); i ++) pw10[i] = pw10[i - 1] * 10 % mod;
	int n, x, y, z;
	cin >> n >> x >> y >> z;
	int M = max(x, max(y, z));
	vi d(1 << (x + y + z + 1), 0);
	d[1] = 1;
	ll res = 0;
	rep(t, 0, n - 1)
	{
		vi nd(d.size());
		for (int mask = 0; mask < d.size(); mask ++) if (d[mask])
		{
			rep(a, 1, M)
			{
				int nmask = 1;
				rep(i, 0, x + y + z - a) if (mask & (1 << i)) nmask |= (1 << (i + a));
				nd[nmask] = (nd[nmask] + d[mask]) % mod;
			}
			nd[1] = (nd[1] + d[mask] * (ll)(10 - M)) % mod;
		}
		int all = (1 << (x + y + z));
		for (int mask = all; mask < nd.size(); mask ++)
			if ((mask & (1 << z)) && (mask & (1 << (y + z)))) res = (res + nd[mask] * pw10[n - t - 1]) % mod, nd[mask] = 0;
			else nd[mask ^ all] = (nd[mask ^ all] + nd[mask]) % mod, nd[mask] = 0;
		d.swap(nd);
	}
	cout << res % mod << endl;
	return 0;
}



Measured memory_bytes: 2304
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <set>
#include <queue>
#include <map>
#include <iomanip>
#include <cstring>
#include <cmath>

using namespace std;
const long double eps = 1e-12;

typedef long long ll;
typedef pair<int , int> pt;

#define sz(a) ((int) a.size() )
#define LL(x) (x << 1)
#define RR(x) ((x << 1) | 1)
#define For(i , a , b) for (int i = a ; i <= b ; i++)
#define Ford(i , a , b) for (int i = a ; i >= b ; i--)
#define Rep(i , n) for (int i = 0 ; i < n ; i++)

const int maxn = 300000 + 1912;
int n;
pt a[maxn];

void ReadData() {
    scanf("%d" , &n);
    For(i , 1 , n) scanf("%d%d" , &a[i].first , &a[i].second);
}

bool cmp(pt a , pt b) {
    if (a.second == b.second) return a.first < b.first;
    return a.second > b.second;
}

priority_queue<int> qu;

bool check(int lim) {
    long long sum = 0;
    while (sz(qu)) qu.pop();
    For(i , 1 , n) {
        sum += a[i].first;
        qu.push(a[i].first);

        while (sz(qu) > lim) {
            sum -= qu.top(); qu.pop();
        }
        if (sz(qu) == lim) if (1LL * lim * a[i].second >= sum ) return true;
    }
    return false;
}

void Process() {
    long long sum = 0;
    sort(a + 1 , a + 1 + n , cmp);
    int res = 0, l = 1, r = n;
    while (l <= r) {
        int mid = (l + r) >> 1;
        if (check(mid)) {
            res = mid; l = mid + 1;
        } else r = mid - 1;
    }
    cout << res << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   // freopen("/users/youaremysky/documents/workspace/input.inp" , "r" , stdin);
    ReadData();
    Process();
}

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

int main() {
  int N, A, cnt, res, i;
  res = 100;
  cin >> N;
  
  for(i=0; i<N; i++){
    cin >> A;
    cnt = 0;
      while(A % 2 == 0){
        A /= 2;
	    cnt++;
      }
    if(cnt <= res) res = cnt;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll       long long
#define ull       unsigned long long
#define  si(x)   scanf("%d", &x)
#define  sll(x)   scanf("%lld", &x)
#define  sd(x)   scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100000
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007



int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
	    ll a;
	    sll(a);
	    if(a==3 || a==5 || a==7) cout << "YES" << endl;
	    else cout << "NO" << endl;
		return 0;
}


Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define INF  1000000000000000009;

int main() {
	string s,t;
	cin>>s>>t;
	int n=s.size(),m=t.size();
	int dp[n+1][m+1]={0};
	for(int i=0;i<=n;i++){
	    for(int j=0;j<=m;j++){
	        dp[i][j]=0;
	    }
	}
	for(int i=1;i<=n;i++){
	    for(int j=1;j<=m;j++){
	        if(s[i-1]==t[j-1]){
	            dp[i][j]=dp[i-1][j-1]+1;
	        }else{
	            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
	        }
	    }
	}
// 	for(int i=0;i<=n;i++){
// 	    for(int j=0;j<=m;j++){
// 	        cout<<dp[i][j]<<" ";
// 	    }
// 	    cout<<"\n";
// 	}
	int i=n,j=m;
	string dq="";
	
	while(i>0&&j>0){
	    if(dp[i][j]==(dp[i-1][j-1]+1)&&dp[i][j]>dp[i-1][j]&&dp[i][j]>dp[i][j-1]){
	       // dq.push_front(s[i-1]);
	       dq=dq+s[i-1];
	       // cout<<"aya";
	        i=i-1;
	        j=j-1;
	    }else if(dp[i-1][j]>dp[i][j-1]){
	        i=i-1;
	    }else{
	        j=j-1;
	    }
	}
	reverse(dq.begin(),dq.end());
	cout<<dq;
	return 0;
}


Measured memory_bytes: 35456
import sys
n=int(input())
a=list(map(int,input().split()))

purged_data = [] #purge : [動詞]〜を粛清する
tmp = a[0] - 1
s=1
for i, e in enumerate(a):
    if e==s:
        purged_data.append(e)
        tmp = e
        s+=1
for i in range(len(purged_data)):
    if purged_data[i]!=i+1:
        print(-1)
        sys.exit()
if len(purged_data)==0:
    print(-1)
    sys.exit()
print(len(a)-len(purged_data))

Measured memory_bytes: 26140
use proconio::input;
use proconio::marker::Usize1;

struct UnionFindTree {
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFindTree {
    fn new(n: usize) -> Self {
        let parent = (0..n).collect();
        let size = vec![1; n];
        Self { parent, size }
    }

    fn find(&mut self, x: usize) -> usize {
        if self.parent[x] == x {
            x
        } else {
            self.parent[x] = self.find(self.parent[x]);
            self.size[x] = 1;
            self.parent[x]
        }
    }

    fn unite(&mut self, x: usize, y: usize) {
        let mut x = self.find(x);
        let mut y = self.find(y);
        if x == y {
            return;
        }

        if self.size[x] > self.size[y] {
            std::mem::swap(&mut x, &mut y);
        }

        self.parent[y] = x;
        self.size[x] += self.size[y];
    }
}
#[allow(non_snake_case)]
fn main() {
    input! {
        N: usize,
        M: usize,
        AB: [(Usize1, Usize1); M]
    }

    let mut uf = UnionFindTree::new(N);

    for &(a, b) in AB.iter() {
        uf.unite(a, b);
    }

    println!("{:?}", uf.size.iter().max().unwrap());
}


Measured memory_bytes: 10748
#include<bits/stdc++.h>
#define int long long

#define F first
#define S second
#define MAX 10000003
using namespace std;
const int mod = 1000000007;

int prime[MAX];
unordered_map<int, int> max_map;

// Function to return a^n
int power(int a, int n)
{
    if (n == 0)
        return 1;
    int p = power(a, n / 2) % mod;
    p = (p * p) % mod;
    if (n & 1)
        p = (p * a) % mod;
    return p;
}

// Function to find the smaest prime factors
// of numbers upto MAX
void sieve()
{
    prime[0] = prime[1] = 1;
    for (int i = 2; i < MAX; i++) {
        if (prime[i] == 0) {
            for (int j = i * 2; j < MAX; j += i) {
                if (prime[j] == 0) {
                    prime[j] = i;
                }
            }
            prime[i] = i;
        }
    }
}

// Function to return the LCM modulo M
int lcmModuloM(const int* ar, int n)
{

    for (int i = 0; i < n; i++) {
        int num = ar[i];
        unordered_map<int, int> temp;

        // Temp stores mapping of prime factor to
        // its power for the current element
        while (num > 1) {

            // Factor is the smallest prime factor of num
            int factor = prime[num];

            // Increase count of factor in temp
            temp[factor]++;

            // Reduce num by its prime factor
            num /= factor;
        }

        for (auto it : temp) {

            // Store the highest power of every prime
            // found till now in a new map max_map
            max_map[it.first] = max(max_map[it.first], it.second);
        }
    }

    int ans = 1;

    for (auto it : max_map) {

        // LCM is product of primes to their highest powers modulo M
        ans = (ans * power(it.F, it.S)) % mod;
    }

    return ans;
}

signed main()
{

    sieve();
    int n;
    cin>>n;

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

    if(n == 1){
        cout<<1;
        return 0;
    }

    //int lcm = (((arr[0] * arr[1]) % mod) * ( (power(__gcd(arr[0], arr[1]), mod - 2)) % mod) ) % mod;

    //for(int i=2;i<n;i++){
    //    lcm = ( ((arr[i] * lcm) % mod) * ((power(__gcd(arr[i], lcm), mod - 2)) % mod)) % mod;
    //}

    int lcm = lcmModuloM(arr, n);

    int ans = 0;
    for(int i=0;i<n;i++){
        ans = (ans + (lcm * power(arr[i], mod-2)) % mod) % mod;
    }

    cout<<ans;
}


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

int main() {
    int N, M;
    cin >> N >> M;
    int A[M];
    for (int i=0; i<M; i++) cin >> A[i];
    int sum=0;
    for (int i=0; i<M; i++) sum+=A[i];
    if (sum<=N) cout << N-sum << endl;
    else cout << -1 << endl;
}

Measured memory_bytes: 3668
import java.util.Scanner;

class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        while(true) {
            String s = sc.next();
            if(s.equals("0")) break;
            int ret = 0;
            for(int i = 0; i < s.length(); i++) ret += s.charAt(i) - 48;
            System.out.println(ret);
        }
    }
}



Measured memory_bytes: 26332
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll dip(ll a[],ll b[],ll c[],ll n)
{
	ll i,j,mx=INT_MIN;
	ll dp[n+1][3];
	for(i=0;i<=n;i++)
	{
		for(j=0;j<3;j++)
		{
			if(i==0)
			dp[i][j]=0;
			else if(j==0)
			{
				dp[i][j]=a[i-1]+max(dp[i-1][1],dp[i-1][2]);
			}
			else if(j==1)
			{
			dp[i][j]=b[i-1]+max(dp[i-1][0],dp[i-1][2]);	
			}
			else
			dp[i][j]=c[i-1]+max(dp[i-1][0],dp[i-1][1]);
		}
		
	}
	mx=max(dp[n][0],max(dp[n][1],dp[n][2]));
	
	return mx;
}
int main()
{ 
int n;
cin>>n;
ll a[n],b[n],c[n],i,j;
for(i=0;i<n;i++)
cin>>a[i]>>b[i]>>c[i];
cout<<dip(a,b,c,n);
return 0;

}


Measured memory_bytes: 4864
import Data.Array.IO
import Data.List
import Data.Ord
import qualified Data.ByteString.Char8 as BS
import Data.Maybe
import Control.Monad

type UnionFindIO = IOArray Int (Int,Int)

newUFIO :: Int -> IO UnionFindIO
newUFIO n = newListArray (1,n) (zip [1..n] (repeat 1))

findUFIO :: Int -> UnionFindIO -> IO Int
findUFIO x uf = do
  (parent,size) <- readArray uf x
  if parent == x then
    return x
    else do
    next <- findUFIO parent uf
    writeArray uf x (next,size)
    return next

sameUFIO :: Int -> Int -> UnionFindIO -> IO Bool
sameUFIO x y uf = do
  xx <- findUFIO x uf
  yy <- findUFIO y uf
  return $ xx == yy

uniteUFIO :: Int -> Int -> UnionFindIO -> IO ()
uniteUFIO x y uf = do
  xx <- findUFIO x uf
  yy <- findUFIO y uf
  (_,xs) <- readArray uf xx
  (_,ys) <- readArray uf yy

  if xx == yy then
    return ()
    else if xs < ys then do
    writeArray uf xx (yy,0)
    else if xs > ys then do
    writeArray uf yy (xx,0)
    else do
    writeArray uf yy (xx,0)
    writeArray uf xx (xx,xs+1)


type City = (Int,(Int,Int))

kruskal :: [City] -> [(City,City)] -> IO Int
kruskal nodes edges = do
  let sorted = sortBy comp (map (\((i,ci),(j,cj)) -> (i,j,dist ci cj)) edges)

  uf <- newUFIO (length nodes)

  let
    kruskal' e@(i,j,c) = do
      same <- sameUFIO i j uf
      if same then
        return 0
        else do
        uniteUFIO i j uf
        return c
        
  mapM kruskal' sorted >>= return . sum
  where
    comp (_,_,c1) (_,_,c2) = compare c1 c2
    dist (x1,y1) (x2,y2) = min (abs $ x1-x2) (abs $ y1-y2)

listToTuple2 (a:b:_) = (a,b)

main = do
  n <- readLn :: IO Int
  nodes <- BS.getContents >>= return . zip [1..] . map (listToTuple2 . map (fst . fromJust . BS.readInt) . BS.words) . BS.lines :: IO [(Int,(Int,Int))]

  
  let roads = f (sortBy (comparing (fst . snd)) nodes) ++ f (sortBy (comparing (snd . snd)) nodes)

  print =<< kruskal nodes roads

  where
    f (_:[]) = []
    f (x:y:xs) = (x,y) : f (y:xs)


Measured memory_bytes: 83324
N = int(input())

firstMax = 0
secondMax = 0
firstMaxIndex = -1

for i in range(N):
    num = int(input())
    if firstMax < num:
        firstMax = num
        firstMaxIndex = i
    elif secondMax < num:
        secondMax = num

for i in range(N):
    if i == firstMaxIndex:
        print(secondMax)
    else:
        print(firstMax)


Measured memory_bytes: 4540
from fractions import gcd
def inverse(a):
    return pow(a, mod - 2, mod)


def usearch(x, a):
    lft = 0
    rgt = len(a) + 1
    while rgt - lft > 1:
        mid = (rgt + lft) // 2
        if a[mid] <= x:
            lft = mid
        else:
            rgt = mid
    return lft



def main():
    a,b,c=map(int, input().split())
    tmp = tuple(sorted([a, b, c]))
    s = set()
    ans = 0
    while tmp not in s:
        a, b, c = tmp
        if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
            break
        s.add(tmp)
        tmp = tuple(sorted([(b+c)//2, (a+c)//2, (a+b)//2]))
        ans += 1
    if tmp not in s:
        print(ans)
    else:
        print(-1)


main()

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define Rep(i,n) for(int i = 1; i <= n; i++)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
template<class T> using V = vector<T>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
    
    int n;
    cin >> n;

    ll takahashi = 1, aoki = 1;

    rep(i,n) {
        ll t, a;
        cin >> t >> a;
        ll roop = max(ceil(takahashi,t), ceil(aoki,a));
        takahashi = t*roop, aoki = a*roop;
        // cout << takahashi << " " << aoki << endl;
    }

    ll ans = takahashi + aoki;
    cout << ans << endl;
}

Measured memory_bytes: 3656
a,b,c = (map(int, input().split())) 
n = list(map(int, input().split())) 
chargeA=0
chargeB=0

for i in range(b):
  if c<n[i]<a:
    chargeA+=1
  else:
    chargeB+=1
print(min(chargeA,chargeB))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#define endl "\n"
#endif
using namespace std;
typedef unsigned long long int lu;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> v;
typedef vector<lu> vu;
typedef vector<v> vv;
typedef vector<vu> vvu;
typedef vector<ld> vld;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef pair<ll, ll> pll;
typedef vector<set<ll>> vsll;
typedef set<pair<ll, ll>> spll;
typedef vector<spll> vspll;
typedef vector<pll> vpll;
typedef pair<lu, lu> puu;
typedef vector<puu> vpuu;
const ll MOD = 1000000007;
const ld PI = 2 * acos(0.0);
const v dx = {1, -1, 0, 0};
const v dy = {0, 0, 1, -1};
#define round(x, y) ((x + y - 1) / y)
#define ce(x, y) ((x + y - 1) / y)
#define amax(x, y) \
  if (y > x) x = y;
#define amin(x, y) \
  if (y < x) x = y;
#define lcm(x, y) ((x) * (y) / __gcd(x, y))
#define sz(x) (ll) x.size()
#define len(x) (ll) x.length()
#define sq(x) ((x) * (x))
#define cb(x) ((x) * (x) * (x))
#define yes cout << "YES\n";
#define no cout << "NO\n";
#define yesno(f) \
  if (f) yes else no;
#define noo \
  { no return; }

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

template <typename T = ll>
vector<T> ga(ll n, bool oneIndexed = false) {
  vector<T> a = vector<T>(n + oneIndexed);

  for (ll i = 0; i < n; i++) {
    T p;
    cin >> p;
    a[i + oneIndexed] = p;
  }

  return move(a);
}

template <typename T, typename A>
void pa(vector<T, A> const &a, ll begin = 0, ll end = -1) {
  if (end == -1) end = sz(a) - 1;
  for (ll i = begin; i <= end; i++) {
    // printf("%lu ", a[i]);
    cout << a[i] << " ";
  }
  cout << endl;
}

template <typename T, typename A>
void papair(vector<T, A> const &a, ll begin = 0, ll end = -1) {
  if (end == -1) end = sz(a) - 1;
  for (ll i = begin; i <= end; i++) {
    // printf("%lu ", a[i]);
    cout << a[i].first << " " << a[i].second << endl;
  }
}

void solve() {
  ll n, w;
  cin >> n >> w;
  v arr, val;
  for (ll i = 0; i < n; i++) {
    ll x, y;
    cin >> x >> y;
    arr.push_back(x);
    val.push_back(y);
  }
  v dp(1e5 + 1000, 1e17);
  dp[0] = 0;
  for (ll j = 0; j < n; j++) {
    for (ll i = 1e5 + 2; i >= 0; i--) {
      dp[i + val[j]] = min(dp[i + val[j]], dp[i] + arr[j]);
    }
  }
  ll m = 0;
  for (ll i = 1; i < 1e5 + 2; i++) {
    if (dp[i] <= w) {
      m = i;
    }
  }
  cout << m;
  // vector<ll> arr = ga(n);
  // code
}

int main(void) {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  // ll t;cin >> t;while(t--)
  solve();
  return 0;
}

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

int main()
{
 int a, b, c, d;
 cin >> a >> b >> c >> d;
 if(a * b >= c * d)
 {
   cout << a * b << endl;
 }
 else
 {
   cout << c * d << endl;
 }
}

Measured memory_bytes: 256
// C.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
using namespace std;

int bufp[9], bufq[9];

int kaijyo(int n) {

    int ans = 1;

    for (int i = n; i >= 1; i--) {
        ans *= i;
    }

    return ans;
}

int order(int A[], int n) {
    int num = 1;
    for (int i = 0; i < n-1; i++) {
        int a = A[i];
        int jyun = 0;
        for (int j = 1; j < a; j++) {
            if (bufp[j] == 0)jyun++;
        }
        bufp[a] = 1;

        num += jyun * kaijyo(n - i - 1);

    }

    return num;
}

int main()
{
    int n;

    cin >> n;

    int p[9], q[9];



    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < n; i++) {
        cin >> q[i];
    }
    
    int a = order(p, n);
    for (int i = 0; i < 9; i++) {
        bufp[i] = 0;
    }
    int b = order(q, n);

    //cout << a << endl;
    //cout << b << endl;
    //cout << kaijyo(2) << endl;
    if (a >= b)cout << a - b << endl;
    else cout << b - a << endl;

    return 0;

}



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

using namespace std;

int main()
{
  string A, B; cin >> A >> B;
  if (A == B) {
    cout << "EQUAL";
  } else if (A.size() > B.size()) {
    cout << "GREATER";
  } else if (A.size() < B.size()) {
    cout << "LESS";
  } else {
    for (int i = 0; i < A.size(); ++i) {
      if (A[i] == B[i]) {
        continue;
      } else if (A[i] > B[i]) {
        cout << "GREATER";
        return 0;
      } else {
        cout << "LESS";
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
n, m = map(int,input().split())
 
AC = 0
# 各問題でACがとれているか確認用
# 0 = まだ正解していない, 1 = すでに正解済み
AC_list = [0] * (n + 1)
WA = 0
WA_List = [0] * (n + 1)
 
for i in range(m):
    p,S = input().split()
    p = int(p)
 
    if S == "AC":
        # 初めての正解
        if AC_list[p] == 0:
            AC += 1
            WA += WA_List[p]
            AC_list[p] = 1
        # ※すでに正解している場合は加算しない
    else:
        # まだ正解していない場合
        if AC_list[p] == 0:
            WA_List[p] += 1
        # ※すでに正解している場合は加算しない
 
print(AC,WA)

Measured memory_bytes: 4596
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;
typedef long long LL;
const int N = 100050;

LL ans = 0;
int t[N], n, m, bj[N];
int mn[N], mnw[N], a[N];
struct node{
	int loc, val;
	inline bool operator < (const node &b)const{
		return val < b.val;
	}
}W[N];
int path(int x){
	if(!t[x])return x;
	return t[x] = path(t[x]);
}
int main()
{

	int i, j, k;
	scanf("%d%d", &n, &m);
	if(2 * (n - m - 1) > n){
		puts("Impossible");
		return 0;
	}
	if(n == m + 1){
		puts("0");
		return 0;
	}
	for(i = 1; i <= n; i ++)
		scanf("%d", &a[i]);
	for(i = 1; i <= m; i ++){
		scanf("%d%d", &j, &k);
		t[path(j + 1)] = path(k + 1);
	}
	for(i = 1; i <= n; i ++)
		mn[i] = 2100000000;
	for(i = 1; i <= n; i ++){
		if(mn[path(i)] > a[i]){
			if(mn[path(i)] != 2100000000)
				ans -= mn[path(i)], bj[mnw[path(i)]] = 0;
			ans += a[i], bj[i] = 1, mnw[path(i)] = i, mn[path(i)] = a[i];
		}
		W[i].loc = i, W[i].val = a[i];
	}
	sort(W + 1, W + n + 1);
	for(i = 1, j = 0; i <= n && j < n - m - 2; i ++)
		if(bj[W[i].loc] == 0)
			j ++, ans += W[i].val;
	printf("%lld", ans);

	return 0;
}


Measured memory_bytes: 2944
#include <iostream>

using namespace std;


int main(){
    
    int n, b, f, r, v;
    int rooms[4][3][10]={0};

    cin >> n;

    for(int i=0; i<n; i++){
        cin >> b >> f >> r >> v;
        rooms[b-1][f-1][r-1] += v;
    }

    for(int j=0; j<4; j++){
        for(int k=0; k<3; k++){
            for(int l=0; l<10; l++){
                cout << " " << rooms[j][k][l];
            }
            cout << endl;
        }
        if(j<3){
            for(int s=0; s<20; s++){
                cout << "#";
            }
            cout << endl;
        }
    }

    return 0;
}




Measured memory_bytes: 3088
n = int(input())
a_s = list(map(int, input().split()))

sum_a = 0
mul_a = 0
mod = 1000000007

for a in a_s:
    sum_a += a
    mul_a += a*a
    sum_a %= mod
    mul_a %= mod

ans = sum_a * sum_a
ans %= mod
ans -= mul_a
ans %= mod

n = mod-2
inv = 1
base = 2

while n:
    if n & 1:
        inv = inv*base % mod
    base = base*base % mod
    n >>= 1

ans *= inv
ans %= mod

print(ans)


Measured memory_bytes: 30792
import java.util.*;

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

        int N = sc.nextInt();
        int A = sc.nextInt();

        if(N%500<=A){
            System.out.println("Yes");
        }
        else{
            System.out.println("No");
        }
    } 
}

Measured memory_bytes: 21588
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

min_a = 10**5
for i in range(A):
    if min_a > a[i]:
        min_a = a[i]

min_b = 10**5
for i in range(B):
    if min_b > b[i]:
        min_b = b[i]

min = min_a + min_b
#print(min)

for i in range(M):
    x, y, c = map(int, input().split())
    tmp = a[x - 1] + b[y - 1] - c
    if min > tmp:
        min = tmp

print(min)


Measured memory_bytes: 18776
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define radrad(a)  180.0 * a / M_PI
#define pow(x) x*x
#define ll long long
static const int MAX = 100010;
static const ll INFTY = 1e12;
static const int NUMMAX = 300;


int main(){

  int N, Q;
  ll  K;
  int A, P[MAX] = {0};

  cin >> N >> K >> Q;

  REP(i, Q){
    cin >> A;
    P[--A]++;
  }

  REP(i, N){
    if( P[i] - (Q - K ) > 0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }


  return 0;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define long long long
using namespace std;
const int N=1e6;
int main()
{
  ios_base::sync_with_stdio(0);cin.tie(0);
  long a,b,c;cin>>a>>b>>c;

  if(c<=max(a,b))cout<<"No\n",exit(0);

  long lft=4*a*b,rgt=(c-a-b)*(c-a-b);
  //cout<<lft<<" "<<rgt<<endl;
  if(lft<rgt)cout<<"Yes\n";
  else cout<<"No\n";

  return 0;
}

Measured memory_bytes: 256
n,k = [int(ch) for ch in input().split()]
snuckList = []
for i in range(n):
    snuckList.append(i+1)
for i in range(k):
    cnt = int(input())
    snucks = [int(ch) for ch in input().split()]
    for snuck in snucks:
        if snuck in snuckList: 
            snuckList.remove(snuck)
print(len(snuckList))

Measured memory_bytes: 67824
#include <iostream>

using namespace std;
int a[505][505],vis[505][505],h,w,tot;
struct node{
	int x1,y1,x2,y2;
};
node step[250005];
int main(){
	ios::sync_with_stdio(false);
	cin >> h >> w;
	for(int i = 1;i <= h;++i)
		for(int j = 1;j <= w;++j)cin >> a[i][j];
	for(int i = 1;i <= h;++i)
		for(int j = 1;j <= w;++j)
		if(a[i][j] %2 == 0)continue;
		else if(i == h && j == w)continue;
		else {
			if(j == w){
				step[++tot] = {i,j,i + 1,j};
				a[i + 1][j]++;
			}
			else {
				step[++tot] = {i,j,i,j + 1};
				a[i][j + 1]++;
			}
		}
	cout << tot << endl;
	for(int i = 1;i <= tot;++i)
		cout << step[i].x1 << ' ' << step[i].y1 << ' ' << step[i].x2 << ' ' << step[i].y2 << endl;
	return 0;
}

Measured memory_bytes: 7168
#include<bits/stdc++.h>
#include<stdio.h>
#define debug(x) cout << '>' << #x << ':' << x << endl;

#define nitro ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
const int mod = 1e9+7;
using namespace std;
using ll = long long int;
const ll invmod = 998244353; 

ll fastpow(ll base, ll exp, ll mod)
{
	ll ans = 1ll;
	while(exp > 0)
	{
		if(exp & 1)
		{
			ans = ((ans%mod) * (base%mod)%mod);
		}
		exp /= 2;
		base = ((base%mod) * (base%mod)%mod);
	}
	return ans;
}

int main()
{
	

	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	//clock_t time_req;time_req = clock(); 
	ll a1, b1, c1, k;
	cin >> a1>> b1 >> c1 >> k;
	ll ans = 0;
	// ll total = a+b+c;
	ll a[4], b[4];
	a[1] = a1; b[1] = 1;
	a[2] = b1; b[2] = 0;
	a[3] = c1; b[3] = -1;
	int i = 1;
	
	while(k !=0)
	{	
		if(a[i] < k)
		{
			ans += a[i]*b[i];
			k -= a[i];
			i++;
		}
		else
		{
			ans += k*b[i];
			k -= k;
			break; 
		}
	}

	cout << ans << '\n';
	

	//time_req = clock()- time_req;cout << "Time Complexity:"<< \n'<<(float)time_req/CLOCKS_PER_SEC << " seconds" << endl; 
	return 0;
 }

  	

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

using namespace std;

long gcd(long a, long b){
  
  while(a%b){
   long r=a%b;
   a=b;
   b=r; 
  }
  
 return b;
}


int main(){
  long n,k;
  cin >> n >> k;
  vector<long> a(n);
  
  cin >> a[0];
   long m=a[0];
   long g=a[0];
  for(int i=1;i<n;i++){
   cin >> a[i];
   m=max(m,a[i]);
    g=gcd(g,a[i]);
  }
 
 if(m>=k&&!(k%g))  cout << "POSSIBLE" << endl;
 else cout << "IMPOSSIBLE" << endl;
  
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.Scanner;
class Main{

	
	static char[][] map;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力



		int h = sc.nextInt();
		int w = sc.nextInt();
		String[] strs = new String[h];
		for(int i = 0;i < h;i++){
			strs[i] = sc.next();
		}
		map = new char[h][w];
		for(int i = 0;i < h;i++){
			String str = strs[i];
			for(int j = 0;j < w;j++){
				map[i][j] = str.charAt(j);
			}
 		}
//		
//		for(int i = 0;i < h;i++){
//			for(int j = 0;j < w;j++){
//				System.out.print(map[i][j]);
//			}
//			System.out.println();
//		}
		
		int[][] rdp = new int[h][w];
		for(int i = 0;i < h;i++){				//横方向のdp
			for(int j = 0;j < w;j++){
				if(j == 0){
					if(map[i][j] == '#'){
						rdp[i][j] = 0;
					}else{
						rdp[i][j] = rsearch(i,j);
					}
				}else{
					if(map[i][j] == '#'){
						rdp[i][j] = 0;
					}else if(rdp[i][j-1] != 0){			//1個前が0じゃないなら同じ
						rdp[i][j] = rdp[i][j-1];
					}else{
						rdp[i][j] = rsearch(i,j);
					}
				}
			}
		}
		
//		for(int i = 0;i < h;i++){
//			for(int j = 0;j < w;j++){
//				System.out.print(rdp[i][j]);
//			}
//			System.out.println();
//		}
//		
//		System.out.println();

		int[][] cdp = new int[h][w];
		
		for(int i = 0;i < h;i++){				//たて方向のdp
			for(int j = 0;j < w;j++){
				if(i == 0){
					if(map[i][j] == '#'){
						cdp[i][j] = 0;
					}else{
						cdp[i][j] = csearch(i,j);
					}
				}else{
					if(map[i][j] == '#'){
						cdp[i][j] = 0;
					}else if(cdp[i-1][j] != 0){			//1個前が0じゃないなら同じ
						cdp[i][j] = cdp[i-1][j];
					}else{
						cdp[i][j] = csearch(i,j);
					}
				}
			}
		}
		

//		for(int i = 0;i < h;i++){
//			for(int j = 0;j < w;j++){
//				System.out.print(cdp[i][j]);
//			}
//			System.out.println();
//		}

		int ans = 0;
		for(int i = 0;i < h;i++){
			for(int j = 0;j < w;j++){
				if(rdp[i][j] + cdp[i][j]-1 > ans){
					ans = rdp[i][j] + cdp[i][j]-1;
				}
			}
		}
		System.out.println(ans);

	}
	
	static int rsearch(int y,int x){
		
		int count = 0;
		while(x < map[0].length && map[y][x] != '#'){
			count++;
			x++;
		}
		return count;	
		
	}

	static int csearch(int y,int x){
		
		int count = 0;
		while(y < map.length && map[y][x] != '#'){
			count++;
			y++;
		}
		return count;	
	}


	static boolean checkswitch(int bit,int[] k,ArrayList<ArrayList<Integer>> list,int[] p,int m){

		//		System.out.println("bit " + bit);

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

			ArrayList<Integer> sub = list.get(i);
			int onnum = 0;						//onの数
			for(int j = 0;j < sub.size();j++){
				//				System.out.println("sub "+ sub.get(j));
				if((bit & (1 << sub.get(j))) != 0){				//目的のスイッチがついているか
					onnum++;
					//					System.out.println("on  ");
				}

			}
			if(onnum % 2 != p[i]){				//一個でも電球がつかなかったらout
				return false;
			}

		}


		return true;

	}

	static int gcd(int a,int b){				//最大公約数を返す
		if(b == 0){
			return a;
		}else{
			return gcd(b, a%b);
		}
	}





}



class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return  otherpair.end - end;
	}
}




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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  ll a, b, v, w, t;
  cin >> a >> v >> b >> w >> t;
  ll A = v*t;
  ll B = w*t;
  if(A >= B + abs(a-b)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (auto &i : a) {
		cin >> i;
	}
	auto b(a);
	sort(b.begin(), b.end());
	map<int, int> m;
	for (int i = 0; i < n; i++) {
		m[b[i]] = i;
	}
	for (auto &i : a) {
		cout << (2 * m[i] < n ? b[n / 2] : b[n / 2 - 1]) << endl;
	}
	return 0;
}

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

int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	for (int i = 0; i < n; i++)cin >> a.at(i);
	sort(a.begin(), a.end());
	vector<ll>b;
	while (a.size() > 1) {
		b.clear();
		b.push_back(a.at(0));
		for (int i = 1; i < a.size(); i++) {
			ll x = a.at(i) % a.at(0);
			if (x != 0)b.push_back(x);
		}
		a = b;
		sort(a.begin(), a.end());
	}
	cout << a.at(0) << endl;
}

Measured memory_bytes: 2168
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re
# from functools import lru_cache # 簡単メモ化 @lru_cache(maxsize=1000)
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb

# slist = "abcdefghijklmnopqrstuvwxyz"
A = int(input())
B = int(input())

num = A-B
if num>0:
    ans = "GREATER"
elif num==0:
    ans = "EQUAL"
else:
    ans = "LESS"

print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Measured memory_bytes: 2940
#!/usr/bin/env python3
import collections
import itertools as it
import math
#import numpy as np
 
#  = input()
n  = int(input())
#  = map(int, input().split())
a  = list(map(int, input().split()))
#  = [int(input()) for i in range(N)]
#
c = collections.Counter(a)

ans = 0

for c_ in c.items():
    if c_[0] > c_[1]:
        ans += c_[1]
    elif c_[0] < c_[1]:
        ans += c_[1] - c_[0]

print(ans)


Measured memory_bytes: 18420
#include<iostream>
#include<algorithm>
#include<stdlib.h>
#include<math.h>
#include<string>

using namespace std;



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

	if (a == 7, b == 5 && c == 5) {
		cout << "YES" << endl;
	}
	else if (b == 7, a == 5 && c == 5) {
		cout << "YES" << endl;
	}
	else if (c == 7, a == 5 && b == 5) {
		cout << "YES" << endl;
	}
	else {
		cout <<" NO" << endl;
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {


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

    private void solve() throws IOException {
        BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);

        StringTokenizer tokenizer = new StringTokenizer(f.readLine());
        int a = Integer.parseInt(tokenizer.nextToken());
        int b = Integer.parseInt(tokenizer.nextToken());
        int c = Integer.parseInt(tokenizer.nextToken());
        int k = Integer.parseInt(f.readLine());
        int needed = 0;
        while (b <= a) {
            b *= 2;
            needed++;
        }
        while (c <= b) {
            c *= 2;
            needed++;
        }

        if (needed <= k) {
            out.println("Yes");
        } else {
            out.println("No");
        }
        out.close();
    }
}

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

int main(){
	char str[1000];
	char table[] = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
	int i,j;
	int length;
	
	scanf("%s", &str);
	
	length = (int)strlen(str);
	//printf("%d", length);
	
	for(i=0; i<length;i++){
		for(j=0;j<26;j++){
			if( table[j] == str[i] ) break;
		}
		
		//printf("%c", str[i]);
		str[i] = table[(26+(j-3))%26];
	}
	
	printf("%s\n", str);
	
	return 0;
}

Measured memory_bytes: 524
n, x, y = map(int, input().split())

ans = [0] * n
for i in range(1, n):
    for j in range(i + 1, n + 1):
        d = min(j - i, abs(x - i) + 1 + abs(y - j))
        ans[d] += 1
print(*ans[1:], sep="\n")

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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int nCr(int n, int r) {
    int ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main(){
    int n;
    cin >> n;
    ll a[5]={};
    REP(i,n){
        string s;
        cin >> s;
        if(s[0]=='M')a[0]++;
        if(s[0]=='A')a[1]++;
        if(s[0]=='R')a[2]++;
        if(s[0]=='C')a[3]++;
        if(s[0]=='H')a[4]++;
    }
    ll ans = 0;
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k = j+1;k<5;k++){
                ans += a[i]*a[j]*a[k];
            }
        }
    }
    COUT(ans);
    return 0;
}  


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

int main() {
    int n;
    std::cin >> n;
    n *= 2;
    auto v = std::vector<int>(n);
    for (int i = 0; i < n; ++i)
        std::cin >> v[i];
    std::sort(v.begin(), v.end());
    std::reverse(v.begin(), v.end());
    int res = 0;
    for (size_t i = 0; i + 2 <= v.size(); i += 2)
        res += v[i + 1];
    std::cout << res << std::endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define F first
#define S second
#define int long long
#define ll long long
//#define int  unsigned long long
#define pb push_back
#define double long double

using namespace std;
using namespace __gnu_pbds;
typedef  tree< int , null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
const int N = 6100000;
const int K = 19;
const int mod = 1e9 + 7;
int dp[N], s[N];
main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int n;
    cin >> n;
    dp[1] = n;
    s[1] = n;
    for (int i = 2; i <= n; i++){
        dp[i] = (dp[i - 1] +  (n - 1) * (n - 1)) % mod;;
        if (i >= 4){
            dp[i] = (dp[i] + s[i - 3]) % mod;
            dp[i] = (dp[i] + n - i + 2) % mod;
        } else dp[i] = (dp[i] + n - 1) % mod;
        s[i] = (s[i - 1] + dp[i]) % mod;
     //   cout << dp[i] << endl;
    }
    cout << dp[n];
}


Measured memory_bytes: 18688
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	void run() {
		Scanner sc = new Scanner(System.in);
		int M = sc.nextInt();
		System.out.println(48-M);
		sc.close();
	}

	void debug(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}

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

Measured memory_bytes: 23508
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    ll n;
    cin >> n;
    vector<int> a;
    while (1) {
        n--;
        a.push_back(n % 26);
        n /= 26;
        if (n == 0)
            break;
    }
    for (int i = a.size() - 1; i >= 0; i--)
        cout << (char)('a' + a[i]);
    cout << endl;
    
    return 0;
}


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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pl;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}
 
bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

ll minll(ll a, ll b){
    if(a >= b)  return b;
    else    return a;
}

ll maxll(ll a, ll b){
    if(a >= b)  return a;
    else    return b;
}

const int SIZE = 1e5+100;
ll n;
ll a[SIZE],b[SIZE];


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

    ll ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i; j < i+2; j++){
            if(b[i] >= a[j]){
            b[i]-=a[j];
            ans += a[j];
            a[j] = 0;
        }
        else{
                ans += b[i];
                a[j] -= b[i];
                b[i] = 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL<<60;

ll GCD(ll x,ll y){
    if(y == 0) return x;
    else return GCD(y,x%y);
}

ll LCM(ll a,ll b){
    return a / GCD(a,b) * b;
}

const int MOD = 1000000007;

int main() {
    int n,m; cin >> n >> m;
    set<int> s;
    for(int i = 0;i < m;i++){
        int x; cin >> x;
        s.insert(x);
    }
    
    if(m == 0){
        cout << n;
        return 0;
    }
    
    int ans = 200;
    int ans1 = 0;
    for(int i = 0;i <= 101;i++){
        if(s.count(i) == 0){
            if(ans > abs(n-i)){
                ans = abs(n-i);
                ans1 = i;
            }
        }
    }
    cout << ans1;
}



Measured memory_bytes: 3596
# -*- coding: utf-8 -*-


def main():
    import sys
    input = sys.stdin.readline

    numbers = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
    k = int(input())
    print(numbers[k - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n=0,m,a,b,c,d,e;
	long double z,w;
	string str,str2,str3;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b;
	if((a*b*(a+b))%3==0){cout<<"Possible";}
	else{cout<<"Impossible";}
	





	cout<<endl;
} 


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long x,a,b;
    scanf("%ld%ld%ld", &x, &a, &b);

    if(b<=a) {
        printf("delicious\n");
    }
    else if(b>a && b<=x+a) {
        printf("safe\n");
    }
    else {
        printf("dangerous\n");
    }

    return 0;
}


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

int main(){
	int x,y;
	cin >> x >> y;
	int sum = 4*x;
	if(y == 2*x || y == sum){
		cout << "Yes" << endl;
		return 0;
	}
	rep(i,x){
		sum -= 2;
		if(sum == y){
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 3624