Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))
 
def how_two(n):
    a = 0
    while n %2 ==0:
        a+=1
        n//=2
    return a
 
log2 = how_two(A[0])
for i in A:
    tmplog2 = how_two(i)
    if log2!=tmplog2:
        log2 =0
        break
        
        
if log2==0:
    print(0)
else:
    def p_prime(n): 
        prime = [2]
        for i in range(3,n+1):
            flag = 0
            for j in prime:
                if i%j == 0:
                    flag = 1
                    break
                if i**0.5 < j:
                    break
            if flag == 0:
                prime.append(i)
        return prime
 
    mod = 10**9+7
    prime = p_prime(int(mod**0.5+1))
    def soinsuu(M):
        a = {}
        for p in prime:
            count = 0
            while M%p ==0:
                count += 1
                M //= p
            if count > 0:
                a[p] = count
        if M != 1:
            a[M] = 1
        return a
 
    def LCM(A):
        from collections import defaultdict
        AA = defaultdict(int)
    
        for i in range(len(A)):
            tmp = soinsuu(A[i])
            for j in tmp:
                AA[j] = max(AA[j], tmp[j])
                
        L = 1
        for i in AA:
            L *= pow(i,AA[i])
        return L
 
    B = []
    twotwo = pow(2,log2)
    for i in A:
        B.append(i//twotwo)
    l = LCM(B)
    l *= pow(2,log2-1)
    ans =(M+l)//(2*l)
    
    print(ans)

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
AA = max(A)
 
def how_two(n):
    a = 0
    while n %2 ==0:
        a+=1
        n//=2
    return a
 
log2 = how_two(A[0])
for i in A:
    tmplog2 = how_two(i)
    if log2!=tmplog2:
        log2 =0
        break
        
        
if log2==0:
    print(0)
else:
    from fractions import gcd
    l = 1
    dame = 0
    for i in A:
        l = (l*i)//gcd(l,i)
        if l//2 >= 10**9:
            dame = 1
            break
    l //= 2
    
    MAX = (M+l)//(2*l)
    MIN = max(1,-(-(AA+2*l)//(4*l)))
    ans = MAX-MIN +1
    #print(MIN)
    
    if dame==1:
        print(0)
    else:
        print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N,M = map(int,input().split())
A = list(map(int,input().split()))

def how_two(n):
    a = 0
    while n %2 ==0:
        a+=1
        n//=2
    return a

log2 = how_two(A[0])
for i in A:
    tmplog2 = how_two(i)
    if log2!=tmplog2:
        log2 =0
        break
        
        
if log2==0:
    print(0)
else:
    def p_prime(n): 
        prime = [2]
        for i in range(3,n+1):
            flag = 0
            for j in prime:
                if i%j == 0:
                    flag = 1
                    break
                if i**0.5 < j:
                    break
            if flag == 0:
                prime.append(i)
        return prime

    mod = 10**9+7
    prime = p_prime(int(mod**0.5+1))
    def soinsuu(M):
        a = {}
        for p in prime:
            count = 0
            while M%p ==0:
                count += 1
                M //= p
            if count > 0:
                a[p] = count
        if M != 1:
            a[M] = 1
        return a

    def LCM(A):
        from collections import defaultdict
        AA = defaultdict(int)
    
        for i in range(len(A)):
            tmp = soinsuu(A[i])
            for j in tmp:
                AA[j] = max(AA[j], tmp[j])
                
        L = 1
        for i in AA:
            L *= pow(i,AA[i])
        return L

    l = LCM(A)
    l //= 2
    ans =(M+l)//(2*l)
    
    print(ans)

Fixed submission:
N,M = map(int,input().split())
A = list(map(int,input().split()))
AA = max(A)
 
def how_two(n):
    a = 0
    while n %2 ==0:
        a+=1
        n//=2
    return a
 
log2 = how_two(A[0])
for i in A:
    tmplog2 = how_two(i)
    if log2!=tmplog2:
        log2 =0
        break
        
        
if log2==0:
    print(0)
else:
    from fractions import gcd
    l = 1
    dame = 0
    for i in A:
        l = (l*i)//gcd(l,i)
        if l//2 >= 10**9:
            dame = 1
            break
    l //= 2
    
    MAX = (M+l)//(2*l)
    MIN = max(1,-(-(AA+2*l)//(4*l)))
    ans = MAX-MIN +1
    #print(MIN)
    
    if dame==1:
        print(0)
    else:
        print(ans)