Problem p03633 (python)

Fixed submission:
def gcd(a, b):
    while b > 0:
        tmp = a
        a = b
        b = tmp % b
    return a


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


n = int(input())
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
t = sorted(t)
_sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    _sum = lcm(_sum, t[i])
    # print(sum)
print(_sum)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b > 0:
        tmp = a
        a = b
        b = tmp % b
    return a


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


n = int(input())
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
t = sorted(t)
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b > 0:
        tmp = a
        a = b
        b = tmp % b
    return a


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


n = int(input())
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
t = sorted(t)
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b > 0:
        tmp = a
        a = b
        b = tmp % b
    return a


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


n = int(input())
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
t = sorted(t)
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b > 0:
        tmp = a
        a = b
        b = tmp % b
    return a


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


n = int(input())
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
t = sorted(t)
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b > 0:
        tmp = a
        a = b
        b = tmp % b
    return a


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


n = int(input())
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    a, b = min(a, b), max(a, b)
    if a == 0:
        return b
    else:
        return gcd(b % a, a)

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


n = int(input())
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)
"""
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
    R = int(n)
    s = 0
    L = []
    div = 2
    first = True
    while s == 0:
        for i in range(div, R + 1):
            if n % i == 0:
                n = n / i
                if i == div and not first:
                    alreadyExist = True
                else:
                    alreadyExist = False
                first = False
                div = i
                if n == 1:
                    s = 1
                if alreadyExist:
                    L[-1][1] += 1
                else:
                    L.append([i, 1])
                break
    return L


n = int(input())
t = [0 for i in range(n)]
fact = []
for i in range(n):
    # print(i)
    t[i] = int(input())
    if i == 0:
        fact = factorization(t[i])
    else:
        tmpFact = factorization(t[i])
        for _tmpFact in tmpFact:
            for _fact in fact:
                if _fact[0] == _tmpFact[0]:
                    _fact[1] = max(_fact[1], _tmpFact[1])
                    break
                elif _fact[0] == fact[-1][0]:
                    fact.append(_tmpFact)
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = 1
for _fact in fact:
    sum *= _fact[0]**_fact[1]
print(sum)
"""

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


n = int(input())
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)
"""
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
    R = int(n)
    s = 0
    L = []
    div = 2
    first = True
    while s == 0:
        for i in range(div, R + 1):
            if n % i == 0:
                n = n / i
                if i == div and not first:
                    alreadyExist = True
                else:
                    alreadyExist = False
                first = False
                div = i
                if n == 1:
                    s = 1
                if alreadyExist:
                    L[-1][1] += 1
                else:
                    L.append([i, 1])
                break
    return L


n = int(input())
t = [0 for i in range(n)]
fact = []
for i in range(n):
    # print(i)
    t[i] = int(input())
    if i == 0:
        fact = factorization(t[i])
    else:
        tmpFact = factorization(t[i])
        for _tmpFact in tmpFact:
            for _fact in fact:
                if _fact[0] == _tmpFact[0]:
                    _fact[1] = max(_fact[1], _tmpFact[1])
                    break
                elif _fact[0] == fact[-1][0]:
                    fact.append(_tmpFact)
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = 1
for _fact in fact:
    sum *= _fact[0]**_fact[1]
print(sum)
"""

Buggy submission (verdict: Runtime Error):
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


n = int(input())
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
t = [0 for i in range(n)]
for i in range(n):
    t[i] = int(input())
sum = t[0]
for i in range(1, n):
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t[i])
    # print(sum)
print(sum)
"""
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
    R = int(n)
    s = 0
    L = []
    div = 2
    first = True
    while s == 0:
        for i in range(div, R + 1):
            if n % i == 0:
                n = n / i
                if i == div and not first:
                    alreadyExist = True
                else:
                    alreadyExist = False
                first = False
                div = i
                if n == 1:
                    s = 1
                if alreadyExist:
                    L[-1][1] += 1
                else:
                    L.append([i, 1])
                break
    return L


n = int(input())
t = [0 for i in range(n)]
fact = []
for i in range(n):
    # print(i)
    t[i] = int(input())
    if i == 0:
        fact = factorization(t[i])
    else:
        tmpFact = factorization(t[i])
        for _tmpFact in tmpFact:
            for _fact in fact:
                if _fact[0] == _tmpFact[0]:
                    _fact[1] = max(_fact[1], _tmpFact[1])
                    break
                elif _fact[0] == fact[-1][0]:
                    fact.append(_tmpFact)
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = 1
for _fact in fact:
    sum *= _fact[0]**_fact[1]
print(sum)
"""

Buggy submission (verdict: Runtime Error):
"""
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z
"""


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


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


n = int(input())
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = int(input())
for i in range(1, n):
    t = int(input())
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t)
print(sum)
"""
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
    R = int(n)
    s = 0
    L = []
    div = 2
    first = True
    while s == 0:
        for i in range(div, R + 1):
            if n % i == 0:
                n = n / i
                if i == div and not first:
                    alreadyExist = True
                else:
                    alreadyExist = False
                first = False
                div = i
                if n == 1:
                    s = 1
                if alreadyExist:
                    L[-1][1] += 1
                else:
                    L.append([i, 1])
                break
    return L


n = int(input())
t = [0 for i in range(n)]
fact = []
for i in range(n):
    # print(i)
    t[i] = int(input())
    if i == 0:
        fact = factorization(t[i])
    else:
        tmpFact = factorization(t[i])
        for _tmpFact in tmpFact:
            for _fact in fact:
                if _fact[0] == _tmpFact[0]:
                    _fact[1] = max(_fact[1], _tmpFact[1])
                    break
                elif _fact[0] == fact[-1][0]:
                    fact.append(_tmpFact)
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = 1
for _fact in fact:
    sum *= _fact[0]**_fact[1]
print(sum)
"""

Buggy submission (verdict: Runtime Error):
def gcd(m, n):
    x = max(m, n)
    y = min(m, n)
    if x % y == 0:
        return y
    else:
        while x % y != 0:
            z = x % y
            x = y
            y = z
        else:
            return z


def lcm(m, n):
    return int(m * n / gcd(m, n))


n = int(input())
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = int(input())
for i in range(1, n):
    t = int(input())
    # print("sum:{} t:{} lcm:{}".format(sum, t, lcm(sum, t)))
    sum = lcm(sum, t)
print(sum)
"""
# 入力 : 自然数     ex) 12
# 出力 : 約数リスト ex) [2, 2, 3]
def factorization(n):
    R = int(n)
    s = 0
    L = []
    div = 2
    first = True
    while s == 0:
        for i in range(div, R + 1):
            if n % i == 0:
                n = n / i
                if i == div and not first:
                    alreadyExist = True
                else:
                    alreadyExist = False
                first = False
                div = i
                if n == 1:
                    s = 1
                if alreadyExist:
                    L[-1][1] += 1
                else:
                    L.append([i, 1])
                break
    return L


n = int(input())
t = [0 for i in range(n)]
fact = []
for i in range(n):
    # print(i)
    t[i] = int(input())
    if i == 0:
        fact = factorization(t[i])
    else:
        tmpFact = factorization(t[i])
        for _tmpFact in tmpFact:
            for _fact in fact:
                if _fact[0] == _tmpFact[0]:
                    _fact[1] = max(_fact[1], _tmpFact[1])
                    break
                elif _fact[0] == fact[-1][0]:
                    fact.append(_tmpFact)
# つまり全t[i]で割り切れる値を出せということ
# 最小公倍数を出せばよい
sum = 1
for _fact in fact:
    sum *= _fact[0]**_fact[1]
print(sum)
"""