Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

a = LIST()

for i in range(1, N):
	if abs(a[0]//2-a[i]//2) % gcd(a[0], a[i]) != 0:
		print(0)
		sys.exit()
tmp = 1
for x in a:
	tmp = x*tmp//gcd(x, tmp)
tmp = tmp//2
print((M-tmp)//(tmp*2)+1)


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

a = LIST()

a = [x//2 for x in a]
if a[0] % 2 == 0:  # 偶数の時
	for x in a:
		if x % 2 == 1:
			print(0)
			sys.exit(0)
	for x in a:
		if a[0] != x and abs(a[0]-x)%gcd(2*a[0], 2*x) != 0:
			print(0)
			sys.exit()

	tmp = 1
	for x in a:
		tmp = x*tmp//gcd(x, tmp)
	print((M-tmp)//(tmp*2)+1)


else:
	for x in a:
		if x % 2 == 0:
			print(0)
			sys.exit(0)
	tmp = 1
	for x in a:  # 奇数の時
		tmp = x*tmp//gcd(x, tmp)
	print((M-tmp)//(tmp*2)+1)

Buggy python submission (verdict: Time Limit Exceeded):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

a = LIST()

# a = [x//2 for x in a]
# if a[0] % 2 == 0:  # 偶数の時
# 	for x in a:
# 		if x % 2 == 1:
# 			print(0)
# 			sys.exit(0)
# 	for x in a:
# 		if a[0] != x and abs(a[0]-x)%gcd(2*a[0], 2*x) != 0:
# 			print(0)
# 			sys.exit()

# 	tmp = 1
# 	for x in a:
# 		tmp = x*tmp//gcd(x, tmp)
# 	print((M-tmp)//(tmp*2)+1)

# else:
# 	for x in a:
# 		if x % 2 == 0:
# 			print(0)
# 			sys.exit(0)
# 	tmp = 1
# 	for x in a:  # 奇数の時
# 		tmp = x*tmp//gcd(x, tmp)
# 	print((M-tmp)//(tmp*2)+1)

for i in range(1, N):
	if abs(a[0]//2-a[i]//2) % gcd(a[0], a[i]) != 0:
		print(0)
		sys.exit()
tmp = 1
for x in a:
	tmp = x*tmp//gcd(x, tmp)
tmp = tmp//2
print((M-tmp)//(tmp*2)+1)


Fixed submission:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, atan, degrees
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from bisect import bisect

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()

a = LIST()

a = [x//2 for x in a]
if a[0] % 2 == 0:  # 偶数の時
	for x in a:
		if x % 2 == 1:
			print(0)
			sys.exit(0)
	for x in a:
		if a[0] != x and abs(a[0]-x)%gcd(2*a[0], 2*x) != 0:
			print(0)
			sys.exit()

	tmp = 1
	for x in a:
		tmp = x*tmp//gcd(x, tmp)
	print((M-tmp)//(tmp*2)+1)


else:
	for x in a:
		if x % 2 == 0:
			print(0)
			sys.exit(0)
	tmp = 1
	for x in a:  # 奇数の時
		tmp = x*tmp//gcd(x, tmp)
	print((M-tmp)//(tmp*2)+1)