TnT/Multi_CodeNet4Repair huggingface dataset:
Problem: 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?

Submission attempts (in order):
N,P=map(int,input().split())
A=list(map(int,input().split()))
for i in range(N):
    A[i]%=2

odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans+=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)

odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans*=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)


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

odds=sum(A)
evens=N-odds 
if odds>0:
    ans=2**evens 
    ans*=2**(odds-1)
    print(ans)
else:
    if P==0:
        print(2**evens)
    else:
        print(0)

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re

# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb


N,P = map(int,input().split())
# arrA = list(map(int,input().split()))
arrA = np.array(input().split(),dtype=np.int64)

A = arrA % 2
if not 1 in A:
    if P == 1:
        print(0)
even = 1
odd = 1
for i in A:
    if i == 0:
        even *= 2
        odd *= 2
    else:
        even = odd + even
        odd = even + odd
if P==0:
    print(even)
else:
    print(odd)

# for row in board:

# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


# from math import factorial,sqrt,ceil,gcd
# from itertools import permutations as permus
# from collections import deque,Counter
# import re

# from decimal import Decimal, getcontext

# # eps = Decimal(10) ** (-100)

import numpy as np
# import networkx as nx
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix
# from scipy.special import comb


N,P = map(int,input().split())
# arrA = list(map(int,input().split()))
arrA = np.array(input().split(),dtype=np.int64)

A = arrA % 2
if not (1 in A):
    if P == 1:
        print(0)
        exit()
    else:
        print(2**N)
        exit()

even = 1
odd = 1
for i in sorted(A)[::-1][1:]:
    if i == 0:
        even *= 2
        odd *= 2
    else:
        even,odd = odd + even , odd + even
if P==0:
    print(even)
else:
    print(odd)

# for row in board:

# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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))

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))

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

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

Verdicts: Wrong Answer

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import scipy.misc as scm


N, P = map(int, input().split())
A = [int(s) % 2 == 0 for s in input().split()]

evens = len(list(filter(lambda x: x == True, A)))
odds = len(A) - evens

if P == 0:
    evens_x = pow(2, evens)
    odds_x = 0
 
    for i in range(0, odds + 1, 2):
        odds_x += scm.comb(odds, i)
    
else:
    evens_x = pow(2, evens)
    odds_x = 0

    for i in range(1, odds + 1, 2):
        odds_x += scm.comb(odds, i)
    
print(int(evens_x * odds_x))


import itertools
import scipy.misc as scm
import sys

N, P = map(int, input().split())
A = [int(s) % 2 == 0 for s in input().split()]

evens = len(list(filter(lambda x: x == True, A)))
odds = len(A) - evens

if P == 0:
    evens_x = int(pow(2, evens))
    odds_x = 0
    
    for i in range(0, odds + 1, 2):
        odds_x += int(scm.comb(odds, i))

    print(evens_x * odds_x)
    
else:
    evens_x = int(pow(2, evens))
    odds_x = 0

    for i in range(1, odds + 1, 2):
        odds_x += int(scm.comb(odds, i))

    print(evens_x * odds_x)
    

_, P = map(int, input().split())
A = [int(s) % 2 == 0 for s in input().split()]

evens = len(list(filter(lambda x: x == True, A)))
odds = len(A) - evens

evens_x = pow(2, evens)

if odds == 0 and P == 0:
    print(int(evens_x))
elif odds == 0 and P == 1:
    print(0)
else:
    odds_x = pow(2, odds - 1)
    print(int(evens_x * odds_x))


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
n,p = [int(i) for i in input().split()]

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

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

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

l = [int(i) for i in input().split()]

l2 = [i for i in l if i %2 == 1]

if not l2 :
    print(2**a if b % 2 == 0 else 0)
else:
    print(2**(a-1))

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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:
  if odd:
    for i in range(tmp):
      ans_tmp += cmb(odd,i*2+1)
else:
  print(odd)
  if odd:
    tmp += 1
    for i in range(tmp):
      ans_tmp += cmb(odd,(i*2))

ans *= ans_tmp
print(ans)

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:
  if odd:
    for i in range(tmp):
      ans_tmp += cmb(odd,i*2+1)
else:
  if odd:
    tmp += 1
    for i in range(tmp):
      ans_tmp += cmb(odd,(i*2))
  else:
    ans_tmp = 1

ans *= ans_tmp
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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?

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import scipy.misc
n,p = map(int,input().split())
ai = [int(i)%2 for i in input().split()]

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


tmp = 2**zero
ans = 0
for i in range(one//2+1):
    if p == 0:
        if i*2 > one:
            break
        ans += scipy.misc.comb(one,0+i*2)
    else:
        if i*2+1 > one:
            break
        ans += scipy.misc.comb(one,1+i*2)
print(int(ans*tmp))

n,p = map(int,input().split())
ai = [int(i)%2 for i in input().split()]

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



# import sys

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)]

tmp = 2**zero
ans = 0
for i in range(one//2+1):
    if p == 0:
        if i*2 > one:
            break
        ans += cmb(one,0+i*2)
    else:
        if i*2+1 > one:
            break
        ans += cmb(one,1+i*2)
print(int(ans*tmp))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
from math import factorial
n,p = map(int, input().split())
A = list(map(int, input().split()))

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

even = 0
not_even = 0
for a in A:
    if a % 2 == 0: even += 1
    else: not_even += 1
print(even, not_even)
ans = 0
if p == 0:
    
    if even != 0: a = factorial(even)
    else: a = 0
    
    b = 0 
    n = 2
    while n <= not_even:
        b += combinations_count(not_even, n)
        n += 2
    print(a + b + a * b + 1)
else:
    
    if not_even != 0: a = factorial(not_even)
    else: a = 0
    
    b = 0
    n = 3
    while n <= even:
        b += combinations_count(even, n)
        n += 2
    print(a + b + a * b)

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import math
a,b = map(int,input().split())
L = list(map(int,input().split()))
Le = [x for x in L if x%2 == 0]
Lo = [x for x in L if x%2 == 1]
#print(Le,Lo)
def nCr(n,r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))
    
if b == 0:
    ev = 0
    od = 1
    while ev <= len(Le)//2:
        ev += nCr(len(Le),ev)
        ev += 2
    while od <= len(Lo)+1:
        od += nCr(len(Lo),od)
        od += 2
elif b == 1:
    ev = 0
    od = 0
    while ev <= len(Le)//2:
        ev += nCr(len(Le),ev)
        ev += 2
    while od <= len(Lo)+1:
        od += nCr(len(Lo),od)
        od += 2
print(ev*od)

n,p = map(int,input().split())
L = list(map(int,input().split()))
Le = [x for x in L if x%2 == 0]
Lo = [x for x in L if x%2 == 1]

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

Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
import math
N, P = map(int, input().split())
A = list(map(int, input().split()))
even = 0
odd = 0
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

oddcmb = 0
if P == 0:
    for i in range(odd)[::2]:
        # print(i)
        oddcmb += comb(odd, i)
    ans = 2**even*oddcmb
    
else:
    for i in range(1, odd)[::2]:
        # print(i)
        oddcmb += comb(odd, i)
    ans = 2**even*oddcmb

print(ans)

import math
N, P = map(int, input().split())
A = list(map(int, input().split()))
even = 0
odd = 0
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

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

oddcmb = 0
if P == 0:
    for i in range(odd+1)[::2]:
        # print(i)
        oddcmb += comb(odd, i)
    ans = 2**even*oddcmb
    
else:
    for i in range(1, odd+1)[::2]:
        # print(i)
        oddcmb += comb(odd, i)
    ans = 2**even*oddcmb

print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
from scipy.special import comb
import numpy as np

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

A = A % 2 != 0
odd = np.sum(A)
even = N - odd
print(A, odd, even)

ans = 0
odd_num = 0
even_num = 0
if P == 1:
    for i in range(1, odd + 1, 2):
        odd_num += comb(odd, i, exact=True)
    even_num = pow(2, even)
    ans = odd_num * even_num
else:
    for i in range(0, odd + 1, 2):
        odd_num += comb(odd, i, exact=True)
    even_num = pow(2, even)
    ans = odd_num * even_num
    # print(odd_num, even_num)
print(ans)


from scipy.special import comb
import numpy as np

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

A = A % 2 != 0
odd = np.sum(A)
even = N - odd


ans = 0
odd_num = 0
even_num = 0
if P == 1:
    for i in range(1, odd + 1, 2):
        odd_num += comb(odd, i, exact=True)
    even_num = pow(2, even)
    ans = odd_num * even_num
else:
    for i in range(0, odd + 1, 2):
        odd_num += comb(odd, i, exact=True)
    even_num = pow(2, even)
    ans = odd_num * even_num
    # print(odd_num, even_num)
print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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 == 1:
    return(j)
  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)

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)

Verdicts: Runtime Error

Accepted
Problem: 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?

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

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import sys


def input():
    return sys.stdin.readline().strip()


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

odd = sum([a % 2 for a in A])
even = len(A) - odd

ans = (2 ** even) * (2 ** (odd - 1))



import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N, P = map(int, input().split())
    A = [0] + list(map(int, input().split()))
    dp_odd = [0 for _ in range(N + 1)]
    dp_even = [0 for _ in range(N + 1)]
    dp_even[0] = 1

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

    if P == 0:
        print(dp_even[-1])
    else:
        print(dp_odd[-1])


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
N,P = map(int, input().split())
A = list(map(int, input().split()))

even_num=0
odd_num=0

for a in A:
    if a%2==0:
        even_num+=1
    else:
        odd_num+=1

ev_case = 2**even_num


from math import factorial

res=0
for i in range(P,odd_num+1,2):                                                                   res += factorial(odd_num) / factorial(i) / factorial(odd_num - i)

print(ev_case*res)

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

even_num=0
odd_num=0

for a in A:
    if a%2==0:
        even_num+=1
    else:
        odd_num+=1

ev_case = 2**even_num


from math import factorial

res=0
for i in range(P,odd_num+1,2):                                                                   res += factorial(odd_num) / factorial(i) / factorial(odd_num - i)

print(int(ev_case*res))

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
from math import factorial
def cmb(n,r):
    if n-r<0:
        return 0
    else:
        return factorial(n) // factorial(r) // factorial(n - r)
        

n,p,*a=map(int,open(0).read().split())

odd=sum(i%2 for i in a)
even=n-odd

print(odd,even)

x=sum(cmb(even,i)for i in range(even+1))
y=sum(cmb(odd,i)for i in range(p,odd+1,2))
print(x*y)


from math import factorial
def cmb(n,r):
    if n-r<0:
        return 0
    else:
        return factorial(n) // factorial(r) // factorial(n - r)
        

n,p,*a=map(int,open(0).read().split())

odd=sum(i%2 for i in a)
even=n-odd


x=sum(cmb(even,i)for i in range(even+1))
y=sum(cmb(odd,i)for i in range(p,odd+1,2))
print(x*y)



Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):

  
  import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


N, P = readnums()
A = map(lambda x: x % 2, readnums())

if not sum(A):
    print(0)
else:
    print(2 ** N // 2)


import sys
input = sys.stdin.readline


def readstr():
    return input().strip()


def readint():
    return int(input())


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


def readstrs():
    return input().split()


N, P = readnums()
A = map(lambda x: x % 2, readnums())

if P:
    if not sum(A):
        print(0)
    else:
        print(2 ** N // 2)
else:
    if not sum(A):
        print(2 ** N)
    else:
        print(2 ** N // 2)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd_bags = len([bag for bag in bags if (bag % 2 == 1]))

if congr_factor == 0 and odd == 0:
  print(2 ** num_bags)
elif congr_factor == 1 and odd == 0:
  print(0)
else:
  print(2 ** (num_bags-1))


num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd = len([a for a in bags if (a % 2 == 1]))

if congr_factor == 0 and odd == 0:
  print(2 ** num_bags)
elif congr_factor == 1 and odd == 0:
  print(0)
else:
  print(2 ** (num_bags-1))


num_bags, congr_factor = list(map(int, input().split()))
bags = list(map(int, input().split()))
odd_bags = len([bag for bag in bags if (bag % 2 == 1)])

if congr_factor == 0 and odd_bags == 0:
  print(2 ** num_bags)
elif congr_factor == 1 and odd_bags == 0:
  print(0)
else:
  print(2 ** (num_bags-1))


Verdicts: Runtime Error

Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
N,P = [int(i) for i in input().split()]
A = [int(i)%2 for i in input().split()]

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

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

print(A)


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

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

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

print(ans)


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):

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

m = sum(A) +1
dp = [0]*(m)

dp[0] = 2


v = 0

odd = 0
even = 1



for a in range(N):
    
    for j in range(2):
        n = A[a]*j
        v += n       
        
        if dp[v-n]%2 != n%2:
            dp[v] = 1
            odd += 1
        
        else:
            dp[v] = 2
            even += 1
if P == 0:
    print(even)
else:
    print(odd)


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


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


dp[0] = [1,0]

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

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,P=map(int,input().split())
A=list(map(int,input().split()))
odd=len([i for i in A if i%2==1])
even=len([i for i in A if i%2==0])

if P==0:
    ans=2**even
    ans_odd=1
    if odd!=0:
        for i in range(odd//2+1):
            ans_odd+=cmb(odd,2*i)
else:
    ans=2**even
    ans_odd=0
    if odd!=0:
        for i in range(odd//2):
            ans_odd+=cmb(odd,2*i+1)
print(ans*ans_odd)

from operator import mul
from functools import reduce

def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

N,P=map(int,input().split())
A=list(map(int,input().split()))
odd=len([i for i in A if i%2==1])
even=len([i for i in A if i%2==0])

if P==0:
    ans=2**even
    ans_odd=1
    if odd!=0:
        ans_odd=0
        for i in range(odd//2+1):
            ans_odd+=cmb(odd,2*i)
else:
    ans=2**even
    ans_odd=0
    if odd!=0:
        for i in range(odd//2):
            ans_odd+=cmb(odd,2*i+1)
print(ans*ans_odd)

Verdicts: Wrong Answer

Accepted
Problem: 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?

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

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

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

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)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
# -*- coding: utf-8 -*-

import sys
import os

input_text_path = __file__.replace('.py', '.txt')
fd = os.open(input_text_path, os.O_RDONLY)
os.dup2(fd, sys.stdin.fileno())

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

A_temp = list(map(int, input().split()))
A = []

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

zero_num = A.count(0)
one_num = A.count(1)

def Permutation(n, m):
    ret = 1
    for i in range(m):
        ret *= (n - i)
    return ret

def Combination(n, m):
    #import itertools
    #lst = [1] * n
    #c = list(itertools.combinations(lst, m))
    
    return Permutation(n, m) // Permutation(m, m)

combination_for_one = 0
if P == 0:
    for i in range(2, one_num + 1, 2):
        combination_for_one += Combination(one_num, i)
    combination_for_one += 1
else:
    for i in range(0, one_num, 2):
        combination_for_one += Combination(one_num, i)

ans = combination_for_one * (2 ** zero_num)

print(ans)

# -*- coding: utf-8 -*-

import sys
import os
import math

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

A_temp = list(map(int, input().split()))
A = []

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

zero_num = A.count(0)
one_num = A.count(1)

def Combination(n, m):
    #print(str(n) + "C" + str(m))
    f = math.factorial
    return f(n) // f(m) // f(n - m)

combination_for_one = 0
if P == 0:
    for i in range(0, one_num + 1, 2):
        combination_for_one += Combination(one_num, i)
else:
    for i in range(1, one_num, 2):
        combination_for_one += Combination(one_num, i)

ans = combination_for_one * (2 ** zero_num)
print(ans)


Verdicts: Runtime Error

Accepted
Problem: 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?

Submission attempts (in order):
# -*- coding: utf-8 -*-
import math

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

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

    print(e_count)
    print(o_count)

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

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

    print(total)


if __name__ == "__main__":
    main()


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

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

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

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

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

    print(total)


if __name__ == "__main__":
    main()


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):


n, p = map(int, input().split())
odds = n - len(list(filter(lambda x: int(x) % 2 == 0, input().split())))
evens = n - odds

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


ans = 0
if p == 0:
    for i in range(0, odds, 2):
        ans += ncr(odds, i)
    ans *= max(1, 2 ** evens)
else:
    for i in range(1, odds, 2):
        ans += ncr(odds, i)
    ans *= max(1, 2 ** evens)
print(ans)




n, p = map(int, input().split())
odds = n - len(list(filter(lambda x: int(x) % 2 == 0, input().split())))
evens = n - odds

print(evens, odds)


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


ans = 0
if p == 0:
    for i in range(0, odds, 2):
        ans += ncr(odds, i)
    ans *= max(1, 2 ** evens)
else:
    for i in range(1, odds, 2):
        ans += ncr(odds, i)
    ans *= max(1, 2 ** evens)
print(ans)




n, p = map(int, input().split())
odds = n - len(list(filter(lambda x: int(x) % 2 == 0, input().split())))
evens = n - odds


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


ans = 0
if p == 0:
    for i in range(0, odds, 2):
        ans += ncr(odds, i)
    if evens > 0:
        ans *= max(1, 2 ** evens)
else:
    for i in range(1, odds, 2):
        ans += ncr(odds, i)
    if evens > 0:
        ans *= max(1, 2 ** evens)
print(ans)






n, p = map(int, input().split())
odds = n - len(list(filter(lambda x: int(x) % 2 == 0, input().split())))
evens = n - odds


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


ans = 0
if p == 0:
    for i in range(0, odds + 1, 2):
        ans += ncr(odds, i)
    if evens > 0:
        ans *= max(1, 2 ** evens)
else:
    if odds > 0:
        for i in range(1, odds + 1, 2):
            ans += ncr(odds, i)
        ans *= max(1, 2 ** evens)
print(ans)


Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import scipy.misc
N,P=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
odd = 0
even = 0
for i in A:
    if i%2 !=0:
        odd += 1
    else:
        even += 1

ans = 0
if P ==1:
    for i in range(1,odd+1,2):
        ans += scipy.misc.comb(odd,i)
else:
    for i in range(0,odd+1,2):
        ans += scipy.misc.comb(odd,i)
ans = ans*(2**even)
print(ans)

import scipy.misc
N,P=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
odd = 0
even = 0
for i in A:
    if i%2 !=0:
        odd += 1
    else:
        even += 1

ans = 0
if P ==1:
    for i in range(1,odd+1,2):
        ans += scipy.misc.comb(odd,i)
else:
    for i in range(0,odd+1,2):
        ans += scipy.misc.comb(odd,i)
ans = ans*(2**even)
print(int(ans))

import scipy.misc
N,P=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
odd = 0
even = 0
for i in A:
    if i%2 !=0:
        odd += 1
    else:
        even += 1

ans = 0
if P ==1:
    for i in range(1,odd+1,2):
        ans += scipy.misc.comb(odd,i)
else:
    for i in range(0,odd+1,2):
        ans += scipy.misc.comb(odd,i)
ans = ans*(2**even)
print(int(-(-1*ans//1)))


N,P=map(int,input().split(' '))
A=list(map(int,input().split(' ')))
for i in A:
    if i%2 != 0:
        print(2**(N-1))
        exit()
if P ==0:
    print(2**N)
else:
    print(0)

Verdicts: Wrong Answer

Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
import math

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

n, p = map(int, input().split())
a_list = list(map(int, input().split()))
surplus0 = 0
surplus1 = 0
for i in a_list:
    if i % 2 == 0:
        surplus0 += 1
    else:
        surplus1 += 1

if p == 0:
    
    s0 = 0
    for i in range(surplus0+1):
        s0 = math.factorial(surplus0)
    
    s1 = 0
    if surplus1 == 0:
        s1 = 1
    elif surplus1 % 2 == 1:
        for i in range(surplus1//2 + 1):
            s1 += combination(surplus1, i*2)
    else:
        for i in range(surplus1//2):
            s1 += combination(surplus1, i*2)
    ans = s0 * s1
else:
    
    s0 = 0
    for i in range(surplus0+1):
        s0 += combination(surplus0, i)
    
    s1 = 0
    if surplus1 == 0:
        s1 = 0
    elif surplus1 % 2 == 1:
        for i in range(surplus1//2 + 1):
            s1 += combination(surplus1, i*2+1)
    else:
        for i in range(surplus1//2):
            s1 += combination(surplus1, i*2+1)
    ans = s0 * s1

print(int(ans))


import math

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

n, p = map(int, input().split())
a_list = list(map(int, input().split()))
surplus0 = 0
surplus1 = 0
for i in a_list:
    if i % 2 == 0:
        surplus0 += 1
    else:
        surplus1 += 1

if p == 0:
    
    s0 = 0
    for i in range(surplus0+1):
        s0 = math.factorial(surplus0)
    
    s1 = 0
    if surplus1 % 2 == 1:
        for i in range(surplus1//2 + 1):
            s1 += combination(surplus1, i*2)
    else:
        for i in range(surplus1//2):
            s1 += combination(surplus1, i*2)
    ans = s0 * s1
else:
    
    s0 = 0
    for i in range(surplus0+1):
        s0 += combination(surplus0, i)
    
    s1 = 0
    if surplus1 == 0:
        s1 = 0
    elif surplus1 % 2 == 1:
        for i in range(surplus1//2 + 1):
            s1 += combination(surplus1, i*2+1)
    else:
        for i in range(surplus1//2):
            s1 += combination(surplus1, i*2+1)
    ans = s0 * s1

print(int(ans))


def solve():
    N, P = list(map(int, input().split()))
    A = list(map(int, input().split()))
    if all([x % 2 == 0 for x in A]):
        if P == 0:
            print(2 ** N)
        else:
            print(0)
    else:
        print(2 ** (N-1))

solve()


Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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]%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]
        print(dp[i])
print(dp[N-1][P])

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]%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]
        print(dp[i])
print(dp[N-1][A[N-1]%2])

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])

Verdicts: Wrong Answer

Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
from math import factorial

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

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

o = 0
e = 0

for i in A:
    if i % 2 == 0:
        e += 1
    else:
        o += 1
on = o // 2

a = []
b = []
ans = 0

if P == 0:
    for i in range(e+1):
        a.append(c(e,i))
    for i in range(on+1):
        b.append(c(o,i*2))        
    for i in a:
        for j in b:
            ans += i * j
else:
    for i in range(e+1):
        a.append(c(e,i))
    for i in range(1,o+1)[::2]:
        b.append(c(o,i))        
    for i in a:
        for j in b:
            ans += i * j
        
print(ans)

from math import factorial

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

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

o = 0
e = 0

for i in A:
    if i % 2 == 0:
        e += 1
    else:
        o += 1
on = o // 2

a = []
b = []
ans = 0

if P == 0:
    for i in range(e+1):
        a.append(c(e,i))
    for i in range(on+1):
        b.append(c(o,i*2))        
    for i in a:
        for j in b:
            ans += i * j
else:
    for i in range(e+1):
        a.append(c(e,i))
    for i in range(1,o+1)[::2]:
        b.append(c(o,i))        
    for i in a:
        for j in b:
            ans += i * j

ans = int(ans)
print(ans)

Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
from math import factorial

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



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

odd_len = 0
even_len = 0
for i in range(n):
    if a_input[i]%2==0:
        even_len+=1
    else:
        odd_len+=1

ans=0
even_comb = 2**even_len
if p==0:
    if odd_len%2==0:
        for i in range(0,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
            print(i)
    if odd_len%2==1:
        for i in range(1,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
else:
    if odd_len%2==0:
        for i in range(1,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
    if odd_len%2==1:
        for i in range(0,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
print(int(ans))


from math import factorial

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



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

odd_len = 0
even_len = 0
for i in range(n):
    if a_input[i]%2==0:
        even_len+=1
    else:
        odd_len+=1

ans=0
even_comb = 2**even_len
if p==0:
    if odd_len%2==0:
        for i in range(0,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
    if odd_len%2==1:
        for i in range(1,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
else:
    if odd_len%2==0:
        for i in range(1,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
    if odd_len%2==1:
        for i in range(0,odd_len+1,2):
            ans+=calc_comb(odd_len,i)*even_comb
print(int(ans))


Verdicts: Wrong Answer

Accepted
Problem: 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?

Submission attempts (in order):
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)

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


Verdicts: Wrong Answer

Accepted