peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
import numpy as np
a, b, x = map(float, input().split())
print(np.degrees(np.arctan((2.0*(np.power(a, 2.0)*b-x))*np.power(a, -3.0))))
# Judge status: Accepted
d, t, s = map(int, input().split())

if d <= s*t:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n, p = map(int, input().split())
a = list(map(int, input().split()))

is_odd = False
for ai in a:
    if ai % 2 == 1:
        is_odd = True
        break

if is_odd:
    ans = 2 ** (n - 1)
else:
    if p == 0:
        ans = 2 ** n
    else:
        ans = 0
print(ans)
# Judge status: Accepted
N = int(input())
Sorted = [list(map(int, input().split())) for _ in range(N)]
Sorted.insert(0, [0, 0, 0])

for i in range(N):
  d = abs(Sorted[i+1][1] - Sorted[i][1]) + abs(Sorted[i+1][2] - Sorted[i][2])
  t = Sorted[i+1][0] - Sorted[i][0]
  if  d > t or d % 2 != t % 2:
    print("No")
    break
else:
  print("Yes")
# Judge status: Accepted
import os, sys, re, math

N = int(input())
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]
C = [int(n) for n in input().split()]

s = 0
for i in range(N):
    s += B[A[i] - 1]
    if i > 0 and A[i - 1] == A[i] - 1:
        s += C[A[i - 1] - 1]

print(s)
# Judge status: Accepted
n = int(input())
B = list(map(int, input().split()))
ans = B[0]+B[n-2]

for i in range(n-2):
    ans += min(B[i],B[i+1])
    
print(ans)
# Judge status: Accepted
a, b, n = map(int, input().split())
if n < b:
    x = n
    print(int(a * x / b) -  a * int(x / b))
else:
    x = b - 1
    print(int(a * x / b) -  a * int(x / b))
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=sorted(map(int,input().split()))
l=list()
for i in range(m):
    l.append(list(map(int,input().split())))
l.sort(key=lambda x:-x[1])
i=0
for b,c in l:
    for j in range(b):
        if i+j<n and a[i+j]<c:
            a[i+j]=c
        else:
            exit()
    i+=b
print(sum(a))
# Judge status: Wrong Answer
L = list(input())
i = 0
cnt = 0
for _ in range(len(L)):
    if ''.join(L[i:i+2]) == '01' or ''.join(L[i:i+2]) == '10':
        for j in range(i,i+2):
            L.pop(i)
            cnt += 1
        i = 0
    else:
        i += 1
print(cnt)
# Judge status: Accepted
import math
N = int(input())

ans = [0 for _ in range(10050)]


for x in range(1, 100):
    for y in range(1, 100):
        for z in range(1, 100):
            a = x**2+y**2+z**2+x*y+y*z+z*x
            if  a < 10050:
                ans[a] +=1

for i in range(N):
    print(ans[i+1])
# Judge status: Accepted
n = int(input())
for i in range(1, 11):
    if 1000*i-n>=0:
        print(1000*i-n)
        break
# Judge status: Accepted
n, p, *a = map(int, open(0).read().split())
odd = [i for i in a if i%2 == 1]
if len(odd) == 0:
    if p == 0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n -1))
# Judge status: Accepted
N=int(input())
for A in range(-118,120):
  for B in range(-119,119):
    if A**5-B**5==N:
      print(A,B)
      exit()
# Judge status: Accepted
S = input()
print('YES' if max(S.count('a'),S.count('b'),S.count('c'))-min(S.count('a'),S.count('b'),S.count('c')) < 2 else 'NO')
# Judge status: Accepted
n = int(input())
a = list(map(int,input().split()))
a.sort(reverse=True)
s = set()
s.add(0)
s.add(-1)
for i in range(n-1):
  if a[i] == a[i+1]:
    s.add(a[i])
m = max(s)
s.discard(m)
k = max(s)
if a.count(m) > 3:
  print(m**2)
else:
  print(m*k)
# Judge status: Accepted
import math
n, d = map(int, input().split())
print(math.ceil(n/(d*2+1)))
# Judge status: Wrong Answer
N = int(input())

ACcount = 0 
WAcount = 0
TLEcount = 0
REcount = 0
for i in range(N):
	S=input()

	if S == "AC":
		ACcount = ACcount + 1
	elif S == "WA":
		WAcount = WAcount + 1
	elif S == "TLE":
		TLEcount = TLEcount + 1
	elif S == "RE":
		REcount = REcount + 1

print("AC x　" + str(ACcount))
print("WA x　" + str(WAcount))
print("TLE x　" + str(TLEcount))
print("RE x　" + str(REcount))
# Judge status: Accepted
#Problem B

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

for i in range(K):

    if A >= B:
        B *= 2
    elif B > A:
        if B >= C:
            C *= 2
        elif B < C:
            pass
    else:
        pass

if A < B and B < C:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
x = int(input())
print(x*1500 - (x//15)*200)
# Judge status: Accepted
import sys
import math
N, D = map(int, input().split())
print(math.ceil(N / (1 + 2 * D)))
# Judge status: Wrong Answer
s = int(input())

print(0,0,10**9,1,s%10**9,s//10**9)
# Judge status: Accepted
# agc006_a.py
N = int(input())
S = list(input())
T = list(input())
ans = N*2
for i in range(N):
    # print(i,S[N-1-i:] , T[:i+1])
    if S[N-1-i:] == T[:i+1]:
        # print("find")
        ans = N*2-(i+1)
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
print("Yes" if (a<c and c<b) or (b<c and c<a) else "No")
# Judge status: Accepted
a,b,c,d=map(int,input().split())
if ((abs(b-a)<=d)&(abs(c-b)<=d))|(abs(c-a)<=d):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n = int(input())
A = list(int(x) for x in input().split())
A.sort(reverse=True)
if n == 2:
    print(A[0])
    exit()

ans = A[0]
for i in range(2, n):
    ans += A[i//2]
print(ans)
# Judge status: Wrong Answer
inp=input().split()
N,A,B=[int(n) for n in inp]
S=input()

total=0
total2=0
for i,s in enumerate(S):
    if s=='a':
        if total<A+B:
            print('Yes')
        else:
            print('No')
        total +=1
    elif s=='b':
        if total<A+B and total2<=B:
            print('Yes')
            total2+=1
        else:
            print('No')
        total +=1
    else:
        print('No')
# Judge status: Wrong Answer
n=int(input())
a=[]
rn=0
cnt=0
for i in range(n):
    b,c=map(int,input().split())
    a.append([b,c])
a=a[::-1]
print(a)   
for i in range(n):
    b,c=a[i]
    b+=cnt
    cnt+=(c-b%c)%c
print(cnt)
# Judge status: Accepted
a,b,c = [int(x) for x in input().split()]

if c - a - b < 0:
    print("No")
elif 4 * a * b < (c - a - b) ** 2:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
n=int(input())
ans=(int(n**0.5))**2
print(ans)
# Judge status: Wrong Answer
n, k = map(int, input().split())
i = 0
d = {}
for _ in range(n):
    a,b = map(int, input().split())
    if a in d:
        d[a] += b
    else:
        d[a] = b

key_l = list(d.keys())
key_l.sort()

ans = d[key_l[-1]]

for key in key_l:
    if i<k:
        i += d[key]
    else:
        ans = key
        break
print(ans)
# Judge status: Accepted
A = [list(map(int, input().split())) for i in range(3)]
N = int(input())
m = [[0]*3 for i in range(3)]
ans,l,r = 0,0,0
for _ in range(N):
  b = int(input())
  for i in range(3):
    if b in A[i]:
      m[i][A[i].index(b)]=1
                
for i in range(3):
  t = sum(m[i])
  l += m[i][i]
  y = 0
  for j in range(3):
    y += m[j][i]
    if i+j == 2:
      r += m[i][j]
  if t==3 or y==3 or r==3 or l==3:
    ans=1

print('Yes' if ans else 'No')
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
s=[0]*(N+1)
for i in range(N): s[i + 1]=s[i]+A[i]
C=[0]*(N);C[0]=abs(A[0]-(s[N]-s[1]));x=10**9;p=0
for i in range(1,N):
  if N-i==1:
    break
  else:
    C[i]=abs(C[i-1]+A[i]-(s[N]-s[i]))
    if x>C[i]:
      x=C[i]
      p=i
print(abs(C[p-1]+A[p]-(s[N]-s[p])))
# Judge status: Accepted
n = int(input())
s = input()
t = input()

lt = min(len(s), len(t))
i = -1
overlap = 0
for i in range(lt):
    if s[-(i + 1):] == t[:i + 1]:
        overlap = i + 1
        if lt >= 2 and s[-(i + 2):] != t[:i + 2]:
            break
    
ans = max(n, len(s) + len(t) - overlap)
print(ans)
# Judge status: Accepted
# -*- coding: utf-8 -*-
n, l = map(int,input().split())
s = []
for i in range(n):
    s.append(str(input()))

s.sort()
ans = ""
for i in range(n):
    ans += s[i]
print(ans)
# Judge status: Wrong Answer
# 点(x, y)から長方形の中心を通る直線を引くと面積を半分にすることができ、分割された小さい方の面積が最大となる
# 点(x, y)が長方形の中心と一致する場合、直線は複数存在する

w, h, x, y = map(int, input().split())

s = w * h
s_min = s / 2

# 中心
a = w / 2
b = w / 2

divide = 0

if x == a and y == b:
    divide = 1
    print(s_min, divide)
else:
    print(s_min, divide)
# Judge status: Accepted
a, b = map(int, input().split())
if a == b:
    print('Draw')
elif a == 1:
    print('Alice')
elif b == 1:
    print('Bob')
elif a > b:
    print('Alice')
else:
    print('Bob')
# Judge status: Accepted
x,y=map(int,input().split())

ans=10**12
if x<=y:
  ans=min(ans,y-x)
if -x<=y:
  ans=min(ans,y+x+1)
if x<=-y:
  ans=min(ans,-y-x+1)
if -x<=-y:
  ans=min(ans,-y+x+2)

print(ans)
# Judge status: Wrong Answer
K=int(input())
S=input()
s=list(S)

if len(s) < K:
    print(S)
else:
    print(s[0:(K-1):1],"...")
# 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]<P[i+1] or P[i-1]>P[i]>P[i+1]:
        cnt += 1
print(cnt)
# Judge status: Accepted
x, k, d = map(int, input().split())

ans = 0
if k * d < abs(x):
    if x >= 0:
        ans = x - k*d
    else:
        ans = x + k*d
    print(abs(ans))
    exit()
    
xd = x // (2*d)
if k % 2:
    tmp = x - 2*d*xd
    l = [abs(tmp-d), abs(tmp+d), abs(tmp+3*d)]
    ans = min(l)
else:
    tmp = x - 2*d*xd
    l = [abs(tmp-2*d), abs(tmp), abs(tmp+2*d)]
    ans = min(l)
print(ans)
# Judge status: Wrong Answer
n,x=map(int,input().split())
l=[int(x) for x in input().split()]

ans=0
s=0

for ll in l:
    if s <= x:
        ans+=1
    s+=ll

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

s = list(s)
t = list(t)

s.sort()
t.sort(reverse=True)

s = ''.join(s)
t = ''.join(t)

if s < t:
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
X,K,D = map(int, input().split())
for i in range(K):
    if X>=0:
        X -= D
    else:
        X += D
    if abs(X)<=D/2:
        break
x = abs(X)
print(x)
# Judge status: Wrong Answer
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
cnt=0
for i in range(N):
    cnt+=min(A[i]+A[i+1],B[i])
print(cnt)
# Judge status: Accepted
N,M = map(int,input().split())
if N == 2 or M == 2:
    Ans = 0
elif N == 1 or M == 1:
    if not N == M:
        Ans = max(N,M)-2
    else:
        Ans = 1
else:
    Ans = (N-2)*(M-2)
print(Ans)
# Judge status: Accepted
N=int(input())
T,A=map(int,input().split())
S=list(map(int,input().split()))
mini=16777216
mininum=0
for i in range(N):
    if abs(T-0.006*S[i]-A)<mini:
        mini=abs(T-0.006*S[i]-A)
        mininum=i+1

print(mininum)
# Judge status: Accepted
from fractions import gcd

n,x=map(int,input().split())
l=list(map(int,input().split()))+[x]
l.sort()

ans=l[1]-l[0]
for i in range(2,n+1):
  sa=l[i]-l[i-1]
  ans=gcd(ans,sa)

print(ans)
# Judge status: Wrong Answer
h=int(input())
w=int(input())
n=int(input())
print((n-1)//max(h,w)+2)
# Judge status: Wrong Answer
# coding: utf-8
A, B, M = map(int, input().split())
# print("A:", A, "B:", B, "M:", M)
a = list(map(int, input().split()))
# print("a:", a)
b = list(map(int, input().split()))
# print("b:", b)
z = [list(map(int, input().split())) for _ in range(M)]
num1 = a[0] + b[0]
for i in range(M):
    # print("z[i]:", z[i])
    x, y, c = z[i]
    # print("x:", x, "y:", y, "c:", c)
    num = a[x - 1] + b[y - 1] - c
    # print(num)
    if num < num1:
        num1 = num
print(num1)
# Judge status: Accepted
h=int(input())

n=0
for i in range(10**12):
  if h<2**i:
    n=i-1
    break
ans=1
for i in range(1,n+1):
  ans+=2**i
print(ans)
# Judge status: Accepted
n=int(input())
a=list(map(int,input().split()))
f=0
t=0
z=0
for i in range(n):
    if a[i]%4==0:
        f+=1
    elif a[i]%2==0:
        t+=1
    else:
        z+=1
flg=False
if t==0 and z-1<=f:
    flg=True
if z<=f and t>0:
    flg=True
if flg:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
num=input()
num=num.split()

print(num[2]+num[0]+num[1])
# Judge status: Accepted
import sys
n = input()
for i in range(2):
    if n[i]==n[i+1] and n[i]==n[i+2]:
        print("Yes")
        sys.exit()
print("No")
# Judge status: Wrong Answer
def main():
    a, b, k = list(map(int, input().split()))

    a = a - k
    if a < 0:
        k = a * -1
        a = 0
    else:
        k = k - a

    b = b - k if b > 0 else 0

    print(a, b)

if __name__ == '__main__':
    main()
# Judge status: Accepted
str = input()
if '7' in str:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
# 2020/01/23
# AtCoder Beginner Contest 144 - C

# Input
n = int(input())

nsq = int(n ** (1/2)) + 1

x = nsq
y = nsq

while x >= 1:
    wkn = x * y
    if n == wkn:
        ans = (x - 1) + (y - 1)
        break
    elif n > wkn:
        y = y + 1
    else:
        x = x - 1

# Output
print(ans)
# Judge status: Wrong Answer
D = int(input())
print('Chrismas' + " Eve"*(25-D))
# Judge status: Accepted
from collections import Counter
n=int(input())
a=list(map(int,input().split()))
cnt=Counter(a)
ans=sum(a)
q=int(input())
for i in range(q):
    b,c=map(int,input().split())
    ans+=(c-b)*cnt[b]
    cnt[c]+=cnt[b]
    cnt[b]=0
    print(ans)
# Judge status: Accepted

x = int(input())
for i in range(-1000,1000):
    for j in range(-1000,1000):
        if i**5 - j**5 == x:
            print(i,j)
            quit()
# Judge status: Accepted
S = list(input())

res = list(set(S))
if(len(res) == 2):
    print('Yes')
else:
    print('No')
# Judge status: Wrong Answer
N = int(input())
for i in range(0,112):
  N = N+i
  n = list(str(N))
  if n[0] == n[1] == n[2]:
    print(N)
# Judge status: Wrong Answer
(N,K) = map(int,input().split())
S = input()
dan = 1

for i in range(N-1):
    if S[i] != S[i+1]:
        dan += 1

if 2*K >= (dan-1):
    print(N)
else:
    print(N-dan+2*K)
# Judge status: Accepted
N=input()
if len(N)==len(set(N)):
    print("yes")
else:
    print("no")
# Judge status: Wrong Answer
import sys
def input(): return sys.stdin.readline().rstrip()

def main():
    S = list(input())

    isWA = False
    if S[0] != 'A':
        isWA = True

    if S[2:-2].count('C') != 1:
        isWA = True

    for s in S:
        if s == 'A' or s == 'C':
            continue
        if s.isupper():
            isWA = True

    if isWA:
        print('WA')
    else:
        print('AC')
    

if __name__ == '__main__':
    main()
# Judge status: Accepted
a,b,c,k = map(int,input().split())
if k%2 == 0:
    print(a-b)
else:
    print(b-a)
# Judge status: Wrong Answer
N = str(input())

if "9" == N[0]:
    if "9" == N[1]:
        print( "YES" )
else:
    print( "NO" )
# Judge status: Wrong Answer
n = int(input())
s = input()

count = 0
for i in range(n-2):
	lis = []
	lis.append(s[i])
	for j in range(i+1,n-1):
		if not s[j] in lis :
			lis.append(s[j])
			for k in range(j+1,n):
				if not s[k] in lis :
					if j-i != k-j:
						count += 1

print(count)
# Judge status: Accepted
t=input()
qn=t.count("?")
print(t.replace("?", "D"))
# Judge status: Accepted
n = int(input())

for a in range(1,10):
  for b in range(1,10):
    if a*b == n:
      print('Yes')
      exit(0)

print('No')
# Judge status: Wrong Answer
num = input
if num == 0:
  print(1)
else:
  print(0)
# Judge status: Accepted
d,n = map(int, input().split())
print(100**d * (n+(n==100)) if d > 0 else (n + (n==100)))
# Judge status: Accepted
X = int(input())

happy = 0
q, m = divmod(X, 500)
happy += q*1000

q, m = divmod(m, 5)
happy += q*5

print(happy)
# Judge status: Accepted
string = input()
ans = 0
score = 0
ok = set('ACGT')
for c in string:
    if c in ok:
        score += 1
    else:
        ans = max(ans, score)
        score = 0
ans = max(ans,score)
print(ans)
# Judge status: Accepted
n, m = map(int, input().split())
print(n*(n-1)//2+m*(m-1)//2)
# Judge status: Wrong Answer
import sys
readline = sys.stdin.readline
from collections import Counter

def main():
    N = int(readline())
    A = [int(readline()) for _ in range(N)]
    c = Counter(A)
    ans = 0
    for _, v in zip(c.keys(), c.values()):
        if v % 2 == 1:
            ans += v
    
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
a1, a2, a3 = map(int, input().split())
if 1 <= a1 <= 13 and 1 <= a2 <= 13 and 1 <= a3 <= 13:
    if a1 + a2 + a3 == 22:
        print('bust')
    else:
        print('win')
# Judge status: Wrong Answer
N = int(input()) # sを取得し、strに値を入れる
B = list(map(int, input().split()))
sum = B[0]
for i in range(0, N-1):
	sum += min(B[i],B[i-1])
sum += B[N-2]
print(sum)
# Judge status: Wrong Answer
n, m = map(int, input().split())
resultList = [0 for i in range(n)]
#print(resultList)
ansAC = 0
ansWA = 0
for i in range(m) :
    result = input().split()
    prob = int(result[0]) - 1
    if result[1] == 'AC' and resultList[prob] == 0 :
        resultList[prob] = 1
        ansAC += 1
    if result[1] == 'WA' and resultList[prob] == 0 :
        ansWA += 1

print(ansAC, ansWA)
# Judge status: Accepted
import sys


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())

n = inint()

if int(-(-n//1.08) * 1.08) != n:
    print(":(")
else:
    print(int(-(-n//1.08)))
# Judge status: Accepted
t = input()

n = t.count('N')
s = t.count('S')
w = t.count('W')
e = t.count('E')

if ((n == 0 and s == 0) or (n > 0 and s > 0)) and\
    ((w == 0 and e == 0) or (w > 0 and e > 0)):
    print("Yes")
else:
    print("No")
# Judge status: Accepted
a,b,m = map(int,input().split())

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

mi = min(a) + min(b)

for i in range(m):
    x,y,c = map(int,input().split())
    v = a[x-1] + b[y-1] - c
    mi = min(mi,v)
print(mi)
# Judge status: Accepted
s = input()
T = input()

slen = len(s)
Tlen = len(T)
ans = "UNRESTORABLE"
if slen >= Tlen:
    for i in range(slen - Tlen + 1)[::-1]:
        for j in range(Tlen):
            if not s[i+j] in ("?", T[j]):
                break
        else:
            ans = s
            ans = ans[:i] + T + ans[i+Tlen:]
            ans = ans.replace("?", "a")
            break

print(ans)
# Judge status: Accepted
a,b=map(int, input().split())
if a%3==0 or b%3==0 or (a+b)%3==0:
    print("Possible")
else:
    print("Impossible")
# Judge status: Accepted
import sys
import os

def file_input():
    f = open('CODE_FESTIVAL_2017Final/input.txt', 'r')
    sys.stdin = f

def main():
    #file_input()
    S=input()

    a=b=c=0

    for s in S:
        if s=='a':
            a+=1
        elif s=='b':
            b+=1
        else:
            c+=1

    if max(a,b,c)-min(a,b,c)<=1:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()
# Judge status: Accepted
from fractions import gcd
N = int(input())
T = [int(input()) for _ in range(N)]
ans = T[0]
for i in range(N):
    ans = (ans * T[i]) // gcd(ans, T[i])
print(ans)
# Judge status: Accepted
a,b,c=map(int,input().split())
print(c if a*c<=b else b//a)
# Judge status: Accepted
N = int(input())
s = [input() for _ in range(N)]
M = int(input())
t = [input() for _ in range(M)]
ans = 0
for i in set(s):
        ans = max(s.count(i) - t.count(i),ans)
print(ans)
# Judge status: Wrong Answer
N = int(input())
A = list(map(int,input().split()))
A.sort()
ans = []
def gcd(a,b):
    if b%a == 0:
        return(a)
    else:
        return(gcd(b%a,b))
for i in range(len(A)-1):
    ans.append(gcd(A[i],A[i+1]))
    A[i+1]=ans[i]
ans.append(gcd(A[1],A[-1]))
print(min(ans))
# Judge status: Accepted
import collections

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

c = collections.Counter(a)

itms=c.items()
cnt=0
for key,value in itms:
    if key<value:
        cnt+=value-key
    elif key==value:
        continue
    else:
        cnt+=value

print(cnt)
# Judge status: Wrong Answer
def nb(n,a,b,ho):
  #print(n,a,b,ho)
  if(b-a<=1):
    return min(abs(hoge[n]-2*hoge[a]),abs(hoge[n]-2*hoge[b]))
  c=(a+b)//2
  if(hoge[b]-2*hoge[c]>=0):
    return nb(n,c,b,ho)
  else:
    return nb(n,a,c,ho)


n=int(input())
moge=list(map(int,input().split()))


hoge=[0]*n
hoge[0]=moge[0]
for i in range(1,n):
  hoge[i]=hoge[i-1]+moge[i]

print(nb(n-1,0,n-1,hoge))
# Judge status: Wrong Answer
a, b, k = map(int, input().split())
print(max(0, a-k), b+min(0, a-k))
# Judge status: Accepted
import sys
input = lambda: sys.stdin.readline().rstrip()

N, K = map(int, input().split())

h = [int(input()) for _ in range(N)]

h.sort()

ans = float("inf")

for i in range(len(h)-(K-1)):
    ans = min(ans, h[i+K-1] - h[i])

print(ans)
# Judge status: Accepted
n = int(input())
if n == 2:
  a, b = map(str,input().split())
  print(b + " " + a)
else:
  L = list(map(int, input().split()))
  M = sorted(L)
  c = (n + 1) // 2 - 1
  a = M[c + 1]
  b = M[c]
  for l in L:
    if l> b:
      print(b)
    else:
      print(a)
# Judge status: Accepted
N, W = map(int, input().split())

dp = [0] + [-1] * W
for i in range(1, N + 1):
    w, v = map(int, input().split())
    for sum_w in range(W - w, -1, -1):
        if dp[sum_w] >= 0:
            dp[sum_w + w] = max(dp[sum_w + w], dp[sum_w] + v)
    # print(dp)
print(max(dp))
# Judge status: Accepted
N, Y = [int(str) for str in input().strip().split()]
Y //= 1000

for i in range(N + 1):
    for j in range(N - i + 1):
        k = N - i - j
        if 10 * i + 5 * j + k == Y:
            print(i, j, k)
            exit()

print(-1, -1, -1)
# Judge status: Accepted
N,K=map(int,input().split())
A=list(map(int,input().split()))
def f(L):
    res=0
    for x in A:
        res+=(x-1)//L
    return res
l=0
r=max(A)
while r-l>1:
    M=(r+l)//2
    if f(M)>K:
        l=M
    else:
        r=M
print(r)
# Judge status: Wrong Answer
n = int(input())

a = list(map(int, input().split()))
q = int(input())
s = []
S = sum(a)
def find(b, a): #配列aからbを探し出す　
  counter = 0
  for i in range(len(a)):
    if a[i] == b:
      counter += 1
  return counter 
for i in range(q):
  b, c = map(int,input().split())
  count = find(b,a)
  S += count * (c - b)
  print(S)
# Judge status: Accepted
import math
n,k = map(int,input().split())
sumlist = []
for i in range(1,n+1):
  point = i
  if point <= k-1:
    s = math.log(k/i,2)
    if s == int(s):
      sumlist.append((1/2)**(int(s)))
    else:
      sumlist.append((1/2)**(int(s)+1))
  else:sumlist.append(1)
print(round(sum(sumlist)/n,10)-10**(-10))
# Judge status: Accepted
N = int(input())
n = len(str(N))
NS = str(N)
ans0 = 0
for i in NS:
    ans0 += int(i)
ans1 = int(NS[0])-1 + 9 * (n-1)
ans2 = 9 * (n-1)

print(max(ans0, ans1, ans2))
# Judge status: Accepted
s = input()

year = int(s[:4])
mo = int(s[5:7])

if year < 2019:
  ans = "Heisei"
elif year == 2019 and mo<= 4:
  ans ='Heisei'
else:
  ans = 'TBD'
print(ans)
# Judge status: Accepted
k=int(input())
a,b=map(int,input().split())
for i in range(a,b+1):
  if i%k==0:
    print("OK")
    exit()
print("NG")
# Judge status: Accepted
n = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
ans = sum(A[::2]) - sum(A[1::2])
print(ans)
# Judge status: Wrong Answer
from itertools import product

s = str(input())
a = list(s)

for i in product([0,1],repeat=3):# 01 に関する直積
    for j,k in enumerate(i): #jが添え字 kがbit
        x = ["+","+","+"]
        #print(i,j,k)
        if k == 1:
            x[j] == "-"
    if eval(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]) == 7:
        print(a[0]+x[0]+a[1]+x[1]+a[2]+x[2]+a[3]+"=7")
        break
# Judge status: Wrong Answer
D=int(input())
c = list(map(int,input().split()))
s = [list(map(int,input().split())) for _ in range(D)]
last_day = [0]*26
score = 0

def calc_sum(day,t,sum):
  sum += s[day-1][t-1]
  for j in range(len(c)):
    if(j!=day-1):
      sum -= c[j]*(day-last_day[j])
  return sum

for i in range(D):
  t = 1
  max = -1000000
  for j in range(26):
    if(max < calc_sum(i+1,j,score)):
      max = calc_sum(i+1,j,score)
      t = j
  last_day[t-1]=i
  score = max
  print(t)
# Judge status: Accepted
s = input().rstrip()

ans = 10**3

for i in range(len(s)-2):
    x = int(s[i:i+3])
    ans = min(ans, abs(x-753))

print(ans)
# Judge status: Accepted
n,k =map(int,input().split())
digitlist = []

while (n/k != 0):
	tmp = n%k
	digitlist.insert(0,(tmp))
	n = n//k

print(len(digitlist))
# Judge status: Wrong Answer
icase=0
if icase==0:
    import sys
    a,b=map(int,input().split())
    for i in range(1,999):
        isum=i*(i+1)//2
        for j in range(i,1000):
            if j*(j+1)//2-isum==b-a and 1<=j*(j+1)//2-b:
                print(j*(j+1)//2-b)
                sys.exit()