Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sqr(x) ((x)*(x))
#define mp make_pair
#define uint unsigned
#define PI pair<int,int>
inline char gc(){
    static char buf[100000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
}
#define gc getchar
inline int read(){
	int x = 0; char ch = gc(); bool positive = 1;
	for (; !isdigit(ch); ch = gc())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = gc())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(int a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
inline int rnd(int x){
	return (rand()<<16|rand())%x;
}
const int N=200005,mod=1000000007;
vector<int> v[N];
int c[N],w[N],father[N],q[N],vis[N],x,y,n;
inline int getfather(int x){
	return father[x]==x?x:father[x]=getfather(father[x]);
}
map<int,int> M[N];
inline int ksm(ll a,int b){
	int ans=1;
	for(;b;b>>=1){
		if(b&1)ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
inline bool cmp(int a,int b){
	return w[a]<w[b];
}
void ins (int a,int b){
	//cout<<a<<" "<<b<<" "<<w[a]<<" "<<w[b]<<endl;
	int t1=getfather(a),t2=getfather(b);
	if(t1!=t2)father[t2]=t1;
}
void check(int a,int b){
	if(c[a]!=c[b]&&w[a]+w[b]<=y)ins(b,a);
}
int main(){
	n=read(); x=read(); y=read();
	for(int i=1;i<=n;i++){
		c[i]=read(); w[i]=read(); v[c[i]].push_back(i); father[i]=q[i]=i;
	}
	for(int i=1;i<=n;i++)if(v[i].size()){
		sort(v[i].begin(),v[i].end(),cmp); vis[v[i][0]]=1;
		for(unsigned j=1;j<v[i].size();i++)if(w[v[i][j]]+w[v[i][0]]<=x)ins(v[i][0],v[i][j]);
	}
	sort(&q[1],&q[n+1],cmp); int jb=0;
	for(int i=2;i<=n;i++){
		if(!jb)jb=q[i];
	}//else cout<<w[i]<<" "<<i<<" "<<father[i]<<endl;
	for(int i=1;i<=n;i++){
		check(i,jb); check(i,q[1]);
	}
	for(int i=1;i<=n;i++)for(int 
	for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
	ll ans=1;
	for(int i=1;i<=n;i++)if(getfather(i)==i){
		int sum=0;
		for(map<int,int>::iterator it=M[i].begin();it!=M[i].end();it++){
			sum+=it->second; for(int j=1;j<=it->second;j++)ans=ans*ksm(j,mod-2)%mod;
		}
		//cout<<i<<" "<<sum<<" "<<ans<<endl;
		for(int j=1;j<=sum;j++)ans=ans*j%mod;
	}
	cout<<ans<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:78:9: error: expected unqualified-id before 'for'
   78 |         for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
      |         ^~~
a.cc:77:37: error: expected ';' before 'for'
   77 |         for(int i=1;i<=n;i++)for(int
      |                                     ^
      |                                     ;
   78 |         for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
      |         ~~~                          
a.cc:78:9: error: expected primary-expression before 'for'
   78 |         for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
      |         ^~~
a.cc:77:37: error: expected ';' before 'for'
   77 |         for(int i=1;i<=n;i++)for(int
      |                                     ^
      |                                     ;
   78 |         for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
      |         ~~~                          
a.cc:78:9: error: expected primary-expression before 'for'
   78 |         for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
      |         ^~~
a.cc:77:37: error: expected ')' before 'for'
   77 |         for(int i=1;i<=n;i++)for(int
      |                                 ~   ^
      |                                     )
   78 |         for(int i=1;i<=n;i++)M[getfather(i)][c[i]]++;
      |         ~~~