Problem:


Score : 400 points

Problem Statement

Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.

Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):

There exists a non-negative integer p such that X= a_k \times (p+0.5).

Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Runtime Error

Solution code:
import sys, fractions
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def lcm_list(a):
    if len(a)==2:
        return a[0]*a[1]//fractions.gcd(a[0], a[1])
    else:
        tmp = lcm_list(a[:-1])
        return tmp*a[-1]//fractions.gcd(tmp, a[-1])

def resolve():
    N, M = LI()
    a = LI()

    a_half = [i//2 for i in a]
    a_half_lcm = lcm_list(a_half)
    has_scm = not 0 in [a_half_lcm//i%2 for i in a_half]

    if has_scm:
        print((M-a_half_lcm)//(2*a_half_lcm)+1)
    else:
        print(0)

if __name__ == '__main__':
    resolve()

Submission status: Runtime Error

Solution code:
import fractions
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

N,M = (int(x) for x in input().split())
a = list(map(int, input().split()))
temp = [a[0],a[0]//2]
broke = False
for i in range(1,N):
    gcd = xgcd(temp[0],a[i])
    if temp[1] % gcd[0] != (a[i]//2) % gcd[0]:
        broke = True
        break
    else:
        x = temp[1] + temp[0]*((a[i]//2)-temp[1])//gcd[0]*gcd[1]
        temp[0] = (temp[0] * a[i]) // math.gcd(temp[0], a[i])
        temp[1] = x % temp[0]
if broke:
    print('0')
else:
    dm = divmod(M,temp[0])
    if dm[1] >= temp[1]:
        print(dm[0]+1)
    else:
        print(dm[0])

Submission status: Runtime Error

Solution code:
import math
def xgcd(a, b):
    x0, y0, x1, y1 = 1, 0, 0, 1
    while b != 0:
        q, a, b = a // b, b, a % b
        x0, x1 = x1, x0 - q * x1
        y0, y1 = y1, y0 - q * y1
    return a, x0, y0

N,M = (int(x) for x in input().split())
a = list(map(int, input().split()))
temp = [a[0],a[0]//2]
broke = False
for i in range(1,N):
    gcd = xgcd(temp[0],a[i])
    if temp[1] % gcd[0] != (a[i]//2) % gcd[0]:
        broke = True
        break
    else:
        x = temp[1] + temp[0]*((a[i]//2)-temp[1])//gcd[0]*gcd[1]
        temp[0] = (temp[0] * a[i]) // math.gcd(temp[0], a[i])
        temp[1] = x % temp[0]
if broke:
    print('0')
else:
    dm = divmod(M,temp[0])
    if dm[1] >= temp[1]:
        print(dm[0]+1)
    else:
        print(dm[0])

Submission status: Runtime Error

Solution code:
from math import gcd


def main():
    N, M = list(map(int, input().split(' ')))
    half_A = list(map(lambda x: int(x) // 2, input().split(' ')))
    lcm = 1
    for half_a in half_A:
        lcm *= half_a // gcd(lcm, half_a)
        if lcm > M:
            print(0)
            exit(0)
    for half_a in half_A:
        if (lcm // half_a) % 2 == 0:
            print(0)
            exit(0)
    num_multiples = M // lcm
    print((num_multiples + 1) // 2)  # count only cases that ratios are odd numbers.


if __name__ == '__main__':
    main()

Submission status: Runtime Error

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


def gcd_from_list(num_list):
    if len(num_list) == 1:
        return num_list[0]
    else:
        return gcd(num_list[0], gcd_from_list(num_list[1:]))


def lcm_from_list(num_list):
    gcd_of_input = gcd_from_list(num_list)
    num_list = list(set(num_list))
    lcm = num_list[0]
    for i in range(len(num_list) - 1):
        lcm = lcm * num_list[i + 1] // gcd_of_input
    return lcm


def main():
    N, M = list(map(int, input().split(' ')))
    half_A = list(map(lambda x: int(x) // 2, input().split(' ')))
    lcm_A = lcm_from_list(half_A)
    num_multiples = M // lcm_A
    print((num_multiples + 1) // 2)  # count only cases that ratios are odd numbers.


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:

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[i] = cnt

    if temp!=1:
        arr[temp] = 1

    if not arr:
        arr[n] = 1

    return arr

import math

n, m = map(int, input().split())
a = list(map(int, input().split()))
# a2 = [num//2 for num in a]
acount = [None]*n # aを2で割れる回数
anum = [None]*n # 割ったあとの残り(=奇数)
for i,num in enumerate(a):
    c = 0
    while num%2==0:
        num //=2
        c += 1
    acount[i] = c
    anum[i] = num
if all(item==acount[0] for item in acount):
    cc = {}
    lcm = anum[0]
    for num in anum[1:]:
        g = math.gcd(lcm, num)
        lcm = lcm * num / g
    num0 = lcm * (pow(2, (acount[0]-1)))
    span = num0*2
    if m<num0:
        print(0)
    else:
        print(int((m-num0)//span + 1))
else:
    print(0)

Submission status: Runtime Error

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

    gc = a[0]*a[1]/fractions.gcd(a[0],a[1])
    for i in range(1,n-1):
        gc *= a[i+1]/fractions.gcd(gc,a[i+1])
    if m<gc/2:
        print(0)
    else:
        print(int((m-gc/2)/gc)+1)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
N,M=map(int,input().split())
a=list(map(int,input().split()))
l=1
count=0
A=a[0]
ans=0
flag=1
while A%2==0:
    A=A//2
    count=count+1
for i in range(N):
    A=a[i]
    b=A//(2**count)
    if b==0 or b%2==0:
        flag=0
        break
    A=A//2
    l=l*A//math.gcd(l,A)
if flag==1:
    ans=M//l
    if ans%2==0:
        print(ans//2)
    else:
        print(ans//2+1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
from math import gcd 
def ma():
    return map(int,input().split())
N,M=ma()
A=list(ma())
temp=A[0]//2

for i in range(N-1):
    temp=temp*(A[i+1]//2)//gcd(temp,(A[i+1]//2))
M+=temp 
ans=M//(2*temp)
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce


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

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

tmp = reduce(lambda x, y: x * y, a)

ans_tmp = (tmp / gcd(*a)) // 2 # 最小公倍数

ans = (m // ans_tmp) // 2
if ans == 0:
    print(0)
else:
    if ans * ans_tmp >= m:
        print(int(ans))
    else:
        print(int(ans+1))

Submission status: Runtime Error

Solution code:
import numpy as np
from math import gcd
from functools import reduce

N, M = map(int,input().split())
a = list(map(int,input().split()))
a = np.array(a)
a = a // 2

def solve(p, q):
    cnt = 1
    while p % 2 == 0 and q % 2 == 0:
        cnt <<= 1
        p >>= 1
        q >>= 1
    if (p - q) % 2 != 0:
        return 0
    return p * q * cnt // gcd(p, q)
k = reduce(solve, a)
if k == 0:
    print(0)
else:
    ans = int((M / k + 1) / 2)
    print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
from math import gcd
from functools import reduce

N, M = map(int,input().split())
a = list(map(int,input().split()))
a = np.array(a)
a = a // 2

def solve(p, q):
    cnt = 1
    while p % 2 == 0 and q % 2 == 0:
        cnt <<= 1
        p >>= 1
        q >>= 1
    if (p - q) % 2 != 0:
        return 0
    return p * q * cnt // gcd(p, q)
k = reduce(solve, a)
if k == 0:
    print(0)
else:
    ans = (M / k + 1) // 2
    print(ans)

Submission status: Runtime Error

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

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

l=1
for i in a:
    l=l*i//2//gcd(l,i//2)
    if l>m:
        break

ans=1 if l<=m else 0
m-=l

print(ans+max(0,m//(2*l)))

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    a,b = max(a,b),min(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(lambda x:int(x)//2,input().split()))

if(all(A[0]%2 == a%2 for a in A)):
    lcm_A = lcm(A[0],A[1])
    for a in A[2:]:
        lcm_A = lcm(lcm_A,a)
    print(int((M/lcm_A+1)//2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    a,b = max(a,b),min(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(lambda x:int(x)//2,input().split()))

if(all(A[0]%2 == a%2 for a in A)):
    lcm_A = lcm(A[0],A[1])
    for a in A[2:]:
        lcm_A = lcm(lcm_A,a)
    print((M/lcm_A+1)//2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import fractions
import math


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

if sum(flag) != flag[0] * n:
    ans = 0
else:
    # 最小公倍数求める
    lcm = a[0]
    for i in range(1, n):
        lcm = lcm * a[i] // fractions.gcd(lcm, a[i])

    ans = math.floor(m / lcm + 0.5)
print(ans)

Submission status: Runtime Error

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

A = [a//2 for a in A]

pre = None
for a in A:
  c = 0
  while a % 2 ==0:
    a //= 2 
    c += 1    
  if pre is None:    
    pre = c
  elif pre != c:
    print(0)
    exit()
  
ans = lcm(A[0],A[1])  
for i in range(n-2):  
  if ans > m:
    print(0)
    exit()
  ans = lcm(ans,A[i+2])  

print(ceil((m//ans)/2))

Submission status: Runtime Error

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

A = [a//2 for a in A]

pre = None
for a in A:
  c = 0
  while a % 2 ==0:
    a //= 2 
    c += 1    
  if pre is None:    
    pre = c
  elif pre != c:
    print(0)
    exit()
  
ans = lcm(A[0],A[1])  
for i in range(n-2):  
  if ans > m:
    print(0)
    exit()
  for i in range(len(A)-2):
    ans = lcm(ans,A[i+2])  

print(ceil((m//ans)/2))

Submission status: Runtime Error

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

A = [a//2 for a in A]

pre = None
for a in A:
  c = 0
  while a % 2 ==0:
    a //= 2 
    c += 1    
  if pre is None:    
    pre = c
  elif pre != c:
    print(0)
    exit()
  
ans = lcm(A[0],A[1])  
for i in range(n-2):  
  if ans > m:
    ans = 0
    break
  for i in range(len(A)-2):
    ans = lcm(ans,A[i+2])  

print(ceil((m//ans)/2))

Submission status: Runtime Error

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)

lcm = lcm_list(a)
scm = lcm / 2

if scm > M:
    print(0)
else:
    cnt = int((M - scm) // lcm)
    print(cnt+1)

Submission status: Runtime Error

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)

lcm = lcm_list(a)
scm = lcm / 2

cnt = 0
while scm <= M:
    scm += lcm
    cnt += 1
print(cnt)

Submission status: Runtime Error

Solution code:
import fractions


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    j = 0
    mul = a[0]
    for i in range(1, n):
        mul = mul * a[i] // fractions.gcd(mul, a[i])
    for i in a:
        if (mul // i) % 2 == 0:
            j = 1
            break
    if m >= mul / 2 and j == 0:
        ans = (m - mul / 2) // mul + 1
        print(int(ans))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions


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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions


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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = a[0]
    for i in range(1, n):
        mul = mul * a[i] // fractions.gcd(mul, a[i])
    a_2 = map(lambda x: mul // x % 2, a)
    if 0 in a_2:
        print(0)
        exit()
    if m >= mul / 2:
        ans = (m - mul / 2) // mul + 1
        print(int(ans))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = a[0]
    for i in range(1, n):
        mul = mul * a[i] // fractions.gcd(mul, a[i])
    a_2 = map(lambda x: mul / x % 2, a)
    if 0 in a_2:
        print(0)
        exit()
    if m >= mul / 2:
        ans = (m - mul / 2) // mul + 1
        print(int(ans))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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


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


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = lcm_list(a)

    if m > (mul // 2):
        ans = ((m - (mul // 2)) // mul) + 1
        print(int(ans))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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


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


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = lcm_list(a)

    if m > mul // 2:
        ans = (m - mul // 2) // mul + 1
        print(int(ans))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = a[0]
    for i in range(1, n):
        mul = mul * a[i] // math.gcd(mul, a[i])
    if m > mul // 2:
        ans = (m - mul // 2) // mul + 1
        print(int(ans))
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = a[0]
    for i in range(1, n):
        mul = mul * a[i] // math.gcd(mul, a[i])
    ans = (m - mul / 2) // mul + 1
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = a[0]
    for i in range(1, n):
        mul = mul * a[i] // math.gcd(mul, a[i])
    ans = (m - mul / 2) // mul + 1
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math


def main():
    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    mul = a[0]
    for i in range(1, n):
        mul = mul * a[i] // math.gcd(mul, a[i])
    if mul % 2 == 1:
        print(0)
        exit()
    ans = (m - mul / 2) // mul + 1
    print(int(ans))


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math

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

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

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

x = 1

for y in a:
    x = lcm(x, y//2)

for y in a:
    if (x//(y//2)) % 2 == 0:
        print(0)
        exit()

max_n = (m-x)//(2*x)

print(max_n+1)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

N, M = rl()
A = rl()

import math
from functools import reduce

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

def get_gcd(A):
    return reduce(math.gcd, A)

gcd = get_gcd(A)
d = 1
for a in set(A):
    d *= a
d //= gcd

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

Submission status: Runtime Error

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

from math import floor
from fractions import gcd
from functools import reduce


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


b = [n // 2 for n in a]

lcm_b = reduce(lcm, b)

for n in b:
    if (lcm_b / n) % 2 == 0:
        print(0)
        exit()

n = floor((M / lcm_b - 1) / 2) + 1

print(n)

Submission status: Runtime Error

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

from math import gcd, floor
from functools import reduce


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


b = [n // 2 for n in a]

odd_lcm = b[0]
for i in range(N - 1):
    odd_lcm = lcm(b[i], b[i + 1])
    if odd_lcm // b[i] % 2 == 0 or odd_lcm // b[i + 1] % 2 == 0:
        print(0)
        exit()

n = floor((M / odd_lcm - 1) / 2) + 1

print(n)

Submission status: Runtime Error

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

from math import gcd, floor
from functools import reduce


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


b = [n // 2 for n in a]
lcm_b = reduce(lcm, b)
n = floor((M / lcm_b - 1) / 2) + 1

print(n)

Submission status: Runtime Error

Solution code:
from functools import reduce
import sys

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


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

def gcd(a, b):
    import math
    return math.gcd(a, b)


def temp(a):
    return int(a * 0.5)

max_a = max(A)

i = 0
while True:
    num = int((i+0.5) * max_a)
    if num > M:
        print(0)
        sys.exit()

    found = True
    for a in A:
        if int(num - 0.5 * a) % a != 0:
            found = False
            break
    if found:
        ans = 1
        break
    i += 1

aa = reduce(lcm, A)

ans += (M - num) // aa

print(int(ans))

Submission status: Runtime Error

Solution code:
#97
judge=0
N,M = map(int,input().split())
import fractions
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, N):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
for i in a:
    if (ans//i)%2==0:
        judge=1
        sss=0
        break
if judge==0 and M-ans//2 <0:
    sss=0
elif judge==0 and M-ans >=0:
    sss=((M-ans//2)//ans)+1
print(sss)

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

# 2つの数の最小公倍数
def lcm(x,y):
    return (x*y) // gcd(x,y)

# リストを引数にして最小公倍数を表示
def lcm_of_list(a):
    return reduce(lcm, a)

def waruni(a):
    return a//2


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

L = lcm_of_list(b)

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

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

print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math
import heapq
mod=10**9+7
inf=float("inf")
from math import sqrt
from collections import deque
from collections import Counter
from math import ceil
input=lambda: sys.stdin.readline().strip()
sys.setrecursionlimit(11451419)
from functools import lru_cache
#メモ化再帰defの冒頭に毎回 @lru_cache(maxsize=10**10)
#引数にlistはだめ
#######ここまでテンプレ#######
#######ここから天ぷら########
@lru_cache(maxsize=10**10)
def gcd(a,b):
    if b==0: return a
    else:
        return gcd(b,a%b)
@lru_cache(maxsize=10**10)        
def lcm(a,b):
    return a*b//gcd(a,b)

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

def llcm(A):
    n=len(A)
    if n==1 : return A[0]
    elif n%2==1 : 
        A[1]=lcm(A[0],A[1])
        if max(A)>m :
            print(0)
            exit()
        return llcm(A[1:])
    else: 
        B=[lcm(A[i],A[i+1]) for i in range(0,n,2)]
        if max(B)>m:
            print(0)
            exit()
        return llcm(B)

B=[i//2 for i in A]
p=llcm(B)
print(m//p - m///(p*2))

Submission status: Runtime Error

Solution code:
from math import gcd
from functools import reduce

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

n, m = map(int, input().split())
A = list(map(int, input().split()))
num = reduce(lcm, A)
num //= 2

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

Submission status: Runtime Error

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

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

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

if(n != 1):
val = (a[0]*a[1]) // gcd(a[0],a[1])
for i in range(1,n-1):
    val = (val*a[i+1]) // gcd(val, a[i+1])
result = (m//val)//2
if((m//val)%2 != 0):
    result = result + 1
print(result)

Submission status: Runtime Error

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

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

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

val = (a[0]*a[1]) // gcd(a[0],a[1])
for i in range(1,n-1):
    val = (val*a[i+1]) // gcd(val, a[i+1])
    result = (m//val)//2
    if((m//val)%2 != 0):
        result = result + 1
print(result)

Submission status: Runtime Error

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

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

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

val = a[0]*a[1] // gcd(a[0],a[1])
for i in range(1,n-1):
    val = val*a[i+1] // gcd(val, a[i+1])
    result = (m//val)//2
    if((m//val)%2 != 0):
        result = result + 1
print(result)

Submission status: Runtime Error

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

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

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

min_a = min(a)

val = a[0]*a[1] // gcd(a[0],a[1])
for i in range(1,n-1):
    val = val*a[i+1] // gcd(val, a[i+1])
if(val//min_a%2 != 0):
    result = m//val//2
    if(m//val%2 != 0):
        result = result + 1
else:
    result = m//val//2
print(result)

Submission status: Runtime Error

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

num1 = a[0]
num2 = 0
while num1 % 2 == 0:
    num1 //= 2
    num2 += 1
gc = 2 ** num2

b = []
for i in a:
    if i % gc != 0 or (i // gc) % 2 == 0:
        print(0)
        exit()
    else:
        b.append(i // gc)

from math import gcd
lcm = 1
for i in b:
    lcm = (lcm * i) // gcd(lcm, i)

ans = m // (lcm * (gc // 2))
ans = (ans + 1) // 2
print(ans)

Submission status: Runtime Error

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

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

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

val = a[0]*a[1] // gcd(a[0],a[1])
for i in range(1,n-1):
    val = val*a[i+1] // gcd(val, a[i+1])
result = m//val//2
if(m//val%2 != 0):
    result = result + 1
print(result)

Submission status: Runtime Error

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

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

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

val = a[0]*a[1] // gcd(a[0],a[1])
for i in range(1,n-1):
    val = val*a[i+1] // gcd(val, a[i+1])
print(val)
result = m//val//2
if(m//val%2 != 0):
    result = result + 1
print(result)

Submission status: Runtime Error

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

num1 = a[0]
num2 = 0
while num1 % 2 == 0:
    num1 //= 2
    num2 += 1
gc = 2 ** num2

b = []
for i in a:
    if i % gc != 0 or (i // gc) % 2 == 0:
        print(0)
        exit()
    else:
        b.append(i // gc)

from math import gcd
lcm = 1
for i in b:
    lcm = (lcm * i) // gcd(lcm, i)

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

Submission status: Runtime Error

Solution code:
from math import gcd
n,m = map(int,input().split())
a = list(map(lambda x: int(x)//2,input().split()))
def lcm(x,y):
    return x*y//gcd(x,y)
T = 1
for i in range(n):
    T = lcm(T,a[i])
ans=-(-(m//T)//2)
c=T
print(ans)

Submission status: Runtime Error

Solution code:
from math import gcd
lcm = 1
def p2(m):
    cnt = 0
    n = m
    while 1:
        if n%2 == 0:
            cnt += 1
            n = n//2
        else:
            break
    return cnt
pp = p2(aa[0])
for a in aa:
    lcm = a * lcm // gcd(a, lcm)
    if pp != p2(a):
        lcm = 10 **18
        break
tmp = lcm // 2
print((m // tmp + 1) // 2)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
aa = list(map(int, input().split()))
from math import gcd
lcm = 1
for a in aa:
    lcm = a * lcm // gcd(a, lcm)
tmp = lcm // 2
print((m // tmp + 1) // 2)

Submission status: Runtime Error

Solution code:
from functools import reduce
from math import gcd

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

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

n = reduce(lcm, [v // 2 for v in A])
print(-(-(M // n) // 2))

Submission status: Runtime Error

Solution code:
from collections import deque

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

s=set(l)
l=set(l)
a1=l.pop()
a2=l.pop()
g=gcd(a1,a2)
lcm=g*(a1/g)*(a2/g)
d=1

while l:
  a=l.pop()
  d=gcd(lcm,a)
  lcm=d*(a/d)*(lcm/d)
  

if lcm>m:
  print(0)
  exit()
  
for a in s:
  if (lcm/a)%2==0:
    print(0)
    break
else:
  if (m//lcm)%2==0:
    print(int((m//lcm)/2))
  else:
    print(int((m//lcm+1)/2))

Submission status: Runtime Error

Solution code:
from collections import deque

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

l=set(l)
a1=l.pop()
a2=l.pop()
g=gcd(a1,a2)
lcm=g*(a1/g)*(a2/g)
d=1

while l:
  a=l.pop()
  d=gcd(lcm,a)
  lcm=d*(a/d)*(lcm/d)
  

if lcm>m:
  print(0)
  exit()
for a in l:
  if (lcm/a)%2==0:
    print(0)
    break
else:
  if (m//lcm)%2==0:
    print(int((m//lcm)/2))
  else:
    print(int((m//lcm+1)/2))

Submission status: Runtime Error

Solution code:
from collections import deque

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

l=set(l)
a1=l.pop()
a2=l.pop()
g=gcd(a1,a2)
lcm=g*(a1/g)*(a2/g)
d=1

while l:
  a=l.pop()
  d=gcd(lcm,a)
  lcm=d*(a/d)*(g/d)
  

if lcm>m:
  print(0)
  exit()
for a in l:
  if (lcm/a)%2==0:
    print(0)
    break
else:
  if (m//lcm)%2==0:
    print(int((m//lcm)/2))
  else:
    print(int((m//lcm+1)/2))

Submission status: Runtime Error

Solution code:
from collections import deque

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

l=set(l)
a1=l.pop()
a2=l.pop()
g=gcd(a1,a2)
lcm=g*(a1/g)*(a2/g)
d=1

while l:
  a=l.pop()
  d=gcd(lcm,a)
  lcm=d*(a/d)*(g/d)
  g=lcm
  

if lcm>m:
  print(0)
  exit()
for a in l:
  if (lcm/a)%2==0:
    print(0)
    break
else:
  if (m//lcm)%2==0:
    print(int((m//lcm)/2))
  else:
    print(int((m//lcm+1)/2))

Submission status: Runtime Error

Solution code:
from collections import deque

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

l=set(l)
a1=l.pop()
a2=l.pop()
g=gcd(a1,a2)
lcm=g*(a1/g)*(a2/g)
d=1
while l:
  a=l.pop()
  d=gcd(g,a)
  lcm=d*(a/d)*(g/d)
  g=lcm
  

if lcm>m:
  print(0)
  exit()
for a in l:
  if (lcm/a)%2==0:
    print(0)
    break
else:
  if (m//lcm)%2==0:
    print(int((m//lcm)/2))
  else:
    print(int((m//lcm+1)/2))

Submission status: Runtime Error

Solution code:
from collections import deque

n,m=map(int,input().split())
l=list(map(int,input().split()))
l=[i/2 for i in l]
if n==1:
  if (m//l[0])%2==0:
    print(int((m//l[0])/2))
  else:
    print(int((m//l[0]+1)/2))

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

l=set(l)
a1=l.pop()
a2=l.pop()
g=gcd(a1,a2)
lcm=g*(a1/g)*(a2/g)
d=1
while l:
  a=s.pop()
  d=gcd(g,a)
  lcm=d*(a/d)*(g/d)
  g=lcm
  

if lcm>m:
  print(0)
  exit()
for a in l:
  if (lcm/a)%2==0:
    print(0)
    break
else:
  if (m//lcm)%2==0:
    print(int((m//lcm)/2))
  else:
    print(int((m//lcm+1)/2))

Submission status: Runtime Error

Solution code:
from collections import deque

n,m=map(int,input().split())
l=list(map(int,input().split()))
l=[i/2 for i in l]
def gcd(a,b):
  while b!=0:
    a,b=b,a%b
  return a

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

if lcm>m:
  print(0)
  exit()
for a in l:
  if (lcm/a)%2==0:
    print(0)
    break
else:
  if (m//lcm)%2==0:
    print(int((m//lcm)/2))
  else:
    print(int((m//lcm+1)/2))