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

Fixed submission:
from itertools import product
import numpy as np

H, W, K = [int(n) for n in input().split()]
arr = np.zeros((H, W))
count = 0

for h in range(H):
    row = input()
    arr[h, :] = np.array([0 if mark=='.' else 1 for mark in row])

for row_onehot, col_onehot in product(product(range(2), repeat=H), product(range(2), repeat=W)):
    row_indexes = np.argwhere(np.array(row_onehot)==1).flatten()
    col_indexes = np.argwhere(np.array(col_onehot)==1).flatten()
    arr_ = arr.copy()
    for row_idx in row_indexes:
        arr_[row_idx, :] = 0
    for col_idx in col_indexes:
        arr_[:, col_idx] = 0
    if arr_.sum() == K:
        count += 1

print(count)

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


H, W, K = [int(n) for n in input().split()]
for _ in range(K):
  a = 1
print(1)

Buggy submission (verdict: Runtime Error):


H, W, K = [int(n) for n in input().split()]
for _ in range(K):
  a = 1
print(count)

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

H, W, K = [int(n) for n in input().split()]
arr = np.zeros((H, W))
count = 0

for h in range(H):
    row = input()
    arr[h, :] = np.array([0 if mark=='.' else 1 for mark in row])

print(1)

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

H, W, K = [int(n) for n in input().split()]
arr = np.zeros((H, W))
count = 0

for h in range(H):
    row = input()
    arr[h, :] = np.array([0 if mark=='.' else 1 for mark in row])

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

H, W, K = [int(n) for n in input().split()]
arr = np.zeros((H, W))
count = 0

for h in range(H):
    row = input()
    arr[h, :] = np.array([0 if mark=='.' else 1 for mark in row])

for row_onehot, col_onehot in product(product(range(2), repeat=H), product(range(2), repeat=W)):
    row_indexes = np.argwhere(np.array(row_onehot)==1).flatten()
    col_indexes = np.argwhere(np.array(col_onehot)==1).flatten()
    arr_ = arr.copy()
    for row_idx in row_indexes:
        arr_[row_idx, :] = 0
    for col_idx in col_indexes:
        arr_[:, col_idx] = 0
    if arr_.sum() == K:
        count += 1

print(count)
Problem p02583 (python)

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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)

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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)

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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)

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

if N < 3:
    print(0)
    exit()

ans = 0
for i in range(0, N - 2):
    for j in range(i + 1, N - 1):
        for k in range(j + 1, N):
            arr = [L[i], L[j], L[k]]
            arr.sort()
            if (arr[0] != arr[1] & arr[1] != arr[2]):
                if (arr[2] < arr[0] + arr[1]):
                    ans = ans + 1

print(ans)
Problem p03164 (python)

Fixed submission:
# -*- coding: utf-8 -*-
INF = float("inf")
# Input#
# n = int(input())
n, tar_w = map(int, input().split())

w = [-1]
v = [-1]
value_max = 0
for i in range(n):
    w_in, v_in = list(map(int, input().split()))
    w.append(w_in)
    v.append(v_in)
    value_max += v_in


memo = [[-1] * (value_max + 1) for i in range(n + 1)]

for i in range(n + 1):
    memo[i][0] = v[i]

for i in range(value_max + 1):
    memo[0][i] = INF


def dp(i, value):
    if memo[i][value] == -1:
        if value > v[i]:
            rest = dp(i - 1, value - v[i])
            if rest == INF:
                tar = INF
            else:
                tar = rest + w[i]
            memo[i][value] = min(dp(i - 1, value), tar)
        else:
            memo[i][value] = min(dp(i - 1, value), w[i])
    return memo[i][value]


ans = -1
OK_MAX = 0
NG_MIN = value_max + 1

while OK_MAX + 1 != NG_MIN:
    i = int((OK_MAX + NG_MIN) / 2)
    ans_tmp = dp(n, i)
    if ans_tmp <= tar_w:
        OK_MAX = i
    else:
        NG_MIN = i

ans = OK_MAX

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# Input#
# n = int(input())
n, tar_w = map(int, input().split())

w = [-1]
v = [-1]

memo = [[-1] * (tar_w + 1) for i in range(n + 1)]

for i in range(tar_w + 1):
    memo[0][i] = 0


def dp(n, tar_w):
    if memo[n][tar_w] == -1:
        if tar_w < w[n]:
            memo[n][tar_w] = dp(n - 1, tar_w)
        else:
            memo[n][tar_w] = max(dp(n - 1, tar_w), dp(n - 1, tar_w - w[n]) + v[n])
    return memo[n][tar_w]


for i in range(n):
    w_in, v_in = list(map(int, input().split()))
    w.append(w_in)
    v.append(v_in)

for i in range(n):
    ans = dp(i,tar_w)

ans = dp(n, tar_w)

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

# Input#
# n = int(input())
n, tar_w = map(int, input().split())

w = [-1]
v = [-1]

memo = [[-1] * (tar_w + 1) for i in range(n + 1)]

for i in range(tar_w + 1):
    memo[0][i] = 0


def dp(n, tar_w):
    if memo[n][tar_w] == -1:
        if tar_w < w[n]:
            memo[n][tar_w] = dp(n - 1, tar_w)
        else:
            memo[n][tar_w] = max(dp(n - 1, tar_w), dp(n - 1, tar_w - w[n]) + v[n])
    return memo[n][tar_w]


for i in range(n):
    w_in, v_in = list(map(int, input().split()))
    w.append(w_in)
    v.append(v_in)


ans = dp(n, tar_w)

print("{}".format(ans))
Problem p03166 (python)

Fixed submission:
# -*- coding: utf-8 -*-
from collections import deque

from sys import setrecursionlimit

setrecursionlimit(1000000)

INF = float("inf")
# Input#
# n = int(input())
n, m = map(int, input().split())
# a = list(map(int, input().split()))

d = deque()
d_tmp = deque()
x = [-1]
y = [[-1] for _ in range((n + 1))]

for _ in [0] * m:
    x_in, y_in = map(int, input().split())
    #    x.append(x_in)
    y[x_in].append(y_in)
    d.append((x_in, y_in))

memo = [-1] * (n + 1)
ans = -1


def dp(i):
    global ans
    if memo[i] == -1:
        ret = 0
        for x_in in y[i][1:]:
            tmp = dp(x_in) + 1
            if tmp > ret:
                ret = tmp
        memo[i] = ret
        if ret > ans:
            ans = ret
        return ret
    else:
        return memo[i]


for i, _ in d:
    if memo[i] == -1:
        dp(i)

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

x = [-1]
y = [-1]
for i in range(m):
    x_in, y_in = map(int, input().split())
    x.append(x_in)
    y.append(y_in)

memo = [-1] * (n + 1)
ans = -1


def dp(i):
    if memo[i] == -1:
        ret = 0
        for j in range(m + 1)[1:]:
            if x[j] == i:
                tmp = dp(y[j]) + 1
                ret = max(tmp, ret)
        memo[i] = ret
        return ret
    else:
        return memo[i]


for i in x[1:]:
    tmp = dp(i)
    ans = max(tmp, ans)

print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

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

x = [-1]
y = [-1]
for i in range(m):
    x_in, y_in = map(int, input().split())
    x.append(x_in)
    y.append(y_in)

memo = [-1] * (n + 1)


def dp(i):
    if memo[i] == -1:
        ret = 0
        for j in range(m + 1)[1:]:
            if x[j] == i:
                tmp = dp(y[j]) + 1
                ret = max(tmp, ret)
        memo[i] = ret
        return ret
    else:
        return memo[i]


ans = -1
for i in range(n + 1)[1:]:
    tmp = dp(i)
    ans = max(tmp, ans)

print("{}".format(ans))
Problem p03168 (python)

Fixed submission:
# -*- coding: utf-8 -*-
# from collections import deque
from sys import setrecursionlimit

setrecursionlimit(1000000)


# INF = float("inf")

# d = deque()
# ---Input---#
n = int(input())
# n, k = map(int, input().split())
p = list(map(float, input().split()))
p = [-1] + p

memo = [[-1 for _ in [0] * (n + 1)] for _ in [0] * (n + 1)]
memo[0][0] = 1
for i in range(len(p))[1:]:
    memo[0][i] = 0
    memo[i][0] = memo[i - 1][0] * (1 - p[i])
memo[0][0] = 1


def dp(i, j):
    if memo[i][j] == -1:
        memo[i][j] = dp(i - 1, j) * (1 - p[i]) + dp(i - 1, j - 1) * p[i]
    return memo[i][j]


ans = 0
tar = int(n / 2) + 1
for i in range(n + 1):
    dp(i, i)
    dp(i, n)

for i in range(n + 1)[tar:]:
    ans += dp(n, i)


print("{}".format(ans))

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
# from collections import deque
# from sys import setrecursionlimit

# setrecursionlimit(1000000)


# INF = float("inf")

# d = deque()
# ---Input---#
n = int(input())
# n, k = map(int, input().split())
p = list(map(float, input().split()))
p = [-1] + p

memo = [[-1 for _ in [0] * (n + 1)] for _ in [0] * (n + 1)]
memo[0][0] = 1
for i in range(len(p))[1:]:
    memo[0][i] = 0
    memo[i][0] = memo[i - 1][0] * (1 - p[i])
memo[0][0] = 1


def dp(i, j):
    if memo[i][j] == -1:
        memo[i][j] = dp(i - 1, j) * (1 - p[i]) + dp(i - 1, j - 1) * p[i]
    return memo[i][j]


ans = 0
tar = int(n / 2) + 1
for i in range(n + 1)[tar:]:
    ans += dp(n, i)


print("{}".format(ans))
Problem p02630 (python)

Fixed submission:
import numpy as np


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

sumA = sum(A)
cnt_num = np.zeros(10**5 + 1)

for i in A:
    cnt_num[i] += 1

for i in range(Q):
    B, C = map(int, input().split())
    sumA += (C - B) * cnt_num[B]
    print(int(sumA))
    cnt_num[C] += cnt_num[B]
    cnt_num[B] = 0

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

sumA = sum(A)
cnt_num = []
for i in range(10**5):
    cnt_num.append(A.count(i))

for i in range(Q):
    B, C = map(int, input().split())
    sumA += (C - B) * cnt_num[B]
    print(sumA)
    cnt_num[C] += cnt_num[B]
    cnt_num[B] = 0

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

sumA = sum(A)
cnt_num = []
for i in range(10**5):
    cnt_num.append(A.count(i))

for i in range(Q):
    B, C = map(int, input().split())
    sumA += (C - B) * cnt_num[B]
    print(sumA)
    cnt_num[C] += cnt_num[B]
    cnt_num[B] = 0
Problem p02639 (python)

Fixed submission:
x = list(map(int, input().split()))
for i in range(len(x)):
    if x[i] == 0:
        print(i+1)

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

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

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)
Problem p02642 (python)

Fixed submission:
import numpy as np


N = int(input())
A = list(map(int, input().split())) + [10**7]

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)

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


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

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input().split())) + [10**7]

A.sort()
e = np.zeros(10**6 + 1)
ans = 0
for i in range(N):
    if e[A[i]] == 0:
        e[::A[i]] = 1 # スライスで倍数indexを一気に変更できる。すごい。
        # 同じ値が重複していないか判定
        if A[i] != A[i+1]:
            ans += 1
print(ans)
Problem p02732 (python)

Fixed submission:
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from copy import deepcopy

n = int(input())
a = list(map(int, input().split()))
C = Counter(a)
S = 0
for key in C:
    S += comb(C[key], 2, exact=True)

for k in range(n):
    A = a[k]
    print(S - C[A] + 1)

Buggy submission (verdict: Runtime Error):
# from collections import deque
from collections import Counter
from scipy.misc import comb
# from scipy.special import comb
from copy import deepcopy

n = int(input())
k = list(map(int, input().split()))
for i in range(len(k)):
    ans = 0
    k_n = deepcopy(k)
    k_n.pop(i)
    c = Counter(k_n)
    for key in c:
        ans += comb(c[key], 2, exact=True)
    print(ans)
Problem p02675 (python)

Fixed submission:
# Nの1の位が
# 2,4,5,7,9のときhonNの1の位が0,1,6,8のときponNの1の位が3のときbonです。

a = int(input()) % 10
print('pphbhhphph'[a] + "on")

Buggy submission (verdict: Runtime Error):
n = input()

if n[1] in [2, 4, 5, 7, 9]:
    print("hon")
elif n[1] in [0, 1, 6, 8]:
    print("pon")
else:
    print("bon")
Problem p02713 (python)

Fixed submission:
import math
import itertools

# a = 6
# b = 4
#
# print(math.gcd(a, b))
k = int(input())
kk = k + 1
ans = 0
for i in range(1, kk):
    # print(i)
    for ii in range(1, kk):
        # print(ii)
        for iii in range(1, kk):
            # print((i,ii,iii))
            gcd2 = math.gcd(ii, iii)
            gcd3 = math.gcd(i, gcd2)
            ans += gcd3

print(ans)

Buggy submission (verdict: Runtime Error):
import math
import itertools

# a = 6
# b = 4
#
# print(math.gcd(a, b))
k = int(input())
kk = k + 1
ans = 0
for i in range(1, kk):
    # print(i)
    for ii in rangea(1, kk):
        # print(ii)
        for iii in range(1, kk):
            # print((i,ii,iii))
            gcd2 = math.gcd(ii, iii)
            gcd3 = math.gcd(i, gcd2)
            ans += gcd3

print(ans)
Problem p02748 (python)

Fixed submission:
aa, bb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

couponMin = float("INF")
for i in range(m):
    x, y, c = map(int, input().split())
    cc = a[x - 1] + b[y - 1] - c
    couponMin = min(couponMin, cc)

print(min(min(a) + min(b), couponMin))

Buggy submission (verdict: Runtime Error):
aa, bb, m = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

couponMin = float("INF")
for i in range(m):
    x, y, c = map(int, input().split())
    cc = a[x - 1] + b[x - 1] - c
    couponMin = min(couponMin, cc)

print(min(min(a) + min(b), couponMin))
Problem p02787 (python)

Fixed submission:
h, n, *L = map(int, open(0).read().split())
dp = [0] * (h + 99999)
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in zip(*[iter(L)] * 2))

print(dp[h])

Buggy submission (verdict: Runtime Error):
h, n, *L = map(int, open(0).read().split())
dp = [0] * (h + 1)
for i in range(1, h + 1):
    dp[i] = min(dp[i - a] + b for a, b in zip(*[iter(L)] * 2))

print(dp[h])
Problem p02995 (python)

Fixed submission:
import fractions

# 最小公倍数
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a, b, c, d = map(int, input().split())
a=  a-1

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

# 最小公倍数
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b, c, d = map(int, input().split())
a=  a-1

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)

Buggy submission (verdict: Runtime Error):
import math

# 最小公倍数
def lcm(x, y):
    return (x * y) // math.gcd(x, y)


a, b, c, d = map(int, input().split())
a=  a-1

c_a = a//c
c_b = b//c

d_a = a//d
d_b = b//d

lcm = lcm(min(c, d), max(c,d))

l_a = a//lcm
l_b = b//lcm




ans =  (b - a)  -  (c_b - c_a) - (d_b - d_a) + (l_b - l_a)

print(ans)
Problem p02767 (python)

Fixed submission:
from statistics import mean
n = input()
x_s = list(map(int,input().split()))
point_x = int(format(mean(x_s), '.0f'))
sum_e = sum([(x - point_x) ** 2 for x in x_s])
print(sum_e)

Buggy submission (verdict: Runtime Error):
from statistics import mean
n = input()
x_s = list(map(int,input().split()))
point_x = int(format(mean(x_s), '.0f'))
sum_e = sum([(x - point_x) ** 2 for x in x_s])
print(sum_e)
Problem p02957 (python)

Fixed submission:
# -*- coding: utf-8 -*-

a_b_list = list(map(int,input().split()))
a = a_b_list[0]
b = a_b_list[1]

k = (a + b) / 2
l = (a + b) % 2

if l == 0:
  print(int(k))
else:
  print("IMPOSSIBLE")

Buggy submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-
a, b = map(int, input().split())
k = (a + b) / 2
l = (a + b) % 2
if l == 0:
    print(k)
else:
    print(“IMPOSSIBLE”)
Problem p02658 (python)

Fixed submission:
import math
import sys
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
else:
  for x in i:
    result *= x
    if(result >= 10**18):
      break
  if(result > 10**18):
    print(-1)
  else:
    print(result)

Buggy submission (verdict: Runtime Error):
import math
N = input()
i = list(map(int, input().split()))
result = 1
if 0 in i:
  print(0)
  return
for x in i:
  result *= x
  if(len(str(result)) >= 19):
    print(-1)
    return
print(result)
Problem p02641 (python)

Fixed submission:
X, N = map(int, input().split())
p = list(map(int, input().split()))
for d in range(X + 1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
elif  2 <= N:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
    print(" ")
else:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())
if N == 0:
	print(X)
elif N == 1:
	p = [int(input())]
else:
    p = list(map(int, input().split()))
for d in range(N+1):
	for s in [-1, +1]:
		a = X + s * d
		if p.count(a) == 0:
			print(a)
			exit(0)

Buggy submission (verdict: Runtime Error):
X,N = list(map(int, input().split()))
if N == 0:
	print(X)
else:
	p = list(map(int,input().split()))
a = 0
b = 0
for i in range(N + 1):
  a = X + i
  b = X - i
  if p.count(b) == 0:
    print(b)
    exit(0)
  elif p.count(a) == 0:
    print(a)
    exit(0)
Problem p02657 (python)

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

Buggy submission (verdict: Runtime Error):
A,B = map(int, input().split(""))
print(A*B)
Problem p02657 (python)

Fixed submission:
a , b = (input().split(' '))
a = int(a)
b = int(b)
print(a*b)

Buggy submission (verdict: Runtime Error):
a = int(input())
b = int(input())

print(a*b)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()

print(a*b)
Problem p02658 (python)

Fixed submission:
def main ():
    N = int(input())
    A = list(map(int,input().split()))
    if 0 in A: 
        print (0)
        return
    prod = 1 
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return
    print(prod) 

main ()

Buggy submission (verdict: Runtime Error):
def main ():
  N = int(input())
  A = list(map(int,input().split()))
  if 0 in A: 
    print (0)
  	return
  prod = 1 
  for a in A:
    prod *= a
 	if prod > 1000000000000000000:
  		print(-1) 
        return
	print(prod)
    
main()

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    if( int(i) == 0):
        print(0)
        return
    product = product * int(i)

if product <= (10**18):
    print(product)
else:
    print(-1)

Buggy submission (verdict: Runtime Error):
N = int(input())
arr = []
product = 1
# while i < N:
arr = ((input().split(' ')))

for i in arr:
    if( i == 0):
        print(0)
        return
    product = product * int(i)

if product <= (10**18):
    print(product)
else:
    print(-1)
Problem p02640 (python)

Fixed submission:
x, y = map(int, input().split(' '))
result = False
for i in range(x+1):
    if (4 * (x - i) + 2 * i) == y:
        result = True
        break
s = 'Yes' if result else 'No'
print(s)

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

if ls.count(0) > 0:
    print(0)
else:
    result = 1
    for i in ls:
        result *= i
        if result > 10 ** 18:
            print(-1)
    print(result)
Problem p02677 (python)

Fixed submission:
import math
a, b, h, m = map(int, input().split(' '))

rec_h = 30 * h + 0.5 * m
rec_m = 6 * m
rec = abs(rec_h-rec_m)
if rec > 180:
    rec = 360 - rec

x = b * math.sin(math.radians(rec))
y = a - b * math.cos(math.radians(rec))

r = math.sqrt(x**2 + y**2)
print(r)

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

rec_h = 30 * h + 0.5 * m
rec_m = 6 * m
rec = (rec_h-rec_m) % 180

x = b * math.sin(math.radians(rec))
y = a - b * math.cos(math.radians(rec))

r = math.sqrt(x**2 + y**2)
print(r)
Problem p02683 (python)

Fixed submission:
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp.append(ls[1:])
for i in range(1 << N):
    price_combi, exp_combi, exp_rst, cnt = [], [], [0] * M, []
    for j in range(N):
        if (i >> j) & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in range(len(exp_combi)):
        for t in range(M):
            exp_rst[t] += exp_combi[s][t]
    [cnt.append(i) for i in exp_rst if i >= X]
    if len(cnt) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [ [] for i in range(M)], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << N):
    price_combi, exp_combi, exp_sum, cnt_ls = [], [], [0] * M, []
    for j in range(N):
        if i >> j & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in exp_combi:
        for t in range(M):
            exp_sum[t] += s[t]
    [ cnt_ls.append(x) for x in exp_sum if x >= X ]
    if len(cnt_ls) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)

Buggy submission (verdict: Runtime Error):
N, M, X = map(int, input().split(' '))
price, exp, rst = [], [ [] for i in range(N) ], -1
for i in range(N):
    ls = list(map(int, input().split(' ')))
    price.append(ls[0])
    exp[i] = ls[1:]
for i in range(1 << M):
    price_combi, exp_combi, exp_sum, cnt_ls = [], [], [0] * M, []
    for j in range(M):
        if i >> j & 1:
            price_combi.append(price[j])
            exp_combi.append(exp[j])
    for s in exp_combi:
        for t in range(M):
            exp_sum[t] += s[t]
    [ cnt_ls.append(x) for x in exp_sum if x >= X ]
    if len(cnt_ls) == M:
        if rst == -1:
            rst = sum(price_combi)
        else:
            rst = min(rst, sum(price_combi))
print(rst)