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

import math
from functools import reduce
import fractions


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)


N, X = map(int, input().split())
x = list(map(int, input().split()))
dif = [abs(X - x[0])]

if N > 1:
    for i in range(N - 1):
        dif.append(x[i + 1] - x[i])
print(abs(gcd_list(dif)))


Error: 0

Fixed submission:

import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def gcd_list(numbers):
    return reduce(math.gcd, numbers)


N, X = map(int, input().split())
x = list(map(int, input().split()))
dif = [abs(X - x[0])]

if N > 1:
    for i in range(N - 1):
        dif.append(x[i + 1] - x[i])
print(gcd_list(dif))
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

import numpy as np
import math
from functools import reduce

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


def gcd(a: int, b: int):
    return gcd(b, a % b) if b else a


N, X = map(int, input().split())
x = list(map(int, input().split()))

d = np.zeros(N, dtype=int)
for n in range(N):
    d[n] = x[n] - X

ret = abs(reduce(gcd, d))

# print(d)
print(ret)


Error: TLE

Fixed submission:

import numpy as np
import math
from functools import reduce

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

N, X = map(int, input().split())
x = list(map(int, input().split()))

d = np.zeros(N, dtype=int)
for n in range(N):
    d[n] = x[n] - X

gcd = reduce(math.gcd, d)

# print(d)
print(gcd)
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

import fractions

N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
# print(N, X, x)

minimum = x[0]
for i in range(len(x)):
    x[i] = x[i] - X
    minimum = min(x[i], minimum)
# print(x, minimum)

gcd_value = fractions.gcd(x[0], x[0])
for i in range(len(x)):
    gcd_value = abs(fractions.gcd(gcd_value, x[i]))
    # print(gcd)
print(gcd_value)


Error: 0

Fixed submission:

import math


N, X = list(map(int, input().split()))
x = list(map(int, input().split()))
# print(N, X, x)

minimum = x[0]
for i in range(len(x)):
    x[i] = x[i] - X
    minimum = min(x[i], minimum)
# print(x, minimum)

gcd_value = math.gcd(x[0], x[0])
for i in range(len(x)):
    gcd_value = math.gcd(gcd_value, x[i])
    # print(gcd)
print(gcd_value)
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

def gcd(a, b):
    if b > a:
        a, b = b, a
    c = a % b
    if c == 0:
        return b
    return gcd(b, c)


N, X = list(map(int, input().split()))
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()

m = xlist[1] - xlist[0]
for i in range(1, len(xlist) - 1):
    d = xlist[i + 1] - xlist[i]
    m = gcd(d, m)
print(m)


Error: 0

Fixed submission:

import math

N, X = list(map(int, input().split()))
xlist = list(map(int, input().split()))
xlist.append(X)
xlist.sort()

m = xlist[1] - xlist[0]
for i in range(1, len(xlist) - 1):
    d = xlist[i + 1] - xlist[i]
    m = math.gcd(d, m)
print(m)
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

from functools import reduce


def gcd(a, b):
    if a < b:
        a, b = b, a
    while b != 0:
        a, b = b, a % b
    return a


def gcd_from_list(vals):
    return reduce(gcd, vals)


n, x = map(int, input().split())
c = [abs(x - xn) for xn in map(int, input().split())]
print(gcd_from_list(c))


Error: 0

Fixed submission:

def gcd(*args):
    a, *args = args
    if len(args) == 0:
        return a
    elif len(args) > 1:
        return gcd(a, gcd(*args))
    else:
        b = args[0]
        if a < b:
            a, b = b, a
        while b != 0:
            a, b = b, a % b
        return a


n, x = map(int, input().split())
c = [abs(x - xn) for xn in map(int, input().split())]
print(gcd(*c))
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd

n, X = map(int, input().split())
x = list(map(int, input().split()))

z = list(map(lambda i: abs(X - i), x))
ans = z[0]
for i in range(1, n):
    ans = gcd(ans, z[i])
print(ans)


Error: 0

Fixed submission:

import math
from functools import reduce

n, X = map(int, input().split())
x = [int(i) - X for i in input().split()]

print(reduce(math.gcd, x))
Problem p03263 (Python) — buggy submission, verdict: Runtime Error

import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    answer = []
    for h in range(H):
        for w in range(W):
            if A[h][w] % 2 == 0:
                continue
            else:
                if h + 1 <= H - 1 and w + 1 <= W - 1:
                    if A[h + 1][w] % 2 == 1:
                        A[h + 1][w] += 1
                        answer.append([h + 1, w + 1, h + 2, w + 1])
                    else:
                        A[h][w + 1] += 1
                        answer.append([h + 1, w + 1, h + 1, w + 2])
                elif h + 1 <= H - 1:
                    A[h + 1][w] += 1
                    answer.append([h + 1, w + 1, h + 2, w + 1])
                elif w + 1 <= W - 1:
                    A[h][w + 1] += 1
                    answer.append([h + 1, w + 1, h + 1, w + 2])
                else:
                    continue
    N = len(answer)
    print(N)
    for i in range(N):
        print(*answer[i], sep=" ")


if __name__ == "__main__":
    main()


Error: WA

Fixed submission:

import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)


def main():
    H, W = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(H)]
    answer = []
    for h in range(H):
        for w in range(W):
            if A[h][w] % 2 == 0:
                continue
            else:
                if h + 1 <= H - 1 and w + 1 <= W + 1:
                    if A[h + 1][w] % 2 == 1:
                        A[h + 1][w] += 1
                        answer.append([h + 1, w + 1, h + 2, w + 1])
                    else:
                        A[h][w + 1] += 1
                        answer.append([h + 1, w + 1, h + 1, w + 2])
                elif h + 1 <= H - 1:
                    A[h + 1][w] += 1
                    answer.append([h + 1, w + 1, h + 2, w + 1])
                elif w + 1 <= W - 1:
                    A[h][w + 1] += 1
                    answer.append([h + 1, w + 1, h + 1, w + 2])
                else:
                    continue
    N = len(answer)
    print(N)
    for i in range(N):
        print(*answer[i], sep=" ")


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

h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
r, c, d = 0, 0, 3
ret = []
for y in range(h * w - 1):
    if y % w == 0:
        d = (d + 1) % 4
    if y % w == w - 1:
        d = (d + 1) % 4
    dy, dx = [(0, 1), (1, 0), (0, -1), (1, 0)][d]
    if a[r][c] % 2 != 0:
        ret.append((r, c, r + dy, c + dx))
        a[r + dy][c + dx] += 1
    r, c = r + dy, c + dx
print(len(ret))
for r1, c1, r2, c2 in ret:
    print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)


Error: WA

Fixed submission:

h, w = map(int, input().split())
a = [list(map(int, input().split())) for i in range(h)]
r, c, d = 0, 0, 3
ret = []
for y in range(h * w - 1):
    if y % w == 0 or y % w == w - 1:
        d = (d + 1) % 4
    dy, dx = [(0, 1), (1, 0), (0, -1), (1, 0)][d]
    if a[r][c] % 2 != 0:
        ret.append((r, c, r + dy, c + dx))
        a[r + dy][c + dx] += 1
    r, c = r + dy, c + dx
print(len(ret))
for r1, c1, r2, c2 in ret:
    print(r1 + 1, c1 + 1, r2 + 1, c2 + 1)
Problem p03263 (Python) — buggy submission, verdict: Runtime Error

import sys

H, W = map(int, input().split())
A = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(H)]

res = []
for i in range(H):
    for j in range(W):
        if A[i][j] % 2 != 0 and j < W - 1:
            A[i][j] -= 1
            A[i][j + 1] += 1
            res.append([i + 1, j + 1, i + 1, j + 2])
        elif A[i][j] % 2 != 0 and i != H - 1 and j == W - 1:
            A[i][j] -= 1
            A[i + 1][j] += 1
            res.append([i + 1, j + 1, i + 2, j + 1])
print(len(res))
for i in range(len(res)):
    print(*res[i])


Error: WA

Fixed submission:

import sys

H, W = map(int, input().split())
A = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(H)]

res = []
for i in range(H):
    for j in range(W):
        if A[i][j] % 2 != 0 and i < W - 1:
            A[i][j] -= 1
            A[i][j + 1] += 1
            res.append([i + 1, j + 1, i + 2, j + 1])
        elif A[i][j] % 2 != 0 and i != H - 1 and j == W - 1:
            A[i][j] -= 1
            A[i + 1][j] += 1
            res.append([i + 1, j + 1, i + 1, j + 2])
print(len(res))
for i in range(len(res)):
    print(*res[i])
Problem p03263 (Python) — buggy submission, verdict: Runtime Error

h, w = map(int, input().split())
T = [[] for i in range(h)]
S = [[0] * w for i in range(h)]
for i in range(h):
    a = list(map(int, input().split()))
    T[i] = a

for i in range(h):
    for j in range(w):
        T[i][j] = T[i][j] % 2

move = []
i = 0
j = 0
k = 0
flag = False
while True:
    px, py = i, j
    if T[i][j] == 1:
        flag = True
    if i % 2 == 0:
        j += 1
        if j == w:
            j -= 1
            i += 1
        if i == h:
            break
        if flag:
            move.append((px, py, i, j))
        if flag and T[i][j] == 1:
            T[i][j] = 0
            flag = False
        k += 1
    else:
        j -= 1
        if j == -1:
            j += 1
            i += 1
        if i == h:
            break
        if flag:
            move.append((px, py, i, j))
        if flag and T[i][j] == 1:
            T[i][j] = 0
            flag = False

print(len(move))
for i in range(len(move)):
    x, y, w, z = move[i][0] + 1, move[i][1] + 1, move[i][2] + 1, move[i][3] + 1
    print(x, y, w, z)


Error: WA

Fixed submission:

h, w = map(int, input().split())
T = [[] for i in range(h)]
S = [[0] * w for i in range(h)]
for i in range(h):
    a = list(map(int, input().split()))
    T[i] = a

for i in range(h):
    for j in range(w):
        T[i][j] = T[i][j] % 2

rec = []
for i in range(h):
    for j in range(w):
        if T[i][j] == 1:
            rec.append((i, j))

rec = sorted(rec)
rec = sorted(rec, key=lambda s: s[1])
move = []
for i in range(0, len(rec), 2):
    if i + 1 == len(rec):
        break
    a, b = rec[i], rec[i + 1]
    sx = a[0]
    sy = a[1]
    tx = b[0]
    ty = b[1]
    while sx != tx and S[sx][sy] != 1:
        move.append((sx, sy, sx + 1, sy))
        S[sx][sy] = 1
        sx += 1
    if sy <= ty:
        while sy != ty and S[sx][sy] != 1:
            move.append((sx, sy, tx, sy + 1))
            S[sx][sy] = 1
            sy += 1
    else:
        while sy != ty and S[sx][sy] != 1:
            move.append((sx, sy, tx, sy - 1))
            S[sx][sy] = 1
            sy -= 1

print(len(move))
for i in range(len(move)):
    x, y, w, z = move[i][0] + 1, move[i][1] + 1, move[i][2] + 1, move[i][3] + 1
    print(x, y, w, z)
Problem p03263 (Python) — buggy submission, verdict: Runtime Error

H, W = map(int, input().split())
G = [list(map(int, input().split())) for i in range(H)]

N = 0
ans = []
for h in range(H):
    for w in range(W - 1):
        if G[h][w] % 2 == 1:
            N += 1
            ans.append((h, w, h, w + 1))
            G[h][w + 1] += 1
            G[h][w] -= 1

for h in range(H - 1):
    if G[h][W - 1] % 2 == 1:
        N += 1
        ans.append((h, W - 1, h + 1, W - 1))
        G[h + 1][W - 1] += 1
        G[h][W - 1] -= 1

print(N)
for y1, x1, y2, x2 in ans:
    print(y1 + 1, x1 + 1, y2 + 1, x2 + 1)


Error: WA

Fixed submission:

H, W = map(int, input().split())
G = [list(map(int, input().split())) for i in range(H)]

N = 0
ans = []
for h in range(H):
    for w in range(W - 1):
        if G[h][w] % 2 == 1:
            N += 1
            ans.append((h, w, h, w + 1))
            G[h][w + 1] += 1
            G[h][w] -= 1

for h in range(H - 1):
    if G[h][W - 1] % 2 == 1:
        N += 1
        ans.append((h, w, h + 1, w))
        G[h + 1][W - 1] += 1
        G[h][W - 1] -= 1

print(N)
for y1, x1, y2, x2 in ans:
    print(y1 + 1, x1 + 1, y2 + 1, x2 + 1)
Problem p03265 (Python) — buggy submission, verdict: Runtime Error

import numpy as np

x_1, y_1, x_2, y_2 = map(int, input().split())

P_1 = np.array([x_1, y_1])
P_2 = np.array([x_2, y_2])
vec_12 = P_2 - P_1
vec_13 = np.array([-vec_12[1], vec_12[0]])
P_3 = P_1 + vec_13
P_4 = P_2 + vec_13
print(P_4[0], P_4[1], P_3[0], P_3[1])


Error: TLE

Fixed submission:

import numpy as np

x_1, y_1, x_2, y_2 = map(int, input().split())

P_1 = np.array([x_1, y_1])
P_2 = np.array([x_2, y_2])
vec_12 = P_2 - P_1
vec_13 = np.array([-vec_12[1], vec_12[0]])
P_3 = P_1 + vec_13
P_4 = P_2 + vec_13
print(P_3[0], P_3[1], P_4[1], P_4[2])
Problem p03266 (Python) — buggy submission, verdict: Time Limit Exceeded

a, b = map(int, input().split())
c = []
d = []
for i in range(1, a + 1):
    if i % b == 0:
        c.append(i)
    elif i % b == b / 2:
        d.append(i)
e = 0
print(len(c) * len(c) * len(c) + len(d) * len(d) * len(d))


Error: TLE

Fixed submission:

import itertools

a, b = map(int, input().split())
c = []
for i in range(1, a + 1):
    if i % b == 0 or i % b == b / 2:
        c.append(i)
d = 0
for i in itertools.product(c, repeat=3):
    if (i[0] + i[1]) % b == 0 and (i[0] + i[2]) % b == 0 and (i[1] + i[2]) % b == 0:
        d += 1
print(d)
Problem p03266 (Python) — buggy submission, verdict: Time Limit Exceeded

N, K = list(map(int, input().split()))
c = N // K
d = 0
for i in range(1, N + 1):
    if K % 2 == 0 and i % K == K // 2:
        d += 1
print(c**3 + d**3)


Error: TLE

Fixed submission:

N, K = list(map(int, input().split()))
c = 0
for i in range(1, N + 1):
    a = 0
    if (i + i) % K == 0:
        for j in range(1, N + 1):
            if (i + j) % K == 0:
                a += 1
    c += a * a
print(c)
Problem p03272 (Python) — buggy submission, verdict: Runtime Error

l = [int(x) for x in input().split()]

ans = l[0] - l[1] + 1
print(ans)


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


Fixed submission:

a = int(input())
b = int(input())

ans = a - b + 1
print(ans)
Problem p03272 (Python) — buggy submission, verdict: Runtime Error

n, i = map(int, input().split())
print(n - i + 1)


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


Fixed submission:

n, i = map(int, input())
print(n - i + 1)
Problem p03272 (Python) — buggy submission, verdict: Runtime Error

"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import numpy as np

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

N, i = map(int, readline().split())
print(N - i + 1)


Error: ValueError: too many values to unpack (expected 2)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03272/Python/s252613778.py", line 14, in <module>
    N, i = map(int, readline())
ValueError: too many values to unpack (expected 2)


Fixed submission:

"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import numpy as np

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

N, i = map(int, readline())
print(N - i + 1)
Problem p03272 (Python) — buggy submission, verdict: Runtime Error

a, b = map(int, input().split())
print(a + 1 - b)
# Source code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 charactersSource code should be longer than 50 characters


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


Fixed submission:

x = int(input())
y = int(input())
if x == y:
    print(y)
else:
    print(y - x + 1)
Problem p03273 (Python) — buggy submission, verdict: Runtime Error

h, w = map(int, input().split())
a = [input() for w in range(h)]

for i in range(h)[::-1]:
    if "#" not in a[i]:
        del a[i]
        h -= 1

n = []
for j in range(w):
    m = ["".join(t[j] for t in a)]
    if "#" in m[0]:
        n += m

for k in range(h):
    print("".join(u[k] for u in n))


Error: WA

Fixed submission:

h, w = map(int, input().split())
a = [input() for w in range(h)]

for i in range(h)[::-1]:
    if "#" not in a[i]:
        del a[i]
        h -= 1
print(a)

n = []
for j in range(w):
    print("j=" + str(j))
    m = ["".join(t[j] for t in a)]
    if "#" in m[0]:
        n += m
print(n)

for k in range(h):
    print("".join(n[k]))