Buggy python submission (verdict: Runtime Error):
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    #h.append(int(input()))
    h[i]=int(input())
h.sort()

q=-1
for i in range(len(h)):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
    if q==0:
        break
print(q)

Fixed submission:
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    h[i]=int(input())
h.sort()
q=-1
for i in range(0,len(h)-n[1]+1):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
print(q)

Buggy python submission (verdict: Runtime Error):
=input().split()
n=[int(i) for i in n]
h=[n[1]]
for i in range(n[0]):
    h[i]=int(input())
h.sort()

q=-1
for i in range(len(h)):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
    if q==0:
        break
print(q)

Fixed submission:
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    h[i]=int(input())
h.sort()
q=-1
for i in range(0,len(h)-n[1]+1):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
print(q)

Buggy python submission (verdict: Runtime Error):
n=input().split()
n=[int(i) for i in n]
h=[]
for i in range(n[0]):
    h.append(int(input()))
h.sort()

q=-1
for i in range(len(h)):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
    if q==0:
        break
print(q)

Fixed submission:
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    h[i]=int(input())
h.sort()
q=-1
for i in range(0,len(h)-n[1]+1):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
print(q)

Buggy python submission (verdict: Runtime Error):
n=input().split()
n=[int(i) for i in n]
h=[]
for i in range(n[0]):
    h.append(int(input()))
h.sort()

q=-1
for i in range(len(h)):
    if q==-1 or q>h[i+n[1]-1]-h[i]:
        q=h[i+n[1]-1]-h[i]
    if q==0:
        break
print(q)

Fixed submission:
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    h[i]=int(input())
h.sort()
q=-1
for i in range(0,len(h)-n[1]+1):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
print(q)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools,math
n=input().split()
n=[int(i) for i in n]
h=[]
for i in range(n[0]):
    h.append(int(input()))
q=-1
 
for j in itertools.combinations(h,n[1]):
    if q>max(j)-min(j) or q==-1:
        q=max(j)-min(j)
    if q==0:
        break
 
print(q)

Fixed submission:
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    h[i]=int(input())
h.sort()
q=-1
for i in range(0,len(h)-n[1]+1):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
print(q)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools,math
n=input().split()
n=[int(i) for i in n]
h=[]
for i in range(n[0]):
    h.append(int(input()))
q=-1

for j in itertools.combinations(h,n[1]):
    if q>max(j)-min(j) or q==-1:
        q=max(j)-min(j)

print(q)

Fixed submission:
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    h[i]=int(input())
h.sort()
q=-1
for i in range(0,len(h)-n[1]+1):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
print(q)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools,math
n=input().split()
n=[int(i) for i in n]
h=[]
for i in range(n[0]):
    h.append(int(input()))
q=[]

for j in itertools.combinations(h,n[1]):
    q.append(max(j)-min(j))

print(min(q))

Fixed submission:
n=input().split()
n=[int(i) for i in n]
h=[0]*n[0]
for i in range(n[0]):
    h[i]=int(input())
h.sort()
q=-1
for i in range(0,len(h)-n[1]+1):
    a=h[i+n[1]-1]-h[i]
    if q==-1 or q>a:
        q=a
print(q)