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 numpy as np
from functools import reduce
from fractions import gcd

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

def main():
    N,M = map(int, input().split())
    a = [int(i) for i in input().split()]
    A = np.array(a)
    
    m = A // 2
    lcm = reduce(lcm_base, m, 1)
    #print(lcm)
    
    if N == 1:
        print(int((M / lcm + 1) / 2) - 1)
    else:
        print(int((M / lcm + 1) / 2))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def func(a, m):
    return m / a - 1 / 2


tmp = 0

for i in range(max(a) // 2, m):
    count = True
    for j in range(len(a)):
        if not func(a[j], i).is_integer():
            count = False
            break

    if count:
        tmp = i
        break

if tmp == 0:
    print(0)

else:
    print(math.ceil(math.floor(m / tmp) / 2))

Submission status: Wrong Answer

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


ans = lcm(A)//2

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

Submission status: Wrong Answer

Solution code:

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

#長さN,偶数からなる
A = list(map(int,input().split()))

#p >= 1, 1<=k<=N
#このXを半公倍数とする
#X = a[k] * (p+0.5)
a = 1
for i in range(N):
	a *= A[i]//2
#print(a)
count = 0
while True:
	if 1 <= a <= M:
		count += 1
		a *= 3
		#print(a)
	else:
		break
print(count)

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    a=tuple(map(lambda x:int(x)//2,input().split()))
    g=a[0]
    b=g%2
    for x in a[1:]:
        if g%2!=b:
            print(0)
            exit()
        g=g*x//gcd(g,x)
    g*=2
    print((M+(g//2))//g)

        

if __name__ == '__main__':
    main()

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])
if ans > M:
    print(0)
else:
    print(M//ans+1)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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



def gcd(a,b):
    x = max([a,b])
    y = min([a,b])
    while y:
        x, y = y, x % y
    return x

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

# 全体の最大公約数, 最小で2
num = A[0]
for i in range(1,N):
    num = gcd(num, A[i])

# それぞれをnumで割った時の偶奇が異なれば、NG
odd = 0
even = 0
for i in range(N):
    if (A[i] / 2) % 2 == 0:
        even += 1
    else:
        odd += 1

if odd > 0 and even > 0:
    print(0)
else:
    # 半最小公倍数
    h = A[0] // 2
    # 最小公倍数
    n = A[0]
    for i in range(1,N):
        h = lcm(h, A[i]//2)
        n = lcm(n, A[i])
    if h == A[-1]:
        h *= 1.5

    if M < h:
        print(0)
    else:
        ans = 1
        M -= h
        ans += M // n
        print(ans)

Submission status: Wrong Answer

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

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

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

l = 1
for i in range(N):
  l = lcm(l, A[i])

M += l // 2

print(M//l)

Submission status: Wrong Answer

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

b = [i//2 for i in a]
c = lcm_list(b)

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

Submission status: Wrong Answer

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

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

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

def my_round(x, d=0):
    p = 10 ** d
    return float(math.floor((x * p) + math.copysign(0.5, x)))/p

#print( m / all_lcm )
#print( round(m / all_lcm ))
print( int(my_round(m / all_lcm)) )

Submission status: Wrong Answer

Solution code:
import math

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

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

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

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

    return arr
B = [[] for _ in range(N)]
p = set()

flag = 0

ans = 0
for i in range(N):
    if A[i] % 4==0:
        ans = 0
        flag = 1
        break
    tmp = factorization(A[i])
    o = 0
    for t in tmp:
        o = [pow(t[0], i) for i in range(1,t[1]+1) ]
        p = p | set(o)
q = 1
pp = list(p)
for i in range(len(pp)):
    q *= pp[i]

if q / 2 > M:
    ans =0
elif flag==0:
    minans = 1
    maxans = M
    cnt = 0
    i = M  //2
    while(cnt < 1000):
        cnt += 1
        if q * (i * 2 + 1) // 2 > M :
            maxans = i
            i -= (maxans-minans) // 2
        else:
            minans = i
            i += (maxans-minans) // 2

    for j in range(4):

        if q*((i-2+j)*2 + 1) // 2 <= M:
            ans = (i-2+j)+1
        

print(ans)

Submission status: Wrong Answer

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

for i in range(n):
  a[i]=a[i]//2
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
    
print(((m+ans)//ans)//2)

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
b=[]
for num in a:
  b.append(num//2)
c=set(b)
import fractions
ans=b[0]
flag=True

if flag:
  for item in c:
    ans=ans*item // fractions.gcd(ans,item)

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

Submission status: Wrong Answer

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

from fractions import gcd
def lcm(a,b):
    return (a*b)//gcd(a,b)
p=1
for a in set(A):#Aの最小公倍数を求める。
  p=lcm(a,p)
#最小公倍数pの0.5倍、1.5倍…x.5倍が半公倍数
answer=round(M/p)
print(answer)

Submission status: Wrong Answer

Solution code:
def egcd(a, b):
    if b == 0:
        return (1, 0, a)
    e = egcd(b, a % b)
    return (e[1], e[0] - a / b * e[1], e[2])

n, m = map(int, raw_input().split())
a = map(int, raw_input().split())
ans = a[0] / 2
lcm = a[0]
for i in xrange(1, n):
    rr = a[i] / 2
    md = a[i]
    e = egcd(lcm, md)
    g = e[2]
    x = e[0]
    if (rr - ans) % g != 0:
        print 0
        exit(0)
    lcm = lcm * md / g
    ans += x * (rr - ans) / g % (md / g) * lcm
    ans %= lcm
    if(ans < 0):
        ans += lcm
    if ans > m:
        print 0
        exit(0)
print((m - ans + lcm - 1) / lcm)

Submission status: Wrong Answer

Solution code:
# coding: utf-8
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 = (int(n) for n in input().split())
a_list = (int(n) for n in input().split())
#a_set = set(a_list)
#a_list_back = list(a_set)
a_list_back = list(dict.fromkeys(a_list))

lcm_number = lcm(a_list_back)
i = lcm_number // 2
counter = 0
if i > M:
  print(0)
  exit()

init_n = M - i
counter = (init_n // lcm_number) + 1
print(counter)

Submission status: Wrong Answer

Solution code:
import math

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

#A = list(map(lambda x: x // 2, A))


from functools import reduce

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)

def gcd_list(numbers):
    return reduce(gcd, numbers)

def lcm_list(numbers):
    return reduce(lcm, numbers, 1)
    
LCM = lcm_list(A)

if LCM == 0:
  print("No")
  
else:
  print(math.ceil(M / LCM))

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
# 長さN
# 整数M
N, M = map(int, input().split())

# 長さNからなる偶数列: a
a = list(set(map(int, input().split())))
#print(a)

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)

result = M//lcm_list(a)
#print(result)
if result == 0:
    print(0)
else:
    print(result+1)

Submission status: Wrong Answer

Solution code:
import fractions

input1 = input()
N = int(input1.split()[0])
M = int(input1.split()[1])
a_n = []

input2 = input()

for i in range(N):
    a_n.append(int(input2.split()[i]))

a_n.sort()
a_n = list(set(a_n))


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

print(round(M / ans))

Submission status: Wrong Answer

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

def gcd(x, y):
  b = max(x, y)
  s = min(x, y)
  r = b % s
  while r != 0:
    b = s
    s = r
    r = b % s
  return s

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

ans = 0
if M >= x:
  ans = 1
  M -= x
  ans += M // (x * 2)

print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from itertools import permutations

def gcd(a: int, b: int):
    """ https://cocodrips.hateblo.jp/entry/2014/03/05/143623
    """
    while b:
        a, b = b, a%b
    return a

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


def main():
    #N = int(input())
    N,M = map(int, input().split())
    #vP = tuple(map(int, input().split()))
    vA = set(map(int, input().split()))
    #vA = list(range(1,N+1))

    l = 2
    for a in vA:
        l = lcm(l,a)
    print(l, file=sys.stderr)
    l //= 2
    print(((M//l)+1)//2)
    #print(abs(p-q))
    #S = input().rstrip()
    #print(S)
    #print(lcm(N, M))
    #print("Yes" if X<=500*K else "No")
    #print(S.count("ABC"))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

a = max(A)
x = a//2
c = False

while x <= M:
    for i in range(N):
        if (x - (A[i]//2)) % A[i] != 0:
            break
        c = True
    if c:
        break
    else:
        x = x + a

if c:
    print( 1 + ( (M - x)// (2*x)))
else:
    print(0)

Submission status: Wrong Answer

Solution code:
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

def lcmlist(l):
    a = l[0]//2
    for i in range(1,len(l)):
        a = lcm(a,l[i]//2)
    return a

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

X = lcmlist(A)

#print(A)
#print(X)

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

print(ans)

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

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

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

#print(llcm, base_llcm)

print(((m-llcm)//base_llcm)+1)

Submission status: Wrong Answer

Solution code:
import fractions as math
n,m = map(int,input().split())
lst1 = list(map(int,input().split()))
lst1 = list(set(lst1))
ans,p = 0,0
lst1.sort(reverse=True)
if len(lst1) == 1:
    a,b = lst1[0]//2,lst1[0]//2
else:
    a,b = lst1[0]//2,lst1[1]//2

syoko = a*b//math.gcd(a,b)
if syoko > m:
    print(0)
    exit()
ans += 1

m -= syoko
ans += m//(syoko*2)
"""
p += syoko
while p <= m:
    p += syoko*2
    ans += 1
"""
print(ans)

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)
if common//2<=M:
    print((M//(common//2))//2+1)
else:
    print(0)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from functools import reduce
from operator import mul

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

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


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

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

lcm = lcm_list(a)
print(int((m)//lcm))

Submission status: Wrong Answer

Solution code:
from functools import reduce
N,M = map(int, input().split())
a = list(map(int, input().split()))
maxmax = 0.5
List =list()
for i in range(len(a)):
    l = list()
    while a[i]*maxmax<M:
        l.append(a[i]*maxmax)
        maxmax+=1
    maxmax = 0.5
    List.append(l)
res = reduce(set.intersection, [set(l_) for l_ in List])
print(len(res))

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

if any([(a // 2 - 1) % 2 != 0 for a in A]):
    print(0)
else:
    l = lcm(*[a // 2 for a in A])
    ans = (m - l) // (2*l)
    if m >= l:
        ans += 1
    print(ans)

Submission status: Wrong Answer

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

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

import fractions
from functools import reduce

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


def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
b = lcm_list(a)

if b > m:
    print(0)
    exit()

c =(m+(b-1))//b 
print(c)

Submission status: Wrong Answer

Solution code:
from fractions import gcd
inpl = lambda: list(map(int,input().split()))
N, M = inpl()
a = inpl()
b = list(map(lambda x: x//2, a))
L = 1
for i in range(N):
    c = b[i]
    g = gcd(L, c)
    s = c//g
    t = L//g
    if s % 2 == 0 or t % 2 == 0:
        print(0)
        exit()
    L *= s
z = M // L
print((z+1)//2)

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(numbers):
    return reduce(lcm, numbers, 1)

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

# [v // 2 for v in A]
print(0)

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)
print((m-(ans//2))//ans+1)

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

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

def div_ceil(x, y): return (x + y - 1) // y

N, M = map(int, input().split())
*A, = map(int, input().split())
A = list(set([a // 2 for a in A]))
G, L = (A[0], A[0])
for a in A[1:]:
    G = gcd(G, a)
    L = L * a
L //= G**(len(A) - 1)
if L % 2 != 0 or (L % 2 == 0 and (L // G) % 2 != 0):
    ans = div_ceil(M // L, 2)
else:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
from functools import reduce
N,M = map(int, input().split())
a = list(map(int, input().split()))
maxmax = 0.5
List =list()
for i in range(len(a)):
    l = list()
    while a[i]*maxmax<M:
        l.append(a[i]*maxmax)
        maxmax+=1
    maxmax = 0.5
    List.append(l)
res = reduce(set.intersection, [set(l_) for l_ in List])
print(len(res))

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(10**5)
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())
X_2 = lcm_list(list(map(int, input().split())))
X = X_2//2
print(M//X-M//X_2)

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

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 gcd(a, b):
    while b:
        a, b = b, a%b
    return a

N, M = rl()
a = list(set(rl()))
a.sort()
A = np.array(a)
B = A * 0.5
if any(B%2==0) and any(B%2==1):
    print(0)
    exit()

b = list(B)
ans = b[0]
for i in range(1, len(b)):
    ans = ans * b[i] // gcd(ans, b[i])
if ans > M:
    answer = 0
else:
    answer = 1 + (M-ans)//(2*ans)

print(int(answer))

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 res >= (10**10):
        print(0)
        exit()
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:
N,M=map(int,input().split())
A=list(map(int,input().split()))

from fractions import gcd
from functools import reduce
import math
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
print(math.ceil(ans))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
def lcm(x,y):
    return int((x * y) / gcd(x,y))
    
n,m = map(int,input().split(" "))
num_row = list(map(int,input().split(" ")))
res = 0
i = 0
first_list = []
#x_list = []
while i < len(num_row) - 1:
    x = lcm(num_row[i],num_row[i + 1])
    #print(x)
    if i == 0:
        if x <= m:
            first = x // 2
            first_list.append(first)
            res += (m - first) // x + 1
        i += 1
    else:    
        if x <= m:
            first = x // 2
            first_list.append(first)
            #x_list.append(x)
            if first not in first_list:  
                res += (m - first) // x + 1
            i += 1
    
    
print(res)

Submission status: Wrong Answer

Solution code:
import math
def main():

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

    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:
#!/usr/bin/env python3
import sys
import fractions as f
from functools import reduce

def lcm2(x,y):
    return (x * y)//f.gcd(x,y)

def lcm(a):
    return reduce(lcm2, a, 1)


def solve(N: int, M: int, a: "List[int]"):
    for i in range(N):
        a[i]/=2

    l=int(lcm(a))

    print((M+l)//l//2)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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 fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
from functools import reduce

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

MINX = reduce(lcm, A)

if M//MINX == 0:
    print(0)
else:
    from math import ceil
    print(ceil(M/(MINX*2)))

Submission status: Wrong Answer

Solution code:
n,m = list(map(int, input().split()))
a = list(map(lambda x: int(x)//2, input().split()))
import fractions
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
ans=m//ans
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())
A = [int(x) for x in input().split()]
ans = 0
lcm_half = A[0]//2
flag = 0
for i in range(1, N):
    gcd = fractions.gcd((A[i] // 2), lcm_half)
    lcm_half = (lcm_half * (A[i] // 2)) // gcd
    if lcm_half > M:
        flag = 1
        break
if flag == 1:
    ans = 0
else:
    M -= lcm_half
    ans = 1+M//(lcm_half*2)
# print(lcm_half)
print(ans)

Submission status: Wrong Answer

Solution code:
import fractions

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

N, M = [int(x) for x in input().split()]
l = [int(x) // 2 for x in input().split()]
ans = l[0]
for i in reversed(range(30)):
  if ans % 2 ** i == 0:
    numof2 = 2 ** i
for i in range(1, N):
  if l[i] % numof2 == 0 and (l[i] // numof2) % 2 == 1: 
    ans = lcm(ans, l[i])
  else:
    ans = M + 1
    break
ans2 = M // ans
print(ans2 // 2 + ans2 % 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(numbers):
    return reduce(lcm_base, numbers, 1)


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

L = lcm(A)

M = M * 2

a = int(M / (L*2))
b = int(M / L)
print(b-a)

Submission status: Wrong Answer

Solution code:
import fractions
N,M=map(int,input().split())
A=list(map(int,input().split()))
out=0
for i in range(N):
    if A[i]%4==0:
        out=1
        break
    else:
        A[i]=A[i]//2
if out==0:
    lcm=1
    for i in range(N):
        C=fractions.gcd(A[i],lcm)
        lcm=A[i]*lcm//C
    X=M//lcm
    if X%2==0:
        X=X//2
    else:
        X=X//2+1
    print(X)
else:
    print(0)

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

l = reduce(lambda n, m: n * m // gcd(n, m), map(lambda x: x // 2, a))
t = m // l
print(t // 2 if t % 2 == 0 else t // 2 + 1)

Submission status: Wrong Answer

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

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)


t = lcm(*A)
print(((2*m//t) + 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(2 * M // n // 2 + 1)


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

sum = 0
for m in range(1,M+1):
    temp = True
    for n in range(N):
        if (2*m/A[n]-1)%2 == 0 and 2*m/A[n]-1>0:
            None
        else:
            temp = False
            break

    if temp == True:
        print(m)
        sum += 1
print(sum)

Submission status: Wrong Answer

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

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)

l = lcm(a)
print((m+l)//(l*2))

Submission status: Wrong Answer

Solution code:
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a,b):
    return a*b//gcd(a,b)

def lcmlist(l):
    a = l[0]
    for i in range(1,len(l)):
        a = lcm(a,l[i])
    return a

import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

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

X = lcmlist(A)

#print(A)
#print(X)

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

print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    def lcm_base(x, y):
        return (x * y) // gcd(x, y)
    def lcm_list(numbers):
        return reduce(lcm_base, numbers, 1)
    N,M=map(int,input().split())
    a=tuple(map(int,input().split()))
    g=lcm_list(a)
    print((M+(g//2))//g)

        

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce
# 長さN
# 整数M
N, M = map(int, input().split())

# 長さNからなる偶数列: a
a = list(set(map(int, input().split())))
#print(a)

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)

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

Submission status: Wrong Answer

Solution code:
from functools import reduce

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


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


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


def lcmm(l):
    return reduce(lcm, l)


x = lcmm(a)

i = m / x
ans1 = -(-m // x)  # 切り上げ
ans2 = m // x  # 切り捨て

if i >= ans2 + 0.5:
    print(ans1)
else:
    print(ans2)

Submission status: Wrong Answer

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

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

def common(a,b):
    #print(a,b)
    #print(euc(a,b))
    return a*b/euc(a,b)

def twodiv(x):
    count=0
    while x%2==0:
        x = x//2
        count+=1
    #print("count:",count)
    return count
  
  
def ans():
    #print(A)
    base = A[0]
    check = twodiv(A[0])
    for i in range(1,N):
        base = common(base,A[i])
        #print(base)
        if twodiv(A[i])!=check:
            #print(twodiv(A[i]))
            return 0
        if base > M :
            print(base)
            return 0
    result = M//base
    
    print(base,result)
    return int((result+1)//2)

print(ans())

Submission status: Wrong Answer

Solution code:
from fractions import gcd
N, M = map(int, input().split())
a = list(map(int, input().split()))
k = a[0]
for i in range(1, N):
    k = (a[i]*k) // gcd(a[i], k)
    if k > M*2:
        print(0)
        exit(0)
ans = (M+(0.5*k)) // k

print(int(ans))

Submission status: Wrong Answer

Solution code:
import sys
inputs = sys.stdin.readlines()

n, m = map(int, inputs[0].split())
A = list(map(int, inputs[1].split()))
B = list(map(lambda x: x//2, A))
sup = 2*min(A)

C = []
for b in B:
    p = 0
    x = b*1
    c = set()
    while x <= sup:
        c.add(x)
        p += 2
        x = b*(p + 1)
    C.append(c)
c = C[0]
for ck in C[1:]:
    c &= ck
    
if c == set():
    print(0)
else:
    print((m // min(c) + 1) // 2)

Submission status: Wrong Answer

Solution code:
def lcm(x, y):
    a = x
    b = y

    if (a > b):
        tmp = a
        a = b
        b = tmp

        tmp = x
        x = y
        y = tmp

    while (b % a != 0):
        tmp = b % a
        b = a
        a = tmp

    return ((x // a) * y)

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

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

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

lm = a[0]

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

for i in range(n):
    if (a[i] % 2 == 0):
        ok = 1

if (ok == 1):
    print(0)
else:
    if (m - lm >= 0):
        ok = 1
        print(ok + ((m - lm) // (lm * 2)))
    else:
        print(0)