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

Solution (Python):
import math
def c(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()))
A_O = [e for e in A if e % 2 == 1]
A_E = [e for e in A if e % 2 == 0]
ans = 0
if P == 0:
    for k in range(math.floor(len(A_O)/2) + 1):
        for l in range(len(A_E) + 1):
            ans += c(len(A_O),2*k) * c(len(A_E),l)
elif P == 1:
    for k in range(math.floor((len(A_O) - 1) /2) + 1):
        for l in range(len(A_E) + 1):
            ans += c(len(A_O),2*k + 1) * c(len(A_E),l)
print(ans)

Solution (Python):
N, P = map(int, input().split())
A = list(map(int, input().split()))
ev = 0
od = 0
for a in A:
    if a % 2 == 0:
        ev += 1
    else:
        od += 1
if P == 0 and od == 0:
    print(2**ev)
else:
    print(2**ev * (2**od//2))

Solution (Python):
N,P = map(int,input().split())
A = list(map(int,input().split()))
odd = 0
for i in range(N) :
    if A[i] % 2 != 0 :
        odd += 1
if odd == 0 :
    if P == 0 :
        ans = 2**N
    else :
        ans = 0
else :
    ans = 2**(N-1)
print(ans)

Solution (Python):
n,p=map(int,input().split())
a=list(map(int,input().split()))
j=True
for t in a:
    if t%2!=0:
        j=False
        break
if j:
    print(2**n if p==0 else 0)
else:
    print(2**(n-1))

Solution (Python):
N, P = map(int, input().split())
A = list(map(int, input().split()))
ev = 0
od = 0
for a in A:
    if a % 2 == 0:
        ev += 1
    else:
        od += 1
if P == 0 and od == 0:
    print(2**ev)
else:
    print(2**ev * (2**od//2))

Solution (Python):
N, P = map(int,input().split())
A = [int(i) for i in input().split()]
p_num = [0,0]
for a in A:
    p_num[a%2] += 1

p = [0,0]

if p_num[1] == 0:
    if P == 0:
        print(2**p_num[0])
    else:
        print(0)
    exit()

print(2**(N-1))

Solution (Python):
N, P = map(int, input().split())
a_list = list(map(int, input().split()))
a=[i%2 for i in a_list]
if sum(a)>0:print(2**(N-1))
else:
    if P==0:
        print(2**N)
    else:
        print(0)

Solution (Python):
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:
    if m==0:print(2**n)
    else:print(0)

Solution (Python):
n, p = map(int, input().split())
a = [i % 2 for i in map(int, input().split())]
zero = a.count(0)
one = a.count(1)

def comb(n, r):
    a = 1
    for i in range(n-r+1, n+1):
        a *= i
    for i in range(1,r+1):
        a //= i
    return a

ans = 0

if p:
    for i in range(zero+1):
        for j in range((one+1)//2 + 1):
            ans += comb(zero, i)*comb(one, 2*j+1)
else:
    for i in range(zero+1):
        for j in range((one+1)//2 + 1):
            ans += comb(zero, i)*comb(one, 2*j)
print(ans)

Solution (Python):
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 pow(2, n)*(1-p)

Solution (Python):

import math

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

def main():
    n, p = map(int, input().split())
    a_list = list(map(int, input().split()))
    odd = 0
    even = 0
    ans = 1
    for a in a_list:
        if a % 2 == 0:
            even += 1
        else:
            odd += 1
    all_cnt = 0
    for i in range(n+1):
        all_cnt += combinations_count(n, i)
    odd_cnt = 0
    for i in range(0, odd+1, 2):
        odd_cnt += combinations_count(odd, i)
    even_cnt =0
    for i in range(even+1):
        even_cnt += combinations_count(even, i)
    if p == 0:
        ans = odd_cnt * even_cnt
    else:
        ans = all_cnt - odd_cnt * even_cnt
    print(ans)

if __name__ == '__main__':
    main()

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

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

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



for i in a:
    if i % 2 == 1:
        print(2 ** (n - 1))
        exit(0)

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

else:
    print(0)

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

d = [1, 0]

for a in A:
    v = d[:]
    if a % 2 == 0:
        v[0] = d[0] + d[0]
        v[1] = d[1] + d[1]
    else:
        v[0] = d[0] + d[1]
        v[1] = d[0] + d[1]
    d = v[:]
    
print(d[P])

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

n,p = map(int, input().split())
list_a = list((map(int, input().split())))
for i in range(0,n):
    list_a[i] = list_a[i] % 2
odd = list_a.count(1)
even = list_a.count(0)
even_ans = int(2**even)
odd_ans = 0
if p == 0:
    for i in range(0,odd+1):
        if i % 2 == 0:
            odd_ans += nCr(odd, i)
else:
    for i in range(0,odd+1):
        if i % 2 == 1:
            odd_ans += nCr(odd, i)

print(int(even_ans * odd_ans))

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

c_odd , c_even = 0, 0

for a in A:
  if a%2 == 0:
    c_even += 1
  else:
    c_odd += 1

if c_odd == 0:
  print(2**N if P==0 else 0)
else:
  print(2**(N-1))
    
"""
fact = [1] * 51

for i in range(1,51):
  fact[i] = fact[i-1] * i
  
def comb(n,r):
  return int(fact[n] / fact[r] / fact[n-r])

idx = 1 if P == 1 else 0

work = 0
while idx <= c_odd:
  work += comb(c_odd, idx)
  idx += 2

print(work * ( 2 ** c_even) )
"""

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

Solution (Python):
n,p = map(int,input().split())	
a = list(map(int,input().split()))
ass = 0
g = 0
k = 0

for i in range(n):
    if a[i] % 2 == 0:
        g += 1
    else:
        k += 1
        


if p == 0:
    rr = 1
    tt = 1
    jj = 1
    for i in range(g):
        rr = rr * (g-i)
        tt = tt * (i+1)
        if tt != 0:
            jj += rr //tt
    jkl = 1
    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:
            jkl += rr//tt
    ass += jj*jkl
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)
        jj += rr//tt
    ass += jj*jkl
print(int(ass))

Solution (Python):
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())

N,p = inpl()
aa = inpl()
cnt = [0]*2
for a in aa:
    cnt[a%2] += 1

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

def C(n, r):
    if r == 0: return 1
    return P(n, r)//math.factorial(r)

if p == 0:
    ans = pow(2,(cnt[0]))
    tmp = 0
    for i in range(0,cnt[1]+1,2):
        tmp += C(cnt[1],i)
    ans *= tmp
else:
    ans = pow(2,(cnt[0]))
    tmp = 0
    for i in range(1,cnt[1]+1,2):
        tmp += C(cnt[1],i)
    ans *= tmp

print(ans)

Solution (Python):
import math
def c(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()))
for i in range(N):
    A[i] %= 2
A.sort()
i = 0
while True:
    if i >= len(A):
        break
    if A[i] == 0:
        i += 1
    elif A[i] == 1:
        i -= 1
        if i < 0:
            i = 0
        break
zero = i
not_zero = len(A) - zero
combination0 = 1
for i in range(1, zero + 1):
    combination0 += c(zero, i)
    
if P == 0:
    combination1_0 = 1
    for i in range(2, not_zero + 1, 2):
        combination1_0 += c(not_zero, i)
    print(combination0 * combination1_0)
else:
    combination1_1 = 0
    for i in range(1, not_zero + 1, 2): 
        combination1_1 += c(not_zero, i)
    print(combination1_1 * combination0)

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

ch = [a for a in A if a%2 == 0]
if len(ch) == len(A):
    if P == 0:
        ans = 2**N
    else:
        ans = 0
else:
    ans = 2**(N-1)

print(ans)

Solution (Python):
import math

N,P = (int(i) for i in input().split())
A = [int(i) for i in input().split()]


even = 0
odd = 0
for i in range(N):
    if A[i]%2 == 0:
        even += 1
    else:
        odd += 1

if P == 0: 
    
    odds = 0
    for i in range(odd+1):
        if i % 2 == 0:
            odds += math.factorial(odd)/(math.factorial(i)*math.factorial(odd-i))
    
    evens = 0
    for i in range(even+1):
        evens += math.factorial(even)/(math.factorial(i)*math.factorial(even-i))

elif P == 1: 
    
    odds = 0
    for i in range(odd+1):
        if i % 2 != 0:
            odds += math.factorial(odd)/(math.factorial(i)*math.factorial(odd-i))
    
    evens = 0
    for i in range(even+1):
        evens += math.factorial(even)/(math.factorial(i)*math.factorial(even-i))


print(int(odds*evens))

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

Solution (Python):
N,P,*A=map(int,open(0).read().split())
print([(1^P)*2**N,2**~-N][any(a&1 for a in A)])

Solution (Python):
N, P, *A = map(int, open(0).read().split())
e, o = 1, 0
for a in A:
    if a % 2:
        e, o = e + o, e + o
    else:
        e, o = 2 * e, 2 * o
print([e, o][P])

Solution (Python):
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)]

n,p = map(int,input().split())
a = list(map(int,input().split()))
zero,one = 0,0
for i in range(n):
    if a[i]%2==1:
        one += 1
    else:
        zero += 1
res = 0
if p==0:
    for i in range(0,one+1,2):
        res += cmb(one,i)
else:
    for i in range(1,one+1,2):
        res += cmb(one,i)
res *= 2**zero
print(res)

Solution (Python):
def pascal(n):
    ret = [[] for _ in range(n+1)]
    for i in range(n+1):
        for j in range(i+1):
            if j == 0 or j == i:
                ret[i].append(1)
            else:
                ret[i].append(ret[i-1][j-1]+ret[i-1][j])
    return ret


N, P = map(int, input().split())
A = [int(x) for x in input().split()]
comb = pascal(N)
count = [0, 0]
for i in A:
    count[i % 2] += 1
ans = 0
if P == 0:
    for i in range(0, count[1]+1, 2):
        ans += comb[count[1]][i]
else:
    for i in range(1, count[1]+1, 2):
        ans += comb[count[1]][i]
ans = ans * (2**count[0])
print(ans)

Solution (Python):
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
if p == 0:
  for i in range(0,on+1,2):
    con += math.factorial(on)//math.factorial(on-i)//math.factorial(i)
else:
  for i in range(1,on+1,2):
    con += math.factorial(on)//math.factorial(on-i)//math.factorial(i)
ans = (2**ze)*con
print(ans)

Solution (Python):
from math import factorial as f

n,p=map(int,input().split())
m=sum(map(lambda x:int(x)%2,input().split()))
o=n-m

a=2**o
b=0

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

Solution (Python):
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)
if m==1:
    print(p*even,)
else:
    print(2**(len(s))-p*even)

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

b0 = 0
b1 = 0

fib = [1]
num = 1
for i in range(1, n+1):
    num *= i
    fib.append(num)

def com(n, r):
    return fib[n] // fib[r] // fib[n - r]

for i in range(n):
    if a[i] % 2 == 0:
        b0 += 1
    else:
        b1 += 1

c0 = 0
c1 = 0

for i in range(b0+1):
    c0 += com(b0, i)

if p == 0:
    for i in range(b1+1):
        if i % 2 == 1:
            continue
        c1 += com(b1, i)
    print(c0 * c1)
else:
    for i in range(b1+1):
        if i % 2 == 0:
            continue
        c1 += com(b1, i)
    print(c0 * c1)

Solution (Python):
from collections import Counter

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

cnt = Counter([0, a[0]])

for ai in a[1:]:
    temp = Counter()
    for k, v in cnt.items():
        temp[k + ai] = v
        
    cnt += temp

ans = 0
for k, v in cnt.items():
    if k % 2 == p:
        ans += v
        
        
print(ans)

Solution (Python):


from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(10000000)

N, P = map(int, raw_input().split())
A = map(int, raw_input().split())
cnt = 0

for a in A:
    if a % 2 == 1:
        cnt += 1

m = {}
def comb(n, k):
    if (n, k) in m:
        return m[(n, k)]
    if n == k or k == 0:
        m[(n, k)] = 1
        return 1
    m[(n, k)] = comb(n - 1, k) + comb(n - 1, k - 1)
    return m[(n, k)]

ans = 0
rem = N - cnt
for i in range(0, cnt + 1, 2):
    ans += comb(cnt, i)
if P == 1:
    ans = 2 ** cnt - ans
print ans * (2 ** rem)

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

dp = [[0]*2 for _ in range(n+1)]
dp[0][0] = 1

for k in range(n):
    for i in range(2):
        dp[k+1][i] = dp[k][i] + dp[k][(i+a[k])%2]
print(dp[-1][p])

Solution (Python):
from collections import Counter
n,p=map(int,input().split())
a=Counter([int(i) % 2 for i in input().split()])

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

Solution (Python):
from sys import stdin

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

dp = [ range(n+1), range(n+1) ]
dp[p][n] = 1
dp[p^1][n] = 0
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

Solution (Python):
'''
2で割った余り == p
p:0
1を偶数個と0を任意の数
p:1
1を奇数個と0を任意の数
'''

def comb(n, r):
    ret = 1
    if (n == r) or (n == 0) or (r == 0):
        ret = 1
    else:
        for i in range(1, n + 1):
            ret *= i
        for i in range(1, r + 1):
            ret //= i
        for i in range(1, n - r + 1):
            ret //= i

    return ret

if __name__ == '__main__':
    n, p = map(int, input().split())
    a = list(map(int, input().split()))
    a_mod2 = list(map(lambda x: x % 2, a))
    cnt_0 = a_mod2.count(0)
    cnt_1 = a_mod2.count(1)
    cnt_odd_1 = cnt_1 if cnt_1 % 2 == 1 else cnt_1 - 1
    cnt_even_1 = cnt_1 if cnt_1 % 2 == 0 else cnt_1 - 1








    ans = 0
    if p == 0:
        rng = list(range(0, cnt_even_1 + 1))[::2]
        for i in rng:
            ans += comb(cnt_1, i)
        ans *= (2 ** cnt_0)
    elif p == 1:
        rng = list(range(1, cnt_odd_1 + 1))[::2]
        for i in rng:
            ans += comb(cnt_1, i)
        ans *= (2 ** cnt_0)
    print(ans)

Solution (Python):



def main():
    n, p = list(map(int, input().split()))
    a = list(map(int, input().split()))
    odd_count = sum([1 for ai in a if ai % 2 == 1])

    
    
    if odd_count == 0:
        if p == 0:
            print(2 ** n)
        else:
            print(0)
    else:
        print(2 ** (n - 1))


if __name__ == '__main__':
    main()

Solution (Python):
N, P = map(int, input().split())
A = list(map(int, input().split()))
even = 0
for a in A:
	if a % 2 == 0:
		even += 1
if even == N:
	if P == 0:
		print(2 ** N)
	else:
		print(0)
else:
	print(2 ** (N-1))

Solution (Python):
n, p = list(map(int, input().split()))
a = list(map(int, input().split()))
flag = True
for ele in a:
  if ele%2==1:
    flag = False
if flag:
  if p==1:
    print(0)
  else:
    print(2**n)
else:
  print(2**(n-1))

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

a = [int(x) for x in input().split()]

odd = 0
even = 1

for i in range(n):
    if a[i] % 2 == 0:
        odd, even = odd*2, even*2
    else:
        odd, even = odd+even, odd+even

if p == 0:
    print(even)
else:
    print(odd)

Solution (Python):
N, P = map(int, input().split())
A = [int(a) for a in input().split()]
dp=[[0,0] for _  in range(N)]
dp[0]=[2,0]
for i in range(1,N):
    if A[i-1]%2 ==0:
        dp[i][0]=dp[i-1][0]*2
        dp[i][1]=dp[i-1][1]*2
    else:
        dp[i][0]=dp[i-1][0]*2
        dp[i][1]+=dp[i-1][0]
        P=1
print(dp[N-1][P])

Solution (Python):





import math

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

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

even_combi = 2 ** even

odd_combi = 0
m = int(odd/2)

for i in range(m+1):
    if P == 0:
        odd_combi += math.factorial(odd) / (math.factorial(i*2) * math.factorial(odd-i*2))
    else:
        if odd-(i*2+1) > 0:
            odd_combi += math.factorial(odd) / (math.factorial(i*2+1) * math.factorial(odd-(i*2+1)))


print(int(even_combi*odd_combi))

Solution (Python):
N, P = map(int, input().split())
A = list(map(int, input().split()))
DP = []
for _ in range(N) :
    DP.append([0,0])
    
DP[0][0] += 1
DP[0][A[0]%2] += 1
for i in range(1,N) :
    for j in range(2) :
        DP[i][ (A[i]+j)%2 ] += DP[i-1][j]
        DP[i][j] += DP[i-1][j]
        
print(DP[N-1][P])

Solution (Python):
import math
n, p = map(int,raw_input().split())

arr = map(int,raw_input().split())

odd = 0
even = 0

for i in range(n):
	if arr[i] %2 == 0 :
		even += 1
	else :
		odd += 1

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

def C(n, r):
	return P(n, r)//math.factorial(r)

oddnum = 0
for i in range(1,odd+1,2):
	oddnum += C(odd,i)

if p == 1:
	print oddnum * 2**even
else :
	print 2**n-(oddnum*2**even)

Solution (Python):
from math import factorial
N, P = map(int, input().split())
A = [int(i) for i in input().split()]
o = []
e = []

def c(n,r):
    a = 1
    for i in range(n-r+1,n+1):
        a *= i
    return a//factorial(r)
for a in A:
    if a % 2: o.append(a)
    else: e.append(a)
ans = 0
if P:
    for i in range(1, len(o) + 1):
        if not i % 2: continue
        ans += c(len(o), i)
        for j in range(1, len(e)+1):
            ans += c(len(e), j) * c(len(o), i)
else:
    ans += 1
    for i in range(1, len(e) + 1):
        ans += c(len(e), i)
    for i in range(1, len(o) + 1):
        if i % 2: continue
        ans += c(len(o), i)
        for j in range(1, len(e) + 1):
            ans += c(len(e), j) * c(len(o), i)
print(ans)

Solution (Python):
N, P = [int(_) for _ in input().split()]
A = [int(_) for _ in input().split()]

Pw = [1]
for i in range(1, 51):
    Pw.append(Pw[-1] * i)

def C(n, m):
    return Pw[n] // Pw[n - m] // Pw[m]

odd = sum(x % 2 for x in A)
even = N - odd

r = 0
for i in range(0, odd + 1, 2):
    r += C(odd, i) * (2**even)

if P == 1:
    r = 2**N - r

print(r)

Solution (Python):
n, p = [int(_) for _ in input().split(' ')]
a = [int(x) % 2 == 0 for x in input().split(' ')]
if all(a):
    if p == 1:
        print(0)
    else:
        print(1 << n)
else:
    print(1 << (n - 1))

Solution (Python):
N, P = map(int,input().split())
A = list(map(int,input().split()))
dp = [0 for _ in range(2)]
dp[0] = 1
for i in range(N):
    c = A[i]%2
    if c == 0:
        dp[0]*=2
        dp[1]*=2
    else:
        s = dp[0]+dp[1]
        dp[0], dp[1] = s, s
print(dp[P])

Solution (Python):
N,P = map(int,input().split(" "))
A = list(map(int,input().split(" ")))
B = [1,0]
for _ in range(N):
    a = A.pop()%2
    p,q = B
    B = [p+q,q+p] if a else [2*p,2*q]
print(B[P])

Solution (Python):
from math import factorial

def comb(n, r):
	return factorial(n) // factorial(r) // factorial(n - r)



n, p = map(int, input().split())
b = list(map(int, input().split()))
a = [b[i] % 2 for i in range(n)]
zero = a.count(0)
one = n - zero


if p == 0:
	if one == 0:
		print(2 ** zero)
	else:
		num = 1
		for i in range(2, one + 1, 2):
			num += comb(one, i)
		print(num * (2 ** zero))

else:
	if one == 0:
		print(0)
	else:
		num = 0
		for i in range(1, one + 1, 2):
			num += comb(one, i)
		print(num * (2 ** zero))

Solution (Python):
from math import factorial
N, P = map(int, input().split(' '))
biscuits = list(map(int, input().split(' ')))
bis_odd = len([i for i in biscuits if i % 2 != 0])
bis_even = len([i for i in biscuits if i % 2 == 0])

if bis_even == len(biscuits):
    if P == 0: print(2**N)
    else: print(0)
else:
    print(2**(N-1))

Solution (Python):
n, p = map(int, input().split())
array = [int(x) for x in input().split()]

even = 0
odd = 0

for item in array:
    if item % 2 == 0:
        even += 1
    else:
        odd += 1

if even == n:
    if p == 0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))

Solution (Python):
def a_biscuits(N, P, A):
    is_include_odd = False  
    for k in A:
        if k % 2 == 1:
            is_include_odd = True
    
    
    
    
    if is_include_odd:
        ans = pow(2, N - 1)
    else:
        ans = pow(2, N) if P == 0 else 0
    return ans

N, P = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
print(a_biscuits(N, P, A))

Solution (Python):
def cc(Nb,j):
    ANS = 1
    for i in range(j):
        ANS = ANS * (Nb-i)/(i+1)
    return int(ANS)


def main():
    N, P = map(int, input().split())
    A = list(map(int, input().split()))
    Na = 0
    Nb = 0
    for i in range(N):
        if A[i]%2 == 0:
            Na += 1
        else:
            Nb += 1
    if P==0:
        S = 0
        if Nb==0:
            return 2**Na
        for j in range(0,Nb+1,2):
            S += cc(Nb,j)
        return (2**Na) * S
    else:
        S=0
        if Nb==0:
            return 0
        for j in range(1,Nb+1,2):
            S += cc(Nb,j)
        return (2**Na) * S


if __name__ == '__main__':
    print(main())

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

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


def biscuits():
    dp = [[[0 for i in range(2)] for j in range(n+1)] for i in range(n+1)]

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

    for i in range(1, n+1):
        for j in range(i+1):
            for k in range(2):
                if j > 0:
                    dp[i][j][k] = dp[i-1][j][k] + dp[i-1][j-1][k-a[i-1] % 2]
                else:
                    dp[i][j][k] = dp[i-1][j][k]

    ans = 0
    for j in range(n+1):
        ans += dp[n][j][p % 2]

    return ans


def main():
    print(biscuits())


if __name__ == '__main__':
    main()

Solution (Python):
from math import factorial as f

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

num_odd = 0
num_even = 0
for i in range(N):
    if A[i] % 2 == 0:
        num_even += 1
    else:
        num_odd += 1

even_choice = 2**num_even

def c(n, k):
    return f(n)//(f(k)*f(n-k))

odd_choice = 0
for i in range(0, num_odd+1):
    if i % 2 == P:
        odd_choice += c(num_odd, i)

print(even_choice*odd_choice)

Solution (Python):
N,P = map(int,input().split())
src = list(map(int,input().split()))

if all(a%2==0 for a in src):
    if P:
        print(0)
    else:
        print(2**N)
    exit()
print(2**(N-1))

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

is_include_odd = False
for k in A:
  if k % 2 == 1:
    is_include_odd = True
    
if is_include_odd:
  print(pow(2,N-1))
else:
  if P == 0:
    print(pow(2,N))
  else:
    print(0)

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

Solution (Python):
import sys
N,P=map(int,input().split())
N=list(input().split())
for i in range (len(N)):
    N[i]=int(N[i])%2
count1=N.count(1)
count0=N.count(0)
if count1<1 and P==1:
    print (0)
    sys.exit()
if count0==0 and count1<2 and P==0:
    print (0)
    sys.exit()
import math
count0_c=0
count1_c=0
if count0!=0:
    for k in range (0,count0+1):
        count0_c+=math.factorial(count0)/(math.factorial(k)*math.factorial(count0-k))
else:
    count0_c=1

if count1!=0:
    for j in range (0,count1//2+1-P):
        count1_c+=math.factorial(count1)/(math.factorial(2*j+P)*math.factorial(count1-2*j-P))
else:
    count1_c=1
print(int(count0_c*count1_c))

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

Solution (Python):
def read():
    return int(input())


def readlist():
    return list(map(int, input().split()))


def readmap():
    return map(int, input().split())


N, P = readmap()
A = readlist()

for i in range(N):
    A[i] = A[i] % 2

cnt_0 = A.count(0)
cnt_1 = A.count(1)


def fact(n):
    if n == 0:
        return 1
    elif n > 0:
        return n*fact(n-1)


def nCr(n,r):
    return fact(n)/(fact(r)*fact(n-r))


if P == 0:
    ans = 2 ** cnt_0
    num = 0
    for i in range(cnt_1 // 2 + 1):
        num += nCr(cnt_1, 2*i)
    ans *= num
    print(int(ans))
else:
    ans = 2 ** cnt_0
    num = 0
    for i in range((cnt_1 - 1) // 2 + 1):
        num += nCr(cnt_1, 2 * i + 1)
    ans *= num
    print(int(ans))

Solution (Python):
tmp = list(map(int,input().split()))
As = list(map(int,input().split()))
n,p = tmp[0],tmp[1]
o ,e  = 0,0
for i in range(n):
  if As[i] % 2:
    o += 1
  else:
    e += 1
def comb(j,k):
  if k == 0:
    return(1)
  else:
    return comb(j-1,k-1) * j / k
ans = 0
if p == 0:
  for i in range(o+1):
    if not i % 2:
      ans += int(comb(o,i))
else:
  for i in range(o+1):
    if i % 2:
      ans += int(comb(o,i))
ans *= (2 ** e)
print(ans)

Solution (Python):
import math

def C(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()))[:N]

ans = 0

odd = len(list(filter(lambda x:x%2==1,A)))
even = len(list(filter(lambda x:x%2==0,A)))

i = 0 if P==0 else 1
while(i<=odd):
    ans += C(odd,i)
    i+=2
    
for i in range(even):
    ans *= 2

print(ans)

Solution (Python):
n, p = list(map(int,input().split()))
a = list(map(int,input().split()))
count = 0
for i in range(n):
    if a[i]%2 == 1:
        count =1
        break

if count == 1:
    print(2**(n-1))
else:
    if p == 0:
        print(2**n)
    else:
        print(0)

Solution (Python):
N,P=map(int,input().split())
A=[int(x) for x in input().split()]
e=0
o=0
for i in range(N):
  if A[i]%2==0:
    e+=1
  else:
    o+=1 


factorial=[1]
for i in range(1,N+1):
    factorial.append(factorial[i-1]*i)
    
def nCr(n,r):
  return int(factorial[n]/(factorial[r]*factorial[n-r]))
  
ans=0
for i in range(1,o+1):
  if i%2==1:
    cnt=nCr(o,i)
    for j in range(0,e+1):
      ans+=cnt*(nCr(e,j))
if P==1:
  print(ans)
else:
  ans=(1<<N)-ans
  print(ans)

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

Solution (Python):
def main():
    N, P = map(int, input().split())
    *A, = map(int, input().split())

    editorial(N, P, A)

def editorial(N, P, A):
    odds = [a for a in A if a % 2 == 1]
    odd = len(odds)
    even = N - odd

    if odd == 0:
        if P == 1:
            print(0)
        else:
            print(2 ** N)
        return
    
    
    ans = 2 ** (N - 1)
    
    
    
    
    
    print(ans)


if __name__ == '__main__':
    main()

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

if all(map(lambda x: x % 2 == 0, A)):
    if P == 0:
        print(2**N)
    else:
        print(0)
else:
    print(2**(N-1))

Solution (Python):
def main():
    N, P = map(int, input().split())
    *A, = map(int, input().split())

    odd = sum(a % 2 for a in A)
    even = N - odd
    o, e = 0, 0
    
    
    
    for i in range(P, odd+1, 2):
        o += ncr(odd, i)

    for i in range(even+1):
        e += ncr(even, i)
    ans = o * e

    print(ans)


def _factorial(n):
    if n < 0:
        raise ValueError("factorial() not defined for negative values")
    a = 1
    for i in range(1, n + 1):
        a *= i
    return a


def npr(n, r):
    if n < r:
        return 0
    a = 1
    for i in range(r):
        a *= n - i
    return a


def ncr(n, r):
    _npr = npr(n, r)
    if _npr == 0:
        return 0
    return _npr // _factorial(r)


if __name__ == '__main__':
    main()

Solution (Python):
import sys


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

Solution (Python):


import sys, math, copy




HUGE = 2147483647
HUGEL = 9223372036854775807
ABC = "abcdefghijklmnopqrstuvwxyz"

def fact(i):
    res = 1
    for j in range(1, i + 1):
        res *= j
    return res

def combi(n, i):
    assert 0 <= i <= n
    return fact(n) // (fact(i) * fact(n - i))

def main():
    n, p = map(int, input().split())
    ai = list(map(int, input().split()))
    assert len(ai) == n

    evens = 0
    odds = 0
    for a in ai:
        if a % 2 == 0:
            evens += 1
        else:
            odds += 1
    way_evens = 2 ** evens
    way_odds = 0
    for no in range(p, odds + 1, 2):
        way_odds += combi(odds, no)

    print(way_evens * way_odds)

main()