stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.393939729997219x):
#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();

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.385454444531906x):
#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();

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

#define ll long long

#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)

#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)

#define EREP(i,a) for(int i=start[(a)];i;i=e[i].next)

template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}

template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}

#define fi first

#define se second

#define mkr(a,b) make_pair(a,b)

inline int read()

{

	int sum=0,p=1;char ch=getchar();

	while(!(('0'<=ch && ch<='9') || ch=='-'))ch=getchar();

	if(ch=='-')p=-1,ch=getchar();

	while('0'<=ch && ch<='9')sum=sum*10+ch-48,ch=getchar();

	return sum*p;

}



#define pii pair<ll,ll>



const int maxn=4e5+20;



pii a[maxn];

int n;

int x[maxn],y[maxn];



inline void init()

{

	n=read();

	REP(i,1,n)x[i]=read(),y[i]=read(),a[i*2-1]=mkr(x[i],i),a[i*2]=mkr(y[i],i);

	REP(i,1,n)if(x[i]>y[i])swap(x[i],y[i]);

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

}



ll Ans=1ll<<60;

int vis[maxn];



inline void doing()

{

	// 1

	if(a[1].se!=a[n*2].se)

	{

		memset(vis,0,sizeof(vis));

		ll L,R;

		vis[a[n*2].se]++;

		REP(i,1,n*2-1)

		{

			if(!vis[a[i].se])vis[a[i].se]++;

			else { L=i;break;}

		}

		memset(vis,0,sizeof(vis));

		vis[a[1].se]++;

		DREP(i,n*2,1)

		{

			if(!vis[a[i].se])vis[a[i].se]++;

			else {R=a[i].fi; break;}

 		}

		memset(vis,0,sizeof(vis));

		REP(i,2,L)

		{

			chkmin(Ans,1ll*(a[n*2].fi-a[1].fi)*(R-a[i].fi));

			chkmax(R,(ll)y[a[i].se]);

		}

		//chkmin(Ans,1ll*(a[n*2].fi-a[1].fi)*(R-L));

	}



	//2

	ll mn1=1ll<<60,mx1=0,mn2=1ll<<60,mx2=0;

	memset(vis,0,sizeof(vis));

	REP(i,1,n*2)

	{

		if(!vis[a[i].se])vis[a[i].se]++,chkmin(mn1,a[i].fi),chkmax(mx1,a[i].fi);

		else chkmin(mn2,a[i].fi),chkmax(mx2,a[i].fi);

	}

	chkmin(Ans,1ll*(mx2-mn2)*(mx1-mn1));

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

	

}



int main()

{

	init();

	doing();

	return 0;

}




// Faster C++ solution for the same problem (measured speedup: 3.204602566726093x):
#include<bits/stdc++.h>

using namespace std;



pair<long long int,long long int> p[200000];



long long int a[2][200001];



int main(){

	ios_base::sync_with_stdio(0);

	cin.tie(0);

	int n;

	cin>>n;

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

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

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

		if(p[i].first<p[i].second)

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

	sort(p,p+n,greater<pair<long long int,long long int> >());

	a[0][n-1]=p[n-1].second;

	a[1][n-1]=p[n-1].first;

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

		a[1][i]=a[1][i+1];

		a[0][i]=min((long long int) p[i].second,a[0][i+1]);

	}

	a[0][n]=a[1][n]=2e9;

	long long int R=p[0].first,B=p[0].second,r=p[0].first,b=p[0].second,ans=6e18;

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

		

		ans=min(ans,(R-min(min(a[0][i+1],r),p[i].second))*(max(B,p[i].first)-min(p[i].first,min(a[1][i+1],b))));

		ans=min(ans,(R-min(min(a[1][i+1],r),p[i].second))*(max(B,p[i].first)-min(p[i].first,min(a[0][i+1],b))));

		

		R=max(R,p[i].first);r=min(r,p[i].first);

		B=max(B,p[i].second);b=min(b,p[i].second);

	}

	ans=min(ans,(R-r)*(B-b));

	cout<<ans<<endl;

}
// Slower C++ solution:
#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; 

}

// Faster C++ solution for the same problem (measured speedup: 1.3495421390941367x):
#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);

    }

}
// Slower C++ solution:
#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; 

}

// Faster C++ solution for the same problem (measured speedup: 1.3502071054516147x):
#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);

    }

}
// Slower C++ solution:
#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; 

}

// Faster C++ solution for the same problem (measured speedup: 1.3498075871571742x):
#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);

    }

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.3422260217111541x):
#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);
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.3853802037559029x):
#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;

}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 1.3429663172081978x):
#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;

}
// Slower C++ solution:
#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;

}

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

// Faster C++ solution for the same problem (measured speedup: 1.3856034000944484x):
#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;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 6.052447799577892x):
#include<bits/stdc++.h>

using namespace std;



const int K = 18, N = 55;

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];

}



bool between(int sub, int super, int x) {

    return (sub&x) == sub && (super&x) == x;

}



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 (!between(S, T, mask))  continue;



        vector<int> vv;

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

            if (between(S, T, v[i]))

                vv.push_back(v[i] & (~mask));



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



        long long ww = 0;

        while (vv.size()) {

            int last = vv.back();

            int cnt = 0;

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

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

        }



        int bc = __builtin_popcount(mask);

        if (bc%2)   ans += ww;

        else        ans -= ww;

    }

    cout<<abs(ans)<<endl;

}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 6.102901739154598x):
#include<bits/stdc++.h>

using namespace std;



const int K = 18, N = 55;

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];

}



bool between(int sub, int super, int x) {

    return (sub&x) == sub && (super&x) == x;

}



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 (!between(S, T, mask))  continue;



        vector<int> vv;

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

            if (between(S, T, v[i]))

                vv.push_back(v[i] & (~mask));



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



        long long ww = 0;

        while (vv.size()) {

            int last = vv.back();

            int cnt = 0;

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

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

        }



        int bc = __builtin_popcount(mask);

        if (bc%2)   ans += ww;

        else        ans -= ww;

    }

    cout<<abs(ans)<<endl;

}