Language: C++

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

const int M = 1e9 + 7;
const int N = 2e5 + 7;
const int K = 20;

vector <pair <int, int> > g[N][K];
vector <int> kek[N];
bool u[N][K];
bool vis[N];
vector <int> ind, t;

void dos(int i)
{
    if (vis[i])
    {
        return;
    }
    ind.push_back(i);
    vis[i] = true;
    for (auto to : g[i])
    {
        dos(to);
    }
}

void dfs(int i, int k)
{
    if (u[i][k])
    {
        return;
    }
    u[i][k] = true;
    for (auto to : g[i][k])
    {
        dfs(to.first, to.second);
    }
    if (k == 0)
    {
        ind.push_back(i);
    }
}

void zhfs(int i, int k)
{
    if (u[i][k])
    {
        return;
    }
    u[i][k] = true;
    for (auto to : g[i][k])
    {
        dfs(to.first, to.second);
    }
    if (k == 0)
    {
        t.push_back(i);
    }
}

int bin(int a, int n)
{
    if (!n)
    {
        return 1;
    }
    if (n % 2 == 0)
    {
        int t = bin(a, n / 2);
        return (t * (ll) t) % M;
    }
    else
    {
        return (a * (ll) bin(a, n - 1)) % M;
    }
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#else
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
#endif
    int n, x, y;
    scanf("%d%d%d", &n, &x, &y);
    vector <int> fact(n + 1), rfact(n + 1);
    fact[0] = 1;
    rfact[0] = 1;
    for (int i = 1; i <= n; i++)
    {
        fact[i] = (fact[i - 1] * (ll) i) % M;
        rfact[i] = bin(fact[i], M - 2);
    }
    vector <pair <int, int> > d;
    for (int i = 0; i < n; i++)
    {
        int c, w;
        scanf("%d%d", &c, &w);
        d.push_back({w, c});
    }
    sort(d.begin(), d.end());
    for (int i = 0; i < n; i++)
    {
        if (d[0].first + d[i].first > y)
        {
            continue;
        }
        int l = 0, r = n;
        while (l < r - 1)
        {
            int m = (l + r) / 2;
            if (d[m].first + d[i].first <= y)
            {
                l = m;
            }
            else
            {
                r = m;
            }
        }
        int cur = 0;
        for (int p = 0; p <= l; p++)
        {
            g[i].push_back(p);
            g[p].push_back(i);
        }
    }
    /*
    memset(u, 0, sizeof u);
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < K; j++)
        {
             zhfs(i, j);
        }
    }
    reverse(t.begin(), t.end());
    memset(u, 0, sizeof u);
    */
    ll ans = 1;
    for (int i = 0; i < n; i++)
    {
        if (!vis[i])
        {
            ind.clear();
            dos(i);
            int sz = ind.size();
            ans = (ans * (ll) fact[sz]) % M;
            map <int, int> cnt;
            for (auto c : ind)
            {
                cnt[c.second]++;
            }
            for (auto c : cnt)
            {
                ans = (ans * (ll) rfact[c.second]) % M;
            }
        }
    }
    printf("%lld\n", ans);
}


Compiler output:
a.cc: In function 'void dos(int)':
a.cc:27:13: error: cannot convert 'std::vector<std::pair<int, int> >' to 'int'
   27 |         dos(to);
      |             ^~
      |             |
      |             std::vector<std::pair<int, int> >
a.cc:17:14: note:   initializing argument 1 of 'void dos(int)'
   17 | void dos(int i)
      |          ~~~~^
a.cc: In function 'int main()':
a.cc:131:18: error: request for member 'push_back' in 'g[i]', which is of non-class type 'std::vector<std::pair<int, int> > [20]'
  131 |             g[i].push_back(p);
      |                  ^~~~~~~~~
a.cc:132:18: error: request for member 'push_back' in 'g[p]', which is of non-class type 'std::vector<std::pair<int, int> > [20]'
  132 |             g[p].push_back(i);
      |                  ^~~~~~~~~
a.cc:159:23: error: request for member 'second' in 'c', which is of non-class type 'int'
  159 |                 cnt[c.second]++;
      |                       ^~~~~~