Language: C++

#include<cmath>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,b,a) for(int i=b;i>=a;i--)
#define efo(i,v,u) for(int i=last[v],u=to[last[v]];i;i=next[i],u=to[i])
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)<(y)?(x):(y))
#define mset(a,x) memset(a,x,sizeof(a))
using namespace std;
typedef long long ll;
void read(int &n)
{
	int t=0,p=1;char ch;
	for(ch=getchar();!('0'<=ch && ch<='9');ch=getchar())
		if(ch=='-') p=-1;
	for(;'0'<=ch && ch<='9';ch=getchar()) t=t*10+ch-'0';
	n=t*p;
}
const int N=4e5+5,M=50000005;
int n,nn,rtn,tot,ext,b[N][2];
struct node
{
	int x,id;
}a[N];
bool cmp(node a,node b){return a.x<b.x;}
int m,co[N],to[M],next[M],last[N],list[N],L[N],R[N];
void link(int u,int v)
{
	to[++m]=v,next[m]=last[u],last[u]=m;
}
bool dfs(int v)
{
	if(co[v^1]) return 0;
	if(co[v]) return 1;
	co[v]=1;
	list[++list[0]]=v;
	efo(i,v,u) if(!co[u])
		if(!dfs(u)) return 0;
	return 1;
}
bool check(int lim)
{
	m=0;mset(last,0);
	fo(i,1,n)
	{
		link(b[i+i-1][0],b[i+i][1]),link(b[i+i][1],b[i+i-1][0]);
		link(b[i+i-1][1],b[i+i][0]),link(b[i+i][0],b[i+i-1][1]);
	}
	fo(i,1,rtn-1) L[i]=1+rtn*(i-1),R[i]=rtn*i;
	L[rtn]=1+rtn*(rtn-1),R[rtn]=nn;
	fo(i,1,rtn)
		fo(j,L[i],R[i]) link(tot+i,b[a[j].id][0]);
	int l=1,r=1;
	fo(i,1,nn)
	{
		while(l<nn && a[i].x-a[l].x>=lim) ++l;
		while(r<nn && a[r+1].x-a[i].x<lim) ++r;
		int ql=min(rtn,(l-1)/rtn+1),qr=min(rtn,(r-1)/rtn+1),qi=min(rtn,(i-1)/rtn+1);
		if(ql==qr)
		{
			fo(j,l,r)
				if(j!=i) link(b[a[i].id][1],b[a[j].id][0]);
		}
		else
		{
			if(ql==qi)
				fo(j,l,i-1) link(b[a[i].id][1],b[a[j].id][0]);
			else
			{
				fo(j,l,R[ql]) link(b[a[i].id][1],b[a[j].id][0]);
				fo(j,ql+1,qi-1) link(b[a[i].id][1],tot+j);
				fo(j,L[qi],i-1) link(b[a[i].id][1],b[a[j].id][0]);
			}
			if(qi==qr)
				fo(j,i+1,r) link(b[a[i].id][1],b[a[j].id][0]);
			else
			{
				fo(j,i+1,R[qi]) link(b[a[i].id][1],b[a[j].id][0]);
				fo(j,qi+1,qr-1) link(b[a[i].id][1],tot+j);
				fo(j,L[qr],r) link(b[a[i].id][1],b[a[j].id][0]);
			}
		}
	}
	mset(co,0);
	fo(i,1,n)
	{
		int x=i+i-1,y=i+i;
		if(!co[b[x][0]] && !co[b[x][1]])
		{
			list[0]=0;
			if(!dfs(b[x][0]))
			{
				fo(j,1,list[0]) co[list[j]]=0;
				list[0]=0;
				if(!dfs(b[x][1])) return 0;
			}
		}
	}
	return 1;
}
int main()
{
	int x,y;
	read(n);nn=n+n;
	fo(i,1,n) read(a[i+i-1].x),read(a[i+i].x);
	tot=1;
	fo(i,1,nn) a[i].id=i,b[i][0]=++tot,b[i][1]=++tot;
	rtn=sqrt(nn);
	sort(a+1,a+nn+1,cmp);
	int l=0,r=a[nn].x+1;
	while(l<r-1)
	{
		int mid=l+r>>1;
		if(check(mid)) l=mid;
		else r=mid;
	}
	printf("%d\n",l);
	return 0;
}

Compiler output:
a.cc: In function 'void link(int, int)':
a.cc:31:19: error: reference to 'next' is ambiguous
   31 |         to[++m]=v,next[m]=last[u],last[u]=m;
      |                   ^~~~
In file included from /usr/include/c++/14/bits/stl_algobase.h:66,
                 from /usr/include/c++/14/bits/specfun.h:43,
                 from /usr/include/c++/14/cmath:3906,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:28:19: note:                 'int next [50000005]'
   28 | int m,co[N],to[M],next[M],last[N],list[N],L[N],R[N];
      |                   ^~~~
a.cc: In function 'bool dfs(int)':
a.cc:7:56: error: reference to 'next' is ambiguous
    7 | #define efo(i,v,u) for(int i=last[v],u=to[last[v]];i;i=next[i],u=to[i])
      |                                                        ^~~~
a.cc:39:9: note: in expansion of macro 'efo'
   39 |         efo(i,v,u) if(!co[u])
      |         ^~~
/usr/include/c++/14/bits/stl_iterator_base_funcs.h:232:5: note: candidates are: 'template<class _InputIterator> constexpr _InputIterator std::next(_InputIterator, typename iterator_traits<_Iter>::difference_type)'
  232 |     next(_InputIterator __x, typename
      |     ^~~~
a.cc:28:19: note:                 'int next [50000005]'
   28 | int m,co[N],to[M],next[M],last[N],list[N],L[N],R[N];
      |                   ^~~~