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

#!/usr/bin/env python3
n, k, c = map(int, input().split())
s = input()

if c == 0:
    if s.count("o") == k:
        for i in range(n):
            if s[i] == "o":
                print(i + 1)
    exit()

left = []
i = 0
while i < n:
    if s[i] == "o":
        left.append(i)
        i += c
    i += 1

right = []
i = n - 1
while i >= 0:
    if s[i] == "o":
        right.append(i)
        i -= c
    i -= 1
right.reverse()
for i in range(len(left)):
    if left[i] == right[i]:
        print(left[i] + 1)


Error: 0

Fixed submission:

#!/usr/bin/env python3
n, k, c = map(int, input().split())
s = input()

if c == 0:
    if s.cnt("o") == k:
        print(*range(1, n + 1), sep="\\n")
    exit()

left = []
i = 0
while i < n:
    if s[i] == "o":
        left.append(i)
        i += c
    i += 1

right = []
i = n - 1
while i >= 0:
    if s[i] == "o":
        right.append(i)
        i -= c
    i -= 1
right.reverse()
for i in range(len(left)):
    if left[i] == right[i]:
        print(left[i] + 1)
Problem p02722 (Python) — buggy submission, verdict: Runtime Error

def make_divisors(n):
    lower_divisors, upper_divisors = [], []
    i = 1
    while i * i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n // i)
        i += 1
    return lower_divisors + upper_divisors[::-1]


n = int(input())

tmp = n - 1
ret = len(make_divisors(tmp)) - 1

tmplen = make_divisors(n)

for item in tmplen:
    if item == 1:
        continue
    val = n
    while True:
        if val % item == 0:
            val = val // item
        else:
            if val % item == 1:
                ret += 1
            break

print(ret)


Error: 0

Fixed submission:

import sympy

n = int(input())

tmp = n - 1
ret = len(sympy.divisors(tmp)) - 1

tmplen = sympy.divisors(n)

for item in tmplen:
    if item == 1:
        continue
    val = n
    while True:
        if val % item == 0:
            val = val // item
        else:
            if val % item == 1:
                ret += 1
            break

print(ret)
Problem p02723 (Python) — buggy submission, verdict: Runtime Error

s = input()
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02723/Python/s530567045.py", line 2, in <module>
    if s[2] == s[3] and s[4] == s[5]:
IndexError: list index out of range


Fixed submission:

s = input().split()
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")
Problem p02723 (Python) — buggy submission, verdict: Runtime Error

s = input()
if s[2] == s[3] and s[4] == s[5]:
    print("Yes")
else:
    print("No")


Error: WA

Fixed submission:

s = input()
if s[3] == s[4] and s[5] == s[6]:
    print("Yes")
else:
    print("No")
Problem p02723 (Python) — buggy submission, verdict: Runtime Error

s = str(input())

if s[2] == s[3]:
    if s[4] == s[5]:
        print("Yes")
        quit()

print("No")


Error: 0

Fixed submission:

s = str(input())

if s[2] == s[3]:
    if s[4] == s[5]:
        print("Yes")

else:
    print("No")
Problem p02723 (Python) — buggy submission, verdict: Runtime Error

S = input()
print("Yes" if S[2] == S[3] and S[4] == S[5] else "No")


Error: WA

Fixed submission:

S = input()
print("Yes" if S[3] == S[4] and S[5] == S[6] else "No")
Problem p02724 (Python) — buggy submission, verdict: Runtime Error

X = int(input())
ans = 0
ans += 1000 * (X // 500)
X = X % 500
ans += 5 * (X // 5)
print(ans)


Error: ValueError: not enough values to unpack (expected 5, got 1)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02724/Python/s107835112.py", line 4, in <module>
    X, Y, A, B, C = map(int, input().split())
ValueError: not enough values to unpack (expected 5, got 1)


Fixed submission:

from collections import deque
import copy

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

p1 = deque(p)
q1 = deque(q)
r1 = deque(r)
p2 = copy.deepcopy(p1)
q2 = copy.deepcopy(q1)
r2 = copy.deepcopy(r1)


ans = 0

ans1 = 0
for _ in range(X):
    if len(r1) > 0:
        if p1[0] > r1[0]:
            ans1 += p1.popleft()
        else:
            ans1 += r1.popleft()
    else:
        ans1 += p1.popleft()

for _ in range(Y):
    if len(r1) > 0:
        if q1[0] > r1[0]:
            ans1 += q1.popleft()
        else:
            ans1 += r1.popleft()
    else:
        ans1 += q1.popleft()

ans2 = 0
for _ in range(Y):
    if len(r2) > 0:
        if q2[0] > r2[0]:
            ans2 += q2.popleft()
        else:
            ans2 += r2.popleft()
    else:
        ans2 += q2.popleft()

for _ in range(X):
    if len(r2) > 0:
        if p2[0] > r2[0]:
            ans2 += p2.popleft()
        else:
            ans2 += r2.popleft()
    else:
        ans2 += p2.popleft()

ans = max(ans1, ans2)
print(ans)
Problem p02725 (Python) — buggy submission, verdict: Time Limit Exceeded

K, N = map(int, input().split())
houses = list(map(int, input().split()))
# syaku_houses = []
# for i, num in enumerate(houses):
#     if i == 0:
#         syaku_houses.append(num)
#     else:
#         syaku_houses.append(num - houses[i - 1])
# print(syaku_houses)

# min_costs = []
# for house in syaku_houses:

# 右回りか左回りか？
for i in range(N - 1):
    houses.append(K + houses[i])

min_costs = []
for i in range(N):
    min_costs.append(houses[N - 1 + i] - houses[i])
print(min(min_costs))


Error: TLE

Fixed submission:

K, N = map(int, input().split())
houses = list(map(int, input().split()))
# syaku_houses = []
# for i, num in enumerate(houses):
#     if i == 0:
#         syaku_houses.append(num)
#     else:
#         syaku_houses.append(num - houses[i - 1])
# print(syaku_houses)

# min_costs = []
# for house in syaku_houses:

# 右回りか左回りか？
reverse_houses = []
for i in range(N - 1):
    reverse_houses.insert(0, -1 * (K - houses[N - 1 - i]))
reverse_houses.reverse()
for house in reverse_houses:
    houses.insert(0, house)

min_costs = []
for i in range(N):
    min_costs.append(houses[N - 1 + i] - houses[i])
print(min(min_costs))
Problem p02725 (Python) — buggy submission, verdict: Runtime Error

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

result = []

for i in range(N):
    if i == N - 1:
        result.append(K - A[i] + A[0])
    else:
        result.append(A[i + 1] - A[i])

result.sort()

print(sum(result[:-1]))


Error: AttributeError: 'list' object has no attribute 'appnd'. Did you mean: 'append'?
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02725/Python/s465874099.py", line 10, in <module>
    result.appnd(A[i + 1] - A[i])
AttributeError: 'list' object has no attribute 'appnd'. Did you mean: 'append'?


Fixed submission:

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

result = []

for i in range(N):
    if i == N - 1:
        result.append(K - A[i] + A[0])
    else:
        result.appnd(A[i + 1] - A[i])

result.sort()

print(sum(result[:-1]))
Problem p02725 (Python) — buggy submission, verdict: Runtime Error

K, N = map(int, input().split())
A = [int(e) for e in input().split()]

ans = 0
S = [(A[i + 1] - A[i]) for i in range(N - 1)]
S.append((K - A[N - 1]) + A[0])
S.sort
m = sorted(S)
for n in range(N - 1):
    ans += m[n]
print(ans)


Error: WA

Fixed submission:

K, N = map(int, input().split())
A = [int(e) for e in input().split()]

ans = 0
for i in range(N - 1):
    S = [A[i + 1] - A[i]]
    S.append((K - A[N - 1]) + A[0])
    m = sorted(S)
    for n in range(N - 1):
        ans += m[n]
print(ans)
Problem p02725 (Python) — buggy submission, verdict: Time Limit Exceeded

import sys
import random


def test(K, N, A):
    ans = []
    maxp = N - 1
    minp = 0
    for i in range(len(A)):
        ans.append(A[maxp] - A[minp])
        A[i] += K
        maxp = (maxp + 1) % (N)
        minp = (minp + 1) % (N)
    print(min(ans))


if __name__ == "__main__":
    if "random" in sys.argv:
        K = int(random.random() * 20000)
        N = int(random.random() * 65536)
        A = sorted([int(random.random() * K) for _ in range(N)])
    else:
        K, N = [int(x) for x in input().split()]
        A = [int(x) for x in input().split()]
    test(K, N, A)
    pass


Error: TLE

Fixed submission:

K, N = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = []
for i in range(len(A)):
    ans.append(max(A) - min(A))
    A[i] += K

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

import numpy as np

N, X, Y = [int(_) for _ in input().split()]
X -= 1
Y -= 1
cnt = np.zeros(N, dtype=int)
for i in range(0, (X + Y) // 2):
    # t-i<=abs(i-X)+1+Y-t
    # 2*t<=abs(i-X)+1+Y+i
    # t<= tmax = 0 - - (abs(i-X)+1+Y+i)//2
    # tmin=i-X+1
    # range(tmin,tmin+Y-tmax) + range(1,tmax-i+1) + range(tmin+1,tmin+N-Y)
    tmin = abs(i - X) + 1
    tmax = 0 - -(abs(i - X) + 1 + Y + i) // 2
    cnt[1 : tmax - i] += 1
    cnt[tmin : tmin + Y - tmax + 1] += 1
    cnt[tmin + 1 : tmin + N - Y] += 1
for i in range((X + Y) // 2, N):
    cnt[1 : N - i] += 1
print(*cnt[1:], sep="\\n")


Error: TLE

Fixed submission:

import numpy as np
from scipy.sparse.csgraph import floyd_warshall
from scipy.sparse import lil_matrix

N, X, Y = [int(_) for _ in input().split()]
G = lil_matrix((N, N))
G[X - 1, Y - 1] = 1
for i in range(N - 1):
    G[i, i + 1] = 1
D = floyd_warshall(G, directed=False)
for i in range(1, N):
    print(np.sum(D == i) // 2)
Problem p02726 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import deque, Counter

n, x, y = map(int, input().split())

inf = 100100100
x -= 1
y -= 1

ans = [0] * n

for i in range(n):
    dist = [inf] * n
    queue = deque()
    queue.append(i)
    dist[i] = 0
    while queue:
        current = queue.popleft()
        d = dist[current]

        if current - 1 >= 0 and dist[current - 1] == inf:
            queue.append(current - 1)
            dist[current - 1] = d + 1
        if current + 1 < n and dist[current + 1] == inf:
            queue.append(current + 1)
            dist[current + 1] = d + 1
        if current == x and dist[y] == inf:
            queue.append(y)
            dist[y] = d + 1
        if current == y and dist[x] == inf:
            queue.append(x)
            dist[x] = d + 1

    for j in range(n):
        ans[dist[j]] += 1

for k in range(1, n):
    print(ans[k] // 2)


Error: TLE

Fixed submission:

from collections import deque

n, x, y = map(int, input().split())

inf = 100100100

x -= 1
y -= 1

ans = [0] * n

for i in range(n):
    dist = [inf] * n
    queue = deque()
    queue.append(i)
    dist[i] = 0
    while queue:
        current = queue.popleft()
        d = dist[current]

        if current - 1 >= 0 and dist[current - 1] == inf:
            queue.append(current - 1)
            dist[current - 1] = d + 1
        if current + 1 < n and dist[current + 1] == inf:
            queue.append(current + 1)
            dist[current + 1] = d + 1
        if current == x and dist[y] == inf:
            queue.append(y)
            dist[y] = d + 1
        if current == y and dist[x] == inf:
            queue.append(x)
            dist[x] = d + 1

    for j in range(n):
        ans[dist[j]] += 1

for k in range(1, n):
    print(ans[k] // 2)
Problem p02726 (Python) — buggy submission, verdict: Time Limit Exceeded

n, x, y = list(map(int, input().split()))
x -= 1
y -= 1

cnt = [0] * n

dist = []
for i in range(n):
    dist.append([-1] * n)
for i in range(n):
    dist[i][x] = abs(i - x)
    dist[i][y] = abs(i - y)
    dist[x][i] = abs(i - x)
    dist[y][i] = abs(i - y)

for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        dis = min(j - i, dist[j][y] + 1 + dist[i][x], dist[j][x] + 1 + dist[i][y])
        cnt[dis] += 1
for i in range(1, n):
    print(cnt[i])


Error: TLE

Fixed submission:

n, x, y = list(map(int, input().split()))
x -= 1
y -= 1

cnt = [0] * n
for i in range(n):
    for j in range(n):
        if i >= j:
            continue
        dist = min(j - i, abs(j - y) + 1 + abs(i - x), abs(j - x) + 1 + abs(i - y))
        cnt[dist] += 1
for i in range(1, n):
    print(cnt[i])
Problem p02726 (Python) — buggy submission, verdict: Time Limit Exceeded

from collections import defaultdict

n, x, y = map(int, input().strip().split())

x -= 1
y -= 1

dist_counts = defaultdict(int)
for i in range(n):
    for j in range(i + 1, n):
        path1 = abs(j - i)
        path2 = abs(x - i) + 1 + abs(y - j)
        dist = min(abs(j - i), path2)
        dist_counts[dist] += 1

for k in range(1, n):
    print(dist_counts[k])


Error: TLE

Fixed submission:

import numpy as np
from collections import defaultdict

n, x, y = map(int, input().strip().split())

x -= 1
y -= 1

inf = 1000000000
dist = np.full((n, n), inf, dtype=np.int)

for i in range(n):
    for j in range(n):
        if i == j:
            dist[i][j] = 0
        else:
            path1 = abs(j - i)
            path2 = abs(x - i) + 1 + abs(y - j)
            dist[i][j] = min(abs(j - i), path2)

dist_counts = defaultdict(int)
for i in range(n):
    for j in range(i + 1, n):
        d = dist[i][j]
        dist_counts[d] += 1

for k in range(1, n):
    print(dist_counts[k])
Problem p02726 (Python) — buggy submission, verdict: Time Limit Exceeded

n, x, y = map(int, input().split())
ans = [0] * n
a = [n] * n
x -= 1
y -= 1
for i in range(0, n):
    a = [n] * n
    a[i] = 0
    b = [i, x, y, x, y]
    for k in b:
        for j in range(k, 0, -1):
            if j == x:
                a[y] = min(a[y], a[j] + 1)
            if j == y:
                a[x] = min(a[x], a[j] + 1)
            a[j - 1] = min(a[j - 1], a[j] + 1)
        for j in range(k, n - 1):
            if j == x:
                a[y] = min(a[y], a[j] + 1)
            if j == y:
                a[x] = min(a[x], a[j] + 1)
            a[j + 1] = min(a[j + 1], a[j] + 1)
    for k in range(0, n):
        ans[a[k]] += 1
for i in range(1, n):
    print(ans[i] // 2)


Error: TLE

Fixed submission:

n, x, y = map(int, input().split())
ans = [0] * n
a = [n] * n
x -= 1
y -= 1
for i in range(0, n):
    a = [n] * n
    a[i] = 0
    for j in range(i, 0, -1):
        if j == x:
            a[y] = min(a[y], a[j] + 1)
        if j == y:
            a[x] = min(a[x], a[j] + 1)
        a[j - 1] = min(a[j - 1], a[j] + 1)
    for j in range(i, n - 1):
        if j == x:
            a[y] = min(a[y], a[j] + 1)
        if j == y:
            a[x] = min(a[x], a[j] + 1)
        a[j + 1] = min(a[j + 1], a[j] + 1)
    for j in range(x, 0, -1):
        if j == x:
            a[y] = min(a[y], a[j] + 1)
        if j == y:
            a[x] = min(a[x], a[j] + 1)
        a[j - 1] = min(a[j - 1], a[j] + 1)
    for j in range(x, n - 1):
        if j == x:
            a[y] = min(a[y], a[j] + 1)
        if j == y:
            a[x] = min(a[x], a[j] + 1)
        a[j + 1] = min(a[j + 1], a[j] + 1)
    for j in range(y, 0, -1):
        if j == x:
            a[y] = min(a[y], a[j] + 1)
        if j == y:
            a[x] = min(a[x], a[j] + 1)
        a[j - 1] = min(a[j - 1], a[j] + 1)
    for j in range(y, n - 1):
        if j == x:
            a[y] = min(a[y], a[j] + 1)
        if j == y:
            a[x] = min(a[x], a[j] + 1)
        a[j + 1] = min(a[j + 1], a[j] + 1)
    for k in range(0, n):
        if k != i:
            ans[a[k]] += 1
for i in range(1, n):
    print(ans[i] // 2)
Problem p02726 (Python) — buggy submission, verdict: Time Limit Exceeded

n, x, y = map(int, input().split())

ans = [0] * n
for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        ans[
            min(j - i, min(abs(i - x) + 1 + abs(y - j), abs(i - y) + 1 + abs(x - j)))
        ] += 1

for x in ans[1:]:
    print(x)


Error: TLE

Fixed submission:

n, x, y = map(int, input().split())

inf = 1000000000
edges = [[inf] * n for _ in range(n)]
for i in range(n - 1):
    edges[i][i + 1] = 1
    edges[i + 1][i] = 1

edges[x - 1][y - 1] = 1

for k in range(n):
    for i in range(n):
        for j in range(n):
            edges[i][j] = min(edges[i][j], edges[i][k] + edges[k][j])

cnts = [0] * (n - 1)
for i in range(n - 1):
    for j in range(i + 1, n):
        cnts[edges[i][j] - 1] += 1

for x in cnts:
    print(x)
Problem p02726 (Python) — buggy submission, verdict: Time Limit Exceeded

# D - Line++

n, x, y = map(int, input().split())
x, y = x - 1, y - 1

cnt = [0] * n
for i in range(n):
    for j in range(i + 1, n):
        dist = min(j - i, abs(x - i) + abs(y - j) + 1)
        cnt[dist] += 1

for i in range(1, len(cnt)):
    print(cnt[i])


Error: TLE

Fixed submission:

# D - Line++

import queue

N, X, Y = map(int, input().split())
X, Y = X - 1, Y - 1
M = [(i, []) for i in range(N)]
for i in range(N):
    if i != 0:
        M[i][1].append(i - 1)
    if i != N - 1:
        M[i][1].append(i + 1)
    if i == X:
        M[X][1].append(Y)
    if i == Y:
        M[Y][1].append(X)

cost = [[-1] * N for _ in range(N)]
p = [[None] * N for _ in range(N)]
Q = queue.Queue()

for i in range(N):
    Q.put(M[i])
    key = M[i][0]
    cost[key][key] = 0
    p[key][key] = key
    while not Q.empty():
        q = Q.get()
        for j in q[1]:
            if cost[i][j] == -1:
                p[i][j] = q[0]
                cost[i][j] = cost[i][p[i][j]] + 1
                Q.put(M[j])

ans = [0] * N
for i in range(N):
    for j in range(N):
        ans[cost[i][j]] += 1

for i in range(1, N):
    print(int(ans[i] / 2))
Problem p02726 (Python) — buggy submission, verdict: Runtime Error

n, x, y = map(int, input().split())
cnt = [0] * n
# 漸化式が建てられそうでめんどくさい場合は、片方を固定する
# 端点を固定する 1..n-2 から順に大きい頂点に向かって伸びていく
for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x - 1:
            if j <= x - 1:  # 1 idx
                cnt[j - i] += 1
            elif j <= y - 1:
                cnt[min(j - i, x + y - i - j - 1)] += 1
            else:
                cnt[x - y - i + j + 1] += 1
        elif x - 1 < x <= y - 1:
            if j <= y - 1:
                cnt[min(j - i, 1 + (i - x + 1) + (y - 1 - j))] += 1
            else:
                cnt[min((j - i), 1 + (i - x + 1) + (j - y + 1))] += 1
        else:
            cnt[j - i] += 1

for i in range(1, n):
    print(cnt[i])


Error: TypeError: 'int' object is not iterable
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02726/Python/s903600229.py", line 18, in <module>
    cnt[min(j - i), 1 + (i - x + 1) + (j - y + 1)] += 1
TypeError: 'int' object is not iterable


Fixed submission:

n, x, y = map(int, input().split())
cnt = [0] * n
# 漸化式が建てられそうでめんどくさい場合は、片方を固定する
# 端点を固定する 1..n-2 から順に大きい頂点に向かって伸びていく
for i in range(n - 1):
    for j in range(i + 1, n):
        if i <= x - 1:
            if j <= x - 1:  # 1 idx
                cnt[j - i] += 1
            elif j <= y - 1:
                cnt[min(j - i, x + y - i - j - 1)] += 1
            else:
                cnt[x - y - i + j + 1] += 1
        elif x - 1 < x <= y - 1:
            if j <= y - 1:
                cnt[min(j - i, 1 + (i - x + 1) + (y - 1 - j))] += 1
            else:
                cnt[min(j - i), 1 + (i - x + 1) + (j - y + 1)] += 1
        else:
            cnt[j - i] += 1

for i in range(1, n):
    print(cnt[i])
Problem p02726 (Python) — buggy submission, verdict: Time Limit Exceeded

#!/usr/bin/python3

(n, x, y) = map(int, input().split())

cs = [0 for i in range(n)]

for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        d = min(abs(j - i), abs(x - i) + 1 + abs(j - y))
        cs[d] += 1

for i in range(1, n):
    print(cs[i])


Error: TLE

Fixed submission:

#!/usr/bin/python3

(n, x, y) = map(int, input().split())

cs = [0 for i in range(n)]

for i in range(1, n + 1):
    for j in range(i + 1, n + 1):
        d = min(abs(j - i), abs(x - i) + 1 + abs(j - y), abs(y - i) + 1 + abs(j - x))
        if d == (abs(y - i) + 1 + abs(j - x)):
            print(i, j, d)
        cs[d] += 1

for i in range(1, n):
    print(cs[i])
Problem p02726 (Python) — buggy submission, verdict: Time Limit Exceeded

N, X, Y = map(int, input().split())

dist_from_X = list(abs(i - (X - 1)) for i in range(N))
dist_from_Y = list(abs(i - (Y - 1)) for i in range(N))

ans_list = [0] * N

for i in range(N):
    for j in range(i, N):
        i_X_Y_j = dist_from_X[i] + 1 + dist_from_Y[j]
        i_Y_X_j = dist_from_Y[i] + 1 + dist_from_X[j]
        i_j = abs(i - j)
        min_dist_i_j = min(i_X_Y_j, i_Y_X_j, i_j)
        ans_list[min_dist_i_j] += 1

for num in ans_list[1:]:
    print(num)


Error: TLE

Fixed submission:

N, X, Y = map(int, input().split())

dist_from_X = list(abs(i - (X - 1)) for i in range(N))
dist_from_Y = list(abs(i - (Y - 1)) for i in range(N))

ans_list = [0] * N

for i in range(N):
    for j in range(N):
        i_X_Y_j = dist_from_X[i] + 1 + dist_from_Y[j]
        i_Y_X_j = dist_from_Y[i] + 1 + dist_from_X[j]
        i_j = abs(i - j)
        min_dist_i_j = min(i_X_Y_j, i_Y_X_j, i_j)
        ans_list[min_dist_i_j] += 1

for num in ans_list[1:]:
    print(num // 2)
Problem p02726 (Python) — buggy submission, verdict: Runtime Error

from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np
from collections import Counter

N, X, Y = map(int, input().split())
F = [[0 for i in range(N)] for j in range(N)]

for i in range(N - 1):
    F[i][i + 1] = 1
    F[i + 1][i] = 1
F[X - 1][Y - 1] = 1
F[Y - 1][X - 1] = 1

G = csgraph_from_dense(F, null_value=0)
d = dijkstra(G)

# print(F)
# print(d)

# print(np.count_nonzero(d == 1))
s = Counter(d.flatten().astype(np.int64))
# print(s)
for i in range(1, N):
    if i in s:
        print(s[i] // 2)
    else:
        print(0)


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


Fixed submission:

from scipy.sparse.csgraph import csgraph_from_dense, dijkstra
import numpy as np

N, X, Y = map(int, input().split())
F = [[0 for i in range(N)] for j in range(N)]

for i in range(N - 1):
    F[i][i + 1] = 1
    F[i + 1][i] = 1
F[X - 1][Y - 1] = 1
F[Y - 1][X - 1] = 1

G = csgraph_from_dense(F, null_value=0)
d = dijkstra(G)

# print(F)
# print(d)

# print(np.count_nonzero(d == 1))
for i in range(1, N):
    print(np.count_nonzero(d == i) // 2)
Problem p02726 (Python) — buggy submission, verdict: Runtime Error

N, X, Y = map(int, input().split())


dic = {}

X = X - 1
Y = Y - 1

for i in range(N):
    for j in range(i + 1, N):
        if i <= X and Y <= j:
            v = X - i + 1 + j - Y
        elif (i <= X) and (X <= j and j <= Y):
            v = min(j - i, X - i + 1 + Y - j)
        elif (X <= i and i <= Y) and Y <= j:
            v = min(j - i, i - X + 1 + j - Y)
        elif (X <= i and i <= Y) and (X <= j and j <= Y):
            v = min(j - i, i - X + 1 + Y - j)
        else:
            v = j - i

        if v in dic:
            dic[v] += 1
        else:
            dic[v] = 1


for i in range(1, N):
    if i in dic:
        print(dic[i])
    else:
        print(0)


Error: KeyError: 4
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02726/Python/s708368036.py", line 29, in <module>
    print(dic[i])
KeyError: 4


Fixed submission:

N, X, Y = map(int, input().split())


dic = {}

X = X - 1
Y = Y - 1

for i in range(N):
    for j in range(i + 1, N):
        if i <= X and Y <= j:
            v = X - i + 1 + j - Y
        elif (i <= X) and (X <= j and j <= Y):
            v = min(j - i, X - i + 1 + Y - j)
        elif (X <= i and i <= Y) and Y <= j:
            v = min(j - i, i - X + 1 + j - Y)
        elif (X <= i and i <= Y) and (X <= j and j <= Y):
            v = min(j - i, i - X + 1 + Y - j)
        else:
            v = j - i

        if v in dic:
            dic[v] += 1
        else:
            dic[v] = 1


for i in range(1, N):
    print(dic[i])