peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import numpy as np
n, m = map(int, input().split())
py = [list(map(int, input().split())) for i in range(m)]
py2 = [py[i].append(i) for i in range(m)]
py.sort(key=lambda x: x[1])
now = py[0][0]
count = 0
anslist = np.empty((m, 2))
for i in range(m):
    if now == py[i][0]:
        count += 1
    else:
        now = py[i][0]
        count = 1
    anslist[py[i][2], 0] = py[i][0]
    anslist[py[i][2], 1] = count

for x, y in anslist:
    print("{:06}".format(int(x)) + "{:06}".format(int(y)))
# Judge status: Accepted
N = int(input())
H = list(map(int,input().split()))
ans = []
count = 0
if len(H) == 1:
  print(0)
  exit()
for i in range(1,N):
  if H[i-1] < H[i]:
    ans.append(count)
    count = 0
  elif H[i-1] >= H[i]:
    count += 1
  if i == N-1:
    ans.append(count)

print(max(ans))
# Judge status: Accepted
n=[]
for i in input():
  if i=='B':
    if n: n.pop()
  else:
    n.append(i)
print(*n,sep='')
# Judge status: Accepted
n = int(input())
s = input()
cnt_w, cnt_b = s.count("."), 0
ans = cnt_w
if s.count(".") == n or s.count("#") == n:
    ans = 0
else:
    for i in range(n):
        if s[i] == "#":
            cnt_b += 1
        else:
            cnt_w -= 1
        if i == n - 1 or s[i] != s[i + 1]:
            ans = min(ans, cnt_w + cnt_b)
print(ans)
# Judge status: Accepted
import math
answer = 0
score = list(map(int,input().split()))
Alist = []
for i in range(2000):
    if math.floor((i+1)*0.08) == score[0]:
        Alist.append(i+1)
for j in range(2000):
    if math.floor((j+1)*0.10) == score[1]:
        if j+1 in Alist:
            print(j+1)
            answer = 1
            break
if answer == 0:
    print(-1)
# Judge status: Accepted
from math import floor


def main():
    S = input()
    result = 0
    for i in range(floor(len(S) / 2)):
        if S[i] != S[len(S) - i - 1]:
            result += 1

    print(result)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
print((int(input())+int(input()))//2*int(input()))
# Judge status: Wrong Answer
import sys

s=input()
t=input()
r=""

for i in range(len(t)):
  if s==t:
    print("Yes")
    sys.exit()
    
  r=s[-1]
  s=s.strip(s[-1])
  s=r+s
  
print("No")
# Judge status: Accepted
n = int(input())
t, x, y = [0]*(n+1), [0]*(n+1), [0]*(n+1)
for i in range(1,n+1):
    t[i], x[i], y[i] = map(int, input().split())

for i in range(1, n+1):
    a = abs(t[i] - t[i-1])
    b = abs(x[i] - x[i-1]) + abs(y[i] - y[i-1])
    if a>=b and a%2 == b%2:
        continue
    else:
        print("No")
        break
else:
    print("Yes")
# Judge status: Accepted
a,b=map(int, input().strip().split())
print((a+b)%24)
# Judge status: Accepted
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

N, M, K = map(int, readline().split())
A = list(map(int, readline().split()))
B = list(map(int, readline().split()))

ac = [0]
bc = [0]

for i in range(N):
    ac.append(ac[i] + A[i])
for i in range(M):
    bc.append(bc[i] + B[i])

ans = 0
j = M

for i in range(N+1):
    if ac[i] > K:
        break
    while bc[j] > K - ac[i]:
        j -= 1
    ans = max(ans, i+j)
        
print(ans)
# Judge status: Wrong Answer
A, B, K = map(int, input().split())

max_num = max(A, B)
min_num = min(A, B)
divs = [m for m in range(1, min_num+1) if min_num % m == 0]

ans = []
for d in divs:
    if max_num % d == 0:
        ans.append(d)
print(ans[K-1])
# Judge status: Wrong Answer
def coffee(ar):
    
    if ar[3] == ar[4] and ar[5] == ar[6]:
      return 'Yes'
    else:
      return 'No'

if __name__ == '__main__':

    ar = str(input().split())

    result = coffee(ar)
    print(result)
# Judge status: Accepted
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np
from functools import reduce

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

n, m = rm()
if n == m:
    print((math.factorial(n) * math.factorial(m) * 2) % mod)
elif abs(n-m) == 1:
    print((math.factorial(n) * math.factorial(m)) % mod)
else:
    print(0)
# Judge status: Accepted
N = int(input())
S = str(input())

alphabet='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
out=''
for i in range(len(S)):
    for j in range(len(alphabet)):
        if S[i]==alphabet[j]:
            out= out + str(alphabet[(j+N)%(len(alphabet))])
print(out)
# Judge status: Accepted
x, n = map(int, input().split(" "))
p = input()
if p == "":
    print(x)
    exit(0)
p = list(map(int, p.split(" ")))
answer = 0
for i in range(1, 102):
    if i not in p:
        if abs(x - answer) > abs(i - x):
            answer = i
print(answer)
# Judge status: Accepted
n,x,y = map(int, input().split())

count = [0]*(n-1)
for i in range(1,n+1):
    for j in range(i+1,n+1):
        d_min = min(abs(i-j),abs(x-i)+1+abs(y-j),abs(x-j)+1+abs(y-i))
        count[d_min-1] += 1

for i in count:
    print(i)
# Judge status: Accepted
#!/usr/bin/env python3

s=input()
m="keyence"
if s=="keyence":
    print("YES")
elif s[0:7]=="keyence":
    print("YES")
elif s[-8:-1]=="keyence":
    print("YES")
elif s[0]=="k" and s[-1]=="e":
    ans = "NO"
    for i in range(6):
        if s[0:i+1]==m[0:i+1] and s[-6+i:]==m[-6+i:]:
            ans="YES"
    print(ans)

else:
    print("NO")
# Judge status: Wrong Answer
n, x = map(int, input().split())
a = list(map(int, input().split()))

a.sort()
count = 0

for i in a:
    if x >= i:
        x -= i
        count += 1
    else:
        pass
        
print(count)
# Judge status: Accepted
"""
dp[与えたダメージ] = 使用した魔力
"""
h, n = map(int, input().split())
attacks = []
INF = 10000000000000
dp = [INF for _ in range(h + 1)]
dp[0] = 0
for i in range(n):
    a, b = map(int, input().split())
    attacks.append([a, b])
    
for i in range(h):
    for j in range(n):
        dp[min(h,i + attacks[j][0])] = min(dp[min(h, i + attacks[j][0])], dp[i] + attacks[j][1])
print(dp[h])
# Judge status: Wrong Answer
n = int(input())
a = list(map(int,input().split()))
a.sort()
if n == 2:
  print(a[1]-a[0])
else:
  print(a[n//2+1]-a[n//2])
# Judge status: Accepted
N, K = map(int, input().split())

N = N % K
# print(N)
ans_candidate_list = [N]
while True:
    N = abs(N - K)
    # print(N)
    # print(ans_candidate_list)
    if N not in ans_candidate_list:
        ans_candidate_list.append(N)
    else:
        break

print(sorted(ans_candidate_list)[0])
# Judge status: Accepted
S = input()
N = len(S)
is_strong_pal = (S == S[::-1])
is_strong_pal &= (S[:(N-1)//2] == S[:(N-1)//2:-1])
is_strong_pal &= (S[(N+3)//2-1:] == S[(N+3)//2-1:][::-1])
print('Yes' if is_strong_pal else 'No')
# Judge status: Accepted
N=int(input())
t=2*N
i=1
while i*i<=N:
  if N%i==0:
    if (i-1)+(N//i-1)<=t:
      t=(i-1)+(N//i-1)
  i += 1
print(t)
# Judge status: Accepted
# -*- coding: utf-8 -*-
N = int(input())
ans_list = [0 for i in range(N + 1)]
for i in range(1, 101):
    for j in range(1, 101):
        for k in range(1, 101):
            now_num = i ** 2 + j ** 2 + k ** 2 + i * j + j * k + k * i
            if now_num > N:
                break
            ans_list[now_num] += 1

for i in range(1, N + 1):
    print(ans_list[i])
# Judge status: Accepted
import collections
c = {0: 0, 1: 0, 2: 1}
n = int(input())
sum = 0
for i in range(3, n + 1):
    c[i] = c[i - 1] * i // (i - 2)
cc = collections.defaultdict(int)
a = list(map(int, input().split()))
for i in a:
    cc[i] += 1
for k, v in cc.items():
    sum += c[v]
# print (c)
# print (cc)
# print (sum)
for i in range(n):
    v = cc[a[i]]
    # print (v)
    # print(c[v], c[v - 1])
    print (sum - c[v] + c[v - 1])
# Judge status: Wrong Answer
import math
H, W = map(int, input().split())

if H == 1 or W == 1:
    print(0)
    exit()
    
print(math.ceil((H * W) / 2))
# Judge status: Accepted
MOD=10**9+7

N,K=map(int,input().split())
ans=0
ans+=N-K+2
ans+=(N+1)*(N+1+K)*(N-K+2)//2
ans%=MOD
ans-=(N+1)*(N+2)*(2*N+3)//6
ans%=MOD
ans+=K*(K-1)*(2*K-1)//6
ans%=MOD
print(ans)
# Judge status: Accepted
n = int(input())
t,x,y = 0,0,0

for i in range(n):
    T,X,Y = map(int,input().split())
    dt,dx,dy = T-t,abs(X-x),abs(Y-y)
    if dt - (dx + dy) < 0 or (dt - (dx + dy))%2 == 1:
        print("No")
        exit()
    t,x,y = T,X,Y

print("Yes")
# Judge status: Accepted
a=input()
n=len(a)

for i in range(2**n):
  res=int(a[0])
  ans=[a[0]]
  for j in range(1,n):
    if i&(1<<j):
      ans.append('+')
      ans.append(a[j])
      res+=int(a[j])
    else:
      ans.append('-')
      ans.append(a[j])
      res-=int(a[j])
  if res==7:
    print(*ans,'=7',sep='')
    exit()
# Judge status: Wrong Answer
S = list(input())
if set(S) == 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))

mn = min(A)
while True:
    ok = False
    for a in A:
        x = a % mn
        if x != 0 and x < mn:
            mn = x
            ok = True
    if not ok:
        break
print(mn)
# Judge status: Wrong Answer
N=int(input())
if N<105:
    print(0)
elif N==105:
    print(1)
else:
    ans=0
    for n in range(106,N+1):
        if n%2:
            K=n//2
            y=0
            for k in range(2,K):
                if n%k==0:
                    y+=1
            if y==6:
                ans+=1
    print(ans)
# Judge status: Accepted
def main():
    n, k = map(int, input().split())

    print(1 if n%k!=0 else 0)

if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
sx, sy, tx, ty = map(int, input().split())
dx, dy = tx-sx, ty-sy
ans = ""
ans += "L" + (dy+1)*"U" + (dx+1)*"R" + "D"
ans += dy*"U" + dx*"R"
ans += dx*"R" + dy*"U"
ans += "D" + (dx+1)*"R" + (dy+1)*"U" + "L"
print(ans)
# Judge status: Accepted
s = input()
ans = True
for i in range(len(s) // 2):
    if s[len(s) - 1 - i] != s[i]:
        ans = False
if ans:
    for i in range(len(s) // 4):
        if s[(len(s) - 1) // 2 - i - 1] != s[i]:
            ans = False

    for i in range(len(s) // 2 + 1, len(s) // 4 + len(s) // 2 + 1):
        if s[i] != s[len(s) - 1 - i]:
            ans = False

print('Yes' if ans else 'No')
# Judge status: Wrong Answer
n,d=map(int,input().split())
x= [list(map(int, input().split())) for i in range(n)]
lis=list(i**2 for i in range(0,22))
ans=0
for i in range(n):
    for k in range(i+1,n):
        check=0
        for j in range(d):
            check+=(x[i][j]-x[k][j])**2
        if check in lis:
            ans+=1
print(ans)
# Judge status: Wrong Answer
a,b=map(int,input().split())
count=0
for i in range(1000):
  count+=i
  if 0<=count-a<=a:
    print(count-a)
    exit()
# Judge status: Accepted
n=int(input())
l=[]
for i in range(int(n**0.5)+1):
  l.append(i**2)
print(max(l))
# Judge status: Accepted
from sys import stdin


def main():
    input = lambda: stdin.readline()[:-1]
    K = int(input())
    A, B = map(int, input().split())

    for i in range(A, B + 1):
        if not i % K:
            print('OK')
            return
    print('NG')


main()
# Judge status: Wrong Answer
N = int(input())
H = input().split()
l=0
t_l = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    t_l = t_l + 1
    if l < t_l:
      l = t_l
  else:
    t_l=0
print(l)
# Judge status: Wrong Answer
n = int(input())
a1 = int(input())
flag= a1%2
ans = a1//2
for i in range(n-1):
    a = int(input())
    ans+=a//2
    if flag and a%2==1:
        ans+=1
        flag=0
    else:
        flag=a%2
print(ans)
# Judge status: Wrong Answer
ae = [int(input()) for i in range(5)]

mm = ae[0]%10
for i in range(5):
    mm = min(mm, ae[i]%10)
    if ae[i]%10 != 0:
        ae[i] = ((ae[i]//10)+1)*10
if mm != 0:
    print(sum(ae)-(10-mm))
else:
    print(sum(ae))
# Judge status: Accepted
N, M = map(int, input().split())
pref = [1] * (N + 1)
iPY = []
for i in range(M):
    p, y = map(int, input().split())
    iPY.append([i, p, y])

iPY.sort(key=lambda x: x[2])
ans = []
for i, p, y in iPY:
    name = str(p).zfill(6) + str(pref[p]).zfill(6)
    ans.append((i, name))
    pref[p] += 1

ans.sort(key=lambda x: x[0])
for _, name in ans:
    print(name)
# Judge status: Accepted
n = int(input())
b = list(map(int,input().split()))
sum = b[n-2] + b[0]
for i in range(n-2):
    sum += min(b[i],b[i+1])

print(sum)
# Judge status: Accepted
import sys
input = sys.stdin.readline
print(-(-int(input()) // 2))
# Judge status: Accepted
from sys import stdin
n = int(stdin.readline().rstrip())
li = [int(stdin.readline().rstrip()) for _ in range(n)]
count = 0
point = 0
for i in li:
    if i == 0:
        point += count//2
        count = 0
    else:
        count += i
point += count//2
print(point)
# Judge status: Wrong Answer
s = input()
if(s[2] == s[3] and s[4] == s[5]):
  print("YES")
else:
  print("NO")
# Judge status: Wrong Answer
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))
max = 0

for i in range(N):
  point = sum(A1[:i]) + sum(A2[i:])
  if max < point:
    max = point

print(max)
# Judge status: Wrong Answer
n=input()
print('Yes' if n.count(n[0])>=3 or n.count(n[1])>=3 else 'No')
# Judge status: Accepted
# イベントソートでもできると思う

import heapq

N, M = map(int, input().split())
event_list = [[m, 10**5] for m in range(1, M+1)]
for i in range(N):
  a, b = map(int, input().split())
  event_list.append([a, b])


event_list.sort()
jobs = []
ans = 0
for event in event_list:
  if event[1] < 10**5:
    heapq.heappush(jobs, -event[1])
  else:
    if jobs:
      ans -= heapq.heappop(jobs)

print(ans)
# Judge status: Accepted
import math
from collections import Counter
a, b = map(int, input().split())
x = math.gcd(a, b)

Nso = []
Nruto = math.sqrt(x)
Nruto = math.floor(Nruto)

for i in range(2, Nruto+1):
    while x % i == 0:
        x = x//i
        Nso.append(i)
    if x == 1:
        break
    Nruto = math.sqrt(x)
    Nruto = math.floor(Nruto)

Nso.append(x)
Nso.append(1)
Nso = Counter(Nso)
print(len(Nso))
# Judge status: Accepted
n = int(input())
a = [[0] * n for i in range(2)]


for i in range(2):
    arr = input().split()
    arr = list(map(int,arr))
    for j in range(n):
        a[i][j] = arr[j]

m = 0
for i in range(n):
    l = 0
    r = 0
    for k in range(i+1):
        l += a[0][k]
    for k in range(i,n):
        r += a[1][k]

    if m <= l + r:
        m = l + r

print(m)
# Judge status: Wrong Answer
O = input()
E = input()
a = ''
cnt = 0
for i in O:
    a += i
    cnt += 1
    if (len(O) == cnt)and(len(O)>len(E)):
        break
    for j in E:
        a += j
        E = E.lstrip(j)
        break
print(a)
# Judge status: Accepted
S = input()
Sliststr = list(S)
Slist = [int(s) for s in Sliststr]
Smod = [0]
mod10 = [1]
count = [0]*2019
ans = 0
for i in range(len(S)-1):
  mod10.append(mod10[i]*10%2019)
for i in range(len(S)):
  Smod.append((Smod[i]+Slist[-i-1]*mod10[i])%2019)
for i in range(len(Smod)):
  count[Smod[i]] += 1
for i in range(2019):
  ans += count[i] * (count[i]-1) // 2
print(ans)
# Judge status: Accepted
import math
n=float(input())
print(n*2*math.pi)
# Judge status: Accepted
n, m = map(int, input().split())
ans = 0
if n > 1:
    ans += n * (n - 1) // 2
if m > 1:
    ans += m * (m - 1) // 2
print(ans)
# Judge status: Accepted
c = [list(map(int, input().split())) for i in range(3)]
print("Yes" if c[1][0]-c[0][0]==c[1][1]-c[0][1]==c[1][2]-c[0][2] and c[2][0]-c[0][0]==c[2][1]-c[0][1]==c[2][2]-c[0][2]
     else "No")
# Judge status: Wrong Answer
N, Y = map(int, input().split())

total = 0
for a in range(N):
    
    for b in range(N):
        
        c = N -a -b
            
        total = a*10000 + b*5000 + c*1000 
        if (total == Y) and (a+b+c==N) and (c>=0):
            print(a, b, c)
            exit()
        
print(-1,-1,-1)
# Judge status: Accepted
n,m = map(int,input().split())
s = [[int(i) for i in input().split()] for i in range(m)]
d = {}

for i in range(m):
    if s[i][0] == 1:
        d[s[i][1]] = 1
    
for i in range(m):
    if s[i][1] == n and s[i][0] in d:
        print("POSSIBLE")
        exit()

print("IMPOSSIBLE")
# Judge status: Accepted
A, B, N = map(int, input().split())
ans = max((A*N)//B - A*(N//B), 0)

def func(x):
    return (A*x)//B - A * (x//B)

if N < B - 1:
    print(func(N))
else:
    print(func(B-1))
# Judge status: Wrong Answer
n = int(input())
li = list(map(int,input().split()))
flag = False
for i in li:
  if i % 6 == 0 or i % 10 == 0:
    continue
  else:
    print("DENIED")
    flag = True
if not flag:
  print("APPROVED")
# Judge status: Wrong Answer
hist = []
nm = list(map(int, input().split()))
for i in range(nm[1]):
    a,b=input().split()
    hist.append((int(a), b))

ac = [0] * nm[0]
wa = [0] * nm[0]

for i in range(nm[1]):
    if hist[i][1] == "AC":
        if ac[hist[i][0]-1] != 1:
            ac[hist[i][0]-1] = 1
    else:
        if ac[hist[i][0]-1] != 1:
            wa[hist[i][0]-1] = wa[hist[i][0]-1] + 1

print(sum(ac), sum(wa))
# Judge status: Accepted
N, D = map(int, input().split())
D = 2*D + 1
print((N+D-1)//D)
# Judge status: Accepted
N, K = list(map(int, input().split()))
H = list(map(int, input().split()))

H.sort(key=lambda x: -x)

c = min(K, N)

i = 0
while 0 < c:
    H[i] = 0
    c -= 1
    i += 1

ans = 0
for j in range(i, N):
    ans += H[j]

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

sum=0


for i in range(k,n):
    if a[i-k]<a[i]:
        print("Yes")
    else:
        print("No")
# Judge status: Accepted
A = list(map(int,input().split()))
A.sort(reverse = True)

X = A[0] - A[1]
Y = A[0] - A[2]
ans = 0

if (X % 2 == 0) and (Y % 2 == 0):
    ans = X//2 + Y//2
elif (X % 2 == 1) and (Y % 2 == 1):
    ans = X//2 + Y//2 + 1
else:
    ans = X//2 + Y//2 + 2

print(ans)
# Judge status: Wrong Answer
print('YNeos'['9' in input()::])
# Judge status: Accepted
s = str(input())
a = s.count("N")
b = s.count("W")
c = s.count("S")
d = s.count("E")
if (a  == 0 and c != 0) or (c  == 0 and a != 0) or (b  == 0 and d != 0) or (d  == 0 and b != 0):
    print("No")
else:
    print("Yes")
# Judge status: Accepted
S = input()

for i in range(1, len(S)):
    if i % 2 > 0: continue
    ans = None
    for j in range((len(S) - i) // 2):
        if S[j] == S[j + (len(S) - i) // 2]:
            continue
        else:
            break
    else:
        ans = len(S) - i
    #
    if ans != None: break

print(ans)
# Judge status: Accepted
S = input()
flg = True

for i, c in enumerate(S):
    if (i%2==0 and c=='L') or (i%2==1 and c=='R'):
        flg = False

print('Yes' if flg else 'No')
# Judge status: Accepted
a, b = [int(i) for i in input().split()]
print("Even" if(a * b % 2 == 0) else "Odd")
# Judge status: Accepted
x = int(input())
if x == 3 or x == 5 or x == 7:
    print("YES")
else:
    print("NO")
# Judge status: Accepted
n = int(input())
s = input()
ans = 0
c = 0
for i in range(n):
    if s[i] == "#":
        c += 1
    else:
        if c >= 1:
            ans += 1
            c -= 1
    
print(ans)
# Judge status: Accepted
n = int(input())
b = [int(i) for i in input().split()]

s = 0
s = b[0]+b[-1]
for i in range(1, n-1):
  s += min(b[i],b[i-1])
  
print(s)
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1,N + 1):
    if(len(str(i)) % 2 == 1):
        ans += 1   
print("%d"%(ans))
# Judge status: Accepted
# https://atcoder.jp/contests/abc135/tasks/abc135_a

A, B = map(int, input().split())


K = (A + B) / 2

if (A + B) % 2 == 0:
    print(int(K))

else:
    print('IMPOSSIBLE')
# Judge status: Accepted
parr = [int(input()) for _ in range(5)]
arr = []

for x in parr:    
    if x%10 == 0:
        arr.append([0,x,x])
    else:
        arr.append([x%10, (x//10 + 1)*10,x])

arr.sort()

found = False
ans = 0
for cur in arr:
    r,v,o = cur
    if r == 0:
        ans += v
    else:
        if found:
            ans += v
        else:
            ans+= o
            found = True

print(ans)
# Judge status: Accepted
s=int(input())
s1=s//100
s2=s-s1*100
if 0<s1<=12 and 0<s2<=12:
    print("AMBIGUOUS")
elif (s1>12 or s1==0) and 0<s2<=12:
    print("YYMM")
elif 0<s1<=12 and (s2>12 or s2==0):
    print("MMYY")
else:
    print("NA")
# Judge status: Wrong Answer
n, k = map(int, input().split())
a = []
for i in range(1,n+1):
    x = i
    for j in range(100001):
        x = x*2
        if x >= k:
            #print(j)
            a.append(1/n * (0.5**(j)))
            break
print(sum(a))
# Judge status: Wrong Answer
N = input()
n = int(N)
output = float((2*n - 1)/n)
print(output)
# Judge status: Accepted
def solve():
    n, k = map(int, input().split())
    s = []
    for i in range(n):
        s.append(int(input()))
    s.sort()
    res = 10 ** 10
    for i in range(n + 1 - k):
        tmp = s[i + k - 1] - s[i]
        res = min(res, tmp)
    print(res)

solve()
# Judge status: Accepted
N = int(input())
s = sorted([int(input()) for _ in range(N)])
ans = sum(s)
if ans % 10 != 0:
    print(ans)
else:
    for s_i in s:
        if s_i % 10 != 0:
            ans -= s_i
            print(ans)
            break
    else:
        print(0)
# Judge status: Accepted
def actual(N, A):
    records = []

    for i, a in enumerate(A, start=1):
        record = dict(student_id=str(i), num_students=a)
        records.append(record)

    records_asc = sorted(records, key=lambda x: x['num_students'])

    return ' '.join([record['student_id'] for record in records_asc])


N = int(input())
A = list(map(int, input().split()))
print(actual(N, A))
# Judge status: Accepted
a,b = map(int,input().split())
if max(a,b)*2<=16:
    print('Yay!')
else:
    print(':(')
# Judge status: Wrong Answer
a,b,c,d = map(int,input().split())
if b*c >= b*d:
    print(b*c)
elif a*c >= b*d:
    print(a*c)
elif a*d >= b*d:
    print(a*d)
else:
    print(b*d)
# Judge status: Accepted
n = int(input())

if((n%1000) == 0):
  ans = 0
else:
  ans = 1000-(n%1000)
  
print(ans)
# Judge status: Wrong Answer
S = input()


def is_palindrome(s):
    N = len(s)
    half = N // 2
    f = s[:half]
    r = s[-half:][::-1]
    return f == r


if is_palindrome(S) and is_palindrome(S[: (len(S) - 1) // 2]):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
x, y = map(int, input().split())
print(min(max(y-x, x-y+2), abs(y+x)+1))
# Judge status: Accepted
import sys
n, k = map(int, sys.stdin.readline().split())
li = list(map(int, sys.stdin.readline().split()))
l = len(li)
t = 0
if l > k:
  li.sort()
  li.reverse()
  t = sum(li[k:])
print(t)
# Judge status: Accepted
# import math
# from itertools import permutations as permus
# from fractions import gcd

# import numpy as np
# import scipy as scp

# 入力の受け取り
s,t = input().split()

ans = t + s

print(ans)
# Judge status: Accepted
N, x = map(int, input().split())
A = list(map(int, input().split()))

if x == 0:
    print(sum(A))
    exit()

count = 0
for i in range(N - 1):
    d = A[i] + A[i + 1] - x
    if d <= 0:
        continue
    if A[i + 1] >= d:
        A[i + 1] -= d
        count += d
    else:
        count += d
        A[i] = d - A[i + 1]
        A[i + 1] = 0


print(count)
# Judge status: Accepted
s = input()[::-1]
templates = [s[::-1] for s in ["dream", "dreamer", "erase", "eraser"]]
while s:
    for template in templates:
        if s.startswith(template):
            s = s.replace(template, "", 1)
            break
    else:
        break
print("YES" if not s else "NO")
# Judge status: Accepted
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
ans = 0
pre = -1
for a in A:
  ans += B[a-1]
  if a - 1 == pre:
    ans += C[a-2]
  pre = a

print(ans)
# Judge status: Accepted
N,M,X=map(int,input().split())
CA=[list(map(int,input().split())) for i in range(N)]
ans=10**18
x=[0]*M
for i in range(1,2**N):
  _ans=0
  _x=x[:]
  f=True
  for j in range(N):
    if i%2==1:
      for k,a in enumerate(CA[j]):
        if k==0:
          _ans+=a
        else:
          _x[k-1]+=a
    i=i//2
  for _ in _x:
    if _<X:
      f=False
      break
  if f:
    ans=min(ans,_ans)
if ans==10**18:
  ans=-1
print(ans)
# Judge status: Accepted
N = int(input())
ans = 0
for i in range(1, N+1):
    num = N // i
    ans += i * num * (num+1) // 2

print(ans)
# Judge status: Wrong Answer
a, b, c =map(int,input().split())
if a**2+b**2 ==c**2:
  print(a*b/2)
elif b**2 + c**2 ==a**2:
  print(b*c/2)
else:
  print(c*a/2)