akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y, h;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
signed main() {
	string s, l = "CODEFESTIVAL2016";
	cin >> s;
	int sum = 0;
	for (int i = 0; i < s.size(); i++) {
		if (s[i] != l[i])
			sum++;
	}
	cout << sum << endl;
	getchar(); getchar();
}

Measured memory_bytes: 256
n, m = map(int, input().split())
a = list(map(int, input().split()))
tmp = []
t = 0
for i in a:
    t += (1/2) * (i+1)
    tmp.append(t)

mx = tmp[m-1]
for i in range(n-m):
    mx = max(mx, tmp[m+i]-tmp[i])
    #print(tmp[m+i], tmp[i])
print(mx)

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

template <class type> class SegmentTree{
public:
    int size;
    vector<type> tree;
    type def;
    type (*marge)(type, type);

    SegmentTree(int n, type d, type (*m)(type, type)){
        size = 1;
        def = d;
        marge = m;
        n++;

        while(size < n){
            size *= 2;
        }

        tree.resize(2*size);

        for(int i = 0;i < size;i++){
            tree[size-1+i] = def;
        }

        for(int i = size-2;i >= 0;i--){
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    SegmentTree(int n, type array[], type d, type (*m)(type, type)){
        size = 1;
        def = d;
        marge = m;
        n++;

        while(size < n){
            size *= 2;
        }

        tree.resize(2*size);

        for(int i = 0;i < size;i++){
            if(i < n) tree[size-1+i] = array[i];
            else tree[size-1+i] = def;
        }

        for(int i = size-2;i >= 0;i--){
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    void update(int i, type val){
        i = size-1+i;
        tree[i] = val;

        while(i > 0){
            i = (i-1)/2;
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    void add(int i, type val){
        i = size-1+i;
        tree[i] = tree[i] + val;

        while(i > 0){
            i = (i-1)/2;
            tree[i] = marge(tree[i*2+1], tree[i*2+2]);
        }

        return;
    }

    type get(int a, int b, int k, int l, int r){
        if(r <= a || b <= l) return def;
        if(a <= l && r <= b) return tree[k];

        type vl = get(a, b, 2*k+1, l, (l+r)/2);
        type vr = get(a, b, 2*k+2, (l+r)/2, r);

        return marge(vl, vr);
    }

    type get(int a, int b){
        return get(a, b, 0, 0, size);
    }
};

int marge(int i, int j){
    return max(i, j);
}

int sum(int i, int j){
    return i + j;
}

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

    int a[100010];
    set<int> st;
    vector<int> vec;
    for(int i = 0;i < n;i++){
        cin >> a[i];
        if(st.find(a[i]) == st.end()){
            vec.push_back(a[i]);
        }
    }

    sort(vec.begin(), vec.end());

    SegmentTree<int> seg(n, -1, marge);
    SegmentTree<int> seg2(n, 0, sum);

    int ans = 0;

    for(int i = 0;i < n;i++){
        int idx = lower_bound(vec.begin(), vec.end(), a[i])-vec.begin();
        int tmp;

        if(idx != 0){
            tmp = seg.get(0, idx);
        }

        if(idx == 0 || tmp == -1){
            ans++;
            seg.update(idx, idx);
            seg2.add(idx, 1);
        }else{
            seg2.add(tmp, -1);
            if(seg2.get(tmp, tmp+1) == 0){
                seg.update(tmp, -1);
            }
            seg.update(idx, idx);
            seg2.add(idx, 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3192
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int n;
vector<vi> G;
vi used;
vll A;

ll dfs(int v, bool root = true){
    used[v] = true;

    if(not root and (int)G[v].size() == 1){
        return A[v];
    }

    priority_queue<ll> q;
    ll sum = 0;
    for(auto& nv : G[v]){
        if(used[nv]) continue;
        ll cur = dfs(nv, false);
        if(cur == -1) return -1;
        sum += cur;
        q.push(cur);
    }
    if(sum < A[v]) return -1;

    ll ret = A[v];
    while(sum > ret and q.size() >= 2){
        ll a = q.top(); q.pop();
        ll b = q.top(); q.pop();

        ll diff = min(b, sum - ret);
        a -= diff;
        b -= diff;
        sum -= 2 * diff;
        ret -= diff;

        if(a > 0) q.push(a);
        if(b > 0) q.push(b);
    }
    if(ret != sum) return -1;

    return ret;
}

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

    cin >> n;
    A = vll(n); for(auto& e : A) cin >> e;

    G = vector<vi>(n);
    rep(i, n - 1){
        int a, b; cin >> a >> b; a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    used = vi(n);

    int r = -1;
    rep(v, n){
        if(G[v].size() == 1){
            r = v;
            break;
        }
    }
    assert(r >= 0);

    cout << (dfs(r) == A[r] ? "YES":"NO") << endl;

    return 0;
}


Measured memory_bytes: 17792
#include <iostream>

using namespace std;

int main() {
  uint64_t h, w;
  cin >> h >> w;
  auto max = (w / 2) + (w % 2);
  auto min = (w / 2);
  auto result = w == 1 || h == 1
    ? 1
    : (max + min) * (h / 2) + max * (h % 2);
  cout << result;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,l;
    cin>>n>>l;
    string a;
    multiset<string>s;
    while(n--){
        cin>>a;
        s.insert(a);
    }
    for(auto it=s.begin();it!=s.end();++it){
        cout<<(*it);
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 256
n,a,b=map(int,input().split())
for i in input():
    if i=="a" and a>0:
        a-=1
        print("Yes")
    elif i=="a" and b>0:
        b-=1
        print("Yes")
    elif i=="b" and b>0:
        b-=1
        print("Yes")
    else:print("No")

Measured memory_bytes: 4016
#include<bits/stdc++.h>
using namespace std;
const long long M =1e6+10,MOD=1000000000;
typedef long long ll;
set<int>st;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s,p;
    cin>>s>>p;
    cout<<p<<s<<endl;
   
 
    return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef ENABLE_DEBUG_OUTPUT
#define DEBUG_LOG(s) cout << s << endl;
#else
#define DEBUG_LOG(s) void();
#endif

int main(){
    vector<int> a(200), b;
    for (auto i = 0; i < 200; i++) {
        a[i] = i * (i + 1) * (i + 2) / 6;
        if(a[i] % 2) b.push_back(a[i]);
    }

    vector<int> dp(1e6, 0), dp_odd(1e6, 0);
    for (auto i = 1; i < 1e6; i++) {
        dp[i] = dp[i - 1] + 1; // 1つ目の正四面体数が1なので+1した値をまず入れる
        for (int elm : a) {
            // 求めたい値i以下の正四面体数毎に前の値+1して最小値を求める
            if(elm <= i) dp[i] = min(dp[i], dp[i - elm] + 1);
            else break;
        }
    }
    for (auto i = 1; i < 1e6; i++) {
        dp_odd[i] = dp_odd[i - 1] + 1;
        for (int elm : b) {
            if(elm <= i) dp_odd[i] = min(dp_odd[i], dp_odd[i - elm] + 1);
            else break;
        }
    }

    while(true) {
        int n;
        cin >> n;

        if(n == 0) break;
        cout << dp[n] << " " << dp_odd[n] << endl;
    }

    return 0;
}


Measured memory_bytes: 10636
#include <cstdlib>
#include <climits>
#include <iostream>
#include <cstdint>
#include <vector>
#include <string>
#include <complex>
#include <bitset>
#include <queue>
#include <deque>
#include <stack>
#include <utility>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <regex>

#include <boost/lexical_cast.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/multi_array.hpp>

using namespace std;

int main()
{
    uint64_t N, T;
    std::cin >> N >> T;

    std::vector<uint64_t> t;

    for (uint64_t i = 0; i < N; ++i) {
        uint64_t tt;
        std::cin >> tt;
        t.push_back(tt);
    }

    uint64_t len = 0;
    uint64_t endtime = 0;
    for (uint64_t i = 0; i < N; ++i) {
        auto now = t[i];
        if (endtime <= now) {
            // 止まってた
            len += T;
            endtime = now + T;
        }
        else {
            // 重複あり
            len += now + T - endtime;
            endtime = now + T;
        }
    }

    std::cout << len << std::endl;

    return 0;
}


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

int main(){
	std::string N;
	std::cin >> N;

	unsigned long long sum_{};
	for( const auto c : N )
		sum_ += c - '0';

	std::cout << ( sum_ % 9 != 0 ? "No" : "Yes" ) << "\n";

	return 0;
}

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

int res = 0;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int arr[3];
    cin >> arr[0] >> arr[1] >> arr[2];
    sort(arr, arr + 3);
    cout << arr[0] + arr[1] << "\n";
    
    return 0;
}

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

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

int main() {
    int N;  cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    int MAX_A = 1e6 + 2;
    vector<int> is_prime(MAX_A, 1), min_prime(MAX_A);  // min_prime[i] := i の最小の素因数
    is_prime[0] = is_prime[1] = 0;
    min_prime[0] = min_prime[1] = -1;
    // エラトステネス
    for (int i = 0; i < MAX_A; ++i) {
        if (is_prime[i]) {
            min_prime[i] = i;
            for (int j = 2; i * j < MAX_A; ++j) {
                is_prime[i * j] = 0;
                min_prime[i * j] = i;
            }
        }
    }

    if (N == 1) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    // gcd(A[0], A[1], ..., A[N - 1]) == 1 ??
    int g = 0;
    for (int i = 0; i < N; ++i) g = gcd(g, A[i]);
    if (g != 1) {
        cout << "not coprime" << endl;
        return 0;
    }

    vector<int> used(MAX_A);
    for (int i = 0; i < N; ++i) {
        set<int> elements;  // A[i] の素因数
        // 高速素因数分解
        int now = A[i];
        while (now != 1) {
            elements.insert(min_prime[now]);
            now /= min_prime[now];
        }
        for (int e : elements) ++used[e];
    }

    for (int i = 0; i < MAX_A; ++i) {
        if (used[i] > 1) {
            cout << "setwise coprime" << endl;
            return 0;
        }
    }

    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 18804
from collections import Counter

n, m = map(int, input().split())
edges = [tuple(map(int, input().split())) for _ in range(m)]

par = [i for i in range(n + 1)]
rank = [0 for _ in range(n + 1)]

def root(x):
    if par[x] == x:
        return x
    else:
        par[x] = root(par[x])
        return par[x]

def same(x, y):
    return root(x) == root(y)

def unite(x, y):
    x = root(x)
    y = root(y)

    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1

for a, b in edges:
    unite(a, b)

roots = [0 for _ in range(n + 1)]
for i in range(1, n + 1):
    roots[i] = root(i)

roots_cnt = Counter(roots)
print(max(roots_cnt.values()))

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

using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (n); ++i)
double const PI = 3.1415926535897932384626433;

int main() {
    int n;
    cin >> n;
    vector<int> p(n), q(n), x(n);
    rep(i, n) { cin >> p[i]; }
    rep(i, n) { cin >> q[i]; }
    rep(i, n) { x[i] = i + 1; }
    int i = 1;
    int a, b;
    do {
        if (x == p)
            a = i;
        if (x == q)
            b = i;
        ++i;
    } while (next_permutation(x.begin(), x.end()));

    cout << abs(a - b) << endl;
    return 0;
}

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

using namespace std;
int main(void){
    string str;
    cin >> str;
    
    if (str[0] == '7') cout << "Yes" << endl;
    else if (str[1] == '7') cout << "Yes" << endl;
    else if (str[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3552
N = int(input())

ans = 0
for i in range(1,N+1):
  if i % 2 != 0:
    count = 1
    for j in range(2,i+1):
      if i % j == 0:
        count += 1
    if count == 8:
      ans += 1
print(ans)
    

Measured memory_bytes: 9148
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int top, s[1000];
void push(int x) {
s[++top] = x;
} int pop() {
top--;
return s[top+1];
} int main(void) {
int i = 0, x, y, top = 0;
char a[1000];
while (scanf("%s", a) != EOF) {
i++;
if (a[0] == '+') {
y = pop();
push(pop() + y);
} else if (a[0] == '-') {
x = pop(); 
push(pop() - x);
} else if (a[0] == '*') {
y = pop();
push(pop() * y);
} else {
push(atoi(a));
}  }
printf("%d\n", pop());
return 0;
}


Measured memory_bytes: 2104
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <array>
#include <map>
#include <queue>
using namespace std;

typedef long long LL;
typedef array<int,10> ai10;

struct info{
	int cnt;
	LL val;
	ai10 to;
	
	info() : cnt{}, val{}, to{} {}
};

int main(){
	int n;
	while(scanf("%d", &n), n){
		vector<int> low(n), high(n);
		for(int i = 0; i < n; ++i){
			scanf("%d%d", &low[i], &high[i]);
		}
		
		vector<ai10> to(4 * n + 1);
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < 10; ++j){
				to[i * 4 + 2][j] |= 1 << (i * 4 + 4);
			}
		
			int ld = (low[i] + 9) / 10 * 10;
			int hd = high[i] / 10 * 10;
			for(int j = ld; j < hd; j += 10){
				to[i * 4][j / 10] |= 1 << (i * 4 + 2);
			}
			for(int j = min(ld - 1, high[i]); j >= low[i]; --j){
				int s;
				if(j < 10){
					s = i * 4;
				}
				else{
					s = i * 4 + 1;
					to[i * 4][j / 10] |= 1 << s;
				}
				to[s][j % 10] |= 1 << (i * 4 + 4);
			}
			for(int j = max(hd, low[i]); j <= high[i]; ++j){
				int s;
				if(j < 10){
					s = i * 4;
				}
				else{
					s = i * 4 + 3;
					to[i * 4][j / 10] |= 1 << s;
				}
				to[s][j % 10] |= 1 << (i * 4 + 4);
			}
		}

		map<int,info> mp;
		mp[0].cnt = 1010101010;
		mp[1].val = 1;
		queue<int> q;
		q.push(1);
		while(!q.empty()){
			int s = q.front();
			info &in = mp[s];
			q.pop();
			for(int d = 0; d < 10; ++d){
				int t = 0;
				for(size_t i = 0; i < to.size(); ++i){
					if(s >> i & 1){
						t |= to[i][d];
					}
				}
				in.to[d] = t;
				if(++mp[t].cnt == 1){
					q.push(t);
				}
			}
		}

		LL ans = 0;
		q.push(1);
		while(!q.empty()){
			int s = q.front();
			q.pop();
			info &in1 = mp[s];
			
			if(s >> (n * 4) & 1){
				ans += in1.val;
			}
			for(int d = 0; d < 10; ++d){
				info &in2 = mp[in1.to[d]];
				in2.val += in1.val;
				if(--in2.cnt == 0){
					q.push(in1.to[d]);
				}
			}
		}
		
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 1036
S = [int(i) for i in list(input())]
if S[2]*10+S[3]<13 and S[2]+S[3]!=0:
    if S[0]*10+S[1]<13 and S[0]+S[1]!=0:
        print("AMBIGUOUS")
    else:
        print("YYMM")
else:
    if S[0]*10+S[1]<13 and S[0]+S[1]!=0:
        print("MMYY")
    else:
        print("NA")

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

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

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

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

// Problem Specific Parameter:

const int limit = 5000010;
ll d[limit];
ll a[limit],b[limit];

int main(void){
	ll N,D;
	cin >> N >> D;
	rep(i,N) cin >> d[i];

	a[0] = D;
	rep(i,N){
		a[i+1] = a[i];
		chmin(a[i+1],abs(a[i]-d[i]));
	}

	b[N]=1LL;
	rrep(i,N){
		if(2*b[i+1] <= d[i]){
			b[i] = b[i+1];
		}else{
			b[i] = b[i+1] + d[i];
			if(b[i+1] < d[i] - b[i+1]) chmin(b[i],d[i]-b[i+1]);
		}
	}

	int Q;
	cin >> Q;

	rep(loop,Q){
		int cur;
		cin >> cur;
		cur--;
		if(a[N] > 0 or a[cur] >= b[cur+1])
			puts("YES");
		else
			puts("NO");
	}

	return 0;
}

Measured memory_bytes: 16256
#include <bits/stdc++.h>
using namespace std;
#define rep2(i,m,n) for (int i = (m); i < (n); ++i)
#define rep(i,n) rep2(i,0,n)
#define debug(x) cerr << x << endl
typedef long long int ll;
typedef long double ld;
typedef pair<int, int> P;
template<typename T> struct V : vector<T> { using vector<T>::vector; };
V() -> V<int>;
V(size_t) -> V<int>;
template<typename T> V(size_t, T) -> V<T>;
template<typename T> vector<T> make_vec(size_t n, T a) { return vector<T>(n, a); }
template<typename... Ts> auto make_vec(size_t n, Ts... ts) { return vector<decltype(make_vec(ts...))>(n, make_vec(ts...)); }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << ' '; return os; }
struct fast_ios { fast_ios(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
const int INF = 1<<30;
const ll LINF = 1LL<<61;
const ll MOD = 1000000007;

int main()
{
    int s;
    cin >> s;
    vector<ll> dp(s+1);
    dp[0] = 1;
    rep(i,s+1)
    {
        if(i - 3 < 0) continue;
        dp[i] += dp[i-3] + dp[i-1];
        dp[i] %= MOD;
    }
    cout << dp[s] % MOD << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;
#define int LL

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

int const MAXN = 2e5 + 5, mod = 998244353;
int frac[MAXN], invfrac[MAXN];

inline int qpow(int a, int k) {
  int re = 1;
  for (; k; k >>= 1, a = a * a % mod)
    if (k & 1) re = re * a % mod;
  return re;
}
inline int C(int n, int m) { return frac[n] * invfrac[m] % mod * invfrac[n - m] % mod; }

signed main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int n, m, K; cin >> n >> m >> K;
  frac[0] = 1;
  for (RI i = 1; i <= n; ++i) frac[i] = frac[i - 1] * i % mod;
  invfrac[n] = qpow(frac[n], mod - 2);
  for (RI i = n; i; --i) invfrac[i - 1] = invfrac[i] * i % mod;
  int ans = 0;
  for (RI k = 0; k <= K; ++k)
    ans = (ans + C(n - 1, k) * qpow(m - 1, n - 1 - k) % mod * m % mod) % mod;
  cout << ans;

  return 0;
}

// created by Daniel yuan
/*
     ________
    /        \
   / /      \ \
  / /        \ \
  \            /
   \  ______  /
    \________/
*/


Measured memory_bytes: 6656
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cassert>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <complex>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <functional>
#include <iterator>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define peri(i,a,b) for(int i=int(b);i-->int(a);)
#define rep(i,n) repi(i,0,n)
#define per(i,n) peri(i,0,n)
#define iter(c) __typeof__((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define all(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<string> vs;
typedef pair<int,int> pii;

const int INFTY=1<<29;
const double EPS=1e-8;

template<typename T1,typename T2>
ostream& operator<<(ostream& os,const pair<T1,T2>& p){
	return os<<'('<<p.first<<','<<p.second<<')';
}
template<typename T>
ostream& operator<<(ostream& os,const vector<T>& a){
	os<<'[';
	rep(i,a.size()) os<<(i?" ":"")<<a[i];
	return os<<']';
}

typedef complex<double> Point;

struct Line{
	Point pos,dir;
	Line(){}
	Line(Point p,Point d):pos(p),dir(d){}
};
typedef Line Segment;

int Signum(double x)
{
	return abs(x)<EPS?0:x<0?-1:1;
}

double Dot(Point a,Point b)
{
	return real(conj(a)*b);
}

double Cross(Point a,Point b)
{
	return imag(conj(a)*b);
}

Point Proj(Line l,Point p)
{
	Point a=p-l.pos,b=l.dir;
	return Dot(a,b)/norm(b)*b+l.pos;
}

int CCW(Point a,Point b,Point c)
{
	Point d1=b-a,d2=c-a;
	if(int sign=Signum(Cross(d1,d2)))
		return sign;	// 1:ccw,-1:cw
	if(Dot(d1,d2)<-EPS)
		return -2;		// c-a-b
	if(norm(d1)<norm(d2)-EPS)
		return 2;		// a-b-c
	return 0;			// a-c-b
}

double DistLP(Line l,Point p)
{
	return abs(Proj(l,p)-p);
}

double DistSP(Segment s,Point p)
{
	int ccw=CCW(s.pos,s.pos+s.dir,Proj(s,p));
	if(ccw==-2)
		return abs(p-s.pos);
	if(ccw==2)
		return abs(p-(s.pos+s.dir));
	return DistLP(s,p);
}

int main()
{
	for(int r,n;cin>>r>>n,r|n;){
		vector<Point> ps(n);
		vi rs(n),vs(n);
		rep(i,n) cin>>real(ps[i])>>imag(ps[i])>>rs[i]>>vs[i];
		
		vi in(n),down(n);
		rep(i,n)
			if(norm(ps[i])<r*r+EPS)
				in[i]=1;
		
		for(int t=1;;t++){
			vector<Point> cps(n);
			rep(i,n){
				Point d=ps[i]/abs(ps[i]);
				cps[i]=ps[i]-1.*vs[i]*t*d;
			}
			
			rep(i,n) if(!in[i] && !down[i])
				if(Signum(real(cps[i]))!=Signum(real(ps[i])) || abs(cps[i])<r+EPS)
					in[i]=1;
			
			int target=-1;
			rep(i,n) if(!in[i] && !down[i])
				if(target==-1 || abs(cps[i])<abs(cps[target])-EPS)
					target=i;
			if(target==-1)
				break;
			
			Point pt=cps[target]/abs(cps[target]);
			Segment laser(1.*r*pt,5000.*pt);
			rep(i,n) if(!in[i] && !down[i])
				if(DistSP(laser,cps[i])<rs[i]+EPS)
					down[i]=1;
		}
		
		cout<<count(all(in),1)<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 1264
/// prime factorization when number is big
#include <bits/stdc++.h>
using namespace std;
#define Mx 200001
typedef long long L;
L High[Mx],A[Mx],n,m,u,v;
void solve(){
    L c=0;
    for(L i=1;i<=n;i++){
        if(High[i]>A[i]){
            c++;
        }
    }
    printf("%lld\n",c );
}
int main()
{
    scanf("%lld%lld",&n,&m);
    for(L i=1;i<=n;i++)scanf("%lld",&High[i]);
    for(L i=0;i<m;i++){
        scanf("%lld%lld",&u,&v);
        A[u]=max(A[u],High[v]);
        A[v]=max(A[v],High[u]);
    }
    solve();
    return 0;
}
/// empty() lld I64d push_back() top() pop() insert() upper_bound() lower_bound() memset() max() min() scanf continue


Measured memory_bytes: 5384
<?php
  $s=rtrim(fgets(STDIN));
  $N=strlen($s);
  $c=0;
  for($i=0;$i<$N;$i++)$c+=$s[$i]!=$s[$N-$i-1];
  for($i=0;$i<($N-1)/2;$i++)$c+=$s[$i]!=$s[($N-1)/2-$i-1];
  echo $c?No:Yes;

Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s;
  cin >> s;
 
  int num=0;
  for(int i=0; i<(s.size()/2); i++){
  if(s[i]!=s[s.size()-1-i]){
    num++;
  }
  }
  
  cout << num << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int[] a = new int[31];
		a[1] = 1;
		a[2] = 2;
		a[3] = 4;
		for(int i=4;i<=30;i++) a[i] = a[i-1]+a[i-2]+a[i-3];
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			System.out.println(a[n]/3650+1);
		}	
	}	
}

Measured memory_bytes: 17252
#include<iostream>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<bitset>
#include<functional>
#include<iterator>
#include<complex>
#include<fstream>
#include<random>
#include<ctype.h>
#include<stdio.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using PII = pair<ll, ll>;
using piii = pair<pii, pii>;
using Pi = pair<int, pii>;
using Graph = vector<vector<int>>;
const int dx[4] = { 0, -1, 1, 0 };
const int dy[4] = { -1, 0, 0, 1 };
bool check(int x, int y) {
	if (0 <= x && x<55 && 0 <= y && y<55)return true;
	else return false;
}
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;

//iの逆元mod inf
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;
}
const double PI = 3.14159265358979323846;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
double Euclidean_distance(double x1, double y1, double x2, double y2) {
	return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}

int prime[1001000];//i番目の素数
bool is_prime[1001010];//is_prime[i]がtrueならiは素数
					   //n以下の素数の数を返す
int sieve(int n) {
	int p = 0;
	for (int i = 0; i <= n; ++i) {
		is_prime[i] = true;
	}
	is_prime[0] = false;
	is_prime[1] = false;
	for (int i = 2; i <= n; ++i) {
		if (is_prime[i]) {
			prime[p] = i;
			p++;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return p;
}

//素因数分解
map<int, int>prime_factor(int n) {
	map<int, int>res;
	for (int i = 2; i*i <= n; ++i) {
		while (n%i == 0) {
			++res[i];
			n /= i;
		}
	}
	if (n != 1)res[n] = 1;
	return res;
}


ll powmod(ll a, ll k, ll mod) {
	ll ap = a, ans = 1;
	while (k) {
		if (k & 1) {
			ans *= ap;
			ans %= mod;
		}
		ap = ap * ap;
		ap %= mod;
		k >>= 1;
	}
	return ans;
}
ll invi(ll a, ll mod) {
	return powmod(a, mod - 2, mod);
}
#define PI 3.14159265358979323846  // 円周率
//逆元Aを足したときのmodで割った余りは
//+=invi(A)
//Yで割ることはY^(10^9+7)-2を掛けることは同値
///////////////////////////////////////


int main() {
	long double a, b;
	cin >> a >> b;
	cout << ll(floor(a*b))<< endl;
	return 0;
}


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

int main() {
  int64_t N, W;
  cin >> N >> W;

  vector<int64_t> w(N + 1, 0), v(N + 1, 0);
  rep1(i, N) cin >> w.at(i) >> v.at(i);

  const int64_t W_MAX = 1e9;
  const int64_t V_MAX = accumulate(v.begin(), v.end(), 0);
  vector<vector<int64_t>> dp(N + 1, vector<int64_t>(V_MAX + 1, W_MAX));
  rep(i, N + 1) dp.at(i).at(0) = 0;

  rep1(i, N) {
    rep(j, V_MAX + 1) {
      if (j < v.at(i)) {
        dp.at(i).at(j) = dp.at(i - 1).at(j);
      } else {
        dp.at(i).at(j) =
            min(dp.at(i - 1).at(j), dp.at(i - 1).at(j - v.at(i)) + w.at(i));
      }
    }
  }

  for (int64_t i = V_MAX; i > 0; i--) {
    if (dp.at(N).at(i) <= W) {
      cout << i << endl;
      return 0;
    }
  }

  return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define ll long long
const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1);


int main(void)
{
    ll n; cin>>n;
    if(n/10%111==0 || n%1000%111==0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 3636
n,a,b = list(map(int,input().split()))
if(a != 0):
    kurikaeshi = n // (a + b)
    mod = n % (a + b)
    ans = a*kurikaeshi
    if(mod - a > 0):
        ans += a
    else:
        ans += mod
if(a == 0):
    ans = 0
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    int n;
    std::cin >> n;
    std::vector<int> h(n);
    rep(i,n) std::cin >> h[i];

    int ans = 0;
    while(std::accumulate(h.begin(),h.end(),0)){
        int cnt = 0;
        bool flag = false;
        for(int i=0; i<n; i++){
            if(h[i]==0){
                flag = false;
            }else if(flag==false){
                h[i]--;
                cnt++;
                flag = true;
            }else{
                h[i]--;
            }
        }
        ans += cnt;
    }
    std::cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3592
import java.util.*;
public class Main{
    public static void main(String[]args){
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        
        if(Math.abs(x-a)>Math.abs(x-b)){
            System.out.println("B");
        }else{
            System.out.println("A");
        }
    }
}


Measured memory_bytes: 23764
/*
  ∧,,∧
( 'ω' )つ ＜WA,またお前か！！　
（m9 ＼ 　　
　 ＼　 ＼
　 　 ) ) ＼
　 ／／ ＼ ＼
　 (＿） 　 (＿)
*/

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

#define all(x) (x).begin(),(x).end()
#define rep(x, y) for (int x = 0; x < y; x++)
#define MOD 1000000007

typedef long long LL;
typedef long double LD;

bool compare_by_b(pair<int, int> a, pair<int, int> b)
{
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

ostringstream oss_global;
string s_global = oss_global.str();

int main()
{
    int N, D;
    cin >> N >> D;

    float k = 2*D + 1;
    int ans = ceil(N/k);

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


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,a,b,c,t;
  scanf("%d",&n);
  while(n--){
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){t=a;a=b;b=t;}
    if(a<c){t=a;a=c;c=t;}
    if(a*a==b*b+c*c)printf("YES\n");
    else            printf("NO\n");
 }
 return 0;
}

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

int main() {
  int N, L; cin >> N >> L;
  string S[N]; for (int i = 0; i < N; i++) cin >> S[i];
  sort(S, S + N);
  string s = "";
  for (int i = 0; i < N; i++) s += S[i];
  cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
const int N=3000,M=3000;
int n,m;
char a[N+5],b[M+5];
int dp[N+1][M+1],pa[N+1][M+1];
int main(){
    int n,m;
    cin>>a+1>>b+1;
    n=strlen(a+1);m=strlen(b+1);
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
        dp[i][j]=dp[i-1][j];pa[i][j]=1; 
        if(dp[i][j-1]>dp[i][j])dp[i][j]=dp[i][j-1],pa[i][j]=2;
        if(a[i]==b[j]&&dp[i-1][j-1]+1>dp[i][j])dp[i][j]=dp[i-1][j-1]+1,pa[i][j]=3;
    }
    int nowi=n,nowj=m;
    string ans; 
    while(nowi&&nowj)
        if(pa[nowi][nowj]==1)nowi--;
        else if(pa[nowi][nowj]==2)nowj--;
        else ans+=a[nowi],nowi--,nowj--;
    for(int i=ans.size()-1;~i;i--)putchar(ans[i]);
    return 0;
}

Measured memory_bytes: 70656
flg = 0
n = int(input())
l = list(map(int,input().split()))
bucket = [0]*10000
for i in range(n):
    bucket[l[i]] += 1
    if flg < l[i]:
        flg = l[i]
for i in range(flg):
    for j in range(bucket[i]):
        print(i,end = ' ')
for i in range(bucket[flg]-1):
    print(flg,end=' ')
print(flg)


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

#include <boost/operators.hpp>

class modint : private boost::operators<modint>, private boost::equivalent<modint> {
  modint(const long long x, const bool y)
      : x(x) {}

 public:
  static long long M;
  long long x;
  modint(const long long x = 0)
      : x((x % M + M) % M) {}
  modint operator-() const { return modint(x ? M - x : 0, true); }
  modint& operator+=(const modint& b) { return ((x += b.x) >= M ? x -= M : 0), *this; }
  modint& operator++() { return (++x >= M ? x -= M : 0), *this; }
  modint& operator-=(const modint& b) { return ((x -= b.x) < 0 ? x += M : 0), *this; }
  modint& operator--() { return (--x < 0 ? x += M : 0), *this; }
  modint& operator*=(const modint& b) { return x = x * b.x % M, *this; }
  modint& operator/=(const modint& b) { return *this *= b.pow(-1); }
  modint pow(long long b) const {
    long long r = 1, a = x;
    b = (b % (M - 1) + (M - 1)) % (M - 1);
    while (b) {
      if (b & 1) r = r * a % M;
      b = b >> 1;
      a = a * a % M;
    }
    return modint(r, true);
  }
  friend bool operator<(const modint& a, const modint& b) { return a.x < b.x; }
  friend std::istream& operator>>(std::istream& s, modint& a) { return s >> a.x, a = a.x, s; }
  friend std::ostream& operator<<(std::ostream& s, const modint& a) { return s << a.x; }
};
long long modint::M = 1000000007;

// #LIB#

using namespace std;
using ll = long long;
#define double long double
#define rep(i, n) for (long long i = 0; i < (n); ++i)
#define repr(i, a, b) for (auto i = (a); i < (b); ++i)
#define itr(x, c) for (auto&& x : (c))
#define updatemax(t, v) ((t) = std::max((t), (v)))
#define updatemin(t, v) ((t) = std::min((t), (v)))
#define endl _endl
const char _endl = (cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout.precision(16), '\n');

int main() {
  ll n;
  cin >> n;
  vector<ll> c(n);
  rep(i, n) cin >> c[i];
  sort(c.begin(), c.end());
  modint ans;
  rep(i, n) ans += modint(c[i]) * (n + 1 - i);
  ans *= modint(4).pow(n - 1);
  cout << ans << endl;
}


Measured memory_bytes: 4732
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

vector<int>E[100000];
bool a[2][100000];
signed main(){
	int n,m;scanf("%d%d",&n,&m);
	rep(i,m){
		int a,b;scanf("%d%d",&a,&b);a--;b--;
		E[a].push_back(b);
		E[b].push_back(a);
	}
	queue<P>que;
	a[0][0]=1;que.push(P(0,0));
	while(!que.empty()){
		P p=que.front();que.pop();
		for(auto v:E[p.second]){
			if(a[!p.first][v]==0){
				a[!p.first][v]=1;
				que.push(P(!p.first,v));
			}
		}
	}
	int c=0,d=0;
	rep(i,n){
		if(a[0][i])c++;
		if(a[1][i])d++;
	}
	ll ans=0;
	rep(i,n){
		if(a[0][i]&&!a[1][i])ans+=d;
		else if(!a[0][i]&&a[1][i])ans+=c;
		else ans+=n-1;
	}
	cout<<ans/2-m<<endl;
}

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

using namespace std ;

const int MAX = 1e5 + 10 ;

char arr[MAX] ;
int n ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>n ;
	string s ;
	cin>>s ;
	char prv = 'A' ;
	for(int i = 0 ; i < 52 ; ++i)
	{
		arr[i] = prv ;
		prv++ ;
		if(prv > 'Z')
			prv = 'A' ;
	}
	for(int i = 0 ; i < s.size() ; ++i)
		cout<<arr[(int)(s[i] - 'A')+n] ;
	return 0 ;
}		

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

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

int main() {
	std::string s; cin>> s;
	const int n = s.size();
	
	std::vector<int> L(n, -1), R(n, n);
	for(int i = n - 1, tmp = n; i >= 0; i--) {
		if(s[i] == 'L') tmp = i;
		else R[i] = tmp;
	}
	for(int i = 0, tmp = -1; i < n; i++) {
		if(s[i] == 'R') tmp = i;
		else L[i] = tmp;
	}
	
	std::vector<int> ans(n, 0);
	for(int i = 0; i < n; i++) {
		if(s[i] == 'L') {
			int dist = std::abs(L[i] - i);
			
			ans[L[i] + dist % 2]++;
		} else {
			int dist = std::abs(R[i] - i);
			
			ans[R[i] - dist % 2]++;
		}
	}
	
	for(auto v: ans) printf("%d ", v);
	printf("\n");
	return 0;
}


Measured memory_bytes: 1792
#include<cstdio>
#include<cstring>
#include<string>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<map>
#include<ctime>

using namespace std;

template <typename T>

inline T read()
{
	T x=0,f=1;char c=getchar();
	while(!isdigit(c))
	{if(c=='-') f=-f;c=getchar();}
	while(isdigit(c))
	{x=(x<<3)+(x<<1)+(c-48);c=getchar();}
	return x*f;
}

#define lint long long int
#define ulint unsigned lint

const int inf=1e9+1e7;

int n,ans=0,minn=inf;

int main(void)
{

	// freopen("testdata.in","r",stdin);
	// freopen("testdata.out","w",stdout);

	scanf("%d",&n);

	for(int i=1,x;i<=n;i++)
	{
		scanf("%d",&x);
		if(x<=minn) ++ans;
		minn=min(minn,x);
	}

	printf("%d\n",ans);

	return 0;

}

Measured memory_bytes: 256
import numpy as np
N, M, Q = map(int, input().split())

train = np.zeros((N, N))
for i in range(M):
	L, R = map(int, input().split())
	train[N-L][R-1] += 1
train = np.cumsum(np.cumsum(train, axis=0), axis=1)

for _ in range(Q):
	p, q = map(int, input().split())
	print(int(train[N-p][q-1]))

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

using namespace std;

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

	int n,a,b;

	cin >> n;

	if(n==1)
	{
		cout << "Hello World" << '\n';
	}
	else
	{
		cin >> a;
		cin >> b;

		cout << a+b << '\n';
	}
	return 0;
}

Measured memory_bytes: 256
module Main where

    import Debug.Trace
    import Data.Ord
    
    solve :: Int -> Int -> Int -> String
    solve a b c
        | a < b && b < c = "Yes"
        | otherwise = "No"
    
    readLine:: IO [Int]
    readLine = fmap (map read . words) getLine
    
    main :: IO() 
    main = do
        [a, b, c] <- readLine
        let ans = solve a b c
        putStrLn ans
    


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>

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

using namespace std;

int main(){
	string s; cin>>s;
	int n=s.length();

	vector<int> R,L;
	int rpre=0,lpre;
	for(int i=1;i<n;i++){
		if(s[i-1]=='R' && s[i]=='L'){
			R.emplace_back(i-rpre);
			lpre=i;
		}
		else if(s[i-1]=='L' && s[i]=='R'){
			L.emplace_back(i-lpre);
			rpre=i;
		}
	}
	L.emplace_back(n-lpre);

	rep(i,R.size()){
		rep(j,R[i]-1) printf("0 ");
		printf("%d %d ",(R[i]+1)/2+L[i]/2,(L[i]+1)/2+R[i]/2);
		rep(j,L[i]-1) printf("0 ");
	}

	return 0;
}


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

public class Main {
	public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
        sc.close();
    }
    
	//フィールド
    Scanner sc;
    int N;
    int K;
    int[] H;    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        this.N = sc.nextInt();
        this.K = sc.nextInt();
        H = new int[N];
        for (int i=0; i<N; i++) {
        	H[i] = sc.nextInt();
        }
    }
    
    //解答処理
    private long solve() {
        long count = 0;
        Arrays.sort(H);
        
        for (int i=0; i<N-K; i++) {
        	count += H[i];
        }
        
        return count;
    }
    
    //出力
    public void show(long answer) {
        System.out.println(answer);
    }

}


Measured memory_bytes: 60856
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int h=sc.nextInt();
        int n=sc.nextInt();
        int[] a=new int[n];
        int[] b=new int[n];
        for(int i=0;i<n;i++)
        {
            a[i]=sc.nextInt();
            b[i]=sc.nextInt();
        }
        int[] dp=new int[h+1];
        Arrays.fill(dp, Integer.MAX_VALUE);
        dp[0]=0;
            for(int j=1;j<=h;j++)
                for(int i=0;i<n;i++)
            {
               dp[j]=Math.min(dp[j],dp[Math.max(0,j-a[i])]+b[i]);
            }
        int res=Integer.MAX_VALUE;
            for(int j=h;j<h+1;j++)
            {
                res=Math.min(res,dp[j]);
            }
            System.out.println(res);
    }

}

Measured memory_bytes: 25736
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = sc.nextInt();
        String S = sc.next();
        sc.close();

        if (K - S.length() < 0) {
            System.out.println(S.substring(0, K) + "...");
        } else {
            System.out.println(S);
        }
    }
}

Measured memory_bytes: 38592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n,x) for(int i=n;i<x;i++)
using ll = long long;
const ll INF = 1e9 + 7;

int main() {
	int n; cin >> n;
	vector<ll> h(n); rep(i, 0, n) cin >> h[i];

	vector<ll> dp(n, INF);
	dp[0] = 0;
	rep(i, 1, n) {
		dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), 
					dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[n - 1] << endl;

	return 0;
}

Measured memory_bytes: 1792
S = input()
T = input()
ans = 0
for i in range(len(S)-len(T)+1):
    s = S[i:i+len(T)]
    num = 0
    for j in range(len(T)):
        if s[j] == T[j]:
            num += 1
    if num>ans:
        ans = num
print(len(T)-ans)

Measured memory_bytes: 73308
n = int(input())
a = n - 1
p = 1
for c in range(2, int((n ** 0.5) * 2)):
    if p % 2 == 1 and c > (n ** 0.5):
        break
    if n % c == 0:
        p = c
        w = int(n / c)
        if (w + c - 2) < a:
            a = (w + c -2)
        else:
            continue
    else:
        continue
print(a)


Measured memory_bytes: 40940
#include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int x;
	int ans;
	int tmp = 1;
	int num[100];
	
	cin >> x;
	
	for (int i = 1; i <= 100; i++) {
		tmp = i;
		for (int j = 1; j <= 100; j++) {
			for (int k = 0; k < j; k++) {
				tmp *= i;
			}
			if (tmp > x) {
				break;
			}
			num[i] = tmp;
			tmp = i;
			
		}
	}
	
	
	sort(num, num + 100);
	reverse(num, num + 100);
	
	for (int i = 1; i <= 100; i++) {
		if (num[i] <= x) {
			cout << num[i] << endl;
			break;
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>str;
    if(str[2]==str[3]&&str[4]==str[5]) cout<<"Yes";
    else cout<<"No";
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //std::mt19937_64 rng(std::chrono::steady_clock::now().time_since_epoch().count());
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] arges) {

		Scanner sc = new Scanner(System.in);
		String line = sc.nextLine();
		int v = Integer.parseInt(line);
		int[] vs = new int[v];
		for (int i = 0; i < v; i++) {
			String line2 = sc.nextLine();
			vs[i] = Integer.parseInt(line2);
		}

		int min = vs[0];
		int max = vs[1]-vs[0];
		for (int i = 1; i < v; i++) {
			if (max<vs[i]-min) {
				max=vs[i]-min;
			}
			if (min>vs[i]) {
				min=vs[i];
			}
			}
		System.out.println(max);

	}
}

Measured memory_bytes: 170192
#include<iostream>
#include<math.h>
#include<string.h>
#include<vector>
using namespace std;

int main(){
	long long n,k;
	cin >> n >> k;
	vector<long long> a(n,0);
	long long hani=k-1;
	
	for(long long i=0;i<n;i++){
		cin >> a[i];
	}
	
	int cnt=0;
	int temp=n;
	while(1){
		temp-=k;
		cnt++;
		if(temp>0){
			temp++;
		}
		if(temp<=0)break;
	}
	cout << cnt << endl;
	
	return 0;
}


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		final int n = sc.nextInt(), d[] = new int[n + 1];
		for(int i = 0; i < n; ++i) 
			d[i] = sc.nextInt();
		sc.close();
		d[n] = 1000;
		Arrays.sort(d);
		int ans = 0;
		for(int i = 0; i < n; ++i) {
			if(d[i] != d[i + 1])++ans;
		}
		System.out.println(ans);
	}

}


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

int main() {
  int n;
  cin >> n;
  vector<string> moji(n);
  set<string> S;
  for (int i = 0; i < n; i++) {
    cin >> moji.at(i);
    S.insert(moji.at(i));
  }
  
  if (S.size() != n) {
    cout << "No" << endl;
  }
  else {
    for (int i = 0; i < n - 1; i++) {
      if (moji.at(i).at(moji.at(i).size() - 1) != moji.at(i + 1).at(0)) {
        cout << "No" << endl;
        break;
      }
      else {
        if (i == n - 2) {
          cout << "Yes" << endl;
        }
      }
    }
  }
}


Measured memory_bytes: 256