Problem p02814 (python)

Fixed submission:
N, M = map(int, input().split())
A = list(set(map(lambda x : int(x)//2, input().split())))
def gcd(x, y):
  return x if y == 0 else gcd(y, x % y)
def lcm(x, y):
  return (x * y) // gcd(x, y)
l = A[0]
for a in A[1:]:
  l = lcm(l, a)
ans = (M // l + 1) // 2
for a in A[1:]:
  if (l // a) % 2 == 0:
    ans = 0
    break
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M = map(int,input().split())
List=list(map(int,input().split()))
aa = int(lcm_list(List)/2)
cnt = 0
a = List[0]
while a%2 == 0:
  cnt+=1
  a = int(a/2)
out = 0
if cnt == 0:
  out = 1
  cnt = 1
for i in range(len(List)):
  if List[i] % (2**cnt) > 0:
    out = 1
  if List[i] % (2**(cnt+1)) == 0:
    out = 1

if out == 1:
  print(0)
else:
  print(int(math.ceil((M / aa)) // 2))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
def lcm_base(x, y):
    return int((x * y) // fractions.gcd(x, y))
def lcm_list(numbers):
    return int(reduce(lcm_base, numbers, 1))

N,M = map(int,input().split())
List=list(map(int,input().split()))
aa = int(lcm_list(List)/2)
cnt = 0
a=List[0]
while a%2 == 0:
  cnt+=1
  a = int(a/2)
out = 0
if cnt == 0:
  out = 1
  cnt = 1
for i in range(len(List)):
  if List[i] % (2**cnt) > 0:
    out = 1
  elif List[i] % (2**(cnt+1)) == 0:
    out = 1

if out == 1:
  print(0)
else:
  print(int(math.ceil((M / aa)) // 2))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
def lcm_base(x, y):
    return int((x * y) // fractions.gcd(x, y))
def lcm_list(numbers):
    return int(reduce(lcm_base, numbers, 1))

N,M = map(int,input().split())
List=list(map(int,input().split()))
aa = int(lcm_list(List)/2)
cnt = 0
a=List[0]
while a%2 == 0:
  cnt+=1
  a = int(a/2)
out = 0
if cnt == 0:
  out = 1
  cnt = 1
for i in range(len(List)):
  if List[i] % (2**cnt) == 1:
    out = 1
  elif List[i] % (2**(cnt+1)) == 0:
    out = 1

if out == 1:
  print(0)
else:
  print(int(math.ceil((M / aa)) // 2))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
def lcm_base(x, y):
    return int((x * y) // fractions.gcd(x, y))
def lcm_list(numbers):
    return int(reduce(lcm_base, numbers, 1))

N,M = map(int,input().split())
List=list(map(int,input().split()))
aa = int(lcm_list(List)/2)
cnt = 0
a=List[0]
while a%2 == 0:
  cnt+=1
  a = int(a/2)
out = 0
if cnt == 0:
  out = 1
  cnt = 1
for i in range(len(List)):
  if List[i] % (2**cnt) == 1:
    out = 1
  elif List[i] % (2**(cnt+1)) == 0:
    out = 1

if out == 1:
  print(0)
else:
  print(int(math.ceil((M / aa)) // 2))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M = map(int,input().split())
List=list(map(int,input().split()))
aa = int(lcm_list(List)/2)
cnt = 0
a=List[0]
while a%2 == 0:
  cnt+=1
  a = int(a/2)
out = 0
if cnt == 0:
  out = 1
  cnt = 1
for i in range(len(List)):
  if List[i] % (2**cnt) == 1:
    out = 1
  elif List[i] % (2**(cnt+1)) == 0:
    out = 1

if out == 1:
  print(0)
else:
  print(int(math.ceil((M / aa)) // 2))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

N,M = map(int,input().split())
List=list(map(int,input().split()))
aa = int(lcm_list(List)/2)
cnt = 0
a=List[0]
while a%2 == 0:
  cnt+=1
  a = int(a/2)
out = 0
if cnt == 0:
  out = 1
  cnt = 1
for i in range(len(List)):
  if List[i] % (2**cnt) == 1:
    out = 1
  elif List[i] % (2**(cnt+1)) == 1:
    out = 1

if out == 1:
  print(0)
else:
  print(int(math.ceil((M / aa)) // 2))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
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())
List=list(map(int,input().split()))
aa = int(lcm_list(List) / 2)
cnt = 0
a=List[0]
while a%2 == 0:
  cnt+=1
  a /= 2
out = 0
if cnt == 0:
  out = 1
  cnt = 1
for i in range(len(List)):
  if List[i] % (2**cnt) == 1:
    out = 1
  elif List[i] % (2**(cnt+1)) == 1:
    out = 1

if out == 1:
  print(0)
else:
  print(int(math.ceil((M / aa)) // 2))

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
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())
List=list(map(int,input().split()))
aa = lcm_list(List) / 2
cnt = 0
a=List[0]
while a%2 == 0:
  cnt+=1
  a /= 2
out = 0
if cnt == 0:
  out = 1
  cnt = 1
for i in range(len(List)):
  if List[i] % (2**cnt) == 1:
    out = 1
  elif List[i] % (2**(cnt+1)) == 1:
    out = 1

if out == 1:
  print(0)
else:
  print(math.ceil((M / aa)) // 2)

Buggy submission (verdict: Runtime Error):
import fractions
from functools import reduce
import math
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())
List=list(map(int,input().split()))
aa = lcm_list(List) / 2
cnt = 0
a=List[0]
while a%2 == 0:
  cnt+=1
  a /= 2
out = 0
for i in range(len(List)):
  if List[i] % (2**cnt) == 1:
    out = 1
  elif List[i] % (2**(cnt+1)) == 1:
    out = 1

if out == 1:
  print(0)
else:
  print(math.ceil((M / aa)) // 2)

Buggy submission (verdict: Runtime Error):
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))