Harryxun/stf_run huggingface dataset:
n = int(input())
a = list(map(int,input().split()))

import bisect
a.sort()

center = a[-1]//2

index = bisect.bisect_left(a,center)

if a[index] != center:
    if index > 0 and center - a[index-1] < a[index] - center:
        index -= 1
        
if index == N-1:
    index -= 1
    
print(a[-1],a[index])

### FIXED CODE ###

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

import bisect
a.sort()

center = a[-1]//2

index = bisect.bisect_left(a,center)

if a[index] != center:
    if index > 0 and center - a[index-1] < a[index] - center:
        index -= 1
        
if index == n-1:
    index -= 1
    
print(a[-1],a[index])
n=input()
s=list(map(int,(input().split(" "))))
ans=1
for i in s:
    ans*=i
    if ans > 1e18:
        print(-1)
        sys.exit(0)
print(ans)

### FIXED CODE ###

n,*l=map(int,open(0).read().split())
a=1
for i in sorted(l):
  a*=i
  if a>10**18: a=-1; break
print(a)
n=int(input())
     
m=int(input())
     
     
if n==m:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

r = input()
k=r.split()
if k[0] == k[1]:
    print('Yes')
else:
    print('No')
n = int(input())
a_max = 0
data = [int(input()) for i in range(n)]
a_max = max(data)
flag = True if a_max == a_max(data.remove(a_max)) else False
for i in range(n):
  if data[i] == a_max and not flag:
    tmp = data.pop(data[i])
    print(max(data))
    data.append(tmp,0)
    
  else:
  	print(a_max)

### FIXED CODE ###

n = int(input())
a_max = 0
data = [int(input()) for i in range(n)]
a_max = max(data)
flag = True if 2 <= data.count(a_max) else False
for i in range(n):
  if data[i] == a_max and not flag:
    tmp = data.pop(i)
    print(max(data))
    data.insert(tmp,0)
    
  else:
  	print(a_max)
import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    st=[tx-sx,ty-sy]; rst=R(st)
    F=[rwt<r,rsw<r]
    c=0
    if rst==0: c=1
    elif F==[1,1]: c=1
    elif F==[1,0] or F==[0,1]: c=0
    elif F==[0,0]:
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos((sw[0]*st[0]+sw[1]*st[1])/rsw/rst)
#      if C(a,b) and C(rst**2,rsw**2-r**2): c=0
#      else: c=1
    x.append(c)
  return all(x)

while 1:
  n=input()
  if n==0: break
  WP=I(n)
  P=I(input())
  for e in P: print ["Safe","Danger"][f(e)]

### FIXED CODE ###

import math as M
def R(A): return (A[0]**2+A[1]**2)**.5
def I(i): return [map(int,raw_input().split()) for _ in [0]*i]
def C(a,b): return a>b or abs(a-b)<1e-6
def f(e1):
  tx,ty,sx,sy=e1
  x=[]
  st=[tx-sx,ty-sy]; rst=R(st)
  for e2 in WP:
    wx,wy,r=e2
    wt=[tx-wx,ty-wy]; rwt=R(wt)
    sw=[wx-sx,wy-sy]; rsw=R(sw)
    F=[rwt<r,rsw<r]
    if F==[1,0] or F==[0,1]: return 0
    elif F==[0,0]:
      a=M.pi/2-M.acos(r/rsw)
      b=M.acos(round((sw[0]*st[0]+sw[1]*st[1])/rsw/rst,4))
      if C(a,b) and C(rst**2,rsw**2-r**2): return 0
  return 1

while 1:
  n=input()
  if n==0: break
  WP=I(n)
  P=I(input())
  for e in P: print ["Safe","Danger"][f(e)]
n, m = (int(x) for x in input().split())
if n % 2 == 0:
  ans = n * m // 2
elif m % 2 == 0:
  m % 2==0:
  ans = n * m // 2
else:
  ans = (n * (m+1) // 2 )- n //2
print(ans)


### FIXED CODE ###

n, m = (int(x) for x in input().split())

if n == 1 or m == 1:
  ans = 1
else:
  if n % 2 == 0:
    ans = n * m // 2
  else:
    if m % 2 == 0:
      ans = n * m // 2
    else:
      ans = n * m // 2 + 1
print(ans)
import fractions

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

ans = fractions.gcd(abs(a[0]-x),abs(a[1]-x))
for i in range(2,n) :
  ans = fractions.gcd(ans,abs(a[i]-x))
  
print(ans)

### FIXED CODE ###

import fractions
import sys

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

if n == 1 :
  print(abs(a[0]-x))
  sys.exit()

ans = fractions.gcd(abs(a[0]-x),abs(a[1]-x))
for i in range(2,n) :
  ans = fractions.gcd(ans,abs(a[i]-x))
  
print(ans)
x, a, b = map(int,input().split())
print('A') if abs(x-a) < abs(s-b) else print('B')

### FIXED CODE ###

x, a, b = map(int,input().split())
print('A') if abs(x-a) < abs(x-b) else print('B')
a = input()
b = input()
print(3^a^b)

### FIXED CODE ###

a = int(input())
b = int(input())
print(a^b)
n = int(input())
e = [[] for i in range(n)]
for i in range(1,n):
    x = int(input())
    e[x-1].append(i)

def dfs(x):
    count = len(e[x])
    if count == 0:
        return 0
    now = 0
    for nex in e[x]:
        now = max(now,dfs(nex))    
    return max(count,now+1)

print(dfs(0))

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)
from collections import defaultdict

n = int(input())
e = [[] for i in range(n)]
for i in range(1,n):
    x = int(input())
    e[x-1].append(i)

def dfs(x):

    count = len(e[x])
    if count == 0:
        return 0
    d = defaultdict(int)
    ma = 0
    s = set()
    for nex in e[x]:
        v = dfs(nex)
        d[v] += 1
        s.add(v)
        ma = max(ma,v)
    now = count
    bef = 0
    for v in sorted(list(s),reverse=True):
        bef += d[v]
        now = max(now,bef+v)
    return now

print(dfs(0))
N =int(input())
list ={"AC"=0, "WA"=0, "TLE"=0, "RE"=0 }
 
for i in range(N):
  words = input()
  list[words]+=1
 
print("AC x "+str(list["AC"]))
print("WA x "+str(list["WA"]))
print("TLE x "+str(list["TLE"]))
print("RE x "+str(list["RE"]))

### FIXED CODE ###

N =int(input())
list ={"AC":0, "WA":0, "TLE":0, "RE":0 }
 
for i in range(N):
  words = input()
  list[words]+=1
 
print("AC x "+str(list["AC"]))
print("WA x "+str(list["WA"]))
print("TLE x "+str(list["TLE"]))
print("RE x "+str(list["RE"]))
N,Q=map(int,input().split())

R=[[] for i in range(N)]
ans=[0]*N

for i in range(N-1):
    a,b=map(lambda x:int(x)-1,input().split())
    R[b].append(a)


c=[0]*N
for i in range(Q):
    p,x=map(int,input().split())
    c[p-1]+=x

ans=[0]*N

for i in range(N-1,-1,-1):
    tem=i
    while True:
        if tem==0:
            ans[tem]=c[0]
            break
        ans[i]+=c[R[tem][0]]
        tem=R[tem][0]


print(*ans)

### FIXED CODE ###

import sys
input=sys.stdin.readline

sys.setrecursionlimit(10**6)


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

A=[[] for i in range(N)]
c=[0]*N

for i in range(N-1):
    a,b=map(int,input().split())
    A[a-1].append(b-1)
    A[b-1].append(a-1)

for i in range(Q):
    p,x=map(int,input().split())
    c[p-1]+=x

def dfs(now,prev=-1):
    for next in A[now]:
        if next==prev:continue
        else:
            c[next]+=c[now]
            dfs(next,now)
dfs(0)
print(*c)
n, m = map(int, input().split())
an = [int(input()) for _ in range(m)]

dp = [0 for _ in range(n+1)]
dp[0] = 1
mod = 10**9 + 7

if m == 0:
    dp[0] = 1
    dp[1] = 1
    for i in range(2, n+1):
        dp[i] = (dp[i-1] + dp[i-2]) % mod
    print(dp[n])
    exit()

if an[0] == 1:
    dp[1] = 0
    a = 1
else:
    dp[1] = 1
    a = 0

if n >= 2:
    for i in range(2, n+1):
        if i == an[a]:
            dp[i] = 0
            a += 1
            if a == len(an):
                a -= 1
        else:
            dp[i] = (dp[i-1] + dp[i-2]) % mod

print(dp[n])


### FIXED CODE ###

n, m = map(int, input().split())
an = [int(input()) for _ in range(m)]

dp = [0 for _ in range(n+1)]
dp[0] = 1
mod = 10**9 + 7

if m == 0:
    dp[0] = 1
    dp[1] = 1
    for i in range(2, n+1):
        dp[i] = (dp[i-1] + dp[i-2]) % mod
    print(dp[n])
    exit()

if an[0] == 1:
    dp[1] = 0
    a = 1
    if len(an) == 1:
        a = 0
else:
    dp[1] = 1
    a = 0

for i in range(2, n+1):
    if i == an[a]:
        dp[i] = 0
        a += 1
        if a == len(an):
            a -= 1
    else:
        dp[i] = (dp[i-1] + dp[i-2]) % mod

print(dp[n])
def bubble_sort(A):
    cnt = 0
    for i in range(len(A) - 1):
        for j in reversed(range(i+1, len(A))):
            if A[j] < A[j - 1]:
                cnt += 1
                tmp = A[j]
                A[j] = A[j - 1]
                A[j - 1] = tmp
    return cnt

cnt = 0
amount = int(input())
nl = list(int(input()) for i in range(amount))

cnt = bubble_sort(nl)

for i in range(amount - 1):
    print(nl[i], end=" ")
print(nl[amount - 1])
print(cnt)

### FIXED CODE ###

def bubble_sort(A):
    cnt = 0
    for i in range(len(A) - 1):
        for j in reversed(range(i+1, len(A))):
            if A[j] < A[j - 1]:
                cnt += 1
                tmp = A[j]
                A[j] = A[j - 1]
                A[j - 1] = tmp
    return cnt

cnt = 0
amount = int(input())
nl = list(map(int, input().split()))

cnt = bubble_sort(nl)

for i in range(amount - 1):
    print(nl[i], end=" ")
print(nl[amount - 1])
print(cnt)
a,b=map(int,input().split())
coins = [a+b,2a-1,2b-1]
print(max(coins))

### FIXED CODE ###

a,b=map(int,input().split())
coins = [a+b,2*a-1,2*b-1]
print(max(coins))
print(input(),count("1"))


### FIXED CODE ###

print(input().count("1"))
A,op,B=input().strip().split()
if op=='+':
  print(A+B)
else:
  print(A-B)

### FIXED CODE ###

A,op,B=input().strip().split()
if op == '+':
  print(int(A)+int(B))
else:
  print(int(A)-int(B))
n = int(input())
A = tuple(map(int, input().split()))
def p(n):
    is_prime = [True if i%2 == 1 else False for i in range(0, n+1) ]
    is_prime[0] = False
    is_prime[1] = False
    is_prime[2] = True # 2は素数
    # 3からの奇数について
    for i in range(3, int(n**0.5) + 1, 2):
        # 既に素数の倍数であればスキップ
        if not is_prime[i]:
            continue
        # iの倍数は素数ではないとする
        for j in range(i*2, n+1, i):
            is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]

primes = p(max(A))
fact_counts = dict()
for a in A:
    for p in primes:
        if p > a:
            continue
        if a%p == 0:
            fact_counts.setdefault(p, 0)
            fact_counts[p] += 1
pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == n:
        print('not coprime')
    else:
        print('setwise coprime')

### FIXED CODE ###

N = int(input())
A = tuple(map(int, input().split()))
maxa = max(A)
min_facts = [0] * (maxa+1)
def p(n):
    """ """
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, n+1):
        if not is_prime[i]:
            continue
        min_facts[i] = i
        
        for j in range(i*2, n+1, i):
            is_prime[j] = False
            if min_facts[j] == 0:
                min_facts[j] = i
p(maxa)
fact_counts = dict()
for a in A:
    while min_facts[a] > 0:
        f = min_facts[a]
        fact_counts.setdefault(f, 0)
        fact_counts[f] += 1
        while a%f == 0:
            a //= f

pairwise = True
for c in fact_counts.values():
    if c > 1:
        pairwise = False
        break

if pairwise:
    print('pairwise coprime')
else:
    if max(fact_counts.values()) == N:
        print('not coprime')
    else:
        print('setwise coprime')
A,B = map(int,input())
check = False
for C in range(1,4):
  if (A * B * C) % 2 == 1:
    check = True
    
print("Yes" if check else "No")

### FIXED CODE ###

A,B = map(int,input().split())
check = False
for C in range(1,4):
  if (A * B * C) % 2 == 1:
    check = True
    
print("Yes" if check else "No")
import  numpy as np

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


ans=np.prod(A)


if ans > 10**18
	print("-1")
	
else:
	print(ans)

### FIXED CODE ###

N=int(input())
A = [int(x) for x in input().split()]

ans=1
if 0 in A:
    ans = 0
else:
    A.sort(reverse=True)
    for a in A:
        if a > 10**18:
            ans = -1
            break
        else:
            ans *= a
            if ans > 10**18:
                ans = -1
                break
print(ans)
s=list(input())
    k=int(input())
    for i in range(len(s)):
        c = ord('z') - ord(s[i]) + 1
        if c > k:
            continue
        else:
            k -= c
            s[i] = 'a'
    if k > 0:
        s[-1] = chr(ord('a') + ((ord(s[-1]) - ord('a') + k) % 26))
    print(''.join(s))

### FIXED CODE ###

s=list(input())
k=int(input())
for i in range(len(s)):
    c = (ord('z') - ord(s[i]) + 1)%26
    if c <= k:
        k -= c
        s[i] = 'a'
s[-1] = chr(ord('a') + ((ord(s[-1]) - ord('a') + k) % 26))
print(''.join(s))
import numpy as npo
a=input()
a=(map(int,input().split()))
a=npo.array(a)
a=npo.sort.()
print(a[-1]-a[0])

print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")
print("")

### FIXED CODE ###

a=input()
a=sorted(map(int,input().split()))
print(a[-1]-a[0])
N = int(input())
list_A = []

for _ in range(N):
    A = int(input())
    list_A.append(A)
    
A = max(list_A)
index_A = list_A.index(A)

for i in range(N):    
    if list_A[i] == A:
    	list_B = sorted(list_A, reverse=True)
     	B = list_B[1]
      	print(B)
    else:
        print(A)

### FIXED CODE ###

N = int(input())
list_A = []

for _ in range(N):
    A = int(input())
    list_A.append(A)
    
A = max(list_A)
index_A = list_A.index(A)

list_B = sorted(list_A, reverse=True)
B = list_B[1]

for i in range(N):    
    if list_A[i] == A:
        print(B)
    else:
        print(A)
n=int(input())
if N<10:
  print(n)
else:
  L=list(map(int, list(str(N))))
  if(L.count(9)==len(L)) or (L[0]!=9 and L.count(9)==len(L) -1):
    print(sum(L))
  else :
    print(9*(len(L)-1)+int(L[0])-1)


### FIXED CODE ###

n=int(input())
if n<10:
  print(n)
else:
  L=list(map(int, list(str(n))))
  if(L.count(9)==len(L)) or (L[0]!=9 and L.count(9)==len(L) -1):
    print(sum(L))
  else :
    print(9*(len(L)-1)+int(L[0])-1)
class Node:
    # def __init__(self, val):
    def __init__(self):
        self.val = None
        self.color = None
        self.a = []

n = int(input())
nodes = []

for i in range(n):
    nodes.append(Node())
    # nodes.append(Node(i+1))

for i in range(n-1):
    u, v, w = map(int, input().split())
    node1 = nodes[u-1]
    node2 = nodes[v-1]
    node1.val = u
    node2.val = v
    node1.a.append([node2, w])
    node2.a.append([node1, w])

# for i in range(n):
#     node = nodes[i]
#     for pair in node.a:
#         print(pair[0])
#         print(pair[1])

root = nodes[0]
root.color = True
nodeSet = set()

def traverse(node, distance):
    if node in nodeSet:
        return
    else:
        nodeSet.add(node)
    # print('# traverse: ' + str(node.val))
    for pair in node.a:
        adjNode = pair[0]
        dis = pair[1]
        if (distance + dis) % 2 == 0:
            adjNode.color = root.color
        else:
            adjNode.color = not root.color
        traverse(adjNode, distance + dis)

traverse(root, 0)

for i in range(n):
    node = nodes[i]
    if node.color:
        print(1)
    else:
        print(0)


### FIXED CODE ###

import sys
sys.setrecursionlimit(10**5)

class Node:
    # def __init__(self, val):
    def __init__(self):
        self.val = None
        self.color = None
        self.a = []

n = int(input())
nodes = []

for i in range(n):
    nodes.append(Node())
    # nodes.append(Node(i+1))

for i in range(n-1):
    u, v, w = map(int, input().split())
    node1 = nodes[u-1]
    node2 = nodes[v-1]
    node1.val = u
    node2.val = v
    node1.a.append([node2, w])
    node2.a.append([node1, w])

# for i in range(n):
#     node = nodes[i]
#     for pair in node.a:
#         print(pair[0])
#         print(pair[1])

root = nodes[0]
root.color = True
nodeSet = set()

def traverse(node, distance):
    if node in nodeSet:
        return
    else:
        nodeSet.add(node)
    # print('# traverse: ' + str(node.val))
    for pair in node.a:
        adjNode = pair[0]
        dis = pair[1]
        if (distance + dis) % 2 == 0:
            adjNode.color = root.color
        else:
            adjNode.color = not root.color
        traverse(adjNode, distance + dis)

traverse(root, 0)

for i in range(n):
    node = nodes[i]
    if node.color:
        print(1)
    else:
        print(0)
A = input()
B = input()
if 1 <= A and B <= 100
	print(A * B)

### FIXED CODE ###

a,b = map(int,input(). split ())
print(a*b)
N,M,X,Y = map(int, input().split())
num_list = [list(map(int, input().split())) for _ in range(2)]

x_max = max(num_list[0])
y_max = max(num_list[1])

if x_max >= y_max:
    print('War')
elif x_max < X or y_max > Y:
    print('War')
else:
    print('No war')


### FIXED CODE ###

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

num = sorted([A,B,C],reverse=True)
print(eval(str(num[0])+str(num[1])+'+'+str(num[2])))
import math

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

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

x.append(X)

x.sort()

dis = []

for i in range(1, n+1):
    dis.append(x[i] - x[i-1])

for i in range(n):
    if i == 0:
        now = dis[i]
    else:
        now = math.gcd(dis[i], now)

print(now)


### FIXED CODE ###

import fractions

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

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

x.append(X)

x.sort()

dis = []

for i in range(1, n+1):
    dis.append(x[i] - x[i-1])

for i in range(n):
    if i == 0:
        now = dis[i]
    else:
        now = fractions.gcd(dis[i], now)

print(now)
a,b,c,x = map(int,open(0).read().split())

ans = 0 
counta = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      ans = ((i*500 + (j*100 + (k*50)
      if ans == x:
        counta += 1
      else:
        pass
      
print(counta)


### FIXED CODE ###

a,b,c,x = map(int,open(0).read().split())

ans = 0 
counta = 0

for i in range(a+1):
  for j in range(b+1):
    for k in range(c+1):
      ans = ((i*500) + (j*100) + (k*50))
      if ans == x:
        counta += 1
      else:
        pass
      
print(counta)
s = list(input())
x, y = map(int, input().split())

x = abs(x)
y = abs(y)

X = [0]
Y = [0]

flag = True
tmp = 0
for i in s:
    if i == 'F':
        tmp += 1
    else:
        if flag:
            X.append(tmp)
        else:
            Y.append(tmp)
        tmp = 0
        flag = not flag

if flag:
    X.append(tmp)
else:
    Y.append(tmp)

# print (X)
# print (Y)

total_X = sum(X)
total_Y = sum(Y)

lst_X = [0] * (total_X + 1)
lst_X[0] = 1
for i in X:
    for j in range(total_X - i, -1, -1):
        if lst_X[j] == 1:
            lst_X[j + i] = 1

# print (lst_X)

lst_Y = [0] * (total_Y + 1)
lst_Y[0] = 1
for i in Y:
    for j in range(total_Y - i, -1, -1):
        if lst_Y[j] == 1:
            lst_Y[j + i] = 1

# print (lst_Y)

if (total_X - x) % 2 == (total_Y - y) % 2 == 0 and lst_X[(total_X - x) // 2] == 1 and lst_Y[(total_Y - y) // 2]:
    print ('Yes')
else:
    print ('No')

### FIXED CODE ###

s = list(input())
x, y = map(int, input().split())

X = [0]
Y = [0]

flag = True
tmp = 0
for i in s:
    if i == 'F':
        tmp += 1
    else:
        if flag:
            X.append(tmp)
        else:
            Y.append(tmp)
        tmp = 0
        flag = not flag

if flag:
    X.append(tmp)
else:
    Y.append(tmp)

# print (X)
# print (Y)

x -= X[1]
X[1] = 0

x = abs(x)
y = abs(y)

total_X = sum(X)
total_Y = sum(Y)

lst_X = [0] * (total_X + 1)
lst_X[0] = 1
for i in X:
    if i == 0:
        continue
    for j in range(total_X - i, -1, -1):
        if lst_X[j] == 1:
            lst_X[j + i] = 1

# print (lst_X)

lst_Y = [0] * (total_Y + 1)
lst_Y[0] = 1
for i in Y:
    if i == 0:
        continue
    for j in range(total_Y - i, -1, -1):
        if lst_Y[j] == 1:
            lst_Y[j + i] = 1

# print (lst_Y)
if x > total_X or y > total_Y:
    print ('No')
    exit()

if (total_X - x) % 2 == (total_Y - y) % 2 == 0 and lst_X[(total_X - x) // 2] == 1 and lst_Y[(total_Y - y) // 2]:
    print ('Yes')
else:
    print ('No')
n = int(input())
*h, = map(int, input().split())

def rec(i: int, c: int) -> int:
    if i == 0:
        return c
    elif i <= 1:
        return rec(i-1, c+abs(h[i]-h[i-1]))

    return min(rec(i-1, c+abs(h[i]-h[i-1])), rec(i-2, c+abs(h[i]-h[i-2])))

print(rec(n-1, 0))


### FIXED CODE ###

n = int(input())
*h, = map(int, input().split())

dp = [float("inf")]*(n+1)
dp[0] = 0

for i in range(1, n):
    dp[i] = min(dp[i-1]+abs(h[i] - h[i-1]), dp[i])
    if i > 1:
        dp[i] = min(dp[i-2]+abs(h[i] - h[i-2]), dp[i])

print(dp[n-1])
[N,K]=list(map(int,input().split()))
V=list(map(int,input().split()))
have=[]
for n,k in enumerate(reversed(range(0,K+1))):
  tmp=[V[:ki]+V[-(k-ki):] for ki in range(k)
      ]+[V[:k],]
  tmp=[sorted(item) for item in tmp if sum(item)>0]
  #print(n,tmp)
  if n!=0:
    for num_remove in range(n):
      tmp2=[item[n:] for item in tmp 
            if all([g<0 for g in item[:n]])
           ]
      
      tmp.extend(tmp2)
      #print("tmp",tmp)
      #print("tmp2",tmp2)
      
  have.extend(tmp)
  #print(n,have[-1])

if have==[]:
  print(0)
else:
  print(max(list(map(sum,have))))


### FIXED CODE ###

l = list(map(int,input().split()
            )
        )
print(int((3*l[0]+l[1])/2
         )
     )
n = int(input())
lis = list(map(int,input().split()))
lis.sort()
p = 0
counter = n
for i in range(n):
    if i>0 and lis[i] == lis[i-1]:
        counter -=1
    elif i>0 and lis[i]<lis[0]*2:
        p += 1
    else:
        for j in range(n):
            if i != j and lis[i]%lis[j] ==0:
                counter -=1
                break
print(counter)


### FIXED CODE ###

x, n = map(int,input().split())
lis = list(map(int,input().split()))
lis.sort()
if n == 0:
    print(x)
else:
    for i in range(lis[n-1]+2):
        
        if i < x and i not in lis:
            a = i
        if i >= x and i not in lis:
            b = i
            if abs(a-x) <= abs(b-x):
                print(a)
            else:
                print(b)
            break
N = int(input())
X = input()

cnt = X.count('1')
if cnt == 1:
    print(*([1] + N), sep='\n')
    exit()

M = 0
for x in X:
    M <<= 1
    if x == '1':
        M += 1

def solve(n):
    ret = 1
    while n > 0:
        ret += 1
        n %= bin(n).count('1')
    return ret

ans = []
p = M % (cnt + 1)
m = M % (cnt - 1)

for i in range(N):
    if X[i] == '0':
        ans.append(solve((p + pow(2, N - i - 1, cnt + 1)) % (cnt + 1)))
    else:
        ans.append(solve((m - pow(2, N - i - 1, cnt - 1)) % (cnt - 1)))
print(*ans, sep='\n')


### FIXED CODE ###

N = int(input())
X = input()

cnt = X.count('1')
if cnt == 1:
    for x in X[:-1]:
        if x == '0':
            print(1)
        else:
            print(0)
    if X[-1] == '1':
        print(0)
    else:
        print(2)
    exit()

M = 0
for x in X:
    M <<= 1
    if x == '1':
        M += 1

def solve(n):
    ret = 1
    while n > 0:
        ret += 1
        n %= bin(n).count('1')
    return ret

ans = []
p = M % (cnt + 1)
m = M % (cnt - 1)

for i in range(N):
    if X[i] == '0':
        ans.append(solve((p + pow(2, N - i - 1, cnt + 1)) % (cnt + 1)))
    else:
        ans.append(solve((m - pow(2, N - i - 1, cnt - 1)) % (cnt - 1)))
print(*ans, sep='\n')