akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
string to_string(const string& s) {
	return '"' + s + '"';
}
string to_string(const bool b) {
	return (b ? "true" : "false");
}
string to_string(const char* s) {
	return to_string((string)s);
}
string to_string(const char c) {
	string s = "'";
	s += c;
	s += "'";
	return s;
}
template<class T, class U>
string to_string(const pair<T, U>& p) {
	string s = "(";
	s += to_string(p.first);
	s += ", ";
	s += to_string(p.second);
	s += ")";
	return s;
}
template<class T>
string to_string(const T& a) {
	bool first = true;
	string s = "{";
	for (const auto& x : a) {
		if(!first){
			s += ", ";
		}
		first = false;
		s += to_string(x);
	}
	s += "}";
	return s;
}
void debug_out() {cerr << '\n';}
template<class Head, class... Tail>
void debug_out(Head head, Tail... tail) {
	cerr << ' ' << to_string(head);
	debug_out(tail...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "] = ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
using ll = long long;
using ld = long double;
const int mod = 1e9 + 7;
const int inf = 1e9 + 100;
const ll inf64 = 7e18l;
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(20);
	int n;
	cin >> n;
	cout << 1ll * n * (n - 1) / 2 << '\n';
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define mkp make_pair
int mi[30],n;
const int N=5e5+10;
int a[N];
pii mxans[N][2];
void update(pii *x,pii y){
	if(y.second==x[0].second||y.second==x[1].second) return ;
	if(x[0].first>x[1].first) swap(x[0],x[1]);
	if(x[0].first<y.first) {x[0]=y;return;}
	if(x[1].first<y.first) {x[1]=y;return;}
}
void update(int k){
	for(int i=n;i>=1;i--){
		if(!(k&(1<<i-1))) continue;
		update(mxans[k],mxans[k-(1<<i-1)][0]);
		update(mxans[k],mxans[k-(1<<i-1)][1]);
	}
}

int getans(int p){
	int ans=-1;
	p++;
	while(p){
		pii temp[2];
		temp[0]=temp[1]=mkp(-1,0);
		update(temp,mxans[p-1][0]);
		update(temp,mxans[p-1][1]);
		p-=(p&(-p));
		ans=max(ans,temp[0].first+temp[1].first);
	}
	return ans;
}
int main()
{
	mi[0]=1;
	for(int i=1;i<=20;i++) mi[i]=mi[i-1]*2;
	scanf("%d",&n);
	for(int i=0;i<mi[n];i++){
		scanf("%d",&a[i]);
		update(i);
		update(mxans[i],mkp(a[i],i+1));
		if(i>=1)	printf("%d\n",getans(i));
	}
	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

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

	auto isValid = false;
	for (auto i = 0; i < 4; ++i)
	{
		string result;
		if ((i & 1) != 0)
		{
			result += "S";
		}
		else
		{
			result += "W";
		}
		if ((i & 2) != 0)
		{
			result += "S";
		}
		else
		{
			result += "W";
		}

		for (auto j = 1; j < N - 1; ++j)
		{
			auto isSame = false;
			if (result[j] == 'S')
			{
				if (s[j] == 'o')
				{
					isSame = true;
				}
			}
			else
			{
				if (s[j] == 'x')
				{
					isSame = true;
				}
			}

			if (isSame)
			{
				result += result[j - 1];
			}
			else if (result[j - 1] == 'S')
			{
				result += "W";
			}
			else
			{
				result += "S";
			}
		}

		isValid = true;
		for (auto j = N - 1; j <= N; ++j)
		{
			auto isSame = false;
			auto current = (j + N) % N;
			auto prev = (j + N - 1) % N;
			auto next = (j + N + 1) % N;
			if (result[current] == 'S')
			{
				if (s[current] == 'o')
				{
					isSame = true;
				}
			}
			else if (s[current] == 'x')
			{
				isSame = true;
			}

			if (isSame)
			{
				if (result[next] != result[prev])
				{
					isValid = false;
					break;
				}
			}
			else
			{
				if (result[next] == result[prev])
				{
					isValid = false;
					break;
				}
			}
		}

		if (isValid)
		{
			cout << result << endl;
			break;
		}
	}

	if (!isValid)
	{
		cout << "-1" << endl;
	}

	return 0;
}

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

int main(){
	string s;
	cin >> s;
	bool a = false,b = false,c = false;
	REP(i,3){
		if(s[i] == 'a') a = true;
		if(s[i] == 'b') b = true;
		if(s[i] == 'c') c = true;
	}
	if(a == true && b == true && c == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
from collections import Counter
def main():
    n = int(input())

    def is_prime(n):
        for i in range(2, n + 1):
            if i * i > n:
                break
            if n % i == 0:
                return False
        return n != 1

    def prime_dec(n):
        i = 2
        table = []
        while i * i <= n:
            while n % i == 0:
                n /= i
                table.append(int(i))
            i += 1
        if n > 1:
            table.append(n)
        return table


    if is_prime(n):
        print(1)
        sys.exit()

    pd = prime_dec(n)
    pdc = Counter(pd)
    pdcl = [pdc[i] for i in pdc]
    r = 0
    for pse in pdcl:
        num = pse
        cnt = 1
        while num > 0:
            if cnt > num:
                break
            else:
                r += 1
                num -= cnt
                cnt += 1
    print(r)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9448
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= (int)end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string N;
    cin >> N;
    rep(i, 0, 3) {
        if (N[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

const int maxn=200005;
const int mlog=20;
int n,k,q;
int x[maxn];
int prv[maxn][mlog],nxt[maxn][mlog];
long long sprv[maxn][mlog],snxt[maxn][mlog];

int main(){
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)scanf("%d",&x[i]);
	int ppt=0;
	for(int j=0;j<mlog;j++)prv[0][j]=0;
	for(int i=1;i<=n;i++){
		while(ppt+1<i&&x[i]-x[ppt+1]>=k)ppt++;
		prv[i][0]=ppt;
		sprv[i][0]=i;
		for(int j=1;j<mlog;j++)
			prv[i][j]=prv[prv[i][j-1]][j-1],sprv[i][j]=sprv[i][j-1]+sprv[prv[i][j-1]][j-1];
	}
	int npt=n+1;
	for(int j=0;j<mlog;j++)nxt[n+1][j]=n+1;
	for(int i=n;i>=1;i--){
		while(npt-1>i&&x[npt-1]-x[i]>=k)npt--;
		nxt[i][0]=npt;
		snxt[i][0]=i;
		for(int j=1;j<mlog;j++)
			nxt[i][j]=nxt[nxt[i][j-1]][j-1],snxt[i][j]=snxt[i][j-1]+snxt[nxt[i][j-1]][j-1];
	}
	scanf("%d",&q);
	while(q--){
		int l,r;
		scanf("%d%d",&l,&r);
		long long ans=0;
		int cl=l,cr=r,cd=0;
		for(int i=mlog-1;i>=0;i--)if(nxt[cl][i]<=r){
			ans+=sprv[cr][i]-snxt[cl][i];
			cl=nxt[cl][i];
			cr=prv[cr][i];
			cd+=(1<<i);
		}
		ans+=cr-cl+cd+1;
		printf("%lld\n",ans);
	}
	return 0;
}

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

using namespace std;

#define LIMIT 100
typedef long long ll;
typedef pair<ll, ll> ii;
int gcd(ll a, ll b) { return (b==0)?a:gcd(b, a%b); }
int lcm(ll a, ll b) { ll i=(a/gcd(a,b))*b; assert(i>0); return i; }

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);

  string s, t;
  cin >> s >> t;
  int i;

  for(i = s.size()-1; i >= t.size()-1; --i){
    bool match = true;

    for(int j = 0; j < t.size() ; ++j){
      if(s[i-j] != '?' && s[i-j] != t[t.size()-1-j]) {
        match = false;
        break;
      }
    }

    if(match){
      for(int j = 0; j < t.size(); ++j){
        s[i-j] = t[t.size()-1-j];
      }
      for (int i = 0; i < s.size(); ++i) {
        if(s[i] == '?') s[i] = 'a';
      }
      std::cout << s << std::endl;
      return 0;
    }
  }
  std::cout << "UNRESTORABLE" << std::endl;

  return 0;
}



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

int main() {
    int N, A;
    cin >> N >> A;
    int x[N], sum = 0;
    rep (i, N) cin >> x[i], sum += x[i];

    long long dp[N + 1][N + 1][sum + 1] = {};
    dp[0][0][0] = 1;

    rep (i, N) rep (j, N) rep (k, sum + 1) if (dp[i][j][k] != 0) {
        if (k + x[i] <= sum) dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
        dp[i + 1][j][k] += dp[i][j][k];
    }

    long long ans = 0;
    range (j, 1, N + 1) if (j * A <= sum) ans += dp[N][j][j * A];

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

Measured memory_bytes: 51072
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;
int r[13]={-1,0,3,0,2,0,2,0,0,2,0,2,0};
int main(void){
  int x,y;
  cin>>x>>y;
  cout<<(r[x]==r[y]?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	bool nc = 1;
	int na,nb;
	char c;
	while(nc){
	std::cin>>na>>c>>nb;
	switch(c){
	case '+':
		cout<<na + nb<<endl;
		break;
	case '-':
		cout<<na - nb<<endl;
		break;
	case '*':
		cout<<na * nb<<endl;
		break;
	case '/':
		cout<<na / nb<<endl;
		break;
	case '?':
		nc = 0;
	}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<string>
#include<utility>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<bitset>
using namespace std;

int main(){

    int n,m;
    cin >> n >> m;
    int ans=0;
    vector<int> a(n);
    for (int i = 0; i < m; i++)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; j++)
        {
            int s;
            cin >> s;
            s--;
            a[s] |= 1<<i;
        }
    }
    
    int p=0;
    for (int i = 0; i < m; i++)
    {
        int x;
        cin >> x;
        p |= (x<<i);
    }
    

    for (int s = 0; s < (1<<n); s++)
    {
        int t=0;
        for (int i = 0; i < n; i++)
        {
            if(s & 1<<i){
                t ^= a[i];
            }
        }
        if(t == p){
            ans ++;
        }
    }

  	cout << ans << endl;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N;
	vector<long long int>v(N);
	vector<long long int>w(N);
	for (int i = 0; i < N; i++) {
		cin >> v[i];
		M += v[i];
	}
	for (int j = 0; j < N; j++) {
		cin >> w[j];
		K += w[j];
	}
	if (K < M) {
		cout << "No" << endl;
		return 0;
	}
	for (int i = 0; i < N; i++) {
		if (v[i] < w[i]) {
			L += (w[i] + 1 - v[i]) / 2;
		}
		else if (v[i] > w[i]) {
			R += v[i] - w[i];
		}
	}
	if (K < max(L,R) + M) {
		cout << "No" << endl;
		return 0;
	}
	cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;

class Main{
      public static void main(String args[]){
	  Scanner sc = new Scanner(System.in);
	  int sheep,wolf;
	  sheep = sc.nextInt();
	  wolf = sc.nextInt();
	  if(wolf>=sheep){
	      System.out.println("unsafe");
	  }else{
	      System.out.println("safe");
	  }
      }
}


Measured memory_bytes: 35720
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int n, l; cin >> n >> l;
    vector<int> apple(n);
    for(int i = 0; i < n; i++) apple[i] = l + i;
    int sum = 0;
    for (int i = 0; i < apple.size(); i++) sum += apple[i];
    int d = INF, ans = 0;
    for(int i = 0; i < apple.size(); i++)
    {
        int tmp = sum - apple[i];
        if(d > abs(sum - tmp))
        {
            ans = tmp;
            d = abs(sum - tmp);
        }
    }
    cout << ans << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

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

int main() {
	int n;
	string s;
	cin >> n >> s;
	int r = 0, b = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s.at(i) == 'R')
		r++;
		else
		b++;
	}
	if (r > b) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>

using namespace std;

char s[50][50];
int d[50][50];

bool bfs(int sx, int sy, int h, int w){
    queue <pair<int, int> > q;
    int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};
    h--;
    w--;

    for (int i = 0; i <= h; i++){
      for (int j = 0; j <= w; j++){
        d[i][j]=-1;
      }
    }
    
    q.push(make_pair(sx,sy));
    d[sx][sy]=0;

    while(!q.empty()){
        pair<int, int> p=q.front(); 
        q.pop();

        for (int i=0; i<4; i++){
            int nx=p.first+dx[i],ny=p.second+dy[i];

            if(0<=nx && nx<=h && 0<=ny && ny<=w && s[nx][ny]!='#' && d[nx][ny]==-1){
                q.push(make_pair(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;
            }
        }
    }

    if (d[h][w] != -1){
      return true;
    }else{
      return false;
    }
}

int main(){
  int H, W;
  cin >> H >> W;
  int ans = 0;
  
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> s[i][j];
      if(s[i][j]=='.') ans++;
    }
  }


  if(bfs(0, 0, H, W)){
    ans -= d[H-1][W-1] + 1;
    printf("%d\n", ans);
  }else{
    printf("-1\n");
  }
  
}


Measured memory_bytes: 3720
d = map(int, input().strip())
g = list(map(int, input().strip().split()))
#print(d)
#print(g)
h = []
for i in range(len(g)):
    h.append([g[i], i + 1])
#print(h)
h.sort()
#print(h)
for i in h:
    print(str(i[1]), end=' ')

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

using namespace std;

int main() {
	int N, H;
	cin >> N >> H;

	vector<int> a(N), b(N);

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

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

	int i = 0, ans = 0;
	while (b[i] > a_max && i < N) {
		H -= b[i];
		i++; ans++;
		if (H <= 0) {
			cout << ans << endl;
			return 0;
		}
	}

	ans += ceil((double)H / a_max);

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

Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner in = new Scanner(System.in);
    int N = in.nextInt();
    Pair[] a = new Pair[N];
    for(int i=0; i<N; ++i){
      String s = in.next();
      int p = in.nextInt();
      a[i] = new Pair(i+1, s, p);
    }
    Arrays.sort(a, 
      (p1, p2) -> {
        if(p1.s.equals(p2.s)){
          return p2.p - p1.p;
        }
        return p1.s.compareTo(p2.s);
      }
    );
    for(Pair p : a){
      System.out.println(p.i);
    }
  }
  static class Pair{
    int i;
    String s;
    int p;
    Pair(int i, String s, int p){
      this.i = i;
      this.s = s;
      this.p = p;
    }
  }
}

Measured memory_bytes: 26324
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  rep(i,5) {
    ll a;
    cin >> a;
    if(a==0) cout << i+1 << endl;
  }

  return 0;
}


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

using namespace std;

typedef long long LL;

string ss[] = {"dream", "dreamer", "erase", "eraser"};

bool dfs(const string& s, int p) {
    if( p == s.size() ) return true;
    for(int i = 0; i<4; ++i) {
        if( s.substr(p, ss[i].size()) == ss[i] )
            if( dfs(s, p+ss[i].size()) ) return true;
    }
    return false;
}

int main() {
    string str;
    cin >> str;
    puts( dfs(str, 0) ? "YES" : "NO" );
}


Measured memory_bytes: 2304
#include<bits/stdc++.h>
//#include<iostream>
//#include<cstdio>
//#include<stdlib.h>
//#include<string.h>
//#include<algorithm>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define READ freopen("in.txt","r",stdin)
#define WRITE freopen("out.txt","w",stdout);
#define pb push_back
#define mem(arr,val) memset(arr,val,sizeof(arr))
#define sf(x) scanf("%d",&x)
#define sf2(x,y) scanf("%d %d",&x,&y)
#define sf3(x,y,z) scanf("%d %d %d",&x,&y,&z)
#define sl(x) scanf("%lld",&x)
#define sl2(x,y) scanf("%lld %lld",&x,&y)

#define sl3(x,y,z) scanf("%lld %lld %lld",&x,&y,&z)
#define sd(x) scanf("%lf",&x);
#define pLL pair<long long,long long>
#define pDB pair<double,double>
#define ff first
#define sn second
#define PRINT_CASE  printf("Case %d: ",tc++)
#define PRINT_CASENL  printf("Case %d:\n",tc++)
//#define mx 100005
#define lnd tree[ind<<1]
#define rnd tree[(ind<<1)+1]
#define cnd tree[ind]
#define lndp b,(b+e)>>1,(ind<<1)
#define rndp ((b+e)>>1)+1,e,(ind<<1)+1
#define IN(a,x,y) (a>=x && a<=y)
#define popcountL __builtin_popcountll
#define popcount __builtin_popcount
/// int other=mask^((1<<n)-1);
typedef long long ll;
typedef long long int lln;
typedef pair<int,int> pii;
ll INF=1<<28;
//typedef long long lld;
const double PI=acos(-1.0);
//int fx[]={1,-1,0,0}; //direction array
//int fy[]={0,0,1,-1};
int dir[4][2]={1,0,-1,0,0,-1,0,1};
int knight[8][2]={1,2,1,-2,2,1,2,-1,-1,2,-1,-2,-2,1,-2,-1};
const long double EPS=1e-7;
//#define INF 10000

struct compare
{
  bool operator()(const pair<int,pii>& l, const pair<int,pii>& r)
  {
      if(l.ff==r.ff)
      {
          return l.sn.ff>r.sn.ff;
      }
      return l.ff<r.ff;
  }
};
// bool operator<(pair<int,pii> l, pair<int,pii> r)
//  {
//      if(l.ff==r.ff)
//      {
//          cout<<"ok "<<endl;
//          return l.sn.ff<r.sn.ff;
//      }
//      return l.ff>r.ff;
//  }

/////////////////////////////////////template sesh/////////////////////////////////////////////////////

///code goes from here
const int mx=500150;
///
int mod=1000000007;

ll arr[mx];
int main()
{
//    SPEED;

    int t,tc=1;
//    sf(t);
    t=1;
    while(t--)
    {
        int a,b,c;
        sf3(a,b,c);
        int countt=0;
        int k;
        sf(k);
        while(a>=b)
        {
            b*=2;
            countt++;
        }
        while(b>=c)
        {
            c*=2;
            countt++;
        }
        if(countt<=k)
        {
            cout<<"Yes"<<endl;
        }
        else
            cout<<"No"<<endl;
    }

    return 0;
}



Measured memory_bytes: 3692
#include <iostream>
using namespace std;
int main () {
	string s;
	cin >> s;
	
	while (s != "0") {
		int sum = 0;
		for (int i = 0; i < s.size(); i ++)
			sum += (int)s[i] - 48;
		cout << sum << "\n";
		cin >> s;
	}
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
string char_to_string(char val) {
    return string(1, val);
}

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

    int zero = 0;
    int one = 0;
    for(int i = 0; i < s.size(); ++i) {
        if(s[i] == '0') {
            zero++;
        } else {
            one++;
        }
    }

    cout << s.size() - abs(zero - one) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <string.h>
#include <vector>
#include <limits>
#include <algorithm>
#include <stdlib.h>
#include <math.h>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <assert.h>
#include <sstream>
#include <type_traits>
#define SET(x,y) x |= (1 << y)
#define CLEAR(x,y) x &= ~(1<< y)
#define READ(x,y) ((0u == (x & (1<<y)))?0u:1u)
#define TOGGLE(x,y) (x ^= (1<<y))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define pb push_back
#define mp make_pair
#define si(n) scanf("%d",&n)
#define sf(n) scanf("%f",&n)
#define sl(n) scanf("%lld",&n)
#define slu(n) scanf("%llu",&n)
#define sd(n) scanf("%lf",&n)
#define ss(n) scanf("%s",n)
#define pnl printf("\n")
#define ll long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pF first
#define pS second
#define CL(a,b) memset(a,b,sizeof(a))
#define sqr(x) ((x)*(x))
#define intLIMIT numeric_limits<int>
#define longLIMIT numeric_limits<long long>
#define GCD(a,b) __gcd((a),(b))
#define dbl(x) (double)(x)
#define vi vector <int>
#define vii vector < pair <int, int> >
#define vll vector <long long>
#define allof(x) (x).begin(), (x).end()
#define fastCin cin.sync_with_stdio(0);cin.tie(0)
#define scanUnsigned(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#define printArr(a,l) cout<<#a<<": ";for(int i=0;i<(l);i++){cout<<a[i]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(int i=0;i<(r);i++){for(int j=0;j<(c);j++){cout<<a[i][j]<<" ";}cout<<endl;}
char _;
using namespace std;
void PRINT (int x, int y) { for (int i = y-1; i >= 0; i--) { cout << READ(x,i); } cout << endl; }

vector<string>vec_splitter(string s){s+=',';vector<string>res;while(!s.empty()){res.push_back(s.substr(0,s.find(',')));s=s.substr(s.find(',')+1);}
return res;}
void debug_out(vector<string>__attribute__((unused))args,__attribute__((unused))int idx,__attribute__((unused))int LINE_NUM){cerr<<endl;}
template<typename Head,typename...Tail>void debug_out(vector<string>args,int idx,int LINE_NUM,Head H,Tail...T){if(idx>0)cerr<<", ";else cerr<<"Line("<<LINE_NUM<<") ";stringstream ss;ss<<H;cerr<<args[idx]<<" = "<<ss.str();debug_out(args,idx+1,LINE_NUM,T...);}
#ifdef LOCAL_DBG
#define dbg(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __LINE__, __VA_ARGS__)
#else
#define dbg(...) 42
#endif

int main () {
	fastCin;
	ll k;
	cin >> k;
	if (k%2==0) {
		cout << -1 << "\n";
	} else {
		ll cur = 0;
		for (int x = 0; x <= 2*1000000; x++) {
			cur *= 10;
			cur += 7;
			cur %= k;
			if (cur==0) {
				cout << x + 1 << "\n";
				return 0;
			}
		}
		cout << -1 << "\n";
	}
	return 0;
}

Measured memory_bytes: 3148
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int N;
  cin >> N;
  int number_of_AB = 0;
  int number_of_end_A = 0;
  int number_of_start_B = 0;
  int number_both = 0;
  
  string temp;
  
  for (int i = 0; i < N; i++){
    cin >> temp;
    //cout << temp << endl;
    for(int j = 0; j < temp.size() -1; j++){
      if(temp.at(j) == 'A' && temp.at(j+1) == 'B'){
        number_of_AB ++;
      }
    }
    
    if(temp.at(0) == 'B' && temp.at(temp.size()-1) != 'A'){
        number_of_start_B ++;
      }
    if(temp.at(temp.size()-1) == 'A' && temp.at(0) != 'B'){
        number_of_end_A ++;
      }
    if(temp.at(temp.size()-1) == 'A' && temp.at(0) == 'B'){
        number_both ++;
      }
  }
 
  //cout << number_of_end_A << endl;
  //cout << number_of_start_B << endl;
  //cout << number_both << endl;
  //cout << number_of_AB << endl;
  
  int diff;
  if(number_of_start_B == 0 && number_of_end_A == 0 && number_both != 0){
    cout << (number_both - 1) + number_of_AB << endl;
  }else if(number_of_start_B == 0 && number_of_end_A == 0 && number_both == 0){
    cout << number_of_AB << endl;
  }else{
    cout << number_both + number_of_AB + min(number_of_end_A, number_of_start_B) << endl;
  }
    

 
 
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<ll> a(n+1);
  vector<ll> b(n);
  rep(i,n+1)cin>>a[i];
  rep(i,n)cin>>b[i];
  ll ans=0;
  rep(i,n) {
    ans+=min(a[i],b[i]);
    b[i]-=min(a[i],b[i]);
    ans+=min(a[i+1],b[i]);
    a[i+1]-=min(a[i+1],b[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int a[2005];
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	sort(a, a + n);
	long long ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			auto it = lower_bound(a + j + 1, a + n, a[i] + a[j]);
			ans += it - (a + j + 1);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod=1000000007;
const int INF=1001001001;

vector<pair<int64_t,int64_t>>prime_factorize(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p; 
}

int main() {
  string s,t;
  cin>>s>>t;
  int r=s.size(),l=t.size();
  if(r<l){cout<<"UNRESTORABLE"<<endl;return 0;}
  bool AD=false;
  for(int i=r-l;i>=0;i--){
    bool ok=true;
    for(int j=0;j<l;j++){
        if(s[i+j]!='?'&&s[i+j]!=t[j]){ok=false;}
    }
    if(ok){
      AD=true;
      for(int j=0;j<l;j++){
        s[i+j]=t[j];
      }
      break;
    } 
  }
  if(!AD){cout<<"UNRESTORABLE"<<endl;}
  else{
    for(int i=0;i<r;i++){
      if(s[i]=='?'){s[i]='a';}
    }
    cout<<s<<endl;
  }
  
  return 0;  
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define LL long long
#define clr(x,i) memset(x,i,sizeof(x))
using namespace std;
LL q,a,b;
void solve()
{
	cin>>a>>b;
	LL s=a*b,sq=0,ans=0;
	sq=(LL)sqrt((long double)s);
	if(sq*sq==s){
		ans=2*(sq-1);
		if(a!=b) ans--; 
	}
	else{
		if(sq*(sq+1)<s)
		  ans=2*sq-1;
		else
		  ans=2*(sq-1);
	}
	printf("%lld\n",ans);
}
int main()
{
	cin>>q;
	while(q--) solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
using P = pair<ll, ll>;
#define rep(i, n) for(int i=0;i<(int)n;i++)
#define PI acos(-1)
#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);
ll mod=1e9+7;


int main(){
    fast_io

    string s,t;
    cin>>s>>t;

    for(int i=0;i<s.size();i++){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/* several useful subroutines */
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int k = getInt();
		int cnt = 0;
		for ( int i = 0 ; i < n ; i++ ) {
			if ( getInt() >= k ) {
				cnt++;
			}
		}
		System.out.println( cnt );
	}
}


Measured memory_bytes: 33560
#include <iostream>
#include <vector>

static void rec(int bit, int prev, int sum, int R, const std::vector<int>& r,
    const std::vector<std::vector<int>>& G,
    const std::vector<std::vector<int>>& memo,
    int& min)
{
    if (bit == ((1 << R) - 1)) {
        if (min == -1) {
            min = sum;
        } else {
            min = std::min(min, sum);
        }
    }

/*
    if (prev != -1 && memo[prev][bit] != -1) {
        if (min == -1) {
            min = sum + memo[prev][bit];
        } else {
            min = std::min(min, sum + memo[prev][bit]);
        }
    }
    */

    for (int i = 0; i < R; i++) {
        if (((bit >> i) & 0x01) == 1) {
            continue;
        }
        int s = sum;
        if (prev != -1) {
            s += G[r[prev]][r[i]];
        }
        rec(bit | (1 << i), i, s, R, r, G, memo, min);
    }
}

int main() {
    int N, M, R; std::cin >> N >> M >> R;
    std::vector<int> r(R);
    for (int i = 0; i < R; i++) {
        std::cin >> r[i];
        r[i]--;  // 0 begin;
    }
    std::vector<std::vector<int>> G(N, std::vector<int>(N, -1));
    for (int i = 0; i < N; i++) {
        G[i][i] = 0;
    }

    for (int i = 0; i < M; i++) {
        int a, b, c;
        std::cin >> a >> b >> c;
        a--; b--;
        G[a][b] = G[b][a] = c;
    }

    for (int k = 0; k < N; k++) {
        for (int i = 0; i < N; i++) {
            for (int j = 0; j < N; j++) {
                if (G[i][k] == -1 || G[k][j] == -1) {
                    continue;
                }

                if (G[i][j] == -1) {
                    G[i][j] = G[i][k] + G[k][j];
                }

                G[i][j] = std::min(G[i][j], G[i][k] + G[k][j]);
            }
        }
    }

    std::vector<std::vector<int>> memo(N, std::vector<int>(256, -1));
    int min = -1;
    rec(0, -1, 0, R, r, G, memo, min);
    std::cout << min << std::endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
 
using namespace std;
 
long long A, B, C, D, E;
 
int main(){
  long long N;
  long long min, ans;
  
  cin >> N;
  cin >> A;
  cin >> B;
  cin >> C;
  cin >> D;
  cin >> E;
 
  min = A;
  if ((A >= B) && (min > B)) {
    min = B;
  } 
  if ((B >= C) && (min > C)){
    min = C;
  }
  if ((C >= D) && (min > D)){
    min = D;
  }
  if ((D >= E) && (min > E)){
    min = E;
  }
 
  if (min >= N) {
    ans = 5;
  } else {
    ans = (N-1)/min + 1 + 4;
  }
  
  cout << ans << endl;
 
}

Measured memory_bytes: 256
#![allow(unused_imports)]

use std::cmp::{self, Ordering};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt::{self, Debug, Display};
use std::io::{self, Read, Write};
use std::process;
use std::str::{self, FromStr};


fn solve(s: String) -> Option<usize> {
    let s = s.as_bytes();
    let (mut i, mut j, mut r) = (0, s.len() - 1, 0);
    loop {
        if i >= j {
            return Some(r);
        }
        if s[i] == s[j] {
            i += 1;
            j -= 1;
        } else if s[i] == 'x' as u8 {
            i += 1;
            r += 1;
        } else if s[j] == 'x' as u8 {
            j -= 1;
            r += 1;
        } else {
            return None;
        }
    }
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    match solve(sc.next()) {
        Some(n) => println!("{}", n),
        None => println!("-1"),
    }
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(256),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: Debug,
    {
        self.buf.clear();
        for c in self.bytes
            .by_ref()
            .map(|c| c.unwrap())
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
        {
            self.buf.push(c);
        }
        str::from_utf8(&self.buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<A: FromStr, B: FromStr>(&mut self, n: usize) -> Vec<(A, B)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<A: FromStr, B: FromStr, C: FromStr>(&mut self, n: usize) -> Vec<(A, B, C)>
    where
        <A as FromStr>::Err: Debug,
        <B as FromStr>::Err: Debug,
        <C as FromStr>::Err: Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: Debug,
    {
        (0..n).map(|_| self.vec(m)).collect()
    }
}


#[allow(dead_code)]
fn print_yesno(x: bool, yes: &'static str, no: &'static str) {
    println!("{}", if x { yes } else { no });
}


#[allow(dead_code)]
fn print_foreach<T: Display, I: IntoIterator<Item = T>>(xs: I) {
    for x in xs.into_iter() {
        println!("{}", x);
    }
}


#[allow(dead_code)]
fn print_or<T: Display>(x: Option<T>, or: &'static str) {
    if let Some(x) = x {
        println!("{}", x);
    } else {
        println!("{}", or);
    }
}


Measured memory_bytes: 4352
import numpy as np

N = int(input().rstrip())
L = [int(i) for i in input().rstrip().split()]
L.sort(reverse = True)

L = np.array(L)
x = L[0]
y = np.sum(L)-L[0]

if x<y:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 27244
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int a=0,b=0,c;
  cin>>c;
  rep(i,c){
    string d,e;
    cin>>d>>e;
    if(d<e){b+=3;}
    else if(d==e){a++;b++;}
    else {a+=3;}
  }
  cout<<a<<" "<<b<<endl;
}


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

#define rep(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define fi first
#define se second
#define mt make_tuple
template<class T1, class T2> bool chmin(T1 &a, T2 b) { return b < a && (a = b, true); }
template<class T1, class T2> bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

using ll = long long; using ld = long double; using vll = vector<ll>; using vvll = vector<vll>; using vld = vector<ld>;
using vi = vector<int>; using vvi = vector<vi>;
using P = pair<ll, ll>;

template <typename T, typename U> ostream &operator<<(ostream &o, const pair<T, U> &v) {  o << "(" << v.first << ", " << v.second << ")"; return o; }
template<size_t...> struct seq{}; template<size_t N, size_t... Is> struct gen_seq : gen_seq<N-1, N-1, Is...>{}; template<size_t... Is> struct gen_seq<0, Is...> : seq<Is...>{};
template<class Ch, class Tr, class Tuple, size_t... Is>
void print_tuple(basic_ostream<Ch,Tr>& os, Tuple const& t, seq<Is...>){ using s = int[]; (void)s{0, (void(os << (Is == 0? "" : ", ") << get<Is>(t)), 0)...}; }
template<class Ch, class Tr, class... Args>
auto operator<<(basic_ostream<Ch, Tr>& os, tuple<Args...> const& t) -> basic_ostream<Ch, Tr>& { os << "("; print_tuple(os, t, gen_seq<sizeof...(Args)>()); return os << ")"; }
ostream &operator<<(ostream &o, const vvll &v) { rep(i, v.size()) { rep(j, v[i].size()) o << v[i][j] << " "; cout << endl; } return o; }
template <typename T> ostream &operator<<(ostream &o, const vector<T> &v) { o << '['; rep(i, v.size()) o << v[i] << (i != v.size()-1 ? ", " : ""); o << "]";  return o; }
template <typename T>  ostream &operator<<(ostream &o, const set<T> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it << (next(it) != m.end() ? ", " : ""); o << "]";  return o; }
template <typename T, typename U>  ostream &operator<<(ostream &o, const unordered_map<T, U> &m) { o << '['; for (auto it = m.begin(); it != m.end(); it++) o << *it; o << "]";  return o; }
#define VN(v) # v
#define print(a) cout << a << "#" << VN(a) << endl;
#define ldout fixed << setprecision(40) 

static const double EPS = 1e-14;
static const long long INF = 1e18;
static const long long mo = 1e9+7;

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

    ll n; cin >> n;
    vll a(n); rep(i, n) cin >> a[i];

    vll dp;
    rep(i, n) {
        auto it = lower_bound(all(dp), a[i]);
        if (it == dp.end())
            dp.pb(a[i]);
        else
            *it = a[i];
    }

    cout << dp.size() << endl;
    return 0;
}

Measured memory_bytes: 4632
//Author - Soumik Roy
//Date & Time - August 03, 2020 4:46 PM
//Problem name - E - Logs
//Problem url - https://atcoder.jp/contests/abc174/tasks/abc174_e
//Time limit - 2000 ms
//Memory Limit - 1024 MB    

#include<bits/stdc++.h>
#define ll                    long long int
#define pb                    push_back
#define F                     first
#define S                     second
#define mp                    make_pair
#define MOD                   1000000007
#define vi                    vector<int>
#define vll                   vector<ll>
#define pll                   pair<ll,ll>
#define pii                   pair<int,int>
#define all(p)                p.begin(),p.end()
#define mid(s,e)              (s+(e-s)/2)
#define eb                    emplace_back
#define ull                   unsigned long long
#define bug(x)				  cout<<"  [ "#x<<" = "<<x<<" ]"<<endl;
#define KAMEHAMEHA            ios_base::sync_with_stdio(0);
#define RASENGAN              ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
void solve()
{
	int n,k,high=0,low=1,mid;
	cin>>n>>k;
	vi a(n);
	for (int i = 0; i < n; i++)
	{
		cin>>a[i];
		high=max(high,a[i]);
	}
	int ans=high;
	while(low<=high)
	{
		mid=low+((high-low)>>1);
		int need=0;
		for(int i=0;i<n;i++)
		{
			int div=a[i]/mid;
			if(a[i]%mid==0)
				div--;
			if(round(a[i]/(div+1))>mid)
				div++;
			need+=div;
		}
		if(need<=k)
		{
			ans=mid;
			high=mid-1;
		}
		else
		{
			low=mid+1;
		}
		
	}
	cout<<ans<<endl;
}
int main()
{
    KAMEHAMEHA
	int t=1;
	//cin>>t;
	for(int cn=1;cn<=t;cn++)
	{
		solve();
	}
    return 0;
}



Measured memory_bytes: 4032
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var n=sc.I;
		var m=sc.I;

		Console.WriteLine("{0}",n^m);
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

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

#define IOS std::cin.tie(0);std::ios_base::sync_with_stdio(false)

#define ll      long long
#define Fi      first
#define Se      second
#define Pb      push_back
#define vi      vector<int>
#define vp      vector<pair<int,int>>
#define vvi     vector<vector<int>>
#define vvp     vector<vector<pair<int,int>>>
using Graph  =  vector<vector<int>>;

#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define output_s(s) printf("%s\n",(s).c_str())
#define END cout<<"\n"

#define rep(i,n)        for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m)      for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m)     for(int i=(int)(n);i<=(int)(m);i++)
#define RRepS(i,n,m)    for(int i=(int)(n);i>=(int)(m);i--)
#define SRepS(i,n,m)    for(int i=(int)(n);i*i<=(int)(m);i++)
#define RepA(x)         for(auto &item:(x))

void CINT(){} //@shibh308's template
template<class Head,class... Tail> void CINT(Head&& head,Tail&&... tail){cin>>head; CINT(move(tail)...);}    
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)
#define VCIN(x) for(auto &item:x) cin>>item

void OUT(){}
template<class Head,class...Tail> void OUT(Head&& head,Tail&&...tail){cout<<head<<(sizeof...(tail)?" ":"\n"); OUT(move(tail)...);}
#define COUT(...) OUT(__VA_ARGS__)

template<typename TypeInt>TypeInt GCD(TypeInt a,TypeInt b){return a%b==0?b:GCD(b,a%b);} //最大公約数
template<typename TypeInt>TypeInt LCM(TypeInt a,TypeInt b){return a*b/GCD(a,b);} //最小公倍数
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
template<class T>bool comp(T a,T b){return abs(a)<abs(b);} //比較関数

void YES(bool f){printf(f?"YES\n":"NO\n");}
void Yes(bool f){printf(f?"Yes\n":"No\n");}
void Possible(bool f){printf(f?"Possible\n":"Impossible\n");}
void POSSIBLE(bool f){printf(f?"POSSIBLE\n":"IMPOSSIBLE\n");}

//----------------------library------------------------//

//const int dx[4]={1,0,-1,0};
//const int dy[4]={0,1,0,-1};
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int NMAX = 55;
const int INF = 1e9;
const int MOD = 1e9+7;
bool flag;

int a[NMAX],b[NMAX],c[NMAX],d[NMAX],A[11];
int N,M,Q,ans=0;
//----------------------Global-------------------------//

void dfs(int now,int val){
    if(now==N+1){
        int sum=0;
        RepS(i,1,Q){
            if(A[b[i]]-A[a[i]]==c[i])sum+=d[i];
        }
        chmax(ans,sum);
        return;
    }
    RepS(i,val,M){
        A[now]=i;
        dfs(now+1,i);
    }
}

signed main(){
    cin>>N>>M>>Q;
    RepS(i,1,Q){
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    dfs(1,1);
    COUT(ans);

    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1000000007;

int main(){
    string s, t;
    cin >> s >> t;

    int sl = s.size(), tl = t.size();

    int dp[sl+1][tl+1]; // dp[i][j] : si, tjまで見たときの最大長
    for(int i=0;i<=sl;i++)
        for(int j=0;j<=tl;j++)
            dp[i][j] = 0;

    for(int i=1;i<=sl;i++){
        for(int j=1;j<=tl;j++){
            if(s[i-1] == t[j-1])
                dp[i][j] = dp[i-1][j-1] + 1;
            else
                dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
        }
    }

    // 復元
    string ans = "";
    int x = sl, y = tl;
    while(x > 0 && y > 0){
        if(dp[x][y] == dp[x-1][y]){
            x--;
        }else if(dp[x][y] == dp[x][y-1]){
            y--;
        }else{
            x--;
            y--;
            ans.push_back(s[x]);
        }
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

}


Measured memory_bytes: 35456
n=int(input())
a=list(map(int,input().split()))
q=int(input())
dic={i:0 for i in range(100002)}
ans=0
for i in range(n):
    dic[a[i]]+=1
    ans+=a[i]
for i in range(q):
    b,c=map(int,input().split())
    dic[c]+=dic[b]
    ans+=dic[b]*(c-b)
    dic[b]=0
    print(ans)

Measured memory_bytes: 99028