Language: C++

#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <queue>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000
#define MAXN 55

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

int n, p, a[MAXN];
int c1, c0;
LL pascal[MAXN][MAXN];
//LL powmod(LL a, LL b) {LL res=1; a %= MOD; for(;b;b>>=1) {if (b&1) res = res*a % MOD; a = a*a % MOD;} return res;}
LL build_pascal() {
  // pascal's triangle
  //    k: 0  1  2  3  4
  //     ---------------
  // n: 0| 1  0  0  0  0
  //    1| 1  1  0  0  0
  //    2| 1  2  1  0  0
  //    3| 1  3  3  1  0
  //    4| 1  4  6  4  1

  for (int n = 2; n < MAXN; n++) {
    FOR1(k, n) {
      pascal[n][k] = pascal[n-1][k-1] + pascal[n-1][k];
    }   
  }
}


int main() {

  memset(pascal, 0, sizeof pascal);
  FORN(i, MAXN) {
    FORN(j, i + 1) pascal[i][j] = 1;
  }
  build_pascal();

  GI(n);
  GI(p);
  c1 = 0;
  c0 = 0;

  FORN(i, n) {
    int tmp;
    GI(tmp);
    c1 += tmp&1;
    c0 += (tmp&1) == 0;
  }

//  if (c1 == 0 && c0 > 0 && p == 0) {
//    printf("here\n");
//    printf("%lld\n", powmod(2, c0));
//    return 0;
//  }

//  printf("c1: %d, c0: %d\n", c1, c0);

  LL ans = 0;
  if (p == 1) {
    for (int tot = 0; tot < n+1; tot++) {
      for (int i0 = 0; i0 < min(c0+1, tot) + 1; i0++) {
        int i1 = tot - i0;
        if (i1 + i0 == 0) continue;
        if (i1 > c1) continue;
        if ((i1&1) == 0) continue;

        ans += pascal[c0][i0] * pascal[c1][i1];
//        printf("0: %d, 1: %d, ans %lld\n", i0, i1, ans);
      }
    }
  }
  else {
    
    for (int tot = 0; tot < n+1; tot++) {
      for (int i0 = 0; i0 < min(c0+1, tot) + 1; i0++) {
        int i1 = tot - i0;
//        printf("       %d (%d)\n", i1, c1);
        if (i1 > c1) continue;
        if (i1&1) continue;

//        printf("   %d c %d, %d c %d\n", c0, i0, c1, i1);
        ans += pascal[c0][i0] * pascal[c1][i1];
//        printf("0: %3d, 1: %3d, ans %lld\n", i0, i1, ans);
      }
    }
  }

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

  
  return 0;
}


Compiler output:
a.cc:53:1: error: extended character   is not valid in an identifier
   53 |   // pascal's triangle
      | ^
a.cc:54:1: error: extended character   is not valid in an identifier
   54 |   //    k: 0  1  2  3  4
      | ^
a.cc:55:1: error: extended character   is not valid in an identifier
   55 |   //     ---------------
      | ^
a.cc:56:1: error: extended character   is not valid in an identifier
   56 |   // n: 0| 1  0  0  0  0
      | ^
a.cc:57:1: error: extended character   is not valid in an identifier
   57 |   //    1| 1  1  0  0  0
      | ^
a.cc:58:1: error: extended character   is not valid in an identifier
   58 |   //    2| 1  2  1  0  0
      | ^
a.cc:59:1: error: extended character   is not valid in an identifier
   59 |   //    3| 1  3  3  1  0
      | ^
a.cc:60:1: error: extended character   is not valid in an identifier
   60 |   //    4| 1  4  6  4  1
      | ^
a.cc:62:1: error: extended character   is not valid in an identifier
   62 |   for (int n = 2; n < MAXN; n++) {
      | ^
a.cc:63:1: error: extended character   is not valid in an identifier
   63 |     FOR1(k, n) {
      | ^
a.cc:63:3: error: extended character   is not valid in an identifier
   63 |     FOR1(k, n) {
      |   ^
a.cc:64:1: error: extended character   is not valid in an identifier
   64 |       pascal[n][k] = pascal[n-1][k-1] + pascal[n-1][k];
      | ^
a.cc:64:3: error: extended character   is not valid in an identifier
   64 |       pascal[n][k] = pascal[n-1][k-1] + pascal[n-1][k];
      |   ^
a.cc:64:5: error: extended character   is not valid in an identifier
   64 |       pascal[n][k] = pascal[n-1][k-1] + pascal[n-1][k];
      |     ^
a.cc:65:1: error: extended character   is not valid in an identifier
   65 |     }   
      | ^
a.cc:65:3: error: extended character   is not valid in an identifier
   65 |     }   
      |   ^
a.cc:65:6: error: extended character   is not valid in an identifier
   65 |     }   
      |      ^
a.cc:65:8: error: extended character   is not valid in an identifier
   65 |     }   
      |        ^
a.cc:66:1: error: extended character   is not valid in an identifier
   66 |   }
      | ^
a.cc:72:1: error: extended character   is not valid in an identifier
   72 |   memset(pascal, 0, sizeof pascal);
      | ^
a.cc:73:1: error: extended character   is not valid in an identifier
   73 |   FORN(i, MAXN) {
      | ^
a.cc:74:1: error: extended character   is not valid in an identifier
   74 |     FORN(j, i + 1) pascal[i][j] = 1;
      | ^
a.cc:74:3: error: extended character   is not valid in an identifier
   74 |     FORN(j, i + 1) pascal[i][j] = 1;
      |   ^
a.cc:75:1: error: extended character   is not valid in an identifier
   75 |   }
      | ^
a.cc:76:1: error: extended character   is not valid in an identifier
   76 |   build_pascal();
      | ^
a.cc: In function 'LL build_pascal()':
a.cc:53:1: error: '\U000000a0' was not declared in this scope
   53 |   // pascal's triangle
      | ^
a.cc:62:32: error: expected ';' before ')' token
   62 |   for (int n = 2; n < MAXN; n++) {
      |                                ^
      |                                ;
a.cc:67:1: warning: no return statement in function returning non-void [-Wreturn-type]
   67 | }
      | ^
a.cc: In function 'int main()':
a.cc:72:1: error: '\U000000a0' was not declared in this scope
   72 |   memset(pascal, 0, sizeof pascal);
      | ^
a.cc:73:2: error: expected ';' before 'for'
   73 |   FORN(i, MAXN) {
      |  ^
      |  ;
a.cc:73:8: error: 'i' was not declared in this scope
   73 |   FORN(i, MAXN) {
      |        ^
a.cc:27:36: note: in definition of macro 'FORN'
   27 | #define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
      |                                    ^
a.cc:76:2: error: expected ';' before 'build_pascal'
   76 |   build_pascal();
      |  ^~~~~~~~~~~~~
      |  ;