Harryxun/stf_run huggingface dataset:
#幅優先探索


from queue import Queue

ans = 0
h,w = map(int, input().split())
maps = [input() for _ in range(h)]
for i in range(1):
    for j in range(1,2):
        if maps[i][j] == '.':
            visited = [[-1]*w for _ in range(h)]
            q = Queue()
            q.put([i,j])
            visited[i][j] = 0
            while not q.empty():
                y,x = q.get()
                for k,l in [[1,0],[-1,0],[0,1],[0,-1]]:
                    if 0 <= y+k < h and 0<= x+l < w:
                        new_y,new_x = y+k,x+l
                    else: continue
                    if visited[new_y][new_x]== -1 and maps[new_y][new_x]==".":
                        visited[new_y][new_x]=visited[y][x]+1
                        q.put([new_y,new_x])
   
          
        
            for ii in range(h):
                for jj in range(w):
                    ans = max(ans,visited[ii][jj])


print(ans)




### FIXED CODE ###

#幅優先探索


from queue import Queue

ans = 0
h,w = map(int, input().split())
maps = [input() for _ in range(h)]
for i in range(h):
    for j in range(w):
        if maps[i][j] == '.':
            visited = [[-1]*w for _ in range(h)]
            q = Queue()
            q.put([i,j])
            visited[i][j] = 0
            while not q.empty():
                y,x = q.get()
                for k,l in [[1,0],[-1,0],[0,1],[0,-1]]:
                    if 0 <= y+k < h and 0<= x+l < w:
                        new_y,new_x = y+k,x+l
                    else: continue
                    if visited[new_y][new_x]== -1 and maps[new_y][new_x]==".":
                        visited[new_y][new_x]=visited[y][x]+1
                        q.put([new_y,new_x])
   
          
        
            for ii in range(h):
                for jj in range(w):
                    ans = max(ans,visited[ii][jj])


print(ans)
S = {'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'STA':1, 'SUN':7}

s = (input())
print(S[s])

### FIXED CODE ###

S = {'MON':6, 'TUE':5, 'WED':4, 'THU':3, 'FRI':2, 'SAT':1, 'SUN':7}

s = input()
print(S[s])
N = int(input())

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, n+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)


### FIXED CODE ###

N = int(input())

cnt = [[0 for _ in range(10)] for _ in range(10)]

for k in range(1, N+1):
    s = str(k)
    cnt[int(s[0])][int(s[-1])] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += cnt[i][j] * cnt[j][i]
print(ans)
import sys

class Node:
    def __init__(self, i):
        self.linked = list()
        self.id = i
        self.blocked = list()
        self.visited = False

line = sys.stdin.readline().strip()
n,m,k = map(int, line.split())
nodes = [] 
for i in range(n):
    nodes.append(Node(i))

for i in range(m):
    line = sys.stdin.readline().strip()
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    nodes[a].linked.append(b)
    nodes[b].linked.append(a)

for i in range(k):
    line = sys.stdin.readline().strip()
    a, b = map(int, line.split())
    a -= 1
    b -= 1
    nodes[a].blocked.append(b)
    nodes[b].blocked.append(a)

start = 0
res = [0] * n
while True:
    visited = [start]
    def deep_first(node):
        for one in node.linked:
            if not nodes[one].visited:
                visited.append(one)
                nodes[one].visited = True 
                deep_first(nodes[one])

    nodes[start].visited = True
    deep_first(nodes[start])           
    for one in visited:
        cands = 0
        for two in nodes[one].blocked:
            if two in visited:
                cands += 1
        res[one] = len(visited) - len(nodes[one].linked) - 1 - cands

    start = -1
    for i in range(1, n):
        if not nodes[i].visited:
            start = i
            break
    if start == -1:
        break

print(" ".join(map(str, res)))

### FIXED CODE ###

import sys

line = sys.stdin.readline().strip()
n,m,k = map(int, line.split())
roots = [-1]*n
linked = [0]*n
def find_root(x):
    if roots[x] < 0:
        return x
    else:
        roots[x] = find_root(roots[x])
        return roots[x]
def unite(x, y):
    x = find_root(x)
    y = find_root(y)
    if (x==y):
        return
    if roots[x] > roots[y]:
        c, d = y,x
        x,y = c,d
    roots[x] += roots[y]
    roots[y] = x

for i in range(m):
    line = sys.stdin.readline().strip()
    a,b = map(int, line.split())
    c, d = a-1,b-1
    linked[c] += 1 
    linked[d] += 1
    unite(c,d)
#print(roots)
blacks = [[]for i in range(n)]
for i in range(k):
    line = sys.stdin.readline().strip()
    a,b = map(int, line.split())
    c,d = a-1, b-1
    blacks[c].append(d)
    blacks[d].append(c)
res = []
for i in range(n):
    r = -roots[find_root(i)] - 1 - linked[i]
    for one in blacks[i]:
        if find_root(one) == find_root(i):
            r -= 1
    res.append(r)
    
print (" ".join(map(str, res)))
N = int(intput())
L = list(map(int, input().split())
L_inv = [1/l for l in L]
print(1 / sum(L_inv))

### FIXED CODE ###

N = int(input())
L = list(map(int, input().split()))
L_inv = [1/l for l in L]
print(1 / sum(L_inv))
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    II = lambda : int(input())

    N = II()
    info = []
    MAXL = 101
    b = [[0] * MAXL for _ in range(MAXL)]

    def vtop(x1,x2,y1,y2,h1):
        ans = h1 + abs(x1-x2) + abs(y1-y2)
        return ans if ans <= 10**9 else 0

    # get info
    info = []
    for i in range(N):
        x,y,h = LMIIS()
        info.append((x,y,h))

    # info = XLMIIS(N)
    if len(info) < N:
        raise Exception()
    elif len(info) > N:
        while True:
            pass

    # init candidates
    for x,y,h in info:
        if h != 0:
            for i in range(MAXL):
                for j in range(MAXL):
                    b[i][j] = vtop(x,j,y,i,h)
        break

    # check
    for x,y,h in info:
        for i in range(MAXL):
            for j in range(MAXL):
                if h == 0:
                    if b[i][j] > vtop(x,j,y,i,h):
                        b[i][j] = 0

                else:
                    if b[i][j] != vtop(x,j,y,i,h):
                        b[i][j] = 0

    # answer
    ansl = []
    for i in range(MAXL):
        for j in range(MAXL):
            if b[i][j] > 0:
                ansl.append((j,i,b[i][j]))
    
    ansl2 = []
    for x0,y0,h0 in ansl:
        f = True
        for x1,y1,h1 in info:
            
            if max(h0-abs(x0-x1)-abs(y0-y1),0) != h1:
                f = False
                break
        if f:
            ansl2.append((x0,y0,h0))
    x,y,h= ansl2[-1]
    print(x,y,h)


if __name__ == '__main__':
    main()

### FIXED CODE ###

#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())

    N = II()
    info = []
    for _ in range(N):
        xi, yi, hi = LMIIS()
        if hi != 0:
            xt, yt, ht = xi, yi, hi
        info.append((xi, yi, hi))

    for Cy in range(101):
        for Cx in range(101):
            H = ht + abs(xt - Cx) + abs(yt - Cy)
            found = True
            for xi, yi, hi in info:
                tmp_h = max(H - abs(Cy-yi) - abs(Cx-xi), 0)
                if tmp_h != hi:
                    found = False
                    break
            if found:
                print('{} {} {}'.format(Cx,Cy,H))
                return



if __name__ == '__main__':
    main()
r = int(input())
import math
print("%.6f"%(math.pi * r * r,math.pi * 2 * r))

### FIXED CODE ###

r = float(input())
import math
print("%.6f"%(math.pi * r * r),"%.6f"%(math.pi * 2 * r))
import math

n = input()
for i in xrange(n):
    result = long(raw_input()) + long(raw_input())
    if int(math.log10(result)) + 1 >80: print "overflow"
    else: print result

### FIXED CODE ###

n = input()
limit = 10 ** 80
for i in xrange(n):
    result = input() + input()
    if result >= limit: print "overflow"
    else: print result
print("NYoe s"[int(input().replace(" ","")).isinteger()::2])

### FIXED CODE ###

print("NYoe s"[int(input().replace(" ",""))**0.5%1==0::2])
import sys 

A = int(sys.argv[1])
B = int(sys.argv[2])

if not (A >= 1):
  pass

if not (B <= 20):
  pass

if A <= B:
  if B % A == 0:
    print(A + B)
  else:
    print(B - A)

### FIXED CODE ###

# -*- coding: utf-8 -*-

def func_a():
  argv = input().split(" ")
  A = int(argv[0]) if int(argv[0]) >= 1 else 0
  B = int(argv[1]) if int(argv[1]) <= 20 else 0

  if A * B == 0:
    pass
  else:
    if B % A == 0:
      print(A + B)
    else:
      print(B - A)


if __name__ == "__main__":
  func_a()
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
G=[[0]*W for i in range(H)]
i=0
j=0
tmp=0
t=1
for a in A:
    tmp+=1
    for k in range(a):
        G[i][j]=tmp
        if j==W-1:
            if t==0:
                i+=1
                t=1
                dx=0
            elif t==1:
                dx=-1
                t=0
        elif j==0:
            if t==0:
                i+=1
                t=1
                dx=0
            elif t==1:
                dx=1
                t=0
        j+=dx
for k in G:
    print(*k,sep=" ")


### FIXED CODE ###

H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
if W==1:
    tmp=0
    for a in A:
        tmp+=1
        for j in range(a):
            print(tmp)
    quit()
G=[[0]*W for i in range(H)]
i=0
j=0
tmp=0
t=1
for a in A:
    tmp+=1
    for k in range(a):
        G[i][j]=tmp
        if j==W-1:
            if t==0:
                i+=1
                t=1
                dx=0
            elif t==1:
                dx=-1
                t=0
        elif j==0:
            if t==0:
                i+=1
                t=1
                dx=0
            elif t==1:
                dx=1
                t=0
        j+=dx
for k in G:
    print(*k,sep=" ")
import sys
input = sys.stdin.buffer.readline
import bisect
import copy
from collections import deque

def main():
    N = int(input())
    a = list(map(int,input().split()))
    INF = 10**12
    
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        u,v = map(int,input().split())
        edge[u-1].append(v-1)
        edge[v-1].append(u-1)
        
    def LIS(dp,num):
        ind = bisect.bisect_left(dp,num)
        ret = dp[ind]
        dp[ind] = num
        return ind,ret
    
    dp = [INF]*(N+2)
    dp[0] = -INF
    dp[1] = a[0]

    ans = [0]*N
    q = deque([])
    
    def DFS(prev,now,dp):
        while q:
            s,t,ind,num = q.pop()
            if t == prev:
                q.append((s,t,ind,num))
                break
            else:
                dp[ind] = num
        ind,num = LIS(dp,a[now])
        ans[now] = ind
        q.append((prev,now,ind,num))
        for fol in edge[now]:
            if fol != prev:
                DFS(now,fol,dp)

    DFS(-1,0,dp)
    print(*ans,sep="\n")
 
if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
import bisect
import copy
from collections import deque
sys.setrecursionlimit(10**7)

def main():
    N = int(input())
    a = list(map(int,input().split()))
    INF = 10**12
    
    edge = [[] for _ in range(N)]
    for _ in range(N-1):
        u,v = map(int,input().split())
        edge[u-1].append(v-1)
        edge[v-1].append(u-1)
        
    def LIS(dp,num):
        ind = bisect.bisect_left(dp,num)
        ret = dp[ind]
        dp[ind] = num
        return ind,ret
    
    dp = [INF]*(N+2)
    dp[0] = -INF

    ans = [0]*N
    q = deque([])
    
    def DFS(prev,now,dp):
        while q:
            s,t,ind,num = q.pop()
            if t == prev:
                q.append((s,t,ind,num))
                break
            else:
                dp[ind] = num
        ind,num = LIS(dp,a[now])
        ans[now] = max(ind,ans[prev])
        q.append((prev,now,ind,num))
        for fol in edge[now]:
            if fol != prev:
                DFS(now,fol,dp)

    DFS(-1,0,dp)
    print(*ans,sep="\n")
 
if __name__ == "__main__":
    main()
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))


ma = -np.inf
for i in range(N-1):
  if sum(A1[:i+1]) + sum(A2[i:]) > ma:
    ma = sum(A1[:i+1]) + sum(A2[i:])

  if N == 1:
    ma = A1[0] + A2[0]

print(ma)

### FIXED CODE ###

import numpy as np

N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
 
ma = -np.inf
for i in range(N-1):
  if sum(A1[:i+1]) + sum(A2[i:]) > ma:
    ma = sum(A1[:i+1]) + sum(A2[i:])
    
if N == 1:
  ma = A1[0] + A2[0]
  
print(ma)
N = int(input())
A = [int(x) for x in input(" ").split()]
 
result = 1
for idx in A:
    result *= idx
if result <= 10**18:
	print(result)
else:
 	print("-1")

### FIXED CODE ###

data = input().split(" ")
a ,b= int(data[0]) , int(data[1])
print(a*b)
N = int(input())
lst = [int(n) for n in input().split(" ")]
val_max = 0
val_min = 0
for i in range(0,N):
  if val_max < i:
    val_max = i
  elseif val_min > i:
    val_min = i
print(val_max-val_min)

### FIXED CODE ###

N = int(input())
lst = [int(n) for n in input().split(" ")]
   
print(max(lst)-min(lst))
from collections import deque
import sys
INF = 11414191981036436433-4

n = int(input())
g = [[] for i in range(n)]
for v in range(n-1):
    a,b,c = map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
    
q,k = map(int,input().split())
k -= 1

r = [INF]*n
que = deque([k])
r[k] = 0
while que:
    v = que.popleft()
    rr = r[v]
    for w,x in G[v]:
        if r[w] == INF:
            r[w] = rr + x
            que.append(w)
            
for i in range(q):
    d,e = map(int,input().split())
    print(r[d-1] + r[e-1])

### FIXED CODE ###

from collections import deque
import sys
INF = 11414191981036436433-4

n = int(input())
g = [[] for i in range(n)]
for v in range(n-1):
    a,b,c = map(int,input().split())
    g[a-1].append((b-1,c))
    g[b-1].append((a-1,c))
    
q,k = map(int,input().split())
k -= 1

r = [INF]*n
que = deque([k])
r[k] = 0
while que:
    v = que.popleft()
    rr = r[v]
    for w,x in g[v]:
        if r[w] == INF:
            r[w] = rr + x
            que.append(w)
            
for i in range(q):
    d,e = map(int,input().split())
    print(r[d-1] + r[e-1])
n=int(input())
x=input()
x_pop=format(x,'b').count('1')
f=[0]*(x_pop+1)
for i in range(1,x_pop+1):
    popcount=format(i,'b').count('1')
    f[i]=f[i%popcount]+1
# print(f)
for i in range(len(x)):
  popcount=x_pop
    if x[i]=='1':
        x_changed=x[:i]+'0'+x[i+1:]
        popcount-=1
    else:
        x_changed=x[:i]+'1'+x[i+1:]
        popcount+=1
    num_changed=int(x_changed,2)
    # print(x_changed,num_changed)
    if num_changed<popcount:
        print(f[num_changed])
    else:
        print(f[num_changed%popcount]+1)


### FIXED CODE ###

## 最初のmodをどうにか高速にやりたい → modの性質を使う
## xiのpopcount（1の数）はxのpopcount+1または-1
n=int(input())
x_str=input()
x_popcount=x_str.count('1')
dp=[0]*(x_popcount+1)
for i in range(1,x_popcount+1):
    popcount=format(i,'b').count('1')
    dp[i]=dp[i%popcount]+1
# print(dp)
# x=int(x_str,2)
if x_popcount>1:
    pows_minus=[pow(2,i,(x_popcount-1)) for i in range(n)]
    # x_minus=x%(x_popcount-1)
    x_minus=0
    for i in range(n):
        if x_str[i]=='1':
            x_minus+=pows_minus[n-1-i]
pows_plus=[pow(2,i,(x_popcount+1)) for i in range(n)]
# x_plus=x%(x_popcount+1)
x_plus=0
for i in range(n):
    if x_str[i]=='1':
        x_plus+=pows_plus[n-1-i]

for i in range(len(x_str)):
    ## xi=xi mod popcount(x)+-1
    xi=-1
    if x_str[i]=='1':
        if x_popcount>1: ## else: xi=-1
            xi=(x_minus-pows_minus[n-1-i])%(x_popcount-1)
    else:
        xi=(x_plus+pows_plus[n-1-i])%(x_popcount+1)
    if xi==-1:
        print(0)
    else:
        print(dp[xi]+1)
S = list(map(str, input().split()))
A = list(map(int, input().split()))
U = int(input())

ind = S.index(U)

A[ind] -= 1

print("".join(A))


### FIXED CODE ###

S = list(map(str, input().split()))
A = list(map(int, input().split()))
U = input()

ind = S.index(U)

A[ind] -= 1

print(" ".join(list(map(str, A))))
N = int(input())

ans = sum([j * (N//j)*(N//j+1)/2 for j in range(N)])

print(ans)

### FIXED CODE ###

N = int(input())

ans = int(sum([j * (N//j)*(N//j+1)/2 for j in range(1,N+1)]))

print(ans)
n,m=map(int,input().split())
branch=[tuple(map(int,input().split())) for _ in range(m)]
cango=dict()
res=[0]
data=[0 for _ in range(1+n)]
def calc(k):
    return 1/2*k*(k-1)
def search(data,x):
    while data[x]>0:
        x=data[x]
    return x,data[x]
for i in range(m):
    a,b=branch.pop()
    aset={a,}
    bset={b,}
    aroot,aidx=search(data,a)
    broot,bidx=search(data,b)
    if aidx!=0:aset=cango[aidx]
    if bidx!=0:bset=cango[bidx]
    lena=len(aset)
    lenb=len(bset)
    if aidx==0 and bidx==0:
        data[a]=-1*a
        data[b]=a
        cango[-1*a]={a,b}
    elif aidx==bidx:
        res.append(res[-1])
        continue
    elif aidx==0 and bidx!=0:
        cango[bidx]|={a,}
        data[a]=bidx
    elif aidx!=0 and bidx==0:
        cango[aidx]|={b,}
        data[b]=aidx
    elif aidx!=0 and bidx!=0 and aidx!=bidx:
        cango.pop(aidx)
        cango.pop(bidx)
        cango[aidx]=aset|bset
        data[broot]=aroot
    res.append(res[-1]-calc(lena)-calc(lenb)+calc(lena+lenb))

for j in range(m-1,-1,-1):
    print(int(res[m]-res[j]))

### FIXED CODE ###

n,m=map(int,input().split())
branch=[tuple(map(int,input().split())) for _ in range(m)]
res=[0]
data=[-1 for _ in range(1+n)]
def calc(k):
    k=abs(k)
    return 1/2*k*(k-1)

def search(data,x):
    if data[x]<=0:
        return x
    else:
        data[x]=search(data,data[x])
    return data[x]

for i in range(m):
    a,b=branch.pop()
    aroot=search(data,a)
    broot=search(data,b)
    if aroot==broot:
        res.append(res[-1])
        continue
    res.append(res[-1]-calc(data[aroot])-calc(data[broot])+calc(data[aroot]+data[broot]))
    if data[aroot]<=data[broot]:
        data[aroot]+=data[broot]
        data[broot]=aroot
    elif data[aroot]>data[broot]:
        data[broot]+=data[aroot]
        data[aroot]=broot
for j in range(m-1,-1,-1):
    print(int(res[m]-res[j]))
n=int(input())
A=list(map(int,input().split()))

mod=10**9+7
ans=1
cs=[0]*3
for a in A:
  c=cs.count(a)
  ans=(ans*c)%mod
  i=cs.index(a)
  cs[i]+=1
print(ans)

### FIXED CODE ###

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

mod=10**9+7
ans=1
cs=[0]*3
for a in A:
  c=cs.count(a)
  if c==0:
    print(0)
    exit()
  ans=(ans*c)%mod
  i=cs.index(a)
  cs[i]+=1
print(ans)
s = input().split()
H = int(s[0])
N = int(s[1])

A = input().split()

if len(A) != N:
    print('error')
else:
    if sum(A) >= H:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

s = input().split()
H = int(s[0])
N = int(s[1])

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

if sum(A) >= H:
    print('Yes')
else:
    print('No')
x = input()

for i in range(200000):
    if x[i] = "T":
        t += 1
    if x[-i-1] = "S":
        s += 1
print(max(s, t))

### FIXED CODE ###

x = input()

st_sub = 0
count = 0
for char in x:

    if st_sub < 0 and char == "S":
        st_sub = 1
    elif char == "S":
        st_sub += 1
    else:
        st_sub -= 1
    
    if st_sub < 0:
        count += 1
    
print(count * 2)
# -*- Coding: utf-8 -*-
N, X = map(int, input().split())
L = list(map(int,input().split()))

index = 1
Sum = L[0]
while Sum <= X:
    Sum += L[index]
    index += 1

print(index) 



### FIXED CODE ###

N,X = map(int,input().split())
L = list(map(int,input().split()))

ans = 1 #位置0も1にカウントするから
p = 0 #今のポジション
for i in range(N):
    p += L[i]
    if p <= X:
         ans += 1
    else:
        break

print(ans)
HW =[list(map(int,input().split())) for i in range(2)]
print((HW[0][0]-HW[1][0])*(HW[0][1]-HW[1][1])

### FIXED CODE ###

HW =[list(map(int,input().split())) for i in range(2)]
print((HW[0][0]-HW[1][0])*(HW[0][1]-HW[1][1]))
A,B=map(int,input(),split())
if 1<=A<=9:
        if 1<=B<=9:
        print(A*B)
else print(-1)

### FIXED CODE ###

A,B=map(int,input().split())
if 1<=A<=9:
        if 1<=B<=9:
            print(A*B)
        else:
            print(-1)
else: print(-1)
N = int(input().split())
ans = 0
if N%2 == 0:
    ans = (N/2) ** 2
else:
    ans = (N/2) ** 2 - 1/4
print(ans)

### FIXED CODE ###

K=int(input())
print((K//2)*((K+1)//2))
import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
x = input()
z = '1' * n
o = '0' * n
X = int(x, 2)

if (n = 1 and x == '1'):
  print(0)
  exit()

if (z == x):
  u = n - 1
  d = n - 1
elif (o == x):
  u = 1
  d = 1
else:
  tmp = len(list(filter(lambda x: x == '1', x)))
  u = tmp + 1
  d = tmp - 1


def popcount(i):
  return i % len(list(filter(lambda x: x == '1', format(i, 'b'))))


def solve(i, count):
  if (i <= 2 * 10**5 and ans[i] != 0):
    return count + ans[i]
  elif (i == 0):
    return count
  else:
    return solve(popcount(i), count + 1)


def solve2(i, div):
  if (i <= 2 * 10**5):
    return ans[i]
  else:
    return ans[i % div] + 1


ans = [0] * (2 * 10 ** 5 + 4)
_u = (2 * 10 ** 5) // u
U = X % u + (u * _u) + u
if(d != 0):
  _d = (2 * 10 ** 5) // d
  D = X % d + (d * _d) * 2 + d * 2
Us = [0] * (2 * 10 ** 5)
Ds = [0] * (2 * 10 ** 5)
for i in range(1, 2 * 10 ** 5 + 4):
  ans[i] = solve(i, 0)
Us[0] = 1 % u
if(d != 0):
  Ds[0] = 1 % d
for i in range(1, 2 * 10 ** 5):
  Us[i] = (Us[i - 1] * 2) % u
  if(d != 0):
    Ds[i] = (Ds[i-1] * 2) % d

for i in range(n):
  if(x[i] == '0'):
    print(solve2(U + Us[n-i-1], u))
  else:
    if (d == 0):
      print(0)
    else:
      print(solve2(D - Ds[n-i-1], d))


### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)

n = int(input())
x = input()
z = '1' * n
o = '0' * n
X = int(x, 2)

if (n == 1 and x == '1'):
  print(0)
  exit()

if (z == x):
  u = n - 1
  d = n - 1
elif (o == x):
  u = 1
  d = 1
else:
  tmp = len(list(filter(lambda x: x == '1', x)))
  u = tmp + 1
  d = tmp - 1


def popcount(i):
  return i % len(list(filter(lambda x: x == '1', format(i, 'b'))))


def solve(i, count):
  if (i <= 2 * 10**5 and ans[i] != 0):
    return count + ans[i]
  elif (i == 0):
    return count
  else:
    return solve(popcount(i), count + 1)


def solve2(i, div):
  if (i <= 2 * 10**5):
    return ans[i]
  else:
    return ans[i % div] + 1


ans = [0] * (2 * 10 ** 5 + 4)
_u = (2 * 10 ** 5) // u
U = X % u + (u * _u) + u
if(d != 0):
  _d = (2 * 10 ** 5) // d
  D = X % d + (d * _d) * 2 + d * 2
Us = [0] * (2 * 10 ** 5)
Ds = [0] * (2 * 10 ** 5)
for i in range(1, 2 * 10 ** 5 + 4):
  ans[i] = solve(i, 0)
Us[0] = 1 % u
if(d != 0):
  Ds[0] = 1 % d
for i in range(1, 2 * 10 ** 5):
  Us[i] = (Us[i - 1] * 2) % u
  if(d != 0):
    Ds[i] = (Ds[i-1] * 2) % d

for i in range(n):
  if(x[i] == '0'):
    print(solve2(U + Us[n-i-1], u))
  else:
    if (d == 0):
      print(0)
    else:
      print(solve2(D - Ds[n-i-1], d))
a,b=map(int-2,input().split());print(abs(a*b))

### FIXED CODE ###

a,b=map(int,input().split());print(abs((a-2)*(b-2)))
N, K = map(int, input().split()))
if N%K==0:
    print(0)
else :
    print(N//K - N%K)

### FIXED CODE ###

N, K = map(int, input().split())
print(0 if N%K==0 else 1)
S = input()
s[3] = '8'
print(s)

### FIXED CODE ###

s = input()
s = s.replace('2017','2018')
print(s)
n = int(input())
a = [list(map(int,input().split()))]
ans = 0
for i in range(n):
  k = sum(a[0][i:])+sum(a[1][0:i+1])
  if k > ans:
    ans = k
print(ans)

### FIXED CODE ###

n = int(input())
a = [list(map(int,input().split())) for i in range(2)]
ans = 0
for i in range(n):
  k = sum(a[1][i:])+sum(a[0][0:i+1])
  if k > ans:
    ans = k
print(ans)