Harryxun/testdata huggingface dataset:
Buggy python submission (verdict: Runtime Error):
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(M)]

cost = [[float('inf')] * N for _ in range(N)]
for i in range(M):
    a, b, c = abc[i][0], abc[i][1], abc[i][2]
    cost[a-1][b-1] = c
    cost[b-1][a-1] = c

from scipy.sparse.csgraph import floyd_warshall
dist = floyd_warshall(cost)

mindist = float('inf')
import itertools
for it in itertools.permutations(r):
    it = list(it)
    d = 0
    for i in range(R - 1):
        d += int(dist[it[i]-1][it[i+1]-1])
    # print(it)
    mindist = min(mindist, d)
print(mindist)


Fixed submission:
N, M, R = map(int, input().split())
r = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(M)]

cost = [[float('inf')] * N for _ in range(N)]
for i in range(M):
    a, b, c = abc[i][0], abc[i][1], abc[i][2]
    cost[a-1][b-1] = c
    cost[b-1][a-1] = c

from scipy.sparse.csgraph import floyd_warshall
dist = floyd_warshall(cost)

mindist = float('inf')
import itertools
for it in itertools.permutations(r):
    it = list(it)
    d = 0
    for i in range(R - 1):
        d += int(dist[it[i]-1][it[i+1]-1])
    # print(it)
    mindist = min(mindist, d)
print(mindist)
Buggy python submission (verdict: Runtime Error):
n = int(input())
a = list(map(int, input().split()))

l = [0] * 9

for i in range(n):
    s = min(a[i] // 400, 9)
    l[s] += 1

m = 0
for i in range(len(l) - 1):
    if l[i] != 0:
        m += 1

M = min(9, l[-1] + m)
print(m, M)


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

l = [0] * 9

for i in range(n):
    s = min(a[i] // 400, 8)
    l[s] += 1

m = 0
for i in range(len(l) - 1):
    if l[i] != 0:
        m += 1

print(max(m, 1), l[-1] + m)

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

l = [0] * 9

for i in range(n):
    l[a[i] // 400] += 1

m = 0
for i in range(len(l) - 1):
    if l[i] != 0:
        m += 1

M = min(9, l[-1] + m)
print(m, M)


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

l = [0] * 9

for i in range(n):
    s = min(a[i] // 400, 8)
    l[s] += 1

m = 0
for i in range(len(l) - 1):
    if l[i] != 0:
        m += 1

print(max(m, 1), l[-1] + m)
Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
aaa = []
for i in range(N):
  aaa.append(list(reversed(list(map(int, input().split())))))

for i in range(0, N*N+1):
  done = [False] * N
  empty = True
  played = False
  for j, aa in enumerate(aaa):
    if len(aa) > 0:
      empty = False
      l = aa[-1]-1
      if (not (done[j] or done[l])) and len(aaa[l]) > 0 and aaa[l][-1] == j+1:
          aa.pop()
          aaa[l].pop()
          done[j], done[l] = True, True
          played = True
  if empty:
    print(i)
    break
  elif not played:
    print(-1)
    break

Fixed submission:
N = int(input())
aaa = []
for i in range(N):
  aaa.append(list(reversed(list(map(int, input().split())))))

cs = set(range(N))
for i in range(0, N*N+1):
  empty = True
  played = False
  ncs = set()
  for j in cs:
    aa = aaa[j]
    if len(aa) > 0:
      empty = False
      l = aa[-1]-1
      if j not in ncs and l not in ncs and len(aaa[l]) > 0 and aaa[l][-1] == j+1:
          aa.pop()
          aaa[l].pop()
          played = True
          ncs.add(j)
          ncs.add(l)
  cs = ncs
  if empty:
    print(i)
    break
  elif not played:
    print(-1)
    break
Buggy python submission (verdict: Runtime Error):
def tobin(n):
    return bin(n)[2:][::-1]

def occur(n, i):
    if i >= len(n):
        return 0
    if n[i] == '1':
        if i == 0:
            o = 1
        else:
            o = int(n[:i][::-1], 2) + 1
    else:
        o = 0
    if i < len(n) - 1:
        o += int(n[i+1:][::-1], 2) * (2 ** i)
    return o

A, B = map(int, input().split())
A, B = tobin(A-1), tobin(B)
F = ""

for i in range(len(B)):
    F += str((occur(B, i) - occur(A, i)) % 2)

print(int(F[::-1], 2))

Fixed submission:
def tobin(n):
    return bin(n)[2:][::-1]

def occur(n, i):
    if i >= len(n):
        return 0
    if n[i] == '1':
        if i == 0:
            o = 1
        else:
            o = int(n[:i][::-1], 2) + 1
    else:
        o = 0
    if i < len(n) - 1:
        o += int(n[i+1:][::-1], 2) * (2 ** i)
    return o

A, B = map(int, input().split())
A, B = tobin(A-1 if A > 0 else 0), tobin(B)
F = ""

for i in range(len(B)):
    F += str((occur(B, i) - occur(A, i)) % 2)

print(int(F[::-1], 2))
Buggy python submission (verdict: Runtime Error):
from numpy import *
input()
a=array(input().split())
d=a-minimum.accumulate(a)
print((d==d.max()).sum())


Fixed submission:
import numpy as np

input()
a = np.array(input().split(), dtype=np.int)

diff = a - np.minimum.accumulate(a)
print((diff == diff.max()).sum())
Buggy python submission (verdict: Runtime Error):
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for x in range(D)])

l_opt = np.array(list(range(1, 27)) * (D // 26) + list(range(1, D % 26 + 1)))
l_max = s.argmax(axis=1) + 1

for day in range(1, D + 1):
    if day * s[l_opt[day - 1] - 1] < s[l_max[day - 1] - 1]:
        l_opt[day - 1] = l_max[day - 1]

for l in l_opt:
    print(l)

Fixed submission:
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for x in range(D)])

l_opt = s.argmax(axis=1)
for l in l_opt:
    print(l + 1)

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

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for x in range(D)])

l_opt = np.array(list(range(1, 27)) * (D // 26) + list(range(1, D % 26 + 1)))
l_max = s.argmax(axis=1) + 1

for day in range(1, D + 1):
    if 2 * s[l_opt[day - 1] - 1] < s[l_max[day - 1] - 1, day + 1]:
        l_opt[day - 1] = l_max[day - 1]

for l in l_opt:
    print(l)

Fixed submission:
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for x in range(D)])

l_opt = s.argmax(axis=1)
for l in l_opt:
    print(l + 1)

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

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for x in range(D)])

l_opt = np.array(list(range(1, 27)) * (D // 26) + list(range(1, D % 26 + 1)))
l_max = s.argmax(axis=1) + 1

for day in range(1, D + 1):
    if 2 * s[l_opt[day - 1] - 1] < s[l_max[day - 1] - 1]:
        l_opt[day - 1] = l_max[day - 1]

for l in l_opt:
    print(l)

Fixed submission:
import numpy as np

D = int(input())
c = np.array(list(map(int, input().split())))
s = np.array([list(map(int, input().split())) for x in range(D)])

l_opt = s.argmax(axis=1)
for l in l_opt:
    print(l + 1)
Buggy python submission (verdict: Runtime Error):
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
B = [0 for i in range(N)]
for i in range(N-1):
  B[i] = A[i + 1] - A[i]
B[N - 1] = N - A[N - 1] + a[0]
ans = N - max(B)
print(ans)


Fixed submission:
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
B = [0 for i in range(N)]
for i in range(N-1):
  B[i] = A[i + 1] - A[i]
B[N - 1] = K - A[N - 1] + A[0]
ans = K - max(B)
print(ans)

Buggy python submission (verdict: Runtime Error):
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
B = [0 for i in range(N)]
for i in range(N-1):
  B[i] = A[i + 1] - A[i]
B[N - 1] = N - A[N] + a[0]
ans = N - max(B)
print(ans)

Fixed submission:
K, N = list(map(int, input().split()))
A = list(map(int, input().split()))
A = sorted(A)
B = [0 for i in range(N)]
for i in range(N-1):
  B[i] = A[i + 1] - A[i]
B[N - 1] = K - A[N - 1] + A[0]
ans = K - max(B)
print(ans)
Buggy python submission (verdict: Runtime Error):
s = input()
n = len(s)
l = (n - 1) // 2
m = n // 4
for i in range(m):
  if s[i] != s[l - i - 1] or s[i] != s[l + i + 1] or s[i] != s[n - i - 1]:
    

Fixed submission:
import sys
s = input()
n = len(s)
l = (n - 1) // 2
s1 = s[:l]
s2 = s[l+1:][::-1]
if s1 != s2:
    print('No')
    sys.exit()
m = l // 2
if l % 2 == 0:
    a1 = s1[:m]
    b1 = s2[:m]
    a2 = s1[m:][::-1]
    b2 = s2[m:][::-1]
else:
    a1 = s1[:m]
    b1 = s2[:m]
    a2 = s1[m+1:][::-1]
    b2 = s2[m+1:][::-1]
if a1 != a2 or b1 != b2:
    print('No')
    sys.exit()
print('Yes')
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = A.copy()
for i in range(1, N):
    ans += (-1) ** i * np.concatenate([A[i:].copy(), A[:i].copy()])
ans = list(ans)
print(" ".join(map(str, ans)))

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
A = np.array(list(map(int, input().split())))
sgn = np.tile(np.array([1, -1]), N // 2)
sgn = np.concatenate([sgn, np.array([1])])
ans = np.empty(N, dtype=np.int)
ans[0] = (A * sgn).sum()
for i in range(1, N):
    ans[i] = 2 * A[i - 1] - ans[i - 1]
print(*ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
ans = np.zeros((N), dtype=np.int)
tmp = np.zeros((N), dtype=np.int)
for i in range(N):
    if i == 0:
        tmp = A.copy()
    else:
        tmp = np.concatenate([A[i:].copy(), A[:i].copy()])
    ans += (-1) ** i * tmp
ans = list(ans)
print(" ".join(map(str, ans)))

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
A = np.array(list(map(int, input().split())))
sgn = np.tile(np.array([1, -1]), N // 2)
sgn = np.concatenate([sgn, np.array([1])])
ans = np.empty(N, dtype=np.int)
ans[0] = (A * sgn).sum()
for i in range(1, N):
    ans[i] = 2 * A[i - 1] - ans[i - 1]
print(*ans)

Buggy python submission (verdict: Runtime Error):
import numpy as np
N = int(input())
A = np.array(list(map(int, input().split())))
B = np.zeros((N, N))
for i, b in enumerate(B):
    b[i:i + 2] = 1 / 2
    if i == len(b) - 1:
        b[0] = 1 / 2
x = np.linalg.solve(B, A).astype(np.int)
print(" ".join(map(str, list(x))))

Fixed submission:
import sys
import numpy as np
input = sys.stdin.readline
N = int(input())
A = np.array(list(map(int, input().split())))
sgn = np.tile(np.array([1, -1]), N // 2)
sgn = np.concatenate([sgn, np.array([1])])
ans = np.empty(N, dtype=np.int)
ans[0] = (A * sgn).sum()
for i in range(1, N):
    ans[i] = 2 * A[i - 1] - ans[i - 1]
print(*ans)
Buggy python submission (verdict: Runtime Error):
import re
import numpy as np
from scipy.sparse import lil_matrix, csr_matrix

N, M = [int(i) for i in re.split(" ", input())]
G = lil_matrix((N, N), dtype=np.bool)

for i in range(M):
    u, v = [int(i) for i in re.split(" ", input())]
    G[u-1, v-1] = True
G = G.tocsr()
G = G.dot(G).dot(G)

S, T = [int(i) for i in re.split(" ", input())]

count = -1
G_tmp = G
for i in range(1, N+1):
    if i == 1:
        pass
    else:
        G_tmp = G_tmp.dot(G)
    if G_tmp[S-1, T-1]:
        count = i
        break

print(count)

Fixed submission:
import numpy as np
S = input()
S_ = list(set(S))
S = np.array(list(S))
S_ = np.array(S_)
ans = 'Yes'
if len(S_)!=2:
    ans = 'No'
elif sum(S==S_[0])!=2:
    ans = 'No'

print(ans)
Buggy python submission (verdict: Runtime Error):
import re
import numpy as np
 
N, K = [int(i) for i in re.split(" ", input())]
A = [int(i) for i in re.split(" ", input())]
count = 0
 
for i in range(N):
  tmp = 0
  for j, a in enumerate(A[i:]):
    tmp += a
    if tmp <= K:
      count += N - j
      break

print(count)

Fixed submission:
import re
X, A = [int(i) for i in re.split(" ", input())]
if X < A:
  print(0)
else:
  print(10)

Buggy python submission (verdict: Runtime Error):
import re
import numpy as np
 
W, H, x, y = [int(i) for i  in re.split(" ", input())]
 
print(W * H / 2)
 
if x * 2 == W and y * 2 == H:
  print(1)
else:
  print(0)

Fixed submission:
import re
X, A = [int(i) for i in re.split(" ", input())]
if X < A:
  print(0)
else:
  print(10)
Buggy python submission (verdict: Runtime Error):
import re
import numpy as np

N, X = [int(i) for i in re.split(" ", input())]
Ls = [int(i) for i in re.split(" ", input())]
Ds = np.cumsum(Ls)
counts = np.sum(Ls <= X) + 1
print(counts)

Fixed submission:
import re
import numpy as np
 
N, X = [int(i) for i in re.split(" ", input())]
Ls = [int(i) for i in re.split(" ", input())]
Ds = np.cumsum(Ls)
counts = np.sum(Ds <= X) + 1
print(counts)
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
A = np.empty(N, dtype=np.int)
B = np.empty(N, dtype=np.int)
for i in range(N):
	A[i], B[i] = map(int, input().split())

for i in range(N):
	print(A[i] * B[i])
	


Fixed submission:
A, B = map(int, input().split())
if 13 <= A:
	print(B)
elif 5 < A:
	print(B // 2)
else:
	print(0)
Buggy python submission (verdict: Runtime Error):
N, K = map(int, input().split())
S = input()

print(S[:K] + {'A': 'a', 'B': 'b', 'C': 'c'}[S[K]] + (S[K+1:] if K+1 < N else ''))


Fixed submission:
N, K = map(int, input().split())
S = input()
K -= 1
print(S[:K] + {'A': 'a', 'B': 'b', 'C': 'c'}[S[K]] + (S[K+1:] if K+1 < N else ''))

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

print(S[1:K] + {'A': 'a', 'B': 'b', 'C': 'c'}[S[K]] + (S[K+1:] if K+1 < N else ''))

Fixed submission:
N, K = map(int, input().split())
S = input()
K -= 1
print(S[:K] + {'A': 'a', 'B': 'b', 'C': 'c'}[S[K]] + (S[K+1:] if K+1 < N else ''))
Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

H, W, N = map(int, input().split())
si, sj = map(int, input().split())
si, sj = si - 1, sj - 1

S = input()
T = input()

# (1-based turn, 0:vertical | 1:horizontal, 0:minDiff | 1:exclusiveMaxDiff)
S_bounds = np.full((N + 1, 2, 2), 0, dtype=np.int)
T_bounds = np.full((N + 1, 2, 2), 0, dtype=np.int)

VERTICAL = 0
HORIZONTAL = 1
MIN_DIFF = 0
MAX_DIFF = 1

T_bounds[0, VERTICAL, :] = si
T_bounds[0, HORIZONTAL, :] = sj

piece_remaining = True

for t in range(N):
	S_bounds[t+1] = T_bounds[t]
	if S[t] == 'U':
		S_bounds[t+1, VERTICAL, MIN_DIFF] -= 1
	elif S[t] == 'D':
		S_bounds[t+1, VERTICAL, MAX_DIFF] += 1
	elif S[t] == 'L':
		S_bounds[t+1, HORIZONTAL, MIN_DIFF] -= 1
	elif S[t] == 'R':
		S_bounds[t+1, HORIZONTAL, MAX_DIFF] += 1
	
	min_i = S_bounds[t+1, VERTICAL, MIN_DIFF]
	max_i = S_bounds[t+1, VERTICAL, MAX_DIFF]
	min_j = S_bounds[t+1, HORIZONTAL, MIN_DIFF]
	max_j = S_bounds[t+1, HORIZONTAL, MAX_DIFF]

	if min_i < 0 or H <= max_i or min_j < 0 or W <= max_j:
		piece_remaining = False
		break

	T_bounds[t+1] = S_bounds[t+1]
	if T[t] == 'U':
		T_bounds[t+1, VERTICAL, MAX_DIFF] = max(0, S_bounds[t+1, VERTICAL, MAX_DIFF] - 1)
	elif T[t] == 'D':
		T_bounds[t+1, VERTICAL, MIN_DIFF] = min(H - 1, S_bounds[t+1, VERTICAL, MIN_DIFF] + 1)
	elif T[t] == 'L':
		T_bounds[t+1, HORIZONTAL, MAX_DIFF] = max(0, S_bounds[t+1, HORIZONTAL, MAX_DIFF] - 1)
	elif T[t] == 'R':
		T_bounds[t+1, HORIZONTAL, MIN_DIFF] = min(W - 1, S_bounds[t+1, HORIZONTAL, MIN_DIFF] + 1)

	min_i = T_bounds[t+1, VERTICAL, MIN_DIFF]
	max_i = T_bounds[t+1, VERTICAL, MAX_DIFF]
	min_j = T_bounds[t+1, HORIZONTAL, MIN_DIFF]
	max_j = T_bounds[t+1, HORIZONTAL, MAX_DIFF]

print('YES' if piece_remaining else 'NO')


Fixed submission:
import numpy as np

H, W, N = map(int, input().split())
si, sj = map(int, input().split())
si, sj = si - 1, sj - 1

S = input()
T = input()


min_i = si
max_i = si
min_j = sj
max_j = sj

piece_remaining = True

for t in range(N):
	if S[t] == 'U':
		min_i -= 1
	elif S[t] == 'D':
		max_i += 1
	elif S[t] == 'L':
		min_j -= 1
	elif S[t] == 'R':
		max_j += 1

	if min_i < 0 or H <= max_i or min_j < 0 or W <= max_j:
		piece_remaining = False
		break

	if T[t] == 'U':
		max_i = max(0, max_i - 1)
	elif T[t] == 'D':
		min_i = min(H - 1, min_i + 1)
	elif T[t] == 'L':
		max_j = max(0, max_j - 1)
	elif T[t] == 'R':
		min_j = min(W - 1, min_j + 1)

print('YES' if piece_remaining else 'NO')
Buggy python submission (verdict: Runtime Error):
import numpy as np

N = int(input())
E = [[] for _ in range(N)]
for i in range(N - 1):
	a, b = map(int, input().split())
	E[a - 1].append(b - 1)
	E[b - 1].append(a - 1)


INF = N + 1
D = [INF] * N

stack = [
	i
	for i in range(N)
	if len(E[i]) == 1
]

for i in stack:
	D[i] = 0

max_d = 0
cnt = 0
while stack:
	nexts = []
	for i in stack:
		if D[i] > max_d:
			D[i] = max_d
		nexts.extend(v for v in E[i] if D[v] == INF)
	max_d += 1
    cnt = len(stacks)
	stack = nexts

Rx2 = max_d * 2 if 1 < cnt else max_d * 2 - 1
print('First' if (Rx2 % 3 != 2) else 'Second')


Fixed submission:
N = int(input())
E = [[] for _ in range(N)]
for i in range(N - 1):
	a, b = map(int, input().split())
	E[a - 1].append(b - 1)
	E[b - 1].append(a - 1)


def farthest(s):
	visited = [False] * N
	stack = [(s, 0)]
	best = s, 0
	while stack:
		i, d = stack.pop()
		visited[i] = True
		if best[1] < d:
			best = i, d
		stack.extend((v, d + 1) for v in E[i] if not visited[v])
	return best

print('First' if (farthest(farthest(0)[0])[1] % 3 != 1) else 'Second')
Buggy python submission (verdict: Runtime Error):
from functools import reduce
N, M, C = map(int, input().split())
B = map(int, input().split())
count = 0
for _ in range(N):
    if 0 < C + reduce(lambda p: p[0]*p[1], zip(map(int, input().split()), B)):
        count += 1
print(count)


Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())
print((H-h)*(W-w))
Buggy python submission (verdict: Runtime Error):
from functools import reduce
N, M, C = map(int, input().split())
B = map(int, input().split())
count = 0
for _ in range(N):
  	if 0 < C + reduce(lambda p: p[0]*p[1], zip(map(int, input().split()), B)):
        count += 1
print(count)

Fixed submission:
from functools import reduce
N, M, C = map(int, input().split())
*B, = map(int, input().split())
count = 0
for _ in range(N):
	if 0 < C + reduce(lambda acc, p: acc + p[0]*p[1], zip(map(int, input().split()), B), 0):
		count += 1
print(count)

Buggy python submission (verdict: Runtime Error):
from functools import reduce
N, M, C = map(int, input().split())
B = map(int, input().split())
count = 0
for _ in range(N):
  	if 0 < C + reduce(lambda p: p[0]*p[1], zip(map(int, input().split()), B)):
    	count += 1
print(count)

Fixed submission:
from functools import reduce
N, M, C = map(int, input().split())
*B, = map(int, input().split())
count = 0
for _ in range(N):
	if 0 < C + reduce(lambda acc, p: acc + p[0]*p[1], zip(map(int, input().split()), B), 0):
		count += 1
print(count)
Buggy python submission (verdict: Runtime Error):
from math import gcd
A, B, K = map(int, input().split())
d = gcd(A, B)
print([i for i in range(100, 0, -1) if d % i == 0][K-1])

Fixed submission:
def gcd(a, b):
	while b != 0:
		a, b = b, a % b
	return a
A, B, K = map(int, input().split())
d = gcd(A, B)
print([i for i in range(100, 0, -1) if d % i == 0][K-1])
Buggy python submission (verdict: Runtime Error):
def nCk(n, k):
    ans = 1
    i = 0
    while i < k:
        ans *= n - i
        i += 1
    i = 1
    while i <= k:
        ans /= i
        i += 1
    return ans

def main():
    [N, P] = map(int, raw_input().split())
    even = 0
    odd = 0
    A = map(int, raw_input().split())
    i = 0
    while i < N:
        if 0 == A[i] & 1:
            even += 1
        else:
            odd += 1
        i += 1
    i = P
    k = 0
    while i <= odd:
        k += nCk(odd, i)
        i += 2
    print((2 ** even) * k)

main()

Fixed submission:
def nCk(n, k):
    ans = 1
    i = 0
    while i < k:
        ans *= n - i
        i += 1
    i = 1
    while i <= k:
        ans /= i
        i += 1
    return ans

def main():
    [N, P] = map(int, raw_input().split())
    even = 0
    odd = 0
    A = map(int, raw_input().split())
    i = 0
    while i < N:
        if 0 == A[i] & 1:
            even += 1
        else:
            odd += 1
        i += 1
    i = P
    k = 0
    while i <= odd:
        k += nCk(odd, i)
        i += 2
    print((2 ** even) * k)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
def nCk(n, k):
    ans = 1
    i = 0
    while i < k:
        ans *= n - i
        i += 1
    i = 1
    while i <= k:
        ans /= i
        i += 1
    return ans

def main():
    [N, P] = map(int, raw_input().split())
    even = 0
    odd = 0
    A = map(int, raw_input().split())
    i = 0
    while i < N:
        if 0 == A[i] & 1:
            even += 1
        else:
            odd += 1
        i += 1
    i = P
    k = 0
    while i <= odd:
        k += nCk(odd, i)
        i += 2
    print((2 ** even) * k)

if __name__ == '__main__':
    main()

Fixed submission:
def nCk(n, k):
    ans = 1
    i = 0
    while i < k:
        ans *= n - i
        i += 1
    i = 1
    while i <= k:
        ans /= i
        i += 1
    return ans

def main():
    [N, P] = map(int, raw_input().split())
    even = 0
    odd = 0
    A = map(int, raw_input().split())
    i = 0
    while i < N:
        if 0 == A[i] & 1:
            even += 1
        else:
            odd += 1
        i += 1
    i = P
    k = 0
    while i <= odd:
        k += nCk(odd, i)
        i += 2
    print((2 ** even) * k)

if __name__ == '__main__':
    main()
Buggy python submission (verdict: Time Limit Exceeded):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1

for a in A:
    #print(a,ans)
    if a == 0:
        ans = 0
        break
    else:
        ans *= a
if ans > i:
    print(-1)
else:
    print(ans)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1
if min(A) == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > i:
            ans = -1
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
 
i = 10**18
ans = 1
if 0 in set(A):
    print(0)
else:
    for a in A:
        ans *= a
    if ans > i:
        print(-1)
    else:
        print(ans)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1
if min(A) == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > i:
            ans = -1
            break
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
A = LI()

i = 10**18
ans = 1
for a in A:
    ans *= a
if ans > i:
    print(-1)
else:
    print(ans)

Fixed submission:
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
A = LI()
#print(A)
i = 10**18
ans = 1
if min(A) == 0:
    ans = 0
else:
    for a in A:
        ans *= a
        if ans > i:
            ans = -1
            break
print(ans)