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:
# ABC150 D
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))
from fractions import gcd
def lcm(x, y):
    """
    xとyの最小公倍数を求める。

    Parameters
    ----------
    x,y : int
        自然数

    Returns
    -------
        最小公倍数：int

    """
    return (x * y) // gcd(x, y)
n,m=nm()
a=nl()
b=[]
lc=[]

# for i in range(n):
#     b.append(a[i]//2)
# print(a)
for i in range(n):
    a[i]//=2
# print(a)
t=0
for i in range(n-1):
    if i==0:
        t=lcm(a[i],a[i+1])
        lc.append(t)
    elif i!=0:
        t=lcm(lc[i-1],a[i+1])
        # t=min(lc[i-1],t)
        lc.append(t)
# print(lc)
# print(max(a))
# ans=(m-max(a)//max(lc))//2
ans=0
ans=(m+max(a))//max(lc)
if ans%2==1:
    ans//=2
    ans+=1
else:
    ans//=2
print(ans)

Submission status: Runtime Error

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

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

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

alcm = A[0]
for i in A[1:]:
  alcm = lcm(alcm, i)

B = int(alcm/2)

y = M//B
if y%2==1:
    y+=1
print(int(y/2))

Submission status: Runtime Error

Solution code:
import sys #追加
sys.setrecursionlimit(10**9)

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

bl = [i//2 for i in al]
from fractions import gcd
ans = 1
for b in bl:
   ans = (ans * b) // gcd(ans, b)

import numpy as np
print(ans, al)
al = ans % (np.array(al) / 2)
if any(al):
   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:
from fractions import gcd
from math import ceil
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=len(bin(a[0]))-bin(a[0]).rfind("1")
for i in range(1,n):
  if c!=len(bin(a[i+1]))-bin(a[i+1]).rfind("1"):
    print(0)
    exit()
g=a[0]
for i in range(n-1):
   g=(g//gcd(g,a[i+1]))*(a[i+1]//gcd(g,a[i+1]))*gcd(g,a[i+1])
g//=2
print(ceil((m//g)/2))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce,lru_cache

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

@lru_cache(maxsize=1000)
def lcm(numbers):
    return reduce(lcm_base, numbers, 1)

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



A = [int(i/2) for i in A]

flag = False
oe = A[0]%2
for i in A:
    if i%2 != oe:
        flag = True
        
if flag:
    print(0)
else:
    this_lcm = lcm(A)
    
    if this_lcm > m:
        print(0)
    else:
        print(math.floor((m-this_lcm)/(2*this_lcm))+1)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math
import numpy as np

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

a = list(set(a))
a = sorted(a)
#print(a)

#最小公倍数
ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // math.gcd(ans, a[i])
#print(ans)

count = 0
while(True):
    if (count+0.5)*ans > m:
        break
    else:
        count += 1
print(count)

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000)
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [ai // 2 for ai in a]
b.sort(reverse = True)
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
def lcm(a, b):
    return a * b // max(1, gcd(a, b))
LCM = lcm(b[0], b[1])
for bi in b:
    LCM = lcm(LCM, bi)
if LCM % 2:
    print(((m // LCM) + 1) // 2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
import math

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(lambda x: int(x), input().split())
a = input().split()
a = [int(_)/2 for _ in a]
gcd = lcm_list(a)
log = int(math.log(m, gcd))
nums = 2**n
count = (log-1)*nums

if log == 0:
  print(0)
elif gcd in a:
  print(round(int(m/2)/gcd))

Submission status: Runtime Error

Solution code:
import math
import fractions


N, M = map(int, input().split())
a_i = list(map(int, input().split()))
half_a_i = []

for i in a_i:
    i //= 2
    half_a_i.append(i)

lcm = half_a_i[0]

for i in range(1, N):
    lcm = lcm * half_a_i[i] // math.gcd(lcm, half_a_i[i])

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

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 = set(list(map(int, input().split())))

c = 0
lcm_num = lcm(*a)
m = lcm_num /2
ans = M // m
for i in a:
  if ans % i ==0:
    ans = 0
    break

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

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce

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

for i in range(n):
    a[i]=a[i]//2
a=set(a)
a=list(a)
b=1
for i in range(len(a)):
    b*=a[i]
c=reduce(fractions.gcd,a)
b//=(c**(len(a)-1))

for i in range(len(a)):
    if b//a[i]//2==b//a[i]/2:
        m=0
        break
if m//b//2==m//b/2:
    print(m//b//2)
else:
    print(m//b//2+1)

Submission status: Runtime Error

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

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

n,m = map(int,input().split())
a = [int(i) for i in input().split()]
na = [i*0.5 for i in a]
l = 1
for i in range(n):
    l = lcm(l,na[i])

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

Submission status: Runtime Error

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



b = [i//2 for i in a]
c = np.gcd.reduce(b)

if c > m:
    print(0)
else:
    d = m // c
    if d % 2 == 0:
        ans = d//2
    else :
        ans = d//2 + 1
    print(ans)

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
// マクロ
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
// 型エイリアス
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;
using vvi = vector<vi>;
using vvs = vector<vs>;
ll gcd(ll a,ll b){
if(b == 0) return a;
return gcd(b,a%b);
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}


int main() {
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    ll ans = 1;
    rep(i,n) {
        ll T;
        ans = lcm(ans, a[i]);
    }
    ans /= 2;
    if(ans == 1) {
        cout << 0 << endl;
        return 0;
    }
    ll result = 0;
    for(int i = 1; i <= m/ans ; i+= 2){
        if(ans * i > m) break;
        else {
            result++;
        }
    }
    cout << result << endl;
}

Submission status: Runtime Error

Solution code:
import fractions

n, m = map(int, input().split())
a = list(map(int, input().split()))
def gcd(x, y):
    if y == 0:
        return x
    else:
        return gcd(y, x % y)

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

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

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

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

Submission status: Runtime Error

Solution code:
import math
import fractions

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

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

ans = (k*2)//gc

for i range (1,ans):
    if (gc * i) % 2 == 0:
        ans -= 1

print(ans)

Submission status: Runtime Error

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

import math
ans = a[0]
for i in range(1,n):
    ans = ans * a[i] // math.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] // math.gcd(ans2, b[i])


if ans2>m:
    print(000)
else:
    print((m-ans2)//ans+1)

Submission status: Runtime Error

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

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


for i in range(1,10):
    flag1=True
    for j in a:
        if (-1+(ans*i/j))%2==1:
            flag1==False
    
    
    if flag1:
        c=ans*i
        break

    
    if ans*i>m:
        c=0
        break


if c==0:
    print(0)
else:
    cans=m//c
    if cans%2==0:
        print(cans//2)
    else:
        cans=(cans+1)//2
        print(cans)

Submission status: Runtime Error

Solution code:
import fractions

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

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
  
k=1
for a in A:
  k=lcm(k,a)

k/=2
  
if k<min(A):
  k*=2*1.5
print(int(M//k//2+M//k%2))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

N, M = map(int, input().split(" "))

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

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

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

s = lcm(*a)

if s > M:
    print(0)

else:
    m = s // 2
    print((M-m)//s + 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:
        a, b = b, a % b
    return a

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

f = lcm(a[0], a[1])
for i in range(2, N):
    f = lcm(f, a[i])

if 1 <= f//2 <= M:
    print((M-f//2)//f + 1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
import functools

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

sums = 0
flag = True

for a in A:
  if a%2!=0:
    print(0)
    exit(0)

for m in range(M):
  for a in A:
    if (m+a//2)%a != 0:
      flag = False
      break 
  
  if flag==True:
    first = m
    break
  else:
    if m==M-1:
      print(0)
      exit(0)
    flag = True


#gcd
g = functools.reduce(lambda x,y:x*y//math.gcd(x,y),A,1)
print(((M-first))//g +1)

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:
    print( 1 + (M - max(lcmA//2, min(A) * 0.5))//lcmA)

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)

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



A = [int(i/2) for i in A]

flag = False
oe = A[0]%2
for i in A:
    if i%2 != oe:
        flag = True
        
if flag:
    print(0)
else:
    this_lcm = lcm(A)
    
    if this_lcm > m:
        print(0)
    else:
        print(math.floor((m-this_lcm)/(2*this_lcm))+1)

Submission status: Runtime Error

Solution code:
import fractions as f
from functools import reduce

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

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

saibai = int(lcm_list(a) / 2)

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**6)

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())
AA = list(map(int, input().split()))
A = list(map(lambda x:x//2, AA))

ans = lcm(*A)
ans = (M//lcm(*A) - 1)//2 + 1 if ans > 0 else 0
print(ans)

Submission status: Runtime Error

Solution code:
public class Main {

    public static void main(String[] args)  {
        System.out.println(0);
    }
}

Submission status: Runtime Error

Solution code:
from fractions import gcd
#from math import gcd
from functools import reduce

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

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

lcmA = reduce(lcm, A)
if M < lcmA//2:
    print(0)
else:
    print( 1 + (M - max(lcmA//2, min(A) * 0.5))//lcmA)

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
import math
import numpy as np

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

a = list(set(a))
a = sorted(a)
#print(a)

#最小公倍数
ans = a[0]
for i in range(1, len(a)):
    ans = ans * a[i] // math.gcd(ans, a[i])
#print(ans)

max_m = m + ans//2

print(max_m//ans)

Submission status: Runtime Error

Solution code:
import fractions
import math
n, m = map(int, input().split())
a = set(map(int, input().split()))
lcm = 1
for ai in a:
  lcm = (lcm * ai) // fractions.gcd(lcm, ai)
print(int((m+lcm/2) // lcm))

Submission status: Runtime Error

Solution code:
from math import gcd

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

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

l = lcm(ai) // 2
i = m // l
if i == 0:
    print(0)
    exit()
if i == 1:
    print(1)
    exit()
ans = int(bin(i)[:-1], 2) + 1

print(ans)

Submission status: Runtime Error

Solution code:
import sys
import math
from functools import reduce

N, M = map(int, input().split(" "))

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

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

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

s = lcm(*a)

if s > M:
    print(0)

else:
    m = s // 2
    print((M-m)//s + 1)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
a = list(map(int, input().split()))
import math
ans = a[0]
for i in range(1,n):
    ans = ans * a[i] // math.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] // math.gcd(ans2, b[i])


if ans2>m:
    print(0)
else:
    print((m-ans2)//ans+1)

Submission status: Runtime Error

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

def get_lcm(a, b):
    return a * b // get_gcd(a, b)


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

B = A[0]

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

Submission status: Runtime Error

Solution code:
import numpy as np

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

    lst = None

    for a in A:
        if a % 2 == 0:
            p = M // a
            Xs = (np.arange(p) + 0.5) * a
            if lst is None:
                lst = Xs
            else:
                lst = np.intersect1d(lst, Xs)
        else:
            pass

    print(len(lst))


if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
from functools import reduce
import fractions


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


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


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


lcm_ans = lcm_list(a)
if lcm_ans % 2 == 0:
    if lcm_ans * (m // lcm_ans + 0.5) <= m:
        print(m // lcm_ans + 1)
    else:
        print(m // lcm_ans)
else:
    print(0)

Submission status: Runtime Error

Solution code:
def gcd(a,b):
    if b == 0: 
        return a
    return gcd(b, a % b)
def lcm(a,n,m):
    ans = a[0]
    for i in range(1,n):
        ans = (ans * a[i])/(gcd(a[i],ans))
    return ans
n,m = map(int,input().split())
a = list( map(int,input().split()) )
l = lcm(a,n,m)


start = l//2
# print(start)
ans = (m - (start))/l
# print(ans)
if ans < 0 :
    print(0)
else:
    ans += 1
    print( round(ans) )

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)


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

L = lcm(A)

a = int(M / L)
b = int(M / (L/2))
print(b-a)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import math
from functools import reduce
flgk=False
flgg=False
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)
    if A2[i]%2==0:
        flgg=True
    else:
        flgk=True

l=lcm_list(A2)

ans=M//l

if flgk and flgg:
    print(0)
else:
    if ans%2==1:
        print(max(ans//2+1,0))
    else:
        print(max(ans//2,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())))
A = A // 2
v = np.lcm.reduce(A)

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

Submission status: Runtime Error

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

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

n,m = map(int,input().split())
a = [int(i) for i in input().split()]
na = [i*0.5 for i in a]
l = 1
for i in range(n):
    l = lcm(l,na[i])

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(1000000)
n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [ai // 2 for ai in a]
b.sort()
def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
def lcm(a, b):
    return a * b // gcd(a, b)
LCM = lcm(b[0], b[1])
for bi in b:
    LCM = lcm(LCM, bi)
if LCM % 2:
    print(((m // LCM) + 1) // 2)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
i=list(map(int,input().split()))
j=list(map(int,input().split()))
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
xx=lcm(*j)
p=i[1]//(xx/2)
if p%2==1:
  a=int(p//2+1)
else:
  a=int(p//2)
print(str(a))

Submission status: Runtime Error

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

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


for i in range(1,10**9+1):
    flag1=True
    for j in a:
        if (-1+(ans*i/j))%2==1:
            flag1==False
    
    
    if flag1:
        c=ans*i
        break

    
    if ans*i>m:
        c=0
        break


if c==0:
    print(0)
else:
    cans=m//c
    if cans%2==0:
        print(cans//2)
    else:
        cans=(cans+1)//2
        print(cans)

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_i = list(map(int, input().split()))
half_a_i = []

for i in a_i:
    i //= 2
    half_a_i.append(i)


if (M // lcm_list(half_a_i)) == 0:
    print(0)
else:
    print(((M // lcm_list(half_a_i)) // 2) + 1)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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

b_odd = [i for i in b if (i % 2 == 1)]
b_even = [i for i in b if (i % 2 == 0)]

if b_even == []:
    # b の最小公倍数を求める
    L = b_odd[0]
    for i in range(1, len(b_odd)):
        L = L * b_odd[i] // gcd(L, b_odd[i])
    print(M//L - M//(2*L))
else:
    # b_odd の最小公倍数を求める
    L_odd = b_odd[0]
    for i in range(1, len(b_odd)):
        L_odd = L_odd * b_odd[i] // gcd(L_odd, b_odd[i])
    # 1 ~ M の中で (L_odd*奇数) と表せる数字の個数が答えの候補
    # (L_oddの倍数の個数) - (2L_oddの倍数の個数)と考える
    tmp = M//L_odd - M//(2*L_odd)
    # つまり L_odd*1, L_odd*3, ..., L_odd*tmp が解答の候補
    # よって候補に対して検証を行う
    ans = 0
    res = [L_odd * i for i in range(1, tmp, 2)]
    for r in res:
        flag = 0
        for bi in b_even:
            if (r // bi) % 2 == 0:
                flag = 1
        if flag == 0:
            ans += 1
    print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import math
nm = list(map(int,input().split()))
a = list(map(int, input().split()))
ans = a[0]
for i in range(1, nm[0]):
    ans = ans * a[i] // fractions.gcd(ans, a[i])
key = ans / 2
start = max([max(a)*3/2, nm[0]])

hidari = math.ceil(start/key) + (1 - (math.ceil(start/key) % 2))
migi = math.floor(nm[1]/key) - (1 - (math.floor(nm[1]/key) % 2))

print(migi)
print(hidari)

print(int((migi-hidari) / 2 + 1))

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)
    max_A = max(A)
    cnt = M // common
    if (cnt + 0.5) * common <= M:
        if max_A * 0.5 <= common * 0.5:
            print(cnt + 1)
        else:
            print(cnt)
    else:
        if max_A * 0.5 <= common * 0.5:
            print(cnt)
        else:
            print(cnt - 1)

if __name__ == "__main__":
    main()

Submission status: Runtime Error

Solution code:
import fractions
 
N, M = map(int, input().split())
a = list(map(int, input().split()))
 
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
 
f = lcm(a[0], a[1])
for i in range(2, N):
    f = lcm(f, a[i])
 
if 1 <= f//2 <= M:
    print((M-f//2)//f + 1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
#s=[int(i) for i in input().split()]
import fractions

n,m=[int(i) for i in input().split()]
l=[int(i) for i in input().split()]

g=(l[0]*l[1])//fractions.gcd(l[0],l[1])
if n>2:
  for i in range(2,n):
    g=(g*l[i])//fractions.gcd(g,l[i])

gg=[]    
cnt=1
while True:
  g2=g*cnt//2
  if g2<=m:
    cnt+=1
    if g2%10==5:
      gg.append(g2)
  else:
    break
print(len(gg))

Submission status: Runtime Error

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

##最大公約数を求める

def gcd(a, b) :
  if(b==0) :
    return a
  else :
    return gcd(b, a%b)
   
##最小公倍数を求める
def lcm(a, b) :
  return a * b / gcd(a, b)
  
##複数個の整数の最小公倍数を求める
def lcm_multi(l) :
  if(len(l) < 2) :
    return l[0]
  res = lcm(l[0], l[1])
  
  for i in range(2, N) :
    res = lcm(l[i], res)
    
  return res

ans = 0
lcm_m = lcm_multi(list_a)
if(M-lcm_m/2 < 0) :
  print(0)
else :
  print(int((M-lcm_m/2) / lcm_m) + 1)

Submission status: Runtime Error

Solution code:
from math import ceil

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

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

common = A[0] // 2
for i in range(len(A)):
  A[i] //= 2
  if A[i] % 2 == 0:
    print(0)
    break
  if i == 0:
    common = gcd(common, A[i])
else:
  mult = A[0] // 2
  for i in range(1,len(A)):
    mult *= A[i] // common
  print(ceil((M // mult) / 2))

Submission status: Runtime Error

Solution code:
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int N, M, lcm;
		N = in.nextInt();
		M = in.nextInt();
		lcm = 1;
		for (int i = 0; i < N; i++)
		{
			int temp = in.nextInt();
			int gcd = 1;
			for (int j = 1; j <= temp && j <= lcm; ++j)
			{
				if(temp % j == 0 && lcm % j == 0)
              	{
					gcd = j;
                }
			}
			
			lcm = (temp * lcm) / gcd;
		}
		lcm /= 2;
		System.out.println(M/lcm - M/(lcm*2));
      	
      	in.close();
	}
}

Submission status: Runtime Error

Solution code:
import sys
from fractions import gcd
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input():
    return sys.stdin.readline().rstrip()

def main():
    N,M=map(int,input().split())
    a=tuple(map(int,input().split()))
    for x in a:
        if x%2:
            raise Exception
    print(0)

        

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
import functools

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

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

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


a_lcm = lcm_list(A_n)
ans = 0

interval = a_lcm//2

for i in range(interval,M+1,interval):
    #print(i)
    if i%2 == 1:
        ans += 1
print(ans)

Submission status: Runtime Error

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

import math
nm=list(map(int,input().split()))
a=list(map(int,input().split()))
lcm1=a[0]
for i in range(nm[0]-1):
    lcm1=lcm(lcm1, a[i+1])
answer=(nm[1]/lcm1-0.5)//1+1
print(int(answer))

Submission status: Runtime Error

Solution code:
# from functools import reduce
import numpy as np
# def gcd(m, n):
#     r = m % n
#     return gcd(n, r) if r else n
# def lcm(x, y):
#     return (x*y) // gcd(x, y)
# def gcds(X):
#     return reduce(gcd, X)
# def lcms(X):
#     return reduce(lcm, X, 1)

N, M = [int(i) for i in input().split()]
X = np.array([int(i) for i in input().split()])
g = np.gcd.reduce(X)

if any((X//g) % 2 == 0):
    print(0)
    quit()

print(int(np.round(M / np.lcm.reduce(X))))

Submission status: Runtime Error

Solution code:
import sys, math
from functools import reduce
import numpy as np

ip = sys.stdin.readline

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, ip().rstrip().split())
a = np.array(list(map(int, ip().rstrip().split())), dtype=np.int)

g, l = gcd_list(a), lcm_list(a)

if sum(a / g % 2) == N:
    if l/2 <= M:
        print(int((M-l/2)//l) + 1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
import math

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(lambda x: int(x), input().split())
a = input().split()
a = [int(_)/2 for _ in a]
gcd = lcm_list(a)
log = int(math.log(m, gcd))

if log == 0:
  print(0)

Submission status: Runtime Error

Solution code:
import math as m
import fractions as f
import functools as ft

N, M = map(int, input().split())
a = set([int(i) for i in input().split()])
cout = 0
for i in a:
    if cout == 0:
        gcd = i
        lcm = i
    else:
        gcd = f.gcd(gcd, i)
        lcm = lcm * i // f.gcd(lcm, i)
    cout += 1
if M - lcm * 0.5 < 0:
    print(0)
else:
    print(m.ceil((M - lcm * 0.5) / lcm))

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)


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

L = lcm(A)

#M = M * 2

a = int(M / L)
b = int(M / int(L/2))
print(b-a)

Submission status: Runtime Error

Solution code:
import fractions
import math
n, m = map(int, input().split())
x = list(map(int , input().split()))

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

all_lcm = x[0]
for xi in x:
    all_lcm = lcm(all_lcm, xi)

def my_round(x, d=0):
    p = 10 ** d
    return float(math.floor((x * p) + math.copysign(0.5, x)))/p

#print( m / all_lcm )
print( round(m / all_lcm ))
#print( int(my_round(m / all_lcm)) )

Submission status: Runtime Error

Solution code:
import fractions
import math

def calc(a,b):
    f=fractions.gcd(a,b)
    f2=a*b//f
    return f2

n,m=map(int,input().split())
A=sorted(list(map(int,input().split())),reverse=True)
A=list(set(A))



before=calc(A[0],A[1])
for i in range(1,len(A)):
    before=calc(A[i],before)

if before>=m:
    print(0)
    exit()
    
print(math.ceil(m/before))

Submission status: Runtime Error

Solution code:
import fractions

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

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

f = lcm(a[0], a[1])
for i in range(2, N):
    f = lcm(f, a[i])

if 1 <= f//2 <= M:
    print((M-f//2)//f + 1)
else:
    print(0)

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())
AA = list(map(int, input().split()))
A = list(map(lambda x:x//2, AA))

ans = (M//lcm(*A) - 1)//2 + 1
ans = ans if ans>0 else 0
print(ans)