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 sys
sys.setrecursionlimit(10**7)

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

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

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

L = list(A)
while len(L) != 1:
  O = list(L)
  if N % 2 == 0:
    L = []
    for i in range(0, N, 2):
      L += [lcm(O[i], O[i+1])]
  else:
    L = [O.pop(0)]
    for i in range(0, N-1, 2):
      L += [lcm(O[i], O[i+1])]
l = L[0]
      
M += l // 2

print(M//l)

Submission status: Runtime Error

Solution code:
cd(x,y):
    while y>0:
        x,y = y,x%y
    return x
N,M = map(int,input().split())
A = list(set(list(map(int,input().split()))))
B = []
for i in range(len(A)):
    B.append((A[i]//2)%2)
B = list(set(B))
if len(B)==2:
    print(0)
else:
    a = A[0]
    for i in range(1,len(A)):
        a = gcd(a,A[i])
    b = a
    for x in A:
        b *= x//a
    if B[0]==1:
        k = (M-b//2)//b
        print(k+1)
    else:
        A = sorted(A)
        flag = 1
        for i in range(1,len(A)):
            if A[i]%A[i-1]!=0:
                flag = 0
                break
        if flag==1:
            k = (M-b//2)//b
            print(k+1)
        else:
            print(0)

Submission status: Runtime Error

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


def calc_double(n):
    return n//2

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

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

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


def resolve():
    input = sys.stdin.readline
    N,M=map(int,input().rstrip().split())
    A=list(map(int,input().rstrip().split()))
    AA=list(map(calc_double,A))
    """
    AA=[0 for _ in range(N)]
    for i in range(N):
        AA[i]=M//A[i]-0.5
    
    for i in range(N):
        AA[i]
    """
    aa= np.array(AA)
    a=int(np.lcm.reduce(aa))
    #a=lcm_list(AA)
    #a=a//2
    """
    count=0
    for i in range(1,M+1,2):
        if a*i<=M:
            count+=1
        else:
            break
    """
    odd=M//a
    count=(odd+1)//2

    print(count)

    

from io import StringIO
import unittest

class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """2 50
6 10"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """3 100
14 22 40"""
        output = """0"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5 1000000000
6 6 2 6 2"""
        output = """166666667"""
        self.assertIO(input, output)

if __name__ == "__main__":
    #unittest.main()
    resolve()

Submission status: Runtime Error

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

a = list(set(a))

result = []

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

a = a[:n]

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

print(len(ans))

Submission status: Runtime Error

Solution code:
import numpy as np
from decimal import *

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

mylist = list(map(int, input().split()))
mylist = list(set(mylist))

myprod = np.prod(mylist)//2
#print(M/myprod)
print(Decimal(str(M/myprod)).quantize(Decimal('0'), rounding=ROUND_HALF_UP))

Submission status: Runtime Error

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

p=0
flag=0
cnt=0
while (a[0]*(p+0.5)<=m) and flag==0:
  #print("p",p)
  for i in range(1,n):
    if (a[0]*(p+0.5)-a[i]//2)%a[i]==0:
      continue
    else:
      flag=1
  if flag==0:
    break
  p+=1
  flag=0
print((int(m-a[0]*(p+0.5))//g+1))

Submission status: Runtime Error

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

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

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

Submission status: Runtime Error

Solution code:
import math
import 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)

#gcd
g = functools.reduce(lambda x,y:x*y//math.gcd(x,y),A,1)

#first one
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


print(((M-first))//g +1)

Submission status: Runtime Error

Solution code:
# coding: utf-8
import fractions as 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)

A2=list(set(A2))

l=lcm_list(A2)
k=l
cnt=-1
flg=False
while k == int(k):
    k=k/2
    cnt+=1

for i in range(cnt):
    for j in range(len(A2)):
        if A2[j]/(2**(j+1)) != int(A2[j]/(2**(j+1))):
            flg=True
    

ans=M//l

if flg:
    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:

def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    #A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    from bisect import bisect_right as br
    c=br(A,A[-1]//2)
    for a in A:
        kou=a*kou//gcd(a,kou)
    for a in range(min(c+1,n))
        if (kou//A[a])%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()

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 or l==-1:
    print(0)
else:
    ans += 1
    print( round(ans) )

Submission status: Runtime Error

Solution code:
import fractions

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

max_a = max(a)

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

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

Submission status: Runtime Error

Solution code:
import fractions

def lcm(a):
    gcd = -1
    lcm = -1
    for i in range(len(a) - 1):
        if i == 0:
            gcd = fractions.gcd(a[i], a[i+1])
            lcm = a[i] * a[i+1] / gcd
        else:
            gcd = fractions.gcd(gcd, a[i+1])
            lcm = lcm * a[i+1] / gcd

    return int(lcm)

nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]

a = list(map(int, input().split()))
aa = [int(x/2) for x in a]
aa = list(set(aa))

l = lcm(aa)
r = int(m/l)

if r % 2 == 0:
    print(int(r/2))
elif l % a[0] == 0:
    print(int(r/2))
else:
    print(int((r+1)/2))

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define MIN(x) *min_element(all(x))
#define MAX(x) *max_element(all(x))
#define in(x) cin >> x
#define co(x) cout << x
#define el  cout << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a, int b)
{
    if (a%b == 0)
    {
        return(b);
    }
    else
    {
        return(gcd(b, a%b));
    }
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main() {
    int n, m, ans=0, x, min, mul=1, lcmn;
    cin >> n >> m;
    VI a;

    REP(i, n){
        cin >> x;
        a.pb(x);
    }
    sort(all(a));
    a.erase(unique(all(a)), a.end());
    min = a[0];
    while(min % 2 != 1){
        min /= 2;
        mul *= 2;
    }
    lcmn = a[0]/mul;
    REP(i, (int)a.size()){
        if(a[i] / mul % 2 != 1 || a[i] % mul != 0)
            ans=-1;
        else
            a[i] /= mul;
        lcmn = lcm(lcmn, a[i]);
    }
    if(ans!=-1){
        ans = m / lcmn;
        if(ans % 2 == 0)
            ans /= 2;
        else
            ans = (ans+1) / 2;
    }else{
        ans = 0;
    }




    cout << ans << endl;

    return 0;
}

Submission status: Runtime Error

Solution code:
def f(n):
    a=0
    while n%2==0:
        n//=2
        a+=1
    return a    
n,m,*a=map(int,open(0).read().split())
c=[f(i) for i in a]
if sum(c)!=c[0]*n:
    print(0)
    exit()
import fractions
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)
a=list(set(a))
b=a[0]*a[1]// fractions.gcd(a[0], a[1])
for i in a:
    b=lcm(i,b)
print(0 if b//2>m else (m-b//2)//b+1)

Submission status: Runtime Error

Solution code:
import numpy as np
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 = map(int, input().split())
a = np.array(list(map(int, input().split())))
a_d = a // 2

ans = m / lcm(*a_d) / 2
if ans.is_integer():
    ans = m // lcm(*a_d) // 2 - 1
    print(int(ans))
else:
    ans = round(m / lcm(*a_d) / 2)
    print(int(ans))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce


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

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

    nLcm = reduce(lcm, B)
    # print(nLcm)

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

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

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

    print(answer)


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

    return count


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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
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:
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()

t=before//2

print(math.ceil((m//t)/2))

Submission status: Runtime Error

Solution code:
import math

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

lcm = li[0]
for i in range(n):
  lcm = lcm * li[i] // math.gcd(lcm,li[i])

ans = 0
ans_bool = False

for i in li:
  if lcm % i == 0 and ((lcm // i) % 2) == 1:
    ans_bool = True
  else:
    ans_bool = False
    break

ans = 2 * m // lcm
ans = math.ceil(ans / 2)

print(ans)

Submission status: Runtime Error

Solution code:
from sys import stdin
from itertools import accumulate, dropwhile, takewhile, groupby
import bisect
import copy
import math
import itertools
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)


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


aq = [int(s) for s in stdin.readline().rstrip().split()]
N = aq[0]
M = aq[1]
pro = 15
a = [int(s) for s in stdin.readline().rstrip().split()]
a2 = map(calc_double, a)


m = int(M-int(M / 2)) - 1
n = lcm_list(a2)
n2 = int(M / n)
n3 = int(M / (n * 2))
print(n2-n3)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
import numpy as np


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


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


def main():
    N, M = map(int, input().split())
    numbers = set(map(int, input().split()))
    numbers = np.array(numbers)
    numbers = numbers // 2

    lcm = lcm_list(numbers)

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from collections import deque
n, m = map(int, input().split())
a = set(map(int, input().split()))

# a[0]に対してリストを作る。
a = tuple(a)
ans = deque()
a0 = a[-1]
a1 = a[-2]
max_p = (2*m-a0)//2*a0 + 1
for j in range(1, max_p):
    x = a0 * (j + 0.5)
    p = (2*x-a1)/(2*a1)
    if p.is_integer() and 1 <= x <= m:
        ans.append(x)

for i in range(len(a)-2):
    w = len(ans)
    for k in range(w):
        j = ans.pop()
        p = (2 * j - a[i]) / (2 * a[i])
        if p.is_integer():
            ans.appendleft(j)

print(len(ans))

Submission status: Runtime Error

Solution code:
import math; 
N , M = map ( int , input().strip().split(" ") ) ;
arr = list( map ( int , input().strip().split(" ") ) ) ;

set1 = set(arr ) ; 
arr = list(set1);
arr.sort();

gcd = arr[0] ; 
for x in arr[1:] :
	gcd = math.gcd( gcd , x ) ;
v = gcd ; 
for x in arr :
	v *= x // gcd ;

yy = -1 ;
for y in range( 1 , v+1 ) :
	if y > M : break ;
	if all( map(lambda x:(y-x//2)%x==0 , arr ) ) :
		yy = y ;
		break ;
if yy == -1 : 
	print ( 0 ) ;
else :
	print ( (M - yy ) // v +1 ) ;

Submission status: Runtime Error

Solution code:
from math import gcd

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

def invalid(a, b):
    if a > b:
        a, b = b, a
    return (b % a == 0 and ((b - a) // 2) % a != 0)

def main():
    N, M = map(int, input().split())
    A = list(set(map(int, input().split())))
    A.sort()
    if len(A) == 1:
        l = A[0]
    else:
        if invalid(A[0], A[1]):
            return 0
        l = lcm(A[0], A[1])
        for i in A[2:]:
            if invalid(l, i):
                return 0
            if l % i == 0:
                continue
            l = lcm(l, i)
    return (M + l // 2) // l

print(main())

Submission status: Runtime Error

Solution code:
from fractions import*
from numpy import*
from itertools import*
from operator import mul
from functools import reduce
n,m=map(int,input().split())
*a,=map(int,input().split())
a.sort(reverse=1)

#一つ見つければあとは最小公倍数
l=[]
for i in range(1,m+1):
    if (i/a[0])%1==0.5 and (i/a[1])%1==0.5:
        l.append(i)
g=list(accumulate(a,gcd))[-1]
GCD=reduce(mul,[i//g for i in a])*g

a=array(a)
b=len(a)
base=-1
for i in l:
    if sum((i/a)%1==0.5)==b:
        base=i
        break
#print(m,base,GCD)
if base==-1:
    print(0)
elif m-base>=0:
    print((m-base)//GCD+1)
else:
    print(0)

Submission status: Runtime Error

Solution code:
import math
import fraction
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
def lcm_base(x, y):
    return (x * y) // fraction.gcd(x, y)
def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)
saisyou = lcm(*A)
kosuu = math.ceil(M/saisyou)
print(kosuu)

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
import numpy as np


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


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


def main():
    N, M = map(int, input().split())
    numbers = set(map(int, input().split()))
    numbers = np.array(numbers)
    numbers // 2

    lcm = lcm_list(numbers)

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
def gcd(a,b): 
    if(b==0): 
        return a 
    else: 
        return gcd(b,a%b)
n, m = map(int, input().split())
a = list(map(int, input().split()))
lcm = a[0]/2
for i in a[1:]:
  lcm = (lcm*(i/2))/gcd(lcm, (i/2))
if lcm>m :
    print(0)
else :
    ans=int((m/lcm)); 
    #print(ans)
    if ans%2==1 : 
        ans=(ans/2)+1   
    else : 
        ans=ans/2
    print(int(ans))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

a = lcm_list(A)
a = a / 2

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

print(c)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split())
a = list(map(int, input().split()))
pre = list(range(1, m+1))
ans = []

def is_han(x, a):
    for i in range(x+1):
        if x == a*(i+0.5):
            return True
    return False

ans = list(map(is_han, pre, a))

print(ans.count(True))

Submission status: Runtime Error

Solution code:
import math

def lcm(a):
    gcd = -1
    lcm = -1
    for i in range(len(a) - 1):
        if i == 0:
            gcd = math.gcd(a[i], a[i+1])
            lcm = a[i] * a[i+1] / gcd
        else:
            gcd = math.gcd(gcd, a[i+1])
            lcm = lcm * a[i+1] / gcd

    return int(lcm)

nm = list(map(int, input().split()))
n = nm[0]
m = nm[1]

a = list(map(int, input().split()))
aa = [int(x/2) for x in a]
aa = list(set(aa))

l = lcm(aa)
r = int(m/l)

if r % 2 == 0:
    print(int(r/2))
elif l % a[0] == 0:
    print(int(r/2))
else:
    print(int((r+1)/2))

Submission status: Runtime Error

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

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

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

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

lcma=0

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

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

print(o)

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

if len(A) >1:
  L = lcm(A)
else:
  L = A[0]

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

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

if s > M:
    print(0)

else:
    m = s // 2
    print((M-m)//s + 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]
if len(a) == 1:
    pass
else:
    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 numpy as np
from fractions import gcd
from functools import reduce
from math import floor

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

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

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

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

last = count_bin(A[0])
for a in A[1:]:
  target = count_bin(a)
  if target == last:
    continue
  else:
    bins = False
#bins = len(list(set(list(map(count_bin, A)))))

if bins == 1:
  lcm = lcm_list(A)
  least_lcm = lcm // 2
  print(max(floor( (M - least_lcm) // lcm + 1), 0))
else:
  print(0)

Submission status: Runtime Error

Solution code:
# coding: utf-8

K, M = (int(x) for x in input().split())

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

A = [x for x in set(A)]
A.sort()
A.reverse()

X = list(range(1, M + 1))

for a in A:
	X = [x for x in X if (x - int(a / 2)) % a == 0]

print(len(X))

Submission status: Runtime Error

Solution code:
import math

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

gc = a[0]

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

ans = (k*2)//gc

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

print(ans)

Submission status: Runtime Error

Solution code:
import fractions

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

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

ans = ans // 2
aa = max(List) * 0.5

x = aa // ans
ans = x * ans


print(int((M / ans + 1) // 2))

Submission status: Runtime Error

Solution code:
count = []
for i in a:
  for num in range(1, 1000):
    result = round(i*(num+0.5))
    if (result > m):
      continue
    else:
      count.append(result)

dups = [x for n, x in enumerate(count) if x in count[:n]]
count2 = 0
for i in dups:
  for x in a:
    result = i/x
    s = str(result).split('.')
    if len(s[1]) <= 1:
      count2 += 1

print(math.floor(count2/len(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):
    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

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


saisyou = lcm(*A)
kosuu = math.ceil(M/saisyou)
print(kosuu)

Submission status: Runtime Error

Solution code:
n, m = map(int, input().split(' '))
from functools import reduce
alist = list(map(int,input().split(' ')))
alist = [i // 2  for i in alist]


from math import gcd

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

def get_lcm_for(your_list):
    return reduce(lambda x, y: getLCM(x, y), your_list)

lcmr = get_lcm_for(alist)

result = (m + lcmr)//(lcmr*2)


print(result)

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

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

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

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

Submission status: Runtime Error

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

result = []

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

a = a[:n]

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

print(len(ans))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
 
def gcd(*numbers):
    return reduce(fractions.gcd, numbers)
 
def gcd_list(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)
 
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) / 2

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

Submission status: Runtime Error

Solution code:
import math

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, N):

    ans = numbers[0]

    for i in range(1,N):
        ans = lcm_base(ans,numbers[i])

    return ans


a_lcm = lcm_list(A_n,N)
ans = 0
interval = a_lcm//2

amari = M // interval

if amari%2 == 1:
    amari = (amari+1)//2

print(amari)

Submission status: Runtime Error

Solution code:
from math import gcd

N, M = map(int, input().split())
A = list(map(int, input().split()))
A = list(set(A))
AA = [a//2 for a in A]
K = [1 for i in range(len(AA))]
'''
def gcd(x, y):
    if x < y:
        x, y = y, x
    while x % y != 0:
        x, y = y, x % y
    return(y)
'''
def lcm(x, y):
    ans = (x * y) // gcd(x, y)
    return(ans)
l = 1
g = AA[0]

for i in range(len(AA)):
    g = gcd(g, AA[i])
    l = lcm(l, AA[i])
AAA = [a // g for a in AA]
C = [a % 2 for a in AAA]

if C == K:
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

Submission status: Runtime Error

Solution code:

def main():
    """"ここに今までのコード"""
    import sys
    input = sys.stdin.readline
    n,m=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    if n==1:
        ans=(m//(A[0]//2)+1)//2
        print(int(ans))
        exit()
    from fractions import gcd
    kou=A[0]*A[1]//gcd(A[0],A[1])
    for a in A:
        kou=A[a]*kou//gcd(a,kou)
        if (kou//a)%2==0:
            print(0)
            exit()
    kou//=2
    #print(kou)
    ans=(m//kou+1)//2
    print(int(ans))
if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import fractions
p = list(map(int,input().split()))
q = list(map(int,input().split()))
ans = ''
def lcm(x, y):
    return int(round((x * y) / fractions.gcd(x, y) , 0))
a = lcm(q[0] , q[1])
for i in range(len(q)):
    a = lcm(a , q[i])
    if a > p[1]:
        ans = 0
        break
if ans == 0:
    print(ans)
else:
    print(int(round(p[1] / a,0)))

Submission status: Runtime Error

Solution code:
import math

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


b = [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:

import math
import fractions

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

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

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

if s > M:
    print(0)

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

Submission status: Runtime Error

Solution code:
def gcd(a,b): 
    if(b==0): 
        return a 
    else: 
        return gcd(b,a%b)
n, m = map(int, input().split())
a = list(map(int, input().split()))
res=int(a[0]/2)
for i in range(n):
    res=((res*(a[i]/2))/(gcd((a[i]/2),res)))
#print(res)

if res>m :
    print(0)
else :
    ans=int((m/res)); 
    #print(ans)
    if ans%2==1 : 
        ans=(ans/2)+1   
    else : 
        ans=ans/2
    print(int(ans))

Submission status: Runtime Error

Solution code:
import fractions

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

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

L = lcm2(A)

a_ = int(M / L)
b_ = int(M / (L/2))
print(b_-a_)

Submission status: Runtime Error

Solution code:
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[a//2 for a in A]

def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x

a1=A.pop()
a2=A.pop()
LCM=lcm(a1,a2)
while A!=[]:
    a2=A.pop()
    LCM=lcm(LCM,a2)
if LCM>M:
    ans=0
else:
    ans=int(-(-(M/LCM)//2))
print(ans)