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 fractions
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=list(set(a))
n=len(a)
#print(a)
for i in range(n):
    a[i]=a[i]//2
f2=1
f=a[0]
for i in range(n):
    f=fractions.gcd(f,a[i])
for i in range(n):
    f2*=a[i]
f2=f2//(f*(n-1))
ans=0
for i in range(n):
    if f2/a[i]%2!=1:
        print(ans)
        break
else:
    ans=m//f2
    print((ans+1)//2)

Submission status: Runtime Error

Solution code:
import fractions


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


#n, m = 10, 1000000000
#a = [(i+1)*2*316 for i in range(n)]

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

gd = a[0]

for i in range(1,n):
  gd = fractions.gcd(gd, a[i])
  if (gd==1):
    break

sm = 1

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

for i in range(n):
  sm *= a[i]
  if (sm > m):
    print(0)
    exit(0)

sm //= gd
m //= sm
m -= 1
m //= 2

print(m+1)

Submission status: Runtime Error

Solution code:
from functools import reduce
import math


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)


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

if __name__ == "__main__":
    main()

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)+1
print(answer)

Submission status: Runtime Error

Solution code:
import math
from math import ceil
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()))
a = list(set(a))
mma = max(a)

flag = False
while True:
    for ai in a:
        if ai%2==1:
            flag = True
            break
    if flag:
        break
    a = list(map(lambda x:x//2, a))

for ai in a:
    if ai%2==0:
        print(0)
        exit(0)
ma = max(a)
co = lcm(*a)
coma = co//ma

ans = 0
if coma==1:
    print(ceil(M/mma))
    exit(0)
else:
    while True:
        if co > M:
            break
        co *= coma
        ans+=1
print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd
N, M = map(int, input().split())
a = list(map(int, input().split()))
k = a[0]
for i in range(1, N):
    k = (a[i]*k) // gcd(a[i], k)
ans = (M+(0.5*k)) // k

print(int(ans))

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

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

print(max(0, int((M + 0.5 * B) // B)))

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(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:
import math

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

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

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

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

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

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)
if k%2==0:
  k/=2

print(int(M//k//2+M//k%2))

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

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

print(int((M + 0.5 * B) // B))

Submission status: Runtime Error

Solution code:
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<string>
#include<vector>
#include<utility>
#include<algorithm>
#include<climits>
#include<set>
#include<map>
#include<cmath>
#include<iomanip>
#include<iterator>
#include<queue>
#include<stack>
#include<cctype>
#include<deque>
#include<time.h>
#include<bitset>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<sstream>
//by Skeef79

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

#pragma warning(disable : 4996)
#pragma comment(linker, "/STACK:16777216")
#define pb push_back
#define en '\n'
#define for0(i,n) for(int i = 0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define vec vector
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const int INF = 2000000000;
const ll LINF = 2000000000000000000;

template<typename T> void print(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cout << a[i] << ' ';
	cout << en;
}

template<typename T> void print(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
	{
		for (int j = 0; j < a[i].size(); j++)
			cout << a[i][j] << ' ';
		cout << en;
	}
}

template <typename T> void input(vector<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(deque<T>& a)
{
	for (int i = 0; i < a.size(); i++)
		cin >> a[i];
}

template<typename T> void input(vector<vector<T>>& a)
{
	for (int i = 0; i < a.size(); i++)
		for (int j = 0; j < a[i].size(); j++)
			cin >> a[i][j];
}

ull gcd(ull a, ull b)
{
	while (b)
	{
		a %= b;
		swap(a, b);
	}
	return a;
}

void solve()
{
	int n;
	cin >> n;
	ull M;
	cin >> M;

	vector<ull> a(n);
	input(a);

	set<ull> st;

	for (auto to : a)
		st.insert(to);

	ull lcm = 1;
	
	for (auto to : st)
	{
		if (st.count(to / 2))
		{
			cout << 0;
			return;
		}

		if (lcm > M)
		{
			cout << 0;
			return;
		}
		lcm = lcm * to / gcd(lcm, to);
		
		if (lcm > M)
		{
			cout << 0;
			return;
		}
	}
	
	lcm /= 2;
	cout << (M / lcm) / 2 + M / lcm % 2;

}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
#endif

	int tst = 1;
	//cin >> tst;
	while (tst--)
		solve();
}

Submission status: Runtime Error

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


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


def resolve():
    n, m = map(int, input().split())
    a = sorted(list(set(map(int, input().split()))), reversed=True)
    b = [x // 2 for x in a]
    s = b[0]
    for i in b[1:]:
        s = lcm(s, i)
        if s > m:
            print(0)
            return
    print(m // s - (m // (2 * s)))


if __name__ == '__main__':
    resolve()

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
a=set(a)
a=list(a)
b=1
for i in range(len(a)):
    b*=a[i]
c=reduce(math.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:
n,m=map(int,input().split())
a=list(map(int,input().split()))
def gcd(x,y):
    if x%y==0:
        return y
    else:
        return gcd(y,x%y)  
def lcm(x,y):
    return x*y/gcd(x,y)  
g=1
for i in range(n):
    g=lcm(g,a[i])
print(1+int((m-max(a)//2)//g))

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//2)/(sa)
if p<1:
    print("0")

else:
    print(int(p)+1)

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], 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 heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations,groupby
import sys
import bisect
import string
import math
import time
import random
def S_():
    return input()
def LS():
    return [i for i in input().split()]
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def NI(n):
    return [int(input()) for i in range(n)]
def NI_(n):
    return [int(input())-1 for i in range(n)]
def StoI():
    return [ord(i)-97 for i in input()]
def ItoS(nn):
    return chr(nn+97)
def LtoS(ls):
    return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[]
    g=[[] for i in range(n)]
    for i in range(E):
        inp=LI()
        org_inp.append(inp)
        if index==0:
            inp[0]-=1
            inp[1]-=1
        if len(inp)==2:
            a,b=inp
            g[a].append(b)
            if not Directed:
                g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp
            aa=(inp[0],inp[2])
            bb=(inp[1],inp[2])
            g[a].append(bb)
            if not Directed:
                g[b].append(aa)
    return g,org_inp
def bit_combination(k,n=2):
    rt=[]
    for tb in range(n**k):
        s=[tb//(n**bt)%n for bt in range(k)]
        rt+=[s]
    return rt
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
u_alp=string.ascii_uppercase
ts=time.time()
#sys.setrecursionlimit(10**5)
input=lambda: sys.stdin.readline().rstrip()
import fractions

def ran_input():
    import random
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0

n,m=LI()
a=sorted([int(i)//2 for i in input().split()])
b=[]
for i in range(n):
    if i==0:
        b.append(a[i])
        continue
    elif i!=b[-1]:
        b.append(a[i])
#a=LI()

'''
s=time.time()
n=10**4
b=[random.randint(10,10**8) for i in range(n)]
t=time.time()
show(t-s)
'''

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

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

fl=False
for i in b:
    t=lcm//i
    if t%2==0:
        fl=True
    
if lcm%2==0 and fl:
    ans=0
    
    
print(ans)

Submission status: Runtime Error

Solution code:
import math
n,m = list(map(int,input().split()))
a = list(map(int,input().split()))
cnt = 0
lcm = 1
for i in range(n):
    a[i]//=2
    lcm = lcm*a[i]//math.gcd(lcm,a[i])
c = [0]*n
flag = False
for i in range(n):
    while a[i]%2==0:
        a[i]//=2
        c[i]+=1
    for j in range(i):
        if c[i]!=c[j]:
            flag = True
            break
if flag:
    print(0)
else:
    tmp = m//lcm
    print((tmp+1)//2)

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)
def calc_half(n):
  return int(n/2)

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

saibai = lcm_list(a)
saibai = saibai/2

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 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)
m = lcm_num /2
ans = M // m
for i in a:
  if ans % i ==0:
    ans = 0

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

Submission status: Runtime Error

Solution code:
import numpy

n, m = map(int, input().split())
a = list(map(int, input().split()))
ahalf = [i//2 for i in a]

lcm = numpy.lcm.reduce(ahalf)

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

Submission status: Runtime Error

Solution code:
import math

def lcm(p,q):
    return p*q//math.gcd(p,q)
n,m = map(int, input().split())
a = list(map(int, input().split()))
x = 1
for i in range(n):
    a[i] = a[i]//2
    x = lcm(x,a[i])
p = m//x
if p%2==0:
    ans = p//2
else:
    ans = p//2 +1
print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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] // fractions.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 numpy

def lcm(x, y):
    return x * y // gcd(x, y)
def gcd(x, y):
    if y == 0:
        return x
    return gcd(y, x % y)

def twos(x):
    m = 16
    ret = 0
    while True:
        if x % (1 << m) == 0:
            x = x >> m
            ret += m
        if m == 0:
            break
        m = m >> 1
    return ret

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

# check
p = twos(a[0])
for x in a:
    if twos(x) != p:
        print(0)
        exit()

a = a // 2
l = numpy.lcm.reduce(a)

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

Submission status: Runtime Error

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

from math import gcd

l = 1
for i in range(n):
    a[i] //= 2
    l = l * a[i] // gcd(l, a[i])
    if l > 1000000000:
        print(0)
        exit()


ans = m // l
print(ans // 2 + ans % 2)

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
A=list(map(int,input().split()))
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
ans=1  
for i in range(n):
  ans = lcm(ans,A[i]//2)
if ans > m:
    print(0)
else:
    print((m//ans)//2+1)

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

a.sort()

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

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

tmp = a[0]/2

for i in range(n-1):
    tmp = lcm(int(a[i+1]/2), tmp)


ans =  int(((m/(2*tmp))-0.5))+1

print(ans)

Submission status: Runtime Error

Solution code:
from fractions import gcd

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


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


lcm = calc_lcm(A)
half_lcm = int(lcm / 2)
print((m // half_lcm) - (m // lcm))

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)
def calc_half(n):
  return int(n/2)

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

saibai = lcm_list(a)
saibai = saibai/2

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

Submission status: Runtime Error

Solution code:
import fractions
def main():
    N, M = map(int, input().split())
    a = tuple(map(int, input().split()))
    s = a[0]
    s2 = max(a)
    s3 = 0
    while True:
        if s2 % 2 == 0:
            s2 /= 2
            s3 +=1
        else:
            break
    for i in a:
        if i % (2 ** s3) != 0:
            print(0)
            return 0
    for i in range(1,N):
        s = s * a[i] // fractions.gcd(s, a[i])
    s /= 2
    a = int(M // (2*s))
    if (M // s) % 2 == 0:
        print(a)
    else:
        print(a+1)
main()

Submission status: Runtime Error

Solution code:
n,m=map(int,input().split())
A=list(map(int,input().split()))
import math
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
ans=1  
for i in range(n):
  ans = lcm(ans,A[i]//2)
print(ans)
if ans > m:
    print(0)
else:
    print((m//ans)//2+1)

Submission status: Runtime Error

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

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]
import numpy as np
ans = 1
for b in bl:
   ans = np.lcm(b, ans)

for a in al:
   if ans % a == 0:
      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:
import fractions
n,m=map(int,input().split())
a=list(map(int,input().split()))
#print(a)
for i in range(n):
    a[i]=a[i]//2
f2=1
for i in range(n):
    f=fractions.gcd(f2,a[i])
    f2=a[i]*f2//f
#print(f2)
ans=0
for i in range(n):
    if f2/a[i]%2!=1:
        print(ans)
        break
else:
    ans=m//f2
    print((ans+1)//2)

Submission status: Runtime Error

Solution code:
from fractions import gcd
N, M = map(int, input().split())
a = [int(c) for c in input().split()]
G = a[0]*a[1]//gcd(a[0], a[1])
g = (a[0]//2)*(a[1]//2)//gcd(a[0]//2, a[1]//2)
for i in range(2,N):
  G = G*a[i]//gcd(G, a[i])
  g = g*(a[i]//2)//gcd(g, a[i]//2)
if M<g:
  print(0)
elif g%2==0:
  print(0)
else:
  n = (M-g)//G
  print(n+1)

Submission status: Runtime Error

Solution code:
import math

n, m = map(int, input().split())
a_array = list(map(int, input().split()))
lcm = 1
for i in range(n):
    a = a_array[i] // 2
    gcd = math.gcd(a, lcm)
    lcm = max(lcm, (lcm // gcd) * a)
print(((m // lcm) + 1) // 2)

Submission status: Runtime Error

Solution code:
n, m = [ int(v) for v in input().split() ]
a_list = list(set([ int(v)//2 for v in input().split() ]))

def gcd(a,b):
    if a < b:
        a, b = b, a
    while b >= 1:
        a, b = b, a % b
    return a
def lcm(a,b):
	return a * b // gcd(a,b)

n = len(a_list)
if n == 1:
    p = a_list[0]
    if p > m:
      print(0)
      else:
        m -= p
        print(m//(p*2)+1)
    
else:
    if all([i % 2 == 1 for i in a_list]):
        p = 1
        for j in a_list:
            p = lcm(p, j)
        if p > m:
            print(0)
        else:
            m -= p
            print(m//(p*2)+1)

    else:
        print(0)

Submission status: Runtime Error

Solution code:
N = int(input())
M = int(input())
A = map(int, input().split())
A = sorted(A, reverse=True)

hankou = []
p = 5
max_a = A[0]
while p <= M:
    hankou.append(max_a * p)
    p += 10

for a in A[1:]:
    hankou = [h for h in hankou if (h / a) % 10 != 0 and (h / a) % 5 == 0]

print(hankou)

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

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


if lb > m:
    print(0)
else:
    ans = (m-lb)//la+1
    print(ans)

Submission status: Runtime Error

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

sA=list(set(A))
for i in range(len(sA)):
    while sA[i]%2==0:
        sA[i]//=2
ssA=list(set(sA))

import math
lcm=ssA[0]
for i in range(1, len(ssA)):
    lcm = lcm * ssA[i] // math.gcd(lcm, ssA[i])
n = M//lcm
if n%2==0:
    print(n//2)
else:
    print(n//2+1)

Submission status: Runtime Error

Solution code:
import numpy as np


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


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


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

M *= 2
v = lcm(a[0], a[1])
for i in range(2, a.shape[0]):
    v = lcm(v, a[i])
    if v > M:
        print(0)
        exit()
print((M // v + 1) // 2)
# for i in range(1, M):
#     if (i % a).sum() == 0:
#         v = i
#         break
# if v != -1:
#     print((M // v + 1) // 2)
# else:
#     print(0)

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())
a = list(set(map(int, input().split())))
n = len(a)
a = [x//2 for x in a]
all_lcm = 1
for i in range(n):
  all_lcm = lcm(all_lcm, a[i])
  if all_lcm > m:
    exit(print(0))
m -= m % all_lcm
flag = m % 2
print(m // all_lcm // 2 + flag)
from fractions import gcd
def lcm(a, b):
  return (a * b) // gcd(a, b)
 
 
n, m = map(int, input().split())
a = list(set(map(int, input().split())))
n = len(a)
a = [x//2 for x in a]
all_lcm = 1
for i in range(n):
  all_lcm = lcm(all_lcm, a[i])
  if all_lcm > m:
    exit(print(0))
if all_gcm % 2 == 0:
  exit(print(0))
print(m // all_lcm // 2 + 1)

Submission status: Runtime Error

Solution code:
import math

def v(n,a):
    for i in a:
        if n%i==0:
            return False
    return True
n,m=list(map(int,input().split()))
a=list(map(int,input().split()))
b=[i//2 for i in a]
l=b[0]
for i in range(1,n):
    l=l*b[i]//math.gcd(l,b[i])
if l%2==0 or l>m:
    print(0)
else:
    p=m//l
    print(p//2+(p%2>0))

Submission status: Runtime Error

Solution code:
import math

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

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

lcm = 1
for aa in a:
    lcm = calc_lcm(lcm, aa)
ans = (m - lcm // 2) // lcm + 1
print(ans)

Submission status: Runtime Error

Solution code:
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

inline long long mod(long long a, long long m) {
  return (a % m + m) % m;
}

long long extGcd(long long a, long long b, long long &p, long long &q) {
  if (b == 0) {
    p = 1;
    q = 0;
    return a;
  }
  long long d = extGcd(b, a % b, q, p);
  q -= a / b * p;
  return d;
}

pair<long long, long long> ChineseRem(long long b1, long long m1, long long b2, long long m2) {
  long long p, q;
  long long d = extGcd(m1, m2, p, q);  // p is inv of m1/d (mod. m2/d)
  if ((b2 - b1) % d != 0) return make_pair(0, -1);
  long long m = m1 * (m2 / d);  // lcm of (m1, m2)
  long long tmp = (b2 - b1) / d * p % (m2 / d);
  long long r = mod(b1 + m1 * tmp, m);
  return make_pair(r, m);
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int N;
  ll M;
  while (cin >> N >> M) {
    vector<ll> A(N);
    for (ll &x : A) cin >> x;
    ll a = 0, m = 1;
    for (ll x : A) {
      auto sol = ChineseRem(a, m, x + x / 2, x);
      a = sol.fst;
      m = sol.snd;
      if (m < 0) break;
      if (a > M) break;
    }
    ll res = 0;
    if (m > 0 && a <= M) {
      res = (M - a) / m + 1;
    }
    cout << res << endl;
  }
  return 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):
    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)
if l>m:
    print(0)
else:
    print( round(m/l) )

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce

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

N, M = map(int,input().split())
A = sorted(list(map(int,input().split())))
lcmA = reduce(lcm, A)
if M < lcmA//2:
    print(0)
else:
    print( 1 + (M - lcmA//2)//lcmA)

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//2)/(sa)
print(p)
if p<1:
    print("0")

else:
    print(int(p)+1)

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) // math.gcd(x, y)
flag = 0
temp = 1
for a in As:
    flag += (a//2) % 2
    temp = lcm(temp,a)

if flag == 0 or flag == N:
    print(math.ceil(M / temp))
else:
    print(0)

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):
    return a * b // get_gcd(a, b)


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

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:
from fractions import gcd

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

A = set(A)
half = [i/2 for i in A]
# print(half)

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


a = 1
for hi in half:
    a *= hi

b = 1
for ai in A:
    b *= ai
b //= 2
# print(a, b)

n = ((M - a) / b) + 1
print(int(n))

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)
  
i = input().split(" ")
N = int(i[0])
M = int(i[1])

a = input().split(" ")
a = [int(i) for i in a]
a_h = [int(i / 2) for i in a]

g = lcm_list(a_h)
kisu = [(g / i) % 2 for i in a_h]
if sum(kisu) == len(kisu): # 入力の半分の最小公倍数が入力の奇数倍すべて
  r = (M - g) // (2 * g) + 1
  r = int(r)
  print(r)
  
else:
  print(0)

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
import fractions

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

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

for i in range(len(A)-1):
    A[i+1]=A[i]*A[i+1]//(fractions.gcd(A[i],A[i+1]))
    B=[A[-1]//2]


if M<B[-1]:
    print(0)
else:
    print((M-B[-1])//A[-1]+1)

Submission status: Runtime Error

Solution code:
from fractions import gcd
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] // gcd(ans, A[i])

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

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
if tmp % 2 != 0:
    ans = 0
else:
    ans = math.ceil(ans_hint / 2)

print(ans)