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_n = list(map(int, input().split()))
a_n = [int(a_n[i]*1/2) for i in range(len(a_n))]
 
def lcm(lis):
    from fractions import gcd
    x = lis[0]
    for i in range(1, len(lis)):
        x = (x * lis[i]) // gcd(x, lis[i])
    return x
res = lcm(a_n)
count = 0
for i in range(len(M)):
    count += 1
    if res*(2*i + 1) > M:
      break
print(count)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
a_n = [int(x/2) for x in input().split()]

def lcm(lis):
    from fractions import gcd
    x = lis[0]
    for i in range(1, len(lis)):
        x = (x * lis[i]) // gcd(x, lis[i])
    return x
res = lcm(a_n)
count = 0
for i in range(int(M/res)-1):
    count += 1
print(count)

Submission status: Runtime Error

Solution code:
import fractions
import math

nm = list(map(int,input().split()))
a = list(map(int, input().split()))

ans = a[0]
for i in range(1, nm[0]):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
key = ans / 2

mem = 0
for i in range(nm[0]):
    if (key / (a[i] / 2)) % 2 == 0:
        mem = mem + 1

if mem == 0:
    num = nm[1]/key
    print(int((num+1) // 2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import fractions
import math

nm = list(map(int,input().split()))
a = list(map(int, input().split()))

ans = a[0]
for i in range(1, nm[0]):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
key = ans / 2

mem = 0
for i in range(nm[1]):
    if (key / (a[j] / 2)) % 2 == 0:
        mem = mem + 1

if mem == 0:
    num = nm[1]/key
    print(int((num+1) // 2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//math.gcd(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n-1):
        x=lcm(c[i-1],b[i+1])
        c.append(x)
        '''
        if x<m:
            continue
        else:
            break
        '''
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import math

nm = list(map(int,input().split()))
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, nm[0]):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
key = ans / 2

num = nm[1]/key


print(int((num+1) / 2))

Submission status: Runtime Error

Solution code:
import fractions
import math

nm = list(map(int,input().split()))
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, nm[0]):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
key = ans / 2
print(key)

num = nm[1]/key


print(int((num+1) / 2))

Submission status: Runtime Error

Solution code:
import fractions
import math

nm = list(map(int,input().split()))
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, nm[0]):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
key = ans / 2

num = math.floor(nm[1]/key)


print(int(num / 2))

Submission status: Runtime Error

Solution code:
import fractions
import math

nm = list(map(int,input().split()))
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, nm[0]):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
key = ans / 2
start = key

hidari = math.ceil(start/key) + (1 - (math.ceil(start/key) % 2))
migi = math.floor(nm[1]/key) - (1 - (math.floor(nm[1]/key) % 2))


print(int((migi-hidari) / 2 + 1))

Submission status: Runtime Error

Solution code:
import fractions
import math
nm = list(map(int,input().split()))
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, nm[0]):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
key = ans / 2
start = key

hidari = math.ceil(start/key) + (1 - (math.ceil(start/key) % 2))
migi = math.floor(nm[1]/key) - (1 - (math.floor(nm[1]/key) % 2))


print(int((migi-hidari) / 2 + 1))

Submission status: Runtime Error

Solution code:
import math
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//math.gcd(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//math.fractions(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//math.gcd(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//math.gcd(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n-1):
        x=lcm(c[i-1],b[i+1])
        c.append(x)
        if x<m:
            continue
        else:
            break
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Submission status: Runtime Error

Solution code:

import math

N, M = map(int, input().split(" "))

a = list(set(map(int, input().split(" "))))

# 2で割り切れる回数を求める
def division(value):

    count = 0

    while(value % 2 == 0):

        value = value // 2
        count += 1

    return count

counts = list(map(division, a))

# 2で割り切れる回数が全てのa_Nで等しい場合
if counts.count(counts[0]) == len(counts):

    a = list(map(lambda x: x // 2, a))
    s = a[0]
    for i in range(1, len(a)):
        s = s * a[i] // math.gcd(s, a[i])

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

else:
    print(0)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int,input().split())
lis  = list(map(int,input().split()))
#aそれぞれを2で割ったものを持っておく
div = []
for i in range(n):
    div.append(lis[i]//2)
#lisそれぞれの要素を2で割り切れる回数をすべて数える
L = []
for i in range(n):
    cnt = 0
    while lis[i] %2 ==0:
        lis[i] //= 2
        cnt += 1
    L.append(cnt)

bl = True
#重複要素を削除して要素数でLがすべて一緒か判断
def set_list(es):
    return len(list(set(es))) == 1

if set_list(L) != 1:
    print(0)
    exit()

#div内の最小子公倍数Tを求める
T = 0
ans = div[0]
for i in range(1,n):
    ans =ans*div[i]//fractions.gcd(ans,div[i])
    T = ans

S = m//T
if S %2 ==0:
    print(S//2)
else:
    print(S//2 +1)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int,input().split())
lis  = list(map(int,input().split()))
#aそれぞれを2で割ったものを持っておく
div = []
for i in range(n):
    div.append(lis[i]//2)
#lisそれぞれの要素を2で割り切れる回数をすべて数える
L = []
for i in range(n):
    cnt = 0
    while lis[i] %2 ==0:
        lis[i] //= 2
        cnt += 1
    L.append(cnt)

bl = True
for i in range(n):
    for j in range(n):
    if L[i] != L[j]:
        bl = False
        print(0)
        exit()
#div内の最小子公倍数Tを求める
T = 0
ans = div[0]
for i in range(1,n):
    ans =ans*div[i]//fractions.gcd(ans,div[i])
    T = ans

S = m//T
if S %2 ==0:
    print(S//2)
else:
    print(S//2 +1)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int,input().split())
lis  = list(map(int,input().split()))
#aそれぞれを2で割ったものを持っておく
div = []
for i in range(n):
    div.append(lis[i]//2)
#lisそれぞれの要素を2で割り切れる回数をすべて数える
L = []
for i in range(n):
    cnt = 0
    while lis[i] %2 ==0:
        lis[i] //= 2
        cnt += 1
    L.append(cnt)

bl = True
for i in range(n-1):
    if L[0] != L[i+1]:
        bl = False
        print(0)
        exit()
#div内の最小子公倍数Tを求める
T = 0
ans = div[0]
for i in range(1,n):
    ans =ans*div[i]//fractions.gcd(ans,div[i])
    T = ans

S = m//T
if S %2 ==0:
    print(S//2)
else:
    print(S//2 +1)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int,input().split())
lis  = list(map(int,input().split()))
#aそれぞれを2で割ったものを持っておく
div = []
for i in range(n):
    div.append(lis[i]//2)
#lisそれぞれの要素を2で割り切れる回数をすべて数える
L = []
for i in range(n):
    cnt = 0
    while lis[i] %2 ==0:
        lis[i] //= 2
        cnt += 1
    L.append(cnt)

bl = True
for i in range(n-1):
    if L[0] != L[i+1]:
        bl = False
        print(0)
        break
#div内の最小子公倍数Tを求める
T = 0
ans = div[0]
for i in range(1,n):
    ans =ans*div[i]//fractions.gcd(ans,div[i])
    T = ans

S = m//T
if S %2 ==0:
    print(S//2)
else:
    print(S//2 +1)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
lis  = list(map(int,input().split()))
#aそれぞれを2で割ったものを持っておく
div = []
for i in range(n):
    div.append(lis[i]//2)
#lisそれぞれの要素を2で割り切れる回数をすべて数える
L = []
for i in range(n):
    cnt = 0
    while lis[i] %2 ==0:
        lis[i] //= 2
        cnt += 1
    L.append(cnt)

bl = True
for i in range(n-1):
    if L[0] != L[i+1]:
        bl = False
        print(0)
        break
#div内の最小子公倍数Tを求める
T = 0
ans = div[0]
for i in range(1,n):
    ans =ans*div[i]//math.gcd(ans,div[i])
    T = ans

S = m//T
if S %2 ==0:
    print(S//2)
else:
    print(S//2 +1)

Submission status: Runtime Error

Solution code:
import fractions as fr
n,m=map(int,input().split())
a=list(map(int,input().split()))
ans=a[0]
for i in range(1,n):
  ans=ans*a[i]//fr.gcd(ans,a[i])
A=int(m//(ans/2))
if A%2==0:
  print(int(A/2))
else:
  print(int(A//2)+1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import numpy as np

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

lcm = np.lcm.reduce([int(i/2) for i in a_list])

if lcm <= M:
    print(((M // lcm) // 2) + 1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1):
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)

if buf!=0 and buf!=n:
    print(0)
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))
    if (a[i]//2)%2!=0:
        buf+=1
    else:
        continue

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)
  
if buf!=0 and buf!=n:
    print(0)
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Submission status: Runtime Error

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

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 1) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return a * b / cd
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  cm = 1
  for x in l :
    cm = lcm(x, cm)
    
  return cm

if(not(check_exist(list_a))) :
  print(0)
  exit()

## 1/2の公倍数
lcm_m = lcm_multi(list(map(lambda x: int(x/2), list_a)))

if(M-lcm_m < 0) :
  print(0)
else :
  print(int((M-lcm_m) / (2*lcm_m)) + 1)

Submission status: Runtime Error

Solution code:
import math
import sys
from fractions import gcd
m=10**9 + 7 
sys.setrecursionlimit(1000010)
(N, M) = list(map(int,input().split()))
A  = list(map(int,input().split()))
B = [ a//2 for a in A]

def lcmn(B):
    if len(B)<1 :
        return 1
    elif len(B) == 1:
        return B[0]
    
    x = B[0] * B[1] // gcd(B[0],B[1])
    if x > M:
        return -1 

    for i in range(2,len(B)):
        x  = lcmn([x,B[i]])
        if x > M:
        return -1 
    return x
    

#print(N,M,A,B)

# print(lcmn(B))

x = lcmn(B)
if x == -1:
    print(0)
else:
    print((M//x+1)//2)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]/2))

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)

c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
for i in range(1,n):
    x=lcm(c[i-1],b[i])
    c.append(x)
    if x<m:
        continue
    else:
        break

d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
ans=int((d+1)//2)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
for i in range(n):
    b.append(int(a[i]/2))

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

c=[lcm(b[0],b[1])]
for i in range(1,n):
    x=lcm(c[i-1],b[i])
    c.append(x)

d=int(m//c[len(c)-1])
ans=int((d+1)//2)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
for i in range(n):
    b.append(int(a[i]/2))

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

c=[lcm(b[0],b[1])]
for i in range(1,n):
    x=lcm(c[i-2],b[i])
    c.append(x)

d=int(m//c[len(c)-1])
ans=int((d+1)//2)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
ans=0
for i in range(n):
    b.append(int(a[i]/2))

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

c=[lcm(b[0],b[1])]
for i in range(1,n):
    x=lcm(c[i-2],b[i])
    c.append(x)

d=int(m//c[len(c)-1])
for i in range(1, d+1):
    if i%2!=0:
        ans+=1
    else:
        continue
print(ans)

Submission status: Runtime Error

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

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 1) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return a * b / cd
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  if(len(l) < 2) :
    return l[0]
  cm = lcm(l[0], l[1])
  for i in range(2, N) :
    cm = lcm(l[i], cm)
    
  return cm

ans = 0
if(not(check_exist(list_a))) :
  print(0)
  exit()

lcm_m = lcm_multi(list_a)
if(M-lcm_m/2 < 0) :
  print(0)
else :
  print(int((M-lcm_m/2) / lcm_m) + 1)

Submission status: Runtime Error

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

##半公倍数が存在するかチェック
def check_exist(l) :
  if(len(l) == 0) :
    return True
  while(True) :
    flag = l[0] % 2
    for x in l[1:] :
      if(x % 2 != flag) :
        return False
    if(flag == 0) :
      l = list(map(lambda x: int(x/2), l))
    else :
      return True
    

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  cd = gcd(a, b)
  return a * b / cd
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  if(len(l) < 2) :
    return l[0]
  cm = lcm(l[0], l[1])
  for i in range(2, N) :
    cm = lcm(l[i], cm)
    
  return cm

ans = 0
if(not(check_exist(list_a))) :
  print(0)
  exit()

lcm_m = lcm_multi(list_a)
if(M-lcm_m/2 < 0) :
  print(0)
else :
  print(int((M-lcm_m/2) / lcm_m) + 1)

Submission status: Runtime Error

Solution code:
import numpy as np
n,m = map(int,input().split())
A = np.array([int(i) for i in input().split()])
A_half = A//2
lcm = 1
for i in A_half:
    lcm = np.lcm(lcm,i)
c = m//lcm
print(c//2 + c%2)

Submission status: Runtime Error

Solution code:
import math


def f(x):
    res = 0
    while x % 2 == 0:
        x /= 2
        res += 1
    return res


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


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


# a -> a'
for i in range(N):
    A[i] = A[i] // 2

# a' -> a''
t = f(A[0])
for i in range(N):
    if f(A[i]) != t:
        print(0)
        exit()
    A[i] >>= t  # A[i] /= 2^t
M >>= t

L = 1
for i in range(N):
    L = lcm(L, A[i])
    if L > M:
        print(0)
        exit()

M /= L
ans = math.ceil(M / 2)
print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
import numpy as np
from math import gcd


# noinspection PyShadowingBuiltinsInspection

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

def main():
    N, M = [int(x) for x in input().split()]
    a = sorted(list({int(x) for x in input().split()}), reverse=True)
    x = a[0]
    p2 = 1
    while x % 2 == 0:
        p2 *= 2
        x //= 2
    flag = False
    y = 1 # a//2 の最小公倍数
    for i in range(len(a)):
        if a[i] % p2 != 0 or (a[i] // p2) % 2 == 0:
            flag = True
            break
        a[i] //= 2
        y = lcm(a[i], y)
    if flag:
        return 0
    z = M // y
    return z // 2 if z % 2 == 0 else z // 2 + 1
    # b = [a[0]]
    # for i in range(1, len(a)):
    #     flag = False
    #     for x in b:
    #         if x % a[i] == 0:
    #             flag = True
    #             break
    #     if not flag:
    #         b.append(a[i])
    # # print(b)
    # y = 1
    # for x in b:
    #     # print(b)
    #     y *= x
    # z = M // y
    # # print(y, z*y)
    # ret = z // 2 if z % 2 == 0 else z // 2 + 1
    # # print(ret)
    #
    # return ret


if __name__ == "__main__":
    print(main())

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))

def f(x):
    res = 0
    while x % 2 == 0:
        x/= 2
        res += 1
    return res

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

for i in range(n):
    a[i] //= 2

t = f(a[0])

ans = 0
for i in range(n):
    if f(a[i] != t):
        print(0)
        exit()
    a[i] >>= t

m >>= t

l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        print(0)
        exit()

m //= l
ans = (m + 1)//2
print(ans)

Submission status: Runtime Error

Solution code:
import math

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

def f(x):
    res = 0
    while x % 2 == 0:
        x/= 2
        res += 1
    return res

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

for i in range(n):
    a[i] //= 2

t = f(a[0])

ans = 0
for i in range(n):
    if f(a[i] != t):
        print(0)
        exit()
    a[i] >>= t

m >>= t

l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        print(0)
        exit()

m //= l
ans = (m + 1)//2
print(ans)

Submission status: Runtime Error

Solution code:
import math
import sys

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

def f(x):
    res = 0
    while x % 2 == 0:
        x/= 2
        res += 1
    return res

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

for i in range(n):
    a[i] //= 2

t = f(a[0])

ans = 0
for i in range(n):
    if f(a[i] != t):
        print(0)
        sys.exit(0)
    a[i] >>= t

m >>= t

l = 1
for i in range(n):
    l = lcm(l, a[i])
    if l > m:
        print(0)
        sys.exit(0)

m //= l
ans = (m + 1)//2
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
def lcm(arr, n) -> (int):
    ans = arr[0]
    for i in range(1, n):
        ans = ((arr[i] * ans) // gcd(arr[i], ans))
    return int(ans)

n, m = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
v = []
for x in arr:
    y = x
    cnt = 0
    while y % 2 == 0:
        y = y // 2
        cnt += 1
    v.append(cnt)
mx = max(v)
mn = min(v)
if mx != mn:
    print(0)
else:
    strt = lcm(arr, n) // 2
    if strt > m:
        print(0)
    else:
        print(int(1 + int((m - strt)) // int((2 * strt))))

Submission status: Runtime Error

Solution code:
import math

l = input().split()
n = int(l[0])
m = int(l[1])

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

d = a[0]/2
lcm = a[0]/2

n = len(a)

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

for i in range(1, n):
    d = gcd(lcm, a[i]/2)
    lcm = ((a[i]/2) * lcm)/d

multiples = m//lcm
odd_multiples = math.ceil((1.0*multiples)/2)
print(odd_multiples)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

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

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
    
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr


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

if gcd(*A) % 2 != 0:
    print(0)
    exit(0)

sisu_2 = factorization(A[0])[0][1] 

lcm_a = lcm(*A)
lcm_a_half = lcm_a // 2

#if (lcm_a // (2**(sisu_2-1)) % 2 == 0) or lcm_a > M:
if factorization(lcm_a)[0][1] != sisu_2 or lcm_a_half > M:
    print(0)
    exit(0)
else:
    print(int((M-lcm_a_half) // (lcm_a_half*2) + 1))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

def lcm(a, b):return a//gcd(a,b)*b
def lcm_list(x): return reduce(lcm, x)
def gcd_list(x): return reduce(gcd, x)

n,m = map(int, input().split())
a = [*map(lambda x: int(x)//2 , input().split())]
l = lcm_list(a)
if l <= m:
    print((m//l+2-1)//2) # round up
else:
    print(0)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(map(lambda x:int(x) // 2, input().split()))

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

temp = lcm(a[0], a[1])
if (temp // a[0]) % 2 == 0 or (temp // a[1]) % 2 == 0:
    print(0)
    exit()

if n > 2:
    for y in a[2:]:
        temp = lcm(temp, y)
        if (temp // y) % 2 == 0 or temp > m:
            print(0)
            exit()

ans = m // temp
print(ans - ans // 2)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(map(lambda x:int(x) // 2, input().split()))

def gcd(a, b):
	while b:
		a, b = b, a % b
	return a

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

temp = lcm(a[0], a[1])
if (temp // a[0]) % 2 == 0 or (temp // a[1]) % 2 == 0:
    print(0)
    exit()

for y in a[2:]:
    temp = lcm(temp, y)
    if (temp // y) % 2 == 0 or temp > m:
        print(0)
        exit()

ans = m // temp
print(ans - ans // 2)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce


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

hA = [a//2 for a in A]
lcm = 1
for a in hA:
    lcm = (lcm * a) // fractions.gcd(lcm, a)
    if lcm > m:
        print(0)
        break
else:
    else:
        if (m//lcm) % 2 == 0:
            print(m//lcm//2)
        else:
            print(m//lcm//2 + 1)

Submission status: Runtime Error

Solution code:
from fractions import gcd

n,m = list(map(lambda x: int(x),input().split()))
a = list(map(lambda x: int(int(x)/2),input().split()))

a_uni = list(set(a))
a_gcd = gcd(a_uni[0],a_uni[1])
a_m = 1
count = 0

for i in a_uni :
    a_m *= i
    if count >= 2 :
        a_gcd = gcd(a_gcd,i)
    count += 1

a_lcm = a_m // a_gcd

while True :
    if a_m % 2 != 0 and a_m % (2*len(a_uni)) != 0 :
        #print((m - a_lcm) // (2*a_lcm) + 1)
        print((m//a_lcm+1)//2)
        break
    elif a_m % (2*len(a_uni)) != 0 :
        print(0)
        break

    a_m //= (2*len(a_uni))

Submission status: Runtime Error

Solution code:
from fractions import gcd

n,m = list(map(lambda x: int(x),input().split()))
a = list(map(lambda x: int(int(x)/2),input().split()))

a_uni = a
a_gcd = gcd(a_uni[0],a_uni[1])
a_m = 1


for i in a_uni :
    a_m *= i
    if i >= 2 :
        a_gcd = gcd(a_gcd,i)

a_lcm = a_m // a_gcd

while True :
    if a_m % 2 != 0 and a_m % (2*len(a_uni)) != 0 :
        #print((m - a_lcm) // (2*a_lcm) + 1)
        print((m//a_lcm+1)//2)
        break
    elif a_m % (2*len(a_uni)) != 0 :
        print(0)
        break

    a_m //= (2*len(a_uni))

Submission status: Runtime Error

Solution code:
from fractions import gcd

n,m = list(map(lambda x: int(x),input().split()))
a = list(map(lambda x: int(int(x)/2),input().split()))

a_uni = list(set(a))
a_gcd = gcd(a_uni[0],a_uni[1])
a_m = 1


for i in a_uni :
    a_m *= i
    if i >= 2 :
        a_gcd = gcd(a_gcd,i)

a_lcm = a_m // a_gcd

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

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,m = list(map(lambda x: int(x),input().split()))
a = list(map(lambda x: int(int(x)/2),input().split()))

a_uni = list(set(a))
a_gcd = gcd(a_uni[0],a_uni[1])
a_m = 1


for i in a_uni :
    a_m *= i
    if i >= 2 :
        a_gcd = gcd(a_gcd,i)

a_lcm = a_m // a_gcd

while True :
    if a_m % 2 != 0 and a_m % (2*len(a_uni)) != 0 :
        #print((m - a_lcm) // (2*a_lcm) + 1)
        print((m//a_lcm+1)//2)
        break
    elif a_m % (2*len(a_uni)) != 0 :
        print(0)
        break

    a_m //= (2*len(a_uni))

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,m = list(map(lambda x: int(x),input().split()))
a = list(map(lambda x: int(int(x)/2),input().split()))

a_uni = list(set(a))
a_gcd = gcd(a_uni[0],a_uni[1])
a_m = 1


for i in a_uni :
    a_m *= i
    if i >= 2 :
        a_gcd = gcd(a_gcd,i)

a_lcm = a_m // a_gcd

while True :
    if a_m % 2 != 0 and a_m % (2*len(a_uni)) != 0 :
        #print((m - a_lcm) // (2*a_lcm) + 1)
        print((M//lcm+1)//2)
        break
    elif a_m % (2*len(a_uni)) != 0 :
        print(0)
        break

    a_m //= (2*len(a_uni))

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,m = list(map(lambda x: int(x),input().split()))
a = list(map(lambda x: int(int(x)/2),input().split()))

a_uni = list(set(a))
a_gcd = gcd(a_uni[0],a_uni[1])
a_m = 1


for i in a_uni :
    a_m *= i
    if i >= 2 :
        a_gcd = gcd(a_gcd,i)

a_lcm = a_m // a_gcd

while True :
    if a_m % 2 != 0 and a_m % (2*len(a_uni)) != 0 :
        #print((m - a_lcm) // (2*a_lcm) + 1)
        break
    elif a_m % (2*len(a_uni)) != 0 :
        print(0)
        break

    a_m //= (2*len(a_uni))

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,m = list(map(lambda x: int(x),input().split()))
a = list(map(lambda x: int(int(x)/2),input().split()))

a_uni = list(set(a))
a_gcd = gcd(a_uni[0],a_uni[1])
a_m = 1


for i in a_uni :
    a_m *= i
    if i >= 2 :
        a_gcd = gcd(a_gcd,i)

a_lcm = a_m // a_gcd

while True :
    if a_m % 2 != 0 and a_m % (2*len(a_uni)) != 0 :
        print((m - a_lcm) // (2*a_lcm) + 1)
        break
    elif a_m % (2*len(a_uni)) != 0 :
        print(0)
        break

    a_m //= (2*len(a_uni))