Problem:


Score : 400 points

Problem Statement

Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.

Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):

There exists a non-negative integer p such that X= a_k \times (p+0.5).

Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))

def gcd(a,b):
  if a==b:
    return a
  a,b=max(a,b),min(a,b)
  if a%b==0:
    return b
  else:
    return gcd(b,a%b)
  
def lcm(a,b):
  return a*b//gcd(a,b)
  
for i in range(N-1):
  if i==0:
    tmp=lcm(a[i]//2,a[i+1]//2)
  else:
    tmp=lcm(tmp,a[i+1]//2)
v=M//tmp
if v%2==1:
  print(v//2+1)
else:
  print(v//2)

Submission status: Runtime Error

Solution code:
from math import gcd, ceil

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

n, M = map(int, input().split())
A = tuple(map(lambda x: int(int(x)/2), input().split()))
scm_core = 1
for a in A:
    scm_core = lcm(scm_core, a)

print(ceil(M // scm_core / 2))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
def lcm1(x,y):
    return (x*y)//math.gcd(x,y)
def lcm2(*numbers):
    return reduce(lcm1,numbers,1)
n,m = map(int,input().split())
a = set(map(lambda x: int(x)//2,input().split()))
l = lcm2(*a)
for i in a:
    if l // i % 2 == 0:
        print(0)
        exit()
print(((m // l) + 1) // 2)

Submission status: Runtime Error

Solution code:
from sys import stdout, stderr
def fprintf(fs, s, *argv):
    fs.write(s.format(*argv))

def printf(s, *argv):
    fprintf(stdout, s, *argv)

from math import *

def gets(type=int, sep=' '):
    return map(type, input().split(sep))

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

def num2(a):
    cnt = 0
    while(a % 2 == 0):
        cnt += 1
        a /= 2
    return cnt

def main():
    n,m = gets()
    a = gets()
    lcm = 1
    cnt2 = -1
    for ai in a:
        lcm = _lcm(lcm,ai)
        n2 = num2(ai)
        if (cnt2 != -1 and cnt2 != n2):
            printf('0\n');
            return
        cnt2 = n2

    fprintf(stderr, 'lcm: {}\n', lcm)

    lo, hi = -1, m+1
    while (lo+1 < hi):
        mid = (lo+hi)//2
        if ((mid*2+1) * lcm//2 <= m):
            lo = mid
        else:
            hi = mid

    printf('{}\n', hi)

main()

Submission status: Runtime Error

Solution code:
N,M = map(int,input().rstrip().split())
A = list(map(int,input().rstrip().split()))
A.sort(reverse=True)

a1 = A[0]
a2 = A[1]

b1 = []
b2 = []

b = 0
p = 1
while b <= M:
  b = a1*(p+0.5)
  b1.append(b)
  p += 1
  
b = 0
p = 1
while b <= M:
  b = a2*(p+0.5)
  b2.append(b)
  p += 1

#for v in b1:
com = list(set(b1)&set(b2))

for n in range(2,N):
  an = A[n]
  for c in com:
    if not isinstance(c/an -0.5, int):
      com.remove(c)

print(len(com))

Submission status: Runtime Error

Solution code:
import math

N, M = [int(i) for i in input().split(' ')]
A = [int(i) for i in input().split(' ')]

lcm = 1
for num in A:
    lcm = lcm * num // math.gcd(lcm, num)
p_max = int(M*2 // lcm)
p_odd = int((p_max + 1) /2)
print(p_odd)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
i=0
for X in range(M):
  for k in A:
    if isinstanse((X-(k/2))/k,float):
      break
    else:
      i+=1
print(i)

Submission status: Runtime Error

Solution code:
import sys
import math
INF=1e9
mod=1e9+7
n,m=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
g=1
init=0
num=a[0]
while(num%2==0):
    num/=2
    init+=1
for i in range(1,n):
    num=a[i]
    cnt=0
    while(num%2==0):
        num/=2
        cnt+=1
    if(cnt!=init):
        print(0)
        sys.exit()
for i in range(n):
    a[i]//=2
    g=g*a[i]//math.gcd(g,a[i])
#print(g)
ans=(m//g)
if(ans%2==1):
    print(ans//2+1)
else:
    print(ans//2)

Submission status: Runtime Error

Solution code:

import numpy as np

N, M = map(np.int, input().split())
a = [int(x) for x in input().split()]
a = np.array(a)
a = a / 2
a = a.astype(int)

lcm = np.lcm.reduce(a)
# (2n-1)*lcm
b = int(M / lcm)
if b == 0 : print(0)
else :
    if b%2 == 0  : b = b - 1
    print( int((b+1)/2) )

Submission status: Runtime Error

Solution code:
import sys
import math
INF=1e9
mod=1e9+7
n,m=[int(i) for i in input().split()]
a=[int(i) for i in input().split()]
g=1
for i in range(n):
    a[i]//=2
    g=g*a[i]//math.gcd(g,a[i])
#print(g)
ans=(m//g)
if(ans%2==1):
    print(ans//2+1)
else:
    print(ans//2)

Submission status: Runtime Error

Solution code:
import sys
import math
INF=1e9
mod=1e9+7
n,m=map(int,input().split())
a=list(map(int,input().split()))
g=1
for i in range(n):
    a[i]//=2
    g=g*a[i]//math.gcd(g,a[i])
#print(g)
ans=(m//g)
if(ans%2==1):
    print(ans//2+1)
else:
    print(ans//2)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import sys
sys.setrecursionlimit(10 ** 9)

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

def llcm(a):
  if len(a) == 1:
    return a
  elif len(a) == 2:
    return lcm(a[0],a[1])
  else:
    return lcm(a[0],llcm(a[1:]))
  
N,M = map(int,input().split())
A = list(map(int,input().split()))

B = set()
flag = False
for a in A:
  if (a//2)%2 == 1 and (a//2) >=3:
    flag = True
  B.add(a//2)

l = llcm(list(B))
#print(l)
if l > M:
  ans = 0
else:
  ans = 1+(M-l)//(2*l)
if not flag:
  ans = max(ans-1,0)
print(ans)

Submission status: Runtime Error

Solution code:
#Atcoderではmathではなく，fractionsを使用．
#a/2が全て同じ数の2の倍数を素因数に持つ必要がある．

import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

def waru2(n):
    count = 0
    while True:
        if n % 2 == 0:
            n //= 2
            count += 1
        else:
            break
    return count

N, M = map(int, input().split())
a = list(map(int, input().split()))

half_a = []
waru = []

for i in a:
    half_a.append(i//2)
    waru.append(waru2(i))

if max(waru) == min(waru):
    half_lcm = lcm_list(half_a)
    print(-(-(M//half_lcm)//2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N, M = map(int, input().split())
a = list(map(int, input().split()))
half_a = []

for i in a:
    half_a.append(i//2)

half_lcm = lcm_list(half_a)

count = 0
print(-(-(M//half_lcm)//2))

Submission status: Runtime Error

Solution code:
import itertools
import sys
import math
import numpy as np
import fractions
from collections import deque
from itertools import combinations
from functools import reduce
from functools import lru_cache
sys.setrecursionlimit(10**9)

def get_lcm(num):
    return reduce(lambda x,y:(x * y) // fractions.gcd(x, y), num, 1)

def main():
    N,M = map(int,input().split())
    half_A = list(map(lambda x:int(x)//2,input().split()))

    lcm = get_lcm(half_A)

    if lcm <= M:
        if reduce(lambda x, y: (lcm // x) % 2 == 1 and (lcm // y) % 2 == 1, half_A):
            print(math.ceil(M/(2*lcm)))
            exit()

    print(0)


if __name__ == "__main__":
  main()

Submission status: Runtime Error

Solution code:
import sys
import math
import fractions
import itertools
from collections import deque
import copy
import bisect

MOD = 10 ** 9 + 7
INF = 10 ** 18 + 7
input = lambda: sys.stdin.readline().strip()

N, M = map(int, input().split())
a = list(map(int, input().split()))
for i in range(N):
    a[i] //= 2


def lcm(x, y):
    return (x * y) // math.gcd(x, y)


LCM = a[0]
for i in range(N - 1):
    LCM = lcm(a[i], a[i + 1])

ans = math.floor((M / LCM - 1) / 2) + 1

print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd, ceil


def prime_factor(n):
    res = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            res.append(i)
            n //= i
    if n > 1:
        res.append(n)
    return res


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    twos_cnt = {prime_factor(num).count(2) for num in a}
    if len(twos_cnt) > 1:
        print(0)
        exit()

    num_two = twos_cnt.pop()
    a_div = [x >> num_two for x in a]

    a_div_lcm = a_div[0]
    for i in range(1, n):
        a_div_lcm = a_div_lcm * a_div[i] // gcd(a_div_lcm, a_div[i])
    print(ceil(m / a_div_lcm * 0.5 - 0.5))

Submission status: Runtime Error

Solution code:
from math import gcd, ceil


def ramp(x):
    if x > 0:
        return x
    else:
        return 0


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a_lcm = a[0]
    for i in range(1, n):
        a_lcm = a_lcm * a[i] // gcd(a_lcm, a[i])
    print(ramp(ceil(m / a_lcm - 0.5)))

Submission status: Runtime Error

Solution code:
from math import gcd


if __name__ == "__main__":
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    a_lcm = a[0]
    for i in range(1, n):
        a_lcm = a_lcm * a[i] // gcd(a_lcm, a[i])
    print(int(m / a_lcm - 0.5) + 1)

Submission status: Runtime Error

Solution code:
from  functools import reduce
from  math import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[i//2 for i in a]
#print(a)
lc=reduce(lambda x,y: (x*y)//gcd(x,y) , a)
#print(lc)
flag=True
for i in a:
  if (lc//i)%2==0:
    flag=False
    break
if flag==False:
  print(0)
else:
  x=m//lc
  print(x//2) if (x%2)==0 else print((x//2)+1)

Submission status: Runtime Error

Solution code:
from  functools import reduce
from  math import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[i//2 for i in a]
#print(a)
lc=reduce(lambda x,y: (x*y)//gcd(x,y) , a)
#print(lc)
flag=True
for i in a:
  if (lc//i)%2==0:
    flag=False
    break
if flag==False:
  print(0)
else:
  x=m//lc
  print(x//2) if x%2==0 else print(x//2+1)

Submission status: Runtime Error

Solution code:
from  functools import reduce
from  math import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[i//2 for i in a]
#print(a)
lc=reduce(lambda x,y: (x*y)//gcd(x,y) , a)
#print(lc)
flag=True
for i in a:
  if (lc/i)%2==0:
    flag=False
    break
if flag==False:
  print(0)
else:
  x=m//lc
  print(x//2) if x%2==0 else print(x//2+1)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def gcd(m, n):
    # 入力を m, n (m ≧ n) とする。
    tmp = max(m,n)
    n = min(m,n)
    m = tmp
    # n = 0 なら、 m を出力してアルゴリズムを終了する。
    if n == 0:
        return m
    # m を n で割った余りを新たに n とし、更に 元のnを新たにm とし 2. に戻る。
    return gcd(n, m % n)

def lcm(m, n):
    return m*n//gcd(m,n)

n,m,*aaa = get_all_int()

x = reduce(lcm, aaa) / 2

ans = 0
if m >= x:
    ans = 1
ans += int((m-x) / (x*2))

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

def gcd(m, n):
    # 入力を m, n (m ≧ n) とする。
    tmp = max(m,n)
    n = min(m,n)
    m = tmp
    # n = 0 なら、 m を出力してアルゴリズムを終了する。
    if n == 0:
        return m
    # m を n で割った余りを新たに n とし、更に 元のnを新たにm とし 2. に戻る。
    return gcd(n, m % n)

def lcm(m, n):
    return m*n//gcd(m,n)

n,m,*aaa = get_all_int()

x = reduce(lcm, aaa) / 2

ans = 0
if ans >= m:
    ans = 1
ans += math.ceil((m-x) / (x*2))

print(ans)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
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)

Submission status: Runtime Error

Solution code:
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

    def gcd(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    alcm = 1
    for a in A:
        d = gcd(alcm, a)
        lcm = lcm * a // d
        if alcm > M:
            print(0)
            exit()

    # a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)

    if a_lcm > M:
        print(0)
    else:
        print((M // a_lcm + 1) // 2)


main()

Submission status: Runtime Error

Solution code:
#author: dokueki

#author: dokueki

import fractions
import math



def find_lcm(num1, num2):
    return (num1*num2)/fractions.gcd(num1, num2)


n, m = map(int, input().split())
l = list(map(int, input().split()))
l = [i//2 for i in l]


num1 = l[0]
num2 = l[1]
lcm = find_lcm(num1, num2)

for i in range(2, len(l)):
    lcm = find_lcm(lcm, l[i])
c = 0

for i in range(int(m/lcm)):
    product = lcm*(2*i+1)
    if product <= m:

        c += 1
    else:
        break
print(c)

Submission status: Runtime Error

Solution code:
#author: dokueki

#author: dokueki

import fractions
import math



def find_lcm(num1, num2):
    return (num1*num2)/fractions.gcd(num1, num2)


n, m = map(int, input().split())
l = list(map(int, input().split()))


num1 = l[0]
num2 = l[1]
lcm = find_lcm(num1, num2)

for i in range(2, len(l)):
    lcm = find_lcm(lcm, l[i])

print(round(m/lcm))

Submission status: Runtime Error

Solution code:
#author: dokueki


def find_lcm(num1, num2):
    if(num1 > num2):
        num = num1
        den = num2
    else:
        num = num2
        den = num1
    rem = num % den
    while(rem != 0):
        num = den
        den = rem
        rem = num % den
    gcd = den
    lcm = int(int(num1 * num2)/int(gcd))
    return lcm


n, m = map(int, input().split())
l = list(map(int, input().split()))

if n == 1:
    if l[0]/2 > m:
        print(0)
    else:
        print(1)
else:

    num1 = l[0]
    num2 = l[1]
    lcm = find_lcm(num1, num2)

    for i in range(2, len(l)):
        lcm = find_lcm(lcm, l[i])

    print(round(m/lcm))

Submission status: Runtime Error

Solution code:
#author: dokueki


from math import gcd


def find_lcm(x, y):
    return (x*y)//gcd(x, y)


n, m = map(int, input().split())
l = list(map(int, input().split()))

if n == 1:
    if l[0]/2 > m:
        print(0)
    else:
        print(1)

else:
    num1 = l[0]
    num2 = l[1]
    lcm = find_lcm(num1, num2)

    for i in range(2, len(l)):
        lcm = find_lcm(lcm, l[i])

    print(round(m/lcm))

Submission status: Runtime Error

Solution code:
from math import gcd
def find_lcm(x, y):
    return (x*y)//gcd(x, y)


n, m = map(int, input().split())
l = list(map(int, input().split()))

num1 = l[0]
num2 = l[1]
lcm = find_lcm(num1, num2)

for i in range(2, len(l)):
    lcm = find_lcm(lcm, l[i])

print(round(m/lcm))

Submission status: Runtime Error

Solution code:
#author: dokueki

from math import *



def find_lcm(x, y):
    return (x*y)//gcd(x, y)


n, m = map(int, input().split())
l = list(map(int, input().split()))

num1 = l[0]
num2 = l[1]
lcm = find_lcm(num1, num2)

for i in range(2, len(l)):
    lcm = find_lcm(lcm, l[i])

print(round(m/lcm))

Submission status: Runtime Error

Solution code:
#author: dokueki


def find_lcm(num1, num2):
    if(num1 > num2):
        num = num1
        den = num2
    else:
        num = num2
        den = num1
    rem = num % den
    while(rem != 0):
        num = den
        den = rem
        rem = num % den
    gcd = den
    lcm = int(int(num1 * num2)/int(gcd))
    return lcm


n, m = map(int, input().split())
l = list(map(int, input().split()))

num1 = l[0]
num2 = l[1]
lcm = find_lcm(num1, num2)

for i in range(2, len(l)):
    lcm = find_lcm(lcm, l[i])

print(round(m/lcm))

Submission status: Runtime Error

Solution code:
#author: dokueki


from math import gcd
from collections import Counter



def find_lcm(num1, num2):
    if(num1 > num2):
        num = num1
        den = num2
    else:
        num = num2
        den = num1
    rem = num % den
    while(rem != 0):
        num = den
        den = rem
        rem = num % den
    gcd = den
    lcm = int(int(num1 * num2)/int(gcd))
    return lcm


n, m = map(int, input().split())
l = list(map(int, input().split()))

num1 = l[0]
num2 = l[1]
lcm = find_lcm(num1, num2)

for i in range(2, len(l)):
    lcm = find_lcm(lcm, l[i])

print(round(m/lcm))

Submission status: Runtime Error

Solution code:
from math import gcd
from collections import Counter



n, m = map(int, input().split())
a = list(map(int, input().split()))
res = []
for i in a:
    for j in range(m):
        grab = i*(j+0.5)
        if grab <= m:
            res.append(grab)
c = 0
d = Counter(res)
for k, v in d.items():
    if v == len(a):
        c += 1
print(c)

Submission status: Runtime Error

Solution code:
import numpy as np
import fractions as fr
from functools import reduce
from math import floor
def lcm_func(x, y):
    return floor((x * y) / fr.gcd(x, y))
def lcm(*numbers):
    return reduce(lcm_func, numbers, 1)
N, M = map(int, input().split())
L = np.array(list(map(int, input().split())))
L_s = L * 1/2
L_S = L_s.tolist()
MB = lcm(*L_S)
Ans = floor(M / MB)
if Ans % 2 == 0:
  print(int(Ans/2))
else:
  print(int(floor(Ans/2)+1))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
N, M = list(map(int, input().split()))
A = list(map(int, input().split()))
Y = reduce(lambda a, b: a * b / gcd(a, b), A)

if (Y / a) % 2 == 1 for all a in A:
  print(M // (Y / 2) - (M // Y))
else:
  print(0)

Submission status: Runtime Error

Solution code:
import sys
import math

sys.setrecursionlimit(1000000)
input = lambda: sys.stdin.readline().rstrip()

N, M = map(int, input().split())
a = list(map(lambda x : int(x) // 2, input().split()))
lcm = 1
for i in a:
    lcm = lcm * i // math.gcd(lcm, i)
ok = True
for i in a:
    if lcm // i % 2 == 0:
        ok = False

if not ok:
    print(0)
else:
    print((M // lcm - 1) // 2 + 1)

Submission status: Runtime Error

Solution code:
n, m = map(lambda x: int(x), input().split())
l=map(lambda x:int(x), input().split())
def gcd(a,b):
	if not b:
		return a
	return gcd(b, a%b)
def lcm(a,b):
	return a*b/gcd(a,b)
ans=1
for a in l:
	ans=lcm(ans,a)
cnt=0
for i in range(int(ans//2),m+1,int(ans)):
	cnt+=1
print(cnt)

Submission status: Runtime Error

Solution code:
n, m = map(lambda x: int(x), input().split())
l=map(lambda x:int(x), input().split())
def gcd(a,b):
	if not b:
		return a
	return gcd(b, a%b)
def lcm(a,b):
	return a*b/gcd(a,b)
ans=1
for a in l:
	ans=lcm(ans,a)
print(int((m-ans//2)//ans+1))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

l=int(lcm_list(a)/2)

print((M//l+1)//2)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))

import fractions
from functools import reduce

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

l=lcm_list(a)/2

print((M//l+1)//2)

Submission status: Runtime Error

Solution code:
import fractions
from math import ceil
from functools import reduce


def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm, numbers)


if __name__ == '__main__':

    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    a = list(map(lambda x: int(x / 2), a))
    base = lcm_list(a)
    if (base / a[0]) % 2 == 0:
        print(0)
    else:
        print(ceil((M // base) / 2))

Submission status: Runtime Error

Solution code:
import sys
import math
from functools import reduce

sys.setrecursionlimit(2147483647)


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


if __name__ == '__main__':
    N, M = map(int, input().split())
    a = list(map(int, input().split()))
    a = list(map(lambda x: int(x / 2), a))
    base = lcm_list(a)
    print(math.ceil((M // base) / 2))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: int(x / 2), a))
base = lcm_list(a)

print(math.ceil((M // base) / 2))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)


N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(map(lambda x: int(x / 2), a))
base = lcm_list(a)

if base != 0:
    print(math.ceil((M // base) / 2))
else:
    print(0)