peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Accepted
N, K = map(int, input().split())
a = [int(x) for x in input().split()]
a.insert(0,0)
for i in range(K,N):
    if a[i-K+1]<a[i+1]:
        print("Yes")
    else: print("No")
# Judge status: Wrong Answer
S = list(input())
N = len(S)
flag = 1

S1 = S[0:int((N-1)/2)]
S2 = S[int((N+1)/2):N]


for i in range(int((N-1)/2)):
  if S1[i] != S1[len(S1)-i-1]:
    flag = 0
  if S2[i] != S2[len(S2)-i-1]:
    flag = 0
    
if flag == 1:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
# https://atcoder.jp/contests/abc139/tasks/abc139_c

n = int(input())
nums = [int(i) for i in input().split()]
nums.append(float('inf'))
ans = 0
t = 0
for i in range(n):
    if nums[i] >= nums[i + 1]:
        t += 1
    else:
        ans = max(ans, t)
        t = 0
print(ans)
# Judge status: Accepted
N, A, B = map(int, input().split())
ans = 0
for i in range(1, N + 1):
    sum_digits = sum(map(int, list(str(i))))
    if A <= sum_digits <= B:
        ans += i
print(ans)
# Judge status: Wrong Answer
s=int(input())
if s+1<=10**9:
  b=str(s+1)
  a=['0','0',b,'1','1','1']
else:
  x2=int(s**(1/2))
  y3=int(s**(1/2))+1
  if x2*y3<s:
    if y3==10**9:
      x2+=1
    else:
      y3+=1
  x2=str(x2)
  y3=str(y3)
  
  y2=str(1)
  x3=str(int(x2)*int(y3)-s)
  x1=str(0)
  y1=str(0)
  a=[x1,y1,x2,y2,x3,y3]
print((' ').join(a))
# Judge status: Wrong Answer
S = list(input())
print('Yes' if len(S)==len(set(S)) else 'No')
# Judge status: Accepted
import math

print(2*int(input())*(math.pi))
# Judge status: Accepted
x=int(input())
for i in range(1,1000):
	if 360*i%x==0:
		ans=360*i//x
		break
print(ans)
# Judge status: Wrong Answer
N = int(input())
X = [int(n) for n in range(N)]

min_ans = +float('inf')

for i in range(N):
    ans = 0
    for x in X:
        ans += (x - i)**2
    min_ans = min([min_ans, ans])

print(min_ans)
# Judge status: Wrong Answer
a, b, c = map(int, input().split())
k = int(input())

res = max([a, b, c]) * (2 * k - 1) + a + b + c
print(res)
# Judge status: Accepted
x,y = map(int,input().split())
for i in range(x+1):
  if i*2+(x-i)*4==y:
    print("Yes");break
else:
  print("No")
# Judge status: Accepted
n,m=map(int,input().split())
ac=[0]*(n+1)
wa=0
for i in range(m):
  p,c=input().split()
  if c=='WA' and ac[int(p)]!=1:
    ac[int(p)]-=1
  elif c=='AC' and ac[int(p)]!=1:
    wa+=abs(ac[int(p)])
    ac[int(p)]=1
print(ac.count(1),wa)
# Judge status: Accepted
from collections import Counter
n = int(input())
l = list(map(int,input().split()))

ans = sum(l)

counter = Counter(l)
q = int(input())
for i in range(q):
    b,c = map(int,input().split())
    ans += (c-b)*counter[b]
    print(ans)
    counter[c] += counter[b]
    counter[b] = 0
# Judge status: Accepted
a,b,c,d,e,f = [ int(input()) for i in range(6) ]

if e-a <= f:
  print("Yay!")
 
else:
  print(":(")
# Judge status: Accepted
a,b = map(int, input().split())
if (a<=8)&(b<=8):
    print("Yay!")
else:
    print(":(")
# Judge status: Accepted
import math
from decimal import Decimal

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

    if Decimal(a).sqrt() + Decimal(b).sqrt() < Decimal(c).sqrt():
        print("Yes")
    else:
        print("No")

main()
# Judge status: Accepted
import math

N,D=(int(x) for x in input().split())

X=Y=p=count=0

for i in range(N):
  X,Y=(int(x) for x in input().split())
  p =math.sqrt(X**2+Y**2)
  if p <= D:
    count += 1
    
print(count)
# Judge status: Wrong Answer
n,m = map(int,input().split())
a = [input() for _ in range(n)]
b = [input() for _ in range(m)]

ans = 0

for i in range(n-m+1):
	for j in range(n-m+1):
		if a[i][j:j+m+1]==b[0]:
			ans = 1
			for k in range(1,m):
				if a[i+k][j:j+m+1] != b[k]:
					ans = 0
			if ans == 1:
				break

if ans==1:
	print('Yes')
else:
	print('No')
# Judge status: Accepted
c11,c12,c13=map(int, input().split())
c21,c22,c23=map(int, input().split())
c31,c32,c33=map(int, input().split())

ans="No"
for a1 in range(c11+1):
    
    b1=c11-a1
    b2=c12-a1
    b3=c13-a1
    a2=c21-b1
    a3=c31-b1

    if c22==a2+b2 and c23==a2+b3 and c32==a3+b2 and c33==a3+b3:
        ans="Yes"
        break

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

n, k = [int(x) for x in stdin.readline().rstrip().split()]

cnt = 1
if n < k:
    print(cnt)
    exit

kk = k
for i in range(100):
    kk = kk * k
    cnt += 1
    if n < kk:
        break

print(cnt)
# Judge status: Wrong Answer
A,B,C = map(int,input().split())
ans = 0
if A == B == C:
  print(-1)
else:
  while A % 2 == 0 and B % 2 == 0 and C % 2 == 0:
    n_A = (B + C) / 2
    n_B = (A + C) / 2
    n_C = (A + B) / 2
    A = n_A
    B = n_B
    C = n_C
    print(A,B,C)
    ans += 1
  print(ans)
# Judge status: Accepted
a,b,c,d = [int(x) for x in input().split()]


print(max(a*c,a*d,b*c,b*d))
# Judge status: Accepted
s = input()
q = int(input())
h, t = [], []
p = 0
for i in range(q):
	c = input().split()
	if c[0] == '1':
		h, t = t, h
		p = 1 - p
	else:
		if c[1] == '1':
			h.append(c[2])
		else:
			t.append(c[2])
if p == 1:
	s = s[::-1]
print("".join(h[::-1]) + s + "".join(t))
# Judge status: Accepted
n, m = map(int, input().split())

if n * 2 >= m:
    print(m // 2)
else:
    print(n + (m - 2 * n) // 4)
# Judge status: Wrong Answer
A,B,C,K =map(int,input().split())

if A >= K:
    print(A)
    

elif A + B >= K:
    print(A)

elif A + B < K:
    c = -1 * (K-(A+B))
    #print(c)
    #print(A)
    cc = A + c
    print(cc)
# Judge status: Accepted
n = int(input())
s = input()

if (len(s) <= n):
    print(s)
else:
    print(s[:n] + '...')
# Judge status: Accepted
n, m = map(int, input().split())
A = list(map(int, input().split()))
BC = [list(map(int, input().split())) for _ in range(m)]

A.sort()
BC.sort(key=lambda x:x[1], reverse=True)

pos = 0
for b, c in BC:
    end = (pos + b) if pos + b <= n else n
    for i in range(pos, end):
        if A[i] < c:
            A[i] = c
        else:
            break
    pos = i + 1
    if pos >= n:
        break

print(sum(A))
# Judge status: Accepted
q, h, s, d = map(int, input().split())
h = min(q + q, h)
s = min(h + h, s)
d = min(s + s, d)
n = int(input())
print(n // 2 * d + n % 2 * s)
# Judge status: Accepted
s=input()
t=input()
if t[:-1]==s:
  print('Yes')
else:
  print('No')
# Judge status: Wrong Answer
a,b,c,d =map(int,input().split())
if b<=c:
    print(0)
elif b>c and b<=d:
    print(b-c)
else:
    print(d-c)
# Judge status: Wrong Answer
# -*- coding: utf-8 -*-

## Library

import sys
from fractions import gcd
import math
from math import ceil,floor
import collections
from collections import Counter
import itertools

## input

# n=int(input())
# A,B,C,D=map(int, input().split())
# string = input()
# yoko = list(map(int, input().split()))
# tate = [int(input()) for _ in range(N)]
# N, M = map(int,input().split()) 
#    P = [list(map(int,input().split())) for i in range(M)]

N = int(input())
A = [int(input()) for _ in range(N)]
C = collections.Counter(A)

ans = 0

for i in range(1,N+1):
    if C[i] % 2 == 1:
        ans += 1

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

from collections import defaultdict
l = defaultdict(int)
r = defaultdict(int)
for si in s:
    r[si] += 1
r[s[0]] -= 1

ans = l['W'] + r['E']
for i in range(1, n):
    l[s[i-1]] += 1
    r[s[i]] -= 1
    #print(l['W'] , r['E'])
    ans = min(ans, l['W'] + r['E'])
print(ans)
# Judge status: Accepted
import math
import sys
from collections import deque
a=input()
for i in range(8):
  c=int(a[0])
  l=[a[0]]
  for j in range(3):
    if i>>j & 1:
      c+=int(a[j+1])
      l+=["+",a[j+1]]
    else:
      c-=int(a[j+1])
      l+=["-",a[j+1]]
  if c==7:
    for i in l:
      print(i,end="")
    print("=7")
    sys.exit()
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
ans=0
for i in range(0,len(a)):
  if i%2==0 and a[i]%2==1:
    ans+=1
print(ans)
# Judge status: Accepted
N, K = map(int, input().split())
lis_p = map(int, input().split())
def calc_exp(x):
    return (int(x) + 1)/2
lis_exp = list(map(calc_exp, lis_p))
dp= sum(lis_exp[0:K])
cumKsum = sum(lis_exp[0:K])
for i in range(1, N-K+1):
    cumKsum = cumKsum - lis_exp[i-1] + lis_exp[i+K-1]
    dp = max(cumKsum, dp)
print(dp)
# Judge status: Accepted
D = int(input())
C = list(map(int, input().split()))
S = [list(map(int, input().split())) for _ in range(D)]

tL = []
for i in range(D):
    tL.append(S[i].index(max(S[i])) + 1)

for t in tL:
    print(t)
# Judge status: Wrong Answer
x=int(input())
a=100
b=0
while 1:
    if a>=x:
        print(b)
        break
    b+=1
    a=a+int(a/100)
# Judge status: Wrong Answer
import sys
sys.setrecursionlimit(10 ** 7)
ans = []
def solve(pre, n, s):
    if len(s) == n:
        ans.append(s)
        return
    for i in range(pre+2):
        solve(i, n, s + chr(ord("a") + i))

def main():
    n = int(input())
    solve(0, n, "a")
    ans.sort()
    for s in ans:
        print(s)

if __name__ == "__main__":
    main()
# Judge status: Accepted
import math
A, B, H, M = map(int, input().split())

h = H % 12
m = M % 60

rh = (h/12+M/60*1/12)*2*math.pi
rm = (m/60)*2*math.pi
r = min(rh - rm, 2*math.pi - (rh - rm))

c = A**2 + B**2 - 2*A*B*math.cos(r)
print(math.sqrt(c))
# Judge status: Accepted
a,b=map(int,input().split())
if (a%3==0 or b%3==0 or (a+b)%3==0) and a+b>2:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
N = int(input())
NN = N
b = ''
i = 0
if N == 0:
  b = '0'
else:
  while (NN!=0):
    bi = abs(NN)%2
    b=str(bi)+b
    NN = (NN-bi*(-1)**i)//2
    i+=1
print(b)
# Judge status: Wrong Answer
n = int(input())

l = 2
a = [2]

for i in range(1, n+1):
    if i == 1:
        a.append(1)
    else:
        l = sum(a)
        a.pop(0)
        a.append(l)

print(l)
# Judge status: Wrong Answer
s = input()
l = ['MON', 'TUE', 'WED', 'THU', 'FRI', 'SAT', 'SUN']
for i in l:
    if i == s:
        print(l.index(i) + 1)
# Judge status: Wrong Answer
n,*L = map(int,open(0).read().split())
sum1 = sum(L)
L.sort()
if sum1%10 != 0:
    print(sum1)
    exit()
else:
    i = 0
    while sum1%10==0:
        sum1 -= L[i]
        if sum1 == 0:
            print(0)
            exit()
        i +=1
print(sum1)
# Judge status: Accepted
n, x = map(int, input().split())
a = list(map(int, input().split()))
cnt = 0
a.sort()
for i in a:
    if a.index(i) == n - 1:
        if i == x:
            cnt += 1
    elif i <= x:
        x -= i
        cnt += 1
    else:
        break
print(cnt)
# Judge status: Accepted
N, K = map(int, input().split(' '))
H_ls = list(map(int, input().split(' ')))
H_ls.sort(reverse=True)
print(sum(H_ls[K:]))
# Judge status: Accepted
N,M=map(int, input().split())

def cal(x):
    return x*(x-1)//2

print(cal(N)+cal(M))
# Judge status: Accepted
import sys
X, Y = map(int, input().split())

MOD = 1000000007
if (2*X-Y)%3!=0:
    print(0)
    sys.exit()

A = int((2*X-Y)/3)
B = int(X-2*A)

if A<0 or B<0:
    print(0)
    sys.exit()

ans = 1
inv = 1
for i in range(B):
    ans = ans * (A+B-i) %MOD
    inv = inv * (i+1) %MOD

ans = ans * pow(inv, MOD-2, MOD) %MOD
print(ans)
# Judge status: Wrong Answer
D = [int(_) for _ in input().split()]

def solve(D):
    N = D[0]
    M = D[1]
    K = D[2]
    
    for l in range(N):
        for k in range(M):
            if M * k + N *l - 2 * k * l == K:
                return "Yes"

    return "No"

print(solve(D))
# Judge status: Wrong Answer
n=int(input())
s=input()
t=input()
ans=0
for i in range(n):
  if s[i:] == t[:n-i]:
    ans = n-i
if ans == 0:
  print(2*n)
else:
  print(2*n-ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))

count = 0
odd = 0

for n in A:
    count += 1
    if (n % 2) == 0:
        count += 1
        if (n % 3) == 0 or (n % 5) == 0:
            odd += 1
        else:
            print("DENIED")
            exit()

if count == len(A):
    print("DENIED")
else:
    print("APPROVED")
# Judge status: Accepted
S = input()
print('Yes') if 'A' in S and 'B' in S else print('No')
# Judge status: Wrong Answer
#!/usr/bin/env python3 ## -*- python -*-
import sys

n = int(input())
x = []
for c in input().split():
  x.append(int(c))
print(x)
a = sys.maxsize
for i in range(min(x), max(x)):
    c = 0
    for j in x:
        c = c + (j-i) * (j-i)
    a = min([a, c])
print(a)
# Judge status: Wrong Answer
import math
count = 0
amari = 9
for i in range(5):
  n = int(input())
  if n%10 == 0:
    count += n
  else:
    count += math.ceil(n/10)*10
    amari = min(amari,n%10)
print(count + amari - 10)
# Judge status: Accepted
N=int(input())
A=list(map(int,input().split()))
L=[None]*N
for id,x in enumerate(A):
  L[x-1] = id+1
str_L=map(str,L)
print(' '.join(str_L))
# Judge status: Accepted
from collections import deque
N = int(input())
H = deque(map(int, input().split()))
ans = 0
n = 0
tmp = H.popleft()
while H:
  nxt = H.popleft()
  if tmp >= nxt:
    n += 1
    ans = max(ans, n)
  else:
    n = 0
  tmp = nxt
print(ans)
# Judge status: Accepted
N, M = map(int,input().split())
s = []
c = []
for i in range(M):
  S, C = map(int,input().split())
  s.append(S)
  c.append(C)


for i in range(10 ** (N + 1)):
  Str = str(i)
  
  if len(Str) == N and all([Str[s[j] - 1] == str(c[j]) for j in range(M)]):
      print(Str)
      exit()

print(-1)
# Judge status: Accepted
S = list(input())
ans =set(S)

a = len(S)
b = len(ans)

if a == b:
    print("yes")
else:
    print("no")
# Judge status: Wrong Answer
n,a,b = list(map(int,input().split()))

if (abs(a-b) % 2) == 0:
    ans = abs(a-b)//2
else:
    ans = min(n-min(a,b),max(a,b)-1)


print(ans)
# Judge status: Accepted
from collections import defaultdict
n = int(input())
lis = list(map(int, input().split()))

mod = 998244353

if lis[0] != 0:
    print(0)
    exit()

d = defaultdict(int)

for i in lis:
    d[i] += 1

if d[0] != 1:
    print(0)
    exit()

ans = 1
for i in range(1, max(lis)+1):
    if i not in d:
        print(0)
        exit()
    ans = ans * (d[i-1]**d[i]) % mod

print(ans)
# Judge status: Accepted
from collections import Counter
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
anas = [''.join(sorted(input())) for _ in range(n)]
c = Counter(anas)


cnt = 0
for v in c.values():
    if v < 2:
        continue
    else:
        cnt += cmb(v, 2)

print(cnt)
# Judge status: Accepted
c = input()
#l = input().split(" ")
#l = list(map(int,l))
a = [chr(ord("a")+i) for i in range(26)]

if c in a:
  print("a")
else:
  print("A")
# Judge status: Accepted
n=int(input())
k=[i*j for i in range(1,10) for j in range(1,10)]
if n in k:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
def main():
    n = int(input())
    if n >= 1000:
        print('ABD')
    else:
        print('ABC')


if __name__ == "__main__":
    main()
# Judge status: Accepted
n,m=map(int,input().split())
pref=[[] for _ in range(n)]
ans=[]
for i in range(m):
  p,y=map(int,input().split())
  pref[p-1].append((i,p,y))
for i in range(n):
  pref[i].sort(key=lambda x: x[2])
  for j,t in enumerate(pref[i]):
    k,q,z=t
    s='0'*(6-len(str(q)))+str(q)+'0'*(6-len(str(j+1)))+str(j+1)
    ans.append((k,s))
ans.sort(key=lambda x: x[0])
for g,h in ans:
  print(h)
# Judge status: Wrong Answer
from collections import Counter
n = int(input())
S = []

for i in range(n):
    s=input()
    S.append(s)
    if i==0:
        res=Counter(list(s))
    else:
        c=Counter(list(s))
        for key in res.keys():
            if key in c.keys():
                res[key] = min(res[key], c[key])
            else:
                res[key] = 0
print(res)
for key in sorted(res.keys()):
    if res[key]>0:
        print(key*res[key],end='')
print('')
# Judge status: Wrong Answer
a=int(input())
b=input()
c=int(a/2)
d=0
e=a-1
i=0
while True:
    if b[i]=='W':
        for j in range(0,e+1)[::-1]:
            if b[j]=='R':
                d=d+1
                e=j-1
                break
    i=i+1
    if i+1>=e: break
print(d)
# Judge status: Accepted
from collections import defaultdict
from collections import deque
from string import ascii_uppercase
import sys, bisect, math, heapq

stdin = sys.stdin
read_int = lambda : list(map(int,stdin.readline().split()))
read_str = lambda : stdin.readline().rstrip()

N, A, B = read_int()

def solve():
    ans = (N // (A + B)) * A
    r = (N % (A + B))
    ans += r if r < A else A
    return ans

if __name__ == "__main__":
    print(solve())
# Judge status: Accepted
a,b = map(int,input().split())

li = [2,3,4,5,6,7,8,9,10,11,12,13,1]

a1 = li.index(a)
b1 = li.index(b)

if a1 > b1:
    print('Alice')
elif a1 == b1:
    print('Draw')
else:
    print('Bob')
# Judge status: Wrong Answer
n = int(input())
from math import sqrt
root = int(sqrt(n))
print(root)

for i in range(root,n+1):
    if n%i == 0:
        ans = i+(n/i)-2
        break
print(int(ans))
# Judge status: Accepted
n = list(str(input()))
if "7" in n:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
A,B,C,D = map(int, input())
ans = list(str(A))
for b in [-B,B]:
    for c in [-C,C]:
        for d in [-D,D]:
            if sum([A,b,c,d]) == 7:
                ans += ["+" + str(x) if x>=0 else str(x) for x in [b,c,d]]
                break
        else:
            continue
        break
    else:
        continue
    break
for i in ans:
    print(i, end = "")
print("=7")
# Judge status: Wrong Answer
a=set([input() for _ in range(2)])
ans={'1','2','3'}
print(ans-a)
# Judge status: Accepted
import sys

read = sys.stdin.buffer.read

n,*x = list(map(int, read().split()))
x_sort = sorted(x)

mean_left = x_sort[n//2-1]
mean_right = x_sort[n//2]


for i in range(n):
  if x[i] <= mean_left:
    print(mean_right)
  elif x[i] >= mean_right:
    print(mean_left)
# Judge status: Accepted
N, M = map(int, input().split())
print("Yes" if N==M else "No")
# Judge status: Accepted
D, N = map(int, input().split())

if N == 100:
    N += 1
print(100**D * N)
# Judge status: Wrong Answer

n = int(raw_input())
c = 2 * (n / 11)
n%= 11
if n >=6:
	c+=2
elif n < 6:
	if n:
		c+=1
print c
# Judge status: Accepted
H,W=list(map(int,input().split()))
H=H-2
W=W-2

if H < 0:
    H=1
if W < 0:
    W=1

ans=H*W
print(ans)
# Judge status: Wrong Answer
import bisect
import collections
n=int(input())
l=sorted(list(map(int,input().split())))
ma=l[-1]
d=collections.Counter(l)
ans=0
for i in range(1,ma-2):
  for j in range(i+1,ma-1):
    c=i+j
    for k in range(j+1,c):
      ans+=d[i]*d[j]*d[k]
print(ans)
# Judge status: Accepted
n = int(input())
p = [0]*(n+1)
flag = 0
if n==1:
    print(1)
    exit()
for i in range(1,n+1):
    p[i] = i + p[i-1]
    if p[i] > n:
        flag = i
        break
r = p[flag] -n
for i in range(1,flag+1):
    if i!=r:
        print(i)
    else:
        continue
# Judge status: Wrong Answer
MOD = 10 ** 9
s = int(input())
x = MOD - (s % MOD)
y = (s + MOD - 1) // MOD
print(0, 0, MOD, 1, x, y)
# Judge status: Accepted
A = set()

for _ in range(int(input())):
    i = int(input())
    if i in A:
        A.remove(i)
    else:
        A.add(i)
        
print(len(A))
# Judge status: Accepted
import sys
input = sys.stdin.readline
N = int(input())
if N < 105 :
    print(0)
elif N >= 105 and N<135 :
    print(1)
elif N>= 135 and N<165 :
    print(2)
elif N>=165 and N<189 :
    print(3)
elif N>=189 and N<195 :
    print(4)
else :
    print(5)
# Judge status: Wrong Answer
def main():
    N = int(input())
    in_p_list = list(map(int, input().split()))
    p_list = [1+i-p for i,p in enumerate(in_p_list)]

    cnt = 1 if p_list[0] == 0 else 0
    for i in range(1,N):
        v = p_list[i]
        if p_list[i-1] == 0:
            continue
        if v != 0:
            continue
        cnt += 1
    print(cnt)


if __name__ == "__main__":
    main()
# Judge status: Accepted
a,b,c=map(int,input().split())
d=(c//a)*b
print(d)
# Judge status: Wrong Answer
n=input();s=input();print(s.count('I')-s.count('D')+1)
# Judge status: Wrong Answer
n =int(input())
a = int(input())
m  = n / 500
if n % 500 == 0:
    print("Yes")
elif m <= a:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
N = input()
A = input()

n = int(N)
a = int(A)


x = n % 500

if x > a:
  print("Yes")
elif x == a:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
a, b = map(int, input().split())
print(str(min(a, b))*max(a,b))
# Judge status: Accepted
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

n, k = na()
h = [ni() for i in range(n)]
h.sort()
ans = min([h[i + k - 1] - h[i] for i in range(n - k + 1)])
print(ans)
# Judge status: Wrong Answer
n=int(input())
c=input()
f=False
wb=wc=0
rb=rc=0
 
for i in range(n):
  if c[i]=="R":
    rc += 1
  else:
    wc += 1
 
for i in range(n):
  if c[i]=="W":
    f=True
  else:
    rc-=1
 
  if f:
    if c[i]=="R":
      rb+=1
      rc-=1
    else:
      wb+=1
      wc-=1
 
    if wb==rc:
      print(wb)
      exit()
 
print(rb)
# Judge status: Wrong Answer
try:
    n=list(map(int, input().strip().split()))
    lis1=[]
    for i in range(0,len(n)):
        for a in range(0,len(n)):
            z=(int(n[a])+int(n[i]))
            lis1.append(z)
    set1=set((lis1))
    lis1=list((set1))
    minscore='9999999999'
    for i in range(0,len(lis1)):
        if float(minscore)>float(lis1[i]):
            minscore=lis1[i]
    
    print(minscore)
    
except:
    print('')
# Judge status: Accepted
n,k=map(int,input().split())
import math
a=math.log(n,k)
b=math.ceil(a)
if a==b:
    print(b+1)
else:
    print(b)
# Judge status: Accepted
n=int(input())
sp=[]
for i in range(n):
    s,p=input().split()
    sp.append([s,int(p),i+1])
sp.sort(key=lambda sp:(sp[0],-sp[1]))
for i in sp:print(i[2])
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
common = int(sum(a) / n + 0.5)
cost = 0
for i in range(n):
  cost += (a[i] - common) ** 2
print(cost)
# Judge status: Accepted
import numpy as np
import sys
readline = sys.stdin.buffer.readline
#K,S=map(int, readline().split())
#S=list(readline())
S=input()

#print(S)
i=S.index('A')
#print(i)

S1 = S[::-1]

j=(S1.index('Z'))
j=len(S)-j
#print(S1)
#print(j)
#print(len(S)-j)
print(j-i)
# Judge status: Accepted
import sys
a,b,c=map(int,input().split())
i=1
l=[]
while True:
    aa=a*i%b
    if aa in l:
        break
    l.append(aa)
    i+=1
    if aa!=0 and c%aa==0:
        print('YES')
        sys.exit()
print('NO')
# Judge status: Accepted
S=input()

i=1
buf=S[0]
count=1
while i<=len(S)-1:
    if buf==S[i]:
        i=i+2
        if i<=len(S):
            count = count + 1
        buf=""
    else:
        count=count+1
        buf=S[i]
        i=i+1
print(count)
# Judge status: Wrong Answer
n = int(input())
t, a = map(int, input().split())
h = [int(i) for i in input().split()]

min = max(h)
ans = []

for i, j in enumerate(h):
    ans.append([abs(int(t - (j * 0.006)) - a),i+1])

print(sorted(ans)[0][1])
# Judge status: Wrong Answer
S = input()
T = input()
ans = len(S)
for i in range(len(T)):
    for j in range(i, len(S)):
        if T[i] == S[j]:
            c = 1
            for k in range(0, min(len(S)-j-1,len(T)-i-1)):
                if T[i+1+k] == S[j+1+k]:
                    c += 1
            tmp = len(T) - c
            ans = min(ans, tmp)
print(ans)
# Judge status: Accepted
n = int(input())
li_a = list(map(int, input().split()))
answer = 0
su = sum(li_a)
mo = (10 ** 9) + 7
for idx, a in enumerate(li_a):
    su = su - a
    answer += (a * su)
print(answer % mo)
# Judge status: Accepted
n = int(input())
import math 
result = []
for a in range(1, int(math.sqrt(n) // 1) + 1):
    if n % a == 0:
        b = n // a
        result.append([a, b])
    
best_count = float("inf")
for a_b in result:
    score = a_b[0] + a_b[1] - 2
    if best_count > score:
        best_count = score

print(best_count)
# Judge status: Accepted
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())

if (e - a) > k:
    print(':(')
else:
    print('Yay!')
# Judge status: Wrong Answer
a, b, c, d, e = map(int, input().split())
ln = [a,b,c,d,e]
for i,j in enumerate(ln):
  if j == 0:
    print(i)
    break
# Judge status: Wrong Answer
import collections
n=int(input())
a=list(map(int,input().split()))
b=list(collections.Counter(a).values())
for i in b:
  print(i)