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:
#!/usr/bin/env python3
import sys
from math import gcd


def countDiv2(k):
    sum = 0
    while k // 2 == 0:
        k //= 2
        sum += 1
    return sum


def solve(N: int, M: int, a: "List[int]"):
    def lcm(a, b):
        return a * b // gcd(a, b)

    def half(n):
        return n//2
    b = list(map(half, a))
    shouldDivisable = 2**countDiv2(a[0])
    shouldNotDivisable = shouldDivisable * 2
    for i in range(1, len(a)):
        if a[i] % shouldDivisable != 0 or a[i] % shouldNotDivisable == 0:
            print(0)
            exit()
    LCM = b[0] if N == 1 else lcm(b[0], b[1])
    for i in range(2, len(b)):
        LCM = lcm(LCM, b[i])
    if M < LCM:
        print(0)
    else:
        print((M-LCM) // (2*LCM)+1)
    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: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from fractions import gcd


def solve(N: int, M: int, a: "List[int]"):
    def lcm(a, b):
        return a * b // gcd(a, b)

    def half(n):
        return n//2
    b = list(map(half, a))
    LCM = lcm(b[0], b[1])
    for i in range(2, len(b)):
        LCM = lcm(LCM, b[i])
    if M <= LCM:
        print(0)
    else:
        print((M-LCM) // (2*LCM)+1)
    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: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
from math import gcd


def solve(N: int, M: int, a: "List[int]"):
    def lcm(a, b):
        return a * b // gcd(a, b)

    def half(n):
        return n//2
    b = list(map(half, a))
    LCM = lcm(b[0], b[1])
    for i in range(2, len(b)):
        LCM = lcm(LCM, b[i])
    if M <= LCM:
        print(0)
    else:
        print((M-LCM) // (2*LCM)+1)
    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: Runtime Error

Solution code:
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(2, n + 1) :
    gcd = math.gcd(lcm, a[i])
    #lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Runtime Error

Solution code:
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(2, n + 1) :
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break
exit()
for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Runtime Error

Solution code:
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]

for i in range(1, n + 1) :
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break
exit()
for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Runtime Error

Solution code:
import math

# define
a = [0] * int(1e5 + 100)
# functions
# main

n, m = (int(s) for s in input().split())

inp = input().split()
for i in range(1, n + 1) :
    a[i] = int(inp[i - 1])

flag = False
lcm = a[1]
for i in range(1, n + 1) : 
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Runtime Error

Solution code:
import math

# define
a = [0] * int(1e5 + 10)
# functions
# main
n, m = (int(s) for s in input().split())

inp = input()
for i in range(1, n + 1) :
    a[i] = int(inp.split()[i - 1])

flag = False
lcm = a[1]
for i in range(1, n + 1) : 
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)
    if(lcm > m):
        flag = True
        break

for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Runtime Error

Solution code:
import math

# define
a = [0] * int(1e5 + 10)
# functions
# main
n, m = (int(s) for s in input().split())

inp = input()
for i in range(1, n + 1) :
    a[i] = int(inp.split()[i - 1])

lcm = a[1]
for i in range(1, n + 1) : 
    gcd = math.gcd(lcm, a[i])
    lcm = int(lcm * a[i] / gcd)

flag = False
for i in range (1, n + 1):
    if lcm / a[i] % 2 == 0 : flag = True

if flag or lcm > m : print(0)
else : print(int( (m - int(lcm / 2)) / lcm ) + 1)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
list = 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(*numbers):
    return reduce(lcm_base,numbers,1)

min = lcm(*list)
ans =0

if int(min/2)<=m:
    if all((2*(min//2)/k-1)%2==0 for k in list):
        ans += min//2
         
if ans:
    print(1+int((m-ans)/min))
    
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
list = 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(*numbers):
    return reduce(lcm_base,numbers,1)

min = lcm(*list)
ans =0

if min%2==0:
    if all((2*(min/2)/k-1)%2==0 for k in list):
        ans += min/2
        
if ans:
    print(1+int((m-ans)/min))
    
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
list = 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(*numbers):
    return reduce(lcm_base,numbers,1)

min = lcm(*list)

ans = 0
if  min/2<= m and min%2 ==0 and min%4 != 0: 
    ans += int(min/2)
    print(int((m-ans)/min)+1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
list = 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(*numbers):
    return reduce(lcm_base,numbers,1)

min = lcm(*list)

ans = 0
for i in range(int(min/2)+1):
    if all((2*i/k-1)%2==0 for k in list):
        ans += i
        break
        
if ans:
    print(1+int((m-ans)/min))
    
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
list = 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(*numbers):
    return reduce(lcm_base,numbers,1)

min = lcm(*list)

ans = 0
if  min/2<= m and min%2 ==0:
    ans += int(min/2)
    print(int((m-ans)/min)+1)
else:
    print(ans)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
list = 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(*numbers):
    return reduce(lcm_base,numbers,1)

min = lcm(*list)

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

Submission status: Runtime Error

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

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

n,m = map(int,input().split())
li = list(map(int,input().split())) 
num = 1
for a in li:
  num = lcm(a,num)
  
m -= num//2
if m < 0:
  print(0)
else:
  print(m//num+1)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
ans=0
for i in range(M):
    for k in range(N):
        if (10*i//A[i])%5==0:
            ans+=1
print(ans)

Submission status: Runtime Error

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

def lcm(a, b):
    return int(a*b / gcd(a, b))
"""
ak の2を除く公約数の組み合わせ一覧のうち、M以下のものを上げれば良い？
もしakが0が含まれると、0個
"""

l = a[0] // 2
for a_ in a[1:]:
    l = lcm(l, a_ // 2)
ans = (m // l)
if ans == 0:
    print(ans)
else:
    print(ans//2 + 1)

Submission status: Runtime Error

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

def lcm(a, b):
    return int(a*b / gcd(a, b))
"""
ak の2を除く公約数の組み合わせ一覧のうち、M以下のものを上げれば良い？
もしakが0が含まれると、0個
"""

l = a[0]
for a_ in a[1:]:
    l = lcm(l, a_)
ans = (m // l)
if ans == 0:
    print(ans)
else:
    print(ans+1)

Submission status: Runtime Error

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

def lcm(a, b):
    return int(a*b / gcd(a, b))
"""
ak の2を除く公約数の組み合わせ一覧のうち、M以下のものを上げれば良い？
もしakが0が含まれると、0個
"""

l = a[0]
for a_ in a[1:]:
    l = lcm(l, a_)
ans = (m // l)
if ans == 0:
    print(ans)
else:
    print(ans+1)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
cur == 0
if n != 1:
    while A[0]%2 == 0:
        cur += 1
        A[0] = A[0]//2
        flag = True
    for i in range(1,n):
        temp = 0
        while A[i]%2 == 0:
            temp += 1
            A[i] = A[i]//2
        if temp != cur:
            flag = False
            break
    if flag:
        g = A[0]*A[1]//(4*gcd(A[0]//2, A[1]//2))
        for i in range(2, n):
            u = g
            v = A[i]//2
            p = u*v//gcd(u,v)
            g = p
        if g <= 2*m:
            print(int((m/g-1)/2)+1)
        else:
            print(0)
    else:
        print(0)
else:
    if A[0] <= 2*m:
        print(int((2*m/A[0]-1)/2)+1)
    else:
        print(0)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
A = list(map(int,input().split()))
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)
ans = 0
g = A[0]*A[1]//(4*gcd(A[0]//2, A[1]//2))
for i in range(2, n):
    u = g
    v = A[i]//2
    p = u*v//gcd(u,v)
    g = p
if g <= m:
    print(int((m/g-1)/2)+1)
else:
    print(0)

Submission status: Runtime Error

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

a = [0]*n
a = [int(s) for s in input().split()]

a_half = [s//2 for s in a]
#print(a)

def check(x):
    while (all(c%2 == 0 for c in x)):
        x = [s//2 for s in x]
        if any(c%2 == 1 for c in x) and any(c%2 == 0 for c in x):
            return 0
        
    
    return 1

def gcd(x,y):
    #print(x,y)
    if(x%y == 0):
        #print(y)
        return y
    else:
        return gcd(y,x%y)


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

if(check(a)== 1):
    x = a_half[0]
    for i in range(1,n):
        y = a_half[i]
        x = lcm(x,y)
    if(x > m):
        print(0)
    else:
        res = int((m//x+1)//2)
        print(res)
else:
    print(0)

Submission status: Runtime Error

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

a = [0]*n
a = [int(s) for s in input().split()]

a_half = [s//2 for s in a]
#print(a)

def check(x):
    while (all(c%2 == 1 for c in x)):
        if any(c%2 == 1 for c in x):
            return 0
        x /= 2
    
    return 1

def gcd(x,y):
    #print(x,y)
    if(x%y == 0):
        #print(y)
        return y
    else:
        return gcd(y,x%y)


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

if(check(a)== 1):
    x = a_half[0]
    for i in range(1,n):
        y = a_half[i]
        x = lcm(x,y)
    if(x > m):
        print(0)
    else:
        res = int((m//x+1)//2)
        print(res)
else:
    print(0)

Submission status: Runtime Error

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

a = [0]*n
a = [int(s) for s in input().split()]

a_half = [s//2 for s in a]
#print(a)

def check(x):
    while (all(c%2 == 1 for c in x)):
        if any(c%2 == 1 for c in x):
            return 0
        x /= 2
    
    return 1

def gcd(x,y):
    #print(x,y)
    if(x%y == 0):
        #print(y)
        return y
    else:
        return gcd(y,x%y)


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

if(check(a)== 1):
    x = a_half[0]
    for i in range(1,n):
        y = a_half[i]
        x = lcm(x,y)
    
    res = int((m//x+1)//2)
    print(res)
else:
    print(0)

Submission status: Runtime Error

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

a = [0]*n
a = [int(s) for s in input().split()]

a_half = [s//2 for s in a]
#print(a)

def check(x):
    while (all(c%2 == 1 for c in x)):
        if any(c%2 == 1 for c in x):
            return 0
        x /= 2
    
    return 1

def gcd(x,y):
    #print(x,y)
    if(x%y == 0):
        #print(y)
        return y
    else:
        return gcd(y,x%y)


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

if(check(a)== 1):
    x = a_half[0]
    for i in range(1,n):
        y = a_half[i]
        x = lcm(x,y)
    
    res = (m//x+1)//2
    print(res)
else:
    print(0)

Submission status: Runtime Error

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

a = [0]*n
a = [int(s) for s in input().split()]

a_half = [s//2 for s in a]
#print(a)

def check(x):
    while (all(c%2 == 1 for c in x)):
        if any(c%2 == 1 for c in x):
            return 0
        x /= 2
    
    return 1

def gcd(x,y):
    #print(x,y)
    if(x%y == 0):
        #print(y)
        return y
    else:
        return gcd(y,x%y)


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

if(check(a)== 1):
    x = a_half[0]
    for i in range(1,n):
        y = a_half[i]
        x = lcm(x,y)
    
    if((m//x)%2==0):
        print(int(m/x)//2)
    else:
        print((int(m/x)+1)//2)
else:
    print(0)

Submission status: Runtime Error

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

a = [0]*n
a = [int(s) for s in input().split()]

a_half = [s//2 for s in a]
#print(a)

def check(x):
    while (all(c%2 == 1 for c in x)):
        if any(c%2 == 1 for c in x):
            return 0
        x /= 2
    
    return 1

def gcd(x,y):
    #print(x,y)
    if(x%y == 0):
        #print(y)
        return y
    else:
        return gcd(y,x%y)


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

if(check(a)== 1):
    x = a_half[0]
    for i in range(1,n):
        y = a_half[i]
        x = lcm(x,y)
    
    if((m//x)%2==0):
        print(int(m/x)//2)
    else:
        print((int(m/x)+1)//2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
#=============================================================================
#ABC150 D
#=============================================================================
import fractions
from functools import reduce

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

lcm = 1
for A in a:
    a//=2
    lcm *=a//fractions.gcd(lcm, a)
    if lcm>0:
        print(0)
        exit()
for A in a:
    if lcm/A==int(lcm/A):
        print(0)
        exit()

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

Submission status: Runtime Error

Solution code:
#=============================================================================
#ABC150 D
#=============================================================================
import fractions
from functools import reduce

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

lcm = a[0]//2
for i in range(1, N):
    x=a[i]//2
    lcm = lcm * x // fractions.gcd(lcm, a[i])
for A in a:
    if lcm/A==int(lcm/A):
        print(0)
        exit()

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

Submission status: Runtime Error

Solution code:
import numpy as np
n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
a = np.array(a)//2

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

x = a[0]
for k in range(1, len(a)):
    x = x * a[k] // gcd(x, a[k])
    
print(((m // x1) + 1) // 2)

Submission status: Runtime Error

Solution code:
import numpy as np
n, m = map(int, input().split())

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

ans = -1
b = [0] * n
for i in range(n):
    if a[i] % 2 != 0:
        ans = 0
        break

    else:
        b[i] = a[i] // 2


    if i == 0:
        num = format(a[i], 'b')[::-1].find('1')

    else:
        if format(a[i], 'b')[::-1].find('1') != num:

            ans = 0
            break
        else: num = format(a[i], 'b')[::-1].find('1')


if ans != 0:
    g = b[0]
    for i in range(1,n):

        g = (g*b[i]) // np.gcd(b[i],g)

    if g > m: ans = 0
    else:
        ans = 1
        g1 = g
        while 1:
            g += 2*g1
            if g > m: break
            else: ans += 1

print(ans)

Submission status: Runtime Error

Solution code:

from fractions import gcd

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

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

ans = -1
b = [0] * n
for i in range(n):
    if a[i] % 2 != 0:
        print(0)
        exit()

    else:
        b[i] = a[i] // 2


    if i == 0:
        num = format(a[i], 'b')[::-1].find('1')

    else:
        if format(a[i], 'b')[::-1].find('1') != num:

            print(0)
            exit()
        else: num = format(a[i], 'b')[::-1].find('1')




bs = b[0]
for i in range(1,n):
    bs *= b[i]
g = bs // gcd(*b)

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

ans = 1
g1 = g
while 1:
    g += 2*g1
    if g > m:
        break
    else:
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

div_num = [0 for _ in range(n)]
same = True

for i in range(n):
    tmp = a[i]
    while tmp%2 == 0:
        tmp //= 2
        div_num[i] += 1
    if div_num[0] != div_num[i]:
        same = False
        break

if same
    lcm = reduce(lambda x, y: (x*y)//fractions.gcd(x, y), a)
    print(int((m/lcm + 1)//2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

div_num = [0 for _ in range(n)]
same = True

for i in range(n):
    tmp = a[i]
    while tmp%2 == 0:
        tmp // = 2
        div_num[i] += 1
    if div_num[0] != div_num[i]:
        same = False
        break

if same
    lcm = reduce(lambda x, y: (x*y)//fractions.gcd(x, y), a)
    print(int((m/lcm + 1)//2))
else:
    print(0)

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
import sys
import fractions
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 solve(N: int, M: int, a: "List[int]"):
    g = lcm_list(a)
    if g > M:
        print(0)
    else:
        print(math.ceil(M/g))
    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: Runtime Error

Solution code:
# a/2の最小公倍数(num)を算出
# aの半公倍の数(res)を(num / M) / 2(四捨五入)とする

import fractions
from decimal import Decimal, ROUND_HALF_UP
N, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
lcm = int(a[0] / 2)
for i in range(1, N):
    lcm = int(lcm * (a[i] / 2) / fractions.gcd(lcm, int(a[i] / 2)))
print(Decimal(M / lcm / 2).quantize(Decimal('0'), rounding=ROUND_HALF_UP))

Submission status: Runtime Error

Solution code:
# a/2の最小公倍数(num)を算出
# aの半公倍の数(res)を(num / M) / 2(四捨五入)とする

import fractions
from decimal import Decimal, ROUND_HALF_UP
N, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
lcm = int(a[0] / 2)
for i in range(1, N):
    lcm = int(lcm * (a[i] / 2) / fractions.gcd(lcm, int(a[i] / 2)))
print(round(M / lcm / 2))

Submission status: Runtime Error

Solution code:
# a/2の最小公倍数(num)を算出
# aの半公倍の数(res)を(num / M) / 2(四捨五入)とする

import math
#from decimal import Decimal, ROUND_HALF_UP
N, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
lcm = int(a[0] / 2)
for i in range(1, N):
    lcm = int(lcm * (a[i] / 2) / math.gcd(lcm, int(a[i] / 2)))
#print(Decimal(M / lcm / 2).quantize(Decimal('0'), rounding=ROUND_HALF_UP))
print(round(M / lcm / 2))

Submission status: Runtime Error

Solution code:
import math
from decimal import Decimal, ROUND_HALF_UP
N, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
lcm = int(a[0] / 2)
for i in range(1, N):
    lcm = int(lcm * (a[i] / 2) / math.gcd(lcm, int(a[i] / 2)))
print(Decimal(M / lcm / 2).quantize(Decimal('0'), rounding=ROUND_HALF_UP))

Submission status: Runtime Error

Solution code:
import math
from decimal import Decimal, ROUND_HALF_UP

# a/2の最小公倍数(num)を算出
# aの半公倍の数(res)を(num // M) // 2とする
N, M = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
lcm = int(a[0] / 2)
for i in range(1, N):
    lcm = int(lcm * (a[i] / 2) / math.gcd(lcm, int(a[i] / 2)))
print(Decimal(M / lcm / 2).quantize(Decimal('0'), rounding=ROUND_HALF_UP))

Submission status: Runtime Error

Solution code:
from fractions import gcd
N, M=map(int, input().split())
A=list(map(int, input().split()))
#最上公倍数
def lcm(x, y):
  return (x * y) //gcd(x, y)
#最小半公倍数
def half_lcm(a,b):
  X=lcm(a,b)//2
  return X

S=[0]*(N-1)
now=A[0]
for i in range(1,N):
  now=lcm(now, A[i])
  S[i-1]=now
  
kobai=S[-1]
hkobai=kobai//2
print(int(1+(M-hkobai)//kobai))




#6*(2.5,7.5,12.5,17.5
#10*(1.5,4.5,7.5,10.5)
#15,45,75,105
#4 (2.5,)
#10(1,)

Submission status: Runtime Error

Solution code:
from fractions import gcd
N, M=map(int, input().split())
A=list(map(int, input().split()))
#最上公倍数
def lcm(x, y):
  return (x * y) //gcd(x, y)
#最小半公倍数
def half_lcm(a,b):
  X=lcm(a,b)//2
  return X

S=[0]*(N-1)
now=A[0]
for i in range(1,N):
  now=lcm(now, A[i])
  S[i-1]=now
  
kobai=S[-1]
hkobai=kobai//2
print(1+(M-hkobai)//kobai)




#6*(2.5,7.5,12.5,17.5
#10*(1.5,4.5,7.5,10.5)
#15,45,75,105
#4 (2.5,)
#10(1,)

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(set(a))
  
#a,bの最大公約数
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)
 
lc = lcm(a[0]/2,a[1]/2)
l = len(a)
if l >= 3:
  for i in range(2,l):
    lc = lcm(lc,a[i]/2)
#print(lc)

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
a = list(set(a))
  
#a,bの最大公約数
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)
 
lc = lcm(a[0]/2,a[1]/2)
l = len(a)
if l >= 3:
  for i in range(2,l):
    lc = lcm(lc,a[i]/2)
#print(lc)

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

Submission status: Runtime Error

Solution code:
n,m = map(int,input().split())
a = list(map(int,input().split()))
    
  
#a,bの最大公約数
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)
  
  
lc = lcm(a[0]/2,a[1]/2)
if n >= 3:
  for i in range(2,n):
    lc = lcm(lc,a[i]/2)
    
cnt = 0
odd = 1
if lc == int(lc): 
  while odd * lc <= m :
    cnt += 1
    odd += 2
print(cnt)

Submission status: Runtime Error

Solution code:
import sys
import fractions

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

if n == 1:
    A = int(input())
    print(int(m/A))
    sys.exit()

A = [int(x) for x in input().split()]

if (A[0]/2)%2 == 0:
    B = [x/2 for x in A if (x/2)%2 == 0]
else:
    B = [x/2 for x in A if (x/2)%2 == 1]

if len(A) != len(B):
    print(0)
    sys.exit()

A = list(set(A))
mx = max(A)

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

print(int(m/skbs)+1)
"""


start = int(mx/2)
ans = 0
for tm in range(start, m, 2):
    flag = 1
    for i in range(len(A)):
        if float(int(tm/A[i])) == float(tm/A[i]) - 0.5:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans = tm
        break

hkbs = 0
a1, a2 = 0, 0
for ttm in range(ans, m, ans):
    flag = 1
    for i in range(len(A)):
        if float(int(ttm/A[i])) == float(ttm/A[i]) - 0.5:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        hkbs += 1
        if hkbs == 1:
            a1 = ttm
        elif hkbs == 2:
            a2 = ttm
            break

if hkbs <= 1:
    print(hkbs)
else:
    print(int((m-ans)/(a2-a1))+1)

Submission status: Runtime Error

Solution code:
import sys
import fractions

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

if n == 1:
    A = int(input())
    print(int(m/int(A/2)))
    sys.exit()

A = [int(x) for x in input().split()]

if (A[0]/2)%2 == 0:
    B = [x/2 for x in A if (x/2)%2 == 0]
else:
    B = [x/2 for x in A if (x/2)%2 == 1]

if len(A) != len(B):
    print(0)
    sys.exit()

A = list(set(A))
mx = max(A)

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

print(int(m/skbs)+1)
"""


start = int(mx/2)
ans = 0
for tm in range(start, m, 2):
    flag = 1
    for i in range(len(A)):
        if float(int(tm/A[i])) == float(tm/A[i]) - 0.5:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans = tm
        break

hkbs = 0
a1, a2 = 0, 0
for ttm in range(ans, m, ans):
    flag = 1
    for i in range(len(A)):
        if float(int(ttm/A[i])) == float(ttm/A[i]) - 0.5:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        hkbs += 1
        if hkbs == 1:
            a1 = ttm
        elif hkbs == 2:
            a2 = ttm
            break

if hkbs <= 1:
    print(hkbs)
else:
    print(int((m-ans)/(a2-a1))+1)

Submission status: Runtime Error

Solution code:
import sys
import fractions

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

A = [int(x) for x in input().split()]

if (A[0]/2)%2 == 0:
    B = [x/2 for x in A if (x/2)%2 == 0]
else:
    B = [x/2 for x in A if (x/2)%2 == 1]

if len(A) != len(B):
    print(0)
    sys.exit()

A = list(set(A))
mx = max(A)

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

print(int(m/skbs)+1)
"""


start = int(mx/2)
ans = 0
for tm in range(start, m, 2):
    flag = 1
    for i in range(len(A)):
        if float(int(tm/A[i])) == float(tm/A[i]) - 0.5:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans = tm
        break

hkbs = 0
a1, a2 = 0, 0
for ttm in range(ans, m, ans):
    flag = 1
    for i in range(len(A)):
        if float(int(ttm/A[i])) == float(ttm/A[i]) - 0.5:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        hkbs += 1
        if hkbs == 1:
            a1 = ttm
        elif hkbs == 2:
            a2 = ttm
            break

if hkbs == 1:
    print(1)
else:
    print(int((m-ans)/(a2-a1))+1)

Submission status: Runtime Error

Solution code:
import sys
import fractions

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

A = [int(x) for x in input().split()]

if (A[0]/2)%2 == 0:
    B = [x/2 for x in A if (x/2)%2 == 0]
else:
    B = [x/2 for x in A if (x/2)%2 == 1]

if len(A) != len(B):
    print(0)
    sys.exit()

A = list(set(A))
mx = max(A)

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

print(int(m/skbs)+1)

"""
start = int(mx/2)
ans = 0
for tm in range(start, m, 2):
    flag = 1
    for i in range(len(A)):
        if float(int(tm/A[i])) == float(tm/A[i]) - 0.5:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        ans = tm
        break

hkbs = 0
for ttm in range(ans, m, ans):
    flag = 1
    for i in range(len(A)):
        if float(int(ttm/A[i])) == float(ttm/A[i]) - 0.5:
            continue
        else:
            flag = 0
            break
    if flag == 1:
        # print(ttm)
        hkbs += 1

print(hkbs)
"""

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nmm = input()
aal = input()
nm = nmm.split(' ')

n = int(nm[0])
m = int(nm[1])
als = aal.split(' ')
al = [int(n) for n in als]


halfLcm = multLcm(*al)/2

for i in al:
	if multLcm == i:
		halfLcm = halfLcm * 1.5

# print(halfLcm)

d = -(-m//halfLcm)
c = d//2 

if halfLcm > m:
   	c = 0  
        
print(int(c))