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

N = int(input())
A = [int(input()) for _ in range(N)]
i = 0
done = {a - 1: False for a in A}
num = 0
while True:
    i = A[i] - 1
    num += 1
    if i == 1:
        print(num)
        exit()
    if done[i]:
        print(-1)
        exit()
    done[i] = True


Error: TLE

Fixed submission:

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

n = int(input())
a = [0] * n
for i in range(n):
    a[i] = int(input())

cnt = 0
lit = 0

while lit != 1 and (lit != 0 or cnt == 0):
    lit = a[lit] - 1
    cnt += 1

if lit == 1:
    print(cnt)
else:
    print(-1)
Problem p03680 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
a = [0] + [int(input()) for _ in range(N)]
ans = 0
idx = 1
flag = False
for i in range(N):
    ans += 1
    if a[idx] == 2:
        print(ans)
        flag = True
        break
    idx = a[idx]
else:
    print(ans if flag else -1)


Error: TLE

Fixed submission:

N = int(input())
a = [0] + [int(input()) for _ in range(N)]
preid = 1
ans = 0
while True:
    tmp = preid
    ans += 1
    if a[preid] == 2:
        print(ans)
        break
    preid = a[preid]
    if a[tmp] == a[preid]:
        print(-1)
        break
Problem p03680 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
a = [int(input()) for _ in range(N)]
pikaa = 1
ans = 0
for _ in range(N):
    pikaa = a[pikaa - 1]
    ans += 1
    if pikaa == 2:
        print(ans)
        exit()
print(-1)


Error: TLE

Fixed submission:

N = int(input())
a = [int(input()) for _ in range(N)]
pikaa = 1
ans = 0
while 1:
    pikaa = a[pikaa - 1]
    ans += 1
    if pikaa == 1:
        print(-1)
        exit()
    elif pikaa == 2:
        print(ans)
        exit()
Problem p03680 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
nxt_btn = {i: int(input()) for i in range(1, n + 1)}

num = -1
crr_btn = 1
for i in range(1, n + 1):
    if nxt_btn[crr_btn] == 2:
        num = i
        break
    crr_btn = nxt_btn[crr_btn]
print(num)


Error: TLE

Fixed submission:

n = int(input())
nxt_btn = {i: int(input()) for i in range(1, n + 1)}

num = 0
crr_btn = 1
while True:
    num += 1
    if nxt_btn[crr_btn] == 1:
        num = -1
        break
    if nxt_btn[crr_btn] == 2:
        break
    crr_btn = nxt_btn[crr_btn]
print(num)
Problem p03680 (Python) — buggy submission, verdict: Time Limit Exceeded

N = int(input())
A = []
for _ in range(N):
    a = int(input())
    A.append(a - 1)
Flags = [False] * N
Flags[0] = True
now = 0
cnt = 0
for _ in range(N):
    cnt += 1
    next_node = A[now]
    if next_node == 1:
        break
    if Flags[next_node]:
        print("-1")
        exit()
    Flags[next_node] = True
    now = next_node
print(cnt)


Error: TLE

Fixed submission:

N = int(input())
A = []
for _ in range(N):
    a = int(input())
    A.append(a - 1)
Flags = [False] * N
Flags[0] = True
now = 0
cnt = 0
while now != 1:
    cnt += 1
    next_node = A[now]
    if Flags[next_node]:
        print("-1")
        exit()
    now = next_node
print(cnt)
Problem p03681 (Python) — buggy submission, verdict: Runtime Error

N, M = map(int, input().split())

MOD = 1000000007

if abs(N - M) > 1:
    print(0)
    exit(0)

dogs = 1
for i in range(1, N + 1):
    dogs *= i
    dogs %= MOD

monks = 1
for i in range(1, M + 1):
    monks *= i
    monks %= MOD

res = (dogs * monks) % MOD
if (N + M) % 2 == 0:
    res *= 2
    res %= MOD

print(res)


Error: 0

Fixed submission:

N, M = map(int, input().split())

MOD = 1_000_000_007

if abs(N - M) > 1:
    print(0)
    exit(0)

dogs = 1
for i in range(1, N + 1):
    dogs *= i
    dogs %= MOD

monks = 1
for i in range(1, M + 1):
    monks *= i
    monks %= MOD

res = (dogs * monks) % MOD
if (N + M) % 2 == 0:
    res *= 2
    res %= MOD

print(res)
Problem p03681 (Python) — buggy submission, verdict: Runtime Error

from math import factorial

n, m = [int(i) for i in input().split()]
mod = 10**9 + 7

ans = 0
diff = abs(n - m)
if diff == 0:
    ans = (factorial(n) ** 2) * 2 % mod
elif diff == 1:
    ans = factorial(n) * factorial(m) % mod
print(ans)


Error: WA

Fixed submission:

from math import factorial

n, m = [int(i) for i in input().split()]
mod = 10e9 + 7

ans = 0
diff = abs(n - m)
if diff == 0:
    ans = (factorial(n) ** 2) * 2 % mod
elif diff == 1:
    ans = factorial(n) * factorial(m) % mod
print(ans)
Problem p03682 (Python) — buggy submission, verdict: Runtime Error

from operator import itemgetter
from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

xyi = [[x, y, i] for i, (x, y) in enumerate(xy)]
edge = set()

xyi.sort()
for (x1, y1, i1), (x2, y2, i2) in zip(xyi, xyi[1:]):
    c = min(abs(x1 - x2), abs(y1 - y2))
    edge.add((i1, i2, c))

xyi.sort(key=itemgetter(1))
for (x1, y1, i1), (x2, y2, i2) in zip(xyi, xyi[1:]):
    c = min(abs(x1 - x2), abs(y1 - y2))
    edge.add((i1, i2, c))

row, col, cost = zip(*edge)

graph = csr_matrix((cost, (row, col)), shape=(n, n))
mst = minimum_spanning_tree(graph, overwrite=True).astype(int)
ans = mst.sum()
print(ans)


Error: ModuleNotFoundError: No module named 'scipy'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03682/Python/s256567036.py", line 2, in <module>
    from scipy.sparse.csgraph import minimum_spanning_tree
ModuleNotFoundError: No module named 'scipy'


Fixed submission:

from operator import itemgetter
from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

xyi = [[x, y, i] for i, (x, y) in enumerate(xy)]
row = []
col = []
cost = []

xyi.sort()
for (x1, y1, i1), (x2, y2, i2) in zip(xyi, xyi[1:]):
    row.append(i1)
    col.append(i2)
    cost.append(min(abs(x1 - x2), abs(y1 - y2)))

xyi.sort(key=itemgetter(1))
for (x1, y1, i1), (x2, y2, i2) in zip(xyi, xyi[1:]):
    row.append(i1)
    col.append(i2)
    cost.append(min(abs(x1 - x2), abs(y1 - y2)))

graph = csr_matrix((cost, (row, col)))
mst = minimum_spanning_tree(graph)
ans = mst.sum().astype(int)
print(ans)
Problem p03682 (Python) — buggy submission, verdict: Runtime Error

from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix
from operator import itemgetter

n = int(input())
xy = [list(map(int, input().split())) + [i] for i in range(n)]

edge = set()
for key in (itemgetter(0), itemgetter(1)):
    xy.sort(key=key)
    for (x1, y1, i1), (x2, y2, i2) in zip(xy, xy[1:]):
        d = min(abs(x1 - x2), abs(y1 - y2))
        edge.add((i1, i2, d))

u, v, c = zip(*edge)

graph = csr_matrix((c, (u, v)), shape=(n, n), dtype=int)
mst = minimum_spanning_tree(graph, overwrite=True).astype(int)
ans = mst.sum()
print(ans)


Error: ModuleNotFoundError: No module named 'scipy'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03682/Python/s206242713.py", line 1, in <module>
    from scipy.sparse.csgraph import minimum_spanning_tree
ModuleNotFoundError: No module named 'scipy'


Fixed submission:

from scipy.sparse.csgraph import minimum_spanning_tree
from scipy.sparse import csr_matrix
import numpy as np

n = int(input())
xy = [list(map(int, input().split())) for _ in range(n)]

x = []
y = []
for i, (ex, ey) in enumerate(xy):
    x.append([ex, i])
    y.append([ey, i])

x.sort()
y.sort()

u = []
v = []
c = []


def f(li):
    for (e1, i1), (e2, i2) in zip(li, li[1:]):
        dist = e2 - e1
        u.append(i1)
        v.append(i2)
        c.append(dist)


f(x)
f(y)

graph = csr_matrix((c, (u, v)))
mst = minimum_spanning_tree(graph).astype(np.int64)
ans = mst.sum()
print(ans)
Problem p03691 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

from itertools import combinations


def solve(n, pairs):
    survivors = {v: {v} for v in range(1, n + 1)}
    for x, y in reversed(pairs):
        for v, srv in survivors.copy().items():
            if x in srv:
                if y in srv:
                    del survivors[v]
                else:
                    srv.add(y)
            elif y in srv:
                srv.add(x)
    return sum(su.isdisjoint(sv) for su, sv in combinations(survivors.values(), 2))


n, m = map(int, input().split())
pairs = [tuple(map(int, line.split())) for line in sys.stdin.readlines()]
print(solve(n, pairs))


Error: TLE

Fixed submission:

import sys

from itertools import combinations


def solve(n, pairs):
    survivors = {v: {v} for v in range(1, n + 1)}
    for x, y in reversed(pairs):
        for v, srv in survivors.copy().items():
            if x in srv:
                if y in srv:
                    del survivors[v]
                else:
                    srv.add(y)
            elif y in srv:
                srv.add(x)
    return sum(su.isdisjoint(sv) for su, sv in combinations(survivors.values(), 2))


n, m = map(int, input().split())
pairs = []
for line in sys.stdin.readlines():
    x, y = map(int, line.split())
    pairs.append((x, y))
print(solve(n, pairs))
Problem p03693 (Python) — buggy submission, verdict: Runtime Error

print("YES" if int("".join(x for x in input().split())) % 4 == 0 else "NO")


Error: ValueError: invalid literal for int() with base 10: '4 3 2'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03693/Python/s741295906.py", line 1, in <module>
    print("YES" if int("".join(list(input()))) % 4 == 0 else "NO")
ValueError: invalid literal for int() with base 10: '4 3 2'


Fixed submission:

print("YES" if int("".join(list(input()))) % 4 == 0 else "NO")
Problem p03693 (Python) — buggy submission, verdict: Runtime Error

r, g, b = map(int, input().split())
ans = r * 100 + g * 10 + b

print("YES" if ans % 4 == 0 else "NO")


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


Fixed submission:

N = int(input())
a = list(map(int, input().split()))

min_color = 0
max_color = 0

cnt = 0

color = [0] * 8

for i in a:
    if i < 400 and color[0] == 0:
        min_color += 1
        max_color += 1
        color[0] = 1

    elif 400 <= i and i < 800 and color[1] == 0:
        min_color += 1
        max_color += 1
        color[1] = 1

    elif 800 <= i and i < 1200 and color[2] == 0:
        min_color += 1
        max_color += 1
        color[2] = 1

    elif 1200 <= i and i < 1600 and color[3] == 0:
        min_color += 1
        max_color += 1
        color[3] = 1

    elif 1600 <= i and i < 2000 and color[4] == 0:
        min_color += 1
        max_color += 1
        color[4] = 1

    elif 2000 <= i and i < 2400 and color[5] == 0:
        min_color += 1
        max_color += 1
        color[5] = 1

    elif 2400 <= i and i < 2800 and color[6] == 0:
        min_color += 1
        max_color += 1
        color[6] = 1

    elif 2800 <= i and i < 3200 and color[7] == 0:
        min_color += 1
        max_color += 1
        color[7] = 1

    elif i >= 3200:
        max_color += 1
        cnt += 1

if cnt == N:
    min_color = 1

print(min_color, max_color)
Problem p03693 (Python) — buggy submission, verdict: Runtime Error

import sys

input = sys.stdin.readline


def main():
    print("YES" if int("".join(input().split())) % 4 == 0 else "NO")


if __name__ == "__main__":
    main()


Error: ValueError: invalid literal for int() with base 10: '4 3 2\\n'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03693/Python/s962788387.py", line 11, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03693/Python/s962788387.py", line 7, in main
    print("YES" if int(input()) % 4 == 0 else "NO")
ValueError: invalid literal for int() with base 10: '4 3 2\\n'


Fixed submission:

import sys

input = sys.stdin.readline


def main():
    print("YES" if int(input()) % 4 == 0 else "NO")


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

print("NO " if int("".join(input().split())) % 4 else "YES")


Error: TypeError: unsupported operand type(s) for %: 'map' and 'int'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03693/Python/s438012053.py", line 1, in <module>
    print("NO " if map(int, "".join(input().split())) % 4 else "YES")
TypeError: unsupported operand type(s) for %: 'map' and 'int'


Fixed submission:

print("NO " if map(int, "".join(input().split())) % 4 else "YES")
Problem p03694 (Python) — buggy submission, verdict: Runtime Error

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


Error: 0

Fixed submission:

n = int(input())
a = [*map(int, input().split())]
a.sort()
ans = 0
for i in range(n - 1):
    ans += a[i + 1] - a[i]
print(ans)
Problem p03694 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
a_list = [int(i) for i in input().split()]
print(max(a_list) - min(a_list))


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/p03694/Python/s482748657.py", line 3, in <module>
    print(max[a_list] - min(a_list))
TypeError: 'builtin_function_or_method' object is not subscriptable


Fixed submission:

n = int(input())
a_list = [int(i) for i in input().split()]
print(max[a_list] - min(a_list))
Problem p03694 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
A = list(map(int, input().split()))
print(max(A) - min(A))


Error: ValueError: invalid literal for int() with base 10: '2 3 7 9'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03694/Python/s043066443.py", line 2, in <module>
    A = [int(input()) for i in range(N)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03694/Python/s043066443.py", line 2, in <listcomp>
    A = [int(input()) for i in range(N)]
ValueError: invalid literal for int() with base 10: '2 3 7 9'


Fixed submission:

N = int(input())
A = [int(input()) for i in range(N)]
print(max(A) - min(A))
Problem p03695 (Python) — buggy submission, verdict: Runtime Error

N = int(input())

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

C = [0] * 9

for i in range(N):
    if 1 <= A[i] <= 399:
        C[0] = 1
    elif 400 <= A[i] <= 799:
        C[1] = 1
    elif 800 <= A[i] <= 1199:
        C[2] = 1
    elif 1200 <= A[i] <= 1599:
        C[3] = 1
    elif 1600 <= A[i] <= 1999:
        C[4] = 1
    elif 2000 <= A[i] <= 2399:
        C[5] = 1
    elif 2400 <= A[i] <= 2799:
        C[6] = 1
    elif 2800 <= A[i] <= 3199:
        C[7] = 1
    else:
        C[8] += 1

num = sum(C[0:8])

ans1 = str(max(num, 1))
ans2 = str(num + C[8])
print(ans1 + " " + ans2)


Error: 0

Fixed submission:

N = int(input())

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

C = [0] * 9

for i in range(N):
    if 1 <= A[i] <= 399:
        C[0] += 1
    elif 400 <= A[i] <= 799:
        C[1] += 1
    elif 800 <= A[i] <= 1199:
        C[2] += 1
    elif 1200 <= A[i] <= 1599:
        C[3] += 1
    elif 1600 <= A[i] <= 1999:
        C[4] += 1
    elif 2000 <= A[i] <= 2399:
        C[5] += 1
    elif 2400 <= A[i] <= 2799:
        C[6] += 1
    elif 2800 <= A[i] <= 3199:
        C[7] += 1
    else:
        C[8] += 1

blank = C[0:8].count(0)

if blank == 0:
    print("8 8")
    exit()

if C[8] == 0:
    ans = str(8 - blank)
    print(ans + " " + ans)
    exit()
elif C[8] >= 8:
    ans = str(max(8 - blank, 1))
    print(ans + " " + 8)
elif 1 <= C[8] <= 7:
    ans = str(8 - blank)
    ans2 = str(min(8, 8 - blank + C[8]))
    print(ans + " " + ans2)
Problem p03695 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
an = list(map(int, input().split()))
over_cnt = 0
colors = []
for a in an:
    rate = a // 400
    if rate >= 8:
        over_cnt += 1
    elif rate not in colors:
        colors.append(rate)

print(max(len(colors), 1), len(colors) + over_cnt)


Error: TypeError: 'int' object is not callable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03695/Python/s943970974.py", line 13, in <module>
    max = min(len(colors) + over_cnt, 8)
TypeError: 'int' object is not callable


Fixed submission:

N = int(input())
an = list(map(int, input().split()))
over_cnt = 0
colors = []
for a in an:
    rate = a // 400
    if rate >= 8:
        over_cnt += 1
    elif rate not in colors:
        colors.append(rate)

min = len(colors)
max = min(len(colors) + over_cnt, 8)
print(min, max)
Problem p03695 (Python) — buggy submission, verdict: Runtime Error

def main():
    _ = int(input())
    A = list(map(int, input().split()))
    c = [False] * (4800 // 400 + 1)
    d = [0] * (4800 // 400 + 1)
    for a in A:
        c[a // 400] = True
        d[a // 400] += 1
    mn = 1 if c[:8].count(True) == 0 else c[:8].count(True)
    mx = c[:8].count(True) + sum(d[8:])
    print(mn, mx)


main()


Error: 0

Fixed submission:

def main():
    _ = int(input())
    A = list(map(int, input().split()))
    c = [False] * (4800 // 400 - 1)
    d = [0] * (4800 // 400 - 1)
    for a in A:
        c[a // 400] = True
        d[a // 400] += 1
    mn = 1 if c[:8].count(True) == 0 else c[:8].count(True)
    mx = c[:8].count(True) + sum(d[8:])
    print(mn, mx)


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

N = int(input())
a = list(map(int, input().split()))
colors = [0] * 9
for i in range(N):
    if 1 <= a[i] and a[i] <= 399:
        colors[0] = 1
    elif 400 <= a[i] and a[i] <= 799:
        colors[1] = 1
    elif 800 <= a[i] and a[i] <= 1199:
        colors[2] = 1
    elif 1200 <= a[i] and a[i] <= 1599:
        colors[3] = 1
    elif 1600 <= a[i] and a[i] <= 1999:
        colors[4] = 1
    elif 2000 <= a[i] and a[i] <= 2399:
        colors[5] = 1
    elif 2400 <= a[i] and a[i] <= 2799:
        colors[6] = 1
    elif 2800 <= a[i] and a[i] <= 3199:
        colors[7] = 1
    else:
        colors[8] += 1

if sum(colors[0:8]) == 0 and colors[8] >= 1:
    MIN = 1
else:
    MIN = sum(colors[0:8])
MAX = sum(colors)

print(MIN, MAX)


Error: TypeError: 'bool' object is not iterable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03695/Python/s269664657.py", line 23, in <module>
    if sum(colors[0:8] == 0) and colors[9] >= 1:
TypeError: 'bool' object is not iterable


Fixed submission:

N = int(input())
a = list(map(int, input().split()))
colors = [0] * 9
for i in range(N):
    if 1 <= a[i] and a[i] <= 399:
        colors[0] = 1
    elif 400 <= a[i] and a[i] <= 799:
        colors[1] = 1
    elif 800 <= a[i] and a[i] <= 1199:
        colors[2] = 1
    elif 1200 <= a[i] and a[i] <= 1599:
        colors[3] = 1
    elif 1600 <= a[i] and a[i] <= 1999:
        colors[4] = 1
    elif 2000 <= a[i] and a[i] <= 2399:
        colors[5] = 1
    elif 2400 <= a[i] and a[i] <= 2799:
        colors[6] = 1
    elif 2800 <= a[i] and a[i] <= 3199:
        colors[7] = 1
    else:
        colors[8] += 1
if sum(colors[0:8] == 0) and colors[9] >= 1:
    MIN = 1
else:
    MIN = sum(colors[0:8])
MAX = sum(colors)

print(MIN, MAX)
Problem p03697 (Python) — buggy submission, verdict: Runtime Error

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

a, b = map(int, readline().split())
ans = a + b if (a + b) < 10 else "error"
print(ans)


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


Fixed submission:

n = int(input())
s = [int(input()) for _ in range(n)]

score = sum(s)
s.sort()
i = 0
while score % 10 == 0:
    score -= s[i]
    i += 1
    if score == 0:
        break
print(score)
Problem p03697 (Python) — buggy submission, verdict: Runtime Error

#!/usr/bin/env python
# _*_ coding: utf-8 _*_
a = input()
a.split()
a.split()[1]

A = int(a.split()[0])
B = int(a.split()[1])

sum = A + B

if sum < 10:
    print(sum)

elif sum >= 10:
    print("error")


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


Fixed submission:

#!/usr/bin/env python
# _*_ coding utf-8 _*_

A = int(input())
B = int(input())

sum = A + B

if sum <= 10:
    print(sum)

elif sum > 10:
    print("error")
Problem p03698 (Python) — buggy submission, verdict: Runtime Error

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


def main():
    """Function."""
    s = str(input())
    check = set()

    for i in range(len(s)):
        check.add(s[i])

    if len(s) != len(check):
        print("no")
    else:
        print("yes")


if __name__ == "__main__":
    main()


Error: TypeError: 'str' object cannot be interpreted as an integer
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03698/Python/s295275910.py", line 19, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03698/Python/s295275910.py", line 9, in main
    for i in range(s):
TypeError: 'str' object cannot be interpreted as an integer


Fixed submission:

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


def main():
    """Function."""
    s = str(input())

    check = set()
    for i in range(s):
        check.add(s[i])

    if len(s) != len(s):
        print("no")
    else:
        print("yes")


if __name__ == "__main__":
    main()
Problem p03699 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys

input = sys.stdin.buffer.readline
n = int(input())
S = []
for _ in range(n):
    S.append(int(input()))
S.sort()
goukei = sum(S)
if goukei % 10 != 0:
    print(goukei)
    exit()
ans = 0
for i in range(n):
    temp = goukei - S[i]
    if temp % 10 == 0:
        temp = 0
    ans = max(ans, temp)

print(ans)


Error: TLE

Fixed submission:

import sys

input = sys.stdin.buffer.readline
n = int(input())
S = []
for _ in range(n):
    S.append(int(input()))
ans = 0
for i in range(1 << n):
    temp = 0
    for j in range(n):
        if (i >> j) & 1:
            temp += S[j]
    if temp % 10 == 0:
        temp = 0
    ans = max(temp, ans)
print(ans)
Problem p03699 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
s = [int(input()) for _ in range(n)]

dp = [set() for _ in range(n + 1)]
for i in range(n):
    dp[i + 1].update(dp[i])
    for x in dp[i]:
        dp[i + 1].add(x + s[i])
    dp[i + 1].add(s[i])


ans = 0
for x in dp[i + 1]:
    if x % 10 != 0:
        ans = max(ans, x)
print(ans)


Error: 0

Fixed submission:

n = int(input())
s = [int(input()) for _ in range(n)]

dp = [set() for _ in range(n + 1)]
for i in range(n):
    dp[i + 1].update(dp[i])
    for x in dp[i]:
        dp[i + 1].add(x + s[i])
    dp[i + 1].add(s[i])


ans = max((x for x in dp[i + 1] if x % 10 != 0), default=0)
print(ans)
Problem p03699 (Python) — buggy submission, verdict: Time Limit Exceeded

n = int(input())
s = [int(input()) for _ in range(n)]

total = sum(s)
s.sort()
if total % 10 != 0:
    print(total)
else:
    for i in range(n):
        if (total - s[i]) % 10 != 0:
            print(total - s[i])
            exit()
    print(0)


Error: TLE

Fixed submission:

n = int(input())
s = [int(input()) for _ in range(n)]


# total:累計, i:index
def dfs(total, i):
    if i == n:
        if total % 10 != 0:
            return total
        else:
            return 0
    return max(dfs(total, i + 1), dfs(total + s[i], i + 1))


print(dfs(0, 0))