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 in C++14 (GCC 5.4.1) (judge verdict: Wrong Answer)

#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}

#define MOD		(1000000000 + 7)	// 10^9 + 7
#define T(n)	((n) % (MOD))		// mod 10^9 + 7
#define N_MAX	(100000 + 100)		// 10^5 + α;
uint32 nCr(uint32 n, uint32 r)
{
	static bool initFlg = false;
	static uint32 *factArray;
	static uint32 *factInverseArray;
	if(!initFlg){
		factArray = (uint32 *)calloc(N_MAX, sizeof(uint32));
		factInverseArray = (uint32 *)calloc(N_MAX, sizeof(uint32));
		factArray[0] = 1;
		factInverseArray[0] = 1;
		for(uint64 i=1; i<N_MAX; i++){
			factArray[i] = T(factArray[i-1] * i);

			// 逆元を求める
			uint64 x = factArray[i];
			uint32 n = MOD - 2;
			uint32 ans = 1;
			while(n>0){
				if((n&1) == 1){ ans = T(ans * x); }
				x = T(x*x);
				n >>= 1;
			}
			factInverseArray[i] = ans;
		}
		initFlg = true;
	}

	uint32 ans = T((uint64)factArray[n] * factInverseArray[r]);
	ans  = T((uint64)ans * factInverseArray[n-r]);
	return ans;
}

void func(void)
{
	uint32 n, p;
	cin >> n >> p;
	
	uint32 v0 = 0;
	uint32 v1 = 0;
	for(uint32 i=0; i<n; i++){
		uint32 a;
		cin >> a;
		if(a%2==0){ v0++; }
		else{ v1++; }
	}

	uint64 patn1 = (p==0) ? 1 : 0;
	for(uint32 r = (p==0) ? 2 : 1; r<=v1; r+=2){
		patn1 += nCr(v1, r);
	}
	if(patn1==0 && p==0){ patn1 = 1; }

	uint64 patn2 = 0;
	for(uint32 r=0; r<=v0; r++){
		patn2 += nCr(v0, r);
	}
	if(patn2==0){ patn2 = 1; }

	uint64 ans = patn1 * patn2;

	cout << ans << endl;

	return;
}