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

#include <cstdio>

#include <algorithm>

#define int long long

#define N 200002

using namespace std;

struct ball{

	int x,y;

}a[N];

int n,i,maxx,minx=1<<30,r[N],b[N];

int my_comp(const ball &a,const ball &b)

{

	return a.x<b.x;

}

signed main()

{

	cin>>n;

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

		cin>>a[i].x>>a[i].y;

		if(a[i].x>a[i].y) swap(a[i].x,a[i].y);

		maxx=max(maxx,a[i].y);

		minx=min(minx,a[i].x);

	}

	int rmax=0,bmin=1<<30,bmax,tmp=1<<30;

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

		rmax=max(rmax,a[i].x);

		bmin=min(bmin,a[i].y);

	}

	int ans=(maxx-bmin)*(rmax-minx);

	sort(a+1,a+n+1,my_comp);

	for(i=1;i<=n;i++) b[i]=a[i].x,r[i]=a[i].y;

	bmax=b[n];

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

		bmax=max(bmax,r[i]);

		tmp=min(tmp,r[i]);

		bmin=min(tmp,b[i+1]);

		ans=min(ans,(maxx-minx)*(bmax-bmin));

	}

	cout<<ans<<endl;

	return 0;

}


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

#include <algorithm>

#include <cstring>

#include <cctype>

using namespace std;



namespace zyt

{

	template<typename T>

	inline bool read(T &x)

	{

		char c;

		bool f = false;

		x = 0;

		do

			c = getchar();

		while (c != EOF && c != '-' && !isdigit(c));

		if (c == EOF)

			return false;

		if (c == '-')

			f = true, c = getchar();

		do

			x = x * 10 + c - '0', c = getchar();

		while (isdigit(c));

		if (f)

			x = -x;

		return true;

	}

	template<typename T>

	inline void write(T x)

	{

		static char buf[20];

		char *pos = buf;

		if (x < 0)

			putchar('-'), x = -x;

		do

			*pos++ = x % 10 + '0';

		while (x /= 10);

		while (pos > buf)

			putchar(*--pos);

	}

	typedef long long ll;

	typedef pair<int, int> pii;

	const int N = 2e5 + 10;

	int n, sufmx[N], sufmn[N];

	pii arr[N];

	int work()

	{

		read(n);

		int mx = 0, mn = 1e9;

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

		{

			read(arr[i].first), read(arr[i].second);

			if (arr[i].first > arr[i].second)

				swap(arr[i].first, arr[i].second);

			mx = max(mx, arr[i].second), mn = min(mn, arr[i].second);

		}

		sort(arr + 1, arr + n + 1);

		ll ans = ll(arr[n].first - arr[1].first) * (mx - mn), k = mx - arr[1].first;

		mn = 1e9, mx = 0;

		sufmx[n + 1] = 0, sufmn[n + 1] = 1e9;

		for (int i = n; i > 0; i--)

			sufmx[i] = max(sufmx[i + 1], arr[i].first), sufmn[i] = min(sufmn[i + 1], arr[i].first);

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

		{

			mn = min(mn, arr[i].second), mx = max(mx, arr[i].second);

			ans = min(ans, k * (max(sufmx[i + 1], mx) - min(sufmn[i + 1], mn)));

		}

		write(ans);

		return 0;

	}

}

int main()

{

	return zyt::work();

}

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

#include <set>

#include <algorithm>

#define int long long

using namespace std;

pair <int,int> a[200005],b[500005];

multiset <int> s;

multiset <int> s2;

int c[500005];

signed main(int argc, char** argv) {

	int n,cnt=0;

	cin >> n;

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

	{

		cin >> a[i].first >> a[i].second;

		b[++cnt]={a[i].first,i};

		b[++cnt]={a[i].second,i};

		if(a[i].first>a[i].second) swap(a[i].first,a[i].second);

	}

	sort(a+1,a+n+1);

	int mn=2e9,MN=2e9,mx=0,MX=0;

	for(int i=1;i<=n;i++) mn=min(mn,a[i].first);

	for(int i=1;i<=n;i++) MN=min(MN,a[i].second);

	for(int i=1;i<=n;i++) mx=max(mx,a[i].first);

	for(int i=1;i<=n;i++) MX=max(MX,a[i].second);

	int ans=(MX-MN)*(mx-mn);

	sort(b+1,b+cnt+1);

	cnt=0;

	int l=1;

	for(int i=1;i<=n*2;i++)

	{

		if(!c[b[i].second]) ++cnt;

		++c[b[i].second];

		while(cnt==n)

		{

			ans=min(ans,(MX-mn)*(b[i].first-b[l].first));

			--c[b[l].second];

			if(c[b[l].second]==0)

				--cnt;

			++l;

		}

	}

	cout << ans;

	return 0;

}

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

#include <algorithm>

#include <cstring>

#include <cctype>

using namespace std;



namespace zyt

{

	template<typename T>

	inline bool read(T &x)

	{

		char c;

		bool f = false;

		x = 0;

		do

			c = getchar();

		while (c != EOF && c != '-' && !isdigit(c));

		if (c == EOF)

			return false;

		if (c == '-')

			f = true, c = getchar();

		do

			x = x * 10 + c - '0', c = getchar();

		while (isdigit(c));

		if (f)

			x = -x;

		return true;

	}

	template<typename T>

	inline void write(T x)

	{

		static char buf[20];

		char *pos = buf;

		if (x < 0)

			putchar('-'), x = -x;

		do

			*pos++ = x % 10 + '0';

		while (x /= 10);

		while (pos > buf)

			putchar(*--pos);

	}

	typedef long long ll;

	typedef pair<int, int> pii;

	const int N = 2e5 + 10;

	int n, sufmx[N], sufmn[N];

	pii arr[N];

	int work()

	{

		read(n);

		int mx = 0, mn = 1e9;

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

		{

			read(arr[i].first), read(arr[i].second);

			if (arr[i].first > arr[i].second)

				swap(arr[i].first, arr[i].second);

			mx = max(mx, arr[i].second), mn = min(mn, arr[i].second);

		}

		sort(arr + 1, arr + n + 1);

		ll ans = ll(arr[n].first - arr[1].first) * (mx - mn), k = mx - arr[1].first;

		mn = 1e9, mx = 0;

		sufmx[n + 1] = 0, sufmn[n + 1] = 1e9;

		for (int i = n; i > 0; i--)

			sufmx[i] = max(sufmx[i + 1], arr[i].first), sufmn[i] = min(sufmn[i + 1], arr[i].first);

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

		{

			mn = min(mn, arr[i].second), mx = max(mx, arr[i].second);

			ans = min(ans, k * (max(sufmx[i + 1], mx) - min(sufmn[i + 1], mn)));

		}

		write(ans);

		return 0;

	}

}

int main()

{

	return zyt::work();

}

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



int isprime(int n) {

	int i;

    for(int i = 2; i * i <= n; i++) {

        if(n % i == 0) return 0;

    }

    return 1; 

}



int main() {

    int i, k, v,an1,an2,suu;

    int MAX_V = 10000;

    int prime[MAX_V+1];

    for(i = 0; i <= MAX_V; i++) {

        prime[i] = 1;

    }

    for(i = 2; i*i <= MAX_V; i++) {

        if(prime[i]) {

            for(k = 2 * i; k <= MAX_V; k += i) {

                prime[k] = 0;   

            } 

        }

    }

   while(1){

        scanf("%d",&suu);

        if(suu != 0){

            for(k=2;k<=suu;k++){

            	if(prime[k-2]==1 && prime[k]==1){

        	    	an1=k-2;

        	    	an2=k;

            	}

            }

            printf("%d %d\n",an1,an2);

        }

        else{

    	    break;

        }

    }

    return 0; 

}

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



int isprime(int n) {

	int i;

    for(int i = 2; i * i <= n; i++) {

        if(n % i == 0) return 0;

    }

    return 1; 

}



int main(){

	int k,suu,an1,an2;

    while(1){

        scanf("%d",&suu);

        if(suu == 0)  break;

        for(k=suu;k>0;k--){

            if(isprime(k-2)==1 && isprime(k)==1){

                an1=k-2;

                an2=k;

                break;

            }

        }

        printf("%d %d\n",an1,an2);

    }

}

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



int main() {

    int i, k, v,an1,an2,suu;

    int MAX_V = 10000;

    int prime[MAX_V+1];

    for(i = 0; i <= MAX_V; i++) {

        prime[i] = 1;

    }

    for(i = 2; i*i <= MAX_V; i++) {

        if(prime[i]) {

            for(k = 2 * i; k <= MAX_V; k += i) {

                prime[k] = 0;   

            } 

        }

    }

   while(1){

        scanf("%d",&suu);

        if(suu != 0){

            for(k=2;k<=suu;k++){

            	if(prime[k-2]==1 && prime[k]==1){

        	    	an1=k-2;

        	    	an2=k;

            	}

            }

            printf("%d %d\n",an1,an2);

        }

        else{

    	    break;

        }

    }

    return 0; 

}

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



int isprime(int n) {

	int i;

    for(int i = 2; i * i <= n; i++) {

        if(n % i == 0) return 0;

    }

    return 1; 

}



int main(){

	int k,suu,an1,an2;

    while(1){

        scanf("%d",&suu);

        if(suu == 0)  break;

        for(k=suu;k>0;k--){

            if(isprime(k-2)==1 && isprime(k)==1){

                an1=k-2;

                an2=k;

                break;

            }

        }

        printf("%d %d\n",an1,an2);

    }

}

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



int main() {

    int i, k, v,an1,an2,suu;

    int MAX_V = 10000;

    int prime[MAX_V+1];

    for(i = 2; i <= MAX_V; i++) {

        prime[i] = 1;

    }

    for(i = 2; i*i <= MAX_V; i++) {

        if(prime[i]) {

            for(k = 2 * i; k <= MAX_V; k += i) {

                prime[k] = 0;   

            } 

        }

    }

   while(1){

        scanf("%d",&suu);

        if(suu != 0){

            for(k=2;k<=suu;k++){

            	if(prime[k-2]==1 && prime[k]==1){

        	    	an1=k-2;

        	    	an2=k;

            	}

            }

            printf("%d %d\n",an1,an2);

        }

        else{

    	    break;

        }

    }

    return 0; 

}

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



int isprime(int n) {

	int i;

    for(int i = 2; i * i <= n; i++) {

        if(n % i == 0) return 0;

    }

    return 1; 

}



int main(){

	int k,suu,an1,an2;

    while(1){

        scanf("%d",&suu);

        if(suu == 0)  break;

        for(k=suu;k>0;k--){

            if(isprime(k-2)==1 && isprime(k)==1){

                an1=k-2;

                an2=k;

                break;

            }

        }

        printf("%d %d\n",an1,an2);

    }

}

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

const int MAX_V = 10000; // 1????????§????´???°??¨?????????



int main() {

	int i, k, n, p, q;

	int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????????

	for(i = 2; i <= MAX_V; i++) {

		prime[i] = 1; // 2??\???????´???°??¨??????

	}

	for(i = 2; i*i <= MAX_V; i++) {

		if(prime[i]) {

			for(k = 2 * i; k <= MAX_V; k += i) {

				prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????

			}

		}

	}

	//?´???°??¨fin

	//while(scanf("%d",&n) != 0){

	while(1){

		scanf("%d",&n);

		if(n==0)break;

		for(i=n;i>=3;i--){//???????????¨????´???°????????????

			if(prime[i] == 1 && prime[i-2] == 1){

				p = i;

				q = p-2;

				break;

			}

		}

	// 	ans[a]=i; a++;

	// 	ans[a]=i-2; a++;

	// }

	// for(i=0;i<=a;i=i+2){

	// 	printf("%d %d\n",ans[i],ans[i+1]);

	// }

		printf("%d %d\n",q,p);

	}

	return 0;

}

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

#include <time.h>

int isprime(int n){

	for(int i = 2; i * i <= n; i++){

		if(n % i == 0){

			return 0;

		}

	}

	return 1;

}

int main() {

	int i,p,q,n;

	while(1){

		scanf("%d",&n);

		if(n == 0){

			break;

		}

		for(i=n;i>=2;i--){

			if(isprime(i) && isprime(i-2) ){

				break;

			}

		}

		printf("%d %d\n",i-2,i);

	}

	return 0;

}





	// clock_t start, now;

	// now = clock();

	// printf("%f\n",(double)(now - start) / CLOCKS_PER_SEC);

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

const int MAX_X = 10000;

int prime[10000];



int main(){



	int i, k, n;



	int border[10];

	for( i = 2; i <= MAX_X; i++) {

		prime[i] = 1;

	}



	for(i = 2; i*i <= MAX_X; i++){

		if(prime[i]) {

			for(k = 2 * i; k <= MAX_X; k += i){

				prime[k] = 0;

			}

		}

	}



	while(1){

		scanf("%d", &n);

		if( n == 0) break;

		int max;

		for( i = n; i >= 2; i--){

			if( prime[i]){

				if( prime[i - 2]){

					max = i;

					break;

				}

			}

		}

		printf("%d %d\n", max -2, max);

	}

	return 0;

}

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



int isprime(int n){

	for(int i = 2; i * i <= n; i++){

		if( n % i == 0) return 0;

	}

	return 1;

}



int main(){

	int n, i;

	while(1){

		scanf("%d", &n);

		if( n == 0) break;

		int max = 0;

		for( i = n; i >=2; i--){

			if( isprime(i)){

				if(isprime( i - 2)){

					max = i;

					break;

				}

			}

		}

		printf("%d %d\n", max - 2, max);

	}

	return 0;

}

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



int main(){

  const int MAX_V = 10000;

  int prime[MAX_V+1];

  int i, k, v, ans, dif;

  for(i = 2; i <= MAX_V; i++){

    prime[i] = 1;

  }

  for(i = 2; i*i <= MAX_V; i++){

    if(prime[i]){

      for(k = 2 * i; k <= MAX_V; k += i){

        prime[k] = 0;

      }

    }

  }

  while(scanf("%d", &v) != EOF){

    if(v == 0) break;

    for(k = v; k >= 2; k--){

      ans = prime[k];

      if(ans == 1){

        dif = prime[k - 2];

        if(dif == 1){

          printf("%d %d\n", k - 2, k);

          break;

        }

      }

    }

  }

  return 0;

}

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



int isprime(int n){

  int i;

  for(i = 2; i * i <= n; i++){

    if(n % i == 0){

      return 0;

    }

  }

  return 1;

}



int main(){

  int k, n, ans, dif;

  while(1){

    scanf("%d", &n);

    if(n == 0){

      break;

    }

    for(k = n; k >= 2; k--){

      ans = isprime(k);

      if(ans == 1){

        dif = isprime(k - 2);

        if(dif == 1){

          printf("%d %d\n", k - 2, k);

          break;

        }

      }

    }

  }

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "stdio.h"

const int MAX_V = 10000; // 1????????§????´???°??¨?????????

int prime[MAX_V+1]; // 1????´???°,0????´???°??§?????????

int main() {

    int i, k, n;

    for(i = 2; i <= MAX_V; i++){

        prime[i] = 1; // 2??\???????´???°??¨??????

    }

    for(i = 2; i * i <= MAX_V; i++) {

        if(prime[i]) {

            for(k = 2 * i; k <= MAX_V; k += i) {

                prime[k] = 0; // ?´???°???2?????\???????????°????´???°??§?????????

            }

        }

    }

   while (1) {

        scanf("%d",&n);

        if (n == 0)break;

//        while(scanf("%d", &n) != 0) {

        int p1 = 0,q1 = 0;

        for(i = n;3 <= i;i--){

            if(prime[i] == 1 && prime[i-2] == 1){  //??????????´???°

                q1 = i;

                p1 = i-2;

                break;

            }

        }

        printf("%d %d\n",p1,q1);//for?????????????????????

    }

    return 0;

}

//????¨??????¨????????????????????????

// Optimized solution to the same problem (faster):
#include "stdio.h"

//#include "time.h"

//?????§??????????´???°?????????????????????

// 5<= n <= 10000

//p1=?°????????´???°p2=??§???????´???°



int isprime(int n) {

    int i;

    for(i = 2; i * i <= n; i++) {   //??????????§????????????¨??§??¶??°??§??????????´???°??¨??????

        if(n % i == 0)return 0;    //????????????????????§?´???°??§?????????

    }

    return 1;

}

int main(){

    int i,n,p1,q1;

   //     clock_t start, now;//??£?¨?

    while(1){

        scanf("%d",&n);

     //   start = clock(); // ????§???????

        if(n == 0)break;

        for(i = n;3 <= i;i--){

            if (isprime(i) == 1 && isprime(i - 2) == 1) break;

        }

        p1 = i-2;

        q1 = i;

       // now = clock(); // ????????????

       // printf("%f\n", (double)(now - start) / CLOCKS_PER_SEC);//??¬???

        printf("%d %d\n",p1,q1);

    }

    return 0;

}

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

using namespace std;



const long long K = 18, N = 55;



vector<long long> vv[1<<K];



long long C[N][N];



void pre() {

    for (long long i=0; i<N; i++) C[i][0] = 1;

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

        for (long long j=1; j<N; j++)

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



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

        for (long long j=1; j<N; j++)

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

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    pre();





    long long n, k, S, T;

    cin>>n>>k>>S>>T;



    if ( (S&T) != S) {

        cout<<0<<endl;

        return 0;

    }



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

        long long x;

        cin>>x;



        if ((x&S) != S) continue;

        if ((x&T) != x) continue;



        for (long long mask = 0; mask < (1<<K); mask++) {

            if ((mask&S) != S) continue;

            if ((mask&T) != mask) continue;

            int ans = x & (~mask);

            vv[mask].push_back(ans);

        }

    }



    long long ans = 0;

    for (long long mask = 0; mask < (1<<K); mask++) {

        if ((mask&S) != S) continue;

        if ((mask&T) != mask) continue;

        sort(vv[mask].begin(), vv[mask].end());



        long long ww = 0;

        while (vv[mask].size()) {

            long long last = vv[mask].back();

            long long cnt = 0;

            while (vv[mask].size() && vv[mask].back() == last)  cnt++, vv[mask].pop_back();



            ww += C[cnt][k]-1;

        }



        long long bc = __builtin_popcount(mask);

        if (bc%2)   ans += ww;

        else        ans -= ww;

    }

    cout<<abs(ans)<<endl;

}


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

using namespace std;



const int K = 18, N = 55;

long long C[N][N];

int cnt[1<<K];



void pre() {

    for (int i=0; i<N; i++) C[i][0] = 1;

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

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

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



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

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

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

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    pre();



    int n, k, S, T;

    cin>>n>>k>>S>>T;



    vector<int> v(n);

    for (int i=0; i<n; i++) cin>>v[i];



    long long ans = 0;

    for (int mask = 0; mask < (1<<K); mask++) {

        if ((S&mask) != S || (T&mask) != mask)  continue;



        vector<int> vv;

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

            if ((S&v[i]) != S || (T&v[i]) != v[i])  continue;

            int z = v[i] & (~mask);

            cnt[z]++;

            vv.push_back(z);

        }



        long long ww = 0;

        for (int x: vv){

            ww += C[cnt[x]][k]-1;

            cnt[x] = 0;

        }



        int bc = __builtin_popcount(mask);

        if (bc%2)   ans += ww;

        else        ans -= ww;

    }

    cout<<abs(ans)<<endl;

}


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

using namespace std;



const int K = 18, N = 55;



vector<int> vv[1<<K];



long long C[N][N];



void pre() {

    for (int i=0; i<N; i++) C[i][0] = 1;

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

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

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



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

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

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

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    pre();





    int n, k, S, T;

    cin>>n>>k>>S>>T;



    if ( (S&T) != S) {

        cout<<0<<endl;

        return 0;

    }



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

        int x;

        cin>>x;



        if ((x&S) != S) continue;

        if ((x&T) != x) continue;



        for (int mask = 0; mask < (1<<K); mask++) {

            if ((mask&S) != S) continue;

            if ((mask&T) != mask) continue;

            int ans = x & (~mask);

            vv[mask].push_back(ans);

        }

    }



    long long ans = 0;

    for (int mask = 0; mask < (1<<K); mask++) {

        if ((mask&S) != S) continue;

        if ((mask&T) != mask) continue;

        sort(vv[mask].begin(), vv[mask].end());



        long long ww = 0;

        while (vv[mask].size()) {

            int last = vv[mask].back();

            int cnt = 0;

            while (vv[mask].size() && vv[mask].back() == last)  cnt++, vv[mask].pop_back();



            ww += C[cnt][k]-1;

        }



        int bc = __builtin_popcount(mask);

        if (bc%2)   ans += ww;

        else        ans -= ww;

    }

    cout<<abs(ans)<<endl;

}


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

using namespace std;



const int K = 18, N = 55;

long long C[N][N];

int cnt[1<<K];



void pre() {

    for (int i=0; i<N; i++) C[i][0] = 1;

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

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

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



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

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

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

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    pre();



    int n, k, S, T;

    cin>>n>>k>>S>>T;



    vector<int> v(n);

    for (int i=0; i<n; i++) cin>>v[i];



    long long ans = 0;

    for (int mask = 0; mask < (1<<K); mask++) {

        if ((S&mask) != S || (T&mask) != mask)  continue;



        vector<int> vv;

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

            if ((S&v[i]) != S || (T&v[i]) != v[i])  continue;

            int z = v[i] & (~mask);

            cnt[z]++;

            vv.push_back(z);

        }



        long long ww = 0;

        for (int x: vv){

            ww += C[cnt[x]][k]-1;

            cnt[x] = 0;

        }



        int bc = __builtin_popcount(mask);

        if (bc%2)   ans += ww;

        else        ans -= ww;

    }

    cout<<abs(ans)<<endl;

}


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

using namespace std;



const int K = 18, N = 55;



vector<int> vv[1<<K];



long long C[N][N];



void pre() {

    for (int i=0; i<N; i++) C[i][0] = 1;

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

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

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



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

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

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

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    pre();





    int n, k, S, T;

    cin>>n>>k>>S>>T;



    vector<int> v(n);

    for (int i=0; i<n; i++) cin>>v[i];

    sort(v.begin(), v.end());



    if ( (S&T) != S) {

        cout<<0<<endl;

        return 0;

    }



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

        int x = v[i];



        if ((x&S) != S) continue;

        if ((x&T) != x) continue;



        for (int mask = 0; mask < (1<<K); mask++) {

            if ((mask&S) != S) continue;

            if ((mask&T) != mask) continue;

            int ans = x & (~mask);

            vv[mask].push_back(ans);

        }

    }



    long long ans = 0;

    for (int mask = 0; mask < (1<<K); mask++) {

        if ((mask&S) != S) continue;

        if ((mask&T) != mask) continue;

        sort(vv[mask].begin(), vv[mask].end());



        long long ww = 0;

        while (vv[mask].size()) {

            int last = vv[mask].back();

            int cnt = 0;

            while (vv[mask].size() && vv[mask].back() == last)  cnt++, vv[mask].pop_back();



            ww += C[cnt][k]-1;

        }



        int bc = __builtin_popcount(mask);

        if (bc%2)   ans += ww;

        else        ans -= ww;

    }

    cout<<abs(ans)<<endl;

}


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

using namespace std;



const int K = 18, N = 55;

long long C[N][N];

int cnt[1<<K];



void pre() {

    for (int i=0; i<N; i++) C[i][0] = 1;

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

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

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



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

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

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

}



int main() {

    ios::sync_with_stdio(0);

    cin.tie(0);

    pre();



    int n, k, S, T;

    cin>>n>>k>>S>>T;



    vector<int> v(n);

    for (int i=0; i<n; i++) cin>>v[i];



    long long ans = 0;

    for (int mask = 0; mask < (1<<K); mask++) {

        if ((S&mask) != S || (T&mask) != mask)  continue;



        vector<int> vv;

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

            if ((S&v[i]) != S || (T&v[i]) != v[i])  continue;

            int z = v[i] & (~mask);

            cnt[z]++;

            vv.push_back(z);

        }



        long long ww = 0;

        for (int x: vv){

            ww += C[cnt[x]][k]-1;

            cnt[x] = 0;

        }



        int bc = __builtin_popcount(mask);

        if (bc%2)   ans += ww;

        else        ans -= ww;

    }

    cout<<abs(ans)<<endl;

}


// Fastest known solution for this problem: