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

Fixed submission:
n = int(input())

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

M = 1000005

cnt = [0 for i in range(M)]

for x in a:
    if cnt[x] != 0:
        cnt[x] = 2
        continue
    for i in range(x, M, x):
        cnt[i] += 1

ans = 0

for x in a:
    if cnt[x] == 1:
        ans += 1
    
print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
n = int(input())

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

a.sort(reverse = True)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

if len(set(a)) == 1:
    print(0)
else:
    
    
    ans = 0

    for i in range(n):
        target = sympy.divisors(a[i])
        if len(set(target) & set(a)) == 1:
            ans += 1

    print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
#sympy.divisors(10**9)
n = int(input())

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

a.sort(reverse = True)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

if len(set(a)) == 1:
    print(0)
else:
    
    
    ans = 0

    for i in range(n):
        target = make_divisors(a[i])
        if len(set(target) & set(a)) == 1:
            ans += 1

    print(ans)

Buggy submission (verdict: Runtime Error):
import sympy
sympy.divisors(10**9)
n = int(input())

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

a.sort(reverse = True)

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

if len(set(a)) == 1:
    print(0)
else:
    
    
    ans = 0

    for i in range(n):
        target = make_divisors(a[i])
        if len(set(target) & set(a)) == 1:
            ans += 1

    print(ans)
Problem p02727 (python)

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

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)

eat_list = []

for i in range(x):
    eat_list.append(p[i])
for i in range(y):
    eat_list.append(q[i])
for i in range(c):
    eat_list.append(r[i])
    
eat_list.sort(reverse=True)

ans = 0

for i in range(x+y):
    ans += eat_list[i]

print(ans)

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

p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))

p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)

eat_list = []

for _ in range(x):
    if p[0] < r[0]:
        eat_list.append(r.pop(0))
    else:
        eat_list.append(p.pop(0))

for _ in range(y):
    if q[0] < r[0]:
        eat_list.append(r.pop(0))
    else:
        eat_list.append(q.pop(0))

print(sum(eat_list))
Problem p02861 (python)

Fixed submission:
N = int(input())
x = []
y = []
for i in range(N):
    a,b = map(int, (input().split()))
    x.append(a)
    y.append(b)
aaa = 0
for i in range(N):
    for k in range(N):
        aaa += ((x[i] - x[k])**2+(y[i] - y[k])**2)**0.5
print(aaa/N)

Buggy submission (verdict: Runtime Error):
N = int(input())
x = []
y = []
for i in range(N):
    a,b = map(int, (input().split()))
    x.append(a)
    y.append(b)
​
aaa = 0
for i in range(N):
    for k in range(N):
        aaa += ((x[i] - x[k])**2+(y[i] - y[k])**2)**0.5
print(aaa/N)
Problem p02923 (python)

Fixed submission:
s = int(input())

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

count = 0
box = []


for i in range(s-1):
    if a[i] >= a[i+1]:
        count += 1
    else:
        count = 0
        
    box.append(count)
    
print(max(box)) if s >=2 else print(0)

Buggy submission (verdict: Runtime Error):
s = int(input())

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

count = 0
box = []

for i in range(s-1):
    if a[i] >= a[i+1]:
        count += 1
    else:
        count = 0
        
    box.append(count)
    
print(max(box))
Problem p03262 (python)

Fixed submission:
import fractions

n, X = map(int, input().split())

x = list(map(int, input().split()))

x.append(X)

x.sort()

dis = []

for i in range(1, n+1):
    dis.append(x[i] - x[i-1])

for i in range(n):
    if i == 0:
        now = dis[i]
    else:
        now = fractions.gcd(dis[i], now)

print(now)

Buggy submission (verdict: Runtime Error):
import math

n, X = map(int, input().split())

x = list(map(int, input().split()))

x.append(X)

x.sort()

dis = []

for i in range(1, n+1):
    dis.append(x[i] - x[i-1])

for i in range(n):
    if i == 0:
        now = dis[i]
    else:
        now = math.gcd(dis[i], now)

print(now)
Problem p03285 (python)

Fixed submission:
N = int(input())

count = 0

for x in range(0,N):
    for y in range(0,N):
        if x*4 + y*7 == N:
            count += 1
            
           
            

print("No") if count == 0 else print("Yes")

Buggy submission (verdict: Runtime Error):
N = int(input())

for x in range(N//2):
    for y in range(N//2):
        if x*4 + y*7 == N:
            flag = True
        else:
            flag = False
            

print("Yes") if flag else print("No")

Buggy submission (verdict: Runtime Error):

N = int(input())

for x in range(N//2):
    for y in range(N//2):
        if x*4 + y*7 == N:
            flag = True
            

print("Yes") if flag else print("No")
Problem p03433 (python)

Fixed submission:
N = int(input())
A = int(input())

S = N%500

print("Yes") if A >= S else print("No")

Buggy submission (verdict: Runtime Error):
N = int(input())

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

a.reverse()

A = []
B = []

for x in range(0,N+1,2):
    A.append(a[x])
    
if N%2 == 1:
    for y in range(1,N,2):
        B.append(a[y])
        
    
else:
    for y in range(1,N+1,2):
        B.append(a[y])
    
    
    

    

print(sum(A)-sum(B))
Problem p03434 (python)

Fixed submission:
N = int(input())

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

a.reverse()

A = []
B = []

for x in range(0,N,2):
    A.append(a[x])
    
        
for y in range(1,N,2):
    B.append(a[y])
    
print(sum(A)-sum(B))

Buggy submission (verdict: Runtime Error):
N = int(input())

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

a.reverse()

A = []
B = []

for x in range(0,N+1,2):
    A.append(a[x])
    
if N%2 == 1:
    for y in range(1,N,2):
        B.append(a[y])
        
    
else:
    for y in range(1,N+1,2):
        B.append(a[y])
    
    
    

    

print(sum(A)-sum(B))

Buggy submission (verdict: Runtime Error):
N = int(input())

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

a.reverse()

A = []
B = []

for x in range(0,N+1,2):
    A.append(a[x])

for y in range(1,N,2):
    B.append(a[y])
    

print(sum(A)-sum(B))
Problem p03493 (python)

Fixed submission:
S = list(input())

print(S.count('1'))

Buggy submission (verdict: Runtime Error):
x = int(input())
a = list(map(int,input().split()))
count = 0
flag = 0
while flag == 0:
    count += 1
    for i in range(x):
        if a[i]%2 == 0:
            a[i] = a[i]/2
        
        else:
            flag = flag+1
            break
print(count-1)

Buggy submission (verdict: Runtime Error):
x = int(input())
a = list(map(int,input().split()))
count = 0
flag = True
while flag:
    count += 1
    for i in range(x):
        if a[i]%2 == 0:
            a[i] = a[i]/2
        
        else:
            flag = False
            break
print(count-1)
Problem p03632 (python)

Fixed submission:
A,B,C,D=map(int,input().split())
 
if B<=C or D<=A:
    print(0)
elif A<=C and B<=D:
    print(B-C)
elif C<=A and D<=B:
    print(D-A)
elif A<=C and D<=B:
    print(D-C)
elif C<=A and B<=D:
    print(B-A)

Buggy submission (verdict: Runtime Error):
S = list(map(int,input().split()))
 
if S[0] =< S[1] =< S[2] =< S[3]:
    print (0)
    
elif S[0] =< S[2] =< S[3] =< S[1]:
    print(S[3]-S[2])
    
elif S[0] =< S[2] =< S[1] =< S[3]:
    print(S[1] - S[2])
    
elif S[2] =< S[0] =< S[3] =< S[1]:
    print(S[3] - S[0])
 
elif S[2] =< S[3] =< S[0] =< S[1]:
    print(0)
Problem p04044 (python)

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

a = [input() for x in range(N)]

a.sort()

print(''.join(a))

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

a = [input() for i in range(L)]

a.sort()

c = ''

for x in a:
    
    c = c+x
    

print(str(c))

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

a = [input() for i in range(L)]

a.sort()

c = ''

for x in a:
    c = c+x
    

print(c)
Problem p02639 (python)

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

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

Buggy submission (verdict: Runtime Error):
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    A = list(map(int, input().split()))
    ans = 0

    A.sort(reverse=True)
    A = tuple(A)

    for i in range(N-1):
        flg = True
        for j in range(i+1, N):
            if A[i] % A[j] == 0:
                flg = False
                break
        if flg == True:
            ans += 1

    if A[N-1] != A[N-2]:
        ans += 1

    print(ans)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))
ans = 0

A.sort(reverse=True)

for i in range(len(A)-1):
    flg = True
    for j in range(i+1, len(A)):
        if A[i] % A[j] == 0:
            flg = False
            break
    if flg == True:
        print(i)
        ans += 1

print(ans)
Problem p02642 (python)

Fixed submission:

def main():
    N = int(input())
    A = list(map(int, input().split()))

    m = max(A) + 1
    dp = [0] * m

    for a in sorted(A):
        if dp[a] != 0:
            dp[a] = 2
            continue
        for i in range(a, m, a):
            dp[i] += 1

    print(sum(dp[i] == 1 for i in A))


if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
from collections import Counter


def main():
    N = int(input())
    A = list(map(int, input().split()))

    A_set = set(A)
    A_dict = Counter(A)
    A_dict.sort()

    for key, count in A_dict.items():
        if count > 1:
            A_set.discard(key)
            continue

        k = key * 2

        if key in A_set:
            while k <= max(A):
                A_set.discard(k)
                k += key

    print(len(A_set))


if __name__ == '__main__':
    main()
Problem p02657 (python)

Fixed submission:
A, B = map(int, input().split())
ans = A*B
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split()))

ans = 1

if 0 in A:
    print(0)
    exit()

for i in range(N):
    ans *= A[i]

    if ans > 10**18:
        ans = -1
        break

print(ans)
Problem p02658 (python)

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

ans = 1

if 0 in A:
    print(0)
    exit()

for i in range(N):
    ans *= A[i]

    if ans > 10**18:
        ans = -1
        break

print(ans)

Buggy submission (verdict: Runtime Error):
package main

import (
	"fmt"
)

func main() {
	var n int
	var ans int = 1
	var t int

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		fmt.Scan(&t)
		ans = ans * t
		if ans > 1000000000000000000 {
			ans = -1
		}
	}

	fmt.Println(ans)
}

Buggy submission (verdict: Runtime Error):
package main

import "fmt"

func main() {
	var n int
	var ans int = 1
	fmt.Scan(&n)
	t := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&t[i])
	}

	for i := 0; i < n; i++ {
		ans = ans * t[i]
	}

	if ans > 1000000000000000000 {
		ans = -1
	}
	fmt.Println(ans)
}
Problem p03035 (python)

Fixed submission:
def main():
    a,b = map(int, input().split())
    if a>=13:
        print(b)
    elif 6<=a<=12:
        print(int(b/2))
    else:
        print(0)
main()

Buggy submission (verdict: Runtime Error):
def main():
    a,b = map(int, input().split())
    if a>=13:
        print(b)
    elif 6<=a<=12:
        print(int(b/2)
    else:
        print(0)
main()
Problem p03044 (python)

Fixed submission:
import sys
sys.setrecursionlimit(10000000)


def main():
    n = int(input())
    
    G=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int, input().split())
        G[u-1].append([v-1,w])
        G[v-1].append([u-1,w])
    ans=[-1]*n
    
    def sub(node,distance):
        for next_node, edge in G[node]:
            if ans[next_node]==-1:
                ans[next_node]=(distance+edge)%2
                sub(next_node,(distance+edge)%2)
    sub(0,0)
    
    for i in ans:
        print(i)
main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecursionlimit


def main():
    n = int(input())
    
    G=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int, input().split())
        G[u-1].append([v-1,w])
        G[v-1].append([u-1,w])
    ans=[-1]*n
    
    def sub(node,distance):
        for next_node, edge in G[node]:
            if ans[next_node]==-1:
                ans[next_node]=(distance+edge)%2
                sub(next_node,(distance+edge)%2)
    sub(0,0)
    
    for i in ans:
        print(i)
main()

Buggy submission (verdict: Runtime Error):
import sys
sys.setrecrusionlimit

def main():
    n = int(input())
    
    G=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int, input().split())
        G[u-1].append([v-1,w])
        G[v-1].append([u-1,w])
    ans=[-1]*n
    
    def sub(node,distance):
        for next_node, edge in G[node]:
            if ans[next_node]==-1:
                ans[next_node]=(distance+edge)%2
                sub(next_node,(distance+edge)%2)
    sub(0,0)
    
    for i in ans:
        print(i)
main()

Buggy submission (verdict: Runtime Error):
def main():
    n = int(input())
    
    G=[[] for _ in range(n)]
    for _ in range(n-1):
        u,v,w = map(int, input().split())
        G[u-1].append([v-1,w])
        G[v-1].append([u-1,w])
    ans=[-1]*n
    
    def sub(node,distance):
        for next_node, edge in G[node]:
            if ans[next_node]==-1:
                ans[next_node]=(distance+edge)%2
                sub(next_node,(distance+edge)%2)
    sub(0,0)
    
    for i in ans:
        print(i)
main()
Problem p02675 (python)

Fixed submission:
n = int(input())
n %= 10
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if n in hon:
    print("hon")
elif n in pon:
    print("pon")
else:
    print("bon")

Buggy submission (verdict: Runtime Error):
n = input()
n %= 10
hon = [2,4,5,7,9]
pon = [0,1,6,8]
bon = [3]

if n in hon:
    print("hon")
elif n in pon:
    print("pon")
else:
    print("bon")
Problem p02631 (python)

Fixed submission:
import copy

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

target = 0
for i in range(n):
    target ^= A[i]

results = [''] * n

for i in range(n):
    results[i] = str(target ^ A[i])

print(" ".join(results))

Buggy submission (verdict: Runtime Error):
import copy

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

target = A[0] ^ A[1] ^ A[2] ^ A[3]

results = [''] * n

for i in range(n):
    results[i] = str(target ^ A[i])

print(" ".join(results))

Buggy submission (verdict: Runtime Error):
import copy

n = int(input())
A = list(map(int, input().split()))
B = copy.deepcopy(A)
results = [''] * n
maxvalue = max(A)
maxvalue2 = max(A)
targetValue = ''
while maxvalue > 0:
    mod = 0
    maxvalue = maxvalue >> 1
    for idx, a in enumerate(A):
        mod += a % 2
        A[idx] = a >> 1
    targetValue = str(mod % 2) + targetValue
for i in range(n):
    maxvalue2 = max(B)
    tmpValue = int(targetValue, 2)
    while maxvalue2 > 0:
        results[i] = str((tmpValue % 2 + B[i] % 2) % 2) + results[i]
        tmpValue = tmpValue >> 1
        B[i] = B[i] >> 1
        maxvalue2 = maxvalue2 >> 1
answers = [''] * n
for idx, res in enumerate(results):
    answers[idx] = str(int(res, 2))
print(" ".join(answers))
Problem p02720 (python)

Fixed submission:
import sys
K = int(input())

listup = []
listup.append(list(range(1, 10)))
list_length = 9
if K <= 9:
    print(listup[0][K - 1])
    sys.exit(0)
for i in range(10000000):
    new_list_floor = []
    for value in listup[i]:
        newlist = []
        mod_value = value % 10
        if mod_value == 0:
            newlist.append(value * 10 + mod_value)
            newlist.append(value * 10 + mod_value + 1)
        elif mod_value == 9:
            newlist.append(value * 10 + mod_value - 1)
            newlist.append(value * 10 + mod_value)
        else:
            newlist.append(value * 10 + mod_value - 1)
            newlist.append(value * 10 + mod_value)
            newlist.append(value * 10 + mod_value + 1)
        list_length_before = list_length
        list_length += len(newlist)
        new_list_floor.extend(newlist)
        if list_length >= K:
            diff = K - list_length_before
            print(newlist[diff - 1])
            sys.exit(0)
    listup.append(new_list_floor)
print(listup)

Buggy submission (verdict: Runtime Error):
import sys
K = int(input())

listup = []
listup.append(list(range(1, 10)))
list_length = 9
finish = False
for i in range(10000000):
    new_list_floor = []
    for value in listup[i]:
        newlist = []
        mod_value = value % 10
        if mod_value == 0:
            newlist.append(value * 10 + mod_value)
            newlist.append(value * 10 + mod_value + 1)
        elif mod_value == 9:
            newlist.append(value * 10 + mod_value - 1)
            newlist.append(value * 10 + mod_value)
        else:
            newlist.append(value * 10 + mod_value - 1)
            newlist.append(value * 10 + mod_value)
            newlist.append(value * 10 + mod_value + 1)
        list_length_before = list_length
        list_length += len(newlist)
        new_list_floor.extend(newlist)
        if list_length >= K:
            diff = K - list_length_before
            print(newlist[diff - 1])
            sys.exit(0)
    listup.append(new_list_floor)
print(listup)
Problem p02732 (python)

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

c = [0]*n

for i in range(n):
    c[a[i]-1] = c[a[i]-1] + 1
    
total = 0
for x in c:
    total = total + x*(x-1)//2

for i in range(n):
    print(total - c[a[i]-1] + 1)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
A = list(map(int, input().split()))

a_types = set(A)
for each in a_types:
    count_dict[each - 1] += A.count(each)

count_dict = [0] * N
for each in A:
    count_dict[each - 1] += 1

all_types = 0
for value in count_dict:
    all_types += value * (value - 1) // 2

# result_dict = {}
# for each in a_types:
#     result_dict[each] = all_types - count_dict[each] + 1

for a in A:
    print(all_types - count_dict[a - 1] + 1)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
A = list(map(int, input().split()))

count_dict = [0] * N
for each in A:
    count_dict[each] += 1

all_types = 0
for value in count_dict:
    all_types += value * (value - 1) // 2

# result_dict = {}
# for each in a_types:
#     result_dict[each] = all_types - count_dict[each] + 1

for a in A:
    print(all_types - count_dict[a] + 1)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
A = list(map(int, input().split()))

a_types = set(A)

count_dict = [0] * N
for each in A:
    count_dict[each] = A.count(each)

all_types = 0
for value in count_dict:
    all_types += value * (value - 1) // 2

# result_dict = {}
# for each in a_types:
#     result_dict[each] = all_types - count_dict[each] + 1

for a in A:
    print(all_types - count_dict[a] + 1)

Buggy submission (verdict: Runtime Error):
import copy
N = int(input())
A = list(map(int, input().split()))

a_types = set(A)

count_dict = [0] * N
for each in a_types:
    count_dict[each] = A.count(each)

all_types = 0
for value in count_dict:
    all_types += value * (value - 1) // 2

# result_dict = {}
# for each in a_types:
#     result_dict[each] = all_types - count_dict[each] + 1

for a in A:
    print(all_types - count_dict[a] + 1)
Problem p02813 (python)

Fixed submission:
import itertools

n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

p_index = -1
q_index = -1
combs = itertools.permutations(range(1, n + 1), n)
for index, each in enumerate(combs):
    if all(P[i] == each[i] for i in range(n)):
        p_index = index

    if all(Q[i] == each[i] for i in range(n)):
        q_index = index
print(abs(p_index - q_index))

Buggy submission (verdict: Runtime Error):
import itertools

n = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))

p_index = -1
q_index = -1
combs = itertools.permutations(range(1, n + 1), n)
for index, each in enumerate(combs, start=1):
#    print(index, each)
    if P[0] == each[0] and P[1] == each[1] and P[2] == each[2]:
        p_index = index

    if Q[0] == each[0] and Q[1] == each[1] and Q[2] == each[2]:
        q_index = index
print(abs(p_index - q_index))
Problem p02814 (python)

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


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


def lcm_list(numbers, maxvalue):
    first = 1
    second = 1
    for i in numbers:
        second = i
        lcm_result = lcm_base(first, second)
        if lcm_result > max_value:
            return -1
        first = lcm_result
    return lcm_result


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

max_value = 2 * m

lcm = lcm_list(A, 2 * m)
if lcm == -1:
    print("0")
    sys.exit(0)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
import sys


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


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


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

max_value = 2 * m

if len(A) > 1:
    lcm = lcm_list(A)
else:
    lcm = A[0]

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
import sys


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


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


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

max_value = 2 * m

lcm = lcm_list(A)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)

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


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


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


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

max_value = 2 * m

lcm = lcm_list(A)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)

Buggy submission (verdict: Runtime Error):
from fractions import gcd
from functools import reduce
import sys

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

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

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

max_value = 2 * m

lcm = lcm_list(A)

if any((lcm / a) % 2 != 1 for a in A):
    print("0")
    sys.exit(0)

max_product = max_value // lcm
print((max_product + 1) // 2)
Problem p03633 (python)

Fixed submission:
from fractions import gcd
n = int(raw_input())
a = []
for i in range(n):
    a.append(int(raw_input()))
result = a[0]
for i in range(1, n):
    result = result * a[i] / gcd(result, a[i])
print result

Buggy submission (verdict: Runtime Error):
from fractions import gcd
n = int(raw_input())
a = []
for i in range(n):
    a.append(int(raw_input()))
result = a[0]
for i in range(1, n):
    result = result * a[i] / gcd(result, a[i])
print result / g