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 math

def gcd(num_list):
    if len(num_list) > 2:
        num_list_new = [math.gcd(*num_list[:2])]
        num_list_new.extend(num_list[2:])
        return gcd(num_list_new)
    elif len(num_list) == 2:
        return math.gcd(*num_list)

def lcm(num_list):
    if len(num_list) > 2:
        num_list_new = [lcm(num_list[:2])]
        num_list_new.extend(num_list[2:])
        return lcm(num_list_new)
    elif len(num_list) == 2:
        return num_list[0] * num_list[1] // math.gcd(num_list[0], num_list[1])

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

lcm_of_a = lcm(a)
count = M * 2 // lcm_of_a
if count % 2 == 0:
    print(count // 2)
else:
    print((count + 1) // 2)

Submission status: Runtime Error

Solution code:
import fractions
N,M = map(int, input().split())
A=[int(x) for x in input().split()]
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
lc=1;
for i in range(N):
    A[i]=int(A[i]/2)

for i in range(N):
    lc=lcm(lc,A[i])
lc*=2
if M%lc>=lc/2:
    print(int(M/lc)+1)
else:
    print(int(M/lc))

Submission status: Runtime Error

Solution code:
import math
n,m = map(int,input().split())
a = list(map(int,input().split()))
b = 1
c = 0
key = 1
key1 = 1
l = []
while key == 1:
    if a[0] % b == 0:
        b *= 2
        c += 1
    else:
        b //= 2
        c -= 0
        key = 0
for i in range(n):
    if a[i] % b == 0:
        if (a[i]//b) % 2 == 0:
            key1 = 0
            break
        else:
            l.append(a[i]//b)
    else:
        key1 = 0
        break
if key1 == 0 or c == 0:
    print(0)
else:
    d = l[0]
    for i in range(1,n):
        d = d* l[i]// math.gcd(d,l[i])
    d = d*b//2
    if (m//d)%2 == 0:
        print((m//d)//2)
    else:
        print((m//d)//2+1)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split(' '))
a = [i//2 for i in list(map(int,input().split(' ')))]
ans = 0
def gcd(n,m):
    if m%n == 0:
        return n
    else:
        n,m=m%n,n
        return gcd(n,m)

for i,j in zip(a[:-1],a[1:]):
    ans = i*j//gcd(i,j)

print(M//ans-M//(ans*2))

Submission status: Runtime Error

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

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

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

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

Submission status: Runtime Error

Solution code:
from math import ceil,floor

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

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

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

common = 1
for i in range(N):
  A[i] /= 2
  common = lcm(common, A[i])

if common % 2 == 0:
  print(0)
else:
  print(ceil((M // common) / 2))

Submission status: Runtime Error

Solution code:
def main():
    n, m = [int(x) for x in input().split()]
    a = [int(x) for x in input().split()]

    A = set()
    for aa in a:
        if aa == 0:
            print("0")
            return
        if not aa in A:
            A.add(aa)
    A = list(A)
    sorted(A, reverse=True)

    multi = min_multi(A[0], A[1])
    for i in range(2, len(A)):
        multi = min_multi(multi, A[i])
    print(int(m / multi) + int((m % multi) / (multi / 2)))


def min_multi(a, b):
    x = a * b
    r = a % b
    while r != 0:
        a = b
        b = r
        r = a % b
    return int(x / b)


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

def gcd(n,m):
    if m == 0:
        return n
    else:
        return gcd(m,n%m)

def lcm(n,m):
    return n*m//gcd(n,m)

n,m = LI()
a = LI()
b = [i//2 for i in a]
for i in range(n):
    if b[i] % 2 == 0:
        print(0)
        quit()

l = lcm(b[0],b[1])
for i in range(2,n):
    l = lcm(l,b[i])

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

Submission status: Runtime Error

Solution code:
from fractions import gcd
import sys
input = sys.stdin.readline

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

def main():
    _, m = map(int, input().split())
    a = list(map(int, input().split()))

    mlcm = lcm(a)

    for i in a:
        if (int(mlcm / i) % 2 == 0):
            print(0)
            return

    print(int((int(m * 2 / mlcm) + 1) / 2))

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from sys import stdin
import math

N, M = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) // 2 for x in stdin.readline().rstrip().split()]
ans = 0
g = 1

for i in range(len(A)):
    g = g * A[i] // math.gcd(g, A[i])

for i in range(len(A)):
    if (g // A[i]) % 2 == 0:
        print(0)
        exit()

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

Submission status: Runtime Error

Solution code:

from fractions import gcd
from math import ceil
from functools import reduce

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

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

def solve(N, M, A):
    num = lcm(A)
    if num > M:
        return 0
    elif num % 2 == 0:
        return M // (num*2)
    else:
        return ceil(M / (num*2))

def main():
    N, M = map(int, input().split())
    A = list(set(int(x)//2 for x in input().split()))
    ans = solve(N, M, A)
    print(ans)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import math
N,M = map(int, input().split())
A=[int(x) for x in input().split()]
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
lc=1;
for i in range(N):
    A[i]=int(A[i]/2)

for i in range(N):
    lc=lcm(lc,A[i])
lc*=2
if M%lc>=lc/2:
    print(int(M/lc)+1)
else:
    print(int(M/lc))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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)

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

p = lcm_list(a)
i = 0

i = int(m/p+0.5)

print(i)

Submission status: Runtime Error

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

from fraction import gcd
from functools import reduce

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

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

lcm = lcm_list(ahs)

result = True
for ah in ahs:
    if (lcm // ah) % 2 == 0:
        result = False
        break

if result == False:
    print(0)
else:
    print((M//lcm-1)//2 + 1)

Submission status: Runtime Error

Solution code:
import fractions

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

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

min_ans = int(gcd * 0.5)

count = (M + min_ans) // gcd

print(count)

Submission status: Runtime Error

Solution code:
def get_gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def get_lcm(a, b, gcd=0):
    if gcd == 0:
        return a * b // get_gcd(a, b)
    else:
        return a * b // gcd


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

A = list(set(A))

if sum([a % 2 != 0 for a in A]) > 0:
    print(0)
else:
    B = A[0]
    for b in A[1:]:
        B = get_lcm(B, b)
    print(int((M + 0.5 * B) // B))

Submission status: Runtime Error

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

gcd_a = reduce(fractions.gcd, a)
tmp = gcd_a

for i in a:
    tmp *= (i / gcd_a)

tmp = int(tmp)
ans = 0

left = tmp
right = m * 2
ans_hint = right // left

ans = math.ceil(ans_hint / 2)

print(ans)

Submission status: Runtime Error

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

a = list(set(a))
ans = a[0]

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

num = ans // 2
if (num == 0):
    print(M//ans)
else:
    print(M//num-M//ans)

Submission status: Runtime Error

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

a, b = A[0], A[1]
while b > 0:
  a, b = b, a%b
  
for b in A[2:]:
  while b > 0:
    a, b = b, a%b
    
A = list(set(A))
prod = 1
for _a in A:
  prod *= _a
  
CM = prod // a
SCM = CM // 2

if SCM > M:
  print(0)
else:
  print(1 + (M - SCM) // CM)

Submission status: Runtime Error

Solution code:
import fractions
n, m = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
min_mul = a[0]
ans = 0
if n == 1:
    pass
else:
    for i in range(1, n):
        min_mul *= a[i] // fractions.gcd(min_mul, a[i])
ans += m // min_mul
if (m // min_mul + 0.5) * min_mul <= m: ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

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

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

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

a_list = []

for item in a_str_list:
    a_list.append(int(item))

a_list = list(set(l))

step = lcm_list(a_list)
start = step // 2

if m - start < 0:
    print(0)
else:
    print(((m-start) // step)+1)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(set(map(int, input().split())))
# print(a)
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

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

# print(lcm(a))
lcm_num = lcm(a)
print(math.ceil((2*m)//lcm_num/2))

Submission status: Runtime Error

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

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


k = a[0]

for i in range(1, N):
    k = (a[i]*k) // fractions.gcd(a[i], k)
ans = M // k
if (k * 0.5) < M:
    ans += 1
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
a = list(map(int, input().split()))
for i in range(n):
	a[i]=a[i]//2
p = a[0]
for i in range(1, n):
    p = p * a[i] // math.gcd(p, a[i])
print(math.ceil(m//p/2))

Submission status: Runtime Error

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

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

a=list(set(a))
sa=1
for i in range(len(a)):
    sa*=a[i]
sa/=len(a)
p=m/(sa)
if p<1:
    print("0")
elif p%1==0:
    print(p)
else:
    print(int(p)+1)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

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

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

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

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


n, m = map(int, input().split())
a = list(map(int, input().split()))
flag = True
ans = 0

for i in range(n):
    a[i] /= 2
tmp = int(gcd_list(a))
#print(tmp)
for i in range(n):
    a[i] //= tmp
    a[i] = int(a[i])
    if a[i] % 2 == 0:
        flag = False

if flag:
    tmp = lcm_list(a)
    ans = (m+tmp) // (2*tmp) 
else:
    ans = 0

print(ans)

Submission status: Runtime Error

Solution code:
import math


def is_prime(n):
    if n == 1:
        return False

    for k in range(2, int(math.sqrt(n)) + 1):
        if n % k == 0:
            return False

    return True


from fractions import gcd
from functools import reduce


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


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


N, M = map(int, input().split())
lc = lcm(*tuple(map(int, input().split())))
# print(lc)
flg = True
if is_prime(lc // 2):
    flg = False
    ans = M / lc
else:
    ans = M / (lc // 2)

from decimal import Decimal, ROUND_HALF_UP
ans = Decimal(str(ans)).quantize(Decimal("0"), rounding=ROUND_HALF_UP)
# print(ans)

if lc <= M and flg:
    ans -= 1
print(int(ans))

Submission status: Runtime Error

Solution code:
import math

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

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

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

Submission status: Runtime Error

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

gcd_a = reduce(math.gcd, a)
tmp = gcd_a

for i in a:
    tmp *= (i / gcd_a)

tmp = int(tmp)
ans = 0

left = tmp
right = m * 2
ans_hint = right // left

ans = math.ceil(ans_hint / 2)

print(ans)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

n,m= map(int,input().split())
a_list = 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)

lcm_value = lcm_list(a_list)

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

Submission status: Runtime Error

Solution code:
def gcd(x, y):
    while y>0:
        x, y = y, x % y
    return x

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


N = input().split()
for a in range(len(N)):
    N[a] = int(N[a])

A = input().split()
for b in range(len(A)):
    A[b] = int(A[b])

mult = 1
for a in range(len(A)):
    mult = lcm(mult, A[a]//2)
    mult = int(mult)

space = N[1] // mult
print((space + 1) // 2)

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

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


bl = [i//2 for i in al]

ans = 1
for b in bl:
   ans = lcm(ans, b)

for a in al:
   if ans // a == ans / a:
      print(0)
      import sys
      sys.exit()

def ceil(a, b):
   return a // b + (a % b > 0)

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

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
A=a[0]
B=a[0]//2
from math import gcd
for i in range(n):
	A=A*a[i]//gcd(A,a[i])
	B=B*(a[i]//2)//gcd(B,a[i]//2)
	B//=A
m-=B
print(m//A+1)

Submission status: Runtime Error

Solution code:
import math
# -*- coding: utf-8 -*-

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

sum = 0
for i in range(m):
    counter = 0
    for k in range(len(a)):
        d = int(a[k])
        if (float(i + 1) - 0.5 * float(d)) % d == 0:
            counter += 1
    if counter == len(a):
        sum += 1

print sum

Submission status: Runtime Error

Solution code:
import sys,math,string,bisect
from itertools import *
input=sys.stdin.readline
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
S=lambda :input().strip()
def find_lcm(num1, num2): 
    if(num1>num2): 
        num = num1 
        den = num2 
    else: 
        num = num2 
        den = num1 
    rem = num % den 
    while(rem != 0): 
        num = den 
        den = rem 
        rem = num % den 
    gcd = den 
    lcm = int(int(num1 * num2)/int(gcd)) 
    return lcm

n,m=M()
l=list(map(int,input().split()))
l=list(set(l))
if(len(l)==1):
    print(math.ceil((m//l[0])/2))
else:
    d=l[0]
    for i in range(1,len(l)):
        d=math.gcd(d,l[i])
    p=1
    for i in range(len(l)):
        l[i]=l[i]//d
    x=list(set(l))
    for i in x:
        p*=i
        if(p>m):
            print(0)
            exit()
    print(math.ceil((m//p)/2))

Submission status: Runtime Error

Solution code:
int n, m;
print (n)

Submission status: Runtime Error

Solution code:
import functools
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()))
LCM=functools.reduce(lcm,A)
HLCM=LCM//2
Y=M//HLCM
if Y%2==0:
    print(Y//2)
else:
    print((Y+1)//2)

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)


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

x = lcm_list(a)
print((m-x//2)//x+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)
  
j_odds, j_even = 0, 0
for i in range(len(A)):
 A[i] = A[i]//2  
 if(A[i]%2 == 0): j_even = 1
 elif(A[i]%2 == 1): j_odds = 1

A = list(set(A))  
if(j_odds*j_even == 1):
  ans = 0
else:
  for i in range(len(A)):
    if(i != 0):
      if(i == 1):
       all_lcm = lcm(A[i-1],A[i])
      else:
        all_lcm = lcm(all_lcm,A[i])
  #print(all_lcm)   
  n = M//all_lcm
  if(n%2 == 0): ans = n//2 
  else: ans = n//2 + 1
 
print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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

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

min_ans = int(gcd * 0.5)

count = 0
for i in range(min_ans, M, gcd):
    count += 1

print(count)

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

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

N,M=map(int,input().split())
a=list(map(int,input().split()))
common=lcm_list(a)
if common//2<=M:
    print((M//(common//2))//2+1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
from math import gcd
N, M = map(int, input().split())
alist = list(map(int, input().split()))
alist = list(map(lambda x: x//2, alist))
alist = list(set(alist))

ans = alist[0]

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

print((M-ans)//(2*ans) + 1)

Submission status: Runtime Error

Solution code:
import sys
import fractions


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


if __name__ == '__main__':
    solve()

Submission status: Runtime Error

Solution code:
from math import ceil
N, M = map(int, input().split())
A = list(map(int, input().split()))
m = min(A)
A = [a // 2 for a in A]


# 最大公約数
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


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


while len(A) > 1:
    A.append(lcm(A.pop(), A.pop()))

X = A[0]
print(ceil((M // X) / 2) - int(X / m < 1))

Submission status: Runtime Error

Solution code:
def get_gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return a

def get_lcm(a, b, gcd=0):
    if gcd == 0:
        return a * b // get_gcd(a, b)
    else:
        return a * b // gcd

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

A = list(set(A))
B = A[0]

for b in A[1:]:
    B = get_lcm(B, b)

print(len(range(int(0.5*B), M+1, B)))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
import fractions

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

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

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

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

c = 0
lcm_num = lcm(*a)
if lcm_num % 2 ==0:
    m = lcm_num /2
else:
    m = lcm_num

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

Submission status: Runtime Error

Solution code:
import math

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

n,m = map(int,input().split())
a = list(map(int,input().split()))
tmplcm = 1
for i in a:
    tmplcm = lcm(tmplcm,i)


m -= tmplcm//2
ans = m // tmplcm +1
print(max(ans,0))

Submission status: Runtime Error

Solution code:
import math
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
l = 1
for i in range(len(AA)):
    l = lcm(l, AA[i])
amari = l % 2
if amari == 1:
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
from fractions import gcd
import sys
sys.setrecursionlimit(10 ** 9)

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

def llcm(a):
  if len(a) == 1:
    return a
  elif len(a) == 2:
    return lcm(a[0],a[1])
  else:
    return llcm(a[0],a[1:])
  
N,M = map(int,input().split())
A = list(map(int,input().split()))

B = set()
for a in A:
  if (a//2)%2 == 0:
    print(0)
    exit()
  else:
    B.add(a//2)

l = llcm(list(B))
#print(l)
if l > M:
  ans = 0
else:
  ans = 1+(M-l)//(2*l)
print(ans)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math
from functools import reduce

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)
    
N,M=map(int,input().split())
A=list(map(int,input().split()))
A2=[]
for i in range(N):
    A2.append(A[i]//2)

l=lcm_list(A2)

ans=M//l
if ans%2==1:
    print(max(ans//2+1,0))
else:
    print(max(ans//2,0))

Submission status: Runtime Error

Solution code:
from math import floor
N,M = map(int,input().split())
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
def prime_decomposition(n):
  i = 2
  d = {}
  while i * i <= n:
    while n % i == 0:
      n //= i
      if i not in d:
          d[i] = 0
      d[i] += 1
    i += 1
  if n > 1:
    if n not in d:
        d[n] = 1
  return d
A = list(map(int,input().split()))
n = prime_decomposition(A[0])[2]
p2 = 2**n
ans = -1
for i in range(N):
    if A[i]%p2==0:
        A[i] //= 2
    else:
        ans = 0
if ans != 0:
    l = A[0]
    for i in range(1,N):
        l = (l*A[i])//gcd(l,A[i])
    ans = floor((M/l+1)/2)
print(ans)

Submission status: Runtime Error

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

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

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

mlcm = 1
for i in a:
    mlcm = lcm(mlcm, i)

for i in a:
    if (int(mlcm / i) % 2 == 0):
        print(0)
        exit(0)

print(int((int(m * 2 / mlcm) + 1) / 2))

Submission status: Runtime Error

Solution code:
import sys
def input():
	return sys.stdin.readline()[:-1]

from fractions import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
m *= 2

if n == 1:
	print((m//a[0]+1)//2)
else:
	lcm = a[0]*a[1]//gcd(a[0], a[1])
	for i in range(2, n):
		lcm = lcm * a[i] // gcd(lcm, a[i])
		if lcm > x:
			print(0)
			sys.exit()

	divs = 0
	for x in a:
		divs += (lcm//x)%2
	if divs < n:
		print(0)
	else:
		print((m//lcm+1)//2)

Submission status: Runtime Error

Solution code:
def p_d():
    import math
    from functools import reduce
    n, m = map(int, input().split())
    *A, = map(lambda x: int(x) // 2, input().split())

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

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

    lcm = lcm_list(A)
    print((m // lcm + 1) // 2)
    
p_d()

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

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

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

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

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


n, m = map(int, input().split())
a = list(map(int, input().split()))
flag = True
for i in range(n):
    if a[i] % 2 == 1:
        flag = False
ans = 0

for i in range(n):
    a[i] /= 2
tmp = int(gcd_list(a))
for i in range(n):
    a[i] //= tmp
    a[i] = int(a[i])
    if a[i] % 2 == 0:
        flag = False

if flag:
    tmp = lcm_list(a)
    ans = (m-tmp) // (2*tmp) + 1
else:
    ans = 0

print(ans)

Submission status: Runtime Error

Solution code:
import sys,math,string,bisect
from itertools import *
input=sys.stdin.readline
from collections import deque,defaultdict
L=lambda : list(map(int,input().split()))
Ls=lambda : list(input().split())
M=lambda : map(int,input().split())
I=lambda :int(input())
S=lambda :input().strip()
def find_lcm(num1, num2): 
    if(num1>num2): 
        num = num1 
        den = num2 
    else: 
        num = num2 
        den = num1 
    rem = num % den 
    while(rem != 0): 
        num = den 
        den = rem 
        rem = num % den 
    gcd = den 
    lcm = int(int(num1 * num2)/int(gcd)) 
    return lcm

n,m=M()
l=list(map(int,input().split()))
d=l[0]
for i in range(1,n):
    d=math.gcd(d,l[i])
p=1
for i in range(n):
    l[i]=l[i]//d
x=list(set(l))
for i in x:
    p*=i
    if(p>m):
        print(0)
        exit()
print(math.ceil((m//p)/2))

Submission status: Runtime Error

Solution code:
import math
n,m=map(int,input().split())
a=[int(_) for _ in input().split()]
od=int(0)
ev=int(0)
lc=int(a[0]//2)
for i in range(1,n):
	lc=(lc*(a[i]//2))//math.gcd(lc,(a[i])//2);
	if (a[i]//2)%2:
		od+=1
	else:
		ev+=1
if ev and od:
	print(0)
else:
	ans=(m-lc)//(2*lc);
	ans+=1
	print(ans)

Submission status: Runtime Error

Solution code:
import math

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

s = 1
for i in range(len(a)):
    s *= a[i] // math.gcd(a[i], s)
    if s > m*3/2:
        print(0)
        break

print((m + s//2) // s)

Submission status: Runtime Error

Solution code:
from math import gcd
n, m = map(int, input().split())
a = list(map(int, input().split()))
if not sum(e & 1 for e in a) in [0, n]:
    print(0)
    exit(0)
lcm = 1
for e in a:
    e //= 2
    lcm = min(m + 10, (lcm * e) // gcd(lcm, e))

res = (1 + m // lcm) // 2
print(res)

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

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

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

a_list = []

for item in a_str_list:
    a_list.append(int(item))

step = lcm_list(a_list)
start = lcm_list(a_list) // 2

if m - start < 0:
    print(0)
else:
    print(((m-start) // step)+1)

Submission status: Runtime Error

Solution code:
import math
import sys

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

def f(n):
    return int(n)//2

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


tmp=1
for i in range(n):
    tmp=(tmp*a[i])//gcd(tmp,a[i])


for i in range(n):
    if (tmp/a[i])%2==0: print(0),sys.exit()

ans=m//(tmp*2)
if m%(tmp*2)>=tmp: ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

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

def main():
    N, M = map(int, input().split())
    A = list(set(map(int, input().split())))
    common = lcm_list(A)
    cnt = M // common
    if (cnt + 0.5) * common <= M:
        print(cnt + 1)
    else:
        print(cnt)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import fractions
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

n, m = map(int, input().split())
a = list(map(int, input().split()))
lcm = lcm_list(a)
count = 0
x = lcm/2
print(math.floor((m-x)/lcm+1))

Submission status: Runtime Error

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

import itertools as iter
import math
import fractions
from functools import reduce

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

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

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

N,M = nums()
A = nums()
half_lcm_A = lcm_list(A)/2

ans = 0

for i in range(1,M+1,2):

    if i * half_lcm_A > M:
        break
    ans += 1


print(ans)

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

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

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

tmp = lcm(*a)
m -= tmp//2
ans = m // tmp +1
print(max(ans,0))