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:
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
a = [A[i] // 2 for i in range(N)]
def calc_gcm(a, b):
	if a > b:
		r = a % b
		a = r
	
	while a > 0:
		r = b % a
		b = a
		a = r
	
	return b
 
def calc_lcm(a, b):
	gcm = calc_gcm(a, b)
	return a * b // gcm

lcm = 1
for i in range(len(a)):
    lcm = calc_lcm(lcm,a[i])
    if lcm > 2 * M:
        lcm = 0
        break
b = lcm
if lcm != 0:
    flag = False
else:
    flag = True

while flag == False:
    flag = True
    for i in range(N):
        if (b // a[i]) % 2 == 0:
            flag = False
    if flag == False:
        b += b
if lcm == 0:
    ans = 0
elif M >= b:
    ans = (M - b) // (2*lcm(a)) + 1
else:
    ans = 0
print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import math
n,m = map(int,input().split())
a = list(map(int, input().split()))
g = a[0]
for i in a:
    g = g * i // fractions.gcd(g,i)
if g/2 > m:
    print(0)
else:
    print((m + g // 2) // g)

Submission status: Runtime Error

Solution code:
N,M = list(map(int,input().split()))
A = list(map(int,input().split()))
a = [A[i] // 2 for i in range(N)]
def calc_gcm(a, b):
	if a > b:
		r = a % b
		a = r
	
	while a > 0:
		r = b % a
		b = a
		a = r
	
	return b
 
def calc_lcm(a, b):
	gcm = calc_gcm(a, b)
	return a * b // gcm

lcm = 1
for i in range(a):
    lcm = calc_lcm(lcm,a[i])
    if lcm > 2 * M:
        lcm = 0
        break
if lcm != 0:
    flag = False
else:
    flag = True

while flag == False:
    flag = True
    for i in range(N):
        if (b // a[i]) % 2 == 0:
            flag = False
    if flag == False:
        b += b
if lcm == 0:
    ans = 0
elif M >= b:
    ans = (M - b) // (2*lcm(a)) + 1
else:
    ans = 0
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
import fractions
lmc=a[0]
for i in range(1,n):
    lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
    if lmc>m:
        print("0")
        exit()
if i in range(n):
   if (lmc//a[i])%2==0:
      print("0")
      exit()
if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)

Submission status: Runtime Error

Solution code:
import fractions
n,m = map(int,input().split())
l = input().split()
for i in range(len(l) -1):
    lcm = (int(l[i]) * int(l[i + 1])) // fractions.gcd(int(l[i]), int(l[i + 1]))
x = m // (int(lcm)/2)
y = m // lcm
print(int(x-y))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A = list(map(int,input().split()))
import numpy as np
import math
A = np.array(A)
A = np.unique(A)
x=0
while np.all(A%2==0):
  A //= 2
  x+=1
  
if np.any(A%2==0):
  print(0)
  exit()
m = max(A)
l = np.array([0]*(m+1))
l[1]=1
for a in A:
  for i in range(3,a+1,2):
    n=0
    while a%i==0:
      a//=i
      n+=1
      
    l[i]=max(l[i],n*i)
  

k = np.cumprod(l[l>=1])[-1]*5*pow(2,x)//10
  
ans = math.ceil(M/k/2)
print(ans)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
import fractions
lmc=a[0]
for i in range(1,n):
    lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
    if lmc>m:
        print("0")
        exit()
if i in range(n):
   if (lmc//a[i])%2==0:
   print("0")
   exit()
if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
import fractions
lmc=a[0]
for i in range(1,n):
    lmc=lmc*a[i]//fractions.gcd(lmc,a[i])
    if lmc>m:
        print("0")
        exit()
if i in range(n):
   if (lmc//a[i])%2==0
   print("0")
   exit()
if (m%lmc)<lmc//2:
    print((m//lmc))
else:
    print((m//lmc)+1)

Submission status: Runtime Error

Solution code:
_,A = input(),list(map(int,input().split()))
for i in A:
  if i%2 == 1:
    print(2/0)
print("unrated")

Submission status: Runtime Error

Solution code:
import fractions
n,m = map(int,input().split())
l = input().split()
for i in range(len(l)):
    lcm = (int(l[i]) * int(l[i + 1])) // fractions.gcd(int(l[i]), int(l[i + 1]))
x = m // (int(lcm)/2)
y = m // lcm
print(int(x-y))

Submission status: Runtime Error

Solution code:
import numpy as np
import math
import functools


# 2数を受け取って最小公倍数を返す関数
def lcm(a, b):
    y = a * b / math.gcd(a, b)
    return int(y)


# 可変引数を受け取って最小公倍数を返す関数
def lcm_2(vals):
    return functools.reduce(lcm, vals)


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

a = np.array(list(map(int, input().split())))
lcm = lcm_2(a)

half_lcm = lcm / 2
ans = 0
flg = False
while True:
    if not sum((half_lcm * 2) % a):
        flg = True
        break

    half_lcm += lcm
    if half_lcm > m:
        break

if flg:
    ans = (m - half_lcm) // lcm + 1

print(int(ans))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

if len(A) == 2:
    a = lcm_base(A[0], A[1])
else:
    a = lcm_list(A)
a = a / 2

b = math.floor(M/a)

if b % 2 == 0:
    c = math.floor(b/2)
else:
    c = math.floor(b/2)+1 

print(c)

Submission status: Runtime Error

Solution code:
import fractions
n,m = map(int,input().split())
a,b = map(int,input().split())
lcm = (a * b) // fractions.gcd(a, b)
x = m // (int(lcm)/2)
y = m // lcm
print(int(x-y))

Submission status: Runtime Error

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


def lcmroop(n1, n2):
    a1 = n1
    a2 = n2
    while n1 % n2 != 0:
        x = n1 % n2
        n1 = n2
        n2 = x
    gcd = n2
    lcm = int(a1 * a2 / gcd)
    return lcm

for i in range(len(a)-1):
    if i == 0:
        lcm = lcmroop(a[i], a[i+1])
    else:
        lcm = lcmroop(lcm, a[i+1])

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

Submission status: Runtime Error

Solution code:
import fractions

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

nums.sort()
# print(nums)

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

if N == 1:
    ans = nums[0]
elif N == 2:
    ans = lcm(nums[0], nums[1])
else:
    ans = hoge(nums)
print((M * 2) // (ans) - (M * 2) // ((ans) * 2)) if (ans) <= (M * 2) else print(0)

def hoge(nums):
    ans = lcm(nums[0], nums[1])
    for i in range(2, N):
        ans = lcm(ans, i)
    return ans

Submission status: Runtime Error

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

st = set()

for i in range(1,m+1):
    if test1(st,i):
        lst = [i%x==x/2 for x in a]
        if all(lst):
            st.add(i)
            break
            
f = (((m // i) - 1) //2)
print(len(st) + f)

Submission status: Runtime Error

Solution code:
import fractions

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

lcm = int((a * b) / fractions.gcd(a, b))
x = int(m / (lcm /2 ))
y = int(m / (lcm))
print(int(x-y))

Submission status: Runtime Error

Solution code:
def lcm(arr, n):
    ans = arr[0]
    for i in range(1, n):
        ans = ((arr[i] * ans) // gcd(arr[i], ans))
    return ans

from math import gcd
n, m = [int(x) for x in input().split()]
arr = [int(x) for x in input().split()]
v = []
for x in arr:
    y = x
    cnt = 0
    while x % 2 == 0:
        x = x // 2
        cnt += 1
    v.append(cnt)
mx = max(v)
mn = min(v)
if mx != mn:
    print(0)
else:
    strt = int(lcm(arr, n)) // 2
    if strt > m:
        print(0)
    else:
        print(1 + int((m - strt)) // int((2 * strt)))

Submission status: Runtime Error

Solution code:
from fractions import gcd

n, m = map(int, raw_input().strip().split())
a = map(int, raw_input().strip().split())

flag = 0
for num in a:
    if num % 4 == 0:
        flag = 1
        break

if flag:
    print 0
    exit()

if n == 1:
    x = n / 2
    q = m / x
    ans = (q + 1) / 2
    print ans
    exit()

lcm = (a[0] * a[1]) / gcd(a[0], a[1])
for i in xrange(2, n):
    lcm = (lcm * a[i]) / gcd(lcm, a[i])

x = lcm / 2
q = m / x
ans = (q + 1) / 2
print ans

Submission status: Runtime Error

Solution code:
import fractions

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

lcm = (a * b) // fractions.gcd(a, b)
x = m // (lcm /2 )
y = m // (lcm)
print(int(x-y))

Submission status: Runtime Error

Solution code:
import fractions
n,m = map(int,input().split())
a,b = map(int,input().split())
lcm = (a * b) // fractions.gcd(a, b)
x = m // (lcm /2 )
y = m // (lcm)
print(int(x-y))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
n,m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] = a[i]//2
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
ans = lcm_list(a)
p = 0
i = 1
for i in range(m,1,-1):
    if i%ans == 0 and i //ans %2 ==1:
        break
    if i >ans:break
    
print((i )//2+1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
#D
N,M=map(int,input().split())
A=list(map(int,input().split()))
g=fractions.gcd(A[0],A[1])
for i in range(2,N):
    g=fractions.gcd(g,A[i])
print(g)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import math
n,m = map(int,input().split())
a = list(map(int, input().split()))
a = set(a)
g = 1
for i in a:
    g *= i // gcd(g,i)
if g * 0.5 > m:
    print(0)
else:
    print(math.floor((m / (g/2) + 1) / 2))

Submission status: Runtime Error

Solution code:
import fractions

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

nums.sort()
# print(nums)

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

def hoge(nums):
    ans = lcm(nums[0], nums[1])
    for i in range(2, N):
        ans = lcm(ans, i)
    return ans

if 2 <= N:
    ans = hoge(nums, ans)
    print((M * 2) // (ans) - (M * 2) // ((ans) * 2)) if (ans) <= (M * 2) else print(0)
else:
    ans = nums[0]
    print((M * 2) // (ans) - (M * 2) // ((ans) * 2)) if (ans) <= (M * 2) else print(0)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

if len(A) == 2:
    a = lcm_base(A[0], A[1])
else:
    a = lcm_list(A)
a = a / 2

b = math.floor(M/a)

if b % 2 == 0:
    c = math.floor(b/2)
else:
   c = math.floor(b/2)+1 

print(c)

Submission status: Runtime Error

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

a.sort(reverse=True)
ans = [i for i in range(max(a)//2,(m + 1)//2)]

for j in a:
    if a % 2 == 1:
        break
    n_ans = []
    for i in ans:
        if ((i / j - 0.5) % 1 == 0):
            n_ans.append(i)
    ans = n_ans[:]

print(len(ans))

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(list(map(int, input().split())))
lcm = np.lcm.reduce(a)

half_lcm = lcm / 2
ans = 0
flg = False
while True:
    if not sum((half_lcm * 2) % a):
        flg = True
        break

    half_lcm += lcm
    if half_lcm > m:
        break

if flg:
    ans = (m - half_lcm) // lcm + 1

print(int(ans))

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A = list(map(int,input().split()))
import numpy as np
import math
A = np.array(A)
A = np.unique(A)
x=0
while np.all(A%2==0):
  A //= 2
  x+=1
  
if np.any(A%2==0):
  print(0)
  exit()
m = max(A)
l = np.array([0]*(m+1))
l[1]=1
for a in A:
  for i in range(3,a+1,2):
    n=0
    while a%i==0:
      a//=i
      n+=1
      
    l[i]=max(l[i],n*i)
  

k = np.cumprod(l[l>=1])[-1]*pow(2,x)
if 1 in A:
  k/=2
  
ans = math.ceil(M/k/2)
print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

if len(A) == 2:
    a = lcm_base(A[0], A[1])
else:
    a = lcm_list(A)
a = a / 2

b = math.floor(M/a)
c = math.floor(b/2)+1

print(c)

Submission status: Runtime Error

Solution code:
import numpy as np
N, M = map(int, input().split())
A = np.array([int(i)//2 for i in input().split()])
A_min = np.min(A)

A_lcm = np.lcm.reduce(A)
x = M // A_lcm
if x % 2 != 0:
    x += 1
print(x//2)

Submission status: Runtime Error

Solution code:
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    power = lcm(power, b)

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)

Submission status: Runtime Error

Solution code:
import numpy as np
from fractions import gcd
from functools import reduce
from math import floor
  
def lcm_base(x, y):
    return (x * y) // gcd(x, y)

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

def count_bin(n):
  res = 0
  while n > 0:
    if n % 2 == 0:
      res += 1
      n = n // 2
    else:
      return res
  return res

def main():
  N ,M = map(int, input().split())
  A = list(set(list(map(int, input().split()))))
  last = count_bin(A[0])
  last_a = A[0]
  for a in A[1:]:
    target = count_bin(a)
    if target == last:
      last_a = gcd(last_a, a)
    else:
      print(0)
      exit()
  least_lcm = last_a // 2
  print(max(floor( (M - least_lcm) // lcm + 1), 0))

main()

Submission status: Runtime Error

Solution code:
import fractions

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

# nums.sort()
# print(nums)

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

ans = lcm(nums[0], nums[1])

def hoge(nums, ans):
    for i in range(2, N):
        ans = lcm(ans, i)
    return ans

if 2 < N:
    ans = hoge(nums, ans)
print((M * 2) // (ans) - (M * 2) // ((ans) * 2)) if (ans)  <= (M * 2) else print(0)

Submission status: Runtime Error

Solution code:
import numpy as np

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

a = np.array(list(map(int, input().split())))
lcm = np.lcm.reduce(a)

half_lcm = lcm / 2
ans = 0
while True:
    if not sum((half_lcm * 2) % a):
        flg = True
        break

    half_lcm += lcm
    if half_lcm > m:
        break

if flg:
    ans = (m - half_lcm) // lcm + 1

print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions
import math

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

len_a = len(a_uniq)

# find lcm
gcd_a = a_uniq[0]
for i in range(1, len_a):
    gcd_a = fractions.gcd(gcd_a, a_uniq[i])

lcm = 1
for j in range(len_a):
    lcm *= a_uniq[j]
    
lcm = lcm / gcd_a
lcm /= 2

print(math.ceil((M / lcm) / 2))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

if len(A) == 2:
    a = lcm_base(A[0], A[1])
else:
    a = lcm_list(A)
    a = a / 2

b = math.floor(M/a)
c = math.floor(b/2)+1

print(c)

Submission status: Runtime Error

Solution code:
import fractions

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

nums.sort()

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

ans = lcm(nums[0], nums[1])
def hoge(nums, ans):
    for i in range(2, N):
        ans = lcm(ans, nums[i])
    return ans

if 2 <= N:
    ans = hoge(nums, ans)
print((M * 2) // (ans) - (M * 2) // ((ans) * 2)) if (ans)  <= (M * 2) else print(0)

Submission status: Runtime Error

Solution code:
import sys
input = sys.stdin.readline #for input speed
# sys.setrecursionlimit(10**7)
from fractions import gcd
def lcm(a, b):
    return a * b // gcd(a, b)
N, M = map(int, input().split())
B = set(map(lambda x: int(x)//2, input().split()))
power = 1
for b in B:
    if b == 2:
        continue
    power = lcm(power, b//2)

mn = min(B)

mn2 = mn // 2
p2 = power // mn2

if p2 % 2 == 0:
    print(0)
    exit()
ans1 = M // mn2 // p2
ans2 = M // mn2 // (p2*2)
print(ans1-ans2)

Submission status: Runtime Error

Solution code:
import sys
import math
from fractions import Fraction
from functools import reduce
n,m=map(int,input().split())
a=list(map(int,input().split()))

halfa=[ai//2 for ai in a]

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

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

halfa_lcm=lcm_list(halfa)

for halfai in halfa:
    if((halfa_lcm//halfai)%2==0):
        print(0)
        sys.exit()

m_halfa_lcm=m/halfa_lcm
print(int(-(-m_halfa_lcm//2)))

Submission status: Runtime Error

Solution code:
n,m=map(int, input().split())
an=[int(i)//2 for i in input().split()]
ma=max(an)
count=0
q=1
mk=0
while m>=ma*q:
    for ak in an:
        if (ma*q)%ak==0 and ((ma*q)//ak)%2==1:
            mk=ma*q
        else:
            break
    q+=2
    if mk!=0
        break
print(m//mk)

Submission status: Runtime Error

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


for ele in range(0,m):
    p = (x - 0.5) / ele
    if p > 0:
        count += 1

print(count)

Submission status: Runtime Error

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from functools import reduce

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

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

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

def main():
    n, m = MAP()
    a = LIST()
    p = lcm(a)
    ans = m//p
    if p * (0.5 + ans) <= m:
        print(ans+1)
    else:
        print(ans)



if __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:

from fractionas import gcd

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

b_list = [i/2 for i in a_list]

SCM_counter = 0

LCM = b_list[0]
for i in range(N):
    LCM = (LCM * b_list[i])//gcd(LCM, b_list[i])

print(N // 2 * LCM)

Submission status: Runtime Error

Solution code:
import fractions
import math

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

len_a = len(a_uniq)

# find lcm
gcd_a = a_uniq[0]
for i in range(1, len_a):
    gcd_a = fractions.gcd(gcd_a, a_uniq[i])

lcm = 1
for j in range(len_a):
    lcm *= a_uniq[j]
    
lcm = lcm / gcd_a
lcm /= 2

print(math.floor(M / lcm) / 2)

Submission status: Runtime Error

Solution code:
def main():
    N , M = map(int , input().split())
    A = list(map(int , input().split()))
    #list_N_even = [i for i in range(2 , N*2 + 2 , 2)]
    #print (list_N_even)
    print (A)

    X = 0.0
    count_n = 0
    count_a = 0
    count_a_old = 0

    for a in A :
        count_a = int(count_a + 1)
        print ( count_a)
        exec("n_list_" + str(count_a) + " = []")
        exec("print (n_list_" + str(count_a) + ")")
        for p in range(1 , M + 1) :
            X = a * (p + 0.5)
            #print (X)
            if X > 0 and M >= X and X.is_integer() :
                count_n = count_n + 1
                exec("n_list_" + str(count_a) + ".append(" + str(X) + ")")
            elif X > M :
                count_a_old = count_a
                break
        exec("print (n_list_" + str(count_a) + ")")
    j = 0
    #new_list = []
    #print (n_list_2)
    for j in range(1 , len(A)+1) :
        print (j)
        if j != 1 :
            print("in")
            exec("print (n_list_" + str(j) + ")")
            exec("print (n_list_" + str(j-1) + ")")
            exec("new_list = list(set(n_list_" + str(j-1) + ") & set(n_list_" + str(j) + "))")
    exec("print (len(new_list))")
    #print (str(len(new_list)))



if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions

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

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

a2 = [0]*N
min_ai = min(ai)
for i in range(N):
    a2[i] = 0.5*a[i]
    if a[i]%2 != 0:
        print(0)
        break
    if a2[i]-min_ai[i] %2 != 0:
        print(0)
        break
else:
    tmp = 1
    for a2i in a2:
        tmp = lcm(tmp,a2i)
    ans = int((M//tmp)//2+1)
    ans -= 
    print(int((M//tmp)//2+1))

Submission status: Runtime Error

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

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

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

def bs(a,m,s,e):
    if a*0.5>m:
        return 0
    
    o=e//2
    while m>a*(o+0.5) or m<a*(o-0.5):
        oo=o
        if m>a*(o+0.5):
            o=(o+e)//2
        else:
            o=(o+s)//2
        if oo==o:
            o+=1
    return o

lcma=0

for i in range(n-1):
    lcma=max(lcma,lcm(a[i],a[i+1]))

o=bs(lcma,m,0,m//lcma+1)

print(o)

Submission status: Runtime Error

Solution code:
import numpy as np
N, M = map(int, input().split())
A = np.array([int(i)//2 for i in input().split()])
A_min = np.min(A)

A_lcm = np.lcm.reduce(A)
print((M / A_lcm )// 2 + 1)

Submission status: Runtime Error

Solution code:
num,max_ = map(int,input().split())
li = list(map(int,input().split()))
sorted(li, reverse = True)
aa = 1
formula = 0
ss =0

for b in range(li[0],num):#10から５０まで
  formula = b / li[0] - 0.5
  if formula.is_integer() == True:
    for a in range(li[0],num):
      formula = b / li[num] - 0.5
      if formula.is_integer() == True:
        aa += 1
        if aa == num :
          ss += 1
      else:
        break
        
    
  
print(ss)

Submission status: Runtime Error

Solution code:
import　fractions

n,m=map(int,input().split())
a = list(map(int, input().split()))
ans = a[0]
for i in range(1,n):
    ans = ans * a[i] // fractions.gcd(ans, a[i])


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

Submission status: Runtime Error

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

ma = max(A)
bases = map(lambda x : x*2, A) 

count = 0
i = 0
while True:
  v = base + ma * i
  is_half = True
  for a, b in zip(A, bases):
    if (v - b) % a != 0:
      is_half = False
      break
  if is_half:
    count += 1
  i += 1

print(count)

Submission status: Runtime Error

Solution code:
N,M = map(int,input().split())
A = list(map(int,input().split()))
B = A
List = []*N
count = 0
check = True
for k in range(0,N):
    if A[k] % 2 != 0:
        check = False
if check:
    for k in range(0,N):
        B[k] = A[k] // 2
    for p in range(0,(M-B[0])//A[0]):
        List[0].append(A[0]*p+B[0])
    for k in range(1,N):
        for p in range(0,(M-B[k])//A[k]):
            if A[k]*p+B[k] in List[k-1]:
                List[k].append(A[k]*p+B[k])        

print(len(List[N-1]))

Submission status: Runtime Error

Solution code:
import fractions

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

halfA = [i // 2 for i in A]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

num = lcm_list(halfA)
ans = M // num

print(ans)

Submission status: Runtime Error

Solution code:
import numpy as np
N, M = map(int, input().split())
A = np.array([int(i)//2 for i in input().split()])
A_min = np.min(A)

A_lcm = np.lcm.reduce(A)
print((M / A_lcm )// 2)

Submission status: Runtime Error

Solution code:
N, M = [int(n) for n in input().split()]
B = [int(n) // 2 for n in input().split()]
m = max(B)

count = 0
for k in range(N):
    for i in range(M // m):
        j = (i + 1) * m
        f = True
        if j <= B[k]:
            f = False
            break
        if j % B[k] != 0:
            f = False
            break
        pp1 = j // B[k]
        if pp1 % 2 == 0:
            f = False
            break
    if f:
        count += 1

print(count)

Submission status: Runtime Error

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

s = []
for i in range(1,a[0],2):
  if int(2*a[0]/i) == 2*a[0]/i:
    s.append(int(2*a[0]/i))
s.sort()

gcd = 0
for X in s:
  flg = 0
  for A in a:
    if int((2*A/X - 1)/2) != (2*A/X - 1)/2:
      flg = 1
  if flg == 0:
    gcd = X
    break
    
if gcd == 0:
  print(0)
  sys.exit()
  
dd = a[-1]*a[-2]/gcd

print(int(M/(a[-1]))+1)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

a = lcm_list(A)
a = a / 2

b = math.floor(M/a)
c = math.floor(b/2)+1

print(c)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

for i, a in enumerate(A):
    if i == 0:
        lcmA = a
    else:
        lcmA = int(a * lcmA / gcd(a, lcmA))

if M < lcmA//2:
    print(0)
else:
    minA = min(A)
    ans = 0
    for i in range(lcmA//2, M+1, lcmA):
        if i % 2 == 1:
            ans += 1
        elif minA < i:
            ans += 1

    print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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

halfA = [i // 2 for i in A]

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
def lcm_list(numbers):
  return reduce(lcm_base, numbers, 1)

num = lcm_list(halfA)
ans = M // num

Submission status: Runtime Error

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

array = []
n = []

for j in range(len(P)):
  n = []
  p = M / P[j] - 0.5
  for i in range(round(p)+1):
    n.append(P[j] * (i + 0.5))
  array.append(n)

a = list(set(array[0]) & set(array[1]))

print(len(a))

Submission status: Runtime Error

Solution code:
import fractions

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

max_a = max(a)

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

for i in range(m//max_a):
    flag = True
    kouho = max_a*(i+0.5)
    for j in range(n):
        if kouho/a[j] - kouho//a[j] != 0.5:
            flag = False
    if flag == True:
        min_ans = kouho*i
        break
print(int((m-min_ans)//g + 1))

Submission status: Runtime Error

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

def main():
    N, M = (int(s) for s in input().split())
    A = [int(i) for i in input().split()]

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

    # nLcm = reduce(lcm, B)
    nLcm = np.lcm(B)

    numDiv2 = [numDividableBy2(i) for i in B]

    if (max(numDiv2) - min(numDiv2)) != 0:
        print(0)
        return

    answer = int((M / nLcm - 1) * 0.5) + 1

    print(answer)


def numDividableBy2(m):
    count = 0
    numRoop = int(math.log2(m)) + 1
    value = m
    for i in range(numRoop):
        if value % 2 == 0:
            count += 1
            value = value // 2
        else:
            return count

    return count


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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
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] // math.gcd(ans, a[i])
if m // ans == 0:
    print(0)
else:
    print(m // ans + 1)

Submission status: Runtime Error

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

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

p = 0
ans = 0
while True:
    m = lcd * (p + 0.5)
    #print(p,m)
    if m > M:
        break
    if int(m) == m:
        ans += 1
    p += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
import bisect
import fractions
N ,M = list(map(int,input().split(" ")))
As = list(map(int,input().split(" ")))

temp = []

# max_div = 0
# for a in As:
#     temp = a
#     hoge = 0
#     while temp % 2 == 0:
#         temp //= 2
#         hoge += 1
#     max_div = max(max_div,hoge)

# print(max_div )
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
flag = 0
temp = 1
a = max(As)
co = 0
while a!= 0:
    if a % 2 == 0:
        a //=2
        co += 1
    else:
        break
n = 2 ** co
for a in As:
    if a % n != 0:
        print(0)
        exit(9)
    temp = lcm(temp,a//2)

if flag == 0 or flag == N:
    print(M // temp - (M//(temp * 2))  )
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math

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] // math.gcd(ans, A[i])

b=ans//2

sum = 0

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

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

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(1)][0]

a = list(set(a))

result = []

point_count = list(range(round(m / min(a))))
point_list = list(map(lambda x: x + 0.5, point_count))

a = a[:n]

for i in range(len(a)):
  result.append(list(map(lambda x: x * a[i], point_list)))
  if i == 0:
    ans = set(result[i])
  else:
    ans = set(ans) & set(result[i])

print(len(ans))