akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int map[101][101];
int w, h;

int dfs(int xs, int ys, int c, int xg, int yg)
{
	if (xs == xg && ys == yg){
		return (1);
	}
	
	map[ys][xs] = -1;
	
	if (1 <= xs - 1 && map[ys][xs - 1] == c){
		if (dfs(xs - 1, ys, c, xg, yg) == 1){
			return (1);
		}
	}
	if (1 <= ys - 1 && map[ys - 1][xs] == c){
		if (dfs(xs, ys - 1, c, xg, yg) == 1){
			return (1);
		}
	}
	if (xs + 1 <= w && map[ys][xs + 1] == c){
		if (dfs(xs + 1, ys, c, xg, yg) == 1){
			return (1);
		}
	}
	if (ys + 1 <= h && map[ys + 1][xs] == c){
		if (dfs(xs, ys + 1, c, xg, yg) == 1){
			return (1);
		}
	}
	
	return (0);
}

int main(void)
{
	
	int i, j, k;
	int xs, ys, xg, yg;
	int n;
	int c, d, x, y;
	
	while (1){
		scanf("%d%d", &w, &h);
		
		if (!(w + h)){
			break;
		}
		
		scanf("%d%d", &xs, &ys);
		scanf("%d%d", &xg, &yg);
		scanf("%d", &n);
		
		memset(map, 0, sizeof(map));
		
		for (i = 0; i < n; i++){
			scanf("%d%d%d%d", &c, &d, &x, &y);
			
			if (d == 0){
				for (j = 0; j < 2; j++){
					for (k = 0; k < 4; k++){
						map[y + j][x + k] = c;
					}
				}
			}
			else {
				for (j = 0; j < 4; j++){
					for (k = 0; k < 2; k++){
						map[y + j][x + k] = c;
					}
				}
			}
		}
		if (dfs(xs, ys, map[ys][xs], xg, yg) == 1){
			printf("OK\n");
		}
		else {
			printf("NG\n");
		}
	}
	return (0);
}

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

#pragma region Macros
using ll = long long;
#define int ll
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
#define IOS\
    ios::sync_with_stdio(false);\
    cin.tie(0);\
    cout.tie(0);
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()
#define SORT(name) sort(name.begin(), name.end())
#define RSORT(name)\
    SORT(name);\
    reverse(all(name));
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
inline void Yes(bool b = true) {cout << (b ? "Yes" : "No") << '\n';}
inline void YES(bool b = true) {cout << (b ? "YES" : "NO") << '\n';}
template <class T> inline void print(T x){ cout << x << '\n';}
template<typename T1,typename T2> inline void chmin(T1 &a, T2 b){ if(a > b) a = b; }
template<typename T1,typename T2> inline void chmax(T1 &a, T2 b){ if(a < b) a = b; }

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
#pragma endregion

#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const int MOD = 1000000007;
const int MAX_N = 100010;

int RMaxQ(int a, int b) {
    return max(a, b);
}
int MaxE() { return 0; }
int RMinQ(int a, int b) {
    return min(a, b);
}
int MinE() { return LLINF; }

signed main() {
    IOS;

    int N, Q;
    cin >> N >> Q;
    V<> A(N);
    REP(i, N) {
        cin >> A[i];
    }

    segtree<int, RMaxQ, MaxE> segmax(A);

    REP(i, Q) {
        int q;
        cin >> q;
        if(q == 1) {
            int x, v;
            cin >> x >> v;
            x--;
            segmax.set(x, v);
        }
        else if(q == 2) {
            int l, r;
            cin >> l >> r;
            l--;
            print(segmax.prod(l, r));
        }
        else {
            int x, v;
            cin >> x >> v;
            x--;

            if(v > segmax.prod(x, N)) {
                print(N + 1);
                continue;
            }

            int lb = x, ub = N - 1;
            while(ub - lb > 1) {
                int mid = (lb + ub) / 2;
                int val = segmax.prod(x, mid + 1);
                if(v <= val) { ub = mid; }
                else { lb = mid; }
            }
            if(v <= segmax.prod(x, lb + 1)) {
                print(lb + 1);
            }
            else {
                print(ub + 1);
            }
        }
    }

    return 0;
}


Measured memory_bytes: 9020
s=input()
c=0
for i in range(len(s)):
    if i % 2 == 0 and s[i] in ["R","U","D"]:
        c += 1
    elif i % 2 == 1 and s[i] in ["L","U","D"]:
        c += 1
print("Yes" if c == len(s) else "No")

Measured memory_bytes: 9028
#include <bits/stdc++.h>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const long double PI  = acos(-1.0L);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
#define chmax(a,b) a = (((a)<(b))?(b):(a))
#define chmin(a,b) a = (((a)>(b))?(b):(a))

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
	int n; cin>>n;
	VI a(n); int b=0,s=n;
	rep(i,n){
		cin>>a[i]; chmax(b,a[i]); chmin(s,a[i]);
	}
	if(b-s==0){
		if(b==n-1||b*2<=n) return cout<<"Yes"<<endl,0;
	}
	if(b-s==1){
		int alone=0;
		rep(i,n){
			if(a[i]==b-1) alone++;
		}
		if(alone<b&&2*(b-alone)<=n-alone) return cout<<"Yes"<<endl,0;
	}
	cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 640
N, K, Q = input().split(' ')
n, k, q = int(N), int(K), int(Q)
t = 'No'
if k - q > 0:
    t = 'Yes'
res = [t] * n

p = [k - q] * n
for i in range(q):
    r = int(input()) - 1
    p[r] += 1
    if p[r] > 0:
        res[r] = 'Yes'
for i in res:
    print(i)

Measured memory_bytes: 7352
// template
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<long long, long long> LP;
#define INF 999999999
#define MOD 1000000007
#define REP(i, n) for(ll i = 0, i##_len = (n); i < i##_len; ++i)
#define REP_AB(i, a, b) for (ll i = ll(a); i <= ll(b); ++i)
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))
#define UNIQUE(v) sort(ALL(v));v.erase(unique(ALL(v)), v.end());
#define SIZE(x) ((ll)(x).size())
#define REVERSE(v) reverse(ALL(v))
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a / gcd(a, b)) * b;}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
#define out cout
#define in cin
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; }
// template end

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    in >> s;
    bool check = true;
    REP(i, s.size()){
        REP(j, s.size()){
            if(i == j) continue;
            if(s[i] == s[j]) check = false;
        }
    }
    if(check) out << "yes" << endl;
    else out << "no" << endl;
}


Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
 
index_lst = [0] * N
for index, i in enumerate(P):
    index_lst[i - 1] = index
 
left_next_Index = list(range(-1, N - 1)) + [-1, -1]
right_next_Index = list(range(1, N + 1)) + [N, N]
ans = 0
for i in range(1, N):
    index = index_lst[i - 1]
    # print (i, index)
    l1 = left_next_Index[index]
    l2 = left_next_Index[l1]
    r1 = right_next_Index[index]
    r2 = right_next_Index[r1]
    # print ('l1 =', l1, ' l2 =', l2, ' r1 =', r1, ' r2 =', r2)
    ans += i * ((index - l1) * (r2 - r1) + (r1 - index) * (l1 -l2))
 
    left_next_Index[r1] = l1
    right_next_Index[l1] = r1
 
print (ans)

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

const int NMAX = 200005;

int n;
int a[NMAX], b[NMAX], c[NMAX], d[NMAX];

int *caut(int x)
{
   return lower_bound(d + 1, d + n + 1, x);
}

int main()
{
   cin >> n;
   for (int i = 1; i <= n; i++)
      cin >> a[i];
   for (int i = 1; i <= n; i++)
      cin >> b[i];

   int rez = 0;
   for (int bit = 0; bit <= 28; bit++)
   {
      for (int j = 1; j <= n; j++)
         c[j] = a[j] % (1 << (bit + 1)), d[j] = b[j] % (1 << (bit + 1));
      sort(d + 1, d + n + 1);
      int unu = 0;
      for (int j = 1; j <= n; j++)
         unu ^= caut ((1 << (bit + 1)) - c[j]) - caut((1 << bit) - c[j]) + caut((1 << (bit + 2)) - c[j]) - caut((3 << bit) - c[j]);
      rez ^= (unu & 1) << bit;
   }
   cout << rez;
   return 0;
}


Measured memory_bytes: 3328
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>

long table[200000][3];

int main()
{
    long N;
    std::cin >> N;
    std::vector<long> A;
    for(long i=0; i<N; i++){
        long temp;
        std::cin >> temp;
        A.push_back(temp);
    }
    std::sort(A.begin(),A.end());

    bool flag=1;
    for(long i=1; i<N; i++){
        if(A[i]==A[i-1]){
            flag=0;
            break;
        }
    }
    if(flag){
        std::cout << "YES" << std::endl;
    }else{
        std::cout << "NO" << std::endl;
    }
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    sort(s.begin(), s.end());
    if(s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
from collections import deque
n = int(input())
A = list(map(int, input().split()))
even_odd = n % 2
b = deque()
for i, a in enumerate(A, 1):
    if i % 2 == even_odd:
        b.appendleft(a)
    else:
        b.append(a)
print(*b)

Measured memory_bytes: 25412
#include <algorithm>
#include <iostream>
#include <numeric>
#include <string>
#include <utility>
#include <vector>

using namespace std;

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

    auto multiplicationFirst = [](const string& s) {
        // value or operator
        enum class T { V, O };
        vector<pair<T, int>> v;
        for (char i : s) {
            if (i == '*' || i == '+') {
                v.emplace_back(T::O, i);
            }
            else {
                v.emplace_back(T::V, i - '0');
            }
        }
        while (true) {
            if (find(begin(v), end(v),
                     make_pair(T::O, static_cast<int>('*'))) == end(v)) {
                break;
            }
            vector<pair<T, int>> t;
            for (size_t i = 0; i < v.size(); ++i) {
                if (v[i] != make_pair(T::O, static_cast<int>('*'))) {
                    t.push_back(v[i]);
                }
                else {
                    t.pop_back();
                    t.emplace_back(T ::V, v[i - 1].second * v[i + 1].second);
                    copy(begin(v) + i + 2, end(v), back_inserter(t));
                    break;
                }
            }
            v = t;
        }
        return accumulate(begin(v), end(v), 0,
                          [](int a, const pair<T, int>& b) {
                              if (b.first == T::O) {
                                  return a;
                              }
                              else {
                                  return a + b.second;
                              }
                          });
    };
    auto leftToRight = [](const string& s) {
        int accumulator = s[0] - '0';
        for (size_t i = 1; i < s.size() - 1; i += 2) {
            if (s[i] == '+') {
                accumulator += s[i + 1] - '0';
            }
            else {
                accumulator *= s[i + 1] - '0';
            }
        }
        return accumulator;
    };
    auto mf = multiplicationFirst(s);
    auto lr = leftToRight(s);
    if (mf == n && lr == n) {
        cout << 'U' << endl;
    }
    else if (mf == n) {
        cout << 'M' << endl;
    }
    else if (lr == n) {
        cout << 'L' << endl;
    }
    else {
        cout << 'I' << endl;
    }
}


Measured memory_bytes: 3192
import java.util.Scanner;

public class Main {

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

        int D = sc.nextInt();
        int T = sc.nextInt();
        int S = sc.nextInt();

        int min = D / S;


        if (min < T) {
            System.out.println("Yes");
        } else if (min == T) {

            if (D % S == 0) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        } else {
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 35664
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
#include <boost/range/adaptors.hpp>

using namespace std;
using boost::adaptors::reversed;
using boost::irange;
using uint = unsigned int;
using ll = long long int;
using ull = unsigned long long int;

ll mypow(ll base, ll exponent) {
    if (exponent == 0) return 1;
    else if (exponent == 1) return base;
    else {
        ll half = mypow(base, exponent / 2);
        assert(abs(half) < 3037000500LL);
        ll full = half * half;
        if (exponent % 2 == 0) {
            return full;
        } else {
            assert(full < numeric_limits<ll>::max() / abs(base));
            return base * full;
        }
    }
}

ll maxbit(ll N){
    ll _k = 0;
    bool is_negative = (N <= 0);
    N = abs(N);
    if (is_negative){
        while (true){
            if (N <= 2 * (mypow(4ll, _k) - 1) / 3) return 2 * _k;
            else _k++;
        }
    } else {
        while (true){
            if (N <= (mypow(4ll, _k + 1) - 1) / 3) return 2 * _k + 1;
            else _k++;
        }
    }
}


int main() {
    ll N;
    cin >> N;
    ll mb = maxbit(N);
    if (mb == 0)cout << '0' << endl;
    else {
        vector<bool> ret(mb);
        while(mb != 0) {
            ret.at(mb - 1) = true;
            N -= mypow(-2ll, mb - 1);
            mb = maxbit(N);
        }
        for (auto && i: ret | reversed){
            if (i) cout << '1';
            else cout << '0';
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

long long modpow(long long,long long);
ll combi(ll,ll);

int main(){
    ll x,y,keyx,keyy,key,ans;scanf("%lld%lld",&x,&y);
    if((-x+2*y)%3!=0 || (2*x-y)%3!=0 || (-x+2*y)<0 || (2*x-y)<0){//(x,y)を(1,2)と(2,1)の線形結合で表したときの係数は非負整数値
        printf("0\n");
        return 0;
    }
    keyx=(-x+2*y)/3;keyy=(2*x-y)/3;//線形結合の係数
    if(keyx<=keyy){key=keyx;}
    else if(keyy<=keyx){key=keyy;}

    ans=combi(keyx+keyy,key);//基底変換された座標系を考えて、最短ルートの計算
    printf("%lld\n",ans);
    return 0;
}

long long combi(long long n,long long r){//繰り返し二乗法を用いてcombination計算
    long long ans,i,under=1,up=1,mod=1000000007;
    for(i=1;i<=r;i++){
        under=under*i;
        under=under%mod;
    }
    under=modpow(under,mod-2);//フェルマーの小定理
    
    for(i=1;i<=r;i++){
        up=up*(n-i+1);
        up=up%mod;
    }
    ans=up*(under%mod);
    return ans%mod;
}

long long modpow(long long a,long long n){//繰り返し二乗法
    long long mod=1000000007;
    if(n==1) return a%mod;
    if(n%2==1) return (a*modpow(a,n-1))%mod;
    long long t=modpow(a,n/2);
    return (t*t)%mod;
}

Measured memory_bytes: 128
N = int(input())
A = list(map(int, input().split(" ")))

decided = False
upping = True
i = 1
before = A[0]
ans = 1
while i < N:
    if decided:
        if upping:
            if before <= A[i]:
                pass
            else:
                decided = False
                ans += 1
        else:
            if before >= A[i]:
                pass
            else:
                decided = False
                ans += 1
    else:
        if before > A[i]:
            upping = False
            decided = True
        elif before < A[i]:
            upping = True
            decided = True
        elif before == A[i]:
            pass
    before = A[i]
    i += 1
print(ans)


Measured memory_bytes: 14224
S = str(input())

ans = 0

for i in range(1,len(S)):
  check_str = S[:-i]
  if len(check_str)%2 == 0:
    if check_str[:len(check_str)//2] == check_str[len(check_str)//2:]:
      break

ans = len(check_str)
print(ans)


Measured memory_bytes: 2940
/**
 *      ABC 66 B
 *      author  : kyomukyomupurin
 *      created : 2018-09-05 03:06:03 
**/

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

bool check(string S){
    int sizeS = S.size();
    string sub1 = S.substr(0, sizeS / 2);
    string sub2 = S.substr(sizeS / 2, sizeS / 2);
    if (sub1 == sub2){
        return true;
    }
    else {
        return false;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    string S; cin >> S;
    int sizeS = S.size();
    S = S.substr(0, S.size() - 2);
    for (int i = 0; i < sizeS; ++i){
        if (check(S)){
            cout << S.size() << endl; return 0;
        }
        else {
            S = S.substr(0, S.size() - 2);
        }
    }
    /*
    while (check(S) == false){
        S = S.substr(0, sizeS - 2); cout << S << endl;
    }*/
    cout << S.size() << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int>P;
template<class T1,class T2>
using Hash = unordered_map<T1, T2>;

int dx[]{ 0,1,1,0,-1,-1 }, dy[]{ 1,1,0,-1,-1,0 };
int main() {
	int t, n;
	while (scanf("%d%d", &t, &n), t) {
		Hash<int, Hash<int, int>>mp, d;
		rep(i, n) {
			int x, y; scanf("%d%d", &x, &y);
			mp[x][y] = 1;
		}
		int sx, sy; scanf("%d%d", &sx, &sy);
		queue<P>que;
		int cnt = 1;
		que.push(P(sx, sy));
		d[sx][sy] = 1;
		while (!que.empty()) {
			P p = que.front(); que.pop();
			if (d[p.first][p.second] > t)continue;
			rep(i, 6) {
				int nx = p.first + dx[i], ny = p.second + dy[i];
				if (!mp[nx][ny] && !d[nx][ny]) {
					que.push(P(nx, ny));
					cnt++;
					d[nx][ny] = d[p.first][p.second] + 1;
				}
			}
		}
		printf("%d\n", cnt);
	}
}

Measured memory_bytes: 3480
#include <stdio.h>
#include <string.h>

int main() {
	int N, i, cnt0 = 0, cnt1 = 0;
	char S[100000];

	scanf("%s", S);
	N = strlen(S);

	for (i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (S[i] != '0') {
				cnt0++;
			}
		}
		else {
			if (S[i] != '1') {
				cnt0++;
			}
		}
	}

	for (i = 0; i < N; i++) {
		if (i % 2 == 0) {
			if (S[i] != '1') {
				cnt1++;
			}
		}
		else {
			if (S[i] != '0') {
				cnt1++;
			}
		}
	}

	if (cnt0 < cnt1) {
		printf("%d\n", cnt0);
	}
	else {
		printf("%d\n", cnt1);
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n,x[100010],l,q,ri[100010][31];
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    rep(i,n)cin>>x[i];
    x[n]=INF;
    cin>>l;
    rep(i,n)ri[i][0]=min(n-1,(int)(upper_bound(x,x+n+1,x[i]+l)-x)-1);
    for(int k=1;k<=30;k++){
        rep(i,n){
            ri[i][k]=ri[ri[i][k-1]][k-1];
        }
    }
    cin>>q;
    while(q--){
        int a,b,ans=0;
        cin>>a>>b;
        a--,b--;
        if(a>b)swap(a,b);
        while(a<b){
            for(int k=30;k>=0;k--){
                if(ri[a][k]<b){
                    a=ri[a][k];
                    ans+=(1<<k);
                    goto hoge;
                }
            }
            ans++;
            break;
            hoge:;
        }
        cout<<ans<<endl;
    }
	return 0;
}


Measured memory_bytes: 27520
// Package main provides
//
// File:  d.go
// Author: ymiyamoto
//
// Created on Thu Dec  6 00:31:35 2018
//
package main

import "fmt"

var l int

type line struct {
	from   int
	weight int
}

func pow(n int) int {
	ret := 1
	for i := 0; i < n; i++ {
		ret *= 2
	}
	return ret
}

func main() {
	fmt.Scan(&l)

	var n int
	for i := 1; pow(i)-1 < l; i++ {
		n = i
	}

	maxWeights := pow(n) - 1
	var lines []line
	for i := n - 1; i >= 0; i-- {
		weight := pow(i) - 1
		newWeigts := (maxWeights + 1) + weight
		if newWeigts < l {
			lines = append(lines, line{from: i, weight: maxWeights + 1})
			maxWeights = newWeigts
		}
	}

	fmt.Println(n+1, 2*n+len(lines))
	for i := 0; i < n; i++ {
		fmt.Println(i+1, i+1+1, pow(i))
		fmt.Println(i+1, i+1+1, 0)
	}

	for _, line := range lines {
		fmt.Println(line.from+1, n+1, line.weight)
	}
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define  ll      long long 
#define  int     ll 
#define  mod     1000000007
#define  pb      push_back
#define  pob     pop_back
#define  f1      first
#define  s2      second
#define  N       500005
#define  K       100005
#define  bol     (int)ceil((say-1)/2.0)
#define  PII     pair<int,int>
#define  PIII    pair<int,PII>
#define  PIIII   pair<PII,PII>
#define  PIIIII  pair<PIII,PII>
#define  PIIIIII pair<PIII,PIII>

using namespace std; 

int n,q;
int dizi[N],cnt[N];
vector<PIII> v;
bool comp(PIII a,PIII b){
	if(ceil(a.s2.f1/sqrt(N))>ceil(b.s2.f1/sqrt(N)))
		return 0;
	if(ceil(b.s2.f1/sqrt(N))>ceil(a.s2.f1/sqrt(N)))
		return 1;
	if(a.s2.s2>b.s2.s2)
		return 0;
	return 1;
}
int32_t main(){
    // freopen("a.gir","r",stdin);      
    // freopen("a.cik","w",stdout);
	scanf("%lld %lld",&n,&q);
	v.resize(q);
	for(int i=1;i<=n;i++){
		scanf("%lld",&dizi[i]);
	}
	for(int i=0;i<q;i++){
		v[i].f1=i;
		scanf("%lld %lld",&v[i].s2.f1,&v[i].s2.s2);
	}
	sort(v.begin(), v.end(),comp);
	/*for(int i=0;i<q;i++){
		printf("%lld %lld\n",v[i].s2.f1,v[i].s2.s2);
	}*/
	int crrL=1,crrR=1,R,L,ans=1;
	cnt[dizi[1]]++;
	for(int i=0;i<q;i++){
		L=v[i].s2.f1;
		R=v[i].s2.s2;
		while(crrL<L){
			cnt[dizi[crrL]]--;
			if(cnt[dizi[crrL]]==0)ans--;
			crrL++;
		}
		while(crrL>L){
			crrL--;
			cnt[dizi[crrL]]++;
			if(cnt[dizi[crrL]]==1)ans++;
		}
		while(crrR<R){
			crrR++;
			cnt[dizi[crrR]]++;
			if(cnt[dizi[crrR]]==1)ans++;
		}
		while(crrR>R){
			cnt[dizi[crrR]]--;
			if(cnt[dizi[crrR]]==0)ans--;
			crrR--;
		}
		v[i].s2.f1=ans;
	}
	sort(v.begin(), v.end());
	for(int i=0;i<q;i++){
		printf("%lld\n",v[i].s2.f1);
	}
}


Measured memory_bytes: 23212
#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>
#include <complex>
#include <queue>
using namespace std;
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define IDX(vec, element_iter) distance((vec).begin(), element_iter)
#define print(x) cout<<(x)<<'\n'
#define print_vec(v) rep(i,v.size()){if(i!=0)cout<<" ";cout<<v[i];}cout<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<'\n'
#define DEBUG_VEC(v) cout<<#v<<":";rep(i,v.size())cout<<" "<<v[i];cout<<'\n'
#define pb push_back
#define mp make_pair
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pll=pair<ll,ll>;
using vll=vector<ll>;
using vvll=vector<vll>;
using vstr=vector<string>;

void solve() {
    ll N;
    cin >> N;
    ll a;
    vll buka(N,0);
    rep(i,N-1){
        cin >> a;
        a--;
        buka[a]++;
    }
    rep(i,N){
        print(buka[i]);
    }
}
 
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
    //int q; cin >> q;
	//while (q--)
		solve();
    return 0;
}

Measured memory_bytes: 4768
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		String[] tokens = in.nextLine().split(" ");
		int a = Integer.parseInt(tokens[0]);
		int b = Integer.parseInt(tokens[1]);

		if (a + b == 15) {
			System.out.println("+");
		} else if (a * b == 15) {
			System.out.println("*");
		} else {
			System.out.println("x");
		}

		in.close();
	}

}

Measured memory_bytes: 21460
while True:
    # 入力
    m,f,r = (int(i) for i in input().split())
    # 終了判定
    if m==-1 & f==-1 & r==-1:
        break
    # 成績判定
    if m==-1 or f==-1:
        print("F")
    elif m+f >= 80:
        print("A")
    elif m+f >= 65:
        print("B")
    elif m+f >= 50:
        print("C")
    elif m+f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    elif m+f < 30:
        print("F")



Measured memory_bytes: 5604
n = int(input())
A = list(map(int, input().split()))

# n = 5
# A = [2,4, 6]

cnt = 0

flag=True
while flag:
    for a in A:
        if a % 2 == 0:
            continue
        else:
            flag=False
            break 
    if not flag: 
        break
    A = [a/2 for a in A]
    cnt = cnt + 1
print(cnt)

Measured memory_bytes: 3060
let sentinel = ('Z', max_int)

let merge_sort a cmp =
  let merge l m r =
    let ni = m - l in
    let nj = r - m in
    let init_ary n p =
      Array.init (n + 1) (fun i -> if i = n then sentinel else a.(p + i))
    in
    let ai = init_ary ni l in
    let aj = init_ary nj m in
    let rec doit i j k =
      if k < r then begin
        if cmp ai.(i) aj.(j) <= 0 then (a.(k) <- ai.(i); doit (i + 1) j (k + 1))
        else (a.(k) <- aj.(j); doit i (j + 1) (k + 1))
      end
    in
    doit 0 0 l
  in
  let rec doit l r =
    if (l + 1) < r then begin
      let m = (l + r) / 2 in
      doit l m;
      doit m r;
      merge l m r
    end
  in
  doit 0 (Array.length a)

let quick_sort a cmp =
  let partition p r =
    let x = a.(r) in
    let swap i j =
      let t = a.(i) in a.(i) <- a.(j); a.(j) <- t
    in
    let rec doit i j =
      if j >= r then i
      else begin
        if cmp a.(j) x <= 0 then (swap (i + 1) j; doit (i + 1) (j + 1))
        else doit i (j + 1)
      end
    in
    let i = doit (p - 1) p in
    swap (i + 1) r;
    i + 1
  in
  let rec doit p r =
    if p < r then begin
      let q = partition p r in
      doit p (q - 1);
      doit q r
    end
  in
  doit 0 (Array.length a - 1)

let stable_p a b equal =
  let n = Array.length a in
  let rec doit i =
    if i = n then true
    else if equal a.(i) b.(i) then doit (i + 1)
    else false
  in
  doit 0

let () =
  let n = read_int () in
  let a = Array.init n (fun _ -> Scanf.scanf "%c %d\n" (fun c d -> (c, d))) in
  let b = Array.copy a in
  merge_sort a (fun (_, x) (_, y) -> compare x y);
  quick_sort b (fun (_, x) (_, y) -> compare x y);
  print_endline (if stable_p a b (fun (xc, xd) (yc, yd) -> xc = yc && xd = yd) then "Stable" else "Not stable");
  Array.iter (fun (c, d) -> Printf.printf "%c %d\n" c d) b

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

int main() {
    int N;
    int v[1000];
    cin >> N;
    for(int i = 0; i < N; i++) {
        cin >> v[i];
    }
    sort(v, v+N);
    double ans = v[0];
    for(int i = 1; i < N; i++) {
        ans = (ans + v[i])/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
macro_rules! get {
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, a, b) = get!(usize, usize, usize);
    let mut sum = 0;
    for i in 1..n+1 {
        let mut s = 0;
        let mut ii = i;
        while ii != 0 {
            s += ii%10;
            ii /= 10;
        }
        if a <= s && s <= b {
            sum += i;
        }
    }
    println!("{}", sum);
}

Measured memory_bytes: 2160
#include<bits/stdc++.h>
using namespace std;
static const int64_t mod=1000000007;
int main(){
  int64_t N;cin>>N;
  string s;cin>>s;
  vector<int64_t>A(2*N);
  for(int i=0;i<2*N;i++){
  if((i%2==0 &&s.at(i)=='B')||(i%2==1 && s.at(i)=='W'))
    A.at(i)=0;
    else
      A.at(i)=1;
  }int64_t sum=0;
  for(int i=0;i<2*N;i++)
    sum+=A.at(i);
  if(sum!=N)
    cout<<0<<endl;
  else{
  int64_t ans=1;int64_t a=0;
    for(int i=2*N-1;0<=i;i--){
    if(A.at(i)==1)a++;
      if(A.at(i)==0){ans=(ans*a)%mod;a--;}
      
    }for(int64_t i=1;i<=N;i++)
      ans=(i*ans)%mod;
    cout<<ans<<endl;
   }
  return 0;
}

Measured memory_bytes: 5228
import sys
sys.setrecursionlimit(10**9)
mod = 998244353
memo = [-1]*(10**6)
memo[0] = 1
def fact(n):
    if memo[n] != -1:
        return memo[n]
    else:
        res = n*fact(n-1)%mod
        memo[n] = res
        return res

def comb(n,k):
    return fact(n)*pow(fact(k),mod-2,mod)*pow(fact(n-k),mod-2,mod)%mod

N,M,K = map(int,input().split())

ans = 0
for k in range(K+1):
    ans += M*pow(M-1,N-k-1,mod)*comb(N-1,k)
    ans %= mod
print(ans)

Measured memory_bytes: 233408
n = int(input())
MOD = 1000000007



  
if n == 1:
	ans = 0
else:
	cala = 10 ** n % MOD
	calb = 9 ** n % MOD
	calc = 8 ** n % MOD
	ans = (cala - calb*2 + calc) % MOD

     
print(ans)



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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

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

	int N; cin >> N;
	vi arr (N);
	F0R(i, N) cin >> arr[i];

	vi occ (1e5+1);
	F0R(i, N) occ[arr[i]]++;

	int total = 0;
	int bad = 0;
	F0R(i, 1e5+1) {
		if (occ[i]) ++total;

		if (occ[i] >= 3) {
			occ[i] = (occ[i] - 1) % 2 + 1;
		}

		if (occ[i] == 2) ++bad;
	}

	print((bad % 2 == 1) ? total - 1 : total);
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
        sc.close();
    }
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(int i=a;i<b;i++)
#define rlo(i,n) for(int i=n-1;i>=0;i--)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()
#define mem(a,b) memset(a,b,sizeof(a))
#define pr(a) {for(auto x:a)cout<<x<<" ";cout<<nl;}

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

void f()
{
  ll n,m,x,y;
  cin>>n>>m>>x>>y;

  ll a[n+2],b[m+2];

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

  b[0]=y;
  for(int i=1;i<=m;i++)
  {
    cin>>b[i];
  }

  sort(a,a+n+1);
  sort(b,b+m+1);

  if(a[n]<b[0])
    cout<<"No War\n";
  else
    cout<<"War\n";

}

int main()
{
    su;
    f();
    return 0;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
typedef long long ll;
typedef std::pair<ll,ll> P;

#define rep(i,n) for(int i = 0; i < int(n); i++)
using namespace std;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

const ll mod = 1000000007;

ll mpow(ll x, ll n) {
	ll ans = 1; x %= mod;
	while (n != 0) {
		if (n & 1) ans = ans * x % mod;
		x = x * x % mod;
		n = n >> 1;
	}
	return ans;
}

ll inv_mod(ll a) { return mpow(a, mod - 2); }

class Factorial {
private:
	vector<ll> fac;
	vector<ll> ifac;
public:

	Factorial(ll N) {
		fac.push_back(1);
		for (int i = 0; i < N; i++) fac.push_back(fac[i] * (i + 1) % mod);
		ifac.resize(N + 1);
		ifac[N] = inv_mod(fac[N]);
		for (int i = 0; i < N; i++) ifac[N - 1 - i] = (ifac[N - i] * (N - i)) % mod;
	}

	ll fact(ll a) { return fac[a]; }
	ll ifact(ll a) { return ifac[a]; }

	ll cmb(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		ll tmp = ifact(a - b) * ifact(b) % mod;
		return tmp * fac[a] % mod;
	}
	ll per(ll a, ll b) {
		if (a == 0 && b == 0) return 1;
		if (a < b || a < 0 || b < 0) return 0;
		return fac[a] * ifac[a - b] % mod;
	}
};

class modint {
	static constexpr std::int_fast64_t Modulus = 1e9 + 7;
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept {
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept {
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept {
		return modint(*this) *= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept {
		a += rhs.a;
		if (a >= Modulus) {
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept {
		if (a < rhs.a) {
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept {
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr operator u64() const { return a; }
};


int main() {
	ll n;
	cin >> n;
	vector<P> ps(n);
	rep(i, n) {
		cin >> ps[i].first >> ps[i].second;
	}
	vector<ll> xs(n), ys(n);
	rep(i, n) {
		xs[i]= ps[i].first - ps[i].second;
		ys[i]= ps[i].first + ps[i].second;
	}
	sort(xs.begin(), xs.end());
	sort(ys.begin(), ys.end());

	ll x = xs.back() - xs.front();
	ll y = ys.back() - ys.front();

	cout << max(x, y) << endl;
	return 0;
}


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

int main()
{
  int A, B;
  cin >> A >> B;
  if(B == 1){
    cout << 0 << endl;
    return 0;
  }
  
  for(int i=1; i<=21; i++){
    if(A*i-(i-1) >= B){
      cout << i << endl;
      return 0;
    }
  }
}


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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    int a,b;
    cin>>a>>b;
    if(a<=0&&0<=b){
        cout<<"Zero"<<endl;
        return 0;
    }

    if(a>0){
        cout<<"Positive"<<endl;
    }
    else{
        if((b-a+1)&1)cout<<"Negative"<<endl;
        else cout<<"Positive"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

void trace(int A[],int N)
{
    int i;
    for(int i=0;i<N;i++)
    {
        if(i>0) printf(" ");
        printf("%d",A[i]);;
    }
    printf("\n");
}

void insertionSort(int A[],int N){
    int j,i,v;
    for(i=1;i<N;i++){
        v=A[i];
        j=i-1;
        while(j>=0 && A[j]>v)
        {
            A[j+1]=A[j];
            j--;
        }
        A[j+1]=v;
        trace(A,N);
    }
}


int main() {
    int N,i,j;
    int A[100];

    scanf("%d",&N);
    for(i=0;i<N;i++) scanf("%d",&A[i]);

    trace(A,N);
    insertionSort(A,N);

    return 0;
}


Measured memory_bytes: 2688
#include <algorithm>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
#define fst first
#define snd second
using ll = long long;
using I = pair<int, int>;

ll g(ll X) { return X - X / 3 - X / 5 + X / 15; }

ll f(ll X) {
  ll ans = 0;
  ll d = 1, low = 1, high = 10;  // [low, high)
  while (high <= X) {
    ans += d * (g(high - 1) - g(low - 1));
    ++d;
    low = high;
    high *= 10;
  }
  ans += d * (g(X) - g(low - 1));
  ans += 4 * (X / 3) + 4 * (X / 5);
  return ans;
}

int main() {
  ll s;
  while (cin >> s) {
    --s;
    ll fail = 0, pass = 1ll << 60;
    while (pass - fail > 1) {
      ll X = (fail + pass) / 2;
      if (f(X) > s) {
        pass = X;
      } else {
        fail = X;
      }
    }
    if (pass > 1) {
      s -= f(pass - 1);
    }
    string ans = "";
    for (ll X = pass; ans.size() < s + 20; X++) {
      if (X % 15 == 0) {
        ans += "FizzBuzz";
      } else if (X % 3 == 0) {
        ans += "Fizz";
      } else if (X % 5 == 0) {
        ans += "Buzz";
      } else {
        ans += to_string(X);
      }
    }
    ans = ans.substr(s, 20);
    cout << ans << endl;
  }
  return 0;
}



Measured memory_bytes: 3260
import numpy as np

n = int(input())
W = np.array(list(map(int, input().split())))

mini = 10000

for i in range(len(W)-1):
  i += 1
  tmp = abs(np.sum(W[:i]) - np.sum(W[i:]))
  if tmp < mini:
    mini = tmp
    
print(mini)

Measured memory_bytes: 21640
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

    cout << ((a == b && b == c) ? "Yes" : "No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#define endl '\n'
using namespace std;




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

	int a, b, c, k;
	cin >> a >> b >> c >> k;
	if (k <= a)
		cout << k;
	else if (k <= a + b)
		cout << a;
	else {
		int d = k - a - b;
		cout << a - d;
	}



	return 0;
}





Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <functional>
#define REP(i, n) for(int i=0;i<n;++i)
#define INF 100000000

using namespace std;

int n;

int main(){
  cin >> n;
  char s;
  
  REP(i, n){
    cin >> s;
    if(s == 'Y'){
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  
  return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize("03")
//#pragma GCC target("avx2")
 
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iomanip>
#include <utility>
#include <unordered_map>
#include <unordered_set>
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define sqr(a) (a)*(a)
#define um unordered_map 
#define us unordered_set
using namespace std;
 
hash<string> hfn;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pld;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef double dbl;
typedef unsigned int ui;
const int inf = 2e9;
const ll mod = 1e9+7;
const ld eps = 1e-7;
const ll biginf = 1e18;
const ld pi = acosl(-1);

void solve()
{
  ll h, w;
  cin >> h >> w;
  vector<vector<ll> > dp(h, vector<ll>(w, 0));
  vector<vector<char> > fld(h, vector<char>(w));
  dp[0][0] = 1;
  for(int i = 0; i < h; i++)
    for(int j = 0; j < w; j++)
      cin >> fld[i][j];
  for(int i = 0; i < h; i++)
  {
    for(int j = 0; j < w; j++)
    {
      if(!i && !j)
        continue;
      if(fld[i][j] == '#')
      {
        dp[i][j] = 0;
        continue;
      }
      if(!i)
      {
        dp[i][j] = dp[i][j-1];
        continue;
      }
      if(!j)
      {
        dp[i][j] = dp[i-1][j];
        continue;
      }
      dp[i][j] = (dp[i-1][j] + dp[i][j-1]) % mod;
    }
  }
  cout << dp.back().back();
}
 
void multisolve()
{
  int t;
  cin >> t;
  while(t--)
    solve();
}
 
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  //freopen("hull.in", "r", stdin);
  //freopen("hull.out", "w", stdout);
  solve();
  //multisolve();
}

Measured memory_bytes: 9088
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stdio.h>
#include <random>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <tuple>
#include <math.h>
#include <set>
#include <map>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
using vc = vector<char> ;
using vvc = vector<vc> ;
using vb = vector<bool> ;
using vvb = vector<vb> ;
using pll = pair<ll,ll> ;
#define all(v) v.begin(),v.end() 
const ll INF = 1e18 ;
const ll mod = 1e9+7 ;
const double pie = acos(-1); 
vll dx4 = {-1,0,1,0} ;
vll dy4 = {0,-1,0,1} ;
vll dx8 = {-1,0,1,1,1,0,-1,-1} ;
vll dy8 = {-1,-1,-1,0,1,1,1,0} ; 

void fix_cout(){cout << fixed << setprecision(20) ; }
ll gcd(ll a,ll b){if(b==0) return a ; return gcd(b,a%b) ; }
ll lcm(ll a,ll b){return a/gcd(a,b)*b ; }
void chmax(ll &a,ll b){if(a<b) a = b ; }
void chmin(ll &a,ll b){if(a>b) a = b ; }

vll fac(2,1),inv(2,1),finv(2,1) ;

void nCr_set(int n){
	for(int i=2;i<=n;i++){
		fac.push_back(fac.at(i-1)*i%mod) ;
		inv.push_back(mod-inv.at(mod%i)*(mod/i)%mod) ;
		finv.push_back(finv.at(i-1)*inv.at(i)%mod) ;
	}
}

ll nCr(ll n,ll r){
	if(n<0||r<0||n<r) return 0 ;
	if(n==r||r==0) return 1 ;
	return fac.at(n)*finv.at(n-r)%mod*finv.at(r)%mod ;
}

ll nHr(ll n,ll r){
	return nCr(n+r-1,n-1) ;
}

int main(){
	ll s ; cin >> s ;
	nCr_set(100000) ;
	ll ans = 0 ;
	for(int i=1;i*3<=s;i++){
		ans += nHr(i,s-i*3) ;
		ans %= mod ;
	}
	cout << ans << endl ;
}

Measured memory_bytes: 5880
class ATherefore:
    def solve(self, tc=0):
        n = int(input())
        if n % 10 in [2, 4, 5, 7, 9]:
            print("hon")
        elif n % 10 in [0, 1, 6, 8]:
            print("pon")
        else:
            print("bon")


x = ATherefore()
x.solve()


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

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

class mint{
	static const int MOD=1e9+7;
	int x;
public:
	mint():x(0){}
	mint(long long y){ x=y%MOD; if(x<0) x+=MOD; }

	mint& operator+=(const mint& m){ x+=m.x; if(x>=MOD) x-=MOD; return *this; }
	mint& operator-=(const mint& m){ x-=m.x; if(x<   0) x+=MOD; return *this; }
	mint& operator*=(const mint& m){ x=1LL*x*m.x%MOD; return *this; }
	mint& operator/=(const mint& m){ return *this*=inverse(m); }
	mint operator+(const mint& m)const{ return mint(*this)+=m; }
	mint operator-(const mint& m)const{ return mint(*this)-=m; }
	mint operator*(const mint& m)const{ return mint(*this)*=m; }
	mint operator/(const mint& m)const{ return mint(*this)/=m; }

	friend mint inverse(const mint& m){
		int a=m.x,b=MOD,u=1,v=0;
		while(b>0){ int t=a/b; a-=t*b; swap(a,b); u-=t*v; swap(u,v); }
		return u;
	}

	friend istream& operator>>(istream& is,mint& m){ long long t; is>>t; m=mint(t); return is; }
	friend ostream& operator<<(ostream& os,const mint& m){ return os<<m.x; }
	int to_int()const{ return x; }
};

mint pow(mint m,long long k){
	mint res=1;
	for(;k>0;k>>=1,m*=m) if(k&1) res*=m;
	return res;
}

int n,c,a[400],b[400];

mint f(int i,int k){
	static bool memo1[400][401];
	static mint memo2[400][401];

	if(memo1[i][k]) return memo2[i][k];
	memo1[i][k]=true;

	mint res=0;
	for(int x=a[i];x<=b[i];x++) res+=pow(mint(x),k);
	return memo2[i][k]=res;
}

int main(){
	scanf("%d%d",&n,&c);
	rep(i,n) scanf("%d",&a[i]);
	rep(i,n) scanf("%d",&b[i]);

	mint dp[401][401];
	dp[0][0]=1;
	rep(i,n) rep(j,c+1) {
		rep(k,j+1) dp[i+1][j]+=f(i,k)*dp[i][j-k];
	}
	printf("%d\n",dp[n][c].to_int());

	return 0;
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int X;
  cin >> X;
  int a = 0;
  for (int i = 1; i <= X; i++) {
    a += i;
    if (a >= X) {
      cout << i << '\n';
      return 0;
    }
  }
  return 0;
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> x(N);
    vector<int> y(N);
    for(int i = 0; i < N; i++){
        cin >> x.at(i);
        y.at(i) = x.at(i);
    }
    sort(x.begin(),x.end());
    int a,b;
    a = x.at(N/2 - 1);
    b = x.at(N/2);
    for(int i = 0;i < N; i++){
        if(y.at(i) > a){
            cout << a << endl;
        }else{
            cout << b << endl;
        }

    }
}

Measured memory_bytes: 3712
N=int(input())
a=list(map(int,input().split()))
cnt=1
val='0'
for n in range(1,N):
	if a[n-1]==a[n] or (val=='+' and a[n-1]<a[n]) or (val=='-' and a[n-1]>a[n]):
		pass
	elif val=='0':
		 if a[n-1]<a[n]:
		 	val='+'
		 elif a[n-1]>a[n]:
		 	val='-'
	else:
		val='0'
		cnt+=1
print(cnt)


Measured memory_bytes: 14228