alexjercan/bugnet huggingface dataset:
Problem p02777 (Python) — buggy submission, verdict: Runtime Error

S = list(map(str, input().split()))
A = list(map(int, input().split()))
U = input()

ind = S.index(U)

A[ind] -= 1

print(" ".join(list(map(str, A))))


Error: ValueError: invalid literal for int() with base 10: 'red'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02777/Python/s433629607.py", line 3, in <module>
    U = int(input())
ValueError: invalid literal for int() with base 10: 'red'


Fixed submission:

S = list(map(str, input().split()))
A = list(map(int, input().split()))
U = int(input())

ind = S.index(U)

A[ind] -= 1

print("".join(A))
Problem p02777 (Python) — buggy submission, verdict: Runtime Error

S, T = input().split()
A, B = input().split()
U = input()

print("{} {}".format(int(A) - (1 if S == U else 0), int(B) - (1 if T == U else 0)))


Error: WA

Fixed submission:

S, T = input().split()
A, B = input().split()
U = input()

print(f"{int(A) - 1 if S == U else 0} {int(B) - 1 if T == U else 0}")
Problem p02777 (Python) — buggy submission, verdict: Runtime Error

S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    A -= 1
else:
    B -= 1

print(A, B)


Error: 0

Fixed submission:

S, T = input().split()
A, B = map(int, input().split())
U = input()

if U == S:
    A -= 1
else:
    B -= 1

print(f"{A} {B}")
Problem p02777 (Python) — buggy submission, verdict: Runtime Error

S, T = list(input().split())
A, B = list(map(int, input().split()))
U = input()
dict = {}
dict[S] = A
dict[T] = B
dict[U] -= 1
print(dict[S], dict[T])


Error: 0

Fixed submission:

S, T = list(input().split())
A, B = list(map(int, input().split()))
U = input()
dict = {}
dict[S] = A
dict[T] = B
dict[U] -= 1
print(f"{dict[S]} {dict[T]}")
Problem p02777 (Python) — buggy submission, verdict: Runtime Error

s, t = input().split()

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

u = input()

if s == u:
    print(a - 1, b)
elif t == u:
    print(a, b - 1)


Error: TypeError: map() must have at least two arguments.
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02777/Python/s053537362.py", line 1, in <module>
    s, t = map(input().split())
TypeError: map() must have at least two arguments.


Fixed submission:

s, t = map(input().split())

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

u = input()

if s == u:
    print(a - 1, b)
elif t == u:
    print(a, b - 1)
Problem p02777 (Python) — buggy submission, verdict: Runtime Error

keys = input().split()
values = tuple(map(int, input().split()))

ball = dict(zip(keys, values))
u = input()

ball[u] -= 1
print(ball[keys[0]], ball[keys[1]])


Error: AttributeError: 'builtin_function_or_method' object has no attribute 'split'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02777/Python/s850348662.py", line 1, in <module>
    keys = input.split()
AttributeError: 'builtin_function_or_method' object has no attribute 'split'


Fixed submission:

keys = input.split()
values = tuple(map(int, input().split()))

ball = dict(zip(keys, values))
u = input()

ball[u] -= 1
print(ball[keys[0]], ball[keys[1]])
Problem p02779 (Python) — buggy submission, verdict: Time Limit Exceeded

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


Error: TLE

Fixed submission:

N = int(input())
A = input().split()
for i in A:
    A = [j for j in A if j != i]
    if len(A) == N - 1:
        N -= 1
        continue
    else:
        print("NO")
        break
if N == 0:
    print("YES")
Problem p02779 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = list(map(int, input().split()))
b = set(a)
a.sort()
if len(a) != len(b):
    print("NO")
else:
    print("YES")


Error: TLE

Fixed submission:

n = int(input())
a = list(map(int, input().split()))
for i in a:
    if a.count(i) >= 2:
        print("NO")
        exit()
print("YES")
Problem p02779 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = [int(x) for x in input().split()]
A.sort()
p = 0
for i in range(N - 1):
    if A[i] == A[i + 1]:
        p = 1
        break
if p == 0:
    print("YES")
else:
    print("NO")


Error: TLE

Fixed submission:

N = int(input())
A = [int(x) for x in input().split()]
d = []
p = 0
for i in range(N):
    if A[i] in d:
        p = 1
        break
    d.append(A[i])
if p == 0:
    print("YES")
else:
    print("NO")
Problem p02779 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
a = [int(i) for i in input().split()]
if len(a) != len(set(a)):
    print("NO")
else:
    print("YES")


Error: TLE

Fixed submission:

n = int(input())
a = input().split()
flag = False
for i in range(n):
    for j in range(i + 1, n):
        if a[i] == a[j]:
            flag = True
            break
    if flag:
        break

if flag:
    print("NO")
else:
    print("YES")
Problem p02779 (Python) — buggy submission, verdict: Runtime Error

already = {}
n = int(input())
a = list(map(int, input().split()))
for x in a:
    if already.get(x):
        print("NO")
        break
    already[x] = True
else:
    print("YES")


Error: 0

Fixed submission:

already = [False] * 200000
n = int(input())
a = list(map(int, input().split()))
for x in a:
    if already[x]:
        print("NO")
        break
    already[x] = True
else:
    print("YES")
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
e = [sum(range(1, pi + 1)) / pi for pi in p]

tmp = 0
for i in range(n):
    tmp += e[i]
    if i >= k:
        tmp -= e[i - k]
    ans = max(ans, tmp)

print(ans)


Error: TLE

Fixed submission:

n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0

tmp = 0
for i in range(n):
    tmp += sum(range(1, p[i] + 1)) / p[i]
    if i >= k:
        tmp -= sum(range(1, p[i - k] + 1)) / p[i - k]
    ans = max(ans, tmp)

print(ans)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [(p + 1) / 2 for p in P]
B = [0 for i in range(N)]
B[0] = A[0]
for i in range(1, N):
    B[i] = B[i - 1] + A[i]
ans = 0
for i in range(K - 1, N):
    if i == K - 1:
        a = B[i]
    else:
        a = B[i] - B[i - K]
    if ans < a:
        ans = a
print(ans)


Error: TLE

Fixed submission:

N, K = map(int, input().split())
P = list(map(int, input().split()))
A = [(p + 1) / 2 for p in P]
ans = 0
for i in range(K - 1, N):
    a = 0
    for j in range(K):
        a += A[i - j]
    if a > ans:
        ans = a
print(ans)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

def f(x):
    return (x + 1) / 2


n, k = [int(i) for i in input().split()]
p = [f(int(i)) for i in input().split()]
ans = sum(p[:k])
a = ans
for i in range(k, n):
    a = a + p[i] - p[i - k]
    ans = max(ans, a)
print(ans)


Error: TLE

Fixed submission:

def f(i):
    return (i + 1) / 2


n, k = [int(i) for i in input().split()]
p = [f(int(i)) for i in input().split()]
ans = sum(p[0:k])
for i in range(1, n - 2):
    ans = max(ans, sum(p[i : i + k]))
print(ans)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

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

V = [0] * (N + 1)
S = [0] * (1010)
for i in range(1009):
    S[i + 1] = S[i] + (i + 1)
# print(S)

for i in range(N):
    p = P[i]
    V[i + 1] = V[i] + S[p] / p

# print(V)

res = 0
for i in range(N + 1 - K):
    res = max(res, V[i + K] - V[i])

print(res)


Error: TLE

Fixed submission:

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

V = [0] * (N + 1)

for i in range(N):
    V[i + 1] = V[i] + sum(range(1, P[i] + 1)) / P[i]

# print(V)

res = 0
for i in range(N + 1 - K):
    res = max(res, V[i + K] - V[i])

print(res)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

N, K = map(int, input().split())
P = list(map(int, input().split()))
t = [0] * 1000000
for i in range(N):
    t[i + 1] = t[i] + P[i] + 1
ans = 0
for i in range(N - K + 1):
    ans = max(ans, t[i + K] - t[i])
print(ans / 2)


Error: TLE

Fixed submission:

N, K = map(int, input().split())
P = list(map(int, input().split()))
answer = 0
for i in range(N - K + 1):
    t = 0
    for j in range(i, i + K):
        j = P[j]
        t += (j * (j + 1) / 2) / j
    answer = max(answer, t)
print(answer)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

n, k = map(int, input().split())
p = list(map(int, input().split()))
a = [0 for _ in range(n + 1)]
for i, pi in enumerate(p):
    a[i + 1] = a[i] + (1 + pi) / 2

ans = 0
for i in range(n - k + 1):
    ans = max(ans, a[i + k] - a[i])
print(ans)


Error: TLE

Fixed submission:

n, k = map(int, input().split())
p = list(map(int, input().split()))
ans = 0
for i in range(n - k + 1):
    x = 0
    for j in range(k):
        pj = p[i + j]
        x += (1 + pj) / 2
    ans = max(ans, x)
print(ans)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

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

MAX = 0
# dp[i] i 番目から i + K - 1 番目までのサイコロの期待値の和
dp = [0] * N
for i in range(N - K + 1):
    if i < 1:
        dp[i] = 0.5 * (sum(p[:K]) + K)
    else:
        dp[i] = dp[i - 1] - 0.5 * p[i - 1] + 0.5 * p[i + K - 1]

    MAX = max(MAX, dp[i])
print(MAX)


Error: TLE

Fixed submission:

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

frst_idx = 0
MAX = 0
for i in range(N - K + 1):
    MAX = max(MAX, (sum(p[i : i + K]) + K) * 0.5)
print(MAX)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)
e_memo = {}
E = 0
for dice in dices:
    E -= expectations.popleft()
    if e_memo.get(dice) is None:
        e_memo[dice] = sum(range(1, dice + 1)) / dice
    e = e_memo[dice]
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)


Error: TLE

Fixed submission:

from collections import deque


line = input().split(" ")
N, K = int(line[0]), int(line[1])
line = input().split(" ")
dices = [int(c) for c in line]

max_E = 0
expectations = deque([0] * K, maxlen=K)

E = 0
for dice in dices:
    E -= expectations.popleft()
    e = sum(range(1, dice + 1)) / dice
    expectations.append(e)
    E += e
    if E < max_E:
        continue
    else:
        max_E = E

print(max_E)
Problem p02780 (Python) — buggy submission, verdict: Runtime Error

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

# cumulated value
c_p = [0] * N
c_p[0] = p[0]

for i in range(1, N):
    c_p[i] = c_p[i - 1] + p[i]

max_e = c_p[K - 1]

for i in range(K, N):
    e = c_p[i] - c_p[i - K]
    max_e = max(max_e, e)

print((max_e + K) / 2)


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02780/Python/s069038365.py", line 14, in <module>
    e = c_p[i + K] - c_p[i]
IndexError: list index out of range


Fixed submission:

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

# cumulated value
c_p = [0] * N
c_p[0] = p[0]

for i in range(1, N):
    c_p[i] = c_p[i - 1] + p[i]

max_e = 0

for i in range(N - K + 1):
    e = c_p[i + K] - c_p[i]
    if e > max_e:
        max_e = e

print((max_e + K) / 2)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

def main():
    N, K = map(int, input().split())
    P = [(v + 1) / 2 for v in map(int, input().split())]

    ans = tmp = sum(P[0:K])
    for i in range(N - K):
        tmp = tmp - P[i] + P[i + K]
        ans = max(ans, tmp)

    print(ans)


if __name__ == "__main__":
    main()


Error: TLE

Fixed submission:

def main():
    N, K = map(int, input().split())
    P = [(v + 1) / 2 for v in map(int, input().split())]

    ans = 0
    for i in range(N - K + 1):
        ans = max(ans, sum(P[i : i + K]))

    print(ans)


if __name__ == "__main__":
    main()
Problem p02780 (Python) — buggy submission, verdict: Runtime Error

import sys
from itertools import accumulate


def solve():
    N, K = map(int, sys.stdin.readline().split())
    cusum_p = (0,) + tuple(accumulate(map(int, sys.stdin.read().split())))
    return (max(i - j for i, j in zip(cusum_p[K:], cusum_p[:-K])) + K) / 2


if __name__ == "__main__":
    answer = solve()
    print(answer)


Error: WA

Fixed submission:

import sys
from itertools import accumulate


def solve():
    N, K = map(int, sys.stdin.readline().split())
    cusum_p = list(accumulate(map(int, sys.stdin.read().split()), initial=0))
    return (max(i - j for i, j in zip(cusum_p[K:], cusum_p[:-K])) + K) / 2


if __name__ == "__main__":
    answer = solve()
    print(answer)
Problem p02780 (Python) — buggy submission, verdict: Runtime Error

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

p_sum = [0] * (n + 1)

for i in range(n):
    p_sum[i + 1] = p_sum[i] + p[i]

ans = 0
for i in range(n - k + 1):
    ans = max(ans, p_sum[i + k] - p_sum[i])

ans = (ans + k) / 2
print(ans)


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02780/Python/s305740242.py", line 7, in <module>
    p_sum[i] = p_sum[i - 1] + p[i]
IndexError: list index out of range


Fixed submission:

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

p_sum = [0] * (n + 1)

for i in range(1, n + 1):
    p_sum[i] = p_sum[i - 1] + p[i]

ans = 0
for i in range(-k + 1):
    ans = max(ans, p_sum[i + k] - p_sum[i])

ans = (ans + k) / 2
print(ans)
Problem p02780 (Python) — buggy submission, verdict: Time Limit Exceeded

N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
tmp = sum(lst[:K])
ret = tmp
for i in range(N - K):
    tmp -= lst[i]
    tmp += lst[i + K]
    ret = max(ret, tmp)
print((ret + K) / 2)


Error: TLE

Fixed submission:

N, K = map(int, input().split())
lst = [int(x) for x in input().split()]
a = len(lst) - K + 1
n = 0
ret_lst = []
for i in range(a):
    m = sum(lst[i : i + K])
    if n < m:
        n = m
        ret_lst = lst[i : i + K]

ll = [x / 2 * (x + 1) / x for x in ret_lst]
print(sum(ll))
Problem p02781 (Python) — buggy submission, verdict: Runtime Error

N = input()
K = int(input())

a = 1
b = [0] * (K + 1)
b[0] = 1
b[1] = int(N[0]) - 1

for c in N[1:]:
    t = int(c)
    for i in range(K - 1, -1, -1):
        b[i + 1] += b[i] * 9
    if t != 0:
        if a + 1 <= K:
            b[a + 1] += t - 1
        if a <= K:
            b[a] += 1
        a += 1

if a == K:
    print(b[K] + 1)
else:
    print(b[K])


Error: 0

Fixed submission:

N = input()
K = int(input())

a = 1
b = [0] * (K + 1)
b[0] = 1
b[1] = int(N[0]) - 1

for c in N[1:]:
    t = int(c)
    for i in range(K - 1, -1, -1):
        b[i + 1] += b[i] * 9
    if t != 0:
        b[a + 1] += t - 1
        b[a] += 1
        a += 1

if a == K:
    print(b[K] + 1)
else:
    print(b[K])
Problem p02782 (Python) — buggy submission, verdict: Runtime Error

r, c, R, C = [int(_) for _ in input().split()]
mod = 10**9 + 7

f = [1] * (3 * 10**6 + 10)
for i in range(1, 3 * 10**6 + 10):
    f[i] = i * f[i - 1] % mod
fi = {}


def comb(n, r):
    if r not in fi:
        fi[r] = pow(f[r], mod - 2, mod)
    if n - r not in fi:
        fi[n - r] = pow(f[n - r], mod - 2, mod)
    return (f[n] * fi[r] * fi[n - r]) % mod


a1 = (C + 2) * f[c + 1] * f[C + R + 2] - (c + 1) * f[C + 2] * f[c + R + 1]
a1 *= (
    pow(R + 1, mod - 2, mod)
    * pow(f[c + 1], mod - 2, mod)
    * pow(f[C + 2], mod - 2, mod)
    * pow(f[R], mod - 2, mod)
)
a2 = (C + 2) * f[c + 1] * f[C + r + 1] - (c + 1) * f[C + 2] * f[c + r]
a2 *= (
    pow(r, mod - 2, mod)
    * pow(f[c + 1], mod - 2, mod)
    * pow(f[C + 2], mod - 2, mod)
    * pow(f[r - 1], mod - 2, mod)
)
ans = a1 - a2
ans %= mod
print(ans)


Error: 0

Fixed submission:

r1, c1, r2, c2 = [int(_) for _ in input().split()]
mod = 10**9 + 7

f = [1] * (10**6 + 1)
for i in range(1, 10**6 + 1):
    f[i] = i * f[i - 1] % mod
fi = {}


def comb(n, r):
    if r not in fi:
        fi[r] = pow(f[r], mod - 2, mod)
    if n - r not in fi:
        fi[n - r] = pow(f[n - r], mod - 2, mod)
    return (f[n] * fi[r] * fi[n - r]) % mod


ans = 0
for x in range(c1, c2 + 1):
    ans += comb(r2 + x + 1, x + 1) - comb(r1 + x, x + 1)
    ans %= mod
print(ans)
Problem p02782 (Python) — buggy submission, verdict: Time Limit Exceeded

def inpl():
    return list(map(int, input().split()))


def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    return (over[n] * under[r] * under[n - r]) % MOD


# 互いに素なx, yについて、a * x + b * y = 1の解の一つを求める。
def extGCD(x, y):
    r = [1, 0, x]
    w = [0, 1, y]
    # print(r, w)
    while w[2] != 1:
        # print(r, w)
        q = r[2] // w[2]
        w_tmp = [r[0] - q * w[0], r[1] - q * w[1], r[2] % w[2]]
        r, w = w, w_tmp

    return w[:2]


def mod_inv(a, m):
    _, x = extGCD(m, a)
    return (x + m) % m


def g(x, y):
    return (cmb(x + y + 2, x + 1) - 1 + MOD) % MOD


r1, c1, r2, c2 = inpl()

MOD = 10**9 + 7

over = [0 for i in range(r2 + c2 + 3)]
under = [0 for i in range(r2 + c2 + 3)]
over[0] = 1
for i in range(r2 + c2 + 2):
    over[i + 1] = over[i] * (i + 1) % MOD

under[r2 + c2 + 2] = mod_inv(over[r2 + c2 + 2], MOD)
for i in range(r2 + c2 + 1, 0, -1):
    under[i] = under[i + 1] * (i + 1) % MOD

print((g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)) % MOD)


Error: TLE

Fixed submission:

def inpl():
    return list(map(int, input().split()))


def cmb(n, r):
    # combination
    if n < r:
        return 0
    r = min(n - r, r)
    if r == 0:
        return 1
    return (over[n] * under[r] * under[n - r]) % MOD


# 互いに素なx, yについて、a * x + b * y = 1の解の一つを求める。
def extGCD(x, y):
    r = [1, 0, x]
    w = [0, 1, y]
    # print(r, w)
    while w[2] != 1:
        # print(r, w)
        q = r[2] // w[2]
        w_tmp = [r[0] - q * w[0], r[1] - q * w[1], r[2] % w[2]]
        r, w = w, w_tmp

    return w[:2]


def mod_inv(a, m):
    x, _ = extGCD(a, m)
    return (x + m) % m


def g(x, y):
    return (cmb(x + y + 2, x + 1) - 1 + MOD) % MOD


r1, c1, r2, c2 = inpl()

MOD = 10**9 + 7

over = [1]
under = [1]
for i in range(r2 + c2 + 2):
    over.append(over[-1] * (i + 1) % MOD)
    under.append(under[-1] * mod_inv(i + 1, MOD) % MOD)

print((g(r2, c2) - g(r2, c1 - 1) - g(r1 - 1, c2) + g(r1 - 1, c1 - 1)) % MOD)
Problem p02783 (Python) — buggy submission, verdict: Runtime Error

H, A = map(int, input().split())

print(H // A + min(H % A, 1))


Error: TypeError: 'int' object is not iterable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02783/Python/s363144861.py", line 3, in <module>
    print(H // A + min(H % A))
TypeError: 'int' object is not iterable


Fixed submission:

H, A = map(int, input().split())

print(H // A + min(H % A))
Problem p02783 (Python) — buggy submission, verdict: Runtime Error

h, a = map(int, input().split())

if h % a == 0:
    print(h // a)
else:
    print(h // a + 1)


Error: ValueError: invalid literal for int() with base 10: '10 4'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02783/Python/s343039066.py", line 1, in <module>
    h = int(input())
ValueError: invalid literal for int() with base 10: '10 4'


Fixed submission:

h = int(input())
a = int(input())

if h % a == 0:
    print(h / a)
else:
    print(h // a + 1)
Problem p02784 (Python) — buggy submission, verdict: Runtime Error

H, N = map(int, input().split())
attacks = list(map(int, input().split()))
if sum(attacks) >= H:
    print("Yes")
else:
    print("No")


Error: 0

Fixed submission:

H, N = map(int, input().split())
attacks = [*map(int, input().split())]
if sum(attacks) >= H:
    print("Yes")
else:
    print("No")
Problem p02785 (Python) — buggy submission, verdict: Runtime Error

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

H.sort(reverse=True)

if K >= N:
    print(0)
else:
    print(sum(H[K:]))


Error: AttributeError: 'map' object has no attribute 'sort'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02785/Python/s623070047.py", line 4, in <module>
    H.sort(reverse=True)
AttributeError: 'map' object has no attribute 'sort'


Fixed submission:

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

H.sort(reverse=True)

if K >= N:
    print(0)
else:
    print(sum(H[K:]))
Problem p02785 (Python) — buggy submission, verdict: Runtime Error

s = input().split()
N = int(s[0])
K = int(s[1])

H = list(map(int, input().split()))
H_s = sorted(H, reverse=True)

print(sum(H_s[K:]))


Error: TypeError: can only assign an iterable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02785/Python/s722693756.py", line 8, in <module>
    H_s[:N] = 0
TypeError: can only assign an iterable


Fixed submission:

s = input().split()
N = int(s[0])
K = int(s[1])

H = list(map(int, input().split()))

H_s = sorted(H, reverse=True)
H_s[:N] = 0

print(sum(H_s))
Problem p02785 (Python) — buggy submission, verdict: Runtime Error

H, K = map(int, input().split())
hp = list(map(int, input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))


Error: TypeError: map() must have at least two arguments.
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02785/Python/s611990638.py", line 2, in <module>
    hp = list(int, map(input().split()))
TypeError: map() must have at least two arguments.


Fixed submission:

H, K = map(int, input().split())
hp = list(int, map(input().split()))
hp.sort(reverse=True)
print(sum(hp[K:]))
Problem p02785 (Python) — buggy submission, verdict: Time Limit Exceeded

from sys import exit

N, K = [int(x) for x in input().split()]
H = list([int(x) for x in input().split()])

if len(H) <= K:
    print(0)
    exit()

H.sort(reverse=True)
H = H[K:]

print(sum(H))


Error: TLE

Fixed submission:

from sys import exit

N, K = [int(x) for x in input().split()]
H = list([int(x) for x in input().split()])

H.sort(reverse=True)

if len(H) <= K:
    print(0)
    exit()

for _ in range(K):
    H.pop(0)

print(sum(H))
Problem p02786 (Python) — buggy submission, verdict: Time Limit Exceeded

H = int(input())
import math

s = 0
a = 2
for i in range(int(math.log2(H))):
    s += a
    a *= 2

print(s + 1)


Error: TLE

Fixed submission:

H = int(input())
n = 0
monsters = [H]
while len(monsters) > 0:
    n += 1
    HH = monsters[0] // 2
    if HH > 0:
        monsters.extend([HH, HH])
    del monsters[0]

print(n)
Problem p02786 (Python) — buggy submission, verdict: Time Limit Exceeded

H = int(input())
m = 1
at = 0
for i in range(H):
    if H == 1:
        at += m
        print(at)
        exit()
    at += m
    H //= 2
    m *= 2


Error: TLE

Fixed submission:

H = int(input())
m = 1
at = 0
while True:
    at += m
    H //= 2
    m *= 2
    if H == 1:
        at += m
        print(at)
        exit()
Problem p02786 (Python) — buggy submission, verdict: Time Limit Exceeded

# -*- coding: utf-8 -*-

H = int(input())

ans = 1
prev = 1
while True:
    if H == 1:
        break
    H //= 2
    prev *= 2
    ans += prev

print(ans)


Error: TLE

Fixed submission:

# -*- coding: utf-8 -*-

H = int(input())

ans = 1
prev = 1
while True:
    H //= 2
    prev *= 2
    ans += prev
    if H == 1:
        break

print(ans)
Problem p02786 (Python) — buggy submission, verdict: Time Limit Exceeded

H = int(input())
c = 0
ans = 0
while H > 1:
    H = H // 2
    c += 1
for i in range(c + 1):
    ans += 2**i
print(ans)


Error: TLE

Fixed submission:

H = int(input())
ans = 0
while H > 0:
    if H == 1:
        ans += 1
    else:
        e = H // 2
        ans += e
        H -= 1
print(ans)