akhauriyash/Code-Regression huggingface dataset:
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <iomanip>

typedef long double ld;
typedef long long ll;

using namespace std;


/* TEMPLATE ENDS HERE */

int main() {
	cout << fixed << setprecision(12);	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max(max(a * c, a * d), max(b * c, b * d)) << endl;
	return 0;
}


ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
		x %= MOD;
	}
	
	mod& operator=(const ll & tx) {
		x = tx % MOD;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return mod((x + m2.x) % MOD);
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return mod((x - m2.x + MOD) % MOD);
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return mod((x * m2.x) % MOD);
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return (*this) * m2.inv();
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}



Measured memory_bytes: 3600
#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; }


// 参考 : http://hos.ac/slides/20140319_bit.pdf
struct FenwickTree_sum { // 0-indexed !
    vector<ll> v;
    const int n;

    FenwickTree_sum(int _n) : n(_n) {
        v.resize(n+1, 0);
    }

    ll sum(int i) { // 区間 [0,i] の総和
        i++;
        ll res = 0;
        for(int x = i; x > 0; x -= x & -x) {
            res += v[x];
        }
        return res;
    }

    ll sum(int i, int j) { // 区間 [i,j] の総和
        return sum(j) - sum(i-1);
    }

    ll lower_bound(ll w) { // v1 + v2 + ⋯ + vx ≧ w となる最小の x
        if(w <= 0) return -1;
        ll x = 0;
        int k = 1;
        while(k*2 <= n) k *= 2;
        for(; k > 0; k /= 2) {
            if(x+k <= n && v[x+k] < w) {
                w -= v[x+k];
                x += k;
            }
        }
        return x;
    }

    void add(int i, ll w) { // i番目に w を加算
        i++;
        for(int x = i; x <= n; x += x & -x) {
            v[x] += w;
        }
    }
};


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

    FenwickTree_sum ft(n);
    rep(i,n) {
        int a;
        cin >> a;
        ft.add(i,a);
    }

    rep(i,q) {
        int type, a, b;
        cin >> type >> a >> b;
        if(type == 0) ft.add(a,b);
        if(type == 1) cout << ft.sum(a,b-1) << endl;
    }
}

Measured memory_bytes: 8204
/*input

*/
#include <iostream>
#include <fstream>
#include <bitset>
#include <vector>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <map>
#include <string>
#include <utility>
#include <ctime>
#include <algorithm>
#include <iomanip>
#include <assert.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define endl '\n'
#define mp make_pair
#define pb push_back
#define MOD 1000000007ULL
#define MOD2 1000000009ULL
#define INF 1000000000ULL
#define F first
#define S second
#define eps 1e-9
#define PI 3.14159265358979
#define gcd __gcd
#define sd(x) scanf("%d", &(x))
#define slld(x) scanf("%lld", &(x))
#define ss(x) scanf("%s", x)
#define sc(x) scanf(" %c", &x)
#define pd(x) printf("%d\n", (x))
#define plld(x) printf("%lld\n", (x));
#define gc getchar

typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<int, int> vii;
typedef vector<ll, ll> vll;

void scanint(int &x)
{
    register int c = gc();
    bool flag = false;
    x = 0;
    for(;((c<48 && c!=45) || c>57);c = gc());
    if(c==45)
    {
		flag = true;
		c = gc();
    }
    for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
    if(flag)
    	x = x - (x<<1);
    return;
}

void scanll(ll &x)
{
	register long long c;
	bool flag = false;
	x = 0;
	for(;((c<48 && c!=45) || c>57);c = gc());
	if(c==45)
	{
		flag = true;
		c = gc();
	}
	for(;c>47 && c<58;c = gc()) {x = (x<<1) + (x<<3) + c - 48;}
	if(flag)
    	x = x - (x<<1);
	return;
}

const int N = 100005;
const int M = 16;
vector<pii> v[N];
bool visited[N];
int cnt[M];
int dp[1<<M];
int val[1<<M];
int arr[M], sz_arr;

void dfs(int u)
{
	visited[u] = true;
	pii pt;
	int d = 0;
	for(int i = 0; i<v[u].size(); i++)
	{
		pt = v[u][i];
		d = d^pt.S;
		if(!visited[pt.F])
			dfs(pt.F);
	}
	cnt[d]++;
	return;
}

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

	// clock_t clk;
	// clk = clock();
	// freopen("in.in", "r", stdin);
	// freopen("out.out", "w", stdout);
	
	int n, a, b, w;
	cin >> n;
	for(int i = 1; i<n; i++)
	{
		cin >> a >> b >> w;
		a++;
		b++;
		v[a].pb(mp(b, w));
		v[b].pb(mp(a, w));
	}
	dfs(1);
	int ans = 0;
	sz_arr = 0;
	for(int i = 1; i<M; i++)
	{
		ans += cnt[i]/2;
		cnt[i] = cnt[i]%2;
		if(cnt[i])
		{
			arr[sz_arr] = i;
			sz_arr++;
		}
	}
	int up = (1<<sz_arr), temp;
	for(int i = 0; i<up; i++)
	{
		val[i] = 0;
		for(int j = 0; j<sz_arr; j++)
			if(i&(1<<j))
				val[i] = val[i]^arr[j];
	}
	dp[0] = 0;
	for(int i = 1; i<up; i++)
	{
		if(val[i] != 0)
			continue;

		dp[i] = __builtin_popcount(i) - 1;
		for(int j = i; j>0; j = i&(j-1))
			if(val[j] == 0 && val[i^j] == 0)
				dp[i] = min(dp[i], dp[j]+dp[i^j]);
	}
	cout << dp[up-1] + ans << "\n";

	// clk = clock() - clk;
	// cout << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
	// printf("Time: %lf", ((double)clk)/CLOCKS_PER_SEC);
	return 0;
}

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

using namespace std;

long long a, b, n;

int main(void)
{
	scanf("%lld %lld %lld", &a, &b, &n);
	
	long long m = min(b - 1, n);
	
	printf("%lld", a * m / b - a * (m / b));
	return 0;
}

Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;

int n;
int a[100000];
vector<int> et[100000];

//部分木vで条件を満たすには, 「v -- vの親」を通る回数が何回になればよいか？を返す.
//絶対に条件を満たせない場合は, -1を返す.
int dfs(int parent, int v) {
	if (et[v].size() == 1) {
		return a[v];
	}
	
	int maxi = 0, ssum = 0;
	for (int i = 0; i < et[v].size(); i++) {
		if (et[v][i] == parent) continue;
		int res = dfs(v, et[v][i]);
		if (res == -1) { return -1; }
		maxi  = max(maxi, res);
		ssum += res;
	}
	
	int x = ssum - a[v];		//折り返す回数
	int y = 2 * a[v] - ssum;	//通る回数
	
	//条件チェック
	if (0 <= x && x <= min(ssum / 2, ssum - maxi) && 0 <= y) {
		return y;
	}
	return -1;
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> a[i];
	if (n == 2) {
		if (a[0] == a[1]) cout << "YES" << endl;
		else cout << "NO" << endl;
		return 0;
	}
	
	for (i = 0; i < n - 1; i++) {
		int src, dst;
		cin >> src >> dst;
		src--;
		dst--;
		et[src].push_back(dst);
		et[dst].push_back(src);
	}
	
	for (i = 0; i < n; i++) {
		if (et[i].size() == 1) continue;
		if (dfs(-1, i) == 0) { cout << "YES" << endl; }
		else { cout << "NO" << endl; }
		break;
	}
	return 0;
}

Measured memory_bytes: 13184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define whole(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
using P = pair<int, int>;
#define debug(var) cout << "[" << #var << "] " << var << endl
const ll mod = 1000000007;
const int INF = 1001001001;


int main(){
    int n;
    cin >> n;
    vector<int> x(n);
    vector<int> y(n);
    vector<int> h(n);
    rep(i, n) cin >> x[i] >> y[i] >> h[i];
    int cx, cy;
    int hmax;
    bool ok;

    rep(i, 101) {
        rep(j, 101) {
            ok = true;
            cx = i;
            cy = j;
            hmax = 0;
            rep(k, n) {
                if (h[k]==0) continue;
                hmax = h[k] + abs(x[k]-cx) + abs(y[k]-cy);
                break;
            }
            if (hmax==0) {
                hmax = 1;
                break;
            }
            rep(k, n) {
                int ih = h[k] + abs(x[k]-cx) + abs(y[k]-cy);
                if (h[k]==0) {
                    if (ih<hmax) {
                        ok = false;
                        break;
                    }
                }
                else {
                    if (ih!=hmax) {
                        ok = false;
                        break;
                    }
                }
            }
            if (ok) break;
        }
        if (ok) break;
    }
    
    
    
    
    cout << cx << " " << cy << " " << hmax << endl;
    return 0;
}


Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
	D = input[0].split(" ");
	
	if (D==25){console.log('Christmas');}
    else if (D==24){console.log('Christmas Eve');}
      else if (D==23){console.log('Christmas Eve Eve');}
       else{console.log('Christmas Eve Eve Eve');}


	
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<stdio.h>
main() {
	int i,count=0;
	int N;
	int a[4];
	scanf("%d",&N);
	a[0] = N / 1000;
	a[1] = (N / 100) % 10;
	a[2] = ((N / 10) % 100)%10;
	a[3] = N % 10;
	for (i = 0;i < 4;++i) {
		if (a[i] == 2)++count;
	}
	printf("%d", count);
	return 0;
}


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


using namespace std;


const int MOD = 998244353;
const int N = 303;

int dp[N][N][N];


int solve(int n, string &s, int k) {
    int lastZero = -1;

    for (int moves = 0; moves <= k; moves++) {
        for (int ones = 0; ones <= n; ones++) {
            dp[0][moves][ones] = 1;
        }
    }

    for (int pref = 1; pref <= n; pref++) {
        for (int moves = 0; moves <= k; moves++) {
            for (int ones = 0; ones <= n; ones++) {
                long long dpHere = 0;

                int last = s[pref - 1] - '0';

                for (int target = 0; target <= 1; target++) {
                    if (last == target) {
                        dpHere += dp[pref-1][moves][ones];
                    } else if (last == 0) {
                        if (ones >= 1) {
                            dpHere += dp[pref][moves][ones-1];
                        }
                    } else {
                        if (lastZero != -1) {
                            int needMoves = pref - lastZero - 1;

                            if (moves >= needMoves) {
                                dpHere += dp[lastZero][moves-needMoves][ones+needMoves];
                            }
                        }
                    }
                }

                dp[pref][moves][ones] = dpHere % MOD;
            }
        }

        if (s[pref - 1] == '0') {
            lastZero = pref - 1;
        }
    }

    return dp[n][k][0];
}

int main() {
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;

    int n = s.size();

    int k;
    cin >> k;

    k = min(k, n);

    cout << solve(n, s, k);

    return 0;
}


Measured memory_bytes: 111200
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [S, W] = input[0].map(Number);

  return S > W ? "safe" : "unsafe";
};

console.log(main(read()));


Measured memory_bytes: 29668
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

int A1,A2,A3;

int main() {

	cin >> A1>>A2>>A3;

	if (A1 + A2 + A3 >= 22) {
		cout << "bust" << endl;

	}
	else {
		cout << "win" << endl;

	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) FOR(i,0,b)
#define INF mugen
#define dump(x) cerr<<#x<<"="<<x<<endl


using ll = long long;
const ll mod = LLONG_MAX;

int N,ans;
vector<int> a;
int main(){
  cin>>N;
  rep(i,N){
    int t;
    cin>>t;
    a.push_back(t);
  }
  int temp=0;
  int memo=0;
  if(N==1){
    cout<<1<<endl;
    return 0;
  }
  sort(a.begin(),a.end());
  for(int i=0;i<N-1;i++){
    temp=1;
    while(a[i]==a[i+1]){
      temp++;
      i++;
    }
    if(temp%2!=0)ans++;
  }
  if(a[N-1]!=a[N-2])ans++;
  cout<<ans<<endl;
}


Measured memory_bytes: 892
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
#include<limits.h>
#include<unordered_map>
#include<unordered_set>
#include<deque>
#include<cstdio>
typedef long long int ll;
#define FOR(i,a,n) for(int i=(int)a;i<(int)n;++i)
#define TFOR(i,N)FOR(i,0,N)
#define ALL(x) x.begin(),x.end();
const int INF = 1LL << 30;
const ll LLINF = 1LL << 60;
int main() {
	int ct=0;
	std::string s;
	std::cin >> s;
	for (int i = 0; i < s.size()-1;++i) {
		if (s[i] != s[i + 1])++ct;
	}
	std::cout << ct << std::endl;
	return 0;
}

Measured memory_bytes: 512
#include<cmath>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=4005;
const int mod=1e9+7;
int n,m,tot;
int l[maxn+8],r[maxn+8],fac[maxn+8],fact[maxn+8],sum[maxn+8];
int f[maxn+8][maxn+8];
char S[maxn+8];
 
int read()
{
    int x=0,f=1;char ch=getchar();
    for (;ch<'0'||ch>'9';ch=getchar()) if (ch=='-') f=-1;
    for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
    return x*f;
}
 
int power(int a,int k)
{
    int sum=1;
    for (;k;k>>=1,a=1ll*a*a%mod)
	if (k&1)
	    sum=1ll*sum*a%mod;
    return sum;
}
 
int C(int n,int m){if (n<m) return 0;return 1ll*fac[n]*fact[m]%mod*fact[n-m]%mod;}
 
int main()
{
    n=read(),m=read();
    scanf("%s",S+1);
    for (int i=1;i<=m;i++)
	{
	    int x=read(),y=read();
	    if (r[tot]>=y) continue;
	    if (l[tot]==x&&r[tot]<y) tot--;
	    l[++tot]=x,r[tot]=y;
	}
    l[++tot]=n,r[tot]=n;
    fac[0]=fact[0]=1;
    for (int i=1;i<=n;i++) sum[i]=sum[i-1]+(S[i]=='1');
    for (int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
    fact[n]=power(fac[n],mod-2);
    for (int i=n-1;i;i--) fact[i]=1ll*fact[i+1]*(i+1)%mod;
    f[0][0]=1;
    for (int i=1;i<tot;i++)
	{
	    //printf("Time:%d\n",i);
	    if (l[i+1]>r[i])
		{
		    for (int j=0;j<=n;j++)
			f[i][0]=(f[i][0]+1ll*f[i-1][j]*C(r[i]-l[i]+1,j+sum[r[i]]-sum[max(l[i]-1,r[i-1])])%mod)%mod;
		    continue;
		}
	    for (int j=0;j<=r[i]-l[i+1]+1;j++)
		    for (int k=0;k<=min(n,l[i+1]-l[i]+j-sum[r[i]]+sum[max(l[i]-1,r[i-1])]);k++)
			{
				if (!f[i-1][k]) continue;
			    //printf("update:%d %d\n",j,k);
			    f[i][j]=(f[i][j]+1ll*f[i-1][k]*C(l[i+1]-l[i],k-j+sum[r[i]]-sum[max(l[i]-1,r[i-1])])%mod)%mod;
			}
	}
    //for (int i=1;i<tot;i++,puts(""))
    // 	for (int j=0;j<=n;j++)
    //	    	    printf("%d ",f[i][j]);
    int ans=(f[tot-1][0]+f[tot-1][1])%mod;
       printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 19328
n,k = map(int,input().split())
if k<=n:
    ans = float((n-k+1)/n)
else:
    ans = 0
c = float(1/n)
for i in range(1,min(k,n+1)):
    num = i
    cnt = 0
    while num<k:
        num*=2
        cnt += 1
    ans += c*float((0.5)**cnt)
print(ans)

Measured memory_bytes: 3064
import numpy as np
N = input()
A = [np.array(map(int,raw_input().split()), dtype=np.int64) for _ in [0]*N]
inf = 10**10
for i in range(N):
    A[i][i] = inf
#print A


result = 0
for i in range(N-1):
    for j, d1 in enumerate(A[i][i+1:], start=i+1):
	#print i,j,A[i], A[j], np.min(A[i]+A[j]),d1
        d2 = np.min(A[i]+A[j])
        if d1 >= d2:
            if d1 > d2:
                print(-1)
                exit()
        else:
            result += d1
print(result)


Measured memory_bytes: 19440
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	b := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&b[i])
	}

	ans := make([]int, n)
	for i := n; i > 0; i-- {
		ok := false
		for j := i; j > 0; j-- {
			if j <= len(b) && b[j-1] == j {
				ok = true
				ans[i-1] = b[j-1]
				b = append(b[:j-1], b[j:]...)
				break
			}
		}
		if !ok {
			fmt.Println(-1)
			return
		}
	}

	for i := 0; i < len(ans); i++ {
		fmt.Println(ans[i])
	}
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef vector<bool> vb;
typedef vector<string> vs;
typedef vector<pair<ll, ll> > vp;
typedef pair<ll, ll> pr;
typedef tuple<ll, ll, ll> ti;

#define FOR(i, a, b) for (int i = (a), _b = (b); i < _b; i++)
#define FORD(i, b, a) for (int i = (b), _a = (a); i > _a; i--)
#define pb push_back

#define vout(v) do {					\
	for (auto i: v)	cout << i << ' ';	\
	cout << '\n';						\
} while (false)

#define matout(mat) do {					\
	for (auto i: mat) {						\
		for (auto j: i)	cout << j << ' ';	\
		cout << '\n';						\
	}										\
} while (false)

#define vin(v)  for (auto &i: v)    cin >> i

#define matin(mat) do {			\
	for (auto &i: mat)	vin(i);	\
} while (false)

ld pi = 3.141592653589793238;
ll M = 1e9 + 7;

ll gcd(ll a, ll b) {
    if (a == 0) return b;

    return gcd(b % a, a);
}

ll power(ll x, ll y) {
	if (y == 0)
		return 1;

	ll p = power(x, y / 2) % M;
	p = (p * p) % M;

	return y % 2 ? (x * p) % M : p;
}

bool is_prime(ll n) {
    if (n == 2) return true;
    if (n < 2) return false;
    if (n % 2 == 0) return false;

    for (int i = 3; i <= sqrt(n); i += 2) {
        if (n % i == 0) return false;
    }

    return true;
}

bool is_palindrome(string s) {
    return equal(s.rbegin(), s.rend(), s.begin());
}

ll factor(ll n) {
	if (n % 2 == 0)	return 2;
	for (int i = 3; i <= sqrt(n); i += 2) {
		if (n % i == 0)	return i;
	}
	return n;
}

int floor_index(vi& v, int l, int r, int k) {
	while (r - l > 1) {
		int m = l + (r - l) / 2;
		if (v[m] <= k)	l = m;
		else			r = m;
	}
	return l;
}

int ceil_index(vi& v, int l, int r, int k) {
	while (r - l > 1) {
		int m = l + (r - l) / 2;
		if (v[m] >= k)	r = m;
		else		l = m;
	}
	int ans = v[l] >= k ? l : r;

	if (ans < 0 || ans >= v.size())	return -1;
	return ans;
}

ll recur(vll& v, vll& dp, int idx) {
	if (idx == v.size())	return 0;
	if (idx == v.size() - 1)	return dp[idx] = 1;
	if (dp[idx] != -1)	return dp[idx];

	if (v[idx + 1] < v[idx])	return dp[idx] = 1;

	return dp[idx] = 1 + recur(v, dp, idx + 1);
}

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

    ll t, n, m, k, q, x, y;
    string s;
    bool flag;

	cin >> n >> x >> t;

	m = ceil((double) n / x);

	cout << m * t << '\n';

    return 0;
}

Measured memory_bytes: 3680
#include<bits/stdc++.h>
#define prArr(Arr,n) for(int _=0;_<n;_++)   cout<<(Arr)[_]<<" ";
using namespace std;
const int INF=(int)0x3f3f3f3f;
const int MOD=(int)1e9+7;

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    long long x,k,d;
    cin>>x>>k>>d;
    if(x<0)
        x=-x;
    long long cnt=x/d;
    if(cnt>=k)
        return cout<<x-k*d,0;
    x-=cnt*d;
    k-=cnt;
    if(k%2)
        x-=d;
    if(x<0)
        x=-x;
    cout<<x;
    return 0;
}


Measured memory_bytes: 3644
#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 << "Left" << endl;
  else if(A+B< C+D) cout << "Right" << endl;
  else cout << "Balanced" << endl;
}

Measured memory_bytes: 384
//Robs Code
/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
/***********MACROS***************/
#define int long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define fij(a,b,l,k) for(i=a;i<=b;i++) for(j=l;j<=k;j++)
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define mxsz 1e5+10
#define mod 1e9 + 7
#define pii pair<int,int>
using namespace std;
const int N = 1e5 + 1;
int n,m,i,j,l,k,x,y,a,b,cnt[3],sum[3];
/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	string s;
	cin>>s;
	if(n%2 == 0){
		if(s.substr(0,n/2) == s.substr(n/2)){
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}
//.........

Measured memory_bytes: 888
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readNInts = readInt >>= flip replicateM readInt

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = getLine >> readInts >>= print . foldl1 gcd 

Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };


int main(){cout<<fixed<<setprecision(10);
		   int a,b,c;
           cin>>a>>b>>c;
           YES(min(min(a,b),c)==5&&max(max(a,b),c)&&a+b+c==17);
}

Measured memory_bytes: 3616
//専用ライブラリ
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll>P;
#define INF 10e9
#define MOD 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define PI acos(-1.0)
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int cmp(P a,P b){
        if(a.fi!=b.fi)
        return a.fi>b.fi;
        else
        return a.se<b.se;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,k;
    cin>>n>>k;
    string s;
    cin>>s;
    int ans=0;
    vector<int> nums;
    
    if(s[0]=='0')
        nums.push_back(0);
    for(int i=0;i<s.length();)
    {
        int j=i;
        while(j<s.length()&&s[j]==s[i])
            j++;
        nums.push_back(j-i);
        i=j;
    }
    if(s.back()=='0')
        nums.push_back(0);
    vector<int> sums(nums.size()+1,0);
    for(int i=0;i<nums.size();i++)
        sums[i+1]=sums[i]+nums[i];
    for(int left=0;left<sums.size();left+=2)
    {
        int right=left+k*2+1;
        if(right>=sums.size())
            right=sums.size()-1;
        ans=max(ans,sums[right]-sums[left]);
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1272
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<functional>
#include<fstream>
#include<utility>
#include<bitset>
#include<map>
#include<deque>
#include<random>
#define rep(N) for (int i = 0; i < N; ++i)
#define For(i, N) for (i = 0; i < N; ++i)
#define rev(N) 	for (int i = N - 1; i >= 0; --i)
#define all(v) v.begin(), v.end()
#define mod 1000000007
#define re return 0

using namespace std;
using ll = long long int;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using vs = vector<string>;
using pii = pair<int, int>;
using pis = pair<int, string>;

template<typename T>
void say(T s) {
	cout << s << endl;
}

template<typename T1, typename T2>
void say(T1 s1, T2 s2) {
	cout << s1 << " " << s2 << endl;
}

int main() {
	int a, b;
	cin >> a >> b;
	if (a % 2 == 1 && b % 2 == 1)say("Odd");
	else say("Even");
}


Measured memory_bytes: 256
s=input()
flag=True
if s[0]!='A':
  flag=False
if s[1].isupper():
  flag=False
cnt=0
for i in range(2,len(s)-1):
  if s[i]=='C':
    cnt+=1
  elif s[i].isupper():
    flag=False
if s[len(s)-1].isupper():
  flag=False
if cnt!=1:
  flag=False
if flag:
  print("AC")
else:
  print("WA")  

Measured memory_bytes: 8980
while True:
  def BMI(h,w):
    X=w/(h/100)**2
    return X
  n =int(input())
  if n==0:
    break
  tbl=[[0 for j in range(2)] for i in range(n)]
  for i in range(n):
    p,h,w=list(map(int, input().split()))
  #  print(BMI(h,w))
    id=abs(22-BMI(h,w))
    tbl[i][0]=p
    tbl[i][1]=id
  #print(tbl)
  id_min=10**9
  ans=0
  for i in range(n):
    if tbl[i][1]<id_min:
      ans=tbl[i][0]
      id_min=tbl[i][1]
  print(ans)    


Measured memory_bytes: 5876
def judge(A,B,C):
    return (A == B and A != C) or (B == C and B != A) or (C == A and C != B)

S = input()
ABC = S.strip().split(' ')
A = int(ABC[0])
B = int(ABC[1])
C = int(ABC[2])
if judge(A,B,C):
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3060
s=[]
gets.split.each{|c|
  case c
  when ?+
    a,b=s.pop(2)
    s<< a + b
  when ?-
    a,b=s.pop(2)
    s<< a - b
  when ?*
    a,b=s.pop(2)
    s<< a * b
  else
    s<< c.to_i
  end
}
p s[0]




Measured memory_bytes: 6868
import collections
n = int(input())
V = list(map(int, input().split()))

even = []
odd = []
for nn in range(n):
    if nn % 2 == 0:
        even.append(V[nn])
    else:
        odd.append(V[nn])

e = collections.Counter(even).most_common()
o = collections.Counter(odd).most_common()

if e[0][0] != o[0][0]:
    print(n - e[0][1] - o[0][1])
else:
    if len(e) == 1 and len(o) == 1:
        print(n // 2)
    elif len(e) == 1 and len(o) >= 2:
        print(n - o[0][1])
    elif len(e) >= 2 and len(o) == 1:
        print(n - e[0][1])
    else:
        print(n - max(e[1][1] + o[0][1], e[0][1] + o[1][1]))




Measured memory_bytes: 21212
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt(),m=sc.nextInt();
		int[] count = new int[m], bit=new int[m];
		int[][] array = new int[m][n];
		for(int i=0;i<m;i++) {
			count[i]=sc.nextInt();
			for(int j=0;j<count[i];j++) array[i][j]=sc.nextInt()-1;
		}
		for(int i=0;i<m;i++) bit[i]=sc.nextInt();
		sc.close();
		int cnt=0;
		for(int i=0;i<(1<<n);i++) {
			int flag=0;
			for(int j=0;j<m;j++) {
				int c=0;
				for(int k=0;k<count[j];k++) {
					if((i&(1<<array[j][k]))!=0) {
						c++;
					}
				}
				if(c%2!=bit[j]) {
					flag=1;
					break;
				}
			}
			if(flag==0) cnt++;
		}
		System.out.println(cnt);
	}
}

Measured memory_bytes: 21844
#include<iostream>

using namespace std;

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

    int nums = 0;
    bool flag = true;
    while(flag){
        flag = false;
        for(int j=N-1; j>=1; j--){
            if(A[j] < A[j-1]){
                nums += 1;
                int tmp = A[j];
                A[j] = A[j-1];
                A[j-1] = tmp;
                flag = true;
            }
        }
    }

    for(int i=0; i<N-1; i++){
        cout << A[i] << " " ;
    }
    cout << A[N-1] << endl;
    cout << nums << endl;
}

Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <algorithm>

#define int long long

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)

#define INF (3e9)

using namespace std;

int N;
int T[103];
int tt[103];
int V[103];

signed main()
{
    cin >> N;

    int sum = 0;
    REPS(i, N) cin >> T[i];
    REPS(i, N) cin >> V[i];
    REPS(i, N+1)
    {
        sum += T[i];
        tt[i] += tt[i-1] + T[i];
    }

    int v = 0;
    float ans = 0.0;
    for (float time = 0; time <= sum; time += 0.5)
    {
        float minv = INF;
        for (int i = 0; i <= N + 1; ++i)
        {
            float tmpv = INF;
            if (i > 0 && time < tt[i-1])
            {
                tmpv = V[i] + tt[i-1] - time;
            }
            else if (i > 0 && tt[i-1] <= time && time < tt[i])
            {
                tmpv = V[i];
            }
            else if (tt[i] <= time)
            {
                tmpv = V[i] + time - tt[i];
            }
            minv = min(minv, tmpv);
        }
        //printf("time:%f, v:%f\n", time, minv);
        ans += minv * 0.5;
    }
    cout << fixed;
    cout << setprecision(5) << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream> 

using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >>c;
	if (a != b && a != c) {
		cout << a<<endl;
	}
	if (a != b && b != c) {
		cout << b << endl;
	}
	if (c != b && a != c) {
		cout << c << endl;
	}

	

	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;

vector<int> G[500];
int dist[500];

int main()
{
	int n, m;
	
	while (scanf("%d\n%d", &n, &m) && n){
		for (int i = 0; i < n; i++) G[i].clear();
		for (int i = 0; i < m; i++){
			int a, b;
			scanf("%d %d", &a, &b);
			G[--b].push_back(--a);
			G[a].push_back(b);
		}
		
		memset(dist, -1, sizeof(dist));
		
		int ans = 0;
		queue<int> q;
		
		for (q.push(0); q.size(); q.pop()){
			int x = q.front();
			
			if (dist[x] < 0) dist[x] = 0;
			if (dist[x] <= 2) ans++;
			
			for (int i = 0; i < G[x].size(); i++){
				if (dist[G[x][i]] >= 0) continue;
				else dist[G[x][i]] = dist[x] + 1;
				q.push(G[x][i]);
			}
		}
		
		printf("%d\n", ans - 1);
	}
	
	return (0);
}

Measured memory_bytes: 1200
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <bits/stdc++.h>
#include<queue>
#include <numeric>
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define fore(i,a) for(auto &i:a)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
 

LL gcd(LL a, LL b){
    if(b == 0) return a;
    return gcd(b,a%b);
}

LL lcm(LL a, LL b){
    LL g = gcd(a,b);
    return a/g *b;
}


int main(){
    string a,b;
    cin >> a >> b;
    int pos=0;
    int num_a=stoi(a);
    int num_b=stoi(b);
    string ans_1,ans_2;
    for(int i=0;i<num_a;++i){
        ans_1+=b;
    }
    
    for(int i=0;i<num_b;++i){
        ans_2+=a;
    }
    
    if(num_a>num_b){
        cout << ans_1;
    }
    else{
        cout << ans_2;
    }
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

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

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

int dp[1010][20010]={};

int main(){
    bool flag=false;
    ll ans=INF,sum=0,mx=0;

    int h,n;
    cin >>h>>n;

    vector<int> a(n);
    vector<int> b(n);
    rep(i,n){
        cin>>a[i];
        cin>>b[i];
        chmax(mx,a[i]);
    }
    rep(i,n+1)rep(j,h+mx+1)dp[i][j]=INF;
    rep(i,n+1)dp[i][0]=0;

    rep(i,n){
        rep(j,h+mx+1){
            if(j-a[i] >= 0){
                dp[i+1][j] = min(dp[i][j], dp[i+1][j - a[i]] + b[i]);
            }else{
                dp[i+1][j] = dp[i][j];
            }
        }
    }

    /*
    rep(i,n+1){
        printf("%d th magic  ",i);
        rep(j,h+mx+1){
            if(dp[i][j]==INF)printf(" INF");
            else printf("%4d",dp[i][j]);
        }
        ln;
    }
    //*/

    rep1(i,h,h+mx)chmin(ans,dp[n][i]);

    //cout <<fixed<<setprecision(16)<< << endl;
    cout<< ans <<endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    return 0;
}


Measured memory_bytes: 77440
import sys
readline = sys.stdin.buffer.readline

if __name__ == "__main__":
    N,M = map(int, input().split())

    s = [0] * 5
    c = [0] * 5
    for i in range(M):
        a,b = map(int, input().split())
        s[i] = a
        s[i] -= 1
        c[i] = b
    
    res = [-1] * N
    ok = True
    for i in range(M):
        if s[i] == 0 and c[i] == 0:
            if N != 1:
                ok = False
            else:
                if res[0] == -1:
                    res[0] = c[i]
                else:
                    if res[s[i]] != c[i]:
                        ok = False
        
        else:
            if res[s[i]] == -1:
                res[s[i]] = c[i]
            else:
                if res[s[i]] != c[i]:
                    ok = False
        
    if not ok:
        print(-1)
    else:
        for i in range(N):
            if i == 0:
                if N == 1:
                    if res[i] == -1:
                        print(0, end="")
                    else:
                        print(res[i], end="")
                else:
                    if res[i] == -1:
                        print(1, end="")
                    else:
                        print(res[i], end="")
            else:
                if res[i] == -1:
                    print(0, end="")
                else:
                    print(res[i], end="")
        print("")




    




Measured memory_bytes: 3188
k = [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]
print(k[int(input())-1])


Measured memory_bytes: 38384
n = readline.strip.to_i
as = readline.strip.split.map(&:to_i)
bs = readline.strip.split.map(&:to_i)

cur = 0
prev = 0
0.upto (n - 1) do |i|
  front = [bs[i], as[i] - prev].min
  rest = bs[i] - front
  nextt = [rest, as[i+1]].min
  prev = nextt
  cur = cur + front + nextt
end
puts cur


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

using namespace std;

#define MAXN 200050
#define MAXLGN 29

int cnt(int *a, int n, int l, int h)
{
	int p = upper_bound(a, a+n, l)-a;
	int q = upper_bound(a, a+n, h)-a;
	--p; --q;

	while (p >= 0 && a[p] > l) --p;
	while (q >= 0 && a[q] > h) --q;

	return q-p;
}

int a[MAXN], b[MAXN], t[MAXN];

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) scanf("%d", &a[i]);
	for (int i = 0; i < n; i++) scanf("%d", &b[i]);

	int ans = 0;
	for (int j = 0; j < MAXLGN; j++) {
		int h1 = (1<<(j+1))-1;
		int l1 = (1<<j)-1;
		int h2 = (1<<(j+2))-1;
		int l2 = (1<<(j+1))+(1<<j)-1;
		for (int i = 0; i < n; i++) t[i] = b[i]&((1<<(j+1))-1);
		sort(t, t+n);
		for (int i = 0; i < n; i++) {
			int x = a[i]&((1<<j+1)-1);
			if ( cnt(t, n, l1-x, h1-x)&1 ) ans ^= (1<<j);
			if ( cnt(t, n, l2-x, h2-x)&1 ) ans ^= (1<<j);
		}
	}
	printf("%d\n", ans);

}


Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n, m;
ll a[200005];
ll b[200005];

bool f(ll p)
{
    ll sum = 0;
    for(ll i = 0; i < n; i++)
    {
        ll t = p / b[i];
        sum += max(0LL, a[i] - t);
    }
    return sum <= m;
}

int main()
{
    scanf("%lld%lld", &n, &m);
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &a[i]);
    }
    for(ll i = 0; i < n; i++)
    {
        scanf("%lld", &b[i]);
    }
    sort(a, a + n);
    sort(b, b + n, greater<ll>());
    ll lt = 0, rt = 4e18, mid, ans;
    while(lt <= rt)
    {
        mid = (lt + rt) / 2;
        if(f(mid)) ans = mid, rt = mid - 1;
        else lt = mid + 1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  string s;
  cin >> s;
  int k;
  cin >> k;
  if(k == 1){
    int a[26] = {};
    REP(i,s.size()){
      a[s[i]-'a']++;
    }
    int rs = 0;
    REP(i,26){
      if(a[i] != 0)
	rs++;

      if(rs == k){
	char c = 'a'+i;
	cout << c << endl;
	return 0;
      }
    }
  }
  
  char c = 'a';
  int sum = 0;
  vector <string> str;
  REP(i,26){
    c = 'a'+ i;
    vector <int> a;
    
    REP(j,s.size()){
      if(s[j] == c){
	if(s.size()-j > k){
	  //cout << "sdfkd" << endl;
	  rep(l,1,k+1){
	    str.pb(s.substr(j,l));
	    }
	}
	else{
	  //cout << "e" << endl;
	  rep(l,1,s.size()-j+1){
	    str.pb(s.substr(j,l));
	  }
	}
      }
    }
    if(str.size() == 0){
    continue;
    }
    sort(str.begin(),str.end());
    REP(j,str.size()-1){
      if(str[j] == str[j+1]){
	str.erase(str.begin()+j);
	j--;
      }
	//cout << str[j] << endl;
    }
    /*
    REP(j,str.size()){
      cout << str[j] << endl;
    }
    cout << "end" << endl;*/
    if(str.size() + sum >= k){
      sort(str.begin(),str.end());
      cout << str[k-1] << endl;
      return 0;
    }
    else{
      sum += str.size();
    }
  }
  return 0;
}


Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std; bool T=false; int main(){ long long N;cin>>N; vector<string> S(N); long long wa=0,ac=0,tle=0,re=0; for (int i = 0; i < N; i++) { cin>>S[i]; if(S[i]=="WA")wa++; if(S[i]=="AC")ac++; if(S[i]=="TLE")tle++; if(S[i]=="RE")re++; } cout<<"AC x "<<ac<<endl; cout<<"WA x "<<wa<<endl; cout<<"TLE x "<<tle<<endl; cout<<"RE x "<<re<<endl; }


Measured memory_bytes: 6408
from math import gcd
N=int(input())
A=list(map(int,input().split()))
wa=[-1]*1000001
pr=[]
t=0
for i in range(2,1000001):
    if wa[i]>=0:
        continue
    pr.append(i)
    wa[i]=t
    for j in range(i**2,1000001,i):
        if wa[j]==-1:
            wa[j]=t
    t+=1
lp=len(pr)
l=[0]*lp
g=gcd(A[0],A[1])
for i in A:
    g=gcd(g,i)
if g>1:
    print("not coprime")
    exit()
for i in A:
    t=i
    for j in range(wa[i],lp):
        pj=pr[j]
        if pj>t:
            break
        if t%pj==0:
            if l[j]:
                print("setwise coprime")
                exit()
            l[j]=1
            while 1:
                t//=pj
                if t%pj:
                    break
print("pairwise coprime")

Measured memory_bytes: 204332
#![allow(unused_imports)]
// use itertools::Itertools;
use proconio::{input, marker::*};
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        m: usize,
        aabb: [(usize, usize); m]
    };
    let mut first = HashSet::new();
    let mut second = HashSet::new();
    for (a, b) in aabb {
        if a == 1 {
            first.insert(b);
        }
        if b == n {
            second.insert(a);
        }
    }
    dbg!();
    println!(
        "{}",
        ["POSSIBLE", "IMPOSSIBLE"][(first.intersection(&second).count() == 0) as usize]
    );
}


Measured memory_bytes: 10208
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>
#define vbool vector<bool>
#define INF 100000000000000009
#define int long long
using P = pair<int,int>;

signed main(){
  int n;
  cin >> n;
  set<int> S;
  rep(i,n){
    int a;
    cin >> a;
    decltype(S)::iterator it = S.find(a);
    if(it != S.end()) S.erase(a);
    else S.insert(a);
  }
  cout << S.size() << endl;

}

Measured memory_bytes: 4864
<?php
// Your code here!
$stdin = trim(fgets(STDIN));
$a = str_split($stdin);
$b = [];
foreach ($a as $value) {
    if(!isset($b[$value])){
        $b[$value] = 1;
    }else{
        $b[$value]++;
    }
    if($b[$value] > 2 || count($b) > 2){
        echo 'No';
        return ;
    }
}
echo 'Yes';
?>

Measured memory_bytes: 4728
#7
A = [list(map(int,input().split())) for i in range(3)]

N = int(input())

B = [int(input()) for i in range(N)]

C = [[0,0,0],[0,0,0],[0,0,0]]
Ans = "No"

for i in range(3):
    for j in range(3):
        if A[i][j] in B:         #AijはリストBに含まれるかどうか
            C[i][j] = 1

for i in range(3):
    if C[i][0]+C[i][1]+C[i][2] == 3:
        Ans ="Yes"

for i in range(3):
    if C[0][i]+C[1][i]+C[2][i] == 3:
        Ans ="Yes"
        
if C[0][0]+C[1][1]+C[2][2] == 3 or C[0][2]+C[1][1]+C[2][0] == 3:
    Ans = "Yes"
    
print(Ans)
            
        

Measured memory_bytes: 9108
#include <bits/stdc++.h>
#define int long long
#define double long double
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
typedef pair<int,int> P;
typedef long long ll;
ostream& operator<<(ostream& o,P p){return o<<"("<<p.first<<","<<p.second<<")";}
istream& operator>>(istream& i,P &p){return i>>p.first>>p.second;}
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T> void prArr(T a,string s=" "){int i=0;for(auto t:a)cout<<i++? s:""<<t;cout<<endl;}

signed main(){
  int n,H;
  cin>>n>>H;

  vector<int> A(n),B(n);;
  for(int i=0;i<n;i++) cin >> A[i]>>B[i];

  sort(A.begin(),A.end(),greater<int>());
  sort(B.begin(),B.end(),greater<int>());

  int ans = 0;
  for(int i=0;i<n;i++)
    if(H>0 && B[i] > A[0]) ans++,H-=B[i];
  
  if(H>0) ans += (H-1)/A[0] + 1;
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
int main() {
	int n;
	cin >> n;
	VI a(n + 1), b(n);
	REP(i, n + 1)
		cin >> a[i];
	REP(i, n)
		cin >> b[i];
	ll ans = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (a[i + 1] <= b[i]) {
			ans += a[i + 1];
			b[i] -= a[i + 1];
			if (a[i] <= b[i]) {
				ans += a[i];
				a[i] = 0;
			}
			else {
				ans += b[i];
				a[i] -= b[i];
			}
		}
		else {
			ans += b[i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 1024
h,w,a,b = list(map(int,input().split()))

ans = [['0']*w for i in range(h)]
for y in range(h):
    for x in range(w):
        if x<a and y<b:
            ans[y][x]="1"
        elif x>=a and y>=b:
            ans[y][x]="1"

for a in ans:
    print("".join(a))

Measured memory_bytes: 11892
#include<bits/stdc++.h>
#include<tr1/unordered_map>
#define CLR(a,x) memset(a,x,sizeof(a))
#define MP make_pair
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> pa;
const int maxn=1e5+10;

inline ll rd(){
    ll x=0;char c=getchar();int neg=1;
    while(c<'0'||c>'9'){if(c=='-') neg=-1;c=getchar();}
    while(c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*neg;
}

int L,N,x[maxn],dir[maxn],y[maxn],rnk[maxn],T,ans[maxn];

inline bool cmp(int a,int b){return x[a]<x[b];}

int main(){
    //freopen("","r",stdin);
	N=rd(),L=rd(),T=rd();
	for(int i=1;i<=N;i++) x[i]=rd(),dir[i]=(rd()==1?1:-1),rnk[i]=i;
	sort(rnk+1,rnk+N+1,cmp);
	ll p=0;
	for(int i=1;i<=N;i++){
		y[i]=((x[i]+T*dir[i])%L+L)%L;
		if(dir[i]==1) p+=ceil(1.0*(T-(L-x[i])+1)/L);
		else p-=ceil(1.0*(T-x[i])/L);
		// printf(":%d\n",p);
	}
	p=(p%N+N)%N;
	sort(y+1,y+N+1);
	for(int i=p+1;i<=N;i++) ans[rnk[i-p]]=y[i];
	for(int i=1;i<=p;i++) ans[rnk[N+i-p]]=y[i];
	for(int i=1;i<=N;i++) printf("%d\n",ans[i]);
    return 0;
}

Measured memory_bytes: 3200