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

S = input()
T = input()

# 例abcdefg...のように文字列が1対1の矢印関係の場合は、
# どのような場合でも置き換えできる。問題は同じ文字が複数現れる場合

# S上に同じ文字sのある場所には
# T上にも同じ文字tがなくてはならない
# つまり、同じ値になっているインデックスの集合を取れば
# 全部同じになっているはず

# 文字種ごとにインデックスの集合を求める
ns = len(S)
indexS = {}
for i in range(ns):
    s = S[i]
    if s in indexS:
        indexS[s].append(i)
    else:
        indexS[s] = [i]
indexT = {}
for i in range(ns):
    t = T[i]
    if t in indexT:
        indexT[t].append(i)
    else:
        indexT[t] = [i]
# 先頭の文字から、インデックスの集合が等しいかチェック
for i in range(ns):
    s = S[i]
    t = T[i]
    i_s = len(indexS[s])
    i_t = len(indexT[t])
    if i_s != i_t:
        print("No")
        break
else:
    print("Yes")


Error: TLE

Fixed submission:

S = input()
T = input()

# 例abcdefg...のように文字列が1対1の矢印関係の場合は、
# どのような場合でも置き換えできる。問題は同じ文字が複数現れる場合

# S上に同じ文字sのある場所には
# T上にも同じ文字tがなくてはならない
# つまり、同じ値になっているインデックスの集合を取れば
# 全部同じになっているはず

# 文字種ごとにインデックスの集合を求める
ns = len(S)
indexS = {}
for i in range(ns):
    s = S[i]
    if s in indexS:
        indexS[s].append(i)
    else:
        indexS[s] = [i]
indexT = {}
for i in range(ns):
    t = T[i]
    if t in indexT:
        indexT[t].append(i)
    else:
        indexT[t] = [i]
# 先頭の文字から、インデックスの集合が等しいかチェック
for s, t in zip(S, T):
    i_s = indexS[s]
    i_t = indexT[t]
    if i_s != i_t:
        print("No")
        break
else:
    print("Yes")
Problem p03252 (Python) — buggy submission, verdict: Time Limit Exceeded

s = list(input())
t = list(input())
x = list(set(s))
y = list(set(t))
a = []
b = []

for i in range(len(set(s))):
    a.append(s.count(x[i]))

for j in range(len(set(t))):
    b.append(t.count(y[j]))

a.sort()
b.sort()

if a == b:
    print("Yes")
else:
    print("No")


Error: TLE

Fixed submission:

s, t = [input() for _ in range(2)]

for i in range(len(s)):
    if s[i] == t[i]:
        pass
    else:
        s_diff = s[i]
        t_diff = t[i]
        s = s.translate(str.maketrans({s_diff: t_diff, t_diff: s_diff}))

if s == t:
    print("Yes")
else:
    print("No")
Problem p03252 (Python) — buggy submission, verdict: Time Limit Exceeded

""" AtCoder """
import collections

S = input()
T = input()

s = {}
t = {}

for i in range(len(S)):
    if S[i] in s and s[S[i]] != T[i] or T[i] in t and t[T[i]] != S[i]:
        print("No")
        exit()
    s[S[i]] = T[i]
    t[T[i]] = S[i]

print("Yes")


Error: TLE

Fixed submission:

""" AtCoder """

S = input()
T = input()

for i in range(len(S)):
    index = i
    tmp = T[i]
    while True:
        index = S.find(S[i], index + 1)
        if index == -1:
            break

        if tmp != T[index]:
            print("No")
            exit()

for i in range(len(T)):
    index = i
    tmp = S[i]
    while True:
        index = T.find(T[i], index + 1)
        if index == -1:
            break
        if tmp != S[index]:
            print("No")
            exit()

print("Yes")
Problem p03252 (Python) — buggy submission, verdict: Time Limit Exceeded

S = input()
T = input()
S_cnt = sorted(S.count(c) for c in set(S))
T_cnt = sorted(T.count(c) for c in set(T))
print("Yes") if S_cnt == T_cnt else print("No")


Error: TLE

Fixed submission:

S = input()
T = input()
N = len(S)
pos_S = {c: set() for c in "abcdefghijklmnopqrstuvwxyz"}
[pos_S[S[i]].add(i) for i in range(N)]
pos_T = {c: set() for c in "abcdefghijklmnopqrstuvwxyz"}
[pos_T[T[i]].add(i) for i in range(N)]
if all(pos_S[S[i]] == pos_T[T[i]] for i in range(N)):
    print("Yes")
else:
    print("No")
Problem p03253 (Python) — buggy submission, verdict: Time Limit Exceeded

mod = 1000000007


def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        h = modpow(a, p // 2)
        return h * h % mod
    else:
        return a * modpow(a, p - 1) % mod


def calc(a, b):
    if b > a - b:
        return calc(a, a - b)
    am = 1
    ad = 1
    for i in range(b):
        am *= a - i
        ad *= i + 1
        am %= mod
        ad %= mod
    return am * modpow(ad, mod - 2) % mod


def main():
    N, M = map(int, input().split())
    res = M
    ans = 1
    i = 2
    while res >= i * i:
        if res % i == 0:
            c = 0
            while res % i == 0:
                c += 1
                res //= i
            ans *= calc(N + c - 1, N - 1)
            ans %= mod
        i += 1
    if res != 1:
        ans *= calc(N, N - 1)
        ans %= mod
    print(ans)


main()


Error: TLE

Fixed submission:

mod = 1000000007


def calc(a, b):
    am = 1
    ad = 1
    for i in range(b):
        am *= (a - i) % mod
        ad *= (i + 1) % mod
    return am * modpow(ad, mod - 2) % mod


def modpow(a, p):
    if p == 0:
        return 1
    if p % 2 == 0:
        p //= 2
        h = modpow(a, p)
        return h * h % mod
    else:
        return a * modpow(a, p - 1) % mod


def main():
    N, M = map(int, input().split())
    res = M
    ans = 1
    i = 2
    while res >= i * i:
        if res % i == 0:
            c = 0
            while res % i == 0:
                c += 1
                res //= i
            ans *= calc(N + c - 1, N - 1) % mod
        i += 1
    if res != 1:
        ans *= calc(N, N - 1) % mod
    print(ans)


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

N, x = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
a.sort()

if sum(a) == x:
    print(N)
    exit()

low = 0
high = N - 1
most_happy = 0

while low <= high:
    i = int((low + high) / 2)
    if sum(a[0:i]) <= x:
        low = i + 1
        if i > most_happy:
            most_happy = i
    else:
        high = i - 1

print(most_happy)
exit()


Error: TLE

Fixed submission:

import itertools

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

if sum(a) == x:
    print(N)
    exit()

for i in range(N - 1, 0, -1):
    for element in itertools.combinations(a, i):
        if sum(element) <= x:
            print(i)
            exit()

print(0)
exit()
Problem p03254 (Python) — buggy submission, verdict: Runtime Error

n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
i = 0
while i != n:
    if a[i] > x:
        break
    else:
        x -= a[i]
        ans += 1
        i += 1
if x > 0 and i == n:
    ans -= 1
if ans < 0:
    ans = 0
print(ans)


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03254/Python/s458600204.py", line 7, in <module>
    if a[i] > x:
IndexError: list index out of range


Fixed submission:

n, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
ans = 0
i = 0
while x > 0:
    if a[i] > x:
        break
    else:
        x -= a[i]
        ans += 1
        i += 1


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

import numpy

N, x = list(map(int, input().split()))
a = list(map(int, input().split()))
a.sort()
a_sum = numpy.cumsum(a)
ans = numpy.sum(a_sum <= x)

if ans == N and x not in a_sum:
    ans -= 1

print(ans)


Error: WA

Fixed submission:

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

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

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

N = int(input())
W = []
ans = True
for i in range(N):
    tmp = input()
    if tmp in W and i != 0:
        ans = False
    W.append(tmp)

if ans:
    last_word = W[0][-1]
    for i in range(1, N):
        if last_word != W[i][0]:
            ans = False
        last_word = W[i][-1]

print("Yes" if ans else "No")


Error: 0

Fixed submission:

N = int(input())
W = []
for i in range(N):
    tmp = input()
    if tmp in W and i != 0:
        print("No")
        exit()
    W.append(tmp)

last_word = W[0][-1]
for i in range(1, len(N)):
    if last_word != W[i][0]:
        print("No")
        exit()
print("Yes")
Problem p03261 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
w = [input() for i in range(n)]
ok = "Yes"
e = w[0][-1]
double = [w[0]]
for i in range(1, n):
    if double.count(w[i]) != 0:
        ok = "No"
        break
    double.append(w[i])
    s = w[i][0]
    if s != e:
        ok = "No"
        break
    e = w[i][-1]
print(ok)


Error: ValueError: invalid literal for int() with base 10: 'hoge'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03261/Python/s660309777.py", line 4, in <module>
    w = [int(input()) for i in range(n)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03261/Python/s660309777.py", line 4, in <listcomp>
    w = [int(input()) for i in range(n)]
ValueError: invalid literal for int() with base 10: 'hoge'


Fixed submission:

# ABC109B

n = int(input())
w = [int(input()) for i in range(n)]
ok = "Yes"
e = w[0][-1]
double = [w[0]]
for i in range(1, n):
    if double.count(w[i]) != 0:
        ok = "No"
        break
    double.append(w[i])
    s = w[i][0]
    if s != e:
        ok = "No"
        break
    e = w[i][-1]
print(ok)
Problem p03262 (Python) — buggy submission, verdict: Time Limit Exceeded

# import math


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


# print(make_divisor_list(24))


N, X = [int(x) for x in input().split()]
xlist = [int(x) for x in input().split()]

# print(xlist)

shiftedX = [x - X for x in xlist]

# print(shiftedX)

maxDivisor = shiftedX[0]
for n in shiftedX:
    maxDivisor = gcd(maxDivisor, n)

print(maxDivisor)


Error: TLE

Fixed submission:

# import math


def make_divisor_list(num):
    if num <= 0:
        # return []
        return make_divisor_list(-num)
    elif num == 1:
        return [1]
    else:
        divisor_list = [1]
        for i in range(2, num // 2 + 1):
            if num % i == 0:
                divisor_list.append(i)
        divisor_list.append(num)
        return divisor_list


# print(make_divisor_list(24))

N, X = [int(x) for x in input().split()]
xlist = [int(x) for x in input().split()]

# print(xlist)

shiftedX = [x - X for x in xlist]

# print(shiftedX)

divisor_set_list = [set(make_divisor_list(x)) for x in shiftedX]
# print(divisor_set_list)

div_set = divisor_set_list[0]

for s in divisor_set_list:
    div_set = div_set & s

# print(div_set)

print(max(div_set))
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

import fractions
from functools import reduce

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

if n == 1:
    ans = xx[0]
else:
    ans = reduce(fractions.gcd, xx)

print(ans)


Error: 0

Fixed submission:

import math
from functools import reduce

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

if n == 1:
    ans = xx[0] - x
else:
    dist = [xx[i + 1] - xx[i] for i in range(n - 1)]
    ans = reduce(math.gcd, dist)

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

n, x = map(int, input().split())
li = list(map(int, input().split()))
t = []
for i in li:
    t.append(abs(i - x))
divisors = []
for i in range(1, int(min(t) ** 0.5) + 1):
    if min(t) % i == 0:
        divisors.append(i)
        if i != min(t) // i:
            divisors.append(min(t) // i)
divisors.sort()
divisors = divisors[::-1]
for j in divisors:
    if all(k % j == 0 for k in t):
        print(j)
        exit()


Error: TLE

Fixed submission:

n, x = map(int, input().split())
li = list(map(int, input().split()))
t = []
for i in li:
    t.append(abs(i - x))
for j in range(min(t)):
    if all(k % (min(t) - j) == 0 for k in t):
        print(min(t) - j)
        exit()
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

#! /usr/bin/env python3

import fractions

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

a.sort()

res = 0
for val in a:
    if res == 0:
        res = val
    else:
        res = fractions.gcd(res, val)
        if res == 1:
            break

print(res)


Error: 0

Fixed submission:

#! /usr/bin/env python3

import math

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

a.sort()

res = 0
for val in a:
    if res == 0:
        res = val
    else:
        res = math.gcd(res, val)
        if res == 1:
            break

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

import fractions

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

gcd = 0

for x in range(N):
    gcd = fractions.gcd(abs(a[x] - X), gcd)
print(gcd)


Error: 0

Fixed submission:

import math

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

gcd = 0

for x in range(N):
    gcd = math.gcd(abs(a[x] - X), gcd)
print(gcd)
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd
from functools import reduce

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

print(reduce(gcd, (abs(x - x0) for x in X)))


Error: TLE

Fixed submission:

import numpy as np

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

print(np.gcd.reduce([x - x0 for x in X]))
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

from sys import stdin
from functools import reduce

# バージョン 3.4.X 以前
import fractions

# バージョン 3.4.X より 後
# import math

input = stdin.readline

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

xn = [abs(X - int(i)) for i in input().split()]


def main():
    print(reduce(fractions.gcd, xn))
    return


main()


Error: 0

Fixed submission:

from sys import stdin
from functools import reduce
import math

input = stdin.readline

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

xn = [abs(X - int(i)) for i in input().split()]


def main():
    print(reduce(math.gcd, xn))
    return


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

from functools import reduce


def euclid(a, b):
    if a < b:
        a, b = (b, a)

    while True:
        r = a % b
        if r == 0:
            break
        a, b = (b, r)

    return b


if __name__ == "__main__":
    n, x = tuple(map(int, input().split()))
    points = [int(x) for x in input().split()]

    buf = [abs(p - x) for p in points]
    print(reduce(lambda a, b: euclid(a, b), buf))


Error: TLE

Fixed submission:

n, x = tuple(map(int, input().split()))
points = [int(x) for x in input().split()]
points.append(x)
points.sort()

ds = [points[i + 1] - points[i] for i in range(len(points) - 1)]
for m in range(min(ds), 0, -1):
    if all([x % m == 0 for x in ds]):
        print(m)
        break
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

from functools import reduce
from fractions import gcd

X = int(input().split()[1])
x = [abs(int(x) - X) for x in input().split()]

print(reduce(gcd, x))


Error: 0

Fixed submission:

from functools import reduce
from math import gcd

X = int(input().split()[1])
x = [abs(int(x) - X) for x in input().split()]

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

from fractions import gcd
from functools import reduce


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


n, x = [int(_) for _ in input().split()]
x_list = [int(_) for _ in input().split()]

list = [abs(x_list[i] - x) for i in range(n)]

answer = gcd_list(list)
print(answer)


Error: 0

Fixed submission:

import math
from functools import reduce


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


n, x = [int(_) for _ in input().split()]
x_list = [int(_) for _ in input().split()]

list = [abs(x_list[i] - x) for i in range(n)]

answer = gcd_list(list)
print(answer)
Problem p03262 (Python) — buggy submission, verdict: Time Limit Exceeded

import math
from functools import reduce


def gcd(ns):
    return reduce(math.gcd, ns)


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

diff = [abs(x - X) for x in L]

if len(diff) == 1:
    print(diff[0])
else:
    print(gcd(diff))


Error: TLE

Fixed submission:

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

min_dist = abs(X - min(L))

ans = 1

for d in range(min_dist, 0, -1):
    b = all((x - X) % d == 0 for x in L)
    if b:
        print(d)
        break
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

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

if x in x_list:
    pass
else:
    x_list.append(x)
    x_list.sort()

min_diff = 99999999999
for i in range(len(x_list) - 1):
    diff = x_list[i + 1] - x_list[i]
    if min_diff > diff:
        min_diff = diff

# 差分の最小を約分していく
x_diff = [xx - x_list[0] for xx in x_list]

for i in range(1, min_diff):
    if min_diff % i != 0:  # 約分できない場合は次の数に進む
        continue
    xx = min_diff // i
    is_divided = [j for j in x_diff if j % xx != 0]
    if len(is_divided) == 0:
        print(xx)
        exit()
print(1)


Error: 0

Fixed submission:

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

x_list.append(x)
x_list.sort()

min_diff = 999_999_999_999
for i in range(len(x_list) - 1):
    diff = x_list[i + 1] - x_list[i]
    if min_diff > diff:
        min_diff = diff

# 差分の最小を約分していく
x_diff = [xx - x_list[0] for xx in x_list]

for i in range(1, min_diff):
    if min_diff % i != 0:  # 約分できない場合は次の数に進む
        continue
    xx = min_diff // i
    is_divided = [j for j in x_diff if j % xx != 0]
    if len(is_divided) == 0:
        print(xx)
        exit()
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

n, s = map(int, input().split())
xxx = [abs(s - y) for y in map(int, input().split())]
d = 0
while True:
    xxx = [x for x in xxx if x > 0]
    d = min(xxx)
    xxx = [x % d for x in xxx]
    if all(x == 0 for x in xxx):
        break
print(d)


Error: 0

Fixed submission:

n, s = map(int, input().split())
xxx = [abs(s - y) for y in map(int, input().split())]
d = 0
while True:
    d = min(xxx)
    xxx = [x % d for x in xxx]
    if all(x == 0 for x in xxx):
        break
print(d)
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

def gcd(a, b):
    big, small = max(a, b), min(a, b)
    if big % small == 0:
        return small
    div = None
    while big % small != 0:
        div = big % small
        big, small = small, div
    else:
        return div


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

d = x[0]
for xi in x[1:]:
    d = gcd(d, xi)
print(abs(d))


Error: 0

Fixed submission:

import math

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

d = x[0]
for xi in x[1:]:
    d = math.gcd(d, xi)
print(d)
Problem p03262 (Python) — buggy submission, verdict: Time Limit Exceeded

from functools import reduce
from fractions import gcd

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

ans = reduce(gcd, x)

print(ans)


Error: TLE

Fixed submission:

from functools import reduce
from fractions import gcd

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

x += [x_ini]

# print(x)

x2 = [x[i] - min(x) for i in range(n + 1)]

# print(x2)

x_ini -= min(x)

# print(x_ini)

ans = reduce(gcd, x2)

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

from fractions import gcd
from functools import reduce

N, X = tuple(int(i) for i in input().split())
x = [int(i) for i in input().split()]

x.append(X)
sx = sorted(x)
dx = [j - i for i, j in zip(sx[:-1], sx[1:])]

mdx = reduce(gcd, dx)

print(mdx)


Error: 0

Fixed submission:

import math
from functools import reduce

N, X = tuple(int(i) for i in input().split())
x = [int(i) for i in input().split()]

x.append(X)
sx = sorted(x)
dx = [j - i for i, j in zip(sx[:-1], sx[1:])]

mdx = reduce(math.gcd, dx)

print(mdx)
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd

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

dX = [abs(X - x) for x in X_list]
if len(dX) == 1:
    print(dX[0])
    exit(0)

D = [abs(X_list[i] - X_list[i + 1]) for i in range(0, N - 1)]
res = D[0]
for x in D[1:]:
    res = gcd(res, x)

ans = 0
for d in dX:
    ans = max(gcd(res, d), ans)
print(ans)


Error: ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03262/Python/s082976387.py", line 1, in <module>
    from fractions import gcd
ImportError: cannot import name 'gcd' from 'fractions' (/usr/lib/python3.10/fractions.py)


Fixed submission:

from fractions import gcd

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

dX = [abs(X - x) for x in X_list]
if len(dX) == 1:
    print(dX[0])
    exit(0)

D = [abs(X_list[i] - X_list[i + 1]) for i in range(0, N - 1)]
res = gcd(D[0], D[1])
for x in D[2:]:
    res = gcd(res, x)

ans = 0
for d in dX:
    ans = max(gcd(res, d), ans)
print(ans)
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd
from functools import reduce


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


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

x_arr = [0] * n

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

for i in range(len(x_arr)):
    x_arr[i] = abs(x_arr[i] - x)
print(gcd_list(x_arr))


Error: 0

Fixed submission:

from math import gcd
from functools import reduce


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


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

x_arr = [0] * n

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

for i in range(len(x_arr)):
    x_arr[i] = abs(x_arr[i] - x)
print(gcd_list(x_arr))
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

def gcd(x, y):
    while y != 0:
        temp = y
        y = x % y
        x = temp
    return x


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

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

dist_list = [abs(X - e) for e in x]

ans = dist_list[0]
for e in dist_list:
    ans = gcd(ans, e)


print(ans)


Error: ModuleNotFoundError: No module named 'fraction'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03262/Python/s329573155.py", line 1, in <module>
    import fraction
ModuleNotFoundError: No module named 'fraction'


Fixed submission:

import fraction

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

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

dist_list = [abs(X - e) for e in x]
ans = dist_list[0]
for e in dist_list:
    ans = fraction.gcd(e, ans)


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

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


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

dx = [abs(X - v) for v in x]
ans = dx[0]
for b in dx[1:]:
    ans = gcd(ans, b)
print(ans)


Error: 0

Fixed submission:

import math

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

dx = [abs(X - v) for v in x]
ans = dx[0]
for b in dx[1:]:
    ans = math.gcd(ans, b)
print(ans)
Problem p03262 (Python) — buggy submission, verdict: Runtime Error

from functools import reduce
import fractions


def solve():
    n, X = map(int, input().split())
    xs = list(map(int, input().split()))
    diffs = [abs(x - X) for x in xs]
    return reduce(fractions.gcd, diffs)


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


Error: 0

Fixed submission:

from functools import reduce
import math


def solve():
    n, X = map(int, input().split())
    xs = list(map(int, input().split()))
    diffs = [abs(x - X) for x in xs]
    return reduce(math.gcd, diffs)


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