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 combination(n, k):
    return math.factorial(n) // math.factorial(k) // math.factorial(n - k)    

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

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

kisu = 0
gusu = 0

for a in A:
    if a%2 == 0:
        gusu += 1
    else:
        kisu += 1

sum_gu = 2**gusu

if P%2==0:
    sum_ki = 0
    for i in range(2,kisu+1, 2):
        sum_ki += combination(kisu, i)
    sum_ki *= sum_gu
    print(sum_gu+sum_ki)
else:
    sum_ki = 0
    for i in range(1,kisu+1, 2):
        sum_ki += combination(kisu, i)
    print(sum_gu*sum_ki)

Solution (Python):
from collections import deque

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

even = 0
odd = 0

for a in input().split():
    check = int(a)

    if check % 2 == 0:
        even += 1
    else:
        odd += 1


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



result = 0
if P == 1:
    
    for i in range(1, odd+1, 2):
        result += comb(odd, i)


else:
    
    for i in range(0, odd+1, 2):
        result += comb(odd, i)

if even == 0:
    mul = 1
else:
    mul = 2 ** even

result *= mul
print(result)

Solution (Python):
def LI():
    return list(map(int, input().split()))


N, P = LI()
A = LI()
gu = 0
ki = 0
for i in range(N):
    if A[i] % 2 == 0:
        gu += 1
    else:
        ki += 1


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

Solution (Python):
Limit = 100
CMB = [[0]*(Limit+1) for _ in range(Limit+1)]
def cmb_table(Limit):
  for i in range(Limit+1):
    for j in range(Limit+1):
      if j == 0 or j == i: 
        CMB[i][j] = 1
      else:
        CMB[i][j] = CMB[i-1][j-1] + CMB[i-1][j]

cmb_table(Limit)

N,P = map(int,input().split())
A = list(map(int,input().split()))
odd = 0; even = 0
for x in A:
  if x%2 == 0:
    even +=1
  else:
    odd +=1
ans = 0
if P%2 == 0: 
  for x in range(even+1):
    E = x
    if E == 0:
      face = 1
    else:
      face = CMB[even][E]
    O = 0
    while E+O <= N:
      if O == 0:
        faco = 1
      else:
        faco += CMB[odd][O]
      O += 2
    
    ans += face*faco 
else:
  for x in range(even+1):
    E = x
    if E == 0:
      face = 1
    else:
      face = CMB[even][E]
    O = 1
    while E+O <= N:
      if O == 1:
        faco = CMB[odd][O]
      else:
        faco += CMB[odd][O]
      O += 2
    
    ans += face*faco 
    
print(ans)

Solution (Python):
N,P = map(int,input().split())
def combi(N,K):
    a = 1
    for i in range(K):
        a *= N-i
    for j in range(K):
        a /= j+1
    return a

ans = 0
lis = list(map(int,input().split()))
ls = []
for a in lis:
    ls.append(a%2)
one = ls.count(1)
zero = ls.count(0)
pattern_a = 0
pattern_b = 0
for j in range(zero+1):
    pattern_b += combi(zero,j)
time = 0
while time<=one:
    if time%2 ==P:
        pattern_a += combi(one,time)
    time += 1
print(int(pattern_a*pattern_b))

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

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

a0 = 0
a1 = 0
for a in al:
    if a%2 == 0:
        a0 += 1
    else:
        a1 += 1

ans = pow(2,a0)
ans2 = 0
if p == 0:
    for i in range(0,51,2):
        if a1 < i:break
        ans2 += com(a1,i)

else:
    for i in range(1,51,2):
        if a1 < i:break
        ans2 += com(a1,i)
print(ans*ans2)

Solution (Python):
from sys import stdin, setrecursionlimit
from collections import Counter, deque, defaultdict
from math import floor, ceil
from bisect import bisect_left
from itertools import combinations
setrecursionlimit(100000)

INF = int(1e10)
MOD = int(1e9 + 7)

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

    count_even, count_odd = 0, 0
    for a in A:
        if a % 2 == 0:
            count_even += 1
        else:
            count_odd += 1
    
    ans = -1
    
    
    if count_odd == 0:
        
        if P == 0:
            
            ans = 2 ** N
        else:
            
            ans = 0
    else:
        
        
        
        ans = 2 ** (N - 1)
    print(ans)


if __name__ == '__main__':
    main()

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

MOD = 2 ** 61 - 1
table_len = 100

fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)

finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len-1, 0, -1):
    finv[i-1] = finv[i] * i % MOD

C = 0
D = 0
for A in As:
    if A % 2:
        D += 1
    else:
        C += 1

ans = pow(2, C)
ans *= sum( ((fac[D] * finv[i] * finv[D-i])%MOD for i in range(P, D+1, 2)) )
print(ans)

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


N,P = MI()
A = LI()

x,y = 0,0
for a in A:
    if a % 2 == 0:
        x += 1
    else:
        y += 1

if y == 0:
    if P == 1:
        print(0)
    else:
        print(2**x)
else:
    print(2**(x+y-1))

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

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

Solution (Python):
import bisect,collections,copy,itertools,math,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())
def main():
    def select(n,k):
        return math.factorial(n)//(math.factorial(k)*math.factorial(n-k))
    n,p = LI()
    a = LI()
    a = list(map(lambda x: x%2, a))
    dic = collections.Counter(a)
    c0 = dic[0]
    c1 = dic[1]
    ans = 0

    if p == 0:
        for i in range(n+1):
            for s in range(i//2+1):
                n1 = 2*s
                n0 = i-n1
                if n0<=c0 and n1<=c1:
                    ans += select(c0,n0)*select(c1,n1)
    else:
        for i in range(1,n+1):
            for s in range((i-1)//2+1):
                n1 = 2*s+1
                n0 = i-n1
                if n0<=c0 and n1<=c1:
                    ans += select(c0,n0)*select(c1,n1)
                    
    print(ans)

main()

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

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

dp[0][0]=1

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

Solution (Python):
from operator import mul
from functools import reduce


def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom


from collections import Counter
n, p = map(int, input().split())
a = list(map(int, input().split()))
a = sorted(list(map(lambda x: x % 2, a)))
a = Counter(a)
ans = 0
if p == 1:
    for i in range(1, a[1] + 1, 2):
        for j in range(a[0] + 1):
            ans += combinations_count(a[1], i) * combinations_count(a[0], j)
if p == 0:
    for i in range(0, a[1] + 1, 2):
        for j in range(a[0] + 1):
            ans += combinations_count(a[1], i) * combinations_count(a[0], j)
print(ans)

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

Solution (Python):
import math
def combinations_count(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()))
even=0
odd=0
answer=0
for a in A:
    if a%2==0:
        even+=1
    else:
        odd+=1
if even==0:
    if P==0:
        if odd==1:
            print(0)
        else:
            for n in range(2,odd+1,2):
                answer+=combinations_count(odd,n)
            print(answer+1)
    else:
        for n in range(1,odd+1,2):
            answer+=combinations_count(odd,n)
        print(answer)
elif odd==0:
    if P==1:
        print(0)
    else:
        answer+=2**even
        print(answer)
else:
    if P==0:
        suuji=0
        for n in range(0,odd+1,2):
            suuji+=combinations_count(odd,n)
        answer+=2**even
        print(answer*suuji)
    else:
        suuji=0
        for n in range(1,odd+1,2):
            suuji+=combinations_count(odd,n)
        answer+=2**even
        print(answer*suuji)

Solution (Python):
def main():
    n,p = map(int,input().split())
    a = list(map(int,input().split()))
    D = {0:0, 1:0}
    for i in range(n):
        D[a[i]%2]+=1
    ans = 0

    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)]
    if p==0:
        for i in range(D[1]//2+1):
            ans += cmb(D[1],2*i)
    else:
        for i in range(D[1]//2):
            ans += cmb(D[1],2*i+1)
    print(ans * pow(2,D[0]))

if __name__ == "__main__":
    main()

Solution (Python):
n,p=map(int,input().split())
a=list(map(int,input().split()))
d={0:0,1:0}
for i in range(n):
  d[a[i]%2]+=1
q=2**d[0]
ans=0
m=d[1]
f=[1]
for i in range(1,m+1):
  f+=[f[-1]*i]
for i in range(m+1):
  if i%2!=p:continue
  ans+=q*f[m]//f[i]//f[m-i]
print(ans)

Solution (Python):
import math
def comb(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, e = 0, 0
for i in A:
    if i % 2 == 0:
        e += 1
    else:
        o += 1
ans = 0
for i in range(P, o+1, 2):
    ans += comb(o, i)
print(ans * 2 ** e)

Solution (Python):
n,p = map(int,input().split())
a = list(map(int,input().split()))
flg = True
for i in a:
    if i % 2 != 0:
        flg = False
        break
if flg:
    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()))
A = [A[i] % 2 for i in range(N)] 
even = A.count(0)
odd = A.count(1)

anseven = 1
ansodd = 1

dic = {0:1}
for i in range(1, 51):
    dic[i] = dic[i - 1] * i


for i in range(1, even + 1):
    anseven += dic[even] // dic[even - i] // dic[i]

if P == 0:
    
    for i in range(2, odd + 1, 2):
        ansodd += dic[odd] // dic[odd - i] // dic[i]

else:
    if odd == 0:
        print(0)
        exit()
    ansodd = 0
    
    for i in range(1, odd + 1, 2):
        ansodd += dic[odd] // dic[odd - i] // dic[i]

print(anseven * ansodd)

Solution (Python):

def comb(n, max_k, mod):
    """
    (n,k) := n個からk個選ぶ組み合わせ
    k = 0~max_Kまでを計算して返す
    """
    res = [1]*(max_k+1)
    t = 1
    for i in range(max_k+1):
        res[i] *= t
        t *= n-i
        t %= mod

    n = reduce(lambda x,y: (x*y)%mod, range(1,max_k+1), 1)
    n = modinv(n, mod)

    for i in reversed(range(max_k+1)):
        res[i] *= n
        res[i] %= mod
        n *= i
        n %= mod
    return res

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

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

evens = 0
odds = 0

for a in A:
    if a%2:
        odds += 1
    else:
        evens += 1


cnt = 0
if P == 0:
    comb = 1
    cnt = 1
    for n in range(2,odds+1,2):
        comb *= (odds+2-n)*(odds+1-n)
        comb //= n*(n-1)
        cnt += comb
else:
    comb = odds
    cnt = odds
    for n in range(3,odds+1,2):
        comb *= (odds+2-n)*(odds+1-n)
        comb //= n*(n-1)
        cnt += comb

print(2**evens * cnt)

Solution (Python):
class Combination:
    def __init__(self, n_max, MOD=10 ** 9 + 7):
        """
        前処理 = O(n_max + log(MOD))
        :param self.fac[n]: n!
        :param self.facinv[n]: 1/n!
        """
        self.mod = MOD
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):
            f = f * i % MOD
            fac.append(f)
        f = pow(f, MOD - 2, MOD)
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):
            f = f * i % MOD
            facinv.append(f)
        facinv.reverse()

    def __call__(self, n, r):  
        if not 0 <= r <= n: return 0
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod


N, P = map(int, input().split())
A = []
for a in map(int, input().split()):
    A.append(a%2)
cnt1 = A.count(1)
cnt0 = N - cnt1
C = Combination(cnt1)
if P==1:
    res = sum(C(cnt1,i) for i in range(1,cnt1+1,2))*pow(2,cnt0)
else:
    res = sum(C(cnt1,i) for i in range(0,cnt1+1,2))*pow(2,cnt0)
print(res)

Solution (Python):
import sys
import math


inint = lambda: int(sys.stdin.readline())
inintm = lambda: map(int, sys.stdin.readline().split())
inintl = lambda: list(inintm())
instrm = lambda: map(str, sys.stdin.readline().split())
instrl = lambda: list(instrm())



def solver1(n, p, A):
    ans = 0
    for i in range(2**n):
        x = 0
        for j in range(n):
            if (i>>j) & 1:
                x += A[j]
        if x % 2 == p:
            ans += 1
    return ans


def solver2(n, p, A):
    odd = 0
    even = 0
    for a in A:
        if a % 2 == 1:
            odd += 1
        else:
            even += 1
    if odd == 0:
        if p == 0:
            return 2 ** even
        else:
            return 0
    else:
        return 2 ** (n-1)


def main():
    n, p = inintm()
    A = inintl()
    
    print(solver2(n, p, A))


main()

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

for i in a:
    cnt[i % 2] += 1

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

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




dp=[0]*(N+2)
dp[0]=(P+1)%2

for i in range(1,N+1):
    if A[i-1]%2==0:
        dp[i]=2*dp[i-1]
    else:
        dp[i]=(2**(i-1)-dp[i-1])+dp[i-1]
print(dp[N])

Solution (Python):
n, p = map(int,input().split())
a=list(map(int, input().split()))
odd=0
even=0
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)]

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

o_pattern=0
for i in range(p,odd+1,2):
    o_pattern += cmb(odd,i)

e_pattern=0
for i in range(even+1):
    e_pattern += cmb(even,i)

print(o_pattern*e_pattern)

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

odd = 0
even = 0
for i in a:
    if i%2 == 0:
        even += 1
    else:
        odd += 1
if odd == 0:
    if p == 1:
        print(0)
    else:
        print(2 ** n)
else:
    print(2 ** (n - 1))

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

odd = 0
for i in a:
    if i%2:
        odd += 1
even = n-odd

ans = 0

for i in range(0,odd+2,2):
    if i+p > odd:
        break
    for j in range(0,even+1):
        if j > even:
            break
        
        a = 1
        for k in range(i+p):
            a *= (odd-k)
            a /= k+1
    
        b = 1
        for k in range(j):
            b *= (even-k)
            b /= k+1
       
        
        ans += a*b
print(int(ans))

Solution (Python):
n, p = map(int, input().split())
a = list(map(int, input().split()))
for i in range(n):
    a[i] %= 2
cnt_zero = a.count(0)
cnt_one = n - cnt_zero
ans = 0
def nCk(n, k):
    if k > n - k:
        return nCk(n, n - k)
    ret = 1
    for i in range(k):
        ret *= n - i
    for i in range(k):
        ret //= i + 1
    return ret
ans = 0
c = 0
for i in range(p, cnt_one + 1, 2):
    c += nCk(cnt_one, i)
ans = (2 ** cnt_zero) * c
print(ans)

Solution (Python):
from math import factorial
def cmb(a,b):
    return factorial(a)//factorial(b)//factorial(a-b)
N,P = map(int,input().split())
A = list(map(int,input().split()))
Odd = 0 
Even = 0
for Ai in A:
    if Ai % 2 == 0:
        Even += 1
    else:
        Odd += 1
ans = 0
if P == 0:
    for i in range(Odd+1)[::2]:
        ans += cmb(Odd,i)
else:
    for i in range(Odd+1)[1::2]:
        ans += cmb(Odd,i)
ans *= pow(2,Even)
print(ans)

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

if even==N:
    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()))
mod = {0:0, 1:0}
for i in a:
    mod[i % 2] += 1
ans = 0
for i in range(p, mod[1] + 1, 2):
    temp = 1
    for j in range(i):
        temp *= mod[1] - j
        temp //= j + 1
    ans += temp
for i in range(mod[0]):
    ans *= 2
print(ans)

Solution (Python):
n, p = map(int, input().split())
a = list(map(int, input().split()))
os = list(filter(lambda x: x % 2 == 1, a))
es = list(filter(lambda x: x % 2 == 0, a))

def calc_even(o_num, e_num):
    if o_num < 0 or e_num < 0:
        return 0
    
    res = 1
    tmp = 1
    for i in range(1, o_num // 2 + 1):
        tmp *= (o_num - i * 2 + 2) * (o_num - i * 2 + 1)
        tmp /= 2 * i * (2 * i - 1)
        res += tmp
    
    res *= 2 ** e_num
    return res

def calc_odd(o_num, e_num):
    if o_num < 0 or e_num < 0:
        return 0
    
    tmp = o_num
    res = tmp
    end = o_num if o_num % 2 == 1 else o_num-1
    for i in range(1, end // 2 + 1):
        tmp *= (o_num - i * 2 + 1) * (o_num - i * 2)
        tmp /= 2 * i * (2 * i + 1)
        res += tmp
    
    res *= 2 ** e_num
    return res
if p == 0:
    res = calc_even(len(os), len(es))
    print(int(res))
else:
    res = calc_odd(len(os), len(es))
    print(int(res))

Solution (Python):
def comb(n, k):
    if k > n // 2:
        return comb(n, n - k)
    numer = 1
    denom = 1
    for i in range(k):
        numer *= n - i
        denom *= k - i
    return numer // denom


def main():
    N, P = list(map(int, input().split()))
    A = list(map(int, input().split()))
    
    cnt_even_bag = len([a for a in A if a % 2 == 0])
    cnt_odd_bag = N - cnt_even_bag
    cnt_even_pattern = 2 ** cnt_even_bag
    cnt_odd_pattern = 0
    for c in range(1, cnt_odd_bag + 1, 2):
        cnt_odd_pattern += comb(cnt_odd_bag, c)
    cnt_even = cnt_even_pattern * cnt_odd_pattern
    if P == 1:
        print(cnt_even)
    else:
        print(2 ** N - cnt_even)


if __name__ == '__main__':
    main()

Solution (Python):
n,p=map(int,input().split())
a=list(map(int,input().split()))
even=0
odd=0
for i in a:
    if i%2==0:
        even+=1
    else:
        odd+=1
import math
ans=2**even
if p==0:
    m=odd//2
    t=1
    for i in range(1,m+1):
        i*=2
        t+=math.factorial(odd)/math.factorial(i)/math.factorial(odd-i)
else:
    m=(odd+1)//2
    t=0
    for i in range(1,m+1):
        i=2*i-1
        t+=math.factorial(odd)/math.factorial(i)/math.factorial(odd-i)
ans*=t
print(int(ans))

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

n0 = 0
n1 = 0

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

x = 0
if p == 0:
    for i in range(0, n1+1, 2):
        x += comb(n1, i)
else:
    for i in range(1, n1+1, 2):
        x += comb(n1, i)

print(2**n0 * x)

Solution (Python):
import math
def main():
    N, P = map(int, input().split())
    A = [int(a) for a in input().split()]
    modA = list()

    for a in A:
        modA.append(a % 2)

    zero = modA.count(0)
    one = modA.count(1)

    ans = tmp = 0
    f = math.factorial
    if P == 0:
        for i in range(0, one + 1, 2):
            tmp += f(one) // (f(i) * f(one - i))
    else:
        for i in range(1, one + 1, 2):
            tmp += f(one) // (f(i) * f(one - i))

    if zero > 0:
        ans = tmp * 2 ** zero
    else:
        ans = tmp

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
from math import factorial
n,p=map(int,input().split())
a=list(map(int,input().split()))
even=0
odd=0
for i in a:
    if i%2==0:
        even+=1
    else:
        odd+=1
def comb(a,b):
    return factorial(a)//(factorial(a-b)*factorial(b))
n_even=0
n_odd=0
for i in range(even+1):
    n_even+=comb(even,i)

if p==1:
    for i in range(1,odd+1,2):
        n_odd+=comb(odd,i)
else:
    for i in range(0,odd+1,2):
        n_odd+=comb(odd,i)
print(n_even*n_odd)

Solution (Python):
import sys
import math
import copy
import heapq
from functools import cmp_to_key
from bisect import bisect_left, bisect_right
from collections import defaultdict, deque, Counter



input = sys.stdin.readline
getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = float("inf")
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def nck(n, k, kaijyo):
    return (npk(n, k, kaijyo) * divide(kaijyo[k])) % MOD

def npk(n, k, kaijyo):
    if k == 0 or k == n:
        return n % MOD
    return (kaijyo[n] * divide(kaijyo[n-k])) % MOD

def fact_and_inv(SIZE):
    inv = [0] * SIZE  
    fac = [0] * SIZE  
    finv = [0] * SIZE  
    inv[1] = 1
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    for i in range(2, SIZE):
        inv[i] = MOD - (MOD // i) * inv[MOD % i] % MOD
        fac[i] = fac[i - 1] * i % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

    return fac, finv

def renritsu(A, Y):
    
    
    
    A = np.matrix(A)
    Y = np.matrix(Y)
    Y = np.reshape(Y, (-1, 1))
    X = np.linalg.solve(A, Y)

    
    return X.flatten().tolist()[0]

class TwoDimGrid:
    
    def __init__(self, h, w, wall="
        self.h = h
        self.w = w
        self.size = (h+2) * (w+2)
        self.wall = wall
        self.get_grid()
        

    def get_grid(self):
        grid = [self.wall * (self.w + 2)]
        for i in range(self.h):
            grid.append(self.wall + getS() + self.wall)

        grid.append(self.wall * (self.w + 2))
        self.grid = grid
    def init_cost(self):
        self.cost = [INF] * self.size

    def pos(self, x, y):
        
        return y * (self.w + 2) + x
    def getgrid(self, x, y):
        return self.grid[y][x]
    def get(self, x, y):
        return self.cost[self.pos(x, y)]
    def set(self, x, y, v):
        self.cost[self.pos(x, y)] = v
        return
    def show(self):
        for i in range(self.h+2):
            print(self.cost[(self.w + 2) * i:(self.w + 2) * (i+1)])
    def showsome(self, tgt):
        for t in tgt:
            print(t)
        return
    def showsomejoin(self, tgt):
        for t in tgt:
            print("".join(t))
        return

    def search(self):
        grid = self.grid
        move = [(0, 1), (0, -1), (1, 0), (-1, 0)]
        move_eight = [(0, 1), (0, -1), (1, 0), (-1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]
        
        
        
        
        

def judge(mid, cnt, n):
    xx = cnt[0]
    if ((mid+1) * (xx-1)) >= n:
        return False
    elif (mid+1) * xx <= n:
        return True
    yoyu = n % (mid+1)
    if Counter(cnt)[xx] <= yoyu:
        return True
    else:
        return False



def solve():
    n, k = getList()
    nums = getList()
    for num in nums:
        if num % 2 == 1:
            print(pow(2, n-1))
            return
    if k == 0:
        print(pow(2, n))
    else:
        print(0)
def main():
    n = getN()
    for _ in range(n):
        solve()

    return
if __name__ == "__main__":
    
    solve()

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

if odd == 0:
    if p == 0:
        ans = 2 ** n
    else:
        ans = 0
else:
    ans = 2 ** (n - 1)

print(ans)

Solution (Python):
from math import factorial

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

cnt = [0,0]
for i in a:
    cnt[i%2] += 1

ans = 0

while True:
    if p > cnt[1]:
        break
    ans += factorial(cnt[1]) // factorial(p) // factorial(cnt[1] - p)
    p += 2

print(ans * 2 ** cnt[0])

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

semua_angka_genap = True
for i in num:
  if i % 2 == 1:
    semua_angka_genap = False

if semua_angka_genap:
  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()))

count = 0
for i in a:
    if i%2 == 0:
        count += 1
if count == n:
    if p == 1:
        print(0)
    else:
        print(2**n)
else:
    print(2**(n-1))

Solution (Python):
n,p = map(int,input().split())
x = 1
y = 0
a = list(map(int,input().split()))
for ai in a:
  if ai%2 == 0:
    x += x
    y += y
  else:
    t = x
    x += y
    y += t
if p == 0:
  print(x)
else:
  print(y)

Solution (Python):

import math
import sys


def II():
    return int(sys.stdin.readline())


def MI():
    return map(int, sys.stdin.readline().split())


def LI():
    return list(map(int, sys.stdin.readline().split()))


def main():
    n, p = MI()
    a = LI()
    num_0 = 0
    num_1 = 0
    for i in range(n):
        if a[i] % 2 == 0:
            num_0 += 1
        else:
            num_1 += 1

    s_1 = 0
    while p <= num_1:
        cmb = math.factorial(num_1) // (
            math.factorial(num_1 - p) * math.factorial(p)
        )
        s_1 += cmb
        p += 2

    print(s_1 * (2 ** num_0))


main()

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

N, P = mapint()
As = list(mapint())
bit = [a%2 for a in As]

pos = {}
pos[0] = 1
for i in range(1, N+1):
    pos[i] = pos[i-1]*i
dic = {}
dic[0] = 0
dic[1] = 0
for i in bit:
    dic[i] += 1

ans = 2**dic[0]
if P==1:
    if dic[1]<1:
        print(0)
        exit(0)
    else:
        pass
        
        
val = 0
for i in range(dic[1]//2+1):
    val += pos[dic[1]]//pos[i*2]//pos[dic[1]-i*2]
print(val*ans)

Solution (Python):
from scipy.special import comb
n, p, *A = map(int, open(0).read().split())
o = sum(a%2 for a in A)
e = n - o

s = 0
for i in range(p, o+1, 2):
  s += comb(o, i, exact=True)
s *= pow(2, e)
print(s)

Solution (Python):
from scipy.special import comb
n, p, *A = map(int, open(0).read().split())
odd = sum(a%2 for a in A)
even = n - odd

if p:
  s = 0
  for i in range(1, odd+1, 2):
    s += comb(odd, i, exact=True)
  s *= pow(2, even)
  print(s)
else:
  s = 0
  for i in range(0, odd+1, 2):
    s += comb(odd, i, exact=True)
  s *= pow(2, even)
  print(s)

Solution (Python):

N_MAX = 100
MOD = 10**9 + 7
fac, finv, inv = [0]*N_MAX ,[0]*N_MAX, [0]*N_MAX
def com_init():
    fac[0], fac[1] = 1, 1
    finv[0], finv[1] = 1, 1
    inv[1] = 1
    for i in range(2, N_MAX):
        fac[i] = fac[i - 1] * i % MOD
        inv[i] = MOD - inv[MOD%i] * (MOD // i) % MOD
        finv[i] = finv[i - 1] * inv[i] % MOD

def com(n, k):
    if n < k: return 0
    if n < 0 or k < 0: return 0
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD


n,p = map(int, input().split())
al = list(map(int, input().split()))
zero = 0
one = 0
com_init()
for a in al:
    if a%2 == 0: zero+=1
    else: one+=1


zero_comb = pow(2,zero)
one_comb = 0
if p == 0:
    for i in range(0,one+1,2):
        one_comb += com(one,i)
else:
    for i in range(1,one+1,2):
        one_comb += com(one,i)

print(zero_comb*one_comb)

Solution (Python):
from scipy.special import comb

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

o,e = 0,0
for a in A:
    if a%2==0:
        e+=1
    else:
        o+=1

if P == 0:
    
    t = 0
    for i in range(0, o+1, 2):
        t += comb(o, i, True)
    print(2**e * t)
else:
    t = 0
    for i in range(1, o+1, 2):
        t += comb(o, i, True)
    print(2**e * t)

Solution (Python):
import collections
import math
def combinations_count(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()))
H = [i%2 for i in A]
B = collections.Counter(H)[1]

ans = 0
for i in range(1,B//2+1):
    ans += combinations_count(B, 2*i)
C = (ans+1) * (2**(len(A)-B))
print(C if P == 0 else 2**N - C)

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

Solution (Python):



from fractions import gcd
from itertools import combinations,permutations,accumulate 

from collections import deque,defaultdict,Counter
import decimal
import re












import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7

def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
n,p = readInts()
A = readInts()
odd = 0
for i in range(n):
    
    
    
    
    if A[i]%2:
        odd += 1
if odd == 0:
    if p == 0:
        print(2**n)
    else:
        print(0)
else:
    print(2**(n-1))

Solution (Python):
from scipy.special import comb
n,p = map(int, input().split())
A = list(map(int, input().split()))
cnt = [0,0] 
for a in A:
    if a%2==0: cnt[0] += 1
    else: cnt[1] += 1
      
ans = 0
if p==0: 
    for i in range(0,cnt[1]+1,2):
        ans += comb(cnt[1],i,exact=True)
    ans *= 2**cnt[0]
else: 
    for i in range(1,cnt[1]+1,2):
        ans += comb(cnt[1],i,exact=True)
    ans *= 2**cnt[0]
print(ans)

Solution (Python):
from sys import stdin
nii=lambda:map(int,stdin.readline().split())
lnii=lambda:list(map(int,stdin.readline().split()))
from math import factorial

n,p=nii()
a=lnii()

x=0
y=0
for i in a:
  if i%2==0:
    x+=1
  else:
    y+=1

def solve(q):
  num=0
  while q<=y:
    num+=factorial(y)//(factorial(q)*factorial(y-q))
    q+=2
  return num

ans=2**x
if p==0:
  num=solve(0)
else:
  num=solve(1)

print(ans*num)