Problem p03633 (python)

Fixed submission:
N = int(input())
result = 1

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


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


for i in range(0, N):
    num = int(input())
    result = lcm(result, num)
print(int(result))

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [0 for i in range(N)]
for t in range(N):
    T[t] = int(input())


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


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


def solve(listT):
    listlen = len(listT)
    ans = -1
    while True:
        ans = lcm(listT[listlen - 2], listT[listlen - 1])
        listT.pop(listlen - 1)
        listT.pop(listlen - 2)
        listT.append(ans)
        listlen = len(listT)
        if(listlen == 1):
            break
    return ans

ans = solve(T)
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [0 for i in range(N)]
for t in range(N):
    T[t] = int(input())


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


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


def solve(listT):
    listlen = len(listT)
    ans = -1
    while True:
        ans = lcm(listT[listlen - 2], listT[listlen - 1])
        listT.pop(listlen - 1)
        listT.pop(listlen - 2)
        listT.append(ans)
        listlen = len(listT)
        if(listlen == 1):
            break
    return ans

ans = solve(T)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000000000)


N = int(input())
T = [0 for i in range(N)]
for t in range(N):
    T[t] = int(input())


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


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


def solve(listT):
    listlen = len(listT)
    ans = -1
    while True:
        ans = lcm(listT[listlen - 2], listT[listlen - 1])
        listT.pop(listlen - 1)
        listT.pop(listlen - 2)
        listT.append(ans)
        listlen = len(listT)
        if(listlen == 1):
            break
    return ans

ans = solve(T)
print(ans)

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(2000000000)

N = int(input())
T = [0 for i in range(N)]
for t in range(N):
    T[t] = int(input())


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


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


def solve(listT):
    listlen = len(listT)
    ans = -1
    while True:
        ans = lcm(listT[listlen-2], listT[listlen-1])
        listT.pop(listlen-1)
        listT.pop(listlen-2)
        listT.append(ans)
        listlen = len(listT)
        if(listlen == 1):
            break

    return ans

print(solve(T))

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit(999999999)

N = int(input())
T = [0 for i in range(N)]
for t in range(N):
    T[t] = int(input())


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


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


def solve(listT):
    listlen = len(listT)
    ans = -1
    while True:
        ans = lcm(listT[listlen-2], listT[listlen-1])
        listT.pop(listlen-1)
        listT.pop(listlen-2)
        listT.append(ans)
        listlen = len(listT)
        if(listlen == 1):
            break

    return ans

print(solve(T))

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [0 for i in range(N)]
for t in range(N):
    T[t] = int(input())


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


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


def solve(listT):
    listlen = len(listT)
    ans = -1
    while True:
        ans = lcm(listT[listlen-2], listT[listlen-1])
        listT.pop(listlen-1)
        listT.pop(listlen-2)
        listT.append(ans)
        listlen = len(listT)
        if(listlen == 1):
            break

    return ans

print(solve(T))

Buggy submission (verdict: Runtime Error):
N = int(input())
T = [0 for i in range(N)]
for t in range(N):
    T[t] = int(input())


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


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


def solve(listT):
    listlen = len(listT)
    ans = -1
    while True:
        ans = lcm(listT[listlen-2], listT[listlen-1])
        listT.pop(listlen-1)
        listT.pop(listlen-2)
        listT.append(ans)
        listlen = len(listT)
        if(listlen == 1):
            break

    print(ans)

solve(T)