akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
using namespace std;

const int N = 1e6 + 100;
bool pr[500001];
vector<int>v;
void sieve()
{

    for(int i = 2; i<=1e5; i++)
    {
        if(pr[i]==0)
        {
            for(int j = i+i; j<=1e4; j+=i)
                pr[j] = 1;
        }
    }
    for(int i = 2; i<=1e5; i++)
    {
        if(pr[i]==0)
        {
            v.pb(i);

        }
    }

}


int main()
{

    // freopen("in.txt", "r", stdin);
    // sieve();
    int t=1;

   // cin >> t;
    while(t--)
    {

        int n;
         string s,T;
         cin >> s >> T;
         int cnt = 0;
         for(int i = 0; i<s.size(); i++){
            if(s[i]==T[i]) continue;
            cnt++;
         }
         cout << cnt << endl;
    }


    return 0;
}


Measured memory_bytes: 3852
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
int main() {
	int a[27] = {};
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i++)
		a[s[i] - 'a']++;
	for (int i = 0; i < 27; i++)
		if (a[i] > 1) {
			cout << "no" << endl;
			return 0;
		}
	cout << "yes" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MAXN = 2e5 + 5;

struct DSU
{
	int fa[MAXN];
	inline void init(int n){ for(int i=1; i<=n; ++i) fa[i] = i;}
	int find(int u){ return fa[u] == u? u: fa[u] = find(fa[u]);}
	inline void connect(int u,int v){ fa[find(u)] = find(v);}
}dsu;

int pre[MAXN], val[MAXN];

int f[MAXN], g[MAXN];

struct cmp{ inline bool operator () (int x,int y) const; };

inline bool cmp::operator () (int x,int y) const
{
	return make_pair((ll)g[x] * f[y], x) < make_pair((ll)g[y] * f[x], y);
}

int main(void)
{
	int n;
	scanf("%d",&n);
	for(int i=2; i<=n; ++i) scanf("%d",&pre[i]);
	for(int i=1; i<=n; ++i) scanf("%d",&val[i]);
	
	for(int i=1; i<=n; ++i)
	{
		if(val[i]) g[i] = 1;
		else f[i] = 1;
	}
	
	set<int,cmp> t;
	for(int i=2; i<=n; ++i)
		t.insert(i);
	
	dsu.init(n);
	
	ll ans = 0;
	while(!t.empty())
	{
		int u = *t.begin(), fa = dsu.find(pre[u]);
		t.erase(t.begin());
		if(fa != 1) t.erase(fa);
		
		ans += (ll)g[fa] * f[u];
		
		f[fa] += f[u];
		g[fa] += g[u];
		dsu.connect(u, fa);
		
		if(fa != 1) t.insert(fa);
	}
	
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 16556
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;

int main(){
	 //cin.tie(0);
	//ios::sync_with_stdio(false);
	//std::cout << std::fixed;
	//std::cout << std::setprecision(12);
	//std::cout << std::defaultfloat;
	int n;
	cin>>n;
	priority_queue<pll> pq;
	FOR(i,0,n){
		LL a,b;
		cin>>a>>b;
		pq.push(MP(-b,a));
	}
	LL t=0;
	while(pq.size()){
		auto pr=pq.top();
		pq.pop();
		auto lm=-pr.ST;
		t+=pr.ND;
		if(t>lm){
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;

	return 0;
}


Measured memory_bytes: 6256
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
	for (;;) {
		int n, m, k; cin >> n >> m >> k;
		if (n == 0) break;
		int l = n * m;
		vector<double> dp(l + 1);
		dp[0] = 1;
		while (n--) {
			vector<double> imos(l + 1);
			for (int i = 0; i + 1 <= l; i++)
				imos[i + 1] += dp[i] / m;
			for (int i = 0; i + m + 1 <= l; i++)
				imos[i + m + 1] -= dp[i] / m;
			dp.assign(l + 1, 0);
			for (int i = 1; i <= l; i++)
				dp[i] = dp[i - 1] + imos[i];
		}
		double ans = 0;
		for (int i = 0; i <= l; i++)
			ans += dp[i] * max(1, i - k);
		printf("%.10f\n", ans);
	}
}

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

int main() {
	char b;
	cin >> b;

	if (b == 'A') cout << 'T' << endl;
	else if (b == 'C') cout << 'G' << endl;
	else if (b == 'G') cout << 'C' << endl;
	else cout << 'A' << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <cassert>
#define InfL 2000000000
#define InfLL 4000000000000000000LL
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
using namespace std;
typedef long long ll;
typedef double db;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<bool> vb;
typedef vector<db> vd;

vl divisor(ll n) {
	vl divlist;
	for (ll i = 1; i * i <= n; i++) {
		if (n % i == 0) {
			divlist.push_back(i);
			if (i * i != n)
				divlist.push_back(n / i);
		}
	}
	sort(divlist.begin(), divlist.end(), less<ll>());
	return divlist;
}

int main() {
	int N;
	cin >> N;
	vi A(N);
	set<int> Aset;
	map<int, int> Amap;
	rep(i, N) {
		cin >> A[i];
		Aset.insert(A[i]);
		Amap[A[i]]++;
	}
	ll ans = 0;
	rep(i, N) {
		vl d = divisor(A[i]);
		rep(j, d.size() + 1) {
			if (j == d.size()) {
				ans++;
				break;
			}
			if (d[j] == A[i]) {
				if (Amap[A[i]] >= 2)
					break;
			}
			else if (Aset.find(d[j]) != Aset.end()) {
				break;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 22700
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9+7;
using ll = long long;
using vi = vector<int>;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()
int main() {
  string a;
  cin >> a;
  int b = a.size();
  vi ans(26,1);
  rep(i,b){
    ans.at(a.at(i)-'a')=0;
  }
  rep(i,26){
    if(ans.at(i)) {
      char aaa = 'a' + i;
     cout << aaa;
     return 0;
  }
  }
  cout << "None";
}

Measured memory_bytes: 3740
#include <iostream>
#include <string>

using namespace std;

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

    int ans = 0;
    int a = 0;
    for(int i=0; i<3; i++){
        if(S[i] == 'R'){
            a++;
            if(ans < a){
                ans = a;
            }
        }else{
            a = 0;
        }
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 3624
n = int(input())
p = [int(i) for i in input().split()]
a,b = [n*i+1 for i in range(n)],[0 for i in range(n)]
for i in range(n-1): print(a[i],end=" ")
print(a[-1])
for i in range(n): b[p[i]-1] = i-a[p[i]-1]
x = abs(b[-1])+1
for i in range(n-1): print(b[i]+x,end=" ")
print(1)

Measured memory_bytes: 6004
#include<cstdio>
#include<algorithm>
using namespace std;
const int MAX_N = 100;
int N;
int P[MAX_N];
int A, B;
int main(){
scanf("%d", &N);
scanf("%d%d", &A, &B);
for(int i = 0; i < N; ++i) scanf("%d", P + i);
int e = 0, m = 0, h = 0;
for(int i = 0; i < N; ++i){
if(P[i] <= A) e++;
else if(P[i] <= B) m++;
else h++;
}
int ans = min(min(e, m), h);
printf("%d\n", ans);
return 0;
}


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

using namespace std;

// 1 to 0-indexed
vector<int> G[100];

typedef pair<int, int> Pii;
typedef pair<int, Pii> Piii;

int bfs(int S, int T, int TTL) {
  
  int memo[100];
  memset(memo, -1, sizeof(memo));
  memo[S] = 0;
  queue<Piii> Q;
  Q.push(Piii(0, Pii(S, TTL)));
  while(!Q.empty()) {
    
    Piii piii = Q.front(); Q.pop();
    
    int cost = piii.first;
    int now = piii.second.first;
    int ttl = piii.second.second;
    
    if(now == T) return cost;
    if(memo[now] < cost) continue;

    if(ttl <= 1) continue;
    
    for(int i=0; i<G[now].size(); i++) {
      int to = G[now][i];
      if(memo[to] == -1) {
	memo[to] = cost + 1;
	Q.push(Piii(cost+1, Pii(to, ttl-1)));
      }
    }
  }
  
  return -1;
}

int main() {
  
  int N;
  while(cin >> N) {
    
    for(int i=0; i<100; i++) G[i].clear();
    
    for(int i=0; i<N; i++) {
      int r; cin >> r; r--;
      int k; cin >> k;
      for(int i=0; i<k; i++) {
	int x; cin >> x; x--;
	G[r].push_back(x);
      }
    }
    
    int Q; cin >> Q;
    while(Q--) {
      int s, t, v;
      cin >> s >> t >> v; s--, t--;
      int res = bfs(s, t, v);
      if(res >= 0) {
	cout << res+1 << endl;
      }
      else {
	cout << "NA" << endl;
      }
    }
    
  }
  
  return 0;
}

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

int main(){
  string n;
  cin >> n;
  long ans = 0;
  rep(i,int(n.size())){
    ans += n[i]-'0';
  }
  if(ans%9==0)cout << "Yes\n";
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		String a = sc.next();
		String b = sc.next();
		String c = sc.next();

		StringBuilder as = new StringBuilder();
		StringBuilder bs = new StringBuilder();
		StringBuilder cs = new StringBuilder();

		as.append(a);
		bs.append(b);
		cs.append(c);

		int count = 0;

		if(a.equals(b)&&a.equals(c)) {
			System.out.println(count);
		}
		else {
			for(int i = 0; i<n; i++) {
				if(as.charAt(i) == bs.charAt(i)) {
					if(as.charAt(i) == cs.charAt(i)) {
						continue;
					}
					else {
						cs.setCharAt(i, as.charAt(i));
						count++;
					}
				}else if(as.charAt(i) == cs.charAt(i)) {
					bs.setCharAt(i, as.charAt(i));
					count++;
				}
				else if(bs.charAt(i) == cs.charAt(i)) {
					as.setCharAt(i, bs.charAt(i));
					count++;
				}else {
					cs.setCharAt(i, as.charAt(i));
					bs.setCharAt(i, as.charAt(i));
					count+=2;
				}
			}
			System.out.println(count);
		}

	}

}

Measured memory_bytes: 25172
//Created by Kira

#include<bits/stdc++.h>
using namespace std;

#define IOS cin.sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define pii pair<int,int> 
#define pb push_back
#define vi vector<int> 
#define ff first
#define ss second
using ll = long long;

const int mod = 1e9 + 7;

ll pwr(ll a, ll b);
    
struct Query{
    int l, r, idx;
};

bool comp(Query x, Query y){
    return x.r < y.r;
}

const int N = 5e5 + 100;
int n, q, a[N], bit[N], last[N * 10], ans[N];


void update(int idx, int val){
    for(; idx <= n; idx += idx &-idx)
        bit[idx] += val;
}
int query(int idx){
    int sum = 0;
    for( ;idx > 0; idx -= idx &-idx)
        sum += bit[idx];
    return sum;
}


int main(){
   IOS

    cin>>n>>q;

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

    Query v[N];
    for(int i = 0; i < q; i++){
        int l, r; cin>>l>>r;
        l--, r--;
        v[i].l = l, v[i].r = r;
        v[i].idx = i;
    }
    

    sort(v, v + q, comp);
    
    memset(bit, 0, sizeof bit);
    memset(last, -1, sizeof last);

    int qi = 0;

    for(int i = 0; i < n; i++){
        if(last[a[i]] != -1)
            update(last[a[i]] + 1, -1);
        last[a[i]] = i;
        update(i + 1, 1);

        while(qi < q && v[qi].r == i){
            ans[v[qi].idx] = query(v[qi].r + 1) - query(v[qi].l);
            qi++;
        }
    }

    

    for(int i = 0; i < q; i++){
        cout<<ans[i]<<"\n";
    }


}

ll pwr(ll a, ll b){
   a %= mod;	//Remove mod if not required
   ll res = 1;
   while(b > 0){
    if(b&1) res = res * a % mod;
        a = a * a % mod;
    b >>= 1;
    }

    return res;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    vector<int> X;
    vector<int> Y;
    REP(i,N){
        int a;
        cin >> a;
        if(a >= 0)
            X.push_back(a);
        else
            Y.push_back(a);
    }

    sort(X.begin(), X.end());
    sort(Y.begin(), Y.end());

    // a < 0
    if(X.size() == 0){
        vector<string> proc;
        ll ans = 0;
        ans += Y[N-1];
        REP(i,N-1){
            proc.push_back(to_string(ans) + " " + to_string(Y[i]));
            ans -= Y[i];
        }
        cout << ans << endl;
        for(auto&& s : proc){
            cout << s << endl;
        }
    }
    // a > 0
    else if(Y.size() == 0){
        vector<string> proc;
        ll ans = 0;
        ans += X[0];
        for(int i = 1; i < N-1; i++){
            proc.push_back(to_string(ans) + " " + to_string(X[i]));
            ans -= X[i];
        }
        proc.push_back(to_string(X[N-1]) + " " + to_string(ans));
        ans = X[N-1] - ans;

        cout << ans << endl;
        for(auto&& s : proc){
            cout << s << endl;
        }

    }
    else{
        vector<string> proc;
        ll tmp1 = 0;
        ll tmp2 = 0;
        int XX = X.size();
        int YY = Y.size();

        tmp1 = X[XX-1];
        for(int i = 1; i < YY; i++){
            proc.push_back(to_string(tmp1) + " " + to_string(Y[i]));
            tmp1 -= Y[i];
        }

        tmp2 = Y[0];
        for(int i = 0; i < XX-1; i++){
            proc.push_back(to_string(tmp2) + " " + to_string(X[i]));
            tmp2 -= X[i];
        }

        proc.push_back(to_string(tmp1) + " " + to_string(tmp2));
        ll ans = tmp1 - tmp2;

        cout << ans << endl;
        for(auto&& s : proc){
            cout << s << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 9332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include<limits.h>
#include<iomanip>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define RALL(v) v.rbegin(),v.rend()
#define check(v) rep(i,v.size()) cout << v[i] << " ";\
cout << endl
#define INF 1e8
typedef long long ll;
using namespace std;
//オーバーフローに気をつけろよおおおおおお
//確認忘れるなよおおおおおお

int main() {
    int n; cin >> n;
    vector<int> v(n-1);
    rep(i,n-1) cin >> v[i];
    v.push_back(INF);
    v.insert(v.begin(),INF);
    int ans = 0;
    rep(i,n) {
        ans += min(v[i],v[i+1]);
    }
    cout << ans << endl;

    return 0;
}

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

typedef long long ll;
const ll N = 200005, L = 262144, inf = 1e18;

ll n, m, a, b, p[N];

struct segtree {
	ll v[2*L], l[2*L];
	void init () {
		for(ll i = 2*L; --i; ) {
			v[i] = inf;
		}
	}
	void lazydown (ll P) {
		v[2*P] += l[P];
		v[2*P+1] += l[P];
		l[2*P] += l[P];
		l[2*P+1] += l[P];
		l[P] = 0;
	}
	void upd (ll S, ll E, ll X, ll SS = 0, ll SE = L-1, ll P = 1) {
		if(S <= SS && SE <= E) {
			v[P] += X;
			l[P] += X;
			return;
		}
		if(S > SE || SS > E) return;
		lazydown(P);
		ll M = (SS+SE)/2;
		upd(S, E, X, SS, M, 2*P);
		upd(S, E, X, M+1, SE, 2*P+1);
		v[P] = min(v[2*P], v[2*P+1]);
	}
	ll get (ll S, ll E, ll SS = 0, ll SE = L-1, ll P = 1) {
		if(S <= SS && SE <= E) return v[P];
		if(S > SE || SS > E) return 2*inf;
		lazydown(P);
		ll M = (SS+SE)/2;
		return min(get(S, E, SS, M, 2*P), get(S, E, M+1, SE, 2*P+1));
	}
	void ass (ll P, ll V) {
		ll C = get(P, P);
		if(C > V) upd(P, P, V-C);
	}
} s1, s2;

int main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&a,&b);
	for(ll i=1;i<=m;i++) {
		scanf("%lld",&p[i]);
	}
	s1.init();
	s2.init();
	s1.ass(a, abs(b-p[1])-a);
	s1.ass(b, abs(a-p[1])-b);
	s2.ass(a, abs(b-p[1])+a);
	s2.ass(b, abs(a-p[1])+b);
	for(ll i=2;i<=m;i++) {
		ll T = min(s1.get(1, p[i])+p[i],s2.get(p[i], n)-p[i]);
		s1.upd(1, n, abs(p[i]-p[i-1]));
		s2.upd(1, n, abs(p[i]-p[i-1]));
		s1.ass(p[i-1], T-p[i-1]);
		s2.ass(p[i-1], T+p[i-1]);
	}
	ll ans = inf;
	for(ll i=1;i<=n;i++) {
		ans = min(ans, s1.get(i, i)+i);
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 18176
def gcd( a , b ):
    # return gcd( a , b ) 
    while a % b != 0:
        return gcd( b , a % b )
    return b

A , B = ( int(x) for x in input().split() )

Gcd = gcd( A , B )
lo_cds = []
up_cds = []
i = 1
while i * i <= Gcd:
    if Gcd % i == 0:
        lo_cds.append(i)
        if Gcd // i != i:
            up_cds.append( Gcd // i )
    i += 1
Cds = lo_cds + up_cds[::-1]
# 1は必ず含まれるし素数判定の邪魔なので事前に省く。
Cds.pop(0)
i = 0


while i < len(Cds):
    j = i + 1
    while j < len(Cds):
        if Cds[j] % Cds[i] == 0:
            Cds.pop(j)
        else:    
            j += 1
    i += 1

print( len(Cds) + 1 )

Measured memory_bytes: 9260
n, y = map(int, input().split())
y //= 1000

for nog in range(n+1):
    for hig in range(n+1 -nog):
        yuk = n - nog - hig
        if nog + hig*5 + yuk*10 == y:
            print(yuk, hig, nog)
            exit(0)
print("-1 -1 -1")


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define boost ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define M 1000000007
#define eb emplace_back
#define watch(x) cout << (#x) <<" is "<< x <<"\n";


using namespace std;
//const int N = 1e6;

int32_t main(){
  boost;
  int tc = 1; //cin >> tc;
  while(tc--)
  {
    int n; cin >> n;
    int ans = n%1000;
    ans = 1000 - ans;
    ans %= 1000;
    cout << ans <<"\n";
  }
}



Measured memory_bytes: 3644
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<algorithm>
#include<map>
using namespace std;

int main()
{
  int a, b;
  int l, s;
  cin >> a >> b;
  if (b % a == 0) {
    cout << b + a << endl;
  } else {
    cout << b - a << endl;
  }
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    const n = chunk.toString();
    const r = n.split("\n");
    r.forEach(x => sp(x));
});

function sp(str){
    const r = str.split(" ").map(x=>Number(x));
    var moji = "";
    for(var i = 0; i < r.length; i++){
        if(r[i] != 0 && r[i+1] != 0){
            for (var d=0; d < r[0]; d++){
                for(var i=0; i < r[1]; i++){
                    moji += "#";
                }
                console.log(moji);
                var moji = "";
            }
            console.log("");
        }else{
            return false;
        }
    }
}


Measured memory_bytes: 19140
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
plus = []
total_minus = 0
for i in range(n):
    diff = a[i] - b[i]
    if diff >= 0:
        plus.append(diff)
    else:
        total_minus += (-1) * diff
plus.sort(reverse=True)
if total_minus == 0:
    print(0)
elif sum(plus) < total_minus:
    print(-1)
else:
    ans = n - len(plus)
    for i in range(n):
        if total_minus <= 0:
            break
        total_minus -= plus[i]
        ans += 1
    print(ans)

Measured memory_bytes: 18356
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int a = in.nextInt();
        String s = in.next();
        out.println(a>=3200?s:"red");
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 21076
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char** argv) {
	long long n;
	cin>>n;
	long long  a[n]={0};
	 	long long  count[n]={0};
	 	long long t=0;
	for(int i=0;i<n;i++) {
		cin>>a[i];
	}
   sort(a,a+n);

   long long t1=0,t2=0,t3=0;
   long long x=0,y=0;
   bool k1=false,k2=false;
   for(int i=n-1;i>0;i--){
   	
   	if(a[i]==a[i-1]){
   		t1=a[i];
   		x=i;
   		k1=true;
		break;
	   }
   	
   }
   

	   if(k1){
	   
	   for(int i=n-1;i>0;i--){
   	if(a[i]==a[i-1]&&i!=x&&i!=(x-1)){
   		t2=a[i];
   		y=i;
   		k2=true;
		  break;	
	   }  }
   }
   if(k1&&k2)cout<<t1*t2<<endl;
 else  cout<<"0";
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b)
{
    return b==0?a:gcd(b,a%b);
}
const int maxn=100000+5;
int a[maxn];
int n,k;
int main()
{
    scanf("%d%d",&n,&k);
    bool flag=true,uni=false;
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        flag|=(a[i]>=k);
        uni|=(a[i]==k);
    }
    sort(a+1,a+1+n);
    if(uni){
        printf("POSSIBLE\n");
    }else{
        if(!flag){
            printf("IMPOSSIBLE\n");
        }else{
            if(n==1){
                if(a[1]==k) printf("POSSIBLE\n");
                else printf("IMPOSSIBLE\n");
            }else{
                int gd=gcd(a[1],a[2]);
                for(int i=3;i<=n;i++)
                    gd=gcd(gd,a[i]);
                bool can=false;
                for(int i=n;i>=1;i--)
                {
                    if(a[i]<k) break;
                    if((a[i]-k)%gd==0){
                        can=true;
                        break;
                    }
                }
                if(can) printf("POSSIBLE\n");
                else printf("IMPOSSIBLE\n");
            }
        }
    }
    return 0;
}


Measured memory_bytes: 640
/**
 * File    : C.cpp
 * Author  : Kazune Takahashi
 * Created : 2018-5-5 21:04:33
 * Powered by Visual Studio Code
 */

#include <iostream>
#include <iomanip>   // << fixed << setprecision(xxx)
#include <algorithm> // do { } while ( next_permutation(A, A+xxx) ) ;
#include <vector>
#include <string> // to_string(nnn) // substr(m, n) // stoi(nnn)
#include <complex>
#include <tuple>
#include <queue>
#include <stack>
#include <map> // if (M.find(key) != M.end()) { }
#include <set>
#include <random> // random_device rd; mt19937 mt(rd());
#include <cctype>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
using namespace std;

#define DEBUG 0 // change 0 -> 1 if we need debug.

typedef long long ll;

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

// const int C = 1e6+10;
// const ll M = 1000000007;

int H, W;
string S[100];

bool valid(int i, int j)
{
  return (0 <= i && i < H && 0 <= j && j < W && S[i][j] == '#');
}

int main()
{
  cin >> H >> W;
  for (auto i = 0; i < H; i++)
  {
    cin >> S[i];
  }
  for (auto i = 0; i < H; i++)
  {
    for (auto j = 0; j < W; j++)
    {
      if (S[i][j] == '#')
      {
        bool ok = false;
        for (auto k = 0; k < 4; k++)
        {
          int x = i + dx[k];
          int y = j + dy[k];
          if (valid(x, y))
          {
            ok = true;
            break;
          }
        }
        if (!ok)
        {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, x) for (ll i = 0; i < (x); i++)
#define chmax(x, a)  do { x = max(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main(void) {
  ll N;
  cin >> N;
  ll V = 0, E = 0;
  rep(i, N) {
    V += (i + 1) * (N - i);
  }
  rep(i, N-1) {
    ll u, v;
    cin >> u >> v;
    u--, v--;
    if (u > v) swap(u, v);
    E += (u + 1) * (N - v);
  }
  cout << (V - E) << endl;
  return 0;
}


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

using namespace std;

typedef long long ll;

ll md = 1000000007;

multimap<int, int> mp;
vector<bool> d0;
vector<bool> d1;
vector<bool> d2;

int main(int, char**)
{
	ll ans = 0;
	int n, a, b;
	cin >> n >> a >> b;
	ans = min(n*a, b);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define forn(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007



using namespace std;

int main()
{

  int H,A,res;
  cin>>H>>A;
  res=ceil((float)H/A);
  cout<<res;

  return 0 ;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <cstdio>
using namespace std;

int main()
{
    int a,b,c,sum=0;
    scanf("%d %d %d",&a,&b,&c);
    for(int i=1;i<=100;i++)
    {
        if(c*i>b)
            break;
        if(c*i>=a)
            sum++;
    }
    printf("%d\n",sum);
    return 0;
}


Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
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; }
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int const INF = 1001001001;


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

int N,M;
cin >> N >> M;

// 電球iにつながれているスイッチの番号を１次元配列S[i]に入れる
vvi S(M);
rep(i,M) {
    int k;
    cin >> k;
    rep(j,k) {
        int s;
        cin >> s;
        //0-index化忘れんなし！
        --s;
        S[i].push_back(s);
    }
}

//電球iのp値を１次元配列Pに入れる
vi P(M);
rep(i,M) cin >> P[i];

//答え
ll ans = 0;

//bit全探索する
//「j番目のフラグが1⇔スイッチjがon」という対応を考えている
for( int bit = 0; bit < (1 << N); ++bit) {

    //okは点灯しない電球があればfalseにする
    bool ok = true;

    //各電球が点灯するか見ていく
    rep(i,M) {
        //onになっているスイッチの個数を数える
        int cnt = 0;
        //各電球につながれているスイッチがonかどうか見ていく
        for(auto v : S[i]) {
            if(bit & (1 << v)) cnt++;
        }
        if(cnt % 2 != P[i]) ok = false;
    }

    if(ok) ++ans;
}

cout << ans << endl;

return 0;
}

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


//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(){
    int a,b,c,k;
    cin >> a >> b >> c >> k;
    int max = 0;

    if(k < a){
        max += k;
    }else{
        max += a;
        k -= a;
        k -= b;
        if(k > 0){
            max += (-k);
        }
        
    }

    cout << max << endl;
    return 0;
}


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

using namespace std;
using uint = unsigned int;
using int64 = long long;
using i64 = int64;
using uint64 = unsigned long long;
using vint = vector<int>;
using vint64 = vector<int64>;
template<typename T>
using p_que = priority_queue<T>;
#define rep(i,N) for(int i=0;i<(int)(N);++i)
#define rep1(i,N) for(int i=1;i<=(int)(N);++i)
#define fs first
#define sc second
#define eb emplace_back
#define all(x) x.begin(),x.end()

template<typename T>
vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<class T> ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}

template<class T, class U> ostream& operator<<(ostream& os, const pair<T, U> p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}

template<class T, class U> ostream& operator<<(ostream& os, const map<T, U>& mp) {
	os << "{";
	for (auto& e : mp) os << e << " ";
	return os << "}";
}

void Main();
signed main() {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);
	Main();
}

/* Cut from here! */

//#define int long long

int GCD(int a, int b) {
	return b ? GCD(b, a % b) : a;
}

void Main() {
	int x, y; cin >> x >> y;
	int g = GCD(x, y);
	int gx = x / g, gy = y / g;
	int m = gx + gy - 1;
	cout << m * g + 1 << endl;
}


Measured memory_bytes: 3164
A, B = [int(x) for x in input().split()]

def prime_factorization(n):
    i = 2
    factors = []
    while i * i <= n:
        if n % i:
            i += 1
        else:
            n //= i
            factors.append(i)
    if n > 1:
        factors.append(n)
    return factors

Aprimes = prime_factorization(A)
Bprimes = set(prime_factorization(B))

ans = 1
ansset = set()
for a in Aprimes:
    if a in ansset:
        continue
    if a in Bprimes:
        ansset.add(a)
        ans += 1

print(ans)



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

int k,R,L;
double p,e,t;

double dfs(double l,double r,int d){
	if(d==k){
		if(abs((l+r)/2-t)<e)return 1.0;
		else return 0.0;
	}else if(abs(l-t)<e&&abs(r-t)<e&&t-e<l&&r<t+e){
		return 1.0;
	}else if(r<t-e||t+e<l){
		return 0.0;
	}else{
		double mid=(l+r)/2;
		double res;
		if(t<=mid){
			res=dfs(l,(l+r)/2,d+1)*(1-p)+dfs((l+r)/2,r,d+1)*p;
		}else{
			res=dfs(l,(l+r)/2,d+1)*p+dfs((l+r)/2,r,d+1)*(1-p);
		}
		return res;
	}
}

int main(){
	cin.sync_with_stdio(false);
	cin>>k>>R>>L;
	cin>>p>>e>>t;
	double res=dfs(R,L,0);
	printf("%.10f\n", res);
	return 0;
}

Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace std;
//#define mod 1000000007
#define pb push_back
typedef long long ll;
typedef long double ld;
#define FOR(i,n) for(i=0;i<n;i++)
#define FORE(i,n) for(i=0;i<=n;i++)
 
 
ll gcd(ll a , ll b)
{
   if(b==0) return a;
   a%=b;
   return gcd(b,a);
   
}
    
ll maxl(ll a,ll b){
    if(a>b)return a;
    return b;
}
 
ll minl(ll a,ll b){
    if(a>b)return b;
    return a;
}
 
ll mod = 998244353;
 
ll mulmod(ll a, ll b,ll c){ 
    ll res = 0; 
    a = a % c; 
    while (b > 0){ 
        if (b % 2 == 1){ 
            res = (res + a) % c;
        }
        a = (a * 2) % c; 
        b /= 2; 
    } 
    return res % c; 
}
 
int binarySearch(int arr[], int l, int r, int x) 
{ 
    if (r >= l) { 
        int mid = l + (r - l) / 2; 
        if (arr[mid] == x) 
            return mid; 
        if (arr[mid] > x) 
            return binarySearch(arr, l, mid - 1, x); 
        return binarySearch(arr, mid + 1, r, x); 
    } 
    return -1; 
} 
 
int a[100005];
int tree[200005];
 
void build(int st,int low,int high){
    if(low==high){
        tree[st] = a[high]%2;
        return;
    }
    int mid = low+(high-low)/2;
    build(2*st,low,mid);
    build(2*st+1,mid+1,high);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
void update(int st,int start,int end,int ind,int val){
    if(start==end){
        tree[st] = val%2;
        return;
    }
    int mid = start+(end-start)/2;
    if(ind<=mid){
        update(2*st,start,mid,ind,val);
    }
    else update(2*st+1,mid+1,end,ind,val);
    tree[st] = tree[2*st]+tree[2*st+1];
}
 
int query(int st,int start,int end,int low,int high){
    if(start>high || end<low)return 0;
    int mid = start + (end-start)/2;
    if(start==low && end==high){
        return tree[st];
    }
    if(low>mid)return query(2*st+1,mid+1,end,low,high);
    if(high<=mid)return query(2*st,start,mid,low,high);
    return query(2*st,start,mid,low,mid)+query(2*st+1,mid+1,end,mid+1,high);
}


int main(){
	ios_base::sync_with_stdio(false);
	cout << setprecision(12);
	int a;
	string s;
	cin >> a;
	cin >> s;
	if(a<3200){
	    cout << "red" << endl;
	    return 0;
	}
	else cout << s << endl;
	return 0;
}


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

void print(const vector<long> &v){
    const size_t n = v.size();
    for(size_t i=1; i<n; i++){
        cout << v[i] << " ";
    }
    cout << endl;
}

int main(void){
    long n;
    cin >> n;
    vector<long> p(n+1), r(n+1), x(n+1);
    for(long i=1; i<=n; i++){
        cin >> p[i];
        r[p[i]] = i;
    }
    for(long i=n; i>=1; i--){
        if(r[p[i]+1]>r[p[i]]){
            x[i] = x[r[p[i]+1]] + 1;
        }else{
            x[i] = 1;
        }
    }
    /*
    print(p);
    print(r);
    print(x);
    */
    long imax=0;
    for(long i=1; i<=n; i++){
        imax = max(imax, x[i]);
    }
    cout << n-imax << endl;
    return 0;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <fstream>
#include <cmath>
#include <ctime>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <list>
#include <deque>
#include <numeric>
#include <set>
#include <climits>
#include <utility>
#include <map>
#include <float.h>
typedef long long ll;
typedef unsigned long long ull;
inline int max( int x, int y ){ return x > y ? x : y ; }
inline int min( int x, int y ){ return x < y ? x : y ; }
inline ll max( ll x, ll y ){ return x > y ? x : y ; }
inline ll min( ll x, ll y ){ return x < y ? x : y ; }
inline ull max( ull x, ull y ){ return x > y ? x : y ; }
inline ull min( ull x, ull y ){ return x < y ? x : y ; }
int GCD( int a, int b ) { return b ? GCD( b , a%b ) : a; }
using namespace std;
#define INF 1000000000
#define MOD 1000000007
#define PIV 3.14159265358979323846
#define MAXN 100
typedef pair<int, int> P;
const int MAX_V = 400+1;

int main(){
	
	int N, K, Q, A;
	int arr[100001];
	
	memset( arr, 0, sizeof(arr) );
	scanf("%d %d %d", &N, &K, &Q);
	for( int i=0; i<Q; ++i ){
		scanf("%d", &A);
		arr[A]++;
	}
	
	int ans = 0;
	for( int i=1; i<=N; ++i ){
		if( K-Q+arr[i] > 0 ) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}









Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define ceil(a, b) a / b + !!(a % b)
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }





ll m, v;
int n, p;
vector<int> a;

bool check(int x) { // x番目の問題を採用できるか
    if (x + 1 <= p) return 1;
    if (a[x] + m < a[p - 1]) return 0;
    
    ll sum = m * (p - 1 + n - x);
    rep3(i, p - 1, x) {
        sum += a[x] + m - a[i];
    }
    if (sum >= m * v) return 1;
    return 0;
}

template<typename T>
void binary_search(T ok, T ng) {
    while (abs(ng - ok) > 1) {
        T mid = (ng + ok) / 2;
        (check(mid) ? ok : ng) = mid;
    }
    cout << ok + 1 << endl;
}

void solve() {
    cin >> n >> m >> v >> p;
    a.resize(n);
    rep(i, n) cin >> a[i];
    sort(all(a), greater<int>());
    binary_search(0, n);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    while (T--) {
        solve();
        // cout << (solve() ? "YES" : "NO") << endl;
    }
}


Measured memory_bytes: 640
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <ctype.h>
using namespace std;

enum { FALSE, TRUE };

#define N 15  /* 最大の行数 */

int imax, jmax, solution, digit[256], low[256], ok[10];
char word[N][16];

void found(void){
	for(int i = 0; i <= imax; i++){
		if(strlen(word[i])>1&&digit[word[i][strlen(word[i])-1]]==0)return;
	}
	++solution;
}

void solve(int sum)  /* 再帰的に試みる */
{
	static int i = 0, j = 0, carry;
	int c, d;

	c = word[i][j];
	if(i < imax) {
		i++;
		if((d = digit[c]) < 0) {  /* 定まっていないなら */
			for(d = low[c]; d <= 9; d++)
				if(ok[d]) {
					digit[c] = d;  ok[d] = FALSE;
					solve(sum + d);  ok[d] = TRUE;
				}
			digit[c] = -1;
		} else solve(sum + d);
		i--;
	} else {
		j++;  i = 0;  d = sum % 10;  carry = sum / 10;
		if(digit[c] == d) {
			if(j <= jmax) solve(carry);
			else if(carry == 0) found();
		} else if(digit[c] < 0 && ok[d] && d >= low[c]) {
			digit[c] = d;  ok[d] = FALSE;
			if(j <= jmax) solve(carry);
			else if(carry == 0) found();
			digit[c] = -1;  ok[d] = TRUE;
		}
		j--;  i = imax;
	}
}

int main(){
	int i, j, k, c;
	char buffer[128];

	jmax = 0;
	while(1){
		cin >> imax;
		if(!imax) break;
		imax--;
		memset(word, 0, sizeof(word));
		memset(digit, 0, sizeof(digit));
		//memset(low,0,sizeof(low));
		memset(ok, 0, sizeof(ok));
		for(i = 0; i < N && i <= imax; i++) {
			cin >> buffer;
			//low[buffer[0]] = 1;
			k = strlen((char*)buffer) - 1;
			if(k > jmax) jmax = k;
			for(j = 0; j <= k; j++) {
				c = word[i][j] = buffer[k - j];
				if(isalpha(c)) digit[c] = -1;
				else if(isdigit(c)) digit[c] = c - '0';
			}
		}
		for(i = 0; i <= 9; i++) ok[i] = TRUE;
		solution = 0;  solve(0);
		cout << solution << endl;
	}
	return 0;
}


Measured memory_bytes: 3072
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	int N;
	cin >> N;
	string S, T;
	cin >> S >> T;
	rep(i, N) {
		cout << S[i] << T[i];
	}
	cout << endl;
}

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		
		Scanner scan = new Scanner(System.in);
		
		int n = scan.nextInt();
		int[] s = new int[n];
		for(int i = 0; i < n; i++) {
			s[i]  = scan.nextInt();
		}

		Arrays.sort(s);
		
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans += s[i];
		}
		
		for (int i = 0; i < n; i++) {
			if ((ans % 10) != 0) { 
				System.out.println(ans);
				return;
			} else {
				if ((s[i] %  10) != 0) {
					ans = ans - s[i];
					System.out.println(ans);
					return;
				}
			}
		}
		System.out.println(0);
		return;
	}

}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  rep(i, n){
    int ia, ib;
    cin >> ia >> ib;
    a.at(i) = ia; b.at(i) = ib;
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if(n % 2 == 1){
    int l = a.at(n/2);
    int r = b.at(n/2);
    cout << r - l + 1 << endl;
  }else{
    int l = (a.at(n/2-1) +a.at(n/2));
    int r = (b.at(n/2-1) +b.at(n/2));
    cout << r - l + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 4816
import java.util.*;

/**
 * @author varun on 7/1/2018
 * @project CompetitiveProgramming
 */
public class Main {
    private static int[] freqMap = new int[200000];
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int maxNumKeys = scanner.nextInt();
        for (int i = 0; i < N; i++) freqMap[scanner.nextInt()]++;
        Arrays.sort(freqMap);
        int ans = 0;
        for (int i = 0; i < freqMap.length-maxNumKeys; i++) ans += freqMap[i];
        System.out.println(ans);
    }
}


Measured memory_bytes: 65612
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(12);
  std::cerr << std::fixed << std::setprecision(6);

  long double L;

  std::cin >> L;

  std::cout << L * L * L / 27 << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mp make_pair
#define pii pair<int,int>
#define inf 0x3f3f3f3f
using namespace std;
const int N=3e3,M=2e4;
bitset<M> b[N];
pii p[2][N];
int n,k,sz[N];
char s[N][M],ans[M];
int main(){
	scanf("%d%d",&n,&k);
	int i,j;
	for(i=1;i<=n;++i){
		scanf("%s",s[i]);
		sz[i]=strlen(s[i]);
	}
	b[n+1][0]=1;
	for(i=n;i;--i) b[i]=b[i+1]|(b[i+1]<<sz[i]);
	int t=0,c=0,tc=0;
	for(i=1;i<=n;++i) if(b[i+1][k-sz[i]]) p[t][++c]=mp(i,0);
	int mn;
	for(i=0;i<k;++i,c=tc,t^=1){
		char mc='z';
		for(j=1;j<=c;++j) mc=min(mc,s[p[t][j].first][p[t][j].second]);
		ans[i]=mc;
		tc=0,mn=inf;
		for(j=1;j<=c;++j){
			int x=p[t][j].first,y=p[t][j].second;
			if(s[x][y]!=mc) continue;
			if(y==sz[x]-1) mn=min(mn,x);
			else p[t^1][++tc]=mp(x,y+1);
		}
		if(mn^inf) for(j=mn+1;j<=n;++j) if(k-sz[j]-i-1>=0 and b[j+1][k-sz[j]-i-1]) p[t^1][++tc]=mp(j,0);
	}
	for(i=0;i<k;++i) putchar(ans[i]);
	return 0;
}

Measured memory_bytes: 47872
#include <stdio.h>
int main(void){
    int a,b,c,tmp;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}



Measured memory_bytes: 2068