Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = sorted(list(set([int(x)//2 for x in input().strip().split()])), reverse=True)
lcm_d = {}
gcd_d = {}
def lcm(a, b, d, dd):
    if (a, b) in d:
        return d[(a, b)]
    ret = a * b // gcd(a, b, dd)
    ret_ = ret
    if gcd(a, b, dd) != 1:
        while (ret // a) % 2 == 0 or (ret // b) % 2 == 0:
            ret += ret_
    d[(a, b)] = ret
    return ret

def gcd(a, b, d):
    if (a, b) in d:
        return d[(a, b)]
    if b == 0:
        return a
    d[(a, b)] = gcd(b, a % b, d)
    return d[(a, b)]

lcm_ = a[0]
for aa in a[1:]:
    lcm_ = lcm(aa, lcm_, lcm_d, gcd_d)

print((m // lcm_ + 1) // 2)


Fixed submission:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = list(set([int(x)//2 for x in input().strip().split()]))

def lcm(a, b):
    return a * b // gcd(a, b)

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def div2cnt(x):
    ret = 0
    while x % 2 == 0:
        ret += 1
        x //= 2
    return ret

cnt = div2cnt(a[0])

for i, aa in enumerate(a):
    if div2cnt(aa) != cnt:
        print(0)
        exit()
    a[i] >>= cnt
else:
    m >>= cnt

lcm_ = 1
for aa in a:
    lcm_ = lcm(lcm_, aa)
    if lcm_ > m:
        print(0)
        exit()

print((m // lcm_ + 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = sorted(list(set([int(x)//2 for x in input().strip().split()])), reverse=True)
lcm_d = {}
gcd_d = {}
def lcm(a, b, d, dd):
    if (a, b) in d:
        return d[(a, b)]
    ret = a * b // gcd(a, b, dd)
    ret_ = ret
    if gcd(a, b, dd) != 1:
        while (ret // a) % 2 == 0 or (ret // b) % 2 == 0:
            ret += ret_
    d[(a, b)] = ret
    return ret

def gcd(a, b, d):
    if (a, b) in d:
        return d[(a, b)]
    if b == 0:
        return a
    d[(a, b)] = gcd(b, a % b, d)
    return d[(a, b)]

lcm_ = a[0]
for aa in a[1:]:
    lcm_ = lcm(aa, lcm_, lcm_d, gcd_d)

print((m // lcm_ + 1) // 2)

Fixed submission:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = list(set([int(x)//2 for x in input().strip().split()]))

def lcm(a, b):
    return a * b // gcd(a, b)

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def div2cnt(x):
    ret = 0
    while x % 2 == 0:
        ret += 1
        x //= 2
    return ret

cnt = div2cnt(a[0])

for i, aa in enumerate(a):
    if div2cnt(aa) != cnt:
        print(0)
        exit()
    a[i] >>= cnt
else:
    m >>= cnt

lcm_ = 1
for aa in a:
    lcm_ = lcm(lcm_, aa)
    if lcm_ > m:
        print(0)
        exit()

print((m // lcm_ + 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = sorted(list(set([int(x)//2 for x in input().strip().split()])), reverse=True)
lcm_d = {}
gcd_d = {}
def lcm(a, b, d, dd):
    if (a, b) in d:
        return d[(a, b)]
    ret = a * b // gcd(a, b, dd)
    ret_ = ret
    if gcd(a, b, dd) != 1:
        while (ret // a) % 2 == 0 or (ret // b) % 2 == 0:
            ret += ret_
    d[(a, b)] = ret
    return ret

def gcd(a, b, d):
    if (a, b) in d:
        return d[(a, b)]
    if b == 0:
        return a
    d[(a, b)] = gcd(b, a % b, d)
    return d[(a, b)]

lcm_ = a[0]
for aa in a[1:]:
    lcm_ = lcm(aa, lcm_, lcm_d, gcd_d)

print((m // lcm_ + 1) // 2)

Fixed submission:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = list(set([int(x)//2 for x in input().strip().split()]))

def lcm(a, b):
    return a * b // gcd(a, b)

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def div2cnt(x):
    ret = 0
    while x % 2 == 0:
        ret += 1
        x //= 2
    return ret

cnt = div2cnt(a[0])

for i, aa in enumerate(a):
    if div2cnt(aa) != cnt:
        print(0)
        exit()
    a[i] >>= cnt
else:
    m >>= cnt

lcm_ = 1
for aa in a:
    lcm_ = lcm(lcm_, aa)
    if lcm_ > m:
        print(0)
        exit()

print((m // lcm_ + 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = sorted(list(set([int(x)//2 for x in input().strip().split()])))
lcm_d = {}
gcd_d = {}
def lcm(a, b, d, dd):
    if (a, b) in d:
        return d[(a, b)]
    ret = a * b // gcd(a, b, dd)
    ret_ = ret
    if gcd(a, b, dd) != 1:
        while (ret // a) % 2 == 0 or (ret // b) % 2 == 0:
            ret += ret_
    d[(a, b)] = ret
    return ret

def gcd(a, b, d):
    if (a, b) in d:
        return d[(a, b)]
    if b == 0:
        return a
    d[(a, b)] = gcd(b, a % b, d)
    return d[(a, b)]

lcm_ = a[0]
for aa in a[1:]:
    lcm_ = lcm(aa, lcm_, lcm_d, gcd_d)

print((m // lcm_ + 1) // 2)

Fixed submission:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = list(set([int(x)//2 for x in input().strip().split()]))

def lcm(a, b):
    return a * b // gcd(a, b)

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def div2cnt(x):
    ret = 0
    while x % 2 == 0:
        ret += 1
        x //= 2
    return ret

cnt = div2cnt(a[0])

for i, aa in enumerate(a):
    if div2cnt(aa) != cnt:
        print(0)
        exit()
    a[i] >>= cnt
else:
    m >>= cnt

lcm_ = 1
for aa in a:
    lcm_ = lcm(lcm_, aa)
    if lcm_ > m:
        print(0)
        exit()

print((m // lcm_ + 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = sorted(list(set([int(x)//2 for x in input().strip().split()])))
lcm_d = {}
gcd_d = {}
def lcm(a, b, d, dd):
    if (a, b) in d:
        return d[(a, b)]
    ret = a * b // gcd(a, b, dd)
    ret_ = ret
    if gcd(a, b, dd) != 1:
        while (ret // a) % 2 == 0 or (ret // b) % 2 == 0:
            ret += ret_
    d[(a, b)] = ret
    return ret

def gcd(a, b, d):
    if (a, b) in d:
        return d[(a, b)]
    if b == 0:
        return a
    d[(a, b)] = gcd(b, a % b, d)
    return d[(a, b)]

lcm_ = a[0]
for aa in a[1:]:
    lcm_ = lcm(aa, lcm_, lcm_d, gcd_d)

print((m // lcm_ + 1) // 2)

Fixed submission:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = list(set([int(x)//2 for x in input().strip().split()]))

def lcm(a, b):
    return a * b // gcd(a, b)

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def div2cnt(x):
    ret = 0
    while x % 2 == 0:
        ret += 1
        x //= 2
    return ret

cnt = div2cnt(a[0])

for i, aa in enumerate(a):
    if div2cnt(aa) != cnt:
        print(0)
        exit()
    a[i] >>= cnt
else:
    m >>= cnt

lcm_ = 1
for aa in a:
    lcm_ = lcm(lcm_, aa)
    if lcm_ > m:
        print(0)
        exit()

print((m // lcm_ + 1) // 2)

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = sorted(list(set([int(x)//2 for x in input().strip().split()])))
def lcm(a, b):
    ret = a * b // gcd(a, b)
    ret_ = ret
    if gcd(a, b) != 1:
        while (ret // a) % 2 == 0 or (ret // b) % 2 == 0:
            ret += ret_

    return ret

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

lcm_ = a[0]
for aa in a[1:]:
    lcm_ = lcm(aa, lcm_)

print((m // lcm_ + 1) // 2)

Fixed submission:
import sys
input = sys.stdin.readline
n, m = [int(x) for x in input().strip().split()]
a = list(set([int(x)//2 for x in input().strip().split()]))

def lcm(a, b):
    return a * b // gcd(a, b)

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def div2cnt(x):
    ret = 0
    while x % 2 == 0:
        ret += 1
        x //= 2
    return ret

cnt = div2cnt(a[0])

for i, aa in enumerate(a):
    if div2cnt(aa) != cnt:
        print(0)
        exit()
    a[i] >>= cnt
else:
    m >>= cnt

lcm_ = 1
for aa in a:
    lcm_ = lcm(lcm_, aa)
    if lcm_ > m:
        print(0)
        exit()

print((m // lcm_ + 1) // 2)