akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define maxn 100020
#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) (x&(-x))
#define inf 0x3f3f3f3f
typedef long long ll;
typedef pair<int,int> pr;

const ll mod = 1e9 + 7;
struct node{
	int x,y;
	bool operator < (node a)const{
		return x == a.x ? y > a.y : x < a.x;
	}
}dt[maxn];
int x[maxn],y[maxn],n,m,tot,a[maxn * 2],cnt;
ll sum[maxn * 2],f[maxn],ans;

void init(){
	rep(i,1,n){
		int it = lower_bound(y + 1,y + m + 1,x[i]) - y;
		if ( x[i] == y[it] || it == 1 || it > m ) continue;
		dt[++tot] = (node){x[i] - y[it - 1],y[it] - x[i]};
		a[++cnt] = dt[tot].x , a[++cnt] = dt[tot].y;
	}
	sort(a + 1,a + cnt + 1);
	rep(i,1,tot){
		dt[i].x = lower_bound(a + 1,a + cnt + 1,dt[i].x) - a;
		dt[i].y = lower_bound(a + 1,a + cnt + 1,dt[i].y) - a;
	}
	sort(dt + 1,dt + tot + 1);
}
inline void modify(int x,ll d){
	for (register int i = x ; i <= cnt ; i += lowbit(i)) sum[i] = (sum[i] + d) % mod;
}
inline ll query(int x){
	ll res = 0;
	for (register int i = x ; i ; i -= lowbit(i)) res = res + sum[i];
	return res % mod;
}
void solve(){
	ans = 1;
	rep(i,1,tot){
		if ( dt[i].x == dt[i - 1].x && dt[i].y == dt[i - 1].y ) continue;
		f[i] = query(dt[i].y - 1) + 1;
		modify(dt[i].y,f[i]);
		ans = (ans + f[i]) % mod;
	}
	cout<<ans<<endl;
}
int main(){
	scanf("%d %d",&n,&m);
	rep(i,1,n) scanf("%d",&x[i]);
	rep(i,1,m) scanf("%d",&y[i]);
	init();
	solve();
}


Measured memory_bytes: 4992
#include <stdio.h>
int main(void){
    int n;
    int a, b, flag = 0;
    scanf("%d", &n);
    scanf("%d %d", &a, &b);
    for(int i = 0; i*n <= b; i++){
        if(a <= i*n) flag = 1;
    }
    if(flag == 1) printf("OK");
    else printf("NG");
    return 0;
}


Measured memory_bytes: 1736
//大文字->小文字 tolower(),逆はtoupper()
//int a = stoi(c); 文字列をintへ
//途中の出力をそのまま残さない
//数値計算 個数以外はdouble
//map<キー,値> p は辞書。p[キー] = 値
//map 全探索
//auto begin = p.begin(), end = p.end();
//for (auto it = begin; it != end; it++) {}
//mapのキー：it->first mapのバリュー：it->second
//絶対値 abs()
//入力は空白で切れる
//大文字判定 isupper(文字) 小文字判定 islower(文字)
//do{}while(next_permutation(ALL(配列)))
//while(N)で回すとき、Nはコピーを作っておく
//小文字に対応する文字コード：S[i] - 'a'
//文字コード→小文字：(char)(数字+'a')
//グラフの距離:隣接行列で扱う
//等価なものに変換する思考
//bool型　初期値はTrue
//島渡りの問題：中間ノードに着目
//配列はvector<>を使う：意味わからないエラーがなくなる。
//背反な事象にちゃんとわける
#include <bits/stdc++.h>
#define rep(i,N) for(int i = 0; i < N;i++)
#define ALL(a) (a).begin(),(a).end()
#define ll long long int
using namespace std;

// K進数でのNの桁数
ll dig(ll N, ll K) {
	ll dig = 0;
	while (N) {
		dig++;
		N /= K;
	}
	return dig;
}
// a,bの最大公約数
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

//nC2の計算
ll C(ll N) {
	return N * (N - 1) / 2;
}

//円周率
const double PI = 3.14159265358979323846;

int main() {
	ll N; cin >> N;
	vector<ll> H(N); rep(i, N)cin >> H[i];

	for (int i = N-1; i >= 1; i--) {
		if (H[i - 1] - H[i] >= 2) {
			cout << "No" << endl;
			return 0;
		}
		else if (H[i - 1] - H[i] == 1)H[i - 1]--;
	}

	cout << "Yes" << endl;
}

Measured memory_bytes: 1152
#include<stdio.h>
void bubbleSort(int*, int);

int main(){
    
    int S[100];
    int i, j, s, t;
    
    scanf("%d",&s);
    for(i=0 ; i<s ; i++){
        scanf("%d",&S[i]);
    }
    
    bubbleSort(S, s);
    
    return 0;
}

void bubbleSort(int *A,int b){
    int i,j;
    int flag = 1,cont=0;
    
    while(flag){
        flag = 0;
        for(i=b-1 ; i>=1 ; i--){
            if(A[i]<A[i-1]){
                j = A[i];
                A[i] = A[i-1];
                A[i-1] = j;
                flag = 1;
                cont++;
            }
        }
    }
    
    for(i=0 ; i<b ; i++){
        if(i==b-1){
            printf("%d\n", A[i]);
        }else{
            printf("%d ", A[i]);
        }
    }
    printf("%d\n",cont);
}


Measured memory_bytes: 2712
import com.sun.security.jgss.GSSUtil;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {
    public static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static FastReader r=new FastReader();
    public static final int INF=1000000005;

    public static class BIT{
        int n=0;
        long []a=new long[0];
        public BIT(int n){
            this.n=n;
            this.a=new long[n+1];
        }
        public void update(int pos,long val){
            for(int i=pos;i<=n;i+=(i&-i)){
                this.a[i]+=val;
            }
        }
        public long getSum(int pos){
//            if(pos==-1) return 0;
            long ans=0;
            for(int i=pos;i>0;i-=(i&-i)){
                ans+=this.a[i];
            }
            return ans;
        }
        public long sum(int left,int right){
            return getSum(right)-getSum(left);
        }
    }

    public static void main(String[] args) {
        int n=r.nextInt();
        int q=r.nextInt();
        BIT fen=new BIT(n);
        for(int i=1;i<=n;++i){
            fen.update(i,r.nextLong());
        }
        for(int i=0;i<q;++i){
            int t=r.nextInt();
            int left=r.nextInt();
            int right=r.nextInt();
            if(t==0){
                fen.update(left+1,right);
            }
            else{
                System.out.println(fen.sum(left,right));
            }
        }
    }
}


Measured memory_bytes: 80700
/*author: hyperion_1724
  date: 
*/

//Optional FAST

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,fma,abm,mmx,avx,avx2,tune=native")

//Required Libraries

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

//Required namespaces

using namespace std;
using namespace __gnu_pbds;

//Required defines

#define endl '\n'

#define READ(X) cin>>X;
#define READV(X) long long X; cin>>X;
#define READAR(A,N) long long A[N]; for(long long i=0;i<N;i++) {cin>>A[i];}
#define rz(A,N) A.resize(N);
#define sz(X) (long long)(X.size())
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define trav(x,A) for(auto &x:A)
#define FORI(a,b,c) for(long long a=b;a<c;a++)
#define FORD(a,b,c) for(long long a=b;a>c;a--)

//Required typedefs

typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef tree<long long,null_type,greater<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set1;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef vector<int> veci;
typedef vector<long long> vecl;

//Required Constants

const long long inf=(long long)1e18;
const long long MOD=(long long)(1e9+7);
const long long INIT=(long long)(1e6+1);

//Required Functions

ll power(ll x,ll y) 
{ 
    if (y == 0) 
        return 1; 
    ll p = power(x, y/2) % MOD; 
    p = (p * p) % MOD; 
  
    return (y%2 == 0)? p : (x * p) % MOD; 
}
ll modInverse(ll a) 
{ 
   return power(a,MOD-2); 
   
}

//Work

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

    READV(N);
    READV(A);
    READV(B);
    vector<vector<ll>> ADJ(N+1);
    FORI(i,0,N-1)
    {
        READV(u);
        READV(v);
        ADJ[u].pb(v);
        ADJ[v].pb(u);
    }
    vector<ll> visit1(N+1,-1);
    deque<ll> bfs;
    bfs.pb(A);
    visit1[A]=0;
    while (sz(bfs)>0)
    {
        ll u=bfs.front();
        bfs.pop_front();
        for(auto v:ADJ[u])
        {
            if (visit1[v]==-1)
            {
                visit1[v]=visit1[u]+1;
                bfs.pb(v);
            }
        }
    }
    vector<ll> visit2(N+1,-1);
    bfs.pb(B);
    visit2[B]=0;
    while (sz(bfs)>0)
    {
        ll u=bfs.front();
        bfs.pop_front();
        for(auto v:ADJ[u])
        {
            if (visit2[v]==-1)
            {
                visit2[v]=visit2[u]+1;
                bfs.pb(v);
            }
        }
    }
    ll ans=inf;
    FORI(i,1,N+1)
    {
        if (visit2[i]==visit1[i])
        {
            ans=min(ans,visit2[i]);
        }
    }    
    if (ans==inf)
    {
        ans=0;
    }
    FORI(i,1,N+1)
    {
        if (visit2[i]>visit1[i] && sz(ADJ[i])==1)
        {
            ans=max(visit2[ADJ[i][0]],ans);
        }
        else if (visit2[i]>visit1[i] && (visit2[i]-visit1[i])%2==0)
        {
            ans=max(ans,visit2[i]);
        }                
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 8064
#include <iostream>
#include <cmath>
using namespace std;


int N;
int W[110];
int main(){
    cin >> N;
    for(int i=1;i<=N;i++) cin >> W[i];
    int ans = 1e9;
    for(int i=1;i<N;i++){
        int s1 = 0,s2 = 0;
        for(int j=1;j<=N;j++){
            if(j<=i) s1 += W[j];
            else s2 += W[j];
        }
        ans = min(ans,abs(s1-s2));
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
// Sasageyo! Sasageyo! Shinzou wo Sasageyo !
// https://goo.gl/IwJzbx

#include<bits/stdc++.h>

using namespace std;

typedef pair<int,int> II;
typedef vector<II> VII;
typedef vector<int> VI;
typedef vector< VI > VVI;

typedef long long int LL;

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(a) (int)(a.size())
#define ALL(a) a.begin(),a.end()
#define SET(a,b) memset(a,b,sizeof(a))
#define si(n) scanf("%d",&n)
#define dout(n) printf("%d\n",n)
#define sll(n) scanf("%lld",&n)
#define lldout(n) printf("%lld\n",n)

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

#define endl '\n'
LL dp[60][60];
LL ncr(LL n, LL r) {
  if(r==0 || r==n || n==0)
    return 1;
  if(dp[n][r])
    return dp[n][r];
  return dp[n][r] = ncr(n-1, r-1) + ncr(n-1,r);
}
int main()
{
	fast_io;
  LL n, oc, ec, p;
  oc = ec = 0;
  cin >> n >> p;
  for(int i=0;i<n;i++) {
    int a;
    cin >> a;
    if(a%2)
      oc++;
    else
      ec++;
  }
  LL ans = 1LL<<ec;
  LL a2 = 0;
  for(int i=p;i<=oc;i+=2)
    a2 += ncr(oc, i);
  cout << ans*a2 << endl;
	return 0;
}

Measured memory_bytes: 256
'use strict';
process.stdin.on('data', function(chunk) {
    var inputs = chunk.toString().trim();
    var expressions = inputs.split('\n');
  
    for (var i = 0; i < expressions.length; i++) {
        if (expressions[i] === '0 ? 0') {
            break;
        }
        var expression = expressions[i].split(' ');
        var left = parseFloat(expression[0]);
        var right = parseFloat(expression[2]);
        var op = expression[1];
  
        switch (op) {
            case '+':
                console.log(left + right);
                break;
            case '-':
                console.log(left - right);
                break;
            case '*':
                console.log(left * right);
                break;
            case '/':
                console.log(Math.floor(left / right));
                break;
        }
  
    }
  
});
process.stdin.resume();
process.stdin.setEncoding('utf8');

Measured memory_bytes: 15964
S = list(input())
Q = int(input())
front = []
back = []
ifZyun = True

for _ in range(Q):
    query = input()
    if query == "1":
        ifZyun = not ifZyun
    else:
        query = list(query)
        F = query[2]
        C = query[4]
        if (F == "1" and ifZyun) or (F == "2" and not ifZyun):
            front.append(C)
        else:
            back.append(C)

if not ifZyun:
    S = S[::-1]
    print("".join(back[::-1] + S + front))
else:
    front = front[::-1]
    print("".join(front + S + back))


Measured memory_bytes: 9984
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <map>
using namespace std;

template<class Abel> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<Abel> diff_weight;

	UnionFind(int n = 1, Abel SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, Abel SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	Abel weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, Abel w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	Abel diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
    int N;
    while (cin >> N) {
        if (N == 0) break;
        bool ok = true;
        UnionFind<int> uf(200); // 単位個数は最悪で 200 個
        map<string,int> str2id; // 単位 -> id の対応
        int final_id = 0;
        for (int i = 0; i < N; ++i) {
            string ichi, unit1, equal, val, unit2;
            cin >> ichi >> unit1 >> equal >> val >> unit2;
        
            // 1個目の単位の番号
            if (!str2id.count(unit1)) {
                str2id[unit1] = final_id++;
            }
            int id1 = str2id[unit1];
        
            // 2個目の単位の番号
            if (!str2id.count(unit2)) {
                str2id[unit2] = final_id++;
            }
            int id2 = str2id[unit2];
        
            // 単位換算
            stringstream si(val.substr(3));
            int diff;
            si >> diff; // "1 kilometre = 10^3 metre" の 3 の部分を取得
        
            // 重み付き Union-Find 木の処理
            if (uf.issame(id1, id2)) {
                int curdiff = uf.diff(id1, id2);
                if (diff != curdiff) ok = false;
            }
            else {
                uf.merge(id1, id2, diff);
            }
        }
        
        if (ok) puts("Yes");
        else puts("No");
	}
}


Measured memory_bytes: 3032
#include <stdio.h>
int main(){
    int S, s = 0, m = 0,h = 0;
    scanf("%d",&S);
    if(S >= 60){
        m = S / 60;
        s = S % 60;
    }else{
        s = S;
    }
    if(m >= 60){
        h = m / 60;
        m = m % 60;
    }
    printf("%d:%d:%d\n", h, m, s);
    return 0;
}

Measured memory_bytes: 1852
#include <stdio.h>

int main(){
    int a,b,c;
    int i,ans=0;
    scanf("%d%d%d",&a,&b,&c);
    for(i=a;i<=b;i++){
        if(c%i==0){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <iostream>
using namespace std;

int main()
{
    int n;
    cin >> n;
    int A[n];
    
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }
    
    for (int i = n-1; i > 0; i--) {
        cout << A[i] << " ";
    }
    cout << A[0] << endl;
    
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 1 << 19, MOD = 924844033;
LL modpow(LL a, int b) {
	LL res = 1;
	for (; b; b >>= 1) {
		if (b & 1) res = res * a % MOD;
		a = a * a % MOD;
	}
	return res;
}

void ntt(LL *a, int n, int inv) {
	for (int i = 1, j = n >> 1; i < n; i++) {
		if (i < j) swap(a[i], a[j]);
		for (int k = n >> 1; (j ^= k) < k; k >>= 1);
	}
	for (int h = 2; h <= n; h <<= 1) {
		int hh = h >> 1, wn = modpow(5, inv ? MOD - 1 - (MOD - 1) / h : (MOD - 1) / h);
		for (int i = 0; i < n; i += h) {
			LL w = 1;
			for (int j = i; j < i + hh; j++) {
				LL x = a[j], y = a[j + hh] * w % MOD;
				a[j] = (x + y) % MOD;
				a[j + hh] = (x - y + MOD) % MOD;
				w = w * wn % MOD;
			}
		}
	}
	if (inv) {
		LL mul = modpow(n, MOD - 2);
		for (int i = 0; i < n; i++) a[i] = a[i] * mul % MOD;
	}
}

LL A[MAXN], B[MAXN], fac[MAXN], inv[MAXN];
int cnt[MAXN], sz[MAXN], n;
vector<int> gra[MAXN];

void dfs(int u, int fa) {
	sz[u] = 1;
	for (int v : gra[u]) if (v != fa) {
		dfs(v, u);
		sz[u] += sz[v];
		++cnt[sz[v]];
	}
	++cnt[n - sz[u]];
}

int main() {
	scanf("%d", &n);
	for (int i = 1; i < n; i++) {
		int u, v; scanf("%d%d", &u, &v);
		gra[u].push_back(v), gra[v].push_back(u);
	}
	for (int i = fac[0] = 1; i <= n; i++) fac[i] = fac[i - 1] * i % MOD;
	inv[n] = modpow(fac[n], MOD - 2);
	for (int i = n; i > 0; i--) inv[i - 1] = inv[i] * i % MOD;
	dfs(1, 0);
	for (int i = 0; i < n; i++) {
		A[i] = (LL)cnt[n - i] * fac[n - i] % MOD;
		B[i] = inv[i];
	}
	int m = 1;
	for (; m < n + n - 1; m <<= 1);
	ntt(A, m, 0), ntt(B, m, 0);
	for (int i = 0; i < m; i++) A[i] = A[i] * B[i] % MOD;
	ntt(A, m, 1);
	for (int i = 1; i <= n; i++)
		printf("%lld\n", (n * fac[n] % MOD * inv[n - i] - A[n - i] + MOD) % MOD * inv[i] % MOD);
	return 0;
}

Measured memory_bytes: 47744
#include<cstdio>
#define mo 1000000007
int f[18][1<<16],n,m,ans,a[17],fac[1<<16],inv[1<<16];
int C(int n,int m){if(n<m)return 0;return 1ll*fac[n]*inv[m]%mo*inv[n-m]%mo;}
void add(int&a,int b){a+=b;if(a>=mo)a-=mo;}
void dec(int&a,int b){a-=b;if(a<0)a+=mo;}
int ksm(int a,int p)
{int ans=1;for(;p;p>>=1,a=a*1ll*a%mo)if(p&1)ans=1ll*ans*a%mo;return ans;}
int main()
{
	scanf("%d%d",&n,&m);f[m+1][0]=1;fac[0]=inv[0]=1;
	for(int i=1;i<1<<n;i++)fac[i]=fac[i-1]*1ll*i%mo;
	inv[(1<<n)-1]=ksm(fac[(1<<n)-1],mo-2);
	for(int i=(1<<n)-2;i;i--)inv[i]=1ll*inv[i+1]*(i+1)%mo;
	for(int i=1;i<=m;i++)scanf("%d",&a[i]);
	for(int i=m;i;i--)
	 for(int st=0;st<1<<n;st++)if(f[i+1][st])
	 {
	 	add(f[i][st],f[i+1][st]);
		int tmp=(1<<n)-a[i]-st;if(tmp<0)continue;
	 	for(int j=0;j<n;j++)if(!(st&(1<<j)))
	 	 dec(f[i][st|(1<<j)],f[i+1][st]*1ll*C(tmp,(1<<j)-1)%mo*fac[(1<<j)]%mo);
	 }
	for(int i=0;i<1<<n;i++)
	 add(ans,f[1][i]*1ll*fac[(1<<n)-1-i]%mo);
	printf("%d\n",ans*1ll*(1<<n)%mo);
}

Measured memory_bytes: 4224
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N = int(readline())
X = np.array(readline().split(),np.int64)
L = int(readline())
Q = int(readline())
AB = np.array(read().split(),np.int64).reshape(-1,2)

AB -= 1
AB.sort(axis = 1)
A = AB[:,0]; B = AB[:,1]

# 2^n 日あれば、どこまでいけるのか

U = 20
dp = [np.full(N,N-1,np.int64) for _ in range(U)]

dp[0] = np.searchsorted(X, X + L, side = 'right') - 1

for n in range(1,U):
    dp[n] = dp[n-1][dp[n-1]]

days = np.ones(Q,np.int64)
for n in reversed(range(U)):
    x = dp[n][A]
    bl = x < B
    days[bl] += (1 << n)
    A[bl] = x[bl]
print('\n'.join(map(str,days)))

Measured memory_bytes: 39380
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int n,m,x,a[101]={0};    cin>>n>>m>>x;
    for(int i=0;i<m;i++){
        int tmp;cin>>tmp;
        a[tmp]++;
    }
    int c0=0,cn=0;
    for(int i=1;i<x;i++)c0+=a[i];
    for(int i=x+1;i<=n;i++)cn+=a[i];
    cout<<min(c0,cn)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll ans = 0;
	ll N, M, Q;
	std::cin >> N >> M >> Q;

	vll a(Q), b(Q), c(Q), d(Q);
	vll p(Q + 1, 0);
	rep(i, 0, Q) {
		std::cin >> a[i] >> b[i] >> c[i] >> d[i];
		p[Q] += d[i];
	}
	rep(i, 0, Q) {
		p[i] = p[Q] - d[i];
		p[Q] = p[i];
	}


	vll A(N + 1, 1);
	while (A[0] ==1) {

		bool flg = true;
		ll idx = N;
		while (idx>=0) {
			if (A[idx] == M) {

				ll j = 1;
				ll n = 0;
				while (idx > j) {
					if (idx == j) {
						flg = false;
						break;
					}
					else if (A[idx - j] != M) {
						n = A[idx - j];
						break;
					}
					j++;
				}

				A[idx] = n + 1;
				idx--;
			}
			else {
				A[idx]++;
				break;
			}
		}
		if (A[0] == 1) {
			rep(i, 1, N) {
				if (A[i] > A[i + 1]) {
					flg = false;
				}
			}
			if (flg) {
				ll tmp = 0;
				rep(i, 0, Q) {
					if (A[b[i]] - A[a[i]] == c[i]) {
						tmp += d[i];
					}
					if (tmp + p[i] < ans) {
						break;
					}
				}
				ans = max(ans, tmp);
			}
		}
		if (idx < 0) {
			A[0]++;
		}
	}


	std::cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3572
#入力数を入力し、0だったら入力を終わる
while True:
    num = int(input())
    if num == 0:break

    #入力をし、空リスト作成
    line = sorted(list(map(int,input().split())))
    kotae = []
    
    #差を求め、差が一番小さい値を出力する
    for i in range(0,num - 1):
        num1 = abs(line[i] - line[i + 1])
        kotae.append(num1)
    print(min(kotae))


Measured memory_bytes: 5640
def max(a,b); a > b ? a : b;end
N,T = gets.split.map(&:to_i)
F = N.times.map{ gets.split.map(&:to_i) }.sort

dp = Array.new(6010, 0)
F.each do |a,b|
  (0 ... T).reverse_each do |t|
    dp[t + a] = max(dp[t + a], dp[t] + b)
  end
end
puts dp.max

Measured memory_bytes: 41464
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return a ? gcd(b%a, a) : b; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
vector<ll> divisor(ll n){
  vector<ll> res;
  for(ll i=1; i*i<=n ; i++){
    while(n%i==0){
      ++res[i];
      n /= i;
    }
  }
  if(n!=1) res[n]=1;
  return res;
}
bool isPrime(ll N){
  for(ll i=2 ; i*i<=N ; i++){
      if(N%i==0){
          return false;
      }
  }
  return true;
}
int main(){
  ll N, A, B;   cin>>N>>A>>B;
  ll ans = 0;
  if((B-A)%2==1){
    ans = B-(B-A+1)/2;
    A = N-A+1;    B=N-B+1;
    chmin(ans, A-(A-B+1)/2);
  }else{
    ll mid = (A+B)/2;
    ans = B - mid;
  }
  cout<<ans<<endl;
  return 0;
}   

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

using namespace std;

int N, ap[109], a[109];
vector < int > ans;

int main ()
{
//freopen ("input", "r", stdin);
//freopen ("output", "w", stdout);

scanf ("%d", &N);
for (int i=1; i<=N; i++)
    scanf ("%d", &a[i]);
for (int step = 1; step <= N; step ++)
{
    int pos = N - step + 1;
    for (int i=N; i>=1; i--)
        if (ap[i] == 0 && pos == a[i])
        {
            ap[i] = 1;
            ans.push_back (pos);
            break;
        }
        else pos -= (ap[i] == 0);
    if (pos == 0)
    {
        printf ("-1\n");
        return 0;
    }
}
reverse (ans.begin (), ans.end ());
for (auto it : ans)
    printf ("%d\n", it);
return 0;
}


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

int arr[10];

bool check(int num) {
    while(num) {
        if(arr[num%10])
            return false;
        num/=10;
    }
    return true;
}

int main()
{
    int n,k;
    int x;
    scanf("%d%d",&n,&k);
    for(int i = 0; i < k; i++) {
        scanf("%d",&x);
        arr[x] = 1;
    }
    while(!check(n)) {
        n++;
    }
    printf("%d",n);
    return 0;
}


Measured memory_bytes: 256
s = gets.chomp

st = 0
i = 0
while i <= s.length-1
  if s[i] == "A"
    start = i
    break
  end
  i += 1
end

fin = 0
i = 0
while i <= s.length-1
  if s[-1-i] == "Z"
    fin = i
    break
  end
  i += 1
end

puts s.length - start - fin

Measured memory_bytes: 2172
void main() {
    string s = readln.chomp;

    long ind;
    long cnt;
    long op;
    while (ind < s.length)
    {
        if (s[ind] == 'A')
        {
            ++cnt;
        }
        else
        {
            if (ind < s.length - 1 &&s[ind] == 'B' && s[ind+1] == 'C')
            {
                op += cnt;
                ++ind;
            }
            else
            {
                cnt = 0;
            }
        }

        ++ind;
    }

    op.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: 2684
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = Integer.parseInt(in.nextLine());
        final long[] arr = new long[n];
        for (int i = 0; i < n; i++) {
            arr[i] = in.nextLong();
        }
        Arrays.sort(arr);
        int idx = n - 1;
        int count = n - 2;
        long res = arr[idx--];
        while (count >= 2) {
            res += 2 * arr[idx--];
            count -= 2;
        }
        if (count == 1) {
            res += arr[idx];
        }
        System.out.println(res);
    }
}


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

## 全探索
for i in range(1,1010,1):
  ans_8 = int(i * 0.08)
  if A == ans_8:
    ans_10 = int(i * 0.10)    
    if B == ans_10:
      print(i)
      exit()
else:
  print('-1')



Measured memory_bytes: 2940
import java.util.Scanner;

public class Main {

	public static void main(String args[]){

		Scanner cin = new Scanner(System.in);

		int A = cin.nextInt();
		int B = cin.nextInt();
		int C = cin.nextInt();
		int a,b,c;
		int count = 0;
		int limit = (int)Math.pow(10, 8);

		for(int i=0;i<limit;i++){
			if(A%2==0&&B%2==0&&C%2==0){
				a=B/2+C/2;
				b=A/2+C/2;
				c=A/2+B/2;
				A=a;
				B=b;
				C=c;
				count++;
			}else{
				break;
			}
		}

		if(count<limit){
			System.out.println(count);
		}else{
			System.out.println("-1");
		}

	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
int a[200010];
int main()
{
    int n, x;
    scanf("%d", &n);

    for (int i = 2; i <= n; i++)
    {
        scanf("%d", &x);
        a[x]++;
    }
    for (int i = 1; i <= n; i++)
    {
        printf("%d\n", a[i]);
    }
}

Measured memory_bytes: 4540
#include <iostream>
using namespace std;

char tolower(char ch) {
  if ('A' <= ch && ch <= 'Z') return ch - 'A' + 'a';
  else return ch;
}

int main() {
  string W; cin >> W;
  string str;
  int cnt = 0;
  while (cin >> str && str != "END_OF_TEXT") {
    for (int i = 0; i < str.size(); i++) str[i] = tolower(str[i]);
    cnt += str == W;
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 3140
#include <stdio.h>

typedef struct rect{
	int w;
	int h;
	int d;  /* 対角線の長さの 2 乗 */
} Rect;

void set(Rect *r, int w, int h){
	r->w = w;
	r->h = h;
	r->d = w * w + h * h;
}

/* 横長整長方形の大きさを比較する (-1: a が小さい, 0:等しい, 1: a が大きい) */
int compare(Rect a, Rect b){
	/* 対角線の長さが短いほうが小さい */
	if (a.d < b.d){
		return -1;
	}else if (a.d > b.d){
		return 1;
	}

	/* 高さの低いほうが小さい */
	if (a.h < b.h){
		return -1;
	}else if (a.h > b.h){
		return 1;
	}

	return 0;
}

int main(void){
	Rect min;  /* 与えられた横長整長方形 */
	Rect r;
	Rect max;
	int w, h, i, j;
	int c;

	while(scanf("%d %d", &h, &w) == 2){
		if (w == 0 && h == 0){
			break;
		}

		set(&min, w, h);
		set(&max, 150, 150);

		/* 与えられた横長整長方形より大きい最小の横長整長方形を総当たりで求める */
		for (i = 2; i <= 150; i++){
			for (j = 1; j < i; j++){
				set(&r, i, j);

				/* 与えられた横長整長方形より大きいか */
				c = compare(r, min);
				if (c <= 0){
					continue;
				}

				/* 条件を満たす横長整長方形の中で最小か */
				c = compare(r, max);
				if (c < 0){
					max = r;
				}
				break;
			}
		}

		/* 出力 */
		printf("%d %d\n", max.h, max.w);
	}

    return 0;
}

Measured memory_bytes: 600
(defun judge-bust (a1 a2 a3)
  (>= (+ a1 a2 a3) 22))

(defun main ()
  (let* ((a1 (read))
	 (a2 (read))
	 (a3 (read)))
    (format t "~a~%"
	    (if (judge-bust a1 a2 a3) "bust" "win"))))

(main)

Measured memory_bytes: 12256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) ((a) <= (x) && (x) < (b))
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589
 
 
#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[8] = { //移動
	{ 0 ,1 },{ -1 ,0 },{ 1 ,0 },{ 0 ,-1 },
	{ 1 ,1 },{ 1 ,-1 },{ -1 ,1 },{ -1 ,-1 }
};
 
//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define INF 10000000000000000LL
 
struct Edge {
	ll from, to;
	ll w;
};
typedef vector<vector<Edge>> Graph;
 
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll m, ll n)
{
	return m * n / gcd(m, n);
}


int main(){
  int n;
  cin >> n;
  Graph g(n);
  vector<ll> a(n),b(n);
  REP(i,n-1){
    int u,v;
    cin >> u >> v;
    u--,v--;
    g[u].push_back({u,v});
    g[v].push_back({v,u});
  }
  REP(i,n){
    scanf("%lld", &a[i]);
  }
  REP(i,n){
    scanf("%lld", &b[i]);
  }

  vector<ll> bsum(n), dist(n);

  function<int(int,int)> dfs1 = [&](int par, int cur){
    ll sum = b[cur] - a[cur];
    for(auto& itr : g[cur]){
      if(itr.to == par) continue;
      ll csum = dfs1(cur, itr.to);
      sum += csum;

      itr.w = -csum;
    }

    return bsum[cur] = sum;
  };  

  dfs1(0,0);
  
  function<void(int,int, ll)> dfs2 = [&](int par, int cur, ll oya){
    dist[cur] = oya;
    for(auto& itr : g[cur]){
      if(itr.to == par) continue;
      dfs2(cur, itr.to, oya + itr.w);
    }
  };  

  dfs2(0,0,0);

  ll distsum = 0, Min = 0;
  REP(i,n){
    distsum += dist[i];
    Min = min(Min, dist[i]);
  }

  distsum += (-Min) * n;

  cout << distsum << endl;

  // function<void(int,int,int)> dfs2 = [&](int par, int cur, int oya){
  //   int sum = oya + 1;
  //   for(auto itr : g[cur]){
  //     if(itr.to == par) continue;
  //     sum += bsum[itr.to];
  //   }

  //   for(auto& itr : g[cur]){
  //     if(itr.to == par) continue;



  //     int nexOya = oya - bsum[itr.to];
  //     dfs2(cur, itr.to, nexOya);
  //   }


  // };

}


Measured memory_bytes: 23692
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) {return (n==0)?1:10*TEN(n-1);}

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    ModInt operator-(const ModInt &r) const {return make(normS(v+MD-r.v));}
    ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};

using Mint = ModInt<924844033>;

const int MN = 2020;
vector<int> g[2*MN];
bool used[2*MN];

int dfs(int p) {
    if (used[p]) return 0;
    used[p] = true;
    int ans = 1;
    for (int d: g[p]) {
        ans += dfs(d);
    }
    return ans;
}

Mint calc(int d, int u) {
    if (u == 0) return 1;
    if (d < u) return 0;
    static Mint dp[MN][MN];
    static bool used[MN][MN];
    if (used[d][u]) return dp[d][u];
    used[d][u] = true;
    return dp[d][u] = calc(d-1, u) + calc(d-2, u-1);
}

Mint fact[MN];
void first() {
    fact[0] = 1;
    for (int i = 1; i < MN; i++) {
        fact[i] = fact[i-1]*i;
    }
}
int main() {
    first();
    int n, k;
    cin >> n >> k;
    for (int l = 0; l < n; l++) {
        for (int r = 0; r < n; r++) {
            if (abs(l-r) == k) {
                g[l].push_back(r+n);
                g[r+n].push_back(l);
            }
        }
    }
    vector<int> v;
    int vsm = 0;
    for (int i = 0; i < 2*n; i++) {
        if (used[i]) continue;
        v.push_back(dfs(i)-1);
        vsm += v.back();
    }

    Mint sm[MN];
    sm[0] = 1;
    for (int d: v) {
        for (int i = n; i >= 0; i--) {
            for (int j = 1; j <= d; j++) {
                if (i-j < 0) continue;
                sm[i] += sm[i-j]*calc(d, j);                
            }
        }
    }

    Mint ans = 0;
    for (int i = 0; i <= n; i++) {
        if (i % 2 == 0) {
            ans += sm[i]*fact[n-i];
        } else {
            ans -= sm[i]*fact[n-i];
        }
    }
    cout << ans.v << endl;
    return 0;
}


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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
ll mod = 1000000007;

int main() {
source:
    double r;
    cin >> r;
    double ans = r * 2 * 3.141592;
    printf("%.10f\n", ans);
    return 0;
}



Measured memory_bytes: 3788
x,y=map(int,input().split())
i=0
if x==3:
  i+=100000
elif x==2:
  i+=200000
elif x==1:
  i+=300000
if y==3:
  i+=100000
elif y==2:
  i+=200000
elif y==1:
  i+=300000
if i==600000:
  i+=400000
print(i)

Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(1000000)

while(1):
    w, h = map(int, input().split())
    if w == 0 and h == 0:
        break
    else:
        maps = [[-1]*(w+2)] + [([-1] + list(map(int, input().split())) + [-1]) for _ in range(h)] + [[-1]*(w+2)]
        seen = [[True]*(w+2)] + [([True] + [False]*w + [True]) for _ in range(h)] + [[True]*(w+2)]
        dxy = ((-1, -1), (-1, 0), (-1, 1), (0, -1), (0, 1), (1, -1), (1, 0), (1, 1))
        
        
        def dfs(y, x):
            seen[y][x] = True
            for i in dxy:
                if seen[y+i[0]][x+i[1]] is False:
                    if maps[y+i[0]][x+i[1]] == 0:
                        seen[y+i[0]][x+i[1]] = True
                    else:
                        dfs(y+i[0], x+i[1])
        
        now = 0
        ans = 0
        while now < w * h:
            y = now // w + 1
            x = now % w + 1
            if seen[y][x] is False:
                if maps[y][x] == 0:
                    seen[y][x] = True
                else:
                    ans += 1
                    dfs(y, x)
            
            now += 1
        
        print(ans)



Measured memory_bytes: 7980
n = int(input())
capa = [int(input()) for _ in range(5)]
for i in range(0,4):
    if capa[i] < capa[i + 1]:
        capa[i + 1] = capa[i]
ans = 4 + n // capa[4] + (0 if n % capa[4] == 0 else 1)
print(ans)

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

typedef long double ld;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30

int main()
{
	string s;
	cin >> s;
	if(s[0] == s[1] || s[1] == s[2] || s[2] == s[3] )
		cout << "Bad" << endl;
	else
		cout << "Good" << endl;
	return 0;
}


Measured memory_bytes: 256
/*
g++ -std=c++11 -o2 -Wall ABC103D.cpp -o ./out/ABC103D.out
./out/ABC103D.out
*/

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

typedef long long ll;
typedef ll Int;

vector<pair<int, int>> links;

constexpr Int N = 2 << 16;

Int tree[2 * N];

auto query = [&N, &tree](int a, int b) -> Int {
    a += N;
    b += N;
    Int s = 0;
    while (a <= b) {
        if (a % 2 == 1) {
            s += tree[a++];
        }
        if (b % 2 == 0) {
            s += tree[b--];
        }
        a /= 2;
        b /= 2;
    }
    return s;
};

auto update = [&N, &tree](int k, int x) -> void {
    k += N;
    tree[k] += x;
    for (k /= 2; k >= 1; k /= 2) {
        tree[k] = tree[2 * k] + tree[2 * k + 1];
    }
};

int main(){
//  freopen("./input/input.txt", "r", stdin);
  ios::sync_with_stdio(0);
  cin.tie(0);
  fill(tree, tree + 2 * N, 0LL);
  int n, m;
  cin >> n >> m;
  int a, b;
  for (int i = 0; i < m; ++i) {
    cin >> a >> b;
    links.push_back({b, a});
  }
  int ans = 0;
  sort(begin(links), end(links));
  for (int i = 0; i < m; ++i) {
    ll s = links[i].second;
    ll t = links[i].first;
    ll w = query(s, t);
    if (w == 0) {
      ++ans;
      update(t - 1, 1);
    }
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3448
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

typedef long long ll;
ll MOD = 1e9 + 7;
ll dp[100010][13];

int main(void)
{
    string s;
    cin >> s;
    int n = s.length();
    dp[0][0] = 1;

    REP(i, n)
    {
        int c;
        if (s[i] == '?')
        {
            c = -1;
        }
        else
        {
            c = s[i] - '0';
        }

        if (c == -1)
        {
            REP(j, 10)
            {
                REP(k, 13)
                {
                    int next = (j + k * 10) % 13;
                    dp[i + 1][next] += dp[i][k];
                }
            }
        }
        else
        {
            REP(j, 13)
            {
                int next = (c + 10 * j) % 13;
                dp[i + 1][next] = dp[i][j];
            }
        }
        REP(j, 13)
        {
            dp[i + 1][j] %= MOD;
        }
    }
    cout << dp[n][5] << endl;
}

Measured memory_bytes: 10624
#include <bits/stdc++.h>
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rrepi(i,a,b) for(int i=((int)(b)-1);i>=(a);--i)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) rrepi(i,0,n)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define ZERO(x) memset(x,0,sizeof(x))
#define MINUS(x) memset(x,-1,sizeof(x))
#define UNIQUE(x) (x).erase(unique(ALL(x)), (x).end())
#define debug(var)  do{std::cout << #var << " : "; view(var);}while(0)
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int,int>;
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){for(const auto& v : vv){ view(v); } }
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void viewarr(T arr[], int n) { for(int i = 0; i < n; ++i) std::cout << arr[i] << " "; std::cout << std::endl; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll qp(ll a,ll b){ll ans=1;do{if(b&1)ans=1ll*ans*a;a=1ll*a*a;}while(b>>=1);return ans;}
ll qp(ll a,ll b,ll mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const int INF = 1e9;
const ll INFL = 1e18;
const int MOD = 1e9 + 7;
const int MAX_N = 1e5;

int main() {
    int N;
    cin >> N;
    cout << (N+1)/2 << endl;
    return 0;
}


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

int main() {
	int N; cin >> N;
	int A[100010];
	for(int i=0; i<N; ++i) cin >> A[i];
	int ki=0;
	for(int i=0; i<N; ++i) if(A[i]%2) ++ki;
	if(ki%2) cout << "NO" << endl;
	else cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 640
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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);

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll sum = 0;
    int right = 0;
    ll rel = 0;
    for(int left = 0; left < n; left++) {
        while(right < n && (sum + a[right]) == (sum ^ a[right])) {
            sum += a[right];
            right++;
        }

        rel += right - left;
        if(left == right) right++;
        else sum -= a[left];
    }
    cout << rel << endl;
}


Measured memory_bytes: 1024
/*
    Author: aksayushx
*/

#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define all(a) a.begin(),a.end()
#define mp make_pair
#define mod 1000000007
using namespace std;
typedef long long ll;
typedef long double ld;

bool sortbysec(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second); 
}
ll power(ll x, ll y)  
{  
    ll res = 1; 
    x = x % mod;
    if (x == 0) return 0;
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x)%mod;  
        y = y>>1; 
        x = (x*x)%mod;  
    }  
    return res;  
} 
ll n,w;
vector<ll> wt,v;
vector<vector<ll>> dp;
void aksayushx()
{
    cin>>n>>w;
    wt.resize(n);
    v.resize(n);
    ll s=0;
    for(ll i=0;i<n;i++) 
    {
        cin>>wt[i]>>v[i];
        s+=v[i];
    }
    ll lim=pow(10,18);
    dp.assign(n,vector<ll>(s+1,lim));
    
    dp[0][v[0]]=wt[0];
    s=v[0];
    dp[0][0]=0;
    for(ll i=1;i<n;i++)
    {
        dp[i][0]=0;
        s+=v[i];
        for(ll j=0;j<=s;j++)
        {
            dp[i][j]=dp[i-1][j];
            if(j-v[i]>=0)
            dp[i][j]=min(dp[i][j],wt[i]+dp[i-1][j-v[i]]);
        }
    }
    ll ans=0;
    for(ll i=0;i<=s;i++)
    {
        if(dp[n-1][i]<=w)
        ans=i;
        
    }
    cout<<ans<<'\n';
    //cout<<dp[n-1][2];
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int test=1;
    //cin>>test;
    while(test--)
        aksayushx();
    return 0;
}


Measured memory_bytes: 82316