Problem p02814 (python)

Fixed submission:
import fractions
from functools import reduce
import numpy as np
import sys

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


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


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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)


def listdivide(list):
    numpy = np.array(list)
    numpy = numpy//2
    return numpy.tolist()


def divide2(x):
    res = 0
    while x % 2 == 0:
        x /= 2
        res += 1
    return res


# while gcd_list(an) % 2 == 0:
#     print(gcd_list(an))
an = listdivide(an)

t = divide2(an[0])
for i in range(1, N):
    if divide2(an[i]) != t:
        print(0)
        sys.exit()

for i in range(t):
    an = listdivide(an)
    M = M // 2

LCM = lcm_list(an)

if LCM > M == 0:
    print(0)
else:
    print(-(-(M // LCM)//2))

Buggy submission (verdict: Runtime Error):
import sys
from fractions import gcd
N, M = map(int, input().split())
an = list(map(lambdax: int(x)//2, input().split()))

lcm = an[0]
for a in an[1:]:
    l = lcm*a//gcd(lcm, a)
    if not (l//lcm % 2 == l//a % 2):
        print(0)
        sys.exit()
    lcm = l
print((M//lcm+1)//2)

Buggy submission (verdict: Runtime Error):
import sys
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

l = an[0]
for a in an[1:]:
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        lcm = LCM
    else:
        print(0)
        sys.exit()
print((M//lcm+1)//2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

l = an[0]
for a in an[1:]:
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        lcm = LCM
    else:
        print(0)
        exit()
print((M//lcm+1)//2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

l = an[0]
for a in an[1:]:
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        l = LCM
    else:
        print(0)
        exit()
print((M//LCM+1)//2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

l = an[0]
for a in :
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        l = LCM
    else:
        print(0)
        exit()
print((M//LCM+1)//2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

a = an[0]
for i in range(1, len(an)):
    GCD = gcd(a, an[i])
    x, y = a // GCD, an[i] // GCD
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(-(-M//a))

Buggy submission (verdict: Runtime Error):
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

a = an[0]
for i in range(1, len(an)):
    GCD = gcd(a, A[i])
    x, y = a // GCD, A[i] // GCD
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(-(-M//a))

Buggy submission (verdict: Runtime Error):
N, M = map(int, input().split())
an = list(map(int, input().split()))



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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

numpy = np.array(an)
numpy = numpy//2
LCM = lcm_list(numpy.tolist())
if LCM > M:
    print(0)
else:
    print(-(-(M // LCM)//2))