akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main(){
	int n, res;
	cin >> n;
	int dif[n], v[n], c[n];
	for(int i=0; i<n; i++){
		cin >> v[i];
	}
	for(int i=0; i<n; i++){
		cin >> c[i];
	}
	for(int i=0; i<n; i++){
		dif[i] = v[i] - c[i];
	}
	res = 0;
	for(int i=0; i<n; i++){
		if(dif[i] > 0){
			res += dif[i];
		}
	}
	cout << res << endl;
	return 0;
}

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

const int inf = 1e18;

bool dfs(int u, auto& vis, const auto& g) {
    bool f = true;
    for (auto p : g[u]) {
        int v = p.first;
        int d = p.second;

        if (vis[v] == inf) {
            vis[v] = vis[u] + d;
            f &= dfs(v, vis, g);
        }
        else {
            f &= (vis[v] == vis[u] + d);
        }
    }
    return f;
}
signed main() {
    int N, M;
    cin >> N >> M;

    vector<vector<pair<int, int>>> G(N);
    for (int i = 0; i < M; i++) {
        int l, r, d;
        cin >> l >> r >> d;
        --l, --r;

        G[l].push_back({r, d});
        G[r].push_back({l, -d});
    }

    vector<int> vis(N, inf);
    bool f = true;
    for (int i = 0; i < N; i++) {
        if (vis[i] != inf) continue;
        vis[i] = 0;
        f &= dfs(i, vis, G);
    }
    cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 18304
n=parse(Int,readline())
a=map(x->parse(Int,x),split(readline()))
v=zeros(100010);
for i=1:n
	v[a[i]+1]+=1
end
s=0
for i=2:100000
	m=v[i-1]+v[i]+v[i+1]
	if s<m
		s=m
	end
end
print(Int(s))

Measured memory_bytes: 178976
#include <bits/stdc++.h>
#define N 200001
using namespace std;
int n,m;
char a[N];
int main()
{
	scanf("%d%d%s",&n,&m,a+1);
	int sum=0;bool flag=1;
	for(int i=1;i<=n;i++)
	{
		if((i==1 || flag) && a[i]=='L') flag=0,sum++;
		if((i==1 || !flag) && a[i]=='R') flag=1,sum++; 
	}
	printf("%d\n",n-max(sum-m*2,1));
	return 0;
}

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

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

int main() {
    ll n,k;cin>>n>>k;
    ll a[n];
    for(ll i=0;i<n;i++){
        cin>>a[i];
    }
    bool dp[k+1];
    dp[0]=false;
    bool b;
    for(ll i=1;i<=k;i++){
        b=false;
        for(ll j=0;j<n;j++){
            if(b==false){
                if(i-a[j]>=0){
                    if(dp[i-a[j]]==false) b=true;
                }
            }
        }
        dp[i]=b;
    }
    
    if(dp[k]==true){
        cout<<"First"<<endl;
    }else{
        cout<<"Second"<<endl;
    }
    
    return 0;
}


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

int main() {
	int n;
	cin >> n;
	int c = 0;
	rep(i, n) {
		int w;
		cin >> w;
		if(w % 2 == 0) {
			c++;
		}
	}
	cout << c << endl;
}


Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define ll long long

using namespace std;

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

    int h, w;
    cin>>h>>w;

    int arr[h][w];
    memset(arr, 0, sizeof(arr[0][0])*h*w);
    for (int i=0;i<h;i++)
    {
        string s;
        cin>>s;
        for (int j=0;j<w;j++)
        {
            if (s[j]=='#')
            {
                arr[i][j]=-1;
            }
        }
    }
    for (int i=0;i<h;i++)
    {
        for (int j=0;j<w;j++)
        {
            if (arr[i][j]==-1)
            {
                int u=h-i, d=i+1, r=j+1, l=w-j;
                //up
                int x=i, y=j;
                while (x!=0)
                {
                    x--;
                    if (arr[x][y]==-1)
                        break;
                    else
                        arr[x][y]+=u;
                }
                //down
                x=i, y=j;
                while (x!=h-1)
                {
                    x++;
                    if (arr[x][y]==-1)
                        break;
                    else
                        arr[x][y]+=d;
                }
                //left
                x=i, y=j;
                while (y!=0)
                {
                    y--;
                    if (arr[x][y]==-1)
                        break;
                    else
                        arr[x][y]+=l;
                }
                //right
                x=i, y=j;
                while (y!=w-1)
                {
                    y++;
                    if (arr[x][y]==-1)
                        break;
                    else
                        arr[x][y]+=r;
                }
            }
        }
    }
    int mini = INT_MAX;
    for (int i=0;i<h;i++)
    {

        for (int j=0;j<w;j++)
        {
            if (arr[i][j]!=-1)
                mini = min(mini, arr[i][j]);
        }
    }

    cout<<h+w-1-mini;




}



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

int main() {
  int N; cin >> N;
  
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin >> A.at(i);
  }
  
  vector<int> B(N);
  for(int i=0;i<N;i++){
    cin >> B.at(i);
  }
  
  vector<int> C(N-1);
  for(int i=0;i<N-1;i++){
    cin >> C.at(i);
  }
  
  int ans=0;
  for(int i=0;i<N;i++){
    ans += B.at(i);
  }
  
  for(int i=0; i < N-1; i++){
    if(A.at(i+1) - A.at(i) == 1){
      ans += C.at(A.at(i)-1); //A_iは1-indexedなので-1する必要がある
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        class CountedHashSet
        {

            class InveerseCompare : IComparer<int>
            {
                public int Compare(int x, int y)
                {
                    return y - x;
                }
            }

            public class Counter
            {
                public Counter()
                {
                    count = 1;
                }

                public int count { get; set; }
            }


            public SortedDictionary<int, Counter> keySet;

            public CountedHashSet()
            {
                keySet = new SortedDictionary<int, Counter>(new InveerseCompare());
            }

            public void Add(int key)
            {
                Counter c;

                if (keySet.TryGetValue(key, out c))
                {
                    c.count++;
                }
                else
                {
                    keySet.Add(key, new Counter());
                }
            }

            public int GetKeyCount(int key)
            {
                Counter c;

                if (keySet.TryGetValue(key, out c))
                {
                    return c.count;
                }

                return 0;
            }
        }

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            CountedHashSet hs = new CountedHashSet();

            string[] s = Console.ReadLine().Split(' ');
            for (int i = 0; i < N; i++)
            {
                int v = int.Parse(s[i]);
                hs.Add(v);
            }

            int ans = 0;
            foreach (KeyValuePair<int, CountedHashSet.Counter> e in hs.keySet)
            {
                if (e.Value.count >= 2)
                {
                    if ( e.Value.count >= 4)
                    {
                        if ( 0 == ans)
                        {
                            Console.WriteLine(Math.BigMul(e.Key, e.Key));
                        }
                        else
                        {
                            Console.WriteLine(Math.BigMul(ans, e.Key));
                        }
                        return;
                    }

                    if (0 == ans)
                    {
                        ans = e.Key;
                    }
                    else
                    {
                        Console.WriteLine(Math.BigMul(ans, e.Key));
                        return;
                    }
                }
            }

            Console.WriteLine(0);
        }
    }
}


Measured memory_bytes: 30808
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
from heapq import heappop, heappush
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return sorted([list(map(int, input().split())) for _ in range(n)])
def sortx(x,n,k):
    if k == 0:x.sort(key=lambda y:y[1,n])
    else:x.sort(reversed=True, key=lambda y:y[1,n])
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a=inp()
        a-=1
        g[i].append(a)
        g[a].append(i)
    return n,g
def graphm():
    n,m=inpm()
    g=[[] for _ in range(n)]
    for _ in range(m):
        a,b,w=inpm()
        a-=1
        b-=1
        g[a].append((b,w))
        g[b].append((a,w))
    return n,m,g

def dijkstra(s,n,g): # sからの最短距離 頂点数n
    s -= 1
    que = []
    d = [10**15 for _ in range(n)]
    d[s] = 0
    heappush( que,(0,s) )
    while len(que)>0:
        p =  heappop(que)
        v = p[1]
        if d[v] < p[0]:
            continue
        for i in range(len(g[v])):
            edge = g[v][i]
            if d[edge[0]] > d[v] + edge[1]:
                d[edge[0]] = d[v] + edge[1]
                heappush( que,(d[edge[0]] , edge[0]) )
    return d

def combi(x,y):
    a=1
    while x>0:
        a=(a*x)%mod
        x-=1
    z=x-y
    while y>0:
        a=(a*pow(y,mod-2,mod))%mod
        y-=1
    while z>0:
        a=(a*pow(z,mod-2,mod))%mod
        z-=1
    return int(a)
    
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    #[x,y]
    return [w[0],w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def main():
    x,y=inpm()
    if x<y:
        x,y=y,x
    if x>2*y:
        print(0)
        return
    d=x-y
    n=(x-2*d)*(1/3)
    if n%1!=0:
        print(0)
        return
    n=int(n)
    a=n+d
    b=n    
    
    res = 1
    for i in range(1,a+b+1):
        res = res*i%mod
    for i in range(1,a+1):
        res = res*mod_inv(i,mod)%mod
    for i in range(1,b+1):
        res = res*mod_inv(i,mod)%mod
    print(res)

if __name__ == "__main__":
    main()




Measured memory_bytes: 44920
// AOJ 405 ASCII Characters
// 2019.9.29

#include <stdio.h>
#include <ctype.h>

int main()
{
	int N;

	scanf("%d", &N);
	if (isupper(N)) putchar('1');
	else if (islower(N)) putchar('2');
	else putchar('0');
	putchar('\n');
	return 0;
}


Measured memory_bytes: 2096
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> a(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];

    int abs_max = INT_MIN;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j)
            abs_max = max(abs_max, abs(a[i] - a[j]));
    }
    cout << abs_max << '\n';
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    String S =sc.next();
    String s[] =S.split("",0);
    String T =sc.next();
    String t[] =T.split("",0);
    int N =S.length();
    int a=N;
    for(int i=0;i<N;i++){
      if(s[i].equals(t[i])){a=a-1;}}
    System.out.println(a);
  }
}


Measured memory_bytes: 65868
import heapq
from collections import Counter
inf = 10**10
n, k = map(int, input().split())

dset = [[] for i in range(n)]
for i in range(n):
    t, d = map(int, input().split())
    dset[t-1].append(d)

for dd in dset:
    if dd: dd.sort(reverse=True)
    else: dd.append(-inf)

dset.sort(key= lambda x: -x[0])

cur = 0
hq = []
# k種類の先頭を除いて格納
for i in range(k):
    cur+=dset[i][0]
    for d in dset[i][1:]: heapq.heappush(hq, -d)

# 残りの種類のすべてを格納
for dd in dset[k:]:
    for d in dd:
        heapq.heappush(hq, -d)

ans = cur + k*k
for i in range(k-1, -1, -1):
    v = dset[i][0] # 削除候補
    if hq:
        w = -heapq.heappop(hq)
    else:
        break
    if v < w:
        cur += w - v
        # heapq.heappush(hq, -v)
    else:
        heapq.heappush(hq, -w)
    ans = max(ans, cur + i*i)
print(ans)

Measured memory_bytes: 33880
import java.util.*;

public class Main {
  public static void main(String args[]) {
    Scanner sc = new Scanner(System.in);
    int n = 1;
    int x = sc.nextInt();
    while (x != 0) {
      System.out.println("Case " + n + ": " + x);
      n++;
      x = sc.nextInt();
    }
  }
}
  

Measured memory_bytes: 41356
N = int(input())
B = list(map(int,input().split()))
A = [0]*N
for i in range(N-1):
  if B[i] > B[i-1] and i > 0:
    A[i] = B[i-1]
  else:
    A[i] = B[i]
ans = sum(A) + B[-1]
print(ans)

Measured memory_bytes: 3060
//1????????????????????????1?????????????????????
//??????????????????????????¨?????§???????????????A???????????????B???????????°???min(A, B)???????¬????????????\??????
//????????????????????????
//????£????????????????????????°?????????????????§???????????§??????????????????
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

struct DATABASE{
	vector<int> kougiS, kougiE;
	int n;
	vector<int> teacherS[100], teacherE[100];
	int m;
	vector<int> studentS[100], studentE[100];
}db;

void solve(){
	int i, j, k;
	int ans = 0;
	for( i = 0; i < db.kougiS.size(); i++ ){
		int s = db.kougiS[i];
		int e = db.kougiE[i];
		int teacherNum = 0, studentNum = 0;
		for( j = 0; j < db.n; j++ ){
			//j??????????????????i????????????????????§??????????????????
			for( k = 0; k < db.teacherS[j].size(); k++ ){
				if( db.teacherS[j][k] <= s && e <= db.teacherE[j][k] )
					break;
			}
			if( k < db.teacherS[j].size() ){
				teacherNum++; //????????§??????
			}
		}
		for( j = 0; j < db.m; j++ ){
			//j??????????????????i????????????????????§??????????????????
			for( k = 0; k < db.studentS[j].size(); k++ ){
				if( db.studentS[j][k] <= s && e <= db.studentE[j][k] )
					break;
			}
			if( k < db.studentS[j].size() ){
				studentNum++; //????????§??????
			}
		}
		ans += min(teacherNum, studentNum);
	}
	cout << ans << endl;
}

void input(){
	int i, j;
	int n, k;
	string s;
	
	cin >> k;
	for( i = 0; i < k; i++ ){
		cin >> s;
		int hs = (s[0] - '0') * 10 + (s[1] - '0');
		int ms = (s[3] - '0') * 10 + (s[4] - '0');
		int he = (s[6] - '0') * 10 + (s[7] - '0');
		int me = (s[9] - '0') * 10 + (s[10] - '0');
		db.kougiS.push_back(hs * 60 + ms);
		db.kougiE.push_back(he * 60 + me);
	}
	cin >> n;
	db.n = n;
	for( i = 0; i < n; i++ ){
		cin >> k;
		for( j = 0; j < k; j++ ){
			cin >> s;
			int hs = (s[0] - '0') * 10 + (s[1] - '0');
			int ms = (s[3] - '0') * 10 + (s[4] - '0');
			int he = (s[6] - '0') * 10 + (s[7] - '0');
			int me = (s[9] - '0') * 10 + (s[10] - '0');
			db.teacherS[i].push_back(hs * 60 + ms);
			db.teacherE[i].push_back(he * 60 + me);
		}
	}
	cin >> n;
	db.m = n;
	for( i = 0; i < n; i++ ){
		cin >> k;
		for( j = 0; j < k; j++ ){
			cin >> s;
			int hs = (s[0] - '0') * 10 + (s[1] - '0');
			int ms = (s[3] - '0') * 10 + (s[4] - '0');
			int he = (s[6] - '0') * 10 + (s[7] - '0');
			int me = (s[9] - '0') * 10 + (s[10] - '0');
			db.studentS[i].push_back(hs * 60 + ms);
			db.studentE[i].push_back(he * 60 + me);
		}
	}
}

int main()
{
	input();
	solve();
	return 0;
}

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

int main(){
    double D, T, S;
    cin >> D >> T >> S;

    double ans;

    ans = D / S;

    if(T < ans){
        cout << "No" << endl;
    } else if(ans <= T){
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3720
#include<bits/stdc++.h>
using namespace std;
vector<int>v;
int a[1010000],n,q,sum;
int main(){
	srand(time(0));
	scanf("%d",&n);
	n-=2;
	int bg1,bg2;
	scanf("%d%d",&bg1,&bg2);
	for(int i=1;i<=n-1;++i)
//		a[i]=rand()%10;
		scanf("%d",&a[i]);
	for(int i=1;i<=n-1;++i)sum+=a[i];
	v=vector<int>(sum+1);
	for(int i=0;i<=sum;++i)v[sum-i]=i;
	for(int i=1;i<=n-1;i++){
		int sz=v.size()-1;
		for(int j=1;j<=a[i];++j)v.push_back(v[sz-j]);
	}
	scanf("%d",&q);
	while(q--){
		int x;
		scanf("%d",&x);
		if(x>=sum)printf("%d\n",x-sum+bg1-bg2);
		else printf("%d\n",v[v.size()-1-x]+bg1-bg2);
	}
}

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

using namespace std;

/**************************************************************/

#define int long long
#define tie() ios_base :: sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define f(i,from,to) for(int i = from ; i <to ; i++)
#define mem(a , v) memset(a , v , sizeof a)
#define all(v) v.begin() , v.end()
#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define what_is(x) cerr << #x << " is : " << x <<endl

const int INF = 1e9 + 7;
const int sz = 1e5 + 20;
/***************************************************************/


char shift(char a , int n)
{
    int x = a - 'A';
    f(i,0,n)
    {
        x = (x+1)%26;
    }
    return x + 'A';
}


void solve()
{
    int n;cin>>n;
    string s;cin>>s;
    for(int i = 0 ; i < s.length() ; i++)
    {
        s[i] = shift(s[i] , n);
    }
    cout<<s<<endl;
    return;
}


int32_t main()
{
    clock_t st = clock();
    tie();
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    clog<<(long double)((clock() - st)/CLOCKS_PER_SEC)<<endl;
    return 0;
}


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

using namespace std;
#define int long long
#define double long double
#define rep(i, n) for(int i=0;i<(n);++i)
#define INF (1ll<<60)
#define FI first
#define SE second
typedef pair<int, int> pii;
#define l_b lower_bound
#define u_b upper_bound

int N;
int MARCH[5];//M, A, R, C, H

signed main() {
    cin >> N;
    rep(i, N) {
        string s;
        cin >> s;
        if (s[0] == 'M')MARCH[0]++;
        if (s[0] == 'A')MARCH[1]++;
        if (s[0] == 'R')MARCH[2]++;
        if (s[0] == 'C')MARCH[3]++;
        if (s[0] == 'H')MARCH[4]++;
    }
    int ans = 0;
    rep(i, 5) {
        rep(j, 5) {
            rep(k, 5) {
                if (i < j && j < k) {
                    ans += MARCH[i] * MARCH[j] * MARCH[k];
                }
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
const int INFTY =2147483647;
int main(){
    ll n;
    ll sum=0;
    cin>>n;
    ll A[200005]={},X[200005]={};
    REP(i,n){
        cin>>A[i];
        X[A[i]]++;
    }
    REP(i,n+1){
        sum+=(X[i]*(X[i]-1))/2;
    }
    REP(i,n){
        cout<<sum-((X[A[i]]*(X[A[i]]-1))/2)+(((X[A[i]]-1)*(X[A[i]]-2))/2)<<endl;
    }
}

Measured memory_bytes: 5760
#include<cstdio>
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
string s;
string w[]={"KIHBR","AKIHBR","KIHABR","KIHBAR","KIHBRA","AKIHABR","AKIHBAR","AKIHBRA","KIHABAR",
"KIHABRA","KIHBARA","AKIHABAR","AKIHABRA","AKIHBARA","KIHABARA","AKIHABARA"};
int main(void){
	register int i;
	cin>>s;
	for(i=0;i<16;++i)
		if(s==w[i]){
			puts("YES");
			return 0;
		}
	puts("NO");
	return 0;
}

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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
    int n;
    cin >> n;
    VI v(n),c(n);
    rep(i,n) cin >> v[i];
    rep(i,n) cin >> c[i];
    ll ans = 0;
    rep(i,n){
        if(v[i] > c[i]) ans += v[i] - c[i];
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize (2)
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 330000
using namespace std;
inline char gc(){
	/*static char now[1<<16],*T,*S;
	if (T==S){T=(S=now)+fread(now,1,1<<16,stdin);if (T==S) return EOF;}
	return *S++;*/return getchar();
}
inline int read(){
	int x=0;char ch=getchar();
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch<='9'&&ch>='0'){x=x*10+ch-'0';ch=getchar();}
	return x;
}
struct node{
	int l,r;
}line[N];
inline bool cmp(node a,node b){return a.l<b.l;}
struct node1{
	int left,right,v;
}tree[N*20];
int num,n,m,root[N];
inline void insert1(int &x,int l,int r,int p){
	tree[++num]=tree[x];x=num;tree[x].v++;if (l==r) return;
	int mid=l+r>>1;if (p<=mid) insert1(tree[x].left,l,mid,p);else insert1(tree[x].right,mid+1,r,p);
}
inline int query(int rt1,int rt2,int l,int r,int l1,int r1){
	if (l1<=l&&r1>=r) return tree[rt2].v-tree[rt1].v;
	int mid=l+r>>1;int tmp=0;if (l1<=mid) tmp+=query(tree[rt1].left,tree[rt2].left,l,mid,l1,r1);
	if (r1>mid) tmp+=query(tree[rt1].right,tree[rt2].right,mid+1,r,l1,r1);return tmp;
}
int main(){
	//freopen("arc.in","r",stdin);
	n=read();m=read();
	for (int i=1;i<=n;++i) line[i].l=read(),line[i].r=read();
	sort(line+1,line+n+1,cmp);int tot=0;printf("%d\n",n);
	for (int i=1;i<=m;++i){root[i]=root[i-1];
	while(line[tot+1].l==i) insert1(root[i],1,m,line[tot+1].r),++tot;}
	for (int len=2;len<=m;++len){
		int j=len,tmp=0,now=m%len;now=m-now;
		for (;j<=m;j+=len) tmp+=query(root[j-len],root[j-1],1,m,j-len+1,j-1);
		if(now<m) tmp+=query(root[now],root[m],1,m,now+1,m);
		printf("%d\n",n-tmp);
	}
	return 0;
}

Measured memory_bytes: 68608
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int a,b; cin>>a>>b;
    
    cout << gcd(a,b)*a/gcd(a,b)*b/gcd(a,b) << ln;
    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = n - 1; 0 <= i; i--){
		cout << a[i];
		if(i != 0){
			cout << " ";
		}
	}
	cout << "\n";
}


Measured memory_bytes: 3104
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll n,d; cin>>n>>d;
    d=2*d+1;
    cout<<(n/d)+(n%d?1:0);

}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    //for getting error from error.txt
    freopen("error.txt", "w", stderr);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    cerr<<"Time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<"\n";
    cerr<<"My CLOCKS_PER_SEC= "<<CLOCKS_PER_SEC<<"\n";
    return 0;
}


Measured memory_bytes: 3708
#include <stdio.h>
int main(){
	int w,h,i,a,b;
	int x[31],y[31];
	scanf("%d%d",&w,&h);
	for(i=1;i<=w;i++){
		x[i]=i;
	}
	for(i=0;i<h;i++){
		scanf("%d,%d",&a,&b);
		int f=x[b];
		x[b]=x[a];
		x[a]=f;
	}
	for(i=1;i<=w;i++){
		printf("%d\n",x[i]);
	}
	scanf("%d",&i);
	return 0;
}

Measured memory_bytes: 592
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			String str = null;

			while (!(str = sc.next()).equals("-")) {
				int m = sc.nextInt();

				for (int i = 0; i < m; i++) {
					int idx = sc.nextInt();
					str = str.substring(idx) + str.substring(0, idx);
				}
				System.out.println(str);
			}
		}
	}
}


Measured memory_bytes: 26624
def main():
	import numpy as np
	n = input()
	d = len(n)
	max = n

	r = 0		
	
	for i in range(3, d+1):#i keta wo tukuru
		for j in range(3**i):
			count = j
			buf = ""
			for k in range(1, i+1):#k keta
				if(count // 3**(i-k) == 2):
					buf = buf+"7"
					count -= 3**(i-k)*2
				elif(count // 3**(i-k) == 1):
					buf = buf+"5"
					count -= 3**(i-k)*1
				elif(count // 3**(i-k) == 0):
					buf = buf+"3"
			if("7" in buf and "5" in buf and "3" in buf and int(buf) <= int(max)):
				r += 1
				#print(buf)
	print(r)
		
main()

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

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define MOD 1000000007

#define trace1(x)                    cout <<#x<<": "<<x<< endl;
#define trace2(x, y)                 cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<< endl;
#define trace3(x, y, z)              cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl;
#define trace4(a, b, c, d)           cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;

typedef long long ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(NULL);
    ll i,j,n,m;
    cin>>n>>m;
    ll a[n];
    for(i=0;i<n;i++)
    cin>>a[i];
    vector<pair<ll,ll> > v;
    for(i=0;i<m;i++)
    {
        ll x,y;
        cin>>x>>y;
        v.pb(mp(y,x));
    }
    sort(all(v));
    sort(a,a+n);
    ll sum=0;
    ll ind=m-1;
    i=0;
    while(i<n)
    {
        if(ind>=0)
        {
            ll tot=v[ind].second;
            ll ele=v[ind].first;
            while(tot>0 && i<n)
            {
                if(a[i]<ele)
                {
                    a[i]=ele;
                    tot--;
                }
                sum+=a[i];
                i++;
            }
            ind--;
        }
        else
        {
            sum+=a[i];
            i++;
        }
    }
    cout<<sum;
    return 0;
}

Measured memory_bytes: 4212
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using ll = long long;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
const ll INF = 1LL << 60;

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

  ll n;
  cin >> n;
  map<pll, ll> m;
  REP(i, 1, n + 1) {
    string s = to_string(i);
    ll a = s[0] - '0', b = s[s.size() - 1] - '0';
    // if (a > b) swap(a, b);
    if (a == 0 || b == 0) continue;
    // cout << i << ":" << a << "," << b << endl;
    m[{a, b}]++;
  }
  ll ans = 0;
  for (auto& x : m) {
    pll p = x.first;
    ll c = x.second;
    ll a = p.first, b = p.second;
    ll d = m[{b, a}];
    ans += c * d;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#n=int(input())
a,b,c=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
k=int(input())
ans='No'
for i in range(0,k+1):
    cnew=c*(2**(i))
    bnew=b*(2**(k-i))
    if a<bnew and bnew<cnew:
        ans='Yes'
print(ans)


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

int main(){
	string s;
  	cin>>s;
  	if((s[0]==s[1]&&s[1]==s[2])||(s[3]==s[1]&&s[1]==s[2]))
      	cout<<"Yes";
  	else
    	cout<<"No";

}

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

int main(){
    int a, b, c, d;
    scanf("%d %d %d %d", &a, &b, &c, &d);
    int d1, d2, d3;
    d1 = abs(a-b);
    d2 = abs(b-c);
    d3 = abs(c-a);
    if ((d1 <= d && d2 <= d) || d3 <= d) {
        printf("%s\n", "Yes");
    } else {
        printf("%s\n", "No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
int l[26];
int main(){
	//freopen("input.txt","r",stdin);// <--Remove Before Submit
	string s,a;
	cin >> s;
	ll d=1,num=0;
	int len = s.length();
	for(int x=0;x<len;x++){
		l[s[x]-'a']++;
		num++;
	}
	for(int x=0;x<26;x++){
		num -= l[x];
		d+= num*l[x];
	}
	cout << d << endl;
}

Measured memory_bytes: 640
while True:
    n,x=map(int, input().split())
    if n==0 and x==0:
        exit()
    ans = 0
    for i in range(1,n+1):
        for j in range(i+1,n+1):
            for k in range(j+1,n+1):
                if i+j+k==x:
                    ans += 1
    print(ans)


Measured memory_bytes: 5596
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>P;
ll n,m,cnt,a[100000],b[100000],x,y,l,ans;
vector<P>v;
int main(void){
    cin>>n>>m;
    for(int i=0;i<n;i++)cin>>a[i];
    sort(a,a+n);
    for(int i=0;i<m;i++){
        cin>>x>>y;
        v.push_back({y,x});
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    for(auto z:v){
        if(l==100000)break;
        for(int i=0;i<z.second;i++){
            if(l==100000)break;
            b[l]=z.first;
            l++;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]<b[i])ans+=b[i];
        else ans+=a[i];
        //cout<<ans<<endl;
    }
    cout<<ans<<endl;
}


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

int check(long long int p, int *w, int n, int k);
int solve(int n, int k, int *w);
int main(){
  int n, k;
  cin >> n >> k;
  int w[n];
  long long int sum=0;
  for(int i=0; i<n; i++) {
    cin >> w[i];
    sum += w[i];
  }


  cout << solve(n, k, w) << endl;
  return 0;
}

int check(long long int p, int *w, int n, int k){
  int i=0;
  for(int j=0; j<k; j++){
    long long int s=0;
    while(s+w[i]<=p){
      s += w[i];
      i++;
      if(i==n) return n;
    }
  }
  return i;
}

int solve(int n, int k, int *w){
  long long int left=0, right=1000000000, m;
  int v;
  while(right>left+1){
    m = (left+right)/2;
    v = check(m, w, n, k);
    if(v>=n) right=m;
    else left=m;
  }
  return right;
}



Measured memory_bytes: 3468
#include <bits/stdc++.h>
using namespace std;
int main(void){
    
    int N;
    int h[100000] = {};
    
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    
    // DPの宣言と初期値を設定
    long long dp[100001];
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
    
    for(int i = 2; i < N; i++){
        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;
}


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

int main () {
  ll x;
  cin >> x;
  
  for (int i = -150; i <= 150; i++) {
    for (int j = -150; j <= 150; j++) {
      ll a = pow(i,5), b = pow(j,5);
      if (a-b == x) {
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
}

Measured memory_bytes: 4072
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
using ll = long long;
#define endl '\n'
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    string s;
    cin >> s;
    int i = 0;
    int len = 0;
    int n = (int)s.size();
    while(i < n){
        int j = i + 1;
        while(j < n && s[j] == s[j - 1]){
            j++;
        }
        if(s[i] == 'R'){
            len = max(len, j - i);
        }
        i = j;
    }
    cout << len << endl;
}
int main(){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);


    solve();
}


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

int main()
{
	string n;
	cin >> n;
	int chk = 0;
	for(int i = 0; i < (int)n.size(); ++i){
		chk += (n[i] - '0');
		chk %= 9;
	}
	cout << (chk % 9 == 0 ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3700
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
	static final long MOD = 1000000007L;
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		PrintWriter pw = new PrintWriter(System.out);
		
		int A = sc.ni();
		int B = sc.ni();
		int C = sc.ni();
		int K = sc.ni();
		for (int a = 0; a <= K; a++) {
			for (int b = 0; b <= K-a; b++) {
				for (int c = 0; c <= K-a-b; c++) {
					int X = A*(1<<a);
					int Y = B*(1<<b);
					int Z = C*(1<<c);
					if (X < Y && Y < Z) {
						pw.println("Yes");
						pw.close();
						return;
					}
				}
			}
		}
		pw.println("No");
		pw.close();
	}
	
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        }
        
        int ni() { 
            return Integer.parseInt(next()); 
        }
  
        long nl() { 
            return Long.parseLong(next()); 
        } 
  
        double nd() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() {
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str;
        }
    }
}

Measured memory_bytes: 32948
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll cnt[200005];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	ll ans = 0;
	for(int a = 1; a <= n; ++a){
		++cnt[a%k];
	}
	for(int a = 1; a <= n; ++a){
		int id = (k - (a%k)) % k;
		if(id != a%k) continue;
		ans += cnt[id] * cnt[id];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
/***
**   AUTHOR::ASHUTOSH MOUDGIL
***/


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

#define pb push_back
#define mp make_pair
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define F first
#define S second
#define int long long
//#define ll long long
#define all(x) x.begin(),x.end()
#define rsort(x) sort(all(x)); reverse(all(x));
#define endl '\n'
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define vi vector<int>
#define vlli vector<long long>
#define pii pair<int,int>
#define mod 1000000007
#define LMAX 1e18
#define deb(x) cout<<#x<<" : "<<x<<endl;
#define PI 3.141592654
#define dbg1(x) cout << #x <<"="<< x <<endl;
#define dbg2(x,y) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<endl;
#define dbg3(x,y,z) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<<endl;
#define dbg4(x,y,z,a) cout << #x <<"="<<x<<", "<<#y<<"="<<y <<", "<<#z<<"="<<z<< ", "<<#a <<"="<<a << endl;
#define dbgarr(x) cout << #x<<endl;for(int i : x){cout << i <<" ";} cout <<endl;



void mymain(){
    int n,a,b;
    cin >> n >> a >> b;
    int ans = (n/(a+b))*a;
    n %= (a+b);
    if(n>=a)
        ans += a;
    else
        ans += n;
    cout << ans << endl;


}

signed main(){
IOS;
///freopen("input.txt", "r", stdin);
///freopen("output.txt", "w", stdout);
int t=1;
//cin>>t;
for(int tt=0;tt<t;tt++){
   ///cout << "Case #" << tt+1 <<": ";
   mymain();
   }
return 0;
}
/*

*/


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

int main(){
  long long a,b,n,res=-1;
  cin >> a >> b >> n;
  long long i=n;
  long long tmp;
  if(b==1){
    cout << 0;
    return 0;
  }
  if(n<b){
    cout << (a*i)/b - a*(i/b);
    return 0;
  }else{
    cout << (a*(b-1))/b - a*((b-1)/b);
    return 0;
  }
  while(i%b!=0){
    tmp = (a*i)/b - a*(i/b);
    res = max(tmp,res);
    i--;
  }
  
  cout << res;
  return 0;
}



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
static const int INF (1<<30);

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char> > a(H, vector<char>(W));
  vector<vector<int> > del(H, vector<int>(W, 0));

  rep(i, H) {
    rep(j, W) {
      cin >> a[i][j];
    }
  }

  int ans = 0;
  rep(i, H) {
    bool black = false;
    rep(j, W) {
      if (a[i][j] == '#') black = true;
    }

    if (!black) {
      rep(j, W) del[i][j] = 1;
    }

  }


  rep(j, W) {
    bool black = false;
    rep(i, H) {
      if (a[i][j] == '#') black = true;
    }

    if (!black) {
      rep(i, H) del[i][j] = 1;
    }

  }


  rep(i, H) {
    bool nonexist = true;
    rep(j, W) {
      if (del[i][j] == 1) continue;
      else nonexist = false;

      cout << a[i][j];
    }
    if (!nonexist) cout << endl;
  }


  return 0;
}

Measured memory_bytes: 256
// Copyright (C) 2017 __debug.

// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License as
// published by the Free Software Foundation; version 3

// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// You should have received a copy of the GNU General Public License
// along with this program; If not, see <http://www.gnu.org/licenses/>.


#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/priority_queue.hpp>

#define x first
#define y second
#define MP std::make_pair
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#ifdef __linux__
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#endif

using std::pair;
using std::vector;
using std::string;

typedef long long LL;
typedef pair<int, int> Pii;

const int oo = 0x3f3f3f3f;

template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, true : false; }
template<typename T> inline bool chkmin(T &a, T b) { return b < a ? a = b, true : false; }
string procStatus()
{
    std::ifstream t("/proc/self/status");
    return string(std::istreambuf_iterator<char>(t), std::istreambuf_iterator<char>());
}
template<typename T> T read(T &x)
{
    int f = 1;
    char ch = getchar();
    for (; !isdigit(ch); ch = getchar())
        f = (ch == '-' ? -1 : 1);
    for (x = 0; isdigit(ch); ch = getchar())
        x = 10 * x + ch - '0';
    return x *= f;
}
template<typename T> void write(T x)
{
    if (x == 0) {
        putchar('0');
        return;
    }
    if (x < 0) {
        putchar('-');
        x = -x;
    }
    static char s[20];
    int top = 0;
    for (; x; x /= 10)
        s[++top] = x % 10 + '0';
    while (top)
        putchar(s[top--]);
}
// EOT

const int MAXN = 5e5 + 5;

int N, Q;
int D, A[MAXN];
int QRY[MAXN];

void input()
{
    read(N); read(D);
    for (int i = 1; i <= N; ++i) {
        read(A[i]);
    }
    read(Q);
    for (int i = 1; i <= Q; ++i) {
        read(QRY[i]);
    }
}

void solve()
{
    static int pos[MAXN], dp[MAXN];

    pos[1] = D;
    for (int i = 1; i <= N; ++i) {
        pos[i + 1] = (A[i] < pos[i] * 2 ? abs(pos[i] - A[i]) : pos[i]);
    }
    dp[N] = 1;
    for (int i = N; i > 1; --i) {
        dp[i - 1] = dp[i] + (A[i] < dp[i] * 2) * A[i];
    }

    for (int i = 1; i <= Q; ++i) {
        puts(pos[QRY[i]] >= dp[QRY[i]] ? "YES" : "NO");
    }
}

int main()
{
#ifdef __DEBUG
    freopen("E.in", "r", stdin);
    freopen("E.out", "w", stdout);
#endif

    input();
    solve();

    return 0;
}

// 少年不识愁滋味，爱上层楼。爱上层楼。为赋新词强说愁。
//     -- 辛弃疾《丑奴儿·书博山道中壁》


Measured memory_bytes: 9728
#include <bits/stdc++.h>
#define X first
#define Y second
typedef long long ll;
using namespace std;

const int MOD = 1e9 + 7;
const ll INF = 1e18;

int n, k;
string s;

vector< pair<int, int> > v;

int main () {

	cin >> n >> k;
	cin >> s;
	for (int i = 0; i < s.size(); i ++) {
		if (s[i] == '0') {
			int p = i;
			while (p < s.size() && s[p] == '0') p ++;
			p --;
			v.push_back({i, p});
			i = p;
		}
	}
	
	if (v.size() == 0) {
		cout << n;
		return 0;
	}
	//for (int i = 0; i < v.size(); i ++) cout << v[i].first << " " << v[i].second << endl;
	
	int maxi = 0;
	for (int i = 0; i < s.size(); i ++) {
		int lo = 0, hi = (int)v.size()-1;
		while (lo < hi) {
			int mid = (lo + hi) / 2;
			if (v[mid].second < i) lo = mid+1;
			else hi = mid; 
		}
		
		if (v[lo].second < i) maxi = max(maxi, n-i);
		else {
			//if (v[lo].first <= i) {
				int f = lo+k;
				if (f >= v.size()) maxi = max(maxi, n-i);
				else maxi = max(maxi, v[f].first-i);
			//}
			/*else {
				int f = lo+k;
				if (f >= v.size()) maxi = max(maxi, n-i);
				else maxi = max(maxi, v[f].first-i);
			}*/
			//cout << i << " pripada: " << v[lo].first << "," << v[lo].second << endl;
		}
	}
	
	cout << maxi;

	return 0;
}

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

int main() {

  int n;
  int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2,
                2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
   cin>>n;
   cout<<a[n-1]<<endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define rep(i,x) for(int i=0;i<(x);++i)
#define rep1(i,x) for(int i=1;i<=(x);++i)
#define rrep(i,x) for(int i=(x)-1;i>=0;--i)
#define rrep1(i,x) for(int i=(x);i>=1;--i)
#define int long long
#define FOR(i,a,x) for(int i=(a);i<(x);++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

template<typename T>T& max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T& min(T&a,T&b){if(a<b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<typename T>T get(){T a;cin>>a;return a;}
template<typename T>T rev(T a){reverse(all(a));return a;}
template<typename T>istream&operator>>(istream&is,vector<T>&vec){rep(i,vec.size())is>>vec[i];return is;}
template<typename T>vector<T>&sort(vector<T>&a){sort(all(a));return a;}

const int inf = 1e9;
const ll linf = 3e18;
const double eps = 1e-9;

bool is_vowel(char c)
{
    if (c == 'a' or c == 'i' or c == 'u' or c == 'e' or c == 'o') return true;
    return false;
}

signed main()
{
    int N;
    
    while (cin >> N, N) {
        vector<string> codes(N);

        rep(i, N) {
            string s; cin >> s;
            codes[i].PB(s[0]);
            rep(j, s.size()) {
                if (is_vowel(s[j])) {
                    if (j + 1 < s.size()) codes[i].PB(s[j + 1]);
                }
            }
        }

        int lb = 0, ub = 50;

        int mi = inf;

        for (int i = 1; i <= 50; ++i) {
            map<string, bool> m;

            rep(j, N) {
                string a = codes[j].substr(0, i);
                if (m.find(a) != m.end()) {
                    goto nxt;
                }
                m[a] = true;
            }

            chmin(mi, i);
nxt:;
        }

        if (mi == inf) cout << -1 << endl;
        else cout << mi << endl;
    }
}

Measured memory_bytes: 1236
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
 
typedef long long ll;
typedef vector<ll> vl;
typedef long double ld;
typedef vector<ld> vd;
typedef bool bl;
typedef vector<bl> vb;
 
const ll e5 = 1 << 20;
const ll mod = 998244353;
const ll e3 = 1 << 13;
const ll INF = 1ll << 60;
 
int main() {
  int n;
  cin >> n;

  vector<int> a(n, 0);
  vector<int> a_num(200000, 0);
  int max_a = 0;
  int max_a_ind = -1;
  int nex_max_a = 0;
  rep(i, n) {
    cin >> a[i];
    a_num[a[i]] += 1;
    if (a[i] > max_a) {
      max_a = a[i];
      max_a_ind = i;
    } else if (a[i] > nex_max_a) {
      nex_max_a = a[i];
    }
  }

  rep(i, n) {
    if (max_a_ind != i || a_num[a[i]] > 1) {
      cout << max_a << endl;
    } else {
      cout << nex_max_a << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>

using namespace std;

namespace Mylib{

}
int main(void){
    
    int N;
    cin >> N;
    string tempStr;
    map<string,int> Smap;
    for(int i=0;i<N;i++){
        cin >> tempStr;
        
        Smap.insert(make_pair(tempStr,0));
        
    }
    cout << Smap.size() << endl;
    
    
    return 0;

}

Measured memory_bytes: 19228