akhauriyash/Code-Regression huggingface dataset:
n = int(input())
arr = [0] * n
for i in range(n):
	arr[i] = int(input())

max_profit = arr[1] - arr[0]
min_price = arr[0]
for i in range(1, n):
	current = arr[i]
	max_profit = max(max_profit, current - min_price)
	min_price = min(min_price, current)

print(max_profit)


Measured memory_bytes: 13368
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+5;
int n;
struct node
{
	int x,y;
}a[maxn];
int main()
{
	scanf("%d",&n);
	int cnt=0;
	if(n%2==0){
		int alfa=n+1;
		for(int i=1;i<=n;i++){
			int x=alfa-i;
			for(int j=i+1;j<=n;j++){
				if(j!=x)a[++cnt].x=i,a[cnt].y=j;
			}
		}
		printf("%d\n",cnt);
		for(int i=1;i<=cnt;i++)
		printf("%d %d\n",a[i].x,a[i].y);
	}
	else{
		int alfa=n;
		for(int i=1;i<=n;i++){
			int x=alfa-i;
			for(int j=i+1;j<=n;j++){
				if(j!=x)a[++cnt].x=i,a[cnt].y=j;
			}
		}
		printf("%d\n",cnt);
		for(int i=1;i<=cnt;i++)
		printf("%d %d\n",a[i].x,a[i].y);
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cstring>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

#define SPLIT 20
template<typename T, T zero>
struct PersistentArray{
  struct vertex{
    T dat;
    vertex* ch[SPLIT];
    vertex(){};
  };
  vertex* root = nullptr;
  ll ver = 0;
  vector<vertex*> version;//指定したバージョンのルート
  vertex* set(ll idx, T x, vertex* par){
    vertex* now = new vertex();
    if(par) {
      memcpy(now->ch, par->ch, sizeof(par->ch));
      now->dat = par->dat;
    }
    if(idx==0) now->dat = x;
    else now->ch[idx%SPLIT] = set(idx/SPLIT, x, now->ch[idx%SPLIT]);
    return now;
  }

  ll update(ll prev, ll idx, T x){
    vertex* now = set(idx, x, (prev==-1?root:version[prev]));
    version.push_back(now);
    return ver++;
  }

  T query(ll prev, ll idx){
    vertex* now = version[prev];
    while(idx){
      now = now->ch[idx%SPLIT];
      idx/=SPLIT;
    }
    if(!now) return zero;
    return now->dat;
  }
};

int main(){
  PersistentArray<ll, 0> ar;
  ll n, k;std::cin >> n >> k;
  for(int i=0;i<n;i++){
    ll t;scanf("%lld", &t);
    ar.update(i-1, i, t);
  }
  vll a;
  for(int i=0;i<n;i++){
    a.push_back(ar.query(n-1, i));
  }
  sort(all(a));
  ll ans = 0;
  for(int i=0;i<k;i++) ans += a[i];
  std::cout << ans << '\n';
}


Measured memory_bytes: 4328
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
#define TEN5 100000 //10^5
#define TEN9 1000000000 //10^9
using namespace std;
using ll = long long;
using PII = pair<int, int>;
const int INF = numeric_limits<int>::max();

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

int main()
{
    int h, w; cin >> h >> w;
    char a[h][w];
    rep(i,h) {
        rep(j,w) {
            cin >> a[i][j];
        }
    }
    
    int flag = 1;
    set<PII> s;
    for(int i = 0; i < h; i++) {
        if (a[i][0] == '.') {
            int line = 1;
            rep(j,w) {
                if (a[i][j] == '#')
                    line = 0;
            }
            if (line) {
                rep(j,w) {
                    s.emplace(i,j);
                }
            }
        }
    }

    for(int i = 0; i < w; i++) {
        if (a[0][w] == '.') {
            int line = 1;
            rep(j,h) {
                if (a[j][i] == '#')
                    line = 0;
            }
            if (line) {
                rep(j,h) {
                    s.emplace(j,i);
                }
            }
        }
    }

    rep(i,h){
        int flag = 0;
        rep(j,w) {
            auto itr = s.find(make_pair(i,j));
            if (itr == s.end()) {
                cout << a[i][j];
                flag = 1;
            }
        }
        if (flag)
            cout << endl;
    }
        
    return 0;
}



Measured memory_bytes: 768
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>

using namespace std;

int count(char p, vector<char> s) {
	int result = 0;

	while (true) {
		bool isSame = true;
		vector<char> temp;

		for (int i = 0; i < s.size() - 1; i++) {
			if (s[i] != p) {
				isSame = false;
				temp.push_back(s[i + 1]);
			} else {
				temp.push_back(s[i]);
			}
		}

		if (isSame && s[s.size() - 1] == p)
			break;

		s = temp;
		result++;
	}
	return result;
}

int main() {
	string str;
	vector<char> s;

	getline(cin, str);
	for (int i = 0; i < str.length(); i++)
		s.push_back(str[i]);

	int min_op = s.size();
	set<char> chars;

	for (int i = 0; i < s.size(); i++) {
		if (chars.insert(s[i]).second) {
			int temp = count(s[i], s);
			min_op = min(temp, min_op);
		}
	}

	cout << min_op << endl;
}

Measured memory_bytes: 256
from heapq import heappush, heappop
INF = 10 ** 20

while True:
  c, n, m, s, d = map(int, input().split())
  s -= 1
  d -= 1
  if c == 0:
    break
  edges = [[] for _ in range(n * (c + 1))]
  for _ in range(m):
    a, b, f = map(int, input().split())
    a -= 1
    b -= 1
    for i in range(c + 1):
      edges[a + i * n].append((b + i * n, f))
      edges[b + i * n].append((a + i * n, f))
      if i != c:
        edges[a + i * n].append((b + (i + 1) * n, f // 2))
        edges[b + i * n].append((a + (i + 1) * n, f // 2))
  for i in range(c):
    edges[d + i * n].append((d + (i + 1) * n, 0))

  cost = [INF] * (n * (c + 1))
  que = []
  heappush(que, (0, s))
  while que:
    total, point = heappop(que)
    for to, fee in edges[point]:
      if cost[to] > total + fee:
        cost[to] = total + fee
        heappush(que, (total + fee, to))
  print(cost[d + n * c])



Measured memory_bytes: 7488
// copied by Nurstan Duisengaliev
// skatal
#include <bits/stdc++.h>
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) x.size()
#define int ll 
using namespace std;
 
const int N = (int)1e7 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 7;
ll fac[N];
ll binpow (int x, int y) {
	if (y == 0) return 1;
	if (y % 2 == 0) {
		ll o = binpow (x, y / 2);
		return (o * o) % mod;
	}	
	else {
		return ((binpow (x, y - 1) * x) % mod);
	}
}
ll cnk (int n, int k) {
	ll x = fac[n];
	ll y = (fac[k] * fac[n - k]) % mod;
	return (x * binpow (y, mod - 2)) % mod;	
}
void solve () {
	int n, m;
	cin >> n >> m;
	fac[0] = 1;
	for (int i = 1; i <= (int)1e7 + 3; i ++) {
		fac[i] = fac[i - 1] * i;
		fac[i] %= mod;
	} 
	ll ans = 0;
	for (int i = 0; i <= n; i ++) {
		int x = i, y = 2 * i;
		if (x <= n && y <= m) {
			int b = m - y;
			if (2 * b + x == n) {
				ans += cnk (i + b, b);    
				ans %= mod;
			}
		}			
	}
	cout << ans;
}
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//	cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 78336
from operator import itemgetter

n, m = map(int, input().split())

# 区間の終端でソート
ab = sorted([tuple(map(int, input().split())) for i in range(m)], key=itemgetter(1))
# 前回除いた橋
removed = -1
ans = 0

for a, b in ab:
    # a が removed より大きい = まだ取り除いてない
    if a > removed:
        removed = b - 1
        ans += 1

print(ans)

Measured memory_bytes: 24788
#include <cstdio>
#include <climits>

int merge(int *A, int left, int mid, int right){
    int i, j;
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1];
    int R[n2+1];
    for(i=0;i<n1;i++)L[i]=A[left+i];
    for(i=0;i<n2;i++)R[i]=A[mid+i];
    L[n1] = INT_MAX;
    R[n2] = INT_MAX;
    i = 0;
    j = 0;
    for(int k=left;k<right;k++){
        if(L[i]<R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
    }
    return right - left;
}

int mergeSort(int *A, int left, int right){
    if(left+1>=right)return 0;
    int c = 0;
    int mid = (left + right)/2;
    c += mergeSort(A, left, mid);
    c += mergeSort(A, mid, right);
    c += merge(A, left, mid, right);
    return c;
}

int main(){
    int i, n, c;
    scanf("%d",&n);
    int s[n];
    for(i=0;i<n;i++)scanf("%d",s+i);
    c = mergeSort(s, 0, n);
    for(i=0;i<n;i++){
        printf("%d",s[i]);
        if(i<n-1)printf(" ");
        else printf("\n");
    }
    printf("%d\n",c);
    return 0;
}



Measured memory_bytes: 6500
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
N,x = map(int,input().split())
As = list(map(int,input().split()))
Bs = As[:]
for i in range(1,N):
    s = As[i] + As[i-1]
    if s > x:
        As[i] = max(0, As[i] - (s - x))
    s = As[i] + As[i-1]
    if s > x:
        As[i-1] = As[i-1] - (s - x)
ans = sum(b - a for a, b in zip(As, Bs))
print(ans)

    
    


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

int main(){
  string w, ans = "Yes";
  char c;
  int pos_s, pos_e;
  
  cin >> w;
  sort(w.begin(), w.end());
  for (c = 'a'; c <= 'z'; c++) {
    pos_s = w.find(c);
    pos_e = w.rfind(c);
    if ((pos_s != string::npos) && (pos_e - pos_s)%2 == 0) ans = "No";
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <map>
#include <vector>
#include <cstring>
#include <ostream>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

template <typename T>
std::ostream& operator << (std::ostream& os, std::vector<T> v) {
  for (int i = 0; i < int(v.size()); ++i) {
    os << v[i] << "\n";
  }
  return os;
}

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

  std::map<int, int> mp;
  int N;
  std::vector<int> a;

  cin >> N;
  a.resize(N);

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

  for (int i = 0; i < N; ++i) {
    mp[a[i]]++;
    mp[a[i] - 1]++;
    mp[a[i] + 1]++;
  }

  int ans = 0;

  for (int i = -1; i <= 100000; ++i) {
    ans = std::max(ans, mp[i]);
  }

  cout << ans << endl;

  system("pause");
  return 0;
}


Measured memory_bytes: 5624
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long

void solve()
{
    double H, W, N;
    cin >> H;
    cin >> W;
    cin >> N;

    if (H > W)
    {
        cout << ceil(N / H) << endl;
    }
    else
    {
        cout << ceil(N / W) << endl;
    }

    return;
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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 (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
ll gcd(ll a, ll b)
{
    if (a < b) return gcd(b, a);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll lcm(ll a, ll b)
{
    return (a * b) / gcd(a, b);
}

void _main()
{
    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;
    const ll L = lcm(N, M);
    map<ll, char> m;
    rep(i, 0, N)
    {
        m[i * (L / N)] = S[i];
    }
    bool ok = true;
    rep(i, 0, M)
    {
        if (m.count(i * (L / M)) == 0)
        {
            m[i * (L / M)] = T[i];
        }
        else if (m[i * (L / M)] != T[i])
        {
            ok = false;
            break;
        }
    }
    cout << (ok ? L : -1) << endl;
}


Measured memory_bytes: 10880
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  cin>>n;
  set<int>st;
  for(int i=0;i<n;i++)
  {
    int x;
    cin>>x;
    if(st.find(x)!=st.end())
    {
      st.erase(x);
    }
    else st.insert(x);
  }
  cout<<st.size()<<endl;
}


Measured memory_bytes: 4864
#include<iostream>
#include<string>
#include<algorithm>
#include <stdio.h>
#include<iostream>
#include<iomanip>
#include<cmath>
#include<array>
#include<vector>
#include<set>
#include <utility>
#include <map>
#include<bitset>

using namespace std;



int main(){
string s,t; cin >>s>>t;
cout<<t<<s<<endl;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int n = sc.nextInt();
		int m = sc.nextInt();
		
		
		// 計算
		long result = 0;
		int MOD = 1000000007;
		if(abs(n-m) <= 1){
		    long[] f = fact(max(n,m), MOD);
		    if(n == m){
		        result = f[n]*f[m]%MOD*2%MOD;
		    }else{
		        result = f[max(n, m)]*f[min(n, m)]%MOD;
		    }
		}
		
		// 出力
		System.out.println(result);
	}
	
	public static long[] fact(int n, long MOD) {
		long[] f = new long[n+1];
		for(int i = 0; i < n+1; i++){
			if(i == 0) f[i] = 1;
			if(i > 0) f[i] = (f[i-1]*i)%MOD;
		}
		return f;
	}
}


Measured memory_bytes: 23764
import Control.Applicative ((<$>), (<*>))
import Control.Monad
import Data.List
import qualified Data.IntMap as IM

main :: IO ()
main = do
  n <- getl toInt
  unless (n == 0) $ do
    xs <- rgetl n $ split toInt
    let rs = solve xs
    if null rs then putStrLn "NA" else mapM_ print rs
    main

solve :: [[Int]] -> [Int]
solve xs = (nub $ map (!! 0) xs) `intersect` cs
  where
    im = foldl (\m [i,t,s] -> IM.insertWith (+) i ((fromIntegral t) * (fromIntegral s)) m) IM.empty xs :: IM.IntMap Integer
    cs = IM.keys $ IM.filter (>= 1000000) im

toInt :: String -> Int
toInt s = read s

toIex :: String -> Integer
toIex s = read s

split :: (String -> a) -> String -> [a]
split f = map f . words

getl :: (String -> a) -> IO a
getl f = f <$> getLine

rgetl :: Int -> (String -> a) -> IO [a]
rgetl n f = map f <$> replicateM n getLine

Measured memory_bytes: 5484
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc()) 
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int MOD = (int)(1e9 + 7);
inline void Add(int &x,int y) {
  x = x + y >= MOD ? x + y - MOD : x + y;
}
inline void Sub(int &x,int y) {
  x = x - y < 0 ? x - y + MOD : x - y;
}
int power(int a,int b) {
  int ret = 1;
  while (b) {
    if (b&1) ret = 1ll * ret * a % MOD;
    a = 1ll * a * a % MOD;
    b >>= 1;
  }
  return ret;
}

const int N = 16, SZ = 100000;
int n, m, val[N + 10], dp[N + 10][1 << N];
int jc[SZ], ijc[SZ];
int comb(int a,int b) {
  if (a < b || b < 0) return 0;
  return 1ll * jc[a] * ijc[b] % MOD * ijc[a-b] % MOD;
}
void prework(int sz) {
  jc[0] = 1;
  rep (i, 1, sz) jc[i] = 1ll * jc[i-1] * i % MOD;
  ijc[sz] = power(jc[sz], MOD - 2);
  rrp (i, sz-1, 0) ijc[i] = 1ll * ijc[i+1] * (i+1) % MOD;
}
int ans;
int main() {
  read(n), read(m);
  rep (i, 1, m)
    read(val[i]), -- val[i];
  prework(1 << n);
  dp[m+1][0] = 1;
  rrp (i, m, 1) {
    rep (s, 0, (1 << n) - 1) {
      Add(dp[i][s], dp[i+1][s]);
      int num = (1 << n) - 1 - val[i];
      rep (j, 0, n-1) if ((s >> j)&1)
	num -= (1 << j);
      rep (j, 0, n-1) if (!((s >> j)&1)) {
	Sub(dp[i][s | (1 << j)], 1ll * dp[i+1][s] * comb(num, (1 << j) - 1) % MOD);
      }
    }
  }
  rep (s, 0, (1 << n) - 1) {
    int num = (1 << n) - 1;
    rep (j, 0, n-1) if ((s >> j)&1)
      num -= (1 << j);
    int tmp = dp[1][s];
    rep (j, 0, n-1) if (!((s >> j)&1)) {
      tmp = 1ll * tmp * comb(num, 1 << j) % MOD;
      num -= (1 << j);
    }
    Add(ans, tmp);
  }
  rep (j, 0, n-1)
    ans = 1ll * ans * jc[1 << j] % MOD;
  ans = 1ll * ans * (1 << n) % MOD;
  cout << ans << endl;
  return 0;
}


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


bool bChk( const int iNum )
{
int i;
int j;
int iDigit;
int n;
int iA[ 20 ];

	n = iNum;
	i = 0;
	while( n > 0 )
	{
		iA[ i ] = n % 10;
		n /= 10;
		i++;
	}

	iDigit = i;

	i = 0;
	j = iDigit - 1;
	while( i < j )
	{
		if( iA[ i ] != iA[ j ] ) return false;

		i++;
		j--;
	}

	return true;
}

int main()
{
int i;
int A;
int B;
int iCnt;

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> A;
	cin >> B;

	iCnt = 0;
	for( i = A; i <= B; i++ )
 	{
 		if( bChk( i ) ) iCnt++;
 	}

	cout << iCnt << endl;

	return 0;
}






Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
using namespace std;
using namespace std::chrono;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const int mod=998244353 ;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

int main(void){
	cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);
	//n問中、上位P問が採用
	llint n,M,V,P,i;cin>>n>>M>>V>>P;
	vector<llint>A(n);
	REP(i,n){cin>>A[i];}
	SO(A);REV(A);
	llint bmin=P-1,bmax=n;
	while(bmax-bmin>1){
		llint bgen=(bmax+bmin)/2;
		llint wa=0;
		for(i=P-1;i<n;i++){
			if(i==bgen){continue;}
			wa+=min(M,max(A[bgen]+M-A[i],0LL));
		}
		if(A[bgen]+M>=A[P-1]&&wa>=M*(V-P)){bmin=bgen;}
		else{bmax=bgen;}
	}
	cout<<bmin+1<<endl;
	return 0;
}



Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,ans=0,num=1;cin>>a>>b;
  while(num<b) {num+=a-1;ans++;}
  print(ans);
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
    public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    while(true){
    int n=0,i,j;
    double sum=0,a=0,b=0;
    n=sc.nextInt();
    if(n==0){
        break;
    }
    int []d =new int[n];
    for(i=0;i<n;i++){
        d[i]=sc.nextInt();
        sum=sum+d[i];
    }
    sum=sum/n;
    for(j=0;j<n;j++){
        a = a+ Math.pow(d[j]-sum,2);
    }
        a= a/n;
        b=Math.sqrt(a);
    
    System.out.println(b);


}

    }
}


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

const int N = 100;
char a[N*2+3];
int n,m; llong ans;

int main()
{
	scanf("%s",a+1); n = strlen(a+1);
	scanf("%d",&m);
	ans = 0;
	for(int i=2,f=0; i<=n; i++)
	{
		if(a[i]==a[i-1]&&f==0) {f = 1; ans++;}
		else {f = 0;}
	}
	if(m==1) {printf("%lld\n",ans); return 0;}
	int l = 1,r = n+1;
	for(int i=1; i<=n; i++)
	{
		if(a[i]!=a[1]) {l = i; break;}
	}
	if(l==1)
	{
		printf("%lld\n",(1ll*n*m)>>1);
		return 0;
	}
	for(int i=n; i>=1; i--)
	{
		if(a[i]!=a[1]) {r = i; break;}
	}
	ans *= m;
	if(((l-1)&1)&&((n-r)&1)) {ans += m-1;}
	printf("%lld\n",ans);
	return 0;
}

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

using namespace std;

int main(){
	
	int N;
	cin >> N;
	vector<int> vec(N);
	
	for(int i=0; i<N; i++){
		cin>>vec.at(i);
	}
	
	std::sort(vec.begin(), vec.end());
	
	cout<< std::abs(vec.at(N-1) - vec.at(0)) << endl;
	
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ll dx[]={0,1,0,-1};
ll dy[]={1,0,-1,0};
ll n,m;
string *s;
bool chk(ll x,ll y,ll n,ll m)
{
    return (x<n && x>=0 && y<m && y>=0);
}
ll solve(ll x1,ll y1, ll x2,ll y2)
{
    ll dp[n][m];
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++)
        dp[i][j]=1e8;
    dp[x1][y1]=0;
    queue<pair<ll,ll> >q;
    q.push(make_pair(x1,y1));
    while(!q.empty())
    {
        pair<ll,ll> p=q.front();
        ll x=p.first;ll y=p.second;
        q.pop();
        for(int i=0;i<4;i++)
        {
            ll xx=x+dx[i];
            ll yy=y+dy[i];

            if(chk(xx,yy,n,m) && s[xx][yy]=='.')
            {

                if(dp[xx][yy] > dp[x][y]+1)
                {
                    dp[xx][yy]=dp[x][y]+1;
                    q.push(make_pair(xx,yy));
                }
            }
        }
    }

    return dp[x2][y2];
}
int main()
{
  cin>>n>>m;
  s=new string[n];
  for(int i=0;i<n;i++)
    cin>>s[i];
    ll ans=0;
  for(int x1=0;x1<n;x1++)
  {
      for(int y1=0;y1<m;y1++)
      {
          for(int x2=0;x2<n;x2++)
          {
              for(int y2=0;y2<m;y2++)
              {
                  if(s[x1][y1]=='.' && s[x2][y2]=='.'){
                    ans=max(ans,solve(x1,y1,x2,y2));
                  }
              }
          }
      }
  }
  cout<<ans;
}


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

  
int main () 
{ 
    //stack <int> s; 
    int n,m;
    cin>>n>>m;
    int a[m];
    for(int i=0;i<m;i++)
    cin>>a[i];
         
    ll s=0;
    for(int i=0;i<m;i++)
    s+=a[i];
    
    if(n-s>=0)
    cout<<n-s<<endl;
    else
    cout<<-1<<endl;
     /*for(int i=1;i<=n;i++)
     cout<<a[i]<<" ";
     cout<<endl;*/
  
    return 0; 
} 

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

int main() {
    int a, b, c, k, tem, ans;
    
    cin >> a >> b >> c >> k;
    ans = a + b + c - max({a, b, c});
    
    tem = max({a, b, c});
    for ( int i = 0; i < k; i++ ) {
        tem *= 2;
    }
    cout << ans + tem << endl;
    
    return (0);
}

Measured memory_bytes: 3632
from heapq import heappop, heappush
n, m = map(int, input().split())
X = sorted([list(map(int, input().split())) for _ in range(n)], key = lambda x: x[0])
hq = []
ans, j = 0, 0
for i in range(1, m + 1):
  while (j < n) and (X[j][0] <= i):
    heappush(hq, -X[j][1])
    j += 1
  if len(hq):
    ans += -heappop(hq)
print(ans)

Measured memory_bytes: 31896
#include <iostream>

#define INFTY 1<<30

using namespace std;

long long count = 0;

void merge(int a[], int left, int mid, int right){
	int n1 = mid - left;
	int n2 = right - mid;
	int l[n1], r[n2];
	for(int i=0; i<n1; i++) l[i] = a[left+i];
	for(int i=0; i<n2; i++) r[i] = a[mid+i];
	l[n1] = INFTY;
	r[n2] = INFTY;
	int i=0;
	int j=0;

	for(int k=left; k<right; k++){
		if(l[i] <= r[j]){
			a[k] = l[i];
			i++;
		}else{
			a[k] = r[j];
			count += n1 - i;
			j++;
		}
	}
}

void mergeSort(int a[], int left, int right){
	if(left+1 < right){
		int mid = (left + right)/2;
		mergeSort(a, left, mid);
		mergeSort(a, mid, right);
		merge(a, left, mid, right);
	}
}

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

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

	mergeSort(array, 0, n);

	cout << count << endl;

	return 0;
}


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

#define ll long long

ll a[200001];

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

	ll n;cin>>n;
	ll k;cin>>k;
	for (ll i=0; i<n; i++) cin>>a[i];sort(a,a+n);
	
	ll lo=-2e18,hi=2e18,ans=0;
	while (lo<=hi){
		ll mid=(lo+hi)>>1,cnt=0;
		for (int i=0; i<n; i++){
			if (a[i]<0){
				ll Lo=0,Hi=n-1,Ans=n;
				while (Lo<=Hi){
					ll Mid=(Lo+Hi)>>1;
					if (a[Mid]*a[i]<=mid) Hi=Mid-1,Ans=Mid;
					else Lo=Mid+1;
				}
				cnt+=n-Ans;
			}
			else{
				ll Lo=0,Hi=n-1,Ans=-1;
				while(Lo<=Hi){
					ll Mid=(Lo+Hi)>>1;
					if(a[Mid]*a[i]<=mid) Lo=Mid+1,Ans=Mid;
					else Hi=Mid-1;
				}
				cnt+=Ans+1;
			}
			if (a[i]*a[i]<=mid) cnt--;
		}
		cnt/=2;
		if(cnt>=k) ans=mid,hi=mid-1;
		else lo=mid+1;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define repr(i, n) for(int i=n-1; i>=0; i--)
#define repr1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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; }

template<int MOD> struct modint {
    long long val;
    constexpr modint(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr modint operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr modint operator + (const modint& r) const noexcept { return modint(*this) += r; }
    constexpr modint operator - (const modint& r) const noexcept { return modint(*this) -= r; }
    constexpr modint operator * (const modint& r) const noexcept { return modint(*this) *= r; }
    constexpr modint operator / (const modint& r) const noexcept { return modint(*this) /= r; }
    constexpr modint& operator += (const modint& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr modint& operator -= (const modint& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr modint& operator *= (const modint& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr modint& operator /= (const modint& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const modint& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const modint& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const modint<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr modint<MOD> modpow(const modint<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = modint<MOD>;

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

    vector<ll> cnt(26, 1);
    rep(i, n) {
        cnt[s[i] - 'a']++;
    }

    mint ans = 1;
    rep(i, 26) {
        ans *= mint(cnt[i]);
    }
    cout << ans - 1 << endl;

}


Measured memory_bytes: 512
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define BUF_SIZE 20
#define DIVISOR 1000000007

// size: specify sizeof(str)
int get_str(char *str, int size) {
    if(!fgets(str, size, stdin)) return -1;
    return 0;
}

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

int get_int2(int *a1, int *a2) {
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return -1;
  sscanf(line, "%d %d", a1, a2);
#else
#error
#endif
  return 0;
}

int main(void) {
    int n, k;
    get_int2(&n, &k);

    int pat, i;
    for(pat = 0; pat < (1<<n); pat++) {
        if(__builtin_popcount(pat)!=k) continue;
        printf("%d:", pat);
        for(i = 0; i < n; i++) {
            if(!(pat & (1<<i))) continue;
            printf(" %d", i);
        }
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 2088
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_imports)]
use std::collections::HashSet;
use std::collections::HashMap;
use std::collections::BTreeSet;
use std::collections::VecDeque;
use std::cmp::{max, min};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        n: usize,
        a: [i64; n],
    }
    let mut two = 0;
    let mut four = 0;
    for i in a.iter() {
        if i % 4 == 0 {
            four += 1;
        } else if i % 2 == 0 {
            two += 1;
        }
    }
    let no = n - four - two;
    if no <= four {
        println!("Yes");
    } else if no <= four + 1 && two == 0 {
        println!("Yes");
    } else {
        println!("No");
    }
}

Measured memory_bytes: 6396
import java.util.Scanner;

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

    String[] list = scanner.next().split("");
    int count = 0;
    for (String s : list) {
      if (Integer.parseInt(s) == 1) {
        count++;
      }
    }

    System.out.println(count);

    scanner.close();
  }
}


Measured memory_bytes: 21972
#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() {
    string s; cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
char g[55][55];
int dp[55][55];
int dx[4] =  {0,0,1,-1};
int dy[4] =  {1,-1,0,0};
int n,m;
bool ch(int x,int y){
	return (x>=1 and y>=1 and x<=n and y<=m);
}
int main() {
	cin>>n>>m; 
	int s = 0;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cin>>g[i][j];
			if(g[i][j]=='.')s++;
		}
	}
	queue<pair<int,int> > q;
	q.push({1,1});
	dp[1][1] = 1;
	while(!q.empty()){
		int x = q.front().first;
		int y = q.front().second;
		q.pop();
		for(int i=0;i<4;i++){
			int xx = x+dx[i];
			int yy = y+dy[i];
			if(!ch(xx,yy))continue;
			if(g[xx][yy]=='#')continue;
			if(dp[xx][yy])continue;
			dp[xx][yy] = dp[x][y]+1;
			q.push({xx,yy});
		}
	}
	if(dp[n][m])cout<<s-dp[n][m]<<endl;
	else cout<<-1<<endl;
	return 0;
}

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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

struct UnionFindSize {
    vector<int> par;
    
    UnionFindSize(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)];
    }
};


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

    ll W, H;
    cin >> W >> H;
    vector<ll> p(W), q(H);
    REP(i, W) cin >> p[i];
    REP(i, H) cin >> q[i];
    UnionFindSize ufw(W+1), ufh(H+1);

    vector<pll> r;
    REP(i, W) r.push_back({p[i], i});
    REP(i, H) r.push_back({q[i], W+i+1});
    sort(r.begin(), r.end());

    ll res = 0;
    ll Wsize = W+1, Hsize = H+1;
    REP(i, r.size()){
    	ll shu = r[i].second/(W+1);
    	ll idx = r[i].second%(W+1);
    	ll val = r[i].first;

    	if(shu==0){
    		res += (val * Hsize);
    		ufw.merge(idx, idx+1);
    		Wsize--;
    	}else{
    		res += (val * Wsize);
    		ufh.merge(idx, idx+1);
    		Hsize--;
    	}
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 8816
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
#define chmax(a, b) a = (((a)<(b))?(b):(a))
#define chmin(a, b) a = (((a)<(b))?(a):(b))

const int INF = 1001001001;
const ll MOD = 1e9+7;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){std::fill((T*)array, (T*)(array+N),val);}

class CompareDist
{
public:
    bool operator()(PLL n1,PLL n2) {
				if(n1.first!=n2.first) return n1.first<n2.first;
				else return n1.second<n2.second;
    }
};

#define lengthof(x) (sizeof(x) / sizeof(*(x)))


__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}

signed main(){
  ll n,y; cin>>n>>y;
  rep(i,n+1){
    rep(j,n+1){
      if(i+j>n) continue;
      int k = n-i-j;
      if(i*10000+j*5000+k*1000==y) return cout<<i SP j SP k<<endl,0;
    }
  }
  cout << -1 SP -1 SP -1 <<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    // cout << 100000 << " " << 100000 << endl;
    // for (int i = 1; i <= 100000; ++i)
    // {
    //     cout << i << " " << 1000000000 << endl;
    // }

    constexpr int inf = 1000000000;

    int n, a, b;
    cin >> n;
    if (n == 1)
    {
        cout << "Hello World" << endl;
    }
    else
    {
        cin >> a >> b;
        cout << a + b << endl;
    }
    

    return 0;
}

Measured memory_bytes: 256
import math
X=int(input())

if X==2:
  print(X)
  exit()

if X%2==0:
  X+=1

while True:
  for i in range(2,int(math.sqrt(X))):
    if X%i==0:
      break
  else:
    print(X)
    exit()
  X+=2

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

typedef long long ll;

void print() {
  std::cout << std::endl;
}

template<class H, class... T>
void print(H&& head, T&&... tail) {
  std::cout << head;
  if (sizeof...(tail) != 0) std::cout << " ";
  print(std::forward<T>(tail)...);
}

int main()
{
  ll K, X;
  std::cin >> K >> X;

  if (K * 500 >= X) {
    print("Yes");
  } else {
    print("No");
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> a[i];
    sum+=a[i];
  }
  int d=1e9;
  int ans;
  for(int i=0;i<n;i++){
    if(d>abs(sum-a[i]*n)){
      d=abs(sum-a[i]*n);
      ans=i;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  int h,a;
  cin >> h >> a;
  int ans=h/a;
  if(h%a!=0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _121A
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] HW = RIntAr();
            int[] hw = RIntAr();
            Console.WriteLine((HW[0]-hw[0]) * (HW[1] - hw[1]));
        }

        static string RSt() { return Console.ReadLine(); }
        static int RInt() { return int.Parse(Console.ReadLine().Trim()); }
        static long RLong() { return long.Parse(Console.ReadLine().Trim()); }
        static double RDouble() { return double.Parse(Console.ReadLine()); }
        static string[] RStAr(char sep = ' ') { return Console.ReadLine().Trim().Split(sep); }
        static int[] RIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => int.Parse(e)); }
        static long[] RLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => long.Parse(e)); }
        static double[] RDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Trim().Split(sep), e => double.Parse(e)); }
        static string WAr<T>(IEnumerable<T> array, string sep = " ") { return string.Join(sep, array.Select(x => x.ToString()).ToArray()); }
    }

}


Measured memory_bytes: 13140
N,M=map(int,raw_input().split(' '))

g=[[False for i in range(N)] for j in range(N)]
ab=[()]*M
v=[False]*N

def dfs(n):
    v[n]=True
    for i in range(N):
        if g[n][i]==True and v[i]==False:
            dfs(i)

for i in range(M):
    a,b=map(int,raw_input().split(' '))
    a-=1
    b-=1
    g[a][b]=g[b][a]=True
    ab[i]=(a,b)

ans=0
for i in range(M):
    a,b=ab[i]
    g[a][b]=g[b][a]=False

    dfs(0)

    if v!=[True]*N:
        ans+=1

    g[a][b]=g[b][a]=True
    v=[False]*N

print ans



Measured memory_bytes: 2696
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <map>
#include <cstdio>
#define fol(i,n) for(int i=0;i<n;i++)
#define db(a) cout << a<< endl;
using namespace std;


int main(){
    int n,a,cnt4=0,odd=0,cnt2=0;
    cin >>n;
    fol(i,n){
        cin >>a;
        if (a%4==0) cnt4++;
        else {
            if(a%2==0)cnt2++;
            else odd++;
        }
    }
    if (odd==0) cout << "Yes"<<endl;
    else{
        if (cnt2==0){
            if (cnt4>=odd-1) cout <<"Yes"<<endl;
            else cout <<"No"<<endl;
        }else{
            if(cnt4>=odd) cout <<"Yes"<<endl;
            else cout <<"No"<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#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() {
    int n, a, b;
    cin >> n >> a >> b;
    vector<int> v(n);
    rep (i, n) {
        cin >> v[i];
    }
    ll ans = 0;
    rep (i, n - 1) {
        ll x = v[i + 1] - v[i];
        ll y = b;
        ans += min(a * x, y);
    }
    cout << ans <<endl;

}

Measured memory_bytes: 640
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
int a,b;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> a>>b;
    if(b%a==0)  cout << a+b << "\n";
    else cout << b-a << "\n";
}

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

using namespace std;
int main() {
	long int a, b, x;
	cin >> a >> b >> x;

	long int a1 = a / x;
	long int b1 = b / x;

	if ((a%x) == 0) {
		a1 = a1 - 1;
	}
	cout << b1 - a1 << endl;

	return 0;
}
	

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

namespace ITP1
{
    class ITP1_1_D
    {
        static void Main(string[] args)
        {
            int h, m, s;

            s = int.Parse(Console.ReadLine());

            h = s / 3600;
            s %= 3600;
           
            m = s / 60;
            s %= 60;
      
            Console.WriteLine(h + ":" + m + ":" + s);
        }
    }
}



Measured memory_bytes: 15956
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<queue>

using namespace std;

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

int main() {
  while (true) {
    int n, m = 0;
    cin >> n;
    if (n == 0) break;
    vector<string> v(n);
    rep (i, n) cin >> v[i];
    map<string, int> mp;
    vector<int> edge[1111];
    bool root[1111] = {};
    rep (i, n) {
      int k = 0, r = -1;
      rep (j, v[i].size()) {
	if (!isalpha(v[i][j])) {
	  string name = v[i].substr(k, j - k);
	  k = j + 1;
	  if (v[i][j] == ':') {
	    if (mp.count(name) == 0u) {
	      r = mp[name] = m++;
	    } else {
	      r = mp[name];
	    }
	    root[r] = true;
	  } else {
	    int t = -1;
	    if (mp.count(name) == 0u) {
	      t = mp[name] = m++;
	    } else {
	      t = mp[name];
	    }
	    edge[r].push_back(t);
	  }
	}
      }
    }
    set<int> st;
    queue<int> que;
    que.push(0);
    int rr = 0;
    while (!que.empty()) {
      int now = que.front();
      que.pop();
      if (st.count(now) > 0u) continue;
      st.insert(now);
      if (root[now]) ++rr;
      rep (i, edge[now].size()) {
	que.push(edge[now][i]);
      }
    }
    cout << st.size() - rr << endl;
  }
  return 0;
}

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

int main() {
    int N;
    map<int,int> cnt;

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

    int res = 0;
    for(auto itr = cnt.begin(); itr != cnt.end(); ++itr) {
        if(itr->first <= itr->second) res += itr->second - itr->first;
        else res += itr->second;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4736
N = int(input())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]
count = 0
if N == 3:
    if x[0] == y[0] and x[1] == y[1] and x[2] == y[2]:
        count += 1
        print("Yes")

for i in range(N-3):
    if x[i] == y[i] and x[i+1] == y[i+1] and x[i+2] == y[i+2]:
        count += 1
        print("Yes")
        break

if count == 0:
    print("No")


Measured memory_bytes: 9172
import math
a,v = map(int,input().split())
b,w = map(int,input().split())
t = int(input())
kyori = abs(a-b)
sa = v-w
if sa <= 0:
	print("NO")
	exit()
if math.ceil(kyori/sa) <= t:
	print("YES")
else:
	print("NO")

Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	int no = 0;
	for(int i = 0; i != s.length(); i++)
	{
		if(s[i] == '7')
		{
			cout << "Yes"<< endl;
			no = 1;
			break;
		}
	}
	if(!no)
		cout << "No"<< endl;
}

Measured memory_bytes: 3628