peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
x, y = map(int, input().split())

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

for i in range(k,n):
  if a[i] > a[i-k]:
    print('Yes')
  else:
    print('No')
# Judge status: Wrong Answer
import sys
sp=input()
t=input()

m=len(sp)
n=len(t)
for i in range(m-n,-1,-1):
  cand=sp[:i].replace('?','a')+t+sp[i+n:].replace('?','a')
  f=0
  for j,w in enumerate(t):
    if sp[j+i]!=w and sp[j+i]!='?':
      f=1
      break
  if f==0:
    print(cand)
    sys.exit()
print('UNRESTOREBLE')
# Judge status: Wrong Answer
p,q= input().split()
(a,b) =(int(p), int(q))
size_bottum = [a,b]
total = 0
total +=max(size_bottum)
total +=max(size_bottum) -1
print(total)
# Judge status: Accepted
A,B=map(int,input().split())
#print(sorted(B)[0])
print((A+B)%24)
# Judge status: Accepted
f = {"AC":0, "WA":0, "TLE":0,"RE":0}
for i in range(int(input())):
    s = input()
    f[s]+=1
for i in f:
    print(i,"x", f[i])
# Judge status: Accepted
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n = int(input())
s = input()
v1 = [None]*n
v2 = [None]*n
v = 0
for i in range(n):
    if s[i]=="#":
        v += 1
    v1[i] = v
v1.insert(0,0)
v = 0
for i in range(n-1, -1, -1):
    if s[i]==".":
        v += 1
    v2[i] = v
v2.append(0)
ans = min((v1[i]+v2[i]) for i in range(n+1))
print(ans)
# Judge status: Accepted
# 初期入力 2020-0730-2150
from bisect import bisect_left
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())
x = list(map(int, input().split()))
x_shift =[i +abs(x[0]) for i in x]
 
dist =[]
for i in range(N-K+1):
    d_end =x_shift[i+K-1] -x_shift[i] #ローソクK本の内、端と端の距離
    d_left =abs(x[i])
    d_right =abs(x[i+K-1])
    dist.append(d_end +min(d_left,d_right))
print(min(dist))
# Judge status: Accepted
import sys
import os


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, A, B = list(map(int, sys.stdin.buffer.readline().split()))
    n = N//(A+B)
    m = N%(A+B)
    print(A*n + min(m, A) if m > A else A*n + m)


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

def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

a = []
diff = 0
a0 = 0
a1 = 0
for xi in range(m):
    a0 = a1
    a1 = int(input())
    a.append(a1)
    if a1-a0>diff :
        diff=a1-a0

print(comb(n,diff))
print(diff)
print(a)

p = [1]
for xi in range(1,diff+1):
    add = 1
    for j in range(1, int(xi/2)):
        add += comb(xi-j,j)
    p.append(add)
# Judge status: Accepted
a = input()

if a.islower():
    print("a")
else:
    print("A")
# Judge status: Accepted
from math import sqrt
a, b = map(str, input().split())
if sqrt(int(a+b)) % 1 == 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
from math import factorial as f
n=int(input())
a=list(map(int,input().split()))

def comb(n,r):
    return int(f(n)/(f(r)*f(n-r)))

m=max(a)
r=0
for i in range(n):
    if abs(m/2-a[i])<abs(m/2-r):
        r=a[i]

print(comb(m,r))
# Judge status: Wrong Answer
H=int(input())
W=int(input())
N=int(input())
M=max(H,W)
print(N//M)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

cnt = [0]*(10**5+2)
for a in A:
    cnt[a] += 1
ans = []
for a in A:
    if a == 0:
        ans.append(cnt[a] +cnt[a+1])
    else:
        ans.append(cnt[a-1] + cnt[a] +cnt[a+1])
print(max(ans))
# Judge status: Accepted
def coins(a,b,c,x):
    num=0
    for i in range(a+1):
        for w in range(b+1):
            for q in range(c+1):
                if 500*i + 100*w + 50*q == x:
                    num += 1
    return num
  
def main():
  a=int(input())
  b=int(input())
  c=int(input())
  x=int(input())
  print(coins(a,b,c,x))
 
if __name__ == '__main__':
    main()
# Judge status: Accepted
n, m = map(int, input().split())

drink = []
for i in range(n):
  a, b = map(int, input().split())
  drink.append((a,b))
drink.sort(key=lambda x: x[0])
ans = 0
for ai in drink:
  ans += ai[0] * min(ai[1], m)
  m -= ai[1]
  if m <= 0:
    print(ans)
    break
# 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 = int(readline())
ans = n // 11 * 2
if 1 <= n % 11 <= 6:
    ans += 1
elif 7 <= n % 11 <= 10:
    ans += 2
print(ans)
# Judge status: Wrong Answer
S = input()
s = len(S)

if s == 2:
  print(1)

for i in range(1,s//2):
  a = s - i*2 
  if a != 0:
    test = S[0:a]
    n = 0
    while True:
      if n == a/2:
        print(len(test))
        break
      elif test[n] != test[n + a//2]:
        break
      else:
        n += 1
  else: 
    print(2)
# Judge status: Wrong Answer
#!/usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    tmp = 1
    for k in A[:K]:
        tmp += k

    for i in range(N - K):
        if tmp < tmp / A[i] * A[i + K]:
            print("Yes")
        else:
            print("No")


if __name__ == "__main__":
    main()
# Judge status: Accepted
S = input()
print("Yes" if len(set(S)) == 3 else "No" )
# Judge status: Wrong Answer
import math

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

pos_1 = 0 
for i in range(N):
    if A_list[i] == 1:
        pos_1 = i

ans = math.ceil((pos_1)/(K-1)) + math.ceil((N-1-pos_1)/(K-1))
print(ans)
# Judge status: Accepted
N, M = map(int, input().split())

c_min = 1
c_max = 10 ** 5
for i in range(M):
    LM = list(map(int, input().split()))
    c_min = max(c_min, LM[0])
    c_max = min(c_max, LM[1])

if c_min > c_max:
    print(0)
else:
    print(c_max - c_min + 1)
# Judge status: Accepted
import math
N,K = map(int,input().split())
x = math.log(N,K)+0.0000000000001

print(math.ceil(x))
# Judge status: Accepted
def abc142c_go_to_school():
    n = int(input())
    a = list(zip(range(1, n+1),list(map(int, input().split()))))
    a.sort(key=lambda x: x[1])
    for item in a:
        print(item[0], end=' ')

abc142c_go_to_school()
# Judge status: Wrong Answer
a,b,x = map(int,input().split())
if a<x and b>x:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
import math
a,b=input().split()
x=int(a+b)
print(x)
if math.sqrt(x).is_integer ==True:
	print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
S = list(input())
K = int(input())
ans = 1

for i in range(len(S)):
    if S[i] != '1' :
        ans = S[i]
        break
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
ans = min(n, m // 2)
m -= ans * 2
ans += max(0, m // 4)
print(ans)
# Judge status: Accepted
n = input().split()
a = int(n[0])
b = int(n[1])
c = a+b
if c >= 24:
  c -= 24
print(c)
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))

#%%
flag = None
up = False
down = False
ans = 1
base = A[0]

for i in range(1, n):
    if base < A[i]:
        up = True
        base = A[i]
    elif base > A[i]:
        down = True
    if (up == True) and (down == True):
        up = False
        down = False
        ans += 1
    base = A[i]
    
print(ans)
# Judge status: Accepted
N = int(input())
an = list(map(int, input().split()))
four = 0
odd = 0
for a in an:
    if a % 2 == 1:
        odd += 1
    elif a % 4 == 0:
        four += 1
print('Yes' if odd <= four or N//2 == four and -(-N//2) == odd else 'No')
# Judge status: Accepted
L = int(input())

x = (1/3) * L

ans = x**3

print(ans)
# Judge status: Accepted
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

s = readline().rstrip().decode()
t = read().rstrip().decode()
ans = []
for i in range(len(s) - len(t) + 1):
    for j, (ss, tt) in enumerate(zip(s[i:], t)):
        if ss not in ('?', tt):
            break
    else:
        memo = s[:i] + t + s[i + len(t):]
        ans.append(memo.replace('?', 'a'))
print(min(ans) if ans else 'UNRESTORABLE')
# Judge status: Wrong Answer


import numpy as np
import fractions as fra


sx,sy,ex,ey=map(int,input().split())
ex-=sx
ey-=sy
s=""
for i in range(ey):
    s+="U"
for i in range(ex):
    s+=("R")
for i in range(ey):
    s+=("D")
for i in range(ex):
    s+=("L")
s+=("D")
for i in range(ex+1):
    s+=("R")
for i in range(ey+1):
    s+=("U")
s+=("LD")
print(s)
# Judge status: Accepted
n = int(input())
cnt = 0
for i in range(105,n+1,2):
    cnt2 = 0
    for j in range(3,i,2):
        if i % j == 0:
            cnt2 += 1
    if cnt2 == 6:
        cnt += 1
print (cnt)
# Judge status: Accepted
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))

l = list(map(lambda x: abs(a - (t - 0.006 * x)), h))
print(l.index(min(l))+1)
# Judge status: Accepted
A, B, C, D = map(int, input().split())
result = 0
for a in range(A, B):
    if C <= a and a < D:
        result += 1
print(result)
# Judge status: Accepted
n=int(input())
s=input()

ans=0
for i in range(n-1):
  cnt=0
  a=set(s[:i+1])
  b=set(s[i+1:])
  for j in a:
    if j in b:
      cnt+=1
  if ans<cnt:
    ans=cnt

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

tmp = max(a)+min(a)
if tmp%2==0:
    tmp = tmp//2
else:
    tmp = tmp//2+1
print(sum(map(lambda x:(x-tmp)**2,a)))
# Judge status: Accepted
def solve():
    N, K = map(int, input().split())
    D = list(map(int, input().split()))
    while True:
        S = list(str(N))
        for s in S:
            if int(s) in D:
                break
        else:
            return N
        N += 1
print(solve())
# Judge status: Accepted
a,b=map(int,input().split())

print((a+b+1)//2)
# Judge status: Accepted
import math        # factorical（階乗) # hypot(距離)
# import heapq
# from fractions import gcd # Python3.5以前 # lcm（最小公倍数） = (a*b)//gcd(a,b)
# from fractions import Fraction
# from math import gcd # Python3.6以降
# --------------------------------------------------------------

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

if x*2 <= a*a*b:
    print(math.degrees(math.atan(a*b*b/(2*x))))
else:
    print(math.degrees(math.atan((a*a*b-x)*2/(a**3))))
# Judge status: Accepted
import itertools
import math
n = int(input())
lis1 = []
for i in range(n):
    lis1.append(list(map(int, input().split())))
S = 0
for i in list(itertools.permutations(range(n))):
    for j in range(n-1):
        S += math.sqrt((lis1[i[j]][0]-lis1[i[j+1]][0])**2 + (lis1[i[j]][1]-lis1[i[j+1]][1])**2)
for i in range(1, n+1):
    S = S / i
print(S)
# Judge status: Accepted
n,x = map(int, raw_input().split(' '))
ais = map(int, raw_input().split(' '))
count,cur,i = 1,0, 0
res = []
while(i < len(ais)):
	cur += ais[i]
	if cur <= x:
		count+=1
	else:
		break

	i +=1
print count
#print len([e for e in res if e <= x])
# Judge status: Accepted
N = int(input())

print(0 if N%1000 == 0 else 1000-(N%1000))
# Judge status: Accepted
N, M = map(int, input().split())
A = list(set(map(lambda x : int(x)//2, input().split())))
def gcd(x, y):
  return x if y == 0 else gcd(y, x % y)
def lcm(x, y):
  return (x * y) // gcd(x, y)
l = A[0]
for a in A[1:]:
  l = lcm(l, a)
ans = (M // l + 1) // 2
for a in A[1:]:
  if (l // a) % 2 == 0:
    ans = 0
    break
print(ans)
# Judge status: Accepted
from collections import Counter

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

print(N - sum(x[1] for x in Counter(A).most_common(K)))
# Judge status: Accepted
# coding: UTF-8
import sys
import numpy as np


a,b,t = map(int, input().split())
print(b * (t//a))
# Judge status: Accepted
X,Y,A,B,C=map(int,input().split())
P=sorted(list(map(int,input().split())))
Q=sorted(list(map(int,input().split())))
R=sorted(list(map(int,input().split())))
print(sum(sorted(P[-X:]+Q[-Y:]+R)[-X-Y:]))
# Judge status: Accepted
N = int(input())
n = N-1
ans = ((n+1)*n)//2
print(ans)
# Judge status: Accepted
n, r = map(int, input().split())
ans = r + 100 * (10 - min(10, n))
print(ans)
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
H=int(input())

opt=[1]
while opt[-1]<=10**12:
    opt.append(opt[-1]*2+1)

count=0
temp=1
while temp<H:
    temp*=2
    count+=1
if count>39:
    print(opt[-1])
else:
    print(opt[count])
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
mon = 1000  #所持金
cnt = 0  #株の所持数
cur = A[0]
for i in range(1,len(A)):
  sec = A[i]
  #値上がりする前に購入
  if cur < sec:
    #買えるだけ買う
    if mon > cur:
      cnt = mon//cur
      mon = mon%cur
  #値が下がる前に売却
  elif cur > sec:
    mon += cur * cnt
    cnt = 0
  cur = sec
if cnt > 0:
  mon += A[-1]*cnt
print(mon)
# Judge status: Accepted
A, B, C = map(int,input().split())

y = C - A + B
if y >= 0:
    print( y )
else:
    print( 0 )
# Judge status: Wrong Answer
def is_palindrome(s: str) -> bool:
    return s[:len(s)//2] == s[-1*(len(s)//2):]


a, b = [int(i) for i in input().split()]
print([is_palindrome(str(n)) for n in range(a, b+1)].count(True))
# Judge status: Accepted
a=list(map(int, input().split()))
s=[[1,3,5,7,8,10,12],[4,6,9,11],[2]]
ans=[]
for i in a:
  for j in range(len(s)):
    if i in s[j]:
      ans.append(j)
      break
if len(set(ans))==1:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
n=int(input())
for i in range(1,10**3+2):
  if i**2>n:print((i-1)**2)
# Judge status: Wrong Answer
k = int(input())
c = 0
x = 0
sx = 0
while c < k:
  sx = str(x)
  c+=1
  for i in range(len(sx)-1):
   if abs(int(sx[i]) - int(sx[i+1])) > 1:
     c-=1
     break
  x+=1
print(x)
# Judge status: Wrong Answer
a,b = map(int,input().split())

ans = (a+b)/2
#print(ans)

if ans%2 == 1:
  print((a+b)//2+1)
else:
  print((a+b)//2)
# Judge status: Accepted
a, b = input().split()
n = int(a+b)
if n == int(n**(1/2))**2:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n = int(input())
a = []
for i in range(n):
  a.append(int(input()))
a.sort()
jud = 1
q = a[0]
ans = 0
for i in range(1,n):
  if(q==a[i]):
    jud += 1
  else: 
    if(jud%2==1):
      ans += 1
    jud = 1
    q = a[i]
if (jud%2==1):
  ans += 1
if(n==1):
  ans = 1
print(ans)
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import numpy as np

rl = sys.stdin.readline

n = int(rl())

li = list(map(int, rl().split()))
if n == 0 and li[0] == 1:
    print(1)
    exit()

can = [1-li[0]]

a = can[0]
for i in range(1, n+1):
    a = a*2
    can.append(a)
    a -= li[i]
    if a < 0:
        print(-1)
        exit()

ans = 0
can.reverse()
li.reverse()
temp = 0
for i in range(n+1):
    temp += li[i]
    ans += min(can[i], temp)
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
print("No" if a+b<c else "Yes")
# Judge status: Accepted
N = int(input())
S = input()
ES, WS= [0]*(N+1), [0]*(N+1)
ES[0], WS[0] = 0, 0
for i in range(1, N+1):
  if S[i-1] == "E":
    ES[i] = ES[i-1] + 1
    WS[i] = WS[i-1]
  elif S[i-1] == "W":
    WS[i] = WS[i-1] + 1
    ES[i] = ES[i-1]
ans = 10**18
for i in range(1, N+1):
  ans = min(ans, WS[i-1] + ES[N] - ES[i])
print(ans)
# Judge status: Wrong Answer
n = int(input())
B = [input() for _ in range(n)]
m = int(input())
R = [input() for _ in range(m)]
L = list(set(B) | set(R))
dict = {key:0 for key in L}
for b in B:
    dict[b] += 1
for r in R:
    dict[r] -=1
print(max(dict.values()))
# Judge status: Wrong Answer
x = list(map(int, input().split()))
print(17-sum(x))
# Judge status: Wrong Answer
A = int(input())  - 1
if A ==0 :print(A)
else : print(int(A*(A+1)/2))
# Judge status: Accepted
x=list(map(int,input().split()))
for i in range(5):
    if x[i]==0:
        print(i+1)
        exit()
# Judge status: Accepted
n,m = map(int,input().split())
if n==1 and m==1: ans=1
elif n==1 or m==1: ans=max(n,m)-2
else: ans = (n-2)*(m-2)
print(ans)
# Judge status: Accepted
a = list(map(int,input().split()))
if len(set(a)) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
if n<1000:
    print("ABC")
else:
    print("ABD")
# Judge status: Accepted
n,s = int(raw_input()),map(int,raw_input().split())
s.sort(key = lambda x:-x)
print sum(s[0:n:2]) - sum(s[1:n:2])
# Judge status: Accepted
x = int(input())
for i in range(1000):
    if x * (i+1) % 360 == 0:
        print(i+1)
        exit()
# Judge status: Accepted
X, K, D = map(int, input().split())
X = abs(X)

a, b = divmod(X, D)
# print(f'{a=}, {b=}')

if a >= K:
    ans = X - K * D
    ans = abs(ans)
    print(ans)
    exit()

_K = K - a
# print(f'{_K=}')
if _K % 2 == 0:
    ans = b
else:
    ans = abs(b - D)
print(ans)
# Judge status: Accepted
def solve():
  T = input()
  ans = T.replace('?','D')
  return ans
print(solve())
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
ans = 0
for i in range(n):
  for j in range(i+1,n):
    for k in range(j+1,n):
      b = [a[i],a[j],a[k]]
      b.sort()
      if b[0] == b[1] or b[1] == b[2]:
        pass
      elif b[0] + b[1] > b[2]:
        ans += 1
print(ans)
# Judge status: Accepted
x, y = map(int, input().split())

ans = 0
Button = [(1, 1), (1, 0), (0, 1), (0, 0)]

ans = float("INF")
for fb, lb in Button:
  t, tx, ty = 0, x, y
  if fb:
    tx = -x
    t += 1
  if lb:
    ty = -y
    t += 1
  if tx > ty:
    continue
  t += ty - tx
  ans = min(ans, t)

print(ans)
# Judge status: Accepted
n = int(input())
s = input()
l = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'
ans = ''
for t in s:
  ans += l[l.index(t)+n]
print(ans)
# Judge status: Wrong Answer
import math
N, M = list(map(int, input().split()))
if N==M==1:
    print(1)
elif M < 2:
    print(int(math.factorial(N)/math.factorial(2)/math.factorial(N-2)))
elif N==0:
    print(int(math.factorial(M)/math.factorial(2)/math.factorial(M-2)))
else:
    print(int(math.factorial(N)/math.factorial(2)/math.factorial(N-2) +  math.factorial(M)/math.factorial(2)/math.factorial(M-2)))
# Judge status: Accepted
a, b, c = map(int, input().split())
print(min(b // a, c))
# Judge status: Accepted
n=int(input())
ans=0
while (ans*(ans+1))//2<n:
  ans+=1
print(ans)
# Judge status: Accepted
a = int(input())
ans = a + a ** 2 + a **3
print(str(ans))
# Judge status: Wrong Answer
n = int(input())
abc = []
for i in range(n):
    abc.append([int(i) for i in input().split()])

dp = [[0,0,0] for i in range(n)]

for i in range(n):
    if i != 0:
        for j in range(3):
            for k in range(3):
                if j != k:
                    dp[i][j] = max(dp[i][j],dp[i-1][k] + abc[i][j])
    else:
        for j in range(3):
            dp[i][j] = abc[i][j]
print(max(dp[n-1]))
print(dp)
# Judge status: Wrong Answer
N,M = map(int,input().split())
n = M // N
m = 0
for i in range(1,N+1):
    x = i
    if M % x == 0:
        if M//x <= n:
            print(M//x)
            quit()
        m = x
print(m)
# Judge status: Wrong Answer
import numpy as np
N,K = map(int,input().split())
a = True
b=0
if N<K:
    print(1)
elif K==10:
    while(a):
        if N//K==0:
            a=False
        else:
            N=N//K+N%K
            b+=1
    print(b+1)
else:
    while(a):
        if N//K==0:
            a=False
        else:
            N=N//K+N%K
            b+=1
    print(b)
# Judge status: Wrong Answer
import math

x, k, d = map(int, input().split())


if x > d * k:
    print(abs(x-d*k))
else:
    if k % 2 == 1:
        print(abs(x - math.ceil(x/d) * d))
    else:
        print(abs(x - (math.ceil(x/d) - 1) * d))
# Judge status: Accepted
from math import ceil
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

print(ceil(n/min(a, b, c, d, e))+4)
# Judge status: Wrong Answer
N,M = map(int,input().split())

def solve(N,M):
  # 今あるもの
  if M < N * 2:
    return N
  
  M -= N * 2
  
  ans = N + M // 3
  return ans

print(solve(N,M))
# Judge status: Wrong Answer
N = int(input())
print( N//2 + 1)
# Judge status: Accepted
N = int(input())
a = [0]
a += list(map(int, input().split(' ')))
b = [0 for _ in range(N + 10)]
for i in range(N, 0, -1):
  res = 0
  for j in range(N // i * i, i, -i):
    res = res ^ b[j]
  b[i] = res ^ a[i]
print(sum(b))
for i in range(1, N + 1):
  if b[i]:
    print(i)
# Judge status: Accepted
import sys
import math
import fractions
from collections import deque
from collections import defaultdict
sys.setrecursionlimit(10**7)

X = int(input())


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


l = lcm(360, X)

print(l // X)
# Judge status: Accepted
N,A,B=map(int,input().split())
if (A-B)%2==0:
  print((B-A)//2)
  exit()

print(min((A+B-1)//2,(N-B+N-A+1)//2))
# Judge status: Accepted
def main():
    r, g, b = map(int, input().split())
    num = r*100+g*10+b
    if num % 4 == 0:
        print('YES')
    else:
        print('NO')
main()
# Judge status: Wrong Answer
s = str(input())
s1 = ""
s2 = ""
flag = 0

for i in range(len(s)):
	if not 0 == i and  not len(s) == i:
		if i % 2 == 0:
			# print("---i--- {0}".format(i))
			s1 = s[0:int((len(s)-i)/2)]
			s2 = s[int((len(s)-i)/2):len(s)-i]
			# print(len(s)-i)
			# print("{0} --s1 \n {1} --s2".format(s1,s2))
			if s1 == s2:
				flag = len(s)-i

print(flag)
# Judge status: Accepted
# coding: utf-8
# Your code here!
n,m=map(int,input().split())

if n==m:
    print("Yes")
    
else:
    print("No")
# Judge status: Accepted
a, b, t = map(int, input().split())
print(int((t + 0.5) // a * b))
# Judge status: Wrong Answer
def chmin(dp, i, target):
    if (dp[i] > target):
        dp[i] = target

n = int(input())
h = [i for i in input().split(" ")]
dp =[10**4] * n

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

print(dp[n - 1])
# Judge status: Accepted
#112_D
N,M=map(int,input().split())
#M//N以下のMの約数の最大
divisors=[]
for i in range(1,int(M**.5)+1):
    if M%i==0:
        divisors.append(i)
        if i!=(M//i):
            divisors.append(M//i)
Ans=1
for x in sorted(divisors):
    if M//N>=x:
        Ans=x
    else:
        break
print(Ans)
# Judge status: Accepted
n,m,k=map(int,input().split())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

ans=0
j=m
for i in range(n+1):
    if a[i]>k:
        break
    time=a[i]+b[j]
    while time>k:
        j-=1
        time=a[i]+b[j]
    ans=max(ans,i+j)
print(ans)
# Judge status: Accepted
from collections import deque
def solve():
    n = int(input())
    A = list(map(int,input().split()))

    q = deque()
    for i in range(n):
        if i % 2 == 0:
            q.append(A[i])
        else:
            q.appendleft(A[i])
    
    ans = list(q)
    if n % 2 != 0:
        ans.reverse()
    
    print(*ans)

if __name__ == '__main__':
    solve()
# Judge status: Accepted
import sys
input = sys.stdin.readline

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

p = 1000
kabu = 0

uri = False

for i in range(n):
    if i == n-1 or (uri and a[i+1] < a[i]):
        #uri
        p += kabu * a[i]
        kabu = 0
        uri = False
    elif (not uri) and a[i+1] > a[i]:
        #kai
        kabu = p // a[i]
        p -= a[i] * kabu
        uri = True

    #print(p, kabu)

print(p)
# Judge status: Wrong Answer
from sys import stdin
from itertools import groupby, permutations
import numpy as np



def main():
    N = int(input())
    L = np.sort(np.array([int(x) for x in input().split()]))

    ret = 0
    # print(L)
    for i in range(N-2):
        for j in range(i + 1, N-1):
            k = np.searchsorted(L, L[i] + L[j], side='right')
            # print(L[i], L[j], k, ret)
            ret += k - j - 1
    return ret


if __name__ == "__main__":
    print(main())
# Judge status: Accepted
n = int(input())
h = list(map(int, input().split()))

now = 0
for i in h:
    if now < i:
        now = i - 1
    elif now == i:
        pass
    else:
        print('No')
        break
else:
    print('Yes')
# Judge status: Accepted
N = int(input())
A = int(input())
B = int(input())
C = int(input())
D = int(input())
E = int(input())
X = min(A, B, C, D, E)
if(N % X == 0):
  print(N//X + 4)
else:
  print(N//X + 5)
# Judge status: Accepted
n = int(input())
for i in range(1,10):
    if int(str(i)*3) >= n:
        print(str(i)*3)
        break