Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
H,N = map(int,input().split())
Alist = []
for i in range(N):
  A = int(input())
  Alist.append(A)
print(Alist)

Fixed submission:
H,N = map(int,input().split())
A = list(map(int,input().split()))
if sum(A) < H:
  print("No")
else:
  print("Yes")
Buggy python submission (verdict: Runtime Error):
N,K = map(int,input().split())
H = list(map(int,input().split()))
if K == 0:
  print(sum(H))
else:
  H.sort(reverse = True)
  if N>K:
    for i in range(K):
      del H[i]
    print(sum(H))
  else:
    print(0)


Fixed submission:
N,K = map(int,input().split())
H = list(map(int,input().split()))
if K == 0:
  print(sum(H))
else:
  H.sort(reverse = True)
  if N>K:
    h = H[K:N]
    print(sum(h))
#    for i in range(K):
 #     del H[i]
  #  print(sum(H))
  else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N = int(input())
if N%2==1:
  print(N-1)
else:
  ans = []
  for i in range(1,N):
    for j in range(1,N):
      cnt=0
      if i*j==N:
        cnt +=i-1
        cnt +=j-1
        ans.append(str(cnt))
  ans=min(ans)
  print(ans)


Fixed submission:
A,B = map(int,input().split())
if A<10 and B<10:
  print(A*B)
else:
  print(-1)
Buggy python submission (verdict: Runtime Error):
A,B=map(int,input().split())
set = 0
for i in range(1,20):
  if B==1:
    set -=1
    break
  elif A == B:
    set +=1
    break
  elif ((A-1)*i)+A >= B:
    set +=1
    break
  else:
    set +=1
print(set+1)


Fixed submission:
s = input ()
t = input ()
count = 0
for i in range(3):
  if s[i]==t[i]:
    count += 1
print (count)
Buggy python submission (verdict: Runtime Error):
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
dis=list[a,b,c,d,e,k]

if max(dis)-min(dis)>=K:
  print(":(")
else("Yay!") 

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
dis =[]
dis.append(a)
dis.append(b)
dis.append(c)
dis.append(d)
dis.append(e)

if max(dis)-min(dis)>k:
  print(":(")
else:
  print("Yay!")
Buggy python submission (verdict: Runtime Error):
S = input()
l = len(S)
count=0
ans=[]
for i in range(l):
  if S[i]=="A" or S[i]=="C" or S[i]=="G" or S[i]=="T":
    count +=1
  else:
    ans.append(count)
    count=0

print(max(ans))


Fixed submission:
S = input()
l = len(S)
count=0
ans= 0
for i in range(l):
  if S[i] in ["A" ,"C" ,"G","T"]:
    count +=1
  else:
    count=0
  ans = max(count,ans)
print(ans)
Buggy python submission (verdict: Runtime Error):
S = input()
if len(S) == 1:
    print('No')
elif len(S) == 2:
    if S[0] == 'h' and S[1] == 'i':
        print('Yes')
    else:
        print('No')
else:
    for i in range(len(S)-2):
        if S[i] == 'h' and S[i + 1] == 'i' and S[i + 2] != 'i':
            print('Yes')
            exit(1)
    print('No')
    

Fixed submission:
S = input()
ans = ''
flag = False
for i in range(5):
    ans += 'hi'
    if ans == S:
        flag = True

print('Yes' if flag else 'No')
Buggy python submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + a[y-1] - c)
print(ans)


Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)

Buggy python submission (verdict: Runtime Error):
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + a[y-1] - c)
print(ans)


Fixed submission:
A, B, M = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
ans = min(a) + min(b)

for i in range(M):
    x, y, c = map(int, input().split())
    ans = min(ans, a[x-1] + b[y-1] - c)
print(ans)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
P = [input().split() for i in range(M)]
k3, k2, k1 = 0, 0, 0

if N == 3:
    for i in range(M):
        if P[i][0] == '1':
            if k3 != 0:
                k3 = min(k3, int(P[i][1]))
            else:
                k3 = int(P[i][1])
        elif P[i][0] == '2':
            if k2 != 0:
                k2 = min(k2, int(P[i][1]))
            else:
                k2 = int(P[i][1])
        else:
            if k1 != 0:
                k1 = min(k1, int(P[i][1]))
            else:
                k1 = int(P[i][1])
    ans = k3 * 100 + k2 * 10 + k1
    ans = ans if M > 0 and len(str(ans)) == 3  else - 1
    print(ans)

elif N == 2:
    for i in range(M):
        if P[i][0] == '1':
            print(-1)
            exit(1)
        elif P[i][0] == '2':
            if k2 != 0:
                k2 = min(k2, int(P[i][1]))
            else:
                k2 = int(P[i][1])
        else:
            if k1 != 0:
                k1 = min(k1, int(P[i][1]))
            else:
                k1 = int(P[i][1])

    ans = k3 * 100 + k2 * 10 + k1
    ans = ans if M > 0 and len(str(ans)) == 2  else - 1
    print(ans)
        
        
else:
    for i in range(M):
        if P[i][0] == '1' or P[i][0] == '2':
            print(-1)
            exit(1)
        else:
            if k1 != 0:
                k1 = min(k1, int(P[i][1]))
            else:
                k1 = int(P[i][1])

    ans = k3 * 100 + k2 * 10 + k1
    ans = ans if M > 0 and len(str(ans)) == 1  else - 1
    print(ans)

Fixed submission:

def solve(x):
    x = str(x)
    if len(x) != N:
        return False
    for s, c in P:
        if x[s - 1] != str(c):
            return False
    return True

if __name__ == "__main__":
    N, M = map(int, input().split())
    P = [list(map(int, input().split())) for i in range(M)]
    ans = 10**N
    for i in range(10 ** N - 1, -1, -1):
        if solve(i):
            ans = min(ans, i)
            
    print(ans if ans != 10**N else -1)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in map(int, input().split()):
    if i in l:
        print("NO")
        exit(0)
    l.append(i)
print("YES")

Fixed submission:
N = int(input())
A = set(map(int, input().split()))
print("YES" if len(A) == N else "NO")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
l = []
for i in map(int, input().split()):
    if i in l:
        print("NO")
        exit()
    l.append(i)
print("YES")

Fixed submission:
N = int(input())
A = set(map(int, input().split()))
print("YES" if len(A) == N else "NO")

Buggy python submission (verdict: Runtime Error):
N = int(input())
l = []
for i in range(N):
    A = int(input())
    if A in l:
        print("NO")
        exit()
    l.append(i)
print("YES")

Fixed submission:
N = int(input())
A = set(map(int, input().split()))
print("YES" if len(A) == N else "NO")

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
l = []
for i in A:
    if i in l:
        print("NO")
        exit()
    l.append(i)
print("YES")

Fixed submission:
N = int(input())
A = set(map(int, input().split()))
print("YES" if len(A) == N else "NO")
Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [0]
E.append(sum([i for i in range(1, P[0] + 1)])/P[0])
for i in range(1,N):
    p = P[i]
    SUM = sum([i for i in range(1, p + 1)])
    E.append(E[i] + SUM / p)
r = K
ans = 0
while r < N + 1:
    ans = max(ans, E[r] - E[r - K])
    r += 1
print(ans)

Fixed submission:
from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [0]
E.append(sum([i for i in range(1, P[0] + 1)])/P[0])
for i in range(1,N):
    p = P[i]
    E.append(E[i] + ((1+p) / 2))
r = K
ans = 0
while r < N + 1:
    ans = max(ans, E[r] - E[r - K])
    r += 1
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = []
for i in range(N):
    p = P[i]
    SUM = sum([i for i in range(1, p + 1)])
    E.append(SUM/p)
l = 0
r = K - 1
ans = 0
while r < N:
    ans = max(ans, sum(E[l:r+1]))
    l += 1
    r += 1
print(ans)

Fixed submission:
from math import ceil
N, K = map(int, input().split())
P = list(map(int, input().split()))
E = [0]
E.append(sum([i for i in range(1, P[0] + 1)])/P[0])
for i in range(1,N):
    p = P[i]
    E.append(E[i] + ((1+p) / 2))
r = K
ans = 0
while r < N + 1:
    ans = max(ans, E[r] - E[r - K])
    r += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, K = map(int, input().split())

if A > K:
    A = A - K
    print(A, end=" ")
    print(B)
    exit(0)

if K > A:
    K = K - A
    A = 0
    if K >= B:
        K = K - B
        B = 0
    if B > K:
        B = B - K
        print(A, end=" ")
        print(B)
        exit(0)
    
    
for i in range(K):
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
    if A == 0 and B == 0:
        break

print(A, end=" ")
print(B)

Fixed submission:
import math
A, B, K = map(int, input().split())

if A >= K:
    A = A - K
    print(A, end=" ")
    print(B)
    exit(0)

if K > A:
    K = K - A
    A = 0
    if K >= B:
        B = 0
        print(A, end=" ")
        print(B)
        exit(0)
    if B > K:
        B = B - K
        print(A, end=" ")
        print(B)
        exit(0)

Buggy python submission (verdict: Time Limit Exceeded):
import math
A, B, K = map(int, input().split())

if A > K:
    A = A - K
    print(A, end=" ")
    print(B)
    exit(0)

if K > A:
    K = K - A
    A = 0
    if K >= B:
        K = K - B
        B = 0
    
    
for i in range(K):
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
    if A == 0 and B == 0:
        break

print(A, end=" ")
print(B)

Fixed submission:
import math
A, B, K = map(int, input().split())

if A >= K:
    A = A - K
    print(A, end=" ")
    print(B)
    exit(0)

if K > A:
    K = K - A
    A = 0
    if K >= B:
        B = 0
        print(A, end=" ")
        print(B)
        exit(0)
    if B > K:
        B = B - K
        print(A, end=" ")
        print(B)
        exit(0)

Buggy python submission (verdict: Runtime Error):
import math
A, B, K = map(int, input().split())

gcd = math.gcd(A, B)
A = A // gcd
B = B // gcd

    
for i in range(K):
    if A >= 1:
        A -= 1
    elif B >= 1:
        B -= 1
    if A == 0 and B == 0:
        break

print(A, end=" ")
print(B)

Fixed submission:
import math
A, B, K = map(int, input().split())

if A >= K:
    A = A - K
    print(A, end=" ")
    print(B)
    exit(0)

if K > A:
    K = K - A
    A = 0
    if K >= B:
        B = 0
        print(A, end=" ")
        print(B)
        exit(0)
    if B > K:
        B = B - K
        print(A, end=" ")
        print(B)
        exit(0)
Buggy python submission (verdict: Runtime Error):
from math import sqrt 
N = int(input())
k = [list(map(int, input().split())) for _ in range(N)]
result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((k[i][0] - k[j][0]) * (k[i][0] - k[j][0]) + (k[i][1] - k[j][1]) * (k[i][1] - k[j][1]))
print(result / N)

Fixed submission:
r = int(input())

print(r**2)

Buggy python submission (verdict: Runtime Error):
N = int(input())
S = input()
S1 = []
for i in range(N // 2):
    S1.append(S[i])

S = S[N // 2 :]
S1 = ''.join(S1)
if S1 == S:
    print('Yes')
else:
    print('No')

Fixed submission:
r = int(input())

print(r**2)
Buggy python submission (verdict: Runtime Error):
from math import sqrt 
N = int(input())
k = [[int(i) for i in input().split()] for i in range(N)]
result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((k[i][0] - k[j][0]) * (k[i][0] - k[j][0]) + k[i][1] - k[j][1]) * (k[i][1] - k[j][1]))
print(result / N)

Fixed submission:

from math import sqrt 
N = int(input())
k = [list(map(int, input().split())) for _ in range(N)]
result = 0
for i in range(N):
    for j in range(N):
        if i != j:
            result += sqrt((k[i][0] - k[j][0]) * (k[i][0] - k[j][0]) + (k[i][1] - k[j][1]) * (k[i][1] - k[j][1]))
print(result / N)
Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 10*10
#N<10**12より√N<10**6]
for i in range(1, i*i <=N):
    if (N % i != 0): continue
    j = N / i
    ans = min(ans, i + j - 2)

print(ans)

Fixed submission:
from math import sqrt
from sys import exit

N = int(input())

for i in range(int(sqrt(N)) + 1, -1, -1):
    if N % i == 0:
        print((i - 1) + (N // i - 1))
        exit()

Buggy python submission (verdict: Runtime Error):
N = int(input())
ans = 10*18
for i in range(1, i*i <=N):
    if (N % i != 0): continue
    j = N / i
    ans = min(ans, i + j - 2)

print(ans)

Fixed submission:
from math import sqrt
from sys import exit

N = int(input())

for i in range(int(sqrt(N)) + 1, -1, -1):
    if N % i == 0:
        print((i - 1) + (N // i - 1))
        exit()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
for i in range(1,N+1):
    for j in range(0,N):
        if i == A[j]:
            print(j+1,end=" ")
            

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
target = []
for i in range(0, N):
    target.append([A[i], i + 1])

target.sort()

for i in range(0, N):
    print(target[i][1],end=" ")
Buggy python submission (verdict: Time Limit Exceeded):
N, K, Q = map(int, input().split())
point = [K for i in range(N)]
A = [int(input()) for j in range(Q)]

for num in A:
    for j in range(1,N+1):
        if not j == num:
            point[j-1] -= 1

for num in point:
    if num > 0:
        print('Yes')
        continue
    print('No')
    

Fixed submission:
N, K, Q = map(int, input().split())
point = [K - Q for i in range(N)]
A = [int(input()) for j in range(Q)]

for num in A:
    point[num-1] += 1

for num in point:
    if num > 0:
        print('Yes')
        continue
    print('No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))
count = []
c = 0
H.reverse()

for i in range(1, len(H)):
    if H[i] >= H[i - 1]:
         c += 1
         continue
    count.append(c)
    c = 0


print(max(count))

Fixed submission:
N = int(input())
H = list(map(int, input().split()))
ans = 0
c = 0
H.reverse()

for i in range(1, len(H)):
    if H[i] >= H[i - 1]:
        c += 1
    else:
        c = 0
    ans = max(c, ans)

print(ans)
Buggy python submission (verdict: Runtime Error):
N = int(input())
H = list(map(int, input().split()))

if H[1] == H[0] + 1:
    print("Yes")
 
elif H[0] - 1 == H[1]:
    print("Yes")
    
else:
    print("No")


Fixed submission:
N = int(input())
H = list(map(int, input().split()))
H[0] -= 1
count = 0
for i in range(1, N):
    if H[i] > H[i - 1]:
        H[i] -= 1 

for i in range(1, N):
    if H[i] <H[i - 1]:
        print("No")
        exit()
print("Yes")
Buggy python submission (verdict: Runtime Error):
#N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
fenum = sum(A)

if B[0] >= A[0]:
    B[0] -= A[0]
    A[0] = 0
    if B[0] > A[1]:
        A[1] = 0
    else:
        A[1] -= B[0]
        B[0] = 0
    
else:
    A[0] -= B[0] 
    B[0] = 0
    
for i in range(1, len(B)):
    if B[i] >= A[i]:
        B[i] -= A[i]
        A[i] = 0
        if B[i] > A[i + 1]:
            A[i + 1] = 0
            continue
        A[i + 1] -= B[i]
        B[i] = 0
    
    else:
        A[i] -= B[i]
        B[i] = 0

print(fenum - sum(A))


Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
fenum = sum(A)

if B[0] >= A[0]:
    B[0] -= A[0]
    A[0] = 0
    if B[0] > A[1]:
        A[1] = 0
    else:
        A[1] -= B[0]
        B[0] = 0
    
else:
    A[0] -= B[0] 
    B[0] = 0
    
for i in range(1, N):
    if B[i] >= A[i]:
        B[i] -= A[i]
        A[i] = 0
        if B[i] > A[i + 1]:
            A[i + 1] = 0
            continue
        A[i + 1] -= B[i]
        B[i] = 0
    
    else:
        A[i] -= B[i]
        B[i] = 0

print(fenum - sum(A))
Buggy python submission (verdict: Runtime Error):
W, H ,x, y = map(int, input().split())
if W % x == 0 and H % y == 0:
    print((W * H) /2, 1)
else:
    if x > y:
      print(min(W * y, W * (H - y)), 0)
    else:
      print(min(H * x, H * (W - x)), 0)
        


Fixed submission:
W, H ,x, y = map(int, input().split())

print(W * H / 2, end=" ")
if 2 * x == W and 2 * y == H:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
W, H ,x, y = map(int, input().split())
difx = W - x
dify = H - y
if W % x == 0 and H % y == 0:
    print(W * dify, 1)
else:
    if difx >= dify:
        print(difx* H, 0)
    else:
        print(dify * W,0)


Fixed submission:
W, H ,x, y = map(int, input().split())

print(W * H / 2, end=" ")
if 2 * x == W and 2 * y == H:
    print(1)
else:
    print(0)

Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
c = 0
if W == H or (x == W and y == H) or (x == 0 and y == H) or (x == W or y == 0) or (y == 0 and x == 0):
    c = 1
if x > W // 2:
    min1 = H * (W - x)
    if y > H // 2:
        mini2 = (H - y) * W
    else:
        mini2 = y * W
    
    print(max(mini1, mini2),c)

else:
    mini1 = x * H
    if y > H // 2:
        mini2 = (H - y) * W
    else:
        mini2 = y * W
    
    print(max(mini1, mini2),c)


Fixed submission:
W, H ,x, y = map(int, input().split())

print(W * H / 2, end=" ")
if 2 * x == W and 2 * y == H:
    print(1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())

a = [int(input()) for i in range(M)]
dp = [0 for i in range(N + 1)]
flag = [False for i in range(N + 1)]
dp[0] = 1
if a[0] != 1:
    dp[1] = 1
for i in a:
    flag[i] = True
for i in range(2,N+1):
    if flag[i - 1] != True:
        dp[i] = dp[i - 1]
    if flag[i - 2] != True:
        dp[i] += dp[i - 2]
print(dp[N] % 1000000007 )

Fixed submission:
N, M = map(int, input().split())

bs = [True for i in range(N+1)]
for i in range(M):
    a = int(input())
    bs[a] = False

dp = [0 for i in range(N+1)]
dp[0] = 1
if bs[1] != False: dp[1] = 1

for i in range(2,N+1):
    if bs[i-1] != False:
        dp[i] += dp[i - 1]
    if bs[i - 2] != False:
        dp[i] += dp[i - 2]

print(dp[N] % 1000000007)
Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
idcard = [[int(j) for j in input().split()] for i in range(M)]
ans = {}
if M == 1:
    print(idcard[0][1] - idcard[0][0] + 1)
    exit()
t = 0
for i in idcard:
    for j in range(i[0], i[1] + 1):
        if j in ans:
            ans[j] += 1
        else:
            ans[j] = 1
        t = max(ans.values())
w = 0
for i in ans.values():
    if i == t:
        w += 1

print(w)

Fixed submission:
N, M = map(int, input().split())
idcard = [[int(j) for j in input().split()] for i in range(M)]

L = 0
R = 10**10
for i in idcard:
    L = max(L, i[0])
    R = min(R, i[1])
if R >= L:
    print(R - L + 1)
else:
    print(0)
Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        v = R * r + G * g
        if v > N:
            continue
        if (N - v) % B != 0:
            continue
        ans +=1 
print(ans)


Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        v = R * r + G * g
        if v > N:
            break
        if (N - v) % B == 0:
            ans +=1 
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N+1):
    for g in range(N+1):
        b =( N - R * r - G * g) / B
        if b >= 0 and b.is_integer():
            ans += 1
print(ans)


Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        v = R * r + G * g
        if v > N:
            break
        if (N - v) % B == 0:
            ans +=1 
        
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
R, G, B, N = map(int, input().split())
ans = 0
for r in range(N+1):
    for g in range(N+1):
        b =( N - R * r - G * g) // B
        if R *r + G * g + B * b == N and b >= 0:
            ans += 1
print(ans)


Fixed submission:
R, G, B, N = map(int, input().split())
ans = 0
for r in range((N//R)+1):
    for g in range((N//G)+1):
        v = R * r + G * g
        if v > N:
            break
        if (N - v) % B == 0:
            ans +=1 
        
print(ans)
Buggy python submission (verdict: Runtime Error):
    N, M = [int(n) for n in input().split()]
    X = sorted([int(n) for n in input().split()])
    if N>=M:
        print(0)
    else:
        dx = []
        for j in range(M-1):
            dx.append(X[j+1]-X[j])
        ans = sorted(dx, reverse=True)
        print(sum(ans[N-1:]))

Fixed submission:
N, M = map(int, input().split())
X = list(map(int, input().split()))
if N >= M:
    print(0)
    exit()
X.sort()
leng = []
for i in range(1, M):
    leng.append(X[i] - X[i-1])
ans = sorted(leng, reverse = True)
print(sum(ans[N - 1:]))
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
l = [0 for i in range(N - K + 1)]
for i in range(N - K + 1):
    l[i] = h[i + 2] - h[i]
print(min(l))

Fixed submission:
N, K = map(int, input().split())
h = [int(input()) for i in range(N)]
h.sort()
mini = 10**10
for i in range(N - K + 1):
    mini = min(mini, h[i+K-1] - h[i])
print(mini)
Buggy python submission (verdict: Runtime Error):
def gcd(x1, x2):
    if x2 == 0:
        return x1
    return gcd(x2, x1 % x2)

N, X = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
    print(abs(X-x[0]))
x.sort()
D = gcd(abs(X-x[0]), abs(X-x[1]))
for i in range(2, N):
    D = gcd(D, abs(X - x[i]))
print(D)

Fixed submission:
def gcd(x1, x2):
    if x2 == 0:
        return x1
    return gcd(x2, x1 % x2)

N, X = map(int, input().split())
x = list(map(int, input().split()))
if N == 1:
    print(abs(X - x[0]))
    exit()
x.sort()
D = gcd(abs(X-x[0]), abs(X-x[1]))
for i in range(2, N):
    D = gcd(D, abs(X - x[i]))
print(D)
Buggy python submission (verdict: Runtime Error):
def hantei(x):
    

N = int(input())
if N >= 105:
    print(1)
else:
    print(0)    

Fixed submission:
N = int(input())
ans = 0
for i in range(N + 1):
    if i % 2 == 0:
        continue
    c = 0
    for j in range(1, i + 1):
        if i % j == 0:
            c += 1
    if c == 8:
        ans += 1
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
a = list(map(int, input().split()))
a.sort()
i = N - 1
c = 0
while i >= 0:
    i = N -1
    while a[i] % 2 != 0:
        i -= 1
        if i < 0:
            print(c)
            exit()
    max_ = a[i] // 2
    a = list(map(lambda x: x * 3, a))
    a[i] = max_
    c += 1
    a.sort()

Fixed submission:
N = int(input())
a = list(map(int, input().split()))
c = 0
for i in range(N):
    while a[i] % 2 == 0:
        a[i] /= 2
        c += 1
print(c)
Buggy python submission (verdict: Runtime Error):
C = [list(map(int, input().split())) for i in range(3)]
x = [0,0,0]
y = []
for i in range(3):
    y.append(C[0][i] - x[0])
for i in range(3):
    x[i] = C[i][0] - y[0]

for i in range(3):
    for j in range(3):
        if x[i] + y[j] != C[i][j]:
            print('No')
            exit(1)
print('Yes')


Fixed submission:
C = [list(map(int, input().split())) for i in range(3)]
x = [0,0,0]
y = [0,0,0]
for i in range(3):
    y[i] = C[0][i] - x[0]
for i in range(3):
    x[i] = C[i][0] - y[0]
flag = True
for i in range(3):
    for j in range(3):
        if x[i] + y[j] != C[i][j]:
            flag = False
print('Yes' if flag else 'No')
Buggy python submission (verdict: Runtime Error):
N = int(input())
L = [2, 1]
for i in range(2, N+1):
    L.append(L[i - 1] + L[i - 2])
print(L[i])


Fixed submission:
N = int(input())
L = [2, 1]
for i in range(2, N+1):
    L.append(L[i - 1] + L[i - 2])
print(L[N])