TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N,K=map(int,input().split())
H=[int(input()) for _ in range(N)]
H.sort(reverse=True)
ans=10**6

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

print(ans)    

N,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
ans=10**6

for i in range(N-K):
    ans=min(ans,H[i]-H[i+K])

print(ans)    

N,K=map(int,input().split())
H=[int(input()) for _ in range(N)]
H.sort()
ans=10**6

for i in range(N-K):
    ans=min(ans,H[i]-H[i+K])

print(ans)    

N,K=map(int,input().split())
H=[int(input()) for _ in range(N)]
H.sort(reverse=True)
ans=10**9

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

print(ans)    

Verdicts: Wrong Answer

Runtime Error

Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])

m = float('inf')

print(h)
for i in range(N-K+1):
    m = min(m, h[i+K-1] - h[i])
    print(h[i+K-1], h[i])

print(m)

N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])

m = float('inf')

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

print(m)

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k=map(int,input().split())
a=[]
for _ in range(n):
  a+=[int(input())]
a.sort()
s=10**9
for i in range(n-k):
  s=min(s,a[i]-a[i+k])
print(s)

n,k=map(int,input().split())
a=[]
for _ in range(n):
  a+=[int(input())]
a.sort()
s=10**9
m=0
for i in range(n):
  if i>=k:
    m+=a[i]-a[i-k]
    s=min(s,m)
  else:
    m+=a[i]
print(s)

n,k=map(int,input().split())
a=[]
for _ in range(n):
  a+=[int(input())]
a.sort()
s=10**9
for i in range(n-k):
  s=min(s,a[i+k]-a[i])
print(s)

n,k=map(int,input().split())
a=[]
for _ in range(n):
  a+=[int(input())]
a.sort()
s=10**9
for i in range(n-k+1):
  s=min(s,a[i+k-1]-a[i])
print(s)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
#coding:utf-8
n,k=int(input().split())
h=[int(input()) for i in range(n)]
h.sort()
print(min(h[i+k-1]-h[i] for i in range(n-k+1)))

#coding:utf-8
n,k=map(int, input().split())
h=[int(input()) for i in range(n)]
h.sort()
print(min(h[i+k-1] - h[i] for i in range(n-k+1)))

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
import scipy as sp

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

tree = sp.array([], dtype = "int")
for i in range(N):
    tree = sp.append(tree, int(input()))

#tree.sort()

print(int(min(tree[K-1:]-tree[:N-K+1])))


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

tree = [int(input()) for i in range(N)]

tree.sort()

print(min(tree[i+K-1] - tree[i] for i in range(N-K+1)))
    

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N,K = map(int,input().split())
List = []
for i in range(N):
  tmp = int(input())
  List.append(tmp)
List = sorted(List)[::-1]
print(str(List[K-1] - List[0]))

N,K = map(int,input().split())
h = []
ans = 10**10
for i in range(N):
    tmp = int(input())
    h.append(tmp)
h = sorted(h)[::-1]
for i in range(N-K):
    ans = min(h[i]-h[i+K-1],ans)
print(str(ans))

N,K = map(int,input().split())
h = [0]*N
for i in range(N):
    h[i] = int(input())
h = sorted(h)
ans = 10**10
for i in range(N-(K-1)):
    tmp = h[i+K-1] - h[i]
    ans = min(tmp,ans)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
a,b=input().split()
c,d=int(a),int(b)
l=[int(input()) for i in range(c)]
L=sorted(l)
x=L[d]-L[0]
for i in range(c-d+1):
    if L[d+i]-L[i]<x:
        x=L[d+i]-L[i]
print(x)

a,b=input().split()
c,d=int(a),int(b)
l=[int(input()) for i in range(c)]
L=sorted(l)
x=L[d-1]-L[0]
for i in range(c-d+1):
    if L[d+i-1]-L[i]<x:
        x=L[d+i-1]-L[i]
print(x)

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N,K = map(int,input().split())
tree_list,new_tree_list = [],[]
for i in range(N):
    tree_list.append(int(input()))

tree_list.sort(reverse=True)

for i in range(len(tree_list)-K+1):
    print(tree_list[0+i],tree_list[K+i-1])
    new_tree_list.append(tree_list[0+i]-tree_list[K+i-1])
new_tree_list.sort()
print(new_tree_list[0])


N,K = map(int,input().split())
tree_list,new_tree_list = [],[]
for i in range(N):
    tree_list.append(int(input()))

tree_list.sort(reverse=True)

for i in range(len(tree_list)-K+1):
    new_tree_list.append(tree_list[0+i]-tree_list[K+i-1])
new_tree_list.sort()
print(new_tree_list[0])


Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N, K = list(map(int, input().split()))

h = []
for i in range(N):
    h.append(int(input()))

h.sort()

minDistance = 10 ** 9
for i in range(0, N - K):
    if h[i + K] - h[i] < minDistance:
        minDistance = h[i + K] - h[i]

print(minDistance)

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

h = []
for i in range(N):
    h.append(int(input()))

h.sort()

minDistance = 10 ** 9
for i in range(0, N - K + 1):
    if h[i + K - 1] - h[i] < minDistance:
        minDistance = h[i + K - 1] - h[i]

print(minDistance)

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k=map(int,input().split())
l=[]
for i in range(n):
  v=int(input())
  l.append(v)
tmp=l[n-1]
for j in range(n-k+1):
  tmp=min(tmp,l[j+k-1]-l[j])
print(tmp)

n,k=map(int,input().split())
l=[]
for i in range(n):
  v=int(input())
  l.append(v)
l.sort()
tmp=l[n-1]
for j in range(n-k+1):
  tmp=min(tmp,l[j+k-1]-l[j])
print(tmp)

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k=map(int,input().split())
h=[int(input())for i in range(n)]
ans=1000000000
for i in range(k,n):
  ans=min(ans,h[i]-h[i-k])
print(ans)

n,k=map(int,input().split())
h=[int(input())for i in range(n)]
h.sort()
ans=1000000000
for i in range(k,n):
  ans=min(ans,h[i]-h[i-k])
print(ans)

n,k=map(int,input().split())
h=[int(input())for i in range(n)]
h.sort()
ans=1000000000
for i in range(k-1,n):
  ans=min(ans,h[i]-h[i-k+1])
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = map(int,input().split())
h_list = [int(input()) for _ in range(n)]
h_list.sort(reverse=True)
i = 0
j = k-1
ans = 10**9

while j < n:
    diff = h_list[j]-h_list[i]
    ans = min(ans,diff)
    i  = j
    j += k-1
print(ans)

n,k = map(int,input().split())
h_list = [int(input()) for _ in range(n)]
h_list.sort(reverse=True)
i = 0
j = k-1
ans = 10**9

while j < n:
    diff = h_list[i]-h_list[j]
    ans = min(ans,diff)
    i += 1
    j += 1
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N,K= list(map(int,input().split(" ")))
nums = []
for i in range(N):
    nums.append(int(input()))
nums.sort()
r = 0
l = 0
ans = []
for i,num in enumerate(nums[:-(K-1)]):
    r = nums[i+K-1]
    l = num
    print("l:",l,"//r:",r)
    ans.append(r-l)
print(min(ans))

N,K= list(map(int,input().split(" ")))
nums = []
for i in range(N):
    nums.append(int(input()))
nums.sort()
r = 0
l = 0
ans = []
for i,num in enumerate(nums[:-(K-1)]):
    r = nums[i+K-1]
    l = num
    # print("l:",l,"//r:",r)
    ans.append(r-l)
print(min(ans))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N,K = map(int,input().split())
lis = [int(input()) for x in range(N)]
lis.sort()
print(min(lis[i+K-1] - lis[i] for x in range(N-K+1)))

N,K = map(int,input().split())
lis = [int(input()) for x in range(N)]
lis.sort()
print(min(lis[i+K-1] - lis[i] for i in range(N-K+1)))

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
l = h[-3::]
print(max(l)-min(l))

n,k = map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
l = [h[i+k-1]-h[i] for i in range(n-k+1)]
print(min(l))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = map(int,input().split(" "))

trees = []
for i in range(n):
    trees.append(int(input()))

trees = sorted(trees,reverse=True)
print(trees)
average = sum(trees)/len(trees)
min_dist = 1e+10
if abs(max(trees) - average) > abs(min(trees) - average):
    for i in range(n)[k-1:]:
        print(i)
        if min_dist > abs(trees[i] - trees[i-k+1]):

            min_dist = abs(trees[i] - trees[i-k+1])
else:
    for i in range(n-k+1):
        if min_dist > abs(trees[i+k-1] - trees[i]):
            min_dist = abs(trees[i+k-1] - trees[i])
print(min_dist)


n,k = map(int,input().split(" "))

trees = []
for i in range(n):
    trees.append(int(input()))

trees = sorted(trees,reverse=True)
average = sum(trees)/len(trees)
min_dist = 1e+10
if abs(max(trees) - average) > abs(min(trees) - average):
    for i in range(n)[k-1:]:
        if min_dist > abs(trees[i] - trees[i-k+1]):

            min_dist = abs(trees[i] - trees[i-k+1])
else:
    for i in range(n-k+1):
        if min_dist > abs(trees[i+k-1] - trees[i]):
            min_dist = abs(trees[i+k-1] - trees[i])
print(min_dist)


Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N,K = map(int,input().split())
treelist = []
difflist = []
append = treelist.append
#print(treelist)
append_diff = difflist.append
for i in range(N):
    tree = int(input())
    #print(tree)
    append(tree)
treelist.sort()
print(treelist)
for i in range(K-1,N):
    diff = treelist[i] - treelist[i-K+1]
    #print(diff)
    append_diff(diff)
print(min(difflist))

N,K = map(int,input().split())
treelist = []
difflist = []
append = treelist.append
#print(treelist)
append_diff = difflist.append
for i in range(N):
    tree = int(input())
    #print(tree)
    append(tree)
treelist.sort()
#print(treelist)
for i in range(K-1,N):
    diff = treelist[i] - treelist[i-K+1]
    #print(diff)
    append_diff(diff)
print(min(difflist))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = [int(i) for i in input().split()]
h = [int(inoput()) for _ in range(n)]
h.sort()

ans = 10**9
for i,j in zip(h,h[k-1:]):
  ans = min(ans,j-i)
print(ans)

n,k = [int(i) for i in input().split()]
h = [int(input()) for _ in range(n)]
h.sort()

ans = 10**9
for i,j in zip(h,h[k-1:]):
  ans = min(ans,j-i)
print(ans)

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N,K = (int(i) for i in input().split())  
h = [int(input()) for i in range(N)]
 
h.sort()
 
ans=[]
 
for i in range(N):
	if i+K==N+1:
		break
	else:
		ans.append(h[i+K-1] - h[i])
print(ans)
print(min(ans))

N,K = (int(i) for i in input().split())  
h = [int(input()) for i in range(N)]
 
h.sort()
 
ans=[]
 
for i in range(N):
	if i+K==N+1:
		break
	else:
		ans.append(h[i+K-1] - h[i])
print(min(ans))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
  flag = 0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1] == 0:
        count += 1
      else:
        pass
  if flag == 0:
    break
print(count)

N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
	flag=0
    for i in range(N):
    	if h[i]>0:
        	h[i] -= 1
      	    flag = 1
        if h[i+1] == 0:
        	count += 1
        else:
        	pass
    if flag == 0:
    	break
print(count)

N = int(input())
h = list(map(int,input().split()))
h.append(0)

count=0
while 1:
  flag=0
  for i in range(N):
    if h[i]>0:
      h[i] -= 1
      flag = 1
      if h[i+1] == 0:
        count += 1
      else:
        pass
  if flag == 0:
    break
print(count)

N,K=list(map(int,input().split()))
h=[]
for i in range(N):
  h.append(int(input()))
h.sort()

minimum=1000000000
for j in range(N-K+1):
  minimum=min(minimum, h[j+K-1]-h[j])
print(minimum)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N, K = map(int,input().split())
h = sorted(int(input()) for _ in range(N))

ans = 1e9+7
for i in range(N-K+1):
  ans = min(ans, h[i+K]-h[i])
print(ans)

N, K = map(int,input().split())
h = sorted(int(input()) for _ in range(N))

ans = 1e9+7
for i in range(N-K+1):
  ans = min(ans, h[i+K-1]-h[i])
print(ans)

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k=map(int,input().split())
l=sorted(list(map(int,input().split())))
ret=float("inf")
print(min([abs(l[i]-l[i+k]) for i in range(n-k)]))

n,k=map(int,input().split())
l=sorted([int(input()) for i in range(n)])
print(min([abs(l[i]-l[i+k]) for i in range(n-k)]))

n,k=map(int,input().split())
l=sorted([int(input()) for i in range(n)])
print(min([abs(l[i]-l[i+k-1]) for i in range(n-k+1)]))

Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
from sys import stdin
import numpy as np
import sys

N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = np.array(map(int, [stdin.readline().rstrip() for _ in range(N)]))

hs = h.sort()
hmin = sys.maxint

for i in range(0, N-K):
    hdiff = hs[i+K] - hs[i]
    if hdiff < hmin:
        hmin = hdiff

print(hmin)



from sys import stdin
import numpy as np
import sys

N, K = [int(x) for x in stdin.readline().rstrip().split()]
h = np.array(list(map(int, [stdin.readline().rstrip() for _ in range(N)])))

h.sort()
hmin = 2**30

for i in range(0, N-K+1):
    hdiff = h[i+K-1] - h[i]
    if hdiff < hmin:
        hmin = hdiff

print(hmin)



Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k=map(int,input().split())
h = [int(input()) for i in range(N)]
h.sort()
ans=10**9
for i in range(n-k+1):
    ans=min(ans,max(h[i:i+k])-min(h[i:i+k]))
print(ans)

n,k=map(int,input().split())
h = [int(input()) for i in range(n)]
h.sort()
ans=10**9
for i in range(n-k+1):
    ans=min(ans,h[i+k-1]-h[i])
print(ans)

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])
print(min([h[i+K] - h[i] for i in range(N-K+1)]))

N, K = map(int, input().split())
h = sorted([int(input()) for i in range(N)])
print(min([h[i+K-1] - h[i] for i in range(N-K+1)]))

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = map(int,input().split())
h = []
for i in range(n):
  hi = int(input())
  h.append(hi)
h.sort()
l = []
for i in range(n-k+1):
  l.append(h[i+k-1] - h[i])
print(max(l))

n,k = map(int,input().split())
h = []
for i in range(n):
  hi = int(input())
  h.append(hi)
h.sort()
l = []
for i in range(n-k+1):
  l.append(h[i+k-1] - h[i])
print(min(l))

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N,K = [int(i) for i in input().split()]
H = sorted([int(input()) for i in range(N)])
print(H)
ans = H[K - 1] - H[0]
for i in range(N - K + 1):
    t = H[K + i - 1] - H[i]
    if ans > t:
        ans = t
print(ans)

N,K = [int(i) for i in input().split()]
H = sorted([int(input()) for i in range(N)])
ans = H[K - 1] - H[0]
for i in range(N - K + 1):
    t = H[K + i - 1] - H[i]
    if ans > t:
        ans = t
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n, k = map(int, input().split())

h = [int(input()) for i in range(n)]
h.sort()

cand = [0]*(n-k+1)
cand[0] = h[k-1] - h[0]


for j in range(1,n-k+1):
    cand[i] = cand[i-1] + h[k+i-1] - h[i]

print(min(cand))

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

h = [int(input()) for i in range(n)]
h.sort()

cand = [0]*(n-k+1)
cand[0] = h[k-1] - h[0]


for j in range(1,n-k+1):
    cand[j] = h[k+j-1] - h[j]

print(min(cand))

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
h_max = 0
h_min = 0
r = 0
ans = []
#print(h)
for i in range(r,n-k+1):
    if n - r < k: 
        break
    h_max = h[r+k]
    #print(h[r:k])
    h_min = h[r])
    ans.append(h_max - h_min)
    r += 1
print(min(ans))


Cn,k = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
h_max = 0
h_min = 0
r = 0
ans = []
#print(h)
for i in range(r,n):
    h_max = max(h[r:k+r])
    #print(h[r:k])
    h_min = min(h[r:k+r])
    if n -r < k: 
        break
    ans.append(h_max - h_min)
    r += 1
print(min(ans))


n,k = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
h.sort()
h_max = 0
h_min = 0
r = 0
ans = []
#print(h)
for i in range(r,n-k+1):
    if n - r < k: 
        break
    h_max = h[r+k-1]
    #print(h[r:k])
    h_min = h[r]
    ans.append(h_max - h_min)
    r += 1
print(min(ans))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()


#y = int(input())
#x = int(input())
a = []
n = int(x[0])
k = int(x[1])
for i in range(k):
    a.append(int(input()))
a = sorted(a)
p = []
for i in range(n-k-1):
    p.append(a[i+k-1]-a[i])
print(min(p))

from statistics import mean, median,variance,stdev
import sys
import math

x = input().split()
#y = input().split()


#y = int(input())
#x = int(input())
a = []
b = int(x[0])
num = int(x[1])
for i in range(b):
    a.append(int(input()))
a = sorted(a)
min = a[num-1]-a[0]
for i in range(num,b):
    if min > a[i]-a[i-num+1]:
        min = a[i]-a[i-num+1]
if min > a[b-1]-a[b-num]:
    min = a[b-1]-a[b-num]
print(min)


Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
5 3
5
7
5
7
7

n, k = map(int, input().split())
h = sorted([int(input()) for i in range(n)])

res = h[k-1] - h[0]
for i in range(k, n):
    tmp = h[i] - h[i-k+1]
    res = min(res, tmp)

print(res)

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = map(int,input())
h = [int(input()) for i in range(n)].sort()
ans = 1000000000
for i in range(n-k+1):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)

n,k = map(int,input())
h = [int(input()) for i in range(n)].sort()
ans = 1000000000
for i in range(n-k):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)

n,k = map(int,input())
h = [int(input()) for i in range(n)].sort()
ans = 1000000000
for i in range(n-k):
  ans = min(ans, h[i+k]-h[i])
print(ans)

n,k = map(int,input().split())
h = sorted([int(input()) for i in range(n)])
ans = 1000000000
for i in range(n-k+1):
  ans = min(ans, h[i+k-1]-h[i])
print(ans)

Verdicts: Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
#115-C
n,k = (int(i) for i in input().split())
t = [int(input()) for i in range(n)] 
#t = [10,15,11,14,12]
t = sorted(t)
min = float('inf')
for i in range(n-k):
    s = t[i+k-1]-t[i]
    if s < min:

print(min)
#print(t)

n,k = (int(i) for i in input().split())
t = [int(input()) for i in range(n)] 
t = [10,15,11,14,12]
t = sorted(t)
min = float('inf')
for i in range(n-k):
    s = t[i+k-1]-t[i]
    if s < min:

print(min)
#print(t)
    

#115-C
n,k = (int(i) for i in input().split())
t = [int(input()) for i in range(n)] 
#t = [10,15,11,14,12]
t = sorted(t)
min = t[k-1]-t[0]
for i in range(n-k+1):
    s = t[i+k-1]-t[i]
    if s < min:
        min = s

print(min)
#print(t)
    

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n, k = map(int, input().split())
h = [int(input()) for i in range(n)]

h.sort()
ans = max(h)
for i in range(n-k+1):
  ans = min(ans, h[i] - h[i+k-1])
print(ans)

n, k = map(int, input().split())
h = [int(input()) for i in range(n)]

h.sort()
ans = 10 ** 9
for i in range(n-k+1):
  ans = min(ans, h[i+k-1] - h[i])
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):

# coding: utf-8

# In[33]:





# In[35]:


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


# In[36]:


p=[]
for i in range(N):
    p.append(int(input()))


# In[44]:


min_val=abs(p[0]-p[1])
for i in range(N):
    for j in range(N):
        if i!=j:
            if abs(p[i]-p[j])<min_val:
                min_val=abs(p[i]-p[j])
print(min_val)




# coding: utf-8

# In[33]:





# In[45]:


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


# In[46]:


p=[]
for i in range(N):
    p.append(int(input()))


# In[49]:


p.sort()


# In[56]:


print(min(p[i+K-1]-p[i] for i in range(N-K+1)))



Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
a=10**9
for i in range(n-k+1):
    a1=h1[i+k-1]-h[i]
    a=min(a,a1)
print(a)

n,k=map(int,input().split())
h=sorted([int(input()) for _ in range(n)])
a=10**9
for i in range(n-k+1):
    a1=h[i+k-1]-h[i]
    a=min(a,a1)
print(a)

Verdicts: Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N, K = map(int, input().split())
h = list(int(input()) for _ in range(N))
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)


N, K = map(int, input().split())
h = [(int(input()) for _ in range(N)]
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)


N, K = map(int, input().split())
h = [(int(input()) for _ in range(N))]
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)


N, K = map(int, input().split())
h = [list(int(input()) for _ in range(N))]
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)

N, K = map(int, input().split())
h = [(int(input()) for _ in range(N)]
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)


N, K = map(int, input().split())
h = sorted(list(int(input()) for _ in range(N)))
fin = h[K-1] - h[0]
for i in range(1, N-K+1):
  t = h[i+K-1] - h[i]
  if fin > t :
    fin = t
print(fin)


Verdicts: Wrong Answer

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = map(int,input().split())
list = []
for i in range(n):
  list.append(int(input()))
list.sort()
min = 10^9
for j in range(n-k+1):
  if list[j+k-1]-list[j] < min:
    min = list[j+k]-list[j]
print(min)


n,k = map(int,input().split())
list = []
for i in range(n):
  list.append(int(input()))
list.sort()
min = 10^9
for j in range(n-k+1):
  if list[j+k-1]-list[j] < min:
    min = list[j+k]-list[j]
print(min)


n,k = map(int,input().split())
list = []
for i in range(n):
  list.append(int(input()))
list.sort()
min = list[n-1]
for j in range(n-k+1):
  if list[j+k-1]-list[j] < min:
    min = list[j+k-1]-list[j]
print(min)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
N, K = map(int, input().split())
H = sorted([int(input()) for _ in range(N)])
print(min(H[i+K-1]-H[i]) for i in range(N-K+1))


N, K = map(int, input().split())
H = sorted([int(input()) for _ in range(N)])
print(min(H[i+K-1]-H[i] for i in range(N-K+1)))


Verdicts: Wrong Answer

Accepted
Problem: In some other world, today is Christmas Eve.  There are N trees planted in Mr. Takaha's garden. The height of the i-th tree (1 \leq i \leq N) is h_i meters.  He decides to choose K trees from these trees and decorate them with electric lights. To make the scenery more beautiful, the heights of the decorated trees should be as close to each other as possible.  More specifically, let the height of the tallest decorated tree be h_{max} meters, and the height of the shortest decorated tree be h_{min} meters. The smaller the value h_{max} - h_{min} is, the better. What is the minimum possible value of h_{max} - h_{min}?

Submission attempts (in order):
n,k = map(int,input().split())
H = sorted([int(input()) for _ in range(n)])
ans = float("INF")
for i in range(0,n - k + 1):
  print(i)
  selected = H[i:k + i]
  ans = min(ans,max(selected) - min(selected))
print(ans)

n,k = map(int,input().split())
H = sorted([int(input()) for _ in range(n)])
ans = float("INF")
for i in range(n - k + 1):
  diff = H[k + i -1] - H[i]
  ans = min(ans,diff)
print(ans)

Verdicts: Wrong Answer

Accepted