stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long int LL;

typedef long double LD;



const int MOD = 1e9 + 7;

const int MAXS = 1 << 17;



int main() {

	int N, X, Y, Z;

	cin >> N >> X >> Y >> Z;



	int xyz = (1 << (X + Y + Z - 1)) | (1 << (Y + Z - 1)) | (1 << (Z - 1));

	int mask = (1 << (X + Y + Z)) -1;



	int dp[2][MAXS];

	int idx = 0, _idx;

	dp[idx][0] = 1;

	for (int k = 0; k < N; ++k) {

		_idx = idx;

		idx ^= 1;

		memset(dp[idx], 0, sizeof(dp[idx]));

		for (int i = 0; i <= mask; ++i) {

			if (dp[_idx][i] > 0) {

				for (int j = 1; j <= 10; j++) {

					int _i = ((i << j) | (1 << (j-1))) & mask;

					if ((_i&xyz) != xyz) (dp[idx][_i] += dp[_idx][i]) %= MOD;

				}

			}

		}

	}

	long res = 1;

	for (int i = 0; i < N; ++i) (res *= 10) %= MOD;

	for (int i = 0; i <= mask; ++i) (res -= dp[idx][i]) %= MOD;



	cout << (res + MOD) % MOD << endl;



	return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long int LL;

typedef long double LD;



const int MOD = 1e9 + 7;

const int MAXS = 1 << 16;



int main() {

	int N, X, Y, Z;

	cin >> N >> X >> Y >> Z;



	int xyz = (1 << (X + Y + Z - 1)) | (1 << (Y + Z - 1)) | (1 << (Z - 1));

	int mask = (1 << (X + Y + Z)) - 1;

	int mask2 = mask >> 1;



	int dp[2][MAXS];

	int idx = 0, _idx;

	dp[idx][0] = 1;

	for (int k = 0; k < N; ++k) {

		_idx = idx;

		idx ^= 1;

		memset(dp[idx], 0, sizeof(dp[idx]));

		for (int i = 0; i <= mask2; ++i) {

			if (dp[_idx][i] > 0) {

				for (int j = 1; j <= 10; j++) {

					int _i = ((i << j) | (1 << (j-1))) & mask;

					if ((_i&xyz) != xyz) (dp[idx][_i&mask2] += dp[_idx][i]) %= MOD;

				}

			}

		}

	}

	long res = 1;

	for (int i = 0; i < N; ++i) (res *= 10) %= MOD;

	for (int i = 0; i <= mask2; ++i) (res -= dp[idx][i]) %= MOD;



	cout << (res + MOD) % MOD << endl;



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <cstdio>

#include <cstring>

#include <algorithm>

using namespace std;

const int mod=1e9+7;

const int maxn=45;

typedef long long LL;

LL dp[maxn][1<<18];

int n,x,y,z;

int main() {

    scanf("%d%d%d%d",&n,&x,&y,&z);

    int tmp=x+y+z-1;

    LL mask=(1<<tmp)-1;

    LL limit=1<<tmp;

    LL no=(1<<(x+y+z-1)) | (1<<(y+z-1)) | (1<<(z-1));

    dp[0][0]=1;

    for (int i=0;i<n;i++) {

        for (int j=0;j<limit;j++) {

            for (int k=1;k<=10;k++) {

                LL t=(j<<k) | (1<<(k-1));

                if ((no&t)==no) continue;

                dp[i+1][t&mask]=(dp[i+1][t&mask]+dp[i][j])%mod;

            }

        }

    }

    LL ans=1;

    for (int i=1;i<=n;i++) ans=ans*10%mod;

    for (int i=0;i<limit;i++) ans-=dp[n][i];

    printf("%lld\n", (ans%mod+mod)%mod);

    return 0;

}


// Optimized solution to the same problem (faster):
#include <cstdio>



const int mod = 1e9 + 7;

const int MAXN = 45, MAXS = ( 1 << 17 ) + 5;



template<typename _T>

void read( _T &x )

{

	x = 0;char s = getchar();int f = 1;

	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}

	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}

	x *= f;

}



template<typename _T>

void write( _T x )

{

	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }

	if( 9 < x ){ write( x / 10 ); }

	putchar( x % 10 + '0' );

}



int f[MAXN][MAXS];

int N, X, Y, Z, st, all;



int bit( const int i ) { return 1 << i - 1; }

bool chk( const int S ) { return ( S & st ) == st; }

void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }

int insert( const int S, const int v ) { return ( S << v | bit( v ) ) & all; }



int main()

{

	read( N ), read( X ), read( Y ), read( Z );

	int up = 1 << X + Y + Z;

	all = ( bit( X + Y + Z ) << 1 ) - 1;

	st = bit( Z ) | bit( Y + Z ) | bit( X + Y + Z );

	

	f[0][0] = 1;

	for( int i = 0 ; i < N ; i ++ )

		for( int S = 0 ; S < up ; S ++ )

			if( f[i][S] && ! chk( S ) )

				for( int k = 1, T ; k <= 10 ; k ++ )

					if( ! chk( T = insert( S, k ) ) )

						add( f[i + 1][T], f[i][S] );

	int ans = 1;

	for( int i = 1 ; i <= N ; i ++ )

		ans = 10ll * ans % mod;

	for( int S = 0 ; S < up ; S ++ )

		if( ! chk( S ) )

			add( ans, mod - f[N][S] );

	write( ans ), putchar( '\n' );

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream> 

#include <cstdio> 

#include <cstdlib> 

#include <cstring> 

#include <cmath> 

#include <algorithm> 

using namespace std; 

const int Mod = 1e9 + 7; 

int N, M, X, Y, Z, f[41][1 << 18]; 

int OK, ALL; 

void pls(int &x, int y) { x += y; if (x >= Mod) x -= Mod; } 

int main () { 

	cin >> N >> X >> Y >> Z; 

	M = X + Y + Z; 

	OK = (1 << (X + Y + Z - 1)) | (1 << (Y + Z - 1)) | (1 << (Z - 1)); 

	ALL = (1 << M) - 1; 

	f[0][0] = 1; 

	for (int i = 1; i <= N; i++) { 

		for (int s = 0; s < 1 << M; s++) { 

			for (int j = 1; j < 11; j++) { 

				int t = ((s << j) | (1 << (j - 1))) & ALL; 

				if ((t & OK) == OK) continue; 

				pls(f[i][t], f[i - 1][s]); 

			} 

		} 

	} 

	int ans = 1; 

	for (int i = 1; i <= N; i++) ans = 10ll * ans % Mod; 

	for (int i = 0; i < 1 << M; i++) ans = (ans - f[N][i] + Mod) % Mod; 

	printf("%d\n", ans); 

    return 0; 

} 

// Optimized solution to the same problem (faster):
#include <cstdio>



const int mod = 1e9 + 7;

const int MAXN = 45, MAXS = ( 1 << 17 ) + 5;



template<typename _T>

void read( _T &x )

{

	x = 0;char s = getchar();int f = 1;

	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}

	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}

	x *= f;

}



template<typename _T>

void write( _T x )

{

	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }

	if( 9 < x ){ write( x / 10 ); }

	putchar( x % 10 + '0' );

}



int f[MAXN][MAXS];

int N, X, Y, Z, st, all;



int bit( const int i ) { return 1 << i - 1; }

bool chk( const int S ) { return ( S & st ) == st; }

void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }

int insert( const int S, const int v ) { return ( S << v | bit( v ) ) & all; }



int main()

{

	read( N ), read( X ), read( Y ), read( Z );

	int up = 1 << X + Y + Z;

	all = ( bit( X + Y + Z ) << 1 ) - 1;

	st = bit( Z ) | bit( Y + Z ) | bit( X + Y + Z );

	

	f[0][0] = 1;

	for( int i = 0 ; i < N ; i ++ )

		for( int S = 0 ; S < up ; S ++ )

			if( f[i][S] && ! chk( S ) )

				for( int k = 1, T ; k <= 10 ; k ++ )

					if( ! chk( T = insert( S, k ) ) )

						add( f[i + 1][T], f[i][S] );

	int ans = 1;

	for( int i = 1 ; i <= N ; i ++ )

		ans = 10ll * ans % mod;

	for( int S = 0 ; S < up ; S ++ )

		if( ! chk( S ) )

			add( ans, mod - f[N][S] );

	write( ans ), putchar( '\n' );

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <algorithm>

#include <climits>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <iostream>

#include <map>

#include <queue>

#include <set>

#include <stack>



#define MP std::make_pair

#define rep(i, l, r) for (int i = (l); i <= (r); ++ i)

#define per(i, r, l) for (int i = (r); i >= (l); -- i)

#define PE(x, a) for (int x = head[a]; x;x = edge[x].next)

#define pb push_back

#define CL(a, b) memset(a, b, sizeof a)

#define PII std::pair<int, int>

#define fi first

#define se second

#define all(x) (x).begin(), (x).end()



typedef long long ll;



const ll HA = 1e9 + 7;



ll f[45][(1 << 17) + 7];

int n, x, y, z;



int main() {

	scanf("%d %d %d %d", &n, &x, &y, &z);

	int st = (1 << (z - 1)) | (1 << (z + y - 1)) | (1 << (z + y + x - 1));

	int lim = (1 << (x + y + z)) - 1;

	f[0][0] = 1;

	rep(i, 1, n) {

		rep(s, 0, lim) {

			if ((s & st) != st && f[i - 1][s])

			rep(c, 1, 10) {

				f[i][lim & ((s << c) | (1 << c - 1))] = (f[i][lim & ((s << c) | (1 << c - 1))] + f[i - 1][s]) % HA;

			}

		}

	}

	ll ans  = 0;

	rep(i, 0, lim) if ((i & st) != st) ans = (ans + f[n][i]) % HA;

	ll tmp = 1;

	rep(i, 1, n) tmp = tmp * 10 % HA;

	ans = (tmp - ans + HA) % HA;

	printf("%lld\n", ans);

	return 0;

}

// Optimized solution to the same problem (faster):
#include <cstdio>



const int mod = 1e9 + 7;

const int MAXN = 45, MAXS = ( 1 << 17 ) + 5;



template<typename _T>

void read( _T &x )

{

	x = 0;char s = getchar();int f = 1;

	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}

	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}

	x *= f;

}



template<typename _T>

void write( _T x )

{

	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }

	if( 9 < x ){ write( x / 10 ); }

	putchar( x % 10 + '0' );

}



int f[MAXN][MAXS];

int N, X, Y, Z, st, all;



int bit( const int i ) { return 1 << i - 1; }

bool chk( const int S ) { return ( S & st ) == st; }

void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }

int insert( const int S, const int v ) { return ( S << v | bit( v ) ) & all; }



int main()

{

	read( N ), read( X ), read( Y ), read( Z );

	int up = 1 << X + Y + Z;

	all = ( bit( X + Y + Z ) << 1 ) - 1;

	st = bit( Z ) | bit( Y + Z ) | bit( X + Y + Z );

	

	f[0][0] = 1;

	for( int i = 0 ; i < N ; i ++ )

		for( int S = 0 ; S < up ; S ++ )

			if( f[i][S] && ! chk( S ) )

				for( int k = 1, T ; k <= 10 ; k ++ )

					if( ! chk( T = insert( S, k ) ) )

						add( f[i + 1][T], f[i][S] );

	int ans = 1;

	for( int i = 1 ; i <= N ; i ++ )

		ans = 10ll * ans % mod;

	for( int S = 0 ; S < up ; S ++ )

		if( ! chk( S ) )

			add( ans, mod - f[N][S] );

	write( ans ), putchar( '\n' );

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define mo 1000000007

int i,j,k,m,n,x,y,z,S,Ans,ans,dp[41][1<<17];

inline ll Pow(ll x,ll d) {

    ll ans = 1, y = x;

    for (; d; y = y * y % mo, d >>= 1)d & 1 ? ans = ans * y % mo : 0;

    return ans;

}

int main() {

    cin >> n >> x >> y >> z;

    S = (1 << x + y + z) - 1;

    ans = (1 << x - 1) | (1 << x + y - 1) | (1 << x + y + z - 1);

    dp[0][0] = 1;

    for (i = 1; i <= n; ++i)

        for (j = 0; j <= S; ++j)

            if (dp[i - 1][j])

                for (k = 1; k <= 10; ++k) {

                    int o = ((j << k) | (1 << k - 1)) & S;

                    if ((o & ans) == ans)(Ans += 1ll * dp[i - 1][j] * Pow(10, n - i) % mo) %= mo;

                    else (dp[i][o] += (dp[i - 1][j]) % mo) %= mo;

                }

    printf("%d\n", Ans);

}

// Optimized solution to the same problem (faster):
#include <cstdio>



const int mod = 1e9 + 7;

const int MAXN = 45, MAXS = ( 1 << 17 ) + 5;



template<typename _T>

void read( _T &x )

{

	x = 0;char s = getchar();int f = 1;

	while( s > '9' || s < '0' ){if( s == '-' ) f = -1; s = getchar();}

	while( s >= '0' && s <= '9' ){x = ( x << 3 ) + ( x << 1 ) + ( s - '0' ), s = getchar();}

	x *= f;

}



template<typename _T>

void write( _T x )

{

	if( x < 0 ){ putchar( '-' ); x = ( ~ x ) + 1; }

	if( 9 < x ){ write( x / 10 ); }

	putchar( x % 10 + '0' );

}



int f[MAXN][MAXS];

int N, X, Y, Z, st, all;



int bit( const int i ) { return 1 << i - 1; }

bool chk( const int S ) { return ( S & st ) == st; }

void add( int &x, const int v ) { x = ( x + v >= mod ? x + v - mod : x + v ); }

int insert( const int S, const int v ) { return ( S << v | bit( v ) ) & all; }



int main()

{

	read( N ), read( X ), read( Y ), read( Z );

	int up = 1 << X + Y + Z;

	all = ( bit( X + Y + Z ) << 1 ) - 1;

	st = bit( Z ) | bit( Y + Z ) | bit( X + Y + Z );

	

	f[0][0] = 1;

	for( int i = 0 ; i < N ; i ++ )

		for( int S = 0 ; S < up ; S ++ )

			if( f[i][S] && ! chk( S ) )

				for( int k = 1, T ; k <= 10 ; k ++ )

					if( ! chk( T = insert( S, k ) ) )

						add( f[i + 1][T], f[i][S] );

	int ans = 1;

	for( int i = 1 ; i <= N ; i ++ )

		ans = 10ll * ans % mod;

	for( int S = 0 ; S < up ; S ++ )

		if( ! chk( S ) )

			add( ans, mod - f[N][S] );

	write( ans ), putchar( '\n' );

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;



int main(){

	int n, p;

	cin >> n >> p;

	int64_t dp[n + 1][100 * n + 1]{};

	dp[0][0] = 1;

	for(int i = 0; i < n; i++){

		int a;

		cin >> a;

		for(int j = 0; j < 100 * n + 1; j++){

			dp[i + 1][j] = dp[i][j];

			if(0 <= j - a) dp[i + 1][j] += dp[i][j - a];

		}

	}

	int64_t ans = 0;

	for(int j = p; j < 100 * n + 1; j += 2) ans += dp[n][j];

	cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <iostream>

using namespace std;



int64_t pow(int64_t a, int n){

	int64_t r = 1;

	while(n){

		if(n & 1) r *= a;

		a *= a;

		n >>= 1;

	}

	return r;

}



int main(){

	int n, p;

	cin >> n >> p;

	int odd = 0;

	for(int i = 0; i < n; i++){

		int a;

		cin >> a;

		if(a & 1) odd++;

	}

	cout << (odd ? pow(2, n - 1) : p ? 0 : pow(2, n)) << endl;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

typedef  long long ll;

typedef  vector<int> vi;

typedef  pair<int,int> pii;

typedef  pair<int,string> pis;

double pi=3.1415926535898;

#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

#define lop(i,n)   for(int i=0;i<int(n);i++)

#define rep(i,a,b) for(int i=a;i<=int(b);++i)

#define rng(i,a,b) for(int i=a;i>=int(b);i--)

#define ms(x,a)    memset(x,a,sizeof(x))

#define all(x)     (x).begin(),(x).end()

#define sz(x)      int(x.size())

#define pb         push_back

#define r0         return 0;

#define CC         continue;

#define bb(x)      cerr<< x <<endl;

#define F          first

#define S          second       //  __builtin_popcount;

//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);

const ll M  = 1e9+7 ;

const int N = 300100;

const int inf = INT_MAX;

const double eps = 1e-7;

//////////////////////    Hi    ^_^  hack me if you can :P



int a[100];

int n, p;

int s;

ll mem[100][5005];

ll dp ( int i, int s)

{

    if ( i == n) return s%2 == p;

    ll &r = mem[i][s];

    if (r!=-1)

    {

        return r;

    }

    return r = dp(i+1,s+a[i])+dp(i+1,s);

}

int main()

{

    speed;

    cin >> n >> p;

    lop(i,n) cin >> a[i];

    ms(mem,-1);

    cout << dp(0,0);



    return 0;

}


// Optimized solution to the same problem (faster):
#pragma GCC optimize("O3")

#include <bits/stdc++.h>

using namespace std;

typedef  long long ll;

typedef  vector<int> vi;

typedef  pair<int,int> pii;

typedef  pair<int,string> pis;

double pi=3.1415926535898;

#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);

#define lop(i,n)   for(int i=0;i<int(n);i++)

#define rep(i,a,b) for(int i=a;i<=int(b);++i)

#define rng(i,a,b) for(int i=a;i>=int(b);i--)

#define ms(x,a)    memset(x,a,sizeof(x))

#define all(x)     (x).begin(),(x).end()

#define sz(x)      int(x.size())

#define pb         push_back

#define r0         return 0;

#define CC         continue;

#define bb(x)      cerr<< x <<endl;

#define F          first

#define S          second       //  __builtin_popcount;

//freopen("output.txt","w",stdout),freopen("input.txt","r",stdin);

const ll M  = 1e9+7 ;

const int N = 300100;

const int inf = INT_MAX;

const double eps = 1e-7;

//////////////////////    Hi    ^_^  hack me if you can :P

 

int a[100];

int n, p;

int s;

ll mem[55][2];

ll dp ( int i, int s)

{

    if ( i == n) return s%2 == p;

    ll &r = mem[i][s%2];

    if (r!=-1)

    {

        return r;

    }

    return r = dp(i+1,(s+a[i])%2 )+dp(i+1,s%2);

}

int main()

{

    speed;

    cin >> n >> p;

    lop(i,n) cin >> a[i];

    ms(mem,-1);

    cout << dp(0,0);

 

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

long long n, p, a, s, ans, d[55][5005]={1};

int main() {

	int i, j;

	cin>>n>>p;

	for(i=1; i<=n; i++) {

		cin>>a;

		for(j=s; j>=0; j--)

			if(d[i-1][j]) {

				d[i][j] += d[i-1][j];

				d[i][j+a] += d[i-1][j];

			}

		s += a;

	}

	for(j=p; j<=s; j+=2) ans += d[n][j];

	cout<<ans;

	return 0;

}

// Optimized solution to the same problem (faster):
#include <iostream>

using namespace std;

long long n, p, a, s=1, c[2];

int main() {

	cin>>n>>p;

	while(n--) cin>>a, c[a%2]=1, s<<=1;

	cout<<(c[1] ? s/2 : p?0:s);

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#define REP(i, n) for (int i = 0; i < (n); i++)

#define RREP(i, a, b) for (int i = a; i < (b); i++)

#define FOR(i, n) for (int i = n; i >= 0; i--)

#include <algorithm>

#include <cmath>

#include <cstdio>

#include <iomanip>

#include <iostream>

#include <map>

#include <queue>

#include <set>

#include <stack>

#include <string>

#include <vector>

#define SIZE 100001

#define MOD 1000000007

#define INF 100000000

#define ll long long

using namespace std;

long long c[51][51];



int main() {

  int n, p;

  scanf("%d%d", &n, &p);

  int a[51];

  bool flag = false;

  REP(i, n) {

    scanf("%d", &a[i]);

    if (a[i] % 2) flag = true;

  }

  ll ans = 1;

  if (flag) {

    REP(i, n - 1) ans *= 2;

    cout << ans << endl;

  } else {

    REP(i, n) ans *= 2;

    if (p == 0)

      cout << ans << endl;

    else

      cout << 0 << endl;

  }



  return 0;

}

// Optimized solution to the same problem (faster):
#define REP(i, n) for (int i = 0; i < (n); i++)

#include <cstdio>

#define ll long long



int main() {

  int n, p;

  scanf("%d%d", &n, &p);



  bool flag = false;

  REP(i, n) {

    int a;

    scanf("%d", &a);

    if (a % 2) {

      flag = true;

      break;

    }

  }



  ll ans = 1;

  if (flag) {

    REP(i, n - 1) ans *= 2;

    printf("%lld\n", ans);

  } else {

    REP(i, n) ans *= 2;

    if (p == 1) ans = 0;

    printf("%lld\n", ans);

  }

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)

#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)

#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)

#define all(x) (x).begin(), (x).end()

#define sz(x) ((int)(x).size())

#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    

    int N, P;

    cin >> N >> P;

    vector<int> A(N);

    int total = 0;

    ll ans = 0;

    

    rep(i, N) {

        cin >> A[i];

        total += A[i];

    }

    

    vector<vector<ll>> dp(N + 1, vector<ll>(total + 1, INT_MIN));

    dp[0][0] = 1;

    

    rep(i, N) {

        rep(ii, total - A[i] + 1) {

            if (dp[i][ii] == INT_MIN) {

                continue;

            }

            

            dp[i + 1][ii] = ((dp[i + 1][ii] == INT_MIN) ? dp[i][ii] : dp[i][ii] + dp[i + 1][ii]);

            

            if (dp[i + 1][ii + A[i]] == INT_MIN) {

                dp[i + 1][ii + A[i]] = dp[i][ii];

            }

            else {

                dp[i + 1][ii + A[i]] = dp[i + 1][ii + A[i]] + dp[i][ii];

            }

        }

    }

    

    rep(i, total + 1) {

        if (((i % 2) == P) && (dp[N][i] != INT_MIN)) {

            ans += dp[N][i];

        }

    }

    

    cout << ans << endl;

    return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)

#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)

#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)

#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)

#define all(x) (x).begin(), (x).end()

#define rall(x) (x).rbegin(), (x).rend()

#define sz(x) ((ll)(x).size())

#define len(x) ((ll)(x).length())

#define endl "\n"



int main() {

    cin.tie(0);

    ios::sync_with_stdio(false);

    // ifstream in("input.txt");

    // cin.rdbuf(in.rdbuf());

    ll n, p;

    cin >> n >> p;

    vector<ll> dp(2, 0);

    dp[0] = 1;

    rep(i, n) {

        ll a;

        cin >> a;

        if (a % 2 == 1) {

            ll tmp = dp[0] + dp[1];

            dp[1] += dp[0];

            dp[0] = tmp;

        }

        else {

            dp[0] *= 2;

            dp[1] *= 2;

        }

    }

    cout << dp[p] << endl;

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long int64;



int64 nCr[575][575];



int64 f(int64 n, int64 r)

{

  if (r == 0 || n == r) return 1;

  if (nCr[n][r] >= 0) return nCr[n][r];

  return nCr[n][r] = f(n - 1, r - 1) + f(n - 1, r);

}



int main()

{

  memset(nCr, -1, sizeof(nCr));;

  int N, P;

  cin >> N >> P;

 

  vector< int > a(N);

  int o = 0;

  int e = 0;

  for (int i = 0; i < N; ++i) {

    cin >> a[i];

    if (a[i] % 2 == 0) {

      e++;

    } else {

      o++;

    }

  }

  

  int64 ans = 0ll;

  for (int i = 0; i <= o; ++i) {

    if (i % 2 == P) {

      ans += f(o, i);

    }

  }

  ans <<= e;

  

  cout << ans << endl;

  

  return 0;

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

// statics

using namespace std;

using int64 = int_fast64_t;

using PAIR = pair<int64, int64>;

constexpr int INF = 1 << 30;

constexpr int64 LINF = 1LL << 60;

constexpr int MOD = 1e9 + 7;

constexpr int MAX_N = 3e5 + 1;



// init/input

#define int int64

#define INIT ios::sync_with_stdio(false);cin.tie(0);

#define VAR(type, ...) type __VA_ARGS__;MACRO_VAR_Scan(__VA_ARGS__);

template<typename T> void MACRO_VAR_Scan(T &t) {cin>>t;}

template<typename First, typename...Rest> void MACRO_VAR_Scan(First &first, Rest&...rest) {cin>>first;MACRO_VAR_Scan(rest...);}

#define VEC(type, c, n) vector<type> c(n);for(auto &&i:c)cin>>i;



// out

#define OUT(dist) cout<<(dist);

#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);

#define SP cout<<" ";

#define BR cout<<endl;

#define zero(n) cout<<setfill('0')<<right<<setw(n)

#define debug(x) cerr<<#x<<":"<< (x);BR;



// utility

#define ALL(a) (a).begin(), (a).end()

#define EACH(i, a) for(auto &&i:(a))

#define FOR(i, a, b) for(int i=(a);i<(b);++i)

#define RFOR(i, a, b) for(int i=(b)-1;i>=0;--i)

#define REP(i, n) for(int i=0;i<(n);++i)

#define RREP(i, n) for(int i=(n)-1;i>=0;--i)



int ncr[55][55];



int power(int x, int n) {

	int res = 1LL;

	while (n > 0) {

		if (n & 1) (res *= x);

		(x *= x);

		n >>= 1;

	}

	return res;

}



int f(int n, int r){

	if(r==0 || r==n) return 1;

	if(ncr[n][r]>0) return ncr[n][r];

	return ncr[n][r] = f(n-1, r-1) + f(n-1, r);

}



signed main() {

  INIT;

	VAR(int,n,p);

	VEC(int,a,n);

	int zero, one=0;

	REP(i,n){

		if(a[i]%2==1) ++one;

	}

	zero = n-one;



	int ans=0;

	REP(i,one+1){

		if(p==i%2){

			ans += f(one,i);

		}

	}

	ans *= power(2,zero);

	OUT(ans)BR;

  

  return 0;

}


// Fastest known solution for this problem: