Buggy python submission (verdict: Runtime Error):
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from math import gcd

    n0, m0 = list(map(int, readline().split()))
    a0 = list(map(int, readline().split()))
    ahalf = [x // 2 for x in a0]
    ans = 0

    if all([x % 2 == 0 for x in ahalf]):
        if all([(x - ahalf[0]) % 4 == 0 for x in ahalf]):
            lcm = a0[0]
            for elem in a0[1:]:
                lcm = (lcm * elem) // gcd(lcm, elem)
            ans = (m0 + (lcm // 2)) // lcm
    elif all([x % 2 == 1 for x in ahalf]):
        lcm = a0[0]
        for elem in a0[1:]:
            lcm = (lcm * elem) // gcd(lcm, elem)
        ans = (m0 + (lcm // 2)) // lcm

    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from fractions import gcd

    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    cnt = [0] * n

    for i, elem in enumerate(a):
        x = elem
        c = 0
        while x % 2 == 0:
            x //= 2
            c += 1
        cnt[i] = c

    ans = 0

    if len(set(cnt)) == 1:
        lcm = a[0]
        for elem in a[1:]:
            lcm = (lcm * elem) // gcd(lcm, elem)
        ans = (m + (lcm // 2)) // lcm

    print(ans)


if __name__ == '__main__':
    main()

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

n, m = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]

a = set(a)
a = list(map(lambda x: x/2, a))
mp = a[0]
g= a[0]

for i in range(1,len(a)):
    g = gcd(g,a[i])
    mp = a[i] * mp

hlcm = int(mp/g)

if hlcm % 2 == 1:
    ans = m // hlcm - (m // (hlcm*2))
else:
    ans = 0

print(ans)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from fractions import gcd

    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    cnt = [0] * n

    for i, elem in enumerate(a):
        x = elem
        c = 0
        while x % 2 == 0:
            x //= 2
            c += 1
        cnt[i] = c

    ans = 0

    if len(set(cnt)) == 1:
        lcm = a[0]
        for elem in a[1:]:
            lcm = (lcm * elem) // gcd(lcm, elem)
        ans = (m + (lcm // 2)) // lcm

    print(ans)


if __name__ == '__main__':
    main()

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

n, m = [int(_) for _ in input().split()]
a = [int(_) for _ in input().split()]

a = set(a)
a = list(map(lambda x: x/2, a))
mp = a[0]
g= a[0]

for i in range(len(a)):
    g = gcd(g,a[i])
    mp = a[i] * mp

hlcm = int(mp/g)

ans = m // hlcm - (m // (hlcm*2))

print(ans)

Fixed submission:
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    from fractions import gcd

    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    cnt = [0] * n

    for i, elem in enumerate(a):
        x = elem
        c = 0
        while x % 2 == 0:
            x //= 2
            c += 1
        cnt[i] = c

    ans = 0

    if len(set(cnt)) == 1:
        lcm = a[0]
        for elem in a[1:]:
            lcm = (lcm * elem) // gcd(lcm, elem)
        ans = (m + (lcm // 2)) // lcm

    print(ans)


if __name__ == '__main__':
    main()