Buggy python submission (verdict: Runtime Error):
from math import gcd, ceil


def prime_factor(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n > 1:
        res.append(n)
    return res


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    twos_cnt = {prime_factor(num).count(2) for num in a}
    if len(twos_cnt) > 1:
        print(0)
        exit()

    num_two = twos_cnt.pop()
    a_div = [x >> num_two for x in a]

    a_div_lcm = a_div[0]
    for i in range(1, n):
        a_div_lcm = a_div_lcm * a_div[i] // gcd(a_div_lcm, a_div[i])
    print(ceil(m / a_div_lcm * 0.5 - 0.5))


Fixed submission:
from functools import reduce


def count_factors(a, factor):
    count = 0
    while a % factor == 0:
        count += 1
        a //= factor
    return count


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


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


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(set(map(lambda x: int(x) // 2, input().split())))
    num_of_two = count_factors(a[0], 2)
    for ai in a[1:]:
        if count_factors(ai, 2) != num_of_two:
            print(0)
            exit()

    a_lcm = reduce(lambda x, y: lcm(x, y), a)
    if a_lcm > m:
        print(0)
        exit()

    print((m // a_lcm + 1) // 2)

Buggy python submission (verdict: Runtime Error):
from math import gcd, ceil


def ramp(x):
    if x > 0:
        return x
    else:
        return 0


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a_lcm = a[0]
    for i in range(1, n):
        a_lcm = a_lcm * a[i] // gcd(a_lcm, a[i])
    print(ramp(ceil(m / a_lcm - 0.5)))


Fixed submission:
from functools import reduce


def count_factors(a, factor):
    count = 0
    while a % factor == 0:
        count += 1
        a //= factor
    return count


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


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


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(set(map(lambda x: int(x) // 2, input().split())))
    num_of_two = count_factors(a[0], 2)
    for ai in a[1:]:
        if count_factors(ai, 2) != num_of_two:
            print(0)
            exit()

    a_lcm = reduce(lambda x, y: lcm(x, y), a)
    if a_lcm > m:
        print(0)
        exit()

    print((m // a_lcm + 1) // 2)

Buggy python submission (verdict: Runtime Error):
from math import gcd


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a_lcm = a[0]
    for i in range(1, n):
        a_lcm = a_lcm * a[i] // gcd(a_lcm, a[i])
    print(int(m / a_lcm - 0.5) + 1)


Fixed submission:
from functools import reduce


def count_factors(a, factor):
    count = 0
    while a % factor == 0:
        count += 1
        a //= factor
    return count


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


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


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(set(map(lambda x: int(x) // 2, input().split())))
    num_of_two = count_factors(a[0], 2)
    for ai in a[1:]:
        if count_factors(ai, 2) != num_of_two:
            print(0)
            exit()

    a_lcm = reduce(lambda x, y: lcm(x, y), a)
    if a_lcm > m:
        print(0)
        exit()

    print((m // a_lcm + 1) // 2)