Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03962 (python)

Fixed submission:
a, b, c = map(int, input().split())

if a == b == c:
    print(1)
elif a == b or b == c or a == c:
    print(2)
else:
    print(3)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
m = set([a, b, c])
print(len(m)

Buggy submission (verdict: Runtime Error):
a, b, c = map(int, input().split())
m = set([a, b, c])）
print(len(m)
Problem p03997 (python)

Fixed submission:
a = int(input())
b = int(input())
h = int(input())

area = int((a + b) * h / 2)
print(area)

Buggy submission (verdict: Runtime Error):
a, b, h = map(int, input().split())

print((a + b) * h / 2)
Problem p04011 (python)

Fixed submission:
N = int(input())   
K = int(input())   
X = int(input())    
Y = int(input())    

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Buggy submission (verdict: Runtime Error):
N, K, X, Y = map(int, input().split())

if N <= K:
    print(N * X)
else:
    print(K * X + (N - K) * Y)

Buggy submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())

if n <= k:
    print(n * x)
else:
    print(k * x + (n - k) * y)

Buggy submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())

if n <= k:
    print(n * x)
else:
    print(k * x + (n - k) * y)

Buggy submission (verdict: Runtime Error):
n, k, x, y = map(int, input().split())

if n <= k:
    print(k * x)
else:
    print(k * x + (n - k) * y)
Problem p04029 (python)

Fixed submission:
# 入力
n = int(input())
# result初期化
result = 0
# １からNまで繰り返し
for i in range(1,n+1):
    # 等差数列
    count = i
    result = result + count
# 結果を表示
print(result)

Buggy submission (verdict: Runtime Error):
ame = N * (N + 1) / 2
print(ame)
Problem p02582 (python)

Fixed submission:
#!/usr/bin/env python
import sys
from itertools import chain

# import numpy as np


def solve(S: str):
    answer = max(list(map(len, S.split("S"))))
    return answer


def main():
    S = input()  # type: str
    print(solve(S))


if __name__ == "__main__":
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys
from itertools import chain


def max_add_1_to_n(loop, n):
    # print('  max_add_1_to_n', loop, n)
    l = len(loop)
    acc = loop.copy()
    # print('    ', acc)
    max_val = max(acc)
    for i in range(1, n):
        for j in range(0, l):
            acc[j] += loop[(i + j) % l]
        # print("    ", acc)
        max_val = max(max(acc), max_val)
    return max_val


def max_add_0_to_n(loop, n):
    # print('  max_add_0_to_n', loop, n)
    if n >= 1:
        return max(max_add_1_to_n(loop, n), 0)
    else:
        return 0


def max_loop_k(loop, K):
    l = len(loop)
    if K <= 2 * l:
        return max_add_1_to_n(loop, K)
    # K は 2 * l より長い
    l_sum = sum(loop)
    if l_sum <= 0:
        return max_add_1_to_n(loop, l)
    else:
        Kdiv = K // l
        Kmod = K % l
        # print('  l Kdiv Kmod', l, Kdiv, Kmod)
        return max_add_0_to_n(loop, l + Kmod) + l_sum * (Kdiv - 1)


def solve(N: int, K: int, P: "List[int]", C: "List[int]"):
    # 簡単のためインデックスを 0 からにする
    # (使用済みは -1 を入れる)
    P = [i - 1 for i in P]
    answer = -float("inf")
    for i0 in range(N):
        if P[i0] == -1:
            continue
        loop = []
        i = i0
        while P[i] != -1:
            loop.append(C[i])
            i_next = P[i]
            P[i] = -1
            i = i_next
        answer = max(answer, max_loop_k(loop, K))

    return answer


def main():
    tokens = chain(*(line.split() for line in sys.stdin))
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    P = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    C = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    answer = solve(N, K, P, C)
    print(answer)


if __name__ == "__main__":
    main()
Problem p02960 (python)

Fixed submission:

P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = [1, 10, 9, 12, 3, 4]

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = [1] + [0] * 12
    # print(priv)
    s = S[::-1]
    for i in range(0, len(s)):
        cur = [0] * 13
        d = s[i]
        # print('i=', i, 'd=', d)
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] += priv[j]
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        # print(cur)
        for j in range(13):
            priv[j] = cur[j] % P_MOD
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)

Buggy submission (verdict: Runtime Error):
import numpy as np

P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = np.array([1, 10, 9, 12, 3, 4], dtype=np.int)

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = np.zeros(13, dtype=np.int)
    priv[0] = 1
    s = S[::-1]
    for i in range(0, len(s)):
        cur = np.zeros(13+13, dtype=np.int)
        d = s[i]
        if d == '?':
            for di in range(10):
                m = (di * MODS[i % 6]) % 13
                cur[m:m+13] = (cur[m:m+13] + priv[0:13]) % P_MOD
            cur[0:13] += cur[13:26]
        else:
            m = (int(d) * MODS[i % 6]) % 13
            cur[m:m+13] = priv[0:13]
            cur[0:13] += cur[13:26]
        priv = cur
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

P_MOD = 1000000007


def solve(S):
    # print(S)
    # 1, 10, 100, 1000, ... を 13 で割った値は 1, 10, 9, 12, 3, 4 で巡回する
    MODS = [1, 10, 9, 12, 3, 4]

    # 現在の桁の余り N の状態を cur[N]
    # 直前の桁の余り N の状態を priv[N] とする
    priv = [1] + [0] * 12
    # print(priv)
    s = S[::-1]
    for i in range(0, len(s)):
        cur = [0] * 13
        d = s[i]
        # print('i=', i, 'd=', d)
        if d == '?':
            for j in range(13):
                for di in range(10):
                    m = di * MODS[i % 6]
                    cur[(j+m) % 13] += priv[j]
        else:
            m = int(d) * MODS[i % 6]
            for j in range(13):
                cur[(m+j) % 13] = priv[j]
        # print(cur)
        for j in range(13):
            priv[i] = cur[i] % P_MOD
    return cur[5]


if __name__ == '__main__':
    S = input()

    ans = solve(S)

    print(ans % P_MOD)
Problem p03014 (python)

Fixed submission:
#!/usr/bin/env python3


def solve(H, W, S):
    grid = [[0] * W for _ in range(H)]
    for y in range(H):
        count = 0
        start = 0
        for x in range(W):
            if S[y][x] == '#':
                for i in range(start, x):
                    grid[y][i] = count
                start = x + 1
                count = 0
            else:
                count += 1
        for i in range(start, W):
            grid[y][i] = count

    for x in range(W):
        count = 0
        start = 0
        for y in range(H):
            if S[y][x] == '#':
                for i in range(start, y):
                    grid[i][x] += count
                start = y + 1
                count = 0
            else:
                count += 1
        for i in range(start, H):
            grid[i][x] += count

    ans = 0
    for x in range(W):
        for y in range(H):
            if grid[y][x] > ans:
                ans = grid[y][x]
    return ans - 1


if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [input().strip() for _ in range(H)]

    ans = solve(H, W, S)

    print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3

import numpy as np


def solve(H, W, S):
    grid = np.zeros(H*W, dtype=np.int)
    for y in range(H):
        count = 0
        start = 0
        yw = y * W
        for x in range(W):
            if S[y][x] == '#':
                grid[yw+start:yw+x] = count
                start = x + 1
                count = 0
            else:
                count += 1
        grid[yw+start:yw+W] = count

    for x in range(W):
        count = 0
        start = 0
        for y in range(H):
            if S[y][x] == '#':
                grid[(start*W+x):(y*W+x):W] += count
                start = y + 1
                count = 0
            else:
                count += 1

        grid[(start*W+x):(H*W+1):W] += count

    return grid.max() - 1


if __name__ == '__main__':
    H, W = map(int, input().split())
    S = [input().strip() for _ in range(H)]

    ans = solve(H, W, S)

    print(ans)
Problem p03035 (python)

Fixed submission:
#!/usr/bin/env python3

def solv(a, b):
    if a >= 13:
        return b
    elif a >= 6:
        return b // 2
    else:
        return 0


if __name__ == '__main__':

    a, b = map(int, input().split())

    ans = solv(a, b)

    print(ans)

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3


def solv(a, b):
    if a >= 13:
        return b
    elif a >= 6:
        return b // 2
    else:
        return 0


if __name__ == '__main__':

    a, b = map(int, input().split())

    ans = solv(a, b)

    print(ans)
#!/usr/bin/env python3


def solv(a, b):
    if a >= 13:
        return b
    elif a >= 6:
        return b // 2
    else:
        return 0


if __name__ == '__main__':

    a, b = map(int, input().split())

    ans = solv(a, b)

    print(ans)
Problem p03106 (python)

Fixed submission:
class Solver:

    def __init__(self):
        pass

    def solve(self, a, b, k):
        for n in range(min(a,b), 0, -1):
            if (a % n) == 0 and (b % n) ==0:
                k -= 1
                if k == 0:
                    return n
        return 1


if __name__ == '__main__':

    solver = Solver()

    a, b, k = map(int, input().split())

    n = solver.solve(a, b, k)
    print(n)

Buggy submission (verdict: Runtime Error):
class Solver:

    def __init__(self):
        pass

    def solve(self, a, b, k):
        for n in range(min(a,b), 0, -1):
            if (a % n) == 0 and (b % n) ==0:
                k -= 1
                if k == 0:
                    return n
        return 1


if __name__ == '__main__':

    solver = Solver()

    a, b, k = map(int, input().split())

    n = solver.solve(a, b, k)
    print(n)
(atcoder) @lx
Problem p02681 (python)

Fixed submission:
S = input()
T = input()

pareil = True
for i in range(0, len(S)):
    if S[i] != T[i]:
        pareil = False
if pareil:
    print('Yes')
else:
    print('No')

Buggy submission (verdict: Runtime Error):
S = input()
T = input()
pareil = True
for i in range(0,len(S)):
	if S[i] != T[i]:
    	pareil = False
if pareil:
	print('Yes')
else:
	print('No')
Problem p02582 (python)

Fixed submission:
s=input()
c=0
tmp=0
for i in range(3):
    if s[i]=='R':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)

Buggy submission (verdict: Runtime Error):
s=input()
c=0
tmp=0
for i in range(3):
    if s[i]='S':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)

Buggy submission (verdict: Runtime Error):
s=input()
c=0
tmp=0
for i in range(3):
    if s[i]='s':
        tmp+=1
        if c<tmp:
            c=tmp
    else:
        tmp=0
print(c)
Problem p02755 (python)

Fixed submission:
import math
a,b=map(int,input().split())
f=0
for i in range(1,1001):
    if math.floor(i*0.08)==a and math.floor(i*0.1)==b:
        f=i
        break;
if f==0:
    print(-1)
else:
    print(f)

Buggy submission (verdict: Runtime Error):
import math
a,b=map(int,input().split())
A=math.ceil((a+1)/0.08)-1
B=math.ceil((b+1)/0.1)-1
A_=math.ceil(a/0.08)
B_=math.ceil(b/0.1)
C=math.floor(B*0.1)-mah.floor(B*0.08)
if b>80 or A<B_ or b-a>C:
    print(-1)
else:
    print(A_)
Problem p02756 (python)

Fixed submission:
s=input()
n=int(input())
r=-1
f=[]
b=[]
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            f.append(q[2])
        else:
            b.append(q[2])
f=''.join(f)
b=''.join(b)
s=f[::-1]+s+b
if r==1:
    s=s[::-1]
print(s)

Buggy submission (verdict: Runtime Error):
s=input()
n=int(input())
r=-1
f=[]
b=[]
for i in range(n):
    q=input().split()
    if q[0]=='1':
        r*=-1
    else:
        t=int(q[1])
        if t*r==-1 or t*r==2 :
            f.append(q[2])
        else:
            b.append(q[2])
s=f[::-1]+s+b
if r==1:
    s=s[::-1]
print(s)
Problem p02783 (python)

Fixed submission:
import math
h,a=map(int,input().split())
t=math.ceil(h/a)
print(t)

Buggy submission (verdict: Runtime Error):
n,k=map(int,input().split())
h=list(map(int,input().split()))
h.sort(reverse=True)
c=0
for i in range(k):
    h.pop(0)
    
for i in range(len(h)):
    c+=h[i]
print(c)
Problem p02817 (python)

Fixed submission:
s,t = input().split()
print(t+s)

Buggy submission (verdict: Runtime Error):
import fractions
X = int(input())

def qprime(n):
    if n<2:return False
    elif n==2:return True
    elif n%2==0:return False
    for i in range(3,math.floor(math.sqrt(n))+1,2):
                   if n % i == 0:return False
    return True


for i in range(X,100000):
    if qprime(i):
        print(i)
        break
Problem p02639 (python)

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

for i in range(5):
    if a[i] == 0:
        print(i+1)

Buggy submission (verdict: Runtime Error):
a = map(int, input().split())

for i in range(5):
    if a[i] == 0:
        print(i+1)
Problem p02641 (python)

Fixed submission:
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    ans = x
else:
    ans = float('inf')

d = float('inf')

for i in range(n+2):
    tmpx = x + 1 + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            if ans >= tmpx:
                ans = tmpx

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    ans = x

d = float('inf')

for i in range(n+1):
    tmpx = x + 1 + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            if ans >= tmpx:
                ans = tmpx

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    ans = x

d = float('inf')

for i in range(n+1):
    tmpx = x + 1 + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            if ans >= tmpx:
                ans = tmpx

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    ans = x

d = float('inf')

for i in range(n+1):
    tmpx = x + 1 + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            if ans > tmpx
                ans = tmpx

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
p = list(map(int, input().split()))

if n == 0:
    ans = x

d = float('inf')

for i in range(n):
    tmpx = x + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            ans = tmpx

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
    p = input()
    ans = x
else:
    p = list(map(int, input().split()))

d = float('inf')

for i in range(n):
    tmpx = x + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            ans = tmpx

print(ans)

Buggy submission (verdict: Runtime Error):
x, n = map(int, input().split())
if n == 0:
    ans = x
else:
    p = list(map(int, input().split()))

d = float('inf')

for i in range(n):
    tmpx = x + n//2 - i
    if not tmpx in p:
        tmpd = abs(x -tmpx) 
        if d >= tmpd:
            d = tmpd
            ans = tmpx

print(ans)
Problem p02830 (python)

Fixed submission:

def solve():
    n = int(input())
    s, t = input().split()

    ans = ''
    for i in range(n):
        ans += s[i] + t[i]
    else:
        print(ans)

if __name__ == '__main__':
    solve()

Buggy submission (verdict: Runtime Error):

def solve():
    n = int(input())
    s = input()
    t = input()

    str = ''
    for i in range(n):
        str += s[i] + t[i]
    else:
        print(str)



if __name__ == '__main__':
    solve()
Problem p02582 (python)

Fixed submission:
S = input()
rain_d = 0
max_rain_d = 0
for s in S:
    if s == 'R':
        rain_d += 1
        max_rain_d = rain_d
    elif s == 'S':
        rain_d = 0
print(max_rain_d)

Buggy submission (verdict: Runtime Error):
S = input()
rain_d = 0
for s in S:
    if s == 'R':
        rain_d += 1
        max_rain_d = rain_d
    elif s == 'S':
        rain_d = 0
print(max_rain_d)
Problem p02683 (python)

Fixed submission:
import sys
import itertools
n, m, x=map(int, input().split())
text = [list(map(int, i.strip('\n').split())) for i in sys.stdin]
num_tex = [i for i in range(1, len(text) + 1)]
all_c = []
for comb in num_tex:
    for v in itertools.combinations(text, comb):
        sum_a = []
        for j in range(1, len(v[0])):
            sum_a.append(sum([v_[j] for v_ in v]))
        if all([x <= sum_a_ for sum_a_ in sum_a]):
            all_c.append(sum([v_[0] for v_ in v]))
if len(all_c)!=0:
    print(sorted(all_c)[0])
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
import sys
import itertools
n, m, x=map(int, input().split())
text = [list(map(int, i.strip('\n').split())) for i in sys.stdin]
num_tex = [i for i in range(1, len(text) + 1)]
all_c = []
for comb in num_tex:
    for v in itertools.combinations(text, comb):
        sum_a = []
        for j in range(1, len(v[0])):
            sum_a.append(sum([v_[j] for v_ in v]))
        if all([x <= sum_a_ for sum_a_ in sum_a]):
            all_c.append(sum([v_[0] for v_ in v]))
print(sorted(all_c)[0])
Problem p02582 (python)

Fixed submission:
s = input()
s = s.split('S')
print(max([len(i) for i in s]))

Buggy submission (verdict: Runtime Error):
s = input()
s = s.replace('S', ' ').split()
print(max([len(i) for i in s]))
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
n = int(input())
a = sorted([int(i) for i in input().split()])
cnt = 1
for ai in a:
  cnt *= ai
  if cnt > 10 ** 18:
    print(-1)
    exit()
print(cnt)
Problem p02817 (python)

Fixed submission:
s, t = input().split()
print("".join([t, s]))

Buggy submission (verdict: Runtime Error):
n, k = [int(i) for i in input().split()]
r, s, p = [int(i) for i in input().split()]
t = list(input())
ans = 0
dic = {'p': s, 's': r, 'r': p}
for i in range(k):
  ans += dic[t[i]]
dic_ls = []
for i in range(k, n):
  if t[i] != t[i - k]:
    ans += dic[t[i]]
  else:
    t[i] = 'j'
print(ans)
Problem p02690 (python)

Fixed submission:
def solve():
    X = int(input())
    memo = {}
    for A in range(500):
        for B in range(500):
            memo[A**5-B**5] = (A,B)
            memo[A**5+B**5] = (A,-B)
    A,B = memo[X]
    print(A, B)

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    X = int(input())
    memo = {}
    for A in range(100):
        for B in range(100):
            memo[A**5-B**5] = (A,B)
            memo[A**5+B**5] = (A,-B)
    A,B = memo[X]
    print(A, B)

if __name__ == "__main__":
    solve()
Problem p02714 (python)

Fixed submission:
def solve():
    N = int(input())
    S = input()
    cnt = {}
    for c in S:
        cnt[c] = cnt.get(c, 0) + 1
    total_triplets = cnt.get('R', 0) * cnt.get('G', 0) * cnt.get('B', 0)
    for stride in range(1, N):
        for i in range(0, N-2*stride):
            j = i + stride
            k = j + stride
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                total_triplets -= 1
    print(total_triplets)

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    N = int(input())
    S = input()
    cnt = {}
    for c in S:
        cnt[c] = cnt.get(c, 0) + 1
    total_triplets = cnt['R'] * cnt['G'] * cnt['B']
    for stride in range(1, N):
        for i in range(0, N-2*stride):
            j = i + stride
            k = j + stride
            if S[i] != S[j] and S[j] != S[k] and S[k] != S[i]:
                total_triplets -= 1
    print(total_triplets)

if __name__ == "__main__":
    solve()
Problem p02814 (python)

Fixed submission:
def solve():
    import math
    N,M = [int(i) for i in input().split()]
    A = list(map(int, input().split()))

    lcm = A[0]
    for i in range(1, N):
        lcm = lcm * A[i] // math.gcd(lcm, A[i])
    first = lcm // 2

    ans_exists = True
    for i in range(N):
        if first % A[i] == 0:
            ans_exists = False

    if ans_exists:
        ans = int((M-first) // lcm + 1)
        print(ans)
    else:
        print('0')

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    import math
    N,M = [int(i) for i in input().split()]
    A = list(map(int, input().split()))

    lcm = A[0]
    for i in range(1, N):
        lcm = lcm * A[i] // math.gcd(lcm, A[i])
    if lcm == 0:
        print('0')
        return
    first = lcm * 0.5

    ans_exists = True
    for i in range(N):
        if first % A[i] == 0:
            ans_exists = False

    if ans_exists:
        ans = int((M-first) // lcm + 1)
        print(ans)
    else:
        print('0')

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    import math
    N,M = [int(i) for i in input().split()]
    A = list(map(int, input().split()))

    lcm = A[0]
    for i in range(1, N):
        lcm = lcm * A[i] // math.gcd(lcm, A[i])
    first = lcm * 0.5

    ans_exists = True
    for i in range(N):
        if first % A[i] == 0:
            ans_exists = False

    if ans_exists:
        ans = int((M-first) // lcm + 1)
        print(ans)
    else:
        print('0')

if __name__ == "__main__":
    solve()

Buggy submission (verdict: Runtime Error):
def solve():
    import math
    N,M = [int(i) for i in input().split()]
    A = list(map(int, input().split()))
    lcm = A[0]
    for i in range(1, N):
        lcm = lcm * A[i] // math.gcd(lcm, A[i])
    first = lcm * 0.5
    ans = int((M-first)//lcm + 1)
    print(ans)

if __name__ == "__main__":
    solve()