Language: C++

#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 1e9+7;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
ll mpow(ll a, ll b){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}

mt19937_64 mt(chrono::steady_clock::now().time_since_epoch().count());
 
ll range(ll l, ll r){
	return l + mt()%(r-l+1);
}
 
ll rev(ll v){
	return mpow(v,MOD-2);
}

const int lim = 25;
const int MAXV = (1<<18);
ll dp[MAXV];

void solve(){
	int n,k,s,t;
	cin >> n >> k >> s >> t;
	if((s&t) != s){
		cout << 0 << ln;
		return;
	}
	vp64 vec1,vec2;
	vec1.pb(mp(0,MAXV-1)); 
	vec2.pb(mp(0,MAXV-1)); 
	ll a[MAXV];
	forn(i,MAXV) a[i]=0;
	ll c = 0;
	forn(i,n) {
		ll tempvar;
		cin >> tempvar;
		if((tempvar&s) == s && (tempvar|t) == t){
			if(c<lim){
				vp64 temp;
				for(auto it : vec1){
					temp.pb(mp((tempvar|it.fi),(tempvar&it.se)));
				}
				for(auto it : temp) vec1.pb(it);
			}
			else{
				vp64 temp;
				for(auto it : vec2){
					temp.pb(mp((tempvar|it.fi),(tempvar&it.se)));
				}
				for(auto it : temp) vec2.pb(it);
			}
			c++;
		}
	}
	// cout << sz(vec1) << ln;
	for(auto it : vec1){
		if(it == mp(0,MAXV-1)) continue;
		ll curval = (it.se | (it.fi ^ (MAXV-1)));
		// cout << curval << ln;
		dp[curval]++;
	}
	forn(i,18) forn(mask,MAXV) if(mask & (1<<i)) dp[mask] += dp[mask^(1<<i)];
	// forn(mask, MAXV){
	// 	forn(j,18){
	// 		if(mask & (1<<j)) dp[mask][j] = (j ? dp[mask][j-1] : a[mask]) + (j ? dp[mask ^ (1<<j)][j-1] : 0);
	// 		else dp[mask][j] = (j ? dp[mask][j-1] : a[mask]);
	// 	}
	// }
	ll ans = 0;
	for(auto it : vec2){
		if(it == mp(0,MAXV-1)) continue;
		// cout << it.fi << " " << it.se << ln;
		ll val1 = (it.fi | (t ^ (MAXV-1)));
		ll val2 = (s | (it.se ^ t));
		// cout << val1 << " " << val2 << ln;
		ans += dp[val1|val2];
	}
	// if(s==0) ans--;
	cout << ans << ln;
}
 
int main()
{
	fast_cin();
    ll t=1;
    // cin >> t;
    forn(i,t) {
    	// cout << "Case #" << i+1 << ": ";
    	solve();
    }
    return 0;
}

Compiler output:
a.cc: In function 'void solve()':
a.cc:142:23: error: no match for 'operator==' (operand types are 'std::pair<long long int, long long int>' and 'std::pair<int, int>')
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                    ~~ ^~
      |                    |
      |                    pair<long long int,long long int>
In file included from /usr/include/c++/14/regex:68,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:181,
                 from a.cc:4:
/usr/include/c++/14/bits/regex.h:1103:5: note: candidate: 'template<class _BiIter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const sub_match<_BiIter>&)'
 1103 |     operator==(const sub_match<_BiIter>& __lhs, const sub_match<_BiIter>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1103:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/regex.h:1199:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&, const sub_match<_BiIter>&)'
 1199 |     operator==(const __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1199:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'std::__cxx11::__sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/regex.h:1274:5: note: candidate: 'template<class _Bi_iter, class _Ch_traits, class _Ch_alloc> bool std::__cxx11::operator==(const sub_match<_BiIter>&, __sub_match_string<_Bi_iter, _Ch_traits, _Ch_alloc>&)'
 1274 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1274:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/regex.h:1366:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type*, const sub_match<_BiIter>&)'
 1366 |     operator==(typename iterator_traits<_Bi_iter>::value_type const* __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1366:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/regex.h:1441:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type*)'
 1441 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1441:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/regex.h:1534:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const typename std::iterator_traits<_Iter>::value_type&, const sub_match<_BiIter>&)'
 1534 |     operator==(typename iterator_traits<_Bi_iter>::value_type const& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1534:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<int, int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/regex.h:1613:5: note: candidate: 'template<class _Bi_iter> bool std::__cxx11::operator==(const sub_match<_BiIter>&, const typename std::iterator_traits<_Iter>::value_type&)'
 1613 |     operator==(const sub_match<_Bi_iter>& __lhs,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:1613:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::sub_match<_BiIter>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/regex.h:2186:5: note: candidate: 'template<class _Bi_iter, class _Alloc> bool std::__cxx11::operator==(const match_results<_BiIter, _Alloc>&, const match_results<_BiIter, _Alloc>&)'
 2186 |     operator==(const match_results<_Bi_iter, _Alloc>& __m1,
      |     ^~~~~~~~
/usr/include/c++/14/bits/regex.h:2186:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::__cxx11::match_results<_BiIter, _Alloc>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:64,
                 from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51:
/usr/include/c++/14/bits/stl_pair.h:1033:5: note: candidate: 'template<class _T1, class _T2> constexpr bool std::operator==(const pair<_T1, _T2>&, const pair<_T1, _T2>&)'
 1033 |     operator==(const pair<_T1, _T2>& __x, const pair<_T1, _T2>& __y)
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_pair.h:1033:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   deduced conflicting types for parameter '_T1' ('long long int' and 'int')
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
In file included from /usr/include/c++/14/bits/stl_algobase.h:67:
/usr/include/c++/14/bits/stl_iterator.h:441:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_Iterator>&)'
  441 |     operator==(const reverse_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:441:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/stl_iterator.h:486:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  486 |     operator==(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:486:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::reverse_iterator<_Iterator>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1667 |     operator==(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1667:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note: candidate: 'template<class _Iterator> constexpr bool std::operator==(const move_iterator<_IteratorL>&, const move_iterator<_IteratorL>&)'
 1737 |     operator==(const move_iterator<_Iterator>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1737:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::move_iterator<_IteratorL>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
In file included from /usr/include/c++/14/bits/char_traits.h:42,
                 from /usr/include/c++/14/string:42,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52:
/usr/include/c++/14/bits/postypes.h:192:5: note: candidate: 'template<class _StateT> bool std::operator==(const fpos<_StateT>&, const fpos<_StateT>&)'
  192 |     operator==(const fpos<_StateT>& __lhs, const fpos<_StateT>& __rhs)
      |     ^~~~~~~~
/usr/include/c++/14/bits/postypes.h:192:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::fpos<_StateT>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
In file included from /usr/include/c++/14/string:43:
/usr/include/c++/14/bits/allocator.h:235:5: note: candidate: 'template<class _T1, class _T2> bool std::operator==(const allocator<_CharT>&, const allocator<_T2>&)'
  235 |     operator==(const allocator<_T1>&, const allocator<_T2>&)
      |     ^~~~~~~~
/usr/include/c++/14/bits/allocator.h:235:5: note:   template argument deduction/substitution failed:
a.cc:142:37: note:   'std::pair<long long int, long long int>' is not derived from 'const std::allocator<_CharT>'
  142 |                 if(it == mp(0,MAXV-1)) continue;
      |                                     ^
In file inc