Language: C++

#include<bits/stdc++.h>
using namespace std;
 
const int MAX=510000;
const int MOD=1000000007;
 
long long fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++) {
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k) {
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}
 
 
int main(){
    COMinit();
    int n,p,o=0,e=0;
    long long ans=0;
    scanf("%d %d",&n,&p);
    vector<int> a(n);
    for (auto&e:a) scanf("%d",&e);
    for (int i=0;i<n;i++) if (a[i]%2) o++;
    e=n-o;
    int even[e];
    int odd[o];
    for (int i=0;i<e;i++) even[i]=COM(e,i);
    for (int i=0;i<o;i++) odd[i]=COM(o,i);
    if (p==0)  {
        if (e==0 || o==0) {
            ans++;
        } else {
            ans+=2;
        }
        if (e>0){
            for (int i=0;i<o;i++) {
                for (int j=0;j<e;j++) {
                    ans+=odd[i]*even[j];
                }
                i++;
            }
        } else {
            for (int i=0;i<o;i++) {
                ans+=odd[i];
                i++;
            }
        }
    } else {
        for (int i=1;i<o;i++) {
            ans+=odd[i];
            i++;
        }
    }
    printf("%d\n",ans);
    return 0;
}
                              
#include<bits/stdc++.h>
using namespace std;

const int MAX=510000;
const int MOD=1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

void COMinit() {
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for (int i=2;i<MAX;i++) {
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}
long long COM(int n,int k) {
    if (n<k) return 0;
    if (n<0 || k<0) return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}


int main(){
    COMinit();
    int n,p,o=0,e=0;
    long long ans=0;
    scanf("%d %d",&n,&p);
    vector<int> a(n);
    for (auto&e:a) scanf("%d",&e);
    for (int i=0;i<n;i++) if (a[i]%2) o++;
    e=n-o;
    int even[e];
    int odd[o];
    for (int i=0;i<e;i++) even[i]=COM(e,i);
    for (int i=0;i<o;i++) odd[i]=COM(o,i);
    if (p==0)  {
        if (e==0 || o==0) {
            ans++;
        } else {
            ans+=2;
        }
        if (e>0){
            for (int i=0;i<o;i++) {
                for (int j=0;j<e;j++) {
                    ans+=odd[i]*even[j];
                }
                i++;
            }
        } else {
            for (int i=1;i<o;i++) {
                ans+=odd[i];
                i++;
            }
        }
    } else {
        for (int i=1;i<o;i++) {
            ans+=odd[i];
            i++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Compiler output:
a.cc:71:11: error: redefinition of 'const int MAX'
   71 | const int MAX=510000;
      |           ^~~
a.cc:4:11: note: 'const int MAX' previously defined here
    4 | const int MAX=510000;
      |           ^~~
a.cc:72:11: error: redefinition of 'const int MOD'
   72 | const int MOD=1000000007;
      |           ^~~
a.cc:5:11: note: 'const int MOD' previously defined here
    5 | const int MOD=1000000007;
      |           ^~~
a.cc:74:11: error: redefinition of 'long long int fac [510000]'
   74 | long long fac[MAX], finv[MAX], inv[MAX];
      |           ^~~
a.cc:7:11: note: 'long long int fac [510000]' previously declared here
    7 | long long fac[MAX], finv[MAX], inv[MAX];
      |           ^~~
a.cc:74:21: error: redefinition of 'long long int finv [510000]'
   74 | long long fac[MAX], finv[MAX], inv[MAX];
      |                     ^~~~
a.cc:7:21: note: 'long long int finv [510000]' previously declared here
    7 | long long fac[MAX], finv[MAX], inv[MAX];
      |                     ^~~~
a.cc:74:32: error: redefinition of 'long long int inv [510000]'
   74 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                ^~~
a.cc:7:32: note: 'long long int inv [510000]' previously declared here
    7 | long long fac[MAX], finv[MAX], inv[MAX];
      |                                ^~~
a.cc:76:6: error: redefinition of 'void COMinit()'
   76 | void COMinit() {
      |      ^~~~~~~
a.cc:9:6: note: 'void COMinit()' previously defined here
    9 | void COMinit() {
      |      ^~~~~~~
a.cc:86:11: error: redefinition of 'long long int COM(int, int)'
   86 | long long COM(int n,int k) {
      |           ^~~
a.cc:19:11: note: 'long long int COM(int, int)' previously defined here
   19 | long long COM(int n,int k) {
      |           ^~~
a.cc:93:5: error: redefinition of 'int main()'
   93 | int main(){
      |     ^~~~
a.cc:26:5: note: 'int main()' previously defined here
   26 | int main(){
      |     ^~~~