Language: C++

#include <bits/stdc++.h>
using namespace std;
#ifdef __DEBUG__
    void debug_out() { cerr << endl; } 
    template <typename Head, typename... Tail>
    void debug_out(Head H, Tail... T) {cerr << " " << H; debug_out(T...);}
    #define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 
#endif

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }



#include <atcoder/lazysegtree>

int N;
vector<int> Idx;
vector<pii> P;
inline void input(){
    fast_io();
    cin >> N;
    P.resize(N);
    Idx.resize(N);
    for (int i = 0; i < N; i++)
    {
        int x,y; cin >> x >> y;
        x--, y--;
        P[i] = make_pair(x, y);
        Idx[x] = i;
    }
}

#include <atcoder/fenwicktree>
#include <atcoder/segtree>


inline int wrong_solve(){
    // 何度でも移動できるのが味噌
    // 移動が一度しかできない場合の答え。
    atcoder::fenwick_tree<int> fw_d(N), fw_u(N);
    vector<int> Ans(N,0);
    auto cmp_x = [](pii a, pii b){return a.first < b.first;};
    sort(P.begin(),P.end(), cmp_x);
    for (int i = 0; i < N; i++)
    {
        int x = i;
        int y = P[i].second;
        fw_d.add(y, 1);
        int a = fw_d.sum(0, y);
        Ans[Idx[x]] = N-1-y-i+a;
    }
    for(auto a:Ans) cout << a << endl;
    return 0;
}  

#include <atcoder/dsu>
int ON2solve(){
    // O(N^2)
    vector<int> Ans(N,0);
    auto cmp_x = [](pii a, pii b){return a.first < b.first;};
    sort(P.begin(),P.end(), cmp_x);
    debug(P);
    atcoder::dsu uf(N+1);
    vector<bool> used(N,false);
    for (int i = 0; i < N; i++)
    {
        if(used[P[i].second]) continue;
        for (int j = i + 1 ; j < N; j++)
        {
            if(P[i].second < P[j].second){
                used[P[j].second] = true;
                uf.merge(i, j);
            }
        }
        
    }

    for (int i = 0; i < N; i++) Ans[Idx[i]] = uf.size(i);
    for(auto a:Ans) cout << a << "\n";    
    return 0;
}

int main()
{
    input();
    ON2solve();
    return 0;
}


Compiler output:
a.cc:33:10: fatal error: atcoder/lazysegtree: No such file or directory
   33 | #include <atcoder/lazysegtree>
      |          ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.