akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <climits>
#include <map>
#include <set>
const int mod = 1e9 + 7;
const int inf = 1 << 20;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
using namespace std;

int main()
{
    int n;
    cin >> n;
    pair<int,int> r[n];
    for(int i = 0; i < n; i++){
        int x,l;
        cin >> x >> l;
        int s = x - l, e = x + l;
        r[i] = make_pair(e,s);
    }
    sort(r,r+n);
    int ans = 1;
    int left = r[0].first;
    for(int i = 1; i < n; i++){
        if(r[i].second < left){
            continue;
        }else{
            ans++;
            left = r[i].first;
        }
    }
    cout << ans;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a,ll b){if(a>b)a=b;}
void chmax(ll &a,ll b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x,ll y,ll z){if(x)cout<<y<<endl;else cout<<z<<endl;}
void anss(bool x,string y,string z){if(x)cout<<y<<endl;else cout<<z<<endl;}   
ll gcd(ll x,ll y){ll r;while((r=x%y)!=0){x=y;y=r;}return y;}

int main(){
  ll i,j,o;
  ll res=0,res1=0,res2=INF,buf=0,buf1=0,buf2=0,buf3=0,buf4=0,sum=0;
  ll l,r;
  bool judge = true;
  ll n;cin>>n;
  vector<string> s(n);
  for(i=0;i<n;i++)cin>>s[i];
  vector<ll> hash(26,INF);
  vector<ll> hashbuf(26,0);
  for(i=0;i<n;i++){
    fill(ALL(hashbuf),0);
    for(j=0;j<s[i].size();j++){
      hashbuf[s[i][j]-'a']++;
    }
    for(j=0;j<26;j++){
      chmin(hash[j],hashbuf[j]);
    }
  }
  for(i=0;i<26;i++){
    for(j=0;j<hash[i];j++)cout<<char('a'+i);
  }
  cout<<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long GCD(long long a,long long b){
    long long r = a % b;
    while(r > 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}
int main(void){
    long long N,X;
    cin >> N >> X;
    vector<long long> x(N);
    for(int i = 0; i < N; i++) cin >> x[i];
    long long G = abs(X-x[0]);
    for(int i = 0; i < N; i++) G = GCD(max(abs(X-x[i]),G),min(abs(X-x[i]),G));
    cout << G << endl;
}


Measured memory_bytes: 1024
import java.util.*;

public class Main {
    
    Scanner sc = new Scanner(System.in);
    int [] lst = new int[101];
    int n,point=0;String s;
    
    void run(){
        while(sc.hasNext()){
            s=sc.next();
            switch(s.charAt(0)){
                case '+':
                    n=pop();lst[point]+=n;break;
                case '-':
                    n=pop();lst[point]-=n;break;
                case '*':
                    n=pop();lst[point]*=n;break;
                default:
                    n=Integer.parseInt(s);
                    push(n);break;
            }
        }
        System.out.println(lst[point]);
    }
        
    void push(int n){
        point++;lst[point]=n;
    }
    
    int pop(){
        point--;return lst[point+1];
    }
    
    public static void main(String[] args) throws Exception {
        new Main().run();
    }
}


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

int main(){
    int N;
    int count_AC = 0, count_WA = 0, count_TLE = 0, count_RE = 0;
    cin >> N;
    vector<string> S(N);
    for(int i = 0; i < N; i++) cin >> S[i];

    for(int i = 0; i < N; i++){

        if(S[i] == "AC") count_AC++;
        if(S[i] == "WA") count_WA++;
        if(S[i] == "TLE") count_TLE++;
        if(S[i] == "RE") count_RE++;

    }
    cout << "AC" << " x " << count_AC << endl;
    cout << "WA" << " x " << count_WA << endl;
    cout << "TLE" << " x " << count_TLE << endl;
    cout << "RE" << " x " << count_RE << endl;
}


Measured memory_bytes: 6368
#pragma once
#include <stdio.h>
#include <sstream>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <limits>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define bit(x,v) ((ll)x << v)

const ll INF = 1000000007;
const int MAX = 210000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}
int pr[100010];
void uini(int n) {
	for (size_t i = 0; i <= n; i++)
	{
		pr[i] = i;
	}
}

int parent(int x) {
	if (x == pr[x]) return x;
	return pr[x] = parent(pr[x]);
}

bool unit(int x, int y) {
	int px = parent(x);
	int py = parent(y);

	if (px == py) return false;
	if (px < py) {
		pr[py] = px;
	}
	else {
		pr[px] = py;
	}
	return true;
}

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string& S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}
// mod 1000000007 の世界で a += b する関数
void add(long long& a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}
ll slide(vector<ll>& v, ll a, ll b) {
	ll azv = abs(v[0] - a);
	ll bzv = abs(v[0] - b);
	ll aov = abs(v[1] - a);
	ll bov = abs(v[1] - b);
	v[0] = a;
	v[1] = b;
	return max((azv + bov), (bzv + aov));
}


void solv() {

	ll a[200010];
	int n;
	cin >> n;
	ll b[2000010];
	fill(b, b + 200010, 0);
	ll ma = 0;
	for (size_t i = 0; i < n; i++)
	{
		cin >> a[i];
		b[a[i]] = b[a[i] - 1] + 1;
		ma = max(ma, b[a[i]]);
	}
	cout << (n - ma) << endl;

}




int main() {
	//COMinit();
	solv();

	return 0;
}


Measured memory_bytes: 5376
#include <stdio.h>

int binarySearch(int *A, int n, int key ) {
  int left = 0, right = n, mid;
  
  while (left < right) {
    mid = (left + right) / 2;
    if (key == A[mid]) return 1;
    if (key > A[mid]) left = mid + 1;
    else if(key < A[mid]) right = mid;
  }
  return 0;
}

int main () {
  int i, n, q, S[100000], T[50000], m = 0;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", &S[i]);
  scanf("%d", &q);
  for(i = 0; i < q; i++) scanf("%d", &T[i]);

  for(i = 0; i < q; i++) {
    m += binarySearch(S, n, T[i]);
  }

  printf("%d\n", m);
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                           \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
  cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  const int B = 12;
  long long V[412345] = {}, W[412345] = {};
  vector<pair<long long, long long>> pre[1 << B];
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) cin >> V[i + 1] >> W[i + 1];
  for (int v = 1; v < (1 << B); v++) {
    int idx[20];
    int vv = v, size = 0;
    for (int i = 0; vv > 0; vv /= 2, i++) {
      idx[i] = vv;
      size++;
    }
    vector<pair<long long, long long>> vec;
    for (int s = 0; s < (1 << size); s++) {
      long long sumV = 0, sumW = 0;
      for (int i = 0; i < size; i++)
        if ((s >> i) & 1) sumV += V[idx[i]], sumW += W[idx[i]];
      vec.emplace_back(sumW, sumV);
    }
    sort(vec.begin(), vec.end());
    long long cur = -1;
    for (auto p : vec) {
      if (cur < p.second)
        pre[v].emplace_back(p.first, p.second), cur = p.second;
    }
  }
  int Q;
  cin >> Q;
  while (Q--) {
    int v, L;
    cin >> v >> L;
    int idx[20];
    int vv = v, size = 0;
    for (int i = 0; vv >= (1 << B); vv /= 2, i++) {
      idx[i] = vv;
      size++;
    }
    vector<pair<long long, long long>> vec;
    for (int s = 0; s < (1 << size); s++) {
      long long sumV = 0, sumW = 0;
      for (int i = 0; i < size; i++)
        if ((s >> i) & 1) sumV += V[idx[i]], sumW += W[idx[i]];
      vec.emplace_back(sumW, sumV);
    }
    long long ans = -1;
    for (auto p : vec) {
      if (p.first > L) continue;
      int i = upper_bound(pre[vv].begin(), pre[vv].end(),
                          make_pair(L - p.first, LLONG_MAX))
              - pre[vv].begin() - 1;
      ans = max(ans, p.second + pre[vv][i].second);
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 166944
object Main extends App{
	val Array(n,a,b) = scala.io.StdIn.readLine.split(" ").map(_.toInt)
    val s = scala.io.StdIn.readLine
    
    var passed = 0
    var passed_abroad = 0
    for(count <- 1 to n){
        s(count-1) match {
            case 'a' => if(passed < a+b){
                println("Yes")
                passed += 1
                }else println("No")
            case 'b' => if(passed < a+b && passed_abroad < b){
                println("Yes")
                passed += 1
                passed_abroad += 1
                }else println("No")
            case 'c' => println("No")
        }
    }
}


Measured memory_bytes: 37116
#include <iostream>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
int gcd(int a, int b) {
	return (b == 0) ? a : gcd(b, a % b);
}
int main() {
	int n, m; std::cin >> n >> m;
	std::string s, t; std::cin >> s >> t;
	const auto g = gcd(n, m);
	const auto min_s = n / g;
	const auto min_t = m / g;
	bool can_make = true;
	for (auto i = 0; i < g && can_make; ++i) {
		can_make = s[i * min_s] == t[i * min_t];
	}
	if (can_make) std::cout << static_cast<long long int>(n) / g * m << '\n';
	else std::cout << "-1\n";
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define ll long long
using ull = unsigned long long;
using namespace std;
#define dump(x)                             \
    if (dbg) {                              \
        cerr << #x << " = " << (x) << endl; \
    }
#define overload4(_1, _2, _3, _4, name, ...) name
#define FOR1(n) for (ll i = 0; i < (n); ++i)
#define FOR2(i, n) for (ll i = 0; i < (n); ++i)
#define FOR3(i, a, b) for (ll i = (a); i < (b); ++i)
#define FOR4(i, a, b, c) for (ll i = (a); i < (b); i += (c))
#define FOR(...) overload4(__VA_ARGS__, FOR4, FOR3, FOR2, FOR1)(__VA_ARGS__)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define bit(n, k) ((n >> k) & 1) /*nのk bit目*/
namespace mydef {
const int INF = 1ll << 60;
const int MOD = 1e9 + 7;
template <class T>
bool chmin(T& a, const T& b) {
    if (a > b) {
        a = b;
        return 1;
    } else
        return 0;
}
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    } else
        return 0;
}
void Yes(bool flag = true) {
    if (flag)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
void No(bool flag = true) {
    Yes(!flag);
}
void YES(bool flag = true) {
    if (flag)
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}
void NO(bool flag = true) {
    YES(!flag);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T& val) {
    std::fill((T*)array, (T*)(array + N), val);
}
bool dbg = false;
}  // namespace mydef
using namespace mydef;
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(), (v).end()
#define SZ(x) ((int)(x).size())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vp vector<pair<int, int>>
#define vvp vector<vector<pair<int, int>>>
#define pi pair<int, int>
//#define P pair<int, int>
//#define V vector<int>
//#define S set<int>
#define asn ans


void solve() {
}

signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;

    cout << A * B << endl;
    solve();
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())

int n, A[50];

int solve(int i, int m) {
    if (m == 0) {
        return 1;
    }
    else if (i >= n) {
        return 0;
    }
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main() {
    int q, M, i;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &A[i]);
    }
    scanf("%d", &q);
    for (int i = 0; i < q; i++) {
        scanf("%d", &M);
        if (solve(0, M)) {
            printf("yes\n");
        }
        else {
            printf("no\n");
        }
    }
    return 0;
}


Measured memory_bytes: 3128
N = int(input())
A = [int(input()) for i in range(N)]

A.sort()

l,r = A[0],A[0]
cnt = 1
l_cnt = cnt
r_cnt = 1
ans1 = 0
while True:
    ans1 += abs(l-A[-r_cnt])
    l = A[-r_cnt]
    cnt += 1
    r_cnt += 1
    if cnt == N:
        break

    ans1 += abs(r-A[-r_cnt])
    r = A[-r_cnt]
    cnt += 1
    r_cnt += 1    
    if cnt == N:
        break

    ans1 += abs(l-A[l_cnt])
    l = A[l_cnt]
    cnt += 1
    l_cnt += 1
    if cnt == N:
        break

    ans1 += abs(r-A[l_cnt])
    r = A[l_cnt]
    cnt += 1
    l_cnt += 1
    if cnt == N:
        break

l,r = A[-1],A[-1]
cnt = 1
l_cnt = 0
r_cnt = 2
ans2 = 0
while True:
    ans2 += abs(l-A[l_cnt])
    l = A[l_cnt]
    cnt += 1
    l_cnt += 1
    if cnt == N:
        break

    ans2 += abs(r-A[l_cnt])
    r = A[l_cnt]
    cnt += 1
    l_cnt += 1
    if cnt == N:
        break

    ans2 += abs(l-A[-r_cnt])
    l = A[-r_cnt]
    cnt += 1
    r_cnt += 1
    if cnt == N:
        break

    ans2 += abs(r-A[-r_cnt])
    r = A[-r_cnt]
    cnt += 1
    r_cnt += 1    
    if cnt == N:
        break

print(max(ans1,ans2))

Measured memory_bytes: 7524
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;

int main(){

	int n;
	cin >> n;

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

	double p[4];

	for(int i = 0; i < 3; i++){
		long temp = 0;
		for(int j = 0 ;j < n; j++){
			if(x[j] - y[j] > 0){
				temp += pow(x[j] - y[j], i + 1);
			}else{
				temp += pow(y[j] - x[j], i + 1);
			}
//			cout << temp << endl;
		}
		p[i] = pow(temp, 1.000000000 / (i + 1));
	}

	p[3] = 0;
	for(int i = 0; i < n; i++){
		int temp = 0;
		if(x[i] - y[i] > 0){
			temp = x[i] - y[i];
		}else{
			temp = y[i] - x[i];
		}
		if(temp > p[3]) p[3] = temp;
	}

	for(int i = 0; i < 4; i++){
		cout << fixed << p[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 1296
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    ll h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << "\n";
    } else if(h%2 && w%2){
        cout << (h*w)/2+1 << "\n";
    }else {
        cout << (h*w)/2 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
int main() 
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int n;cin>>n;
	float s = 0;
	for (int i = 0; i < n; i++)
	{
		float x;cin>>x;
		string u;cin>>u;
		if(u=="JPY")s+=x;
		else s+=x*380000;
	}
	cout<<s;
}

Measured memory_bytes: 3792
#include <iostream>

using namespace std;

int main() {
    long long n, a, b;
    cin >> n >> a >> b;

    if (a == b) {
        cout << 1 << endl;
    } else if (a > b) {
        cout << 0 << endl;
    } else if (n == 1) cout << 0 << endl;
    else if (n == 2) cout << 1 << endl;
    else {
        cout << (n - 2) * (b - a) + 1 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <unistd.h>
#include <algorithm>
#include <functional>

char ibuf[4000000];
char *ibufe = ibuf-1;

void readall(){
  int k, t = 0;
  while((k=read(STDIN_FILENO, ibuf+t, sizeof(ibuf)-t))>0) t += k;
}

int read_uint(){
  int x=0;
  while(*(++ibufe) <'0');
  do {
    x *= 10;
    x += *ibufe-'0';
  } while(*(++ibufe) >='0');

  return x;
}

int n;
int S[1<<18];
int Q[19];

int main(){
  readall();
  n = read_uint();
  for(int i=0;i<(1<<n);i++) S[i] = read_uint();
  std::sort(S, S+(1<<n), std::greater<int>());
  int k = 0;
  for(int i=0;i<(1<<n);){
    int j = i;
    for(i++; S[i] == S[j]; i++) ;
    S[k++] = i-j;
  }
  Q[n] = 1;
  for(int i=0;i<k;i++){
    int l;
    int a=0;
    for(l=n;l>=0 && a < S[i];l--){
      int x = Q[l];
      Q[l] = a;
      a += x;
    }
    if(a<S[i]){
      write(STDOUT_FILENO, "No\n", 3);
      return 0;
    }
    l++;
    Q[l] += a-S[i];
    for(int t=0;t<l;t++) Q[t] += S[i];
  }
  write(STDOUT_FILENO, "Yes\n", 4);
  return 0;
}


Measured memory_bytes: 4224
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
const int dy8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dx8[] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T, typename U> inline bool chmax(T &a, U b) { return a < b ? (a = b, true) : false; }
template <typename T, typename U> inline bool chmin(T &a, U b) { return a > b ? (a = b, true) : false; }
struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

template <typename Abelian>
struct BIT0based {
  BIT0based(int n, const Abelian UNITY = 0) : n(n), UNITY(UNITY), dat(n, UNITY) {}

  void add(int idx, Abelian val) {
    while (idx < n) {
      dat[idx] += val;
      idx |= idx + 1;
    }
  }

  Abelian sum(int idx) {
    Abelian res = UNITY;
    --idx;
    while (idx >= 0) {
      res += dat[idx];
      idx = (idx & (idx + 1)) - 1;
    }
    return res;
  }

  Abelian sum(int left, int right) {
    if (right <= left) return UNITY;
    return sum(right) - sum(left);
  }

  Abelian operator[](const int idx) { return sum(idx, idx + 1); }

  int lower_bound(Abelian val) {
    if (val <= UNITY) return 0;
    int res = 0, exponent = 1;
    while (exponent <= n) exponent <<= 1;
    for (int mask = exponent >> 1; mask > 0; mask >>= 1) {
      if (res + mask - 1 < n && dat[res + mask - 1] < val) {
        val -= dat[res + mask - 1];
        res += mask;
      }
    }
    return res;
  }

private:
  int n;
  const Abelian UNITY;
  vector<Abelian> dat;
};

int main() {
  int n; cin >> n;
  ll pat = 1LL * n * (n + 1) / 2;
  vector<int> a(n); REP(i, n) cin >> a[i];
  int lb = 0, ub = 1000000000;
  while (ub - lb > 1) {
    int mid = (lb + ub) >> 1;
    vector<int> b(n);
    REP(i, n) b[i] = a[i] <= mid ? 1 : -1;
    BIT0based<int> bit(n * 2 + 1);
    int now = n;
    REP(i, n) {
      now += b[i];
      bit.add(now, 1);
    }
    now = n;
    ll cnt = 0;
    REP(i, n) {
      cnt += bit.sum(now + 1, n * 2 + 1);
      now += b[i];
      bit.add(now, -1);
    }
    // cout << mid << ' ' << cnt << '\n';
    (cnt <= pat / 2 ? lb : ub) = mid;
  }
  cout << ub << '\n';
  return 0;
}


Measured memory_bytes: 1808
#include<stdio.h>

static const int N = 501;
static const int INFTY = (1<<21);

int main(){
  int M[N][N];
  int n,m,k,l; 
  int i,j;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    for(j=0;j<n;j++)M[i][j]=0;
  }
  
  for(i=0;i<n;i++){
    scanf("%d %d",&m,&k);
    m--;
    for(j=0;j<k;j++){
      scanf("%d",&l);
      l--;
      M[m][l]=1;
    }
  }
  
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }
  return 0;
}



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

int main() {
   cin.tie(0);
   ios_base::sync_with_stdio(false);
   int n;
   cin >> n;
   vector<int> a(n);
   for (int i=1;i<=n;++i){
       cin >> a[i];
   }
   int cnt=0;
   for (int i=1;i<n+1;++i){
       if ((i*a[i])%2==1){
           cnt++;
       }
   }
   cout << cnt << endl;
   return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<double> v(N);
	for (int i = 0; i < N; i++)cin >> v.at(i);
	for (int i = 0; i < N - 1; i++) {
		sort(v.begin(), v.end());
		v.push_back((v.at(0) + v.at(1)) / 2);
		v.erase(v.begin(),v.begin()+2);
	}
	cout << v.at(0) << endl;
	return 0;
}

Measured memory_bytes: 3832
void main()
{
    long n = readln.chomp.to!long;

    long[26] cnts;
    cnts[] = 1L << 30;
    foreach (i; 0 .. n)
    {
        string s = readln.chomp;
        foreach (x; lowercase)
        {
            cnts[x-'a'] = min(cnts[x-'a'], s.count(x));
        }
    }

    string result;
    foreach (i, x; cnts)
    {
        if (x) result ~= (i + 'a').to!dchar.repeat(x).to!string;
    }

    result.writeln;
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.container;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int N;
	int O;
	int Z;
	scanf("%d", &N);
	if(N%2!=0){
		printf("%d",N/2+1);
	}
	else if(N%2==0){
		printf("%d",N/2);
	}
return 0;
}

Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
int main()
{
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll ans = 0;
    rp(i, 0, n - 2)
    {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
S = str(input())
N = len(S) + 1
A = [0] * N
for i in range(N-1):
    if S[i] == "<":
        A[i+1] = max(A[i]+1, A[i+1])

for i in range(N-2, -1, -1):
    if S[i] == ">":
        A[i] = max(A[i], A[i+1]+1)

print(sum(A))

Measured memory_bytes: 23348
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());
            string ans = "";
            switch (D)
            {
                case 22:ans = "Christmas Eve Eve Eve";break;
                case 23:ans = "Christmas Eve Eve";break;
                case 24:
                    ans = "Christmas Eve"; break;
                default:
                    ans = "Christmas";
                    break;
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
N,K=map(int,input().split())
ans=0
H=[0]*N
for i in range(N):
    X = i+1
    while X:
        if X<K:
            X*=2
            H[i]+=1
        else:
            X=0
for i in range(N):
    ans += 1/(N*2**H[i])
print(ans)


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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int dif = A - B;
		if (dif%2 == 0) {
			System.out.println(Math.abs(A - dif/2));
		} else {
			System.out.println("IMPOSSIBLE");
		}
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

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

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

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

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

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

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define ub upper_bound
#define lb lower_bound
#define all(v) ((v).begin()),((v).end())
#define allr(v) ((v).rbegin()),((v).rend())
#define ff first
#define ss second
#define mp make_pair
#define pll pair<ll,ll> 
#define fo(i,n) for(ll i=0;i<n;i++)
#define foa(i,s,e) for(ll i=(s);i<e;i++)
#define fod(i,s,e) for(ll i= (s);i>=(e);i--)
#define max3(a,b,c) max(max(a,b),c)
#define min3(a,b,c) min(min(a,b),c)
#define deb(x) cerr<<#x<<' '<<'='<<' '<<x<<'\n'
#define sz(x) (ll)(x.size())
const ld pi = 3.14159265358979323846;
//ll MOD = 1e9 + 7;
ll MOD = 998244353;
const char nl = '\n';
const ll inf = 1e15;
ll mul(ll x,ll y){
    return (1ll* (x%MOD)*(y%MOD));
}
ll modpow(ll x,ll y){ll z=1;while(y>0){if(y%2)z=mul(z,x);x =mul(x,x) ;y/=2;}return z;}
ll power(ll x,ll y){ll z=1;while(y>0){if(y%2)z=z*x;x =x*x ;y/=2;}return z;}
ll gcd(ll a,ll b){if(a<b) return gcd(b,a);if(b==0) return a;return gcd(b,a%b);} 
ll min(ll a,ll b){if(a<b)return a;return b;}
ll max(ll a,ll b){if(a>b)return a;return b;}
ll sq(ll a){
    ll ans = (1ll*a*a);
    return ans;
}
void solve(){
    char c;
    cin>>c;
    if(c<='Z' && c>='A')cout<<'A'<<nl;
    else cout<<'a'<<nl;
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("inputf.txt" , "r" , stdin) ;
    freopen("outputf.txt" , "w" , stdout) ;
    freopen("error.txt" , "w" , stderr) ;
    #endif
    ll t = 1;
    //cin>>t;
    while(t--){
        solve();
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";


}


Measured memory_bytes: 3800
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let k: i32 = sc.read();
    let a: i32 = sc.read();
    let b: i32 = sc.read();
    let min_k = (a + k - 1) / k * k;
    let ans = if min_k <= b { "OK" } else { "NG" };
    println!("{}", ans);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}

Measured memory_bytes: 2132
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n,k;
    cin>>n>>k;
    int arr[n];
    for(int i=0;i<n;i++)
    cin>>arr[i];
    sort(arr,arr+n);
    int sum=0;
    for(int i=0;i<k;i++)
    sum+=arr[i];
    cout<<sum;
}


Measured memory_bytes: 3572
#pragma region template
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
inline bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
inline bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll h, a;
  cin >> h >> a;
  print((h+a-1)/a);
}


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

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

typedef long long ll;
typedef long double ld;

const int INF = 1e9;
const ld EPS = 1e-8;

int solve(const vector<string> &a) {
  int N = a.size();

  bool flag = true;
  REP(i,N)REP(j,N) if(a[i][j] == '#') flag = false;
  if(flag) return -1;

  int c = 0;
  REP(i,N) {
    bool tmp = false;
    REP(j,N) if(a[j][i] == '.') tmp = true;
    c += tmp;
  }

  int res = INF;
  REP(i,N) {
    int w = 0;
    REP(j,N) if(a[i][j] == '.') ++w;
    bool b = false;
    REP(j,N) if(a[j][i] == '#') b = true;
    res = min(res, c + w + 1 - b);
  }
  return res;
}

int main(){
  int N;
  cin >> N;
  vector<string> a(N);
  REP(i,N) cin >> a[i];

  cout << solve(a) << endl;
  return 0;
}



Measured memory_bytes: 512
n = gets.to_i
a = gets.split.map(&:to_i).sort
a_max = a[-1]
b = Array.new(a_max + 1, true)
for i in 0...(n - 1) do
  next if b[a[i]] == false
  v = a[i] * 2
  while v <= a_max do
    b[v] = false
    v += a[i]
  end
  b[a[i]] = false if a[i] == a[i + 1]
end
count = 0
a.each do |v|
  count += 1 if b[v] == true
end
puts count


Measured memory_bytes: 38156
import java.io.*;
public class Main {
	
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		
		while(true){
			String[] str = br.readLine().split(" ");
			int H = Integer.parseInt(str[0]);
			int W = Integer.parseInt(str[1]);
			if(H==0 && W==0)break;
			/*System.out.print("\n");
		
			for(int i=0; i<W; i++){
				System.out.print("#");
			}
			System.out.print("\n");
			for(int j=0; j<H-2; j++){

				System.out.print("#");
				for(int i=0; i<W-2; i++){
					System.out.print(".");
				}
				System.out.print("#");
				System.out.print("\n");
			}
			
			for(int i=0; i<W; i++){
				System.out.print("#");
			}
			System.out.print("\n"); */
			
			for(int i=0; i<H; i++){
				for(int j=0;j<W; j++){
					if(i==0 || j==0 || i==H-1 ||j==W-1){
						System.out.print("#");
					}else{
						System.out.print(".");
					}
				}
				System.out.print("\n");
			}
			System.out.print("\n");
		}	
	}

}

Measured memory_bytes: 35220
N, M = map(int, input().split(" "))

L_max = 0
R_min = N
for i in range(M):
    L, R = map(int, input().split(" "))

    if L_max < L:
        L_max = L
    if R_min > R:
        R_min = R

if R_min < L_max:
    print(0)
else:
    print(R_min - L_max + 1)


Measured memory_bytes: 3060
import java.io.*;

public class Main {

	/**
	 * @param args
	 * @throws IOException 
	 */
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String input = br.readLine();
			String[] size = input.split(" ");
			Integer height = Integer.parseInt(size[0]);
			Integer width = Integer.parseInt(size[1]);
			if(height == 0 && width == 0){
				break;
			}
			for(int i=1; i <= height; i++){
				for(int j=1; j <= width; j++){
					System.out.print("#");
				}
				System.out.print("\n");
			}
			System.out.println("");
		}

	}

}

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;

struct UnionFind{
    vector<int> data;
    //data[i] = -x ... iが根であり、サイズがx
    //data[i] = x ... iの親がx

    //最初は全員根
    UnionFind(int size): data(size,-1){}

    bool union_set(int x, int y){//サイズがx>yになるようにしてから、xにyをつなげる
        x=root(x);
        y=root(y);
        if(x != y){
            if(data[y] < data[x]) swap(x,y);
            data[x] += data[y];
            data[y] = x;
        }
        return x != y;
    }
    bool find_set(int x, int y){//ルートが一致するかどうかを返す
        return root(x) == root(y);
    }
    int root(int x){//根を見つける。ついでに深さ2にしちゃう
        return data[x]<0 ? x : data[x]=root(data[x]);
    }
    int size(int x){
        return -data[root(x)];
    }
};

struct Edge{
    int s,t,cost;
    bool operator<(const Edge &o) const{
        return cost < o.cost;
    }
};

struct Graph{
    int n;
    vector<Edge> es;

    int kruskal(){
        sort(ALL(es));

        UnionFind uf(n);
        int min_cost = 0;
        REP(i,es.size()){
            Edge e = es[i];
            if(!uf.find_set(e.s, e.t)){//辺を追加しても閉路ができなければ採用
                min_cost += e.cost;
                uf.union_set(e.s, e.t);
            }
        }

        return min_cost;
    }
};


int main() {
    int V,E;
    cin >> V >> E;
    Graph g;
    g.n = V;

    REP(i,E){
        Edge e;
        cin >> e.s >> e.t >> e.cost;
        g.es.push_back(e);
    }

    cout << g.kruskal() << endl;
    return 0;
}


Measured memory_bytes: 4544
def main():
    N = int(input())
    num_list = [int(i) for i in input().split()]
    order_list = [0 for i in range(N)]

    for index,num in enumerate(num_list):
        order_list[num-1] = index+1
    
    print(" ".join(map(str,order_list)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 18368
//-------------------------------------------
//-               Train Fare                -
//-                                         -
//-       autumn_eel niha katemasen!        -
//-------------------------------------------

#include<iostream>
#include<functional>
#include<queue>
#include<deque>
#include<vector>
#include<algorithm>
using namespace std;

inline void reader(int *x) {
	int k = getchar_unlocked(); *x = k - '0';
	while (true) {
		k = getchar_unlocked();
		if (k < '0') break;
		*x = ((*x) << 1) + ((*x) << 3) + k - '0';
	}
}
inline void writeln(int x) {
	int s = 0, p; char f[7];
	while (x) {
		p = x; x /= 10;
		f[s++] = p - (x << 1) - (x << 3);
	}
	if (!s) f[s++] = 0;
	while (s--) putchar_unlocked(f[s] + '0');
	putchar_unlocked('\n');
}
#pragma warning(disable:4996)
int n, m, q, a[200003], b[200003], c[200003], d[200003], e[100003], f[100003], g[100003];
int h1[100003], h2[100003], h3[100003], h4[100003], dist[100003], E[200003];
vector<pair<int, int> > z[100003]; vector<int> x[100003];
vector<int>D[100003];
int Q1[110000], Q1L, Q1R;
int main() {
	reader(&n); reader(&m); reader(&q);
	fill(d, d + m + 1, 1 << 30);
	for (int i = 1; i <= m; i++) { reader(&a[i]), reader(&b[i]); f[a[i]]++; f[b[i]]++; }
	for (int i = 1; i <= q; i++) reader(&c[i]), d[c[i]] = i;
	for (int i = 1; i <= n; i++) { x[i].resize(f[i]); }
	for (int i = 1; i <= m; i++) {
		x[a[i]][g[a[i]]] = b[i]; g[a[i]]++;
		x[b[i]][g[b[i]]] = a[i]; g[b[i]]++;
	}
	fill(dist, dist + n + 1, -1); dist[1] = 0;
	Q1[0] = 1; Q1R = 1;
	while (Q1R > Q1L) {
		int a1 = Q1[Q1L]; Q1L++;
		for (int i : x[a1]) {
			if (dist[i] == -1) {
				dist[i] = dist[a1] + 1;
				Q1[Q1R] = i; Q1R++;
			}
		}
	}
	int rn = 0;
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) h1[a[i]]++;
		if (dist[b[i]] > dist[a[i]]) h1[b[i]]++;
	}
	for (int i = 1; i <= n; i++)z[i].resize(h1[i]);
	for (int i = 1; i <= m; i++) {
		if (dist[a[i]] > dist[b[i]]) { z[a[i]][h2[a[i]]] = make_pair(b[i], d[i]); h2[a[i]]++; }
		if (dist[b[i]] > dist[a[i]]) { z[b[i]][h2[b[i]]] = make_pair(a[i], d[i]); h2[b[i]]++; }
	}
	for (int i = 1; i <= n; i++) { h3[dist[i]]++; rn = max(rn, dist[i]); }
	for (int i = 0; i <= rn; i++) D[i].resize(h3[i]);
	for (int i = 1; i <= n; i++) D[dist[i]][h4[dist[i]]] = i, h4[dist[i]]++;
	e[1] = (1 << 30);
	for (int i = 1; i <= rn; i++) {
		for (int j : D[i]) {
			for (pair<int, int>k : z[j]) {
				e[j] = max(e[j], min(e[k.first], k.second));
			}
		}
	}
	for (int i = 2; i <= n; i++) {
		if (e[i] < 300000) E[e[i]]++;
	}
	for (int i = 1; i <= q; i++) {
		E[i] += E[i - 1];
		writeln(E[i]);
	}
	return 0;
}

Measured memory_bytes: 24968
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a, b;
    cin >> a >> b;
    int sa = a.size(), sb = b.size();
    if(sa < sb) cout << "LESS" << endl;
    else if(sa > sb) cout << "GREATER" << endl;
    else{
        rep(i,sa){
            if(a[i] == b[i]) continue;
            if(a[i] < b[i]){
                cout << "LESS" << endl;
                return 0;
            }
            if(a[i] > b[i]){
                cout << "GREATER" << endl;
                return 0;
            }
        }
        cout << "EQUAL" << endl;
    }
    return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>
void maxChainOrder(int);
int min(int, int);
int A[101][101], p[101];
int main() {
    int j, i, n, v;
    scanf("%d", &n);
    for (i = 0; i < n - 1; i++) {
        scanf("%d", &p[i]);
        scanf("%d", &v);
    }
    scanf("%d", &p[n - 1]);
    scanf("%d", &p[n]);
    maxChainOrder(n);
            printf("%d\n", A[1][n]);
    return 0;
}
void maxChainOrder(int n) {
    int i, j, k, a, c;  //最初の段
    for (i = 1; i <= n; i++) {
        A[i][i] = 0;
    }
    //二番目以降
    for (a = 2; a <= n; a++) {

        for (i = 1; i <= n-a+1; i++) {
            j = a + i - 1;
            A[i][j] = 200000001;
            for (k = i; k <= j - 1; k++) {
                //小さいほうをAに代入
                c = A[i][k] + A[k + 1][j] + p[i - 1] * p[k] * p[j];
                A[i][j] = min(c, A[i][j]);
            }
        }
    }
}
int min(int x, int y) {
    if (x < y) {
        return x;
    }
    else {
        return y;
    }
}


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

// Returns floor of square root of x
int floorSqrt(int x)
{
    // Base cases
    if (x == 0 || x == 1)
    return x;

    // Staring from 1, try all numbers until
    // i*i is greater than or equal to x.
    int i = 1, result = 1;
    while (result <= x)
    {
      i++;
      result = i * i;
    }
    return (i - 1)*(i-1);
}

// Driver program
int main()
{
    int x ;
    cin>>x;
    cout << floorSqrt(x) << endl;
    return 0;
}


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

int n,k,a[100009],dp[1<<20],rui[100009][20],cnt[20],sum[1<<20];

int main(){
  cin>>n>>k;
  r(i,n){
    cin>>a[i]; a[i]--;
    cnt[a[i]]++;
    rui[i][a[i]]++;
  }
  r(i,n-1){
    r(j,k) rui[i+1][j]+=rui[i][j];
  }
  r(i,1<<20)dp[i]=1e9;
  r(i,1<<20){
    r(j,20){
      if(i&(1<<j))sum[i]+=cnt[j];
    }
  }
  dp[0]=0;
  for(int i=0;i<(1<<k);i++){
    for(int j=0;j<k;j++){
      if(i&(1<<j))continue;
      dp[i|(1<<j)]=min(dp[i|(1<<j)],dp[i]+cnt[j]-(rui[sum[i|(1<<j)]-1][j]- (i==0?0:rui[sum[i]-1][j]) ));
    }
  }
  cout<<dp[(1<<k)-1]<<endl;
}


Measured memory_bytes: 19436
#include <iostream>
using namespace std;
int main()
{
  int x,ans;
  cin>>x;
  bool bb;
  for(int i=x; ;i++){
    bb=true;
    for(int j=2;j<i;j++){
      if(i%j==0){bb=false; break;}
    }
    if(bb==true){ans=i; break;}
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>

std::string solve(int a, const std::string& s)
{
  return a >=3200 ? s : "red";
}

int main()
{
  int a;
  std::string s;
  std::cin >> a >> s;

  std::cout << solve(a, s) << std::endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys, math, itertools, collections, bisect
input = lambda: sys.stdin.buffer.readline().rstrip().decode('utf-8')
inf = float('inf') ;mod = 10**9+7
mans = inf ;ans = 0 ;count = 0 ;pro = 1

n=int(input())
A=[list(map(int,input().split())) for i in range(n)]
now=[0]*n
rest=n*(n-1)//2
for i in range(n):
    for j in range(n-1):
        A[i][j]=A[i][j]-1

S={i for i in range(n)}
tmp=set()
while rest and S:
    used=[0]*n  
    # print(now)
    count+=1
    for si in S:
        if n-1<=now[si]:
            continue
        ene=A[si][now[si]]
        if n-1<=now[ene]:
            continue
        if A[ene][now[ene]] == si and not(used[si] or used[ene]):
            rest-=1
            now[si]+=1; now[ene]+=1
            used[si]=used[ene]=1
            tmp.add(si); tmp.add(ene)
    S=tmp.copy(); tmp=set()
for ni in now:
    if ni != n-1:
        print(-1)
        break
else:
    print(count)





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

ll mod=998244353;

int expo(int base,int exponent){
    int ans=1;
    while(exponent!=0){
        if(exponent&1) ans=(1LL*ans*base)%mod;
        base=(1LL*base*base)%mod;
        exponent>>=1;
    }
    return ans%mod;
}

bool palin(string s)
{
    ll i,j;
    i=0;j=s.length()-1;
    while(j>=i)
    {
        if(s[i]!=s[j]) return false;
        i++;j--;
    }
    return true;
}


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

    int tests=1,asn=0;
   //scanf("%d",&tests);
   //cin>>tests;
    while(tests--)
    {
     ll n,i;
     string s;
     cin>>s;
     n=s.length();
     if(!palin(s)) {cout<<"No";return 0;}
     if(!palin(s.substr(0,(n-1)/2))) {cout<<"No";return 0;}
     if(!palin(s.substr((n-1)/2 +1,(n-1)/2))) {cout<<"No";return 0;}
     cout<<"Yes";

    }
    //cout<<asn;
    return 0;
}

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

using namespace std;

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

const double pi = 3.14159265358979323846;

#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll N;
  cin >> N;

  map< string, ll > m;

  string S;
  ll c = 0;
  for (ll i = 0; i < N; i++) {
    cin >> S;

    if (m.find(S) == m.end()) {
      m[S] = 1;
    } else {
      m[S]++;
    }

    c = max(c, m[S]);
  }

  for (auto a : m) {
    if (a.second == c) {
      cout << a.first << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 25216
# -*- coding: utf-8 -*-
from bisect import bisect_left
from sys import stdin



readl = stdin.readline

## input
N,Q = map(int, readl().rstrip().split())
STX = [list(map(int, readl().rstrip().split())) for _ in range(N)]
Dn = [None for _ in range(Q+1)]
for i in range(Q):
  Dn[i] = int(readl().rstrip())
Dn[Q] = 10**10
ans = [-1] * (Q+1)
skip = [-1] * (Q+1)

for s,t,x in sorted(STX,key=lambda x:x[2]):
  l = bisect_left(Dn,s-x)
  r = bisect_left(Dn,t-x)
  while l < r:
    if skip[l] < 0:
      ans[l] = x
      skip[l] = r
      l += 1
    else:
      l = skip[l]

for d in ans[:-1]:
  print(d)

Measured memory_bytes: 75764
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int arr[n], arr2[n];
    for(int i=0; i<n; i++)
    {
        scanf("%d", arr+i);
        arr2[i]=arr[i];
    }
    sort(arr2, arr2+n);
    for(int i=0; i<n; i++)
    {
        if(arr[i]!=arr2[n-1])
            printf("%d\n", arr2[n-1]);
        else
            printf("%d\n", arr2[n-2]);
    }
    return 0;
}


Measured memory_bytes: 3200
import fractions
from sys import stdin
N = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
l_gcd = [0] * (len(data) + 1)
r_gcd = [0] * (len(data) + 1)
for ind,(i,j) in enumerate(zip(data,reversed(data))):
    l_gcd[ind + 1] = fractions.gcd(l_gcd[ind],i)
    r_gcd[ind + 1] = fractions.gcd(r_gcd[ind],j)
r_gcd = list(reversed(r_gcd))
ans = 0
for k in range(N):
    ans = max(fractions.gcd(l_gcd[k],r_gcd[k+1]),ans)
print(ans)

Measured memory_bytes: 16072