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

import heapq


def max_heapify(a, i):
    h = len(a)
    l = 2 * i + 1
    r = 2 * i + 2
    if l < h and a[l] > a[i]:
        largest = l
    else:
        largest = i
    if r < h and a[r] > a[largest]:
        largest = r

    if largest != i:
        tmp = a[i]
        a[i] = a[largest]
        a[largest] = tmp
        max_heapify(a, largest)


def build_max_heap(a):
    h = len(a)
    for i in range(h // 2 - 1, -1, -1):
        max_heapify(a, i)


heap = []
while True:
    s = input().split()
    if s[0] == "end":
        break
    elif s[0] == "extract":
        # build_max_heap(heap)
        # print(heap[0])
        # heap = heap[1:]
        # build_max_heap(heap)
        heapq.heapify(heap)
        print(heapq.heappop(heap)[1])
    elif s[0] == "insert":
        heapq.heappush(heap, (-int(s[1]), int(s[1])))


### FIXED CODE ###

import sys


def extract_max(A):
    x = A[0]
    A[0] = A[-1]
    A.pop()
    H = len(A)
    i = 0
    while i < H:
        v = A[i]
        rv = 0
        lv = 0
        r = (i + 1) * 2
        l = r - 1
        if l < H:
            lv = A[l]
            if r < H:
                rv = A[r]

        if v < lv and lv > rv:
            A[l] = v
            A[i] = lv
            i = l
        elif v < rv:
            A[r] = v
            A[i] = rv
            i = r
        else:
            break
    return x


def insert(a, n):
    i = len(a)
    a.append(n)
    while i > 0:
        p = int((i + 1) / 2) - 1
        v = a[i]
        pv = a[p]
        if pv < v:
            a[p] = v
            a[i] = pv
            i = p
        else:
            break


def main():
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    S = []
    for cmd in cmds:  # input()
        if cmd[0] == "i":
            insert(S, int(cmd[7:]))

        elif cmd == "extract":
            a = extract_max(S)
            print(a)

        elif cmd == "end":
            break


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

h,w,m = map(int,input().split())
hw = [list(map(int,input().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
kaburi = True
for x in ans_x:
    if kaburi == False:
        break
    for y in ans_y:
        if [x,y] not in hw:
            kaburi = False
            break
print(ans - int(kaburi))

### FIXED CODE ###

import sys
input = sys.stdin.readline
h,w,m = map(int,input().rstrip().split())
hw = [list(map(int,input().rstrip().split()))for _ in range(m)]

tate = [0]*(h+1)
yoko = [0]*(w+1)
bombpoint = set()

for x,y in hw:
    tate[x] += 1
    yoko[y] += 1
    bombpoint.add((x,y))

ans_x = []
ans_y = []
x_max = max(tate)
y_max = max(yoko)
for i in range(len(tate)):
    if tate[i] == x_max:
        ans_x.append(i)
for i in range(len(yoko)):
    if yoko[i] == y_max:
        ans_y.append(i)

ans = x_max + y_max
for x in ans_x:
    for y in ans_y:
        if (x,y) not in bombpoint:
            print(ans)
            exit()
print(ans - 1)
### BUGGY CODE ###

def solve():

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

    m = max(a) 
   # print("max:" + str(m))

    ans = 0
    lists = [0, 0, 0]

    for i in range(N):
        X = a[i]
        tmp = 0
        for k in range(N):
            x = a[k] + 1
            y = a[k] - 1
            z = a[k]
            if X == x or X == y or X == z:
                tmp += 1
        if tmp >= ans:
            ans = tmp
            lists[0] = ans

    ans = 0        

    for i in range(N):
        X = a[i] + 1
        tmp = 0
        for k in range(N):
            x = a[k] + 1
            y = a[k] - 1
            z = a[k]
            if X == x or X == y or X == z:
                tmp += 1
        if tmp >= ans:
            ans = tmp
            lists[1] = ans
    
    ans = 0
            
    for i in range(N):
        X = a[i] - 1
        tmp = 0
        for k in range(N):
            x = a[k] + 1
            y = a[k] - 1
            z = a[k]
            if X == x or X == y or X == z:
                tmp += 1
        if tmp >= ans:
            ans = tmp
            lists[2] = ans

    print(max(lists))


if __name__ == "__main__":
    solve()

                




### FIXED CODE ###

def solve():
    
    N = int(input())
    a  = list(map(int, input().split()))

    lists = [0] * ((10**5)+2)

    for i in a:
        lists[i] += 1
        lists[i+1] += 1
        lists[i-1] += 1

    print(max(lists))    

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

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()　#小さい順位欲しいとき
    return divisors

n=int(input())
a=sorted(list(map(int,input().split())))
dic={}
for k in a:
    if k in dic:
        dic[k]=0
        continue
    f=1
    x=make_divisors(k)
    for i in x:
        if i in dic:
            f=0
            break
    if f:
        dic[k]=1
print(sum(dic.values()))

### FIXED CODE ###

M=10**6+10
c=[0]*M
n=int(input())
a=sorted(list(map(int,input().split())))
for k in a:
    if c[k]:
        c[k]=2
        continue
    for i in range(k,M,k):
        c[i]+=1
ans=0
for i in a:
    if c[i]==1:
        ans+=1
print(ans)
### BUGGY CODE ###


md=10**9+7
t=1
# t=int(input())

for some_num in range(0,t):
    n=int(input())
    vals=[int(i) for i in input().split(" ")]

    sum=0

    for i in range(0,n):
        for j in range(0,i):
            sum=(sum + vals[i]*vals[j])%md

print(sum)



### FIXED CODE ###


md=10**9+7
t=1
# t=int(input())

for some_num in range(0,t):
    n=int(input())
    vals=[int(i) for i in input().split(" ")]

    s=0
    for i in range(0,n):
        s=(s+vals[i])%md

    csum=0

    for i in range(0,n-1):
        s-=vals[i]

        csum= (csum+vals[i]*s)%md

    print(csum)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
color_painted = [1]
color_used = 1
a_mins = {1 : a[-1], }
for i in range(n-2,-1,-1):
    if a_mins[color_used] <= a[i]:
        color_used = 0
        while color_used < len(color_painted):
            color_used += 1
            if a[i] < a_mins[color_used]:
                a_mins[color_used] = a[i]
                break
        else:
            color_used += 1
            a_mins[color_used] = a[i]
            color_painted.append(color_used)
    elif a[i] < a_mins[color_used]:
        a_mins[color_used] = a[i]

print(len(color_painted))

### FIXED CODE ###

from bisect import *
n = int(input())
a = [int(input()) for i in range(n)]

color = [-a[0]]
for i in range(1,n):
    if -a[i] >= color[-1]:
        color.append(-a[i])
    else:
        idx = bisect_right(color,-a[i])
        color[idx] = -a[i]

print(len(color))
### BUGGY CODE ###

def main():
    N = int(input())
    A = list(map(int, input().split()))

    B = [(A[i], i) for i in range(N)]
    B.sort(key = lambda x: x[0], reverse = True)

    DP = [[0] * (N + 1) for _ in range(N + 1)]

    for i in range(N):
        a = B[i][0]
        tmp = B[i][1]
        for x in range(i + 1):
            DP[x + 1][i - x] = max(DP[x + 1][i - x], DP[x][i - x] + a * abs(tmp - x))
            DP[x][i - x + 1] = max(DP[x][i - x + 1], DP[x][i - x] + a * abs((N - tmp - 1) - (i - x)))

    ans = 0
    for i in range(N + 1):
        ans = max(ans, DP[i][N - i])

    print (ans)

    # for tmp in DP:
    #     print (tmp)

if __name__ == '__main__':
    main()

### FIXED CODE ###

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

B = [(A[i], i) for i in range(N)]
B.sort(key = lambda x: x[0], reverse = True)

DP = [[0] * (N + 1) for _ in range(N + 1)]

for i in range(N):
    a = B[i][0]
    tmp = B[i][1]
    for x in range(i + 1):
        DP[x + 1][i - x] = max(DP[x + 1][i - x], DP[x][i - x] + a * abs(tmp - x))
        DP[x][i - x + 1] = max(DP[x][i - x + 1], DP[x][i - x] + a * abs((N - tmp - 1) - (i - x)))

ans = 0
for i in range(N + 1):
    ans = max(ans, DP[i][N - i])

print (ans)

# for tmp in DP:
#     print (tmp)
### BUGGY CODE ###

import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
#from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

import heapq
def dijkstra(start, end):
	dist = defaultdict(lambda: float('inf'))
	dist[start] = 0
	heap = []
	heapq.heappush(heap, (0, start))
	while heap:
		d, n = heapq.heappop(heap)
		if n == end:
			return d
		if dist[n] != d:
			continue
		edges = get_edges(n)
		for nn, ed in edges:
			nd = d + ed
			if dist[nn] > nd:
				dist[nn] = nd
				heapq.heappush(heap, (nd, nn))
	return -1

def get_edges(n):
	i, j = n
	edges = []
	if M[i][j] == '#': return edges
	for di, dj in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
		ni, nj = i+di, j+dj
		if not (0 <= ni < H and 0 <= nj < W): continue
		if M[ni][nj] == '#': continue
		edges.append(((ni, nj), 0))
	for di in range(-2, +3):
		for dj in range(-2, +3):
			ni, nj = i+di, j+dj
			if di == 0 and dj == 0: continue
			if (di, dj) in [(1, 0), (-1, 0), (0, 1), (0, -1)]:
				continue
			if not(0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			edges.append(((ni, nj), 1))
	return edges

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])
d = dijkstra(start, end)
print(d)


### FIXED CODE ###

import sys, math
from collections import defaultdict, deque, Counter
#from bisect import bisect_left, bisect_right
#from itertools import combinations, permutations, product
from heapq import heappush, heappop
#from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

dist = defaultdict(lambda: float('inf'))
def dijkstra(start, end):
	dist[start] = 0
	heap = []
	heappush(heap, (0, start))
	while heap:
		d, n = heappop(heap)
		if n == end:
			return d
		if dist[n] != d:
			continue
		edges = get_edges(n)
		for nn, ed in edges:
			nd = d + ed
			if dist[nn] > nd:
				dist[nn] = nd
				heappush(heap, (nd, nn))
	return -1

def get_edges(n):
	i, j = n
	edges = []
	if M[i][j] == '#': return edges
	for di in range(-2, +3):
		for dj in range(-2, +3):
			ni, nj = i+di, j+dj
			if di == 0 and dj == 0: continue
			if not(0 <= ni < H and 0 <= nj < W): continue
			if M[ni][nj] == '#': continue
			if (di, dj) in [(1,0),(-1,0),(0,1),(0,-1)]:
				edges.append(((ni, nj), 0))
			else:
				edges.append(((ni, nj), 1))
	return edges

H, W = rl()
C = rl()
D = rl()
M = []
for i in range(H):
	s = rs()
	M.append(s)

start = tuple([C[0]-1, C[1]-1])
end = tuple([D[0]-1, D[1]-1])
d = dijkstra(start, end)
print(d)
### BUGGY CODE ###

import numpy as np
from numpy.linalg import solve

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

l=[[0]*n for _ in range(n)]
k=0
for i in range(n-1):
    l[i][k]=1
    l[i][k+1]=1
    k+=1
l[n-1][0]=1
l[n-1][n-1]=1
p=[[0] for _ in range(n)]
for i in range(n):
    p[i]=a[i]*2
for i in solve(l,p):
  print(int(i), end=" ")

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
l=[0]*n
s=0
for i in range((n-1)//2):
    s+=a[2*i+1]
l[0]=sum(a)-2*s
for i in range(n-1):
    l[i+1]=2*a[i]-l[i]
for i in l:
    print(int(i), end=" ")
### BUGGY CODE ###

n = int(input())


import math
from functools import reduce
def gcd(numbers):
  return reduce (math.gcd, numbers)


ans = 0
a = list(map(int, input().split()))
for i in range(n):
  c = a[i]
  a.remove(c)
  ans = max(ans, gcd(a))
  a.insert(i, c)
#print(a)
  

print(ans)

### FIXED CODE ###

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

import math
l_gcd = []
r_gcd = []

c = a[0]
for i in a[:-1]:
  c = math.gcd(c, i)
  l_gcd.append(c)
  
c = a[-1]
for j in a[1:][::-1]:
  c = math.gcd(c, j)
  r_gcd.append(c)
  
ans = max(r_gcd[-1], l_gcd[-1])
for r, l in zip(r_gcd[:-1], l_gcd[:-1][::-1]):
  c = math.gcd(r, l)
  ans = max(ans, c)
print(ans)
### BUGGY CODE ###

import sys
import math
import heapq
push = heapq.heappush
pop = heapq.heappop
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0

n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))

hp = []
for i in lst1:
    push(hp,(-i,i,1))

for i in range(k):
    res = pop(hp)
    res2 = [0]*3
    res2[0] = -res[1]/(res[2]+1)
    res2[1] = res[1]
    res2[2] = res[2]+1
    push(hp,tuple(res2))

print(math.ceil(-pop(hp)[0]))

### FIXED CODE ###

#揃える長さを決め打って二分探索
import sys
import math
readline = sys.stdin.buffer.readline
def even(n): return 1 if n%2==0 else 0
n,k = map(int,readline().split())
lst1 = list(map(int,readline().split()))
lst1.sort(reverse=True)
def func(mid): #ここが関数部分
    res = 0
    for i in range(n):
        if mid >= lst1[i]:
            continue
        res += math.ceil(lst1[i]/mid)-1
        if res > k:
            return False
    return True


def binary_search(): #2分探索
    ok = 10**9
    ng = 0
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if func(mid):
            ok = mid
        else:
            ng = mid

    return ok

print(binary_search())
### BUGGY CODE ###

import math

S = input()
l = len(S)
S = S[::-1]
dp =[[0 for _ in range(13) ] for _ in range(l + 1)]
amari = dict(zip( list(range(0,13)),[0] *13 ))
kurai = 1
MOD = (10 ** 9) + 7
dp[0][0] = 1

for keta,c in  enumerate(S):

    if c == "?":
        for j in range(0,10):
            temp = (j * kurai) % 13
            for i in range(13):
                dp[keta + 1][(temp + i) % 13] += dp[keta][i]
                dp[keta + 1][(temp + i) % 13] %= MOD
    else:
        temp = (int(c) * kurai) % 13
        for i in range(13):
            dp[keta + 1][(temp + i) % 13]  += dp[keta][i]
            dp[keta + 1][(temp + i) % 13] %= MOD
    kurai *= 10
    keta %= MOD
print(dp[-1][5] % MOD)

### FIXED CODE ###


import sys

S =  sys.stdin.readline()[:-1]
l = len(S)
# S = S[::-1]
S = list(reversed(S))

dp =[[0 ] * 13 for _ in range(l + 1)]
kurai = 1
MOD = (10 ** 9) + 7
dp[0][0] = 1

for keta in range(len(S)):
    c =S[keta]

    if c == "?":
        for j in range(0,10):
            kurai %= 13
            temp = (j * kurai) % 13
            for i in range(13):
                dp[keta + 1][(temp + i) % 13] += (dp[keta][i] )
                dp[keta + 1][(temp + i) % 13] %= MOD
    else:
        kurai %= 13

        temp = (int(c) * kurai) % 13
        for i in range(13):
            dp[keta + 1][(temp + i) % 13]  += (dp[keta][i] )
            dp[keta + 1][(temp + i) % 13] %= MOD
    kurai *= 10
    keta %= MOD
print(dp[-1][5] )
### BUGGY CODE ###

k=int(input())
z=range(1,k+1)
import math
from functools import reduce
sum=0
for i in z:
	for j in z:
		for jj in z:
			sum=sum+reduce(math.gcd,[i,j,jj])
print(sum)


### FIXED CODE ###

k=int(input())
z=range(1,k+1)
import math
from functools import reduce
sum=0
for i in z:
	for j in z:
		for jj in z:
			sum=sum+reduce(math.gcd,[i,j,jj])
print(sum)
### BUGGY CODE ###

N = int(input())
li = [int(i) for i in input().split()]

# タプルを作って裏返したペアが存在するかどうか
tupple = []
for i in range(N) :
    s = str(i+1) + ' ' + str(li[i])
    tupple.append(s)

c = 0
for tup in tupple :
    t = tup.split()
    needle = t[1] + ' ' + t[0]
    if needle in tupple :
        c += 1

print(c//2)

### FIXED CODE ###

N = int(input())
li = [int(i) for i in input().split()]

c = 0
for i in range(1,N+1) :
    # iを基準に行って帰ってこれればOK
    if (i == li[li[i-1]-1]) :
        c += 1

print(c//2)
### BUGGY CODE ###

n=input()
Numbers = list(map(int,input().split()))
ans=0
while all([x%2==0 for x in Numbers]):
    ans+=1
    [t/2 for t in Numbers]
print(ans)

### FIXED CODE ###


n=input()
Numbers = list(map(int,input().split()))
ans=0
while all(x%2==0 for x in Numbers):
    ans+=1
    Numbers=[t/2 for t in Numbers]
print(ans)
### BUGGY CODE ###

MAX=10**5+1
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

Q=int(input())
for _ in range(Q):
  ans=0
  l,r=map(int,input().split())
  for i in range(l,r+1,2):
    if is_prime[i] and is_prime[(i+1)//2]:
      ans+=1
  print(ans)


### FIXED CODE ###

MAX=101010
is_prime=[True]*MAX
is_prime[0]=False
is_prime[1]=False
for i in range(2,MAX):
  if is_prime[i]==False:
    continue
  for j in range(i*2,MAX,i):
    is_prime[j]=False

a=[0]*MAX
for i in range(MAX):
  if i%2==0:
    continue
  if is_prime[i] and is_prime[(i+1)//2]:
    a[i]=1

s=[0]
for x in a:
  s.append(s[-1]+x)

Q=int(input())
for _ in range(Q):
  l,r=map(int,input().split())
  print(s[r+1]-s[l])
### BUGGY CODE ###

import itertools
n = int(input())
s = input()
dat = []
for i in range(n):
    dat.append(set([]))
for i in range(n):
    for j in range(max(i, 2), 0, -1):
        for x in dat[j-1]:
            dat[j].add(x + s[i])
    dat[0].add(s[i])
print(len(dat[2]))
#print(dat[2])

### FIXED CODE ###

n = int(input())
s = input()
res = 0
pos = []
for i in range(10):
    pos.append([])

for i in range(len(s)):
    c = int(s[i])
    pos[c].append(i)
import bisect
# 0010
# print(format(10, '04d'))
res = 0
for num in range(0, 1000):
    numstr = format(num, '03d')
    iscan = True
    curpos = -2
    for i in range(3):
        curpos += 1
        val = int(numstr[i])
        ind = bisect.bisect_left(pos[val], curpos)
        if ind == len(pos[val]):
            iscan = False
            break
        curpos = pos[val][ind]

    if iscan:
        res += 1
print(res)
### BUGGY CODE ###

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



mini=1
count=1
index_min=P.index(mini)
while P[0]>mini:
  P=P[:index_min]
  mini=min(P)
  index_min=P.index(mini)
  count+=1
"""
count=1
for i in range(1,N):
  if min(P[:i+1])==P[i]:
    count+=1
"""
print(count)



### FIXED CODE ###

n=int(input())
p=list(map(int, input().split()))
ans=1
l=[p[0]]
buf=p[0]
for i in range(1,n):
    l.append(p[i])
    if p[i]<=buf:
        ans+=1
        buf=p[i]
print(ans)
### BUGGY CODE ###

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


min_ct = 1000000000
for i in range(N):
    ct = 0
    j = 0
    k = N-1
    while j < i:
        if S[j] == "W":
            ct += 1
        j += 1
    while k > i:
        if S[k] == "E":
            ct += 1
        k -= 1
    if min_ct > ct:
        min_ct = ct


print(min_ct)


### FIXED CODE ###

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

num_W = 0
num_E = 0
for i in range(1,N):
    if S[i] == "E":
        num_E += 1
min_ct = num_W + num_E

for i in range(1,N):
    if S[i-1] == "W":
        num_W += 1
    if S[i] == "E":
        num_E -= 1
    ct = num_W + num_E
    if min_ct > ct:
        min_ct = ct


print(min_ct)
### BUGGY CODE ###

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


class Dice:
    def __init__(self, n):
        self.upper    = n[0]
        self.backward = n[1]
        self.right    = n[2]
        self.left     = n[3]
        self.ahead    = n[4]
        self.bottom   = n[5]

    def roll_north(self):
        self.upper, self.ahead, self.bottom, self.backward = self.backward, self.upper, self.ahead, self.bottom

    def roll_south(self):
        self.upper, self.ahead, self.bottom, self.backward = self.ahead, self.bottom, self.backward, self.upper

    def roll_east(self):
        self.upper, self.right, self.bottom, self.left = self.left, self.upper, self.right, self.bottom

    def roll_west(self):
        self.upper, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.upper

    def roll_side(self):
        self.ahead, self.right, self.backward, self.left = self.left, self.ahead, self.right, self.backward


dice_info = Dice(list(map(int, input().split())))
q = int(input())

for i in range(q):
    upper, ahead = map(int, input().split())

    while not (upper == dice_info.upper or ahead == dice_info.ahead):
        dice_info.roll_north()
        dice_info.roll_side()

    while upper != dice_info.upper:
        dice_info.roll_east()

    while ahead != dice_info.ahead:
        dice_info.roll_side()

    print(dice_info.left)


### FIXED CODE ###

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


class Dice:
    def __init__(self, n):
        self.upper    = n[0]
        self.backward = n[1]
        self.right    = n[2]
        self.left     = n[3]
        self.ahead    = n[4]
        self.bottom   = n[5]

    def roll_north(self):
        self.upper, self.ahead, self.bottom, self.backward = self.backward, self.upper, self.ahead, self.bottom

    def roll_south(self):
        self.upper, self.ahead, self.bottom, self.backward = self.ahead, self.bottom, self.backward, self.upper

    def roll_east(self):
        self.upper, self.right, self.bottom, self.left = self.left, self.upper, self.right, self.bottom

    def roll_west(self):
        self.upper, self.right, self.bottom, self.left = self.right, self.bottom, self.left, self.upper

    def roll_side(self):
        self.ahead, self.right, self.backward, self.left = self.left, self.ahead, self.right, self.backward


dice_info = Dice(list(map(int, input().split())))
q = int(input())

for i in range(q):
    upper, ahead = map(int, input().split())

    if upper is dice_info.left:
        dice_info.roll_east()
        
    elif upper is dice_info.right:
        dice_info.roll_west()

    while not (upper == dice_info.upper or ahead == dice_info.ahead):
        dice_info.roll_north()

    while upper != dice_info.upper:
        dice_info.roll_east()

    while ahead != dice_info.ahead:
        dice_info.roll_side()

    print(dice_info.left)
### BUGGY CODE ###

import sys
def input(): return sys.stdin.readline().strip()

n=int(input())
x=int(input(),2)

i1=1<<n
for i in range(n-1,-1,-1):
#    xi=x^(1<<i)
    i1=i1>>1
    xi=x^i1
#    print(xi,popcount(xi),xi%popcount(xi))
    icnt=0
    while xi>0:
        icnt+=1
        xi=xi%bin(xi).count("1")
    print(icnt)        
        


### FIXED CODE ###

import sys
def input(): return sys.stdin.readline().strip()

n=int(input())
xs=input()
xj=xs.count("1")

x=int(xs,2)
xip=x%(xj+1)
if xj!=1:
    xim=x%(xj-1)

for i in range(n-1,-1,-1):
    if xs[n-1-i]=="0":
        pxi=xj+1
        i2=pow(2,i,pxi)
        xi=(xip+i2)%pxi
    elif xj==1:
        print(0)
        continue
    else:
        pxi=xj-1
        i2=pow(2,i,pxi)
        xi=(xim-i2)%pxi
    xi=xi%pxi
    if xi==0:
        print(1)
        continue
    icnt=1
    while xi>0:
#        print("i",i,"xi",xi,"icnt",icnt)
        icnt+=1
        xi=xi%(bin(xi).count("1"))
    print(icnt)
### BUGGY CODE ###

n = int(input())

import math
root = math.ceil(math.sqrt(n))

for i in range(n):
    if n%(root+i)==0:
        print(len(str(root+i)))
        break



### FIXED CODE ###

n = int(input())

import math
root = math.ceil(math.sqrt(n))

for i in range(1,root+1):
    if n%i==0:
        ans = n//i
print(len(str(ans)))