Language: C++

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
	template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
	template <class Arg1, class... Args>
	void __f(const char* names, Arg1&& arg1, Args&&... args) {
		const char* sep = strchr(names + 1, ',');
		cerr.write(names, sep - names) << " : " << arg1 << "  ";
		__f(sep + 1, args...);
	}
#else
#define trace(...) 0
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("popcnt")
#pragma GCC target("avx2,sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define _CRT_SECURE_NO_WARNINGS
#endif
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<int,pii> piii;
typedef pair<char,int> pci;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> plll;
 


#define pb push_back
 
// order_of_key (k), find_by_order(k)
#define fi first
#define se second
#define input_arr(a,n) for(__typeof (n) i=0; i<n; ++i) {cin>>a[i];}
#define debug_arr(a,n) {{for(__typeof (n) i=0; i<n; ++i) {cout<<a[i]<<" ";}cout<<"\n";}}
#define maxheap priority_queue<ll>
#define minheap priority_queue<ll,vector<ll> ,greater<ll>>
#define initialise(a, x) memset(a, x, sizeof(a))
#define endl '\n'
#define ordered_set tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>
#define MAX 1000020
#define maxn 200005
#define eps 0.0000001

const ll mod=998244353;
const ll inf=1e18+2;


bool sorter(pair<pii,int> a, pair<pii,int> b)
{
	return a.fi.fi < b.fi.fi;
}

int par[maxn];
int size[maxn];

int find(int x)
{
	if(par[x]==x) return par[x];
	return par[x]=find(par[x]);
}
void merge(int x,int y)
{
	int parx=find(x);
	int pary=find(y);

	if(pary==parx) return;

	if(size[parx]>=size[pary])
	{
		size[parx]+=size[pary];
		par[pary]=parx;
		return;
	}
	size[pary]+=size[parx];
	par[parx]=pary;
}


signed main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// freopen("input.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);

	for(int i=0;i<maxn;i++) {par[i]=i;size[i]=1;}

	int n;
	cin>>n;

	std::vector<pair<pii,int> > v1;
	std::vector<pair<pii,int> > v2;

	for(int i=0;i<n;i++)
	{
		int l,r;
		cin>>l>>r;
		v1.pb({{l,r},i});
		v2.pb({{-l,-r},i});
	}

	sort(v1.begin(), v1.end(), sorter);
	sort(v2.begin(), v2.end(), sorter);

	int ans[n];
	initialise(ans,0);

	ordered_set st1,st2;

	st1.insert({v1[0].fi.se,v1[0].se});

	for(int i=1;i<n;i++)
	{
		pii top=*(st1.find_by_order(0));

		if(top.fi < v1[i].fi.se)
		{
			merge(top.se,v1[i].se);
		}
		else
			st1.insert({v1[i].fi.se, v1[i].se});
	}

	st2.insert({v2[0].fi.se,v2[0].se});

	for(int i=1;i<n;i++)
	{
		pii top=*(st2.find_by_order(0));

		if(top.fi < v2[i].fi.se)
		{
			merge(top.se,v2[i].se);
		}
		else
			st2.insert({v2[i].fi.se, v2[i].se});
	}

	for(int i=0;i<n;i++)
	{
		cout<<size[find(i)]<<'\n';
	}


	
	
	

	return 0;
}

Compiler output:
a.cc: In function 'void merge(int, int)':
a.cc:74:12: error: reference to 'size' is ambiguous
   74 |         if(size[parx]>=size[pary])
      |            ^~~~
In file included from /usr/include/c++/14/string:53,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:60:5: note:                 'int size [200005]'
   60 | int size[maxn];
      |     ^~~~
a.cc:74:24: error: reference to 'size' is ambiguous
   74 |         if(size[parx]>=size[pary])
      |                        ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:60:5: note:                 'int size [200005]'
   60 | int size[maxn];
      |     ^~~~
a.cc:76:17: error: reference to 'size' is ambiguous
   76 |                 size[parx]+=size[pary];
      |                 ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:60:5: note:                 'int size [200005]'
   60 | int size[maxn];
      |     ^~~~
a.cc:76:29: error: reference to 'size' is ambiguous
   76 |                 size[parx]+=size[pary];
      |                             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:60:5: note:                 'int size [200005]'
   60 | int size[maxn];
      |     ^~~~
a.cc:80:9: error: reference to 'size' is ambiguous
   80 |         size[pary]+=size[parx];
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:60:5: note:                 'int size [200005]'
   60 | int size[maxn];
      |     ^~~~
a.cc:80:21: error: reference to 'size' is ambiguous
   80 |         size[pary]+=size[parx];
      |                     ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:60:5: note:                 'int size [200005]'
   60 | int size[maxn];
      |     ^~~~
a.cc: In function 'int main()':
a.cc:95:43: error: reference to 'size' is ambiguous
   95 |         for(int i=0;i<maxn;i++) {par[i]=i;size[i]=1;}
      |                                           ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:60:5: note:                 'int size [200005]'
   60 | int size[maxn];
      |     ^~~~
a.cc:149:23: error: reference to 'size' is ambiguous
  149 |                 cout<<size[find(i)]<<'\n';
      |                       ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:60:5: note:                 'int size [200005]'
   60 | int size[maxn];
      |     ^~~~