Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
import math


def get_num(i):
    return int(b / i) - int((a-1) / i)


a, b, c, d = [int(i) for i in input().split()]

all_num = b - a + 1
c_num = get_num(c)
d_num = get_num(d)
lcm = int(c * d / math.gcd(c, d))
lcm_num = get_num(lcm) 

print(all_num - c_num - d_num + lcm_num)


Fixed submission:
a, b, c, d = [int(i) for i in input().split()]


def get_num(i):
    return b // i - (a-1) // i


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


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


all_num = b - a + 1
c_num = get_num(c)
d_num = get_num(d)
lcm = lcm(c, d)
lcm_num = get_num(lcm)

print(all_num - c_num - d_num + lcm_num)
Buggy python submission (verdict: Runtime Error):
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    S = input()
    T = input()

    numdic = [0]*(len(T)+1)
    for i in range(len(S)+1-len(T)):
        small = S[i:i+len(T)]
        same = 0
        for s in range(len(T)):
            if small[s] == T[s]:
                same += 1
        numdic[i] = same

    ans = len(T) - max(numdic)
    print(ans)




if __name__ == '__main__':
    solve()

Fixed submission:
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    S = input()
    T = input()

    numdic = [0]*(100000)
    for i in range(len(S)+1-len(T)):
        small = S[i:i+len(T)]
        same = 0
        for s in range(len(T)):
            if small[s] == T[s]:
                same += 1
        numdic[i] = same

    ans = len(T) - max(numdic)
    print(ans)




if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

A.sort()
checked = []
ans = 0
before = 0
first = True
for i in A:
    if before == i and first:
        if flag:
            ans -= 1
        first = False
        continue
    elif before != i:
        first = True
    elif not first:
        continue
    flag = True
    for l in checked:
        if l > i // 2:
            break
        if i % l == 0:
            flag = False
            break
    if flag:
        checked.append(i)
        ans += 1
    before = i

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

A.sort()

maxnum = A[-1]
checklist = [True]*(maxnum+1)
before = 0

for a in A:
    if before == a:
        checklist[a] = False
        continue
    num = 2
    while num * a <= maxnum:
        checklist[a * num] = False
        num += 1
    before = a

ans = 0
for i in A:
    ans += checklist[i]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int,input().split()))

A.sort()
checked = []
ans = 0
before = 0
first = True
for i in A:
    if before == i and first:
        if flag:
            ans -= 1
        first = False
        continue
    elif before != i:
        first = True
    elif not first:
        continue
    flag = True
    for l in checked:
        if l > i // 2:
            break
        if i % l == 0:
            flag = False
            break
    if flag:
        checked.append(i)
        ans += 1
    before = i

print(ans)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))

A.sort()

maxnum = A[-1]
checklist = [True]*(maxnum+1)
before = 0

for a in A:
    if before == a:
        checklist[a] = False
        continue
    num = 2
    while num * a <= maxnum:
        checklist[a * num] = False
        num += 1
    before = a

ans = 0
for i in A:
    ans += checklist[i]
print(ans)
Buggy python submission (verdict: Runtime Error):
a,b=map(str,input().split())
a=int(a)
b = b[0]+b[2:]
b = int(b)
ans = a*b
ans = str(ans)
ans = ans[:-2]
ans = int(ans)
print(ans)

Fixed submission:
a,b=map(str,input().split())
a=int(a)
b = b[0]+b[2:]
b = int(b)
ans = a*b
ans = str(ans)
if len(ans)>=3:
    ans = ans[:-2]
    ans = int(ans)
else:
    ans = 0
print(ans)
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,6):
    print(-1)
else:
    print(money)


Fixed submission:
S = input()
T = input()
if len(S)+1 ==len(T) and S ==T[:-1]:
    print('Yes')
else:
    print('No')
Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,6)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,6):
    print(-1)
else:
    print(money)

Fixed submission:
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,7):
    print(-1)
else:
    print(money)

Buggy python submission (verdict: Runtime Error):
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,6)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,6):
    print(-1)
else:
    print(money)

Fixed submission:
import itertools
import numpy as np
N,M,X=map(int, input().split())
book = []
for _ in range(N):
    book.append(list(map(int, input().split())))
book = np.array(book)
money=pow(10,7)
for i in itertools.product([0,1], repeat=N):
    book2=book
    dellist = []
    for n,l in enumerate(i):
        if l==0:
            dellist.append(n)
    book2=np.delete(book2, dellist, 0)
    ansar = np.sum(book2,axis=0)
    if np.sum(ansar[1:]>=X)==M:
        if money>ansar[0]:
            money = ansar[0]
if money == pow(10,7):
    print(-1)
else:
    print(money)
Buggy python submission (verdict: Time Limit Exceeded):
A,B,N=map(int, input().split())
answer=0
import math
Blist=[]
apple=min(B,N)
for i in range(1,apple+1):
    newans=math.modf(i/B)[0]*A
    newans//=1
    answer=newans if newans>answer else answer
print(int(answer))

Fixed submission:
A,B,N=map(int, input().split())
answer=0
import math
if N < B:
    print(int(math.modf(N/B)[0]*A))
else:
    apple=min(B,N)
    startnum = B-1 if B>1 else 1
    for i in range(startnum,apple+1):
        newans=math.modf(i/B)[0]*A
        newans//=1
        answer=newans if newans>answer else answer
    print(int(answer))

Buggy python submission (verdict: Time Limit Exceeded):
A,B,N=map(int, input().split())
answer=0
import math
for i in range(1,N+1):
    newans=math.modf(i/B)[0]*A
    newans//=1
    answer=newans if newans>answer else answer
print(int(answer))

Fixed submission:
A,B,N=map(int, input().split())
answer=0
import math
if N < B:
    print(int(math.modf(N/B)[0]*A))
else:
    apple=min(B,N)
    startnum = B-1 if B>1 else 1
    for i in range(startnum,apple+1):
        newans=math.modf(i/B)[0]*A
        newans//=1
        answer=newans if newans>answer else answer
    print(int(answer))
Buggy python submission (verdict: Runtime Error):
R = input()
print(R*2*3.141)

Fixed submission:
R = int(input())
print(R*2*3.141)
Buggy python submission (verdict: Time Limit Exceeded):
K = int(input())
import math
sumnation = 0
for a in range(1,K+1):
    for b in range(1,K+1):
        for c in range(1,K+1):
            sumnation += math.gcd(math.gcd(a,b),c)
print(sumnation)

Fixed submission:
K = int(input())
import math
sumnation = 0
gcdlist = []
for A in range(1,K+1):
    for B in range(1,K+1):
        gcdlist.append(math.gcd(A,B))
for a in range(1,1+K):
    for b in range(1,1+K):
        gcd_a_b = gcdlist[(a-1)*K+b-1]
        for c in range(1,1+K):
            sumnation += gcdlist[(gcd_a_b-1)*K+c-1]
print(sumnation)
Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
gcddic = {}
mod_n = (10**9+7)
for i in range(K,0,-1):
    x = pow((K//i),N)
    ll=2
    while(ll*i<=K):
        x -= gcddic[ll*(i)]
        ll += 1
    gcddic[i] = x
sumnation = 0
for i,l in gcddic.items():
    sumnation += i*l
print(sumnation%mod_n)

Fixed submission:
N,K = map(int,input().split())
gcddic = {}
mod_n = (10**9+7)
for i in range(K,0,-1):
    x = pow((K//i),N,mod_n)
    ll=2
    while(ll*i<=K):
        x -= gcddic[ll*(i)]
        ll += 1
    gcddic[i] = x
sumnation = 0
for i,l in gcddic.items():
    sumnation += i*l
print(sumnation%mod_n)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
gcddic = {}
for i in range(K,0,-1):
    gcddic[i] = (K//(i))**N
    ll=2
    while(ll*i<=K):
        gcddic[i] -= gcddic[ll*(i)]
        ll += 1
sumnation = 0
for i,l in gcddic.items():
    sumnation += i*l
print(sumnation%(10**9+7))

Fixed submission:
N,K = map(int,input().split())
gcddic = {}
mod_n = (10**9+7)
for i in range(K,0,-1):
    x = pow((K//i),N,mod_n)
    ll=2
    while(ll*i<=K):
        x -= gcddic[ll*(i)]
        ll += 1
    gcddic[i] = x
sumnation = 0
for i,l in gcddic.items():
    sumnation += i*l
print(sumnation%mod_n)

Buggy python submission (verdict: Time Limit Exceeded):
N,K = map(int,input().split())
gcddic = {}
for i in range(K,0,-1):
    gcddic[i] = (K//(i))**N
    ll=2
    while(ll*i<=K):
        gcddic[i] -= gcddic[ll*(i)]
        ll += 1
sumnation = 0
for i,l in gcddic.items():
    sumnation += i*l
print(sumnation%(10**9+7))

Fixed submission:
N,K = map(int,input().split())
gcddic = {}
mod_n = (10**9+7)
for i in range(K,0,-1):
    x = pow((K//i),N,mod_n)
    ll=2
    while(ll*i<=K):
        x -= gcddic[ll*(i)]
        ll += 1
    gcddic[i] = x
sumnation = 0
for i,l in gcddic.items():
    sumnation += i*l
print(sumnation%mod_n)
Buggy python submission (verdict: Time Limit Exceeded):
N,K=map(int, input().split())
stopf = True
def exchangeK():
    global stopf
    global N
    if N > abs(N-K):
        N = abs(N-K)
    else:
        stopf = False
while stopf:
    exchangeK()
print(N)

Fixed submission:
N,K=map(int, input().split())
stopf = True
wari = N // K
N = N - K*wari
def exchangeK():
    global stopf
    global N
    if N > abs(N-K):
        N = abs(N-K)
    else:
        stopf = False
while stopf:
    exchangeK()
print(N)
Buggy python submission (verdict: Runtime Error):
N,M = map(int,input().split())

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

Fixed submission:
N,M = map(int,input().split())

ans = (N+M)*(N+M-1)//2 - N*M
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Alist=list(map(int, input().split()))
numdic = {}
for i in Alist:
    if i in numdic:
        numdic[i] += 1
    else:
        numdic[i] = 1
ansdic = dict.fromkeys(numdic, [0,False])
for i in Alist:
    if ansdic[i][1]:
        print(ansdic[i][0])
    else:
        kazu = 0
        numdic[i] -= 1
        for l in numdic.values():
            kazu += l*(l-1)//2
        ansdic[i] = [kazu,True]    
        numdic[i] += 1
        print(kazu)

Fixed submission:
N = int(input())
Alist=list(map(int, input().split()))
numdic = {}
for i in Alist:
    if i in numdic:
        numdic[i] += 1
    else:
        numdic[i] = 1
Apple = 0
for i in numdic.values():
    Apple += i*(i-1)//2
for i in Alist:
    tmp = Apple
    tmp -= (numdic[i]-1)
    print(tmp)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Alist=list(map(int, input().split()))
numdic = {}
for i in Alist:
    if i in numdic:
        numdic[i] += 1
    else:
        numdic[i] = 1
for i in Alist:
    numdic[i] -= 1
    kazu = 0
    for l in numdic.values():
        kazu += l*(l-1)//2
    print(kazu)
    numdic[i] += 1

Fixed submission:
N = int(input())
Alist=list(map(int, input().split()))
numdic = {}
for i in Alist:
    if i in numdic:
        numdic[i] += 1
    else:
        numdic[i] = 1
Apple = 0
for i in numdic.values():
    Apple += i*(i-1)//2
for i in Alist:
    tmp = Apple
    tmp -= (numdic[i]-1)
    print(tmp)
Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
reverseflag = 0
for _ in range(Q):
    newS = input()
    if int(newS[0]) == 1:
        reverseflag += 1
        reverseflag %= 2
    else:
        if (newS[2] == '1' and reverseflag==0) or (newS[2] != '1' and reverseflag!=0):
            S = newS[4]+S[:]
        else:
            S = S[:]+newS[4]
if reverseflag == 1:
    S = S[::-1]
print(S)

Fixed submission:
from collections import deque
s = input()
s = deque(s)
q = int(input())
reverse = False
for i in range(q):
    query = input()
    if len(query) == 1:
        reverse = not reverse
    else:
        if not reverse:
            if query[2] == '1':
                s.appendleft(query[4])
            else:
                s.append(query[4])
        else:
            if query[2] == '2':
                s.appendleft(query[4])
            else:
                s.append(query[4])
s ="".join(list(s))
if reverse:
    s = s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
reverseflag = 0
for _ in range(Q):
    newS = input()
    if int(newS[0]) == 1:
        reverseflag += 1
        reverseflag %= 2
    else:
        if (newS[2] == '1' and reverseflag==0) or (newS[2] != '1' and reverseflag!=0):
            S = newS[4]+S[:]
        else:
            S = S[:]+newS[4]
if reverseflag == 1:
    S = S[::-1]
print(S)

Fixed submission:
from collections import deque
s = input()
s = deque(s)
q = int(input())
reverse = False
for i in range(q):
    query = input()
    if len(query) == 1:
        reverse = not reverse
    else:
        if not reverse:
            if query[2] == '1':
                s.appendleft(query[4])
            else:
                s.append(query[4])
        else:
            if query[2] == '2':
                s.appendleft(query[4])
            else:
                s.append(query[4])
s ="".join(list(s))
if reverse:
    s = s[::-1]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
S=input()
Q=int(input())
for _ in range(Q):
    newS = input()
    if int(newS[0]) == 1:
        S = S[::-1]
    else:
        if newS[2] == '1':
            S = newS[4]+S[:]
        else:
            S = S[:]+newS[4]
print(S)

Fixed submission:
from collections import deque
s = input()
s = deque(s)
q = int(input())
reverse = False
for i in range(q):
    query = input()
    if len(query) == 1:
        reverse = not reverse
    else:
        if not reverse:
            if query[2] == '1':
                s.appendleft(query[4])
            else:
                s.append(query[4])
        else:
            if query[2] == '2':
                s.appendleft(query[4])
            else:
                s.append(query[4])
s ="".join(list(s))
if reverse:
    s = s[::-1]
print(s)
Buggy python submission (verdict: Time Limit Exceeded):
H,N = map(int,input().split())
Alist = []
Blist = []
for _ in range(N):
    A,B = map(int,input().split())
    Alist.append(A)
    Blist.append(B)

dp = [float('inf')]*(H+1)
dp[0] = 0
for h in range(H+1):
    for n in range(N):
        damage = Alist[n]
        cost = Blist[n]
        first_index = min(h + damage, H)
        dp[first_index] = min(dp[h] + cost, dp[first_index])
        
print(dp[-1])

Fixed submission:
H,N = map(int,input().split())
Alist = []
Blist = []
for _ in range(N):
    A,B = map(int,input().split())
    Alist.append(A)
    Blist.append(B)

dp = [float('inf')]*(H+1)
dp[0] = 0
for h in range(H+1):
    for n in range(N):
        damage = Alist[n]
        cost = Blist[n]
        first_index = min(h + damage, H)
        dp[first_index] = min(dp[h] + cost, dp[first_index])
        
print(dp[-1])
Buggy python submission (verdict: Time Limit Exceeded):
H,W = map(int,input().split())
maze = []
from collections import deque
for _ in range(H):
    s = list(input())
    maze.append(s)
direction = [[1,0],[0,1],[-1,0],[0,-1]]
ans = -1
for row in range(H):
    for col in range(W):
        if maze[row][col] == "#":
            continue
        distance = [[-1 for _ in range(W)] for _ in range(H)]
        d = deque([[row,col]])
        distance[row][col] = 0
        while(len(d)>0):
            nowrow, nowcol = d.popleft()
            for subrow, subcol in direction:
                subrow += nowrow
                subcol += nowcol
                if subrow < 0 or subrow >= H or subcol < 0 or subcol >= W:
                    continue
                if maze[subrow][subcol] == "#":
                    continue
                if distance[subrow][subcol] != -1:
                    continue
                d.append([subrow, subcol])
                distance[subrow][subcol] = distance[nowrow][nowcol] + 1
            ans = max(ans,max([max(maxrow) for maxrow in distance]))
print(ans)

Fixed submission:
H,W = map(int,input().split())
maze = []
from collections import deque
for _ in range(H):
    s = list(input())
    maze.append(s)
direction = [[1,0],[0,1],[-1,0],[0,-1]]
ans = -1
for row in range(H):
    for col in range(W):
        if maze[row][col] == "#":
            continue
        distance = [[-1 for _ in range(W)] for _ in range(H)]
        d = deque([[row,col]])
        distance[row][col] = 0
        while(len(d)>0):
            nowrow, nowcol = d.popleft()
            for subrow, subcol in direction:
                subrow += nowrow
                subcol += nowcol
                if subrow < 0 or subrow >= H or subcol < 0 or subcol >= W:
                    continue
                if maze[subrow][subcol] == "#":
                    continue
                if distance[subrow][subcol] != -1:
                    continue
                d.append([subrow, subcol])
                distance[subrow][subcol] = distance[nowrow][nowcol] + 1
            ans = max(ans,max([max(maxrow) for maxrow in distance]))
print(ans)
Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))

    A.sort()
    lenA = len(A)
    ans = 0

    if K == 1:
        print(0)
        sys.exit()

    def com(n, r, mod):
        r = min(r, n - r)
        if r == 0:
            return 1
        res = ilist[n] * iinvlist[n - r] * iinvlist[r] % mod
        return res

    ilist = [0]
    iinvlist = [1]

    def modinv(a, mod=10 ** 9 + 7):
        return pow(a, mod - 2, mod)

    tmp = 1
    for i in range(1, N + 1):
        tmp *= i
        tmp %= mod
        ilist.append(tmp)
        iinvlist.append(modinv(tmp, mod))

    for front in range(lenA):
        for last in range(lenA-front-K+1):
            last = last + front + K - 1
            f_x = A[last] - A[front]
            count = last - front - 1
            ans += com(count, K-2, mod) * f_x
    ans %= mod
    print(ans)

if __name__ == '__main__':
    solve()

Fixed submission:
import sys
import bisect
import itertools
import collections
import fractions
import heapq
import math
from operator import mul
from functools import reduce
from functools import lru_cache


def solve():
    readline = sys.stdin.buffer.readline
    mod = 10 ** 9 + 7
    N, K = map(int, readline().split())
    A = list(map(int, readline().split()))

    A.sort()
    lenA = len(A)
    ans = 0

    if K == 1:
        print(0)
        sys.exit()

    def com(n, r, mod):
        r = min(r, n - r)
        if r == 0:
            return 1
        res = ilist[n] * iinvlist[n - r] * iinvlist[r] % mod
        return res

    def modinv(a, mod=10 ** 9 + 7):
        return pow(a, mod - 2, mod)

    ilist = [0]
    iinvlist = [1]
    tmp = 1
    for i in range(1, N + 1):
        tmp *= i
        tmp %= mod
        ilist.append(tmp)
        iinvlist.append(modinv(tmp, mod))

    sum_of_com = []
    now = 0

    for i in range(K-2, N+1):
        now += com(i, K-2, mod)
        sum_of_com.append(now)

    ans = 0
    for first in range(lenA-K+1):
        ans -= A[first] * sum_of_com[lenA-first-K]
    for last in range(K-1, lenA):
        ans += A[last] * sum_of_com[last-K+1]
    ans %= mod
    print(ans)

if __name__ == '__main__':
    solve()
Buggy python submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce

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

numdic = {}

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

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

lcmnum = lcm_list(alist)

for i in alist:
    if (lcmnum//i)%2==0:
        print(0)
        sys.exit()

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)


Fixed submission:
from fractions import gcd
from functools import reduce
import sys

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

numdic = {}

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

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

lcmnum = lcm_list(alist)

for i in alist:
    if (lcmnum//i)%2==0:
        print(0)
        sys.exit()

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)

Buggy python submission (verdict: Runtime Error):
import math
from functools import reduce

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

numdic = {}

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

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

lcmnum = lcm_list(alist)

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)


Fixed submission:
from fractions import gcd
from functools import reduce
import sys

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

numdic = {}

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

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

lcmnum = lcm_list(alist)

for i in alist:
    if (lcmnum//i)%2==0:
        print(0)
        sys.exit()

pmax = M // lcmnum
pmax = pmax - 1 if pmax % 2 == 0 else pmax

print((pmax+1)//2)