peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from math import log2

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

res = 10**9
for v in a:
    cnt = 0
    while v % 2 == 0:
        v /= 2
        cnt += 1
    res = min(cnt, res)
print(res)
# Judge status: Accepted
from collections import Counter
N,K = map(int,input().split())
A = list(map(int,input().split()))
A = Counter(A)
values, counts = zip(*A.most_common())
counts = list(counts)
ans = 0

while K < len(counts):
  ans += counts[-1]
  counts.pop(-1)

print(ans)
# Judge status: Accepted
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    k = int(input())

    res = 1
    idx = 0
    for i in range(len(s)):
        if s[i] != "1":
            res = s[i]
            idx = i + 1
            break

    if k < idx:
        print(1)
    else:
        print(res)


if __name__ == '__main__':
    resolve()
# Judge status: Accepted
n = int(input())
now = 0
for i in range(1,10000):
  now += n
  if now % 360 == 0:
    print(i)
    exit()
# Judge status: Accepted
from collections import defaultdict
N,*A = map(int,open(0).read().split())
d = defaultdict(int) #初期値１
for a in A:
    d[a] ^= 1 #0と1を反転
print(sum(d.values()))
# Judge status: Wrong Answer
L, R = map(int, input().split())
l = L % 2019
if l + R - L >= 2019:
    ans = 0
else:
    ans = (l * (l + 1)) % 2019
print(ans)
# Judge status: Accepted
n, a = [int(input()) for _ in range(2)]

if n % 500 <= a:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
def main():
    MOD = 998244353
    N = int(input())
    D = list(map(int, input().split(' ')))
    max_d = max(D)
    counter = [0] * (max_d + 1)
    for d in D:
        counter[d] += 1
    if D[0] != 0 or counter[0] != 1:
        print(0)
        return
    ans = 1
    for d in range(1, max_d + 1):
        ans *= pow(counter[d - 1], counter[d], MOD)
        ans %= MOD
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
import bisect

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


a.sort()
b.sort()
c.sort()


result = 0
for i in range(n):
    b_bisect_in_a = bisect.bisect_left(a, b[i])
    b_bisect_in_c = bisect.bisect_right(c, b[i])
    result += b_bisect_in_a * (n - b_bisect_in_c)
        
        
print(result)
# Judge status: Accepted
n, q = map(int, input().split())
s = input()
a = [0 for i in range(n)]
ct = 0
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        ct += 1
    a[i] = ct

for i in range(q):
    l, r = map(int, input().split())
    if l == 1:
        print(a[r-2])
    else:
        print(a[r-2]-a[l-2])
# Judge status: Accepted
A, B = map(int, input().split())
S = input()
print('Yes' if len(S) == A + B + 1 and \
               S.count('-') == 1 and \
               S[A] == '-' else 'No')
# Judge status: Accepted
S, T = map(str, input().split())
print(T+S)
# Judge status: Wrong Answer
import math
a,b,x = map(int,input().split())
ku = math.degrees(math.atan(2*(b/a)-2*x/a**3))
if x >a*b/2:
  print(ku)
else:
  print(math.degrees(math.atan(a*b**2/(2*x))))
# Judge status: Wrong Answer
## C - Multiple Gift
import math
X, Y = map(int, input().split())
print( int(math.log2(Y / X )) + 1 )
# Judge status: Accepted
import math

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

print(A*B//math.gcd(A,B))
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
total=0
ans1=0
ans2=0
for i in a:
    total+=i
tmp1=total//n
tmp2=-(-total//n)
for i in a:
    ans1+=(i-tmp1)**2
for i in a:
    ans2+=(i-tmp2)**2
print(min(ans1,ans2))
# Judge status: Accepted
n, k = map(int, input().split())
p = list(map(int, input().split()))
p.sort()
cost=0
for t in range(k):
    cost+=p[t]
print(cost)
# Judge status: Wrong Answer
from itertools import product

N = int(input())
A = []
B = []
for _ in range(N):
    a, b = map(int, input().split())
    A.append(a), B.append(b)
A.sort()
B.sort()

print(B[N // 2] - A[N // 2] + 1)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

x, y = map(int, readline().split())
if x <= y:
    if (x >= 0 and y >= 0) or (x <= 0 and y <= 0):
        ans = y - x
    else:
        ans = abs(abs(x) - y) + 1
else:
    if (x >= 0 and y >= 0) or (x <= 0 and y <= 0):
        ans = min(abs(x) + abs(y) + 1, abs(abs(y) - abs(x)) + 2)
    else:
        ans = abs(x - abs(y)) + 1
print(ans)
# Judge status: Wrong Answer
(str_len,cng_cnt) = input().split(" ")
str_input = list(input())


cng_cnt= int(cng_cnt)
tmp1=""
cnt=0
cnt2=0
for st in str_input:
    if(tmp1 == st ):
      cnt = cnt+1
    else:
      cnt2= cnt2 + 1
      
    tmp1=st

if (cng_cnt > cnt2 ):
	c_up = cng_cnt * 2 
else:
	c_up= (cnt2 * 2) + (cng_cnt - cnt2)
ans =cnt + c_up

print(ans)
# Judge status: Accepted
s=list(input())

if len(s) == len(set(s)):
  answer = "yes"
else:
  answer = "no"

print(answer)
# Judge status: Accepted
N, *A = map(int, open(0).read().split())

x = [0] * (N + 1)
ans = []
for i in reversed(range(1, N + 1)):
    tmp = 0
    for j in range(i, N + 1, i):
        tmp += x[j]

    if tmp % 2 != A[i - 1]:
        x[i] += 1
        ans.append(i)

print(len(ans))
if ans:
    print(*ans)
# Judge status: Wrong Answer
N = input()
L = N.split()
a = int(L[0])
b = int(L[1])

if a < b:
    c = a
    a = b
    b = a

r = a % b
    
while r != 0:
    a = b
    b = r
    r = a % b

# この時のbが最大公約数

print(int(L[0])*int(L[1])/b)
# Judge status: Accepted
N = int(input())
cnt = 0

L = input().split()
L = [int(s) for s in L]

L.sort(reverse=True)

for i in range(len(L)-2):
    for j in range(i, len(L)-1):
        for k in range(j, len(L)):
            if L[i] < L[j] + L[k] and (L[i] != L[j] and L[i] != L[k] and L[j] != L[k]):
                # print(L[i] , L[j] , L[k])
                cnt += 1

print(cnt)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))


p = 0
res = 0

while p < N:
    while p + 1 < N and A[p] == A[p + 1]:
        p += 1
    if p + 1 < N and A[p] < A[p + 1]:
        while p + 1 < N and A[p] < A[p + 1]:
            p += 1
    elif p + 1 < N and A[p] > A[p + 1]:
        while p + 1 < N and A[p] > A[p + 1]:
            p += 1
    res += 1
    p += 1
print(res)
# Judge status: Accepted
import numpy as np
from copy import deepcopy


S = np.array([s for s in input()], str)
T = np.array([t for t in input()], str)
nS, nT = map(len, (S, T))
ans = ''
idx = []

if nS < nT:
    ans = 'UNRESTORABLE'
else:
    for i in range(nS - nT + 1):
        s = S[i:i + nT]
        if np.all((s == T) | (s == '?')):
            idx.append(i)

if not idx:
    ans = 'UNRESTORABLE'
else:
    i = idx[-1]
    S[i:i + nT] = T
    ans = np.where(S == '?', 'a', S)

print(''.join(ans))
# Judge status: Accepted
N,Q = map(int,input().split())
S = input()

t = [0]*(N+1)
for i in range(N):
    t[i+1] = t[i] + (S[i:i+2] == "AC")
    
for i in range(Q):
    l,r = map(int,input().split())
    print(t[r-1]-t[l-1])
# Judge status: Wrong Answer
A, B = (input().split())
print(B,A)
# Judge status: Accepted
#coding:utf-8
w, a, b = map(int, input().split())

if abs(a-b) <= w:
    print(0)
else:
    print(abs(a-b)-w)
# Judge status: Accepted
n, k = map(int, input().split())
print(1 + (n - 2) // (k - 1))
# Judge status: Accepted
A, B, C, D, K = list(map(int,input().split()))
a = 60 * A + B
b = 60 * C + D
c = b - a
ans = c - K
print(ans)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

N = int(input().strip())
pas_list = [int(input().strip()) for _ in range(5)]

count = (N // min(pas_list) + 1) -1+5
print(count)
# Judge status: Accepted
n, m = map(int, input().split())
c = [False for i in range(200000)]
d = [False for i in range(200000)]
for i in range(m):
	a, b = map(int, input().split())
	if a == 1:
		c[b] = True
	if b == n:
		d[a] = True
for i in range(200000):
	if c[i] and d[i]:
		print ("POSSIBLE")
		exit()
print ("IMPOSSIBLE")
# Judge status: Wrong Answer
S=input()
Sbara=list(S)
if Sbara[2]==Sbara[3] and Sbara[4]==Sbara[5]:
  print("yes")
else:
  print("no")
# Judge status: Accepted
S = input()

print('x'*len(S))
# Judge status: Accepted
N = list(input())
N = list(map(int, N))
N = [0] + N
n = len(N)

answer = 0
for i in range(n - 1, -1, -1):
    if N[i] == 10:
        N[i - 1] += 1
        continue
    if N[i] == 5 and N[i - 1] >= 5:
        N[i - 1] += 1
        answer += 5
    elif N[i] <= 5:
        answer += N[i]
    else:
        N[i - 1] += 1
        answer += 10 - N[i]

print(answer)
# Judge status: Accepted
N, P = map(int, input().split())
A = list(map(int, input().split()))

odd = 0
for a in A:
    if a % 2 != 0:
        odd += 1

if odd == 0:
    if P == 1:
        res = 0
    else:
        res = 2 ** N
else:
    res = 2 ** (N - 1)

print(res)
# Judge status: Accepted
import math

A, B, H, M = (int(x) for x in input().split())

H %= 12

deg = abs(H*30 - M*5.5)
if deg >= 180:
    deg = 360 - deg

rad = deg*math.pi / 180

print((A**2 + B**2 - 2*(A*B*math.cos(rad)))**0.5)
# Judge status: Accepted
a,b=map(int,input().split())
print(max([2*a-1,2*b-1,a+b]))
# Judge status: Accepted
n,m = map(int,input().split())
a = (n*(n-1))//2
b = (m*(m-1))//2
print(a+b)
# Judge status: Accepted
from math import ceil

n = int(input())

res = []
while n != 0:
    res.append(n % 2)
    n = ceil(n / -2)
if res == []:
    res.append(0)

print(''.join([str(i) for i in res[::-1]]))
# Judge status: Accepted
n = int(input())

pay = 800 * n
get = (n // 15) * 200

ans = pay - get

print(ans)
# Judge status: Accepted
import numpy as np
a, b, h, m = map(int, input().split())
m_v = 6
h_v = 0.5

time = h * 60 + m
h_pos = time * h_v
m_pos = m * m_v

rad = abs(min((min(h_pos, m_pos)+360)-max(h_pos, m_pos), max(h_pos, m_pos)- min(h_pos, m_pos)))
rad = rad / 180 * np.pi

ans = (a**2 + b**2 - 2*a*b*np.cos(rad))**0.5
print(ans)
# Judge status: Wrong Answer
s = list(input())
a = len(s)
b = len(set(s))
print('Yes') if a == b else print('No')
# Judge status: Accepted
X = input()
if X =='RRR':
    print('3')
elif X =='RRS' or X =='SRR':
    print('2')
elif X =='RSS' or X =='SRS' or X =='SSR' or X =='RSR':
    print('1')
elif X =='SSS':
    print('0')
# Judge status: Accepted
n,k=map(int,input().split())
cnt=0
lst=[]
for i in range(n):
  a,b=map(int,input().split())
  lst.append([a,b])
lst.sort(key=lambda x:x[0])
for j in range(n):
  cnt+=lst[j][1]
  if cnt>k-1:
    print(lst[j][0])
    break
# Judge status: Wrong Answer
n = int(input())
arr = list(map(int, input().split()))
t = 0
for i in set(arr):
    t += i
print(abs(n-t))
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split())) + [0]
ans = 0
for i in range(1, n + 1):
    if a[i] + a[i - 1] > x:
        ans += a[i] + a[i - 1] - x
        a[i] -= a[i] + a[i - 1] - x
print(ans)
# Judge status: Accepted
n = int(input())
#a = [list(map(int, input().split())) for _ in range(n)]
start = []
end = []
for i in range(n):
    a,b = map(int, input().split())
    start.append(a)
    end.append(b)
start.sort()
end.sort()
if (n%2==1):
    print(end[n//2]-start[n//2]+1)
else:
    s = start[n//2-1]+start[n//2]
    e = end[n//2-1]+end[n//2]
    print(e-s+1)
# Judge status: Wrong Answer
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[0:k+1]))
# Judge status: Wrong Answer
N = int(input())
cnt = 0
for i in range(1, N):
  if i * (1 + i) // 2 >= N:
    cnt = i
    break
for i in range(cnt, 0, -1):
  if i <= N:
    print(i)
    N -= i
# Judge status: Accepted
N,x=map(int,input().split())
a=list(map(int,input().split()))
ans=0
for i in range(N-1):
    ex=sum(a[i:i+2])-x
    if ex>0:
        ans+=ex
        if a[i+1]>=ex:
            a[i+1]-=ex
        else:
            a[i+1]=0
            a[i]-=ex-a[i+1]
print(ans)
# Judge status: Wrong Answer
import sys
input = sys.stdin.readline
K = int(input())
flag = 0
seven = 0
if K % 2 != 0:
  for i in range(10000):
    seven = seven * 10 + 7
    if seven % K == 0:
      ans = i + 1
      flag = 1
      break
else:
  flag = 2
if flag == 2:
  print(-1)
elif flag == 0:
  print(K-1)
else:
  print(ans)
# Judge status: Accepted
from fractions import gcd
N = int(input())
A = list(map(int,input().split()))

lc = [0]
for a in A:
    lc.append(gcd(lc[-1], a))
rc = [0]
for a in A[::-1]:
    rc.append(gcd(rc[-1], a))
rc.reverse()

ans = 0
for l,r in zip(lc,rc[1:]):
    g = gcd(l,r)
    ans = max(ans, g)
print(ans)
# Judge status: Wrong Answer
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

def main():
    from builtins import int, map
    N, K, S = map(int, input().split())
    # al + ... ar = SがちょうどK個
    # S S S S S 1 1 1 1 1 1みたいな感じでいい?
    ans = [S] * K + [S + 1] * (N - K)
    print(*ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n,k=map(int, input().split())
    l=[list(map(int,input().split())) for i in range(n)]
    l.sort(key=lambda x:x[0])
    kosu=0
    for i in range(n):
        kosu+=l[i][1]
        if kosu>=k:
            print(l[i][0])
            break
resolve()
# Judge status: Accepted
c = input()
print('vowel' if c in ['a', 'e', 'i', 'o', 'u'] else 'consonant')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
allSousa = sum(B)-sum(A)
atob = 0
for a, b in zip(A, B):
  if a < b:
    atob += (b-a)//2+(b-a)%2
if allSousa < atob:
  print("No")
else:
  print("Yes")
# Judge status: Accepted
N=int(input())
u=[]
v=[]
for i in range(N):
    x,y=map(int,input().split())
    u.append(x+y)
    v.append(x-y)
print(max(max(u)-min(u),max(v)-min(v)))
# Judge status: Accepted
a, b = map(int, input().split())

ans = 0
for i in range(a, b+1):
  s = str(i)
  judge = True
  for j in range(2):
    if s[j] != s[4-j]:
      judge = False
  if judge:
    ans += 1
    
print(ans)
# Judge status: Wrong Answer
from math import factorial
n=int(input())
A=list(map(int,input().split()))

a=max(A)
B=[]
for i in range(n):
    B.append(factorial(a)//((factorial(A[i])*factorial(a-A[i]))))

print(a,A[B.index(max(B))])
# Judge status: Wrong Answer
s=input()

flag=True

for i in range(1,len(s)-1):
    if s[i-1]==s[i]:
        flag=False

if flag:
    print("Good")
else:
    print("Bad")
# Judge status: Accepted
n=int(input())
a,b,c=2,1,3
for i in range(n):
    a,b,c=b,c,(b+c)
print(a)
# Judge status: Accepted
n,m =map(int, input().split())
ab =[]
for i in range(n):
    a,b =map(int, input().split())
    ab.append([a,b])
ab.sort()
sum =0
count =0
num =0
for i in range(n):
    price =ab[i][0]*ab[i][1]
    if ab[i][1] +count <= m:
        count +=ab[i][1]
        sum +=price
    else:
        num += m -count
        sum +=num*ab[i][0]
        break
print(sum)
# Judge status: Wrong Answer
n,m=map(int,input().split())
for i in range (1,m+1):
    a=i
    b=n-i
    print (a,b)
# Judge status: Accepted
import math
R = int(input())
print(math.pi*2*R)
# Judge status: Accepted


N_A, N_B, N_M = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
B = list(map(int,input().split(" ")))
M = [list(map(int,input().split(" "))) for i in range(N_M)]

candidates = [min(A)+min(B),]

for m in M:
    #print(A[m[0]-1] + B[m[1]-1] - m[2])
    candidates.append(A[m[0]-1] + B[m[1]-1] - m[2])

print(min(candidates))
# Judge status: Wrong Answer
N = int(input())

if N == 1:
  print(1)
  exit()

L = [0]*(N+1)
for i in range(2, N+1):
  L[i] = L[i-1] + L[i-2]

print(L[N])
# Judge status: Accepted
N = int(input())
 
if N % 2 > 0 or N < 10:
  print(0)
  exit()
else:
  #S = str(N)[::-1]
  ans = 0
  N = N // 10
  for i in range(50):
    ans += N
    N = N // 5
    
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())

if a >= 13:
    print(b)
elif 6 <= a <= 12:
    print(b//2)
else:
    print(0)
# Judge status: Accepted
n=int(input())
print((10**n-9**n-9**n+8**n)%(10**9+7))
# Judge status: Wrong Answer
N = int(input())
sp_list = []
sorted_list = []
for i in range(N):
  S,P = map(str, input().split(' '))
  sorted_list.append([S,P])
  sp_list.append(S + ' ' + P)
sorted_list = sorted(sorted_list, key=lambda x:(x[1]), reverse=True)
sorted_list = sorted(sorted_list, key=lambda x:(x[0]))
for i in range(N):
  count=1
  for j in range(N):
    if sp_list[i] == sorted_list[j][0]+' '+sorted_list[j][1]:
      print(count)
      break
    count+=1
# Judge status: Wrong Answer
n, k = map(int, input().split())
s = input()

if n == 1:
    print(0)
    exit()

two = 0
pre = s[0]
cont = 1
ans = 0
for c in s[1:]:
    if c != pre:
        if c == s[0]:
            two += 1
        ans += cont - 1
        cont = 1
        pre = c
    else:
        cont += 1
ans += cont - 1

if s[0] != s[1]:
    ans += 1
print(ans + 2 * min(k, two))
# Judge status: Wrong Answer
sx,sy,tx,ty = map(int,input().rstrip().split(" "))
dx = tx - sx
dy = ty-sy
ans = ""
ans += "R"*dx + "U" * dy
ans += "L" * dx + "D" * dy
ans += "D" + "R" * (dx + 1) + "U" * (dy + 1)
ans += "U" + "L" * (dx + 1) + "D" * (dy + 1)
print(ans)
# Judge status: Accepted
N=int(input())
D=list(map(int,input().split()))
MOD=998244353
goal=-1
tree=[0]*(N)
ans=1
for i in range(N):
    a=D[i]
    goal=max(a,goal)
    tree[a]+=1
if tree[0]==1 and D[0]==0:
    for i in range(1,goal+1):
        ans*=pow(tree[i-1],tree[i],MOD)
        ans%=MOD
    print(ans)
else:
    print(0)
# Judge status: Accepted
N, K = map(int, input().split())
S = input()
segs = []
prev = "x"
for c in S:
    if c != prev:
        segs.append([c])
    else:
        segs[-1].append(c)
    prev = c
ans = sum(len(seg) - 1 for seg in segs)
print(min(ans + 2 * K, N - 1))
# Judge status: Wrong Answer
n = int(input())
sum_i = 0
for i in range(n):
    i += 1
    # 足しても大丈夫なとき
    if n - (sum_i + i) >= i:
        sum_i += i
        print(i)
    else:
        print(n - sum_i)
        break
# Judge status: Accepted
n=int(input())
w=list(map(int,input().split()))
m=max(w)
for _ in range(n):
    m=min(m,abs(sum(w[:_])-sum(w[_:])))
print(m)
# Judge status: Accepted
n=int(input())
s=input()
ans=''
for t in s:
        ord_t=ord(t)
        ord_t+=n
        if(ord_t>ord('Z')):
                ord_t-=26
        ans+=chr(ord_t)
print(ans)
# Judge status: Accepted
a, b, c = map(int, input().split())

res1 = a+b+c
res2 = max(a, b, c)*3
if (res2-res1)%2==0:
  print((res2-res1)//2)
else:
  res3 = (max(a, b, c)+1)*3
  print((res3-res1)//2)
# Judge status: Wrong Answer
A = input()
B = input()
C = B[:len(B)-2]
if A == C:
  D = "Yes"
else:
  D = "No"
print(D)
# Judge status: Wrong Answer
n= int(input())

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

#print(a)

if a[0] != 0:
    print(-1)
    exit(0)

b=1
count=1
asum =sum(a)
alim = asum

for i in range(n-1):
    if a[i+1] > 2*b:
        print(-1)
        exit(0)
    else:
        alim = alim - a[i+1]
        b= min(2*b-a[i+1], alim)

        count += b



print(count+ asum)
# Judge status: Wrong Answer
N, M = map(int, input().split())
p = []
S = []
for _ in range(M):
    n, s = input().split()
    p.append(int(n))
    S.append(s)

wa = 0
ac = 0
ac_list = []
for i, s in enumerate(S):
    if p[i] not in ac_list:
        if s == "WA":
                wa += 1
        else:
                ac += 1
                ac_list.append(p[i])

print(ac, wa)
# Judge status: Accepted
a=input()
if a==a.upper():
    print("A")
else:
    print("a")
# Judge status: Accepted
N = int(input())
if N == 0:
    print("0")
else:
    ans = []
    p = 1
    while 2**(p-1) <= abs(N):
        if N%(2**p) > 0:
            ans.append("1")
            N -= (-2)**(p-1)
        else:
            ans.append("0")
        p += 1

    print("".join(ans[::-1]))
# Judge status: Accepted
N = int(input())
s = []
for i in range(N):
    s.append(sorted(input()))
s.sort()

ans = 0
tmp = 1
for i in range(N-1):
    if s[i] == s[i + 1]:
        tmp += 1
    else:
        ans += tmp * (tmp-1) // 2
        tmp = 1
ans += tmp * (tmp-1) // 2
print(ans)
# Judge status: Accepted

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

B = [0] * N
if N % 2 == 0:
  for i in range(N):
    if i % 2 == 0:
      B[N//2+i//2] = A[i]
    else:
      B[N//2-(i//2+1)] = A[i]
else:
  for i in range(N):
    if i % 2 == 1:
      B[N//2+(i//2+1)] = A[i]
    else:
      B[N//2-(i//2)] = A[i]

print(*B)
# Judge status: Accepted
_ = input()
S = input().lstrip('.').rstrip('#')
n = len(S)

x = 0
y = S.count('.')
c = min(n-y, y)
for i in range(n):
  if S[i] == '#':
    x += 1
  else:
    y -= 1
  c = min(c, x+y)
print(c)
# Judge status: Accepted
s = input()

if(len(s) <= 2):
    print(len(set(list(s))))
    exit()
dp = [0 for _ in range(len(s)+1)]
dp[0] = 0
dp[1] = 1
dp[2] = len(set(list(s[:2])))
for i in range(3,len(s)+1):
    if(s[i-1] != s[i-2]):dp[i] = dp[i-1] + 1
    else:dp[i] = dp[i-3] + 2
print(dp[-1])
# Judge status: Wrong Answer
a,b=map(int,input().split( ))
sum=a*500
if sum>=b:
  print("Yes")
else:
  print("NO")
exit()
# Judge status: Accepted
n,m=map(int,input().split())

if n*m==1 :
    ans=1
elif n==1 or m==1 :
    ans=max(n,m)-2
else:
    ans=(m-2)*(n-2)
print(ans)
# Judge status: Accepted
from collections import deque
n,m = map(int,input().split())
tuna = [[] for i in range(n+1)]
ans = [0 for i in range(n+1)]
for _ in range(m):
    a,b = map(int,input().split())
    tuna[a].append(b)
    tuna[b].append(a)
q = deque()
q.append(1)
while q:
    now = q.popleft()
    saki = tuna[now]
    for i in saki:
        if ans[i] == 0:
            q.append(i)
            ans[i] = now
print("Yes")
for i in range(2,n+1):
    print(ans[i])
# Judge status: Accepted
a, b = map(int, input().split())
if a < b:
    a, b = b, a
A = a
B = b
while a % b != 0:
    a, b = b, a % b
print((A*B)//b)
# Judge status: Accepted
abc=list(map(int , input().split()))
count=0
for i in range(0,len(abc)-1):
    abc.sort()
    if(abc[i] != abc[i+1]):
        count+=1
        
        
    
    
print(count+1)
# Judge status: Wrong Answer
D = int(input())

A = ["Chrinstmas"]

for i in range(25 - D):
  A.append("Eve")

S = ''.join(A)

print(S)
# Judge status: Accepted
def main():
    import sys
    def input():
        return sys.stdin.readline()[:-1]
    a=int(input())
    print(a+a**2+a**3)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, c, d = input()

if (a == b and c == d and a != c) or (a == c and b == d and a != b) or (a == d and b == c and a != b):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
import math
def lcm(x, y): # 最小公倍数
    return (x * y) // math.gcd(x, y)


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

lcm_cd = lcm(c, d)

under_b = b - b//c - b//d + b//lcm_cd
over_a = (a-1) - (a-1)//c - (a-1)//d + (a-1)//lcm_cd

print(under_b - over_a)
# Judge status: Wrong Answer
N = int(input())
W = [int(weight) for weight in input().split()]
sum_w = sum(W)
left_sum = 0
min = 10000
min_index = 0
for i in range(len(W)):
  left_sum += W[i]
  if abs(2*left_sum - sum_w) < min:
    min = abs(2*left_sum - sum_w)
    min_index = i
print(min_index)
# Judge status: Wrong Answer
from math import floor


def main():
    N, M = map(int, input().split(" "))
    A = list(map(int, input().split(" ")))
    A.sort(reverse=True)
    print(A)
    while M > 0:
        for i in range(0, N):
            if A[i] > 2 and M > 0:
                A[i] = floor(A[i] / 2)
                M -= 1
        print(A)
    print(sum(A))


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
w, a, b = map(int, input().split())
if a < b < a + w and a - w < b < a:
    print(0)
elif not a < b < a + w:
    print(b - a - w)
elif not a - w < b < a:
    print(a - b - w)
# Judge status: Accepted
#!/usr/bin/env python

n = int(input())

if n == 0:
    print(0)
    exit()

ans = ''
while abs(n) > 0:
    r = n%2 
    ans = str(r) + ans 
    
    if r == 1:
        n -= 1
    n //= (-2)

print(ans)
# Judge status: Wrong Answer
n = int(input());
s = input();
ans = []

for i in s:
    num = ord(i) + n;
    #正規化
    num = num - ord("a")
    num = num % 26 
    print(num)
    ans.append(chr(num  + ord("a")))

new = ""
for j in ans:
    new += j

print(new)
# Judge status: Wrong Answer
s = input()
s = sorted(s)
s = set(s)
alpha = 'a'
flg = 0
for i in range(1,26):
    if (alpha not in s):
        flg = 1
        break
    else : alpha = chr(ord(alpha)+1)
if (flg): print(alpha)
else: print("None")