Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

INF = 10 ** 10
def main():
    N, M = map(int, input().split())

    dp = [[INF] * N for _ in range(N)]
    edges = []
    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        dp[a][b] = c
        dp[b][a] = c
        edges.append((a, b, c))
        
    for i in range(N):
        dp[i][i] = 0

    for m in range(N):
        for s in range(N):
            for e in range(N):
                if dp[s][m] != INF and dp[m][e] != INF:
                    dp[s][e] = min(dp[s][e], dp[s][m] + dp[m][e])

    ans = 0
    for a, b, c in edges:
        found = False
        for s in range(N):
            for e in range(N):
                if dp[s][a] + c + dp[b][e] == dp[s][e]:
                    found = True
                    break
            if found:
                break
        if not found:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict

INF = 10 ** 10
def main():
    N, M = map(int, input().split())

    dp = [[INF] * N for _ in range(N)]
    edges = []
    for i in range(M):
        a, b, c = map(int, input().split())
        a -= 1
        b -= 1
        dp[a][b] = c
        dp[b][a] = c
        edges.append((a, b, c))

    for i in range(N):
        dp[i][i] = 0

    for m in range(N):
        for s in range(N):
            for e in range(N):
                if dp[s][m] != INF and dp[m][e] != INF:
                    dp[s][e] = min(dp[s][e], dp[s][m] + dp[m][e])

    ans = 0
    for a, b, c in edges:
        for s in range(N):
            if dp[s][a] + c == dp[s][b]:
                break
        else:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict

MOD = 10 ** 9 + 7
def main():
    N = int(input())
    A_list = list(sorted(list(map(int, input().split()))))

    num_of_zero = A_list.count(0)
    if N % 2 == 0:
        if num_of_zero != 0:
            print(0)
            return
    else:
        if num_of_zero != 1:
            print(0)
            return
    for i in range(N - 1, 0, -2):
        if A_list.count(i) != 2:
            print(0)
            return

    print(pow(2, (N // 2), MOD))

if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict
from collections import Counter

MOD = 10 ** 9 + 7
def main():
    N = int(input())
    c = Counter(list(map(int, input().split())))

    if N % 2 == 0 and c[0] != 0:
        print(0)
        return
    if N % 2 != 0 and c[0] != 1:
        print(0)
        return
    for i in range(N - 1, 0, -2):
        if c[i] != 2:
            print(0)
            return

    print(pow(2, (N // 2), MOD))

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict


memo = {}


def dfs(s):
    tuple_s = tuple(s)
    if tuple_s in memo:
        return memo[tuple_s]

    if s.count("B") == len(s) or s.count("W") == len(s):
        return 0

    ans = 10 ** 20
    stone = s[0]
    t = s[:]
    while t[0] == stone:
        t = t[1:]
    ans = min(ans, dfs(t) + 1)

    stone = s[-1]
    t = s[:]
    while t[-1] == stone:
        t = t[:-1]
    ans = min(ans, dfs(t) + 1)

    memo[tuple_s] = ans
    return ans


def main():
    s = input()
    print(dfs(list(s)))


if __name__ == '__main__':
    main()


Fixed submission:

def main():
    S = input()

    t = S[0]
    for i in range(1, len(S)):
        if t[-1] != S[i]:
            t += S[i]
    print(len(t) - 1)

if __name__ == '__main__':
    main()

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


def dfs(s):
    if s.count("B") == len(s) or s.count("W") == len(s):
        return 0

    ans = 10 ** 20
    stone = s[0]
    t = s[:]
    while t[0] == stone:
        t = t[1:]
    ans = min(ans, dfs(t) + 1)

    stone = s[-1]
    t = s[:]
    while t[-1] == stone:
        t = t[:-1]
    ans = min(ans, dfs(t) + 1)

    return ans


def main():
    s = input()
    print(dfs(list(s)))


if __name__ == '__main__':
    main()


Fixed submission:

def main():
    S = input()

    t = S[0]
    for i in range(1, len(S)):
        if t[-1] != S[i]:
            t += S[i]
    print(len(t) - 1)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict
from itertools import count


def main():
    n = int(input())
    A, B = map(int, input().split())
    for _ in range(n - 1):
        t, a = map(int, input().split())
        for n in count(1):
            if n * t >= A and n * a >= B:
                A, B = n * t, n * a
                break
    print(A + B)


if __name__ == '__main__':
    main()


Fixed submission:
import math
from decimal import Decimal


def main():
    N = int(input())
    t, a = 1, 1
    for _ in range(N):
        _t, _a = map(int, input().split())
        n = Decimal(max(math.ceil(t / _t), math.ceil(a / _a)))
        t, a = _t * n, _a * n

    print(t + a)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):


# all_split("abc") -> [['abc'], ['ab', 'c'], ['a', 'bc'], ['a', 'b', 'c']]
def all_split(s):
    ans = []
    for i in range(2 ** (len(s) - 1)):
        b = list(map(int, format(i, "0" + str(len(s) - 1) + "b")))
        ans.append(split(s, b))
    return ans


def split(s, split_positions):
    assert len(s) - 1 == len(split_positions)

    ans = []
    pre = 0
    for i, is_split in enumerate(split_positions, start=1):
        if is_split:
            ans.append(s[pre:i])
            pre = i

    ans.append(s[pre:])
    return ans


def main():
    s = input()
    ans = 0
    for a in all_split(s):
        ans += eval("+".join(a))
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:


# all_split("abc") -> [['abc'], ['ab', 'c'], ['a', 'bc'], ['a', 'b', 'c']]
def all_split(s):
    if len(s) == 1:
        return [s]
    
    ans = []
    for i in range(2 ** (len(s) - 1)):
        b = list(map(int, format(i, "0" + str(len(s) - 1) + "b")))
        ans.append(split(s, b))
    return ans


def split(s, split_positions):
    assert len(s) - 1 == len(split_positions)

    ans = []
    pre = 0
    for i, is_split in enumerate(split_positions, start=1):
        if is_split:
            ans.append(s[pre:i])
            pre = i

    ans.append(s[pre:])
    return ans


def main():
    s = input()
    ans = 0
    for a in all_split(s):
        ans += eval("+".join(a))
    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = 10 ** 10


def main():
    A, B, C = map(int, input().split())
    ans = INF
    for a1 in range(1, A):
        a2 = A - a1
        ans = min(ans, abs(a1 * B * C - a2 * B * C))
    for b1 in range(1, B):
        b2 = B - b1
        ans = min(ans, abs(A * b1 * C - A * b2 * C))
    for c1 in range(1, C):
        c2 = C - c1
        ans = min(ans, abs(A * B * c1 - A * B * c2))

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
INF = float("inf")


def main():
    A, B, C = map(int, input().split())

    ans = INF
    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        ans = 0

    ans = min(ans, B * C)
    ans = min(ans, A * C)
    ans = min(ans, A * B)

    print(ans)


if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def f(b, n):
    if n < b:
        return n
    return f(b, n // b) + n % b


def main():
    N = int(input())
    S = int(input())

    if N < S:
        print(-1)
        return

    ans = INF
    for b in range(2, int(sqrt(N)) + 1):
        if f(b, N) == S:
            ans = min(ans, b)

    bs = set()
    t = N - S
    for i in range(1, int(sqrt(t)) + 5):
        if t % i == 0:
            bs.add(i)
            bs.add(t // i)
    bs.add(N)
    bs.add(N + 1)

    for b in bs:
        if b == 1:
            continue
        if f(b, N) == S:
            ans = min(ans, b)

    if ans == INF:
        print(-1)
    else:
        print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
from math import floor, sqrt
INF = 10 ** 20


def f(b, n):
    if n < b:
        return n
    else:
        return f(b, n // b) + (n % b)


def main():
    n = int(input())
    s = int(input())

    ans = INF
    # 1桁
    if n == s:
        ans = min(ans, n + 1)

    # 2桁
    for p in range(1, int(sqrt(n)) + 1):
        q = s - p
        b = (n - q) // p
        if 2 <= b and f(b, n) == s:
            ans = min(ans, b)

    # 3桁以上
    for b in range(2, int(sqrt(n)) + 1):
        if f(b, n) == s:
            ans = min(ans, b)

    print(-1 if ans == INF else ans)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Runtime Error):
import bisect
def main():
  X, N = map(int, input().split())
  if N == 0:
    print(X)
    return
  P = set(map(int, input().split()))

  NP = sorted(list(set(range(101)) - P))
  right = bisect.bisect(NP, X)
  left = right - 1
  if abs(X - NP[left]) <= abs(X - NP[right]):
    print(NP[left])
  else:
    print(NP[right])
    
main()

Fixed submission:
import bisect
def main():
  X, N = map(int, input().split())
  if N == 0:
    print(X)
    return
  P = set(map(int, input().split()))

  NP = sorted(list(set(range(102)) - P))
  right = bisect.bisect(NP, X)
  left = right - 1
  if left == -1 or abs(X - NP[left]) > abs(X - NP[right]):
    print(NP[right])
  else:
    print(NP[left])

main()
Buggy python submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
  ans *= i
  if ans > 1e18:
  	print(-1)
    return
  
if ans > 1e18:
  print(-1)
else:
  print(ans)


Fixed submission:
def solve():
  ans = 1
  if 0 in A:
    return 0
  for i in A:
    ans *= i
    if ans > 1e18:
      return -1
  return ans


N = int(input())
A = list(map(int, input().split()))
print(solve())

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 1
for i in A:
  ans *= i
if ans > 1e18:
  print(-1)
else:
  print(ans)

Fixed submission:
def solve():
  ans = 1
  if 0 in A:
    return 0
  for i in A:
    ans *= i
    if ans > 1e18:
      return -1
  return ans


N = int(input())
A = list(map(int, input().split()))
print(solve())
Buggy python submission (verdict: Runtime Error):
A, B = map(int, input().split())
print((A*(B*100))//100)

Fixed submission:
A, B = input().split()
A = int(A)
B = float(B)
print(int(A*int(round(B*100))//100))
Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
jufuku = 0
if x == 0 and y == 0:
    if y / x == H / W:
        naname = W * H / 2
        jufuku = 1
        kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)


Fixed submission:
W, H, x, y = map(int, input().split())
jufuku = 0
if W / 2 == x and H / 2 == y:
    jufuku = 1
print(W * H / 2, jufuku)

Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
jufuku = 0
if (x == 0 and y == 0) or y / x == H / W:
    naname = W * H / 2
    jufuku = 1
    kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)


Fixed submission:
W, H, x, y = map(int, input().split())
jufuku = 0
if W / 2 == x and H / 2 == y:
    jufuku = 1
print(W * H / 2, jufuku)

Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(int, input().split())
jufuku = 0
if y / x == H / W:
    naname = W * H / 2
    jufuku = 1
    kiri = naname
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    kiri = max(tate, yoko)
print(kiri, jufuku)


Fixed submission:
W, H, x, y = map(int, input().split())
jufuku = 0
if W / 2 == x and H / 2 == y:
    jufuku = 1
print(W * H / 2, jufuku)

Buggy python submission (verdict: Runtime Error):
W, H, x, y = map(float, input().split())
jufuku = 0
if W % x == 0 and H % y == 0:
    kiri = W * H / 2
    jufuku = 1
else:
    # 縦
    tate = min((W - x) * H, x * H)
    # 横
    yoko = min(W * (H - y), W * y)
    if tate == yoko:
        jufuku = 1
    else:
        kiri = max(tate, yoko)
print(kiri, jufuku)

Fixed submission:
W, H, x, y = map(int, input().split())
jufuku = 0
if W / 2 == x and H / 2 == y:
    jufuku = 1
print(W * H / 2, jufuku)
Buggy python submission (verdict: Runtime Error):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
D = []
for _ in range(M):
    b, c = map(int, input().split())
    for i in range(b):
        D.append(c)
D.sort(reverse=True)
for i in range(len(A)):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break
print(sum(A))


Fixed submission:
def cD():
    D = []
    for bc in BC:
        for i in range(bc[1]):
            D.append(bc[0])
            if len(D) > N:
                return D
    return D


N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append([c, b])
BC.sort(reverse=True)
D = cD()
for i in range(min(len(A), len(D))):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break
print(sum(A))

Buggy python submission (verdict: Time Limit Exceeded):
N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = [list(map(int, input().split())) for _ in range(M)]

for bc in BC:
    f = True
    for i in range(bc[0]):
        if A[i] > bc[1]:
            f = False
    if f:
        for i in range(bc[0]):
            A[i] = bc[1]
    A.sort()
print(sum(A))


Fixed submission:
def cD():
    D = []
    for bc in BC:
        for i in range(bc[1]):
            D.append(bc[0])
            if len(D) > N:
                return D
    return D


N, M = map(int, input().split())
A = sorted(list(map(int, input().split())))
BC = []
for _ in range(M):
    b, c = map(int, input().split())
    BC.append([c, b])
BC.sort(reverse=True)
D = cD()
for i in range(min(len(A), len(D))):
    if A[i] < D[i]:
        A[i] = D[i]
    else:
        break
print(sum(A))
Buggy python submission (verdict: Runtime Error):
import math
ae = [int(input()) for _ in range(5)]
min_ae = 9
num = 0
for a in ae:
    s = str(a)
    if s[-1] == "0":
        pass
    else:
        min_ae = min(int(s[-1]), min_ae)
    if min_ae==int(s[-1]):
        num = a
ae.remove(num)
ceil_ae = [math.ceil(a/10)*10 for a in ae]
print(num + sum(ceil_ae))


Fixed submission:
import math
ae = [int(input()) for _ in range(5)]
if all([a%10==0 for a in ae]):
    min_ae = 0
else:
    min_ae = 9
num = 0
for a in ae:
    s = str(a)
    if s[-1] == "0":
        pass
    else:
        min_ae = min(int(s[-1]), min_ae)
    if min_ae==int(s[-1]):
        num = a
ae.remove(num)
ceil_ae = [math.ceil(a/10)*10 for a in ae]
print(num + sum(ceil_ae))
Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A[:K]:
    for b in B[:K]:
        AB.append(a + b)
AB.sort(reverse=True)

ABC = []
for ab in AB[:K]:
    for c in C[:K]:
        ABC.append(ab + c)
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)


Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = [a + b for a in A for b in B]
AB.sort(reverse=True)
ABC = [ab + c for ab in AB[:K] for c in C[:K]]
ABC.sort(reverse=True)
[print(abc) for abc in ABC[:K]]

Buggy python submission (verdict: Time Limit Exceeded):
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = []
for a in A:
    for b in B:
        AB.append(a + b)
AB.sort(reverse=True)

ABC = []
for ab in AB[:K]:
    for c in C[:K]:
        ABC.append(ab + c)
ABC.sort(reverse=True)

for abc in ABC[:K]:
    print(abc)

Fixed submission:
X, Y, Z, K = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse=True)
B = sorted(list(map(int, input().split())), reverse=True)
C = sorted(list(map(int, input().split())), reverse=True)

AB = [a + b for a in A for b in B]
AB.sort(reverse=True)
ABC = [ab + c for ab in AB[:K] for c in C[:K]]
ABC.sort(reverse=True)
[print(abc) for abc in ABC[:K]]
Buggy python submission (verdict: Runtime Error):
import re

rexp = re.compile("AC")

N, Q = map(int, input().split())
S = input()
ruiseki_S = [""]
for i in range(N):
    ruiseki_S.append(ruiseki_S[i] + S[i])
for i in range(Q):
    l, r = map(int, input().split())
    a = ruiseki_S[r].replace(ruiseki_S[l - 1], "", 1)
    print(len(rexp.findall(a)))


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == "AC" else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
import re

rexp = re.compile("AC")

N, Q = map(int, input().split())
S = input()
ruiseki_S = [""]
for i in range(N):
    ruiseki_S.append(ruiseki_S[i] + S[i])
for i in range(Q):
    l, r = map(int, input().split())
    a = ruiseki_S[r].replace(ruiseki_S[l - 1], "", 1)
    print(len(rexp.findall(a)))


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == "AC" else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
import re
rexp = re.compile("AC")
N, Q = map(int, input().split())
S = input()
for _ in range(Q):
    l, r = map(int, input().split())
    s = S[l-1:r]
    print(len(rexp.findall(s)))


Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == "AC" else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])

Buggy python submission (verdict: Time Limit Exceeded):
N, Q = map(int, input().split())
S = input()
for _ in range(Q):
    l, r = map(int, input().split())
    s = S[l-1:r]
    print(s.count("AC"))

Fixed submission:
N, Q = map(int, input().split())
S = input()
t = [0] * (N + 1)
for i in range(N):
    t[i + 1] = t[i] + (1 if S[i : i + 2] == "AC" else 0)
for i in range(Q):
    l, r = map(int, input().split())
    print(t[r - 1] - t[l - 1])
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a_list = list(map(int, input().split()))
num = a_list[0]

for i in range(n):
    num = math.gcd(num, a_list[i])
print(num)

Fixed submission:
a, b = map(int, input().split())
if b % a == 0:
    print(a+b)
else:
    print(b-a)
Buggy python submission (verdict: Runtime Error):
import math
n = int(input())
a_list = list(map(int, input().split()))
num = a_list[0]

for i in range(n):
    num = math.gcd(num, a_list[i])
print(num)

Fixed submission:
import fractions
n = int(input())
a_list = list(map(int, input().split()))
num = a_list[0]

for i in range(n):
    num = fractions.gcd(num, a_list[i])
print(num)

Buggy python submission (verdict: Runtime Error):
n = int(input())
a_list = list(map(int, input().split()))
num = a_list[0]

for i in range(n):
    num = math.gcd(num, a_list[i])
print(num)

Fixed submission:
import fractions
n = int(input())
a_list = list(map(int, input().split()))
num = a_list[0]

for i in range(n):
    num = fractions.gcd(num, a_list[i])
print(num)
Buggy python submission (verdict: Time Limit Exceeded):
k, a, b = map(int, input().split())
maisu = 1
if b - a <= 2:
    maisu += k
else:
    while True:
        if k >= 2 and maisu >= a:
            maisu += b-a
            k -= 2
        else:
            k-= 1
            maisu += 1
        if k == 0:
            break
print(maisu)

Fixed submission:
k, a, b = map(int, input().split())
maisu = 1
if b - a <= 2:
    maisu += k
else:
    cc = (k - (a-1))//2
    maisu += (b-a)*cc
    maisu += k-2*cc
print(maisu)
Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
min = h[k-1] - h[0]
for i in range(len(h)-k+1):
    dif = h[i+k-1] - h[i]
    if t < min:
        min = t
print(min)


Fixed submission:
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
min = h[k-1] - h[0]
for i in range(len(h)-k+1):
    dif = h[i+k-1] - h[i]
    if dif < min:
        min = dif
print(min)

Buggy python submission (verdict: Runtime Error):
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
min = '100000'
for i in range(len(h)-k+1):
    if h[i+k-1] - h[i] < min:
        min = h[i+k-1] - h[i]
print(min)


Fixed submission:
n, k = map(int, input().split())
h = [int(input()) for _ in range(n)]
h.sort()
min = h[k-1] - h[0]
for i in range(len(h)-k+1):
    dif = h[i+k-1] - h[i]
    if dif < min:
        min = dif
print(min)
Buggy python submission (verdict: Runtime Error):
n = int(input())
sft = 753
list = []
while n > 0:
    list.append(i%10)
    i //= 10 # 必須
list.reverse()
ans = 1000
for i in range(len(list)-2):
    tmp = 100*list[i] + 10*list[i+1] + list[i+2]
    sft - tmp if sft - tmp < ans else ans
print(ans)


Fixed submission:
s = input()
print(min(abs(int(s[i:i+3]) - 753) for i in range(len(s) - 2)))

Buggy python submission (verdict: Runtime Error):
n = int(input())
sft = 753
list = []
while n > 0:
    list.append(i%10)
    i //= 10 # 必須
list.reverse()
ans = 1000
for i in range(len(list)+2):
    tmp = 100*list[i] + 10*list[i+1] + list[i+2]
    sft - tmp if sft - tmp < ans else ans
print(ans)

Fixed submission:
s = input()
print(min(abs(int(s[i:i+3]) - 753) for i in range(len(s) - 2)))
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = int(input())
b = int(input())
result ='Hello World' if n == 1 else a+b
print(result)


Fixed submission:
import sys

N = int(input())

if N == 1:
    print("Hello World")
    sys.exit()
AB = [int(input()) for _ in range(2)]
print(sum(AB))
Buggy python submission (verdict: Runtime Error):
n = int(input())
for i in range(900):
    x = list(n)
    if x[0]==x[1]==x[2]:
        print(n)
        break 
    n+=1


Fixed submission:
n = input()
if n[0] == n[1] == n[2]:
    ans = n
elif n[1] > n[0] or (n[1] == n[0] and n[2] > n[0]):
    ans = str(int(n[0])+1)*3
elif n[1] <= n[0] or n[2] < n[0]:
    ans = n[0]*3
print(ans)