Buggy python submission (verdict: Time Limit Exceeded):
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = A[0]//2
flag = 0
numofdiv2 = 0
for s in range(A[0]):
    if A[0] % 2 == 0:
        numofdiv2 += 1
        A[0] //= 2
    else:
        break
for i in range(1, N):
    for k in range(A[i]):
        if A[i] % (2**numofdiv2) != 0 or A[i] % (2**(numofdiv2+1)) == 0:
            flag = 1
            break
    gcd = fractions.gcd((A[i] // 2), lcm_half)
    lcm_half = (lcm_half * (A[i] // 2)) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)


Fixed submission:
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = A[0]//2
flag = 0
numofdiv2 = 0
for s in range(A[0]):
    if A[0] % 2 == 0:
        numofdiv2 += 1
        A[0] //= 2
    else:
        break

for i in range(1, N):

    if A[i] % (2**numofdiv2) != 0 or A[i] % (2**(numofdiv2+1)) == 0:
        flag = 1
        break
    gcd = fractions.gcd((A[i] // 2), lcm_half)
    lcm_half = (lcm_half * (A[i] // 2)) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = A[0]//2
flag = 0
numofdiv2 = 0
for s in range(A[0]):
    if A[0] % 2 == 0:
        numofdiv2 += 1
        A[0] //= 2
    else:
        break
for i in range(1, N):
    for k in range(A[i]):
        if A[i] % (2**numofdiv2) != 0 or A[i] % (2**(numofdiv2+1)) == 0:
            flag = 1
            break
    gcd = fractions.gcd((A[i] // 2), lcm_half)
    lcm_half = (lcm_half * (A[i] // 2)) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)


Fixed submission:
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = A[0]//2
flag = 0
numofdiv2 = 0
for s in range(A[0]):
    if A[0] % 2 == 0:
        numofdiv2 += 1
        A[0] //= 2
    else:
        break

for i in range(1, N):

    if A[i] % (2**numofdiv2) != 0 or A[i] % (2**(numofdiv2+1)) == 0:
        flag = 1
        break
    gcd = fractions.gcd((A[i] // 2), lcm_half)
    lcm_half = (lcm_half * (A[i] // 2)) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = A[0]//2
flag = 0
numofdiv2 = 0
for s in range(A[0]):
    if A[0] % 2 == 0:
        numofdiv2 += 1
        A[0] //= 2
    else:
        break
for i in range(1, N):
    numofdiv2_new = 0
    kari = A[i]
    for k in range(A[i]):
        if kari % 2 == 0:
            numofdiv2_new += 1
            kari //= 2
        else:
            if numofdiv2 != numofdiv2_new:
                flag = 1
                break
    gcd = fractions.gcd((A[i] // 2), lcm_half)
    lcm_half = (lcm_half * (A[i] // 2)) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)


Fixed submission:
import fractions
N, M = map(int, input().split())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = A[0]//2
flag = 0
numofdiv2 = 0
for s in range(A[0]):
    if A[0] % 2 == 0:
        numofdiv2 += 1
        A[0] //= 2
    else:
        break

for i in range(1, N):

    if A[i] % (2**numofdiv2) != 0 or A[i] % (2**(numofdiv2+1)) == 0:
        flag = 1
        break
    gcd = fractions.gcd((A[i] // 2), lcm_half)
    lcm_half = (lcm_half * (A[i] // 2)) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)