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:
import numpy as np
import math
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g

def lcm(arr):
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
    return l


N,M = map(int,input().split())
A = np.array(list(map(int,input().split())))
AA = A*0.5
print(math.floor((M/lcm(AA)+1)/2))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)

def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

def lcm_core(a,b):
    g = gcd_core(a,b)
    return (a*b)//g

def lcm(arr):
    l = lcm_core(arr[0],arr[1])
    for i in range(2,len(arr)):
        l = lcm_core(l,arr[i])
    return l


N,M = map(int,input().split())
A = np.array(list(map(int,input().split())))
AA = A*0.5
print(AA)
print(math.ceil(M/lcm(AA)/2))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

N, M = map(int, input().split())
alist = list(map(lambda k: int(k) // 2, input().split()))

numdic = {}

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

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

lcmnum = lcm_list(alist)

for i in alist:
    if (lcmnum//i)%2==0:
        print(0)
        sys.exit()

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N, M = map(int, input().split())
alist = list(map(lambda k: int(k) // 2, input().split()))

numdic = {}

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

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

lcmnum = lcm_list(alist)

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)

Submission status: Runtime Error

Solution code:
from fractions import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

n, m = map(int, input().split())
a = [int(x) for x in input().split()]

def solve(a):
    tmp = None
    for ta in a:
        if tmp is None:
            tmp = log(ta)
        else:
            if tmp == log(ta):
                continue
            else:
                print(0)
                return
    l = lcm(*a)
    print(m // l - m // (2*l))

solve(a)

Submission status: Runtime Error

Solution code:
from math import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

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

l = lcm(*(int(x) // 2 for x in input().split()))

print(m // l - m // (2*l))

Submission status: Runtime Error

Solution code:
from math import gcd

def lcm(*args):
    ans = 1
    for x in args:
        ans = ans * x // gcd(ans, x)
    return ans

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

l = lcm(*map(int, input().split()))

print(m // (l//2) - m // l)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


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


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


def lcm_list(numbers):
    x = 1
    for i in range(n):
        x = lcm_base(x, numbers[i])
        if x > 2*m:
            print(0)
            exit()

    return x


def count_two(x):
    count = 0
    while x%2 == 0:
        count += 1
        x //= 2
    return count


two_count = count_two(A[0])
for a in A[1:]:
    if two_count != count_two(a):
        print(0)
        exit()

LCM = lcm_list(A)
# print(LCM)
print((m - LCM//2)//LCM + 1)

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


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


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


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


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


def count_two(x):
    count = 0
    while x%2 == 0:
        count += 1
        x //= 2
    return count


two_count = count_two(A[0])
for a in A[1:]:
    if two_count != count_two(a):
        print(0)
        exit()

LCM = lcm(*A)
# print(LCM)
print((m - LCM//2)//LCM + 1)

Submission status: Runtime Error

Solution code:
#D
from math import gcd
N,M=map(int,input().split())
a=list(map(int,input().split()))
b=[0 for i in range(N)]
for i in range(N):
    b[i]=int(a[i]/2)
    
LCM=1
for i in range(N):
    LCM=int(LCM*b[i]/gcd(LCM,b[i]))
    
flag=True
for i in range(N):
    if int(LCM/b[i])%2==0:
        flag=False
        break

if flag:
    ans=M//LCM
    ans+=ans%2
    ans=int(ans/2)
    
else:
    ans=0

print(ans)

Submission status: Runtime Error

Solution code:
import math
def gcd(l):
    if len(l) == 1:
        return l[0]
    elif len(l) == 2:
        return math.gcd(l[0], l[1])
    else:
        return math.gcd(l[0], gcd(l[1:]))

def lcm(l, mx):
    if len(l)==1:
        return l[0] if l[0] <= mx else 0
    if len(l)==2:
        return l[0]*l[1]//gcd(l) if l[0]*l[1]//gcd(l) <= mx else 0
    if lcm(l[0:2], mx) > 0:
        l.append(lcm(l[0:2], mx))
        del l[0:2]
        return lcm(l, mx)
    return 0

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
if any([i%4==0 for i in a]):
    print(0)
else:
    l = [i//2 for i in a]
    x = lcm(l, 1000000007)
    if x==0:
        print(0)
    else:
        print((m//x+1)//2)

Submission status: Runtime Error

Solution code:
import math
def gcd(l):
    if len(l) == 1:
        return l[0]
    elif len(l) == 2:
        return math.gcd(l[0], l[1])
    else:
        return math.gcd(l[0], gcd(l[1:]))

def lcm(l, mx):
    if len(l)==1:
        return l[0] if l[0] <= mx else 0
    if len(l)==2:
        return l[0]*l[1]//gcd(l) if l[0]*l[1]//gcd(l) <= mx else 0
    if lcm(l[0:2], mx) > 0:
        l.append(lcm(l[0:2], mx))
        del l[0:2]
        return lcm(l, mx)
    return 0

n, m = map(int, input().split())
a = [int(i) for i in input().split()]
if any([i%4==0 for i in a]):
    print(0)
else:
    l = [i//2 for i in a]
    x = lcm(l, m)
    print((m//lcm(l, m)+1)//2)

Submission status: Runtime Error

Solution code:
from math import ceil
N, M = map(int, input().split())
A = list(map(int, input().split()))

# 2で割ったものに置き換え
A = [a // 2 for a in A]

# 各要素について、2で割り切れる回数が等しいかチェック
count_div_2 = None
for a in A:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1

    if count_div_2 is None:
        count_div_2 = cnt
    elif cnt != count_div_2:
        print(0)
        exit()

# LCM計算
while len(A) > 1:
    a, b = A.pop(), A.pop()
    my_lcm = lcm(a, b)

    # Mを超えたlcmは意味がない
    if my_lcm > M:
        print(0)
        exit()

    A.append(my_lcm)


print(ceil(M // A[0] / 2))

Submission status: Runtime Error

Solution code:
import itertools
N=int(input())
C=list(set(map(int,input().split())))
C_sorted=sorted(C)
def LC(X):
  k=0
  for j in range(len(X)):
    k+=(len(X)-j)*X[j]
  return k

def f(D):
  Comb=[]
  for pair in itertools.combinations(C_sorted,D):
    Comb.append(pair)
  Sum_D=0
  for i in range(len(Comb)):
    Sum_D+=LC(Comb[i])
  return Sum_D

t=0
for D in range(1,N+1):
  t+=f(D)
print(((2**N)*t)%((10**9)+7))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
B=[A[i]//2 for i in range(len(A))]

from fractions import gcd 
x=B[0]
for i in range(1,N):
  x=(x*B[i])//gcd(x,B[i])
lcm=x  
if all((lcm//b)%2==1 for b in B):
  Max=M//lcm
  if MaX%2==1:
    print((Max+1)//2)
  else:
    print((Max)//2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[A[i]//2 for i in range(len(A))]

from fractions import gcd 
x=B[0]
for i in range(1,N):
  x=(x*B[i])//gcd(x,B[i])
lcm=x  
if all((lcm//b)%2==1 for b in B):
  Max=M//lcm
  if MaX%2==1:
    print((Max+1)//2)
  else:
    print((Max)//2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[A[i]//2 for i in range(len(A))]

import math
ans=B[0]
for i in range(1,N):
  ans=math.gcd(ans,B[i])
mul=B[0]//ans
for j in range(1,N):
  mul=mul*(B[j]//ans)
lcm=ans*mul

if all((lcm//b)%2==1 for b in B):
  Max=M//lcm
  if MaX%2==1:
    print((Max+1)//2)
  else:
    print((Max)//2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[A[i]//2 for i in range(len(A))]

import fractions
ans=B[0]
for i in range(1,N):
  ans=fractions.gcd(ans,a[i])
mul=B[0]
for j in range(1,N):
  mul=mul*B[j]
lcm=mul//ans

if all((lcm//b)%2==1 for b in B):
  Max=M//lcm
  if MaX%2==1:
    print((Max+1)//2)
  else:
    print((Max)//2)
else:
  print(0)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
n,m = map(int,input().split())
a = list(map(int,input().split()))

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

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

t = lcm_list(a)

cnt = 0
p = 0.5
while True:
    if 1 <= t*p <= m:
        cnt += 1
        p += 1
    else:
        break

print(cnt)

Submission status: Runtime Error

Solution code:
from math import gcd

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

A_lcm = 1
for i in range(N):
    A_lcm *= A[i] // gcd(A_lcm, A[i])
    
for i in A:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()

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

Submission status: Runtime Error

Solution code:
import fractions
def lcm(a, b):
    return a // fractions.gcd(a, b) * b

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

for i in A_half:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()
ans = (M // A_lcm + 1) // 2
print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions
def lcm(a, b):
    return a * b / fractions.gcd(a, b)

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

for i in A_half:
    if A_lcm // i % 2 == 0:
        print(0)
        exit()
ans = (M // A_lcm + 1) // 2
print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions
def lcm(a, b):
    return a * b / fractions.gcd(a, b)

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

ans = 0
if (M // 2) % 2 == 0:
    ans = (M // A_lcm) // 2
else:
    ans = (M // A_lcm) // 2 + 1

print(int(ans))

Submission status: Runtime Error

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

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

ans = 0
if (M // 2) % 2 == 0:
    ans = (M // A_lcm) // 2
else:
    ans = (M // A_lcm) // 2 + 1

print(int(ans))

Submission status: Runtime Error

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

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

A_half = [0.5 * a for a in A]
A_lcm = A_half[0]

for i in range(1, N):
    A_lcm = lcm(int(A_lcm), int(A_half[i]))

ans = (M // A_lcm) // 2 if (M // 2) % 2 == 0 else (M // A_lcm) // 2 + 1
print(int(ans))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
B=[i+1 for i in range (M)]
C=[s for s in B if (s/A[j]-0.5).is_integer() for j in range(0,N-1)]
print(len(C))

Submission status: Runtime Error

Solution code:
import math


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


def calc(n, m):
    for i in range(cycle//m+1):
        X = m * (i + 0.5)
        flag = True
        for x in n:
            if (X - x // 2) % x != 0:
                flag = False
                break
        if flag:
            return int(X)
    return -1


N, M = map(int, input().split())
A = list(map(int, input().split()))
cycle = 1
ma = 0
for a in A:
    cycle = lcm(cycle, a)
    ma = max(ma, a)
start = calc(A, ma)

if start == -1:
    print(0)
else:
    print((M - start) // cycle + 1)

Submission status: Runtime Error

Solution code:
from math import gcd
lcm = lambda x, y: x*y//gcd(x, y)

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

cm = arr[0]
for e in arr[1:]:
    cm = lcm(cm, e)

if any([cm//e % 2 == 0 for e in arr]):
    print(0)
    exit()
print((m//cm+1)//2)

Submission status: Runtime Error

Solution code:
import math
N , M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(lambda x:x//2, A))
ans = 0
flag = 1
for i in range(N):
  if B[i] %2 == 0:
    flag = 0
if flag:
  minv = 1
  C = [0]*(N+1)
  C[0] = 1
  for j in range(N):
      C[j+1] = C[j]*B[j]//math.gcd(C[j], B[j])
  minv = C[N]
  ans = int((M-minv)/(2*minv)+1)
print(ans)

Submission status: Runtime Error

Solution code:
import math
N , M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(lambda x:x//2, A))
ans = 0
flag = 1
for i in range(N):
  if B[i] %2 == 0:
    flag = 0
if flag:
  minv = 1
  C = [0]*(N+1)
  C[0] = 1
  for j in range(N):
      C[j+1] = C[j]*B[j]//math.gcd(C[j], B[j])
  minv = C[N]
  ans = int((M/minv-1)/2)+1
print(ans)

Submission status: Runtime Error

Solution code:
import math
N , M = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(lambda x:x//2, A))
ans = 0
flag = 1
for i in range(N):
  if B[i] %2 == 0:
    flag = 0
if flag:
  minv = 1
  C = [0]*(N+1)
  C[0] = 1
  for j in range(N):
      C[j+1] = C[j]*B[j]//math.gcd(C[j], B[j])
  minv = C[N-2]
  ans = int((M/minv-1)/2)+1
print(ans)

Submission status: Runtime Error

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

a.sort()
p = int(M/a[-1]-0.5)
candidate = []
for i in range(1,p+1):
  candidate.append(a[-1]*(i+0.5))

for i in range(N-2,-1,-1):
  del_idx = []
  p = len(candidate)
  for j in range(p):
    if (candidate[j]-0.5*a[i])%a[i] != 0:
      del_idx.append(j)
  
print(len(candidate)-len(del_idx))

Submission status: Runtime Error

Solution code:
from math import gcd
N, M = map(int, input().split())
S = list(map(int, input().split()))

temp = S[0]
for i in range(1, N):
    temp = temp*S[i]//gcd(temp, S[i])
if temp//2 > M:
    print(0)
else:
    print((M-temp//2)//temp+1)

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)
    
N,M=map(int,input().split())
A=set(map(int,input().split()))
cnt=0
B=[]
C=[]

for i in A:
    tmp=(i/2)
    if tmp%2!=0:
        B.append(i)
    else:
        C.append(i)
#print(B)        
q=lcm(*A)
#print(q)
if len(A)==len(B) or len(A)==len(C):
    if 2*M<q:
        print(0)
    elif (2*M//q)%2==0:
        print(2*M//(2*q))
    else:
        print(2*M//(2*q)+1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
def main():
    from math import gcd, ceil

    n, m, *a = map(int, open(0).read().split())
    b = [0 for _ in range(n)]
    a.sort()

    for i, j in enumerate(a):
        c = 0
        while j % 2 == 0:
            c += 1
            j = j // 2
        a[i] = j
        b[i] = c

    if len(set(b)) > 1:
        print(0)
        exit()

    lcm = 1
    for i in a:
        lcm = (lcm * i) // gcd(lcm, i)

    k = b[0] - 1
    ans = ceil(m // 2 ** k // lcm / 2)
    print(ans)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
def gcd_e(x, y):
  if y == 0:
    return x
  else:
    return gcd_e(y,x%y)      

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

n,m=list(map(int,input().split()))
A=list(map(int,input().split()))
a,b=A[0],0

for i in range(1,n):
  b = A[i]
  a = lcm(a,b)
  
if a / 2 > m:
  print('0')
else:
  print((m-a//2)//a+1)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,M = map(int,input().split())
a = list(map(int,input().split()))

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

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

lcm = lcm_list(a)
print((M+lcm//2)//lcm)

Submission status: Runtime Error

Solution code:
import sys
import math
from functools import reduce

readline = sys.stdin.buffer.readline


def main():
    gcd = math.gcd

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

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

    B = A[::]
    while not any(b % 2 for b in B):
        B = [b // 2 for b in B]

    if not all(b % 2 for b in B):
        print(0)
        return

    semi_lcm = reduce(lcm, (a // 2 for a in A))
    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import sys
from math import gcd
from functools import reduce

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60


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


def main():
    N, M, *A = map(int, read().split())
    A = [a // 2 for a in A]

    semi_lcm = reduce(lcm, A)
    for a in A[1:]:
        semi_lcm = lcm(semi_lcm, a)
        if semi_lcm > M or semi_lcm // a % 2 == 0:
            print(0)
            return

    print((M // semi_lcm + 1) // 2)
    return


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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

for i in range(n):
    a[i] = a[i]//2
    
# print(a)
def calc(n):
    ret = 0
    while n%2 == 0:
        ret +=1
        n/=2
    return ret


flag = True
t = 0
for i in range(n-1):
    # t = 2**calc(a[i])
    if calc(a[i]) == calc(a[i+1]):
        continue
    else:
        flag = False
        break


gcd_a = 1
for i in range(n):
    p = max(gcd_a, a[i])
    q = min(gcd_a, a[i])
    gcd_a = gcd_a*a[i]//gcd(p, q)
# print("gcd_a", gcd_a)

if flag:
    if (m//gcd_a)%2 == 0:
        print(int((m//gcd_a)//2))
    else:
        print(int((m//gcd_a+1)//2))
else:
    print(0)

Submission status: Runtime Error

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

for i in range(n):
    a[i] = a[i]//2
    
# print(a)
def calc(n):
    ret = 0
    while n%2 == 0:
        ret +=1
        n/=2
    return ret


flag = True
t = 0
for i in range(n-1):
    t = 2**calc(a[i])
    if calc(a[i]) == calc(a[i+1]):
        continue
    else:
        flag = False
        print(0)
        exit()

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


gcd_a = a[0]
for i in range(1,n):
    p = max(gcd_a, a[i])
    q = min(gcd_a, a[i])
    gcd_a = gcd_a*a[i]//gcd(p, q)
# print("gcd_a", gcd_a)

if flag:
    if (m//gcd_a)%2 == 0:
        print(int((m//gcd_a)//2))
    else:
        print(int((m//gcd_a+1)//2))

Submission status: Runtime Error

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

for i in range(n):
    a[i] = a[i]//2
    
# print(a)
def calc(n):
    ret = 0
    while n%2 == 0:
        ret +=1
        n/=2
    return ret


flag = True
t = 0
for i in range(n-1):
    t = 2**calc(a[i])
    if calc(a[i]) == calc(a[i+1]):
        continue
    else:
        flag = False
        print(0)
        exit()

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


gcd_a = a[0]
for i in range(1,n):
    p = max(gcd_a, a[i])
    q = min(gcd_a, a[i])
    gcd_a = gcd_a*a[i]//gcd(p, q)
# print("gcd_a", gcd_a)

if flag:
    if (m//gcd_a)%2 == 0:
        print(int((m//gcd_a)//2))
    else:
        print(int((m//gcd_a+1)//2))

else:
    print(0)

Submission status: Runtime Error

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

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

def calc(n):
    ret = 0
    while n%2 == 0:
        ret +=1
        n/=2
    return ret


flag = True
t = 0
for i in range(n-1):
    t = 2**calc(a[i])
    if calc(a[i]) == calc(a[i+1]):
        continue
    else:
        flag = False
        print(0)
        exit()

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

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

gcd_a = a[0]
for i in range(1,n):
    p = max(gcd_a, a[i])
    q = min(gcd_a, a[i])
    gcd_a = gcd_a*a[i]//gcd(p, q)
# print("gcd_a", gcd_a)

if flag:
    if (m//gcd_a)%2 == 0:
        print(int((m//gcd_a)//2))
    else:
        print(int((m//gcd_a+1)//2))

else:
    print(0)

Submission status: Runtime Error

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

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

def calc(n):
    ret = 0
    while n%2 == 0:
        ret +=1
        n/=2
    return ret


flag = True
t = 0
for i in range(n-1):
    t = 2**calc(a[i])
    if calc(a[i]) == calc(a[i+1]):
        continue
    else:
        flag = False
        print(0)
        exit()

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

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

gcd_a = a[0]
for i in range(1,n):
    p = max(gcd_a, a[i])
    q = min(gcd_a, a[i])
    gcd_a = gcd_a*a[i]//gcd(p, q)
print("gcd_a", gcd_a)

if flag:
    if (m//gcd_a)%2 == 0:
        print((m//gcd_a)//2)
    else:
        print((m//gcd_a+1)//2)

else:
    print(0)

Submission status: Runtime Error

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

def calc(n):
    ret = 0
    while n%2 == 0:
        ret +=1
        n/=2
    return ret
flag = True
t = 0
for i in range(n-1):
    t = 2**calc(a[i])
    if calc(a[i]) == calc(a[i+1]):
        continue
    else:
        flag = False
        print(0)
        exit()

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

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

gcd_a = a[0]
for i in range(1,n):
    p = max(gcd_a, a[i])
    q = min(gcd_a, a[i])
    gcd_a = gcd_a*a[i]//gcd(p, q)

if flag:
    if (m//gcd_a)%2 == 0:
        print((m//gcd_a)//2)
    else:
        print((m//gcd_a+1)//2)

else:
    print(0)

Submission status: Runtime Error

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

def calc(n):
    ret = 0
    while n%2 == 0:
        ret +=1
        n/=2
    return ret
flag = True
t = 0
for i in range(n-1):
    t = 2**calc(a[i])
    if calc(a[i]) == calc(a[i+1]):
        continue
    else:
        flag = False
        print(0)
        exit()

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

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

gcd_a = a[0]
for i in range(1,n):
    p = max(gcd_a, a[i])
    q = min(gcd_a, a[i])
    gcd_a = gcd_a*a[i]//gcd(p, q)

if flag:
    print(m//(2*gcd_a) + (m%(2*gcd_a)//gcd_a))

else:
    print(0)

Submission status: Runtime Error

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

def calc(n):
    ret = 0
    while n%2 == 0:
        ret +=1
        n/=2
    return ret
flag = True
t = 0
for i in range(n-1):
    t = 2**calc(a[i])
    if calc(a[i]) == calc(a[i+1]):
        continue
    else:
        flag = False
        print(0)
        exit()

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

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

gcd_a = a[0]
for i in range(1,n):
    print(i,gcd_a)
    p = max(gcd_a, a[i])
    q = min(gcd_a, a[i])
    print(gcd(p,q))
    gcd_a = gcd_a*a[i]//gcd(p, q)

if flag:
    print(m//(2*gcd_a) + (m%(2*gcd_a)//gcd_a))

else:
    print(0)

Submission status: Runtime Error

Solution code:

def main():
    n, m = map(int, input().split())
    aa = list(map(int, input().split()))

    from math import gcd
    from functools import reduce

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

    l = reduce(lcm, aa)
    count = (m - l//2) // l + 1

    print(count)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from fractions import gcd
n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
for i in a:
  lcm = lcm // gcd(lcm,i) * i
ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
sum = 0
for i in a:
  if (lcm // i) % 2 == 1:
    sum += 1
if sum != len(a):
  ans = 0
print(ans)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2147483647)


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

import math
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //math.gcd(ans, a[i])

if ans%2==1:
    print(0)
    exit()

ans=ans//2

print((((m//ans)*(-1))//2)*(-1))

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(2147483647)


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

import math
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //math.gcd(ans, a[i])

cnt=0
i=1
tmp=ans
while 1:
    #print(tmp)
    if tmp%2==0 and (tmp//2)%2==1:
        if (tmp//2)%2<=m:
            cnt+=1
        else:
            break
    
    if tmp//2>m:
        break
    i+=1
    tmp=ans*i

print(cnt)

Submission status: Runtime Error

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

import math
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] //math.gcd(ans, a[i])

cnt=0
i=1
tmp=ans
while 1:
    #print(tmp)
    if tmp%2==0 and (tmp//2)%2==1:
        if (tmp//2)%2<=m:
            cnt+=1
        else:
            break
    
    if tmp//2>m:
        break
    i+=1
    tmp=ans*i

print(cnt)

Submission status: Runtime Error

Solution code:
def n1():return [int(x) for x in 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)

n,m=n1()
A=n1()
B=[i//2 for i in A]
while True:
    s=sum([i%2 for i in s])
    if sum(s)<n:
        break
if 0<s<n:
    print(0)
else:
    c=lcm_list(B)
    if c>m:
        print(0)
    else:
        print((m-c)//(c*2)+1)

Submission status: Runtime Error

Solution code:
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [[input().split()] for _ in range(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes,no): print(yes) if b else print(no)

n,m=n1()
A=n1()
B=[i//2 for i in A]
s=sum([i%2 for i in B])
if 0<s<n:
    print(0)
else:
    import fraction
    from functools import reduce
    def lcm_base(x, y):
        return (x * y) // fraction.gcd(x, y)
    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)
    c=lcm_list(B)
    if c>m:
        print(0)
    else:
        print((m-c)//(c*2)+1)

Submission status: Runtime Error

Solution code:
import math
import numpy as np

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

X_list = []

for p in range(math.floor(M/min(A))):
    X_list.append([a*(p+0.5) if a*(p+0.5)<M else -1 for a in A])
    
X_list_T = np.array(X_list).T
X_list_common = set(X_list_T[0])

for i in range(1, N):
    X_list_common =  X_list_common & set(X_list_T[i])
    
X_list_common = set(X_list_T[0])


if -1 in X_list_common:
    print(len(X_list_common - 1))
else:
    print(len(X_list_common))

Submission status: Runtime Error

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

X_list = []

for p in range(math.floor(M/min(A))):
    X_list.append([a*(p+0.5) if a*(p+0.5)<M else -1 for a in A])
    
import numpy as np

X_list_T = np.array(X_list).T

X_list_common = set(X_list_T[0])

for i in range(1, N):
    X_list_common =  X_list_common & set(X_list_T[i])
    
if -1 in X_list_common:
    print(len(X_list_common - 1))
else:
    print(len(X_list_common))

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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

n = lcm(a[0]//2, a[1]//2)
for i in range(2, N):
    n = lcm(n, a[i]//2)

if(M >= n):
    a = (M//n)//2
    if(a%2 == 0):
        print(a)
    else:
        print(a+1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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

n = lcm(a[0]//2, a[1]//2)
for i in range(2, N):
    n = lcm(n, a[i]//2)

if(M >= n):
    ans = (M//n)//2
    print(ans+1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

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

n = lcm(a[0], a[1])
for i in range(2, N):
    n = lcm(n, a[i])

if(M >= n//2):
    ans = (M//(n//2))//2
    print(ans+1)
else:
    print(0)

Submission status: Runtime Error

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

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

min = 1
for ak in a:
    min = min*ak // math.gcd(min,ak) // 2

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