peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted

N = int(input())
M = str(N)
List = []
for i in M:
    if i == '7':
        List.append(i)
    else:
        pass
if len(List) != 0:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
A, B, C = map(int, input().split())

print(C - (A - B))
# Judge status: Accepted
a,b,c = map(int,input().split())
k = int(input())

for i in range(k):
    if a >= b:
        b *=2
        continue
    elif b >= c:
        c *= 2
    else:
        c *= 2

if a < b and b < c:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
if n%2==0:
    print(n/2)
else:
    print((n//2)+1)
# Judge status: Accepted
n = int(input())
S = input()
l = 0
r = 0
for s in S:
  if s == "(":
    r += 1
  else:
    if r > 0:
      r -= 1
    else:
      l += 1
ans = "("*l + S + ")"*r
print(ans)
# Judge status: Accepted
def coloring_colorfully(s):

    ans = 0
    color = {"0":"1", "1":"0"}

    for i in range(1, len(s)):
        if s[i-1] == s[i]:
            ans += 1
            s[i] = color[s[i]]

    return ans

def main():
    s = list(str(input()))
    print(coloring_colorfully(s))

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

if (A == B):
    print(A + B)
else:
    print(max(A, B) * 2 - 1)
# Judge status: Accepted
N,M = map(int,input().split())
g = [[] for _ in range(N+1)]
for _ in range(M):
    a,b = map(int,input().split())
    g[a].append(b)
    g[b].append(a)
from collections import deque

queue = deque([1])
d = [None]*(N+1)
d[1]=None
while queue:
    now = queue.popleft()
    for i in g[now]:
        if d[i] is None:
            d[i]=now
            queue.append(i)
print("Yes")
for i in range(2,N+1):
    print(d[i])
# Judge status: Accepted
def solve(N, W, weightValues):
    dp = [0] * (W + 1)
    s = 0
    for w, v in weightValues:
        s += w
        for j in range(min(W, s), w - 1, -1):
            if dp[j - w] + v > dp[j]:
                dp[j] = dp[j - w] + v

    print(max(dp))


N, W = map(int, input().split())
weightValues = sorted([list(map(int, input().split())) for i in range(N)])
solve(N, W, weightValues)
# Judge status: Accepted
N = int(input())
k = 0
ans = 0
while N >= ans:
    k += 1
    ans = k * (k+1) / 2

exit_num = int(k * (k+1) / 2 - N)
for i in range(1,k+1):
    if i != exit_num:
        print(i)
# Judge status: Wrong Answer
A, B, C = map(int, input().split())
print(B + C - A)
# Judge status: Accepted
import sys

input = sys.stdin.readline

def main():
    ans = 0
    A, B, C, K = map(int, input().split())
    if K%2 == 0:
        ans = A - B
    else:
        ans = B - A
    if ans >= 10**18:
        ans = 'Unfair'
    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
alis=list(map(int,input().split()))
xlis=dict()
for i in set(alis):
    xlis[i-1]=0
    xlis[i+1]=0
    xlis[i]=0
for i in alis:
    xlis[i-1]+=1
    xlis[i+1]+=1
    xlis[i]+=1
print(max(xlis.values()))
# Judge status: Wrong Answer
a,b = map(int,input().split())
print("Even" if (a*b)%2==0 else print("Odd"))
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
x=a[0]
y=a[1]
a.sort(reverse=True )
for i in range(2,n):
    if a[i]<0:
        if x>y:
            x+=a[i]
        else:
            y+=a[i]
    else:
        if x<y:
            x+=a[i]
        else:
            y+=a[i]
print(max(x,y)-min(x,y))
# Judge status: Wrong Answer
L = [2,1]
N = int(input())
K = 0
if N == 1:
  print(1)
else:
  for i in range(N-1):
    K = L[i+1]+L[i]
    L.append(K)
print(K)
# Judge status: Accepted
c1 = input()
c2 = input()
if (c1[0] == c2[2]) and (c1[1] == c2[1]) and (c1[2] == c2[0]):
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n =int(input())

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

box =[0]*n
sum=0
for i in reversed(range (n)):
  sum=0
  for j in (range(int(n/(i+1))-1)):
    sum +=box[i+(i+1)*(j+1)]
  box[i]=(sum+num[i])%2


ans = []
for i in range(n):
  if box[i]==1:
    ans.append(i+1)
print(len(ans))
ans=[str(a) for a in ans]
ans=" ".join(ans)
print(ans)
# Judge status: Accepted
s = 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
n = int(input())
ans = 0
bef = 0
for _ in range(n):
  a = int(input())
  if a == 0:
    bef = 0
    continue
  ans += (a + bef) // 2
  if (a + bef) % 2 == 1:
    bef = 1
print(ans)
# Judge status: Wrong Answer
s,t=list(input()),list(input())
s.sort();t.sort(reverse=True)
l=[''.join(s),''.join(t)]
r=sorted(l)
print('Yes' if l==r else 'No')
# Judge status: Wrong Answer
n=int(input())
if (n/10==9 or n%10==9):
	 print("Yes")
else :
	print("No")
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))
cnt = 0

for i in range (1, n-1):
  if p[i-1] < p[i] and p[i] < p[i+1]:
    cnt += 1
  elif p[i-1] > p[i] and p[i] > p[i+1]:
    cnt += 1
    
print(cnt)
# Judge status: Accepted
X = int(input())
se = set(n**e for n in range(32) for e in range(2,11) if n**e <= X)

answer = max(se)
print(answer)
# Judge status: Accepted
from collections import Counter
N=int(input())
a=list(map(int,input().split()))

ans=0
cnt = Counter(a)
for k,v in cnt.items():
    if k>v:
        ans+=v
    else:
        ans+=v-k
print(ans)
# Judge status: Wrong Answer
a,b = list(map(int,input().split()))
if a >= b:
  print(a*(a-1))
else:
  print(b*(b-1))
# Judge status: Wrong Answer
n,m,k = map(int, input().split())

for i in range(n+1):
  for j in range(m+1):
    if i*(m-j)+j*(n-1):
      print("Yes")
      exit()
print("No")
# Judge status: Accepted
import numpy as np

S = input()
NSEW = [S.count("N"), S.count("S"), S.count("E"), S.count("W")]

if np.prod(NSEW) > 0:
    print("Yes")
    exit()
elif NSEW[0] + NSEW[1] > 0 and NSEW[0] * NSEW[1] == 0:
    print("No")
    exit()
elif NSEW[2] + NSEW[3] > 0 and NSEW[2] * NSEW[3] == 0:
    print("No")
    exit()
print("Yes")
# Judge status: Accepted
N = int(input())
tmp = N // 15
cost = 800 * N - 200 * tmp
print(cost)
# Judge status: Wrong Answer
inputs = [input() for i in range(2)]
n = int(inputs[0])
a = map(lambda x: int(x), inputs[1].split(" "))

b = {}
for i in a:
  if i not in b:
    b[i] = 1
  else:
    b[i] += 1
count = 0
for k in b.keys():
  tmp = abs(k - b[k])
  if tmp > b[k]:
    count += b[k]
  else:
    count += tmp


print(count)
# Judge status: Accepted
a,b,c = [int(x) for x in input().split()]

m = max([a,b,c])
if m % 2 == sum([a,b,c]) % 2:
    print(((3 * m) - sum([a,b,c])) // 2)
else:
    print((((m+1) - a) + ((m+1)-b) + ((m+1)-c)) // 2)
# Judge status: Accepted
import sys
k, s = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
for x in range(min(k+1, s+1)):
    for y in range(min(k+1, s - x + 1)):
        if s - x - y <= k:
            cnt += 1
print(cnt)
# Judge status: Wrong Answer
from fractions import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations

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

    print(A + B) if A + B <= 24 else print((A + B) % 24)

if __name__ == '__main__':
    main()
# Judge status: Accepted
a, b, c, d = input()

if a == b == c or b == c == d:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
n=int(input())
ans = 0
for i in range(1, n+1):
    occ = (n/i);
    val = int((occ * (occ+1))/2);
    ans += val*i;
print(ans)
# Judge status: Accepted
arr=list(map(int,input().split()))
if sum(arr)>=22:
  print('bust')
else:
  print('win')
# Judge status: Wrong Answer
n=(input())
print(chr(ord(n)+1))
print(n,"is followed by",(chr(ord(n)+1)))
# Judge status: Wrong Answer
N = int(input())

c = [[0]*10 for i in range(10)]

for i in range(1,N+1):
    a = N % 10
    b = 0
    while N > 0:
        b = N
        N = N // 10
    c[a][b] += 1

ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j]*c[j][i]

print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())
if a>=13:
  print(b)
elif 12<=a<=6:
  print(b//2)
else:
  print(0)
# Judge status: Accepted
import fractions
  
N = int(input())
A = list(map(int, input().split()))

ans = 0
MOD = 10**9 + 7

LCM = A[0]
for i in range(1, N):
    LCM *= A[i]//fractions.gcd(LCM, A[i])
    
for a in A:
  ans += LCM//a
  
print(ans%MOD)
# Judge status: Accepted
from collections import Counter
n = int(input().strip())
L = list(map(int, input().strip().split()))
seen=Counter()
ans=0
for j in range(n):
    ans+=seen[j-L[j]]
    seen[L[j]+j]+=1
print(ans)
# Judge status: Accepted
s=input()
t=input()
ans=False
for i in range(len(s)):
    s=s[-1]+s[:-1]
    if s==t:
        ans=True
        break
        
if ans==True:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x = list(input().split())
x.sort()

if int(x[0]) + int(x[1]) == int(x[2]):
    print('YES')
else:
    print('FALSE')
print(x)
# Judge status: Wrong Answer
n = int(input())
lst = list(map(int, input().split()))

m = max(lst)
r = m//2
k = float('inf')

for i in range(n):
  if abs(r-lst[i]) < abs(r-k):
    k = lst[i]
    
print(m, k)
# Judge status: Accepted
n = int(input())
p = list(map(int, input().split()))

s = 1
t = p[0]
for i in range(1,n):
  if p[i] <= t:
    s += 1
    t = p[i]
print(s)
# Judge status: Wrong Answer
N,A,B=input().split()
if (int(B)-int(A))%2==1:
  print(A)
else:
  print((int(B)-int(A))//2)
# Judge status: Accepted
def main():
    n, k = map(int, input().split())
    p = list(map(int, input().split()))

    p.sort()

    ans = 0
    for i in range(k):
        ans += p[i]

    print(ans)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
n=int(input())
a=list(input().split())
student=[]
ans=[]
for i in range(n):
    tmp=[]
    tmp.append(a[i])
    tmp.append(i+1)
    student.append(tmp)
student.sort(key=lambda x:x[0])
for i in range(n):
    ans.append(str(student[i][1]))
print(' '.join(ans))
# Judge status: Accepted
s=input()
t=input()
ss = sorted(s)
tt = sorted(t,reverse=True)
if ss < tt:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
    n = int(input())
    s = input()

    wnum = s.count("W")
    enum = s.count('E')

    first = enum
    ans = first

    for i in range(n):
        if s[i] == "E":
            first -= 1
        if i >= 1:
            if s[i-1] == "W":
                first += 1
        if ans > first:
            ans = first
        #print(i, ans, first)
    print(ans)




if __name__ == "__main__":
    main()
# Judge status: Accepted
W, H, N = map(int, input().split())
XYA = [list(map(int, input().split())) for _ in range(N)]

x1, x2, y1, y2 = 0, W, 0, H

for xya in XYA:
    a = xya[2]
    if a == 1:
        x1 = max(x1, xya[0])
    if a == 2:
        x2 = min(x2, xya[0])
    if a == 3:
        y1 = max(y1, xya[1])
    if a == 4:
        y2 = min(y2, xya[1])

w = max(0, x2-x1)
h = max(0, y2-y1)

print(w*h)
# Judge status: Accepted
N=int(input())
power=1
for i in range(1,N+1):
  power=power*i
  power=power%(10**9+7)
print(power)
# Judge status: Accepted
N,M = map(int,input().split())

if N == 1 and M == 1:
  ans = 1
elif N == 1 or M == 1:
  ans = N * M - 2
elif N == 2 or M == 2:
  ans = 0
else:
  ans = (N - 2) * (M - 2)
  
print(ans)
# Judge status: Accepted
a = int(input())
b = int(input())
h = int(input())
z =int((a + b)*h/2)
print(z)
# Judge status: Wrong Answer
c1 = input()
c2 = input()
if c1 == c2[-1:] and c2 == c1[-1:]:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
N = int(input())
Ps = list(map(int,input().split()))
cnt = 0
for i in range(1,N-1):
  if Ps[i-1] < Ps[i]<Ps[i+1] or Ps[i+1] < Ps[i]<Ps[i-1]:
    cnt+=1
print(cnt)
# Judge status: Wrong Answer
import sys
input=lambda: sys.stdin.readline().rstrip()
n=int(input())
C=[1]*n
Ans=[C]
cur=n-1
while cur:
  cur=0
  for i in range(n-1):
    if C[i+1]<i+2:
      cur=i+1
  D=[]
  for i in range(n):
    if i<cur:
      D.append(C[i])
    elif i==cur:
      D.append(C[i]+1)
    else:
      D.append(1) 
  if cur!=0:
    Ans.append(D)
  C=Ans[-1]
for a in Ans:
  ans=""
  for i in range(n):
    ans+=chr(a[i]+96)
  print(ans)
# Judge status: Wrong Answer
a = int(input())
b = int(input())

if (a==1) and (b==2):
  print(3)
if (a==1) and (b==3):
  print(2)
if (a==2) and (b==3):
  print(1)
# Judge status: Accepted
mod=2019
a=input()

N=len(a)
t=[0]*mod
t[0]=1

w=1
u=0

for i in range(N):
  u=int(a[N-1-i]) * w + u
  v=u % mod
  t[v] += 1
  w *=10
  w %= mod

ans=0
for i in t:
  ans += (i-1)*i//2

print(ans)
# Judge status: Accepted
#import sys
#import numpy as np
import math
#from fractions import Fraction
import itertools
from collections import deque
from collections import Counter
import heapq
from fractions  import gcd
#input=sys.stdin.readline
#import bisect
n,a,b=map(int,input().split())
ans=(b*(n-1)+a-a*(n-1)-b)+1
if ans<0:
  print(0)
  exit()
print(ans)
# Judge status: Accepted
n = int(input())

print(n * (n + 1) // 2 - n)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = 0
for i in range(n):
  if a[i] <= b[i]:
    if a[i+1] >= b[i] - a[i]:
      ans += b[i]
      a[i+1] -= b[i] - a[i]
      a[i] = 0
    else:
      ans += a[i] + a[i+1]
      a[i+1] = 0
      a[i] = 0
  else:
    ans = b[i]
    a[i] -= b[i]
print(ans)
# Judge status: Wrong Answer
N,L =input().split()
listA=[]
for i in range(int(N)):
    listA.append(input())

print(sorted(listA))
# Judge status: Accepted
a,b,c = list(map(int, input().split()))
k = int(input())

c1=0
while(1):
    if a<b:
        break
    else:
        c1+=1
        b=b*2

c2=0
while(1):
    if b<c:
        break
    else:
        c2+=1
        c=c*2

if c1+c2<=k:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()

num_win = 0
num_win_f = 0
num_next = A + B
for s in S:
  if s == "a" and num_win < num_next:
    print("Yes")
    num_win += 1
  elif s == "b" and num_win < num_next and num_win_f < B:
    print("Yes")
    num_win += 1
    num_win_f += 1
  else:
    print("No")
# Judge status: Wrong Answer
k = int(input())
a, b = map(int, input().split())

ans = 0
if a == b:
    if a%k == 0:
        print("OK")
    else:
        print("NG")
else:
    for i in range(a,b):
        if i%k == 0:
            ans += 1
        else:
            ans += 0
if ans >= 1:
    print("OK")
else:
    print("NG")
# Judge status: Accepted
B,C,A=map(int, input().split())
print(A,B,C)
# Judge status: Accepted
n = int(input())
C = list(input())
l = 0
r = n-1
ans = 0
while l < r:  
  while C[l] == 'R' and l<r:
    l += 1    
  while C[r] == 'W' and l<r:
    r -= 1
  if C[l]=='W' and C[r] == 'R':
    ans += 1
    l += 1
    r -= 1
    
print(ans)
# Judge status: Wrong Answer

N,K = list(map(int,input().split()))
X = list(map(int,input().split()))
Xrev = X[::-1]
ans = abs(X[0]-X[-1])
for i in range(N-K+1):
    Xdis = abs(X[i])+abs(X[i+K-1]-X[i])
    ans = min(ans,Xdis)
for i in range(N-K+1):
    Xdis = abs(Xrev[i])+abs(Xrev[i+K-1]-Xrev[i])
    ans = min(ans,Xdis)
print(ans)
# Judge status: Accepted
a,b = map(int,input().split())
t = b-a
print(t*(t+1)//2-b)
# Judge status: Wrong Answer
n,k,*l=map(int,open(0).read().split())
for _ in range(min(k,20)):
  s=[0]*(n+1)
  for i in range(n):
    s[max(i-l[i],0)]+=1
    s[min(i+l[i]+1,n)]-=1
  l[0]=min(s[0],n)
  for i in range(1,n):
    l[i]=min(l[i-1]+s[i],n)
print(*l)
# Judge status: Wrong Answer
A = list(map(int, input().split()))
A.sort()
print(A)
if A == [5,5,7]:
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
n = int(input())
s = [0]*n
for i in range(n):
    s[i] = input()

ac = s.count('AC')
wa = s.count('WA')
tle = s.count('TLE')
re = s.count('RE')
print('AC x',ac)
print('WA x',wa)
print('TLE x',tle)
print('Re x',re)
# Judge status: Accepted
T = input()
for c in T:
    if c == '?':
        print('D', end='')
    else:
        print(c, end='')
print()
# Judge status: Accepted
# A - ABD

N = int(input())

if 1 <= N < 1000:
    print('ABC')
elif 1000<= N < 1999:
    print('ABD')
elif N <= 0 or 1999 <= N:
    print('Out of range')
# Judge status: Accepted
N = input()
x = list(map(int, input().split()))

x.sort(reverse=True)
alice = 0
bob = 0
for i, j in enumerate(x):
    if i % 2 ==0:
        alice += j
    else:
        bob += j

print(alice - bob)
# Judge status: Accepted
a,b,m=map(int,input().split())
ali=list(map(int,input().split()))
bli=list(map(int,input().split()))

an=min(ali)+min(bli)

for i in range(m):
    x,y,c=map(int,input().split())
    if an>((ali[x-1]+bli[y-1])-c):
        an=((ali[x-1]+bli[y-1])-c)

print(an)
# Judge status: Wrong Answer
w=input()
l='thequickbrownfoxjumpsoverthelazydog'
a=0
if len(w)%2!=0:
    print('No')

else:
    for i in range(len(l)):
        if w.count(l[i])%2!=0:
            print('No')
            a+=1
            break
        else:
            continue
if a==0:
    print('Yes')
# Judge status: Accepted
def tapdance(s):
    for i in range(len(s)):
        if i % 2 == 0:
            if s[i] != 'R' and s[i] != 'U' and s[i] != 'D':
                return 'No'
        else:
            if s[i] != 'L' and s[i] != 'U' and s[i] != 'D':
                return 'No'
    return 'Yes'
s = input()
print(tapdance(s))
# Judge status: Accepted
a = list(map(int, input().split()))
a_sum = sum(a)
if a_sum >= 22:
    print('bust')
else:
    print('win')
# Judge status: Accepted
s = input()
for a in range(len(s)):
  if s[a]=='A':
    break
s = s[::-1]
for z in range(len(s)):
  if s[z] =='Z':
    break
print(len(s)-z-a)
# Judge status: Accepted
import sys
input=sys.stdin.readline


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: Accepted
n, k=map(int, input().split())

a = []
for i in range(k):
  int(input())
  x = list(map(int, input().split()))
  b = a + x
  a = list(set(b))
print(n - len(a))
# Judge status: Accepted
N = int(input())
a = list(map(int,input().split()))

aset = set(a)
if 1 not in aset:
    print(-1)
else:
    nex = 1
    counter = 0
    for i in range(N):
        if a[i] == nex:
            nex += 1
        else:
            counter += 1
    print(counter)
# Judge status: Accepted
def main():
    x, a, b = map(int, input().split())

    if b <= a:
        print("delicious")
    elif a < b and b <= a + x:
        print("safe")
    elif a + x < b:
        print("dangerous")
main()
# Judge status: Wrong Answer
def solve(a,b,c,x,y):
  k_max = min(x,y)
  l = []
  for i in range(k_max):
    s = a*(x-i)+b*(y-i)+c*i*2
    l.append(s)
  return min(l)   

A,B,C,X,Y = map(int,input().split())
print(solve(A,B,C,X,Y))
# Judge status: Accepted
n=int(input())
h=[list(map(int,input().split())) for i in range(n)]

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

for i in range(1,n+1):
    for j in range(3):
        for k in range(3):
            if j == k:
                continue
            dp[i][j] = max(dp[i][j],dp[i-1][k]+h[i-1][j])

print(max(dp[n]))
# Judge status: Accepted
import heapq

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

def max_listup(limit):
  l = list(map(lambda x:int(x)*-1, input().split()))
  heapq.heapify(l)
  cnt = 1
  res = []
  while l:
    if cnt > limit:
      break
    m = heapq.heappop(l)
    res.append(m*-1)
    cnt += 1
  return res

if __name__ == "__main__":
  all = sorted(max_listup(x) + max_listup(y) + list(map(int, input().split())))
  ans = 0
  for _ in range(x+y):
    ans += all.pop()

  print(ans)
# Judge status: Wrong Answer
#problem-b
a,b = map(int, input().split())
print(str(a)*b if a>=b else str(b)*a)
# Judge status: Accepted
N, K, S = map(int, input().split())

ans = [S] * K

if S == 10**9:
    for _ in range(N-K):
        ans.append(1)
else:
    for _ in range(N-K):
        ans.append(S+1)
print(*ans)
# Judge status: Wrong Answer
n = int(input())
if n==1:
  print(0)
else:
  cnt = 0
  flg = 0
  for i in range(10000001):
    if n<i:
      break
    if i==0 or i==1 or n%i!=0:
      continue
    j = i
    while(n%j==0):
      if flg==0:
        flg = 1
      n /= j
      j *= i
      cnt += 1
  if flg==0:
    print(1)
  else:
    print(cnt)
# Judge status: Accepted
n,t = map(int,input().split())
ans = 10**9
l = []
for i in range(n):
  l.append(list(map(int,input().split())))
for i in range(n):
  if l[i][1] <= t:
    ans = min(l[i][0],ans)
if ans == 10**9:
  print("TLE")
else:
  print(ans)
# Judge status: Accepted
from sys import stdin
from heapq import heapify, heappop, heappush
from bisect import bisect_right

N, M = map(int, stdin.readline().split())
AB = [None]*N
for i in range(N):
    AB[i] = list(map(int, stdin.readline().split()))
AB.sort()

salary = 0
hq = []
j = 0
for i in range(1, M+1):
    while j < N and AB[j][0] == i:
        heappush(hq, -AB[j][1])
        j += 1
    if hq:
        salary -= heappop(hq)
print(salary)
# Judge status: Accepted
S = input()
K = int(input())
V = []
for e in S:
    V.append(ord(e)-97)
for i in range(len(S)):
    if S[i] == 'a':
        continue
    if K < 26-V[i]:
        pass
    else:
        K -= 26-V[i]
        V[i] = 0
V[-1] += K
V[-1] %= 26
V = [chr(e+97) for e in V]
print("".join(V))
# Judge status: Accepted
#!/usr/bin/env python3
a, b, c, d = map(int, input().split())
arr = [0] * 101

for i in range(a, b + 1):
    arr[i] += 1

for j in range(c, d + 1):
    arr[j] += 1

ans = len([cnt for cnt in arr if cnt >= 2])

print(ans - 1 if ans != 0 else 0)
# Judge status: Accepted
N, K = map(int, input().split())
R, S, P = map(int, input().split())
scoredict = {'r':P, 's':R, 'p':S}
T = input()

score = 0
for i in range(K):
    score += scoredict[T[i]]
    last = T[i]
    while True:
        i += K
        if i >= N:
            break
        if T[i] == last:
            last = None
            continue
        else:
            score += scoredict[T[i]]
            last = T[i]

print(score)
# Judge status: Accepted
s = int(input())
a = s // 100
b = s % 100

if 1 <= a <= 12 and 1 <= b <= 12:
    print("AMBIGUOUS")
elif 1 <= a <= 12:
    print("MMYY")
elif 1 <= b <= 12:
    print("YYMM")
else:
    print("NA")
# Judge status: Accepted
k,s=map(int,input().split())
count=0
for x in range(k+1):
  for y in range(k+1):
    if x+y>=s-k and x+y<=s:
      count +=1
print(count)
# Judge status: Wrong Answer
N,K = map(str,input().split())
#N = int(input())
#A = list(map(int,input().split()))

c=int(N+K)

for i in range(1,350):
    if c//i == i:
        print('Yes')
        exit()
print('No')
# Judge status: Accepted
from math import gcd

def main():
    N = int(input())
    A = list(map(int, input().split()))
    R = [0] * (N+1)
    L = [0] * (N+1)
    for i in range(N):
        L[i+1] = gcd(L[i], A[i])

    for i in range(N-1,-1,-1):
        R[i] = gcd(R[i+1], A[i])
    ans = 0
    for i in range(N):
        ans = max(ans, gcd(L[i],R[i+1]))
    print(ans)

if __name__ == "__main__":
    main()
# Judge status: Accepted
n = int(input())
pnts = [tuple(map(int, input().split())) for i in range(n)]

mxsum = max(map(lambda p: p[0]+p[1], pnts))
mnsum = min(map(lambda p: p[0]+p[1], pnts))
mxdif = max(map(lambda p: p[0]-p[1], pnts))
mndif = min(map(lambda p: p[0]-p[1], pnts))

print(max([mxsum - mnsum, mxdif-mndif]))
# Judge status: Accepted
import sys
from math import pi, cos, sqrt
from collections import defaultdict
readline = sys.stdin.buffer.readline
#sys.setrecursionlimit(10**8)


def geta(fn=lambda s: s.decode()):
    return map(fn, readline().split())


def gete(fn=lambda s: s.decode()):
    return fn(readline().rstrip())


def main():
    N = gete(int)
    v = list(geta(int))
    v.sort()

    base = 1

    ans = v[0]
    for vi in v[1:]:
        ans += vi * base
        base *= 2

    print(ans / base)


if __name__ == "__main__":
    main()
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
s = a+b+c
if (s>22):
  print('bust')
else: 
  print('win')
# Judge status: Accepted
H,A=map(int,input().split())
if H%A==0:
    print(H//A)
else:
    print(H//A+1)
# Judge status: Accepted
s=input()
d={}
n="No"
for i in s:
  if i in d:
    d[i]=d[i]+1
  else:
    d[i]=1
    
if len(d) ==2:
  for k,v in d.items():
    n="Yes"
    
print(n)