Harryxun/stf_run huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 998244353

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []

    while True:
        n,m = LI()
        if n == 0 and m == 0:
            break

        cs = [I() for _ in range(m)]
        xs = [I() for _ in range(n)]
        d = collections.defaultdict(int)
        d[128] = 0
        for x in xs:
            n = collections.defaultdict(lambda: inf)
            for k,v in d.items():
                for c in cs:
                    nk = max(min(k+c,255),0)
                    if n[nk] > v + (x-nk) ** 2:
                        n[nk] = v + (x-nk) ** 2
            d = n

        rr.append(min(d.values()))


    return '\n'.join(map(str, rr))


print(main())




### FIXED CODE ###

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    rr = []
    M = 256
    sq = [i**2 for i in range(M)]
    nkss = [[sq[abs(x-nk)] for nk in range(M)] for x in range(M)]
    ML = list(range(M))

    def f(m, n):
        cs = [I() for _ in range(m)]
        xs = [I() for _ in range(n)]
        ml = list(range(m))
        d = [inf] * M
        nd = [inf] * M
        d[128] = 0
        ckl = list(map(lambda x: (max(min(x[0]+x[1], 255), 0), x[1]), (itertools.product(cs, ML))))
        for i in range(n):
            nd = [inf] * M
            for nk,k in ckl:
                if nd[nk] > d[k]:
                    nd[nk] = d[k]
            d = [nn + kk for nn,kk in zip(nd, nkss[xs[i]])]
        return min(d)

    while True:
        n,m = LI()
        if m == 0 and n == 0:
            break
        rr.append(f(m,n))

    return '\n'.join(map(str,rr))




print(main())
import numpy as np
n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

pk = np.array([])
ansum = np.array([])
for i,name  in enumerate(p):
    pk = np.append(pk, (name+1)/2)
    if i >= 2:
        ansum = np.append(ansum, np.sum(pk[-k:]))

print(np.max(ansum))

### FIXED CODE ###

n,k = list(map(int, input().split()))
p = list(map(int, input().split()))

p1 = (sum(p[:k]) + k)/2

ansum = [p1]
for i  in range(len(p)-k):
    p1 = p1 - (p[i]+1)/2 + (p[i+k]+1)/2
    ansum.append(p1)

print(max(ansum))
# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???
while 1:
	str = input()
	op_num = int( input() )
	for i in range(op_num):
		op = input().split()
		a = int(op[1])
		b = int(op[2])
		if op[0]=="replace":
			str = str.replace(str[ a:b+1 ], op[3])
		elif op[0]=="reverse":
			str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		elif op[0]=="print":
			print(str[a:b+1])

### FIXED CODE ###

# 21-String-Transformation.py

# ???????????????
# ????????? str ?????????????????????????????????????????????????????????????????°????????????????????????????????????
# ???????????\?????????????????????????????§??????

# print a b: str ??? a ??????????????? b ??????????????§??????????????????
# reverse a b: str ??? a ??????????????? b ??????????????§?????????????????????
# replace a b p: str ??? a ??????????????? b ??????????????§??? p ?????????????????????
# ????????§??????????????? str ????????????????????? 0 ???????????¨????????????

# Input
# 1 ?????????????????? str ????????????????????????str ?????±?°????????????????????????????
# 2 ????????????????????° q ?????????????????????????¶???? q ??????????????????????¨??????¢?????§?????????????????????

# Output
# ??? print ???????????¨???????????????????????????????????????????????????

# Constraints
# 1???str????????????1000
# 1???q???100
# 0???a???b<str?????????
# replace ????????§??? b???a+1=p?????????

# Sample Input 1
# abcde
# 3
# replace 1 3 xyz
# reverse 0 2
# print 1 4
# Sample Output 1
# xaze

# Sample Input 2
# xyz
# 3
# print 0 2
# replace 0 2 abc
# print 0 2
# Sample Output 2
# xyz
# abc

#??\???

str = input()
op_num = int( input() )
for i in range(op_num):
	op = input().split()
	a = int(op[1])
	b = int(op[2])
	if op[0]=="replace":
		# str = str.replace(str[ a:b+1 ], op[3])
		str = str[0:a] + op[3] + str[b+1:]
	elif op[0]=="reverse":
		# str = str.replace(str[a:b+1], str[ b-len(str) : a-len(str)-1 : -1 ] )
		str = str[:a] + str[a:b+1][::-1] + str[b+1:]
	# elif op[0]=="print":
	else:
		print(str[a:b+1])
N = int(input())
al = []
bl = []
for i in range(N):
    a,b = map(int,input().split())
    al.append(a)
    bl.append(b)
al.reverse()
bl.reverse()

plus = 0
for i in range(N):
    if al[i]+plus > bl[i]:
        amari = (al[i]+plus) % bl[i]
        syo = (al[i]+plus) // bl[i]
        if amari != 0:
            syo += 1
        plus += bl[i] * syo - (al[i]+plus)

    elif al[i]+plus < bl[i]:
        amari = bl[i] % (al[i]+plus)
        syo = bl[i] // (al[i]+plus)
        if amari != 0:
            syo += 1
        plus += syo

    else:
        continue


print(plus)



### FIXED CODE ###

n = int(input())
ab = []
for _ in range(n):
    ab.append(list(map(int,input().split())))

cnt = 0
for i in range(n-1,-1,-1):
    a,b = ab[i][0],ab[i][1]
    num = a + cnt
    if num % b == 0:
        continue
    else:
        amari = num % b
        cnt += b-amari
    
print(cnt)
l=map(int,raw_input().split())
a=l[0]
b=l[1]
c=a*b
d=(a+b)*2
print c+" "+d

### FIXED CODE ###

l = map(int, raw_input().split())
a=l[0]
b=l[1]
c=a*b
d=(a+b)*2
print str(c)+" "+str(d)
from math import log2
from math import ceil
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    t=max(0,ceil(log2(k/i)))
    ans+=(0.5**t)/n
print(ans)

### FIXED CODE ###

from math import log2
from math import ceil
n,k=map(int,input().split())
ans=0
for i in range(1,n+1):
    t=max(0,ceil(log2(k/i)))
    ans+=(0.5**t)/n
print(ans)
while True:
    num = input()

    print = sum(map(int,list(str(num))))
    if num == 0:
        break

### FIXED CODE ###

num_list=[]
while True:
    num = input()
    if num == 0:
        break
    num_list.append(num)

for num in num_list:
    print sum(map(int,list(str(num))))
n,m=map(int,input().split())
a=[list(map(int,input().split()))for i in range(n)]
b=[int(input())for i in range(m)]
[print(sum([j*k for j,k in zip(a[i],b]))for i in range(n)]


### FIXED CODE ###

n,m=map(int,input().split())
a=[list(map(int,input().split())) for _ in range(n)]
b=[int(input())for _ in range(m)]
[print(sum([j*k for j,k in zip(a[i],b)]))for i in range(n)]
import math

def main():
    N, M = tuple(map(int, input().split(' ')))
    man_list = []
    point_list = []
    for i in range(N):
        man_list.append(tuple(map(int, input().split(' '))))
    for i in range(M):
        point_list.append(tuple(map(int, input().split(' '))))

    result = []
    for i, man in enumerate(man_list):
        a, b = man
        min_ = float('inf')
        for j, point in enumerate(point_list):
            c, d = point
            v = abs(a-c)+ abs(b-d)
            if len(result) < i+1:
                min_ = v
                result.append(j+1)
                continue
            if v < min_:
                result[i] = j+1
                min_ = v


    for r in result:
        print('{}'.format(r))


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    A, B = tuple(map(int, input().split(' ')))
    print('{}'.format((A+B)%24))


if __name__ == '__main__':
    main()
class Combinatorics:
    def __init__(self, N, mod):
        '''
        Preprocess for calculating binomial coefficients nCr (0 <= r <= n, 0 <= n <= N)
        over the finite field Z/(mod)Z.
        Input:
            N (int): maximum n
            mod (int): a prime number. The order of the field Z/(mod)Z over which nCr is calculated.
        '''
        self.mod = mod
        self.fact = {i: None for i in range(N+1)}         # n!
        self.inverse = {i: None for i in range(1, N+1)}   # inverse of n in the field Z/(MOD)Z
        self.fact_inverse = {i: None for i in range(N+1)} # inverse of n! in the field Z/(MOD)Z
        
        # preprocess
        self.fact[0] = self.fact[1] = 1
        self.fact_inverse[0] = self.fact_inverse[1] = 1
        self.inverse[1] = 1
        for i in range(2, N+1):
            self.fact[i] = i * self.fact[i-1] % self.mod
            q, r = divmod(self.mod, i)
            self.inverse[i] = (- (q % self.mod) * self.inverse[r]) % self.mod
            self.fact_inverse[i] = self.inverse[i] * self.fact_inverse[i-1] % self.mod
    
    def perm(self, n, r):
        '''
        Calculate nPr = n! / (n-r)! % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return (self.fact[n] * self.fact_inverse[n-r]) % self.mod
    
    def binom(self, n, r):
        '''
        Calculate nCr = n! /(r! (n-r)!) % mod
        '''
        if n < r or n < 0 or r < 0:
            return 0
        else:
            return self.fact[n] * (self.fact_inverse[r] * self.fact_inverse[n-r] % self.mod) % self.mod
        
    def hom(self, n, r):
        '''
        Calculate nHr = {n+r-1}Cr % mod.
        Assign r objects to one of n classes.
        Arrangement of r circles and n-1 partitions:
            o o o | o o | | | o | | | o o | | o
        '''
        if n == 0 and r > 0:
            return 0
        if n >= 0 and r == 0:
            return 1
        return self.binom(n + r - 1, r)
n,a,b=map(int,input().split())
c = Combinatorics(n+k,lim)
ans = (2**n-1-c.binom(n,a)-c.binom(n,b))
print(ans%lim)

### FIXED CODE ###

n,a,b = map(int,input().split())
lim = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

print((pow(2,n,lim)-combination(n,a)-combination(n,b)-1) % lim)
s=input()
if s[0]=s[1] and s[1]==s[2]:
  print("Yes")
  
else :
  print("No")


### FIXED CODE ###

s=input()
if s[0]==s[1] and s[1]==s[2]:
  print("No")
  
else :
  print("Yes")
n, m, k=map(int, input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))

k=tmp

ans=0

cnt1=0
cnt2=0
cost1=0
cost2=0

for i in range(n):
    cost1+=a[i]
    if cost1<=k:
        cnt1+=1
    else:
        cost1-=a[i]
        break

for j in range(m):
    cost2+=b[j]
    if cost2<=k:
        cnt2+=1
    else:
        cost2-=b[j]
        break

if cnt1>cnt2:
    ans+=cnt1
    k-=cost1
    for i in range(m):
        k-=b[i]
        if k>=0:
            ans+=1
        else:
            break
    
    print(ans)

elif cnt2>cnt1:
    ans+=cnt2
    k-=cost2
    for i in range(n):
        k-=a[i]
        if k>=0:
            ans+=1
        else:
            break
    
    print(ans)

else:
    alpha+=cnt1
    tmp-=cost1
    for i in range(m):
        tmp-=b[i]
        if k>=0:
            alpha+=1
        else:
            break
    
    bata+=cnt2
    k-=cost2
    for i in range(n):
        k-=a[i]
        if k>=0:
            bata+=1
        else:
            break

    ans=max(alpha, bata)

    print(ans)

### FIXED CODE ###

n, m, k=map(int, input().split())
A=list(map(int, input().split()))
B=list(map(int, input().split()))

a=[0]
b=[0]

for i in range(n):
    a.append(a[i]+A[i])

for i in range(m):
    b.append(b[i]+B[i])

ans, j=0, m
for i in range(0, n+1):
    if a[i]>k:
        break
    else:
        while a[i]+b[j]>k:
            j-=1
        
    ans=max(ans, i+j)


print(ans)
a,b,c=input().split

print("YES" if a[-1]==b[0] and b[-1]==c[0] else "NO")

### FIXED CODE ###

a,b,c=input().split()

print("YES" if a[-1]==b[0] and b[-1]==c[0] else "NO")
N = int(input())
r = range(N)
l = list(r)
sum = 0

for i in l:
  sum += l[i]

print(sum)
  


### FIXED CODE ###

N = int(input())
result = int(N*(N-1)//2)

print(result)
N=int(input())
timeslis2=[0,]*(100000)
timeslis2[1]=1
numlist2=numlist[::-1]
def times2(N):
    if N!=0:
        if timeslis2[N]==0:
            mini2=[]
            i=0
            while i<=11 and len(mini2)<=2:
                if N-numlist2[i]>=0:
                    mini2.append(times2(N-numlist2[i]))
                #print(mini2,numlist2[i],i)
                i+=1
            mini2.sort()
            timeslis2[N]=mini2[0]+1
            return mini2[0]+1
        else:
            return timeslis2[N]
    return 0
print(times2(N))

### FIXED CODE ###

N=int(input())
numlist=[1, 6, 9, 36, 81, 216, 729, 1296, 6561, 7776, 46656, 59049]
timeslis2=[0,]*(100001)
timeslis2[1]=1
numlist2=numlist[::-1]
def times2(N):
    if N!=0:
        if timeslis2[N]==0:
            mini2=[]
            i=0
            while i<=11 and len(mini2)<=2:
                if N-numlist2[i]>=0:
                    mini2.append(times2(N-numlist2[i]))
                #print(mini2,numlist2[i],i)
                i+=1
            mini2.sort()
            timeslis2[N]=mini2[0]+1
            return mini2[0]+1
        else:
            return timeslis2[N]
    return 0
print(times2(N))
n, m, l = list(map(lambda x: int(x), input().split(" ")))
A = list()
for i in range(n):
    A.extend([list(map(lambda x: int(x), input().split(" ")))])
B = list()
for i in range(m):
    B.extend([list(map(lambda x: int(x), input().split(" ")))])
C = list([[0 for n_ in range(n)]for l_ in range(l)])
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for a in C:
    print("%d" % a[0], end="")
    for b in a[1:]:
        print(" %d" % b, end="")
    print()

### FIXED CODE ###

n, m, l = list(map(lambda x: int(x), input().split(" ")))
A = list()
for i in range(n):
    A.extend([list(map(lambda x: int(x), input().split(" ")))])
B = list()
for i in range(m):
    B.extend([list(map(lambda x: int(x), input().split(" ")))])
C = list([[0 for l_ in range(l)]for n_ in range(n)])
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k] * B[k][j]
for a in C:
    print("%d" % a[0], end="")
    for b in a[1:]:
        print(" %d" % b, end="")
    print()
s=input()
t=input()
ans = 0
for i in range(len(s)):
  	if(s[i]!=t[i]):
      ans+=1
print(ans)

### FIXED CODE ###

s=input()
t=input()
ans = 0
for i in range(len(s)):
	if(s[i]!=t[i]):
		ans+=1
print(ans)
N = int(input()) / 2
a = input().split()

if a[N] == a[N + 1]:
    print(0)
else:
    print(int(a[N+1]) - int(a[N]))

### FIXED CODE ###

N=int(int(input())/2)
a=sorted(list(map(int,input().split())))
print(int(a[N])-int(a[N-1]))
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N = int(input())
    C = list(input().strip())
    invC = C[::-1]
    ans = 0
    leftW = C.index('W')
    rightR = N - 1 - invC.index('R')
    while leftW < rightR:
        # print('C={}, invC={}'.format(C, invC))
        # print('leftW={}, rightR={}'.format(leftW, rightR))
        ans += 1
        C[rightR] = 'W'
        invC[-1-rightR] = 'W'
        C[leftW] = 'R'
        invC[-1-leftW] = 'R'
        leftW = C.index('W')
        rightR = N - 1 - invC.index('R')
    print(ans)

if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**6)
    N = int(input())
    C = list(input().strip())
    l, r = 0, N-1
    ans = 0
    if 'R' not in C or 'W' not in C:
        print(0)
        return True
    while l < r:
        while C[l] == 'R':
            l += 1
        while C[r] == 'W':
            r -= 1
        if l < r:
            ans += 1
            l += 1
            r -= 1
            
    print(ans)

if __name__ == '__main__':
    main()
num1=int(input)
num2=int(input)
s=num1*num2
print(s)


### FIXED CODE ###

s = raw_input().split()
a = int(s[0])
b = int(s[1])
print("{0} {1}".format(a*b, 2*(a+b)))
s = input()
n = len(s)

a = "10" * (n // 2) + ("1" if n % 2 == 0 or n == 1 else "")
b = "01" * (n // 2) + ("0" if n % 2 == 0 or n == 1 else "")

sum_a = 0
for i in range(n):
    if s[i] != a[i]: sum_a += 1

sum_b = 0
for i in range(n):
    if s[i] != b[i]: sum_b += 1

print(min(sum_a, sum_b))

### FIXED CODE ###

s = input()
n = len(s)

a = "10" * (n // 2) + ("1" if n % 2 == 1 else "")
b = "01" * (n // 2) + ("0" if n % 2 == 1 else "")

sum_a = 0
for i in range(n):
    if s[i] != a[i]: sum_a += 1

sum_b = 0
for i in range(n):
    if s[i] != b[i]: sum_b += 1

print(min(sum_a, sum_b))
#coding:utf-8

def call(n):
    i=1

    for i in range(1,n+1):
        x=i
        if x%3==0:
            print(" "+str(x),end="")
        else:
            while x!=0:
                if x%10==3:
                    print(" "+str(x),end="")
                    break
                else:
                    x/=10
                    
    print("")

n=int(input())
call(n)

### FIXED CODE ###

#coding:utf-8

def call(n):
    for i in range(1,n+1):
        x=i
        if x%3==0:
            print(" "+str(i),end="")
        else:
            while x!=0:
                if x%10==3:
                    print(" "+str(i),end="")
                    break
                else:
                    x//=10
                    
    print("")

n=int(input())
call(n)
class BigCombination(object):
    __slots__ = ["mod", "factorial", "inverse"]

    def __init__(self, mod= 10**9+7, max_n = 10**6):
        fac, inv = [1], []
        fac_append, inv_append = fac.append, inv.append

        for i in range(1, max_n+1):
            fac_append(fac[-1] * i % mod)

        inv_append(pow(fac[-1], mod-2, mod))

        for i in range(max_n, 0, -1):
            inv_append(inv[-1] * i % mod)

        self.mod, self.factorial, self.inverse = mod, fac, inv[::-1]

    def get_combination(self, n, r):
        if n < r or n == 0 or r == 0:
            return 0
        return self.factorial[n] * self.inverse[r] * self.inverse[n-r] % self.mod

    def get_permutation(self, n, r):
        return self.factorial[n] * self.inverse[n-r] % self.mod

N = int(input())
A = [int(x) for x in input().split()]
se = []
c = sum(A) - N * (N + 1) / 2
for i in range(len(A)):
    if A[i] == c:
        se.append(i)
l = se[0]
r = se[1]
import math

print(N)
Big = BigCombination()

for i in range(2,N+2):
    k = Big.get_combination(N+1, i)
    
    t = Big.get_combination(l+N-r,i-1)
    res  = k -t
    print(res)



### FIXED CODE ###

mod = 10**9+7
N = int(input())
A = [int(x) for x in input().split()]
se = []
c = sum(A) - N * (N + 1) / 2
for i in range(len(A)):
    if A[i] == c:
        se.append(i)
l = se[0]
r = se[1]
import math

print(N)

factorial = [1]
inverse = [1]
for i in range(1, N + 2):
    factorial.append(factorial[-1] * i % mod)
    inverse.append((pow(factorial[-1], mod - 2, mod)))


def nCr(n, r):
    if n < r or n == 0 or r == 0:
        return 0
    return factorial[n] * inverse[r] * inverse[n - r] % mod



for i in range(2,N+2):
    k = nCr(N+1, i)
    
    t = nCr(l+N-r,i-1)
    res  = k -t
    print(res % mod)
A = []
A.append(input().split())
A.append(input().split())
A.append(input().split())
N = int(input())
b = [input() for _ in range(N)]
 
for i in range(N):
  for j in range(3):
    if b[i] in A[j]: A[j][A[j].index(b[i])] = True
    
if (A[0] and A[3] and A[6]) or (A[1] and A[4] and A[7]) or (A[2] and A[5] and A[8]) or (A[0] and A[1] and A[2]) or (A[3] and A[4] and A[5]) or (A[6] and A[7] and A[8]) or (A[0] and A[4] and A[8]) or (A[2] and A[4] and A[6]): print('Yes')
else: print('No')

### FIXED CODE ###

A = []
A += input().split()
A += input().split()
A += input().split()
N = int(input())
b = [input() for _ in range(N)]
 
for i in range(N):
  if b[i] in A:
    A[A.index(b[i])] = '.'
    
if (A[0] == '.' and A[3] == '.' and A[6] == '.') or (A[1] == '.' and A[4] == '.' and A[7] == '.') or (A[2] == '.' and A[5] == '.' and A[8] == '.') or (A[0] == '.' and A[1] == '.' and A[2] == '.') or (A[3] == '.' and A[4] == '.' and A[5] == '.') or (A[6] == '.' and A[7] == '.' and A[8] == '.') or (A[0] == '.' and A[4] == '.' and A[8] == '.') or (A[2] == '.' and A[4] == '.' and A[6] == '.'): print('Yes')
else: print('No')
n=int(input())
flag=0
for i in range(9):
    for j in range(9):
        if i*j=n:
            flag=1
            break
if flag: print("Yes")
else: print("No")

### FIXED CODE ###

n=int(input())
flag=0
for i in range(1,10):
    for j in range(1,10):
        if i*j==n:
            flag=1
            break
if flag: print("Yes")
else: print("No")
from collections import Counter


def dfs(n):
    if memo[n] >= 0:
        rst = memo[n]
    else:
        tmp = n
        one = 0
        while tmp > 0:
            one += tmp & 1
            tmp >>= 1
        m = n % one
        rst = 1 if m == 0 else 1 + dfs(m)
        memo[n] = rst
    return rst


N = int(input())
X = input()
# X = list(map(int, list(input())))
# one = Counter(X)[1]


memo = [-1] * (1 << (N + 1))
memo[0] = 0

x = int(X, 2)
for i in range(N):
    ans = dfs(x ^ (1 << ((N - 1) - i)))
    print(ans)


### FIXED CODE ###

from collections import Counter
import sys
sys.setrecursionlimit(10 ** 6)


def dfs(n):
    if memo[n] >= 0:
        rst = memo[n]
    else:
        tmp = n
        one = 0
        while tmp > 0:
            one += tmp & 1
            tmp >>= 1
        m = n % one
        rst = 1 if m == 0 else 1 + dfs(m)
        memo[n] = rst
    return rst


N = int(input())
# X = input()
X = list(map(int, list(input())))
one = Counter(X)[1]


if one > 1:
    Sm = 0
    mm = one - 1
    tm = 1
    for i in range(N - 1, -1, -1):
        tm %= mm
        if X[i] == 1:
            Sm += tm
            Sm %= mm
        tm *= 2

Sp = 0
mp = one + 1
tp = 1
for i in range(N - 1, -1, -1):
    tp %= mp
    if X[i] == 1:
        Sp += tp
        Sp %= mp
    tp *= 2


memo = [-1] * (2 * (10 ** 5) + 10)
memo[0] = 0

# x = int(X, 2)
# for i in range(N):
#     ans = dfs(x ^ (1 << ((N - 1) - i)))
#     print(ans)
for i in range(N):
    if one == 1:
        if X[i] == 0:
            m = (Sp + pow(2, N - 1 - i, mp)) % mp
            if m == 0:
                print(1)
            else:
                print(1 + dfs(m))
        else:
            print(0)
        continue

    if X[i] == 0:
        m = (Sp + pow(2, N - 1 - i, mp)) % mp
    else:
        m = (Sm - pow(2, N - 1 - i, mm)) % mm
    
    if m == 0:
        print(1)
    else:
        print(1 + dfs(m))