qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import numpy as np 
import sys

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

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

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

A = np.array(a)

##while np.sum(A%2) == 0:
##A = A//2

if np.sum(A%2) != len(A):
    print("0")
    sys.exit()
    
tmp = 1##LCM

for i in range(N):
    tmp = lcm(tmp,a[i]//2)

if tmp > M:
    print("0")

else:
    print((M//tmp+1)//2)

Fixed code:
import numpy as np 
import sys

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

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

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

A = np.array(a)

while np.sum(A%2) == 0:
    A = A//2

if np.sum(A%2) != len(A):
    print("0")
    sys.exit()
    
tmp = 1##LCM

for i in range(N):
    tmp = lcm(tmp,a[i]//2)

if tmp > M:
    print("0")

else:
    print((M//tmp+1)//2)
Buggy code:
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while b:
        a,b = b,a%b
    return a

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

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

if(all(A[0]%2 == a%2 for a in A)):
    lcm_A = lcm(A[0],A[1])
    for a in A[2:]:
        lcm_A = lcm(lcm_A,a)
    print((M/lcm_A+1)//2)
else:
    print(0)



Fixed code:
def cnt_div2(n):
    cnt=0
    while n%2==0:
        n//=2
        cnt+=1
    return cnt
def gcd(a,b):
    a,b = max(a,b),min(a,b)
    while b:
        a,b = b,a%b
    return a

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

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

if(all(cnt_div2(A[0]) == cnt_div2(a) for a in A)):
    if N==1:
        lcm_A = A[0]
    else:
        lcm_A = lcm(A[0],A[1])
        for a in A[2:]:
            lcm_A = lcm(lcm_A,a)
    print(int((M/lcm_A+1)//2))
else:
    print(0)
Buggy code:
#  --*-coding:utf-8-*--

def gcd(n, m):
    while m > 0:
        n, m = m, n%m

    return n

def f(M, A):
    lcm = 1

    for a in A:
        g = gcd(lcm, a)
        lcm = lcm*a//g

        if lcm > M:
            return 0

    for a in A:
        if lcm//a%2 == 0:
            return 0

    return (M-lcm)//(2*lcm) + 1
            


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

    print(f(M,A))

    


Fixed code:
#  --*-coding:utf-8-*--

def gcd(n, m):
    while m > 0:
        n, m = m, n%m

    return n

def f(M, A):
    lcm = 1

    for a in A:
        g = gcd(lcm, a)
        lcm = lcm*a//g

        if lcm > M:
            return 0

    for a in A:
        if lcm//a%2 == 0:
            return 0

    return (M-lcm)//(2*lcm) + 1
            


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

    print(f(M,A))

    



if __name__ == '__main__':
    main()
Buggy code:
import math
import sys
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)

C = gcd_list(A)
B = [0 for _ in range(N)]

for i in range(N):
  B[i] = C // A[i]
  if B[i] % 2 == 0:
    print(0)
    sys.exit()

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

Fixed code:
import math
import sys
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
  
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

C = lcm_list(A)
B = [0 for _ in range(N)]

for i in range(N):
  B[i] = C // A[i]
  if B[i] % 2 == 0:
    print(0)
    sys.exit()

print( (M // C + 1) // 2)
Buggy code:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=[ai//2 for ai in a]
# print(half_a)
lcm=half_a[0]
for i in range(n-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow_cnt=0
tmp=half_a[0]
while tmp%2==0:
    pow_cnt+=1
    tmp=tmp//2
flag=True
for ai in half_a[1:]:
    if ai%pow2[pow_cnt]==0:
        flag=False
        break
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)

Fixed code:
import math
n,m=map(int,input().split())
a=list(map(int,input().split()))
half_a=[ai//2 for ai in a]
# print(half_a)
lcm=half_a[0]
for i in range(n-1):
    a,b=lcm,half_a[i+1]
    lcm=a*b//math.gcd(a,b)
# print(lcm)
pow_cnt=0
tmp=half_a[0]
while tmp%2==0:
    pow_cnt+=1
    tmp=tmp//2
flag=True
for ai in half_a[1:]:
    if ai%(2**pow_cnt)!=0:
        flag=False
        break
    elif  ai%(2**(pow_cnt+1))==0:
        flag=False
        break
if flag:
    print(math.ceil(m//lcm/2))
else:
    print(0)
Buggy code:
n,m=map(int,input().split())
a=[ i //2 for i in list(map(int,input().split()))]
def f(x):
  c=0
  while(x%2==0):
    x//=2
    c+=1
  return c
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
def lcm(a,b):
  return a//gcd(a,b)*b

t=f(a[0])
for i in range(len(a)):
  if t!=f(a[i]):
    exit(0)
  a[i]//=2**t
m//=2**t
l=1
for i in a:
  l=lcm(l,i)
  if l>m:
    print(0)
    exit(0)
m//=l
print((m+1)//2)

Fixed code:
n,m=map(int,input().split())
a=[ i //2 for i in list(map(int,input().split()))]
def f(x):
  c=0
  while(x%2==0):
    x//=2
    c+=1
  return c
def gcd(a,b):
  if b==0:
    return a
  return gcd(b,a%b)
def lcm(a,b):
  return a//gcd(a,b)*b

t=f(a[0])
for i in range(len(a)):
  if t!=f(a[i]):
    print(0)
    exit(0)
  a[i]//=2**t
m//=2**t
l=1
for i in a:
  l=lcm(l,i)
  if l>m:
    print(0)
    exit(0)
m//=l
print((m+1)//2)
Buggy code:
import itertools

def main():
    input_line = map(int,input().split(' '))
    n,m = input_line
    a = list(map(lambda x:int(x)//2,input().split(' ')))
    print(a)
    glc = 1
    for i in range(len(a)):
        glc = a[i]*glc//GCD(a[i],glc)
    print(glc)
    print(((m//glc)+1)//2)
    return 


def GCD(a,b):
    if a < b:
        a,b = b,a
        

    while a % b !=0 :
        n = a % b
        a = b
        b = n
    return b

if __name__ == "__main__":
    main()


Fixed code:
import itertools

def main():
    input_line = map(int,input().split(' '))
    n,m = input_line
    a = list(map(lambda x:int(x)//2,input().split(' ')))

    pre_j = 0
    for i in range(len(a)):
        j=0
        while(a[i]%(2**j)==0):
            j+=1
        if i==0:
            pre_j=j
        if pre_j != j:
            print(0)
            return 0

    glc = 1
    for i in range(len(a)):
        glc = a[i]*glc//GCD(a[i],glc)
    print(((m//glc)+1)//2)
    return 


def GCD(a,b):
    if a < b:
        a,b = b,a
        
    while a % b !=0 :
        n = a % b
        a = b
        b = n
    return b

if __name__ == "__main__":
    main()
Buggy code:
import sys

def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

n,m=map(int,input().split())
a=tuple(map(int,input().split()))
a.sort()
lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm,i)
for i in a:
    if (lcm//i)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)

Fixed code:
import sys

def gcd(x,y):
    while y:
        x,y = y , x % y 
    return x

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

lcm = 1
for i in a:
    lcm = lcm * i // gcd(lcm,i)
for i in a:
    if (lcm//i)%2 == 0:
        print(0)
        sys.exit()
print((m+lcm//2)//lcm)
Buggy code:
N, M = map(int, input().split())
a = list(map(int, input().split()))
a = list(set(a))
N = len(a)
for k in range(N):
  a[k] //= 2


count = 0
foo = 1

while a[0]%2 == 0:
  foo *= 2
  a[0] // 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

for odd in [3, 5, 7, 11]:
  flag = False
  for k in range(N):
    if a[k]%odd == 0:
      a[k] //= odd
      flag = True
  if flag:
    foo *= odd
 

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

lcm = a[0]
for k in range(1, N):
  lcm = lcm * a[k] // euclid(lcm, a[k])
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)



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

foo = 1
while a[0]%2 == 0:
  foo *= 2
  a[0] //= 2
for k in range(1, N):
  if a[k] % foo == 0 and a[k]%(2*foo) !=0:
    a[k] //= foo
    continue
  else:
    print(0)
    exit()
ans = 0

for odd in [3, 5, 7, 11]:
  flag = False
  for k in range(N):
    if a[k]%odd == 0:
      a[k] //= odd
      flag = True
  if flag:
    foo *= odd
 
 
def euclid(a, b):
  while b:
    a, b = b, a%b
  return a

lcm = a.pop()
for k in range(1, N):
  b = a.pop()
  lcm = lcm * b // euclid(lcm, b)
  if lcm* foo > M:
    print(0)
    exit()
lcm *= foo
ans = int((M / lcm -1)//2 + 1)
print(ans)
Buggy code:
from math import gcd
from functools import reduce

n,m=map(int,input().split())
lst=list(map(lambda x : int(x)//2,input().split()))
divi=lst[0]//2
for i in range(1,n):
    if lst[i]//2!=divi:
        print(0)
        exit()

work=reduce(lambda x,y: x*y//gcd(x,y),lst)
print((m//work+1)//2)

Fixed code:
from math import gcd
from functools import reduce

n,m=map(int,input().split())
lst=list(map(lambda x : int(x)//2,input().split()))
divi=0
x=lst[0]
while x%2==0:
    x//=2
    divi+=1

for i in range(1,n):
    divi2=0
    x=lst[i]
    while x%2==0:
        x//=2
        divi2+=1
    if divi!=divi2 :
        print(0)
        exit()

work=reduce(lambda x,y: x*y//gcd(x,y),lst)
print((m//work+1)//2)
Buggy code:
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

    def gcd(v1, v2):
        while v1 % v2 != 0:
            tmp = v2
            v2 = v1 % v2
            v1 = tmp
        return v2

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    alcm = 1
    for a in A:
        d = gcd(alcm, a)
        lcm = lcm * a // d
        if alcm > M:
            print(0)
            exit()

    # a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)

    if a_lcm > M:
        print(0)
    else:
        print((M // a_lcm + 1) // 2)


main()


Fixed code:
# from math import sqrt
# from heapq import heappush, heappop
# from collections import deque
from functools import reduce

# a, b = [int(v) for v in input().split()]


def main():
    N, M = [int(v) for v in input().split()]
    A = list(set([int(v) // 2 for v in input().split()]))

    def func(a):
        count = 0
        while a % 2 == 0:
            count += 1
            a //= 2
        return count

    fa = func(A[0])
    for a in A[1:]:
        if func(a) != fa:
            print(0)
            exit()

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

    def lcm(v1, v2):
        return v1 * v2 // gcd(v1, v2)

    a_lcm = 1
    for a in A:
        d = gcd(a_lcm, a)
        a_lcm = a_lcm * a // d
        if a_lcm > M:
            print(0)
            exit()

    # a_lcm = reduce(lambda v1, v2: lcm(v1, v2), A)

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


main()
Buggy code:
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

N,M = map(int,input().split())
a = list(map(lambda a: int(a)//2, input().split()))
g = lcm(*a)
if any([2 * g // item % 2 == 0 for item in a]):
    print(0)
else:
    ans = M//g
    ans = max(math.ceil(ans/2),0)   
    print(ans)

Fixed code:
import math
from functools import reduce
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)

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

N,M = map(int,input().split())
a = list(map(lambda a: int(a)//2, input().split()))
g = lcm(*a)
if any([g // item % 2 == 0 for item in a]):
    print(0)
else:
    ans = M//g
    ans = max(math.ceil(ans/2),0)   
    print(ans)
Buggy code:
from math import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [i // 2 for i in a]
l = 1
for a in A:
    lcd *= a // gcd(lcd, a)
for a in A:
    if lcd // a % 2 == 0:
        print(0)
        exit()
print((M//lcd+1)//2)


Fixed code:
from math import gcd
N, M = map(int, input().split())
A = list(map(int, input().split()))
A = [i // 2 for i in A]
lcd = 1
for a in A:
    lcd *= a // gcd(lcd, a)
for a in A:
    if lcd // a % 2 == 0:
        print(0)
        exit()
print((M//lcd+1)//2)
Buggy code:
def lcm(a, b):
  return a // gcd(a, b) * b

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

def cnt(a):
  res = 0
  while(a and a % 2 == 0):
    a //= 2
    res += 1
  return res

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

l = 1
c = cnt(A[0])
for a in A:
  if cnt(a) != c or c == 1:
    print(0)
    exit()
  else:
    l = lcm(l, a)
d = m // l
print((d + 1) // 2)

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

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

def cnt(a):
  res = 0
  while(a and a % 2 == 0):
    a //= 2
    res += 1
  return res

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

l = 1
c = cnt(A[0])
for a in A:
  if cnt(a) != c or c == 0:
    print(0)
    exit()
  else:
    l = lcm(l, a // 2)
d = m // l
print((d + 1) // 2)
Buggy code:
from math import gcd, ceil
from functools import reduce
import sys

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

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

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

if N == 1:
    print((M//a[0]+1)//2)
    sys.exit()

A = []
s = set()
for x in a:
    cur = 0
    y = x
    while y%2 == 0:
        cur += 1
        y //= 2
    s.add(cur)
    if len(s) >= 2:
        print(0)
        sys.exit()
lcm = lcm_list(A)
print((M//lcm+1)//2)

Fixed code:
from math import gcd, ceil
from functools import reduce
import sys

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

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

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

s = set()
for x in a:
    cur = 0
    y = x
    while y%2 == 0:
        cur += 1
        y //= 2
    s.add(cur)
    if len(s) >= 2:
        print(0)
        sys.exit()
lcm = lcm_list(a)
print((M//lcm+1)//2)
Buggy code:
from functools import reduce
import math
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 = [i//2 for i in list(set(a))]

cnt_common = -1
for i in a:
  cnt = 0
  while i % 2 == 0:
    i = i//2
    cnt += 1
  if cnt_common == -1:
    cnt_common = cnt
    continue
  if cnt_common != cnt:
    nothing = True
    break

b=lcm_list(a)
if nothing:
  print(0)
else:
  ans = (m-b)//(2*b) + 1
  print(max(ans,0))

Fixed code:
from functools import reduce
import math
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 = [i//2 for i in list(set(a))]
nothing = False
cnt_common = -1
for i in a:
  cnt = 0
  while i % 2 == 0:
    i = i//2
    cnt += 1
  if cnt_common == -1:
    cnt_common = cnt
    continue
  if cnt_common != cnt:
    nothing = True
    break

b=lcm_list(a)
if nothing:
  print(0)
else:
  ans = (m-b)//(2*b) + 1
  print(max(ans,0))
Buggy code:
import sys

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

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

GCD = 1
t = a[0]
cond = 0
while t%2 == 0:
	t //= 2
	cond += 1
	
mod = 2**cond
for i in range(len(a)):
	t = a[i]
	t_div,t_mod = divmod(t,mod)
	if t_div == 0:
		print(0)
		sys.exit()
	if mod != 0:
		print(0)
		sys.exit()
	if t_div % 2 == 0:
		print(0)
		sys.exit()


	GCD = GCD*a[i] // gcd(GCD,a[i])
	
A = (2*m) // GCD
if A%2 == 1:
	A+=1

print(A//2)

Fixed code:
import sys

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

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

GCD = 1
t = a[0]
cond = 0
while t%2 == 0:
	t //= 2
	cond += 1
	
mod = 2**cond
for i in range(len(a)):
	t = a[i]
	t_div, t_mod = divmod(t,mod)
	if t_div == 0 or t_mod > 0:
		print(0)
		sys.exit()
	if t_div % 2 == 0:
		print(0)
		sys.exit()

	GCD = GCD*a[i] // gcd(GCD,a[i])
	
A = (2*m) // GCD
if A%2 == 1:
	A+=1

print(A//2)
Buggy code:
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]//=2
x=a[0]
for j in range(30):
    if x%2==0:
        x//=2
    else:
        p=j
for i in range(1,n):
    x=a[i]
    for j in range(30):
        if x%2==0:
            x//=2
        else:
            if p!=j:
                print(0)
                exit()
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // gcd(ans, a[i])
    if ans>m:
        print(0)
        exit()
if (m//ans)%2==0:
    print(m//ans//2)
else:
    print(m//ans//2+1)

Fixed code:
def gcd(a,b):
    while b:
        a,b=b,a%b
    return a
n,m=map(int,input().split())
a=list(map(int,input().split()))
for i in range(n):
    a[i]//=2
x=a[0]
for j in range(30):
    if x%2==0:
        x//=2
    else:
        p=j
        break
for i in range(1,n):
    x=a[i]
    for j in range(30):
        if x%2==0:
            x//=2
        else:
            if p!=j:
                print(0)
                exit()
            break
ans = a[0]
for i in range(1, n):
    ans = ans * a[i] // gcd(ans, a[i])
    if ans>m:
        print(0)
        exit()
if (m//ans)%2==0:
    print(m//ans//2)
else:
    print(m//ans//2+1)
Buggy code:
from math import gcd
import sys

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

lcm = 1
for a in A:
    gcd_ = gcd(lcm, a//2)
    lcm = lcm * (a // 2 // gcd_)
for a in A:
    if lcm // (a // 2) % 2 == 1:
        print(0)
        sys.exit()

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


Fixed code:
from math import gcd
import sys

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

lcm = 1
for a in A:
    gcd_ = gcd(lcm, a//2)
    lcm = lcm * (a // 2 // gcd_)
for a in A:
    if (lcm // (a // 2)) % 2 == 0:
        print(0)
        sys.exit()

print(M // lcm - M // (2 * lcm))
Buggy code:
from math import gcd, ceil


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


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

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

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

ok = True
for aa in a:
    if (lcm_v//aa) % 2 != 1:
        ok = False
        break

if ok:
    ans = ((m//lcm_v)+1)//2
print(ans)

Fixed code:
from math import gcd, ceil


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


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

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

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

ok = True
for aa in a:
    if (lcm_v//aa) % 2 != 1:
        ok = False
        break
ans = 0
if ok:
    ans = ((m//lcm_v)+1)//2
print(ans)
Buggy code:
import math
from functools import reduce
from copy import deepcopy
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)
Acopy = deepcopy(A)
flag = -1
for i in range(n):
  cnt = 0
  while True:
    if Acopy[i] % 2 == 1:
      break
    else:
      Acopy[i] //= 2
      cnt += 1
  if i == 0:
    flag = cnt
  else:
    if flag != cnt:
      print(0)
      break
else:
  A = [a//2 for a in A]
  lcm = lcm_list(A)
  ans = 0
  for t in range(lcm,m,2*lcm):
    ans += 1
  print(ans)


Fixed code:
import math
from functools import reduce
from copy import deepcopy
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)
Acopy = deepcopy(A)
flag = -1
for i in range(n):
  cnt = 0
  while True:
    if Acopy[i] % 2 == 1:
      break
    else:
      Acopy[i] //= 2
      cnt += 1
  if i == 0:
    flag = cnt
  else:
    if flag != cnt:
      print(0)
      break
else:
  A = [a//2 for a in A]
  lcm = lcm_list(A)
  print((lcm+m)//2//lcm)
Buggy code:
N, M = map(int,input().split())
A = list(map(int,input().split()))
# 17:22

import sys
from math import gcd
def lcm(a,b):
    return a//gcd(a,b)*b
#%%
ans = 0
L = 1
for i in range(N):
    L = lcm(L, A[i])
    if L>2*M:
        print(0)
        sys.exit()

L2 = L
L1 = L//2
for a in A:
    if (L1//a)&1==0:
        print(0)
        sys.exit()
ans = M//L1 - M//L2
print(ans)


Fixed code:
N, M = map(int,input().split())
A = list(map(int,input().split()))
# 17:22

import sys
from math import gcd
def lcm(a,b):
    return a//gcd(a,b)*b
#%%
ans = 0
L = 1
for i in range(N):
    L = lcm(L, A[i])
    if L>2*M:
        print(0)
        sys.exit()

L2 = L
L1 = L//2
for a in A:
    if (L//a)&1==0:
        print(0)
        sys.exit()
ans = M//L1 - M//L2
print(ans)
Buggy code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
p = 0
for i in A:
  if i % 2 == 0:
    i //= 2
  else:
    p = 1
    break
L = A[0]
k = 0
while A[0] % 2 == 0:
  k += 1
  A[0] //= 2
for i in range(1, N):
  a, b = L, A[i]
  while b != 0:
    a, b = b, a % b
  b = A[i] // a
  L *= b
  cnt = 0
  while A[i] % 2 == 0:
    cnt += 1
    A[i] //= 2
  if cnt != k:
    p = 1
    break
if p == 1:
  S = 0
else:
  S = M // L - M // (2 * L)
print(S)

Fixed code:
N, M = map(int, input().split())
A = list(map(int, input().split()))
p = 0
for i in range(N):
  if A[i] % 2 == 0:
    A[i] //= 2
  else:
    p = 1
    break
L = A[0]
k = 0
while A[0] % 2 == 0:
  k += 1
  A[0] //= 2
for i in range(1, N):
  a, b = L, A[i]
  while b != 0:
    a, b = b, a % b
  b = A[i] // a
  L *= b
  cnt = 0
  while A[i] % 2 == 0:
    cnt += 1
    A[i] //= 2
  if cnt != k:
    p = 1
    break
if p == 1:
  S = 0
else:
  S = M // L - M // (2 * L)
print(S)