Harryxun/stf_run huggingface dataset:
def LI():return list(map(int,input().split()))
h,w,m=LI()
S=[[0]*w for i in range(h)]
a=[0]*(h+50)
b=[0]*(w+50)
for i in range(m):
    h,w=LI()
    S[h-1][w-1]=1
    a[h-1]+=1
    b[w-1]+=1

mx=max(a)
my=max(b)
ind_x=[i for i,j in enumerate(a) if j==mx]
ind_y=[i for i,j in enumerate(b) if j==my]

ans=0
for x in ind_x:
    for y in ind_y:
        if S[x][y]==0:
            tmp=mx+my
            print(tmp)
            exit()
        else:
            tmp=mx+my-1

        ans=max(ans,tmp)
        
print(ans)


### FIXED CODE ###

h,w,m=map(int,input().split())
a=[0]*h
b=[0]*w
hw=[]
for _ in range(m):
    hh,ww=map(int,input().split())
    hw+=((hh-1,ww-1)),
    a[hh-1]+=1
    b[ww-1]+=1
    
ma=max(a)
mb=max(b)

# x_ind=[i for i,j in enumerate(a) if j==ma]
# y_ind=[i for i,j in enumerate(b) if j==mb]



cnt=0
# sonzai suru

for i,j in hw:
    if a[i]==ma and b[j]==mb:cnt+=1

if cnt==a.count(ma)*b.count(mb):
    print(ma+mb-1)
else:
    print(ma+mb)
a, b = map(int,input().split())
A = list(str(a)*b,), B = list(str(b)*a)
C = max(len(A),len(B))
for i in range(C)
  if A[i] > B[i]:
  　　　　print(str(B))
         break
  elif B[i] > A[i]:
         print(str(A))
         break

### FIXED CODE ###

a,b = map(int,input().split())
C = min(a,b)
D = max(a,b)
print(str(C)*D)
r = input()
result = 3*r*r
print(result)

### FIXED CODE ###

r = int(input())
result = 3*r*r
print(result)
H, W = map(int, input().split())
S = ['.'+input()+'. ' for _ in range(H)]

S.insert(0, '.'*(W+2))
S.insert(H+1, '.'*(W+2))

flg = 0
for i in range(1, W+1):
    for j in range(1, H+1):
        if S[i][j]=='#':
            if S[i+1][j]=='.' and S[i-1][j]=='.' and S[i][j+1]=='.' and S[i][j-1]=='.':
                flg = 1
                break

if flg==0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

H, W = map(int, input().split())
S = ['.'+input()+'. ' for _ in range(H)]

S.insert(0, '.'*(W+2))
S.insert(H+1, '.'*(W+2))

flg = 0
for i in range(1, H+1):
    for j in range(1, W+1):
        if S[i][j]=='#':
            if S[i+1][j]=='.' and S[i-1][j]=='.' and S[i][j+1]=='.' and S[i][j-1]=='.':
                flg = 1
                break
    else:
        continue
    break
    
if flg==0:
    print('Yes')
else:
    print('No')
data = input()
a = int(data[0])
b = int(data[1])
print(a * b - a - b + 1)

### FIXED CODE ###

data = input().split()
a = int(data[0])
b = int(data[1])
print(a * b - a - b + 1)
n,d=map(int,input().split())
x=[list(map(int,input().split()))]
ans=0
for i in range(n):
  for j in range(i+1,n):
    tmp=0
    for k in range(d):
      tmp+=abs(x[i][d]-x[j][d])**2
    tmp=tmp**0.5
    if tmp==int(tmp):1
      ans+=1
print(ans)

### FIXED CODE ###

N, D = map(int, input().split())
X = [list(map(int,input().split())) for i in range(N)]
ans = 0
for i in range(N):
  for j in range(i+1,N):
    tmp = 0
    for k in range(D):
      tmp += abs(X[i][k]-X[j][k])**2
    tmp = tmp**0.5
    if tmp == int(tmp):
      ans += 1
print(ans)
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

r = []

if A%10 != 0:
    r.append(10 - A%10)
    A += 10 - A%10
if B%10 != 0:
    r.append(10 - B%10)
    B += 10 - B%10
if C%10 != 0:
    r.append(10 - C%10)
    C += 10 - C%10
if D%10 != 0:
    r.append(10 - D%10)
    D += 10 - D%10
if E%10 != 0:
    r.append(10 - E%10)
    E += 10 - E % 10

print(A+B+C+D+E-max(r))


### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())

r = []

if A%10 != 0:
    r.append(10 - A%10)
    A += 10 - A%10
if B%10 != 0:
    r.append(10 - B%10)
    B += 10 - B%10
if C%10 != 0:
    r.append(10 - C%10)
    C += 10 - C%10
if D%10 != 0:
    r.append(10 - D%10)
    D += 10 - D%10
if E%10 != 0:
    r.append(10 - E%10)
    E += 10 - E % 10

if r:
    print(A+B+C+D+E-max(r))
else:
    print(A+B+C+D+E)
from collections import Counter

i = int(input())

dic = {}
for j in range(i):
    word = input()
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1


dic2 = sorted(dic.items(), key=lambda x:x[1])

k = len(dic2)-1
s = 0
while True:
    t = dic2[k][1]
    print(dic2[k][0])
    k -= 1
    if t == dic2[k][1]:
        s = 1
    else:
        break

### FIXED CODE ###

i = int(input())

dic = {}
for j in range(i):
    word = input()
    if word in dic:
        dic[word] += 1
    else:
        dic[word] = 1


dic2 = sorted(dic.items(), key=lambda x:x[1])
k = len(dic2)-1
s = 0
ans = []
for p in range(len(dic2)):
    t = dic2[k][1]
    ans.append(dic2[k][0])
    k -= 1
    if t == dic2[k][1]:
        s = 1
    else:
        break
ans.sort()
for ak in ans:
    print(ak)
import itertools
N = int(input())

ans = [0]*(10**4)
for i1 in range(1, 100):
    i2 = i1+1
    i3 = i1+2
    L = list(itertools.combinations_with_replacement((i1, i2, i3), 3))
    for i in L:
        i = list(i)
        x = i[0]
        y = i[1]
        z = i[2]
        n = (x**2)+(y**2)+(z**2)+(x*y)+(y*z)+(z*x)
        if n > 10**4:
            break
        if len(list(set(i))) == 1:
            ans[n] += 1
        if len(list(set(i))) == 2:
            ans[n] += 3
        if len(list(set(i))) == 3:
            ans[n] += 6
        
for k in range(1, N+1):
    print(ans[k])

### FIXED CODE ###

n = int(input())
ans = [0 for _ in range(10050)]
for i in range(1,105):
    for j in range(1,105):
        for k in range(1,105):
            v = i*i+j*j+k*k+i*j+j*k+k*i
            if v<10050:
                ans[v]+=1
for i in range(n):
    print(ans[i+1])
n=int(input())
#s = input().split()
print(s)
r = 0
b = 0
for i in s:
    if i == "R":
        r += 1
    if i == "B":
        b += 1

if r <= b:
    print("No")
else:
    print("Yes")

### FIXED CODE ###

n=int(input())
s = input()
#print(s)
r = 0
b = 0
for i in s:
    if i == "R":
        r += 1
    if i == "B":
        b += 1

if r <= b:
    print("No")
else:
    print("Yes")
D, G = map(int, input().split())
P = []
C = []
for i in range(D):
  p, c = map(int, input().split())
  P.append(p)
  C.append(c)

ans = 1e9
for mask in range(2**D - 1):
  score = 0
  num = 0
  rest_max = -1

  for i in range(D):
    if (mask >> i) & 1:
      score += 100 * (i+1) * P[i] + C[i]
      num += P[i]
    else:
      rest_max = i

  #print('mask {}, score {}, num {}, rest_max {}'.format(format(mask, '010b'), score, num, rest_max))

  if score < G:
    scr1 = 100 * (rest_max + 1)
    need = (G - score + scr1 - 1) // scr1
    if need >= P[rest_max]:
      #print('fault')
      continue
    num += need
    #print('追加 {}, 合計 {}'.format(need, num))
  else:
    #print('合計 {}'.format(num))

  ans = min(ans, num)

print(ans)

### FIXED CODE ###

D, G = map(int, input().split())
P = []
C = []
for i in range(D):
  p, c = map(int, input().split())
  P.append(p)
  C.append(c)

ans = 1e9
for mask in range(2**D):
  score = 0
  num = 0
  rest_max = -1

  for i in range(D):
    if (mask >> i) & 1:
      score += 100 * (i+1) * P[i] + C[i]
      num += P[i]
    else:
      rest_max = i

  if score < G:
    scr1 = 100 * (rest_max + 1)
    need = (G - score + scr1 - 1) // scr1
    if need >= P[rest_max]:
      continue
    num += need

  ans = min(ans, num)

print(ans)
l = input().split()
d = min(l)
e = max(l)
f = l.remove(max(l), min(l))

print(str(d) + " " + f + " " + e)

### FIXED CODE ###

l = list(map(int, input().split()))
l.sort()
for i in range(len(l)):
    if i == len(l)-1:
        print(l[i])
    else:
        print(l[i], end = " ")
def gcd(a,b):
    while (b!= 0):
        a,b=b,a%b
    return a

l = raw_input().split()

a = int(l[0])
b = int(l[1])
c = int(l[2])
d = int(l[3])

lcm = ((c*d)//(gcd(c,d)))

div = []

div.append((a-1)/c)
div.append((a-1)/d)

div.append(b/c)
div.append(b/d)

div.append(a/lcm)
div.append(b/lcm)

ans =  (div[2]-div[0])+(div[3]-div[1])-(div[5]-div[4])
ans = (b-a+1) - ans

print ans


### FIXED CODE ###

S = raw_input()
flag = True
for i in range(3):
    if (S[i+1] == S[i]):
        flag = False
        break

if flag == True:
    print ("Good")
else:
    print("Bad")
import math

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

ans = []
for i in range(10000):
    a_shouhizei = math.floor(i * 8/100)
    b_shouhizei = math.floor(i * 10/100)
    if a_shouhizei == a and b_shouhizei == b:
        ans.append(i)
print(min(ans))

### FIXED CODE ###

import math

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

ans = []
for i in range(10000):
    a_shouhizei = math.floor(i * 8/100)
    b_shouhizei = math.floor(i * 10/100)
    if a_shouhizei == a and b_shouhizei == b:
        ans.append(i)
if ans == []:
    print('-1')
else:
    print(min(ans))
a, b = map(int, input().split())
c = int(b - a)
d =int( c * (c - 1) // 2 + c  -b)
print(d)


### FIXED CODE ###

N = int(input())
if N < 1000:
    print('ABC')
else:
    print('ABD' )
import math
def lcm(x, y):
    return int((x * y)/math.gcd(x, y))
a, b = map(int, input().split())
print(lcm(a,b))


### FIXED CODE ###

import math
def gcd(m, n):
    x = max(m,n)
    y = min(m,n)
    if x%y == 0:
        return y
    else:
        while x%y != 0:
            z = x%y
            x = y
            y = z
        else:
            return z
def lcm(m, n):
    return int(m*n/gcd(m,n))
a, b = map(int, input().split())
print(lcm(a,b))
A=int(input())
B=int(input())
print((A-1)*(B-1))

### FIXED CODE ###

A,B=map(int,input().split())
print((A-1)*(B-1))
in_rating = 0
N = int(input())
R = int(input())

if N >= 10:
  in_rating = R
  print(in_rating)
else:
  in_rating = R + 100 * (100-N)
  print(in_rating)


### FIXED CODE ###

n,r=map(int,input().split())

if n >= 10:
  print(r)
else:
	in_rate = r + 100 * (10-n)
	print(in_rate)
a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in[0]*b]
print(({i[1]for i in c if c[0]==1}&{i[0]for i in c if c[1]==a}=={})*'IM'+'POSSIBLE')

### FIXED CODE ###

a,b=map(int,input().split())
c=[list(map(int,input().split()))for i in[0]*b]
d=[]
e=[]
for i in c:
  if i[0]==1:d+=[i[1]]
  elif i[1]==a:e+=[i[0]]
print((set(d)&set(e)==set())*'IM'+'POSSIBLE')
def sieve(n):
	p=[True]*(n+1)
	p[0]=p[1]=False
	for i in range(2,n+1,2):
		if p[i]==True:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p

def solve(n):
		if n<2:return 0
		c=1
		for i in range(3,n+1,2):
			if p[i]==1:
				c+=1
		return c

p=sieve(100000)
while True:
	try:
		n = int(input())
		print(solve(n))
	except EOFError:
		break

### FIXED CODE ###

def sieve(n):
	p=[True for i in range(n+1)]
	p[0]=p[1]=False
	for i in range(2,n+1):
		if p[i]==True:
			for j in range(i*i,n+1,i):
				p[j]=False
	return p

def solve(n):
		if n<2:return 0
		c=1
		for i in range(3,n+1,2):
			if p[i]==1:
				c+=1
		return c

p=sieve(1000000)
while True:
	try:
		n = int(input())
		print(solve(n))
	except EOFError:
		break
from numba import njit

@njit
def solve():
    n, k = map(int,input().split())
    l = list(map(int,input().split()))
    
    if k >= 50:
        k = 50
    
    dp= [[0,0]]
    for i in range(n-1):
        dp += [[0]*2]
    
    ans = l[:]
    
    for i in range(k):
        for j in range(n):
            tmp = ans[j]
            dp[j][0] = (j+1 - tmp)
            dp[j][1] = (j+1 + tmp)
    
        ans = [0] * n
    
        for x in range(n):
            for y in range(n):
                if dp[y][0] <= x+1 <= dp[y][1]:
                    ans[x] += 1
    
    else:
        return ans

print(*solve())

### FIXED CODE ###

import numpy as np
from numba import njit

@njit #処理の並列化

def imos(n, a):
    
    l=np.zeros((n+1), dtype = np.int64)

    for i in range(n):
        ai = a[i] # 光の強さ_これにより照らせる範囲が決まる
        start = max(0, i - ai) #StartIndex_照らせる範囲
        end = min(n, i + ai + 1) #EndIndex + 1_照らせる範囲
        l[start] += 1 # 各々を'+1'と'-1'で表し...
        l[end] -= 1
    return np.cumsum(l)[:n] # 累積和をとる_cumulative sum

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

for _ in range(k):
    a = imos(n, a)
    if a.min() == n: # すべての要素が最大値'n'になるとbreak
        break

print(*a)
K = int(input())

from itertools import product
d = {}
num_list = []
for i in range(10):
    nums = set([min((i-1)%10, i), i, max((i+1)%10, i)])
#     nums = set([i, min(10-(i-1)%10, i),max((i+1)%10, i)])
    nums = [str(el) for el in nums]
    d[i] = list(product([str(i)], list(nums)))
    d[i] = [int(''.join(el)) for el in d[i]]
    d[i] = ['{:02}'.format(el) for el in d[i]]
    
    num_list.extend(d[i])
num_list = sorted(num_list)
dd = [None, None, d, 
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(1,10)},
      {i:[] for i in range(10)}]

def gen_2ll():
    count = 0
    ret = 0
    while int(ret)!=99:
        if int(ret)< 9 :
            ret += 1
            count += 1
            yield ret
        else:
            for i in range(1,10):
                for ret in d[i]:
                    count += 1
                    yield ret

ll2_list = list(gen_2ll())
                   
def get_digit_top_list(num_digit, top_num):
    ret = dd[num_digit][top_num]
    if ret:
        return ret

    second_nums = sorted(set([min((top_num-1)%10, top_num), top_num, max((top_num+1)%10, top_num)]))    
    for second_num in second_nums:
        rem_nums = get_digit_top_list(num_digit-1, int(second_num))
        for rem_num in rem_nums:
            ll = str(top_num) + rem_num
            ret.append(ll)
    dd[num_digit][top_num] = ret

    
    return ret

def get_ll(K):

def get_kth_ll(K):
    if K<=len(ll2_list):
        print(ll2_list[K-1])
    else:
        K -= len(ll2_list)
        for num_digit in range(3,100):
            for top_num in range(1,10):
                _ll_list = get_digit_top_list(num_digit, top_num)
                if K-len(_ll_list)<0:
                    print(sorted([int(el) for el in _ll_list])[K])
                else:
                    K -= len(_ll_list)
get_kth_ll(K)
                

### FIXED CODE ###

from collections import deque

k = int(input())
count = 0
q = deque(range(1,10))

while count < k:
    l = q.popleft()
    resid = l % 10
    if resid != 0: q.append(l*10 + resid - 1)

    q.append(l*10 + resid)
    
    if resid != 9: q.append(l*10 + resid + 1)
    
    count += 1

print(l)
import sys

if __name__ == "__main__":
  args = sys.argv
  print(args)
```
  num = args[0]
  slimes = args[1]

  tmp = []
  for i in range(0,len(smiles)):
    if len(tmp): 
      if slimes[i] == slimes[i+1] and slimes[i] != tmp[-1]:
          tmp.append(slimes[i])
    else:
      if slimes[i] == slimes[i+1]:
          tmp.append(slimes[i])

  print(len(tmp))    
```


### FIXED CODE ###

if __name__ == "__main__":
  num = input()
  slimes = input()

  tmp = []
  for i in range(0,len(slimes)):
    if len(tmp):
      if slimes[i] != tmp[-1]:
          tmp.append(slimes[i])
    else:
      tmp.append(slimes[i])
  print(len(tmp))
A,B = map(int,input().split())

if A + B % == 0 and A + B != 0:
	print("Possible")
else:
	print("Impossible")

### FIXED CODE ###

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

if A % 3 == 0 or B % 3 == 0 or (A + B) % 3 ==0:
	print("Possible")
else:
	print("Impossible")
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

list_inp = [a,b,c,d,e]
min_last = 100
for index, inp in enumerate(list_inp):
  tmp = int(str(inp)[-1])
  if tmp == 0:
    continue
  
  if tmp <= min_last:
    min_last = tmp
    min_last_index = index

# 全部の料理がちょうど１０分単位だった場合
if min_last == 100:
  min_last = 0

# 切り上げ
def ceil(src,range):
  if str(src)[-1] == '0':
    return src
  else:
    return ((int)(src / range) + 1 ) * range

ans = 0
for index,value in enumerate(list_inp):
  if index == min_last_index:
    continue
  else:
    ans += ceil(value, 10)


print(ans + list_inp[min_last_index])

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

list_inp = [a,b,c,d,e]
min_last = 100
for index, inp in enumerate(list_inp):
  tmp = int(str(inp)[-1])
  if tmp == 0:
    continue
  
  if tmp <= min_last:
    min_last = tmp
    min_last_index = index

# 全部の料理がちょうど１０分単位だった場合
if min_last == 100:
  min_last_index = 0

# 切り上げ
def ceil(src,range):
  if str(src)[-1] == '0':
    return src
  else:
    return ((int)(src / range) + 1 ) * range

ans = 0
for index,value in enumerate(list_inp):
  if index == min_last_index:
    continue
  else:
    ans += ceil(value, 10)


print(ans + list_inp[min_last_index])
A = list(input())
B = list(input())
C = list(input())
s = A.pop(0)
while True:
    if A == [] and s == 'a':
        print('A')
        exit()
    if B == [] and s == 'b':
        print('B')
        exit()
    if C == [] and s == 'c':
        print('C')
        exit()
    
    if s == 'a':
        s = A.pop(0)
    if s == 'b':
        s = B.pop(0)
    if s == 'c':
        s = C.pop(0)

### FIXED CODE ###

A = list(input())
B = list(input())
C = list(input())
s = A.pop(0)
while True:
    if A == [] and s == 'a':
        print('A')
        exit()
    elif B == [] and s == 'b':
        print('B')
        exit()
    elif C == [] and s == 'c':
        print('C')
        exit()
    if s == 'a':
        s = A.pop(0)
    elif s == 'b':
        s = B.pop(0)
    elif s == 'c':
        s = C.pop(0)
a,b=input()


### FIXED CODE ###

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

def main():
    n, k = map(int, input().split())
    ans = [0 for i in range(n+1)]
    for x in sys.stdin.readlines():
        a, b = map(int, x.split())
        ans[a] += b

    cnt = 0
    for i in range(n+1):
        cnt += ans[i]
        if cnt >= k:
            print(ans[i])

if __name__ == "__main__":
    main()

### FIXED CODE ###

# https://atcoder.jp/contests/abc061/tasks/abc061_c
import sys

def main():
    n, k = map(int, input().split())
    ans = [0 for _ in range(10**5+1)]
    for x in sys.stdin.readlines():
        a, b = map(int, x.split())
        ans[a] += b

    cnt = 0
    for i in range(10**5+1):
        cnt += ans[i]
        if cnt >= k:
            print(i)
            exit()

if __name__ == "__main__":
    main()
n=int(input())
a=[int(input()) for _ in range(n)]
aa=sorted(a[:])
for i in range(n):
  k=a[i]
  t=-1
  while True:
    if aa[t] != k:
      print(aa[t])
      break
    else: t -= 1

### FIXED CODE ###

n=int(input())
a=[int(input()) for _ in range(n)]
aa=sorted(list(set(a[:])),reverse=True)
maxa=aa[0]
f=False if a.count(maxa) != 1 else True
for i in range(n):
    if a[i] == maxa and f:
        print(aa[1] if len(aa) != 1 else maxa)
    else:
        print(maxa)
import sys
#input=sys.stdin.readline
sys.setrecursionlimit(3000)


#L=-1  R=1
n,k=map(int,input().split())
s=input()
#print(s)
t=s[0]
c=[-1,1][s[0]=="R"]
d=[0]

for i in range(1,n):
    if t!=s[i]:
        d.append(c)
        c=0
    t=s[i]
    c+=[-1,1][s[i]=="R"]
d.append(c)
c=len(d)

#print(c,d)
if c>2:
    for i in range(1,k+1):
        d[i*2]*=-1
#print(d)
"""
p=[-1,-1]
for i in range(1,c-1):
    tmp=(abs(d[i-1])+abs(d[i])+abs(d[i+1]))
    if tmp>p[0]:
        p[0]=tmp
        p[1]=i
i=p[1]
for j in range(k):
    if i+j*2>=c: break
    d[i+j*2]*=-1
"""
chk=0
ans=0
for i in d:
    if (i>0 and chk>0) or (i<0 and chk<0):
        chk+=i
    else:
        if chk!=0: ans+=abs(chk)-1
        chk=i

print(ans+(abs(chk)-1))

### FIXED CODE ###

n,k=map(int,input().split())
s=input()
#print(s)
t=s[0]
c=[-1,1][s[0]=="R"]
d=[0]

for i in range(1,n):
    if t!=s[i]:
        d.append(c)
        c=0
    t=s[i]
    c+=[-1,1][s[i]=="R"]
d.append(c)
c=len(d)

#print(c,d)
if c>2:
    for i in range(1,k+1):
        if i*2>=c: break
        d[i*2]*=-1
#print(d)
"""
p=[-1,-1]
for i in range(1,c-1):
    tmp=(abs(d[i-1])+abs(d[i])+abs(d[i+1]))
    if tmp>p[0]:
        p[0]=tmp
        p[1]=i
i=p[1]
for j in range(k):
    if i+j*2>=c: break
    d[i+j*2]*=-1
"""
chk=0
ans=0
for i in d:
    if (i>0 and chk>0) or (i<0 and chk<0):
        chk+=i
    else:
        if chk!=0: ans+=abs(chk)-1
        chk=i

print(ans+(abs(chk)-1))
count=0
n=int(input())
while n%2=!1:
  n=n/2
  count+=1
  

### FIXED CODE ###

n=int(input())
i=1
if n==1:
  print(1)
else:
  while n>=2**i:
  	i+=1
  print(2**(i-1))
a,b=map(int, input().split())

if a==1:
  k=14
else:
  k=a
if b==1:
  m=14
else:
  m=b
  
if k>m:
  print("Alice")
elif k==m:
  print("Draw")
else k<m:
  print("Bob")

### FIXED CODE ###

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

if a==1:
  k=14
else:
  k=a
if b==1:
  m=14
else:
  m=b
  
if k>m:
  print("Alice")
elif k==m:
  print("Draw")
else:
  print("Bob")
N = int(input())
s = [int(input()) for i in range(N)]
temp=s.copy()
s_max=max(temp)
temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
	print(s_max2)


### FIXED CODE ###

N=int(input())
s=[int(input()) for i in range(N)]

temp=s.copy()
s_max=max(temp)
temp.remove(s_max)
s_max2=max(temp)

for i in range(N):
  if s[i]<s_max:
    print(s_max)
  else:
    print(s_max2)
# B Trick or Treat

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

sunuke = [0] * N
for i in k:
  d = int(input())
  a = list(map(int, input().split()))
  for ai in a:
    sunuke[ai-1] += 1
print(sunuke.count(0))
  
  

### FIXED CODE ###

# B Trick or Treat

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

sunuke = [0] * N
for i in range(K):
  d = int(input())
  a = list(map(int, input().split()))
  for ai in a:
    sunuke[ai-1] += 1
print(sunuke.count(0))
def pickup(S,ans):
    l = len(S)
    if l<2:
        return ans
    check_dif = False
    #print(S)
    for i in range(l-1):
        if i+1
        if S[i] != S[i+1]:
            S.pop(i)
            S.pop(i)
            #print(S)
            check_dif = True
            ans += pickup(S,ans)
            break
    if not check_dif:
        return ans
    else:
        return ans+2
    
S=input()
l = len(S)
S_list = [S[i] for i in range(l)]
ans =0
print(pickup(S_list,ans))

### FIXED CODE ###

S=input()
num_one=S.count('1')
num_zero=S.count('0')
ans = 2*min(num_one,num_zero)
print(ans)
import numpy as np

N=int(input())
a=int(np.sqrt(N))
b=float('inf')
for i in range(1,a+1):
    if N%i==0:
        if i+N//i<b:
            ans=i

print(ans+N//ans-2)


### FIXED CODE ###

import numpy as np

N=int(input())
a=int(np.sqrt(N))
b=float('inf')
for i in range(1,a+1):
    if N%i==0:
        if i+N//i<b:
            ans=i

print(ans+N//ans-2)
from collections import Counter

N = int(input())
Y = input()
X = int(Y,2)
cnt = bin(X).count('1')
for i in range(1,N+1):
  t = 0
  a = X ^ (1<<(N-i))
  if Y[i-1] == '1':
    b = cnt - 1
  else:
    b = cnt + 1
  a %= b
  t += 1
  while a > 0:
    b = bin(a).count('1')
    a %= b
    t += 1
  print(t)

### FIXED CODE ###

from collections import Counter

N = int(input())
X = input()
cnt = X.count('1')
memo = [0]*(N+1)
memo2 = [[0]*(N+1) for _ in range(2)]
memo2[0][1] = memo2[1][1] = 1

if cnt == 0:
  for _ in range(N):
    print(1)
  exit()

for i in range(1,N+1):
  if i == 1:
    if cnt > 1:
      memo2[0][i] = 1 % (cnt-1)
    memo2[1][i] = 1 % (cnt+1)
  else:
    if cnt > 1:
      memo2[0][i] = memo2[0][i-1]*2 % (cnt-1)
    memo2[1][i] = memo2[1][i-1]*2 % (cnt+1)
  t = 0
  a = i
  while a > 0:
    b = bin(a).count('1')
    a %= b
    t += 1
  memo[i] = t
  
X1 = 0
X_1 = 0
for i in range(1,N+1):
  if X[N-i] == '1':
    X1 += memo2[1][i]
    X_1 += memo2[0][i]
    X1 %= cnt+1
    if cnt > 1:
      X_1 %= cnt-1
    
for i in range(N,0,-1):
  Y = 0
  if X[N-i] == '1':
    if cnt == 1:
      print(0)
      continue
    Y = X_1 - memo2[0][i]
    if Y < 0:
      Y += cnt - 1
    print(memo[Y]+1)
  else:
    Y = X1 + memo2[1][i]
    Y %= cnt + 1
    print(memo[Y]+1)