Problem p02814 (python)

Fixed submission:
import math
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1): #2のi乗ですべての数が割れるかどうか
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)

if buf!=0 and buf!=n: #偶奇が入り混じってるとき
    print(0)
elif n==1: #配列の要素が1つしかないとき
    d=int(m//b[0])
    print(int((d+1)//2))
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Buggy submission (verdict: Runtime Error):
import math
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
s=math.floor(math.log2(max(a)))
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))

for i in range(s+1):
    for j in b:
        if j%(2**i)==0:
            buf+=1
        else:
            continue
    if buf==n:
        buf=0
        continue
    else:
        break

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)

if buf!=0 and buf!=n:
    print(0)
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
buf=0
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]//2))
    if (a[i]//2)%2!=0:
        buf+=1
    else:
        continue

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)
  
if buf!=0 and buf!=n:
    print(0)
else:
    c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
    for i in range(1,n):
        x=lcm(c[i-1],b[i])
        c.append(x)
        if x<m:
            continue
        else:
            break
    
    d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
    ans=int((d+1)//2)
    print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
for i in range(n): #aは偶数なので、1/2した値の配列を作った
    b.append(int(a[i]/2))

def lcm(x,y): #最小公倍数を求める関数の定義
    return (x*y)//fractions.gcd(x,y)

c=[lcm(b[0],b[1])] #以下のサイクルで求めた最小公倍数を入れる配列
for i in range(1,n):
    x=lcm(c[i-1],b[i])
    c.append(x)
    if x<m:
        continue
    else:
        break

d=int(m//c[len(c)-1]) #最後の値(c[len(c)-1])が配列bの最小公倍数
ans=int((d+1)//2)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
for i in range(n):
    b.append(int(a[i]/2))

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

c=[lcm(b[0],b[1])]
for i in range(1,n):
    x=lcm(c[i-1],b[i])
    c.append(x)

d=int(m//c[len(c)-1])
ans=int((d+1)//2)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
for i in range(n):
    b.append(int(a[i]/2))

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

c=[lcm(b[0],b[1])]
for i in range(1,n):
    x=lcm(c[i-2],b[i])
    c.append(x)

d=int(m//c[len(c)-1])
ans=int((d+1)//2)
print(ans)

Buggy submission (verdict: Runtime Error):
import fractions
n,m=map(int, input().split())
a=list(map(int, input().split()))
b=[]
ans=0
for i in range(n):
    b.append(int(a[i]/2))

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

c=[lcm(b[0],b[1])]
for i in range(1,n):
    x=lcm(c[i-2],b[i])
    c.append(x)

d=int(m//c[len(c)-1])
for i in range(1, d+1):
    if i%2!=0:
        ans+=1
    else:
        continue
print(ans)