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

n = int(input())


def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(n**0.5) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1


ans = prime(n)
print(ans)


Error: AttributeError: module 'fractions' has no attribute 'sqrt'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02819/Python/s955323601.py", line 21, in <module>
    ans = prime(n)
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02819/Python/s955323601.py", line 12, in prime
    for k in range(2, int(fractions.sqrt(n)) + 1):
AttributeError: module 'fractions' has no attribute 'sqrt'


Fixed submission:

# import math
import fractions

n = int(input())


def prime(n):
    if n == 1:
        n += 1
    while True:
        flag = 0
        for k in range(2, int(fractions.sqrt(n)) + 1):
            if n % k == 0:
                flag = 1
                break
        if flag == 0:
            return n
        n += 1


ans = prime(n)
print(ans)
Problem p02819 (Python) — buggy submission, verdict: Time Limit Exceeded

import random


def is_prime3(q, k=50):
    q = abs(q)
    if q == 2:
        return True
    if q < 2 or q & 1 == 0:
        return False

    # n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q - 1) >> 1
    while d & 1 == 0:
        d >>= 1

    # 判定をk回繰り返す
    for i in range(k):
        a = random.randint(1, q - 1)
        t = d
        y = pow(a, t, q)
        # [0,s-1]の範囲すべてをチェック
        while t != q - 1 and y != 1 and y != q - 1:
            y = pow(y, 2, q)
            t <<= 1
        if y != q - 1 and t & 1 == 0:
            return False
    return True


X = int(input())

while not is_prime3(X):
    X += 1

print(X)


Error: TLE

Fixed submission:

def factors(n):
    return [i for i in range(2, n) if n % i == 0]


X = int(input())

prime_l = factors(X)
while True:
    for i in prime_l:
        if X % i == 0:
            break
    prime_l.append(X)
    X += 1
print(X)
Problem p02819 (Python) — buggy submission, verdict: Runtime Error

import math

x = int(input())


def is_prime(n):
    if n < 2:
        return False
    if n % 2 == 0 and n > 2:
        return False
    return all(n % i for i in range(3, int(math.sqrt(n)) + 1, 2))


for n in range(100005):
    if n >= x and is_prime(n):
        print(n)
        break


Error: 0

Fixed submission:

import sympy

pg = sympy.primerange(2, 100001)

x = int(input())

for p in pg:
    if p >= x:
        print(p)
        break
Problem p02821 (Python) — buggy submission, verdict: Runtime Error

from itertools import accumulate

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

A.sort(reverse=True)
d = [0] * (A[0] * 2 + 1)
for i in range(N):
    d[A[i]] += 1
d = list(accumulate(d[::-1]))[::-1]
S = list(accumulate([0] + A))

left = 0
right = A[0] * 2 + 1
while right - left > 1:
    mid = (left + right) // 2
    m = 0
    for i in range(N):
        m += d[max(0, mid - A[i])]
    if m >= M:
        left = mid
    else:
        right = mid

ans = 0
m = 0
for i in range(N):
    t = min(d[max(0, right - A[i])], M - m)
    ans += S[t] + A[i] * t
    m += t
ans += left * (M - m)
print(ans)


Error: WA

Fixed submission:

from itertools import accumulate

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

A.sort(reverse=True)
d = [0] * (A[0] * 2 + 1)
for i in range(N):
    d[A[i]] += 1
d = list(accumulate(d[::-1]))[::-1]
b = list(accumulate(A))

left = 0
right = A[0] * 2 + 1
while right - left > 1:
    mid = (left + right) // 2
    m = 0
    for i in range(N):
        m += d[max(0, mid - A[i])]
    if m >= M:
        left = mid
    else:
        right = mid

ans = 0
m = 0
for i in range(N):
    t = min(d[max(0, left - A[i])], M - m)
    ans += b[t] + A[i] * t
    m += t
print(ans)
Problem p02821 (Python) — buggy submission, verdict: Time Limit Exceeded

from numpy.fft import rfft, irfft
import numpy as np
from bisect import bisect_left, bisect_right

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

a = np.zeros(2**18)
for Ai in A:
    a[Ai] += 1

fa = rfft(a)
a2 = irfft(fa**2)
a2 = np.round(a2).astype(np.int)

cum_a2 = np.cumsum(a2)

index = bisect_left(cum_a2, N**2 - M)
eli = cum_a2[index] - (N**2 - M)

a2[index] -= eli

ans = sum(A) * 2 * N - (a2[: index + 1] * np.arange(index + 1)).sum()
print(ans)


Error: TLE

Fixed submission:

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

c = [ai + aj for ai in A for aj in A]
c.sort()

ans = sum(c[-M:])
print(ans)
Problem p02821 (Python) — buggy submission, verdict: Runtime Error

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
s = [0]
for ai in a:
    s.append(ai + s[-1])


def count(x, accum=False):
    ret = 0
    for ai in a:
        lo, hi = -1, n
        while hi - lo > 1:
            mid = (lo + hi) // 2
            if ai + a[mid] >= x:
                lo = mid
            else:
                hi = mid
        ret += ai * hi + s[hi] if accum else hi
    return ret


lo, hi = 0, 1000000000
while hi - lo > 1:
    mid = (lo + hi) // 2
    if count(mid) >= m:
        lo = mid
    else:
        hi = mid

print(count(lo, accum=True) - (count(lo) - m) * lo)


Error: 0

Fixed submission:

n, m = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
s = a[0]
t = 0
j = 1
ret = 0
for i in range(n):
    s -= a[i]
    ret += a[i] * 2
    m -= 1
    while j < n and (i >= n - 1 or a[i + 1] + a[i + 1] <= a[i] + a[j]):
        if m < i * 2:
            for k in range(i):
                if m > 0:
                    ret += a[j] + a[k]
                    m -= 1
                if m > 0:
                    ret += a[j] + a[k]
                    m -= 1
        else:
            ret += a[j] * i * 2 + t * 2
            m -= i * 2
        s += a[j]
        j += 1
    num = (j - i - 1) * 2
    if m <= num:
        for k in range(i + 1, j):
            if m > 0:
                ret += a[i] + a[k]
                m -= 1
            if m > 0:
                ret += a[i] + a[k]
                m -= 1
        break
    m -= num
    ret += s * 2 + a[i] * num
    t += a[i]
    print(a, m, num, s, i, j, ret)
print(ret)
Problem p02823 (Python) — buggy submission, verdict: Runtime Error

import numpy as np
from decimal import Decimal

N, A, B = map(Decimal, input().split())
ab_max = np.amax(np.array([A, B]))
ab_min = np.amin(np.array([A, B]))

if (A - B) % 2 == 0:
    print(int((ab_max - ab_min) / 2))
else:
    print(int(np.amin([ab_min - 1, N - ab_max]) + (ab_max - ab_min + 1) / 2))


Error: TLE

Fixed submission:

import numpy as np

N, A, B = map(int, input().split())
ab_max = np.amax(np.array([A, B]))
ab_min = np.amin(np.array([A, B]))

if (A - B) % 2 == 0:
    print(int((ab_max - ab_min) / 2))
else:
    print(int(np.amin([(ab_max - 1), (N - ab_min)])))
Problem p02829 (Python) — buggy submission, verdict: Runtime Error

a = int(input())
b = int(input())
print(6 - a - b)


Error: ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02829/Python/s996128891.py", line 1, in <module>
    a, b = map(int, input().split())
ValueError: not enough values to unpack (expected 2, got 1)


Fixed submission:

a, b = map(int, input().split())
ans = 6 - (a + b)
print(ans)
Problem p02829 (Python) — buggy submission, verdict: Runtime Error

def main():
    A = int(input())
    B = int(input())

    ans = 6 - A - B

    print(ans)


if __name__ == "__main__":
    main()


Error: 0

Fixed submission:

def main():
    A = input()
    B = input()

    if A == "1" and B == "2":
        ans = 3
    elif A == "2" and B == "3":
        ans = 1
    elif A == "3" and B == "1":
        ans = 2

    print(ans)


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

a = int(input())
b = int(input())
print(6 - a - b)


Error: ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02829/Python/s060375473.py", line 1, in <module>
    a, b = map(int, input().split())
ValueError: not enough values to unpack (expected 2, got 1)


Fixed submission:

a, b = map(int, input().split())
print(6 - a - b)
Problem p02830 (Python) — buggy submission, verdict: Runtime Error

n = int(input())
s, t = input().split()
out = ""
for i in range(n):
    out += s[i] + t[i]
print(out)


Error: ValueError: invalid literal for int() with base 10: 'ip cc'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02830/Python/s669050732.py", line 2, in <module>
    s, t = [int(input()) for i in range(2)]
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02830/Python/s669050732.py", line 2, in <listcomp>
    s, t = [int(input()) for i in range(2)]
ValueError: invalid literal for int() with base 10: 'ip cc'


Fixed submission:

n = int(input())
s, t = [int(input()) for i in range(2)]
out = ""
for i in range(n):
    out += s[i] + t[i]
print(out)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions


def main():
    A, B = map(int, input().split())

    print(A * B // fractions.gcd(A, B))


if __name__ == "__main__":
    main()


Error: 0

Fixed submission:

import math


def main():
    A, B = map(int, input().split())

    print(A * B // math.gcd(A, B))


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

a, b = map(int, input().split())


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


def lcm(x, y):
    return (x * y) // gcd(x, y)


print(lcm(a, b))


Error: TLE

Fixed submission:

import numpy as np

a, b = map(int, input().split())

print(np.lcm(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

# C - Snack

from fractions import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))


Error: 0

Fixed submission:

# C - Snack

from math import gcd

A, B = map(int, input().split())
print(A * B // gcd(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


ab = input()
a = int(ab.split(" ")[0])
b = int(ab.split(" ")[1])

print(lcm(a, b))


Error: 0

Fixed submission:

import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


ab = input()
a = int(ab.split(" ")[0])
b = int(ab.split(" ")[1])

print(lcm(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

a, b = map(int, input().split())

print((a * b) // fractions.gcd(a, b))


Error: 0

Fixed submission:

import math

a, b = map(int, input().split())

print((a * b) // math.gcd(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd

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


def lcm(x, y):
    return (x * y) // gcd(x, y)


print(lcm(A, B))


Error: 0

Fixed submission:

import math

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


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


print(lcm(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

A, B = [int(i) for i in input().split()]

print(int(A * B / fractions.gcd(A, B)))


Error: TLE

Fixed submission:

import numpy as np

A, B = [int(i) for i in input().split()]

print(np.lcm(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

a, b = map(int, input().split())
print(a // fractions.gcd(a, b) * b)


Error: WA

Fixed submission:

import math

a, b = map(int, input().split())
print(a / math.gcd(a, b) * b)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd

a, b = tuple(map(int, input().split()))
print(int(a * b / gcd(a, b)))


Error: 0

Fixed submission:

from math import gcd

a, b = tuple(map(int, input().split()))
print(int(a * b / gcd(a, b)))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

A, B = map(int, input().split())
print(A * B // fractions.gcd(A, B))


Error: 0

Fixed submission:

import math

A, B = map(int, input().split())
print(A * B // math.gcd(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

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

print(int(A * B / fractions.gcd(A, B)))


Error: 0

Fixed submission:

import math

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

print(int(A * B / math.gcd(A, B)))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

def calc_gcd(a, b):
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b

    return b


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

if a < b:
    tmp = a
    a = b
    b = tmp

gcd = calc_gcd(a, b)
ans = int(a * b / gcd)

print(ans)


Error: 0

Fixed submission:

import math

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

ans = int(a * b / math.gcd(a, b))

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

import fractions

data = input().split()
val = [int(n) for n in data]

res = val[0] * val[1] / fractions.gcd(val[0], val[1])

print(int(res))


Error: WA

Fixed submission:

import math

data = input().split()
val = [int(n) for n in data]

res = val[0] * val[1] / math.gcd(val[0], val[1])

print(res)
Problem p02831 (Python) — buggy submission, verdict: Time Limit Exceeded

num_list = [int(i) for i in input().split()]

result = 0

if num_list[0] < num_list[1]:
    A = num_list[0]
    B = num_list[1]
else:
    A = num_list[1]
    B = num_list[0]

while True:
    amari = A % B
    if amari == 0:
        break
    A = B
    B = amari

# 最大公約数 B

# 最小公倍数
result = num_list[0] * num_list[1] // B

print(result)


Error: TLE

Fixed submission:

num_list = [int(i) for i in input().split()]

result = 0

max = num_list[0] * num_list[1]
for i in range(1, max + 1):
    amari_1 = i % num_list[0]
    amari_2 = i % num_list[1]
    if amari_1 == 0 and amari_2 == 0:
        result = i
        break

print(result)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

a, b = map(int, input().split())

k = fractions.gcd(a, b)

ans = (a * b) // k

print(ans)


Error: 0

Fixed submission:

import math

a, b = map(int, input().split())

k = math.gcd(a, b)

ans = (a * b) // k

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

import fractions

if __name__ == "__main__":
    A, B = input().split()
    A = int(A)
    B = int(B)
    ret = (A * B) // fractions.gcd(A, B)
    print(ret)


Error: 0

Fixed submission:

import math

if __name__ == "__main__":
    A, B = input().split()
    A = int(A)
    B = int(B)
    ret = (A * B) // math.gcd(A, B)
    print(ret)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

a, b = map(int, input().split())

print(a * b // fractions.gcd(a, b))


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


Fixed submission:

from sys import stdin
import fractions

a = int(stdin.readline().rstrip())
b = int(stdin.readline().rstrip())

print(a * b // fractions.gcd(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

a, b = map(int, input().split())

print(int((a * b) / fractions.gcd(a, b)))


Error: TLE

Fixed submission:

import numpy as np

a, b = map(int, input().split())

print(int((a * b) / np.gcd(a, b)))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

from sys import stdin
import fractions

A, B = [int(x) for x in stdin.readline().rstrip().split()]

print((A * B) // fractions.gcd(A, B))


Error: 0

Fixed submission:

from sys import stdin
import math

# A = int(stdin.readline().rstrip())
A, B = [int(x) for x in stdin.readline().rstrip().split()]
# print(A, B)

if A < B:
    A, B = B, A

print((A * B) // math.gcd(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd

a, b = map(int, input().split())
t = gcd(a, b)
print(a // t * b)


Error: 0

Fixed submission:

import math

a, b = map(int, input().split())
t = math.gcd(a, b)
print(a // t * b)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

a, b = map(int, input().split())

ans = a * b // fractions.gcd(a, b)
print(ans)


Error: 0

Fixed submission:

import math

a, b = map(int, input().split())

ans = a * b // math.gcd(a, b)
print(ans)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

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


def gcd(m, n):
    r = m % n
    return gcd(n, r) if r else n


def lcm(x, y):
    return (x * y) // gcd(x, y)


def sol(a, b):
    return (a * b) // gcd(a, b)


a, b = list(map(int, input().split()))
print(sol(a, b))


Error: 0

Fixed submission:

import math

a, b = [int(x.strip()) for x in input().split()]
print((a * b) // math.gcd(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

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

print(A * B // fractions.gcd(A, B))


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


Fixed submission:

import fraction

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

print(A * B // fraction.gcd(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

x, y = map(int, input().split())
print((x * y) // fractions.gcd(x, y))


Error: 0

Fixed submission:

import math

x, y = map(int, input().split())
print((x * y) // math.gcd(x, y))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

# import math
import fractions

a, b = map(int, input().split())

print((a * b) // fractions.gcd(a, b))


Error: 0

Fixed submission:

import math

a, b = map(int, input().split())

print((a * b) // math.gcd(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd

# from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))
exit(0)


Error: 0

Fixed submission:

# from fractions import gcd
from math import gcd

a, b = map(int, input().split())
print(a * b // gcd(a, b))
exit(0)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

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


def get_lcm(a, b):
    return (a * b) // fractions.gcd(a, b)


print(get_lcm(A, B))


Error: 0

Fixed submission:

import math

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


def get_lcm(a, b):
    return (a * b) // math.gcd(a, b)


print(get_lcm(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

# 最小公倍数lcm（ least common multiple）を返す関数は用意されていない
# が、lcm(a, b) = a * b / gcd(a, b)で求められる

A, B = map(int, input().split())
ans = A * B // fractions.gcd(A, B)
print(ans)


Error: 0

Fixed submission:

import math

# 最小公倍数lcm（ least common multiple）を返す関数は用意されていない
# が、lcm(a, b) = a * b / gcd(a, b)で求められる

A, B = map(int, input().split())
ans = A * B // math.gcd(A, B)
print(ans)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

A, B = [int(n) for n in input().split()]

print(A * B // fractions.gcd(A, B))


Error: 0

Fixed submission:

import math

A, B = [int(n) for n in input().split()]

print(int((A * B) / math.gcd(A, B)))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

from fractions import gcd

N = input().split()

A = int(N[0])
B = int(N[1])

lcm = int(A * B / gcd(A, B))

print(lcm)


Error: 0

Fixed submission:

import math

N = input().split()

A = int(N[0])
B = int(N[1])

lcm = int(A * B / math.gcd(A, B))

print(lcm)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

a, b = map(int, input().split())

print(a * b // fractions.gcd(a, b))


Error: AttributeError: module 'fractions' has no attribute 'gcd'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p02831/Python/s463768606.py", line 5, in <module>
    print(int(a * b / fractions.gcd(a * b)))
AttributeError: module 'fractions' has no attribute 'gcd'


Fixed submission:

import fractions

a, b = map(int, input().split())

print(int(a * b / fractions.gcd(a * b)))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions

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

v = fractions.gcd(X[0], X[1])
j = X[0] / v
p = int(X[1] * j)

print(p)


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


Fixed submission:

import functions

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

v = functions.gcd(X[0], X[1])
j = X[0] / v
p = int(X[1] * j)

print(p)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b = map(int, input().split())

print(lcm(a, b))


Error: 0

Fixed submission:

import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b = map(int, input().split())

print(lcm(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b = map(int, input().split())

print(lcm(a, b))


Error: 0

Fixed submission:

import math as ma


def lcm(x, y):
    return (x * y) // ma.gcd(x, y)


a, b = map(int, input().split())

print(lcm(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


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

print(lcm(A, B))


Error: 0

Fixed submission:

import math


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


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

print(lcm(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

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


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


print(A * B // gcd(A, B))


Error: 0

Fixed submission:

import math

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

print(A * B // math.gcd(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

import fractions as f

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

print(A * B // f.gcd(A, B))


Error: 0

Fixed submission:

import math

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

print(A * B // math.gcd(A, B))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

# import math

a, b = map(int, input().split())

# print(a * b // math.gcd(a, b))


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


def lcm(a, b):
    return a * b // gcd(a, b)


print(lcm(a, b))


Error: 0

Fixed submission:

import math

a, b = map(int, input().split())

print(a * b // math.gcd(a, b))
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-Snack.py
#
from fractions import gcd

a, b = map(int, input().split())
ans = int(a * b // gcd(a, b))
print(ans)


Error: 0

Fixed submission:

#!/usr/local/bin python
# -*- coding: utf-8 -*-
#
# ~/PycharmProjects/atcoder/C-Snack.py
#
import math

a, b = map(int, input().split())
ans = int(a * b / math.gcd(a, b))
print(ans)
Problem p02831 (Python) — buggy submission, verdict: Runtime Error

# 最小公倍数
import fractions

a, b = map(int, input().split())


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


print(lcm(a, b))


Error: 0

Fixed submission:

# 最小公倍数
import math

a, b = map(int, input().split())


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


print(lcm(a, b))