akhauriyash/Code-Regression huggingface dataset:
import sys
import math

A = raw_input()
A = int(A)

primes = []

for i in xrange(100004):
    if i <= 1:
        continue
    if not primes:
        primes.append(i)
        continue
    for j in primes:
        #print i, j, primes
        if i % j == 0:
            break
        if math.sqrt(i) < j:
            primes.append(i)
            break
    else:
        primes.append(i)
for x in primes:
    if x < A:
        continue
    print x
    break

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

signed main() {
int A, B, C, X, Y;
cin >> A >> B >> C >> X >> Y;

int ans = 0;
if( 2*C <= A && 2*C <= B){
    ans = 2*C*max(X, Y);
}else if( A+B <= 2*C ){
    ans = A*X + B*Y;
}else if( A+B > 2*C){
    ans = min(2*C*max(X, Y), min(X, Y)*2*C + A*( X-min(X, Y)) + B*( Y-min(X, Y)));
}
cout << ans << endl;

}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <vector>
#include <algorithm>
#include <iostream>
#include <bitset>
#include <cassert>
#include <queue>
#include <random>
#include <stack>
#include <iomanip>

using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
typedef long double ldouble;

typedef vector<llong> vecllong;
typedef vector<vecllong> vvecllong;

template<class T> inline bool chmin(T& to, T compare) {
    if (to > compare) {
        to = compare;
        return true;
    }
    return false;
};

template<class T> inline bool chmax(T& to, T compare) {
    if (to < compare) {
        to = compare;
        return true;
    }
    return false;
};

const llong MOD = 1e9 + 7;
const llong INF = 1e17;

#define FOR(i, n) for (llong i = 0; i < n; i++)
#define FORS(i, a, b) for (llong i = a; i < b; i++)
#define FORR(i, n) for (llong i = n; i > 0; i++)

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

    llong N, W;
    cin >> N >> W;

    vecllong weight(N);
    vecllong value(N);

    FOR(i, N) {
        cin >> weight[i] >> value[i];
    }

    vvecllong dp(N + 2, vecllong(W + 1, 0));

    FOR(i, N + 1) {
        FORS(w, 1, W + 1) {
            if(w - weight[i] >= 0) {
                dp[i + 1][w] = max({dp[i + 1][w], dp[i][w], dp[i][w - weight[i]] + value[i]});
            } else {
                dp[i + 1][w] = max(dp[i + 1][w], dp[i][w]);
            }
        }
    }

    cout << dp[N][W] << endl;

    return 0;
}

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

const int nMax = 1000000;

class Sieve
{
private:
	int n;
	vector<int> f, primes;

public:
	Sieve(int v = 1) : n(v), f(n + 1)
	{
		f[0] = f[1] = -1;
		for (ll i = 2; i <= n; i++) {
			if (f[i]) continue;
			primes.push_back(i);
			f[i] = i;
			for (ll j = i * i; j <= n; j += i) {
				if (!f[j]) f[j] = f[i];
			}
		}
	}

	vector<pair<ll, int>> factor(ll x)
	{
		vector<pair<ll, int>> res;
		for (const auto& p : primes) {
			int y = 0;
			while (x%p == 0) {
				x /= p;
				y++;
			}
			if (y != 0) res.emplace_back(p, y);
		}
		if (x != 1) res.emplace_back(x, 1);
		return res;
	}
};

int main()
{
	ll n;
	cin >> n;
	Sieve s(nMax);
	vector<pair<ll, int>> fs = s.factor(n);

	int ans = 0;
	for (const auto& item : fs) {
		int shoulder = item.second;
		int start = 1;
		while (start <= shoulder) {
			shoulder -= start;
			start++;
			ans++;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 7804
#include<algorithm>
#include<iostream>
#include<cstring>
#include<stdio.h>
#include<cstdio>
#include<cmath>
#define ll long long
using namespace std;
const ll maxn=1e2+7;
char s[maxn],t[maxn]; 
bool cmp(char x,char y){
    return x>y;
}
int main(void){
    gets(s);
    gets(t);
    ll lens=strlen(s);
    ll lent=strlen(t);
    sort(s,s+lens);
    sort(t,t+lent,cmp);
    for(ll i=0;i<max(lens,lent);i++){
        if(s[i]<t[i]){
            cout<<"Yes"<<endl;
            return 0;
        }
        else
		if(s[i]>t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A=list(map(int,input().split()))
X=1<<50
Y,Z=0,0
M=0
for i in range(50):
  X>>=1
  Y,Z=0,0
  for j in range(N):
    if X&A[j]:
      Y+=1
    else:
      Z+=1
  if Y<Z and M+X<=K:
    M+=X
P=0
for i in range(N):
  P+=M^A[i]
print(P)

Measured memory_bytes: 86524
#include <stdio.h>

int main(void){
	double a, b, c, d, e, f;
	double x, y;
	double arc_A;

	while (scanf("%lf %lf %lf %lf %lf %lf", &a, &b, &c, &d, &e, &f) != -1){
		arc_A = (a * e) - (b * d);
		x = ((e * c) + ((-1) * b * f)) / arc_A;
		y = (((-1) * d * c) + (a * f)) / arc_A;
		
		(x == -0.000) ? x += 0 : x;	
		(y == -0.000) ? y += 0 : y;
		printf("%.3f %.3f\n", x, y);
	}

	return(0);
}

Measured memory_bytes: 652
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
// 	cin>>test;	
	while(test--)
	{
	long a,b=0,c,k,i,n,temp;
		cin>>n;
		cout<<n*(n+1)/2;
		
		
    }
    
}


Measured memory_bytes: 256
A, B, Q = map(int, input().split())

INF = 10 ** 11 + 1
S = [-INF] + [int(input()) for _ in range(A)] + [INF]
T = [-INF] + [int(input()) for _ in range(B)] + [INF]
X = [int(input()) for _ in range(Q)]

def bsr(a, v):
	lo, hi = 0, len(a) - 1
	while lo <= hi:
		mi = (lo + hi) // 2
		if v < a[mi]:
			hi = mi - 1
		else:
			lo = mi + 1
	return lo

for x in X:
	sr = bsr(S, x)
	sl = sr - 1
	tr = bsr(T, x)
	tl = tr - 1
	cost = []
	for m in [S[sr], S[sl]]:
		for n in [T[tr], T[tl]]:
			cost += [abs(x - m) + abs(m - n), abs(x - n) + abs(m - n)]
	print(min(cost))


Measured memory_bytes: 16132
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define pob pop_back
#define pp push
#define pf push_front 
#define pof pop_front 
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree< ll  , null_type,less<ll >, rb_tree_tag,tree_order_statistics_node_update>

#define ff first
#define ss second

int main(){
	ll n,x=0;
	cin>>n;
	ll a[n+1],b[n];
	for(ll i=0;i<=n;i++){
		cin>>a[i];
	}
	for(ll i=0;i<n;i++){
		cin>>b[i];
	}
	for(ll i=0;i<n;i++){
		if(b[i]>=a[i]){
			b[i]-=a[i];
			x+=a[i];
			a[i]=0;
			if(a[i+1]-b[i]>0){
				x+=b[i];
				a[i+1]=a[i+1]-b[i];
			}
			else {
				x+=a[i+1];
				a[i+1]=0;
			}
		}
		else if(b[i]<a[i]){
			x+=b[i];
	
		}
	}
	cout<<x;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
using namespace std;

template<typename A, typename B> bool chmin(A &a, const B &b){ return b < a && (a = b, true); }
template<typename A, typename B> bool chmax(A &a, const B &b){ return a < b && (a = b, true); }

int main(){
  int n,a = 0;
  string s;
  cin >> s;
  n = s.size();
  for (int i = 0; i < n; i++){
    if (i % 2 == 0 && s[i] == 'L'){
      cout << "No\n";
      return 0;
    }
    if (i % 2 == 1 && s[i] == 'R'){
      cout << "No\n";
      return 0;
    }
  }
  cout << "Yes\n";
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repf(i,a,b) for (int i = (a); i < (b); i++)
#define repi(i,a,b) for (int i = (a); i <= (b); i++)
#define repr(i,a,b) for (int i = (a); i >= (b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(all(x));
#define RSORT(x) sort(rall(x));
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vd = vector<double>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;
using tiii = tuple<int, int, int>;
const ll inf = 1ll<<29;
const ll mod = 1000000007;
const double eps = 1e-9;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};

int main() {
  int N, D; cin >> N >> D;
  vvi X(N,vi(D)); rep(i,N) rep(j,D) cin >> X.at(i).at(j);
  
  vi square;
  rep(i,128) {
    square.push_back(i*i);
  }

  int ans = 0;
  rep(i,N-1) {
    repf(j,i+1,N) {
      int d2 = 0;
      rep(k,D) {
        d2 += abs(X.at(i).at(k)-X.at(j).at(k)) * abs(X.at(i).at(k)-X.at(j).at(k));
      }
      if(find(all(square),d2)!=square.end()) ans++;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main(){
	string s; cin >> s;
	if(s=="RRR")
		cout << 3 << endl;
	else if(s=="RRS"||s=="SRR")
		cout << 2 << endl;
	else if(s=="SSS")
		cout << 0 << endl;
	else
		cout << 1 << endl;
	return 0;
}

Measured memory_bytes: 3620
def resolve():
    import sys
    input = sys.stdin.readline
    # row = [int(x) for x in input().rstrip().split(" ")]
    # n = int(input().rstrip())

    a, b = [int(x) for x in input().rstrip().split(" ")]
    s = input().rstrip()

    if str.isdecimal(s[0:a]) and str.isdecimal(s[a+1: len(s)]) and s[a] == "-":
        print("Yes")
    else:
        print("No")




if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61812
n = int(input())
a = list(map(int, input().split()))

counter = 1
lista = []
for i in range(len(a)):
    if a[i] == counter:
        lista.append(a[i])
        counter += 1
if len(lista) > 0:
    print(n - len(lista))
else:
    print(-1)

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

int N;
vector<int> x, rx;
int L;

vector<vector<int>> dp, rdp;

void init() {
  rx = x;
  reverse(rx.begin(), rx.end());

  int latte = rx[0];
  for (int i = 0; i < N; ++i) {
    rx[i] = latte - rx[i];
  }

  auto doubling = [&](vector<vector<int>> &d, const vector<int> &x) {
    d.assign(17, vector<int>(N));
    for (int l = 0, r = 0; l < N; ++l) {
      while (r < N && x[r] - x[l] <= L) r++;
      d[0][l] = r - 1;
    }
    for (int i = 0; i + 1 < 17; ++i) {
      for (int j = 0; j < N; ++j) {
        d[i + 1][j] = d[i][d[i][j]];
      }
    }
  };

  doubling(dp, x);
  doubling(rdp, rx);
}

int ans(int a, int b) {
  auto rec = [&](int a, int b, const vector<vector<int>> &d) {
    int res = 0;
    while (a < b) {
      for (int i = 16; i >= 0; --i) {
        if (d[i][a] < b || !i) {
          a = d[i][a];
          res += (1 << i);
          break;
        }
      }
    }

    return res;
  };

  if (a < b) {
    a--, b--;
    return rec(a, b, dp);
  } else {
    a = N - a;
    b = N - b;

    return rec(a, b, rdp);
  }
}

int main() {
  cin >> N;

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

  cin >> L;
  init();

  int q;
  cin >> q;
  while (q--) {
    int a, b;
    cin >> a >> b;
    cout << ans(a, b) << endl;
  }
}


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

#define x first
#define y second
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long LL;
const int maxn = 1e5+15;
int dp[150][maxn],a[maxn],cnt;
int main(){
    int x; cin >> x; int cnt = 1;
    for(int i = 0;i < 6; ++i){
        for(int j = 1;j <= 20; ++j){
            a[cnt++] = (100+i)*j;
        }
    }
    dp[0][0] = 1; 
    for(int i = 1;i < cnt; ++i){
        for(int j = 0;j <= x; ++j){
            dp[i][j] = dp[i-1][j];
            if(j >= a[i]) dp[i][j] = max(dp[i][j],dp[i-1][j-a[i]]);
        }
    }
    cout << dp[cnt-1][x] << '\n';
    return 0;
}

Measured memory_bytes: 48640
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author NikuKyabe
 */

#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n)  FOR(i,0,(n))


class CHAndV {
public:
	void solve(std::istream& in, std::ostream& out) {
    int h,w,k;
    in >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    REP(i, h)REP(j, w){
      in >> c[i][j];
    }

    int bit = 0;
    int ans = 0;
    while(bit < pow(2, h)){
      int bit2 = 0;
      vector<vector<char>> cp = c;
      REP(i, h){
        if((bit >> i) & 1){
          REP(j, c[i].size()){
            cp[i][j] = '.';
          }
        }
      }
      while(bit2 < pow(2, w)){
        int cnt = 0;
        vector<vector<char>> ccp = cp;
        REP(i, w){
          if((bit2 >> i) & 1){
            REP(j, ccp.size()){
              ccp[j][i] = '.';
            }
          }
        }
        REP(i,h)REP(j,w){
          if(ccp[i][j] == '#'){
            cnt++;
          }
        }
        if(cnt == k) ans++;
        bit2++;
      }
      bit++;
    }
    out << ans << endl;
	}
};


signed main() {
  ios::sync_with_stdio(false);
  cout.tie(0);
  cout << fixed;
	CHAndV solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4020
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void run_case(){
    ll x, k, d;
    cin>>x>>k>>d;
    if(x<0) x *= -1;
    int par = k % 2;
    ll ans = 0;
    ll amt = x/d;
    if(k < amt) {
        ans = x - k*d;
    } else {
        int par2 = amt%2;
        if(par == par2) {
            ans = x - amt * d;
        } else{
            ans = x - amt * d - d;
        }
    }
    cout<<abs(ans)<<'\n';

}
int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    if (fopen("input.in", "r")) 
        freopen("input.in", "r", stdin), freopen("output.out", "w", stdout);
    int t;
    t = 1;
    while(t--){
        run_case();
    }
}


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

const int maxn=1e5+10;
int n,k,a[maxn],res=1e9;

int f(int l,int r){
	if(r<0)
		return -l;
	if(l>0)
		return r;
	return r-l+min(-l,r);
}

int main(){
	cin>>n>>k;
	for(int i=1;i<=n;++i)
		cin>>a[i];
	for(int i=1;i+k-1<=n;++i)
		res=min(res,f(a[i],a[i+k-1]));
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
#define int long long
using LL = long long;
using namespace std;
using Graph = vector<vector<int>>;
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 INF = 1e9;
const LL LLINF = 1e18+10000000;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

vector<LL> pos, neg;
LL zero = 0;
LL npos, nneg, nzero;

LL f(LL x){
    // x 未満の個数
    LL ret = 0;
    if(x < 0){
        repe(i, neg){
            LL now = -i;
            LL bd = (-x+now-1)/now;
            ret += pos.size() - (lower_bound(all(pos), bd) - pos.begin());
        }
    }else if(x == 0){
        ret = nneg+nzero;
    }else{
        repe(i, neg){
            LL now = -i;
            LL bd = (x+now-1)/now;
            LL tmp = neg.size() - (upper_bound(all(neg), -bd) - neg.begin());
            if(now < bd) tmp--; 
            ret += tmp;
        }
        // cout << ret << endl;
        repe(now, pos){
            LL bd = (x+now-1)/now;
            LL tmp = lower_bound(all(pos), bd) - pos.begin();
            if(now < bd) tmp--; 
            ret += tmp;
        }
        // cout << ret << endl;
        ret /= 2;
        ret += nneg+nzero;
    }
    // cout << x << " " << ret << endl;
    return ret;
}

signed main(){
    fastcin();
    int n, k;
    cin >> n >> k;
    vector<LL> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n){
        if(a[i] > 0) pos.push_back(a[i]);
        else if(a[i] == 0) zero++;
        else neg.push_back(a[i]);
    }
    sort(all(pos));
    sort(all(neg));
    LL lpos = pos.size(), lneg = neg.size();
    npos = lpos*(lpos-1)/2 + lneg*(lneg-1)/2;
    nneg = lpos*lneg;
    nzero = zero*(zero-1)/2 + lpos*zero + lneg*zero;
    // cout << npos << " " << nneg << " " << nzero << endl;
    // cout << n*(n-1)/2 << " " << npos+nzero+nneg << endl;

    LL ok = -LLINF, ng = LLINF;
    while(abs(ok-ng) > 1){
        LL mid = (ok+ng)/2;
        if(f(mid) < k) ok = mid;
        else ng = mid;
    }
    if(ok < 0) ok++; // ????????
    cout << ok << endl;
}

Measured memory_bytes: 3956
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <cmath>
#include <algorithm>
#include <map>
#include <sstream>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <functional>
#include <utility>
#include <stdio.h>
#define ll long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define F first
#define S second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
int n;
bool a[110][20];
ll p[110][20];
int c[110];
ll res=-1e18;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<10;j++)
		    cin >>a[i][j];
	} 
	for (int i=0;i<n;i++)
	{
		for (int j=0;j<=10;j++)
		    cin >>p[i][j];
	} 
	for (int i=1;i<(1<<10);i++)
	{
		fill(c,c+n,0);
		for (int j=0;j<10;j++)
		{
			if (!(i & (1<<j))) continue;
			for (int k=0;k<n;k++) if (a[k][j]) c[k]++;
		}
		ll r=0;
		for (int j=0;j<n;j++) r+=p[j][c[j]];
		res=max(res,r); 
	}
	cout <<res;
	return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int

using namespace __gnu_pbds;

typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;


#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
#define mod 1000000007
/* Precode Start Here *\


power of 2 less than or equal to N

ll largest_power(ll N)
{
    //changing all right side bits to 1.
    N = N (N>>1);
    N = N| (N>>2);
    N = N| (N>>4);
    N = N| (N>>8);


//as now the number is 2 * x-1, where x is required answer, so adding 1 and dividing it by
 2.
            return (N+1)>>1;

}


     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}




/* Precode Ends */
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);

 ll n,a,f=0;
 cin>>n;
 for(int i=0;i<n;i++)
 {
     cin>>a;
     if(a%2==0)
     {
         if(a%3==0||a%5==0)
         {
             continue;
         }
         else
         {
             f=1;
         }
     }
 }
 if(f==1)
 {
     cout<<"DENIED"<<endl;
 }
 else
 {
     cout<<"APPROVED"<<endl;
 }

return 0;
}



Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author hakamada
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CADDi_2 solver = new CADDi_2();
        solver.solve(1, in, out);
        out.close();
    }

    static class CADDi_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int H = in.nextInt();
            int W = in.nextInt();
            int co = 0;


            for (int i = 0; i < N; i++) {
                boolean Hok = false;
                boolean Wok = false;
                int pH = in.nextInt();
                int pW = in.nextInt();
                if (pH >= H) {
                    Hok = true;
                }
                if (pW >= W) {
                    Wok = true;
                }
                if ((Hok) && (Wok)) {
                    co++;
                }
            }
            out.println(co);
        }

    }
}



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

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define INF (1 << 29)

using namespace std;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	while(1){
		c -= b;

		if(c <= 0){
			cout << "Yes" << endl;
			break;
		}

		a -= d;

		if(a <= 0){
			cout << "No" << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3632
io = STDIN
N,M=io.gets.split.map(&:to_i)
dates=(1..M).to_a
pays= N.times.map{io.gets.split.map(&:to_i)}.
sort{|a,b|(b[1]<=>a[1]).nonzero?||b[0]<=>a[0]}.map do |a,b|
  if ix=dates.bsearch_index{|d|d>=a}
    dates.delete_at(ix)
    b
  else
    0
  end
end
p pays.inject(:+)


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    sort(a.begin(), a.end());
    int flag = 0;
    for(int i = 0; i < n-1; i++){
        if(a.at(i) == a.at(i+1)){
            flag = 1;
            break;
        }
    }
    if(flag == 0){
        cout << "YES";
    } else {
        cout << "NO";
    }
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A,S;
  S=0;
  map<lint,int> m;
  m[0]++;
  lint ans=0;
  REP(i,N){
    cin>>A;
    S+=A;
    ans+=m[S];
    m[S]++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 12800
#include <cstdio>
#include <algorithm>
#include <vector>

typedef long long LL;
const int MN = 100005;

int N, A[MN], deg[MN];
std::vector<int> G[MN];

LL DFS(int u, int p) {
	int cnt = 0;
	LL sum = 0, mxv = 0;
	for (int v : G[u]) if (v != p) {
		LL x = DFS(v, u);
		if (x == -1) return -1;
		++cnt, sum += x, mxv = std::max(mxv, x);
	}
	if (!cnt) return A[u];
	if (A[u] > sum || A[u] < mxv || 2 * A[u] < sum) return -1;
	return 2 * A[u] - sum;
}

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	for (int i = 1, x, y; i < N; ++i) {
		scanf("%d%d", &x, &y);
		G[x].push_back(y);
		G[y].push_back(x);
		++deg[x], ++deg[y];
	}
	if (N == 2) return printf(A[1] == A[2] ? "YES" : "NO"), 0;
	int s = 0;
	for (int i = 1; i <= N; ++i) if (deg[i] > 1) s = i;
	puts(DFS(s, 0) == 0 ? "YES" : "NO");
	return 0;
}

Measured memory_bytes: 16404
N, K = map(int, input().split())
AB = [map(int, input().split()) for _ in range(N)]

l = {}
for a, b in AB:
	if a not in l:
		l[a] = b
	else:
		l[a] += b

k = K
for m in sorted(l):
	k -= l[m]
	if k <= 0:
		print(m)
		break


Measured memory_bytes: 50444
def main():
    H,W,M = map(int,input().split())
    s = []
    h_cnt = [0 for i in range(H)]
    w_cnt = [0 for i in range(W)]
    for i in range(M):
        h,w = map(int,input().split())
        s.append([h-1,w-1])
        h_cnt[h-1] += 1
        w_cnt[w-1] += 1
    h_m,w_m = max(h_cnt), max(w_cnt)
    h_mp,w_mp = [],[]
    for i in range(H):
        if h_cnt[i] == h_m:
            h_mp.append(i)
    for i in range(W):
        if w_cnt[i] == w_m:
            w_mp.append(i)
    f = 0
    for i in range(M):
        if h_cnt[s[i][0]] == h_m and w_cnt[s[i][1]] == w_m:
            f += 1
    if len(w_mp)*len(h_mp)-f<1:
        print(h_m+w_m-1)
    else:
        print(h_m+w_m)

if __name__ == "__main__":
    main()


Measured memory_bytes: 82476
#include <iostream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

template<typename T>
void inputVector(vector<T> * p, int a){
    rep(i, a){
        T input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

int K, A, B;

ll solve() {
    ll ans = 0;
    ll simple = K + 1;
    if (A >= B - 1) return simple; // 換金する意味なし
    
    ans = A;
    int rest = K - A + 1;   // Aにしたときの残K
    if (rest <= 0) return simple;

    ll abroop = rest / 2;
    ans += abroop * (B - A);
    int last = rest - abroop * 2;
    ans += last;
    //printf("%d,%d,%d,%d\n", rest, ans, last, B-A);
    return ans;
}

int main(int argc, const char * argv[]) {
    K = inputValue();
    A = inputValue();
    B = inputValue();
    
    output(solve());
    
    return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<array>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include <tuple>
#include<cmath>
#include<queue>
#include <climits>

using lli = long long int;
using namespace std;
int inf = 1000000007;

int H, W;

int main() {
	cin >> H >> W;
	int wf[10][10];
	for (int i = 0; i < 10; i++)
		for (int j = 0; j < 10; j++)cin >> wf[i][j];
	//WF
	for (int t = 0; t < 10; t++)
		for (int s = 0; s < 10; s++)
			for (int g = 0; g < 10; g++)
				wf[s][g] = min(wf[s][g], wf[s][t] + wf[t][g]);
	int ans = 0;
	for (int i = 0; i < H; i++)
		for (int j = 0; j < W; j++) {
			int c;
			cin >> c;
			if (c == -1)continue;
			ans += wf[c][1];
		}
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <vector>
#include <functional>
#include <queue>
#include <unordered_set>
#include <climits>
#include <set>
#include <list>
#include <cmath>
#include <map>

using namespace std;
typedef long long ll;

int main()
{
	ll N, X, M;
	cin >> N >> X >> M;
	ll sum = 0;
	ll count = 0;
	ll now = X;
	ll next = -1;
	while(count < N && count < M){
		sum += now;
		next = (now * now) % M;
		count++;
		now = next;
	}
	if(count == N){
		cout << sum << endl;
		return 0;
	}
	
	// 
	ll ans = sum;
	N -= count;
	
	sum = 0;
	count = 0;
	X = now;
	next = -1;
	while(count < N && next != X){
		sum += now;
		next = (now * now) % M;
		count++;
		now = next;
	}
	
	ans += sum * (N / count);
	for(int i = 0; i < N % count; i++){
		ans += now;
		now = (now * now) % M;
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 3616
#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() {
  int n;cin >> n;
  vi x(n,0),y(n,0);
  rep(i,n) {
    int a,b;
    cin >> a >> b;
    x.at(i) = a + b;
    y.at(i) = a -b ;
  }
  sort(rrng(x));
  sort(rrng(y));

  cout << max(x.at(0)-x.at(n-1),y.at(0)-y.at(n-1)) << endl;

  return 0;
}


Measured memory_bytes: 4772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
const ll INF = 1e10;

int main() {
    ll n,w; cin >> n >> w;
    ll sw,value; cin >> sw >> value;

    vector<vector<ll>> item(4);
    item[0].push_back(value);

    for (ll i = 0; i < n - 1; i ++)  {
        ll weight,value; cin >> weight >> value;
        item[weight - sw].push_back(value);
    }


    for (ll i = 0; i < 4; i ++) {
        sort(item[i].begin(),item[i].end(),greater<ll>());
        for (ll j = 1; j < item[i].size(); j ++) {
            item[i][j] += item[i][j - 1];
        }
    }
    
    ll ans = 0;
    for (ll i = 0; i < item[0].size() + 1; i ++) {
        for(ll j = 0; j < item[1].size() + 1; j ++) {
            for (ll k = 0; k < item[2].size() + 1; k ++) {
                for (ll l = 0; l < item[3].size() + 1; l ++) {
                    if (sw * i + (sw + 1) * j + (sw + 2) * k + (sw  + 3) * l <= w) {
                        ll tmp = 0;
                        if (i > 0) tmp += item[0][i - 1];
                        if (j > 0) tmp += item[1][j - 1];
                        if (k > 0) tmp += item[2][k - 1];
                        if (l > 0) tmp += item[3][l - 1];
                        ans  = max(ans, tmp);
                    }
                }
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
def main(S):
    if S[0] == 'A' and S[2:(len(S)-1)].count('C') == 1:
       S = S.replace('A', 'a', 1)
       S = S.replace('C', 'c', 1)
       if S == S.lower():
           print("AC")
       else:
           print("WA")
    else:
        print("WA")
       

if __name__ == '__main__':
    S = input()
    main(S)


Measured memory_bytes: 2940
#include <stdio.h>
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
  char suit;
  int value;
};

struct Card L[MAX / 2 + 2], R[MAX / 2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
  
  int i, j, k;
  int n1 = mid - left;
  int n2 = right - mid;
  
  for(i = 0; i < n1; i++) 
    L[i] = A[left + i];
  
  for(i = 0; i < n2; i++) 
    R[i] = A[mid + i];
  
  L[n1].value = R[n2].value = SENTINEL;
  i = j = 0;
  
  for(k = left; k < right; k++) {
    if(L[i].value <= R[j].value) {
      A[k] = L[i++];
    } else {
      A[k] = R[j++];
    }
  }
}

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

int partition(struct Card A[], int n, int p, int r) {
  
  int i, j;
  struct Card t, x;
  
  x = A[r];
  i = p - 1;
  
  for(j = p; j < r; j++) {
    if(A[j].value <= x.value) {
      i++;
      t = A[i];
      A[i] = A[j];
      A[j] = t;
    }
  }
  t = A[i + 1];
  A[i + 1] = A[r];
  A[r] = t;
  
  return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
  
  int q;
  
  if(p < r) {
    q = partition(A, n, p, r);
    quickSort(A, n, p, q - 1);
    quickSort(A, n, q + 1, r);
  }
}

int main(){
  
  int n, i, v;
  struct Card A[MAX], B[MAX];
  char S[10];
  int stable = 1;
  
  scanf("%d", &n);
  
  for(i = 0; i < n; i++) {
    scanf("%s %d", S, &v);
    A[i].suit = B[i].suit = S[0];
    A[i].value = B[i].value = v;
  }
  
  mergeSort(A, n, 0, n);
  quickSort(B, n, 0, n - 1);
  
  for(i = 0; i < n; i++) {
    if(A[i].suit != B[i].suit) 
      stable = 0;
  }
  
  if(stable == 1) printf("Stable\n");
  else printf("Not stable\n");
  
  for(i = 0; i < n; i++) {
    printf("%c %d\n", B[i].suit, B[i].value);
  }
  
  return 0;
}

Measured memory_bytes: 2952
package main

import (
	"fmt"
	"math"
)

func abs(a int) int {
	return int(math.Abs(float64(a)))
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	var n, x, t int
	fmt.Scan(&n, &x)
	cnt := 0
	pos := 0
	last := 0
	for i:=0; i<n+1; i++ {
		cnt += 1
		fmt.Scan(&t)
		pos = last + t
		last = pos
		if pos > x {
			break
		}
	}
	fmt.Println(cnt)
}


Measured memory_bytes: 512
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {
		Scanner scanner = new Scanner(System.in);
		String a = scanner.nextLine();
		String b = scanner.nextLine();

		if(a.length() > b.length()){
			System.out.println("GREATER");
		}else if (a.length() < b.length()) {
			System.out.println("LESS");
		}else if (a.charAt(0) > b.charAt(0)) {
			System.out.println("GREATER");
		}else if (a.charAt(0) < b.charAt(0)) {
			System.out.println("LESS");
		}else {
			System.out.println("EQUAL");
		}
	}
}


Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cstring>
#include<cassert>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<limits>
#include<ctime>
#include<stack>
#include<bits/stdc++.h>
#include<string>
#include<stdlib.h>
#include<stdio.h>

typedef long long ll;
using namespace std;
const ll x=1000000007;
int mod(ll a){
	return a%x;
}
int main(){
	ll n,ans=1;
	cin>>n;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans=mod(ans);
	}
	cout<<ans;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define ALL(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = int(1e9)+10;
const ll INFll = ll(1e18)+10;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;

int main() {
  ll N, K; cin >> N >> K;
  Vll A(N), F(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> F[i];
  sort(ALL(A));

  auto f = [&] (ll x) {
    ll y = 0;
    Vll xF(N);
    rep(i, N) xF[i] = x/F[i];
    sort(ALL(xF));
    rep(i, N) y += max(A[i] - xF[i], 0ll);
    return (y <= K);
  };

  ll ok = ll(2e12) + 5;
  ll ng = -1;
  while (llabs(ok - ng) > 1) {
    ll mid = (ok + ng) / 2;
    if (f(mid)) ok = mid;
    else ng = mid;
  }
  cout << ok << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define forn(i,n) for(int i=0;i<n;i++)
#define fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%lld", &n)
#define sff(a,b) scanf("%lld %lld", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define ll long long int
#define f find
#define ub upper_bound
#define lb lower_bound
#define ld long double
#define in insert
#define bs binary_search  
#define le length()
const ll max_i=1e15;
#define np(s) next_permutation(s.begin(),s.end())
//it gives the lexicographically next string
 ll GCD(ll a,ll b)
    {
        if(b==0)
            return a;
        else return GCD(b,a%b);
    }
int main()
{
  int t=1;
  //cin>>t;
  while(t--)
  {
    string s,t;
    cin>>s>>t;
    int ans=0;
    for(int i=0;i<3;i++)
    {
      if(s[i]==t[i])ans++;
    }
    cout<<ans;
  }
  return 0;
}


Measured memory_bytes: 256
from itertools import accumulate, chain

n, c = map(int, input().split())
xs, vs = zip(*(map(int, input().split()) for _ in range(n)))

ds = [j - i for i, j in zip(chain([0], xs), chain(xs, [c]))]

clockwise = chain([0], (v - d for v, d in zip(accumulate(vs), accumulate(ds))))
anticlockwise2 = [0] + [v - d*2 for v, d in zip(accumulate(vs[::-1]), accumulate(ds[::-1]))]
anticlock_clock = (x + y for x, y in zip(accumulate(clockwise, func=max), reversed(anticlockwise2)))

anticlockwise = chain([0], (v - d for v, d in zip(accumulate(vs[::-1]), accumulate(ds[::-1]))))
clockwise2 = [0] + [v - d*2 for v, d in zip(accumulate(vs), accumulate(ds))]
clock_anticlock = (x + y for x, y in zip(accumulate(anticlockwise, func=max), reversed(clockwise2)))

print(max(chain(anticlock_clock, clock_anticlock)))

Measured memory_bytes: 59224
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;




int main() {
  
   
  
    int n;
    int m;
 
   cin >> n >> m;
  
   int ans = 0;
 
  for(int i=0;i<=n;i++){
    
    for(int j=0;j<=n;j++){
      
      
      int z = m - i - j;
      
   if(0 <= z and z <= n){
      ans = ans + 1;
    }
         
    
     }
    
  }
  

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

Measured memory_bytes: 256
n=int(input())
tree={}
root=None

def insert(tree,number):
    parent=None
    children=root
    while children!=None:
        parent=children
        if number>children:
            children=tree[parent][1]
        else:
            children=tree[parent][0]
    tree[number][2]=parent
    if number>parent:
        tree[parent][1]=number
    else:
        tree[parent][0]=number

def preorder(tree,i):
    if i==None:
        return
    print(" {}".format(i),end="")
    preorder(tree,tree[i][0])
    preorder(tree,tree[i][1])

def inorder(tree,i):
    if i==None:
        return
    inorder(tree,tree[i][0])
    print(" {}".format(i),end="")
    inorder(tree,tree[i][1])

def find(x,number):
    while x!=None and number!=x:
        if x>number:
            x=tree[x][0]
        else:
            x=tree[x][1]
    return x

def find_parent(x,number):
    y=0
    t=-1
    while x!=None and number!=x:
        y=x
        if x>number:
            x=tree[x][0]
            t=0
        else:
            x=tree[x][1]
            t=1
    return y,t

def get_minimum(tree,number):
    while tree[number][0]!=None:
        number=tree[number][0]
    return number    

def delete(tree,number):
    if tree[number][0]==None and tree[number][1]==None:
        y,t=find_parent(root,number)
        tree[y][t]=None
    elif tree[number][0]==None or tree[number][1]==None:
        if tree[number][0]==None:
            next_number=tree[number][1]
        else:
            next_number=tree[number][0]
        y,t=find_parent(root,number)
        tree[y][t]=next_number
    elif tree[number][0]!=None and tree[number][1]!=None:
        next_number=get_minimum(tree,tree[number][1])
        y,t=find_parent(root,number)
        next_y,next_t=find_parent(root,next_number)
        left,right=tree[number][0],tree[number][1]
        if tree[number][1]==next_number:
            right=None
        tree[y][t]=next_number
        tree[next_y][next_t]=None
        tree[next_number]=[left,right]


for i in range(n):
    tmp=list(input().split())
    if tmp[0]=="print":
        inorder(tree,root)
        print()
        preorder(tree,root)
        print()
    else:
        number=int(tmp[1])
        if tmp[0]=="insert":
            if root==None:
                root=number
                tree[number]=[None,None,None]
            else:
                tree[number]=[None,None,None]
                insert(tree,number)
            
        elif tmp[0]=="find":
            if find(root,number) is not None:
                print("yes")
            else:
                print("no")
        
        else:
            delete(tree,number)



Measured memory_bytes: 77956
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int ans = 0;
		int[] answers = {1,2,4,8,16,32,64,125};
		while(n >= answers[ans + 1]) {
			ans++;
		}
		System.out.println(answers[ans]);
	}

}

Measured memory_bytes: 21844
#include <iostream>

int main() {
  int a, b, ans;
  scanf("%d %d", &a, &b);
  if (a > 9 || b > 9) {
    ans = -1;
  }
  else {
	ans = a * b;
  }
  
  printf("%d", ans);
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        switch(n % 10) {
            case 2: case 4: case 5: case 7: case 9:
                System.out.println("hon");
                return;
            case 0: case 1: case 6: case 8:
                System.out.println("pon");
                return;
            case 3:
                System.out.println("bon");
                return;
        }
    }
}


Measured memory_bytes: 35704
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <set>
using namespace std;

int main() {

	int n;
	cin >> n;
	set<string> s;
	int unique_items = 0;

	for (int i = 0; i < n; i++) {
		string temp;
		cin >> temp;
		s.insert(temp);
	}

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

}

Measured memory_bytes: 19048
N = int(input())
S = []
T = []

for i in range(N):
    s, t = input().split()
    t = int(t)
    S.append(s)
    T.append(t)

X = input()
num = None

for i in range(N):
    if X == S[i]:
        num = i + 1
        break

total = sum(T[num:N])

print(total)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
using namespace std;
const int MIN = -1e6, MAX=1e6;
int k, x;
int main() {
    scanf("%d%d", &k, &x);
    int begin = max(x - k + 1, MIN);
    int end = min(x + k - 1, MAX);
    for (int i = begin; i <= end; i++) 
       printf("%d ", i);
}

Measured memory_bytes: 128
#include <stdio.h>

int main() {
  int H , W,i,j;

  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0) {
      break;
    }
    for(j=1; j<=H; j++) {
      for(i=1; i<=W; i++) {
	printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;

}

Measured memory_bytes: 572
n,m = map(int, input().split())
a = [list(map(int, input().split())) for _ in range(m)]
l_max = 0
r_min = 100000000
for i in range(m):
    if (l_max < a[i][0]):
        l_max = a[i][0]
for i in range(m):
    if (r_min > a[i][1]):
        r_min = a[i][1]
print(max(r_min-l_max+1, 0))

Measured memory_bytes: 27336
#include <bits/stdc++.h>
#define enter putchar('\n')
#define space putchar(' ')
#define pii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define MAXN 1000005
#define mo 999999137
#define pb push_back
//#define ivorysi
using namespace std;
typedef long long int64;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
        if(c == '-') f = -1;
        c = getchar();
    }
    while(c >= '0' && c <= '9') {
        res = res * 10 + c - '0';
        c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N,K;
int64 a[100005];
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    read(N);read(K);
    for(int i = 1 ; i <= N ; ++i) {
        read(a[i]);
    }
    int64 ans = 1e16;
    for(int i = 1 ; i <= N - K + 1; ++i) {
        int t = i + K - 1;
        if(1LL * a[i] * a[t] > 0) {
            ans = min(ans,max(abs(a[i]),abs(a[t])));
        }
        else ans = min(ans,min(-2 * a[i] + a[t],2 * a[t] - a[i]));
    }
    out(ans);enter;
    return 0;
}


Measured memory_bytes: 1024
using System;
public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        int cnt = 0;
        
        for(int x = 0;x < N;x++){
            string[] seat = Console.ReadLine().Split(' ');
            int bot = int.Parse(seat[0]);
            int top = int.Parse(seat[1]);
            cnt = cnt + (top - bot + 1);
        }
        
        Console.WriteLine(cnt);
    }
}

Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

    private static boolean isPrime(int x) {
        if (x < 2) {
            return false;
        } else if (x == 2) {
            return true;
        }
        if (x % 2 == 0) {
            return false;
        }
        for (int i = 3; i * i <= x; i += 2) {
            if (x % i == 0) {
                return false;
            }
        }
        return true;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        while (true) {
            if (isPrime(x)) {
                System.out.println(x);
                return;
            }
            x++;
        }
    }

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vll = vector<long long int>;
using vb = vector<bool>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<long long int>>;
using ll = long long int;

int main(){
    ll N; cin >> N;
    vll A(N), B(N); vvll C(N, vll(2));
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
        C[i][0] = A[i] + B[i];
        C[i][1] = i;
    }
    sort(C.begin(),C.end());
    ll t=0, a=0;
    ll k = 0;
    for(int i=N-1; i>=0; i--){
        ll j = C[i][1];
        if(k%2==0){t+=A[j];}
        else{a+=B[j];}
        k++;
    }
    cout << t-a;
}

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

using namespace std;

#define ALL(x) x.begin(), x.end()

typedef long long int lld;
typedef pair<int, int> pii;

const int maxn = 1e5 + 5;

vector<int> mat[maxn];
int dp[maxn], deg[maxn];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(15);
	cout << fixed;

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int s, t;
		cin >> s >> t;
		mat[s].push_back(t);
		deg[t]++;
	}

	queue<int> que;

	for (int i = 1; i <= n; i++) {
		if (deg[i] == 0)
			que.push(i);
	}

	while (!que.empty()) {
		int top = que.front();
		que.pop();

		for (int i : mat[top]) {
			if (dp[i] <= dp[top] + 1) {
				deg[i]--;

				// make sure the path to [i] is the longest --> can push into queue
				if (deg[i] == 0)
					que.push(i);

				dp[i] = dp[top] + 1;
			}
		}
	}

	cout << *max_element(dp, dp + maxn) << endl;



	return 0;
}

Measured memory_bytes: 6528
import numpy as np
N = int(input())
MAX_V = 10001
s = [int(input()) for _ in range(N)]

dp = np.zeros((N+1, MAX_V), np.int)
dp[0, 0] = 1
for i in range(N):
    for j in range(MAX_V):
        if dp[i, j]:
            dp[i+1, j] = 1
            dp[i+1, j + s[i]] = 1

for ans in range(MAX_V-1, -1, -1):
    if dp[N, ans]:
        if ans % 10 or ans == 0:
            print(ans)
            break


Measured memory_bytes: 19820