Language: C++

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define ALL(x) x.begin(),x.end()
#define SZ(x) (int)x.size()
#define SQ(x) (x)*(x)
#define MN(a,b) a = min(a,(__typeof__(a))(b))
#define MX(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#ifdef BALBIT
#define IOS()
#define bug(...) fprintf(stderr,"#%d (%s) = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define bug(...)
#endif

const int iinf = 1e9+10;
const ll inf = 1ll<<60;
const ll mod = 1e9+7 ;


void GG(){cout<<"0\n"; exit(0);}

ll mpow(ll a, ll n, ll mo = mod){ // a^n % mod
    ll re=1;
    while (n>0){
        if (n&1) re = re*a %mo;
        a = a*a %mo;
        n>>=1;
    }
    return re;
}

ll inv (ll b, ll mo = mod){
    if (b==1) return b;
    return (mo-mo/b) * inv(mo%b,mo) % mo;
}

const int maxn = 1e6+5;

ll C[55][55];

void build(){
    for (int i = 0; i<55; ++i) {
        for (int j = 0; j<55; ++j) {
            if (j > i) {
                C[i][j] = 0; continue;
            }
            if (i == 0|| j == 0) C[i][j] = 1;
            else {
                C[i][j] = C[i-1][j-1] + C[i-1][j];
            }
        }
    }
}

signed main(){
    IOS();
    build();
    int n,k,s,t; cin>>n>>k>>s>>t;
    vector<int> a;
    int nbit = 0;
    for (int i = 0; i<18; ++i) {
        if (!(s&(1<<i)) && (t&(1<<i))) nbit++;
    }
    for (int cnt = 0; cnt<n; ++cnt) {
        int x; cin>>x;
        int y = 0;
        bool ok = true;
        for (int i = 0; i<18; ++i) {
            if ((s & (1<<i)) && (!(t&(1<<i)))) GG();
            if (s&(1<<i)) {
                if ((x>>i)&1){

                }else{
                    ok = false; break;
                }
            }else if (!(t&(1<<i))) {
                if ((x>>i)&1){
                    ok = false; break;
                }else{
                }
            }else{
                y<<=1;
                y+=(x>>i)&1;

            }
        }
        if (ok) a.pb(y);
    }
    bug("Hey");
    n = SZ(a);
    vector<vector<short> > st;
    ll re = 0;
    for (int x : a) {
        bug(x);
        for (int msk = 0; msk<(1<<nbit); ++msk) {
            //bug("Hi");
            vector<short> m(nbit);
            for (int i = 0; i<nbit; ++i) {
                if (msk & (1<<i)) {
                    m[i] = (x>>i) & 1;
                }else{
                    m[i] = -1;
                }
            }
            st.pb(m);
        }
    }
    SORT_UNIQUE(st);
    for (auto &m : st){
            int add = (__builtin_popcount(msk) %2 == 1)?-1:1;
            int num = 0;
            for (int y : a) {
                bool ok = true;
                for (int i = 0; i<nbit; ++i) {
                    if (m[i] != -1) {
                        if (((y>>i)&1)!=m[i]) {
                            ok = false; break;
                        }
                    }
                }
                if (ok) num++;
            }
            //bug(num);
            for (int i = 1; i<=k; ++i) {
                re += add * C[num][i];
            }
            bug(re);
        }
    }
    cout<<re<<endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:122:43: error: 'msk' was not declared in this scope
  122 |             int add = (__builtin_popcount(msk) %2 == 1)?-1:1;
      |                                           ^~~
a.cc: At global scope:
a.cc:142:5: error: 'cout' does not name a type
  142 |     cout<<re<<endl;
      |     ^~~~
a.cc:143:1: error: expected declaration before '}' token
  143 | }
      | ^