peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
def readinput():
    k,n=map(int,input().split())
    a=list(map(int,input().split()))
    return k,n,a

def main(k,n,a):
    dmax=0
    for i in range(n-1):
        dmax=max(dmax,a[i+1]-a[i])
    dmax=max(dmax,k+a[0]-a[n-1])
    return k-dmax

if __name__=='__main__':
    k,n,a=readinput()
    ans=main(k,n,a)
    print(ans)
# Judge status: Wrong Answer
n = int(input())
num = []
maxnum = 0
count = 1
for i in range(n):
  a = int(input())
  if a!=maxnum:
    maxnum = max(maxnum,a)
  else:
    count += 1
  num.append(a)
  
for i in range(n):
  if count>1:
    print(maxnum)
  else:
    if num[i]!=maxnum:
      print(maxnum)
    else:
      subnum = num[0:i] + num[i+1:n]
      subnum = sorted(subnum)
      print(subnum[n-2])
# Judge status: Wrong Answer
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

S = input()

if S[0] == "A" and S[2:-2].count("C") == 1 and S.count("A") == 1 and S.count("C") == 1:
    S = S.replace("A", "")
    S = S.replace("C", "")
    if S == S.lower():
        print('AC')
        quit()
print('WA')
# Judge status: Accepted
from bisect import bisect_right

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

pos = bisect_right(a, a[-1]/2)
if pos == 0 or abs(a[-1]/2 - a[pos-1]) > abs(a[-1]/2 - a[pos]):
    print(a[-1], a[pos])
else:
    print(a[-1], a[pos-1])
# Judge status: Accepted
i=input()
if ("N" in i and "S" not in i) or ("W" in i and "E" not in i) or ("W" not in i and "E" in i) or ("N" not in i and "S" in i):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
l = [0] * n
for i in range(n):
    l[a[i]-1] = i+1
for i in range(n):
    print(l[i],end = ' ')
# Judge status: Accepted
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
num = 0
for i in range(n):
    a, b = AB[n - i - 1]
    if (num + a) % b != 0:
        num += b - (num + a) % b
print(num)
# Judge status: Accepted
n = int(input())
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    if i % 2 == 0 and a[i] % 2 == 1:
        ans += 1
print(ans)
# Judge status: Accepted
S = input()
T = input()

ans = "No"

for _ in range(len(S)):
    if S == T:
        ans = "Yes"
    S = S[-1] + S[:-1]

print(ans)
# Judge status: Accepted
N = int(input())
S = input()
ans = ''
for s in S:
    i = ord(s)+N
    if i >= 65 + 26:
        i -= 26
    ans += chr(i)
print(ans)
# Judge status: Accepted
import collections
ans = input()
ans = list(collections.Counter(ans).values())
for i in ans:
    if i % 2 == 0:
        pass
    else:
        print("No")
        exit()
print("Yes")
# Judge status: Accepted
N = int(input())
K = int(input())
X = int(input())
Y = int(input())
cos = 0
for i in range(N):
    if K >= (i + 1):
        cos += X
    else:
        cos += Y
    
    
print(cos)
# Judge status: Accepted
from math import ceil
N,K = map(int,input().split())
A = list(map(int,input().split()))

def is_ok(X):
    #最大値をX以下にできるか
    cnt = 0
    for a in A:
        cnt += ceil(a/X)-1
    return cnt <= K

def bisearch(high,low):
    while high - low > 1:
        mid = (high+low)//2
        if is_ok(mid):
            high = mid
        else:
            low = mid
    return high

print(bisearch(10**9+1,0))
# Judge status: Accepted
a=int(input())
b=int(input())
x=[1,2,3]
x.remove(a)
x.remove(b)
print(x[0])
# Judge status: Accepted
a, b, c = map(int, input().split())
for i in range(min(a,b)+1, max(a,b)):
    if i == c:
        print("Yes")
        exit()
print("No")
# Judge status: Accepted
N,x=map(int,input().split())
a=list(map(int,input().split()))
a.sort()

ans=0
for i in range(N):
    if x>=a[i]:
        ans+=1
        x-=a[i]
    else:
        break
if ans==N:
    if x==0:
        pass
    else:
        ans-=1
print(ans)
# Judge status: Accepted
n = int(input())
a = list(input())
b = list(set(a))
ans = 1
for i in b:
    ans %= 10**9+7
    ans *= a.count(i)+1
print((ans-1)%(10**9+7))
# Judge status: Accepted
n = int(input())

t = [int(input()) for _ in range(5)]

q, r = divmod(n, min(t))

if r > 0:
    q += 1
    
print(q+4)
# Judge status: Accepted
# A - Next Alphabet
def main():
    C = input().rstrip()
    ans = chr(ord(C) + 1)
    print(ans)


if __name__ == "__main__":
    main()
# Judge status: Accepted
def main():
    n, q = map(int, input().split())
    ss = list(input())
    lrs = [list(map(int, input().split())) for _ in range(q)]
    cum_sum = [0] * n
    for i in range(1, n):
        if ss[i-1] == 'A' and ss[i] == 'C':
            cum_sum[i] += 1
        cum_sum[i] += cum_sum[i-1]
    for l, r in lrs:
        print(cum_sum[r-1]-cum_sum[l-1])


if __name__ == "__main__":
    main()
# Judge status: Accepted
n=int(input())
k=len(str(n))
c=n//10**(k-1)
print(c+9*(k-1) if n==(c+1)*10**(k-1)-1 else c+9*(k-1)-1)
# Judge status: Accepted
N = int(input())

A = N % 1000

if A == 0:
  print(0)
else:
  print(1000-A)
# Judge status: Wrong Answer
n = int(input())
xs = []
ys = []
for _ in range(n):
    x, y = map(int, input().split())
    xs.append(x)
    ys.append(y)

s = 0
c = 0
for i in range(n):
    for k in range(i + 1, n):
        s += ((xs[i] - xs[k]) ** 2 + (ys[i] - ys[k]) ** 2) ** 0.5
        c += 1
a = s / c
for i in range(1, n):
    a *= i
print(a)
# Judge status: Accepted
#!/usr/bin/env python3

import heapq

def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a = [-x for x in a]  # Negate to use min-heap as max-heap
    heapq.heapify(a)
    for i in range(m):
        x = heapq.heappop(a) * (-1)
        x //= 2
        heapq.heappush(a, -x)
    print(sum(a) * (-1))

if __name__ == "__main__":
    main()
# Judge status: Accepted
#141A

#1.入力をちゃんと受け取ること
b=input()
#2.結果を出力する
if b=='Sunny' :
    print('Cloudy')
elif b=='Rainy':
    print('Sunny')
elif b=='Cloudy':
    print('Rainy')
# Judge status: Wrong Answer
S = input("")
if len(S)<=1000 and len(S)>=1:
    if S.endswith(('o', 'ch', 's', 'sh', 'x', 'z')):
        print(S.lower()+"es")
    else:
        print(S.lower()+"s")
# Judge status: Wrong Answer
from sys import stdin
h,w = [int(x) for x in stdin.readline().rstrip().split()]
import math
def bishop(h,w):
    if h == 1:
        ans = 1
    else:
        ans = int(w/2)*h + (w%2)*math.ceil(h/2)
    print(ans)
    return
# Judge status: Wrong Answer
N,M=map(int,input().split())
AB=[]
for _ in range(N):
    a,b=map(int,input().split())
    AB.append([a,b])
AB.sort(key=lambda x:-1*x[1]*10**6-x[0])
cnt=0
ans=0
while True:
    end=False
    for i in range(0,N):
        if M-cnt>=AB[i][0]:
            ans+=AB[i][1]
            cnt+=1
            AB[i][0]=10**7
            break
        if i==N-1:
            end=True
    if end:
        break
print(ans)
# Judge status: Wrong Answer
a = input()
ok = True
for i in range(0, len(a)//2 + 2, 2):
    if a[i:i + 2] != "hi":
        ok = False
        break

if ok:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,c=map(int,input().split())
if b>=c:
  print("delicious")
elif a+b >=c:
  print("safe")
else:
  print("dangerous")
# Judge status: Accepted
n, k = map(int, input().split())

ans = 0

for i in range(k, n+2):
    ans += n*i-i**2+i+1

print(ans % (10**9+7))
# Judge status: Accepted
H=int(input())

if H == 1:
  ans=1
  
H_list=[]
while H > 1:
    if H % 2 != 0:
        H=H-1
    H_list.append(H)
        
    H = H//2
    
H_list.sort()
 
ans_list=[]
for h in H_list:
    if h == 2:
        ans = 3
    else :
        ans = 2*ans+1
    ans_list.append(ans)
    
print(ans)
# Judge status: Accepted
n = int(input())
sa = [0]
ans = float("INF")
for i, ai in enumerate(list(map(int, input().split()))):
    sa.append(sa[i] + ai)
for i in range(n + 1):
    ans = min(ans, abs(sa[i] - (sa[-1] - sa[i])))
print(ans)
# Judge status: Accepted
from collections import Counter
N,K=map(int,input().split())
A=list(map(int,input().split()))

cnt=Counter(A)
cnt_sorted=sorted(cnt.items(), reverse=True,key=lambda x:x[1])

sum=0
for i in range(min(K,len(cnt))):
    sum+=cnt_sorted[i][1]

print(N-sum)
# Judge status: Wrong Answer
import numpy
N, K = map(int,input().split())
h = numpy.array(input().split(),numpy.int32)


dp = numpy.array([10**5]*N,numpy.int32)
dp[0] = 0

for i in range(N) :
    for j in range(1,K+1) :
        x = i+j
        if x< N :
            m = dp[i]+abs(h[i]-h[x])
            if m < dp[x] :
                dp[x] = m

print(dp[-1])
# Judge status: Accepted
n,a,b,c,d = map(int,input().split())
s = input()
if d<c:
    if "##" not in s[a-1:d] and '...' in s[b-2:d+1]:
        print('Yes')
    else:
        print('No')
    
else:
    if "##" not in s[a-1:d]:
        print('Yes')
    else:
        print('No')
# Judge status: Wrong Answer
N = int(input())
X = [None for _ in range(N)]
for i in range(N):
  X[i] = list(map(int,input().split()))
A = [None for _ in range(N)]
B = [None for _ in range(N)]
for i in range(N):
  A[i] = X[i][0]
  B[i] = X[i][1]
  
S = sum(A)
MAX = max(B)

if S > MAX:
  print('No')
  exit()

for i in range(N):
  if X[i][0] > X[i][1]:
    print('No')
    exit()
    
print('Yes')
# Judge status: Accepted
N,K=map(int,input().split())
p=sorted(list(map(int,input().split())))
print(sum(p[:K]))
# Judge status: Wrong Answer
a, b = map(int, input().split())
ans = a + b
if ans > 24:
    ans = ans - 24
print(ans)
# Judge status: Wrong Answer
def main():
    import sys
    import time
    start=time.time()
    K=int(sys.stdin.readline())
    s=''
    while True:
        s+='7'
        if int(s)%K==0:
            print(len(s))
            break
    
        if time.time()-start>=1.8:
            print(-1)
            break

main()
# Judge status: Accepted

h, a = input().split()
h = int(h)
a = int(a)
x = a
attack = 1

while h > x :
    h -= x
    attack += 1

print(attack)
# Judge status: Accepted
import sys
import heapq
from decimal import Decimal

input = sys.stdin.readline
k, s = map(int, input().split())

ans = 0
for x in range(k+1):
    for y in range(k+1):
        z = s - x - y
        if z >= 0 and z <= k:
            ans += 1
    
print(ans)
# Judge status: Accepted
aas = {'a':'b','b':'c','c':'d','d':'e','e':'f','f':'g','g':'h','h':'i','i':'j','j':'k','k':'l','l':'m','m':'n','n':'o','o':'p','p':'q','q':'r','r':'s','s':'t','t':'u','u':'v','v':'w','w':'x','x':'y','y':'z'}
print(aas[input()])
# Judge status: Wrong Answer
import math

n = int(input())
for i in range(1, 6):
    print(0)
for i in range(6, n+1):
    x = int(math.sqrt(i)) + 1
    ans = 0
    for j in range(1, x):
        for f in range(1, x):
            for k in range(1, x):
                if (j + f + k) ** 2 - j*f - j*k - f*k == i:
                    ans += 1
    print(ans)
# Judge status: Wrong Answer
S = list(input())
T = list(input())
flag = False
C = []
for i in range(len(S)):
  flag = False
  ii = len(S) - i
  for j in range(len(T)):
    if (ii+j >= len(S)):
      flag = False
      break
    elif S[ii+j]==T[j] or S[ii+j] == "?":
      flag = True
    else:
      flag = False
      break
  if (flag):
    for k in range(len(T)):
      S[ii+k] = T[k]
    C.append("".join(S).replace("?","a"))
if (C != []):
  print(min(C))
else:
  print("UNRESTORABLE")
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))

color = [0] * 9

for a in A:
  if a <= 399:
    color[0] = 1
  elif a <= 799:
    color[1] = 1
  elif a <= 1199:
    color[2] = 1
  elif a <= 1599:
    color[3] = 1
  elif a <= 1999:
    color[4] = 1
  elif a <= 2399:
    color[5] = 1
  elif a <= 2799:
    color[6] = 1
  elif a <= 3199:
    color[7] = 1
  else:
    color[8] += 1
    
max_num = sum(color)
min_num = max(1, sum(color[:-1]))
 
print(min_num, max_num)
# Judge status: Wrong Answer
n,d = map(int,input().split())
if n%(2*d+1) == 0:
    print(n%(2*d+1))
else:
    print(n%(2*d+1)+1)
# Judge status: Wrong Answer
n=int(input())

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

a.sort()
b.sort()


suma=sum(a)
sumb=sum(b)



#sum(a)+2*k=sum(b)+k
#k=(sum(a)-sum(b))

k=suma-sumb
#
#1 1 1 6
#2 2 2 3

if k<0:
    print("No")
    exit()
cnt=0
for i in range(n):
    if a[i]>b[i]:
        cnt+=b[i]-a[i]
    elif a[i]<b[i]:
        cnt+=((-1)*(a[i]-b[i])//2)

if cnt>=k:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N, K = map(int,input().split())

S = input()

SL = list(S)
SL[K-1] = SL[K-1].lower()
ans = "".join(SL)

print(ans)
# Judge status: Accepted
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
N = int(input())
A = [int(input()) for _ in range(N)]

from collections import deque
from bisect import bisect_left

D = deque([])

for a in A:
    i = bisect_left(D,a)
    if i==0:
        D.appendleft(a)
    else:
        D[i-1] = a

print(len(D))
# Judge status: Wrong Answer
N, M = map(int,input().split())

if N == 1 or M == 1:
    if N + M == 1:
        print(1)
    else:
        print(N*M-2)
else:
    print((N-2)*(M-2))
# Judge status: Accepted
import sys
sys.setrecursionlimit(100000)

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

def kaijo(n):
    if n == 1:
        return 1
    return n * kaijo(n - 1) % ((10 ** 9) + 7)


if abs(n - m) > 1:
    print(0)
    exit()
a = kaijo(n)
b = kaijo(m)

if n == m:
    print((a * b * 2) % ((10 ** 9) + 7))
else:
    print((a * b ) % ((10 ** 9) + 7))
# Judge status: Accepted
def koubai(a,b):
    if b == 0:
        return a
    else:
        return koubai(b,a%b)

a,b = map(int,input().split())
if a < b :
    a,b = b,a  
s = koubai(a,b)
print( int ( (a*b) /s ) )
# Judge status: Wrong Answer
s = input()
k = int(input())    
for si in s:
    if si != '1':
        print(si)
        exit()
else:
    print(1)
# Judge status: Accepted
S = input()

first = int(S[0:2])
last = int(S[2:4])

if (0 < first < 13):
	if (0 < last < 13):
		print("AMBIGUOUS")
	else:
		print("MMYY")
else:
	if (0 < last < 13):
		print("YYMM")
	else:
		print("NA")
# Judge status: Wrong Answer
t=input()
trigger=1
app=['dream','dreamer','erase','eraser']
while len(t)>0 and trigger:
    for i in range(4):
        key=app[i]
        if key==t[:len(key)]:
            t=t[len(key):]
            trigger+=1
            break
    trigger-=1
if t=='':
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
N = int(input())
S = []

for i in range(N):
  S.append(input())
set(S)
print(len(S))
# Judge status: Accepted
N, A, B = map(int, input().split())
S = input()

confirmed = 0
confirmedB = 0

for c in S:
    if c == "a" and confirmed < A+B:
        print("Yes")
        confirmed += 1
    elif c == "b" and confirmed < A+B:
        if confirmedB < B:
            print("Yes")
            confirmed += 1
            confirmedB += 1
        else:
            print("No")
    else:
        print("No")
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

tmp = [0 for i in range(N+1)]
length = 0
for i in range(N):
  tmp[i+1] = tmp[i] + A[i]
  length += A[i]
  
ans = 0
for i in range(1, N+1):
 ans = min(ans, abs((length - tmp[i]) - tmp[i]))

print(ans)
# Judge status: Wrong Answer
x, s = *open(0),

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

p = 0
wp = 0

for char in s:
    if char == 'c' or p >= a+b:
        print('No')
        continue
    if char == 'a':
        p += 1
        print('Yes')
        continue
    if wp < b:
        p += 1
        wp += 1
        print('Yes')
    else:
        print('No')
# Judge status: Accepted
# AGC 027 A - Candy Distribution Again
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0
for i in range(n):
    if i == n-1:
        if x == a[i]:
            count += 1
        else:
            break
    elif x >= a[i]:
        x -= a[i]
        count += 1
    else:
        break
        
print(count)
# Judge status: Wrong Answer
import sys
input = lambda: sys.stdin.readline().rstrip()

S = input()

N = len(S)

S_left = S[:(N-1)//2]
S_right = S[(N+1)//2:]


def ch_kaibun(s):
    if not s:
        return True

    if len(s) % 2 == 0:
        return False 

    n = len(s)
    for i in range((n-1)//2):
        if s[i] != s[n-1-i]:
            return False
    return True


if ch_kaibun(S) and ch_kaibun(S_left) and ch_kaibun(S_right):
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
a,b=map(int,input().split())
l=[]
for x in range(a):
    l.append(b-x)
    l.append(b+x)
l.remove(b)
print(sorted(l))
# Judge status: Accepted
import sys
import math

from collections import defaultdict
from collections import deque
def load(vtype=int):
    return vtype(input().strip())
    
n = load()
li = []
for _ in range(5):
    li.append(load())

mn = min(li)
mni = li.index(mn)

ans = math.ceil(n / mn) + mni + (5-mni-1)
print(ans)
# Judge status: Accepted
a, b, c, d = [int(i) for i in input().split()]
print("Yes" if abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d) else "No")
# Judge status: Accepted
n = int(input())
l = [64,32,16,8,4,2,1]
for i in l:
  if i <= n:
    print(i)
    break
# Judge status: Accepted
from collections import deque
q=deque()
def MI(): return map(int, input().split())
N,M=MI()
g=[[] for _ in range(N+1)]
for _ in range(M):
  a,b=MI()
  g[a].append(b)
  g[b].append(a)
check=[0]*(N+1)
check[1]=1
ans=[0]*(N+1)
q.append(1)
while len(q)>0:
  v=q.popleft()
  for u in g[v]:
    if check[u]==0:
      check[u]=1
      ans[u]=v
      q.append(u)
print('Yes')
for i in range(2,N+1):
  print(ans[i])
# Judge status: Accepted
from math import sqrt, ceil

n = int(input())
data = list(map(int, input().split()))
balls = []

mid = n//2+1
table = [0] * n
for idx in range(mid-1, n):
    table[idx] = data[idx]
    if data[idx] == 1:
        balls.append(idx+1)
for idx in range(mid-2, -1, -1):
    score = 0
    for idx2 in range(idx, n, idx+1):
        score += table[idx2]
    if score%2 != data[idx]:
        table[idx] = 1
        balls.append(idx+1)

print(len(balls))
if len(balls) > 0:
    print(' '.join(map(str, balls)))
# Judge status: Accepted
a = int(input());

if a >= 30:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
X = int(input())

#Happyness
H = 0

div_500 = X // 500
div_5 = (X - 500 * div_500) // 5

H = 1000 * div_500 + 5 * div_5

print(H)
# Judge status: Accepted
import itertools
import math
import fractions
import functools
a, b = map(int, input().split())
if (b+a)/2 == (b+a)//2:
    print((b+a)//2)
else: print("IMPOSSIBLE")
# Judge status: Accepted
# A - Dividing a String
S = input()
ans = 0
tmp = ''
prev = ''
for i in range(len(S)):
    tmp += S[i]
    if tmp!=prev:
        ans += 1
        prev = tmp
        tmp = ''
print(ans)
# Judge status: Accepted
s = input()
s = s.split('/')
s = list(map(int, s))
if s[0]<2018 or (s[0]==2019 and s[1]<=4 and s[2]<=30):
    print('Heisei')
else:
    print('TBD')
# Judge status: Wrong Answer
n = int(input())
l = list(map(int,input().split()))
l.sort(reverse = True)
if l[0] > sum(l[1:n]):
    print('Yes')
else:
    print('No')
# Judge status: Accepted
N, W = map(int, input().split())

dp = [[0]*(W+1) for _ in range(N+1)]

for i in range(1, N+1):
  w, v = map(int, input().split())
  for j in range(W+1):
    dp[i][j] = dp[i-1][j]
    if j >= w:
      dp[i][j] = max(dp[i][j], dp[i-1][j-w]+v)

print(dp[N][W])
# Judge status: Accepted
k = int(input())
if k%2 == 0:
  print((k//2)**2)
else:
  print((k//2)*(k+1)//2)
# Judge status: Accepted
from collections import deque
from itertools import count
Odd = deque(input())
Even = deque(input())
rtnList = lambda x: Odd if x & 1 else Even
ans = ''
for i in count(1,1):
    try:
        s = rtnList(i).popleft()
    except IndexError:
        print(ans)
        exit()
    ans += s
# Judge status: Wrong Answer
stir=input()
lst=stir.split(" ")
l=int(lst[0])
r=int(lst[1])
t=lst[2]
b=1
x=0
multiples=[]
while(b<101):
    multiples.append(int(t)*b)
    b+=1
for a in range(l-1, r+1):
    for m in multiples:
        if(m==a):
            x+=1
print(x)
# Judge status: Wrong Answer
N = int(input())
s = str(input())
t = str(input())

if s == t:
    print(N)
else:
    for i in range(N):
        if s[N-1-i]!=t[i]:
            print(2*N-i)
            break
# Judge status: Accepted
import math

N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
maxA = A[len(A)-1]
valid = [True] * (maxA+1)

for i in range(len(A)):
    if valid[A[i]] == False:
        continue
    if i != 0 and A[i-1] == A[i]:
        valid[A[i]] = False
    else:
        for j in range(A[i]*2, maxA+1, A[i]):
            valid[j] = False

count = 0
for i in range(len(A)):
    if valid[A[i]] == True:
        count += 1
print(count)
# Judge status: Accepted
N = int(input())
A = list(map(int,input().split()))
arai = sum(A)
sunuke = 0
ans = 10000000000000000
for i in A[:-1]:
    arai -= i
    sunuke += i
    x = abs(sunuke - arai)
    if x < ans:
        ans = x
print(ans)
# Judge status: Wrong Answer
import math
n = int(input())
ans = 20**(n-2) % (10**9 + 7)
print(math.floor(ans))
# Judge status: Accepted
n,t= map(int, input().split())
l=[]
for i in range(n):
        l.append(list(map(int, input().split())))
ans = 10**9
for i in range(n):
        cost = l[i][0]
        time = l[i][1]
        if time <= t and cost < ans:
                ans=cost
if ans == 10**9:
        print("TLE")
else:
        print(ans)
# Judge status: Wrong Answer
from collections import Counter
from scipy.misc import comb
N = int(input())
An = list(map(int, input().split()))
counter = Counter(An)
cnt = 0
for c in counter.values():
    cnt += comb(c, 2)
for a in An:
    print(int(cnt - comb(counter[a], 2) + comb(counter[a]-1, 2)))
# Judge status: Accepted
t=input()
t=t.replace("?", "D")
print(t)
# Judge status: Wrong Answer
n, a, b = map(int, input().split())

if n == 1 and a != b:
    ans = 0
else:
    ans = (b * (n - 1) + a) - (a * (n - 1) + b)

print(ans)
# Judge status: Accepted
N = int(input())

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

for k in range(1,N+1):
    c[int(str(k)[0])][int(str(k)[-1])]+=1

ans = 0

for k in range(81):
    i = k // 9 + 1
    j = k % 9 + 1
    ans += c[i][j] * c[j][i]

print(ans)
# Judge status: Wrong Answer
s = list(input())
l = list("keyence")
i = 0
for si in s:
    if l[i] == si:
        i+=1
        if i == 7:
            print("YES")
            break
else:
    print("NO")
# Judge status: Wrong Answer
import sys
H = int(input())
if H == 1:
    sys.exit()
cnt = 1
i = 1
H //= 2
while H > 0:
    i <<= 1
    cnt += i
    H //= 2
print(cnt)
# Judge status: Accepted
import queue
q=queue.Queue()
for i in range(1,10):
    q.put(i)
N=int(input())
for i in range(N):
    a=q.get()
    b=a%10
    if b!=0:
        q.put(10*a+b-1)
    q.put(10*a+b)
    if b!=9:
        q.put(10*a+b+1)
print(a)
# Judge status: Accepted
a, b, c, k = map(int, input().split())
if k <= a:
    print(k)
elif k <= a + b:
    print(a)
else:
    print(a-(k - a - b))
# Judge status: Accepted
import sys
input = sys.stdin.readline
input = sys.stdin.buffer.readline

#sys.setrecursionlimit(10**9)

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))
# rstrip().decode('utf-8')
#import numpy as np


def main():
	a,b=MI()
	for i in range(100):
		if (a-1)*i+1>=b:
			print(i)
			exit(0)
			
if __name__ == "__main__":
	main()
# Judge status: Accepted
from math import sqrt


def distance(a, b):
    return sqrt(a ** 2 + b ** 2)


n, d = list(map(int, input().split()))
res = 0
for _ in range(n):
    l = list(map(int, input().split()))
    if d >= distance(l[0],l[1]):
        res += 1
print(res)
# Judge status: Accepted
a, b, t = map(int, input().split())
T = int((t+0.5)//a)
print(T*b)
# Judge status: Wrong Answer
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
for i in range(n):
  a[i]=max(a[i]-b[i],0)
  b[i]=max(b[i]-a[i],0)
for i in range(n):
  a[i+1]=max(b[i]-a[i+1],0)
print(sum(a))
# Judge status: Accepted
import sys
import math

a, b, h, m = map(int, input().split())
h = (h+m/60)/12*2*math.pi
m = m/60*2*math.pi
p1 = [a*math.cos(h), a*math.sin(h)]
p2 = [b*math.cos(m), b*math.sin(m)]
print(((p1[0]-p2[0])**2+(p1[1]-p2[1])**2)**0.5)