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 fractions
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,raw_input().split())
a = map(int,raw_input().split())
a = list(set(a))
LCM = lcm_list(a)
if LCM%2 == 1:
  print 0
  exit(0)

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

Submission status: Wrong Answer

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
kouho=[]
for i in A:
    j=1
    while i*(j+0.5)<=M:
        kouho.append([i*(j+0.5)])
        j+=1    
print(kouho)
count = 0
for k in kouho:
    if kouho.count(k) == N:
        count += 1
print(count//2)

Submission status: Wrong Answer

Solution code:
import sys
import fractions


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    n, m = list(map(int, readline().split()))
    a = list(map(int, readline().split()))
    lcm = a[0]
    for v in a[1:]:
        lcm = lcm * v // fractions.gcd(lcm, v)
    print((m - (lcm // 2)) // lcm + 1)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

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

two = set()
for i in a:
    j = i
    while i % 2 == 0:
        i //= 2
    if i == 1:
        two.add(j)
if len(two) > 1:
    print(0)
else:
    b = []
    for i in a:
        b.append(i // 2)
    bs = list(set(b))
    kake = 1
    for i in bs:
        kake *= i
    baisu = m // kake

    print(-(-baisu // 2))

Submission status: Wrong Answer

Solution code:
from fractions import gcd
from math import ceil


def lcm(iterable):
    a = iterable[0]

    for b in iterable:
        a = a * b / gcd(a, b)

    return a


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

    lcm_b = lcm(B)

    # print(lcm_b)

    if lcm_b > M:
        print(0)
    else:
        print(ceil(M / lcm_b / 2))


if __name__ == '__main__':
    main()

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=list(set(a))
b=[x//2 for x in a]
b.sort(reverse=1)
l=1
y=b[0]
for x in b:
  if l%x!=0:
    l=l*x//gcd(l,x)
ans=((m//l)+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()))
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // gcd(ans, a[i])
g=ans//2
kai=m//g
kai=-(-kai//2)
print(kai)

Submission status: Wrong Answer

Solution code:
# 最大公約数
def gcd(a, b):
    while b != 0:
        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()))
a_half = list(map(lambda x: x//2 , a))
lcm_num = a[0]
lcm_half = a_half[0]
for i in range(1,N):
    lcm_num = lcm(lcm_num , a[i])
    lcm_half = lcm(lcm_half, a_half[i])
print((M - lcm_half) // lcm_num + 1)

Submission status: Wrong Answer

Solution code:
def inpl():
    return list(map(int, input().split()))


def gcd(a, b):
    # greatest common divisor
    while b > 0:
        a, b = b, a % b

    return a


def lcm(a, b):
    # least common multiple
    return a * b // gcd(a, b)


N, M = inpl()
A = inpl()
A.sort(reverse=True)

all_lcm = 1
for a in A:
    all_lcm = lcm(all_lcm, a // 2)

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

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

baisu = A[0]

for i in range(1, n):
    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 sys
from fractions import gcd

read = sys.stdin.read
N, M, *a = map(int, read().split())
a = list(set(a))
m = 2 * M

lcm = a[0]
for i in a:
    g = gcd(lcm, i)
    lcm = lcm * i // g
    if lcm > m:
        print(0)
        exit()

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
import sys

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

# 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 main():
    N, M = [int(i) for i in input().split()]
    a = [int(i)//2 for i in input().split()]
    ans = a[0]
    for i in range(1, N):
            ans = ans * a[i] // gcd(ans, a[i])
    if ans > M:
        print(0)
    else:
        print(ceil(M/ans/2))

    

main()

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 ans():
    #print(A)
    base = A[0]
    for i in range(1,N):
        base = common(base,A[i])
        #print(base)
        if base > M:
            return 0
    result = M//base
    
    #print(base,result)
    return int((result+1)//2)

print(ans())

Submission status: Wrong Answer

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

sums = 0
flag = True

for m in range(M):
  for a in A:
    if (m%a)*2 != a:
      flag = False
      break 
  if flag==True:
    sums += 1
  else:
    flag = True

print(sums)

Submission status: Wrong Answer

Solution code:
n, m = map(int, input().split())
A = tuple(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)
c = 0
while t <= 2*m:
    c += 1
    # print(t)
    t *= 3
    

print(c)

Submission status: Wrong Answer

Solution code:
import fractions
from functools import reduce

def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

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

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

p = lcm_list(a)
i = 0

i = int(m/p+0.5)

print(i)

Submission status: Wrong Answer

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

hana=[]
for i in a:
  hana.append(i//2)

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

mini=hana[0]
for i in range(n):
  mini=lcm(mini,hana[i])

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

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 = rl()
a.sort()
A = np.array(a)
B = A * 0.5
if any(B%2==0):
    print(0)
    exit()

b = list(B)
ans = b[0]
for i in range(1, N):
    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:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    def gcd(a,b):
        if a == 0:
            return b
        return gcd(b%a,a)
    n,m = LI()
    a = LI()
    l = a[0]
    for i in a[1:]:
        g = gcd(l,i)
        l = l*i//g
    L = l
    l = 0
    r = m
    while r-l > 1:
        x = (l+r) >> 1
        if (2*x-1)*L <= 2*m:
            l = x
        else:
            r = x
    print(l)
    return

#Solve
if __name__ == "__main__":
    solve()

Submission status: Wrong Answer

Solution code:
from fractions import gcd
n,m=map(int,input().split())
a=list(map(int,input().split()))
l=1
for i in a:
    i=i//2
    l=l*i//gcd(i,l)
    if m<l:
        print(0)
else:
    print((m//l+1)//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 = tuple(map(int, input().split()))

x = lcm(a)
print((m-x//2)//x+1)

Submission status: Wrong Answer

Solution code:
from functools import reduce

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

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

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

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

lcm_value = lcm_list(a_list)

print((m*2//lcm_value+1)//2)

Submission status: Wrong Answer

Solution code:
import fractions

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

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

half_gcd = gcd // 2

count = (M + half_gcd) // gcd

print(count)

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

Submission status: Wrong Answer

Solution code:
import numpy as np
N, M = map(int, input().split())
a = list(map(int, input().split()))
ans = []
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)
    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:
from functools import reduce
def gcd(a,b):
    temp=a
    a=b
    b=temp%a
    if b==0:
        return a
    else:
        return gcd(a,b)

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=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 sys import exit

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

lcm = semiA[0]
for i in range(1, N):
    lcm = lcm * semiA[i] // gcd(lcm, semiA[i])
    if lcm > M:
        print(0)
        exit()

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

Submission status: Wrong Answer

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

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)

Min = lcm(a)

Sum = 0

x = 1
while Min * x <= M:
    Sum += 1
    x += 2

print(Sum)

Submission status: Wrong Answer

Solution code:
def d_semi_common_multiple():
    from fractions import gcd
    from functools import reduce
    N, M = [int(i) for i in input().split()]
    A = [int(i) for i in input().split()]

    lcm = reduce(lambda x, y: x * y // gcd(x, y), A)
    lcm_half = reduce(lambda x, y: x * y // gcd(x, y), A) // 2
    return M // lcm_half - M // lcm

print(d_semi_common_multiple())

Submission status: Wrong Answer

Solution code:
import fractions
def func(x, y):
  tmp=fractions.gcd(x, y)
  return x*y//tmp

N, M=map(int, input().split())
if N==1:
  a=int(input())
  c=a//2
  if c>M:
    print(0)
  else:
    print(int((M/c-1)/2)+1)
  exit()

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

c=func(b[0], b[1])
for i in range(2, N):
  c=func(c, b[i])
  
if c>M:
  print(0)
else:
  print(int((M/c-1)/2)+1)

Submission status: Wrong Answer

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

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

n, m = map(int, input().split())
a = [int(x)//2 for x in input().split()]
tmp = sum(list(map(lambda x:x%2, a)))
if tmp != 0 and tmp != n:
    print(0)
    exit(0)
ma = max(a)
for x in a:
    ma = (ma-x + 2*x-1)//(2*x)*(2*x)+x
    if ma > m:
        print(0)
        exit(0)
lc = 1
for x in a:
    lc = lcm(lc, 2*x)
    if lc > m:
        print(0)
        exit(0)
ret = 1
m -= ma
ret += m//lc
print(ret)

Submission status: Wrong Answer

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
lcm = 1
cnt = 0
for e in a:
    e //= 2
    lcm *= e // gcd(lcm, e)
    if lcm > m: break
    cnt += e & 1

if cnt in {0, n}:
    res = (1 + m // lcm) // 2
else:
    res = (m // lcm) // 2
print(res)

Submission status: Wrong Answer

Solution code:
import fractions as f
from functools import reduce

def lcm_base(x, y):
    return (x * y) // f.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
def calc_half(n):
  return int(n/2)

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

a_half = list(map(calc_half,a))
saibai = lcm_list(a_half)
counter = 0
saibai1 = 0
ans = 0

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

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

ans = alist[0]

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

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

Submission status: Wrong Answer

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

#gcd, lcm
import fractions
def lcm(nums):
  ans = nums[0]
  for i in range(1, len(nums)):
      ans = ans * nums[i] // fractions.gcd(ans, nums[i])
  return ans

lb = lcm(b)
la = lcm(a)
if lb <= m:
  ans = 1+(m-lb)//la
else:
  ans = 0
print(ans)

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

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

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

num = lcm_list([v // 2 for v in A])
# print(-(-M // num) // 2)
print(0)

Submission status: Wrong Answer

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

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

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

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

x = m // LCM
y = m // (LCM * 2)
print(x - y)

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
ans=a[0]
for i in range(1,n):
    ans = ans * a[i] // gcd(ans, a[i])
    if a[i]%4==0:
        print(0)
        quit()
    if ans//2>m:
        print(0)
        quit()
ans//=2
if ans>m:
    print(0)
else:
    print((m-ans)//(ans*2)+1)

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
    elif num % 2 == 0:
        return M // (num*2)
    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
def Lcm(X,Y):
  return X*Y//fractions.gcd(X,Y)
N,M=[int(s) for s in input().split()]
ls=[int(s) for s in input().split()]
c=1
ans=1
while ls[0]%2==0:
  ls[0]//=2
  c*=2
for i in range(1,N):
  if ls[i]%c!=0:
    ans=0
    break
  elif ls[i]%(2*c)==0:
    ans=0
    break
  else:
    ls[i]//=c
  #print(ls)
if ans==0:
  print(0)
else:
  lcm=1
  for e in ls:
    lcm=Lcm(lcm,e)
    if lcm*c>M:
     # print(1)
     # print(lcm)
      break
  else:
    x=lcm*c//2
    y=M//x+1
    #print(x)
    print(max([y//2,0]))

Submission status: Wrong Answer

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

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)

elif lcm(B) == M and lcm(B)%2 == 0:
    print(0)
    
elif lcm(B) == M and lcm(B)%2 == 1:
    print(1)
else:
    if lcm(B)%2 ==1:
        print((M-lcm(B))//2//lcm(B)+1)
    else:
        print((M-2*lcm(B))//2//lcm(B)+1)

Submission status: Wrong Answer

Solution code:
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,pprint,fractions
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n,m = inpl()
a = inpl()
ttt = []
def f(x):
    cnt = 0
    while x%2==0:
        cnt += 1
        x //= 2
    return [cnt,x]
# print(f(2))
g = f(a[0])[0]
ttt.append(f(a[0])[1])
for i in range(1,n):
    tmp = f(a[i])
    if g != tmp[0]:
        print(0)
        quit()
    ttt.append(tmp[1])
xx = 1
ttt = list(set(ttt))
# print(ttt)
for mm in ttt:
    xx *= mm
ggg = 2**g*xx
# print(ggg)
print((m-ggg//2)//ggg+1)

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)
print((m//(lcm//2))-(m//lcm))

Submission status: Wrong Answer

Solution code:
n,m = map(int, input().split())
a = [x for x in map(int, input().split())]
sett = set(a)
lst = []

for i in range(len(sett)):
  x = 0
  p = 0
  while x <= m:
    x = int(a[i]*(p+0.5))
    if x > m:
      break
    lst.append(x)
    p += 1

res = []
for i in lst:
  if lst.count(i) == len(sett):
    res.append(i)
print(len(res)//2)

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

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

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


n, m = na()
a = na()
lcm = a[0]
for i in range(1, n):
    lcm = lcm * a[i] // gcd(lcm, a[i])
r = lcm//2
b = m//r
print((b+1)//2)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri Jan 10 18:12:40 2020

@author: praty
"""
def gcd(a,b):
    if(b==0):
        return a;
    else:
        return gcd(b,a%b);
n,k = map ( int , input().split());
a = [ int(x) for x in input().split()];
x = 1;
for i in range (n) :
    a[i]=a[i]//2 ;
    x = (x * a[i])//gcd(x,a[i]);
print((k//x) -(k//(2*x))) ;

Submission status: Wrong Answer

Solution code:
from fractions import gcd


def solve():
    N, M, *a = map(int, open(0).read().split())
    
    a_half = [ai // 2 for ai in a]
    half_lcm = a_half[0]
    for ai in a_half[1:]:
        half_lcm = (half_lcm * ai) // gcd(half_lcm, ai)
    ans = 1 + ((M - half_lcm) // half_lcm) // 2
    if M < half_lcm:
        ans = 0
    print(ans)


if __name__ == '__main__':
    solve()

Submission status: Wrong Answer

Solution code:
# coding: utf-8
import fractions
from functools import reduce
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)

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

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

def lcm_list(numbers):
    return reduce(lcm, numbers)
N, M = map(int, input().split())
A = list(map(int, input().split()))
# for i in range(N):
#     A[i] = (A[i] + 0.5) * 10
G = gcd_list(A)
L = lcm_list(A)
l = L // G
ans = (M // l) // 2
print(ans if ans == 0 else ans + 1)

Submission status: Wrong Answer

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

    return gcd(b % a, a)


def lcd(a, b):
    g = gcd(a, b)
    return a * b // g


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

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

mn = min(A)
l = 1
for e in A:
    l = lcd(l, e)

tmp = (m + mn) // l
ans = tmp // 2 + tmp % 2

print(ans)

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
if div != 1:
  m //= (div//2)
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
  if cnt == 0:
    print(0)
    break
else:
  print(a)
  lcm = a[0]
  for i in range(1,n):
    big,sml = a[i],lcm
    while sml != 0:
      big,sml = sml,big%sml
    lcm *= a[i] // big
  print(lcm)
  ans = m // (2*lcm)
  print(ans)
  if m % (2*lcm) >= lcm:
    ans += 1
  print(ans)

Submission status: Wrong Answer

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

div = set()

for x in a:
    x //= 2
    xsq = int(x**0.5)
    for d in range(1, xsq+1):
        if x%d:
            continue
        div.add(d)
        div.add(x//d)

lcm = 1
for x in div:
    lcm *= x

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

Submission status: Wrong Answer

Solution code:
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 // G
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:
import fractions

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

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

f = x//2

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

Submission status: Wrong Answer

Solution code:
import sys
def input():
    return sys.stdin.readline()[:-1]
n,m=map(int,input().split())
a=list(map(int,input().split()))
from fractions import gcd
ans=a[0]
for i in range(1,n):
    ans = ans * a[i] // gcd(ans, a[i])
    if a[i]%2==0:
        print(0)
        quit()
    if ans//2>m:
        print(0)
        quit()
ans//=2
if ans>m:
    print(0)
else:
    print((m-ans)//(ans*2)+1)

Submission status: Wrong Answer

Solution code:
import math

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

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

pres = []
num = 1;
den = -1

for e in a:
    if(den == -1):
        den = e//2
    else:
        den = gcd(den,e//2)
    if((e//2) not in pres):
        num *= e//2
        pres.append(e//2)
ans = math.ceil((m*den)/(num*2))
if((num//den)>(m)):
    ans = 0
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)

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())
xs = map(int, input().split())
b = None
for x in xs:
    for i in range(30):
        if x%(2**i):
            break
    if b!=None:
        if b!=i:
            b = -1
            break
    b = i
if b==-1:
    print(0)
else:
    r = lcm_list(xs)
    if r//2 > M:
        print(0)
    else:
        print((M-r//2)//r+1)

Submission status: Wrong Answer

Solution code:
from fractions import gcd

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

x=1
for aa in a:
 x=(x*aa)//gcd(x,aa)

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

def factorization(n):
    p=2
    fcr=[]
    while p*p<=n:
        while n%p==0:
            fcr.append(p)
            n//=p
        p+=1
    if n>1:
        fcr.append(n)
    return fcr

l=factorization(x)
#print(l)
ll=[i for i in l if i%2==1]
ans=1
for i in ll:
 ans*=i

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

Submission status: Wrong Answer

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

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


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

flag = False

for i in range(N):
    B[i] = (A[i] // 2) % 2

if(sum(B) == 0 or sum(B) == N):
    flag = True

if(flag):
    over = False
    a = A[0]
    i = 1
    while(a <= M and i < N):
        a = lcm(a, A[i])
        if(a > M):
            over = True
        i += 1
    if(over):
        print(0)
    else:
        ans = (M - a//2) // a + 1
        print(ans)
else:
    print(0)

Submission status: Wrong Answer

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


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

n, m = map(int, input().split())
l = list(map(int, input().split()))
for i in range(n):
    l[i] = l[i] // 2
a = lcm_list(l)
print(-(-m // a) // 2)

Submission status: Wrong Answer

Solution code:
import fractions

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

lcm = a_list[0]
lcm_2 = a_list[0]//2

for i in range(1, n):
    lcm = lcm * a_list[i] // fractions.gcd(lcm, a_list[i])
    lcm_2 = lcm_2 * (a_list[i]//2) // fractions.gcd(lcm_2, (a_list[i]//2))

print((m-lcm_2)//lcm+1)

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]//=2

pow2 = 2**50

p2 = set()

for i in range(n):
    tmp = fractions.gcd(pow2,a[i])
    p2.add(tmp)
    if len(set())>1:
        print(0)
        exit()
def lcd(x,y):
    tmp = fractions.gcd(x,y)
    x//=tmp 
    y//=tmp 
    return x*y*tmp
tmp = a[0]

for i in range(n):
    tmp = lcd(tmp,a[i])
    if tmp > m:
        print(0)
        exit()

tmp2 = tmp*2

ans = m//tmp 
ans2 = m//tmp2
ans -= ans2
print(ans)

Submission status: Wrong Answer

Solution code:
from sys import stdin
import numpy as np


# noinspection PyShadowingBuiltinsInspection

def main():
    N, M = [int(x) for x in input().split()]
    a = np.sort(np.array([int(x) for x in input().split()]) // 2)[::-1]
    b = [a[0]]
    for i in range(1, N):
        flag = False
        for x in b:
            if x % a[i] == 0:
                flag = True
                break
        if not flag:
            b.append(a[i])
    # print(b)
    y = 1
    for x in b:
        # print(b)
        y *= x
    z = M // y
    # print(y, z*y)
    ret = z // 2 if z % 2 == 0 else z // 2 + 1
    print(ret)

    return


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N,M = map(int,input().split())
As = []
for a in set(input().split()):
    for x in range(1,M):
        V = int(float(a) * float(x+0.5))
        if V > M:
            break
        As.append(V)
R = 0
for x in range(1,M):
    C = As.count(x)
    if C == N:
        R += 1
print(R)

Submission status: Wrong Answer

Solution code:
import math
from functools import reduce

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)
elif ans % 2 == 0:
    print(0)
else:
    print((M - ans) // (2*ans) + 1)