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:
from fractions import gcd
import queue
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) // (2*a_lcm) + 1)

Submission status: Runtime Error

Solution code:
import sys
from fractions import gcd
N, M = map(int, input().split())
an = list(map(lambdax: int(x)//2, input().split()))

lcm = an[0]
for a in an[1:]:
    l = lcm*a//gcd(lcm, a)
    if not (l//lcm % 2 == l//a % 2):
        print(0)
        sys.exit()
    lcm = l
print((M//lcm+1)//2)

Submission status: Runtime Error

Solution code:
import sys
from fractions import gcd
N, M = map(int, input().split())
an = list(map(int, input().split()))

l = an[0]
for a in an[1:]:
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        lcm = LCM
    else:
        print(0)
        sys.exit()
print((M//lcm+1)//2)

Submission status: Runtime Error

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

l = an[0]
for a in an[1:]:
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        lcm = LCM
    else:
        print(0)
        exit()
print((M//lcm+1)//2)

Submission status: Runtime Error

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

l = an[0]
for a in an[1:]:
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        l = LCM
    else:
        print(0)
        exit()
print((M//LCM+1)//2)

Submission status: Runtime Error

Solution code:
import sys

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

def gcd(x, y):
  if y:
    return gcd(y, x%y)
  else:
    return x

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


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

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

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

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

Submission status: Runtime Error

Solution code:
from heapq import heappush, heappop
from collections import deque
import re
import math
import functools
import itertools


def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29


def mk1d(n, val=INF):
    return [val for i in range(n)]

def mk2d(h, w, val=INF):
    return [[val for i in range(w)]for i in range(h)]

DIV = 998244353


def convolve(a, b):
    p, g = 1107296257, 5
    n0, n1 = len(a), len(b)
    n = 1 << (max(n0, n1) - 1).bit_length() + 1
    a = a + [0] * (n-n0)
    b = b + [0] * (n-n1)
    w = pow(g, (p - 1) // n, p)
    invw = pow(w, p-2, p)

    def fft(f):
        d = n // 2
        v = w
        while d >= 1:
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, u * (f[j] - f[j+d]) % p
                u = u * v % p
            v = v * v % p
            d //= 2

    def ifft(f):
        d = 1
        while d < n:
            v = pow(invw, n // (2 * d), p)
            u = 1
            for i in range(d):
                for j in range(i, n, 2*d):
                    f[j+d] *= u
                    f[j], f[j+d] = (f[j] + f[j+d]) % p, (f[j] - f[j+d]) % p
                u = u * v % p
            d *= 2

    fft(a), fft(b)
    for i in range(n):
        a[i] = a[i] * b[i] % p
    ifft(a)
    invn = pow(n, p - 2, p)
    return [a[i] * invn % p for i in range(n0 + n1 - 1)]


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 main():
    N,M = isRaw()
    As = isRaw()
    As2 = [a//2 for a in As]
    div2X =2
    while True:
        divResult = [a%div2X==0 for a in As]
        if sum(divResult) != len(As2):
            break
        div2X *=2
    div2X*=2
    if sum([a % div2X == 0 for a in As]) !=0:
        return 0
    lcm = lcm_list(As2)
    nCM = M//lcm
    return (nCM+1)//2

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

Submission status: Runtime Error

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


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 factor_two(x):
    counter = 0
    while x%2==0:
        x = x/2
        counter = counter + 1
    return counter



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

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


# print(N, M)
# print(a)

alpha = [int(x/2) for x in a]


# check 2の因数
factor = [factor_two(x) for x in a]

if not all([e == factor[0] for e in factor[1:]]):
    print("0")
    sys.exit()


# sys.exit()


L = lcm_list(alpha)

print(int(math.ceil(M/2/L - 0.5)))

Submission status: Runtime Error

Solution code:
import math
from fractions import gcd

from functools import reduce
import sys



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

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

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


def factor_two(x):
    counter = 0
    while x%2==0:
        x = x/2
        counter = counter + 1
    return counter



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

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


# print(N, M)
# print(a)

alpha = [int(x/2) for x in a]


# check 2の因数
factor = [factor_two(x) for x in a]

if not all([e == factor[0] for e in factor[1:]]):
    print("0")
    sys.exit()


# sys.exit()


L = lcm_list(alpha)

print(math.ceil(M/2/L - 0.5))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
# from fractions import reduce
import sys



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 factor_two(x):
    counter = 0
    while x%2==0:
        x = x/2
        counter = counter + 1
    return counter



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

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


# print(N, M)
# print(a)

alpha = [int(x/2) for x in a]


# check 2の因数
factor = [factor_two(x) for x in a]

if not all([e == factor[0] for e in factor[1:]]):
    print("0")
    sys.exit()


# sys.exit()


L = lcm_list(alpha)

print(math.ceil(M/2/L - 0.5))

Submission status: Runtime Error

Solution code:
import math
from fractions import reduce
import sys



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 factor_two(x):
    counter = 0
    while x%2==0:
        x = x/2
        counter = counter + 1
    return counter



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

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


# print(N, M)
# print(a)

alpha = [int(x/2) for x in a]


# check 2の因数
factor = [factor_two(x) for x in a]

if not all([e == factor[0] for e in factor[1:]]):
    print("0")
    sys.exit()


# sys.exit()


L = lcm_list(alpha)

print(math.ceil(M/2/L - 0.5))

Submission status: Runtime Error

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

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

def gcd(x, y):
  if y:
    return gcd(y, x%y)
  else:
    return x

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

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    ans = 0
    break
  a[i] >>= t
m >>= t

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

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

Submission status: Runtime Error

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

l = an[0]
for a in :
    LCM = l*a//gcd(l, a)
    if LCM//l % 2 == LCM//a % 2 == 1:
        l = LCM
    else:
        print(0)
        exit()
print((M//LCM+1)//2)

Submission status: Runtime Error

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

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

def lcm(x, y):
  z = x * y
  if x < y:
    x, y = y, x
  while x%y != 0:
    x, y = y, x%y
  return z // y

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    print(0)
    break
  a[i] >>= t
m >>= t

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

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

Submission status: Runtime Error

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

a = an[0]
for i in range(1, len(an)):
    GCD = gcd(a, an[i])
    x, y = a // GCD, an[i] // GCD
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(-(-M//a))

Submission status: Runtime Error

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

a = an[0]
for i in range(1, len(an)):
    GCD = gcd(a, A[i])
    x, y = a // GCD, A[i] // GCD
    if x % 2 == y % 2 == 1:
        a = x*y*z
    else:
        print(0)
        break
else:
    print(-(-M//a))

Submission status: Runtime Error

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

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

def lcm(x, y):
  z = x * y
  if x < y:
    x, y = y, x
  while x%y != 0:
    x, y = y, x%y
  return z // y

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    print(0)
    break
  a[i] >>= t
m >>= t

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

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

Submission status: Runtime Error

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

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

def lcm(x, y):
  z = x * y
  if x < y:
    x, y = y, x
  while x%y != 0:
    x, y = y, x%y
  return z // y

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    print(0)
    break
  a[i] >>= t
m >>= t

L = a[0]
for i in range(1, n):
  L = lcm(L, a[i])
  if L > M:
    print(0)
    break

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

Submission status: Runtime Error

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

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

def lcm(x, y):
  z = x * y
  if x < y:
    x, y = y, x
  while x%y != 0:
    x, y = y, x%y
  return z // y

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    print(0)
    break
  a[i] //= 2 ** t
m //= 2 ** t

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

if L > m:
  ans = 0
else:
  m //= L
  ans = (m+1) // 2
print(ans)

Submission status: Runtime Error

Solution code:
import math

n, m = map(int, input().split())
res, mx, lm = int(0), 2000000001, 1
data = list(map(int, input().split()))

for i in range(n):
    res = data[i]
    g = math.gcd(lm, res)
    lm = int(lm * res / g)
    if lm >= mx:
        print(0)
        exit()
temp = lm / 2
for i in range(n):
    if temp % data[i] != data[i] // 2:
        print(0)
        exit()
ans = int(m / lm)
val = m % lm
if val >= lm / 2:
    ans += 1
print(int(ans))
exit(0)

Submission status: Runtime Error

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

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

def lcm(x, y):
  z = x * y
  if x < y:
    x, y = y, x
  while x%y != 0:
    x, y = y, x%y
  return z // y

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    print(0)
    break
  a[i] //= 2 ** t

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

if L > m:
  ans = 0
else:
  m //= L
  ans = (m+1) // 2
print(ans)

Submission status: Runtime Error

Solution code:
#ABC150_D

from fractions import gcd
N,M=map(int,input().split())
A=list(map(int,input().split()))
lcm=a[0]//2

for x in A:
    x//=2
    g=gcd(lcm,x)
    
    if (lcm//g)%2!=(x//g)%2:
        print(0)
        exit()
    
    lcm=lcm*x//g
print((M//lcm+1)//2)

Submission status: Runtime Error

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

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

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    print(0)
    break
  a[i] //= 2 ** t

lcm = a[0]
for i in range(1, n):
  lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

if lcm > m:
  ans = 0
else:
  m //= lcm
  ans = (m+1) // 2
print(ans)

Submission status: Runtime Error

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

def search(x):
    lo = 0
    hi = 10**9
    while lo < hi:
        mid = lo + (hi-lo)//2
        if x * (2*mid+1) > 2 * m :
            hi = mid
        else:
            lo = mid + 1

    return lo

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


def lcm(arr, n):
    ans = arr[0]
    for i in range(1,n):
        ans = (arr[i] * ans) / (gcd(arr[i], ans))

    return ans

arr = [ int(i) for i in input().split() ]
g = search(lcm(arr,n))
print(g)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
s = set()
B = []
for a in A:
    t = a & -a
    s.add(t)
    if len(s) > 1:
        print(0)
        exit()
    B.append(a // t)

from math import gcd
l = 1
for b in B:
    l = b*l // gcd(b,l)

x = l*t // 2
ans = M//x - M//(2*x)
print(ans)

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()]
for i in range(N):
    if( i == 0 ):
        ld = A[i] // 2
    else:
        ld = ld * A[i] // 2 // math.gcd( ld, A[i] // 2 )
ans = M // ld
if( ans % 2 == 0 ):
    ans = ans // 2
else:
    ans = ans // 2 + 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from math import gcd
n,m = [int(j) for j in input().split()]
A = [int(j)//2 for j in input().split()]
s = A[0]
for i in A[1:]:
    s = int(s*i/gcd(i,s))
a = m//s
if a%2==0:
    print(int(a//2)) 
else:
    print(int(a//2)+1)

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 lcmroop(n1, n2):
    a1 = n1
    a2 = n2
    while n1 % n2 != 0:
        x = n1 % n2
        n1 = n2
        n2 = x
    gcd = n2
    lcm = int(a1 * a2 / gcd)
    return lcm

for i in range(len(a)-1):
    if i == 0:
        lcm = lcmroop(a[i], a[i+1])
    else:
        lcm = lcmroop(lcm, a[i+1])

num = m // lcm
if num % 2 == 0:
    print(num//2)
else:
    print(num//2+1)

Submission status: Runtime Error

Solution code:
import itertools
import math

def main():
    input_line = map(int,input().split(' '))
    n,m = input_line
    a = list(map(lambda x:int(x)//2,input().split(' ')))
    print(a)
    glc = 1
    for i in range(len(a)):
        glc = a[i]*glc//math.gcd(a[i],glc)
    print(glc)
    print(((m//glc)+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]//=2
from copy import copy
b=copy(a)
while True:
	i=0
	for i in range(n):
		if b[i]%2==0:
			b[i]//=2
		else:
			break
	if i==0:
		break
	else:
		print(0)
		exit()
a_gcd=a[0]
for i in range(1,n):
	a_gcd=a_gcd*a[i]//gcd(a_gcd,a[i])
print((m+a_gcd)//(a_gcd*2))

Submission status: Runtime Error

Solution code:
# ABC150 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from fractions import gcd
from math import ceil
def lcm(x, y):
    return (x * y) // gcd(x, y)
n,m=nm()
a=nl()
ans=0
a=[x//2 for x in a] 

lcm_v=a[0]
for i in range(n):
    lcm_v=lcm(lcm_v,a[i])
ok_flg=[(lcm_v//i)%2==1 for i in a]
if all(ok_flg):
    ans=((m//lcm)+1)//2
print(ans)

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 range(0,len(a)):
  lcm = (lcm * a[i]) // gcd(lcm,a[i])

ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
sum = 0
for i in range(0,len(a)):
  if (lcm // a[i]) % 2 == 1:
    sum += 1

if sum != len(a):
  ans = 0
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd

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

a=list(set(a))

l=a[0]//2
g=a[0]//2
for i in range(1,len(a)):
    g=gcd(g,a[i]//2)
    l=l*a[i]//(2*g)

ans=(M-l)//(2*l)+1

print(ans)

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 range(0,len(a)):
  lcm = lcm * a[i] // gcd(lcm,a[i])

ans = m // lcm
if (ans+0.5) * lcm <= m:
  ans += 1
sum = 0
for i in range(0,len(a)):
  if (lcm // a[i]) % 2 == 1:
    sum += 1

if sum != len(a):
  ans = 0
print(ans)

Submission status: Runtime Error

Solution code:
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

func GCD(a, b int) int {
  if a < b { a, b = b, a }
  for 0 < b {
    a, b = b, a % b
  }
  return a
}

func LCM(A []int) int {
  lcm := A[0]
  for _, a := range A {
    lcm = lcm * a / GCD(lcm, a)
  }
  return lcm
}

func main() {
  NM := NextIntVec()
  M := NM[1]
  A := NextIntVec()
  k := 0
  for a := A[0]; a % 2 == 0; k++ {
    a /= 2
  }
  ans := -1
  for _, a := range A[1:] {
    cnt := 0
    for _a := a; _a % 2 == 0; cnt++ {
      _a /= 2
    }
    if cnt != k {
      ans = 0
      break
    }
  }
  if ans < 0 { ans = (M / (LCM(A) / 2) + 1) / 2 }
  Write(ans)
  Output()
}

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions

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

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

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

lcm = lcm_list(a_list)

print(int(-(-(M//(lcm/2)) // 2)))

Submission status: Runtime Error

Solution code:
import fractions,sys

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] // fractions.gcd(ans, a[i])
ff=[]
for j in  a:
    count=0
    for i in range(1,36):
        if j%(2**i)==0:
            count+=1
    ff.append(count)
ff=[i==ff[0] for i in ff]

 
# b = [int(i/2) for i in a]
# b_list=[i%4==0 for i in b]
# bb=sum(b_list)
# if bb!=0 and bb!=n:
if all(ff)==False:
    print(0)
    exit()

ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])

# tf=[(ans2/i)%2==0 for i in b]
# and any(tf)
if ans2>m:
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)

Submission status: Runtime Error

Solution code:
import fractions,sys

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] // fractions.gcd(ans, a[i])
ff=[]
for j in  a:
    count=0
    for i in range(1,36):
        if j%(2**i)==0:
            count+=1
    ff.append(count)
ff=[i==ff[0] for i in ff]

 
# b = [int(i/2) for i in a]
# b_list=[i%4==0 for i in b]
# bb=sum(b_list)
# if bb!=0 and bb!=n:
if all(ff)==False:
    print(0)
#     exit()

ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])

# tf=[(ans2/i)%2==0 for i in b]
# and any(tf)
if ans2>m:
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)

Submission status: Runtime Error

Solution code:
import fractions,sys

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] // fractions.gcd(ans, a[i])
 
 
b = [int(i/2) for i in a]
b_list=[i%4==0 for i in b]
bb=sum(b_list)
if bb!=0 and bb!=n:
    print(0)
    exit()

ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])

tf=[(ans2/i)%2==0 for i in b]
if ans2>m and any(tf):
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)

Submission status: Runtime Error

Solution code:
import fractions
 
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] // fractions.gcd(ans, a[i])
 
 
b = [int(i/2) for i in a]
ans2= b[0]
for i in range(1,n):
    ans2 = ans2 * b[i] // fractions.gcd(ans2, b[i])

tf=[(ans2/i)%2==0 for i in b]
if ans2>m and any(tf):
    print(0)
else:
    print((m-ans2)//(ans2*2)+1)

Submission status: Runtime Error

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

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

C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x

a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[a//2 for a in A]
W=set()
for i in range(N):
    if A[i]%2!=0:
        W.add(0)
    else:
        a=A[i]//2
        cnt=1
        while a%2!=0:
            a=a//2
            cnt+=1
        W.add(cnt)
if len(W)>1:
    print(0)
    exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x
a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    ans=int(-(-(M//LCM)//2))
print(ans)

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = list(int(i/2) for i in map(int, input().split()))
m = max(A)
A.remove(m)

for i in range(m,M+1,2*m):
	semi = True
	for j in A:
		if i not in range(j,M+1,2*j):
			semi = False
			break
	if semi:
		base = i
		break

print(int(((M // base) + 1)/2))

Submission status: Runtime Error

Solution code:
N, M = map(int, input().split())
A = list(list(range(int(i/2),M+1,2*int(i/2))) for i in map(int, input().split()))
P = set(A[0]).intersection(*A[1:])
print(len(P))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
#define debug(x) cout << #x << " = " << x << '\n';
using namespace std;



int main() {
    cout << fixed << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    int n, m;
    cin >> n >> m;
    ll a[n];
    ll lcm = 1;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i] /= 2;
        lcm = lcm * a[i] / __gcd(lcm, a[i]);
        if (lcm > 1000000000) {
            cout << 0;
            return 0;
        }
    }

    ll ans = m / lcm;
    cout << ans / 2 + ans % 2;

}

Submission status: Runtime Error

Solution code:
import math
import fractions

#最小公倍数
def union_lcm(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=num*lists[i]//fraction.gcd(num,lists[i])
        return num


#最大公約数
def union_gcd(lists):
    if len(lists)==1:
        return lists[0]
    elif len(lists)>1:
        num=lists[0]
        for i in range(1,len(lists)):
            num=fraction.gcd(num,lists[i])
        return num
    
n,m=map(int,input().split())
lists=list(map(int,input().split()))

#受け取ったリスト内の要素を2で割る(uselistっていうlistに保管)
uselist=[0 for i in range(n)]
for i in range(n):
    uselist[i]=lists[i]//2
  
G=union_lcm(uselist)
flag=True
for some in uselist:
    if (G//some)%2==0:
        flag=False
        break
if flag:
    if (m//G)%2==0:
        print((m//G)//2)
    else:
        print((m//G+1)//2)
    
else:
    print(0)

Submission status: Runtime Error

Solution code:
import numpy as np

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

hlcm = 0
cnt = 0

num = a[0]

while num % 2 == 0:
    num //= 2
    cnt += 1

prev_cnt = cnt
hlcm = num

for i in range(1,N):
    num = a[i]
    cnt = 0

    while 1:
        if num % 2 == 0:
           num //= 2
           cnt +=1

        else:
            if cnt != prev_cnt:
               print(0)
               exit()
            else:
               prev_cnt = cnt
               hlcm = np.lcm(hlcm,num*cnt)
               break



ans = M//hlcm
# print(hclm)
print((ans+1)//2)


# num = int(input())
# cnt = 0
# while num % 2 == 0:
#     num //= 2
#     cnt += 1
# print(cnt)

Submission status: Runtime Error

Solution code:
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>
#include <numeric>
#include <string.h>
#include <sys/time.h>
#include <random>


#define fs first
#define sc second

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

ll gcd(ll a, ll b) {
    if(a < b) return gcd(b, a);
    ll r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}


int main(){
    ll n, m, a[101000];
    cin >> n >> m;

    for(int i = 0; i < n; i++){
        cin >> a[i];
        a[i] /= 2;
    }

    ll hist = a[0];
    for(int i = 1; i < n; i++){
        if(hist > m){
            cout << 0 << endl;
            return 0;
        }
        ll x = hist * a[i] / gcd(hist, a[i]);
        if((x / hist) % 2 == 0){
            cout << 0 << endl;
            return 0;
        }
        else{
            hist = x;
        }

        if(hist > m){
            cout << 0 << endl;
            return 0;
        }
    }
    if(hist > m){
        cout << 0 << endl;
        return 0;
    }

    cout << (m - hist) / (2 * hist) + 1 << endl;



    return 0;
}

Submission status: Runtime Error

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

def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x

a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    ans=int(-(-(M//LCM)//2))
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

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


list = {}

hlcm = 0


cnt = 0

num = a[0]

while num % 2 == 0:
    num //= 2
    cnt += 1

prev_cnt = cnt
hlcm = num

for i in range(1,N):
    num = a[i]
    cnt = 0

    while 1:
        if num % 2 == 0:
           num //= 2
           cnt +=1

        else:
            if cnt != prev_cnt:
               print(0)
               exit()
            else:
               prev_cnt = cnt
               hclm = np.lcm(hlcm,num*cnt)
               break


# print(hclm)
print(int((M-hclm)/(hclm*2))+1)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

N, M = map(int, input().split())
A = sorted(list(map(int, input().split())), reverse = True)#長さがN

def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
  
def half_lcm_list(numbers):
    return reduce(lcm_base, numbers, 1) / 2

min_A = half_lcm_list(A)

#print(min_A)
ans = 0
if min_A > M:
  ans = 0
else:
  ans = 1
  ans += int((M - min_A) / (min_A * 2))
  
print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np

[N, M] = list(map(int, input().split()))
A = list(map(int, input().split()))
X = []
for a in A:
  P_max = int((M / a) - 0.5)
  P = list(range(1, P_max+1, 1))
  x_a = {int(a * (p + 0.5)) for p in P}
  X.append(x_a)
s0 = X[0] & X[1]
if len(s0) == 0:
  ans = 0
elif N == 2:
  ans = len(s0)
else:
  S = []
  S.append(s0)
  for i in range(2, N, 1):
    s = S[-1] & X[i]
    S.append(s)
    if len(s) == 0:
      break
  ans = len(S[-1])
print(ans)

Submission status: Runtime Error

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


list = {}

hlcm = 0


cnt = 0

num = a[0]

while num % 2 == 0:
    num //= 2
    cnt += 1

prev_cnt = cnt
hlcm = num

for i in range(1,N):
    num = a[i]
    cnt = 0

    while 1:
        if num % 2 == 0:
           num //= 2
           cnt +=1

        else:
            if cnt != prev_cnt:
               print(0)
               exit()
            else:
               prev_cnt = cnt
               hclm = hlcm * num
               break


# print(hclm)
print(int((M-hclm)/(hclm*2))+1)

Submission status: Runtime Error

Solution code:
import fractions
n,m = map(int,input().split())
l = input().split()
lcm = 1
sum = 0
for i in range(len(l)):
    lcm = (int(l[i]) * lcm) // fractions.gcd(int(l[i]), lcm)
for i in range(len(l)):
    if (lcm // int(l[i])) % 2 == 1:
        sum += 1
if sum == len(l):
    x = m // (int(lcm) / 2)
    y = m // lcm
    print(int(x - y))
else:
    print(0)

Submission status: Runtime Error

Solution code:
ort fractions
n,m = map(int,input().split())
l = input().split()
lcm = 1
sum = 0
for i in range(len(l)):
    lcm = (int(l[i]) * lcm) // fractions.gcd(int(l[i]), lcm)
for i in range(len(l)):
    if (lcm // int(l[i])) % 2 == 1:
        sum += 1
if sum == len(l):
    x = m // (int(lcm) / 2)
    y = m // lcm
    print(int(x - y))
else:
    print(0)