Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import copy
import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)
 
m = 10**9
def score(point = 0, n = 0, now=0, done=[]):
    global m
    if point >= g:
        if m > n: m = n
    elif point+100*(now+1)*P[now] >= g:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: 
            m = n
    else:
        done.append(now)
        if now == -1:
            for i in range(d):
                score(point, n, i, copy.copy(done))
        else:
            for i in range(d):
                if not i in done:
                    score(point+P[now]*100*(now+1) + C[now], n + P[now], i, copy.copy(done))

done = []
score(0,0,-1,done)
print(m)

### FIXED CODE ###

import math
 
d,g = [int(i) for i in input().split()]
P = []
C = []
for i in range(d):
    p,c = [int(i) for i in input().split()]
    P.append(p)
    C.append(c)

# cnt = 0
# def count():
#     global cnt
#     cnt+=1
#     print(cnt)

def flag(point,P,now):
    if point+100*(now+1)*(P-1) >= g: return 1
    elif point+100*(now+1)*P + C[now] >= g: return 2
    else: return 0

m = 10**9
def score(point = 0, n = 0, now=-1, remain = list(range(d))):
    global m
    if m <= n: return
    elif now == -1:
        for i in remain:
            score(point, n, i, remain)
    elif point >= g: m = n
    elif flag(point,P[now],now) == 1:
        n += math.ceil((g-point)/(100*(now+1)))
        if m > n: m = n
    elif flag(point,P[now],now) == 2:
        n += P[now]
        if m > n: m = n
    else:
        if m <= n+P[now]: return
        else:
            remain = remain[:]
            remain.remove(now)
            nxtp = point + P[now]*100*(now+1) + C[now]
            for i in remain:
                score(nxtp, n + P[now], i, remain)

score()
print(m)
### BUGGY CODE ###

import math

Q = int(input())
li = []
M = 0
for index in range(Q):
	l, r = map(int, input().split())
	li.append((l, r))
	M = max([M, l, r])

primes = list(range(M+1))
primes[0] = 0
primes[1] = 0
for prime in primes:
	if prime > math.sqrt(M):
		break
	if prime == 0:
		continue
	for non_prime in range(2 * prime, M, prime):
		primes[non_prime] = 0

for l, r in li:
	count = 0
	for i in range(l,r+1,2):
		if primes[i] != 0 and primes[(i+1)//2] != 0:
			count += 1
	print(count)

### FIXED CODE ###

import math

Q = int(input())
li = []
M = 0
for index in range(Q):
	l, r = map(int, input().split())
	li.append((l, r))
	M = max([M, l, r])

primes = list(range(M+1))
primes[0] = 0
primes[1] = 0
cut_root = math.sqrt(M+1)
for prime in primes:
	if prime > cut_root:
		break
	if prime == 0:
		continue
	for non_prime in range(2 * prime, M, prime):
		primes[non_prime] = 0
similar_2017 = [0 for _ in range(M+1)]
similar_2017[3] = 1
for i in range(5, M+1, 4):
	if primes[i] != 0:
		if primes[(i+1)//2] != 0:
			similar_2017[i] = 1
similar_sum = [0 for _ in range(M+1)]
for i in range(1,M+1):
	if similar_2017[i] == 1:
		similar_sum[i] = similar_sum[i-1] + 1
	else:
		similar_sum[i] = similar_sum[i-1]

for l, r in li:
	print(similar_sum[r] - similar_sum[l-1])
### BUGGY CODE ###

H,W = map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(H)]
B = [[int(a) for a in input().split()] for _ in range(H)]

L = [[0]*W for _ in range(H)]
for i in range(H):
    for j in range(W):
        L[i][j] = abs(A[i][j]-B[i][j])


dp = {}
dp[(0, 0)] = [L[0][0], -L[0][0]]
for i in range(1, W):
    dp[(0, i)] = []
    for k in dp[(0, i-1)]:
        dp[(0, i)].append(k+L[0][i])
        dp[(0, i)].append(k-L[0][i])
for i in range(1, H):
    dp[(i, 0)] = []
    for k in dp[(i-1, 0)]:
        dp[(i, 0)].append(k+L[i][0])
        dp[(i, 0)].append(k-L[i][0])
        
for i in range(1, H):
    for j in range(1, W):
        dp[(i, j)] = []
        if i != 0:
            for t in dp[(i-1, j)]:
                dp[(i, j)].append(t+L[i][j])
                dp[(i, j)].append(t-L[i][j])
        if j != 0:
            for t in dp[(i, j-1)]:
                dp[(i, j)].append(t+L[i][j])
                dp[(i, j)].append(t-L[i][j])
        if i-1 > 0 and j-1 > 0:
            dp.pop((i, j))
            
ans = 10**9
for k in dp[(H-1, W-1)]:
    ans = min(ans, abs(k))
    
print(ans)

### FIXED CODE ###

H,W = map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(H)]
B = [[int(b) for b in input().split()] for _ in range(H)]

C = [[0]*W for _ in range(H)]
num = 80
for i in range(H):
    for j in range(W):
        C[i][j] = abs(A[i][j]-B[i][j])
        
dp = [[0]*W for _ in range(H)]
dp[0][0] |= (1<<num+C[0][0]) | (1<<num-C[0][0])

for i in range(H):
    for j in range(W):
        if i > 0:
            dp[i][j] |= (dp[i-1][j]<<num+C[i][j]) | (dp[i-1][j]<<num-C[i][j])
        if j > 0:
            dp[i][j] |= (dp[i][j-1]<<num+C[i][j]) | (dp[i][j-1]<<num-C[i][j])
            
b = list(bin(dp[-1][-1]))[::-1]
ans = 10**9
for i in range(len(b)):
    if b[i] == "1":
        ans = min(ans, abs(num*(H+W-1)-i))

print(ans)
### BUGGY CODE ###

import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
n,m = na()
a = na()

import heapq

aa = []
for k in a:
  heapq.heappush(aa, -k)

for i in range(m):
    b,c = na()
    for j in range(b):
        heapq.heappush(aa, -c)

ans = 0
for i in range(n):
  ans += heapq.heappop(aa)

print(-ans)

### FIXED CODE ###

import sys
stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

n,m = na()
a = na()

bc = [na() for i in range(m)]
bc.sort(key=lambda x:x[1])

for b,c in bc[::-1]:
  a.extend([c]*b)
  if len(a)>2*n:
    break

a.sort(reverse=True)
print(sum(a[:n]))
### BUGGY CODE ###

H,W=map(int,input().split())
S=[[i for i in list(input())]for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
for i in range(H):
    count=0
    for j in range(W):
        if S[i][j]=="#":
            count=0
        else:
            count=count+1
        L[i][j]=count
for i in range(H):
    count=0
    for j in range(W)[::-1]:
        if S[i][j]=="#":
            count=0
        else:
            count=count+1
        R[i][j]=count
for i in range(W):
    count=0
    for j in range(H):
        if S[j][i]=="#":
            count=0
        else:
            count=count+1
        U[j][i]=count
for i in range(W):
    count=0
    for j in range(H)[::-1]:
        if S[j][i]=="#":
            count=0
        else:
            count=count+1
        D[j][i]=count
ans=0
for i in range(H):
    for j in range(W):
        ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(ans)

### FIXED CODE ###

H,W=map(int,input().split())
S=[[i for i in list(input())]for _ in range(H)]
L=[[0]*W for _ in range(H)]
R=[[0]*W for _ in range(H)]
U=[[0]*W for _ in range(H)]
D=[[0]*W for _ in range(H)]
for i in range(H):
    count=0
    for j in range(W):
        if S[i][j]=="#":
            count=0
        else:
            count=count+1
        L[i][j]=count
for i in range(H):
    count=0
    for j in range(W)[::-1]:
        if S[i][j]=="#":
            count=0
        else:
            count=count+1
        R[i][j]=count
for i in range(W):
    count=0
    for j in range(H):
        if S[j][i]=="#":
            count=0
        else:
            count=count+1
        U[j][i]=count
for i in range(W):
    count=0
    for j in range(H)[::-1]:
        if S[j][i]=="#":
            count=0
        else:
            count=count+1
        D[j][i]=count
ans=0
for i in range(H):
    for j in range(W):
        ans=max(ans,L[i][j]+R[i][j]+U[i][j]+D[i][j]-3)
print(ans)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
x = 1145141919810
for i in range(1,n):
    x=min(x,abs(sum(a[:i])-sum(a[i:])))
print(x)

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = float("INF")
X = sum(a)

x = 0
for i in range(n):
    x += a[i]
    if i+1 < n:
        ans = min(ans,abs(X-2*x))
print(ans)
### BUGGY CODE ###

X, Y = map(int, input().split())
x = X
if X == Y:
    print(-1)
else:
    while X % Y == 0:
        X = X + x
    print(X)

### FIXED CODE ###

X, Y = map(int, input().split())
x = X
if X % Y == 0:
    print(-1)
else:
    print(X)
### BUGGY CODE ###

"""
連続する部分文字列の種類は多くてN**2個ある。
N<=5000という制約から考えて、これらの連続する部分文字列に対して全探索ができる。
問題は、各部分文字列が条件を満たしているかどうかをどうやって調べるかだ。
これは、各部分文字列種ごとにどの区間で出現するかをメモしておけば良い。
dic["hogehoge"] => "hogehoge"という連続部分文字列が出現する区間をメモした配列
dic["hogehoge"] = [(0,7),(2,9),(6,13),(10,17)]　といった具合だ。
dic[hogehoge][x][1]とdic[hogehoge][x+1][1]が重複しているかを調べることで条件を満たすかどうかを判定できる。
区間(i,j)のjで昇順並びになっている必要があるが、実直にi,jでループして連続部分文字列を探索すれば、自然と昇順でメモされる。
計算量はO(N**2)で間に合う。
"""
N = int(input())
S = input()

dic = {}
for i in range(N):
    for j in range(N):
        if S[i:j+1] not in dic:
            dic[S[i:j+1]] = []
        dic[S[i:j+1]].append((i,j))

ans = 0
for k,v in dic.items():
    if len(v) > 1:
        for i in range(1,len(v)):
            if v[i][0]<=v[i-1][1]:
                break
        else:
            ans = max(ans,len(k))
print(ans)




### FIXED CODE ###

"""
X文字が条件にあてはまるとき、X-1文字も条件に当てはまる。したがって、二分探索を使うのがよい。
一回の探索に、O(N**2)かかる。
探索はO(logN)回行うため、全体でO(N**2logN)で、ギリ間に合う。
"""
N = int(input())
S = input()

def is_ok(X):
    dic = {}
    for i in range(N+1-X):
        sub = S[i:i+X]
        if sub not in dic:
            dic[sub] = (i,i+X-1)
        else:
            if dic[sub][1] < i:
                return True
    return False

def bisearch(high,low):
    while high - low > 1:
        mid = (high+low)//2
        if is_ok(mid):
            low = mid
        else:
            high = mid
    return low
print(bisearch(N,0))
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from collections import deque

h, w = map(int, input().split())
ch, cw = map(int, input().split())
gh, gw = map(int, input().split())

s = []
for i in range(h):
    s.extend(input().rstrip('\n'))

d = [10 ** 18 for j in range(h*w)]

stack = deque([[ch-1, cw-1, 0]])
stack_append = stack.append
stack_popleft = stack.popleft


while stack:
    curh, curw, cnt = stack_popleft()
    if d[curh * w + curw] <= cnt:
        continue
    else:
        d[curh * w + curw] = cnt
    for dh, dw in ((-1,0), (1,0), (0,1), (0,-1)):
        nh = curh + dh
        nw = curw + dw
        if nh >= 0 and nh < h and nw >= 0 and nw < w and s[nh * w + nw] == '.':
            stack_append([nh, nw, cnt])
    for nh in range(curh-2, curh+3):
        if nh >= 0 and nh < h:
            for nw in range(curw-2,curw+3):
                if nw >= 0 and nw < w and s[nh * w + nw] == '.':
                     stack_append([nh, nw, cnt+1])

# for item in d:
#     print(item)
gh -= 1
gw -= 1

if d[gh*w + gw] == 10 ** 18:
    print(-1)
else:
    print(d[gh*w + gw])

### FIXED CODE ###

import sys
input = sys.stdin.readline

import heapq

INF = 10 ** 10

def dijkstra(n, G, s):
    dist = [INF] * n
    dist[s] = 0
    h = []
    heapq.heappush(h, (0, s))

    while h:
        # 使っていない頂点のうち、現時点で最も距離の近いものを選びvとする
        d, v = heapq.heappop(h)
        if dist[v] < d:
            continue
        # vから到達可能な頂点について、距離が短くなれば更新
        for end, cost in G[v]:
            if dist[end] > dist[v] + cost:
                dist[end] = dist[v] + cost
                heapq.heappush(h, (dist[end], end))
    return dist


H, W = map(int, input().split())
N = H * W
ch, cw = map(lambda x:int(x)-1, input().split())
gh, gw = map(lambda x:int(x)-1, input().split())

s = []
es = tuple([] for i in range(N))

for h in range(H):
   s.append(input().rstrip('\n'))

for h in range(H):
    for w in range(W):
        if s[h][w] != '.':
            continue
        a = h*W+w
        esappend = es[a].append
        for dh in (-2, -1, 0, 1, 2):
            for dw in (-2, -1, 0, 1, 2):
                if dh == 0 and dw == 0:
                    continue
                nh = h + dh
                nw = w + dw
                if 0 <= nh and nh < H and 0 <= nw and nw < W and s[nh][nw] == '.':
                    b = nh*W+nw
                    if (dh, dw) in [(-1,0),(1,0),(0,-1),(0,1)]:
                        esappend((b, 0))
                    else:
                        esappend((b, 1))

dist = dijkstra(N, es, ch*W+cw)
if dist[gh*W+gw] == INF:
    print(-1)
else:
    print(dist[gh*W+gw])
### BUGGY CODE ###

import itertools
import heapq
from heapq import heappush, heappop
global G

def input_graph(N, xy):
  global G
  comb_list = list(itertools.combinations(xy, 2))
  for i in range(N*(N-1)//2):
    a, b = comb_list[i]
    an, axy = a
    ax, ay = axy
    bn, bxy = b 
    bx, by = bxy
    cost = min(abs(ax-bx), abs(ay-by))
    G[an] += [(cost, bn)]
    G[bn] += [(cost, an)]

def prim(V):
  global G, used 
  edgelist = []
  for e in G[0]:
    heappush(edgelist, e)
  used[0] = True
  res = 0
  while edgelist:
    minedge = heappop(edgelist)
    if used[minedge[1]]:
      continue 
    v = minedge[1]
    used[v] = True 
    for e in G[v]:
      if not used[e[1]]:
        heappush(edgelist, e)
    res += minedge[0]
  return res

def main():
  global G, used
  N = int(input())
  xy = []
  for i in range(N):
    xy += [[i, list(map(int, input().split()))]]
  G = [[] for _ in range(N)]
  used = [False for _ in range(N)]
  input_graph(N, xy)
  print(prim(N))

if __name__ == "__main__":
  main()

### FIXED CODE ###

import itertools
import heapq
from heapq import heappush, heappop
global G, inp_x, inp_y

def input_graph(N):
  global G, inp_x, inp_y
  inp_x = []
  inp_y = []
  for i in range(N):
    x, y = map(int, input().split())
    inp_x.append((x, i))
    inp_y.append((y, i))
  inp_x.sort()
  inp_y.sort()
  for i in range(N-1):
    xa = inp_x[i][1]
    xb = inp_x[i+1][1]
    ya = inp_y[i][1]
    yb = inp_y[i+1][1]
    cost_x = abs(inp_x[i][0]-inp_x[i+1][0])
    cost_y = abs(inp_y[i][0]-inp_y[i+1][0])
    G[xa] += [(cost_x, xb)]
    G[xb] += [(cost_x, xa)]
    G[ya] += [(cost_y, yb)]
    G[yb] += [(cost_y, ya)]

  
def prim(V):
  global G, used
  edgelist = []
  for e in G[0]:
    heappush(edgelist, e)
  used[0] = True
  res = 0
  while edgelist:
    minedge = heappop(edgelist)
    if used[minedge[1]]:
      continue 
    v = minedge[1]
    used[v] = True 
    for e in G[v]:
      if not used[e[1]]:
        heappush(edgelist, e)
    res += minedge[0]
  return res

def main():
  global G, used
  N = int(input())
  G = [[] for _ in range(N)]
  used = [False for _ in range(N)]
  input_graph(N)
  print(prim(N))

if __name__ == "__main__":
  main()
### BUGGY CODE ###

import itertools
import math
from functools import reduce
import collections
def gcd_list(numbers):
    return reduce(math.gcd,numbers)
K=int(input())
ans=0
x=list(itertools.combinations_with_replacement(range(1,K+1),3))
for i in x:
  c=collections.Counter(i)
  if max(c.values())==1:
    ans+=6*gcd_list(i)
  elif max(c.values())==2:
    ans+=3*gcd_list(i)
  else:
    ans+=gcd_list(i)
print(ans)
  

### FIXED CODE ###

import itertools
import math
from functools import reduce
K=int(input())
ans=0
for i in range(1,K+1):
  for j in range(1,K+1):
    t=math.gcd(i,j)
    for k in range(1,K+1):
      ans+=math.gcd(t,k)
print(ans)
### BUGGY CODE ###

# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import os
import sys
import math
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())
    ans = []
    for i in itertools.product(xrange(k+1), repeat=2):
        x, y = i
        z = s - sum(i)
        if(z >= 0 and z<=k and sum([x,y,z])==s):
            ans.append((x,y,z))
    sys.stdout.write("%d" % len(ans))

if __name__ == '__main__':
    main()


### FIXED CODE ###

# coding: utf-8
from __future__ import unicode_literals
from __future__ import print_function
import sys
import itertools

def main():
    k,s = map(int,sys.stdin.read().split())
    ans = []
    count = 0
    for x in xrange(k+1):
        for y in xrange(k+1):
            if x + y <= s:
                z = s - (x + y)
                if(z>=0 and z <= k):
                    count += 1
                    # ans.append([x,y,z])
            else:
                break
    # sys.stdout.write("%d" % len(ans))
    sys.stdout.write("%d" % count)

if __name__ == '__main__':
    main()
### BUGGY CODE ###

n,k,q = map(int,input().split())
l = [int(input()) for _ in range(q)]
l.sort()
ll = set(l)
l2 = []

for _ in ll:
	l2.append(l.count(_))

lll = list(ll)

for _ in range(1,n+1):
	if _ in lll:
		if k - q + l2[lll.index(_)] > 0:
			print('Yes')
		else:
			print('No')
	else:
		if k - q > 0:
			print('Yes')
		else:
			print('No')


### FIXED CODE ###

n,k,q = map(int,input().split())
a = [k-q]*n
for i in range(q):
	a[int(input())-1] += 1
for i in a:
	print('Yes' if i>0 else 'No')
### BUGGY CODE ###

s = input()
mod = 10 ** 9 + 7

dp = [1] + [0] * 12
for c in s:
  tmp = dp[:]
  if c == '?':
    dp = [0] * 13
    for n in range(10):
      for i in range(13):
        index = (10 * i + n) % 13
        dp[index] = (dp[index] + tmp[i]) % mod
  else:
    n = int(c)
    for i in range(13):
      dp[(10 * i + n) % 13] = tmp[i]
print(dp[5])

### FIXED CODE ###

s = input()
mod = 10 ** 9 + 7

dp = [1] + [0] * 12
for c in s:
  tmp = dp[:]
  if c == '?':
    dp = [0] * 13
    for n in range(10):
      for i in range(13):
        index = (10 * i + n) % 13
        dp[index] = (dp[index] + tmp[i]) % mod
  else:
    n = int(c)
    for i in range(13):
      dp[(10 * i + n) % 13] = tmp[i]
print(dp[5])
### BUGGY CODE ###

s=list(input())
q=int(input())
for i in range(q):
    x=list(input())
    if len(x)==1:
        s=list(reversed(s))
    else:
        if x[2]=='1':
            s.insert(0,x[4])
        else:
            s.append(x[4])
print(''.join(s))


### FIXED CODE ###

import sys
read=sys.stdin.buffer.read
readline=sys.stdin.buffer.readline
readlines=sys.stdin.buffer.readlines
from collections import deque

S=deque(readline().rstrip().decode())
Q=int(readline())
query=readlines()

flag=False
for q in query:
    if q[0]==ord('1'):
        flag= not flag
    else:
        _,f,c=q.decode().split()
        f=int(f)
        if flag^(f==1):
            S.appendleft(c)
        else:
            S.append(c)
ans=''.join(S)
if flag:
    ans=ans[::-1]
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
inf = 10 ** 9
dp = [0] + [inf] * ((1 << n) - 1)
for _ in range(m):
    newdp = [p for p in dp]
    a, b = map(int, input().split())
    c = sum(1 << (int(i) - 1) for i in input().split())
    for bits in range(len(dp)):
        newdp[bits | c] = min(newdp[bits | c], dp[bits] + a)
    dp = newdp
print(-1 if dp[-1] == inf else dp[-1])


### FIXED CODE ###

n, m = map(int, input().split())
inf = 10 ** 9
dp = [0] + [inf] * ((1 << n) - 1)
for _ in range(m):
    newdp = [p for p in dp]
    a, b = map(int, input().split())
    c = sum(1 << (int(i) - 1) for i in input().split())
    for bits in range(len(dp)):
        newdp[bits | c] = min(newdp[bits | c], dp[bits] + a)
    dp = newdp
print(-1 if dp[-1] == inf else dp[-1])
### BUGGY CODE ###

import sys
input = sys.stdin.readline

N=int(input())
for i in range(1,N+1):
  cnt=0
  listx=list(range(1,101-2))
  for x in listx:
    for y in range(1,101-x+1):
      for z in range(1,101-x-y+1):
        if i==x**2+y**2+z**2+x*y+y*z+z*x:
          cnt+=1
  print(cnt)


### FIXED CODE ###

import sys
input = sys.stdin.readline
import math

N=int(input())
ans=[0]*(N+1)
sn=int(math.sqrt(N)+1)
for x in range(1,sn+1):
  for y in range(1,sn+1):
    for z in range(1,sn+1):
      i=x**2+y**2+z**2+x*y+y*z+z*x
      if 1<=i<=N:
        ans[i]+=1
for h in range(1,N+1):          
  print(ans[h])
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A = []
point = [0] * N

for i in range(Q):
  A.append(int(input()))
  i += 1

for i in A:
    point[i - 1] += 1

point2 = []
for i in range(len(point)):
    point2.append(K - (sum(point) - point[i]))

for i in point2:
  if i > 0:
    print("Yes")
  else:
    print("No")

### FIXED CODE ###

N, K, Q = map(int, input().split())
point = [0] * N

for i in range(Q):
    point[int(input()) - 1] += 1
    i += 1

sum_point = sum(point)

for i in range(N):
    ans = K - (sum_point - point[i])
    if ans > 0:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N,K = map(int,input().split())
A = list(map(int, input().split()))
sum = 0
last = 0
sw = 0
for num in range(K):
  last += A[num]
for i in range(1,N-K+1):
  for j in range(K):
    sum += A[i+j]
    if last < sum:
      print("Yes")
      sw = 1
      break
  if sw ==0:
    print("No")
  last = sum
  sum = 0
  sw = 0

### FIXED CODE ###

N,K = map(int,input().split())
A = list(map(int, input().split()))

for i in range(0,N-K):
  if A[i] < A[i+K]:
    print("Yes")
  else:
    print("No")
### BUGGY CODE ###

# coding: utf-8
import math


def calc():
    n = int(input())

    tops = list(map(int, input().split()))
    middles = list(map(int, input().split()))
    lowers = list(map(int, input().split()))

    lowers = sorted(lowers, reverse=True)

    max_lower = max(lowers)
    middles = sorted(list(filter(lambda x: x < max_lower, middles)), reverse=True)

    if middles == []:
        return 0

    max_middle = max(middles)
    tops = sorted(list(filter(lambda x: x < max_middle, tops)), reverse=True)
    
    if tops == []:
        return 0

    counter = 0
    for top in tops:
        for middle in middles:
            if middle <= top:
                break

            for lower in lowers:
                if lower <= middle:
                    break
                
                counter += 1
                
    return counter

count = calc()
print(count)

### FIXED CODE ###

# coding: utf-8
import math
import bisect

def calc():
    n = int(input())
    tops = list(map(int, input().split()))
    middles = list(map(int, input().split()))
    lowers = list(map(int, input().split()))
 
    tops = sorted(tops)
    lowers = sorted(lowers)
 
    counter = 0
 
    for i in range(n):
        # A < B
        top_num = bisect.bisect_left(tops, middles[i])
        
        # B < C
        lower_num = n - bisect.bisect_right(lowers, middles[i])
        
        counter += top_num * lower_num
    
    return counter
 
print(calc())
### BUGGY CODE ###

n = int(input())
al = list(int(input()) for _ in range(n))
num = []
i = 0
cnt = 0
while i < n:
    if al[i] == 2:
        print(cnt+1)
        break
    else:
        if i in num:
            print(-1)
            break
        else:
            num.append(i)
            i = al[i]-1
            cnt += 1


### FIXED CODE ###

n = int(input())
al = list(int(input()) for _ in range(n))

a = 1
cnt = 0
while True:
    cnt += 1
    a = al[a-1]
    if a == 2:
        print(cnt)
        break
    if cnt == n:
        print(-1)
        break
### BUGGY CODE ###

N=int(input())
X=input()
for i in range(N):
    Xi = int(X[:i] + str(1-int(X[i])) + X[i+1:], 2)
    ans = 0
    while Xi!=0:
        Xi = Xi % bin(Xi).count('1')
        ans += 1
    print(ans)

### FIXED CODE ###

N=int(input())
X=input()
popcount=X.count('1')
bi1=[]
bi0=[]
Xnum1 = 0
Xnum0 = 0
if popcount != 1:
    for i in range(N):
        if i==0: bi1.append(1)
        else: bi1.append(bi1[i-1]*2%(popcount-1))
        Xnum1 = (Xnum1 + int(X[N-i-1])*bi1[i])%(popcount-1)
for i in range(N):
    if i==0: bi0.append(1)
    else: bi0.append(bi0[i-1]*2%(popcount+1))
    Xnum0 = (Xnum0 + int(X[N-i-1])*bi0[i])%(popcount+1)
for i in range(N):
    if popcount==1 and X[i]=='1':
        print(0)
        continue
    if X[i]=='1':
        Xi = (Xnum1 - bi1[N-i-1])%(popcount-1)
    else:
        Xi = (Xnum0 + bi0[N-i-1])%(popcount+1)
    ans = 1
    while Xi!=0:
        Xi = Xi % bin(Xi).count('1')
        ans += 1
    print(ans)