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:
#D
import math
N,M = map(int,input().split())
A = list(map(int,input().split()))


def GCD(x,y):
    x,y = max(x,y),min(x,y)
    if y == 0:
        return x
    else:
        return GCD(y,x%y)
    
g = A[0]
for i in range(N-1):
    g = GCD(A[i+1],g)
    
bai = g
for i in range(N):
    if GCD(bai,A[i]) == A[i]:
        pass
    else:
        bai*=A[i]//g
    

han = bai
while han%2 == 0:
    han//=2
    
#print(han)
ans = math.ceil((M//han)/2)
print(ans)

Submission status: Wrong Answer

Solution code:
import itertools
import fractions
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
tmp=lcm_list(A)
print((M-tmp//2)//tmp+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def lcm(nums):
  x = nums[0]
  for i in range(1, len(nums)):
    x = (x * nums[i]) // gcd(x, nums[i])
  return x
N, M = map(int, input().split())
a = list(map(int,input().split()))
flag = 0
for i in range(len(a)):
  a[i] = a[i] / 2
  if a[i] % 2 == 0:
    flag = 1
if flag == 1:
  print(0)
else:
  A = lcm(a)
  print(int((M // A + 1) // 2))

Submission status: Wrong Answer

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

import fractions

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

f = x//2

if f > m:
    print(0)
else:
    print((m-f)//x + 1)

Submission status: Wrong Answer

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


A=a[0]

def lcm(X,Y):
    x=X
    y=Y
    if y>x:
        x,y=y,x
    while x%y!=0:
        x,y=y,x%y
    return X*Y//y
    
for i in range(1,N):
    A=lcm(A,a[i])
M-=A//2
if A%4==0:
    print(0)
else:
    print(M//A+1)

Submission status: Wrong Answer

Solution code:
import fractions
import sys
n,m=map(int,input().split())
A=list(map(int,input().split()))
B=[]
for i in range(n):
  B.append(A[i]//2)
b=1
for i in range(n):
  b=b*B[i]//fractions.gcd(b,B[i])
  if b>m:
    print(0)
    sys.exit()
if b>m:
  print(0)
else:
  print(1+(m-b)//(2*b))

Submission status: Wrong Answer

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

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

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

x = A[0]
for i in range(1, N):
  x = lcm(x, A[i])
#print(x)

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

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
import sys

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

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

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

x = lcm_list(A)
if x>M:
    print(0)
    sys.exit()
print(((M//x)//2)+1)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


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


def LCM(a, b):
    return a*b//GCD(a, b)


def solve(N: int, M: int, a: "List[int]"):
    lcm = a[0]
    for i in range(N):
        lcm = LCM(a[i], lcm)

    # 1 <= lcm <= 2M
    print(int(((2*M/lcm)-1)//2) + 1)

    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, a)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from functools import reduce
def gcd(a,b):
	if not b:
		return a
	return gcd(b,a%b)

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

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

LCM=reduce(lcm,arr)

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,copy,time
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())


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

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

N,M = inpl()
aa = inpl()
tmp = aa[0]//2
for a in aa[1:]:
    tmp = lcm(a//2,tmp)


print(M//tmp - M//(tmp*2))

Submission status: Wrong Answer

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

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 solve(N, M, A):
    num = lcm(*A)
    if num > M:
        return 0
    else:
        return ceil(M / (num*2))
    

def main():
    N, M = map(int, input().split())
    A = list(set(int(x)//2 for x in input().split()))
    ans = solve(N, M, A)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

for i in range(n):
    l[i] //= 2
    if l[i] % 2 == 0:
        print(0)
        exit()

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

count = 0

ans1 = m//ans
if ans1 % 2 == 0:
    print(ans1//2)
else:
    print(ans1//2+1)

Submission status: Wrong Answer

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])

s = ans//2

if M < ans: print(0)
else: print(M//ans+1)

Submission status: Wrong Answer

Solution code:
import sys
from math import ceil
n, m = [int(i) for i in sys.stdin.readline().split()]
s_ls = [int(i) for i in sys.stdin.readline().split()]
a_ls = [i // 2 for i in s_ls]
if len(set(a_ls).intersection(set(s_ls))) > 0:
    print(0)
else:
    def gcd(a, b):
        while a and b:
            if a < b:
                b %= a
            else:
                a %= b
        return max(a, b)

    def scm(a, b):
        _gcd = gcd(a, b)
        return a * b // _gcd

    flg = True
    res = a_ls[0]
    for a in a_ls[1:]:
        res = scm(res, a)
        if res > m:
            flg = False
            break

    if flg:
        print((m - res) // (res * 2) + 1)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

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

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)

a_lcm = lcm_list(a)
ls = []
for i in range(n):
    ls.append(a[i]//2)



ls_lcm = lcm_list(ls)

#print(ls_lcm)
if a_lcm > m:
    print(0)
else:
    if m % a_lcm < (ls_lcm):
        c = m // a_lcm
    else:
        c = m // a_lcm+1
    print(c)

Submission status: Wrong Answer

Solution code:
def lcm(x, y):
    if x > y:
        greater = x
    else:
        greater = y
    while(True):
        if((greater % x == 0) and (greater % y == 0)):
            lcm = greater
            break
        greater += 1
    return lcm


N = input().split()
for a in range(len(N)):
    N[a] = int(N[a])

A = input().split()
for b in range(len(A)):
    A[b] = int(A[b])

mult = 1
for a in range(len(A)):
    mult = lcm(mult, A[a]//2)
    mult = int(mult)

space = N[1] // mult
print((space + 1) // 2)

Submission status: Wrong Answer

Solution code:
def GCD(x,y):
    if y==0:
        return x
    return GCD(y,x%y)
N, M = map(int,input().split())
A = list(map(int,input().split()))
ans = 1
for i in A:
    ans = (ans*(i//2))//GCD(ans,i)
    if ans%i == 0:
        print(0)
        exit()
print(M//ans-M//(ans*2))

Submission status: Wrong Answer

Solution code:
import sys
readline = sys.stdin.buffer.readline
from fractions import gcd
from functools import reduce

n,m = map(int,readline().split())
alst = list(map(int,readline().split()))

if n == 1:
  g = alst[0]
  if g * 3 > 2 * m:
    print(0)
  else:
    print((m-g//2)//g)
  quit()
else:
  mm = 2 * m
  f = lambda x,y:x*y//gcd(x,y)
  g = reduce(f, alst)
if g > mm:
  print(0)
else:
  c = mm // g
  c = c//2+c%2
  print(c)

Submission status: Wrong Answer

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

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

a = sorted(list(set(a)))

owa = 0
saiko = a[0]//2
che = (a[0]//2)%2
if che == 0:
    owa = 1

for i in range(1,len(a)):
    if (a[i]//2)%2 == 0:
        owa = 1
        break
    t1 = a[i]//2
    koe = gcd(saiko,t1)
    saiko = (saiko*t1)//koe

if owa == 1:
    print(0)
else:
    if (M//saiko)%2 == 0:
        print((M//saiko)//2 )
    else:
        print(((M//saiko)+1)//2)

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])


for i in range(N) :
  if a[i] % 4 == 0 :
    print(0)
    break
else :
  print(int(M / f + 0.5))

Submission status: Wrong Answer

Solution code:
import math
def gcd(m, n):  # 最大公約数を求める
    while n:
        m, n = n, m % n
    return m


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

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

# ans = 0
# candidates = []
# saisyo = lcm
# while 2*M >= lcm:
#     candidates.append(lcm)
#     lcm += saisyo
#
# for c in candidates:
#     if c//2 % 2 == 1:
#         ans += 1
# print(ans)
if 1 > M/lcm:
    print(0)
else:
    print(math.ceil(M/lcm))

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)

n,m = map(int, input().split())
a = list(map(int, input().split()))
lcm_a = a[0]
for i in a[1:]:
  lcm_a = lcm_a * i // fractions.gcd(lcm_a,i)
  if lcm_a * 2 > m:
    print(0)
    exit()
ans = (m - lcm_a // 2) // lcm_a + 1
print(ans)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
#from math import gcd
N,M = map(int,input().split())
A = list(map(int,input().split()))
lcm = A[0]
ki = 0; gu = 0
for i in range(1,N):
    if (A[i]//2)%2 == 1:
        ki = 1
    else:
        gu = 1
    if ki*gu == 1:
        print(0)
        exit()
    lcm = lcm*A[i] // gcd(lcm,A[i])
    if lcm > 2*M:
        print(0)
        exit()

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

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
half_a = [i//2 for i in a]
from fractions import gcd
def lcm(x,y):
  return (x*y) // gcd(x,y)
q = 1
for i in range(n):
    q = lcm(q,a[i])
start = q//2
if start > m:
    print(0)
    exit()
print((m-start)//q+1)

Submission status: Wrong Answer

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

a = list(set(a))

candidate = 1
for i in a:
    candidate = candidate * i
if candidate > M:
    print(0)
    exit()
tmp = int(M // 2 // candidate + 1)
print(tmp)

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]//=2
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // gcd(ans, a[i])
    if ans>m:
        print(0)
        exit()
if (m//ans)%2==0:
    print(m//ans//2)
else:
    print(m//ans//2+1)

Submission status: Wrong Answer

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

N, M = [int(i) for i in input().split()]
A = [int(i)//2 for i in input().split()]
x = lcm(*A)
print(math.ceil((M//x)/2))

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

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

def gcd(a, b):
    # 大きい方を被除数、小さい方を除数とする
    dividend = max(a, b)
    divider = min(a, b)

    if divider == 0:
        return dividend

    # 最大公約数を見つけるまで繰り返す
    while dividend % divider != 0:
        # 除算を行い、その除数を次回の被除数、剰余を次回の除数として処理を繰り返す
        r = dividend % divider
        dividend = divider
        divider = r

    # 一方がもう一方を割り切れた時点で、その除数を最大公約数とみなせる
    return divider


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

# print(x, y)

temp = reduce(lcm, y, 1)
# print(temp)
# ans = (m // temp) // 2
ans = (m // temp) / 2

# print(ans)
ans = math.ceil(ans)
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline


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


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    d = A[0]
    for a in A:
        d = lcm(d, a)
    ans = (2*M)//d/2
    ans = -(-ans//1)
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:

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


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

lcm = a[0]
len = len(a)

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

lcm//=2

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

Submission status: Wrong Answer

Solution code:
import fractions

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

lcm = 1
for i in arr:
    j = i//2
    lcm = lcm * j // fractions.gcd(lcm, j)

print(round(m/lcm/2))

Submission status: Wrong Answer

Solution code:
import fractions
N, M = map(int, input().split())
A = [ int(x) for x in input().split() ]

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

#print( M // (ans // 2 ) )
b = M // (ans // 2 )
if b % 2 == 0:
  print( b//2 )
else:
  print( (b+1)//2 )

Submission status: Wrong Answer

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

A=list(map(int,input().split()))
B=list(map(lambda x: x//2, A))

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//(fractions.gcd(A[i],A[i+1]))
    B[i+1]=B[i]*B[i+1]//(fractions.gcd(B[i],B[i+1]))



print(-((-(M-B[-1]))//A[-1]))

Submission status: Wrong Answer

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

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

all_lcm = lcm(1, x[0])
for xi in x:
    all_lcm = lcm(all_lcm, xi)

print( round(m / all_lcm / 2))

Submission status: Wrong Answer

Solution code:
def gcd(a,b):
  r=a%b
  while(r>0):
    a=b
    b=r
    r=a%b
  return b

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

n,m = map(int,input().split())
li = list(map(int,input().split()))
fl = False
fl2 = False
now = 1
for i in li:
  now = lcm(now,i)
  if i%4 == 0:
    fl=True
  else:
    fl2=True
  
  
if fl == True and fl2 == True:
  print(0)
else:
  hoge = now//2
  if(hoge > m):
    print(0)
  else:
    print(1+(m-hoge)//now)

Submission status: Wrong Answer

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


def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = 1
    for a in A:
        if a & 1:
            print(0)
            exit()
        else:
            ans = (ans * a // 2) // fractions.gcd(ans, a // 2)

    if ans > (M // 2):
        print(0)
        exit()
    print(-((-M // ans) // 2))


    
    
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

N, M = map(int, input().split())
a = [int(c) for c in input().split()]
b = [c//2 for c in a]
g = reduce(lcm_base, b, 1)
G = reduce(lcm_base, a, 1)
if M<g:
  print(0)
elif g==G:
  print(0)
else:
  n = (M-g)//G
  print(n+1)

Submission status: Wrong Answer

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

import functools
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)

if lcm(B) > M:
    print(0)
else:
    print((M-lcm(B))//2//lcm(B)+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

# bの最小公倍数を求める
L = b[0]
for i in range(1, N):
    L = L * b[i] // gcd(L, b[i])

# 1, 2, ..., M の中で lcm * 奇数 の形で表せるものの個数が答え
if (M // L) % 2 == 0:
    m = M // L - 1
else:
    m = M // L
print(m // 2 + 1)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-

import sys
from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(li): return reduce(lcm, li, 1)

N, M = MAP()
A = LIST()

l = lcm_list(A)

for a in A:
    if l // a % 2 != 1:
        print(0)
        exit()
ans = ceil(M, l)
print(ans)

Submission status: Wrong Answer

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

# GCD -- START --
def gcd(x,y):
  while y:
    x,y=y,x%y
  return x
# GCD --- END ---
 
def scm(a, b):
  _gcd = gcd(a, b)
  return a * b // _gcd

def main():
  n,m=LI()
  l=LI()

  k=l[0]//2
  for x in l[1:]:
    k=scm(k,x//2)
  # print(k)

  _a=m//k
  if _a%2==0:
    return _a//2
  return -(-_a//2)

# main()
print(main())

Submission status: Wrong Answer

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

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 solve(N, M, A):
    num = lcm(*A)
    if num % 2 == 0:
        return 0
    else:
        return ceil(M / (num*2))
    

def main():
    N, M = map(int, input().split())
    A = list(set(int(x)//2 for x in input().split()))
    ans = solve(N, M, A)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import fractions
import itertools
import fractions
import heapq
import collections
import bisect
import sys
import functools

sys.setrecursionlimit(10**9)
mod = 998244353
inf = 10**20

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()

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

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

n,m = LI()
a = LI()


lcm = lcm_list(a)
if lcm//2==1:
    print(0)
    exit()
print((m//(lcm//2))-(m//lcm))

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

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

H=[a//2 for a in A]
lcm_H=H[0] if N==1 else lcm(H[0],H[1])
for i in range(2,N):
    lcm_H=lcm(lcm_H,H[i])

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

Submission status: Wrong Answer

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


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


def resolve():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = [x // 2 for x in a]
    s = b.pop()
    for i in b:
        s = lcm(s, i)
    print(m // s - m // (2 * s))


if __name__ == '__main__':
    resolve()

Submission status: Wrong Answer

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

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

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

L = ar[0] // 2
for i in range(1, n):
    L = LCM(L, int(ar[i] // 2))

x = (m + L - 1) / L
print(int(x // 2))

Submission status: Wrong Answer

Solution code:
import functools
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(a, b):
    return a * b // gcd (a, b)
N,M=map(int,input().split())
A=list(map(int,input().split()))
LCM=functools.reduce(lcm,A)
HLCM=LCM//2
Y=M//HLCM
if Y%2==0:
    print(Y//2)
else:
    print((Y+1)//2)

Submission status: Wrong Answer

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


N, M = map(int,input().split())
A = list(map(int,input().split()))
ans = 1
for i in A:
    ans = (ans*(i//2))//GCD(ans,i)
    if ans%2 == 0:
        print(0)
        exit()
print(M//ans-M//(ans*2))

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd

read = sys.stdin.read
N, M, *a = map(int, read().split())

lcm = a[0]
for i in a:
    g = gcd(lcm, i)
    lcm = lcm * i // g

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

Submission status: Wrong Answer

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


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


N, M = map(int, input().split())
a = list(map(int, input().split()))
l = reduce(lcm, a)
ans = ceil((2*M // l) / 2)
print(ans)

Submission status: Wrong Answer

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

lcm = functools.reduce(lambda x, y: x // gcd(x, y) * y, A)
if lcm // 2 > M:
    print(0)
else:
    print((M - lcm // 2) // lcm + 1)

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

from fractions import gcd
from functools import reduce

N,M,*A = map(int,read().split())

# 「奇数倍」に帰着
A = [x >> 1 for x in A]

def merge(a,b):
    g = gcd(a,b)
    a //= g; b //= g
    if a % 2 == 0:
        return 0
    if b % 2 == 0:
        return 0
    n = a * b
    if n > 10 ** 9:
        return 0
    return n

x = reduce(merge, A)
if x == 0:
    answer = 0
else:
    answer = (M//x) - (M//(x+x))

print(answer)

Submission status: Wrong Answer

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
cnt = 0
while True:
  if a[0] % 2 == 0:
    a[0] //= 2
    cnt += 1
  else:
    break
div = 2 ** cnt
for i in range(1,n):
  if a[i] % div == 0:
    a[i] //= div
    if a[i] % 2 == 0:
      print(0)
      break
  else:
    print(0)
    break
else:
  #print(m)
  #print(a)
  lcm = a[0]
  for i in range(1,n):
    big,sml = a[i],lcm
    while sml != 0:
      big,sml = sml,big%sml
    gcd = big
    lcm *= a[i] // gcd
  #print(lcm)
  dbl = 2 * lcm
  ans = m // dbl
  m -= dbl * ans
  #print(dbl,ans,m)
  if m >= lcm:
    ans += 1
  print(ans)

Submission status: Wrong Answer

Solution code:
def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor:GCD)を求める
    計算量: O(log(min(a, b)))
    """
    if b == 0:
        return a
    return gcd(b, a%b)


def lcm(a, b):
    """a, bの最小公倍数(least common multiple:LCM)を求める
    計算量: O(log(min(a, b)))"""
    return (a * b) // gcd(a, b)


def multi_gcd(array: list) -> int:
    """arrayのGCDを求める
    計算量: O(Nlog)
    """
    n = len(array)
    ans = array[0]
    for i in range(1, n):
        ans = gcd(ans, array[i]) 
    return ans

             
def multi_lcm(array):
    """arrayのLCMを求める"""
    ans = array[0] 
    for i in range(1, len(array)):
        ans = (ans * array[i]) // gcd(ans, array[i])
    return ans 


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

div = multi_lcm(a)
ans = 0
if m - div // 2 >= 0:
    ans += 1
m = m - div // 2 
ans += m // div
if m < 0:
    print(0)
else:
    print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
N,M = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
for i in range(N) :
    A[i] = A[i] // 2
import fractions
from fractions import gcd
def lcm(x,y) :
    return(x*y) // fractions.gcd(x,y)
k = A[0]
for i in range(1,N) :
    k = lcm(k,A[i])
j = 1
count = 0
while True :
    g = k * j
    if g > M :
        break
    else :
        j+=2
        count+=1
print(count)

Submission status: Wrong Answer

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


def main():
    N, M = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]
    ans = A[0] // 2
    for a in A:
        if a & 1:
            print(0)
            exit()
        else:
            ans = (ans * a // 2) // fractions.gcd(ans, a // 2)

    if ans > M // 2:
        print(0)
        exit()
    print(-((-M // ans) // 2))


    
    
    


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

def main():
    N, M = map(int, input().split())
    A = list(set(map(int, input().split())))
    if len(A) == 1:
        l = A[0]
    else:
        l = lcm(A[0], A[1])
        for i in A[2:]:
            l = lcm(l, i)
    print((M + l // 2) // l)

main()

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
def gcd(a,b):
  while b:a,b=b,a%b
  return a
def lcm(a,b):return a*b//gcd(a,b)
l=a[0]//2
ll=a[0]
odd=even=False
for i in range(1,n):
  if a[i]%2:odd=True
  else:even=True
  l=lcm(l,a[i]//2)
  ll=lcm(ll,a[i])
  if l>m:print(0);exit()
if odd and even:print(0);exit()
print((m-l)//ll+1)

Submission status: Wrong Answer

Solution code:
import fractions
import math
 
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
 
n, m = list(map(int, input().split()))
a = list(map(lambda x: int(x) // 2, input().split()))
lcm_all = a[0]
for i in range(1, len(a), 1):
    lcm_all = lcm(lcm_all, a[i])
print(math.ceil(m / lcm_all) // 2)

Submission status: Wrong Answer

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

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

all_lcm = lcm(1, x[0])
for xi in x:
    all_lcm = lcm(all_lcm, xi)

print( math.ceil(m / all_lcm / 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m=map(int,input().split())
a=[i//2 for i in set(list(map(int,input().split())))]
l=1
for i in a:
    l=l*i//gcd(i,l)
print((m//l+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions 
import functools

n,m = (int(i) for i in input().split())
A = [int(i) for i in input().split()]

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

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

l = lcm(A)
if l > m: print(0)
else: print((m+l)//l)

Submission status: Wrong Answer

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

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

    if M < ans:
        ans = 0
        break

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

Submission status: Wrong Answer

Solution code:
import sys
import fractions as fr
input = sys.stdin.readline

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

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

res = 1
for i in range(N):
    res = lcm(res,a[i])
    if a[i]%2==1:
        print(0)
        exit()
    if res >= (10**12):
        print(0)
        exit()
#print(res)
if res%2==1 or res == 0:
    print(0)
    exit()
if M < res//2:
    print(0)
    exit()
k = (2*M//res + 1)//2
print(k)

Submission status: Wrong Answer

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


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


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

base = B[0]

is_break = False
for b in B:
  if base % b == 0:
    continue
  
  new_base = lcm(base, b)
  if (new_base // base) % 2 == 0:
    is_break = True
    break
  
  base = new_base

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


print(ans)