peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import sys
from itertools import combinations
import math


def I(): return int(sys.stdin.readline().rstrip())


def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))


def S(): return sys.stdin.readline().rstrip()


def LS(): return list(sys.stdin.readline().rstrip().split())


A, B, K = LI()
temp = 0
for i in range(1, max(A, B)+1):
    if A % i == 0 and B % i == 0:
        temp += 1
    if temp == K:
        print(i)
        exit()
# Judge status: Accepted
# 初期入力
S =input()

#
flag = True

for i,v in enumerate(S):
    if (i+1) %2 ==1 and v in "RUD":
        flag ="Yes"
    elif(i+1) %2 ==1 and v not in "RUD":
        flag ="No"
        break
    if (i+1) %2 ==0 and v in "LUD":
        flag ="Yes"
    elif(i+1) %2 ==0 and v not in "LUD":
        flag ="No"
        break
print(flag)
# Judge status: Accepted
n = int(input())
print(800 * n - 200 * (n // 15))
# Judge status: Accepted
w = input()
if all([w.count(i)%2 == 0 for i in set(w)]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
div = 0
even = 0
for a in A:
    if a % 4 == 0:
        div += 1
    elif a % 2 == 0:
        even += 1

odd = n - div - even
if even:
    odd += 1
if div:
    div += 1

if div >= odd or even == n:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
S = input()
l = len(S)
bw = '01' * (l // 2 + 1)
wb = '10' * (l // 2 + 1)
bw_count = len([ 1 for a, b in zip(S, bw) if a != b  ])
wb_count = len([ 1 for a, b in zip(S, wb) if a != b  ])
print(min(bw_count, wb_count))
# Judge status: Accepted
import sys

n, *a = map(int, sys.stdin.read().split())

def main():
    m = 10 ** 5
    cnt = [0] * (m + 1)
    for x in a:
        cnt[x] += 1
        if x > 0: cnt[x-1] += 1
        if x < m: cnt[x+1] += 1
    print(max(cnt))

if __name__ ==  '__main__':
    main()
# Judge status: Accepted
X = int(input())

beki = []
for i in range(1,32):
    beki.append(i**2)
for i in range(1,11):
    beki.append(i**3)
for i in range(1,6):
    beki.append(i**4)
for i in range(1,4):
    beki.append(i**5)
for j in range(6,10):
    beki.append(2**j)
    
beki = sorted(beki, reverse=True)
for a in beki:
    if a <= X:
        print(a)
        break
# Judge status: Accepted
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
print(max(max([s.count(e)-t.count(e) for e in s+t]),0))
# Judge status: Accepted
n, x, t = map(int, input().split())
if n % x == 0:
    print((n//x)*t)
else:
    print((n//x+1)*t)
# Judge status: Wrong Answer
a,b,c,d=map(int,input().split())
if abs(a-c)<d or (abs(a-b)<d and abs(b-c)<d):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x, a, b = map(int, input().split())
i = x-a
j = x-b
if i < j:
    print('A')
else:
    print('B')
# Judge status: Accepted
def main():
	c = []
	
	for _ in range(3):
		c.append(list(map(int, input().split())))

	a = [0] * 3
	b = [0] * 3

	for i in range(3):
		b[i] = c[0][i] - a[0]

	for i in range(1, 3):
		a[i] = c[i][0] - b[0]
	
	is_able = True

	for i in range(3):
		for j in range(3):
			if a[i] + b[j] != c[i][j]:
				is_able = False
				break

	if is_able:
		print("Yes")
	else:
		print("No")

  
if __name__ == "__main__":
  	main()
# Judge status: Accepted
N = int(input())
s = list(input())
t = list(input())
c = 0
for i in range(1,N+1):
  if s[-i:] == t[:i]:
    if c <= i:
      c = i
print(2*N-c)
# Judge status: Accepted
import math

N, X, T = [int(i) for i in input().split()]
 
print(math.ceil(N / X) * T)
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()


S = input()

y = S[:4]
m = S[5:7]
d = S[8:10]

new_S = y + m + d

if int(new_S) > 20190430:
    print("TBD")
else:
    print("Heisei")
# Judge status: Accepted
n, m = map(int, input().split())
s = [list(map(int, input().split())) for _ in range(n)]
p = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    l = [0]*m
    for j in range(m):
        l[j] = abs(s[i][0] - p[j][0]) + abs(s[i][1] - p[j][1])
    print((l.index(min(l)) +1))
# Judge status: Accepted
k,x =map(int, input().split()) 

if (500*k)-x >= 0:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
D = int(input())

cs = [int(i) for i in input().split()]

last = {n: 0 for n in range(1, 27)}
ans = []
for day in range(1, D-26):
    ss = [int(i) for i in input().split()]
    max_score = 0
    max_i = 1
    for i, s in enumerate(ss, 1):
        human = day-last[i]
        s_human = s + cs[i-1] * (human*2)
        if s_human > max_score:
            max_score = s_human
            max_i = i
    ans.append(max_i)
    last[max_i] = day
# Judge status: Wrong Answer
import sys
import collections as cc
import math as mt
I=lambda:list(map(int,input().split()))
a,b,c,d=I()
print(max(b*d,a*c,a*d,b*d))
# Judge status: Wrong Answer
n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()

s = 0
num = 0
for i in range(len(a)):
    if x >= a[i]:
        x -= a[i]
        num += 1
    else:
        break

print(num)
# Judge status: Accepted
from fractions import gcd
from functools import reduce
import sys
input = sys.stdin.readline

def lcm_base(x, y):
    return (x * y) // gcd(x, y)

def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

def main():
    N = int(input())
    T = [int(input()) for _ in range(N)]
    print(lcm(T))

if __name__ == '__main__':
    main()
# Judge status: Accepted
s = input()
q = int(input())

reverse_flag = 0
head = ""
back = ""
for _ in range(q):
    query = input()
    if query[0] == "1":
        reverse_flag ^= 1
    else:
        t,f,c = query.split()
        f = int(f) + reverse_flag
        if f%2 == 1:
            head = c + head
        else:
            back = back + c
s = head + s + back
print(s if reverse_flag%2 == 0 else s[::-1])
# Judge status: Wrong Answer
def main():
  s = input()[::-1]
  l = len(s)
  n = 2019
  dp = [0]*n
  wk = 0
  r = 1
  for i in range(l):
    wk += int(s[i])*r
    wk %= n
    dp[wk] += 1
    r*= 10
    r %= n
  print(sum([i*(i-1)//2 for i in dp]),dp)
main()
# Judge status: Accepted
A,B,C = map(int,input().split())
count7 = 0
count5 = 0

ans = [A,B,C]

for i in ans:
    if i == 7:
        count7 += 1
    elif i == 5:
        count5 += 1

if count7 == 1 and count5 == 2:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
from collections import deque
O = deque(input())
E = deque(input())
ans = []
for _ in range(len(O)):
    ans.append(O.popleft())
    if E:
        ans.append(E.popleft())
print("".join(ans))
# Judge status: Accepted

X, Y, A, B, C = map(int, input().split())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
R = list(map(int, input().split()))

P.sort()
Q.sort()
cand = P[-X:] + Q[-Y:] + R
cand.sort()
print(sum(cand[-(X + Y):]))
# Judge status: Accepted
# B 
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
def calc(a,b):
    sa=list(str(a))
    sb=list(str(b))
    res=0
    for aa in sa:
        res+=int(aa)
    for bb in sb:
        res+=int(bb)
    return res

n=ni()
ans=10**6
for i in range(1,n):
    a=i
    b=n-i
    t=calc(a,b)
    ans=min(ans,t)
print(ans)
# Judge status: Wrong Answer
import math

X = int(input())

t = 0
m = 100

while m < X:
  m = math.ceil(m * 1.01)
  t += 1

print(t)
# Judge status: Accepted
N, M = map(int, input().split())

res = 0
if 2 * N <= M:
    res += N
    M -= 2 * N
    res += M // 4
else:
    res += M // 2

print(res)
# Judge status: Wrong Answer
s = input()

l = len(s)
ans = 1
tmp = s[0]
nxt = ""
for i in range(1,l):
    nxt += s[i]    
    if tmp == s[i]:
        continue
    else:
        ans += 1
        tmp = nxt
        nxt = ""

print(ans)
# Judge status: Accepted
x = input()
s = 0
ans = 0
for c in x:
    if c == 'S':
        s += 1
    else:
        if s == 0:
            ans += 2
        else:
            s -= 1
print(ans)
# Judge status: Accepted
s = input()

if s == "hi" or s == "hihi" or s == "hihihi" or s =="hihihihi" or s =="hihihihihi" or s =="hihihihihihihi" or s =="hihihihihihihihi" or s =="hihihihihihihihihi" or s =="hihihihihihihihihihi":
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a = sorted(a)

cnt = {}
for i in range(n):
    if a[i] not in cnt:
        cnt[a[i]] = 0
    cnt[a[i]] += 1
    
ans = 0
for i in range(n):
    tmp = cnt[a[i]]
    if a[i] - 1 in cnt:
        tmp += cnt[a[i] - 1]
    if a[i] + 1 in cnt:
        tmp += cnt[a[i] + 1]
    ans = max(ans, tmp)
print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

def f(A):
    for a in A:
        if a == 0:
            print(0)
            return
    v = 1
    for a in A:
        v *= a
        if v > int(1e+18):
            print(-1)
            return
    print(v)
    return

f(A)
# Judge status: Accepted
N=int(input())
A=[tuple(map(int,input().split())) for i in range(N)]
A.sort(key=lambda x: x[1])
a=0
b=0 
c=0 
for i in range(len(A)):
   a+=A[i][0]
   b=A[i][1]
   if a>b:
      c+=1
      print('No')
      break
if c==0:
  print('Yes')
# Judge status: Wrong Answer

W,H,N = map(int, input().split())
bottom = [0, 0]
top = [W,H]

for _ in range(N):
    x,y,a = map(int, input().split())
    if a==1:
        bottom[0] = max(bottom[0], x)
    elif a==2:
        top[0] = min(top[0], x)
    elif a==3:
        bottom[1] = max(bottom[1], y)
    elif a==4:
        top[1] = min(top[1], y)

print(max(0, (top[0]-bottom[0])*(top[1]-bottom[1])))
# Judge status: Accepted
# A - Digit Sum 2

N = input()
digit = len(N)
ans = 0

for i in range(digit):
    ans += int(N[i])
    if i<digit-1 and N[i+1]!='9':
        ans += 9*(digit-1-i)-1
        break

print(ans)
# Judge status: Accepted
n = int(input())
s = list(input())
ans = 1001001
wn = 0
en = sum([1 for i in s[1:] if i == 'E'])
for i in range(n):
    ans = min(ans, wn + en)
    if s[i] == 'W':
        wn += 1
    if i != n - 1:
        if s[i + 1] == 'E':
            en -= 1
print(ans)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
a.sort()

ans = 0
for i in range(1, n):
    ans += a[n - i//2 - 1]

print(ans)
# Judge status: Accepted
N = int(input())
ans = 0
if N % 2 == 1:
    print(ans)
else:
    for i in range(1, 10000):
        a = N // (2 * (5**i))
        ans += a
        if a == 0:
            break
    print(ans)
# Judge status: Wrong Answer
a=input().split()
print(abs(int(a[0])-int(a[1])))
# Judge status: Accepted
S=str(input())
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
  print("Bad")
else:
  print("Good")
# Judge status: Wrong Answer
l = [int(input()) for _ in range(5)]
k = int(input())
 
flag = False
for i in range(5):
  for j in range(i +1, 5):
    if l[j] - l[i] > k:
      flag = True
      break

if flag:
  print(":(")
else:
  print("Yay")
# Judge status: Accepted
s = input()
a = ""
for i in s:
    if i == "0" or i == "1":
        a += i
    else:
        a = a[:-1]
print(a)
# Judge status: Accepted
import sys
from functools import lru_cache
 
#read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**6)
def read():
  return int(readline())
def reads():
  return map(int, readline().split())
def mp(arg):
  return map(int,arg.split())

h1,m1,h2,m2,k=reads()
limit=(h2-h1)*60+m2-m1
res=0
if limit-k>=0:
    limit-=k
else:limit=0
print(limit)
# Judge status: Accepted
A, B, C = map(int, input().split())
mx = max(A, B, C)
if mx == A:
  print(10*A + B + C)
elif mx == B:
  print(10*B + C + A)
else:
  print(10*C + A + B)
# Judge status: Wrong Answer
a,b=input().split()
a=int(a)
b=float(b)
z=a*b//1
print(int(z))
# Judge status: Accepted
def resolve():
    N = int(input())
    ans = 0
    for i in range(1,N+1):
        if len(str(i))%2==1:
            ans += 1
    print(ans)

if '__main__' == __name__:
    resolve()
# Judge status: Accepted
import math as mt
N = int(input())

if N % 2 == 1 or N < 2:
    print(0)
    exit()

r = 0
L = int(mt.log(N,5))
for i in range(1,L+1):
    p = N//(5**i)//2
    r += p
    #print(N,5**i,p)
print(r)
# 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())

ans = 0
for i in range(1,N+1):
    j = N//i
    ans += i*j*(j+1)//2

print(ans)
# Judge status: Accepted
N, M = list(map(int,input().split()))
if N == 1 and M == 1:  print(1)
elif N == 1:  print(M - 2)
elif M == 1:  print(N - 2)
else:  print((N - 2) * (M - 2))
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()
s=[i for i in input()]
x=0 ; st=[[],[]]
for _ in range(int(input())):
    inp=list(map(str,input().split()))
    if len(inp)==1: x^=1
    else: st[(int(inp[1])-1)^x].append(inp[2])
if x==0:
    st[0].reverse()
    ans=st[0]+s+st[1]
elif x==1:
    st[1].reverse()
    s.reverse()
    ans=st[1]+s+st[0]
print(''.join(ans))
# Judge status: Accepted
import numpy as np
import sys

read= sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
MOD = 1000000007
sys.setrecursionlimit(10**7)


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

cnt4,cnt2 = 0,0

for i in a:
    if i%4 == 0:
        cnt4 += 1
    elif i%2 == 0:
        cnt2 += 1

cnt2 = max(1,cnt2)

print("Yes" if 2*cnt4 + cnt2 >= N else "No")
# Judge status: Accepted
N = int(input())
res = (N + 111 - 1) // 111
print(res*111)
# Judge status: Accepted
K = int(input())

def gcd(a,b):
  if b == 0:
    return a
  else:
    return gcd(b, a%b)

def gcd3(a,b,c):
  return gcd(a, gcd(b,c))

ans = 0

for x in range(1,K+1):
  for y in range(1,K+1):
    for z in range(1,K+1):
      ans += gcd3(x,y,z)

print(ans)
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
S = set(A)
M = max(S)
A.sort()

pre_a = 0
for a in A:
    if a == pre_a:
        S.discard(a)
    if a in S:
        j = a * 2
        while j <= M:
            S.discard(j)
            j += a
    pre_a = a
print(len(S))
# Judge status: Accepted
def calc_intersection():
    n = int(input())
    s = input()
    list_intersection = []

    for i in range(1, n):
        a = set(s[:i])
        b = set(s[i:])
        intersection_a_b = a.intersection(b)
        list_intersection.append(len(intersection_a_b))
    return max(list_intersection)


if __name__ == '__main__':
    print(calc_intersection())
# Judge status: Accepted
n, a, b = map(int, input().split())
if a > b:
    print(0)
elif n == 1 and a != b:
    print(0)
elif n == 1:
    print(1)
else:
    print((b-a)*(n-2)+1)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
m=1000
num=0
for x in range(N-1):
  if A[x]>A[x+1]:
    m+=A[x]*num
    num=0
  elif A[x]<A[x+1]:
    num+=m//A[x]    
    m-=A[x]*(m//A[x])
m+=A[N-1]*num
print(m)
# Judge status: Accepted
N,x=map(int,input().split())
a=list(map(int,input().split()))
a=sorted(a)
cnt=0
for i in range(N):
    if sum(a)==x:
        cnt=N
    elif sum(a)>x:
        if x>=a[i]:
            x-=a[i]
            cnt+=1
        else:
            break
    else:
        cnt=N-1

print(cnt)
# Judge status: Accepted
import numpy as np
n,k = map(int,input().split())

p = np.array(input().split(),np.int)


fs = p[:k]
f = sum(fs)
m = n - k + 1
qs = np.zeros(m)
qs[0] = f
if n == k:
    ans = (f + k)/2
    print(ans)
else:
    for i in range(k,n):
        a = qs[i-k] - p[i-k] + p[i]
        qs[i-k+1] = a
    ans = (max(qs)+k) / 2
    print(ans)
# Judge status: Accepted
import bisect,collections,copy,heapq,itertools,math,operator,string
def I(): return int(input())
def S(): return input()
def LI(): return list(map(int,input().split()))
def LS(): return list(input().split())
##################################################
S = S()
ans = 1
if 'S' in S:
    if not 'N' in S:
        ans = 0
if 'N' in S:
    if not 'S' in S:
        ans = 0
if 'E' in S:
    if not 'W' in S:
        ans = 0
if 'W' in S:
    if not 'E' in S:
        ans = 0
print({1:'Yes',0:'No'}[ans])
# Judge status: Accepted
from collections import Counter
n = int(input())
x = list(map(int,input().strip().split()))

rate = []
over = 0
for i in range(n):
  if x[i]//400 >=8:
    over += 1
  else:
    rate.append(x[i]//400)
elem = len(set(rate))

_min = elem
_max = elem +over
if elem  == 0:
  _min = 1
#if elem + over >=8:
#  _max = 8 

print(str(_min),str(_max))
# Judge status: Accepted
N, A, B = map(int, input().split())

period = N // (A + B)
number = N % (A + B)

if number >= A:
  print(A * period + A)
else:
  print(A * period + number)
# Judge status: Accepted
N,M = map(int,input().split())
E = []
for i in range(N):
  S = list(map(int,input().split()))
  S.remove(S[0])
  L = list(set(S))
  
  E.extend(L)
p = 0
for j in range (M):
  if E.count(j+1) == N:
    p += 1
print(p)
# Judge status: Accepted
import math
n, d = map(int, input().split())
arr = []
ans = 0
for i in range(n):
  x = list(map(int, input().split()))
  arr.append(x)

p = []
for i in range(n):
  for j in range(n):
    if i < j:
      p.append([i, j])

for ij in p:
  y = arr[ij[0]]
  z = arr[ij[1]]
  d = 0
  for i, j in zip(y, z):
    d += (i - j) ** 2 
  d = math.sqrt(d)
  if d == int(d):
    ans += 1
print(ans)
# Judge status: Wrong Answer
K = int(input(), 10)
S = input()

if 0 < K < 101 and 0 < len(S) < 101:
    if len(S) < K:
        print(S)
    else:
        print(S[:K] + "...") 
elif K > 100 or K < 1:
    print("Please choose an interger between 1 to 100")
elif len(S) > 100 or len(S) < 1:
    print("Please enter at least at least 1 string and not more than 100")
# Judge status: Accepted
N, K, S = map(int, input().split())
print(*([S]*K+[S+1 if S!=10**9 else S-1]*(N-K)))
# Judge status: Wrong Answer
K = input()
S = input()
K = int(K)
if len(S) < K:
    print(S)
else:
    a = S[:K] + "..."
    print(a)
# Judge status: Accepted
s="".join(input().split())
print("YES" if int(s)%4==0 else "NO")
# Judge status: Accepted
n,w=map(int,input().split())
l=[list(map(int,input().split())) for i in range(n)]

dp=[[0 for i in range(w+1)] for j in range(n+1)]

for i in range(n):
 for sum_w in range(w+1):

  if sum_w-l[i][0]>=0:
   dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w-l[i][0]]+l[i][1])

  dp[i+1][sum_w]=max(dp[i+1][sum_w],dp[i][sum_w])

print(dp[-1][-1])
# Judge status: Wrong Answer
import bisect

n = int(input())
a = list(map(int, input().split()))
A = sorted(a)
s = [0]*(n+1)
b = [0]*(n+1)
c = []
for i in range(1, n+1):
    x = a[i-1]
    s[i] = bisect.bisect_right(A, x) - bisect.bisect_left(A, x)
    if b[a[i-1]] == 0:
        c.append(s[i]*(s[i]-1)//2)
        b[a[i-1]] = 1
S = sum(c)
print(c)
for i in range(1, n+1):
    print(S - s[i] + 1)
# Judge status: Wrong Answer
k,x = map(int, input().split())
print('No' if x*500<x else 'Yes')
# Judge status: Accepted
A = int(input())
import collections
total = 0
listN = list(map(int,input().split()))
dic = collections.Counter(listN)
listB = list(dic.values())
for i in listB:
    total += i * (i-1) // 2
dic_keys = list(dic.keys())
dic_values = list(dic.values())
for i in range(len(dic_values)):
    B = dic_values[i]
    dic_values[i] = total-(B-1)
dic = {}
for i in range(len(dic_values)):
    dic[dic_keys[i]] = dic_values[i]
for i in listN:
    print(dic[i])
# Judge status: Wrong Answer
from heapq import heappush, heappop
N = int(input())
H = []
for _ in range(N):
    A, B = map(int,input().split())
    heappush(H, (B - A, A))
t = 0
for _ in range(N):
    S, A = heappop(H)
    if S > t:
        print("No")
        break
    t += A
    if len(H) == 0:
        print("Yes")
# Judge status: Wrong Answer
s=input()
ans = 0
for i in range(len(s)//2+1):
 if s[i] != s[len(s)-1-i]:
  ans+=1
print(ans)
# Judge status: Accepted
O = str(input())
E = str(input())
st = ''
if len(O) == len(E):
    for i in range(len(O)):
        st += O[i]
        st+= E[i]
    print(st)
else:
    for i in range(len(O)-1):
        st += O[i]
        st+= E[i]
    
    print(st+O[-1])
# Judge status: Accepted
n = int(input())

ans = 0
for i in range(1, n + 1):
    num = i
    digits = 0
    while num:
        digits += 1
        num //= 10
    if digits % 2 == 1:
        ans += 1

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

if (A-B)>=C:
    print("0")
else:
    print(C-A+B)
# Judge status: Accepted
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

x = I()
if x >= 30:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A, B, C = map(int, input().split())
print("Yes" if A < C < B or B < C < A else "No")
# Judge status: Accepted
s = input()
revs = s[::-1]
MAX = 0
for i in range(len(s)):
  if s[i]=="A":
    begin = i
    break
    
for i in range(len(s)):
  if revs[i]=="Z":
    end = i+1
    break
print(len(s)-end-begin+1)
# Judge status: Wrong Answer
import fractions
from functools import reduce
n,m = map(int,input().split())
a = list(map(int,input().split()))

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

b = [i//2 for i in a]
c = lcm_list(b)

if c > m:
    print(0)
else:
    d = m // c
    if d % 2 == 0:
        ans = d//2
    else :
        ans = d//2 + 1
    print(ans)
# Judge status: Accepted
from fractions import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
n,m = map(int,input().split())
a = list(map(int,input().split()))
ans = 1
for i in a:
    ans = lcm(ans,i)
for i in a:
    if (ans//i) % 2 == 0:
        print(0)
        exit()
print(((m//(ans//2))+1)//2)
# Judge status: Accepted
import collections

s = list(input())
c = collections.Counter(s)

if len(c) == 2 and c.most_common()[0][1] == 2:
  print("Yes")
else:
  print("No")
# Judge status: Wrong Answer
N = input().split()

a =int(N[0])
b =int(N[1])
c =int(N[2])
d =int(N[3])

A = min(a,d)


    
    
q = d - a

if b < q:
    print(A)
else:
    print(A - d - a -b)
# Judge status: Accepted
a, b, c = map(int,input().split())
k = int(input())
 
for i in range(k):
  if b <= a:
    b *= 2
  elif c <= b:
    c *= 2
  else:
    break
    
if a >= b or b >= c:
  print('No')
else:
  print('Yes')
# Judge status: Wrong Answer
import sys

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

    t = 0
    while True:
        for i in range(N):
            if A[i] % 2 == 0:
                A[i] //= 2
            else:
                print(t)
                sys.exit()
        t += 1
# Judge status: Accepted
s = input()
for l in [chr(i) for i in range(97, 97+26)]:
  if l not in s:
    print(l)
    exit()
print('None')
# Judge status: Accepted
import sys
input=sys.stdin.readline
from bisect import bisect_right, bisect_left
n=int(input())
a = [list(map(int, input().split())) for _ in range(3)]
a[0].sort()
a[2].sort()



cnt=0
for i in range(n):
    index_1 = bisect_left(a[0],a[1][i])
    index_2 = n-bisect_right(a[2],a[1][i])
    cnt+=index_1*index_2
print(cnt)
# Judge status: Wrong Answer
x = list(map(int, input().split()))
for i, item in enumerate(x):
  if item == 0:
    print(i)
    break
# Judge status: Wrong Answer
a, b, x = map(int,input().split())

if a+b > x:
  if a < x:
    print("YES")
else:
  print("NO")
# Judge status: Accepted
def main():
    import sys
    read = sys.stdin.buffer.read
    readline = sys.stdin.buffer.readline
    readlines = sys.stdin.buffer.readlines
    sys.setrecursionlimit(10 ** 7)

    x, n = map(int, readline().split())
    p = list(map(int, readline().split()))
    check = float('inf')
    ans = 0
    for i in range(1000):
        if i not in p:
            if check > abs(x - i):
                ans = i
                check = abs(x - i)
    print(ans)


if __name__ == '__main__':
    main()