Harryxun/stf_run huggingface dataset:
import sys
import collections
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")

n=int(input())
d=list(map(int,input().split()))
d.append(0)
c=collections.Counter(d)
if c.most_common()[0][1]>2:
    print(0)
    quit()
if 0 in c:
    if c[0]==2:
        print(0)
        quit()
if 12 in c:
    if c[12]==2:
        print(0)
        quit()
li=list(map(int,c.keys()))

ans=0
for i in range(2**len(li)):
    hour=[]
    for j in range(len(li)):
        if c[li[j]]==2:
            hour.append(li[j])
            hour.append(24-li[j])
            break
        if i&(1<<j):
            hour.append(li[j])
        else:
            hour.append(24-li[j])
    hour.sort()
    # print(hour)
    tmp=24+hour[0]-hour[-1]
    for j in range(len(li)-1):
        tmp=min(tmp,hour[j+1]-hour[j])
    ans=max(ans,tmp)
print(ans)

### FIXED CODE ###

import sys
import collections
def input():
    return sys.stdin.readline()[:-1]
inf=float("inf")

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

c=collections.Counter(d)
if c.most_common()[0][1]>2:
    print(0)
    quit()
if 0 in c:
    if c[0]==1:
        print(0)
        quit()

li=list(map(int,c.keys()))
li.append(0)
ans=0
# print(li)
# print(len(li))
for i in range(2**len(li)):
    hour=[]
    for j in range(len(li)):
        if c[li[j]]==2:
            hour.append(li[j])
            hour.append(24-li[j])
            continue
        if i&(1<<j):
            hour.append(li[j])
        else:
            hour.append(24-li[j])
    hour.sort()
    # print(hour)
    tmp=24+hour[0]-hour[-1]
    for j in range(len(hour)-1):
        tmp=min(tmp,hour[j+1]-hour[j])
    # print(tmp)
    ans=max(ans,tmp)
print(ans)
A = int(input()) #500
B = int(input()) #100
C = int(input()) #50
X = int(input())
count = 0 #初期値
           
#全件走査
maxA = X // 500 if 500 * A > X else A
for i in range(maxA + 1):
  maxB = (X - 500 * i) // 100 if 100 * B > (X - 500 * i) else B
  for j in range(maxB + 1):
    q,mod = divmode (X - 500 * i - 100 * j ,50)
    if mod == 0 and q <= C:count += 1      
print(count)


### FIXED CODE ###

A = int(input()) #500
B = int(input()) #100
C = int(input()) #50
X = int(input())
count = 0 #初期値
           
#全件走査
maxA = X // 500 if 500 * A > X else A
for i in range(maxA + 1):
  maxB = (X - 500 * i) // 100 if 100 * B > (X - 500 * i) else B
  for j in range(maxB + 1):
    q,mod = divmod (X - 500 * i - 100 * j ,50)
    if mod == 0 and q <= C:count += 1    
print(count)
(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and (cs[-1] > ps[-1] or cs[-1] > qs[-1]):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        break
# print ps, qs

print tot



### FIXED CODE ###

(x, y, A, B, C) = map(int, raw_input().split())

ps = sorted(map(int, raw_input().split()), reverse=True)[:x]
qs = sorted(map(int, raw_input().split()), reverse=True)[:y]
cs = sorted(map(int, raw_input().split()))

tot = sum(ps) + sum(qs)

while cs and ((ps and cs[-1] > ps[-1]) or (qs and cs[-1] > qs[-1])):
    if ps and qs:
        if ps[-1] < qs[-1]:
            tot -= ps.pop()
            tot += cs.pop()
        else:
            tot -= qs.pop()
            tot += cs.pop()
    elif ps:
        tot -= ps.pop()
        tot += cs.pop()
    elif qs:
        tot -= qs.pop()
        tot += cs.pop()
    else:
        break
# print ps, qs

print tot
import itertools

N = int(input())
T = []
T.append(tuple(map(int, input().split())))
T.append(tuple(map(int, input().split())))

M = [0]*N
for i in range(N):
    M[i] = i+1

ans = []
for i, v in enumerate(itertools.permutations(M, N)):
    if v in T:
        ans.append(i)

print(abs(ans[0] - ans[1]))

### FIXED CODE ###

import itertools
import sys

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

if P == Q:
    print(0)
else:
    M = [0]*N
    for i in range(N):
        M[i] = i+1

    ans = []
    for i, v in enumerate(itertools.permutations(M, N)):
        if v in [P, Q]:
            ans.append(i)

    print(abs(ans[0] - ans[1]))
L,R=map(int,input().split())
M=2019
import sys
for i in range(L,R):
    for j in range(i+1,R+1) :
        if (i*j)%2019 < M :
            M = (i*j)%2019
            if M == 0:
                sys,exit()
print (M)

### FIXED CODE ###

N, A, B = map(int,input().split())
if B<N*A :
    print(B)
else :
    print(N*A)
A, B = map(int, input().split())

if B < 0:
    print(A - B)
elif A > 1 and B > 1:
    print(A * B)
else A ==1 or B == 1:
    print(A + B)


### FIXED CODE ###

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

add = A + B
sub = A - B
mul = A * B

if add > sub and add > mul:
    print(add)
elif sub > add and sub > mul:
    print(sub)
elif mul > add and mul > sub:
    print(mul)
else:
    print(add)
X, Y, Z, K = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
l = []

for i in range(X):
    for j in range(Y):
        l.append(a[i] + b[j])
l.sort(reverse = True)
l = l[:K]

L = []
c.sort(reverse = True)

for i in range(len(l)):
    for j in range(min(Z, K)):
        L.append(l[i] + c[j])

L.sort(reverse = True)
for i in range(K):
    print(L[i])

### FIXED CODE ###

a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if b - a > k or  c - a > k or  d - a > k or  e - a > k or  c - b > k or  d - b > k or  e - b > k or  d - c > k or  e - c > k or  e - d > k:
    print(":(")
else:
    print("Yay!")
n=int(input()) 
lis=list(map(int,input().split()))
m=min(lis)
new=lis
while True:
  for i in range(n):
    new[i]%=m
  if all(nn==0 for nn in new):
    print(m)
    exit()
  ll=[m]
  for nn in new:
    if nn!=0:
      ll.append(nn)
  new=ll
  m=min(new)


### FIXED CODE ###

n=int(input()) 
lis=list(map(int,input().split()))
m=min(lis)
new=lis
num=0
while True:
  for i in range(n+num):
    new[i]%=m
  if all(nn==0 for nn in new):
    print(m)
    exit()
  new.append(m)
  sl={m}
  for i in range(n+num):
    if new[i]!=0:
      sl.add(new[i])
  m=min(sl)
  num+=1
N = int(input())
A = []
for i in range(N):
   A.append(input())
S = 0
for i in range(N-1):
    if A[i][-1] == A[i+1][0]:
        S += 1
B = 0
for i in range(N):
    for j in range(N):
      if A[i] == A[j]:
        B += 1
      else:
        B += 0

if S == N-1 and B == N:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

import fractions
from functools import reduce


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N, X = (int(i) for i in input().split())
A = [int(i) for i in input().split()]


def aho(x):
  return x - X


B = list(map(aho, A))

C = gcd_list(B)

print(abs(C))
import 
a,b = map(int, input().split())
s = input()

if len(s) == (a+b+1) and all([c != '-' for c in s[:a]+s[a+1:]]) and s[a] == '-':
  print('Yes')
else:
  print('No')

### FIXED CODE ###

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

if len(s) == (a+b+1) and all([c != '-' for c in s[:a]+s[a+1:]]) and s[a] == '-':
  print('Yes')
else:
  print('No')
a,b,c,d = input()
init = max(a,c)
term = min(b,d)
if term-init <= 0 and :
  print "0"
else:
  print (term-init)

### FIXED CODE ###

a,b,c,d = map(int, raw_input().split())
init = max(a,c)
term = min(b,d)
if term-init <= 0:
  print "0"
else:
  print (term-init)
L,R=map(int,input().split())
l=L//2019
ll=L%2019
r=R//2019
if l<r or ll==0 or :
  print(0)
else:
  print(ll*(ll+1))

### FIXED CODE ###

L, R = map(int, input().split())
if R - L >= 2018:
	print(0)
else:
	ans = 2019
	for i in range(L, R):
		for j in range(i + 1, R + 1):
			ans = min(ans, i * j % 2019)
	print(ans)
n = input()
n_max = -10**9
 
for i in range(0, n-1):
 R[i] = input()

n_min = R[0]

for i in range(0, n-1):
 if R[i] <= n_min:
  n_min = R[i]
 if n_max <= R[i] - n_min:
  n_max = R[i] - n_min
 
print n_max

### FIXED CODE ###

n = input()
n_max = -(10**9)
n_min = input() 

for i in range(0, n-1):
 R = input()
 if n_max < R - n_min:
  n_max = R - n_min
 if R < n_min:
  n_min = R
 
print n_max
if B==0 and 0>A:
    print(abs(A))
elif B>=A and A>=0:
    print(B-A)
elif B>=0 and 0>=A:
    if abs(B)>=abs(A):
        print(abs(B)-abs(A)+1)
    else:
        print(abs(A)-abs(B)+1)
elif 0>=B and B>=A:
    print(abs(A)-abs(B))
    
elif A>B and B>=0:
    print(A-B+2)
elif A>=0 and 0>=B:
    if abs(A)>=abs(B):
        print(abs(A)-abs(B)+1)
    else:
        print(abs(B)-abs(A)+1)
elif 0>=A and A>=B:
    print(abs(B)-abs(A)+2)

### FIXED CODE ###

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

if B==0 and 0>A:
    print(abs(A))
elif B==0 and A>0:
    print(abs(A)+1)
elif B>=A and A>=0:
    print(B-A)
elif B>=0 and 0>=A:
    if abs(B)>=abs(A):
        print(abs(B)-abs(A)+1)
    else:
        print(abs(A)-abs(B)+1)
elif 0>=B and B>=A:
    print(abs(A)-abs(B))
    
elif A>B and B>=0:
    print(A-B+2)
elif A>=0 and 0>=B:
    if abs(A)>=abs(B):
        print(abs(A)-abs(B)+1)
    else:
        print(abs(B)-abs(A)+1)
elif 0>=A and A>=B:
    print(abs(B)-abs(A)+2)
s = list(input())
t = list(input())
s = "".join(s.sort())
t = "".join(t.sort())
ans = 'No'
if s < t:
    ans = 'Yes'
print(ans)

### FIXED CODE ###

s = sorted(list(input()))
t = sorted(list(input()), reverse=True)
s = "".join(s)
t = "".join(t)
ans = 'No'
if s < t:
    ans = 'Yes'
print(ans)
n=int(inpt())
c=n**3
print(c)

### FIXED CODE ###

n=int(input())
c=n**3
print(c)
import collections
N = int(input())
listA = []
for i in range(N):
    listA.append(input())
c = collections.Counter(listA)
c = c.most_common()
max_number = c[0][1]
print(c[0][0])
for i in range(1,N+1):
    if max_number == c[i][1]:
        print(c[i][0])
    else:
        exit()

### FIXED CODE ###

import collections
N = int(input())
listA = []
listB = []
for i in range(N):
    listA.append(input())
c = collections.Counter(listA)
c = c.most_common()
max_number = c[0][1]
listB.append(c[0][0])
A = len(c)
for i in range(1,A):
    if max_number == c[i][1]:
        listB.append(str(c[i][0]))
    else:
        break
listB.sort()
for i in listB:
    print(i)
import itertools
n,m,q = map(int,input().split())
array = []
A = [i for i in range(1,m+1)]
A_list = list(itertools.combinations(A,n))
max_sum = [0]*len(A_list)

for i in range(q):
    a,b,c,d = map(int,input().split())
    for j in range(len(A_list)):
        if A_list[j][b-1]-A_list[j][a-1] == c:
            max_sum[j] += d
print(max(max_sum))

### FIXED CODE ###

import itertools
n,m,q = map(int,input().split())
array = []
A = [i for i in range(1,m+1)]
A_list = list(itertools.combinations_with_replacement(A,n))
max_sum = [0]*len(A_list)

for i in range(q):
    a,b,c,d = map(int,input().split())
    for j in range(len(A_list)):
        if A_list[j][b-1]-A_list[j][a-1] == c:
            max_sum[j] += d
print(max(max_sum))
def gcd(a,b):
  r = (int)(a%b)
  while(r!=0):
    a=(int)(b)
    b=(int)(r)
    r=(int)(a%b)
  return b
def lcm(a,b):
    return (a*b)/gcd(a,b)
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))


### FIXED CODE ###

def gcd(a,b):
  a = int(a)
  b = int(b)
  r = (int)(a%b)
  while(r!=0):
    a=(int)(b)
    b=(int)(r)
    r=(int)(a%b)
  return b
def lcm(a,b):
    return int((a*b)//gcd(a,b))
n = int(input())
ans = int(input())
for i in range(n-1):
  num = int(input())
  ans = lcm(max(ans,num),min(ans,num))
print(int(ans))
a,b = map(int, input.split())

if a < b:	print(str(a+'0') * b )
else:	print(str(b+'0') * a )

### FIXED CODE ###

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

if a < b:	print(str(a) * b )
else:	print(str(b) * a )
a,b=map(int,input().split())
c=a+b
d=a-b
e=a*b
print(max(c,d,e)

### FIXED CODE ###

a,b=map(int,input().split())
print(max(a+b,a-b,a*b))
N = int(input())
A = map(int, input().split())

count = -1
flag = True

while flag == True:
    count += 1
    for i in range(N):
        if A[i]%2 == 0:
            A[i] /= 2

        else:
            flag = False
            break



print(count)


### FIXED CODE ###

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

count = -1
flag = True

while flag == True:
    count += 1
    for i in range(N):
        if A[i]%2 == 0:
            A[i] /= 2

        else:
            flag = False
            break



print(count)
while True:
  inp=raw_input()
  a= set(inp)
  if(a==""):
    break
  elif(len(a)==1):
      print("No")
  else:
      print("Yes")
 

### FIXED CODE ###

#! /usr/bin/env python3

s=set(input())
print("Yes") if len(s)==2 else print("No")
N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+100)] for _ in range(N+10)]
dp[0][0] = 0
for i, (item_weight, item_value) in enumerate(items): 
    for total_weight in range(W+10):                   
        dp[i+1][total_weight] = max(dp[i][total_weight], dp[i+1][total_weight])
        dp[i+1][total_weight+item_weight] = max(dp[i][total_weight]+item_value, dp[i+1][total_weight+item_weight])
        
print(dp[N][W])

### FIXED CODE ###

N, W = map(int, input().split())
items = [list(map(int, input().split())) for _ in range(N)]

dp = [[0 for _ in range(W+10)] for _ in range(N+10)]

for i, (item_weight, item_value) in enumerate(items):
    for total_weight in range(W+1):
        if (total_weight-item_weight) >= 0:
            dp[i+1][total_weight] = max(dp[i][total_weight-item_weight] + item_value, dp[i+1][total_weight])
        dp[i+1][total_weight] = max(dp[i+1][total_weight], dp[i][total_weight])
        
print(dp[N][W])
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
ans = 0
mons = 0
yusha = 0
for i in range(N):
	mons = max(A[i] - yusha, 0)
    ans += min(yusha, A[i])
    ans += min(mons, B[i])
    yusha = max(0, B[i] - mons)
print(ans)

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
ans = 0
mons = 0
yusha = 0
for i in range(N):
    mons = max(A[i] - yusha, 0)
    ans += min(yusha, A[i])
    ans += min(mons, B[i])
    yusha = max(0, B[i] - mons)
ans += min(yusha, A[N])
print(ans)
from collections import deque
S = input()
Q = int(input())
rev = 0

for i in range(Q):
    T = input().split()
    if T[0] == '1':
        rev += 1
    else:
        if T[1] == '1':
            if rev % 2 == 0:
                S.insert(0, T[2])
            else:
                S.append(T[2])
        else:
            if rev % 2 == 0:
                S.append(T[2])
            else:
                S.insert(0,T[2])
ans = ''.join(S)
if rev % 2 ==0:
    print(ans)
else:
    print(ans[::-1])

### FIXED CODE ###

from collections import deque
S = input()
Q = int(input())
R = deque(S)
rev = 0

for i in range(Q):
    T = input().split()
    if T[0] == '1':
        rev += 1
    else:
        if T[1] == '1':
            if rev % 2 == 0:
                R.appendleft(T[2])
            else:
                R.append(T[2])
        else:
            if rev % 2 == 0:
                R.append(T[2])
            else:
                R.appendleft(T[2])
ans = ''.join(R)
if rev % 2 ==0:
    print(ans)
else:
    print(ans[::-1])
N, M = map(int, input().split())

list1 = []
list2 = []

count = 0
C = 0
o = 0
b = 0
G = 0

for i in range(1, N + 1):
    list1.append(i * 2)
    if i >= 2:
        C = sum(list1)
        list1.remove(list1[o])
        o += 1
    if C % 2 == 0:
        count += 1
    C = 0

for q in range(1, M + 1):
    list2.append((q * 2) - 1)
    if q >= 2:
        G = sum(list2)
        list2.remove(list2[b])
        b += 1
    if G % 2 == 0:
        count += 1
    G = 0

for w in list1:
    for e in list2:
        total = w + e
        if total % 2 == 0:
            count += 1

print(count)

### FIXED CODE ###

import math


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

count = N * (N - 1) / 2 + M * (M - 1) / 2
print(math.floor(count))
N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))

data=[]
for n1 in range(N):
  data.append([])
  for n2 in range(N):
    data[n1].append(0)
    
for m in M:
  a,b=map(int,input().split(' '))
  data[a-1][b-1]=H[b-1]
  data[b-1][a-1]=H[a-1]
ans=0
for n in N:
  if H[n-1]>max(data[n-1]):
    ans+=1
print(ans)

### FIXED CODE ###

N,M=map(int,input().split(' '))
H=list(map(int,input().split(' ')))

data=[]
for n in range(N):
  data.append(H[n]-1)
    
for m in range(M):
  a,b=map(int,input().split(' '))
  data[a-1]=max(data[a-1],H[b-1])
  data[b-1]=max(data[b-1],H[a-1])
  
ans=0
for n in range(N):
  if H[n-1]-1==data[n-1]:
    ans+=1
print(ans)
N, K = map(int, input().split())
ListH = list(map(int, input().split()))

#ListH.sort(reverse=True)
sum=0

if N<=K:
    print(0)
else:
     
for i in range(N-K):
    sum+=ListH[i]

print(sum)

### FIXED CODE ###

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


if N<=K:
    print(0)
else:
    ListH.sort()
    sum=0
    for i in range(N-K):
        sum+=ListH[i]

    print(sum)
N,M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    E[a-1].append((b-1, -c))
    
    
#ベルマンフォード法:負閉路の検出とある一点から他のすべての点への最短距離の算出

def BellmanFord(E, N, M, source):
    #E:E[a]は頂点aを始点とする辺のリストであり、辺の終点bと辺の重みwが(b, w)の形で格納されている
    #N:頂点の数
    #M:辺の数
    #source:始点
    #グラフの初期化
    inf = 10**15
    d = [inf for i in range(N)]
    d[source] = 0
    
    #辺の緩和
    for i in range(N):
        for j in range(M):
            e = E[j]
            if len(e) == 0:
                continue
            for edge in e:
                if d[edge[0]] > d[j] + edge[1]:
                    d[edge[0]] = d[j] + edge[1]
                    if i == N-1 and j == N-1: return -1
    
    return d

dist = BellmanFord(E, N, M, 0)
if dist == -1:
    print("inf")
else:
    print(-dist[N-1])

### FIXED CODE ###

N,M = map(int, input().split())
E = [[] for _ in range(N)]
for _ in range(M):
    a, b, c = map(int, input().split())
    E[a-1].append((b-1, -c))
    
    
#ベルマンフォード法:負閉路の検出とある一点から他のすべての点への最短距離の算出

def BellmanFord(E, N, source):
    #E:E[a]は頂点aを始点とする辺のリストであり、辺の終点bと辺の重みwが(b, w)の形で格納されている
    #N:頂点の数
    #source:始点
    #グラフの初期化
    inf = 10**20
    d = [inf for _ in range(N)]
    d[source] = 0
    
    #辺の緩和
    for i in range(N):
        for j in range(N):
            e = E[j]
            if len(e) == 0:
                continue
            for edge in e:
                if d[edge[0]] > d[j] + edge[1]:
                    d[edge[0]] = d[j] + edge[1]
                    if i == N-1 and edge[0] == N-1:
                        return -1
    
    return d

dist = BellmanFord(E, N, 0)
if dist == -1:
    print("inf")
else:
    print(-dist[N-1])
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

ans = 0
pre = -1
for i in A:
  ans += B[i-1]
  if i == pre+1:
  	ans += C[i-1]
  pre = i
print(ans)

### FIXED CODE ###

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

ans = 0
pre = -1
for i in A:
  ans += B[i-1]
  if i == pre+1:
  	ans += C[pre-1]
  pre = i
print(ans)
N = int(input())
li = list(map(int,input().split()))

L = [0] * 10**6

import math
from functools import reduce

if reduce(math.gcd,li)!=1:
    print('not coprime')
    exit()

for i in li:
    L[i] = 1
#print(L)

for k in range(2,10**6//2+1):
    t = 0
    for j in range(0,10**6,k):
        t += L[j]
    if t > 1:
        print('setwise coprime')
        exit()
print('pairwise coprime')

### FIXED CODE ###

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

S = max(li)
L = [0] * (S+1)

import math
from functools import reduce

if reduce(math.gcd,li) != 1:
    print('not coprime')
    exit()

for i in li:
    L[i] = 1

for k in range(2,S+1):
    t = 0
    for j in range(0,S+1,k):
        t += L[j]
    if t > 1:
        print('setwise coprime')
        exit()
print('pairwise coprime')
n = int(input())
x = input()
ones = 0
for i in x:
    if i=='1':
        ones += 1
mods = [0, 0]
for i in range(n):
    if x[n-i-1]=='1':
        mods[0] += pow(2, i, ones-1)
        mods[1] += pow(2, i, ones+1)
mods[0] %= ones-1
mods[1] %= ones+1
def f(x):
    if x==0:
        return 1
    cnt = 1
    while x>0:
        p = bin(x).count('1')
        x %= p
        cnt += 1
    return cnt
for i in range(n-1, -1, -1):
    if x[n-i-1]=='1':
        init = (mods[0] - pow(2, i, ones-1))%(ones-1)
    else:
        init = (mods[1] + pow(2, i, ones+1))%(ones+1)
    print(f(init))

### FIXED CODE ###

n = int(input())
x = input()
ones = 0
for i in x:
    if i=='1':
        ones += 1
mods = [0, 0]
for i in range(n):
    if x[n-i-1]=='1':
        if ones>1:
            mods[0] += pow(2, i, ones-1)
        mods[1] += pow(2, i, ones+1)
if ones>1:
    mods[0] %= ones-1
mods[1] %= ones+1
def f(x):
    if x==0:
        return 1
    cnt = 1
    while x>0:
        p = bin(x).count('1')
        x %= p
        cnt += 1
    return cnt
for i in range(n-1, -1, -1):
    if x[n-i-1]=='1' and ones==1:
        print(0)
        continue
    if x[n-i-1]=='1':
        init = (mods[0] - pow(2, i, ones-1))%(ones-1)
    else:
        init = (mods[1] + pow(2, i, ones+1))%(ones+1)
    print(f(init))
a = input()
total = 0
for i in a[range(1,4)]:
  if i = 'R':
    total +=1
  else:
    total = 0


### FIXED CODE ###

a = input()
if a =='SSS':
  print(0)
elif a=='RRR':
  print(3)
elif a == 'RRS' or a== 'SRR':
  print(2)
else:
  print(1)
W, H, x, y, r = map(int, input().split())
if x >= r and x + r <= W and y >= r and y + r <= H
  print("Yes")
else:
  print("No")


### FIXED CODE ###

W, H, x, y, r = map(int, input().split())
if x >= r and x + r <= W and y >= r and y + r <= H:
  print("Yes")
else:
  print("No")
line = input().rstrip().split(' ')

fst_point = int(line[0]) * 10 + int(line[1])
sec_point = int(line[1]) * 10 + int(line[2])

if fst_point > sec_point:
    return print(fst_point + int(line[2]))
else:
    return print(sec_point + int(line[0]))
  

### FIXED CODE ###

x, y, z = map(int,input().split())

max_lines = [[x * 10 + y, z],
                 [x * 10 + z, y],
                 [y * 10 + x, z],
                 [y * 10 + z, x],
                 [z * 10 + x, y],
                 [z * 10 + y, x]]

max_point = 0
one_point = 0
for max_line in max_lines:
    if max_line[0] >= max_point:
        max_point = max_line[0]
        one_point = max_line[1]

print(max_point + one_point)
import math

r = int(input())

s = float(2 * math.pi * r)
circle = float(math.pi * r**2)

print("%.7f %.7f" %(s,circle))

### FIXED CODE ###

import math

r = input()
print('%f %f'% (math.pi *r *r , 2 * math.pi * r))
h = int(input())

log = {'1': 1 , '2': 3, '3': 3, '4': 7 }

i = 1
while i <= h:
  if str(i) in log:
    # print(log[str(i)])
  else:
    n = i // 2
    log.setdefault(str(i), log[str(n)]*2+1)
    # print(log[str(i)])
  i=i+1
print(log[h])



### FIXED CODE ###

def input_int():
    return int(input())

def suss(num):
  result = 2
  while num > 1:
    num = num // 2
    result = result * 2
  return result - 1

h = input_int()
print(suss(h))
x = input()
counter = 0
while True:
        if x == '0':
                break
        else:
                counter = counter+1
                return('Case %d:%s' %(counter,x))


### FIXED CODE ###

i = 0
while i <10000:
    x = input()
    if x == '0':
        break
    else:
        i += 1
        print('Case %d: %s' %(i,x))