TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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).

Submission attempts (in order):
from fractions 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 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)



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

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
cnt = [0 for i in range(len(A))]
for i in range(len(A)):
    a = A[i]
    l = lcm(l, a)
    count = 0
    while True:
        if a % 2 == 0:
            a //= 2
            count += 1
        else:
            cnt[i] = count
            break
count = cnt[0]
flag = True
for i in range(len(A)):
    if cnt[i] != count:
        flag = False
        break
if flag:
    l = l // 2
    ans = M // l
    print((ans+1)//2)
else:
    print(0)

Verdicts: Time Limit Exceeded

Accepted
Problem: 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).

Submission attempts (in order):
import numpy as np

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

while True:
    aa=aa//2
    if (aa%2).any()==1:
      break
     
if (aa%2).all()!=1:
  print(0);exit()

t=list(set(aa))


import fractions as fr
from functools import reduce

def gcd(*numbers):
    return reduce(fr.gcd, numbers)

def gcd_list(numbers):
    return reduce(fr.gcd, numbers)


lcm=np.prod(t)//gcd_list(t)

print(int((m/lcm+1)//2))



import numpy as np

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

while True:
    aa=aa//2
    if (aa%2).any()==1:
      break

print(aa)      
if (aa%2).all()!=1:
  print(0);exit()

t=list(set(aa))


import fractions as fr
from functools import reduce

def gcd(*numbers):
    return reduce(fr.gcd, numbers)

def gcd_list(numbers):
    return reduce(fr.gcd, numbers)


lcm=np.prod(t)//gcd_list(t)

print(int((m/lcm+1)//2))



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

b=set([(i//2)%2 for i in a])
c=set([i//2 for i in a])
if 0 in b:
    print(0)
    exit()

    
import fractions as fr
from functools import reduce

def gcd(*numbers):
    return reduce(fr.gcd, numbers)

def gcd_list(numbers):
    return reduce(fr.gcd, numbers)

kk=1
for i in list(c):
  kk*=i
low=(kk)//gcd_list(list(c))


    
print(m//low//2+1)

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

def dividable_with_2(x):
  cnt=0
  while x%2==0:
    x//=2
    cnt+=1
  return cnt

eg=dividable_with_2(a[0])

for q in a:
  if dividable_with_2(q) != eg:
    print(0)
    exit()

def gcd(x,y):
  if y>x:
    y,x=x,y    
  while y!=0:
    x,y=y,x%y
  return x

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

d=[i//2 for i in a]
L=d[0]
for i in range(n):
  L=lcm(L,d[i])

ans=(m//L+1)//2

print(ans)

  
  

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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 my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


n, m = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
res, div2 = 0, None
for ai in a_pr:
    cnt = 0
    while a % 2 == 0:
        a //= 2
        cnt += 1
    if div2 is None:
        div2 = cnt
    elif cnt != div2:
        print(0)
        exit()

print(int(my_round(m // lcm_ / 2)))


import fractions
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
a = [int(i/2) for i in a]
num_gcd = a[0]
for i in range(1, n):
    num_gcd = num_gcd * a[i] // fractions.gcd(num_gcd, a[i])
print(round((m // num_gcd) / 2))


import fractions
import math
n, m = list(map(int, input().split()))
a = sorted(list(map(int, input().split())))
a = [int(i/2) for i in a]
num_gcd = a[0]
for i in range(1, n):
    num_gcd = num_gcd * a[i] // fractions.gcd(num_gcd, a[i])
print(math.ceil((m // num_gcd) / 2))


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 my_round(val, digit=0):
    p = 10 ** digit
    return (val * p * 2 + 1) // 2 / p


n, m = list(map(int, input().split()))
a_pr = [i // 2 for i in list(map(int, input().split()))]
lcm_ = lcm_list(a_pr)
res, div2 = 0, None
for ai in a_pr:
    cnt = 0
    while ai % 2 == 0:
        ai //= 2
        cnt += 1
    if div2 is None:
        div2 = cnt
    elif cnt != div2:
        print(0)
        exit()

print(int(my_round(m // lcm_ / 2)))


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
from fractions import gcd


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


n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
g1 = a[0]
g2 = a[0] // 2
t = 0
k = a[0]
while k % 2 == 0:
    k //= 2
    t += 1
for i in range(n):
    c = 0
    g1 = lcm(g1, a[i])
    if g1 > m:
        break
    while a[i] % 2 == 0:
        a[i] //= 2
        c += 1
    if c != t:
        print(0)
        exit(0)
for i in range(n):
    g2 = lcm(g2, a[i])
    if g2 > m:
        break
print(m // g2 - m // g1)


from fractions import gcd


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


n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
g1 = a[0]
g2 = a[0] // 2
t = 0
k = a[0]
while k % 2 == 0:
    k //= 2
    t += 1
for x in a:
    c = 0
    g1 = lcm(g1, x)
    if g1 > m:
        break
    while x % 2 == 0:
        x //= 2
        c += 1
    if c != t:
        print(0)
        exit(0)
for i in range(n):
    g2 = lcm(g2, a[i] // 2)
    if g2 > m:
        break
print(m // g2 - m // g1)


from fractions import gcd


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


n, m = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
g1 = a[0]
g2 = a[0] // 2
for i in range(n):
    g1 = lcm(g1, a[i])
    if g1 > m:
        break
for i in range(n):
    g2 = lcm(g2, a[i] // 2)
    if g2 > m:
        break
print(m // g2 - m // g1)


from math import gcd

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
l = [0] * n
for i in range(n):
    tmp = a[i]
    while tmp % 2 == 0:
        tmp //= 2
        l[i] += 1
    if i > 0 and l[i] != l[i - 1]:
        print(0)
        exit(0)
res = 1
for i in range(n):
    res = lcm(res, a[i] // 2)
print(m // res - m // (res * 2))


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n , m = map(int, input().split())
a = list(map(int,input().split()))

def gcd(num1,num2):
    r=1
    while r>0:
        r=num1%num2
        num1=num2
        num2=r
    return num1

def lcm(num1,num2):
    gcd1=gcd(num1,num2)
    return num1*num2//gcd1

lcm1=a[0]//2
lcm2=a[0]

for i in range(1,n):
    t=a[i]
    if lcm1//(t//2)%2==0:
        lcm1=0
        lcm2=0
    lcm1=lcm(lcm1,t//2)
    lcm2=lcm(lcm2,t)


if lcm1!=0:
    ans1=m//lcm1
    ans2=m//lcm2
    ans=ans1-ans2
else:
    ans=0

print(ans)


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

def gcd(num1,num2):
    r=1
    while r>0:
        r=num1%num2
        num1=num2
        num2=r
    return num1

def lcm(num1,num2):
    gcd1=gcd(num1,num2)
    return num1*num2//gcd1

lcm1=a[0]//2
lcm2=a[0]

for i in range(1,n):
    t=a[i]
    lcm1=lcm(lcm1,t//2)
    lcm2=lcm(lcm2,t)
    ta=max(t//2,lcm1)
    tb=min(t//2,lcm1)
    if ta!=tb and ta//tb%2==0:
        lcm1=0
        lcm2=0
        break

if lcm1!=0:
    ans1=m//lcm1
    ans2=m//lcm2
    ans=ans1-ans2
else:
    ans=0

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):

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

#print(A)

while not any(a % 2 for a in A):
    A = [a // 2 for a in A]

#print(A)
#print(all(a % 2 for a in A))

if not all(a % 2 for a in A):
    print(0)
    exit()
    
#print(1)

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b // gcd(a, b)
    
ans = 1
for i in A:
    ans = lcm(ans, i)

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

#import sys

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

N = len(A)
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

LCM = A[0]
for i in range(1, N): 
    LCM = lcm(LCM, A[i])
    print(LCM)
    
if LCM > M:
    ans = 0
else:
    M //= LCM
    ans = (M + 1) // 2

print(ans)

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

A = list(set(map(int, input().split(" "))))
G = A.copy()
 
while not any(x % 2 for x in G):
    G = [i // 2 for i in G]
 
if not all(x % 2 for x in G):
    print(0)
    exit(0)
    
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
    
def lcm(a, b):
    return a * b // gcd(a, b)
    
total = 1

for x in A:
    total = lcm(total, x // 2)

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

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def gcd(a, b):
    while b != 0:
        a, b = b, a % b
    return(a)

def lcm(a, b):
    return a*b//gcd(a,b)
#import sys
#input = sys.stdin.readline
def main():
    N, M = map( int, input().split())
    A = list( map( int, input().split()))
    B = [a for a in A]
    T = 1
    L = 1
    C = [0]*N
    for i in range(30):
        if B[i]%2 == 0:
            B[i] //= 2
            C[i] += 1
    p = C[0]
    for i in range(N-1):
        if p != C[i+1]:
            print(0)
            return
    q = pow(2,p)
    t = 1
    for i in range(N):
        t = lcm(1,t)
    m = t*q
    if m > M:
        print(0)
        return
    print((M-m)//(q*t)+1)

if __name__ == '__main__':
    main()

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

def lcm(a, b):
    return a*b//gcd(a,b)
#import sys
#input = sys.stdin.readline
def main():
    N, M = map( int, input().split())
    A = list( map( int, input().split()))
    B = [a for a in A]
    T = 1
    L = 1
    C = [0]*N
    for i in range(N):
        for _ in range(30):
            if B[i]%2 == 0:
                B[i] //= 2
                C[i] += 1
            else:
                break
    p = C[0]
    for i in range(N-1):
        if p != C[i+1]:
            print(0)
            return
    q = pow(2,p)
    t = 1
    for i in range(N):
        t = lcm(t,B[i])
    m = t*q//2
    if m > M:
        print(0)
        return

    print((M-m)//m+1)

if __name__ == '__main__':
    main()



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

def lcm(a, b):
    return a*b//gcd(a,b)
#import sys
#input = sys.stdin.readline
def main():
    N, M = map( int, input().split())
    A = list( map( int, input().split()))
    B = [a for a in A]
    T = 1
    L = 1
    C = [0]*N
    for i in range(N):
        for _ in range(30):
            if B[i]%2 == 0:
                B[i] //= 2
                C[i] += 1
            else:
                break
    p = C[0]
    for i in range(N-1):
        if p != C[i+1]:
            print(0)
            return
    q = pow(2,p)
    t = 1
    for i in range(N):
        t = lcm(t,A[i]//2)
    if t > M:
        print(0)
        return

    print((M-t)//(t*2) + 1)

if __name__ == '__main__':
    main()



Verdicts: Runtime Error

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
import fractions
n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in a]

def f(x):
  cnt = 0
  while x%2 == 0:
    x /= 2
    cnt += 1
  return cnt

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    print(0)
    break
  a[i] //= 2 ** t

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

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

n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in a]

def f(x):
  cnt = 0
  while x%2 == 0:
    x /= 2
    cnt += 1
  return cnt

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

t = f(a[0])
for i in range(1, t):
  if f(a[i]) != t:
    print(0)
    break
  a[i] >>= t
m >>= t

L = a[0]
for i in range(1, n):
  L = lcm(L, a[i])
  if L > M:
    print(0)
    break

m //= L
ans = (m+1) // 2
print(ans)

import sys

def f(x):
  cnt = 0
  while x%2 == 0:
    x /= 2
    cnt += 1
  return cnt

def gcd(x, y):
  if y:
    return gcd(y, x%y)
  else:
    return x

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


n, m = map(int, input().split())
a = list(map(int, input().split()))
a = [i//2 for i in a]

t = f(a[0])
for i in range(n):
  if f(a[i]) != t:
    print(0)
    sys.exit()
  a[i] >>= t
m >>= t

l = 1
for i in range(n):
  l = lcm(l, a[i])
  if l > m:
    print(0)
    sys.exit()

m //= l
ans = (m+1) // 2
print(ans)

Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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 lcm(a,b):
    return a*b//gcd(a,b)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=0
keta=0
buf=0
while(buf>0):
    buf/=2
    keta+=1
for i in range(n):
    buf=b[i]
    tmp=0
    while(buf>0):
        buf/=2
        tmp+=1
    if(keta!=tmp):
        flag=True
x=1
if(b[0]%2==0):
    f=1
for i in range(n):
    x=lcm(x,b[i])
res=m//x+1
res//=2
#print(x)
if(flag):
    print(0)
else:
    print(res)


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 lcm(a,b):
    return a*b//gcd(a,b)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=False
for i in range(n):
    if(b[i]%2!=b[0]%2):
        flag=True
x=1
if(b[0]%2==0):
    f=True
for i in range(n):
    x=lcm(x,b[i])

if(f):
    l=0
else:
    res=m//x+1
    res//=2
print(x)
if(flag):
    print(0)
else:
    print(res)


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 lcm(a,b):
    return a*b//gcd(a,b)
b=[0]*n
for i in range(n):
    b[i]=a[i]//2
flag=False
f=0
keta=0
buf=b[0]
while(buf%2==0):
    buf/=2
    keta+=1
for i in range(n):
    buf=b[i]
    tmp=0
    while(buf%2==0):
        buf/=2
        tmp+=1
    if(keta!=tmp):
        flag=True
x=1
if(b[0]%2==0):
    f=1
for i in range(n):
    x=lcm(x,b[i])
res=m//x+1
res//=2
#print(x)
if(flag):
    print(0)
else:
    print(res)


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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)

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,tt = divmod(a[i], mod)
	if t == 0 or tt != 0:
		print(0)
		sys.exit()
	if t % 2 == 1:
		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)

n, m = map(int,input().split())
p = list(map(int, input().split()))
print(0)

import sys
import numpy as np
import math
N, M = map(int, input().split())

A = np.array(list(map(int, input().split())), np.int64)

cnt = 0
while True:
	num_E = np.count_nonzero(A % 2 == 0) 
	if 0 < num_E < N:
		print(0)
		sys.exit()
	elif num_E == 0:
		cnt -= 1
		break
	else:
		cnt += 1
		A //= 2

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

	return gcd(b, a%b)
lcm = A[0]
for i in range(1,N):
	tmp_gcd = gcd(lcm, A[i])
	lcm *= A[i]//tmp_gcd
	if lcm > M:
		print(0)
		sys.exit()
M = math.floor(M/(2**cnt))

ans = 1 + (M-lcm)//(2*lcm)
print(ans)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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


G = A[0]/2
for a in A[1:]:
    print(G)
    G *= (a/2)/gcd(G,a//2)

if M//G % 2 == 0:
    print(int(M//G/2))
else:
    print(int(M//G//2 + 1))

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


G = A[0]/2
for a in A[1:]:
    G *= (a/2)/gcd(G,a//2)
for a in A:
    if G % a == 0:
        print(0)
        exit()
print(int(M//G - M//G//2))

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
n, m = map(int, input().split())
a = list(map(int, input().split()))
print(0)

import math
from functools import reduce
n, m = map(int, input().split())
A = list(map(int, input().split()))

a0 = A[0]
cnt = 0
while a0%2 == 0:
    a0 //= 2
    cnt += 1

a = []
for aa in A:
    if cnt == 1:
        if aa%4 == 0:
            print(0)
            exit()
    else:
        if aa%(2**(cnt-1)) != 0 or aa%(2**cnt) != 0 or aa%(2**(cnt+1)) == 0:
            print(0)
            exit()
    a.append(aa//2)


def lcm_base(p, q):
    return (p * q) // math.gcd(p, q)


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


lcm = lcm_list(a)
print(m//lcm - m//(lcm*2))

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=1
test=A[0]
l=0

while test%2 == 0:
  test=test//2
  c*=2
  
for i in np.arange(N-1):
  if A[i+1]%c!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(c*2)==0:
    print(0)
    l=1
    break
  else:
    k=A[i+1]//c
    test=test*k//math.gcd(test,k)
if l==0:
  k=test*c/2


import math
import numpy as np
N,M=map(int,input().split())
A=list(map(int,input().split()))
c=1
test=A[0]
l=0

while test%2 == 0:
  test=test//2
  c*=2
  
for i in np.arange(N-1):
  if A[i+1]%c!=0:
    print(0)
    l=1
    break
  elif A[i+1]%(c*2)==0:
    print(0)
    l=1
    break
  else:
    k=A[i+1]//c
    test=test*k//math.gcd(test,k)
if l==0:
  k=test*c//2
  print(M//k//2+M//k%2)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
from math import gcd
from functools import reduce
N, M = map(int, input().split())
a = list(map(int, input().split()))

half_a = [ai // 2 for ai in a]
L = reduce(lambda x, y: x * y // gcd(x, y), half_a)


from fractions import gcd
from functools import reduce

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

half_a = [ai // 2 for ai in a]
L = reduce(lambda x, y: x * y // gcd(x, y), half_a)
print((M - L) // (2 * L) + 1)


from fractions import gcd
from functools import reduce

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

half_a = [ai // 2 for ai in a]
L = reduce(lambda x, y: x * y // gcd(x, y), half_a)
print((M - L) // (2 * L) + 1 if M >= L else 0)


from functools import reduce

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


def f(x):
    c = 0
    while x % 2 == 0:
        x //= 2
        c += 1
    return c


def gcd(x, y):
    return gcd(y, x % y) if y != 0 else x


nth = [f(ai) for ai in a]
if len(set(nth)) == 1:
    half_a = [ai >> 1 for ai in a]
    L = reduce(lambda x, y: x * y // gcd(x, y), half_a)
    ans = (M - L) // (2 * L) + 1 if M >= L else 0
else:
    ans = 0
print(ans)


Verdicts: Runtime Error

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)):
    pass
else:
    print(0)



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)



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)



Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
import fractions


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


def div_count_by_2(x):
    count = 0
    while x % 2 == 0:
        count += 1
        x //= 2

    return count


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

num = A[0]
count = div_count_by_2(num)
for a in A:
    if count == div_count_by_2(a):
        continue
    else:
        print(0)
        exit()

x = A[0]
for a in A:
    x = lcm(x, a)

ans = (m - x//2) // x + bool((m - x//2) % x)
print(ans)

import fractions


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


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

x = A[0]
y = A[0] // 2

for a in A:
    x = lcm(x, a)
    y = lcm(y, a//2)


ans1 = m // x + bool(m%x)
ans2 = m // y + bool(m%y)

print(ans2 - ans1)



import fractions


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


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

x = A[0]

for a in A:
    x = lcm(x, a)

m -= x//2
ans = m // x + bool(m%x)

print(ans)



from math import gcd
from functools import reduce
import sys
input = sys.stdin.readline


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


def count_factor_2(num):
    count = 0
    while num % 2 == 0:
        num //= 2
        count += 1
    return count


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

    check = len(set(map(count_factor_2, A)))
    if check != 1:
        print(0)
        return

    lcm_a = reduce(lcm, A)
    step = lcm_a * 2
    ans = (m + lcm_a) // step
    print(ans)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
N, M = map(int, input().split())
A = list(map(int, input().split()))

def gcd(m, n):
    if n == 0:
        return m
    return gcd(n, m % n)

LCM = A[0]
for a in A:
    LCM = LCM * a // gcd(LCM, a)

print(LCM)

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

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

K = A[0]
LCM = K
for a in A:
    K = gcd(K, a)
    LCM = LCM * a // K

print(LCM)

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

B = set([a & (-a) for a in A])
if len(B) > 1:
    print(0)
    exit()

def gcd(n, m):
    if m == 0:
        return n
    return gcd(m, n % m)

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

A = [a // 2 for a in A]
LCM = A[0]
for a in A:
    LCM = lcm(LCM, a)

ans = ((M // LCM) + 1) // 2
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
#!/usr/bin/env python

from sys import stdin
from math import ceil

N, M = (int(wd) for wd in stdin.readline().split())
a = [int(wd) for wd in stdin.readline().split()]

def kouyakusuu(g1, g2):
    if g1 < g2:
        return kouyakusuu(g2, g1)
    if g2 == 0:
        return g1
    return kouyakusuu(g2, g1 % g2)

def koubaisuu(g1, g2):
    return (g1 * g2) // kouyakusuu(g1, g2)

def gojohou(A, B):
    C = A % B
    if C == 0:
        return (1, -(A // B) + 1, B)
    b, c, d = gojohou(B, C)
    return (c, b - c * (A // B), d)

def jouyo(A, a, B, b):
    C = kouyakusuu(A, B)
    if C != 1:
        if a % C != b % C:
            return None
        nB = B // C
        return jouyo(A, a, nB, b % nB)
    aa, bb, cc = gojohou(A, B)
    assert cc == 1
    ret = bb * B * a + aa * A * b
    return A * B, ret % (A * B)

cur = (a[0], a[0] // 2)
for aa in a[1:]:
    cur = jouyo(cur[0], cur[1], aa, aa//2)
    if cur is None:
        break
#print(cur)
if cur is None:
    print(0)
else:
    print(int(ceil((M - cur[1]) / cur[0] + 1)))


#!/usr/bin/env python

from sys import stdin
from math import ceil

N, M = (int(wd) for wd in stdin.readline().split())
a = [int(wd) for wd in stdin.readline().split()]

def kouyakusuu(g1, g2):
    if g1 == 0 or g2 == 0:
        return g1
    return kouyakusuu(g2, g1 % g2)

def jouyo(g1, g2):
    M1, P1 = g1
    M2, P2 = g2
    if M1 < M2:
        M1, M2 = M2, M1
        P1, P2 = P2, P1
    ret = P1
    for _ in range(M2):
        if ret % M2 == P2:
            break
        ret += M1
        pass
    if ret % M2 != P2:
        return None
    return (M1 * M2 / kouyakusuu(M1, M2), ret)

cur = (a[0], a[0] // 2)
for aa in a[1:]:
    cur = jouyo(cur, (aa, aa//2))
    if cur is None:
        break
if cur is None:
    print(0)
else:
    print(int(ceil((M - cur[1]) / cur[0] + 1)))


#!/usr/bin/env python

from sys import stdin
from math import floor

N, M = (int(wd) for wd in stdin.readline().split())
a = [int(wd) for wd in stdin.readline().split()]

def kouyakusuu(g1, g2):
    if g1 < g2:
        return kouyakusuu(g2, g1)
    if g2 == 0:
        return g1
    return kouyakusuu(g2, g1 % g2)

def koubaisuu(g1, g2):
    return (g1 * g2) // kouyakusuu(g1, g2)




def solve2(N, M, a):
    ret = 1
    cnt2 = 1
    while a[0] % (2**cnt2) == 0: cnt2 += 1
    ng = 2 ** cnt2
    cnt2 -= 1
    ok = 2 ** cnt2
    for aa in a:
        if aa % ng == 0:
            return 0
        if aa % ok != 0:
            return 0
        ret = koubaisuu(ret, aa // 2)
    return int(floor((M - ret) / (ret * 2)) + 1)

print(solve2(N, M, a))


Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
import math
def lcm(x,y):
    return(x*y)//math.gcd(x,y)
n,m=map(int,input().split())
l=list(map(int,input().split()))
a=l[0]//2
for i in range(n-1):
    a=lcm(a,l[i+1]//2)
 
ok = True
for aa in l:
    if (a//aa) % 2 != 1:
        ok = False
        break
ans = 0
if ok:
    ans = ((m//a)+1)//2
print(ans)

import math
def lcm(x,y):
    return(x*y)//math.gcd(x,y)
n,m=map(int,input().split())
l=list(map(int,input().split()))
a=l[0]//2
for i in range(n-1):
    a=lcm(a,l[i+1]//2)
 
ok = True
for i in range(n):
  if (a//(l[i]//2))%2!=1:
    ok=False
    break
ans = 0
if ok:
    ans = ((m//a)+1)//2
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
import fractions
import sys
readline = sys.stdin.buffer.readline
N, M = map(int, readline().split())
a = list(map(int, readline().split()))
# print(N, M, a)

tmp = 1
for x in a:
    x //= 2
    tmp2 = x // fractions.gcd(tmp, x)
    M //= tmp2
    tmp *= tmp2

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


import fractions
import sys
readline = sys.stdin.buffer.readline
N, M = map(int, readline().split())
a = list(map(int, readline().split()))
# print(N, M, a)

def lcm(a, b):
	return a * b // fractions.gcd(a, b)
tmp = 1
for x in a:
    tmp = lcm(tmp, x//2)
# print(tmp)
ans = (M // tmp + 1) // 2
print(ans)


import fractions
import sys
readline = sys.stdin.buffer.readline
N, M = map(int, readline().split())
a = list(map(int, readline().split()))
# print(N, M, a)

MOD = 10**9 + 7

tmp = 1
for x in a:
    x //= 2
    tmp2 = x // fractions.gcd(tmp, x)
    M //= tmp2
    tmp *= tmp2
    tmp %= MOD

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

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

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

def f(x):
    res = 0
    while x%2==0:
        x //= 2
        res += 1
    return res

def main():
    import sys
    readline = sys.stdin.buffer.readline
    N, M = map(int, readline().split())
    a = list(map(int, readline().split()))
    for i in range(N):
        a[i] //= 2

    t = f(a[0])
    for i in range(N):
        if f(a[i]) == t:
            a[i] >>= t
        else:
            print(0)
            return
    M >>= t

    l = 1
    for i in range(N):
        l = lcm(l, a[i])
        if l > M:
            print(0)
            return

    M //= l
    ans = (M + 1) // 2
    print(ans)

main()

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
def main():
    N, M = map(int, input().split())
    A = tuple(map(int,input().split()))
    ans = count(A, N, M)
    print(ans)
def count(A, N, M):
    t = hMt(A[0])
    B = [A[0]//(2**t)]
    for val in A[1:]:
        if hMt(val) != t:
            ans = 0
            return ans
        B.append(val//(2**t))
    T = nlcm(B)
    MdivT = (M//(2**t))//T
    ans = countodd(MdivT)
    return ans
def countodd(M):
    if M%2 == 0:
        ans = M//2
    else:
        ans = M//2 + M%2
    return ans
def nlcm(A):
    LCM = A[0]
    for val in A[1:]:
        #print("%d %d gcm:%d LCM:%d"%(LCM,val,gcm(LCM,val),lcm(LCM,val)))
        LCM = lcm(LCM,val)
    return LCM
    
def gcm(a, b):
    abtuple = (a,b)
    abmin = min([0,1], key=lambda x:abtuple[x])
    remainder = abtuple[1-abmin]%abtuple[abmin]
    if remainder == 0:
        return abtuple[abmin]
    return gcm(abtuple[abmin], remainder)
def lcm(a,b):
    prod = a*b
    ans = prod//gcm(a,b)
    return ans
def hMt(num):
    ans = 0
    tmp = num
    while tmp%2 == 0:
        tmp = tmp//2
        ans += 1
    return ans
main()

def main():
    N, M = map(int, input().split())
    A = tuple(map(int,input().split()))
    ans = count(A, N, M)
    print(ans)
def count(A, N, M):
    t = hMt(A[0])
    B = [A[0]//(2**t)]
    for val in A[1:]:
        if hMt(val) != t:
            ans = 0
            return ans
        B.append(val//(2**t))
    T = nlcm(B)
    MdivT = (M//(2**(t-1)))//T
    ans = countodd(MdivT)
    return ans
def countodd(num):
    if num%2 == 0:
        ans = num//2
    else:
        ans = num//2 + num%2
    return ans
def nlcm(A):
    LCM = A[0]
    for val in A[1:]:
        #print("%d %d gcm:%d LCM:%d"%(LCM,val,gcm(LCM,val),lcm(LCM,val)))
        LCM = lcm(LCM,val)
    return LCM
    
def gcm(a, b):
    abtuple = (a,b)
    abmin = min([0,1], key=lambda x:abtuple[x])
    remainder = abtuple[1-abmin]%abtuple[abmin]
    if remainder == 0:
        return abtuple[abmin]
    return gcm(abtuple[abmin], remainder)
def lcm(a,b):
    prod = a*b
    ans = prod//gcm(a,b)
    return ans
def hMt(num):
    ans = 0
    tmp = num
    while tmp%2 == 0:
        tmp = tmp//2
        ans += 1
    return ans
main()

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
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)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
import sys

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

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

s = []
step = 1

def division(a, step):
    flag = True
    for i in a:
        # print(step)
        f = str(step / i).split(".")[1]
        if f != "5":
            flag = False
            break

    # print(step, flag)
    return flag


while(len(s) != 2):

    if step > M:
        print(0)
        sys.exit()

    if division(a, step):
        s.append(step)
    step += 2

print(s)
d = s[1] - s[0]

print(2+(M-s[1])//d)

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

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

while not any(x%2 for x in g): g = [i //2 for i in g]

if not all(x%2 for x in g): print(0); exit(0)

def gcd(a, b):

    while b:

        a, b = b, a % b
    return a

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


tot = 1

for x in a: tot = lcm(tot, x//2)
print((M//tot+1)//2)

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
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))

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

Verdicts: Runtime Error

Accepted
Problem: 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).

Submission attempts (in order):
import fractions
N, M = map(int,input().split())
A = list(map(int,input().split()))
cnt = M
for i in range(N):
  if A[i]%2 == 0:
    A[i] = A[i]//2
  else:
    cnt = 0
gcd = A[0]
for i in range(1, N):
  gcd = gcd*A[i]//fractions.gcd(gcd, A[i])
print(min(cnt, 1+(M-gcd)//(2*gcd)))
print(1 + (999999988)//24)

import fractions
N, M = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N):
  A[i] = A[i]//2
gcd = A[0]
for i in range(1, N):
  gcd = gcd*A[i]//fractions.gcd(gcd, A[i])
print(1 + (M-gcd)//(2*gcd))

import fractions
N, M = map(int,input().split())
A = list(map(int,input().split()))
cnt = M
for i in range(N):
  if A[i]%2 == 0:
    A[i] = A[i]//2
  else:
    cnt = 0
gcd = A[0]
for i in range(1, N):
  gcd = gcd*A[i]//fractions.gcd(gcd, A[i])
print(min(cnt,1 + (M-gcd)//(2*gcd)))

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 numberof2(n):
  ans = 0
  while n%2 == 0:
    n = n//2
    ans += 1
  return ans

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

for i in range(N):
  if A[i]%2 == 0:
    A[i] = A[i]//2
  else:
    cnt = 0
for i in range(N-1):
  if numberof2(A[i]) != numberof2(A[i+1]):
    cnt = 0
    
lcm = A[0]
for i in range(1, N):
  lcm = lcm*A[i]//gcd(lcm, A[i])

print(min(cnt, 1+(M-lcm)//(2*lcm)))

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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).

Submission attempts (in order):
import fractions
from functools import reduce
N,M=map(int,input().split())
A=list(map(int,input().split()))
A=[a//2 for a in A]
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
x=lcm_list(A)
print(-(-M//2//x))

import sys
N,M=map(int,input().split())
A=list(set(map(int,input().split())))
N=len(A)
A=[a//2 for a in A]

def f(x):
    cnt=0
    while x%2==0:
        x//=2
        cnt+=1
    return cnt
C=f(A[0])
for a in A:
    if f(a)!=C:
        print(0)
        sys.exit()
def lcm(x,y):
    xy=x*y
    while y!=0:
        x,y=y,x%y
    return xy//x
LCM=A[0]
for i in range(1,N):
    LCM=lcm(LCM,A[i])
if LCM>M:
    ans=0
else:
    M//=LCM
    ans=(M+1)//2
print(ans)

Verdicts: Wrong Answer

Accepted