peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
from collections import defaultdict
n,k=map(int,input().split())
ab=[input() for i in range(n)]
d = defaultdict(list)
[d[int(i.split()[0])].append(int(i.split()[1])) for i in ab]
sd=sorted(d.items(), key=lambda x:x[0])
c=0
for i,l in sd:
  c+=sum(l)
  print(i,l)
  if c>=k:
    print(i)
    exit()
# Judge status: Accepted
n = int(input())
p = list(map(int,input().split()))
cnt = 0
for i in range (1,n-1):
  if p[i] <= p[i-1] and p[i] > p[i+1]:
    cnt += 1
  if p[i] <= p[i+1] and p[i] > p[i-1]:
    cnt += 1
print(cnt)
# Judge status: Accepted
import sys
N, A, B = map(int, input().split())

if A > B:
    print(0)
    sys.exit(0)
if N == 1:
    if A == B:
        print(1)
    else:
        print(0)
    sys.exit(0)

x = B*(N-1)+A
n = A*(N-1)+B
print(x-n+1)
# Judge status: Accepted
import sys
from copy import copy


N, K, *D = map(int, open(0).read().split())


candidate = sorted(list({i for i in range(10)} - set(D)))
like_integer = copy(candidate)
  
# 1桁の場合を判定
for j in candidate:
  if j >= N:
    print(j)
    sys.exit()
    
for i in range(1, 6):  
  order = 10 ** i
  
  
  _candidate = []
  for l in like_integer:
    for c in candidate:
      lc = order * l + c
      if lc >= N:
        print(lc)
        sys.exit()
      _candidate.append(lc)
  candidate = _candidate
# Judge status: Wrong Answer
n = int(input())
array1 = []
array2 = []
for i in range(n):
  x,y = map(int,input().split())
  array1.append(abs(x+y))
  array2.append(abs(x-y))
  
print(max(max(array1)-min(array1), max(array2)-min(array2)))
# Judge status: Accepted
s=input()
AC="AC"
if not s[0]=="A":
  AC="WA"
s=s[1:]  
if not s[1:-1].count("C")==1:
  AC="WA"
s=s.replace("C","c")


if not s.islower():
  AC="WA"
  
print(AC)
# Judge status: Accepted
n = int(input())
s = list(input())

ans = [None] * (n-1)

for i in range(1,n):
  a = s[0:i]
  b = s[i:n]

  ans[i-1] = len(set(b))-len((set(b)-set(a)))

ans.sort(reverse = True)

print(ans[0])
# Judge status: Accepted
s = str(input())

if s[2] == s[3] and s[4] == s[5]:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
n,k,s = map(int,input().split())
rem = s+1
if rem > 10**9:
    rem = 1
li = []
for i in range(n):
    if i < k:
        li.append(s)
    else:
        li.append(rem)
print(*li)
# Judge status: Wrong Answer
s = input()

A = 0
B = 0
C = 0

for x in s:
    if x == 'a':
        A += 1
    elif x == 'b':
        B += 1
    else:
        C += 1

l = sorted([A, B, C])

print('YES' if l[2] == l[1] else 'NO')
# Judge status: Accepted
S = input()

if S == 'SUN':
    print('7')

elif S == 'MON':
    print('6')

elif S == 'TUE':
    print('5')

elif S == 'WED':
    print('4')

elif S == 'THU':
    print('3')

elif S == 'FRI':
    print('2')

elif S == 'SAT':
    print('1')
# Judge status: Wrong Answer
x = int(input())
print(x//500*500*2+x%500)
# Judge status: Accepted
n = int(input())
a = sorted(list(map(int,input().split())))
u = 10**18
ans = 1
for i in a:
    ans *= i
    if i == 0:
        print(0)
        exit()
    if ans > u:
        print(-1)
        exit()
print(ans)
# Judge status: Accepted
from fractions import gcd
from functools import reduce

def lcm_base(x, y):
    return (x * y) // gcd(x, y)
def lcm_list(nums):
    return reduce(lcm_base, nums, 1)

def main():
    n = int(input())
    t = [int(input()) for _ in range(n)]
    print(lcm_list(t))

if __name__ == '__main__':
    main()
# Judge status: Accepted
from fractions import gcd
N = int(input())
A = list(map(int, input().split()))
 
ans = 0
MOD = 1000000007
 
LCM = A[0]
for i in range(1, N):
    LCM *= A[i] // gcd(LCM, A[i])
    
for a in A:
  ans += LCM // a
  
print(ans%MOD)
# Judge status: Accepted
N = int(input())
l = [0]*(10**6+1)
for a in map(int,input().split()) :
    l[a] += 1
ans = 0

for i in range(1, 10**6 + 1) :
    if l[i] == 1 :
        ans += 1
    if l[i] > 0 :
        for j in range(i , 10**6 + 1, i) :
            l[j] = 0

print(ans)
# Judge status: Accepted
n,a,b = list(map(int, input().split()))
print(max(0, (b-a)*(n-2)+1))
# Judge status: Wrong Answer
A=''.join(input().split())
ans=0

for i in range(1, len(A)):
    ans=max(ans, eval(A[:i]+'+'+A[i:]))
    
print(ans)
# Judge status: Wrong Answer
n = int(input())

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

b = [0] * 9 
for i in range(n):
  if a[i] // 400 < 8:
    b[a[i] // 400] += 1
  else:
    b[8] += 1

minsum = 0
maxsum = 0
for i in range(8):
  if b[i] > 0:
    minsum += 1
maxsum = minsum
maxsum += b[8]
if maxsum == 0:
  maxsum = 1
print("{} {}".format(minsum, maxsum))
# Judge status: Accepted
A=input()
if "9" in A:
   print("Yes")
else:
   print("No")
# Judge status: Wrong Answer
#heapだけ？
#x<=a,y<=b
import heapq
x,y,a,b,c = map(int, input().split( ))

*p, = map(int, input().split( ))
*q, = map(int, input().split( ))
*r, = map(int, input().split( ))
#p = [(pi,0) for pi in p_]
#q = [(qi,1) for qi in q_]
#r = [(ri,2) for ri in r_]
p = p[-x:]
q = q[-y:]
e = p+q
heapq.heapify(e)
assert (len(e)==x+y)
for ri in r:
    heapq.heappush(e,ri)
    heapq.heappop(e)
print(sum(e))
# Judge status: Wrong Answer
S = input()
if S[5:7] == 12>=5:
  print("TBD")
else:
  print("Heisei")
# Judge status: Wrong Answer
A, B = map(int, input().split(" "))
if A < B:
    print(B * (B - 1))
elif A == B:
    print(A * 2)
else:
    print(A * (A - 1))
# Judge status: Accepted
N=int(input())
if N<1000:
  print('ABC')
else:
  print('ABD')
# Judge status: Accepted
N,K = map(int,input().split())

if N%K==0:
  print(0)
else:
  print(1)
# Judge status: Accepted
n=int(input())
p=list(map(int,input().split()))
ans=0
for i in range(1,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: Accepted
N = input()
if (N[0] == N[1]) and (N[1] == N[2]):
    print('Yes')
elif (N[1]==N[2]) and (N[2] == N[3]):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
def main(s: str):
    ans = 1

    prev = s[0]
    for s in s[1:]:
        if s == prev:
            prev += s
        else:
            prev = s
            ans += 1

    if len(prev) == 2: ans += 1

    print(ans)


if __name__ == "__main__":
    s = input()

    main(s)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
s=sum(a)
res=0
m=1

for i in a:
    b=m-i
    if b<0:
        print(-1)
        exit(0)
    res+=i
    res+=b
    s-=i
    m=min(b*2,s)
print(res)
# Judge status: Wrong Answer
a,b=(int(x) for x in input().split())
c = ( a + b ) % 3
if (str(c) == '0'):
    print ( 'Possible' )
else:
    print ( 'Impossible' )
# Judge status: Accepted
a,b = input().split()

s = int(a+b)
ans = "No"
for i in range(1,1000):
    if s/i == i:
        ans = "Yes"

print(ans)
# Judge status: Wrong Answer
s = str(input())
alphabet = ["a","b","c","d","e","f"
,"g","h","i","j","k","l","m","n",
"o","p","q","r","s","t","u","v","w","x","y","z"]

for i in s:
    if i in alphabet:
        alphabet.remove(i)
if len(alphabet)!=0:
    print(alphabet[0])
else:
    print("None")
# Judge status: Wrong Answer
N = int(input())

locx = 0
locy =0
time = 0
for i in range(N):
  t,x,y = map(int,input().split())
  time = t-time
  dis = abs(locx-x)+abs(locy-y)
  if (time-dis)<0 :
    print("No")
    exit()
  if (time-dis)%2 == 1:
    print("No")
    exit()
    
  
  
  locx = x
  locy = y
    
  
else :
  print("Yes")
# Judge status: Wrong Answer
N = int(input())
p = list(map(int,input().rstrip().split(" ")))
ans = 0
swap = 0
for i in range(N - 1):
    if p[i] == i + 1:
        swap = p[i]
        p[i] = p[i + 1]
        p[i + 1] = swap
        ans += 1
print(ans)
# Judge status: Accepted
t = int(input())
if t >= 30:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
# APC 001: A – Two Integers
x, y = map(int, input().split())
print('-1' if x % y == 0 else x * y)
# Judge status: Accepted
a,b=map(int,input().split())
print("Even" if a*b % 2 == 0 else "Odd")
# Judge status: Wrong Answer
import math

n=int(input())

def ts(x):
    return x*(x+1)
m=n
for i in range(math.ceil(math.sqrt(2*n)-2),math.floor(math.sqrt(2*n))+1,1):
    if ts(i)<=2*n<=ts(i+1):
        m=i+1
        break

a=n%(m+1)
b=n//(m+1)
if a!=0:
    print(a)
i=1
c=0
while c!=b:
    if i!=a and n+1-i!=a:
        print(i)
        print(m+1-i)
        c+=1
# Judge status: Wrong Answer
a, b, c = map(int, input().split())

if a == b == c:
    print(-1)
    exit()

if a % 2 != 0 or b % 2 != 0 or c % 2 != 0:
    print(0)
    exit()

N = (a + b + c) // 3
cnt = 1
while N:
    if N % 2 != 0: break
    N //= 2
    cnt += 1

print(cnt)
# Judge status: Wrong Answer
x = int(input())
Y = [500, 100, 50, 10, 5, 1]
ans = 0
for i in Y:
    if i == 500:
       ans +=  (x // i)*1000
    elif i == 5:
        ans +=  (x // i)*5
    x -= (x//i)*i
    if x == 0:
        break
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
s=0
for i in range(n-1):
    if a[i+1]<a[i]:
        t=a[i]-a[i+1]
        s+=t
        a[i+1]+=t
print(s)
# Judge status: Wrong Answer
X, Y, A, B, C = map(int, input().split())
ps = sorted(map(int, input().split()), reverse = True)
qs = sorted(map(int, input().split()), reverse = True)
rs = sorted(map(int, input().split()), reverse = True)

red_apples = X
green_apples = Y

while red_apples > 0 and X - red_apples < C and rs[X-red_apples] > ps[red_apples-1]:
    red_apples -= 1

while green_apples > 0 and X+Y-red_apples-green_apples < C and rs[X+Y-red_apples-green_apples] > qs[green_apples-1]:
    green_apples -= 1

print(sum(ps[:red_apples]) + sum(qs[:green_apples]) + sum(rs[:X+Y-red_apples-green_apples]))
# Judge status: Accepted
import sys
import math

K = int(input())
A, B = map(int, sys.stdin.readline().strip().split())

if B >= math.ceil(A / K) * K:
    print('OK')
else:
    print('NG')
# Judge status: Wrong Answer
from itertools import groupby

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

D = {
    'L': 0,
    'R': 0
}

for val, it in groupby(input()):
    D[val] += 1

if D['L'] == D['R']:
    u = 2 * max([0, D['L'] - k]) + (D['L'] - k == 0)
else:
    u = 1 + 2 * max([0, min(D.values()) - k])

print(n - u)
# Judge status: Accepted
s=list(input())
top=bool()
t=[]
u=[]
n=int(input())
for i in range(n):
  q=list(map(str,input().split()))
  if q[0]=='1':
    top=not top
  else:
    if (q[1]=="1") ^ top:
      t.append(q[2])
    else:
      u.append(q[2])
s=list(reversed(t))+s+u
if top:
  print(*list(reversed(s)),sep='')
else:
  print(*s,sep='')
# Judge status: Wrong Answer
s = input()
ans = 0
for i in range(1, len(s) // 2 - 1):
  if s[:i] == s[i:2*i]:
    ans = 2 * i
print(ans)
# Judge status: Accepted
import math

n=int(input())

for i in range(n,0,-1):
    if math.sqrt(i).is_integer():
        print(i)
        break
# Judge status: Wrong Answer
N = int(input())
count = 0
for i in range(1,N+1):
  if i % 2 == 1:
    count+=1
    
print(count)
# Judge status: Accepted
a=int(input())
if a%2==0:
  print(int(a*a/4))
else:
  print(int(((a+1)*(a-1))/4))
# Judge status: Accepted
import sys

def solve():
    input = sys.stdin.readline
    S = input().strip("\n")
    if S[0] == "S": print("Cloudy")
    elif S[0] == "C":print("Rainy")
    else: print("Sunny")
    return 0

if __name__ == "__main__":
    solve()
# Judge status: Wrong Answer
c = str(input())
for c in "aiueo":
  print("vowel")
else:
  print("consonant")
# Judge status: Wrong Answer
S,T = input().split()


ans = S + T

print(ans)
# Judge status: Accepted
# coding: utf-8


def solve(*args: str) -> str:
    h1, m1, h2, m2, k = map(int, args[0].split())
    return str((h2-h1)*60 + (m2-m1) - k)


if __name__ == "__main__":
    print(solve(*(open(0).read().splitlines())))
# Judge status: Accepted
N = int(input())

ans = 10 ** 18

for i in range(1, int(N ** 0.5 + 0.5) + 1):
    if N % i == 0:
        walk = i + N // i - 2
        ans = min(ans, walk)

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

if (a < 10 and b < 10):
  print(a*b)
else:
  print(-1)
# Judge status: Accepted
n = input()

if n.islower():
  print('a')
else:
  print('A')
# Judge status: Wrong Answer
n=int(input())
for p in range(2, n):
    if n % p != 0:
        print(n)
        break
    else:
       n=n+1
# Judge status: Accepted
s=list(input())
o=['R','U','D']
e=['L','U','D']
for i in range(len(s)):
    if (i+1)%2==0:
        if s[i] not in e:
            print("No")
            exit()
    else:
        if s[i] not in o:
            print("No")
            exit()
print("Yes")
# Judge status: Wrong Answer
N=list(reversed(input()))
ans=0
old=0
k=[]
for n in N:
    if int(n)+old<=5:
        ans+=int(n)+old
        k.append([int(n)+old,int(n)])
        old=0
    else:
        ans+=10-(int(n)+old)
        k.append([10-(int(n)+old),int(n)])
        old=1
if old==1:
    ans+=1
print(ans)
# Judge status: Accepted
N = int(input())

cnt = 0
for a in range(1, 10 ** 6 + 1):
    for b in range(1, 10 ** 6 + 1):
        if N - a * b <= 0:
            break
        if N - a * b > 0:
            cnt += 1

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

# def lcm(a,b): return a*b//gcd(a,b)

n = int(input())

ans = 1
for i in range(n):
    t = int(input())
    ans = lcm(t, ans)
print(ans)
# Judge status: Wrong Answer
import math

def main():
    N = int(input())
    for a in range(1, int(math.sqrt(N)))[::-1]:
        if N % a == 0:
            b = N // a
            print(a + b - 2)
            return

if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
ratelist = [1, 400, 800, 1200, 1600, 2000, 2400, 2800, 3200]
rate = [0] * n
count = 0
for i in range(n):
    rate[i] = sum([A[i] >= j for j in ratelist])
    if rate[i] == 9:
        count += 1
ans = len(set(rate))
if count > 0:
    ans -= 1
print('{} {}'. format(max(1, ans), ans + count))
# Judge status: Accepted
import sys
input=sys.stdin.readline

n,W=map(int,input().split())
items=[list(map(int,input().split())) for i in range(n)]
import numpy as np

dp=np.zeros([n+1,W+1],dtype=np.int64)
for i in range(n):
  w=items[i][0]
  v=items[i][1]
  dp[i+1][:w]=dp[i][:w]
  dp[i+1][w:]=np.maximum(dp[i][w:],dp[i][:-w]+v)
print(dp[-1][-1])
# Judge status: Accepted
z = input().split()
a=int(z[0])
b=int(z[1])
c=int(z[2])
k=int(z[3])
res=0

if k>=a:
 res=res+a
 if k-1>=b:
   res=res+b-b
   if k-(a+b)>=c:
    res=res+c-2*c
   else:
    res=res+(k-a-b)-2*(k-a-b)
 else:
   res=res+(k-a)-(k-a)
else:
 res=res+k
print(res)
# Judge status: Accepted
N, Q = map(int, input().split())
S = input()
query = [input().split() for i in range(Q)]
AC = [0 for i in range(N+1)]

for i in range(N):
    AC[i+1] = AC[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    L, R = int(query[i][0]), int(query[i][1])
    print(AC[R-1] - AC[L-1])
# Judge status: Accepted
import math

s=input()
count=0
a=-1
  
for i in range(math.floor(len(s)/2)):
  if s[i]!=s[a]:
    count+=1
  a+=-1
  
print(count)
# Judge status: Accepted

A = list(map(int, input().split()))
if sum(A) > 21:
    print("bust")
else:
    print("win")
# Judge status: Accepted
n=int(input())
x=[input() for _ in range(n)]
ans='Yes'
if len(x)==len(set(x)):
  for i in range(n-1):
    if x[i][-1]!=x[i+1][0]:
      ans='No'
      break
else:
  ans='No'
print(ans)
# Judge status: Accepted
N = int(input())

if N < 10:
  print(N)
elif N < 100:
  print(9)
elif N < 1000:
  print(N - 90)
elif N < 10000:
  print(909)
elif N < 100000:
  print(N - 9090)
elif N == 100000:
  print(90909)
# Judge status: Wrong Answer
import copy

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

As = [copy.copy(Bs[0])]
As.extend(copy.copy(Bs))

#print(Bs)
#print(As)

for index, B in enumerate(Bs):
    print(Bs)
    print(As)
    if B < As[index]:
        As[index] = B

#print(As)
print(sum(As))
# Judge status: Accepted
sx,sy,tx,ty = map(int,input().split())
ans = 'R'*(tx-sx)+'U'*(ty-sy) + 'L'*(tx-sx) +'D'*(ty-sy) + 'D' + 'R'*(tx-sx+1) + 'U'*(ty-sy+1)+ 'L' + 'U' + 'L'*(tx-sx+1) + 'D'*(ty-sy+1) + 'R'
print(ans)
# Judge status: Accepted
k, y = [int(i) for i in input().split()]
print('Yes' if 500 * k >= y else 'No')
# Judge status: Wrong Answer
n = int(input())
A = list(map(int, input().split()))

xor = 0
for a in A:
    xor ^= a
result = []
for a in A:
    result.append(xor ^ a)
print(result)
# Judge status: Accepted
N, K = map(int, input().split())
H = [int(input()) for i in range(N)]

H.sort()
ans = float("inf")
for i in range(N-K+1):
	ans = min(ans, H[i+K-1]-H[i])

print(ans)
# Judge status: Wrong Answer
A,B= map(int,input().split())
if A>=13:
    print(B)
elif A<=12 & A>=6:
    print(B/2)
elif A<=5:
    print(0)
# Judge status: Accepted
N, = map(int, input().split())
X = list(map(int, input().split()))
R = [0]*N
for x in X:
    R[x-1] += 1
for r in R:
    print(r)
# Judge status: Wrong Answer
INT_MAX=10**18+7
MOD=10**9+7
def INPUT():return list(int(i) for i in input().split())
def LIST_1D_ARRAY(n):return [0 for _ in range(n)]
def LIST_2D_ARRAY(m,n):return [[0 for _ in range(n)]for _ in range(m)]
#################################################################################
a,b,c=INPUT()
if a==5 and b==7 and c==5:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
s=input()
k=int(input())

for i in range(k):
	if s[i]!="1":
		print(s[i])
		break
else:
	print("1")
# Judge status: Accepted
n = str(input())
ans = 0
for x in n:
  ans+=int(x)
if ans==1:
  ans=10
print(ans)
# Judge status: Accepted
import math

n,k = map(int,input().split())
c = 0
for i in range(1,n+1):
  if i >= k:
    c += 1
  else:
    s = math.ceil(math.log2(k/i))
    c += (1/2)**s
print(c/n)
# Judge status: Wrong Answer
X = input()
X_int = int(X)

if 360%X_int==0:
  print( int( 360 / X_int) )
else:
  print( 360 )
# Judge status: Wrong Answer
n, m = map(int, input().split())
result = []
x = [i for i in range(1, 2*m+2)]
for i in range(m):
    result.append([x[i], x[-i-1]])
for j in result:
    print(*j)
# Judge status: Accepted
import sys
from collections import deque, Counter, defaultdict
from fractions import gcd
input = sys.stdin.readline

def main():
    n = int(input())
    As = [int(input()) for i in range(n)]
    sAs = sorted(As)
    mn1 = sAs[-1]
    mn2 = sAs[-2]
    for i in range(n):
        if As[i] == mn1:
            print(mn2)
        else:
            print(mn1)
    return 

if __name__ == '__main__':
    main()
# Judge status: Accepted
import heapq as q
import sys
input = sys.stdin.readline
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]

ans = 0

v = []
q.heapify(v)

ab.sort()
i = 0
for j in range(m):
  while True:
    if i >= n:
      break
    a, b = ab[i]
    if a > j + 1:
      break
    q.heappush(v, -b)
    i += 1
  if v:
    ans -= q.heappop(v)
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ct=0
b=0
for i in range(0,n-2):
  p=a[i]
  for j in range(i+1,n-1):
    q=a[j]
    for k in range(j+1,n):
      r=a[k]
      if p!=q and q!=r and r!=p and 2*max(p,q,r)<p+q+r:
        ct+=1
print(ct)
# Judge status: Wrong Answer
AB,BC,CA = sorted(map(int,input().split()))
print(AB*BC/2)
# Judge status: Accepted
inp = list(map(int,input().split()))
N = inp[0]
A = inp[1]
B = inp[2]
l=list()
for i in range(N+1):
    n0 = i % 10
    n1 = (i % 100 - n0) // 10
    n2 = (i % 1000 - n0 - n1*10) // 100
    n3 = (i % 10000 - n0 - n1*10 - n2*100) // 1000
    n4 = (i % 100000 - n0 - n1*10 - n2*100 - n3*1000) // 10000
    if A <= n0+n1+n2+n3+n4 <= B:
        l.append(i)
print(sum(l))
# Judge status: Wrong Answer
s=input().replace("eraser","").replace("dreamer","").replace("erase","").replace("dream","")
if s=="":print('YES')
else:print('NO')
# Judge status: Wrong Answer
n=int(input())
s=[]
for i in range(n):
  s.append(input())
m=int(input())
t=[]
for i in range(m):
  t.append(input())
from collections import Counter
s=Counter(s)
t=Counter(t)
ans=-1000000
for i in s:
  ans=max(ans,s[i]-t.get(i,0))
for i in t:
  ans=max(ans,-t[i]+s.get(i,0))


print(ans)
# Judge status: Accepted
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    N, T = map(int, input().split())
    MAX_ANS = 10000
    ans = MAX_ANS
    for _ in range(N):
        c, t = map(int, input().split())
        if c < ans and t <= T:
            ans = c
    if ans == MAX_ANS:
        print('TLE')
    else:
        print(ans)

if __name__ == '__main__':
    main()
# Judge status: Accepted
A,B,C = map(int, input().split())
print('Yes' if A<=C<=B else 'No')
# Judge status: Accepted
s = input()
de_num = 0
le_num = 0
ans = [0]*(len(s)+1)

for i in range(len(s)):
    if s[i] == "<":
        de_num += 1
    else:
        de_num = 0
    ans[i+1] = de_num

s = s[::-1]
ans.reverse()

for i in range(len(s)):
    if s[i] == ">":
        le_num += 1
    else:
        le_num = 0
    ans[i+1] = max(le_num,ans[i+1])

print(sum(ans))
# Judge status: Accepted
n = int(input())
print(2*n*3.14159264)
# Judge status: Accepted
S=input()

if S=="ABC":
    print("ARC")
else:
    print("ABC")
# Judge status: Wrong Answer
import random

N = int(input())
A = []
B = 0
while 0  not in A and 9 not in A:
    for i in range(0,N):
        A.append(random.randint(0,9))
for j in range(0,N):
    B += A[j]*10**j
x = B % 10**9 + 7
print(x)
# Judge status: Accepted
n,l=map(int, input().split())
s=[]
for i in range(n):
  s.append(input())
s.sort()
sen=""
for i in range(n):
  sen=sen+s[i]
print(sen)
# Judge status: Wrong Answer
def getInput():
    return [int(i) for i in input().rstrip().split(' ')]

N = getInput()[0]
a_i = getInput()
a_i.sort(reverse=True)

team = [[0 for i in range(3)] for i in range(N)]
sums = 0
for i in range(3):
    for j in range(N):
        team[j][i] = a_i.pop(0)
        if i==1:
            sums += team[j][1]

print(sums)
# Judge status: Wrong Answer
n,k=map(int,input().split())
print(n%k)
# Judge status: Accepted
A,B,C = list(map(int,input().strip().split()))

if C - ( A - B ) < 0:
    print(0)
else:
    print(C - (A-B))
# Judge status: Accepted
A, B, C = map(int, input().split())
K = int(input())
M = max(A, B, C)
G = A+B+C-M
print(G+M*(2**K))
# Judge status: Accepted
S=int(input())
cnt=0
import math
def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if S<3:
  print(0)
else:
  syou=S//3
  amari=S%3
  while syou>0:
    cnt=cnt+combinations_count(syou+amari-1, amari)
    syou=syou-1
    amari=amari+3
  print(cnt%((10**9)+7))
# Judge status: Accepted
n = int(input())
t,a = map(float,input().split())
h = list(map(float,input().split()))
best = 10 ** 5
ans = -1
for i in range(n):
    tt = t - h[i] * 0.006
    best = min(best,abs(tt - a))
    if abs(a - tt) == best:
        ans = i
print(ans+1)
# Judge status: Wrong Answer
s=input()
tmp = 0
ans = -1
flg= 1
for i in range(len(s)):
  if s[i] in ["A","G","C","T"]:
    tmp += 1
  else:
    if ans <= tmp:
      ans = tmp
      flg = 0
      tmp = 0
print(ans if flg==0 else tmp)
# Judge status: Wrong Answer
from sys import stdin
lines = stdin.readlines()
 
S, T = map(str, lines[0].split())
A, B = map(int, lines[1].split())
U = lines[2]

if S == U :
  a = A - 1
  b = B
else :
  a = A
  b = B - 1

print(a, b)
# Judge status: Wrong Answer
n, k = map(int, input().split())
d = list(map(int, input().split()))
lis = []
for i in range(10):
    if not i in d:
        lis.append(i)
inf = 1001001001
ans = inf
def dfs(s, n):
    if len(s) == 4:
        if int(s) >= n:
            global ans
            ans = min(ans, int(s))
        return
    else:
        for i in lis:
            dfs(s + str(i), n)
dfs("", n)
print(ans)
# Judge status: Accepted
#!/usr/bin/env python3
x, y, z = map(int, input().split())
print(z, x, y)
# Judge status: Accepted
c = input()
if c in 'aiueo':
    print('vowel')
else:
    print('consonant')
# Judge status: Accepted
N = int(input())
ps = [int(i) for i in input().split()]

ans = 0
for a, b in zip(ps, sorted(ps)):
    if a != b:
        ans += 1

if ans > 2:
    print('NO')
else:
    print('YES')
# Judge status: Wrong Answer
N, L =list(map(int, input().split()))
array = []
word = ""
for i in range(N):
    s = input()
    array.append(s)
print(array)
new_array = sorted(array)    
print(new_array)
for j in range(N):
    word += new_array[j]
print(word)
# Judge status: Wrong Answer
inN = int(input())

D=1000000000 + 7
p=0
for i in range(inN):
  p*=i
  if (D < p): p=p%D

print(str(p))