Language: C++

#include<bits/stdc++.h>
#define maxn 10005
using namespace std;
typedef long long LL;
int read()
{
	char c;int sum=0,f=1;c=getchar();
	while(c<'0' || c>'9'){if(c=='-')f=-1;c=getchar();}
	while(c>='0' && c<='9'){sum=sum*10+c-'0';c=getchar();}
	return sum*f;
}
int n;
struct node{
	int x,id,rev;
	friend bool operator <(node a,node b){return a.x<b.x;}
}d[maxn*2];
int a[maxn],b[maxn],c[maxn*2];
int leaf[maxn*2],lson[maxn*100],rson[maxn*100],tot;
int head[maxn*2],to[maxn*4],nex[maxn*4],cnt,num;
int root,top,sum,index,s[maxn*2],dfn[maxn*2],low[maxn*2],bel[maxn*2];
bool vis[maxn*2];
void add(int u,int v)
{
	to[++cnt]=v;
	nex[cnt]=head[u];
	head[u]=cnt;
}
void build(int &x,int l,int r)
{
	if(!x) x=++tot;
	if(l==r)
	{
		leaf[l]=x;
		return;
	}
	int mid=(l+r)>>1;
	build(lson[x],l,mid);build(rson[x],mid+1,r);
}
void connect(int x,int l,int r)
{
	if(l==r) return;
	add(x,lson[x]);add(x,rson[x]);
	int mid=(l+r)>>1;
	connect(lson[x],l,mid);connect(rson[x],mid+1,r);
}
void insert(int x,int l,int r,int ql,int qr,int id)
{
	if(ql>qr) return;
	if(l==ql && qr==r)
	{
		add(id,x);
		return;
	}
	int mid=(l+r)>>1;
	if(qr<=mid) insert(lson[x],l,mid,ql,qr,id);
	else if(ql>mid) insert(rson[x],mid+1,r,ql,qr,id);
	else insert(lson[x],l,mid,ql,mid,id),insert(rson[x],mid+1,r,mid+1,qr,id);
}
void ins(int id,int x,int dis)
{
    int L,R,l,r,mid;
    l=x;r=2*n;
    while(l<r)
	{
        mid=(l+r+1)/2;
        if(c[mid]-c[x]<dis) l=mid;
		else r=mid-1;
    }
    R=l;
    l=1;r=x;
    while(l<r)
	{
        mid=(l+r)/2;
        if(c[x]-c[mid]<dis) r=mid;
		else l=mid+1;
    }
    L=l;
    insert(root,1,2*n,L,x-1,id);
    insert(root,1,2*n,x+1,R,id);
}
void tarjan(int x)
{
	s[++top]=x;
	dfn[x]=low[x]=++index;
	vis[x]=1;
	for(int i=head[x];i;i=nex[i])
	{
		if(!dfn[to[i]])
		{
			tarjan(to[i]);
			low[x]=min(low[x],low[to[i]]);
		}
		else if(vis[to[i]])
		low[x]=min(low[x],dfn[to[i]]);
	}
	if(dfn[x]==low[x])
	{
		sum++;
		do
		{
			vis[s[top]]=0;bel[s[top]]=sum;
			top--;
		}
		while(s[top+1]!=x);
	}
}
bool check(int x)
{
	cnt=0;
	memset(head,0,sizeof(head));
	connect(root,1,2*n);
	for(int i=1;i<=n;i++)
	{
		add(leaf[b[i]],i*2-1);
        add(leaf[a[i]],i*2);
        ins(i*2-1,a[i],x);
        ins(i*2,b[i],x);
	}
	top=index=sum=0;
	memset(vis,0,sizeof(vis));
	memset(dfn,0,sizeof(dfn));
	memset(low,0,sizeof(low));
	for(int i=1;i<=num;i++)
	if(!dfn[i]) tarjan(i);
	for(int i=1;i<=n;i++)
    if(bel[i*2-1]==bel[i*2]) return false;
    return true;
}
int main()
{
	n=read();
	for(int i=1;i<=n;i++)
	{
		a[i]=read(),b[i]=read();
		d[i*2-1].x=a[i];d[i*2-1].rev=0;
		d[i*2].x=b[i];d[i*2].rev=1;
		d[i*2-1].id=d[i*2].id=i;
	}
	sort(d+1,d+2*n+1);
	for(int i=1;i<=2*n;i++)
	{
		if(!d[i].rev) a[d[i].id]=i;
		else b[d[i].id]=i;
		c[i]=d[i].x;
	}
	tot=2*n;
    build(root,1,2*n);
    num=tot;
    int l=0,r=1000000000,mid;
    while(l<r)
	{
        mid=(l+r+1)/2;
        if (check(mid)) l=mid;else r=mid-1;
    }
    printf("%d\n",l);
	return 0;
}

Compiler output:
a.cc:20:18: error: 'int index' redeclared as different kind of entity
   20 | int root,top,sum,index,s[maxn*2],dfn[maxn*2],low[maxn*2],bel[maxn*2];
      |                  ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121,
                 from a.cc:1:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'void tarjan(int)':
a.cc:84:25: error: no pre-increment operator for type
   84 |         dfn[x]=low[x]=++index;
      |                         ^~~~~
a.cc: In function 'bool check(int)':
a.cc:119:23: error: overloaded function with no contextual type information
  119 |         top=index=sum=0;
      |                       ^