Problem:


Score : 400 points

Problem Statement

Given are a sequence A= {a_1,a_2,......a_N} of N positive even numbers, and an integer M.

Let a semi-common multiple of A be a positive integer X that satisfies the following condition for every k (1 \leq k \leq N):

There exists a non-negative integer p such that X= a_k \times (p+0.5).

Find the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Constraints

1 \leq N \leq 10^5

1 \leq M \leq 10^9

2 \leq a_i \leq 10^9

a_i is an even number.

All values in input are integers.

Input

Input is given from Standard Input in the following format:

N M
a_1 a_2 ... a_N

Output

Print the number of semi-common multiples of A among the integers between 1 and M (inclusive).

Sample Input 1

2 50
6 10

Sample Output 1

2

15 = 6  \times 2.5 

15 = 10 \times 1.5 

45 = 6  \times 7.5 

45 = 10 \times 4.5 

Thus, 15 and 45 are semi-common multiples of A. There are no other semi-common multiples of A between 1 and 50, so the answer is 2.

Sample Input 2

3 100
14 22 40

Sample Output 2

0

The answer can be 0.

Sample Input 3

5 1000000000
6 6 2 6 2

Sample Output 3

166666667



Sample input:
2 50
6 10


Sample output:
2

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nmm = input()
aal = input()
nm = nmm.split(' ')

n = int(nm[0])
m = int(nm[1])
als = aal.split(' ')
al = [int(n) for n in als]


multL = multLcm(*al)
halfLcm = multL/2

for i in al:
	if multL == i:
		halfLcm = halfLcm * 1.5

# print(halfLcm)

d = -(-m//halfLcm)
c = d//2 

if halfLcm > m:
   	c = 0  
        
print(int(c))

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nmm = input()
aal = input()
nm = nmm.split(' ')

n = int(nm[0])
m = int(nm[1])
als = aal.split(' ')
al = [int(n) for n in als]


halfLcm = multLcm(*al)/2
# print(halfLcm)
for i in al:
	if halfLcm == i:
		halfLcm = halfLcm * 1.5

d = -(-m//halfLcm)
c = d//2 

if halfLcm > m:
   	c = 0  
        
print(int(c))

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nmm = input()
aal = input()
nm = nmm.split(' ')

n = int(nm[0])
m = int(nm[1])
als = aal.split(' ')
al = [int(n) for n in als]


halfLcm = multLcm(*al)/2

d = -(-m//halfLcm)
c = d//2 

if halfLcm > m:
   	c = 0  
        
print(int(c))

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nmm = input()
aal = input()
nm = nmm.split(' ')

n = int(nm[0])
m = int(nm[1])
als = aal.split(' ')
al = [int(n) for n in als]


halfLcm = multLcm(*al)/2

d = -(-m//halfLcm)
c = -(-d//2) 

if halfLcm > m:
   	c = 0  
        
print(int(c))

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nmm = input()
aal = input()
nm = nmm.split(' ')

n = int(nm[0])
m = int(nm[1])
als = aal.split(' ')
al = [int(n) for n in als]


halfLcm = multLcm(*al)/2

d = -(-m//halfLcm)
c = -(-d//2)    
        
print(c)

Submission status: Runtime Error

Solution code:
'''
https://atcoder.jp/contests/abc150/tasks/abc150_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

    if n == 1:
        if m >= a[0]//2:
            print((m-a[0]//2) // a[0] + 1)
        else:
            print(0)
        exit()

    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    g = gcd_group(a)
    for i in a:
        if (i//g)%2 == 0:
            print(0)
            exit()
    lcm = lcm_group(a)
    semi_lcm = lcm // 2
    if m >= semi_lcm:
        print((m-semi_lcm)//lcm + 1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''
https://atcoder.jp/contests/abc150/tasks/abc150_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

    if n == 1:
        if m >= a[0]:
            print((m-a[0]) // a[0] + 1)
        else:
            print(0)
        exit()

    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    g = gcd_group(a)
    for i in a:
        if (i//g)%2 == 0:
            print(0)
            exit()
    lcm = lcm_group(a)
    semi_lcm = lcm // 2
    if m >= semi_lcm:
        print((m-semi_lcm)//lcm + 1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''
https://atcoder.jp/contests/abc150/tasks/abc150_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

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

    if n == 1:
        if m >= a[0]:
            print((m-a[0]) // a[0] + 1)
        else:
            print(0)

    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    lcm = lcm_group(a)
    semi_lcm = lcm // 2
    if m >= semi_lcm:
        print((m-semi_lcm)//lcm + 1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
'''
https://atcoder.jp/contests/abc150/tasks/abc150_d
'''
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate
    #from itertools import product
    from bisect import bisect_left,bisect_right
    import heapq
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,m = map(int, input().split())
    a = list(map(int, input().split()))
    def gcd(a, b):
        if b == 0:
            return a
        else:
            return gcd(b, a % b)
    
    def gcd_group(arr):
        g = gcd(arr[0], arr[1])
        for i in range(2, len(arr)):
            g = gcd(g, arr[i])
        return g
    
    def lcm(a, b):
        g = gcd(a, b)
        return (a*b)//g
    
    def lcm_group(arr):
        l = lcm(arr[0], arr[1])
        for i in range(2, len(arr)):
            l = lcm(l, arr[i])
        return l
    
    lcm = lcm_group(a)
    semi_lcm = lcm // 2
    if m >= semi_lcm:
        print((m-semi_lcm)//lcm + 1)
    else:
        print(0)


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nmm = input()
aal = input()
nm = nmm.split(' ')

n = int(nm[0])
m = int(nm[1])
als = aal.split(' ')
al = [int(n) for n in als]


# n = 2
# m = 1000000000
# al = [6,6,2,6,2]

c = 0

halfLcm = multLcm(*al)/2

for i in range(1, m, 2):
    if (halfLcm * i) > m:
        break
    else:
        c += 1
        
print(c)

Submission status: Runtime Error

Solution code:
import sys,queue,math,copy
from functools import reduce
from fractions import gcd
input = sys.stdin.readline
LI = lambda : [int(x) for x in input().split()]
LI_2 = lambda : [int(x) / 2 for x in input().split()]

lcm = lambda a : reduce(lambda x, y : x * y // gcd(x,y), a)
N,M = LI()
A = LI_2()
c = lcm(A)
for i in A:
    if (c // i) % 2 == 0:
        print (0)
        exit (0)
print (math.ceil(M//c) / 2))

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nmm = str(input())
aal = str(input())
nm = nmm.split(' ')

n = int(nm[0])
m = int(nm[1])
al = aal.split(' ')

# n = 2
# m = 1000000000
# al = [6,6,2,6,2]

c = 0

halfLcm = multLcm(*al)/2

for i in range(1, m, 2):
    if (halfLcm * i) > m:
        break
    else:
        c += 1
        
print(c)

Submission status: Runtime Error

Solution code:
import sys
import math

N, M = map(int, input().split())
a = list(map(lambda x: int(x) >> 1, input().split()))

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

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

Submission status: Runtime Error

Solution code:
import math
import functools as f
import fractions as fra


def multGcd(*num):
    return f.reduce(fra.gcd, num)


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


def multLcm(*num):
    return f.reduce(lcm, num)

nm = input().split(' ')
n = int(nm[0])
m = int(nm[1])
al = input().split(' ')

# n = 2
# m = 1000000000
# al = [6,6,2,6,2]

c = 0

halfLcm = multLcm(*al)/2

for i in range(1, m, 2):
    if (halfLcm * i) > m:
        break
    else:
        c += 1
        
print(c)

Submission status: Runtime Error

Solution code:
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n,m = mi()
alis = li()
for i in range(n):
    alis[i] //= 2

ima = alis[0] & -alis[0]
alis[0] //= (1<<(ima-1))
for i in range(1,n):
    tmp = alis[i] & -alis[i]
    if ima != tmp:
        print(0)
        exit()
    else:
        alis[i] //= (1<<(ima-1))

tmp = (1<<(ima-1))
#a>b
def gcd(a,b):
    if a < b:
        a,b = b,a
    while b!=0:
        a,b=b,a%b
    return a
#a>b
def lcm(a,b):
    return a*b // gcd(a,b)
ima = 1
for i in range(n):
    ima = lcm(alis[i],ima)
    if ima*tmp > m:
        print(0)
        exit()
ans = 0

tmm = m//ima
if tmm % 2 ==0:
    print(tmm//2)
else:
    print(tmm//2 +1)

Submission status: Runtime Error

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

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

num = lcm(a)
thr = m - num//2

if thr <= 0:
    print(0)
else:
    print(-(-thr//num))

Submission status: Runtime Error

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

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

num = lcm(a)
thr = m - num//2

if thr <= 0:
    print(0)
else:
    print(-(-thr//num))

Submission status: Runtime Error

Solution code:
import sys
input=lambda: sys.stdin.readline().rstrip()

n,m=map(int,input().split())
A=[int(i)//2 for i in input().split()]
ct=0
s=A[0]
while s:
  if s%2==0:
    s//=2
    ct+=1
  else:
    s=0
chk=True
for i in range(1,n):
  cur=0
  a=A[i]
  while a:
  if a%2==0:
    a//=2
    cur+=1
  else:
    a=0
  if cur!=ct:
    chk=False
    break


def gcd(a,b):
  while b:
    a,b=b,a%b
  return a
if not chk:
  print(0)
else:
  lcm=A[0]
  for i in range(1,n):
    lcm*=A[i]//gcd(lcm,A[i])
  print((m//lcm+1)//2)

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 7)

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

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

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    # for j in a:
    #     if j % 2 != 0:
    #         print("0")

    # a = [i/2 for i in a]
    l = lcm_list(a)

    # if l == 0:
    #     print(0)
    #     exit()

    i = l / 2

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

    if m < i:
        print("0")
    else:
        # print("1")
        # print(int(((m - i) // l) + 1))
        print(int((m // i + 1) // 2))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 7)

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

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

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    # for j in a:
    #     if j % 2 != 0:
    #         print("0")

    # a = [i/2 for i in a]
    l = lcm_list(a)

    # if l == 0:
    #     print(0)
    #     exit()

    i = l / 2

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

    if m < i:
        print("0")
    else:
        print("1")
        # print(int(((m - i) // (l)) + 1))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
import sys
sys.setrecursionlimit(10 ** 7)

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

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

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    # for j in a:
    #     if j % 2 != 0:
    #         print("0")

    # a = [i/2 for i in a]
    l = lcm_list(a)

    # if l == 0:
    #     print(0)
    #     exit()

    i = l / 2

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

    if m < i:
        print("0")
    else:
        print(int(((m - i) // (l)) + 1))

Submission status: Runtime Error

Solution code:
from fractions import gcd
from functools import reduce
sys.setrecursionlimit(10 ** 7)

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

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

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    # for j in a:
    #     if j % 2 != 0:
    #         print("0")

    # a = [i/2 for i in a]
    l = lcm_list(a)

    # if l == 0:
    #     print(0)
    #     exit()

    i = l / 2

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

    if m < i:
        print("0")
    else:
        print(int(((m - i) // (l)) + 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(*numbers):
    return reduce(lcm_base, numbers, 1)

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    # for j in a:
    #     if j % 2 != 0:
    #         print("0")

    # a = [i/2 for i in a]
    l = lcm_list(a)

    if l == 0:
        print(0)
        exit()

    i = l / 2

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

    if m < i:
        print("0")
    else:
        print(int(((m - i) // (l)) + 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(*numbers):
    return reduce(lcm_base, numbers, 1)

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    # for j in a:
    #     if j % 2 != 0:
    #         print("0")

    # a = [i/2 for i in a]
    l = lcm_list(a)

    i = l / 2

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

    if m < i:
        print("0")
    else:
        print(int(((m - i) // (l)) + 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(*numbers):
    return reduce(lcm_base, numbers, 1)

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    for j in a:
        if j % 2 != 0:
            print("0")

    l = lcm_list(a)

    i = l / 2

    if m < i:
        print("0")
    else:
        print(int(((m - i) // l) + 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(*numbers):
    return reduce(lcm_base, numbers, 1)

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    if j in a:
        if j % 2 != 0:
            print("0")

    l = lcm_list(a)

    i = l / 2

    if m < i:
        print("0")
    else:
        print(int(((m - i) // l) + 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(*numbers):
    return reduce(lcm_base, numbers, 1)

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


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    l = lcm_list(a)

    i = l / 2

    if m < i:
        print("0")
    else:
        print(int(((m - i) // l) + 1))

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)


if __name__ == '__main__':
    n, m = list(map(int, input().split(" ")))
    a = list(map(int, input().split(" ")))
    a = list(set(a))

    l = lcm_list(a)

    i = l / 2

    if m < i:
        print("0")
    else:
        print(int(((m - i) // l) + 1))

Submission status: Runtime Error

Solution code:
import math
import bisect
import heapq
from fractions import gcd #math in python 3.7
from collections import deque

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

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



def twos(n):
    count = 0
    while n % 2 == 0:
        count += 1
        n //= 2

    return count

if min(a,key=two) != max(a,key=two) :
    print(0)
else:
    lcm = 1
    for i in a:
        lcm = lcm * i // gcd(lcm * i)
        if lcm > m:
            print(0)
            break

    else: print((m + lcm)//(2*lcm))

Submission status: Runtime Error

Solution code:
import math
import bisect
import heapq
from collections import deque

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

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


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


def scm(a):
    for i in range(n):
        if a[i] % 2 == 1:
            return 0
    l = 1
    for i in range(n):
        a[i] = a[i] // 2
        l = lcm(l,a[i])

    count = 0
    lc = l
    if not 1 <= l <= m:
        return 0

    for i in range(l, m+1, 2*lc):
        count += 1

    return count

print(scm(a))

Submission status: Runtime Error

Solution code:
import math
import bisect
import heapq
from collections import deque

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

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


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


def scm(a):
    for i in a:
        if i % 2 == 1:
            return 0
    l = 1
    for i in range(n):
        a[i] = a[i] // 2
        l = lcm(l,a[i])

    count = 0
    lc = l
    if not 1 <= l <= m:
        return 0

    for i in range(l, m+1, 2*lc):
        count += 1

    return count

print(scm(a))

Submission status: Runtime Error

Solution code:
import math
import bisect
import heapq
from collections import deque

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

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


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


def scm(a):
    for i in a:
        if i % 2 == 1: return 0

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

    l = 1

    for i in range(n):
        l = lcm(l,a[i])

    count = 0
    lc = l
    # print(l)
    if not(1 <= l <= m): return 0

    for i in range(l,m+1,2 * lc):
        count += 1

    return count

print(scm(a))

Submission status: Runtime Error

Solution code:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

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)

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

a = l()

ap = [0 for i in range(N)]
for i in range(N):
    co = 0
    while a[i] % 2 == 0:
        a[i] //= 2
        co += 1
    ap[i] = co

for i in range(1,N):
    if ap[i] != ap[i-1]:
        print(0)
        exit()

po = int(lcm_list(a) * math.pow(2,ap[0]-1))

p = -(-(M // po) // 2)

print(p)

Submission status: Runtime Error

Solution code:
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
input = sys.stdin.readline
mod = 10**9+7
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    return int(input())
def s(x): #圧縮
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa != x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): #listをスペースごとに分ける
    return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
    return max(map(max,x))
def In(x,a): #aがリスト(sorted)
    k = bs.bisect_left(a,x)
    if k != len(a) and a[k] ==  x:
        return True
    else:
        return False

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)

"""
def nibu(x,n,r):
    ll = 0
    rr = r
    while True:
        mid = (ll+rr)//2

    if rr == mid:
        return ll
    if (ここに評価入れる):
        rr = mid
    else:
        ll = mid+1
"""

N,M = m()

a = l()

ap = [0 for i in range(N)]
for i in range(N):
    co = 0
    while a[i] % 2 == 0:
        a[i] //= 2
        co += 1
    ap[i] = co

for i in range(1,N):
    if ap[i] != ap[i-1]:
        print(0)
        exit()

po = int(lcm_list(a) * math.pow(2,ap[i]-1))

p = -(-(M // po) // 2)

print(p)

Submission status: Runtime Error

Solution code:
import numpy as np
from functools import reduce


n,m=map(int,input().split())
A=list(map(lambda x: int(x)//2,input().split()))

lcm=np.lcm.reduce(np.array(A))
if any([i for i in range(n) if lcm%(A[i]*2)==0]):
    print(0);exit()

ans=m//(2*lcm)
print(ans if m//lcm==0 else ans+1)

Submission status: Runtime Error

Solution code:
import sys
import fractions
from functools import reduce
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

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

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

N, M = map(int, input().split())
a = [int(x) for x in input().split()]

ans = 0
half_lcm = lcm_list(a) // 2

a = set(a)
for i in range(half_lcm, M+1, half_lcm):
    if all(int((i / x * 2)) & 1 for x in a):
        ans += 1

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
import math
 
N, M = map(int, input().split())
a = np.array(list(map(int, input().split()))) // 2
 
def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count

two_num = check_two(a[0])
for i in range(1, len(a)):
    if two_num != check_two(a[i]):
        print(0)
        exit()
 
my_lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > N:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

Submission status: Runtime Error

Solution code:
import math
from functools import reduce

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

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

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

A_lcm = lcm_list(A)

ans = (M + (A_lcm // 2)) // A_lcm

print(ans)

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
import math

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

def lcm(a, b):
    return a * b // fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count

two_nums = [check_two(i) for i in a]
if len(set(two_nums)) > 1:
    print(0)
    exit()

my_lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > N:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

Submission status: Runtime Error

Solution code:
import fractions
import numpy as np
import math

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

def lcm(a, b):
    return a * b / fractions.gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

two_nums = [check_two(i) for i in a]
if len(set(two_nums)) > 1:
    print(0)
    exit()

my_lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    my_lcm = lcm(my_lcm, a[i])
    if my_lcm > N:
        print(0)
        exit()
    
ans = M // my_lcm
print(math.ceil(ans / 2))

Submission status: Runtime Error

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

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

def lcm(a, b):
    return a * b / gcd(a, b)
    
def check_two(num):
    count = 0
    while num % 2 == 0:
        num /= 2
        count += 1
    return count

two_nums = [check_two(i) for i in a]
if len(set(two_nums)) > 1:
    print(0)
    exit()

lcm = lcm(a[0], a[1])
for i in range(2, len(a)):
    lcm = lcm(lcm, a[i])
    if lcm > N:
        print(0)
        exit()
    
ans = M // lcm
print(math.ceil(ans / 2))

Submission status: Runtime Error

Solution code:
import fractions
from functools import reduce
N,M = map(int,input().split())
a = list(set(list(map(int,input().split()))))
a = [a[i]//2 for i in range(len(a))]
for i in range(len(a)-1):
    c = (a[i] * a[i+1]) // fractions.gcd(a[i], a[i+1])
    a[i+1] = c

g = c
cnt = (M-g)//(2*g)+1

print(cnt)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,M = map(int,input().split())
a = list(set(list(map(int,input().split()))))
a = [a[i]//2 for i in range(len(a))]
for i in range(len(a)-1):
    c = (a[i] * a[i+1]) // math.gcd(a[i], a[i+1])
    a[i+1] = c

g = c
cnt = (M-g)//(2*g)+1

print(cnt)

Submission status: Runtime Error

Solution code:
import math
from functools import reduce
N,M = map(int,input().split())
a = list(set(list(map(int,input().split()))))
a = [a[i]//2 for i in range(len(a))]
def lcm(x, y):
    return (x * y) // math.gcd(x, y)
def gcd(numbers):
    return reduce(lcm, numbers)

g = gcd(a)
cnt = (M-g)//(2*g)+1

print(cnt)