peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def solve():
    N, M = map(int, input().split())
    if M<2*N:
        return M//2
    return N+(M-2*N)//4
print(solve())
# Judge status: Wrong Answer
import re
S = input()
print("YES" if re.match("(dream|dreamer|erase|eraser)", S) else "NO")
# Judge status: Accepted
n, a, b = map(int, input().strip().split())

if (b - a) % 2 == 1:
    dt1 = a - 1
    dt1 += 1
    b1 = b - dt1
    t1 = dt1 + (b1 - 1) // 2

    dt2 = n - b
    dt2 += 1
    a1 = a + dt2
    t2 = dt2 + (n - a1) // 2
    print(min(t1, t2))
else:
    print((b - a) // 2)
# Judge status: Accepted
import sys

def propare():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    r = int(next(tokens))

    solve(r)

def solve(r: int):
    print(int(r*r/1))
    return


 
if __name__ == "__main__":
    propare()
# Judge status: Accepted
n = int(input())
f = [int(input()) for _ in range(n)]
f = [0] + f
vis = [0] * (n + 1)
s , flag , ans = 1 , 0 , 0
vis[s] = 1
while f[s] != 2:
	if vis[f[s]] == 1:
		flag = 1
		break
	s = f[s]
	vis[s] = 1
	ans+=1

if (flag):
	print(-1)
else:
	print(ans+1)
# Judge status: Wrong Answer
x = int(input())
job = []
time = []
for i in range(x):
    j, t = list(map(int, input().split()))
    job.append(j)
    time.append(t)
jt = 0
tt = 0
f = 0
print(job, time)
for i in range(x):
    if job[i] <= time[i]:
        pass
    else:
        print("No")
        f = 1
        break
    jt += job[i]
    if tt < time[i]:
        tt = time[i]
    if jt > tt:
        f = 1
        print("No")
        break
if f == 0:
    print("Yes")
# Judge status: Accepted
#100b
D,N = map(int, input().split())

if D==0:
    if N!=100:
        print(N)
    else:
        print(1*(N+1))
elif D==1:
    if N!=100:
        print(100*N)
    else:
        print(100*(N+1))
elif D==2:
    if N!=100:
        print(10000*N)
    else:
        print(10000*(N+1))
# Judge status: Accepted
#!/usr/bin/env python3

import bisect

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

A = sorted(A)
B = sorted(B)
C = sorted(C)

res = 0
for b in B:
    index_a = bisect.bisect_left(A, b)
    index_c = bisect.bisect_right(C, b)
    res += index_a * (N - index_c)

print(res)
# Judge status: Accepted
def main():
    n = input()
    l = len(n)
    ans = 0
    p = 0

    for i in range(l-1, -1, -1):
        v = int(n[i])
        if p == 1:
            v += 1
        if v > 5 or (i != 0 and v == 5 and int(n[i-1]) >= 5):
            ans += (10-v)
            p = 1
        else:
            ans += v
            p = 0
    if p == 1:
        ans += 1

    print(ans)
main()
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))

if 0 in a:
    print(0)
    exit()
    
ans = 1
for i in range(n):
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)
# Judge status: Accepted
import math
def main():
  s = input()
  t = input()
  sx=sorted(s)
  tx=sorted(t,reverse=True)
  if sx<tx:
    print('Yes')
  else:
    print('No')
main()
# Judge status: Wrong Answer
a,b,c=[int(i) for i in input().split()]
if c in [(a*i)%b for i in range(b)]:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
import sys
N, K = map(int, input().split())
a = [0] * N
a = [list(map(int, input().split())) for _ in range(K*2)]
Sunuke = list(range(1,N+1))
#print(a)

for i,word in enumerate(a):
#	print("i",i,word)
	if (i % 2) == 1:
#		print(word)
		for j,check in enumerate(Sunuke):
			if check in word:
#				print(check,word,Sunuke)  
				Sunuke.remove(check)
print(len(Sunuke))
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
if a == b+c or b == a+c or c == a+c:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())

C = 4
D = 7
value = 0
ans = "No"

for i in range(100):
    for j in range(100):
        value = C * i + D * j
        if value == N:
            ans = "Yes"
            break

print(ans)
# Judge status: Wrong Answer
def a(D,T,S):
  a=D/S
  if a<=T:
    return Yes
  else:
    return No
# Judge status: Wrong Answer
a,b=map(int,input().split())
print('Possible') if a+b>=3 or a%3==0 or b%3==0 else print('Impossible')
# Judge status: Accepted
n, m = map(int, input().split())
d = {}
cnt_ac = 0
cnt_wa = 0
for _ in range(m):
    p, s = input().split()
    if p not in d:
        d[p] = [s]
    else:
        d[p].append(s)
for i in d:
    if 'AC' in d[i]:
        cnt_ac += 1
        cnt_wa += d[i].index('AC')
print(cnt_ac, cnt_wa)
# Judge status: Wrong Answer
def main():
    a, b = map(int, input().split())
    a = min(a, b)
    b = max(a, b)

    d = gcd(a, b)
    d1 = a / d
    d2 = b / d
    print(int(d * d1 * d2))


def gcd(a, b):
    while b > 0:
        tmp = a % b
        a = b
        b = tmp
    return a


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
N = int(input())
X = list(map(int, input().split()))

S = sorted(X)
print(S)

for i in range(N):
  if X[i] <= S[N//2 - 1]:
    print(S[N//2])
  else:
    print(S[N//2 -1])
# Judge status: Accepted
import sys

s = input()
t = input()
lenS = len(s)
lenT = len(t)
for i in range(lenS-lenT,-1,-1):
  sub = s[i:i+lenT]
  for j in range(lenT):
    if sub[j]!="?" and sub[j]!=t[j]:
      break
  else:
    s=s.replace("?","a")
    print(s[:i]+t+s[i+lenT:])
    sys.exit()
  continue
  
print('UNRESTORABLE')
# Judge status: Accepted
class Solution(object):
	def is_hitachi_string(self, string):

		if len(string) == 0:
			print 'No'
			return

		hi_str = 'hi'
		hi_idx = 0
		for idx in xrange(len(string)):
			if idx > 9:
				print 'No'
				return

			if string[idx] != hi_str[hi_idx]:
				print 'No'
				return

			hi_idx = (hi_idx + 1) % 2

		if hi_idx == 0:
			print 'Yes'
		else:
			print 'No'

if __name__ == '__main__':
	sol = Solution()
	string = raw_input()
	sol.is_hitachi_string(string)
# Judge status: Wrong Answer
N=int(input())
S=input()

r,g,b=[],[],[]
for i in range(N):
  s = S[i]
  if s=='R':r.append(i)
  elif s=='G':g.append(i)
  else:b.append(i)

count = 0
for i in r:
  for j in g:
    x,y,z = i+j, (i+j)/2, min(i,j)-abs(i-j)
    c = 0
    if x in b:c+=1
    if y in b:c+=1
    if z in b:c+=1
    count += len(b)-c
print(count)
# Judge status: Accepted
S1=input()
S2=input()
ans=1
for i in range(3):
  if S1[i]!=S2[2-i]:
    ans=ans*0
print(["NO","YES"][ans])
# Judge status: Accepted
s = input()
t = input()

for i in range(len(s)):
  s = s[-1] + s[:-1]
  if s==t:
    print("Yes")
    exit()
print("No")
# Judge status: Accepted
n,k=map(int,input().split())
D = list(map(str,input().split()))
x = n
while True:
  y = str(x)
  for i in range(len(y)):
    if y[i] in D:
      break
  else:
    ans = x
    break
  x += 1
print(ans)
# Judge status: Wrong Answer
o = list(input())
e = list(input())

lst = []
for oo,ee in zip(o,e):
    lst.append(oo+ee)

print("".join(lst))
# Judge status: Wrong Answer
s,t=input().split()
a,b=map(int,input().split())
u=input()
if s==u:
    print(a-1)
else:
    print(b-1)
# Judge status: Accepted
s = input()

if s[1] == 'B':
  print('ARC')
else:
  print('ABC')
# Judge status: Accepted
n,m = map(int,input().split())
h = list(map(int, input().split()))
ab = [0]* m
box = [1] * n
for i in range(m):
    ab[i] = list(map(int,input().split()))
    if h[ab[i][0]-1] == h[ab[i][1]-1]:
        box[ab[i][0]-1] = 0
        box[ab[i][1] - 1] = 0
    elif h[ab[i][0]-1] > h[ab[i][1]-1]:
        box[ab[i][1] - 1] = 0
    else:
        box[ab[i][0] - 1] = 0
print(sum(box))
# Judge status: Wrong Answer
s=input()
if s[-1]=='s':
	print(s[:len(s)-1]+'es')
else:
	print(s+'s')
# Judge status: Wrong Answer
N, X, Y = map(int, input().split())
distance = []
N += 1
XYdist = Y - X - 1

for i in range(2, N) :
  for j in range(1, i) :
    if i >= Y and j <= X :
      distance.append(i - j - XYdist)
    else :
      distance.append(i - j)
      
for i in range(1, N - 1) :
  print(distance.count(i))
# Judge status: Accepted
s=input()
if('7' in s):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
k = int(input())
x = int(input())
y = int(input())

if n<=k:
    ans = x*n
else:
    ans = x*k + y*(n-k)

print(ans)
# Judge status: Accepted
n, k = map(int, input().split())
d = list(input().split())
#n = 1000
flag = True
while flag:
    flag2 = True
    for si in str(n):
        if si in d:
            n += 1
            flag2 = False
            break
    if flag2:
        break
    else:
        flag = True
            
print(n)
# Judge status: Wrong Answer
a,b = map(int, input().split())
print("Even" if a*b%2 == 0 else "No")
# Judge status: Accepted
def main():
    N = int(input())
    *a, = map(int, input().split())

    d = [0] * (N + 1)
    for x in a:
        d[x] += 1

    b = 0
    for x in d:
        b += x * (x - 1) // 2

    for x in a:
        t = b - (d[x] - 1)

        print(t)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())
# Judge status: Accepted
n,k = map(int,input().split())
s = input()
edge,inside,cnt,ix = 0,0,0,0
if s[0]=='R' or s[-1]=='R':
  edge += 1
temp = ''
for i in range(n):
  if temp=='R' and s[i]=='L':
    inside += 1
  elif temp==s[i]:
    cnt += 1
  temp = s[i]
if inside>=k:
  print(min(k*2+cnt,n-1))
else:
  print(min(inside*2+edge+cnt,n-1))
# Judge status: Accepted
tmp = input().split(" ")
age = int(tmp[0])
fee = int(tmp[1])

if age >= 13:
  print(fee)
elif age >= 6:
  print(int(fee/2))
else:
  print(0)
# Judge status: Accepted
n = input()
A = []
sum = 0
for i in n:
    A.append(i)
    sum += int(i)

if A[0] == '1':
    print(max(sum, (len(A) - 1) * 9))
else:
    print(max(sum, (len(A) - 1) * 9 + int(A[0]) - 1))
# Judge status: Wrong Answer
n,k = map(int,input().split())
l = []
for i in range(1,n):
  if n > 0:
    n = n // k
    l.append(n)
  else:
    break
print(len(l))
# Judge status: Accepted
s = input()
print("AC" if 'C' in s[2:-1] and 'A' in s and s[1:].replace('C', '', 1).islower() else "WA")
# Judge status: Wrong Answer
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())
cnt = 0
for i in range(1, n+1):
    if i%2==0:
        continue
    elif sum(make_divisors(i))==8:
        cnt = cnt + 1
print(cnt)
# Judge status: Accepted
k,x = map(int,input().split())
st = x-k+1
en = x+k

print(*list(range(st,en)))
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
mod = 10 ** 9 + 7
ans = 0
x = 1
for bit in range(60):
    b = 0
    for i, aa in enumerate(a):
        if aa % 2:
            b += 1
        a[i] //= 2
    ans += (x * b * (n - b)) % mod
    ans %= mod
    x *= 2
    x %= mod
print(ans)
# Judge status: Accepted
n = int(input())
s = input()

nopen = 0
sl = ''
sr = ''

for c in s:
    if c == '(':
        nopen += 1
    else:
        if nopen == 0:
            sl += '('
        else:
            nopen -= 1

nopen = sum([1 if c == '(' else -1 for c in sl + s])
sr = ')' * nopen


print(sl + s + sr)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

box = [0] * (N+1)
ans = []
for i in range(N,0,-1):
  work = 0
  for j in range(0,N+1,i):
    work += box[j]
    #print(i,j)
  if work % 2 != A[i-1]:
    box[i] = 1
    ans.append(i)

print(len(ans))
if len(ans) > 0:
  print(" ".join(list(map(str, ans))))
# Judge status: Wrong Answer
N = int(input())
i = list(map(int, input().split()))

min = i[0]
count = 1

for n in range(N-1):
    if min > i[n]:
        min = i[n]
        count +=1
    else: pass

print(count)
# Judge status: Wrong Answer
n = int(input())
a = [int(x) for x in input().split()]
d=0
while True:
    c=0
    for i in range(n):
        if a[i]%2==0:
            a[i]=a[i]/2
            c+=1
    if c==0:
        break
    else:
        d+=1
print(d)
# Judge status: Accepted
K,N= map(int,input().split())
A= list(map(int,input().split()))
A = A + [A[0]+K]
diff = [b-a for a,b in zip(A,A[1:])]
mA = max(diff)
print(K-mA)
# Judge status: Accepted
N, M = map(int,input().split())

if N*2 > M:
  print(M//2)
else:
  print(N + (M-N*2)//4)
# Judge status: Accepted
n = int(input())

sp = []
for i in range(1,n+1):
    s,p = input().split()
    sp.append([s,int(p),i])

sp.sort(reverse = True,key = lambda x:x[1])
sp.sort(key = lambda x:x[0])

for i in range(n):
    print(sp[i][2])
# Judge status: Accepted
n, k = map(int, input().split())

ans = 0
for i in range(1, n+1):
    p = 1 / n
    point = i
    while True:
        if point >= k:
            break
        else:
            point *= 2
            p *= 0.5
    ans += p
print(ans)
# Judge status: Accepted
S = input()

ans = []

for i in range(len(S)):
    if i == 3:
        ans.append('8')
    else:
        ans.append(S[i])
        
print(''.join(ans))
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split(" ")))
for a in A:
    if a%2 == 0:
        if a%3 != 0 and a%5 != 0:
            print('DENIED')
            exit()
print('APPROVED')
# Judge status: Accepted
from decimal import Decimal

x = int(input())
cnt = 0

while True:
    a = cnt ** 5
    if a < x:
        a = x - a
        z = -1
    else:
        a -= x
        z = 1

    a = Decimal(a) ** Decimal("0.2")
    if a % 1 == 0:
        print(cnt, int(a * z))
        break

    cnt += 1
# Judge status: Wrong Answer
i = list(map(int, input().split()))
ans=0

if i[0]<i[1]:
    for n in range(i[1]):
        ans += i[0]*10**n
        print(ans)

else:
    for n in range(i[0]):
        ans += i[1]*10**n
        print(ans)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
S = sorted(A, reverse=True)
X = S[0]
N -= 2
i = 0
while N > 0:
    i += 1
    x = S[i]
    X += x
    if N == 1:
        break
    X += x
    N -= 2
print(X)
# Judge status: Accepted
n = int(input())
c = input()

#右端から見ていって初めのRが出たらWとRをカウントする
cnt = 0
R = 0
W = 0

for i in range(n):
    if c[i] == "R":R += 1
    else:W += 1

for i in range(R):
    if c[i] == "W":cnt += 1
print(cnt)
# Judge status: Accepted
x=input()
b=x[0]
for i in x[1:]:
  if b==i:
    print("Bad")
    break
  b=i
else:
  print("Good")
# Judge status: Wrong Answer
def main():
    A = list(map(int, input().split()))

    diff = 0
    print(A)
    for i in range(len(A)):
        diff += max(A)-A[i]
    if diff%2 == 0:
        print(diff//2)
    else:
        print(diff//2+2)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n,W=map(int,input().split())
dp=[0]*(W+1)
for _ in range(n):
	w,v=map(int,input().split())
	for j in range(W-w+1):
		dp[j+w]=max(dp[j+w],dp[j]+v)
print(dp[W])
# Judge status: Wrong Answer
N = int(input())
A = [int(x) for x in input().split()]

cnt = 0
flg_2 = 0
for a in A:
    if a % 4 == 0:
        cnt += 1
    elif a == 2:
        flg_2 += 1
if flg_2 >= 2:
    N -= flg_2 - 1
# if cnt >= N//2:
if cnt >= ((N-1)/2):
    ans = 'Yes'
else:
    ans = 'No'
print(ans)
# Judge status: Accepted
N, R= map(int, input().split())

if N <= 10:
    print(R+(100*(10-N)))
else:
    print(R)
# Judge status: Wrong Answer
N, K = list(map(int, input().split()))


def x(N, K):
    y = (N)
    f = 0
    while True:
        N = abs(N - K)

        if y > N:
            y = N

        if y == N:
            f += 1

        if f > 2:
            return y


# if K == 0:
#     print(N)
# elif K == 1:
#     print(0)
# else:
#     print(x(N, K))
print(x(N, K))
# Judge status: Accepted
n, k = map(int, input().split())
s = input() + "#"
group = 0
count = 0
for i in range(n):
  if s[i] == s[i+1]:
    count += 1
  else:
    group += 1
if k >= group//2:
  print(n-1)
else:
  print(count + 2*k)
# Judge status: Accepted
from fractions import gcd
a,b=map(int,input().split())
num=gcd(a,b)
l=[1]
while num!=1:
    x=int(num**(1/2))
    for i in range(2,x+2):
        if num%i==0:
            num=num//i
            l.append(i)
            break
        elif i==x+1:
            l.append(num)
            num=1
            break
print(len(set(l)))
# Judge status: Accepted
from collections import defaultdict
dict=defaultdict(lambda:0)
n=int(input())

for x in range(1,100):
    for y in range(1, 100):
        for z in range(1,100):
            p=(x+y+z)**2-(x*y+y*z+z*x)
            dict[p]+=1

for i in range(1,n+1):
    print(dict[i])
# Judge status: Accepted
n,y=map(int,input().split())
flag=True
for i in range(n+1):
    if flag:
        for j in range(n-i+1):
            k=n-i-j
            if 10000*i+5000*j+1000*k==y:
                print('{} {} {}'.format(i,j,k))
                flag=False
                break
    else:
        break
if flag:
    print('-1 -1 -1')
# Judge status: Wrong Answer
n,k = map(int,input().split())

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

id_one = lst.index(1)
left_length = len(lst[0:id_one])
#print(left_length)
right_length = len(lst[id_one:])-1
#print(right_length)

counter = 0
mn = min(left_length,right_length)
mx = max(left_length,right_length)

mx -= mn % (k-1)

while mn > 0:
    counter += 1
    mn -= k-1

mx -= mn % (k-1)

while mx > 0:
    counter += 1
    mx -= k-1




print(counter)
# Judge status: Accepted
import sys
X, Y = map(int, input().split())

for i in range(X+1):
    if Y == i*2 + (X-i)*4:
        print('Yes')
        sys.exit()
print('No')
# Judge status: Accepted
k, x = map(int, input().split())

if 500*k >= x:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
b = [i * j for i in range(1,10) for j in range(1,10)]
print("Yes" if n in b else "No")
# Judge status: Wrong Answer
N,X = map(int,input().split())
W = list(map(int,input().split())) + [X]
W = sorted(W)
dist = 10**18
if len(W) == 2:
  print(W[1]-W[0])
  exit()
for i in range(1,N):
  dist = min(dist, W[i]-W[i-1])
for j in range(1,N):
  if (W[i]-W[i-1])%dist != 0:
    dist -= 1
print(dist)
# Judge status: Wrong Answer
def main():
    n = int(input())
    s = list(input())
    if n % 2 != 0:
        print("No")
    else:
        div = n // 2
        if s[:div-1] == s[div:n-1]:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
x = input()
num = [0]
for i in x:
    if i == "S":
        num.append(num[-1] - 1)
    else:
        num.append(num[-1] + 1)
print(max(max(num), 0) * 2)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split())) 
ans = 0
for i in range(N-1):
    for j in range(i+1, N):
        if A[i] + A[j] == abs(i-j):
            ans += 1
            print("OK",end="")
print(ans)
# Judge status: Accepted
a =int(input())
d = 25-a
print('Christmas' + ' Eve'*d)
# Judge status: Accepted
n, a, b, c, d = map(int, input().split())
s = input()
if ("##" in s[min(a, b): max(c, d)]) or (d < c and "..." not in s[b-2: d+1]):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n=int(input())
robot=[]
for i in range(n):
	x,l=map(int,input().split())
	robot.append([x,l])
robot.sort()
ans=1
for i in range(n-1):
	if robot[i][0]+robot[i][1]>robot[i+1][0]-robot[i+1][1]:
		if robot[i][0]+robot[i][1]<robot[i+1][0]+robot[i+1][1]:
			robot[i+1]=robot[i]
	else:
		ans+=1
print(ans)
# Judge status: Accepted
MOD = 10 ** 9 + 7
def choose(n,r):
  num = 1
  den = 1
  for i in range(r):
    num *= n-i
    num %= MOD
  for i in range(r):
    den *= i+1
    den %= MOD
  return num * pow(den, MOD-2, MOD) % MOD
def solve(x,y):
  if (x+y)%3!=0:
    return 0
  k = (x+y)//3
  if x<k or y<k:
    return 0
  return choose(k, min(y-k, x-k))
print(solve(*map(int, input().split())))
# Judge status: Accepted
a,b,c = map(int,input().split())

print(a * b // 2)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
temp=[0]*n
for i in range(n):
  if a[i]%4==0:
    temp[i]=2
  elif a[i]%2==0:
    temp[i]=1
if n%2!=0 and sum(temp)>=n-1:
  print("Yes")
elif sum(temp)>=n:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
from itertools import accumulate 
n,q = map(int,input().split())
s = input()
l = [list(map(int,input().split())) for _ in range (q)]
flg =[]
for i in range(n-1):
  if s[i:i+2]=="AC":
    flg.append(1)
  else:
    flg.append(0)
flg2 = [0]+flg
flg2 = list(accumulate(flg2))
for i in l:
  print(flg2[i[1]-1]-flg2[i[0]-1])
# Judge status: Accepted
a, b = map(int, input().split())
if a <= 0 and b >= 0:
    print("Zero")
elif a>0:
    print("Positive")
else:
    if abs(b-a)%2 == 0:
        print("Negative")
    else:
        print("Positive")
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))

rate=[0]*9
ansmin=0
ansmax=0
a.sort()
over=0

for i in a:
  for j in range(1,9):
    if 400*(j-1) <= i <= 400*j-1:
      rate[j]=1
      break
    elif i >= 3200:
      over+=1
      break

ansmin = rate.count(1)
ansmax = rate.count(1)

if over != 0:
  if ansmax + over >= 8:
    ansmax = 8
  else:
    ansmax = ansmax + over
#print(rate)
print(ansmin, ansmax)
# Judge status: Accepted
# ABC138C

n = int(input())
v = list(map(int, input().split()))
v = sorted(v)
ans = (v[0] + v[1]) / 2
for i in range(2, len(v)):
    ans = (ans + v[i]) / 2
print(ans)
# Judge status: Accepted
N = int(input())
 
def base(x, n):
  ret = []
  while x != 0:
    ret.append( x % abs(n))
    if n < 0:
      x = - ( (-x)//n )
    else:
      x //= n
  return ret
 
if N == 0:
  print(0)
else:
  print("".join(map(str, reversed(base(N, -2)))))
# Judge status: Accepted
N = int(input())
count = 0
for i in range(1,N+1):
    if int(len(str(i))) % 2 == 1:
        count += 1
print(count)
# Judge status: Wrong Answer
# zentansaku
S = input()
T = input()
Ns = len(S)
Nt = len(T)

cand = []

N = max(0, Ns - Nt + 1)
for i in range(N):
    for j in range(Nt):
        s = S[i + j]
        t = T[j]
        if s == t or s == "?":
            continue
        else:
            break
    else:
        pre = S[:i].replace("?", "a")
        cand.append(pre + T)

if not cand:
    print("UNRESTORABLE")
else:
    cand.sort()
    print(cand[0])
# Judge status: Wrong Answer
N, H = map(int, input().split())

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

B.sort(reverse=True)

res = 0
for b in B:
    if b > Amax:
        if H < b:
            print(res)
            exit()
        H -= b
        res += 1
    else:
        break

print(res + (H // Amax + int(H % Amax != 0)))
# Judge status: Accepted
i = 1
d = 100
n = int(input())

if n == 100:
    print(0)
else:
    while True:
        d = int(d * 1.01)
        if n <= d:
            break
        i = i + 1
    print(i)
# Judge status: Wrong Answer
n,s = map(int, input().split())

for x in range(n):
    if x > 2000:
        break
    for y in range(n):
        if y > 2000:
            break
        tmp = n-x-y
        if (x*10000+y*5000+tmp*1000) == s and 0<=tmp<=2000:
            print('{} {} {}'.format(x,y,tmp))
            exit(0)

print('-1 -1 -1')
# Judge status: Accepted
A,B,C = map(int,input().split())

if (A%2)*(B%2)*(C%2)==0:
    print(0)
else:
    print(min(A*B,B*C,C*A))
# Judge status: Accepted
n=int(input())
l=[]
for _ in range(n-1):
  c,s,f=map(int,input().split())
  for i,t in enumerate(l):
    if t>s: t=-(-t//f)*f
    else: t=s
    l[i]=t+c
  l+=[s+c]
for i in l+[0]:
  print(i)
# Judge status: Accepted
l = [1, 2, 3]
for i in range(2): l.remove(int(input()))
print(l[0])
# Judge status: Accepted
A,B,K=map(int,input().split())
if A<K:
    K=K-A
    A=0
else:
    A=A-K
    K=0
if K!=0:
    if K>B:
        B=0
    else:
        B=B-K
print(A,B)
# Judge status: Accepted
ans = [1, 2, 3]
ans.remove(int(input()))
ans.remove(int(input()))
print(ans[0])
# Judge status: Wrong Answer
import fractions
a, b = map(int, input().split())


def lcm(x, y):
    return x*y/fractions.gcd(x, y)


print(lcm(a, b))
# Judge status: Accepted
def INT():
    return int(input())

def MI():
    return map(int, input().split())

def LI():
    return list(map(int, input().split()))

from collections import deque
n = INT()
a = LI()
b = deque()

for i in range(n):
    if i % 2 == 0:
        b.append(a[i])
    else:
        b.appendleft(a[i])
        
if (-1)**n == -1:
    b.reverse()
    
print(*b)