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: Wrong Answer

Solution code:
import functools
n,m = map(int,input().split())
L = list(map(int,input().split()))
L = [x//2 for x in L]
def ll(a,b):
    while b:
        a,b = b,a%b
    return a
def lcm(a,b):
    return a*b//ll(a,b)
def lc(a):
    return functools.reduce(lcm,L)
d = lc(L)

if m//d%2 ==1:
    em = m//d//2+1
elif m//d%2 == 0:
    em = m//d//2
if n//d%2 ==1:
    en = n//d//2+1
elif n//d%2 == 0:
    en = n//d//2
print((em-en))

Submission status: Wrong Answer

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

# Sort
AN.sort()
setAN = list(set(AN))

# 最も大きい値の最小の半公倍数を考える
if setAN[0] >= M:
    print("0")
    exit

def checkAllElement(X, setList):
    for element in setList:
        p = X / element - 0.5
        if not p.is_integer():
            return False
    return True

firstPCount = -1
secondPCount = 0
tmpPCount = 0
while secondPCount == 0:
    X = setAN[0] * (tmpPCount + 0.5)
    if X > M:
        break

    # 全ての要素に対して成り立つか確認する
    if checkAllElement(X, setAN[1:]):
        if firstPCount >= 0:
            secondPCount = tmpPCount
        else:
            firstPCount = tmpPCount
    tmpPCount += 1

if secondPCount > 0:
    firstX = setAN[0] * (firstPCount + 0.5)
    secondX = setAN[0] * (secondPCount + 0.5)
    print(int((M + firstX) // (secondX - firstX)))
elif firstPCount >= 0:
    print(1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:

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

from fractions import gcd
from functools import reduce
import math

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

l = reduce(lcm, A)

if l > (M):
  print(0)
else:
  print(math.ceil(M/l))

Submission status: Wrong Answer

Solution code:
def gcd(m,n):
	if(n==0):
		return m
	return gcd(n,m%n)

ans=0
n,m=map(int,input().split())
a=list(map(int,input().split()))
lcm=a[0]//2
flag=0
f=1
if(lcm&1):
	flag=1
for i in range(n):
	if(flag^((a[i]//2)&1)):
		f=0
		break
	lcm=((a[i]//2)*lcm)//(gcd(a[i]//2,lcm))
	if(lcm>m):
		f=0
		break
if(f):
	if(lcm&1):
		ans=(m//(2*lcm))+1
	else:
		ans=m//lcm
print(ans)

Submission status: Wrong Answer

Solution code:
import sys

N, M = map(int, input().split())
A = list(set([i for i in map(int, sys.stdin.readline().split())]))

if len(A) > 1:
  a, b = A[0], A[1]
  prod = a * b
  while b > 0:
    a, b = b, a%b
  
  if len(A) > 2:
    for b in A[2:]:
      prod *= b
      while b > 0:
        a, b = b, a%b
  
  CM = prod // a
  SCM = CM // 2

  if CM % 4 == 0:
    print(0)
    sys.exit()
  
else:
  CM = A[0]
  SCM = CM // 2

if SCM > M:
  print(0)
else:
  print(1 + (M - SCM) // CM)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce


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


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


n,m=map(int,input().split())
A=list(map(int,input().split()))
ans=lcm_list(A)
m -=ans//2
print(m//ans+1)

Submission status: Wrong Answer

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

a = set(sorted(a, reverse=True))

import functools

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

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

def lcm(nums):
        return functools.reduce(multiple, nums)

_c = [x//2 for x in a]
_lcm = lcm(_c)

if _lcm > m:
    print(0)
else:
    print(m//(_lcm*2) - _c[0]*2//(_lcm*2)+1)

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int,input().split())
A = list(map(int,input().split()))
cnt = M
for i in range(N):
  if A[i]%2 == 0:
    A[i] = A[i]//2
  else:
    cnt = 0
gcd = A[0]
for i in range(1, N):
  gcd = gcd*A[i]//fractions.gcd(gcd, A[i])
print(min(cnt, 1+(M-gcd)//(2*gcd)))
print(1 + (999999988)//24)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

def lcm(a):
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

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

l = lcm(ai) // 2
i = m // l
if i == 0:
    print(0)
    exit()
if i == 1:
    print(1)
    exit()
ans = int(bin(i)[:-1], 2) + 1

print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import sys
input = sys.stdin.readline


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

    v = A[0]
    for i in range(1, N):
        a, b = v, A[i]
        v = a * b // gcd(a, b)
    print((M // v + 1) // 2)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

def get_ints():
    return list(map(int, input().split()))

[n, m] = get_ints()
a = get_ints()

def small_lcm(x, y):
    if x is None or y is None:
        return None
    ans = x * y // gcd(x, y)
    return ans if ans <= m else None

l = reduce(small_lcm, map(lambda x: x // 2, a))
if l is None:
    print(0)
    exit(0)
t = m // l
print(t // 2 if t % 2 == 0 else t // 2 + 1)

Submission status: Wrong Answer

Solution code:
import math
def main():

    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    A = sorted([a // 2 for a in A])
    if max(A) > M: return 0
    if any(a % 2 == 0 for a in A):
        return 0

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

    prev = 1
    for i in range(len(A)):
        c = gcd(prev, A[i])
        prev = (prev // c) * A[i]

    return (M // prev  + 1) // 2

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

Submission status: Wrong Answer

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

cnt=0
dist = 1
width = 2
fstCmm = 0
while dist <= M:
    flag = 1
    for a in A:
        if (dist / a) - int(dist / a) != 0.5:
            flag  = 0
            break
    if flag == 1:
        fstCmm = dist
        break
    dist += width

print((M-dist)//(dist*2) +1)

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    if b == 0: 
        return a
    return gcd(b, a % b)
def lcm(a,n,m):
    ans = a[0]
    for i in range(1,n):
        ans = (ans * a[i])/(gcd(a[i],ans))
        if ans > 10**20:
            return -1
    return ans
n,m = map(int,input().split())
a = list( map(int,input().split()) )
l = lcm(a,n,m)


start = l//2
# print(start)
ans = (m - (start))//l
# print(ans)
if ans < 0 or l==-1:
    print(0)
else:
    ans += 1
    print( round(ans) )

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
a = list(set(map(int, input().split())))

ans = []
#M = 104
if np.prod(np.array(a)) / (2 ** len(a)) > M:
  pass
else:
  for i in range(1, M + 1, 2):
    if all(list(map(lambda x: i / x - int(i / x) == 0.5, a))):
      ans.append(i)
      #print(i)
      if len(ans) == 2:
        break
#print(ans)
if len(ans) == 2:
  print((M -ans[0])// (ans[1] -ans[0])+ 1)
else:
  print(len(ans))

Submission status: Wrong Answer

Solution code:
def gcd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
A = list(set(list(map(int,input().split()))))
B = []
for i in range(len(A)):
    B.append((A[i]//2)%2)
B = list(set(B))
if len(B)==2:
    print(0)
else:
    a = A[0]
    for i in range(1,len(A)):
        a = gcd(a,A[i])
    b = a
    for x in A:
        b *= x//a
    flag = 1
    for a in A:
        if (b//2-a//2)%a!=0:
            flag = 0
            break
    if flag==1:
        k = (M-b//2)//b
        print(k+1)
    else:
        print(0)

Submission status: Wrong Answer

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

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

b = max(a)
c = int(m/b)

cs = []
if (b * c) + (b/2) < m:
    for i in range(c + 1):
        cs.append(b * (i + 0.5))
else:
    for i in range(c):
        cs.append(b * (i + 0.5))

d = 0
for x in cs:
    cont = True
    for i in range(n):
        if x/a[i] - int(x/a[i]) == 0.5:
            continue
        else:
            cont = False
            break
    if cont:
        d += 1



print(d)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**5)

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

# 最大公約数
def gcd(a, b) :
    if b > a : 
        a, b = b, a
    
    while b != 0 :
        a, b = b, a % b
    return a
    
# 最小公倍数
def lcm(a, b) :
    return a * b // gcd(a, b)
  
f = a[0]
if N >= 2 :
  for i in range(1, N) :
    f = lcm(f, a[i])
    
print(int(M / f + 0.5))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
import sys
input = sys.stdin.readline


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


if n == 1:
    if A[0] % 2 == 1:
        print(0)
        exit()

    b = m / A[0] - (0.5)
    # print(b)
    print(int(b//1))
    exit()
    




baisu = A[0]
if A[0] % 2 == 1 or A[0] == 0:
    print(0)
    exit()




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



# for a in A:
    # baisu = lcm(baisu, a)
# print(baisu)


b = baisu // 2
c = m // b + 1
d = c // 2
print(d)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M=map(int,input().split())
a=list(map(int,input().split()))
common=lcm_list(a)//2
if common>M:
    print(0)
elif M%(common*2)!=0:
    print((M//common)//2+1)
elif M%(common*2)==0:
    print((M//common)//2)

Submission status: Wrong Answer

Solution code:
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=map(int,input().split())
a_list=list(map(int,input().split()))

kobai=lcm_list(list(map(lambda x:int(x/2),a_list)))


a=M//kobai

if a%2==1:
    print(a//2+1)
else:
    print(a//2)

Submission status: Wrong Answer

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


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

    lcm = lcm_list(numbers)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
N, M = map(int, input().split())
a_list = list(map(int, input().split()))

# lcm & gcd not math
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

from functools import reduce
def lcm_multi(num_list):
    return reduce(lcm, num_list, 1)

lcm_num =  lcm_multi(a_list)

print((M - lcm_num // 2) // lcm_num + 1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
import math
def gcd(a,b):
    if b < a: a,b = b,a 
    while a != 0:
        a,b = b%a,a
    return b

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

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n,m = map(int,input().split())
a = list(map(int,input().split()))
my_lcm = 1
bit_even = 0
for i in range(n):
    if a[i]%2:
        bit_even = 1
        break
    my_lcm = lcm(my_lcm,a[i]//2)
#print(my_lcm)
ans = m // my_lcm - (m // my_lcm)//2
if bit_even:
    print(0)
else: print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
#from math import gcd
def lcm(a,b):
    return a*b//gcd(a,b)
def main():
    n,m=map(int,input().split())
    A=list(set(list(map(int,input().split()))))
    if len(A)>2:
        print(0)
        exit()
    elif len(A)<2:
        l = A[0]
    else:
        l = lcm(A[0],A[1])
    for i in range(1,m+1):
        for a in A:
            if i != a*(i//a+.5):
                print((m-i)//l+1)
                exit()
main()

Submission status: Wrong Answer

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

def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

number = lcm(A)
maxNumber = max(A)
a = [x // 2 for x in A]
number2 = lcm(a)

if number2 // maxNumber < 3:
    minNumber = number2 // maxNumber * 3

else:
    minNumber = number2

if M >= minNumber:
    ans = (M - minNumber) // number
else:
    ans = -1
print(ans + 1)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        N, M = map(int, input().split())
        a = list(map(int, input().split()))

        d = a[0]
        for i in range(1, N):
            d = self.lcm(d, a[i])

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

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

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


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Wrong Answer

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

b=[(i//2)%2 for i in a]
if 0 in b:
    print(0)
    exit()
    
low=1
for i in set(a):
    low*=i//2
    
print(m//low//2+1)

Submission status: Wrong Answer

Solution code:
words = lambda t : list(map(t, input().split()))
n,m = words(int)
xs = words(int)

def gcd(x,y):
    while not y == 0:
        tmp = y
        y = x%y
        x = tmp
    return x

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

lcms = 1
plus = 1
odd = (xs[0]//2) % 2 == 1
ans = True
for x in xs:
    if odd and (x//2)%2 == 0 or (not odd and (x//2)%2 == 1):
        ans = False
        break
    lcms = lcm(lcms,x)
    plus = lcm(plus, x//2)

#print(lcms,plus)
if ans:
    print((m + plus) // (lcms))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
A=list(map(int,input().split()))
def lcm(a):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

ans = lcm(A)//2

if ans > m:
    print(0)
else:
    print((m-ans)//(ans*2)+1)

Submission status: Wrong Answer

Solution code:
import fractions
import functools

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

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


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

aset = set(alist)
xalist = [int(x * 0.5) for x in aset]
amax = max(aset)

print(xalist)

llcm = lcm(*xalist)
base_llcm = lcm_base(llcm, amax)

#print(llcm, base_llcm)
ans = (m-llcm) // base_llcm + 1
print(max(ans, 0))

Submission status: Wrong Answer

Solution code:
def gcd(m,n):
    x = max(m,n)
    y = min(m,n)

    if x%y == 0:
        return y
    else:
        while x%y!=0:
            z = x%y
            x = y
            y = z
        else:
            return z

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

[N,M] = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

# a 共通の最小公倍数を求める

skoubaisu = 1
for x in a:
    skoubaisu = lcm(skoubaisu,x)

print(M//skoubaisu+1)

Submission status: Wrong Answer

Solution code:
import fractions
import sys
readline = sys.stdin.buffer.readline
N, M = map(int, readline().split())
a = list(map(int, readline().split()))
# print(N, M, a)

MOD = 10**9 + 7

tmp = 1
for x in a:
    x //= 2
    tmp2 = x // fractions.gcd(tmp, x)
    M //= tmp2
    tmp *= tmp2
    tmp %= MOD

ans = (M + 1) // 2
print(ans)

Submission status: Wrong Answer

Solution code:
def calc(d):
  return int(d/2)

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

a = list(set(a))
a = list(map(calc, a))
#print(a)

import fractions
ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
#print(ans)

res = 0
for i in range(1, M+1, 2): 
    x = i*ans
    #print(x)
    if x>M+1:
      break
    res += 1
print(res)

Submission status: Wrong Answer

Solution code:
import sys

sys.setrecursionlimit(500000)
def input():
    return sys.stdin.readline()[:-1]

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

    def div2(n):
        count=0
        while n%2!=1:
            count+=1
            n//=2
        return count

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

    def lcd(a):
        l = a[0]
        for i in range(1,N):
            l *= (a[i]*l)//gcd(l,a[i])
        return l

    b = [div2(a[i]) for i in range(N)]

    flag = True

    for i in range(1,N):
        if b[i]!=b[0]:
            flag=False
            break

    if flag:
        for i in range(N):
            a[i]=a[i]//2
        l = lcd(a)
        
        print((M+l)//(2*l))
    else:
        print(0)



if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
seqs = set()
for a in list(map(int, input().split())):
    seqs.add((a, a//2))
seqs = list(seqs)
N = len(seqs)
def egcd(a, b):
    x,y, u,v = 0,1, 1,0
    while a != 0:
        q, r = b//a, b%a
        m, n = x-u*q, y-v*q
        b,a, x,y, u,v = a,r, u,v, m,n
    gcd = b
    return gcd, x, y

s1 = seqs[0]
for i in range(1, N):
    s2 = seqs[1]
    if (s2 == s1): continue

    a1, a2 = s1
    b1, b2 = s2

    g, x0, y0 = egcd(a1, -b1)

    # print(g, x0, y0)

    if (b2 - a2) % g != 0:
        print(0)
        quit()

    a1 *= (b2 - a2) // g
    b1 *= (b2 - a2) // g
    x0 = x0 % (b1 // g)

    s1 = [a2 + a1 * x0, a1 * b1 // g]

#print(M, s1)
print((M - s1[0]) // s1[1] + 1)

Submission status: Wrong Answer

Solution code:
import functools
N, M = map(int, input().split())
a = [int(i)//2 for i in input().split()]
def euclid(a, b):
    if b == 0:return a
    else:return euclid(b, a%b)
def multiple(a, b):
    return a*b // euclid(a, b)
def lcm(nums):
        return functools.reduce(multiple, nums)
num = int(M/lcm(a))
if num%2 == 0:
  print(num//2)
else:
  print(num-int(num/2))

Submission status: Wrong Answer

Solution code:
N, M = map(int, input().split())
As = map(lambda a: int(a) >> 1, input().split())

from fractions import gcd
from functools import reduce

l = reduce(lambda a, b: a * b // gcd(a, b), As)

i = 2
while l & (i - 1) == 0:
    i <<= 1
i = (i >> 1) - 1

fg = False

if fg:
    print(0)
else:
    print(M // l - M // (l * 2))

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int, input().split())
AA = list(map(int, input().split()))
A = list(map(lambda x:x//2, AA))

ans = A[0]
for i in range(1, N):
    ans = ans * A[i] // fractions.gcd(ans, A[i])

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

Submission status: Wrong Answer

Solution code:

def gcd(a, b):
    r = 0
    while True:
        if b > a:
            a, b = b, a
        r = a % b
        if r == 0:
            return b
        a = b
        b = r
def lcm(a, b):
    g = gcd(a, b)
    return (a // g) * b
res = 0
def func():
    global res
    N, M = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    for i in A:
        if i % 4 == 0:
            return
    n = A[0]
    for i in range(N - 1):
        n = lcm(n, A[i + 1])
    res = M // n
    if M >= n:
        res += 1
func()
print(res)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
from fractions import gcd

N,M=map(int, sys.stdin.readline().split())
A=map(int, sys.stdin.readline().split())

#奇数があれば答えはゼロ
for a in A:
    if a%2==1:
        print 0
        quit()

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

for i,a in enumerate(A):
    if i==0: x=a
    else: x=lcm(x,a)


for i,a in enumerate(A):
    a/=2
    if i==0: semi_x=a
    else: semi_x=lcm(semi_x,a)


print (M-semi_x)/x+1

Submission status: Wrong Answer

Solution code:
import fractions


N, M = map(int, input().split())
a_i = list(map(int, input().split()))
half_a_i = []

for i in a_i:
    i //= 2
    half_a_i.append(i)

lcm = half_a_i[0]

for i in range(1, N):
    lcm = lcm * half_a_i[i] // fractions.gcd(lcm, half_a_i[i])

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

Submission status: Wrong Answer

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

x = y
for i in range(n):
    x *= b[i]//y

d = m//x
print((d+1)//2)

Submission status: Wrong Answer

Solution code:
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time
from fractions import gcd
#import random
import fractions


def I(): return int(input())


def MI(): return map(int, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def good(A, N):
    # A = sorted(A)
    ans = A[0]
    # for i in range(1, N):
    #     ans = fractions.gcd(A[i], ans)
    for i in range(1, N):
        ans = ans * A[i] // fractions.gcd(ans, A[i])
    return ans


def main():
    N, M = MI()
    a = LI()
    n = good(a, N)

    # print(n, n // 2, M)
    if n // 2 > M:
        print(0)
    else:
        print((2 * M - n) // n // 2 + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]
    N,M = LMIIS()
    A = list(map(lambda x: int(x)//2 ,input().split()))
    # print(A)
    from fractions import gcd
    g = A[0]
    for i in A[1:]:
        g = gcd(g,i)
    if g != 1:
        print(0)
        return
    lcm = 1
    for i in set(A):
        lcm *= i
    lcm //= g
    #print(lcm,(M-lcm) // (lcm*2))

    print((M-lcm) // (lcm*2) +1 if M >= lcm else 0)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

from fractions import gcd
from functools import reduce
import math
import numpy as np
A=np.array(A)
def lcm_base(x, y):
  return (x * y) // gcd(x, y)

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


X=lcm(*A)
Y=Gcd(*A)
i=1
while 1:
  if Y%(i*2)==0:
    i*=2
  else:
    break
ans=M*2/X/i
if ans<1:
  ans=0
else:
  j=1
  _ans=10**9
  while X*j<2*M:
    _X=X*j
    if np.prod((_X/A)//2)%2==1:
      _ans=math.ceil((M-(_X//2))/Y)
      break
    j+=1
  if _ans<math.ceil(ans):
    ans=(M-(_X//2))/Y
print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
import fractions
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))
n=len(a)
a.sort()
#print(a)
ans=0
c=1
for i in range(n):
    if a[i]%4==0:
        print(ans)
        break
    elif a[i]%2==0:
        a[i]=a[i]//2
else:
    for i in range(n):
        c*=a[i]
    z=m//c
    print((z+1)//2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions

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

div_count = 0
while True:
    all_odd = True
    for i in range(len(a)):
        a[i]//=2
        if a[i]%2==0:
            all_odd = False
        if a[i]==0:
            print(0)
            sys.exit()
    if all_odd is True:
        break
    else:
        div_count+=1

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

if div_count>0:
    m//=2*div_count
print(m//_min-(m//_min)//2)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)

import math
import fractions
from functools import reduce

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


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


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


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


def resolve():
    N, M = [int(x) for x in sys.stdin.readline().split()]
    a_list = [int(x) for x in sys.stdin.readline().split()]

    if any([(a // 2) % 2 == 0 for a in a_list]):
        print(0)
        return
    else:
        L = lcm_list(a_list)
        print(M // L + 1)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)

Submission status: Wrong Answer

Solution code:
import sys

N, M = map(int, input().split())
A = list(set([i for i in map(int, sys.stdin.readline().split())]))

if len(A) > 1:
  a, b = A[0], A[1]
  prod = a * b
  while b > 0:
    a, b = b, a%b
  
  if len(A) > 3:
    for b in A[2:]:
      prod *= b
      while b > 0:
        a, b = b, a%b
  
  CM = prod // a
  SCM = CM // 2

  if CM % 4 == 0:
    print(0)
    sys.exit()
  
else:
  CM = A[0]
  SCM = CM // 2

if SCM > M:
  print(0)
else:
  print(1 + (M - SCM) // CM)

Submission status: Wrong Answer

Solution code:
def lcm(a,m):
    from fractions import gcd
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
        if x > m:
            return m+1
    return x

n,m = map(int, input().split())
a = list(map(int, input().split()))
b = [i//2 for i in a]
lcm = lcm(b,m)
i=1
count=0
if m >= lcm:
    m-=lcm
    count = m//(lcm*2) + 1
print(count)

Submission status: Wrong Answer

Solution code:
import fractions
n, m = map(int, input().split())
a = list(set(list(map(int, input().split()))))
ans = a[0] / 2
for i in range(1, len(a)):
    ans = ans * a[i]/2 // fractions.gcd(ans, a[i]/2)
print(int(m//ans - (m//(ans*2))))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce


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


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

c = reduce(lambda x, y: lcm(x, y), aa)

d = m // c

if d % 2 == 1:
    print(d // 2 + 1)
else:
    print(d // 2)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
N, M = map(int, input().split())
A = list(map(int, input().split()))
AA = list(map(lambda x: x//2, A))
def lcm_(x, y):
    return x * y // gcd(x, y)
if any(map(lambda x:not x&1, AA)):
    if all(map(lambda x:x==AA[0], AA[1:])):
        print(M//AA[0] - M//(2*AA[0]))
    else:
        print(0)
else:
    a = reduce(lcm_, AA)
    print(M//a - M//(2*a))

Submission status: Wrong Answer

Solution code:
import fractions

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

ans = a2[0]
for i in range(1, len(a2)):
    ans = ans * a2[i] // fractions.gcd(ans, a2[i])

result = 0
i = 1

q, mod = divmod(m, ans)
q2, mod2 = divmod(q, 2)

if mod2 == 0:
  print(int(q2))

else:
  print(int(q2 + 1))

Submission status: Wrong Answer

Solution code:
import fractions as f
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=a[0]
ma=max(a)
mi=min(a)
for i in range(n):
    c=(c*a[i])//(f.gcd(c,a[i]))
if c in a:
    print((m+(ma//2))//c)
else:
    print((m-c//2+ma//2)//(c//2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce

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

def egcd(a, b):
    if a == 0:
        return b, 0, 1
    else:
        g, y, x = egcd(b % a, a)
        return g, x - (b // a) * y, y


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

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


axs = list()
abs = [[0,0] for i in range(n)]
for i in range(n):
    a = As[i]
    axs.append(a)
    b = As[i] // 2
    abs[i] = [a,b]
    # print(abs[i])

    
lcm = lcm_list(axs)
if m//lcm == 0:
    print(0)
else:
    print(m // lcm+1)

# たぶん嘘開放

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from fractions import gcd

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

def lcm(a):   
    x = a[0]
    for i in range(1, len(a)):
        x = (x * a[i]) // gcd(x, a[i])
    return x

N, M = rl()
a = list(set(rl()))
a.sort()
A = np.array(a)
B = A // 2


b = list(B)
ans = lcm(b)
if ans > M:
    answer = 0
else:
    answer = 1 + (M-ans)//(2*ans)

print(answer)

Submission status: Wrong Answer

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

def half(a, b):
    return a*(b+0.5)
#最大公約数
def gcb(a,b):
    while b!=0:
        a,b=b,a%b
    return a
#最小公倍数
def lcm(a,b):
    return a * b // gcb(a, b)

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

ans = 0
sub = sub // 2
ra = m // sub
ans = ra // 2

if ans != 0:
    print(ans + 1)
else:
    print(ans)