Buggy python submission (verdict: Runtime Error):
N, P = map(int, input().split())
odd = sum([int(i) % 2 for i in input().split()])
even = N-odd

if odd == 0:
    if P == 0:
        print(2**even)
    else:  # P==1
        print(0)
else:
    print(2**even * (2**odd//2))


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

d = defaultdict(int)

d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1

ans = 0
for v in d.values():
    if v >= 2:
        ans += (v*(v-1))//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

s = [0]
sum = 0
for i in range(N):
    sum += A[i]
    s.append(sum)
s = sorted(s)

ans = 0
for r in set(s):
    cr = s.count(r)
    if cr >= 2:
        ans += (cr*(cr-1))//2

print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

d = defaultdict(int)

d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1

ans = 0
for v in d.values():
    if v >= 2:
        ans += (v*(v-1))//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

s = [0]
sum = 0
for i in range(N):
    sum += A[i]
    s.append(sum)
s = sorted(s)

ans = 0
for r in set(s):
    if s.count(r) >= 2:
        ans += (s.count(r)*(s.count(r)-1))//2

print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

d = defaultdict(int)

d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1

ans = 0
for v in d.values():
    if v >= 2:
        ans += (v*(v-1))//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

s = [0]
sum = 0
for i in range(N):
    sum += A[i]
    s.append(sum)
s = sorted(s)

ans = 0
for r in set(s):
    if s.count(r) >= 2:
        ans += (s.count(r)*(s.count(r)-1))//2

print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

d = defaultdict(int)

d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1

ans = 0
for v in d.values():
    if v >= 2:
        ans += (v*(v-1))//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
for l in range(N):
    for r in range(l+1, N+1):
        if sum(A[l:r]) == 0:
            ans += 1

print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

d = defaultdict(int)

d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1

ans = 0
for v in d.values():
    if v >= 2:
        ans += (v*(v-1))//2

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(i) for i in input().split()]

ans = 0
for l in range(N):
    for r in range(l+1, N+1):
        if sum(A[l:r]) == 0:
            ans += 1

print(ans)


Fixed submission:
from collections import defaultdict
N = int(input())
A = [int(i) for i in input().split()]

d = defaultdict(int)

d[0] = 1
sum = 0
for i in range(N):
    sum += A[i]
    d[sum] += 1

ans = 0
for v in d.values():
    if v >= 2:
        ans += (v*(v-1))//2

print(ans)