alexjercan/bugnet huggingface dataset:
Problem p03497 (Python) — buggy submission, verdict: Time Limit Exceeded

n, k = map(int, input().split())
A = list(map(int, input().split()))
array = {}
ans = 0

for a in A:
    if a in array.keys():
        array[a] += 1
    else:
        array[a] = 1

array = sorted(array.values())

if len(set(A)) > k:
    num = len(array) - k
    for i in range(num):
        ans += array[i]

print(ans)


Error: TLE

Fixed submission:

n, k = map(int, input().split())
A = list(map(int, input().split()))
array = []
ans = 0

for i in set(A):
    array.append(A.count(i))

array.sort()

if len(set(A)) > k:
    num = len(array) - k
    for i in range(num):
        ans += array[i]

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

from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))
c = Counter(A).most_common()[::-1]

ans = 0
if len(c) > K:
    for i in range(len(c) - K):
        ans += c[i][1]

print(ans)


Error: TLE

Fixed submission:

from collections import Counter

N, K = map(int, input().split())
A = list(map(int, input().split()))
c = Counter(A).most_common()[::-1]

ans = 0
while len(c) > K:
    res = c.pop(0)
    ans += res[1]
print(ans)
Problem p03497 (Python) — buggy submission, verdict: Time Limit Exceeded

import collections

N, K = map(int, input().split())
arr = list(map(int, input().split()))
ans = 0
cnt = collections.defaultdict(int)
for num in arr:
    cnt[num] += 1

vals = sorted(cnt.values())

if len(cnt) > K:
    for i in range(len(cnt) - K):
        ans += vals[i]

print(ans)


Error: TLE

Fixed submission:

from collections import Counter

N, K = map(int, input().split())
counter = Counter(list(map(int, input().split())))
ans = 0
if len(counter.keys()) > K:
    for i in range(len(counter.keys()) - K):
        ans += counter.most_common()[0 - i - 1][1]

print(ans)
Problem p03497 (Python) — buggy submission, verdict: Runtime Error

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

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0

for i in range(len(cnt)):
    if len(cnt) - i <= K:
        break
    ans += cnt[i][1]

print(ans)


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


Fixed submission:

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

cnt = {}

for a in A:
    if a not in cnt:
        cnt[a] = 0
    cnt[a] += 1

cnt = sorted(cnt.items(), key=lambda x: x[1])
ans = 0
i = 0

while len(cnt) > K:
    ans += cnt[i][1]
    i += 1

print(ans)
Problem p03497 (Python) — buggy submission, verdict: Runtime Error

from collections import Counter

n, m = map(int, input().split())
dic = Counter(map(int, input().split()))
lis = sorted(dic.items(), key=lambda x: x[1], reverse=True)

res = 0
for i in range(min(m, len(lis))):
    res += lis[i][1]
print(n - res)


Error: 0

Fixed submission:

from collections import Counter

n, m = map(int, input().split())
dic = Counter(map(int, input().split()))
lis = sorted(dic.items(), key=lambda x: x[1], reverse=True)

res = 0
for i in range(m):
    res += lis[i][1]
print(n - res)
Problem p03498 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
a = list(map(int, input().split()))
b, idx = zip(*sorted(zip(a, range(1, n + 1))))
if b[-1] < 0:
    print(n - 1)
    # 全て負の数なので後ろから累積和をとる
    for i in range(n - 1):
        print(n - i, n - i - 1)
elif b[0] >= 0:
    print(n - 1)
    for i in range(n - 1):
        print(i + 1, i + 2)
else:
    # max or min を足して全て正の数に直す
    print(2 * n - 2)
    if b[-1] > abs(b[0]):
        # add max
        for i in range(n):
            if i + 1 != idx[-1]:
                print(idx[-1], i + 1)
        for i in range(n - 1):
            print(i + 1, i + 2)
    else:
        for i in range(n):
            if i + 1 != idx[0]:
                print(idx[0], i + 1)
        for i in range(n - 1):
            print(n - i, n - i - 1)


Error: IndexError: tuple index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03498/Python/s089705711.py", line 19, in <module>
    print(idx[n - 1], i + 1)
IndexError: tuple index out of range


Fixed submission:

n = int(input())
a = list(map(int, input().split()))
b, idx = zip(*sorted(zip(a, range(1, n))))
if b[-1] < 0:
    print(n - 1)
    # 全て負の数なので後ろから累積和をとる
    for i in range(n - 1):
        print(n - i, n - i - 1)
elif b[0] >= 0:
    print(n - 1)
    for i in range(n - 1):
        print(i + 1, i + 2)
else:
    # max or min を足して全て正の数に直す
    print(2 * n - 2)
    if b[-1] > abs(b[0]):
        # add max
        for i in range(n - 1):
            print(idx[n - 1], i + 1)
        for i in range(n - 1):
            print(i + 1, i + 2)
    else:
        for i in range(n - 1):
            print(idx[0], i + 2)
        for i in range(n - 1):
            print(n - i, n - i - 1)
Problem p03501 (Python) — buggy submission, verdict: Runtime Error

N, A, B = map(int, input().split())

print(min(N * A, B))


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


Fixed submission:

N, A, B = map(int, input().split())

print(min(N * A), B)
Problem p03501 (Python) — buggy submission, verdict: Runtime Error

n, a, b = map(int, input().split())
print(min(b, a * n))


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


Fixed submission:

n, a, b = map(int, input())
print(min(b, a * n))
Problem p03502 (Python) — buggy submission, verdict: Runtime Error

N = input()
x = sum(int(i) for i in N)
print("Yes" if int(N) % x == 0 else "No")


Error: TypeError: not all arguments converted during string formatting
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03502/Python/s802256796.py", line 3, in <module>
    print("Yes" if N % x == 0 else "No")
TypeError: not all arguments converted during string formatting


Fixed submission:

N = input()
x = sum(int(i) for i in N)
print("Yes" if N % x == 0 else "No")
Problem p03502 (Python) — buggy submission, verdict: Runtime Error

N = input()
sum = 0

for i in N:
    sum += int(i)
if int(N) % sum == 0:
    print("Yes")
else:
    print("No")


Error: TypeError: unsupported operand type(s) for +=: 'int' and 'str'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03502/Python/s766793657.py", line 5, in <module>
    sum += i
TypeError: unsupported operand type(s) for +=: 'int' and 'str'


Fixed submission:

N = input()
sum = 0

for i in N:
    sum += i
if N % sum == 0:
    print("Yes")
else:
    print("No")
Problem p03502 (Python) — buggy submission, verdict: Runtime Error

# -*- coding: utf-8 -*-
N = int, input()
num = str(N[1])
char_list = list(num)
sum = 0
for i in range(len(char_list)):
    sum += int(char_list[i])

if int(N[1]) % sum == 0:
    print("Yes")
else:
    print("No")


Error: TypeError: not all arguments converted during string formatting
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03502/Python/s573872997.py", line 9, in <module>
    if N[1] % sum == 0:
TypeError: not all arguments converted during string formatting


Fixed submission:

# -*- coding: utf-8 -*-
N = int, input()
num = str(N[1])
char_list = list(num)
sum = 0
for i in range(len(char_list)):
    sum += int(char_list[i])

if N[1] % sum == 0:
    print("Yes")
else:
    print("No")
Problem p03502 (Python) — buggy submission, verdict: Runtime Error

n = int(input())

ntmp = n
sum = 0

while True:
    sum += ntmp % 10
    ntmp = ntmp // 10
    if ntmp == 0:
        break

if n % sum == 0:
    print("Yes")

else:
    print("No")


Error: 0

Fixed submission:

n = int(input())

ntmp = n
sum = 0

while ntmp >= 10:
    sum += ntmp % 10
    ntmp = ntmp // 10

if n % sum == 0:
    print("Yes")

else:
    print("No")
Problem p03504 (Python) — buggy submission, verdict: Time Limit Exceeded

def main():
    N, C = map(int, input().split())
    stc = [[0] * (10**5) for _ in range(C)]
    for _ in range(N):
        s, t, c = map(int, input().split())
        stc[c - 1][s - 1 : t] = [1] * (t - s + 1)
    print(max(map(sum, zip(*stc))))


main()


Error: TLE

Fixed submission:

def main():
    N, C = map(int, input().split())
    stc = [list(map(int, input().split())) for _ in range(N)]
    st = []
    mxt = 0
    mnt = 0
    while len(stc) > 0:
        s, t, c = stc.pop()
        for i, (ss, tt, cc) in enumerate(stc):
            if c == cc:
                if s == tt:
                    stc.pop(i)
                    stc.append((ss, t, c))
                    break
                elif ss == t:
                    stc.pop(i)
                    stc.append((s, tt, c))
                    break
        else:
            mnt = min(mnt, s - 1)
            mxt = max(mxt, t)
            st.append((s - 1, t))
    cs = [0] * (mxt + 1)
    for s, t in st:
        cs[s] += 1
        cs[t] += -1
    ans = 0
    cc = 0
    for c in cs:
        cc += c
        ans = max(ans, cc)
    print(ans)


main()
Problem p03504 (Python) — buggy submission, verdict: Time Limit Exceeded

# N個のimosなので二次元でやる 0.5がうざいので*2する( (2*10^5) * C )

# なぜか2WAが取れない

# これ嘘解法ぽい気がする

N, C = map(int, input().split())
x = 2 * (10**5)
# x = 30  # test
imos = [[0 for _ in range(x)] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int, input().split())
    s, t, c = s * 2 - 1, t * 2 - 1, c - 1
    imos[c][s - 1] += 1
    imos[c][t] -= 1
    # imos[c][s - 1] = min(1, imos[c][s - 1])  # test

for i in range(C):
    for j in range(1, x):
        imos[i][j] += imos[i][j - 1]
        # imos[i][j] = min(1, imos[i][j])  # test

ans = 0
for j in range(x):
    tmp = 0
    for i in range(C):
        tmp += min(1, imos[i][j])
    ans = max(ans, tmp)
# print("-----------")
# for x in imos:
#     print(x)
print(ans)

# 1 3
# 3 4 2


Error: TLE

Fixed submission:

# N個のimosなので二次元でやる 0.5がうざいので*2する( (2*10^5) * C )

# なぜか2WAが取れない

# 嘘解法？

N, C = map(int, input().split())
x = 2 * (10**5)
# x = 30  # test
imos = [[0 for _ in range(x)] for _ in range(C)]
for _ in range(N):
    s, t, c = map(int, input().split())
    s, t, c = s * 2 - 1, t * 2 - 1, c - 1
    imos[c][s - 1] += 1
    imos[c][t] -= 1

for i in range(C):
    for j in range(1, x):
        imos[i][j] += imos[i][j - 1]
        imos[i][j] = min(1, imos[i][j])  # test

ans = 0
for j in range(x):
    tmp = 0
    for i in range(C):
        tmp += imos[i][j]
    ans = max(ans, tmp)
# print("-----------")
# for x in imos:
#     print(x)
print(ans)

# 1 3
# 3 4 2
Problem p03523 (Python) — buggy submission, verdict: Runtime Error

s = input()
t = "AKIHABARA"
idx = 0
ng = 0
for i in range(len(t)):
    if t[i] == s[idx]:
        idx += 1
    elif t[i] != "A":
        ng = 1
        break
    if idx == len(s):
        if i < len(t) - 2:
            ng = 1

        break

if idx != len(s):
    ng = 1

if ng:
    print("NO")
else:
    print("YES")


Error: 0

Fixed submission:

s = input()
cnt = 0
idx = 0
target = "KIHBR"
for i in range(len(s)):
    if s[i] == "A":
        cnt += 1
        if idx == 1 and cnt == 1:
            print("NO")
            exit()
        if cnt >= 2:
            print("NO")
            exit()
    else:
        if idx <= 5 and target[idx] == s[i]:
            idx += 1
            cnt = 0
        else:
            print("NO")
            exit()
if idx == 5:
    print("YES")
Problem p03523 (Python) — buggy submission, verdict: Runtime Error

from itertools import product


candidates = []
non_as = ["KIH", "B", "R", ""]
for seps in product(["A", ""], repeat=4):
    candidates.append("".join(sep + non_a for sep, non_a in zip(seps, non_as)))

print("YES") if input() in candidates else print("NO")


Error: AttributeError: 'list' object has no attribute 'add'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03523/Python/s198624494.py", line 7, in <module>
    candidates.add("".append(sep + non_a for sep, non_a in zip(seps, non_as)))
AttributeError: 'list' object has no attribute 'add'


Fixed submission:

from itertools import product


candidates = []
non_as = ["KIH", "B", "R", ""]
for seps in product(["A", ""], repeat=4):
    candidates.add("".append(sep + non_a for sep, non_a in zip(seps, non_as)))

print("YES") if input() in candidates else print("NO")
Problem p03524 (Python) — buggy submission, verdict: Runtime Error

from collections import Counter


S = input()
C = Counter(S)
vs = sorted(list(C.values()))
if len(vs) == 1:
    print("YES") if vs[0] == 1 else print("NO")
elif len(vs) == 2:
    print("YES") if vs[0] == vs[1] and vs[0] == 1 else print("NO")
else:
    print("YES") if vs[2] - 1 <= vs[0] and vs[2] - 1 <= vs[1] else print("NO")


Error: EOFError: EOF when reading a line
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03524/Python/s357391578.py", line 2, in <module>
    K = int(input())
EOFError: EOF when reading a line


Fixed submission:

s = input()
K = int(input())
s_dic = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
for i, c in enumerate(s):
    s_dic[c].append(i)
substrings = set()
for lc in "abcdefghijklmnopqrstuvwxyz":
    for i in s_dic[lc]:
        for j in range(i + 1, len(s) + 1):
            substrings.add(s[i:j])
    if len(substrings) >= K:
        break
print(sorted(list(substrings))[K - 1])
Problem p03525 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
d = sorted(list(map(int, input().split())) + [0])

bit, cnt = [0] * 24, 1
for num in d:
    bit[((num - 12) * cnt + 12) % 24] += 1
    cnt *= -1

if any(i > 1 for i in bit):
    print(0)
    exit()
ans = [i for i, li in enumerate(bit * 2) if li == 1]
s = min(ans[i] - ans[i - 1] for i in range(1, len(ans)))
print(s)


Error: 0

Fixed submission:

n = int(input())
d = sorted(list(map(int, input().split())) + [0])

bit, cnt = [0] * 24, 1
for num in d:
    bit[(num - 12) * cnt + 12] += 1
    cnt *= -1

if any(i > 1 for i in bit):
    print(0)
    exit()
ans = [i for i, li in enumerate(bit * 2) if li == 1]
s = min(ans[i] - ans[i - 1] for i in range(1, len(ans)))
print(s)
Problem p03525 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import Counter
from itertools import product


N = int(input())
D = list(map(int, input().split()))
D_cnt = Counter(D)
if N >= 24 or D_cnt[0] > 0 or D_cnt[12] > 1 or any(D_cnt[i] > 2 for i in range(1, 12)):
    print(0)
    exit()
clock = [0, 24]
undet = []
if 12 in D_cnt:
    clock.append(12)
for i in range(1, 12):
    if D_cnt[i] == 2:
        clock.append(i)
        clock.append(24 - i)
    elif D_cnt[i] == 1:
        undet.append(i)

ans = 0
for rp in product([0, 1], repeat=len(undet)):
    candidate = clock[:]
    for j, is_flipped in enumerate(rp):
        candidate.append(undet[j]) if is_flipped else candidate.append(24 - undet[j])
    candidate.sort()
    ans = max(ans, min(ca - cb for cb, ca in zip(candidate, candidate[1:])))
print(ans)


Error: TLE

Fixed submission:

import numpy as np
from numba import njit


@njit("i1(i1,i1[:])", cache=True)
def solve(N, D):
    ans = 0
    for i in range(1 << N):
        clocks = np.zeros((N + 2), dtype=np.int8)
        clocks[-1] = 24
        for j in range(N):
            if i >> j & 1:
                clocks[j + 1] = D[j]
            else:
                clocks[j + 1] = 24 - D[j]
        clocks.sort()
        ans = max(ans, np.min(np.diff(clocks)))
    return ans


N = int(input())
D = np.array(input().split(), dtype=np.int8)
if N >= 24:
    print(0)
else:
    print(solve(N, D))
Problem p03533 (Python) — buggy submission, verdict: Runtime Error

S = input()
Acount = 0
count = 0
AKIBA = ["K", "I", "H", "B", "R"]
AKIBAcount = [1, 0, 0, 1, 1]
flag = 1
for i in range(len(S)):
    if count == 5:
        if S[i] == "A":
            Acount += 1
        else:
            flag = 0
        if Acount >= 2:
            flag = 0

    if S[i] == "A":
        Acount += 1
    else:
        if count <= 4:
            if S[i] == AKIBA[count] and Acount <= AKIBAcount[count]:
                count += 1
                Acount = 0
            else:
                flag = 0
                break

if flag == 1 and count == 5:
    print("YES")
else:
    print("NO")


Error: 0

Fixed submission:

S = input()
Acount = 0
count = 0
AKIBA = ["K", "I", "H", "B", "R"]
AKIBAcount = [1, 0, 0, 1, 1]
flag = 1
for i in range(len(S)):
    if count == 5:
        if S[i] == "A":
            Acount += 1
        if Acount >= 2:
            flag = 0
    if S[i] == "A":
        Acount += 1
    else:
        if S[i] == AKIBA[count] and Acount <= AKIBAcount[count]:
            count += 1
            Acount = 0
        else:
            flag = 0
            break

if flag == 1 and count == 5:
    print("YES")
else:
    print("NO")
Problem p03535 (Python) — buggy submission, verdict: Runtime Error

from collections import Counter


def solve(n, ds):
    if n >= 24:
        return 0
    freq = Counter(ds)
    if (0 in freq) or (freq[12] >= 2) or max(freq.values()) >= 3:
        return 0
    up_low = [0, 0]
    switch = 0
    ans = 25
    for d, s in sorted(freq.items()):
        if s == 2:
            ans = min(ans, d - up_low[0], d - up_low[1])
            up_low[0] = up_low[1] = d
        else:
            ans = min(ans, d - up_low[switch])
            up_low[switch] = d
            switch ^= 1
    ans = min(ans, 24 - sum(up_low))
    return ans


print(solve(int(input()), list(map(int, input().split()))))


Error: 0

Fixed submission:

from collections import Counter
from itertools import product, combinations


def solve(n, ds):
    if n >= 24:
        return 0
    freq = Counter(ds)
    if 0 in freq or freq[12] >= 2 or max(freq.values()) >= 3:
        return 0
    cmp = set()
    alt = []
    for d, l in freq.items():
        if l == 2 or d == 12:
            cmp.add(d)
            cmp.add(24 - d)
        else:
            alt.append((d, 24 - d))
    ans = min((abs(x - y) for x, y in combinations(cmp, 2)), default=0)
    for prd in product((0, 1), repeat=len(alt)):
        tmp_cmp = cmp.copy().union(x[i] for x, i in zip(alt, prd))
        tmp = min(abs(x - y) for x, y in combinations(tmp_cmp, 2))
        tmp = min(tmp, min(freq.keys()))
        ans = max(ans, tmp)
    return ans


print(solve(int(input()), list(map(int, input().split()))))
Problem p03543 (Python) — buggy submission, verdict: Runtime Error

N = list(input())

if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
    print("Yes")
else:
    print("No")


Error: TypeError: 'int' object is not iterable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03543/Python/s022209254.py", line 1, in <module>
    N = list(int(input()))
TypeError: 'int' object is not iterable


Fixed submission:

N = list(int(input()))
a = set(N)
a = list(a)
if len(a) <= 2:
    print("Yes")
else:
    print("No")
Problem p03543 (Python) — buggy submission, verdict: Runtime Error

n = input()
print("Yes" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else "No")


Error: TypeError: 'builtin_function_or_method' object is not subscriptable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03543/Python/s404486327.py", line 2, in <module>
    print("Yes" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else "No")
TypeError: 'builtin_function_or_method' object is not subscriptable


Fixed submission:

n = input
print("Yes" if n[0] == n[1] == n[2] or n[1] == n[2] == n[3] else "No")
Problem p03544 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


if N > 1:
    for i, n in enumerate(lc()):
        if i == N - 2:
            print(n)
            break
else:
    print(1)


Error: TLE

Fixed submission:

N = int(input())


def lc():
    l0, l1 = 2, 1
    while 1:
        yield l0 + l1
        l0, l1 = l1, l0 + l1


for i, n in enumerate(lc()):
    if i == N - 2:
        print(n)
        break
Problem p03544 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
lucas_number = [0] * (n + 1)
lucas_number[0] = 2
lucas_number[1] = 1
for i in range(2, n + 1):
    lucas_number[i] = lucas_number[i - 1] + lucas_number[i - 2]
print(lucas_number[n])


Error: 0

Fixed submission:

n = int(input())
lucas_number = [0] * (n + 1)
lucas_number[0] = 2
lucas_number[1] = 1
for i in range(2, n + 1):
    lucas_number[i] = lucas_number[i - 1] + lucas_number[i - 2]
print(lucas_number[i])
Problem p03544 (Python) — buggy submission, verdict: Runtime Error

N = int(input())

L = [None] * (N + 1)
L[0] = 2
L[1] = 1

for i in range(2, N + 1):
    L[i] = L[i - 1] + L[i - 2]

print(L[N])


Error: 0

Fixed submission:

from typing import List


N = int(input())

L: List[int] = [None] * (N + 1)
L[0] = 2
L[1] = 1

for i in range(2, N + 1):
    L[i] = L[i - 1] + L[i - 2]

print(L[N])
Problem p03544 (Python) — buggy submission, verdict: Runtime Error

def main():
    N = int(input())
    la = 2
    lb = 1
    for _ in range(N):
        lc = la + lb
        la = lb
        lb = lc
    print(la)


main()


Error: 0

Fixed submission:

def main():
    N = int(input())
    la = 2
    lb = 1
    for _ in range(N - 1):
        lc = la + lb
        la = lb
        lb = lc
    print(lc)


main()
Problem p03544 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
# N = 86


def f(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    elif n == 2:
        return 3
    return 2 * f(n - 2) + f(n - 3)


def g(n):
    L = [0] * (n + 1)
    L[0] = 2
    L[1] = 1
    for i in range(2, n + 1):
        L[i] = L[i - 1] + L[i - 2]

    return L[-1]


print(g(N))


Error: TypeError: can only concatenate str (not "int") to str
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03544/Python/s962780069.py", line 25, in <module>
    print(g(N))
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03544/Python/s962780069.py", line 16, in g
    L = [0] * (n + 1)
TypeError: can only concatenate str (not "int") to str


Fixed submission:

N = input()
# N = 86


def f(n):
    if n == 0:
        return 2
    elif n == 1:
        return 1
    elif n == 2:
        return 3
    return 2 * f(n - 2) + f(n - 3)


def g(n):
    L = [0] * (n + 1)
    L[0] = 2
    L[1] = 1
    for i in range(2, n + 1):
        L[i] = L[i - 1] + L[i - 2]

    return L[-1]


print(g(N))
Problem p03545 (Python) — buggy submission, verdict: Runtime Error

from itertools import product

A, B, C, D = input()
for op1, op2, op3 in product("+-", repeat=3):
    expr = "{}{}{}{}{}{}{}".format(A, op1, B, op2, C, op3, D)
    if eval(expr) == 7:
        print("{}{}{}{}{}{}{}=7".format(A, op1, B, op2, C, op3, D))
        break


Error: 0

Fixed submission:

from itertools import product

A, B, C, D = input()
for op1, op2, op3 in product("+-", repeat=3):
    expr = f"{A}{op1}{B}{op2}{C}{op3}{D}"
    if eval(expr) == 7:
        print(f"{A}{op1}{B}{op2}{C}{op3}{D}=7")
        break