Language: C++

#include <bits/stdc++.h>
using namespace std;
#define N 210000
#define mod 1000000007
#define ll long long
int n,X,Y,cnt;
int c[N],w[N],a[N],pos[N],num[N],jc[N],njc[N];
vector<int>v1[N],v2[N];
int cmp(int x,int y){return v1[x][0]<v1[y][0];}
int qpow(int x,int y)
{
	int ret=1;
	while(y)
	{
		if(y&1)ret=(ll)ret*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}
	return ret;
}
void init()
{
	jc[0]=njc[0]=1;
	for(int i=1;i<=n;i++)jc[i]=(ll)jc[i-1]*i%mod;
	njc[n]=qpow(jc[n],mod-2);
	for(int i=n-1;i>=1;i--)njc[i]=(ll)njc[i+1]*(i+1)%mod;
}
int C(int x,int y){return (ll)jc[x]*njc[y]%mod*njc[x-y]%mod;}
int main()
{
	//freopen("tt.in","r",stdin);
	scanf("%d%d%d",&n,&X,&Y);
	init();
	for(int i=1;i<=n;i++)
		scanf("%d%d",&c[i],&w[i]),a[++cnt]=c[i];
	sort(a+1,a+1+cnt);
	cnt=unique(a+1,a+1+cnt)-a-1;
	for(int i=1;i<=n;i++)
	{
		c[i]=lower_bound(a+1,a+1+cnt,c[i])-a;
		v1[c[i]].push_back(w[i]);
	}
	for(int i=1;i<=cnt;i++)
	{
		sort(v1[i].begin(),v1[i].end());
		pos[i]=i;
	}
	sort(pos+1,pos+1+cnt,cmp);
	for(int i=1;i<=cnt;i++)
		v2[i]=v1[pos[i]];
	num[1]=upper_bound(v2[1].begin(),v2[1].end(),X-v2[1][0])-v2[1].begin();
	if(cnt>1)num[1]=max(num[1],
	upper_bound(v2[1].begin(),v2[1].end(),Y-v2[2][0])-v2[1].begin());

	for(int i=2;i<=cnt;i++)
	{
		num[i]=upper_bound(v2[i].begin(),v2[i].end(),X-v2[i][0])-v2[i].begin();
		num[i]=max(num[i],
		upper_bound(v2[i].begin(),v2[i].end(),Y-v2[1][0])-v2[i].begin());
	}
	int sum=num[1],ans=1;
	for(int i=2;i<=cnt;i++)
	{
		if(v2[i][0]+v2[1][0]>Y)break;
		ans=(ll)ans*C(sum+num[i],sum)%mod;
		sum+=num[i];
	}
	printf("%d\n",ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:51:28: error: no matching function for call to 'max(int&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   51 |         if(cnt>1)num[1]=max(num[1],
      |                         ~~~^~~~~~~~
   52 |         upper_bound(v2[1].begin(),v2[1].end(),Y-v2[2][0])-v2[1].begin());
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:51:28: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   51 |         if(cnt>1)num[1]=max(num[1],
      |                         ~~~^~~~~~~~
   52 |         upper_bound(v2[1].begin(),v2[1].end(),Y-v2[2][0])-v2[1].begin());
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:51:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   51 |         if(cnt>1)num[1]=max(num[1],
      |                         ~~~^~~~~~~~
   52 |         upper_bound(v2[1].begin(),v2[1].end(),Y-v2[2][0])-v2[1].begin());
      |         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:57:27: error: no matching function for call to 'max(int&, __gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type)'
   57 |                 num[i]=max(num[i],
      |                        ~~~^~~~~~~~
   58 |                 upper_bound(v2[i].begin(),v2[i].end(),Y-v2[1][0])-v2[i].begin());
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  257 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:257:5: note:   template argument deduction/substitution failed:
a.cc:57:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and '__gnu_cxx::__normal_iterator<int*, std::vector<int> >::difference_type' {aka 'long int'})
   57 |                 num[i]=max(num[i],
      |                        ~~~^~~~~~~~
   58 |                 upper_bound(v2[i].begin(),v2[i].end(),Y-v2[1][0])-v2[i].begin());
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  303 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:303:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5706:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(initializer_list<_Tp>)'
 5706 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5706:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5716:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(initializer_list<_Tp>, _Compare)'
 5716 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5716:5: note:   template argument deduction/substitution failed:
a.cc:57:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   57 |                 num[i]=max(num[i],
      |                        ~~~^~~~~~~~
   58 |                 upper_bound(v2[i].begin(),v2[i].end(),Y-v2[1][0])-v2[i].begin());
      |                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~