Harryxun/stf_run huggingface dataset:
def get_quad(n, p):
    for ni in range(n,0,-1):
        if p[ni] and p[ni - 2] and p[ni - 6] and p[ni - 8]:
            return ni
def sieve(n):
    p = [1] * (n + 1)
    p[0] = p[1] = 0
    
    for i in range(int(n ** 0.5) + 1):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p
import sys
f = sys.stdin

n = []
while True:
    ni = int(f.readline())
    if ni == 0:
        break
    n.append(ni)

prime = sieve(max(n))
for ni in n:
    print(get_quad(ni, prime))

### FIXED CODE ###

def get_quad(n, p):
    if n < 19:
        return 13
    n = (n + 1) // 10 * 10 - 1
    for ni in range(n,0,-10):
        if p[ni] and p[ni - 2] and p[ni - 6] and p[ni - 8]:
            return ni
        
def sieve():
    n = 10000001
    p = [1] * n
    p[0] = p[1] = 0
    
    for i in range(int(n ** 0.5)):
        if p[i]:
            for j in range(2 * i, len(p), i):
                p[j] = 0
    return p

import sys
f = sys.stdin

prime = sieve()
while True:
    n = f.readline().strip()
    if not n.isdigit():
        continue
    n = int(n)
    if n == 0:
        break
    print(get_quad(n, prime))
Last login: Fri Oct 18 22:40:34 on ttys000

The default interactive shell is now zsh.
To update your account to use zsh, please run `chsh -s /bin/zsh`.
For more details, please visit https://support.apple.com/kb/HT208050.
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
  File "a.py", line 3
    s = A - 2B
             ^
SyntaxError: invalid syntax
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
12 4
Traceback (most recent call last):
  File "a.py", line 1, in <module>
    A, B = map(int, input().split)
TypeError: 'builtin_function_or_method' object is not iterable
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
12 4
4
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ vim k.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python k.py
(2, 3, 4)
nakamurashuntaMacBook-Pro:~ n.shunta$ vi k.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python k.py
4
nakamurashuntaMacBook-Pro:~ n.shunta$ rm k.py
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
  File "a.py", line 17
    for r in data
                ^
SyntaxError: invalid syntax
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
3
3 1 2
22
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
3
3 1 2
(3, 1)
(3, 2)
(1, 3)
(1, 2)
(2, 3)
(2, 1)
22
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
  File "a.py", line 9
    for i in itertools.combinations(box, 2)
                                          ^
SyntaxError: invalid syntax
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ python a.py
3
3 1 2
(3, 1)
(3, 2)
(1, 2)
11
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py
nakamurashuntaMacBook-Pro:~ n.shunta$ vim a.py

N = int(input())
box = list(map(int, input().split()))

import itertools

boxes = []
data = []

for i in itertools.combinations(box, 2): 
    boxes.append(i)

for k in boxes:
    data.append(k[0] * k[1])

i = 0 

for r in data:
    i = r + i 

print(i)

### FIXED CODE ###

N = int(input())
box = list(map(int, input().split()))

import itertools

boxes = []
data = []

for i in itertools.combinations(box, 2): 
    boxes.append(i)

for k in boxes:
    data.append(k[0] * k[1])

i = 0 

for r in data:
    i = r + i 

print(i)
def main():
    n,k= map(int,input().split())
    h = [int(i) for i in input().split()]
    inf = 10**7
    dp = [inf]*100005
    dp[0] = 0
    for i in range(1,n):
        for j in range(1,min(k,i)+1):
            dp[i] = min(dp[i-j] + abs(h[i-j] - h[i]))
    print(dp[n-1])
main()

### FIXED CODE ###

def main():
    n,k= map(int,input().split())
    h = [int(i) for i in input().split()]
    inf = 10**7
    dp = [inf]*100005
    dp[0] = 0
    for i in range(1,n):
        dp[i] = min(dp[i-j] + abs(h[i-j] - h[i]) for j in range(1,min(k,i)+1))
    print(dp[n-1])
main()
from collections import deque

h, w = map(int, input().split())

l = [input() for i in range(h)]
memo = [[-1]*w for i in range(h)]

black_cells = deque()
for i in range(h):
    for j in range(w):
        if l[i][j] == "#":
            black_cells.append((i, j))
            memo[i][j] = 0

while black_cells:
    nh, nw = black_cells.popleft()
    count = memo[nh, nw]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        new_nh = nh + dy
        new_nw = nw + dx
        if new_nh < 0 or h <= new_nh or new_nw < 0 or w <= new_nw:
            continue
        if memo[new_nh][new_nw] == -1:
            memo[new_nh][new_nw] = count + 1
            black_cells.append((new_nh, new_nw))
print(count)

### FIXED CODE ###

from collections import deque

h, w = map(int, input().split())

l = [input() for i in range(h)]
memo = [[-1]*w for i in range(h)]

black_cells = deque()
for i in range(h):
    for j in range(w):
        if l[i][j] == "#":
            black_cells.append((i, j))
            memo[i][j] = 0

count = 0
while black_cells:
    nh, nw = black_cells.popleft()
    count = memo[nh][nw]
    for dy, dx in ((1, 0), (0, 1), (-1, 0), (0, -1)):
        new_nh = nh + dy
        new_nw = nw + dx
        if new_nh < 0 or h <= new_nh or new_nw < 0 or w <= new_nw:
            continue
        if memo[new_nh][new_nw] == -1:
            memo[new_nh][new_nw] = count + 1
            black_cells.append((new_nh, new_nw))
print(count)
A, B   = map(int, input().spli
x= A+B
y= A-B
z=A*B
print(max([x,y,z]))

### FIXED CODE ###

A, B   = map(int, input().split())
x= A+B
y= A-B
z=A*B
print(max([x,y,z]))
import math
A,B,C,D = map(int,input().split())


def number(A,B,x):
    left = math.ceil(A/x)
    right = math.floor(B/x)
    return (right - left + 1)
    
ans = B-A+1
ans -=number(A,B,C)
ans -=number(A,B,D)
ans +=number(A,B,(C*D)/math.gcd(C,D))

print(ans)



### FIXED CODE ###

import math
from fractions import gcd


A,B,C,D = map(int,input().split())
lcm = C//gcd(C,D)*D
ans = B - B//C - B//D + B//lcm
a = A-1
ans -= a - a//C - a//D + a//lcm 

print(ans)
a = input()
b = input()
a_12 = int(a[0:2])
a_3 = int(a[2])
a_45 = int(a[3:5])
b_12 = int(b[0:2])
b_3 = int(b[2])
b_45 = int(b[3:5])
a_21 = int(a[1]+a[0])
b_21 = int(b[1]+b[0])
ans = (b_12-a_12+1)*10 - a_3 - (10 - b_3 - 1)
if a_21 < a_45:
    ans = ans - 1
if b_21 > b_45:
    ans = ans - 1
print(ans)

### FIXED CODE ###

a,b=map(str,input().split( ))
a_12 = int(a[0:2])
a_3 = int(a[2])
a_45 = int(a[3:5])
b_12 = int(b[0:2])
b_3 = int(b[2])
b_45 = int(b[3:5])
a_21 = int(a[1]+a[0])
b_21 = int(b[1]+b[0])
ans = (b_12-a_12+1)*10 - a_3 - (10 - b_3 - 1)
if a_21 < a_45:
    ans = ans - 1
if b_21 > b_45:
    ans = ans - 1
print(ans)
while 1:
  a,op,b = map(int,raw_input().split())
  if op == "+":
    print a + b
  elif op == "-":
    print a - b
  elif op == "*":
    print a * b
  elif op == "/":
    print a / b
  else:
    break
  

### FIXED CODE ###

while 1:
  s = raw_input().split()
  a, b =int(s[0]), int(s[2])
  op = s[1] 

  if op == "+":
    print "%d" %(a + b)
  elif op == "-":
    print "%d" %(a - b)
  elif op == "*":
    print "%d" %(a * b)
  elif op == "/":
    print "%d" %(a / b)
  else:
    break
n,k=map(int,input().split())
a=list(map(int,input().split()))

ans=0
now=1
i=1
result=[1]
while i<=k:
    now=a[now]
    if now in result:
        x=result.index(now)
        length=i-1-x
        ans=result[(k-x)%length+x]
    result.append(now)
    i+=1
    
if ans!=0:
    print(ans)
else:
    print(result[-1])

### FIXED CODE ###

n,k=map(int,input().split())
a=list(map(lambda x:int(x)-1,input().split()))

ans=-1
l=[-1]*n
now=0
i=1
result=[0]
while i<=k:
    now=a[now]
    if l[now]!=-1:
        
        length=i-l[now]
        d=(k-i)%length+l[now]
        ans=l.index(d)
        break
    l[now]=i
    i+=1
    
if ans!=-1:
    print(ans+1)
else:
    print(now+1)
a = int(input())
print(3*r**2)

### FIXED CODE ###

r = int(input())

print(3*r*r)
a,b,c == (map(int,input().split()))

if a == b == c:
    print(1)
elif a == b or a == c or b == c:
    print(2)
else:
    print(3)


### FIXED CODE ###

a,b,c=list(map(int,input().split()))

if a==b and b==c:
    print(1)
elif a==b or b==c or c==a:
    print(2)
else:
    print(3)
def binary_search(S, a):
    leng = len(S)
    mid = leng // 2
    if S[mid] == a:
        return True
    elif leng < 2:
        return False
    elif S[mid] < a:
        return binary_search(S[mid+1:], a)
    else:
        return binary_search(S[:mid], a)
        
if __name__=="__main__":
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))
    ans = 0
    for i in T:
        if binary_search(S, i):
            ans += 1
    print(ans)

### FIXED CODE ###

def binary_search(S, t):
    start = 0
    end = len(S)
    while True:
        mid = start + (end-start)//2
        if S[mid] == t:
            return True
        elif (end-start) < 2:
            return False
        elif S[mid] < t:
            start = mid
        else:
            end = mid

if __name__ == "__main__":
    n = int(input())
    S = list(map(int, input().split()))
    q = int(input())
    T = list(map(int, input().split()))
    ans = 0
    for i in T:
        if binary_search(S, i):
            ans += 1
    print(ans)
from collections import Counter
n = int(input())
arr = list(map(int, input().split()))

if n == 2 and arr[0] != arr[1]:
    print(0)
    exit()

if n == 2 and arr[0] == arr[1]:
    print(1)
    exit()

odd_list =[]
num_list =[]

for i in range(n):
    if i%2 == 0:
        odd_list.append(arr[i])
    if i%2 != 0:
        num_list.append(arr[i])

odd_count = Counter(odd_list)
num_count = Counter(num_list)
odd1 = odd_count[odd_count.most_common()[0][0]]
num1 = num_count[num_count.most_common()[0][0]]



if len(set(arr)) == 1:
    print(int(n/2))
    exit()

if len(set(odd_count)) == 1 and len(set(num_count)) != 1:
    num2 = num_count[num_count.most_common()[1][0]]
    if odd_list[0] == num_count.most_common()[0][0]:
        print(int(n/2)-num2)
        exit()
    if odd_list[0] != num_count.most_common()[0][0]:
        print(int(n/2)-num1)
        exit()

if len(set(odd_count)) != 1 and len(set(num_count)) == 1:
    odd2 = odd_list[odd_count.most_common()[1][0]]
    if num_list[0] == odd_count.most_common()[0][0]:
        print(int(n/2)-odd2)
        exit()
    if num_list[0] != odd_count.most_common()[0][0]:
        print(int(n/2)-odd1)
        exit()

odd2 = odd_count[odd_count.most_common()[1][0]]
num2 = num_count[num_count.most_common()[1][0]]

if odd_count.most_common()[0][0] != num_count.most_common()[0][0]:
    print(n-odd1-num1)

if odd_count.most_common()[0][0] == num_count.most_common()[0][0]:
    print(min(n-odd1-num2, n-odd2-num1))

### FIXED CODE ###

from collections import Counter
n = int(input())
arr = list(map(int, input().split()))

odd_list =[]
num_list =[]

for i in range(n):
    if i%2 == 0:
        odd_list.append(arr[i])
    if i%2 != 0:
        num_list.append(arr[i])

odd_count = Counter(odd_list)
num_count = Counter(num_list)
odd1 = odd_count[odd_count.most_common()[0][0]]
num1 = num_count[num_count.most_common()[0][0]]

if odd1 != num1:
    print(n-odd_count.most_common()[0][1]-num_count.most_common()[0][1])
    exit()

if len(set(arr)) == 1:
    print(int(n/2))
    exit()

if len(set(num_list))==1 and len(set(odd_list))==1:
    print(0)
    exit()

if len(set(odd_count)) == 1 and len(set(num_count)) != 1:
    num2 = num_count[num_count.most_common()[1][0]]
    if odd_list[0] == num_count.most_common()[0][0]:
        print(int(n/2)-num2)
        exit()
    if odd_list[0] != num_count.most_common()[0][0]:
        print(int(n/2)-num1)
        exit()

if len(set(odd_count)) != 1 and len(set(num_count)) == 1:
    odd2 = odd_list[odd_count.most_common()[1][0]]
    if num_list[0] == odd_count.most_common()[0][0]:
        print(int(n/2)-odd2)
        exit()
    if num_list[0] != odd_count.most_common()[0][0]:
        print(int(n/2)-odd1)
        exit()

odd2 = odd_count[odd_count.most_common()[1][0]]
num2 = num_count[num_count.most_common()[1][0]]

if odd_count.most_common()[0][0] != num_count.most_common()[0][0]:
    print(n-odd1-num1)

if odd_count.most_common()[0][0] == num_count.most_common()[0][0]:
    print(min(n-odd1-num2, n-odd2-num1))
x = ( a * b ) * 2
z = ( a / x ) or ( b / x )
print( x, z )

### FIXED CODE ###

a,b=[int(x) for x in input().split()]
print(a*b,(a+b)*2)
import sys
import heapq  # heapqライブラリのimport

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, C = rl()
STC = [[] for _ in range(C+1)]

for _ in range(N):
    s, t, c = rl()
    STC[c].append((s, t))

for i in range(1, C+1):
    stc = STC[i]
    if len(stc) > 1:
        for j in range(1, len(stc)):
            if stc[j][0] == stc[j-1][1]:
                stc[j] = (stc[j-1][0], stc[j][1])
                stc.pop(j-1)
        STC[i] = stc

program = []
for stc_list in STC:
    for s, t in stc_list:
        program.append((s, t))

program.sort()

recorder = [0]
heapq.heapify(recorder)

for s, t in program:
    if s-0.5 > recorder[0]:
        recorder.heappop(recorder)
    recorder.heappush(recorder, t)

print(len(recorder))


### FIXED CODE ###

import sys
import heapq  # heapqライブラリのimport

stdin = sys.stdin
 
ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, C = rl()
STC = [[] for _ in range(C+1)]

for _ in range(N):
    s, t, c = rl()
    STC[c].append((s, t))

for i in range(1, C+1):
    stc = STC[i]
    stc.sort()
    p = []
    for j in range(1, len(stc)):
        if stc[j][0] == stc[j-1][1]:
            stc[j] = (stc[j-1][0], stc[j][1])
            p.append(j-1)
    for x in p[::-1]:
        stc.pop(x)
    STC[i] = stc

program = []
for stc_list in STC:
    for s, t in stc_list:
        program.append((s, t))

program.sort()

recorder = [-1]
heapq.heapify(recorder)

for s, t in program:
    if s-0.5 > recorder[0]:
        heapq.heappop(recorder)
    heapq.heappush(recorder, t)

print(len(recorder))
a, b, n =  map(int, input().split())
p = 0
for i in range(1, n+1):
  if p < (a*i)//b - a*(i//b):
    p = (a*i)//b - a*(i//b)
print(p)

### FIXED CODE ###

k = int(input())
a, b = map(int,input().split())
list1 = []
x =(k+a-1)//k
y = b // k

for i in range(x,y+1):
  list1.append(i)
if list1 == []:
  print('NG')
else:
  print('OK')
import math

N = int(input())
X = math.log(N + 1, 2)
Y = math.ceil(X)

print(Y)

### FIXED CODE ###

import math

N, R = map(int, input().split())
X = math.log(N + 0.000001, R)
Y = math.ceil(X)

print(Y)
a=[[[0]*10]*3]*4
for _ in range(int(input())):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]=v
for i in range(4):
 for j in range(3):
  print(' '.join(a[i][j]))
 print('#'*20)

### FIXED CODE ###

a=[[10*[0]for _ in[0]*3]for _ in[0]*4]
for _ in[0]*int(input()):
 b,f,r,v=map(int,input().split())
 a[b-1][f-1][r-1]+=v
for i in range(4):
 for j in range(3):print('',*a[i][j])
 if i<3:print('#'*20)
val1=int(input())

print(val1*(val1+1)/)

### FIXED CODE ###

val1=int(input())
print(int(val1*(val1+1)/2))
from math import log, ceil
print(ceil(int(log(*map(int, input().split())) - 0.001) + 0.001))

### FIXED CODE ###

N, R = map(int, input().split())
print(R + max(0, 100 * (10 - N)))
H, W, K = list(map(int, input().split()))

mat = [None] * H

m = {
  '.': 0,
  '#': 1
}

for i in range(H):
  mat[i] = list(map(lambda x: m[x], list(input())))

res = 0
pattern = set()

def total(mat):
  return sum([sum(r) for r in mat])

def fillH(mat, i):
  res = mat[i]
  mat[i] = [0] * W
  return res

def restoreH(mat, i, v):
  mat[i] = v

def fillV(mat, j):
  res = [None] * W
  for i in range(H):
    res[i] = mat[i][j]
    mat[i][j] = 0
  return res

def restoreV(mat, j, v):
  for i in range(H):
    mat[i][j] = v[i]

def DFS(mat, path):
  global pattern
  global res
  #print(mat, path)
  if total(mat) > K:
    for i in range(H):
      if not i in path[0]:
        v = fillH(mat, i)
        path[0] |= {i}
        DFS(mat, path)
        restoreH(mat, i, v)
        path[0].remove(i)
    for j in range(W):
      if not j in path[1]:
        v = fillV(mat, j)
        path[1] |= {j}
        DFS(mat, path)
        restoreV(mat, j, v)
        path[1].remove(j)
  elif total(mat) < K:
    return
  else:
    if not tuple(map(frozenset, path)) in pattern:
      pattern |= {tuple(map(frozenset, path))}
      res += 1

DFS(mat, [set(), set()])

print(res)

### FIXED CODE ###

H, W, K = list(map(int, input().split()))

c = [None] * H

for i in range(H):
  c[i] = list(input())

res = 0

for h in range(2 ** H):
  for w in range(2 ** W):
    cnt = 0
    for i in range(H):
      for j in range(W):
        if ((h >> i) & 1) == 0 and ((w >> j) & 1) == 0 and c[i][j] == '#':
          cnt += 1
    #print(cnt)
    if cnt == K:
      res += 1

print(res)
#ABC117 B
N = int(input())
Ln = [input() for i in range(N)]
Ln.sort()
max = L[0]
sun = 0
for i in N-1:
    sum += L[i+1]
    
if max < sum:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

#ABC117 B
N = int(input())
Ln = list(map(int, input().split()))
Ln.sort(reverse=True)
max = Ln[0]
sum = sum(Ln)
    
if max < sum - max:
    print("Yes")
else:
    print("No")
n = int(input())
s = str(input())
  
alp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
f = ''
 
for i in range(len(s)):
    for j in range(26):
        m = i + n
        if m >= 26:
            m -= 26
        if s[m] == alp[j]:
            f += alp[j]
print(f)

### FIXED CODE ###

n = int(input())
s = input()
for x in s:
    st = (ord(x) +n-65)%26
    print(chr(65+st),end='')
def count_baisuu(a, b):
  return b - (a % b)
  
def main():
  n = int(input())
  alist = []
  blist = []
  ab = []
  for i in range(n):
    a, b = input_list()
    ab.append((a, b))
    alist.append(a)
    blist.append(b)
    
  dp = [0]*n
  i = n - 1
  for a, b in reversed(ab):
    if i != n-1:
      a += sum(dp)
    if a % b == 0:
      continue
    if a < b:
      dp[i] = b - a
    else:
      dp[i] = count_baisuu(a, b)
    i -= 1
  print(sump(dp))
  
  

import math
import fractions
from functools import reduce


def input_list():
  return map(int, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
main()

### FIXED CODE ###

def count_baisuu(a, b):
  return b - (a % b)
  
def main():
  n = int(input())
  alist = []
  blist = []
  ab = []
  for i in range(n):
    a, b = input_list()
    ab.append((a, b))
    alist.append(a)
    blist.append(b)
  
  s = 0
  res = 0
  for i in range(n-1, -1, -1):
    alist[i] += res
    
    if alist[i] % blist[i] == 0:
      continue
    res += blist[i] - (alist[i]%blist[i])
  print(res)
  exit()
  dp = [0]*n
  i = n - 1
  res = 0
  for a, b in reversed(ab):
    if i != n-1:
      res += dp[i]
    a += res
    if a % b == 0:
      continue
    if a < b:
      dp[i] = b - a
    else:
      dp[i] = count_baisuu(a, b)
    i -= 1
  print(dp)
  
  

import math
import fractions
from functools import reduce


def input_list():
  return map(int, input().split())

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
main()
MAX = 2*10**5
def popcount(x):
    '''xの立っているビット数をカウントする関数
    (xは64bit整数)'''

    # 2bitごとの組に分け、立っているビット数を2bitで表現する
    x = x - ((x >> 1) & 0x5555555555555555)

    # 4bit整数に 上位2bit + 下位2bit を計算した値を入れる
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)

    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f # 8bitごと
    x = x + (x >> 8) # 16bitごと
    x = x + (x >> 16) # 32bitごと
    x = x + (x >> 32) # 64bitごと = 全部の合計
    return x & 0x0000007f
s_map = [0 for i in range(MAX+1)]
def solve(n):
    if n == 0:
        return 1
    if s_map[n] > 0:
        return s_map[n]
    s_map[n] = 1 + solve(n % popcount(n))
    return s_map[n]

N = int(input())
X = input()
num_x = int(X, 2)
p_cnt = X.count('1')
for i in range(N):
    c_p_cnt = p_cnt+1 if X[i] == '0' else p_cnt-1
    x = num_x + 2**(N-1-i) if X[i] == '0' else num_x - 2**(N-1-i)
    if x == 0:
        print(0)
    else:
        print(solve(x % c_p_cnt))



### FIXED CODE ###

N = int(input())

ans = [0 for i in range(10**4+1)]
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            n = x*x + y*y + z*z + x*y + y*z + z*x
            if n <= 10**4:
                ans[n] += 1

for i in range(1, N+1):
    print(ans[i])
N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit(0)

waru = 998244353

dic = {}
dic2 = {}

for i in range(1, N+1):
    dic[i] = D[i-1]

for number, distance in dic.items():
    if distance in dic2:
        dic2[distance] = dic2[distance] + 1
    else:
        dic2[distance] = 1

if 0 in dic2:
    if dic2[0] >= 2:
        print(0)
        exit(0)

l = []

for i in range(1, len(dic2.items()) -1):
    l.append(dic2[i] ** dic2[i+1])

r = 1
for x in l:
    r *= x
d, m = divmod(r, waru)
print(m)

### FIXED CODE ###

N = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit(0)

waru = 998244353

dic = {}
dic2 = {}

for i in range(1, N+1):
    dic[i] = D[i-1]

for number, distance in dic.items():
    if distance in dic2:
        dic2[distance] = dic2[distance] + 1
    else:
        dic2[distance] = 1

if 0 in dic2:
    if dic2[0] >= 2:
        print(0)
        exit(0)

l = []

for i in range(1, len(dic2.items()) - 1):
    if i in dic2 and (i+1) in dic2:
        l.append(dic2[i] ** dic2[i+1])
    else:
        print(0)
        exit(0)

r = 1
for x in l:
    r *= x

d, m = divmod(r, waru)
print(m)
import math
import sys
sys.setrecursionlimit(100000)

# N = 4
# HRR = [10, 30, 40, 20]
# # N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []


def calculate(pos, n, hrr, cost):
    if pos > n - 1:
        return
    if pos == n-1:
        result.append(int(cost))
        return

    if pos + 1 <= n - 1:
        calculate(pos + 1, n, hrr, cost + math.fabs(hrr[pos + 1] - hrr[pos]))

    if pos + 2 <= n - 1:
        calculate(pos + 2, n, hrr, cost + math.fabs(hrr[pos + 2] - hrr[pos]))


calculate(0, N, HRR, 0)
print(min(result))

### FIXED CODE ###

# N = 4
# HRR = [10, 30, 40, 20]
# N = 2
# HRR = [10, 10]

N = int(input())
HRR = list(map(int,input().split()))
result = []
for i in range(N):
    if i == 0:
        result.append(0)
    elif i == 1:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        result.append(s1)
    else:
        s1 = result[i - 1] + abs(HRR[i] - HRR[i - 1])
        s2 = result[i - 2] + abs(HRR[i] - HRR[i - 2])
        result.append(min(s1, s2))

print(result[-1])
N = int(input())

S = input()

ans = True
for i in range(N):
  if S[i] != S[i + N / 2]:
    ans = False
    
if ans:
  print('Yes')
else:
  print('No')

### FIXED CODE ###

N = int(input())
S = input()

N = int(N / 2)
if S[: N] == S[N: ]:
    print('Yes')
else:
    print('No')