akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long                  // Short form for long long
#define ld long double                // Short form for long double
typedef pair<ll, ll> pii;              // Pair of long long
typedef vector<ll> vi;                // Vector of long long
typedef vector<vi> vvi;               // Vector of vector of long long
typedef vector<pii> vii;               // Vector of pairs
typedef vector<vii> vvii;             // Vector of vector of pairs
#define pq priority_queue             // Max heap (To convert to min heap, use negative sign before every value)
#define ff first                      // For pairs
#define ss second                     // For pairs
#define pb push_back                  // Pushback to vector
#define mp make_pair                  // Makes pairs to be stored as pair
#define all(c) (c).begin(), (c).end() // Mainly used by me in sorting

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

vvi adj;
ll n,m,x,y,k;
// vi dp,vis;
ll mod = 1e9 + 7;
ll t=1;

bool isPrime(ll n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false;   
    for (ll i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false;   
    return true; 
} 

ll max_(ll a,ll b,ll c,ll d){
    return max(max(a,b),max(c,d));
}



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    // cin>>t;
    while(t--){
        cin>>n;    
        vi a(n);
        for(int i=0;i<n;i++)cin>>a[i];
        ll dp[n][n];
        for(int l=n-1;l>=0;l--){
            for(int r=l;r<n;r++){
                if(l==r)dp[l][r] = a[l];
                else{
                    dp[l][r] = max(a[l] - dp[l+1][r],a[r] - dp[l][r-1]);
                }                
            }
        }
        cout<<dp[0][n-1];
    }
    return 0;
}    

Measured memory_bytes: 46464
// "header" {{{
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_map>
#include <string>
#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <cstring>
#include <iomanip>
#include <tuple>

using namespace std;

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define pii pair<int,int> 
//#define int long long
#define setout(n,x) setw(n) << setfill(x)
#define Fixed fixed << setprecision(10)
const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const long long mod = 1000000007;

inline double sqrt( const double &x) 
{
	double         xHalf = 0.5 * x;
	int64_t  tmp   = 0x5FE6EB50C7B537AAl - ( *(int64_t*)&x >> 1);
	double         xRes  = * (double*)&tmp;

	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	xRes *= ( 1.5 - ( xHalf * xRes * xRes ) );
	return xRes * x;
}
// }}}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	double t,a;
	int n;
	cin >> n >> t >> a;
	pair<int,double> minv = make_pair(0,INF);
	reps(i,n){
		double h;
		cin >> h;
		if(minv.second > max(t-h * 0.006,a)-min(t-h * 0.006,a)){
			minv = make_pair(i,max(t-h * 0.006,a)-min(t-h * 0.006,a));
		}
	}
	cout << minv.first << '\n';
	return 0;	
}


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

int main() {
  int N, A;
  cin >> N >> A;
  
  if (N >= 500) {
    N %= 500;
  }
  
  if (N <= A) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }   
}

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

int N, M, r, t, n, m, s, q, ts, te;
int d[10001][722];
int cum[10001][722];

int main() {
    int N, M;
    while (cin >> N >> M, N || M) {
        memset(d, 0, sizeof d);
        cin >> r;
        for (int i=0; i<r; ++i) {
            cin >> t >> n >> m >> s;
            d[m][t-540] += (s == 1 ? 1 : -1);
        }
        memcpy(cum, d, sizeof d);
        for (int i=1; i<=M; ++i) {
            for (int j=1; j<722; ++j) {
                d[i][j] = d[i][j-1] + d[i][j];
                cum[i][j] = cum[i][j-1] + (0 < d[i][j]);
            }
        }
        cin >> q;
        for (int i=0; i<q; ++i) {
            cin >> ts >> te >> m;
            if (ts - 541 < 0) {
                cout << cum[m][te-541] << endl;
            } else {
                cout << cum[m][te-541] - cum[m][ts-541] << endl;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 57580
import Data.List
import System.IO

f :: (Int,Int) -> Int -> (Int,Int)
f (m,a) x =
  let m' = min m x
      a' = max a (x-m)
  in
    (m',a')

exec :: (Int,Int) -> IO (Int,Int)
exec (m,a)= do
  l <- getLine
  let i = read l :: Int
      o = (m,a) `seq` i `seq` f (m,a) i
  eof <- isEOF
  if eof
  then return o
  else exec o

main = do
  n <- getLine
  (_,o) <- exec (2000000000,-2000000000)
  print o

Measured memory_bytes: 49792
use proconio::{
   fastout, input,
   marker::{Bytes, Chars, Isize1, Usize1},
};

use std::collections::BinaryHeap;

#[fastout]
fn main() {
   input! {
      n:usize,
      a:[isize;n]
   }
   let mut flag = vec![true; n];
   let mut ans = 0;
   let mut out = vec![];
   let mut max = BinaryHeap::new();
   let mut min = BinaryHeap::new();
   for (i, x) in a.iter().enumerate() {
      max.push((*x, i));
      min.push((-1 * *x, i));
   }
   for t in 0..n - 1 {
      let (max_value, min_value);
      loop {
         let (x, i) = max.pop().unwrap();
         if flag[i] {
            max_value = x;
            flag[i] = false;
            break;
         }
      }
      loop {
         let (x, i) = min.pop().unwrap();
         if flag[i] {
            min_value = -1 * x;
            flag[i] = false;
            break;
         }
      }

      if t == n - 2 {
         out.push((max_value, min_value));
         ans = max_value - min_value;
      } else {
         let next_max = max.peek().unwrap().0;
         let next_min = min.peek().unwrap().0;
         if next_max == -1 * next_min {
            if next_max > 0 {
               out.push((min_value, max_value));
               max.push((min_value - max_value, flag.len()));
               min.push((-1 * (min_value - max_value), flag.len()));
               flag.push(true);
            } else {
               out.push((max_value, min_value));
               max.push((max_value - min_value, flag.len()));
               min.push((-1 * (max_value - min_value), flag.len()));
               flag.push(true);
            }
         } else if next_max.abs() > next_min.abs() {
            out.push((min_value, max_value));
            max.push((min_value - max_value, flag.len()));
            min.push((-1 * (min_value - max_value), flag.len()));
            flag.push(true);
         } else {
            out.push((max_value, min_value));
            max.push((max_value - min_value, flag.len()));
            min.push((-1 * (max_value - min_value), flag.len()));
            flag.push(true);
         }
      }
   }
   println!("{}", ans);
   for i in out {
      println!("{} {}", i.0, i.1);
   }
}


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

int main() {

	int X, N, tmp, chk_minus = 0, chk_plus = 0, c1, c2;
	cin >> X >> N;
	vector<int> p(N);
	bool flag = true;

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

	if (N == 0) {
		cout << X << endl;
		return 0;
	}

	//if (N == 1&&p[0]==X) {
	//	cout << X-1 << endl;
	//	return 0;
	//}

	for (int i = 0; i <= N; i++) {
		chk_minus = X - i;
		flag = true;
		for (int j = 0; j < N; j++) {
			if (chk_minus == p[j]) {
				flag = false;
			}
		}
		if (flag == true) {
			goto OUT1;
		}
	}
OUT1:

	for (int i = 0; i <= N; i++) {
		chk_plus = X + i;
		flag = true;
		for (int j = 0; j < N; j++) {
			if (chk_plus == p[j]) {
				flag = false;
			}
		}
		if (flag == true) {
			goto OUT2;
		}
	}
OUT2:

	c1 = abs(X - chk_minus);
	c2 = abs(X - chk_plus);



	if (c1 == c2) {
		cout << chk_minus << endl;
		//cout << "1" << endl;
		return 0;

	}
	if (c1 > c2) {
		cout << chk_plus << endl;
		//cout << "2" << endl;
		return 0;

	}
	else {
		cout << chk_minus << endl;
		//cout << "3" << endl;
		return 0;
	}


}


Measured memory_bytes: 3648
#include<iostream>
#include<stdlib.h>
#include<iomanip>
#include<string>
#include<math.h>

using namespace std;

int main(){
    string S1,S2,S3;
    int a=0,b=0,c=0;
    char n;
    cin>>S1>>S2>>S3;
    n=S1[a];
    a++;
    while(1){
        switch(n){
            case 'a':
            if(a==S1.length()){
                cout<<"A"<<endl;
                return 0;
            }
            else n=S1[a];
            a++;
            break;

            case 'b':
            if(b==S2.length()){
                cout<<"B"<<endl;
                return 0;
            }
            else n=S2[b];
            b++;
            break;

            case 'c':
            if(c==S3.length()){
                cout<<"C"<<endl;
                return 0;
            }
            else n=S3[c];
            c++;
            break;
        }
    }
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		// long t = System.currentTimeMillis();
		new Main().run();
		// System.err.println(System.currentTimeMillis() - t);
	}

	void run() {
		Scanner sc = new Scanner();
		String s = sc.next();
		for (int i = 0; i + 1 < s.length(); ++i) {
			int j = i + 1;
			if (s.charAt(i) == 'A' && s.charAt(j) == 'C') {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}

	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}

	class Scanner {
		private final InputStream in = System.in;
		private final byte[] buffer = new byte[1024];
		private int ptr = 0;
		private int buflen = 0;

		private boolean hasNextByte() {
			if (ptr < buflen) {
				return true;
			} else {
				ptr = 0;
				try {
					buflen = in.read(buffer);
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (buflen <= 0) {
					return false;
				}
			}
			return true;
		}

		private int readByte() {
			if (hasNextByte())
				return buffer[ptr++];
			else
				return -1;
		}

		private boolean isPrintableChar(int c) {
			return 33 <= c && c <= 126;
		}

		private void skipUnprintable() {
			while (hasNextByte() && !isPrintableChar(buffer[ptr]))
				ptr++;
		}

		public boolean hasNext() {
			skipUnprintable();
			return hasNextByte();
		}

		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (isPrintableChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}

		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}

		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			long n = 0;
			boolean minus = false;
			int b = readByte();
			if (b == '-') {
				minus = true;
				b = readByte();
			}
			if (b < '0' || '9' < b) {
				throw new NumberFormatException();
			}
			while (true) {
				if ('0' <= b && b <= '9') {
					n *= 10;
					n += b - '0';
				} else if (b == -1 || !isPrintableChar(b)) {
					return minus ? -n : n;
				} else {
					throw new NumberFormatException();
				}
				b = readByte();
			}
		}
	}
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


// union by size + path having
class UnionFind {
public:
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    // Constructor
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    // Member Function
    // Find
    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    // Union(Unite, Merge)
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

// 友達の友達の。。。で繋がれたら４つ目を満たす
void solve() {
    int N,M,K;
    cin >> N >> M >> K;
    UnionFind uf(N+1);

    // 友達候補
    //vector<vector<int>> direct_friends(N+1,vector<int>());
    //vector<vector<int>> blocked_friends(N+1,vector<int>());
    vector<int> direct_friends(N+1,0);
    vector<int> blocked_friends(N+1,0);

    REP(_,M) {
        int a,b;
        cin >> a >> b;
        uf.merge(a,b);
        direct_friends[a]++;
        direct_friends[b]++;
    }

    REP(_,K) {
        int c,d;
        cin >> c >> d;
        if (uf.issame(c,d)) {
            blocked_friends[c]++;
            blocked_friends[d]++;
        }
    }

    FOR(i,1,N+1) {
        // 自分を抜く
        auto def_size = uf.size(i) - 1;
        // 直接の友達を抜く
        def_size -= direct_friends[i];
        // ブロックし合ってるのを抜く
        def_size -= blocked_friends[i];
        if (i != N) cout << def_size << " ";
        else cout << def_size << endl;
    }



}

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


Measured memory_bytes: 3200
# include <bits/stdc++.h>
# define speed ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
# pragma GCC target("avx2")
# pragma GCC optimize("O3")
# pragma GCC optimize("unroll-loops")
# define int long long
  
using namespace std;
  
const int N = 1e3 + 7;
const int mod = 1e9 + 7;

int32_t main() {
    speed;
    long double a, b;
    cin >> a >> b;
    b = round(b * 100);
    cout << (int)(a * b / 100);
}


Measured memory_bytes: 3808
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a=sc.nextInt(),b=sc.nextInt(),c=sc.nextInt();
        sc.close();
        System.out.printf("%d %d %d\n",c,a,b);
    }
}

Measured memory_bytes: 35672
#include<cstdio>
#include<iostream>
using namespace std;
long long dp[55][2505], ans;
int n, a, m;
int main() {
	scanf("%d%d", &n, &a); dp[0][0] = 1; m = a * n;
	for (int t, i = 1; i <= n; ++i) {
		scanf("%d", &t);
		for (int j = i; j; --j)
			for (int k = m; k >= t; --k)
				dp[j][k] += dp[j-1][k-t];
	} 
	for (int i = 1; i <= n; ++i) ans += dp[i][i*a];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <stdio.h>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define repone(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define Rep(j,n) for(int j=0;j<(int)(n);++j)
#define Repo(j,o,n) for(int j=o;j<(int)(n);++j)
#define Repone(j,n) for(int j=1;j<(int)(n);++j)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define int long long
#define pb(a) push_back(a)
#define pbpair(a,b) push_back(make_pair(a,b))
#define MOD 1000000007
#define INF 9223372036854775807
#define pairint pair<int,int>
int gcd( int x, int y ){ return y ? gcd(y, x%y) : x; }
signed main() {
int x=0,y=0,z=0,w=0,n=0,m=0;
std::cin >> x;
if(x==7||x==5||x==3)std::cout << "YES" << '\n';
else std::cout << "NO" << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define TOSTRING(x) #x
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());
#define PAU system("pause")

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vb> vvb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 30);
const double PI = acos(-1);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string S;
	cin >> S;
	REP(i, SZ(S)-1) {
		if (S[i] == S[i + 1]) {
			cout << i + 1 << " " << i + 2 << endl;
			return 0;
		}
	}
	REP(i, SZ(S) - 2) {
		if (S[i] == S[i + 2]) {
			cout << i + 1 << " " << i + 3 << endl;
			return 0;
		}
	}
	cout << -1 << " " << -1 << endl;
	PAU;
	return 0;
}


Measured memory_bytes: 712
#include<bits/stdc++.h>
#define ll long long
#define endl '\n'
#define fi first
#define se second
#define ls(a) tree[a].l
#define rs(a) tree[a].r
#define lz(a)  tree[a].lz
#define sum(a) tree[a].sum
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l) for(int i=r;i>=l;i--)
#define mid l+r>>1
#define lson l,mid,ls(p)
#define rson (mid)+1,r,rs(p)
const int MX=1e5+7;
const int N=1e9+1;
const int mod=998244353;
const double pi=3.1415926535897932384;
double isp=1e-13;
using namespace std;
ll qpow(ll a,ll b,ll MOD=mod){for(ll ans=1;;a=a*a%MOD,b>>=1){if(b&1)ans=ans*a%MOD;if(!b)return ans;}}
ll inv(ll a,ll MOD=mod){return qpow(a,MOD-2,MOD);}//要求MOD为质数
ll exgcd(ll a,ll b,ll &x,ll &y){if(b==0){x=1,y=0;return a;}ll ret=exgcd(b,a%b,y,x);y-=a/b*x;return ret;}
ll getInv(int a,int mod){ll x,y;ll d=exgcd(a,mod,x,y);return d==1?(x%mod+mod)%mod:-1;}//求a在mod下的逆元，不存在逆元返回-1，不要求MOD为质数
ll add(ll a,ll b){ll ans=(a+b)%mod;return ans>=0?ans:ans+mod;}
void  mul(ll &a,ll b){a=a%mod*(b%mod)%mod; }
vector<int>G[MX];
int a[MX];
int main()
{
  ios::sync_with_stdio(0),cin.tie(0);
  int n;
  cin>>n;
  rep(i,1,n)a[i]=mod;
  for(int i=1;i<n;i++)
  {
      int x,y;
      cin>>x>>y;
      G[x].push_back(y);
      G[y].push_back(x);
  }
  priority_queue<pair<int,int>>q;
  int k;
  cin>>k;
  rep(i,1,k)
  {
      int x,val;
      cin>>x>>val;
      a[x]=val;
      q.push({-val,x});
  }
  if(q.empty())
  {
      q.push({0,1});
  }
  int tmp=0;
  while(!q.empty())
  {
      auto x=q.top();
      q.pop();
      int val=-x.fi;
  //    cout<<val<<" "<<x.se<<endl;
      for(int y:G[x.se])
      {
//          cout<<y<<" a="<<a[y]<<endl;

          if(a[y]<mod)
          {
              if(abs(a[y]-val)!=1)
              {
                  tmp++;
                  break;
              }
          }
          else
          {
              a[y]=val+1;
              q.push({-val-1,y});
          }

    //      cout<<y<<" a2="<<a[y]<<endl;
      }
      if(tmp)break;
  }
  if(tmp){
    cout<<"No"<<endl;
    return 0;
  }
  cout<<"Yes"<<endl;
  rep(i,1,n)cout<<a[i]<<endl;
}


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

int main() {
  int n, k, c;
  string s;
  cin >> n >> k >> c >> s;

  vector<int> l(n), r(n), lt(n, -1e9), rt(n, 1e9);

  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      l[i] = 1;
      lt[i] = i;
      i += c;
    }
  }
  for (int i = 0; i + 1 < n; i++) {
    l[i + 1] += l[i];
    lt[i + 1] = max(lt[i + 1], lt[i]);
  }

  for (int i = n - 1; i >= 0; i--) {
    if (s[i] == 'o') {
      r[i] = 1;
      rt[i] = i;
      i -= c;
    }
  }
  for (int i = n - 1; i - 1 >= 0; i--) {
    r[i - 1] += r[i];
    rt[i + 1] = max(rt[i - 1], rt[i]);
  }

  for (int i = 0; i < n; i++) {
    if (s[i] != 'o') continue;
    int s = 0, lti = -1e9, rti = 1e9;
    if (i - 1 >= 0) {
      s += l[i - 1];
      lti = lt[i - 1];
    }
    if (i + 1 < n) {
      s += r[i + 1];
      rti = rt[i + 1];
    }
    if (s < k || (s == k && rti - lti - 1 < c)) cout << i + 1 << '\n';
  }
  cout << flush;
}


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

#define ff first
#define ss second
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(int i=x;i<=n;i++)

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

using namespace std;

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

	ll n; cin >> n;
	ll b[n];

	f(i, 0, n - 2) cin >> b[i];

	ll sum = b[0];

	f(i, 1, n - 2) sum += (min(b[i - 1], b[i]));
	sum += b[n - 2];
	
	cout << sum;


	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}
ll dp[3010][3010][4];
int main(){

    ll r,c,k;
    cin>>r>>c>>k;
    vector<vector<ll>> t(r,vector<ll>(c,0));
    rep(i,k){
        ll r1,c1,v1;
        cin>>r1>>c1>>v1;
        t[r1-1][c1-1]=v1;
    }
    rep(i,r){
        rep(j,c){
            for(int l=3;l>0;l--){
                dp[i][j][l] = max(dp[i][j][l],dp[i][j][l-1]+t[i][j]);
            }
            for(int l=0;l<4;l++){
                dp[i][j+1][l]=max(dp[i][j][l],dp[i][j+1][l]);
                dp[i+1][j][0]=max(dp[i+1][j][0],dp[i][j][l]);

            }
        }
    }

    cout<<dp[r][c-1][0]<<endl;

return 0;
}


Measured memory_bytes: 355856
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	long long N, A;
	long long total = 0;
	cin >> N;
	vector<long long> vec(N);
	vector<long long> high{ 0 };
	for (long long i = 0; i < N; i++) {
		cin >> A;
		vec.at(i) = A;
	}
	for (long long j = 1; j < N; j++) {
		if (vec.at(j) < vec.at(j - 1)) {
			high.push_back(vec.at(j - 1) - vec.at(j));
			vec.at(j) = vec.at(j - 1);
		}
	}
	for (long long k = 0; k < high.size(); k++)
		total += high.at(k);
	cout << total << endl;
}


Measured memory_bytes: 6748
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int n, k;
int64 a[200005];

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> n >> k;
    int64 l = 1, r = 0;
    for (int i = 0; i < n; i++){
        cin >> a[i];
        r = max(r, a[i]);
    }
    while (l < r){
        int64 mid = (l + r) >> 1;
        int64 cnt = 0;
        for (int i = 0; i < n; i++){
            cnt += a[i] / mid + (a[i] % mid != 0) - 1;
        }
        if (cnt <= k) r = mid; else l = mid + 1;
    }
    cout << l;
    return 0;
}


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

using namespace std;

int main() 
{
	int n;	cin >> n;
	string cad;	cin >> cad;
	// cout << cad.size() << "\n";
	if (cad.size() > n )
		cout << cad.substr(0, n) + "...\n";
	else
		cout << cad << "\n";
	
}

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

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

int n, c;
vector<int> a, b;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while(1){
        cin >> n >> c;
        if(n == 0 && c == 0) break;
        a.assign(n, 0);
        b.assign(c, 0);
        REP(i, n) REP(j, 16) {
            int x; cin >> x;
            if(j != 0) a[i] <<= 1;
            a[i] += x;
        }
        REP(i, c) REP(j, 16) {
            int x; cin >> x;
            if(j != 0) b[i] <<= 1;
            b[i] += x;
        }

        vector<vector<int>> dp(35, vector<int>((1<<16), -1));
        dp[0][a[0]] = 0;
        REP(i, n){
            for(int mask = 0; mask < (1 << 16); mask++){
                if(dp[i][mask] != -1){
                    int m = mask | a[i];
                    REP(j, c){
                        int andnum = m & b[j];
                        int notandnum = m & ~b[j];
                        dp[i+1][notandnum] = max(dp[i+1][notandnum], dp[i][mask] + __builtin_popcount(andnum));
                    }
                }
            }
        }

        int ans = 0;
        REP(i, (1 << 16)){
            ans = max(ans, dp[n][i]);
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 12328
mp1 = {}
mp2 = {}
cnt = [0] * 4

mp1['AC'] = 0
mp1['WA'] = 1
mp1['TLE'] = 2
mp1['RE'] = 3

mp2[0] = 'AC'
mp2[1] = 'WA'
mp2[2] = 'TLE'
mp2[3] = 'RE'

n = int(input())

for i in range(n):
	s = input()
	cnt[mp1[s]] += 1

for i in range(4):
	print(mp2[i], 'x', cnt[i])

Measured memory_bytes: 9216
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math
    #from math import gcd

    #inf = 10**17
    #mod = 10**9 + 7

    x, y = map(int, input().split())
    res = 10**10
    if x == -y:
        res = 1
    if x < y:
        res = min(res, y-x)
    if x > y:
        res = min(res, x-y+2)
    if -x < y:
        res = min(res, y+x+1)
    if -x > y:
        res = min(res, -x-y+1)
    print(res)

if __name__ == '__main__':
    main()

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

int arr[100005][4];
int dp[100005][4];
int n;
int f(int day, int flag){ 
    

    if(day==n) return 0;
    if(dp[day][flag]!=-1) return dp[day][flag];

    int maxi=0;

    if(flag==0){
        
        maxi=max(maxi,arr[day][1]+f(day+1,1));
        maxi=max(maxi,arr[day][2]+f(day+1,2));
        maxi=max(maxi,arr[day][3]+f(day+1,3));
    }
    else if(flag==1){
        
        maxi=max(maxi,arr[day][2]+f(day+1,2));
        maxi=max(maxi,arr[day][3]+f(day+1,3));
    }
    else if(flag==2){
        maxi=max(maxi,arr[day][1]+f(day+1,1));
        maxi=max(maxi,arr[day][3]+f(day+1,3));
    }
    else if(flag==3){
        maxi=max(maxi,arr[day][1]+f(day+1,1));
        maxi=max(maxi,arr[day][2]+f(day+1,2));
    }

    
  return dp[day][flag]=maxi;
}
int main(){
   
    cin>>n;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<n;i++){
        for(int j=1;j<4;j++)
            cin>>arr[i][j];
    }
     cout<<f(0 , 0);


   

    return 0;
}

Measured memory_bytes: 14468
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)


using namespace std;

int main() {

	SINT32 N = 0;
	SINT32 NG = 0;

	cin >> N;

	vector<string> DATA(N);
	
	for (SINT32 i = 0; i < N; i++) {
		cin >> DATA[i];

		if (i != 0) {
			if (DATA[i].front() != DATA[i-1].back()) {
				NG = 1;
				break;
			}
		}

		rep(j,i) {
			if (DATA[i] == DATA[j]) {
				NG = 1;
				break;
			}
		}
		
	}

	if (NG == 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();

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

const long long INF = 1000000000000000005;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
#ifdef LOCAL_DEFINE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  int n, w_max, sum_val = 0;
  cin >> n >> w_max;
  vector<int> w(n), v(n);
  for (int i = 0; i < n; ++i)
  {
    cin >> w[i] >> v[i];
    sum_val += v[i];
  }
  vector<long long> dp(sum_val + 1, INF);
  dp[0] = 0;
  for (int i = 0; i < n; ++i)
  {
    for (int j = sum_val - v[i]; j >= 0; --j)
    {
      dp[v[i] + j] = min(dp[v[i] + j], dp[j] + w[i]);
    }
  }
  int ans = 0;
  for (int i = 0; i <= sum_val; ++i)
  {
    if (dp[i] <= w_max)
    {
      ans = max(ans, i);
    }
  }
  cout << ans << '\n';
}

Measured memory_bytes: 1024
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 indexR = 0;
		int indexL = 0;
		int[] exist = new int[n];
		Arrays.fill(exist, -1);
		for(int i = 0; i < n+1; i++){
		    int a = sc.nextInt()-1;
		    if(exist[a] != -1){
		        indexR = i;
		        indexL = exist[a];
		    }
		    exist[a] = i;
		}
		// 計算
		long result = 0;
		int MOD = 1000000007;
		Combination comb = new Combination(n+1);
		int cnt = indexL + n-indexR;
		
		// 出力
		for(int i = 0; i < n+1; i++){
		    long tmp = 0;
		    if(cnt >= i) tmp = comb.combination(cnt, i);
		    result = (comb.combination(n+1, i+1) - tmp + MOD)%MOD;
		    System.out.println(result);
		}
	}
}

class Combination {
	static final int MOD = 1000000007;
	long[] fact;
	long[] invFact;
	long[] inv;
	
	public Combination (int n) {
		fact = new long[n+1];
		invFact = new long[n+1];
		inv = new long[n+1];
		fact[0] = 1;
		fact[1] = 1;
		invFact[0] = 1;
		invFact[1] = 1;
		inv[1] = 1;
		for (int i = 2; i < n+1; i++) {
			fact[i] = fact[i - 1] * i % MOD;
			inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
			invFact[i] = invFact[i - 1] * inv[i] % MOD;
		}
	}
	
	public long combination(int n, int k) {
		if (n < k || n < 0 || k < 0) {
			return 0;
		}
		return fact[n] * (invFact[k] * invFact[n - k] % MOD) % MOD;
	}
}



Measured memory_bytes: 61692
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long
using namespace std;

typedef long long ll;
typedef vector <int> vi;
typedef vector<vi> vvi;
typedef pair <int, int> ii;
typedef pair<int, pair<int,int> > iii;
typedef vector<ii> vii;
typedef vector<iii> viii;

int a[200000];
signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]*=2;
	}
	int homie = 0;
	for(int i=0;i+1<n;i++){
		if(i%2==0)
			homie-=a[i];
		else homie+=a[i];
	}
	vi m;
	int m0 = (a[n-1] - homie)/2;
	m.pb(m0);
	for(int i=0;i+1<n;i++){
		int x1 = a[i] - m.back();
		m.pb(x1);
	} 
	for(int i=0;i<m.size();i++)
		cout<<m[i]<<" ";

	return 0;
}


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <stack>
using namespace std;

int main() {


    int n;
    string s;
    cin >> n >> s;

    stack <int> st;
    for(int i=0; i<n; i++){
    	if (st.empty()){
    		st.push(s[i]);
    	} else {
    		if (st.top() != s[i]) {
    			st.push(s[i]);
    		}
    	}
    }

    cout << st.size() << endl;

} 

Measured memory_bytes: 768
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;


int main(){
	for (double vb; cin >> vb; ){
		for (int i = 1; ; i++) {
			double v = sqrt(2 * (i - 1) * 5 * 9.8);
			if ( v >= vb) {
				cout << i << endl;
				break;
			}
		}
	}
	
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << endl;
#else
	#define DBG(X)
	#define endl '\n'
#endif
 
using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const ll mod = 1e9 + 7;
const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }

const int MAX_N = (int)2e5 + 777;

int a[MAX_N], b[MAX_N], n;

void solve()
{
	cin >> n;

	set<pii> setik; // {value, position}

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

	for(int i = 0; i < n; ++i)
	{
		cin >> a[i];
		setik.emplace(a[i], i);
	}

	ll answ = 0;

	while(!setik.empty())
	{
		auto iter = prev(setik.end());

		int i = iter->second;
		int prv = i - 1;

		if(prv < 0)
			prv += n;

		int nxt = i + 1;

		if(nxt >= n)
			nxt -= n;

		setik.erase(iter);

		int sm = a[prv] + a[nxt];

		if(a[i] > sm && a[i] > b[i])
		{
			int cnt = (a[i] - b[i]) / sm;
			a[i] -= sm * cnt;
			answ += cnt;

			if(cnt)
				setik.emplace(a[i], i);
		}

#ifdef __LOCAL
		for(int i = 0; i < n; ++i)
			cout << a[i] << " ";

		cout << endl;
#endif
	}

	for(int i = 0; i < n; ++i)
	{
		if(a[i] != b[i])
		{
			cout << NIL << endl;
			return;		
		}
	}

	cout << answ << endl;
}

int main()
{
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 11264
var fs = require('fs'),
    length = fs.fstatSync(process.stdin.fd).size,
    buffer = new Buffer(length),
    bytesRead = fs.readSync(process.stdin.fd, buffer, 0, length, 0),
    input = buffer.toString('utf8', 0, bytesRead).split('\n');
main();
function main(){
// do something
a=input[0].split(' ').map(Number);
console.log(a[0]*a[1],2*(a[0]+a[1]));
}


Measured memory_bytes: 15160
def prime_pair(n):
    pairs = {}
    tmp = n
    for i in range(2, n):
        if i * i > n:
            break
        if tmp % i != 0:
            continue
        ex = 0
        while tmp % i == 0:
            ex += 1
            tmp /= i
        pairs[i] = ex
    if tmp != 1:
        pairs[int(tmp)] = 1
    return pairs

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


A, B = list(map(int, input().split()))

ppa = prime_pair(A)
ppb = prime_pair(B)

g = gcd(A,B)
ppg = prime_pair(g)

print(len(ppg.keys())+1)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;

int x,y,pi[23][2],pt[2][23],pl[23],sum=2000000000;

bool bj1(int a,int b)
{
	return pi[a][1]<pi[b][1]||(pi[a][1]==pi[b][1]&&a<b);
}

bool bj2(int a,int b)
{
	return pi[a][0]<pi[b][0]||(pi[a][0]==pi[b][0]&&a<b);
}

int suan(int a,int b)
{
	int pp[2][23];
	for(int i=1; i<=b; i++) pp[0][i]=pt[0][i];
	for(int i=1; i<=a; i++) pp[1][i]=pt[1][i];
	sort(pp[1]+1,pp[1]+1+a,bj1);
	sort(pp[0]+1,pp[0]+1+b,bj2);
	for(int i=1; i<=a+b; i++) pl[i]=pp[i%2][(i-1)/2+1];
	for(int i=1; i<a+b; i++) if(pi[pl[i]][i%2]>pi[pl[i+1]][(i+1)%2]) return sum;
	int p=0;
	for(int i=1; i<=a+b; i++)
	{
		p+=pl[i]-i;
		for(int j=1; j<i; j++) if(pl[j]>pl[i]) p++;
	}
	return p;
}

void sou(int k,int a,int b)
{
	if(a==0&&b==0)
	{
		sum=min(sum,suan(x,y));
		return;
	}
	if(a!=0)
	{
		pt[1][a]=k;
		sou(k+1,a-1,b);
	}
	if(b!=0)
	{
		pt[0][b]=k;
		sou(k+1,a,b-1);
	}
	return;
}

int main()
{
	int n; scanf("%d",&n);
	for(int i=1; i<=n; i++) scanf("%d",&pi[i][i%2]);
	for(int i=1; i<=n; i++) scanf("%d",&pi[i][1-i%2]);
	y=n/2; if(n%2==1) x=y+1; else x=y;
	sou(1,x,y);
	if(sum==2000000000) printf("-1");
	else printf("%d",sum);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define pb push_back
#define fi first
#define se second
#define fr(i,s,e) for(i=s;i<e;i++)
#define ms(arr,val) memset(arr,val,sizeof(arr))
using namespace std;

const int mxn=2e5+1;
ll coeff[mxn],difficulty[mxn],n,k;
bool check(ll mid)
{
  ll required=0;
  for(int i=0;i<n;i++)
  {
    ll val=coeff[i]*difficulty[i];
    if(val>mid)
    {
      required+=coeff[i]-(mid)/difficulty[i];
    }
  }
  return required<=k;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

  int t=1;
//  cin>>t;
  int tt=1;
  while(t--){
    cin>>n>>k;
    ll i;
    fr(i,0,n)
    cin>>coeff[i];
    fr(i,0,n)
    cin>>difficulty[i];
    sort(coeff,coeff+n);
    reverse(coeff,coeff+n);
    sort(difficulty,difficulty+n);
    ll beg=0,last=1e12,mid,ans=0;
    while(beg<=last)
    {
      mid=(beg+last)>>1;
      if(check(mid))
        ans=mid,last=mid-1;
      else beg=mid+1;
    }
    cout<<ans;
   // cout<<"Case #"<<tt<<": ";
   // tt++;
    }
  return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define endl "\n"
#define inf (1e9+7)
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

class item {
public:
	int weight;
	int value;
};

ll Knapsack1(vector<item>v, int n, int w) {
	ll dp[n + 1][w + 1];
	for (int wt = 0; wt <= w; wt++)
		dp[1][wt] = 0;
	dp[1][v[1].weight] = v[1].value;
	for (int i = 2; i <= n; i++) {
		for (int wt = 0; wt <= w; wt++) {
			dp[i][wt] = dp[i - 1][wt];
			if (v[i].weight > wt) continue;
			dp[i][wt] = max(dp[i][wt], v[i].value + dp[i - 1][wt - v[i].weight]);
		}
	}
	return *max_element(dp[n], dp[n] + w + 1);
}
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, w;
	cin >> n >> w;
	vector<item>v(n + 1);//1 based indexing
	for (int i = 1; i <= n; i++)
		cin >> v[i].weight >> v[i].value;
	cout << Knapsack1(v, n, w) << endl;

	return 0;
}


Measured memory_bytes: 81620
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 200010;
int p[10][10] = {0};
int n,ans = 0;
int AA(int num){
	while(num >= 10){
		num/=10;
	}
	return num;
}
void init(){
	int x,y;
	for(int i = 1; i <= n; i++){
		x = i%10;
		y = AA(i);
		p[y][x]++;
		//cout  <<"y :" <<y <<"x :"<< x <<" "<< p[y][x]<<endl;
	}
}
void num_sum(){
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			//cout << p[i][j] <<"****"<< p[j][i]<<endl;
			ans = ans+p[i][j]*p[j][i];
		}
	}
}
int main() {
	cin >> n;
	init();
	num_sum();
	cout << ans <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>

using namespace std;
typedef long long ll;

int f(int x) {
	while (x >= 10) {
		x = x / 10;
	}
	return x;
}

int main(void) {
	int n; cin >> n;
	vvint rec(10,vint(10));
	for (int i = 1; i <= n; i++) {
		rec[i % 10][f(i)]++;
	}
	ll ans=0;
	for (int i = 1; i < 10; i++) {
		for (int j = 1; j < 10; j++) {
			ans += rec[i][j] * rec[j][i];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define int long long
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
typedef long long ll;
using namespace std;

int mypow(int a,int b){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1)*a%mod;
	return mypow(a,b/2)*mypow(a,b/2)%mod;
}
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int gcd(int a,int b){
	if(b==0) return a;
	return (b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

signed main(){
	string s;
	cin>>s;
	if(s.size()==2){
		cout<<s<<endl;
	}
	else{
		cout<<s[2]<<s[1]<<s[0]<<endl;
	}
	return 0;
}

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



int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin>>n;
    vector<ll>a(n);
    rep(i,n)cin>>a[i];
    ll ans=0;
    ll t=0;
    rep(i,n){
        t+=a[i];
        if(a[i]==0||i==n-1){
            ans+=t/2;
            t=0;
        }
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
int main(int argc, char const *argv[]) {
    int n;
    cin >> n;
    vector<int> h(n);
    REP(i,n) cin >> h[i];
    h.push_back(0);
    int now = 100;
    ll ans = 0;
    while(now > 0){
        bool f = false;
        REP(i,n+1) {
            if (h[i] >= now) f = true;
            else {
                if (f) {
                    ans++;
                    f = false;
                }
            }
        }
        now--;
    }
    cout << ans << endl;
    return 0;
}

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

const ll MX = 1e18;

int main() {
	int n;
	cin >> n;
	ll ans=1;
	
	bool flg = false;
	rep(i,n){
		ll a;
		cin >> a;
		if (a ==0){
			cout << 0 << endl;
			return 0;
		}
		if(flg || MX/ans < a){
			flg = true;
		}
		ans *= a;
	}
	if(flg) cout << -1 <<endl;
	else cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 3568
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn main() {
    let a = read::<i32>();
    let s = read::<String>();

    if a >= 3200 {
        println!("{}", s);
    } else {
        println!("red");
    }
}


Measured memory_bytes: 4352
#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 all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
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;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

ll dp[45][2];
int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(0);

   int n;
   ll K;
   cin >> n >> K;
   vector<ll> a(n);
   rep(i, 0, n) cin >> a[i];
   rep(i, 0, 45) dp[i][1] = -1;
   dp[41][0] = 0;
   rrep(d, 40, 0) {
      ll mask = 1LL << d;
      int cnt = 0;
      rep(i, 0, n) if (a[i] & mask) cnt++;
      if (dp[d + 1][1] >= 0)
         chmax(dp[d][1], dp[d + 1][1] + mask * max(cnt, n - cnt));
      if (K & mask) {
         chmax(dp[d][1], dp[d + 1][0] + mask * cnt);
         chmax(dp[d][0], dp[d + 1][0] + mask * (n - cnt));
      } else {
         chmax(dp[d][0], dp[d + 1][0] + mask * cnt);
      }
   }
   cout << max(dp[0][0], dp[0][1]) << endl;
   return 0;
}

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

using namespace std;

int main(void)
{

    //freopen("C:\\Users\\Administrator\\Desktop\\debug.in", "r", stdin);
    int a, b;

    while(cin >> a >> b && !(a == 0 && b == 0))
        if(a < b)
            cout << a << " " << b << endl;
        else
            cout << b << " " << a << endl;


   return 0;
}



Measured memory_bytes: 3084