peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
n = int(input())
if  n == 1 or n == 2 or n == 3:
    print(1)
    exit()
while n > 0:
    for i in range(n):
        for j in range(2, 10):
            if n == i**j:
                print(n)
                exit()
    n -= 1
# Judge status: Accepted
def gcd(a,b):
    while b!=0:
        a,b=b,a%b
    return a

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

if c%gcd(a, b) == 0:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
a,b,c,d=map(int,input().split())
if (abs(b-a)<=d and abs(c-b)<=d)or abs(c-a)<=d:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
s=input()

l=len(s)

ans="x"
for i in range(l-1):
    ans = ans +"x"
print(ans)
# Judge status: Accepted
n = int(input())
a = sorted(map(int, input().split()))
m = a[-1]
for i in range(n - 1):
    c = abs(a[i] - a[-1] / 2)
    if c < m:
        m = c
        r = i
print(a[-1], a[r])
# Judge status: Accepted
def count_two(n):
  count = 0
  while n % 2 == 0:
    count += 1
    n //= 2
  return count

def main():
  N = int(input())
  ans = 1
  maxv = 0
  for i in range(1, N + 1):
    tmp = count_two(i)
    if tmp > maxv:
      maxv = tmp
      ans = i
  print(str(ans))
    
if __name__ == '__main__':
  main()
# Judge status: Wrong Answer
N = int(input())
row = []
for n in range(N):
  x, l = [int(i) for i in input().split()]
  row.append((x,l))
orders = sorted(row, key=lambda x:x[0]) 

remain = N 
edge = -1000000000000000
Redge = 1000000000000000
for n in range(N):
  x0 = orders[n][0]
  l0 = orders[n][1]
  if n == N -1:
    re = Redge
  else:
    re = orders[n+1][0] + orders[n+1][1]
  if x0 - l0 < edge:
    remain -= 1
  elif x0 + l0 > re:
  	remain -= 1
  else:
    edge = x0 + l0

print(remain)
# Judge status: Accepted
x=int(input())
temp=0
for i in range(1,x+1):
  temp=temp+i
  if temp>=x:
    break
print(i)
# Judge status: Wrong Answer
import sys
import collections

s = list(map(str,input()))
t = list(map(str,input()))
cnts = collections.Counter(s)
cntt = collections.Counter(t)
cs = sorted(cnts.values())
ct = sorted(cntt.values())

print(cnts)
print(cntt)

if len(s) != len(t):
    print("No")
    sys.exit()

for i,j in zip(cnts.values(),cntt.values()):
    if i != j:
        print("No")
        sys.exit()

print("Yes")
# Judge status: Accepted
k,n = map(int,input().split())
a = list(map(int,input().split()))
a.append(a[0]+k-a[n-1])
counter = 0

for i in range(n):
  if counter < a[i+1]-a[i]:
    counter = a[i+1]-a[i]

print(min(k-counter,a[n-1]-a[0]))
# Judge status: Accepted
n,x,y=map(int,input().split())
ans=[0]*n
for i in range(1,n+1):
 for j in range(i+1,n+1):
   dist1=j-i
   dist2=abs(x-i)+abs(y-j)+1
   dist3=abs(y-i)+abs(x-j)+1
   d=min(dist1,dist2,dist3)
   ans[d]+=1
for i in range(1,n):
 print(ans[i])
# Judge status: Accepted
n=int(input())
s=str(input())
d=True

if len(s)%2==0:
  for i in range(len(s)//2):
    if s[i]!=s[len(s)//2+i]:
      d=False
else:
  d=False
  
if d:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
N = int(input())
power = 1
m = 10**9 + 7
for i in range(N):
    power = power*(i+1)
    poewr = power % m
print(power)
# Judge status: Accepted
a, b, c, x, y = map(int, input().split())
minVal = c * 2 * (10 ** 5)
for i in range(10**5):
    total = (c*2) * i + a * max(0, x-i) + b * max(0, y-i)
    minVal = min(total, minVal)
print(minVal)
# Judge status: Accepted
n = int(input())

ans = (10**n - 2*9**n + 8**n)%(10**9 + 7)

print(ans)
# Judge status: Accepted
n , a , b = map(int,input().split())
ans = 0
def digitSum(n):
    # 数値を文字列に変換
    s = str(n)
    # １文字ずつ数値化し配列にする。
    array = list(map(int, s))
    # 合計値を返す
    return sum(array)
for i in range(1,n+1):
    if a <= digitSum(i) <= b:
        ans += i
print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a<=10 and b<=10:
	print("Yay!")
else:
		print(":(")
# Judge status: Accepted
s = list(input())
n = len(s)
mae = ""
now = ""
ans = 0
for i in range(n):
    now = now + s[i]
    if mae != now:
        ans += 1
        mae = now
        now = ""
print(ans)
# Judge status: Wrong Answer
a = input().split()
b = 0
for i in range(len(a)):
    a.sort(reverse=True)
    b = b + int(a[0])
    a[0] = str(int(a[0]) - 1)
print(b)
# Judge status: Accepted
n=int(input())
ws=list(map(int,input().split()))
s1=ws[0]
s2=sum(ws[1:])
a=abs(s1-s2)
for t in ws[1:]:
    s1+=t
    s2-=t
    a=min(a,abs(s1-s2))
print(a)
# Judge status: Accepted
A = set(list(map(int,input().split())))
print(len(A))
# Judge status: Accepted
A, B, C, K = list(map(int,input().split()))
count = 0
s = 0
if A > K:
	print(K)
elif A+B > K:
	print(A)
else:
	print(2*A + B - K)
# Judge status: Wrong Answer
A, B, T = map(int, input().split())
tc = 0
n = 0
cnt = 0

if A > T + 0.5:
    pass
else:
    while tc < T + 0.5:
        n += B
        cnt += 1
        tc += cnt*A

print(n)
# Judge status: Accepted
import math
N = int(input())
print(111*math.ceil(N/111))
# Judge status: Accepted
n = int(input())
a = [int(input()) for _ in range(n)]
ans = 0
j = 0
for i in range(n):
    ans+=1
    if i==0:
      j=a[i]
    if j==2:
      print(ans)
      quit()
    j = a[j-1]
print(-1)
# Judge status: Wrong Answer
N=int(input())
L=list(map(int,input().split()))
count=0
for a in range(N):
    for b in range(N):
        for c in range(N):
            if L[a]<(L[b]+L[c]) and L[b]<(L[a]+L[c]) and L[c]<(L[b]+L[a]) and a!=b and b!=c and c!=a:
                count=count+1
            else:
                continue
print(count)
# Judge status: Accepted
A, B = map(int, input().split())

if A == B:
    print("Draw")
elif A == 1:
    print("Alice")
elif B == 1:
    print("Bob")
elif A > B:
    print("Alice")
else:
    print("Bob")
# Judge status: Wrong Answer
N=int(input())
if N in [2,4,5,7,9]: print('hon')
elif N in [0,1,6,8]: print('pon')
else: print('bon')
# Judge status: Wrong Answer
a,b,x = map(int,input().split())
div,mod = divmod(b-a,x) #1,1
if mod == 0 and a%x == 0:#
  print(div+1)
elif a%x < mod:
  print(div-1)
else:
  print(div)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
num=[0]*(max(a)+1)
for i in range(n):
    num[a[i]]+=1
ans=0
if max(a)<3:
    ans=sum(num)
else:
    for i in range(1,max(a)):
        num2=num[i-1]+num[i]+num[i+1]
        if ans<num2:
            ans=num2
print(ans)
# Judge status: Wrong Answer
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(2,n-1):
  if p[i-1]<p[i]<p[i+1] or p[i-1]>p[i]>p[i+1]:
    ans += 1
print(ans)
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
N=int(input())
S=[i for i in input()]
ans=0
for i in range(N-1):
    if S[i]=='#' and S[i+1]=='.':
        ans+=1
print(ans)
# Judge status: Accepted
N = int(input())
A = set()
for n in range(N):
    A.add(input())
print(len(A))
# Judge status: Accepted
K=int(input())
print(K//2*(K//2+K%2))
# Judge status: Accepted
import numpy as np

A = np.zeros((3,3),int)
for i in range(3):
    A[i,:] = np.array([int(x) for x in input().split()])
    
N = int(input())

for _ in range(N):
    b = int(input())
    A[A==b] = 0

ans = 'No'
if np.sum(A[0,:])==0 or np.sum(A[1,:])==0 or np.sum(A[2,:])==0 or np.sum(A[:,0])==0 or np.sum(A[:,1])==0 or np.sum(A[:,2])==0 or np.sum(A[0,0]+A[1,1]+A[2,2])==0 or np.sum(A[0,2]+A[1,1]+A[2,0])==0:
   ans = 'Yes'

print(ans)
# Judge status: Wrong Answer
import sys


def resolve():
    H, N = map(int, sys.stdin.readline().split())
    m = map(int, sys.stdin.read().split())
    AB = zip(m, m)
    INF = 10**20
    dp = [INF]*(H+10**4)
    dp[0] = 0
    for a, b in AB:
        for j in range(H+10**4):
            dp[j] = min(dp[j], dp[j-a] + b if j-a >= 0 else INF)
    return min(dp[H:])


if __name__ == 'main':
    print(resolve())
# Judge status: Wrong Answer
n, a, b = map(int, input().split())
s=input()

tp=0
up=0

for i in range(n):
  if tp >= a+b:
    print('No')
  elif s[i]=='a':
    print('Yes')
    tp+=1
  elif s[i]=='b':
    if up < b:
      print('Yes')
      tp+=1
      up+=1
  else:
    print('No')
# Judge status: Accepted
#!/usr/bin/env python
"""AtCoder Beginner Contest 167: A - Registration
https://atcoder.jp/contests/abc167/tasks/abc167_a
"""


def main():
    S = input()
    T = input()

    if S == T[0:-1]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()
# Judge status: Accepted
N=int(input())
for i in range(1,10):
    for j in range(1,10):
        if i*j==N:
            print("Yes")
            exit()
        else:
            pass
print("No")
# Judge status: Accepted
def sumNum(num, sums):
    if num == 0:
        return sums
    sums += num % 10
    num = num // 10
    return sumNum(num, sums)

N = int(input())
keta = 0

for A in range(1, N):
    B = N - A
    _A = sumNum(A, 0)
    _B = sumNum(B, 0)
    ret = _A + _B
    if keta == 0:
        keta = ret
    if keta <= ret:
        continue
    keta = ret

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

if A >= 13:
    print(B)
elif A >= 6:
    print(B // 2)
else:
    print(0)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))

for i in range(n-1):
    b = a.count(i+1)
    print(b)
# Judge status: Wrong Answer
N = int(input())
a = [int(i) for i in input().split()]

m = pow(10, 9)

s = sum(a)
for i in range(1, N):
    b = sum(a[:i])
    c = s - b
    #print(b)
    #print(c)
    if m > (abs(b-c)):
        m = abs(b-c)
print(m)
# Judge status: Accepted
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    x, y = map(int, input().split())
    inf = float('inf')
    r1 = y - x if y - x >= 0 else inf
    r2 = y - -x + 1 if y - -x >= 0 else inf
    r3 = -y - x + 1 if -y - x >= 0 else inf
    r4 = -y - -x + 2 if -y - -x >= 0 else inf
    r = min(r1, r2, r3, r4)
    print(r)

if __name__ == '__main__':
    main()
# Judge status: Accepted
def main():
    a, b, c, d = map(int, input().split())

    print(max(a * c, a * d, b * c, b * d))


if __name__ == "__main__":
    main()
# Judge status: Accepted
N = int(input())
*W, = map(int, input().split())
 
s1, s2 = 0, sum(W)
ans = sum(W)
 
for i in range(N):
  s1 += W[i]
  s2 -= W[i]
  ans = min(ans, abs(s1 - s2))
print(ans)
# Judge status: Accepted
from itertools import accumulate
from bisect import bisect_left
 
n,m,k=map(int,input().split())
a=list(accumulate([0]+list(map(int,input().split()))))
b=list(accumulate([0]+list(map(int,input().split()))))
#print(b)
mx=0
for i in range(n+1):
  if a[i]>k:continue
  #print('a[i];'+str(a[i]))
  idx=min(bisect_left(b,k-a[i]),m)
  #print(idx)
  if b[idx]>k-a[i]:idx-=1
  if a[i]+b[idx]>k:continue
  mx=max(mx,i+idx)
print(mx)
# Judge status: Wrong Answer
a = input()
if a.isupper():
    print("A")
else:
    print(a)
# Judge status: Accepted
N=int(input())
A=input().split()
A=list(map(int,A))
def can_divide_by_2():
    for i in range(N):
        a=A[i]
        if a%2==0:
            a=a//2
            A[i]=a
        else:
            return False
for u in range(1000000):
    x=can_divide_by_2()
    if x==False:
        break
print(u)
# Judge status: Accepted
# author:  Taichicchi
# created: 27.09.2020 23:04:41

import sys

x, y = map(int, input().split())

cnt = 0

while x <= y:
    x *= 2
    cnt += 1

print(cnt)
# Judge status: Accepted
A = [1,3,5,7,8,10,12]
B = [4,6,9,11]
C = [2]

x,y = map(int, input().split())

if (x in A and y in A) or (x in B and y in B) or (x in C and y in C):
	print('Yes')
else:
	print('No')
# Judge status: Wrong Answer
n = int(input())
s = list(reversed(input()))
t = list(input())


for idx, (ss, tt) in enumerate(zip(s,t)):
    if ss != tt:
        break
if list(reversed(s)) == t:
    print(len(s))
else:
    print(n + n - idx)
# Judge status: Wrong Answer
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

r1 = []
for j in range(N):
	if T[j] == 'r':
		r1.append(P)
	elif T[j] == 's':
		r1.append(R)
	else:
		r1.append(S)

for i in range(K,N):
	if r1[i] == r1[i - K]:
		if r1[i] != r1[i - K * 2] and (i - K * 2) > -1:
			r1[i] = 0
print(sum(r1))
# Judge status: Accepted
k, x = map(int, input().split())
s = x - k + 1
e = x + k - 1
l = list(range(s, e+1))
print(' '.join(map(str, l)))
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = 0
for i in range(1, 2*N, 2):
  ans += A[i]
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
k=int(input())
d={"a":a,"b":b,"c":c}
for i in range(k+1):
    if d["a"]<d["b"]<d["c"]:
        print("Yes")
        exit()
    elif d["a"]>=d["c"]:
        d["c"]*=2
    elif d["a"]>=d["b"]:
        d["b"]*=2
    elif d["b"]>=d["c"]:
        d["c"]*=2
print("No")
# Judge status: Wrong Answer
n = int(input())
d = [int(i) for i in input().split()]
d.sort()
c = 0
y = d[len(d)//2-2:len(d)//2+2]


for k in range(min(y), max(y)):

	arc = []
	abc = []

	for j in d:
		if k <= j:
			arc.append(j)
		else:
			abc.append(j)
			
	if len(arc) == len(abc):
		c+=1 

print(c)
# Judge status: Accepted
A = [int(input()) for i in range(5)]
B = [(10 - a % 10) % 10 for a in A]
print(sum(A) + sum(B) - max(B))
# Judge status: Wrong Answer
# AtCoder
from collections import Counter
N, M = map(int, input().split())
A = Counter(list(map(int, input().split())))

for i in range(M):
    b, c = map(int, input().split())
    A[c] += b

A = sorted(A.items(), reverse=True, key=lambda x: x[0])

ans = 0
for n, c in A:
    if N > c:
        ans += n*c
        N -= c
    else:
        ans += n*c
        print(ans)
        exit()
# Judge status: Accepted
n, k = map(int, input().split())
BASE = 10**9 + 7

def sm(mn :int, mx :int) -> int:
    n = mx - (mn - 1)
    return int((mx + mn) * (n / 2))

cnt = 0
for i in range(k, n+2):
    mn, mx = sm(0, i-1), sm(n-(i-1), n)
    cnt += mx - (mn-1)
    cnt = cnt % BASE
print(cnt)
# Judge status: Accepted
s = input()
slen = len(s)
for i in range(1, slen):
    s = s[:-1]
    slen = len(s)
    if i % 2 == 0:
        half = slen // 2
        if s[half:] == s[:half]:
            print(slen)
            break
# Judge status: Accepted
from collections import Counter

c=Counter(input())
l=sorted([c["a"],c["b"],c["c"]])

if l[0]==l[1]==0:print("YES" if l[2]==1 else "NO");exit()
if l[0]==0:print("YES" if l[1]==l[2]==1 else "NO");exit()
if l[0]==l[1]==l[2]:print("YES")
elif l[0]+1==l[1]==l[2]:print("YES")
elif l[0]+1==l[1]+1==l[2]:print("YES")
else:print("NO")
# Judge status: Accepted
a, b, c = map(int, input().split())
if len(set([a,b,c])) == 2:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
# https://atcoder.jp/contests/tenka1-2019-beginner/tasks/tenka1_2019_c

from copy import deepcopy
n = int(input())
s = list(input())
t = deepcopy(s)
t1 = 0
for i in range(n - 1):
    if s[i] == '#' and s[i + 1] == '.':
        t1 += 1
        s[i + 1] = '#'

t2 = 0
for i in range(n - 1)[::-1]:
    if t[i] == '#' and t[i + 1] == '.':
        t2 += 1
        t[i] = '.'
ans = min(t1, t2)
print(ans)
# Judge status: Wrong Answer
n=int(input())
s=[]
while n!=0:
    r=n%(-2)
    if r<0:
        r+=2
    n=(n-r)//(-2)
    s.append(str(r))
s.reverse()
print(''.join(s))
# Judge status: Accepted
s = str(input())
Alst = []
Zlst = []
for i in range(len(s)):
    if s[i]=='A':
        Alst.append(i)
    elif s[i]=='Z':
        Zlst.append(i)
print(max(Zlst)-min(Alst)+1)
# Judge status: Accepted
N, M = map(int, input().split())

if N % 2 == 1:
    for a in range(1, M + 1):
        print(a, N - a + 1)
else:
    for a in range(1, M + 1):
        print(a, N - a + (a <= N // 4))
# Judge status: Accepted
a,b,x = map(int,input().split())

cnt = b // x - (a - 1) // x

print(cnt)
# Judge status: Accepted
S = str(input())

if S == "ABC":
    print("ARC")
else:
    print("ABC")
# Judge status: Accepted
k, s = map(int, input().split())
cnt = 0
for x in range(k + 1):
    for y in range(k + 1):
        z = s - x - y
        if 0 <= z <= k:
            cnt += 1
print(cnt)
# Judge status: Accepted
n = int(input())
c = 0
for i in range(1, n + 1):
    if 1 <= i <= 9 or 100 <= i <= 999 or 10000 <= i <= 99999:
        c += 1
print(c)
# Judge status: Wrong Answer
n, x = map(int, input().split())
a = list(map(int, input().split()))
original = x
a.sort()

cnt = 0
for i in a:
    if x >= i:
        x -= i
        cnt += 1
    else:
        break
if original != sum(a) and cnt == x:
    cnt -= 1

print(cnt)
# Judge status: Wrong Answer
list=list(map(int,input().split()))
a=list.count(1)

print(a)
# Judge status: Accepted
a,b,c = map(int,input().split())
print('Yes' if a<=c<=b else 'No')
# Judge status: Accepted
r=int(input())
L=2.0*3.1415926*r
print(L)
# Judge status: Accepted
n = int(input())
sp = []
for i in range(n):
  s,p = input().split()
  sp.append([s, 100 - int(p), i+1])
sp.sort()
ans = []
for s,p,i in sp:
  ans.append(i)
print("\n".join(map(str, ans)))
# Judge status: Accepted
n = int(input())
X = list(map(int,input().split()))

S = sorted(X)
ml = S[n//2-1]
mr = S[n//2]
for x in X:
  if x <= ml:
    print(mr)
  else:
    print(ml)
# Judge status: Wrong Answer
num = input()
ans = []
for n in range(len(num)-3):
	tmp = int(num[n:n+3])
	i = 753 - tmp
	if i < 0:
		i *= -1
	ans.append(i)
print(min(ans))
# Judge status: Accepted

a,v = map(int, input().split())
b,w = map(int, input().split())
t = int(input())

if a < b:
    b1 = w*t + b
    a1 = v*t + a
    if a1 >= b1:
        flag = 1
    else:
        flag = 0
elif a > b:
    b1 = -w*t + b
    a1 = -v*t + a
    if a1 <= b1:
        flag = 1
    else:
        flag = 0
if flag == 0:
    print("NO")
else:
    print("YES")
# Judge status: Accepted
N = int(input())
a1 = list(map(int, input().split()))
a2 = list(map(int, input().split()))
print(max(sum(a1[:i+1])+sum(a2[i:]) for i in range(N)))
# Judge status: Wrong Answer
a = 12
b = 11
c = a * b
if c % 2 == 0:
  print ('Even')
else:
  print ('Odd')
# Judge status: Accepted
n = int(input())
print(n *(n - 1) // 2)
# Judge status: Accepted
n = input()

nn = list(n)
flag = 0

for i in range(3):
    if nn[i] == '7':
        flag += 1

if flag >= 1:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer

S, T = input().split()
A, B = map(int, input().split())
U = input()

if "S"=="U":
    print(A-1, B)
else :
    print(A, B-1)
# Judge status: Accepted
N = int(input())
A = [list(map(int, input().split())) for i in range(2)]
sum_list = [sum(A[0][0:i+1])+sum(A[1][i:N]) for i in range(N)]
print(max(sum_list))
# Judge status: Accepted
s = input()
k = len(s)
a = [0]*(k+1)
for i in range(k):
  if s[i] == '<':
    a[i+1] = max(a[i+1],a[i]+1)
for j in range(k-1,-1,-1):
  if s[j] == '>':
    a[j] = max(a[j],a[j+1]+1)
print(sum(a))
# Judge status: Accepted
A, B, C, X, Y = list(map(int, input().split()))

ans = A*X + B*Y
c = min(X, Y)
ans = min(A*(X-c) + B*(Y-c) + c*C*2, ans)
c = max(X, Y)
ans = min(c*C*2, ans)

print(ans)
# Judge status: Accepted
import sys
input=sys.stdin.readline
from bisect import bisect_left
N = int(input())
#S = input()[:-1]
#N,M = map(int,input().split())
#S,T = map(str,input().split())
A = list(map(int,input().split()))
#A = [int(input()) for _ in range(N)]
#S = [input() for _ in range(N)]
#A = [list(map(int,input().split())) for _ in range(N)]
d = 0
A.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        s = A[i]+A[j]
        dex = bisect_left(A,s)
        if dex > j:
          d += dex -j -1
print(d)
# Judge status: Accepted
def main():
    S = input()
    N = len(S)
    if S == "keyence":
        print("YES")
        return
    for i in range(N):
        for j in range(i + 1, N + 1):
            cand = S[:i] + S[j:]
            if cand == "keyence":
                print("YES")
                return

    print("NO")
    return


main()
# Judge status: Accepted
S = input()
T = input()

count = 0
for i in range(len(S)):
    if S[i] != T[i]:
        count += 1

print(count)
# Judge status: Accepted
import sys
import math
import bisect

def main():
    A = list(map(int, input().split()))
    A.sort()
    if len(A) == 3 and A == [5, 5, 7]:
        print('YES')
    else:
        print('NO')

if __name__ == "__main__":
    main()
# Judge status: Accepted
a = [int(i) for i in input().split()]

if sum(a) >= 22:
  print('bust')
else:
  print('win')
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
if all(i%3==0 or i%5==0 for i in A if i%2==0):
    print('APPROVED')
else:
    print('DENIED')
# Judge status: Accepted
#!/usr/bin/env python3

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

ans = 0 
for i in range(n):
    if i==0:
        ans += b[0]
    elif i==n-1:
        ans += b[n-2]
    else:
        ans += min([b[i-1], b[i]])
print(ans)
# Judge status: Accepted
(A, V) = map(lambda a: float(a), input().split())
(B, W) = map(lambda a: float(a), input().split())
T = float(input())

D = abs(A - B)
X = V - W

if (X*T >= D):
  print("YES")
else:
  print("NO")
# Judge status: Accepted
n = int(input())

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

a.sort(reverse=True)

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

print(kotae)
# Judge status: Accepted
n=int(input())
import math
for i in range(int(math.sqrt(n)),0,-1):
  if n%i==0:
    print(i+n//i-2)
    break
# Judge status: Wrong Answer
s=int(input())
a=[s]
i=0
while i<100:
  if a[i]%2==0:
    a.append(a[i]//2)
  else:
    a.append(a[i]*3+1)
  if a[i+1] in a[:i]:
    print(i+2)
    exit()
  i+=1
# Judge status: Wrong Answer
a,b,c = map(int,input().split())
k = int(input())

i = 0
for i in range(k):
    if(b>c):
        c = c*2
    elif(a>b):
        b = b*2
    else:
        break
if(a<b<c):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
A = input().split()
res = []
for i in A:
  if i not in res:
    res.append(i)

if len(res) == 2:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
MM = input().split()
A = int(MM[0])
B = int(MM[1])
C = int(MM[2])
K = int(input())
S = [A,B,C]
S.sort()
S[-1] = S[-1] * 2 *K
total =0
for i in S:
  total += i
print(total)
# Judge status: Accepted
a, b, c = map(int, input().split())
if min(a,b) < c < max(a,b):
	print("Yes")
else:
	print("No")
# Judge status: Accepted
S = input()
ans = len(S)
cntS = 0
for i in range(len(S)):
    if (S[i] == 'S'):
        cntS += 1
    else:
        if (cntS > 0):
            cntS -= 1
            ans -= 2
        else: cntS = 0
print(ans)
# Judge status: Wrong Answer
s,t = raw_input().split(' ')
print s+t
# Judge status: Accepted
n = int(input())
a = [int(x) for x in input().split()]
a.sort()
ans = []
for i in range(a[0], a[-1]+1):
    cnt = 0
    for j in range(n):
        cnt += (a[j] - i)**2
    ans.append(cnt)

print(min(ans))
# Judge status: Accepted
N = int(input())
l = [int(x) for x in input().split()]

if 0 in l:
    ans = 0
else:
    n = min(N,len(l))
    ans = 1
    for i in l[:n]:
        ans *= i
        if ans > 10**18:
            ans = -1
            break
print(ans)
# Judge status: Accepted
import sys
readline = sys.stdin.readline

N = int(readline())
ans = []
import bisect
for i in range(N):
  a = -int(readline())
  ind = bisect.bisect_right(ans, a)
  if ind == len(ans):
    ans.append(a)
  else:
    ans[ind] = a
    
print(len(ans))
# Judge status: Accepted
n = int(input())
s = str(input())
t = str(input())
z = s + t
for i in range(n):
    if s[i:] == t[:n-i]:
        z = s + t[n-i:]
        break
print(len(z))
# Judge status: Accepted
n,m=map(int,input().split())
a=[]
for i in range(n):
  a.append(input())
b=[]
for i in range(m):
  b.append(input())

res=0
for i in range(0,n-m+1):
  for k in range(0,n-m+1):
    keep=0
    for j in range(i,i+m):    
      if b[j-i] in a[j][k:k+m]:
        keep+=1
      if keep==m:
        print("Yes")
        res=1
        break
  if res==1:
    break
if res==0:
  print("No")
# Judge status: Wrong Answer
import collections

N = int(input())
A = map(int, input().split())
A_count = dict(collections.Counter(A))
A_countsort = sorted(A_count, reverse=True)
# print(A_countsort)
hen_list = []
for key in A_countsort:
    if A_count[key] >= 2:
        hen_list.append(key)
if len(hen_list) >= 2:
    print(hen_list[0]*hen_list[1])
else:
    print(0)
# Judge status: Accepted
ma = lambda :map(int,input().split())
lma = lambda :list(map(int,input().split()))
tma = lambda :tuple(map(int,input().split()))
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq
import sys
n,T = ma()
ans=10**15
for i in range(n):
    c,t=ma()
    if t<=T:
        ans=min(ans,c)
if ans==10**15:
    print("TLE")
else:print(ans)