Problem:


Score : 200 points

Problem Statement

There are N bags of biscuits. The i-th bag contains A_i biscuits.

Takaki will select some of these bags and eat all of the biscuits inside.
Here, it is also possible to select all or none of the bags.

He would like to select bags so that the total number of biscuits inside is congruent to P modulo 2.
How many such ways to select bags there are?

Constraints

1 \leq N \leq 50

P = 0 or 1

1 \leq A_i \leq 100

Input

Input is given from Standard Input in the following format:

N P
A_1 A_2 ... A_N

Output

Print the number of ways to select bags so that the total number of biscuits inside is congruent to P modulo 2.

Sample Input 1

2 0
1 3

Sample Output 1

2

There are two ways to select bags so that the total number of biscuits inside is congruent to 0 modulo 2:

Select neither bag. The total number of biscuits is 0.

Select both bags. The total number of biscuits is 4.

Sample Input 2

1 1
50

Sample Output 2

0

Sample Input 3

3 0
1 1 1

Sample Output 3

4

Two bags are distinguished even if they contain the same number of biscuits.

Sample Input 4

45 1
17 55 85 55 74 20 90 67 40 70 39 89 91 50 16 24 14 43 24 66 25 9 89 71 41 16 53 13 61 15 85 72 62 67 42 26 36 66 4 87 59 91 4 25 26

Sample Output 4

17592186044416



Sample input:
2 0
1 3


Sample output:
2

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
a = list(map(int,input().split()))
m = 0
for i in range(n):
    if a[i]%2 == 1:
        m += 1
if m == 0 and p == 1:
    print(0)
elif m==0 and p==0:
    print(2*(n))
else:
    print((2**(m-1))*(2**(n-m)))

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
a = list(map(int,input().split()))
m = 0
for i in range(n):
    if a[i]%2 == 1:
        m += 1
print((2**(m-1))*(2**(n-m)))

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a=l.count(0)
b=l.count(1)
ans1=1
if not a==0:
  for i in range(0,a+1,2):
    ans11=1
    for j in range(a,a-i-1,-1):
      ans11*=j
    for j in range(1,1+i):
      ans11//=j
    ans1+=ans11
ans2=1
if not b==0:
  for i in range(p,b+1,2):
    ans21=1
    for j in range(b,b-i-1,-1):
      ans21*=j
    for j in range(1,1+i):
      ans21//=j
    ans2+=ans21
print(ans1*ans2)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a=l.count(0)
b=l.count(1)
ans1=1
for i in range(0,a+1,2):
  ans11=1
  for j in range(a,a-i,-1):
    ans11*=j
  for j in range(1,1+i):
    ans11//=j
  ans1+=ans11
ans2=1
for i in range(p,b+1,2):
  ans21=1
  for j in range(b,b-i,-1):
    ans21*=j
  for j in range(1,1+i):
    ans21//=j
  ans2+=ans21
print(ans1*ans2)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
l=list(map(lambda x:int(x)%2,input().split()))
a=l.count(0)
b=l.count(1)
ans1=1
for i in range(0,a+1,2):
  ans11=1
  for j in range(a,a-i,-1):
    ans11*=j
  for j in range(1,1+i):
    ans11//=j
  ans1+=ans11
ans2=1
for i in range(p,b+1,2):
  ans21=1
  for j in range(b,b-i,-1):
    ans21*=j
  for j in range(1,1+i):
    ans21//=j
  ans2+=ans21
print(ans1+ans2)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
a=list(map(int,input().split()))
for i in a:
  i%=2
k=a.count(1)
ans=0
for i in range(p,n+1,2):
  t=1
  for j in range(k,k-i,2):
    t*=j
  for j in range(1,1+i,2):
    t//=j
  ans+=t
print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split());a=list(map(int,input().split()));b=[0,0]
for i in a:b[i%2]+=1
if 0==b[1]:print(2**n)
else:print(2**(n-1))

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split());a=list(map(int,input().split()));b=[0,0]
for i in a:b[i%2]+=1
print(2**b[p]-p)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
lst_A = list(map(int, input().split()))

ans = 2 ** (N-1)
print(ans)

Submission status: Wrong Answer

Solution code:
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))

ev = 0
ad = 0
for i in A:
  if i % 2 == 0:
    ev += 1
  else:
    ad += 1

R = 1
if P == 1:
  if ad == 0:
    print("0")
    exit()
  R = ad
  ad -= 1
  

f = [1, 1]
for i in range(2, ad + 1):
  f.append(f[-1] * i)
num = 1
for i in range(2, ad + 1, 2):
  num += f[ad] // (f[i] * f[ad - i])

print(pow(2, ev) * num * R)

Submission status: Wrong Answer

Solution code:
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))

ev = 0
ad = 0
for i in A:
  if i % 2 == 0:
    ev += 1
  else:
    ad += 1

R = 1
if N == 1:
  if ad == 0:
    print("0")
    exit()
  R = ad
  ad -= 1
  

f = [1, 1]
for i in range(2, ad + 1):
  f.append(f[-1] * i)
num = 1
for i in range(2, ad + 1, 2):
  num += f[ad] // (f[i] * f[ad - i])

print(pow(2, ev) * num * R)

Submission status: Wrong Answer

Solution code:
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))

ev = 0
ad = 0
for i in A:
  if i % 2 == 0:
    ev += 1
  else:
    ad += 1

R = 1
if N == 1:
  if ad == 0:
    print("0")
    exit()
  ad -= 1
  R = ad

f = [1, 1]
for i in range(2, ad + 1):
  f.append(f[-1] * i)
num = 1
for i in range(2, ad + 1, 2):
  num += f[ad] // (f[i] * f[ad - i])

print(pow(2, ev) * num * R)

Submission status: Wrong Answer

Solution code:
N, P = list(map(int, input().split()))
A = list(map(int, input().split()))

ev = 0
ad = 0
for i in A:
  if i % 2 == 0:
    ev += 1
  else:
    ad += 1

if N == 1:
  if ad == 0:
    print("0")
    exit()
  ad -= 1

f = [1, 1]
for i in range(2, ad + 1):
  f.append(f[-1] * i)
num = 1
for i in range(2, ad + 1, 2):
  num += f[ad] // (f[i] * f[ad - i])

print(pow(2, ev) * num)

Submission status: Wrong Answer

Solution code:
import numpy as np 
N, P = map(int, input().split())
A = np.array(list(map(int, input().split())))

even = ((A % 2) == 0).sum()
odd = len(A) - even
flag = True

if (P == 1) & (odd == 0):
  print(0)
  flag = False

if flag:
  print((2**even) * (2**(odd - 1)))

Submission status: Wrong Answer

Solution code:
import math
N, P = map(int, input().split())
A = list(map(int, input().split()))
odd = 0
even = 0

def nCr(n, r):
    return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1
even_cmb = 1
for i in range(1, even+1):
    even_cmb += nCr(even, i)

if P == 0:
    odd_cmb = 1
    for i in range(2, odd+1):
        if i % 2 != 0:
            continue
        print(nCr(odd, i))
        odd_cmb += nCr(odd, i)
    ans = even_cmb * odd_cmb
else:
    odd_cmb = 0
    for i in range(1, odd+1):
        if i % 2 == 1:
            odd_cmb += nCr(odd, i)
    ans = even_cmb * odd_cmb
print(ans)
exit()

Submission status: Wrong Answer

Solution code:
import math
N, P = map(int, input().split())
A = list(map(int, input().split()))
odd = 0
even = 0

def nCr(n, r):
    return math.factorial(n) // math.factorial(n-r) // math.factorial(r)

for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1
even_cmb = 1
for i in range(1, even+1):
    even_cmb += nCr(even, i)
odd_cmb = 0
if P == 0:
    for i in range(2, odd+1):
        if i % 2 != 0:
            continue
        odd_cmb += nCr(odd, i)
    ans = even_cmb * odd_cmb + 1
else:
    for i in range(1, odd+1):
        if i % 2 == 1:
            odd_cmb += nCr(odd, i)
    ans = even_cmb * odd_cmb
print(ans)
exit()

Submission status: Wrong Answer

Solution code:
N,P=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x:x%2,a))
if 1 in a:
    print(2**N)
else:
    if P%2==0:
        print(2**(N-1))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
N,P=map(int,input().split())
a=list(map(int,input().split()))
a=list(map(lambda x:x%2,a))
if 1 in a:
    print(2**(N-1))
else:
    if P%2==0:
        print(2**(N-1))
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
import math

N, P = map(int, input().split())
mA = [int(i) % 2 for i in input().split()]
nZ = mA.count(0)
nO = mA.count(1)
def C(n,r):
    if n == 0 or r == 0:
        return 1
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
if P == 0:
    tZ = sum([C(nZ, i) for i in range(1, nZ+1)])+1
    tO = sum([C(nO, 2*i) for i in range(1, (nO//2)+1)])+1

    print(tO*tZ)
else:
    tZ = sum([C(nZ, i) for i in range(1, nZ+1)])+1
    tO = sum([C(nO, 2*i-1) for i in range(1, (nO//2)+1)])+1

    print(tO*tZ)

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
A = list(map(int,input().split()))

ans = [0]
for i in A:
    ans2 = []
    for a in ans:
        ans2.append(i+a)
        ans2.append(i)
        ans = ans2

count = 0
for num in ans:
    if num%2 == p:
        count += 1

print(count)

Submission status: Wrong Answer

Solution code:
import math
N,P=map(int,input().split())
A=list(map(int,input().split()))
Odd=0
Eve=0

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

for i in range(N):
    if A[i]%2==1:
        Odd+=1
    else:
        Eve+=1
if P==1:
    Ocnt=0
    for i in range(Odd):
        if 1+2*i>Odd:
            break
        else:
            Ocnt+=combinations_count(Odd,1+2*i)
    print(Ocnt*(2**Eve))
else:
    Ocnt=0
    for i in range(Odd):
        if 2*i>Odd:
            break
        else:
            Ocnt+=combinations_count(Odd,2*i)
    print(Ocnt*(2**Eve))

Submission status: Wrong Answer

Solution code:
import collections
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
input = sys.stdin.readline
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

def combi(a,b):
	num = 1
	for j in range(b):
		num = num*(a-j)//(j+1)
	return num

N,P = IL()
A = IL()

odd = 0
even = 0
for i in A:
	if i%2 != 0:
		odd += 1
	else:
		even += 1

zero = 1
if even != 0:
	for i in range(1,even+1):
		zero += combi(even,i)
		print(zero)

if P == 1:
	ans = 0
	for i in range(1,odd+1,2):
		ans += combi(odd,i)*zero
else:
	ans = 0
	for i in range(0,odd+1,2):
		ans += combi(odd,i)*zero
		
print(ans)

Submission status: Wrong Answer

Solution code:
import math

def cc(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

n, p = map(int, input().split())
a = list(map(int, input().split()))
o = 0
e = 0
s = 0
for i in a:
  if i%2:
    o += 1
  else:
    e += 1
if p:
  for j in range(1,o,2):
    s += cc(o, j)
else:
  for k in range(0,o,2):
    s += cc(o, k)
print(s*2**e)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
A = list(map(int, input().split()))

even = 0
odd  = 0
for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

ans = 2 ** (even + odd - 1)
if odd == 0:
    if P == 0: ans = 0
    else: ans = 2 ** even
    
print(ans)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
A = list(map(int, input().split()))

even = 0
odd  = 0
for a in A:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1

ans = 2 ** (even + odd - 1)
if odd == 0 and P == 1:
    ans = 0
print(ans)

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
a = list(map(int,input().split()))

cnt = 0
for x in a:
    if x % 2 == 0:
        cnt += 1
        
if cnt == n:
    print(0)
else:
    print(2**n//2)

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
a = list(map(int,input().split()))

if n == 1:
    if a[0] % 2 == 1:
        print(1)
    elif p == 0:
        print(2)
    else:
        print(0)
else:
    print(2**n//2)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
a = list(map(int, input().split()))
odd = 0
for i in a:
    if i % 2:
        print(2 ** (n - 1))
if p:
    print(0)
else:
    print(2 ** n)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
a = list(map(int, input().split()))
odd = 0
for i in a:
    if i % 2:
        odd += 1
if odd == n and odd == 1 and p == 0:
    print(0)
else:
    ans = (2 ** (n - odd)) * (2 ** odd // 2)
    print(ans)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
a = list(map(int, input().split()))
odd = 0
for i in a:
    if i % 2:
        odd += 1
ans = (2 ** (n - odd)) * (2 ** odd // 2)
print(ans)

Submission status: Wrong Answer

Solution code:
import math


def nCr(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


n, p = map(int, input().split())
a = list(map(int, input().split()))
count = 0
for i in a:
    if i % 2:
        count += 1
ans = 0
for i in range(1, count + 1, 2):
    ans += nCr(count, i)
ans_ = 0
for i in range(0, n - count + 1, 2):
    ans_ += nCr(n - count, i)
if p == 1:
    if count == 0:
        print(0)
    elif count == n:
        print(ans)
    else:
        print(ans * ans_ * 2)
else:
    if count == 0:
        print(ans_)
    elif count == n:
        print(ans)
    else:
        print(ans * ans_ * 2)

Submission status: Wrong Answer

Solution code:
N,P = [int(i) for i in input().split()]
A = [int(i)%2 for i in input().split()]

k = A.count(1)
l = A.count(0)

if P == 0:
    if k == 0:
        print(2**l)
    ans = 1
    ans = 2**(k-1+l)
else:
    if k == 0:
        print(0)
        exit()
    else:
        ans = 1
        ans = 2**(k-1+l)

print(A)

Submission status: Wrong Answer

Solution code:
N,P = [int(i) for i in input().split()]
A = [int(i)%2 for i in input().split()]

k = A.count(1)
l = A.count(0)

if P == 0:
    ans = 1
    ans = 2**(k-1+l)
else:
    if k == 0:
        print(0)
        exit()
    else:
        ans = 1
        ans = 2**(k-1+l)

print(ans)

Submission status: Wrong Answer

Solution code:
import math
n,p = map(int, input().split())
aa = list(map(int, input().split()))

aa = list(map(lambda x:x%2, aa))
odd = aa.count(1)
even = aa.count(0)
ans = 2**even
# if p==1:
#     ans*=odd
#     odd-=1
# 偶数個の選び方
pattern = 0
for i in range(p, odd+1, 2):
    print(even, odd, i, math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i)))
    pattern += math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i))
print(ans*pattern)

Submission status: Wrong Answer

Solution code:
import math
n,p = map(int, input().split())
aa = list(map(int, input().split()))

aa = list(map(lambda x:x%2, aa))
odd = aa.count(1)
even = aa.count(0)
ans = 2**even
# 偶数個の選び方
pattern = 0
for i in range(0, odd+1, 2):
    # print(i, odd, math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i)))
    pattern += math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i))
print(ans*pattern)

Submission status: Wrong Answer

Solution code:
import math
n,p = map(int, input().split())
aa = list(map(int, input().split()))

aa = list(map(lambda x:x%2, aa))
odd = aa.count(1)
even = aa.count(0)
ans = 2**even
if p==1 and odd%2==0:
    ans *= odd
    odd -= 1
# 偶数個の選び方
pattern = 0
for i in range(0, odd+1, 2):
    # print(i, odd, math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i)))
    pattern += math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i))
print(ans*pattern)

Submission status: Wrong Answer

Solution code:
import math
n,p = map(int, input().split())
aa = list(map(int, input().split()))

aa = list(map(lambda x:x%2, aa))
odd = aa.count(1)
even = aa.count(0)
ans = 2**even
if p==1:
    ans *= odd
    odd -=1
# 偶数個の選び方
pattern = 0
for i in range(0, odd+1, 2):
    # print(i, odd, math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i)))
    pattern += math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i))
print(ans*pattern)

Submission status: Wrong Answer

Solution code:
import math
n,p = map(int, input().split())
aa = list(map(int, input().split()))

aa = list(map(lambda x:x%2, aa))
odd = aa.count(1)
even = aa.count(0)
ans = 2**even
if p==1:
    ans *= odd
    odd -=1
# 偶数個の選び方
pattern = 0
for i in range(0, odd+1, 2):
    # print(i, odd, math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i)))
    pattern += math.factorial(odd) // (math.factorial(i)*math.factorial(odd-i))
print(pattern)

Submission status: Wrong Answer

Solution code:
N, P = map(int,input().split())
A = list(map(int,input().split()))

nCr = {}
def cmb(n, r):
    if r == 0 or r == n: return 1
    if r == 1: return n
    if (n,r) in nCr: return nCr[(n,r)]
    nCr[(n,r)] = cmb(n-1,r) + cmb(n-1,r-1)
    return nCr[(n,r)]


odd = 0
even= 0

res = 0

for i in A:
    if i%2:
        odd += 1
    else:
        even += 1

'''
if P==0:
    res += 1
    if odd >= 2:
        odd -= 2
        res += uoo(odd)
    if even >= 1:
        res += 2**even
'''


evensum = 0
oddsum = 0

if P == 0: 
    # odd 
    for i in range(2,odd+1,2):
        oddsum += cmb(odd, i)
    # even
    for i in range(1,even+1):
        evensum += cmb(even, i)
    res = oddsum + evensum

# P == 1
else: 
    # odd
    if odd >= 1:
        for i in range(1,odd+1,2):
            oddsum += cmb(odd, i)
        res += 1
    # even
    #if even >= 1:

    for i in range(1,even+1):
        evensum += cmb(even, i)
    res += oddsum * evensum



print(res)

Submission status: Wrong Answer

Solution code:
import math
def a():return input()#s
def ai():return int(input())#a,n or k
def ma():return map(int, input().split())#a,b,c,d or n,k
def ms():return map(str, input().split())#,a,b,c,d
def lma():return list(map(int, input().split()))#x or y
def lms():return list(map(str, input().split()))#x or y
def say(i):return print("Yes" if i == 1 else "No")
def Say(i):return print("YES" if i == 1 else "NO")
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

a,b = ma()
x = lma()
k =[]
r=0
s=0
for i in range(a):
    if x[i]%2==0:k.append(0)
    else:k.append(1)
if b == 1:
    for i in range((sum(k)+1)//2):
        s+= comb(sum(k),2*i+1)*(2**(a-sum(k)))
else :
    for i in range(sum(k)//2):
        s+= comb(sum(k),2*i+1)*(2**(a-sum(k)))

print(s)

Submission status: Wrong Answer

Solution code:
n,r=map(int,input().split())
c=[i%2for i in list(map(int,input().split()))]
p=sum(c)
print((2**(n-1))if p==0 else(0if r!=1else 2**n))

Submission status: Wrong Answer

Solution code:
n,r=map(int,input().split())
c=[i%2for i in list(map(int,input().split()))]
p=sum(c)
print(0if p==0 and r!=0else(2**(p-1))*(2**(n-p)))

Submission status: Wrong Answer

Solution code:
n,r=map(int,input().split())
c=[i%2for i in list(map(int,input().split()))]
p=sum(c)
print((2**(p-1))*(2**(n-p)))

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())

print(2 ** (N - 1))

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())
a = list(map(int,input().split()))
if all(a[i]%2==0 for i in range(n)):
    print(2**n)
else:
    print(2**(n-1))

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, P] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    E_count = 0L
    O_count = 0L
    for i in range(N):
        if int(input_raw[i]) % 2 == 0:
            E_count += 1
        else:
            O_count += 1

    if P == 1:
        if O_count==0:
            print 0;
            return
 


    print (2L**E_count ) * (2L ** (O_count - 1L))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, P] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    E_count = 0
    O_count = 0
    for i in range(N):
        if int(input_raw[i]) % 2 == 0:
            E_count += 1
        else:
            O_count += 1

    if P == 1:
        if O_count==0:
            print 0;
            return
 


    print (2**E_count ) * (2 ** (O_count - 1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline


def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, P] = [int(input_raw[0]), int(input_raw[1])]
    input_raw = read_func().strip().split()
    E_count = 0
    O_count = 0
    for i in range(N):
        if int(input_raw[i]) % 2 == 0:
            E_count += 1
        else:
            O_count += 1

    if P == 1:
        if O_count==0:
            print 0;
            return
    if P == 0:
        if E_count==0 and O_count == 1:
            print 0;
            return


    print (2**E_count ) * (2 ** (O_count - 1))


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import math

def main():
    """Function."""
    n, p = map(int, input().split())
    a = list(map(int, input().split()))

    e_count, o_count = 0, 0
    for dum in a:
        if dum % 2 == 0:
            e_count += 1
        else:
            o_count += 1

    print(e_count)
    print(o_count)

    total = 0
    if p == 0:
        dum = 1
        for i in range(o_count // 2):
            n = (i + 1) * 2
            dum += (math.factorial(o_count) // (math.factorial(o_count - n) * math.factorial(n)))
        total += (2 ** e_count) * dum

    elif p == 1:
        if o_count == 0:
            pass
        else:
            dum = 0
            for i in range((o_count + 1) // 2):
                n = (i * 2) + 1
                dum += (math.factorial(o_count) // (math.factorial(o_count - n) * math.factorial(n)))
            total += (2 ** e_count) * dum

    print(total)


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
As = list(map(int, input().split()))

if N == 1:
    print(int(As[0] % 2 == P))
else:
    print(2 ** (N - 1))

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline

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

    A = list(map(lambda x: x % 2, A))
    if A.count(1):
        ans = pow(2,N-1)
    else:
        if P == 0:
            ans = pow(2,N)
        else:
            ans = pow(2,N-1)

    print(ans)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from math import factorial
N, P = map(int, input().split())
A = list(map(int, input().split()))

odd, even = 0,0
for a in A:
    if a%2==0:
        even += 1
    else:
        odd += 1

def combination(n, r):
    return int(factorial(n)/factorial(r)/factorial(n-r))

ans = 0
if P==0:
    for i in range(0,odd+1):
        if i%2==0:
            ans += combination(odd,i)*(2**even)
else:
    for i in range(1,odd+1):
        if i%2==1:
            ans += combination(odd,i)*(2**even)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial
N, P = map(int, input().split())
A = list(map(int, input().split()))

odd, even = 0,0
for a in A:
    if a%2==0:
        even += 1
    else:
        odd += 1

def combination(n, r):
    return int(factorial(n)/factorial(r)/factorial(n-r))

ans = 0
if P==0:
    for i in range(0,N+1):
        if i%2==0:
            ans += combination(N,i)*(2**even)
else:
    for i in range(1,N+1):
        if i%2==1:
            ans += combination(N,i)*(2**even)
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial

def cal(n, r):
    return factorial(n) // factorial(r) * factorial(n-r)

N, P = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
Even = 0
Odd = 0
Even_num = 0
Odd_num = 0

for i in A:
    if i % 2 == 0:
        Even += 1
    else:
        Odd += 1

if P == 0:
    if Even >= 1:
        for j in range(Even+1):
            Even_num += cal(Even, j)
        
    if Odd >= 2:
        if Odd % 2 == 0:
            for j in range(2, Odd+2, 2):
                Odd_num += cal(Odd, j)
        else:
            for j in range(2, Odd+1, 2):
                Odd_num += cal(Odd, j)
    ans =  Even_num + Odd_num + Even_num * Odd_num + 1

else:
    for j in range(Even+1):
        Even_num += cal(Even, j)
        
    if Odd >= 2:
        if Odd % 2 == 0:
            for j in range(2, Odd+2, 2):
                Even_num += cal(Odd, j)
        else:
            for j in range(2, Odd+1, 2):
                Even_num += cal(Odd, j)
    
    if Odd >= 1:
        if Odd % 2 == 0:
            for j in range(1, Odd, 2):
                Odd_num += cal(Odd, j)
        else:
            for j in range(1, Odd+1, 2):
                Odd_num += cal(Odd, j)
        
        ans += Odd_num * Even_num
        
print(ans)

Submission status: Wrong Answer

Solution code:
from math import factorial

def cal(n, r):
    return factorial(n) // factorial(r) * factorial(n-r)

N, P = map(int, input().split())
A = [int(i) for i in input().split()]
ans = 0
Even = 0
Odd = 0

for i in A:
    if i % 2 == 0:
        Even += 1
    else:
        Odd += 1

if P == 0:
    for j in range(Even+1):
        ans += cal(Even, j)
        
    if Odd >= 2:
        if Odd % 2 == 0:
            for j in range(2, Odd+2, 2):
                ans += cal(Odd, j)
        else:
            for j in range(2, Odd+1, 2):
                ans += cal(Odd, j)

else:
    Even_num = 0
    Odd_num = 0
    for j in range(Even+1):
        Even_num += cal(Even, j)
        
    if Odd >= 2:
        if Odd % 2 == 0:
            for j in range(2, Odd+2, 2):
                Even_num += cal(Odd, j)
        else:
            for j in range(2, Odd+1, 2):
                Even_num += cal(Odd, j)
    
    if Odd >= 1:
        if Odd % 2 == 0:
            for j in range(1, Odd, 2):
                Odd_num += cal(Odd, j)
        else:
            for j in range(1, Odd+1, 2):
                Odd_num += cal(Odd, j)
        
        ans += Odd_num * Even_num
        
print(ans)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
A = list(map(lambda x:int(x)%2, input().split()))
one = A.count(1)
zero = A.count(0)
print(int((one>0)*2**(one-1)*2**zero))

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
a=list(map(int,input().split()))
a=[i%2 for i in a]
if sum(a)>0:
    print(2**(n-1))
else:
    print("0")

Submission status: Wrong Answer

Solution code:

n, p = map(int, input().split())
listA=list(map(int,input().split()))

print(pow(2,len(listA)-1))

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
a_list = list(map(int, input().split()))
import math
count = 0
even_count = 0
odd_count = 0
for a in a_list:
    if a % 2 == 0:
        even_count += 1
    else:
        odd_count += 1

if even_count > 0:
    print(2**(N-1))

else:
    if P == 0:
        print(2**N)
    else:
        print(0)

Submission status: Wrong Answer

Solution code:
n, p=map(int, raw_input().split())
cnt=sum([a%2 for a in map(int, raw_input().split())])
print pow(2, n-1) if cnt else 0

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
listA=list(map(int, input().split()))

if n == 1:
    if p==0:
        if listA[0]%2==0:
            print(2)
        else:
            print(1)
    else:
        if listA[0]%2==0:
            print(0)
        else:
            print(1)
else:
    print(2**(n-1))

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())

a = list(input())

if p == 1:
    print(0)

elif p == 0:
    print(2 ** n)

else:
    print(2 ** (n - 1))

Submission status: Wrong Answer

Solution code:
n,p = map(int,input().split())	
a = list(map(int,input().split()))
ass = 0
g = 0
k = 0
if p == 0:
    ass += 1
for i in range(n):
    if a[i] % 2 == 0:
        g += 1
    else:
        k += 1
        


if p == 0:
    rr = 1
    tt = 1
    for i in range(g):
        rr = rr * (g-i)
        tt = tt * (i+1)
        if tt != 0:
            ass += rr //tt

    rr = 1
    tt = 1
    for i in range(k//2):
        rr = rr *(k-2*i)*(k-2*i-1)
        
        tt = tt * (2*i+1) * (2*i+2)

        if tt != 0:
            ass += rr//tt
else:
    rr = 1
    tt = 1
    jkl = 1
    for i in range(g):
        rr = rr * (g-i)
        tt = tt * (i+1)
        if tt != 0:
            jkl += rr //tt
    
    rr = 1
    tt = 1
    jj = 0
    if k % 2 == 1:
        u = k//2+1
    else:
        u = k//2
    for i in range(u):
        if i == 0:
            rr = k
            tt = 1
        else:
            rr = rr*(k-2*i)*(k-2*i+1)
            tt = tt*(2*i)*(2*i+1)
        #print(rr,tt)
        jj += rr//tt
        #print(jj)
    #print(jj,jkl)
    ass += jj*jkl
print(int(ass))

Submission status: Wrong Answer

Solution code:
import math
n,p = map(int,input().split())
a = list(map(int,input().split()))
ze = 0
on = 0
for i in range(n):
  if a[i] %2 == 0:
    ze+=1
  else:
    on += 1
con = 0
for i in range(0,on+1,2):
  con += math.factorial(on)//math.factorial(on-i)//math.factorial(i)
ans = (2**ze)*con
print(ans)

Submission status: Wrong Answer

Solution code:
def comb(n,a):
  s=1
  for i in range(a):
    s*=((n-i)/(i+1))
  return int(s)

n,p=map(int,input().split())
l=list(map(int,input().split()))
m=len([i for i in l if i%2])
o=n-m

a=(2**(o))
b=0

if m:
  if p:
    for i in range(1,m+1,2):
      b+=comb(m,i)
  else:
    for i in range(0,m+1,2):
      b+=comb(m,i)
  print(a*b)
else:
  if p==0:
    print(a)
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
def comb(n,a):
  s=1
  for i in range(a):
    s*=((n-i)/(i+1))
  return int(s)

n,p=map(int,input().split())
l=list(map(int,input().split()))
m=len([i for i in l if i%2])
o=n-m

a=(2**(o))
b=0
if p:
  for i in range(1,m+1,2):
    b+=comb(m,i)
else:
  for i in range(0,m+1,2):
    b+=comb(m,i)

if m:
  print(a*b)
else:
  if p==0:
    print(a)
  else:
    print(0)

Submission status: Wrong Answer

Solution code:
def comb(n,a):
  s=1
  for i in range(a):
    s*=((n-i)/(i+1))
  return int(s)

n,p=map(int,input().split())
l=list(map(int,input().split()))
m=len([i for i in l if i%2])
o=n-m

a=(2**(o))
b=0
if p:
  for i in range(1,m+1,2):
    b+=comb(m,i)
else:
  for i in range(0,m+1,2):
    b+=comb(m,i)
print(a*b)

Submission status: Wrong Answer

Solution code:
n,m=map(int,input().split())
s=list(map(int,input().split()))
odd=0
even=0
p=0
for i in s:
    if i%2==1:
        odd+=1
    else:
        even+=1
even=2**even
from math import factorial
def f(n,m):
    return factorial(n)//(factorial(n-m)*factorial(m))
for i in range(1,odd+1,2):
    p+=f(odd,i)
print(p*even)

Submission status: Wrong Answer

Solution code:
from sys import stdin

n, p = map(int, stdin.readline().split(' '))
a = map(int, stdin.readline().split(' '))

dp = [[0] * (n + 1)] * 2
dp[p][n] = 1
for i in xrange(n-1, -1, -1):
   for k in [0,1]: dp[k][i] = dp[k][i+1] + dp[(k+a[i])%2][i+1]

res = dp[0][0]

print res

Submission status: Wrong Answer

Solution code:
from sys import stdin

n, p = map(int, stdin.readline().split(' '))
a = map(int, stdin.readline().split(' '))

dp = [[0] * (n + 1)] * 2
dp[p][n] = 1
for i in xrange(n-1, -1, -1):
   for p in [0,1]: dp[p][i] = dp[p][i+1] + dp[(p+a[i])%2][i+1]

res = dp[0][0]

print res