peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
from collections import Counter

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

c = Counter(tree)
if tree[0] != 0 or c[0] != 1:
    print(0)
else:
    ans = 1
    a = c[0]
    for i in range( 1,len(c)):
        t = c[i]
        if t == 0:
            print(0)
            exit()
        else:
            ans *= ( a**t )
            a = t
    print(ans%998244353)
# Judge status: Accepted
import sys
def I(): return int(sys.stdin.readline().rstrip())

X = I()
q,r = X//100,X%100
if q*5 >= r:
    print(1)
else:
    print(0)
# Judge status: Wrong Answer
N,M=map(int,input().split())
A=[list(map(int,input().split())) for i in range(N)]
A=sorted(A,key=lambda x:x[1])
cost=0
num=0
for i in range(N):
    if num+A[i][1]>M:
        print(cost+A[i][0]*(M-num))
        break
    else:
        cost+=A[i][0]*A[i][1]
        num+=A[i][1]
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    n, m = map(int, input().split())

    dp = [[] for _ in range(n)]
    ans = [0] * m

    for i in range(m):
        p, y = map(int, input().split())
        dp[p - 1].append((y, i))
    
    for j, k in enumerate(dp):
        k.sort()    
        for l, (s, t) in enumerate(k):
            ans[t] = str(j + 1).zfill(6) + str(l + 1).zfill(6)
    
    print(*ans, sep = "\n")


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
def main():
    S=int(input())

    mod=10**9+7
    all=pow(2,S-1)
    for i in range(S-2,S-5,-1):
        all=all-pow(2,i)
    all-=S
    print(all)
    
if __name__=="__main__":
    main()
# Judge status: Accepted
import sys

c = [list(map(int, input().split())) for _ in range(3)]
if c[0][0] - c[0][1] == c[1][0] - c[1][1] == c[2][0] - c[2][1]:
  if c[0][1] - c[0][2] == c[1][1] - c[1][2] == c[2][1] - c[2][2]:
    if c[0][0] - c[1][0] == c[0][1] - c[1][1] == c[0][2] - c[1][2]:
      if c[1][0] - c[2][0] == c[1][1] - c[2][1] == c[1][2] - c[2][2]:
        print("Yes")
        sys.exit()
print("No")
# Judge status: Accepted
x,y,z = list(map(int,input().split()))
print(z,x,y)
# Judge status: Accepted
import statistics  
N = int(input())
A=list(map(int, input().split()))
B=[]
for number, i in enumerate(A, 1):
    B.append(i-number)
median = int(statistics.median(B))
ans2 = 0
for i in B:
    ans2 += abs(i-median)
print(ans2)
# Judge status: Accepted
a,b,c,d=input()
print('Yes' if a==b==c or b==c==d else 'No')
# Judge status: Accepted
MOD = 10**9 + 7
S = int(input())
dpt = [[0 for i in range(S+1)] for i in range(S//3+1)]

for i in range(3, S+1):
    dpt[1][i] = 1

for i in range(2, S//3+1):
    s = 0
    for j in range(3*i, S+1):
        s += dpt[i-1][j-3]
        dpt[i][j] = s % MOD
print(sum([dpt[i][S] for i in range(S//3+1)])%MOD)
# Judge status: Wrong Answer
n = int(input())
s = []
for i in range(n):
  s.append(i)

for i in range(n):
  t = 0
  if(s[i] != i + 1):
    t += 1
    if(t <= 2):
      print('Yes')
    else:
      print('No')
# Judge status: Accepted
import math
h,w=map(int,input().split())
if h==1 or w==1:print(1)
elif h%2==0:print(w*(h//2))
else:print(w*(h//2)+math.ceil(w/2))
# Judge status: Accepted
n = int(input())
p = [int(_) for _ in input().split()]

dif = sum(idx != pp for idx, pp in enumerate(p, 1))  # 1からidx
if dif <= 2:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
a, b, c, d =map(int, input().split())

print(max(a*c,a*d,b*c,b*d))
# Judge status: Accepted
N,M=map(int,input().split())
X=list(map(int,input().split()))

if N>=M:
  print(0)
  exit()

X = sorted(X)

diff=[]
for i in range(1,M):
  diff.append(X[i]-X[i-1])

diff = sorted(diff)
print(sum(diff[:M-N]))
# Judge status: Wrong Answer
n,k=map(int,input().split())
s=0
l=list(map(int,input().split()))
c=0
for i in range(n):
    s+=l[i]
    if(k<s):
        break
    c+=1
print(c)
# Judge status: Accepted
N, M = sorted(map(int, input().split()))
print(abs((N - 2) * (M - 2)))
# Judge status: Accepted
x, n = map(int,input().split())
P = list(map(int,input().split()))
Q = []
ans = 100
for i in range(-100,101):
    if i+1 in P:continue
    else:
        Q.append(i+1)
for j in Q:
    d = abs(j - x)
    ans = min(d, ans)

l = x -ans
m = x + ans
if l in Q:
    print(l)
else:
    print(m)
# Judge status: Wrong Answer
x = int(input())

if x == 1:
    print(1)
else:
    cur = 0
    for i in range(0, 44720):
        cur += i
        if x > cur and x <= cur + i + 1:
            print(i+1)
            break
# Judge status: Accepted
from collections import Counter
s = list(input())
t = list(input())

sc = Counter(s)
tc = Counter(t)

sc_l = sorted(sc.values())
tc_l = sorted(tc.values())

if sc_l == tc_l:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
LEFT = A[0]
RIGHT = sum(A[1:])
MIN = abs(LEFT-RIGHT)
for i in range(1,N-1):
    LEFT += A[i]
    RIGHT -= A[i]
    MIN = min(MIN,abs(LEFT-RIGHT))
print(MIN)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
if a>=b:
    x=a
elif a<b:
    x=b
if c>=d:
    y=c
elif d>c:
    y=d
print(x*y)
# Judge status: Wrong Answer
N = int(input())
total = 0
for i in range(1, N + 1):
    if i % 3 != 0 and i % 5 != 0:
        total += i
print(total)
# Judge status: Accepted
n = int(input())
V = list(map(int, input().strip().split()))

V.sort()
out = V[0]
for i in range(n - 1):
    j = i + 1
    out = (out + V[j]) / 2
print(out)
# Judge status: Accepted
# 20200610_yorukatsu_b.py
N = int(input())
A = []
B = []
for i in  range(N):
    a,b = map(int,input().split())
    A.append(a)
    B.append(b)

push = 0
for i in range(N):
    if (A[N-i-1] + push) % B[N-i-1] != 0:
        push += abs(B[N-i-1] - ((push + A[N-i-1]) % B[N-i-1]))
print(push)
# Judge status: Accepted
N = int(input())

print("Christmas" + " Eve" *(25-N))
# Judge status: Accepted
n,k = map(int,input().split())
A = input()

ans = 1 + -(-(n-k)//(k-1))

print(ans)
# Judge status: Accepted
a,b=map(int,input().split());print((b-a)*(b-a+1)//2-b)
# Judge status: Accepted
def resolve():
    n = int(input())
    d1 = {}
    d2 = {}

    for i in range(n):
        x, y = map(int, input().split())
        if x+y not in d1:
            d1[x+y] = 1
        if x-y not in d2:
            d2[x-y] = 1
    d1key = d1.keys()
    d1key = sorted(d1key)
    d2key = d2.keys()
    d2key = sorted(d2key)
    print(max(abs(d1key[0]-d1key[-1]), abs(d2key[0]-d2key[-1])))
resolve()
# Judge status: Accepted
import sys
readline = sys.stdin.readline

def main():
    N, M = map(int, readline().rstrip().split())
    X = list(map(int, readline().rstrip().split()))

    if N >= M:
        print(0)
        return

    X.sort()
    X = [abs(X[i+1]-X[i]) for i in range(M-1)]
    X.sort()
    ans = sum(X)
    for i in range(N-1):
        ans -= X[-i-1]
    
    print(ans)


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

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

Nagasa = len(L)

print(math.ceil((Nagasa-1)/(K-1)))
# Judge status: Accepted
x = int(input())
y = x + 100
is_prime = [False] * 2 + [True for _ in range(2, y+1)]
prime = []
for i in range(2, y+1):
	for j in range(i*2, y+1, i):
		is_prime[j] = False
for i in range(y+1):
	if is_prime[i]:
		prime.append(i)
for i in range(len(prime)):
  if prime[i] >= x:
    print(prime[i])
    break
  else:
    continue
# Judge status: Accepted
import math

a,b,x=map(int,input().split())
tan=0

if 2*x>=b*(a**2):
    tan=(2*(a**2)*b-2*x)/(a**3)
else:
    tan=a*(b**2)/(2*x)

print(math.degrees(math.atan(tan)))
# Judge status: Accepted
from itertools import permutations
from math import factorial as fact
N = int(input())
towns = [list(map(int, input().split())) for _ in range(N)]
acc = 0
for p in permutations(range(N), N):
    for i in range(N - 1):
        t1, t2 = towns[p[i]], towns[p[i + 1]]
        acc += ((t1[0] - t2[0]) ** 2 + (t1[1] - t2[1]) ** 2) ** .5
print(acc / fact(N))
# Judge status: Wrong Answer
N, M = map(int, input().split())
A = list(map(int, input().split()))
print(N-(sum(A)))
# Judge status: Accepted
inp = (input().split())

if inp.count('5') == 2 and inp.count('7') == 1:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N, X = map(int, input().split())
L = [int(l) for l in input().split()]
if sum(L) <= X:
  print(N+1)
  exit()
D = 0
ans = 1
for i in range(N):
  D += L[i]
  if D <= X:
    ans += 1
  else:
    print(ans)
    exit()
# Judge status: Accepted
n,k=map(int,input().split())
A=[int(x) for x in input().split()]

s,l=0,max(A)
while l-s>1:
  m=(s+l)//2
  if sum([(a-1)//m for a in A]) >k:
    s=m
  else:
    l=m

print(l)
# Judge status: Wrong Answer
from math import factorial as f
print(f(int(input())))
# Judge status: Accepted
# -*- coding: utf-8 -*-

A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
min = sorted(a)[0]+sorted(b)[0]
for i in range(M):
    x, y, c = map(int, input().split())
    d = a[x-1]+b[y-1]-c
    if min > d:
        min = d
print(min)
# Judge status: Wrong Answer
N = int(input())
if N<105:
  print(0)
elif N<135:
  print(1)
elif N<189:
  print(2)
elif N<195:
  print(3)
else:
  print(4)
# Judge status: Accepted
x, y = map(int,input().split())
f = False
for i in range(x+1):
    if 2*i + 4*(x-i) == y:
        f = True
        break
if f:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
#!/usr/bin/env python3
import sys

def main():
    N, M = map(int, input().split())
    
    if M % 2 == 1:
        for i in range(M//2):
            print(i+1,M-i)
        for j in range(M//2 + 1):
            print(M+1+j,2*M+1-j)
    else:
        for i in range(M//2):
            print(i+1, M+1-i)
        for j in range(M//2):
            print(M+2+j,2*M+1-j)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
S = input()
ans = S[:4] + '8' + S[5:]
print(ans)
# Judge status: Accepted
x = int(input())

n1 = 0
while True:
    x = x - 500
    if x < 0:
        x += 500
        break
    else:
        n1 += 1

n2 = 0
while True:
    x = x - 5
    if x < 0:
        x += 5
        break
    else:
        n2 += 1

print(n1*1000 + n2*5)
# Judge status: Accepted
H1, H2, H3, H4, K = map(int, input().split())
up = H1*60 + H2
down = H3*60 + H4
print(down - up - K)
# Judge status: Accepted
def main():
    import fractions
    n = int(input())
    array = list(map(int, input().split()))
    lcm = array[0]
    for i in range(1, n):
        lcm = lcm * array[i] // fractions.gcd(lcm, array[i])

    total = 0
    for i,num in enumerate(array):
        total += lcm // num
    print(int(total%(10**9+7)))

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer

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

goodObservatory = [1]*N
goodObservatoryCount = 0

H = input().split()

for i in range(M):
	A,B = map(int, input().split())
	if H[A-1] > H[B-1]:
		goodObservatory[B-1] = 0
	elif H[A-1] < H[B-1]:
		goodObservatory[A-1] = 0


for i in range(N):
	if goodObservatory[i] == 1:
		goodObservatoryCount += 1

print(goodObservatoryCount)
# Judge status: Accepted
n = int(input())
s = input()
l = 0
r = 0
count = 0
need = 0
for i in range(n):
    if s[i] == "(":
        l += 1
        count += 1
    else:
        r += 1
        if count > 0:
            count -= 1
        else:
            need += 1
print("(" * need + s + ")" * (l + need - r))
# Judge status: Wrong Answer
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]

d = [0] * (N+1)
d[0] = 1
d[1] = 1

for i in range(2,N+1):
    if(i in a):
        d[i] = 0
    else:
        d[i] = d[i-1] + d[i-2]

print(d[-1])
# Judge status: Accepted
n, k = map(int, input().split())

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

from itertools import accumulate

aa

for _ in range(k):
    d = [0] * n

    for i, a in enumerate(aa):
        d[max(i-a, 0)] += 1
        end = i+1+a
        if end < n:
            d[end] -= 1

    d = list(accumulate(d))
    if aa == d:
        break
    aa = d


print(' '.join(str(a) for a in aa))
# Judge status: Wrong Answer
N = int(input())
A = [int(x) for x in input().split()]

ans = []

for k in range(N):
  S = sum(A[:k])
  T = sum(A[k:])
  ans.append(abs(S-T))

print(min(ans))
# Judge status: Accepted
n=[int(x) for x in list(input()[::-1])]+[0]
ans = 0
step = 0
for i in range(len(n)-1):
  x = n[i]+step
  if x < 5 or (x==5 and n[i+1]<5):
    ans += x
    step = 0
  else:
    ans += 10 - x
    step = 1
print(ans+step)
# Judge status: Accepted
N = int(input())
H = list(map(int, input().split()))
H.reverse()
def main():
  for i in range(N-1):
    if (H[i+1] - H[i] >= 2):
      print("No")
      return
    if (H[i+1] - H[i] == 1):
      H[i+1] -= 1
  print("Yes")

main()
# Judge status: Wrong Answer
from collections import deque

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

graph = [[] for _ in range(n+1)]

for i in range(m):
 a, b = map(int, input().split())
 graph[a].append(b)
 graph[b].append(a)

dist = [-1] * (n+1)
dist[0] = 0
dist[1] = 0

d = deque()
d.append(1)

while d:
 v = d.popleft()
 for i in graph[v]:
   if dist[i] != -1:
     continue
   dist[i] = dist[v] + 1
   d.append(i)

ans = dist[1:]
print(*ans, sep="\n")
# Judge status: Accepted
import math

n = int(input())

while True:
  x = math.sqrt(n)
  #####print(n)
  if x.is_integer():
    print(n)
    exit()
  n -= 1
# Judge status: Accepted
n = int(input())
print(((n//2)+(n%2))/n)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
numa = 0
numb = 0
num = sum(b)-sum(a)
for i in range(n):
    x = b[i] - a[i]
    if x > 0:
        numa += -(-x//2)
        if x % 2 == 1:
            numb += 1
    else:
        numb -= x
if (num-numa)*2 == num-numb and num > numa:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
n,m = map(int,input().split())
n = min(n,m)
x = sorted(map(int,input().split()))
dx = [0] * (m-1)

for i in range(m-1):
    dx[i] = x[i+1] - x[i]
    
dx = sorted(dx)
    
print(sum(dx[:-(n-1)]))
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
print(sum(list(map(lambda x:abs(x), a))))
# Judge status: Accepted
# coding: utf-8

input_ = input()
N = int(input_)

sum_ = 0

for i in range(N):
    sum_ += i + 1

print(sum_)
# Judge status: Accepted
from sys import stdin
from fractions import gcd
def lcm(a,b):
    return a*b//gcd(a,b)

def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    t=[int(readline()) for _ in range(n)]

    ans=1
    for i in range(n):
        ans=lcm(ans,t[i])

    print(ans)

if __name__=="__main__":
    main()
# Judge status: Accepted
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

ans = 0
for i, v in enumerate(a):
    x -= v
    if i == n - 1:
        if x == 0:
            ans += 1
        break
    else:
        if x >= 0:
            ans += 1
            continue
        else:
            break

print(ans)
# Judge status: Wrong Answer
N,K = map(int,input().split())
x = list(map(int,input().split()))
ans=10**15

for i in range(K):
    if i + K > N:
        break
    else:
        a = min(abs(x[K+i-1]),abs(x[i])) 
        ans = min(ans,x[K+i-1]-x[i]+a)
print(ans)
# Judge status: Accepted
X=int(input())

n500,r500=divmod(X,500)
n50=r500//5
print(n500*1000+n50*5)
# Judge status: Wrong Answer
import itertools
n,m,q=map(int,input().split())
abcd=[None]*q
for i in range(q):
    abcd[i]=list(map(int,input().split()))
num=0
for l in list(map(list, itertools.combinations(list(range(1,m+1))*m, n))):
    num_ = 0
    for x in abcd:
        if l[x[1]-1]-l[x[0]-1] == x[2]:
            num_ += x[3]
    num = max(num ,num_)
print(num)
# Judge status: Accepted
W, H, x, y = (int(whxy) for whxy in input().split())

print(float(W)*float(H)/2, 1 if 2*x==W and 2*y==H else 0)
# Judge status: Wrong Answer
s=input()

n=len(s)

ans=100000
for i in range(n-3):
  t=str(s[i])+str(s[i+1])+str(s[i+2])
  x=abs(753-int(t))
  
  ans=min(ans,x)
  
print(ans)
# Judge status: Accepted
h,w=map(int,input('').split(' '))
masu=0

masu=masu+(w*(h//2))

if h%2==1:
    if w%2==1:
        masu=masu+(w//2)+1
    else:
        masu=masu+(w//2)

if h==1 or w==1:
    masu=1

print(masu)
# Judge status: Wrong Answer
palindrome = list(input())
half = len(palindrome) // 2
lst = set()

for i in range(half):
    if palindrome[i] != palindrome[len(palindrome) - i - 1]:
        lst.add(palindrome[i])
print(len(lst))
# Judge status: Wrong Answer
X,Y,Z = map(int,input().split())

X = X-Z
i = 0
while X >= 0:
    if X > Y:
        X = X-Y
        i += 1
    X = X-Z
    
print(i)
# Judge status: Accepted
def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = sorted([A[i] - (i+1) for i in range(N)])
    b = B[N//2]
    print(sum([abs(val - b) for val in B]))

if __name__ == "__main__":
    main()
# Judge status: Accepted
import math

x = int(input())

if x == 2:
    print(2)
    exit()

elif x%2 == 0:
    ans = x+1

else:
    ans = x

#2以外の素数は奇数であることに注意

while True:
    for i in range(3, int(math.sqrt(ans))+1, 2):
        if ans%i == 0:
            ans += 2
            break
    else:
        print(ans)
        exit()
# Judge status: Accepted
n = int(input())
S = dict()
for i in range(n):
    word = input()
    if word not in S:
        S[word] = 1
    else:
        S[word] += 1
S = sorted(S.items(), key=lambda x:x[1], reverse=True)

max_v = S[0][1]
ans = []
for k,v in S:
    if v == max_v:
        ans.append(k)
    else:
        break
ans = sorted(ans)
for i in ans:
    print(i)
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
count = 0
for i in range(1,n-1):
    test_list=sorted([p[i-1],p[i],p[i+1]])
    if(test_list[1]==p[i]):
        count += 1
print(count)
# Judge status: Accepted
import math
import sys

n=int(input())

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

if d[0]!=0 or 0 in d[1:]:
    print(0)
    sys.exit()

lis=[0 for i in range(n)]

for i in range(n):
    lis[d[i]]+=1

for i in range(1,n-1):
    if lis[i]==0 and lis[i+1]!=0:
        print(0)
        sys.exit()
s=1

i=0
while i+1<=n-1 and lis[i+1]!=0:
    s=(s*pow(lis[i],lis[i+1],998244353))%998244353
    i+=1
print(s)
# Judge status: Accepted
W, H, x, y = map(int, input().split())

area = W*H / 2
pl = x == W / 2 and y == H / 2
print(area, int(pl))
# Judge status: Accepted
n,k = map(int,input().split())
li = [i for i in range(0,n+1)]
#print(li)
#[0,1, 2, 3]
tmp = 0
def exc(n):
    return (n)*(n+1)//2

for i in range(k,n+2):
    #print(i,li[n-i+1:],li[:i],sum(li[n-i+1:]) - sum(li[:i]))
    #tmp += sum(li[n-i+1:]) - sum(li[:i]) + 1
    mi = exc(i-1)
    ma = exc(n) - exc(n-i)
    #print(i,mi,ma,ma - mi + 1)
    tmp += ma - mi + 1
print(tmp%(10**9+7))
# Judge status: Accepted
import sys
readline = sys.stdin.readline

def solve():
    A, B, C = map(int, readline().split())
    K = int(readline())

    count = 0

    while B <= A:
        B *= 2
        count += 1
    
    while C <= B:
        C *= 2
        count += 1
    
    if count > K:
        print('No')
    else:
        print('Yes')

solve()
# Judge status: Accepted
def cal_cost(co, h, i, j):
    return co + abs(h[i]-h[j])

n = int(input())
h = [int(i) for i in input().split(" ")]
lis = [0 for i in range(n)]
lis[1] = cal_cost(lis[0], h, 0, 1)
for i in range(2, n):
    temp1 = cal_cost(lis[i-2], h, i-2, i)
    temp2 = cal_cost(lis[i-1], h, i-1, i)
    lis[i] = min(temp1, temp2)
print(lis[-1])
# Judge status: Accepted
n = int(input())
h = [int(x) for x in input().split()]

dp = [0] * n
dp[0] = 0
dp[1] = abs(h[1]-h[0])

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

print(dp[n-1])
# Judge status: Accepted
from bisect import bisect_left

N = int(input())
*L, = map(int, input().split())
L.sort()

ans = 0
for i in range(N):
    for j in range(i+1, N):
        a, b = L[i], L[j]
        ans += (bisect_left(L, a+b)-(j+1))

print(ans)
# Judge status: Accepted
from copy import deepcopy

n = int(input().strip())
x = list(map(int, input().split()))
y = deepcopy(x)
y.sort()
m1 = y[n // 2 - 1]
m2 = y[(n // 2)]

for e in x:
    if e <= m1:
        print(m2)
    else:
        print(m1)
# Judge status: Wrong Answer
def main():
    import math
    n, *ab = map(int, open(0).read().split())
    a = ab[::2]
    b = ab[1::2]

    ans = 0
    for x, y in zip(a[::-1], b[::-1]):
      if x%y != 0:
        ans += y - (x + ans) % y

    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Accepted
N, K=map(int, input().split())
A=list(map(int, input().split()))

x=0
y=max(A)

def f(l):
  nums=0
  for a in A:
    if a%l==0:
      nums+=a//l-1
    else:
      nums+=a//l
  if nums>K:
    return False
  else:
    return True

while y-x>1:
  tmp=(x+y)//2
  if f(tmp)==True:
    y=tmp
  else:
    x=tmp
    
print(y)
# Judge status: Accepted
a, b, x = map(int, input().split())
if x >= a and x <= a + b:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
A = int(input())
B = int(input())
C = int(input())
X = int(input())
#A,B,C,X = 2,2,2,100
ans = 0

for a in range(0,A+1):
	for b in range(0,B+1):
		for c in range(0,C+1):
			if a * 500 + b * 100 + c * 50 == X: 
				ans = ans + 1

print(ans)
# Judge status: Accepted
a,b=map(int,input().split())
if a==1 and b==1:
    print(0)
else:
    print(a*(a-1)//2+b*(b-1)//2)
# Judge status: Accepted
x = int(input())

if x >= 30:
    print('Yes')

else:
    print('No')
# Judge status: Wrong Answer
N = input()
Dig = len(N)
if Dig == 1:
    print(N)
else:
    for i in range(Dig):
        if N[i] != 9:
            num = i
            break
        else:
            continue
    list_num = list(N)
    target = int(list_num[num]) -1
    ans = 9*(num -1) + target + 9*(Dig)
    print(ans)
# Judge status: Accepted
x, y = map(int, input().split())
i = 1
c = y - x + 1

while True:
    if c <= y:
        c = 2**i * x
        i += 1
    else:
        print(i - 1)
        break
# Judge status: Accepted
s = input()
ans = []

for i in range(len(s)):
    if s[i] == "0" or s[i] == "1":
        ans.append(s[i])
    elif s[i] == "B" and ans != []:
        del ans[len(ans) - 1]
    
print("".join(ans))
# Judge status: Accepted
import collections
N = int(input())
a = list(map(int,input().split()))
B = collections.Counter(a)
ans = 0
for i in set(a):
    if B[i] < i:
        ans += B[i]
    else:
        ans += B[i]-i
print(ans)
# Judge status: Wrong Answer
n, l = map(int, input().split())
ans = []
for i in range(n):
    #index = 0
    s = str(input())
    for i in range(n):
        #print(ans, len(ans))
        if i > len(ans):
            ans.append(s)
            break
        elif str(ans[i*l:(i+1)*l]) < s:
            ans.insert(i-1,s)
            break

            #print(ans)
print("".join(ans))
# Judge status: Accepted
s = str(input())
cnt = 0
cnt_list = []

for i in range(len(s)):
    if s[i] in 'ACGT':
        cnt += 1
        cnt_list.append(cnt)
    else:
        cnt = 0
        cnt_list.append(0)
print(max(cnt_list))
# Judge status: Wrong Answer
n,w=map(int,input().split())
dp=[[0]*(w+1) for i in range(n)]
wet=[]
val=[]
for i in range(n):
  we,va=map(int,input().split())
  wet.append(we)
  val.append(va)
for i in range(w+1):
  if(wet[0]==i):
    dp[0][i]=val[0]
  elif(wet[0]<i):
    break
for i in range(1,n):
  for j in range(w+1):
    dp[i][j]=dp[i-1][j]
    if(wet[i]<=j):
      dp[i][j]=max(dp[i][j],dp[i-1][j-wet[i]]+val[i])
print(dp[n-1][w])
# Judge status: Accepted
n = int(input())
ab = [list(map(int,input().split())) for i in range(n)]
# (a, b) := (仕事にかかる時間, 締め切り)

ab = sorted(ab, key = lambda x:x[1])
time = 0
for a, b in ab:
    time += a
    if time <= b:continue
    print('No')
    exit()
print('Yes')
# Judge status: Accepted
n = int(input())
name = ''
while n>0:
    n -= 1
    name += chr(ord('a') + n%26)
    n//=26
print(name[::-1])
# Judge status: Accepted
from collections import deque
n = int(input())
a = list(map(int, input().split()))

q = deque()
t = 0
for i in a:
  if t == 0: q.append(i)
  else: q.appendleft(i)
  t = -1 - t
  
if t == 0: print(*q)
else: print(*reversed(q))