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:
Num=[1,1,2,6,24,120,720,5040,40320,362880,3628800,39916800,479001600,6227020800,87178291200,1307674368000,20922789888000,355687428096000,6402373705728000,121645100408832000,2432902008176640000,51090942171709440000,1124000727777607680000,25852016738884976640000,620448401733239439360000,15511210043330985984000000,403291461126605635584000000,10888869450418352160768000000,304888344611713860501504000000,8841761993739701954543616000000,265252859812191058636308480000000,8222838654177922817725562880000000,263130836933693530167218012160000000,8683317618811886495518194401280000000,295232799039604140847618609643520000000,10333147966386144929666651337523200000000,371993326789901217467999448150835200000000,13763753091226345046315979581580902400000000,523022617466601111760007224100074291200000000,20397882081197443358640281739902897356800000000,815915283247897734345611269596115894272000000000,33452526613163807108170062053440751665152000000000,1405006117752879898543142606244511569936384000000000,60415263063373835637355132068513997507264512000000000,2658271574788448768043625811014615890319638528000000000,119622220865480194561963161495657715064383733760000000000,5502622159812088949850305428800254892961651752960000000000,258623241511168180642964355153611979969197632389120000000000,12413915592536072670862289047373375038521486354677760000000000,608281864034267560872252163321295376887552831379210240000000000,30414093201713378043612608166064768844377641568960512000000000000,1551118753287382280224243016469303211063259720016986112000000000000,80658175170943878571660636856403766975289505440883277824000000000000,4274883284060025564298013753389399649690343788366813724672000000000000,230843697339241380472092742683027581083278564571807941132288000000000000,12696403353658275925965100847566516959580321051449436762275840000000000000,710998587804863451854045647463724949736497978881168458687447040000000000000,40526919504877216755680601905432322134980384796226602145184481280000000000000,2350561331282878571829474910515074683828862318181142924420699914240000000000000,138683118545689835737939019720389406345902876772687432540821294940160000000000000]

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

tmp=0
total=0
for i in A:
    tmp+=i%2
R=N-tmp

K=1
for i in range(1,R+1):
    K+=Num[R]//(Num[R-i]*Num[i])


if(tmp%2==P):
    total=1
    for i in range(2,tmp+1,2):
        total+=(Num[tmp]//(Num[tmp-i]*Num[i]))*K
else:
    for i in range(1,tmp+1,2):
        total+=(Num[tmp]//(Num[tmp-i]*Num[i]))*K

print(total)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
n,p = [int(i) for i in input().split()]

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

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
l=list(map(int,input().split()))
def comb(n,r):
    if n==r or r==0:
        return 1
    t=1
    for i in range(r+1,n+1):
        t*=i
    for i in range(1,r+1):
        t=t//i
    return t
g=0
k=0
for i in l:
    if i%2==0:
        g+=1
    else:
        k+=1
if p==0:
    h=k//2
    ans=0
    for i in range(0,h+1):
        ans+=comb(k,2*i)
    print(ans*(2**g))
else:
    h=(k+1)//2
    ans=0
    for i in range(h):
        ans+=comb(k,2*i+1)
    print(ans*(2**g))

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
l=list(map(int,input().split()))
def comb(n,r):
    t=1
    for i in range(r+1,n+1):
        t*=i
    for i in range(1,r+1):
        t=t//i
    return t
g=0
k=0
for i in l:
    if i%2==0:
        g+=1
    else:
        k+=1
if p==0:
    h=k//2
    ans=0
    for i in range(0,h+1):
        ans+=comb(k,2*i)
    f=g//2
    kai=0
    for i in range(f+1):
        kai+=comb(g,2*i)
    print(ans*kai)
else:
    h=(k+1)//2
    ans=0
    for i in range(h):
        ans+=comb(k,2*i+1)
    print(ans*(2**g))

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
l=list(map(int,input().split()))
def comb(n,r):
    t=1
    for i in range(r+1,n+1):
        t*=i
    for i in range(1,r+1):
        t=t//i
    return t
g=0
k=0
for i in l:
    if i%2==0:
        g+=1
    else:
        k+=1
if p==0:
    h=k//2
    ans=0
    for i in range(0,h+1):
        ans+=comb(k,2*i)
    print(ans*(2**g))
else:
    h=(k+1)//2
    ans=0
    for i in range(h):
        ans+=comb(k,2*i+1)
    print(ans*(2**g))

Submission status: Wrong Answer

Solution code:
N,P=map(int,input().split())
L=list(map(int,input().split()))
for q in range(N):
  L[q]=L[q]%2
s=0
if P==0:
  s+=1
i=0
while i<=N-1:
  m=L[i]
  for j in range(i+1,N):
    for k in range(j,N):
      m+=L[k]
      if m%2==P:
        s+=1
  i+=1
print(s)

Submission status: Wrong Answer

Solution code:
N,P=map(int,input().split())
L=list(map(int,input().split()))
for q in range(N):
  L[q]=L[q]%2
s=0
if P==0:
  s+=1
if L[N-1]==P:
  s+=1
i=0
while i<=N-2:
  m=L[i]
  for j in range(i+1,N):
    for k in range(j,N):
      m+=L[k]
      if m%2==P:
        s+=1
  i+=1
print(s)

Submission status: Wrong Answer

Solution code:
N,P=map(int,input().split())
L=list(map(int,input().split()))
for q in range(N):
  L[q]=L[q]%2
s=0
if P==0:
  s+=1
if L[N-1]==P:
  s+=1
i=0
while i<=N-2:
  m=L[i]
  for j in range(i+1,N):
    m+=L[i+1]
    if m%2==P:
      s+=1
  i+=1
print(s)

Submission status: Wrong Answer

Solution code:
from math import factorial as f
n,p,*a=map(int,open(0).read().split())
x=len([i for i in a if i%2])
y=n-x

xx=0
for i in range(p,x,2):
    xx+=f(x)//f(i)//f(x-i)

yy=0
for i in range(0,y):
    yy+=f(y)//f(i)//f(y-i)

print(xx*yy+xx*(p^0)+yy*(p^1))

Submission status: Wrong Answer

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

def cmb(n, r):
    p, q = 1, 1
    for i in range(r):
        p = p * (n - i)
        q = q * (i + 1)
    return p // q


even = A.count(0)
odd = A.count(1)

if P == 0:
    n = 1
    cnt = 0
    while odd >= 2 * n:
        cnt += cmb(odd, 2 * n)
        n += 1
    if even == 0:
        print(cnt + 1)
    else:
        print(2 ** even * cnt)
else:
    n = 0
    cnt = 0
    while odd >= 2 * n + 1:
        cnt += cmb(odd, 2 * n + 1)
        n += 1
    if odd == 0:
        print(0)
    elif even == 0:
        print(cnt + 1)
    else:
        print(2 ** even * cnt)

Submission status: Wrong Answer

Solution code:
from math import factorial as f
n,p,*a=map(int,open(0).read().split())
x=len([i for i in a if i%2])
y=n-x

xx=0
for i in range(p,x,2):
    xx+=f(x)//f(i)//f(x-i)

yy=0
for i in range(0,y):
    yy+=f(y)//f(i)//f(y-i)

print(xx*yy+xx)

Submission status: Wrong Answer

Solution code:
n, p = map(int,input().split())
src = list(map(int, input().split()))
even_count = 0 #偶数
odd_count = 0 #奇数
for s in src:
    if s%2 == 0:
        even_count += 1
    else:
        odd_count += 1
if p == 1 and odd_count == 0:
    print(0)
else:
    print(2**even_count*2**(odd_count-1))

Submission status: Wrong Answer

Solution code:
n, p = map(int,input().split())
src = list(map(int, input().split()))
even_count = 0 #偶数
odd_count = 0 #奇数
for s in src:
    if s%2 == 0:
        even_count += 1
    else:
        odd_count += 1
if odd_count == 0:
    print(0)
else:
    if p == 1 and odd_count == 0:
        print(0)
    else:
        print(2**even_count*2**(odd_count-1))

Submission status: Wrong Answer

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

def C(u,d):
    count=1
    for i in range(d):
        count*=(u-i)/(d-i)
    return count

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

ans=0
for i in range(odd+1)[P%2::2]:
    ans+=C(odd,i)

temp=0
for i in range(even+1):
    temp+=C(even,i)
    
print(int(ans*temp))

Submission status: Wrong Answer

Solution code:
N,P=map(int,input().split())
A=list(map(int,input().split()))
odd=len([x for x in A if x%2==1])
if odd==0 and P==1:
    ans=0
else:
    ans=2**(N-1)
print(ans)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
A = list(map(int, input().split()))
if N == 1:
    a = 0
    a  +=  0 % 2 == P
    a+=A[0] % 2 == P
    print(a)
else:
	print(pow(2, N-1))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
As = list(map(int, input().split()))
nE = 0
nO = 0
for A in As:
  if A%2 == 0:
    nE += 1
  else:
    nO += 1
r = 0
# \sum_{2k<=nO}C_nO_2k
for k in range(0, nO+1, 2):
  c = 1
  for i in range(1, k+1):
    c = c*(nO+1-i)//i
  r += c
r = r*2**nE
print(r)

Submission status: Wrong Answer

Solution code:
from scipy.misc import*
N,P,*A=map(int,open(0).read().split());O=sum(a%2for a in A)
print(2**(N-O)*sum(comb(O,2*i+P,exact=1)for i in range(O)))

Submission status: Wrong Answer

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

if N == 1 and A[0] % 2 != P:
    ans = 0
else:
    ans = 2**(N-1)

print(ans)

Submission status: Wrong Answer

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

if P != 0 and P % 2 == 0:
    ans = 0
elif N == 1 and A[0] % 2 != P:
    ans = 0
else:
    ans = 2**(N-1)

print(ans)

Submission status: Wrong Answer

Solution code:
n,p=map(int, input().split())
a=list(map(int, input().split()))
total=sum( n%2 for i in a )

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

Submission status: Wrong Answer

Solution code:
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
dp[0][1]=0
for i in range(1,n+1):
	if a[i-1]%2==1:
		dp[i][1]=dp[i-1][0]+dp[i-1][1]
		dp[i][0]=dp[i-1][1]+dp[i-1][0]
	else:
		dp[i][1]=dp[i-1][1]*2
		dp[i][0]=dp[i-1][0]*2
for i in dp:
	print(i)
print(dp[n][p])

Submission status: Wrong Answer

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,p = LI()
    a = LI()
    o = 0
    for i in a:
        o += i%2
    e = n-o
    ans = (1<<e)*((1<<o)>>1)
    print(ans)
    return
#B
def B():

    return

#C
def C():

    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    A()

Submission status: Wrong Answer

Solution code:
def main():
    n,p = map(int,input().split())
    ls = [int(x) for x in range(n)]
    flg = False
    for i in range(n):
        if ls[i]%2==1:
            flg = True
            break
    if flg :
        print(2**(n-1))

    else:
        if p == 0:
            print(2**n)
        else:
            print(0)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,p = map(int,input().split())
    ls = [int(x) for x in range(n)]
    flg = False
    for i in range(n):
        if ls[i]%2==1:
            flg = True
            break
    if flg :
        print(2**(n-1))

    else:
        if p == 0:
            print(0)
        else:
            print(2**n)
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main():
    n,p = map(int,input().split())
    ls = [int(x) for x in range(n)]
    flg = False
    for i in range(n):
        if ls[i]%2==1:
            flg = True
            break
    if flg :
        print(2**(n-1))

    else:
        if p == 0:
            print(0)
        else:
            print(2**(n-1))
if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
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())
x = [int(i) for i in input().split()]
odd = 0
ans = 0
ans_tmp = 0
for i in x:
  if i%2:
    odd += 1

ans += 2**(n-odd)
tmp = odd//2
if p:#p==1のとき
  if odd:
    for i in range(tmp):
      ans_tmp += cmb(odd,i*2+1)
else:#p==0のとき
  print(odd)
  if odd:
    tmp += 1
    for i in range(tmp):
      ans_tmp += cmb(odd,(i*2))

ans *= ans_tmp
print(ans)

Submission status: Wrong Answer

Solution code:
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())
x = [int(i) for i in input().split()]
odd = 0
ans = 0
ans_tmp = 0
for i in x:
  if i%2:
    odd += 1

ans += 2**(n-odd)
tmp = odd//2
if p:#p==1のとき
  print(odd)
  if odd:
    for i in range(tmp):
      ans_tmp += cmb(odd,i*2+1)
else:#p==0のとき
  if odd:
    tmp += 1
    for i in range(tmp):
      ans_tmp += cmb(odd,(i*2))

ans *= ans_tmp
print(ans)

Submission status: Wrong Answer

Solution code:
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())
x = [int(i) for i in input().split()]
odd = 0
ans = 0
ans_tmp = 0
for i in x:
  if i%2:
    odd += 1

ans += 2**(n-odd)
tmp = odd//2
if p:#p==1のとき
  if odd:
    for i in range(tmp):
      ans_tmp += cmb(odd,i*2+1)
else:#p==0のとき
  if odd:
    tmp += 1
    for i in range(tmp):
      ans_tmp += cmb(odd,(i*2))

ans *= ans_tmp
print(ans)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
A = list(map(int, input().split()))
for i in range(N):
    A[i] %= 2
A_1 = A.count(1)
A_0 = A.count(0)

import math
def conbination(n, r): #nCrを求める
    # nCr = n! //(r! * (n-r)!)
    return math.factorial(n) //(math.factorial(r) * math.factorial(n-r))


# print ('A_0, A_1 = ', A_0, A_1)
if P == 0: #2の倍数
    ans = 2 ** A_0 #偶数のものの選び方
    if A_1 >= 1:
        tmp = 0
        # A_1個の奇数から偶数個を選ぶ
        for i in range(0, A_1 + 1, 2):
            tmp = conbination(A_1, i)
        ans *= tmp
    if A_0 == 0:
        ans += 1
else:
    ans = 2 ** A_0 #偶数のものの選び方
    tmp = 0
    # A_1個の奇数から偶数個を選ぶ
    for i in range(1, A_1 + 1, 2):
        # print (i, end = ' ')
        tmp += conbination(A_1, i)
    ans *= tmp

print (ans)

Submission status: Wrong Answer

Solution code:
n, p = map(int, input().split())
A = list(map(int, input().split()))
even = len(list(filter(lambda x: x%2==0, A)))
odd = len(list(filter(lambda x: x%2==1, A)))
even_ans = 2 ** even
odd_ans = 2 ** odd // 2
print(even_ans * odd_ans)

Submission status: Wrong Answer

Solution code:
i=2**~-int(input()[:2]);print((i,0)[i%2])

Submission status: Wrong Answer

Solution code:
i=int(input()[:2])-1;print((2**i,0)[i%2])

Submission status: Wrong Answer

Solution code:
print(2**~-int(input()[:2]))

Submission status: Wrong Answer

Solution code:
print(2**int(input()[:2]))

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC17 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n,p = map(int,sys.stdin.readline().split())
a = list(map(int,sys.stdin.readline().split()))
fact = [1]*51
for i in range(1,51):
    fact[i] = fact[i-1]*i
def comb(n,r):
    return fact[n]//fact[n-r]//fact[r]
x = list(map(lambda x:x % 2,a))
c = x.count(1)
ans = 0
if p:
    for i in range(c+1):
        if i % 2:
            for j in range(n-c+1):
                ans += comb(c,i)*comb(n-c,j)
else:
    for i in range(c+1):
        if i % 2 == 0:
            for j in range(n-c+1):
                if j % 2 == 0:
                    ans += comb(c,i)*comb(n-c,j)
print(ans)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
#AGC17 A

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7

n,p = map(int,sys.stdin.readline().split())
a = list(map(int,sys.stdin.readline().split()))
def comb(n,r):
    return math.factorial(n)/math.factorial(n-r)/math.factorial(r)
x = list(map(lambda x:x % 2,a))
c = x.count(1)
ans = 0
if p:
    for i in range(c+1):
        if i % 2:
            for j in range(n-c+1):
                ans += comb(c,i)*comb(n-c,j)
else:
    for i in range(c+1):
        if i % 2 == 0:
            for j in range(n-c+1):
                if j % 2 == 0:
                    ans += comb(c,i)*comb(n-c,j)
print(ans)

Submission status: Wrong Answer

Solution code:
import numpy as np
N, P = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A)
A = A % 2
A = list(A)
count0 = A.count(0)
count1 = A.count(1)

#print(count0, count1, P)

if P == 0 and count1 % 2 == 0:
    tmp = 2**(count1-1) * 2**count0

elif P == 0 and count1 % 2 == 1:
    tmp = 2**(count1-1) * 2**count0

elif P == 1 and count1 % 2 == 0:
    tmp = 2**(count1-1) * 2**count0

elif P == 1 and count1 % 2 == 1:
    tmp = 2**(count1-1) * 2**count0 

if count1 == 0 and P == 1:
    tmp = 0

print(round(tmp))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, P = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A)
A = A % 2
A = list(A)
count0 = A.count(0)
count1 = A.count(1)

#print(count0, count1, P)

if P == 0 and count1 % 2 == 0:
    tmp = 2**(count1-1) * 2**count0

elif P == 0 and count1 % 2 == 1:
    tmp = 2**(count1-1) * 2**count0

elif P == 1 and count1 % 2 == 0:
    tmp = 2**(count1-1) * 2**count0

elif P == 1 and count1 % 2 == 1:
    tmp = 2**(count1-1) * 2**count0 

print(round(tmp))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, P = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A)
A = A % 2
A = list(A)
count0 = A.count(0)
count1 = A.count(1)

print(count0, count1, P)

if P == 0 and count1 % 2 == 0:
    tmp = 2**(count1-1) * 2**count0

elif P == 0 and count1 % 2 == 1:
    tmp = 2**(count1-1) * 2**count0

elif P == 1 and count1 % 2 == 0:
    tmp = 2**(count1-1) * 2**count0

elif P == 1 and count1 % 2 == 1:
    tmp = 2**(count1-1) * 2**count0 

print(round(tmp))

Submission status: Wrong Answer

Solution code:
import numpy as np
N, P = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(A)
A = A % 2
A = list(A)
count0 = A.count(0)
count1 = A.count(1)

#print(count0, count1, P)

if P == 0 and count1 % 2 == 0:
    tmp = 2**(count1-1) * 2**count0

elif P == 0 and count1 % 2 == 1:
    tmp = 2**(count1-1) * 2**count0

elif P == 1 and count1 % 2 == 0:
    tmp = 2**(count1-1) * 2**count0

elif P == 1 and count1 % 2 == 1:
    tmp = 2**(count1-1) * 2**count0 - 1

print(round(tmp))

Submission status: Wrong Answer

Solution code:
# AGC017A - Biscuits
def main():
    n, p = tuple(map(int, input().rstrip().split()))
    A = tuple(map(lambda x: int(x) % 2, input().rstrip().split()))
    if sum(A) == n:  # all numbers are even
        print(2 ** n if p == 0 else 0)
    else:
        print(2 ** (n - 1))


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
N,P=map(int,input().split())
A=list(map(int,input().split()))
tab=[[0]*2 for _ in range(N)]
tab[0][0]=1
tab[0][A[0]%2]+=1
for i in range(1,N):
    tab[i][0] = tab[i-1][0]+tab[i-1][1]
    tab[i][1] = tab[i-1][0]+tab[i-1][1]
print(tab[N-1][P])

Submission status: Wrong Answer

Solution code:
a, b = map(int, input().split())
c = list(map(int, input().split()))
e_odd = False
for i in c:
    if i % 2 == 1:
        e_odd = not e_odd
        break
if not e_odd:
    if b == 1:
        print(0)

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split()) # 横に2個
A = [0 if a % 2 == 0 else 1 for a in list(map(int, input().split()))]
odd = A.count(1)
even = A.count(0)

if (P == 1 and odd == 0 ):
    ans = 0
else:
    ans = 2**(len(A)) // 2

print(ans)

Submission status: Wrong Answer

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

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

if P == 1 and o >= 1:
    print(int((2**e)*(2**(o-1))))
elif P == 1 and o == 0:
    print(0)
else:
    print(int(2**N-((2**e)*(2**(o-1)))))

Submission status: Wrong Answer

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

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

if P == 1 and odd >= 1:
    print((2**even)*(2**(odd-1)))
elif P == 1 and odd == 0:
    print(0)
else:
    print(2**N-((2**even)*(2**(odd-1))))

Submission status: Wrong Answer

Solution code:
import math

n, p = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]

o_cnt = 0
e_cnt = 0

for i in range(n):
    if a[i] % 2 == 1:
        o_cnt += 1
    else:
        e_cnt += 1

ans = 0
for i in range(o_cnt//2):
    if o_cnt == 0:
        if p == 0:
            print(2**e_cnt)
            break
        else:
            print(0)
            break
    else:
        ans += (math.factorial(o_cnt)//(math.factorial(i*2+p)*math.factorial(o_cnt-i*2-p)))*2**e_cnt
        if i == o_cnt//2-1:
            if p == 0:
                ans += (math.factorial(o_cnt)//(math.factorial((i+1)*2+p)*math.factorial(o_cnt-(i+1)*2-p)))*2**e_cnt
            print(ans)

Submission status: Wrong Answer

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

for i in range(n):
    A[i]%=2
one=A.count(1)
if one==n and p==0:
    print(2**n)
elif one==n and p==1:
    print(0)
else:
    print(2**(n-1))

Submission status: Wrong Answer

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

for i in range(n):
    A[i]%=2
one=A.count(1)
if one==n:
    print(2**n)
else:
    print(2**(n-1))

Submission status: Wrong Answer

Solution code:

n, p = [ int(v) for v in input().split() ]
num_list = sorted([ int(v) % 2 for v in input().split() ])
a = num_list.count(1)
b = num_list.count(0)
if a == 0 and p == 1:
    print(0)
else:
    print((2**b)*(2**(a-1)))

Submission status: Wrong Answer

Solution code:



n, p = [ int(v) for v in input().split() ]
num_list = sorted([ int(v) % 2 for v in input().split() ])
a = num_list.count(1)
b = num_list.count(0)
print((2**b)*(2**(a-1)))

Submission status: Wrong Answer

Solution code:


n, p = [ int(v) for v in input().split() ]
num_list = sorted([ int(v) % 2 for v in input().split() ])
a = num_list.count(1)
b = num_list.count(0)
print(a,b)
print((2**b)*(2**(a-1)))

Submission status: Wrong Answer

Solution code:

n, p = [ int(v) for v in input().split() ]
num_list = sorted([ int(v) % 2 for v in input().split() ])
a = num_list.count(1)
b = num_list.count(0)
print((2**a)*(2**(b-1)))

Submission status: Wrong Answer

Solution code:
def solve(n, p, a):
    return 2**(n-1)

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

Submission status: Wrong Answer

Solution code:
N,P = map(int,input().split())
A = [int(x) for x in input().split()]

odd = sum(x&1 for x in A)

if odd:
  # どちらも半分ずつ
  answer = 2**(N-1)
else:
  answer = (2 ** N) * P

print(answer)

Submission status: Wrong Answer

Solution code:
from sys import stdin
from scipy.misc import comb
import numpy as np
N,P = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
even = 0
odd  = 0
for i in data:
    if i % 2 == 0:
        even += 1
    else:
        odd  += 1
ans = 0
print(even,odd)
if P == 0:
    for j in range(0,odd+1,2):
        ans += (comb(odd,j,exact=True) * 2 ** even)
else:
    for j in range(1,odd+1,2):
        ans += (comb(odd,j,exact=True) * 2 ** even)

print(int(round(ans)))

Submission status: Wrong Answer

Solution code:
from sys import stdin
from scipy.misc import comb
import numpy as np
N,P = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
even = 0
odd  = 0
for i in data:
    if i % 2 == 0:
        even += 1
    else:
        odd  += 1
ans = 0
print(even,odd)
if P == 0:
    for j in range(0,odd+1,2):
        ans += (comb(odd,j,exact=True) * 2 ** even)
else:
    for j in range(1,odd+1,2):
        ans += (comb(odd,j,exact=True) * 2 ** even)

print(int(ans))

Submission status: Wrong Answer

Solution code:
from sys import stdin
from scipy.misc import comb
import numpy as np
N,P = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
even = 0
odd  = 0
for i in data:
    if i % 2 == 0:
        even += 1
    else:
        odd  += 1
ans = 0

if P == 0:
    for j in range(0,odd+1,2):
        ans += (comb(odd,j) * 2 ** even)
else:
    for j in range(1,odd+1,2):
        ans += (comb(odd,j) * 2 ** even)

print(int(round(ans)))

Submission status: Wrong Answer

Solution code:
from sys import stdin
from scipy.misc import comb
import numpy as np
N,P = [int(x) for x in stdin.readline().rstrip().split()]
data = [int(x) for x in stdin.readline().rstrip().split()]
even = 0
odd  = 0
for i in data:
    if i % 2 == 0:
        even += 1
    else:
        odd  += 1
ans = 0

if P == 0:
    for j in range(0,odd,2):
        ans += (comb(odd,j) * 2 ** even)
else:
    for j in range(1,odd,2):
        ans += (comb(odd,j) * 2 ** even)

print(int(round(ans)))

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
N, K = list(map(int, input().split()))
A = list(map(int, input().split()))
odd = len([a for a in A if a %2 == 1])

if K == 0 and odd == 0:
  print(2**N)
elif K == 1 and odd == N:
  print(0)
else:
  print(2**(N-1))

Submission status: Wrong Answer

Solution code:
N, P = map(int, input().split())
As = list(map(int, input().split()))
even = 0
odd = 0
for a in As:
    if a % 2 == 0:
        even += 1
    else:
        odd += 1
print(even)
print(odd)
E = 2**even
if P == 0:
    O = 1
    o = 1
    for i in range(2, odd+1, 2):
        o = int(o*(odd+1-i)*(odd+2-i)/i/(i-1))
        O += o
else:
    O = odd
    o = odd
    for i in range(3, odd+1, 2):
        o = int(o*(odd+1-i)*(odd+2-i)/i/(i-1))
        O += o
print(E*O)

Submission status: Wrong Answer

Solution code:
def nCr(n, r):
    ret = 1
    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

n, p = map(int, input().split())
a = map(int, input().split())
even, odd = 0, 0

for i in a:
  if i & 1:
    odd += 1
  else:
    even += 1

c_even = 2**even
c_odd = 0

start = 1 if p else 0

while start <= odd:
    c_odd += nCr(odd, start)
    start += 2
print(c_even, c_odd)
print(c_even * c_odd)

Submission status: Wrong Answer

Solution code:
n,p=map(int,input().split())
a=[int(i)%2 for i in input().split()]
g=a.count(0)
k=len(a)-g
if p==1 and k==0:
    ans=0
else:
    ans=(2**g)*(2**k)//2
print(ans)

Submission status: Wrong Answer

Solution code:
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 = [(int(i) % 2) for i in input().split()]
e_num = a.count(0)
o_num = a.count(1)
all_pattern = 2 ** n
o_pattern = 2 ** (e_num)
if o_num >= 2:
    for i in range(2, o_num + 1, 2):
        o_pattern += combinations_count(o_num, i)
e_pattern = all_pattern - o_pattern
if p == 1:
    print(e_pattern)
else:
    print(o_pattern)

Submission status: Wrong Answer

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

if n == 1:
    ans = int(a[0] % 2 == p)
else:
    ans = 2 ** ((n - 1) + int(a[0] % 2 == 0))

print(ans)

Submission status: Wrong Answer

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

e = sum(x % 2 == 0 for x in a)
o = sum(x % 2 == 1 for x in a)

if n == 1:
    ans = int(a[0] % 2 == p)
else:
    ans = max((2 ** o) // 2, 1) * 2 ** e

print(ans)

Submission status: Wrong Answer

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

e = sum(x % 2 == 0 for x in a)
o = sum(x % 2 == 1 for x in a)

if n == 1:
    ans = int(a[0] % 2 == p)
else:
    ans = (2 ** o) // 2 * 2 ** e

print(ans)

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**(n-1))

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*(n-1))