Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
import math
k = int(input())

ans = 0
for a in range(1, k + 1):
    for b in range(1, k + 1):
        for c in range(1, k + 1):
            ans += math.gcd(math.gcd(a, b), c)

print(ans)

Fixed submission:
k = int(input())

import math

ans = 0
ans += 0.5*k*(k+1)
# print(ans)

for a in range(1, k):
    for b in range(a+1,k+1):
        n = math.gcd(a, b)
        ans += n*6
        for c in range(b+1, k+1):
            if c != b:
                ans += math.gcd(n, c)*6

# for i in range(1, k-1):
#     for j in range(i+1, k):
#         for k in range(j+1, k+1):
#             d = math.gcd(i, j)
#             ans += math.gcd(d, k)*6

print(int(ans))

Buggy python submission (verdict: Runtime Error):
import math

ans = 0
ans += 0.5*k*(k+1)
# print(ans)

for a in range(1, k):
    for b in range(a+1,k+1):
        n = math.gcd(a, b)
        ans += n*6
        # print(a, b, n)

for i in range(1, k-1):
    for j in range(i+1, k):
        for k in range(j+1, k+1):
            d = math.gcd(i, j)
            ans += math.gcd(d, k)*6
            # print(i, j, k)

        #
        #
        # for c in range(b+1, k+1):
        #     ans += math.gcd(n, c)*3
        # print(a, b, c)

print(int(ans))

Fixed submission:
k = int(input())

import math

ans = 0
ans += 0.5*k*(k+1)
# print(ans)

for a in range(1, k):
    for b in range(a+1,k+1):
        n = math.gcd(a, b)
        ans += n*6
        for c in range(b+1, k+1):
            if c != b:
                ans += math.gcd(n, c)*6

# for i in range(1, k-1):
#     for j in range(i+1, k):
#         for k in range(j+1, k+1):
#             d = math.gcd(i, j)
#             ans += math.gcd(d, k)*6

print(int(ans))
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())

def func(n, k):
    if n == k:
        return print(0)
    elif n > k:
        if n % k == 0:
            return print(0)
        else:
            func(n%k, k)
    else:
        if k % n == 0:
            print((k-n)//n)
        else:
            print(k//n)

func(n, k)

Fixed submission:
n, k = map(int, input().split())
m = n%k
print(min(m, abs(m-k)))
Buggy python submission (verdict: Runtime Error):
n, m = map(int, input().split())
print(n*(n-1)//2 + m*(m-1)//2a)

Fixed submission:
def combination(n, x, mod=10**9+7):
    # nCx, a=n!, b=x!, c=(n-x)!
    # ex) combination(5, 2) = 10
    _factorial = [1] * (n+1)
    tmp = 1
    for i in range(1, n+1):
        tmp = (tmp * i) % mod
        _factorial[i] = tmp

    tmp = _factorial[n]
    tmp = (tmp * pow(_factorial[x], mod-2, mod)) % mod
    tmp = (tmp * pow(_factorial[n-x], mod-2, mod)) % mod
    return tmp

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

if m > 1 and n > 1:
    M = combination(m, 2)
    N = combination(n, 2)
elif m <= 1 and n > 1:
    M = 0
    N = combination(n,2)
elif m > 1 and n <= 1:
    M = combination(m, 2)
    N = 0
else:
    M, N = 0, 0

print(M+N)
Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
al = list(map(int, input().split()))
c = Counter(al)

k = 0
for v in c.values():
    if v == 1:
        continue
    else:
        k += combinations_count(v, 2)

for a in al:
    if c[a] == 1:
        print(k)
    elif c[a] == 2:
        print(k-combinations_count(c[a], 2))
    else:
        print(k-combinations_count(c[a], 2)+combinations_count(c[a]-1,2))


Fixed submission:
from collections import Counter
from operator import mul
from functools import reduce


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


n = int(input())
al = list(map(int, input().split()))
c = Counter(al)

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

for a in al:
    if c[a] == 1:
        print(k)
    elif c[a] == 2:
        print(k-cmb(c[a], 2))
    else:
        print(k-cmb(c[a], 2)+cmb(c[a]-1,2))

Buggy python submission (verdict: Time Limit Exceeded):
from collections import Counter
import math


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n = int(input())
al = list(map(int, input().split()))
c = Counter(al)

k = 0
for v in c.values():
    if v == 1:
        continue
    else:
        k += combinations_count(v, 2)

for a in al:
    if c[a] == 1:
        print(k)
    elif c[a] == 2:
        print(k-combinations_count(c[a], 2))
    else:
        print(k-combinations_count(c[a], 2)+combinations_count(c[a]-1,2))


Fixed submission:
from collections import Counter
from operator import mul
from functools import reduce


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


n = int(input())
al = list(map(int, input().split()))
c = Counter(al)

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

for a in al:
    if c[a] == 1:
        print(k)
    elif c[a] == 2:
        print(k-cmb(c[a], 2))
    else:
        print(k-cmb(c[a], 2)+cmb(c[a]-1,2))
Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = int(input())
head = []
tail = []

cnt = 0
for _ in range(n):
    li = list(input().split())
    if li[0] == '1':
        head, tail = tail, head
        s = s[::-1]
        cnt += 1
    else:
        if li[1] == '1':
            head += li[2]
        else:
            tail += li[2]

ans = head[::-1] + s + tail
print(*ans , sep='')

Fixed submission:
s = list(input())
n = int(input())
head = []
tail = []

cnt = 0
for _ in range(n):
    li = list(input().split())
    if li[0] == '1':
        head, tail = tail, head
        cnt += 1
    else:
        if li[1] == '1':
            head += li[2]
        else:
            tail += li[2]

if cnt % 2 != 0:
    s = s[::-1]
    
ans = head[::-1] + s + tail
print(*ans , sep='')

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = int(input())
head = []
tail = []

cnt = 0
for _ in range(n):
    li = list(input().split())
    if li[0] == '1':
        head, tail = tail, head
        s = s[::-1]
        cnt += 1
    else:
        if li[1] == '1':
            head.append(li[2])
        else:
            tail.append(li[2])

ans = head[::-1] + s + tail
print(*ans , sep='')

Fixed submission:
s = list(input())
n = int(input())
head = []
tail = []

cnt = 0
for _ in range(n):
    li = list(input().split())
    if li[0] == '1':
        head, tail = tail, head
        cnt += 1
    else:
        if li[1] == '1':
            head += li[2]
        else:
            tail += li[2]

if cnt % 2 != 0:
    s = s[::-1]
    
ans = head[::-1] + s + tail
print(*ans , sep='')

Buggy python submission (verdict: Time Limit Exceeded):
s = list(input())
n = int(input())
head = []
tail = []

cnt = 0
for _ in range(n):
    li = list(input().split())
    if li[0] == '1':
        head, tail = tail, head
        s = s[::-1]
        cnt += 1
    else:
        if li[1] == '1':
            head.append(li[2])
        else:
            tail.append(li[2])

ans = head[::-1] + s + tail
print(*ans , sep='')

Fixed submission:
s = list(input())
n = int(input())
head = []
tail = []

cnt = 0
for _ in range(n):
    li = list(input().split())
    if li[0] == '1':
        head, tail = tail, head
        cnt += 1
    else:
        if li[1] == '1':
            head += li[2]
        else:
            tail += li[2]

if cnt % 2 != 0:
    s = s[::-1]
    
ans = head[::-1] + s + tail
print(*ans , sep='')
Buggy python submission (verdict: Runtime Error):
h, n = map(int, input().split())
al = list(map(int, input().split()))
al_s = sorted(al, reverse=True)

if al_s[0] + al_s[1] >= h:
    print('Yes')
else:
    print('No')



Fixed submission:
h, n = map(int, input().split())
al = list(map(int, input().split()))
al_s = sorted(al, reverse=True)

count = 0
for a in al_s:
    h -= a

if h <= 0:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
hl = list(map(int, input().split()))
hl_s = sorted(hl, reverse=True)

if k >= n:
    print(0)
else:
    for _ in range(k):
        hl_s.pop(0)
    print(sum(hl_s))

Fixed submission:
n, k = map(int, input().split())
hl = list(map(int, input().split()))
hl_s = sorted(hl, reverse=True)

if k >= n:
    print(0)
else:
    del hl_s[0:k]
    print(sum(hl_s))
Buggy python submission (verdict: Runtime Error):
if (a + b) > k:
    if a < k:
        b = b - (k - a)
        a = 0
    else:
        a = k - a
else:
    a, b = 0, 0

print(a, b)

Fixed submission:
a, b, k = map(int, input().split())

if (a + b) >= k:
    if a >= k:
        a = a - k
    else:
        b = b - (k-a)
        a = 0
else:
    a, b = 0, 0

print(a, b)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
al = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
    print(al.index(i) + 1)

Fixed submission:
n = int(input())
al = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
    ans[al[i] - 1] = i + 1
print(*ans)

Buggy python submission (verdict: Runtime Error):
n = int(input())
al = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
    print(index(i) + 1)

Fixed submission:
n = int(input())
al = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
    ans[al[i] - 1] = i + 1
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
al = list(map(int, input().split()))
ans = []
for i in range(1, n+1):
    ans.append(al.index(i) + 1)
print(*ans)

Fixed submission:
n = int(input())
al = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
    ans[al[i] - 1] = i + 1
print(*ans)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
words = []
cnt = 0
for _ in range(n):
    s = list(input())
    ss = sorted(s)

    if ss in words:
       cnt += words.count(ss)
    words.append(ss)

print(cnt)

Fixed submission:
n = int(input())
ss = list(''.join(sorted(list(input()))) for _ in range(n))
words = {}
cnt = 0

for s in ss:
    if s in words:
        cnt += words[s]
        words[s] += 1
    else:
        words[s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
words = []
cnt = 0
for _ in range(n):
    s = list(input())
    ss = sorted(s)

    if ss in words:
       cnt += words.count(ss)
    words.append(ss)

print(cnt)

Fixed submission:
n = int(input())
ss = list(''.join(sorted(list(input()))) for _ in range(n))
words = {}
cnt = 0

for s in ss:
    if s in words:
        cnt += words[s]
        words[s] += 1
    else:
        words[s] = 1
print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
s = []
count = 0
for _ in range(n):
    si = input()
    tmp_list = []
    tmp_list_s = []

    for i in range(10):
        tmp_list.append(si[i])

    tmp_list_s = sorted(tmp_list)

    if tmp_list_s in s:
        count += s.count(tmp_list_s)
    s.append(tmp_list_s)

print(count)


Fixed submission:
n = int(input())
ss = list(''.join(sorted(list(input()))) for _ in range(n))
words = {}
cnt = 0

for s in ss:
    if s in words:
        cnt += words[s]
        words[s] += 1
    else:
        words[s] = 1
print(cnt)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
al = [int(input()) for _ in range(n)]

for i in range(n):
    tmp = al[:i] + al[i+1:]
    print(max(tmp))

Fixed submission:
n = int(input())
al = list(int(input()) for _ in range(n))
al_s = sorted(list(set(al)), reverse=True)

if al.count(al_s[0]) == 1:
    for a in al:
        if a != al_s[0]:
            print(al_s[0])
        else:
            print(al_s[1])
else:
    for i in range(n):
        print(al_s[0])
Buggy python submission (verdict: Time Limit Exceeded):
l, r = map(int, input().split())
m = 2019

flg = False
for i in range(l, r):
    for j in range(l+1, r+1):
        if i*j%2019 == 0:
            flg = True
            break
        elif i*j%2019 < m:
            m = i*j%2019

if flg == True:
    print(0)
else:
    print(m)

Fixed submission:
l, r = map(int, input().split())

if (r-l)//2019 >= 1:
    print(0)
else:
    ans = float('inf')
    for i in range(l, r+1):
        for j in range(l, r+1):
            if i != j:
                ans = min(ans, (i*j)%2019)

    print(ans)
Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

cd_gcd = math.gcd(c, d)
cd_lcm = c * d // cd_gcd

ans = (b - a + 1) - (b - a -1)//c - (b - a -1)//d + (b - a -1)//cd_lcm
print(ans)

Fixed submission:
# import math
from fractions import gcd

a, b, c, d = map(int, input().split())

cd_lcm = c * d // gcd(c, d)

x1 = b//c - (a-1)//c
x2 = b//d - (a-1)//d
x3 = b//cd_lcm - (a-1)//cd_lcm

print((b-(a-1))-x1-x2+x3)

Buggy python submission (verdict: Runtime Error):
import math

a, b, c, d = map(int, input().split())

cd_gcd = math.gcd(c, d)
cd_lcm = c * d // cd_gcd

ans = (b - a) - (b - a)//c - (b - a)//d + (b - a)//cd_lcm
print(ans)

Fixed submission:
# import math
from fractions import gcd

a, b, c, d = map(int, input().split())

cd_lcm = c * d // gcd(c, d)

x1 = b//c - (a-1)//c
x2 = b//d - (a-1)//d
x3 = b//cd_lcm - (a-1)//cd_lcm

print((b-(a-1))-x1-x2+x3)
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n, m = map(int, input().split())
lrl = list(list(map(int, input().split())) for _ in range(m))
idl = np.array([0]*n)

for lr in lrl:
    idl[lr[0]-1:lr[1]] += 1

print(np.sum(idl == m))

Fixed submission:
n, m = map(int, input().split())
lrl = list(list(map(int, input().split())) for _ in range(m))
lmax = 0
rmin = n

for lr in lrl:
    if lr[0] > lmax:
        lmax = lr[0]
    if lr[1] < rmin:
        rmin = lr[1]
if lmax <= rmin:
    print(rmin-lmax+1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lrl = list(list(map(int, input().split())) for _ in range(m))
idl = [0]*n

for lr in lrl:
    for i in range(lr[0]-1, lr[1]):
        idl[i] += 1

print(idl.count(m))




Fixed submission:
n, m = map(int, input().split())
lrl = list(list(map(int, input().split())) for _ in range(m))
lmax = 0
rmin = n

for lr in lrl:
    if lr[0] > lmax:
        lmax = lr[0]
    if lr[1] < rmin:
        rmin = lr[1]
if lmax <= rmin:
    print(rmin-lmax+1)
else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
n, m = map(int, input().split())
lrl = list(list(map(int, input().split())) for _ in range(m))
idl = [0]*n
count = 0

for lr in lrl:
    for i in range(lr[0]-1, lr[1]):
        idl[i] += 1

for i in idl:
    if i == m:
        count += 1

print(count)



Fixed submission:
n, m = map(int, input().split())
lrl = list(list(map(int, input().split())) for _ in range(m))
lmax = 0
rmin = n

for lr in lrl:
    if lr[0] > lmax:
        lmax = lr[0]
    if lr[1] < rmin:
        rmin = lr[1]
if lmax <= rmin:
    print(rmin-lmax+1)
else:
    print(0)
Buggy python submission (verdict: Runtime Error):
s = input()
aa = int(s[:2])
bb = int(s[2:])

if 0<aa and aa<=12:
  if 0<bb and bb<=12:
    print('AMBIGUOUS')
  elif bb==0:
    print('NA')
  else:
    print('MMYY')
elif aa!=0:
  0<bb and bb<=12:
  print('YYMM')
else:
  print('NA')


Fixed submission:
s = input()
aa = int(s[:2])
bb = int(s[2:])

if 0<aa and aa<=12:
  if 0<bb and bb<=12:
    print('AMBIGUOUS')
  else:
    print('MMYY')
else:
  if 0<bb and bb<=12:
    print('YYMM')
  else:
    print('NA')
Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        k = (n - i*r - j*g)
        if k >= 0 and k % b == 0:
            cnt += 1
            # print(i, j, k)

print(cnt)

Fixed submission:
r, g, b, n = map(int, input().split())

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        k = (n - i*r - j*g)
        if k >= 0 and k % b == 0:
            cnt += 1
            # print(i, j, k)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
r, g, b, n = map(int, input().split())

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        k = (n - i*r - j*g)//b
        if 0 <= k <= n//b + 1 and i*r + j*g + k*b == n:
            cnt += 1
            # print(i, j, k)

print(cnt)

Fixed submission:
r, g, b, n = map(int, input().split())

cnt = 0
for i in range(n//r + 1):
    for j in range(n//g + 1):
        k = (n - i*r - j*g)
        if k >= 0 and k % b == 0:
            cnt += 1
            # print(i, j, k)

print(cnt)
Buggy python submission (verdict: Runtime Error):
a = [int(input()) for _ in range(5)]
delta = []
time = 0

for i in range(5):
    a10 = 0
    if str(a[i])[-1] != '0':
        a10 = (10 - int(str(a[i])[-1]))
        delta.append(a10)
    time += a[i] + a10


print(time-max(delta))


Fixed submission:
a = [int(input()) for _ in range(5)]
delta = []
time = 0
count = 0

for i in range(5):
    a10 = 0
    if str(a[i])[-1] != '0':
        a10 = (10 - int(str(a[i])[-1]))
        delta.append(a10)
        count += 0
    time += a[i] + a10

if count == 0:
    delta.append(0)

print(time-max(delta))
Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
ll = list(list(map(int, input().split())) for _ in range(q))

for i in range(q):
    l = ll[i][0]
    r = ll[i][1]
    print(s[l-1:r].count('AC'))


Fixed submission:
n, q = map(int, input().split())
s = input()
ll = list(list(map(int, input().split())) for _ in range(q))

acl = [0] * n
cnt = 0
for i in range(1, n):
    if s[i-1:i+1] == 'AC':
        cnt += 1
    acl[i] = cnt

for i in range(q):
    l = ll[i][0]
    r = ll[i][1]
    print(acl[r-1] - acl[l-1])

Buggy python submission (verdict: Time Limit Exceeded):
n, q = map(int, input().split())
s = input()
l = [list(map(int, input().split())) for _ in range(q)]

for i in range(q):
    st = l[i][0]-1
    en = l[i][1]
    print(s[st:en].count('AC'))



Fixed submission:
n, q = map(int, input().split())
s = input()
ll = list(list(map(int, input().split())) for _ in range(q))

acl = [0] * n
cnt = 0
for i in range(1, n):
    if s[i-1:i+1] == 'AC':
        cnt += 1
    acl[i] = cnt

for i in range(q):
    l = ll[i][0]
    r = ll[i][1]
    print(acl[r-1] - acl[l-1])
Buggy python submission (verdict: Time Limit Exceeded):
s = input()
n = len(s)
flag = True
while flag:
    n1 = len(s)
    s = s.replace('01', '')
    s = s.replace('10', '')
    n2 = len(s)
    if n1 > n2:
        continue
    else:
        flag = False
        break

print(n-len(s))





Fixed submission:
s = input()

c0 = s.count('0')
c1 = s.count('1')

print(min(c0, c1)*2)
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
h = list(map(int, input().split()))

cost = [1001001001] * n
cost[0] = 0

for i in range(n):
    if i < n-k:
        for j in range(i+1, i+k+1):
            cost[j] = min(cost[j], cost[i] + abs(h[i] - h[j]))
    else:
        for j in range(i, n):
            cost[j] = min(cost[j], cost[i] + abs(h[i] - h[j]))

print(cost[-1])




Fixed submission:
n, k = map(int, input().split())
h = list(map(int, input().split()))

cost = [1001001001] * n
cost[0] = 0

for i in range(n):
    if i < n-k:
        for j in range(i+1, i+k+1):
            cost[j] = min(cost[j], cost[i] + abs(h[i] - h[j]))
    else:
        for j in range(i, n):
            cost[j] = min(cost[j], cost[i] + abs(h[i] - h[j]))

print(cost[-1])
Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]

hl_s = sorted(hl, reverse=True)
delta = 10*10**9

if n > 1000:
    while n < 1000:
        if hl_s[n//2] < (hl_s[0] + hl_s[n-1])//2:
            hl_s = hl_s[:n//2]
        else:
            hl_s = hl_s[n//2:]
        n = len(hl_s)

for i in range(len(hl_s)-k+1):
    h_max = max(hl_s[i:i+k])
    h_min = min(hl_s[i:i+k])
    if delta > (h_max - h_min):
        delta = h_max - h_min
    if delta == 0:
        break

print(delta)

Fixed submission:
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
hl.sort()

h_min = min(hl[i+k-1] - hl[i] for i in range(n-k+1))
print(h_min)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
delta = 10*10**9

hl_s = sorted(hl, reverse=True)

if n > 1000:
    if hl_s[n//2] > (hl_s[0] + hl_s[n])//2: #中央値＞平均値
        hl_s = hl_s[:n//2]
    else:
        hl_s = hl_s[n//2:]

for i in range(len(hl_s)-k+1):
    h_max = max(hl_s[i:i+k])
    h_min = min(hl_s[i:i+k])
    if delta > (h_max - h_min):
        delta = h_max - h_min
    if delta == 0:
        break

print(delta)

Fixed submission:
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
hl.sort()

h_min = min(hl[i+k-1] - hl[i] for i in range(n-k+1))
print(h_min)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
delta = 10*10**9

hl_s = sorted(hl, reverse=True)

if n > 10000:
    if hl_s[n//2] > (hl_s[0] + hl_s[n])//2: #中央値＞平均値
        hl_s = hl_s[:n//2]
    else:
        hl_s = hl_s[n//2:]

for i in range(len(hl_s)-k+1):
    h_max = max(hl_s[i:i+k])
    h_min = min(hl_s[i:i+k])
    if delta > (h_max - h_min):
        delta = h_max - h_min
    if delta == 0:
        break

print(delta)


Fixed submission:
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
hl.sort()

h_min = min(hl[i+k-1] - hl[i] for i in range(n-k+1))
print(h_min)

Buggy python submission (verdict: Time Limit Exceeded):
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]

hl_s = sorted(hl, reverse=True)
delta = 10*10**9

for i in range(n-k+1):
    h_max = max(hl_s[i:i+k])
    h_min = min(hl_s[i:i+k])
    if delta > (h_max - h_min):
        delta = h_max - h_min
    if delta == 0:
        break

print(delta)

Fixed submission:
n, k = map(int, input().split())
hl = [int(input()) for _ in range(n)]
hl.sort()

h_min = min(hl[i+k-1] - hl[i] for i in range(n-k+1))
print(h_min)
Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
xlst = list(map(int, input().split()))

for i in range(n):
    x_ = xlst.copy()
    x_.pop(i)
    x_.sort(reverse=True)
    print(x_[n//2-1])


Fixed submission:
n = int(input())
xl = list(map(int, input().split()))
xl_s = sorted(xl)

l = xl_s[n//2-1]
r = xl_s[n//2]

for x in xl:
    if x >= r:
        print(l)
    else:
        print(r)
Buggy python submission (verdict: Time Limit Exceeded):
a, b, k = map(int, input().split())

l = []
for i in range(a, b+1):
    l.append(i)
ans = sorted(list(set(l[:k] + l[-k:])))
for a in ans:
    print(a)



Fixed submission:
a, b, k = map(int, input().split())

if b-a>=2*k:
    for i in range(a, a+k):
        print(i)

    for j in range(b-k+1, b+1):
        print(j)
else:
    for n in range(a, b+1):
        print(n)