criyle/codenet-compile-errors huggingface dataset:
Language: C

//此程序使用了qt专属名称，请勿模仿。侵权必究！！！
//我真是太菜了……
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int N=1000100;
int n,m,l,k;
int a[N],f[N][30];
inline int read()
{
	int sum=0,flag=1;
	char c;
	for(;c<'0'||c>'9';c=getchar())if(c=='-') flag=-1;
	for(;c>='0'&&c<='9';c=getchar())sum=(sum<<1)+(sum<<3)+c-'0';
	return sum*flag;
}
int main()
{
//	freopen("trav.in","r",stdin);
//	freopen("trav.out","w",stdout);
	n=read();
	k=log2(n)+1;
	for(int i=1;i<=n;++i)
	{
		a[i]=read();
	}
	l=read();
	for(int i=1,j=2;i<=n;++i)
	{
		while(j<=n)
		{
			if(a[j]-a[i]<=l)
			{
				++j;
			}
			else
			{
				break;
			}
		}
		f[i][0]=j-1;
	}
	for(int i=1;i<=k;++i)
	{
		for(int j=1;j<=n;++j)
		{
			f[j][i]=f[f[j][i-1]][i-1];
		}
	}
	m=read();
	while(m--)
	{
		int x=read(),y=read(),z=0;
		if(x>y)
		{
			swap(x,y);
		}
		for(int i=k;i>=0;--i)
		{
			if(f[x][i]<y)
			{
				z+=1<<i;
				x=f[x][i];
			}
		}
		printf("%d\n",z+1);
	}
	return 0;
}





Compiler output:
main.c:3:9: fatal error: bits/stdc++.h: No such file or directory
    3 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<cstdio>
#include<vector>
using namespace std;
const int N=100002;
int n,L,q,x[N],i,j,k,a,b,l,r;
int h[N],t[N],v[N],Ans[N];
int dep[N],p[N];
struct Uzi{
	int d,id;
};
vector<Uzi>g[N];
void add(int a,int b){
	t[++k]=h[a];
	h[a]=k;
	v[k]=b;
}
void init(){
	scanf("%d",&n);
	for(i=1;i<=n;i++)
		scanf("%d",x+i);
	scanf("%d",&L);
	for(l=r=1;l<n;l++){
		while(r<n&&x[r+1]-x[l]<=L)
			r++;
		add(r,l);
	}
}
void dfs1(int i){
	for(int j=h[i];j;j=t[j]){
		dep[v[j]]=dep[i]+1;
		dfs1(v[j]);
	}
}
void dfs(int i){
	p[dep[i]]=i;
	for(int j=0;j<g[i].size();j++){
		if(dep[g[i][j]].d==dep[i])
			Ans[g[i][j].id]=1;
		else{
		if(p[dep[g[i][j].d]]>=g[i][j].d)
			Ans[g[i][j].id]=dep[i]-dep[g[i][j].d];
		else
			Ans[g[i][j].id]=dep[i]-dep[g[i][j].d]+1;
		}
	}
	for(int j=h[i];j;j=t[j])
		dfs(v[j]);
}
void work(){
	scanf("%d",&q);
	for(i=1;i<=q;i++){
		scanf("%d%d",&a,&b);
		if(a>b)
			a^=b^=a^=b;
		g[a].push_back((Uzi){b,i});
	}
	dfs1(n);
	dfs(n);
	for(i=1;i<=q;i++)
		printf("%d\n",Ans[i]);
	//while(1);
}
int main(){
	init();
	work();
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:37:23: error: no match for 'operator[]' (operand types are 'int [100002]' and '__gnu_cxx::__alloc_traits<std::allocator<Uzi>, Uzi>::value_type' {aka 'Uzi'})
   37 |                 if(dep[g[i][j]].d==dep[i])
      |                       ^
Language: C

#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[100005];
int dp[100005][50];

ll read()
{
	ll sum=0;int 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 main()
{
    int n=read();
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    int l=read(),q=read();
    for(int i=1;i<=n;i++)
    {
        int id=upper_bound(a+1,a+1+n,a[i]+l)-a-1;
        if(a[i]+l>=a[n])
            dp[i][0]=n;
        else
            dp[i][0]=id;
    }
     
    for(int i=1;i<=30;i++)
    {
        for(int j=1;j<=n;j++)
            dp[j][i]=dp[dp[j][i-1]][i-1];
    }
    while(q--)
    {
        int s=read(),e=read();
        if(e<s)
            swap(s,e);  
        long long ans=0;
        for(int i=30;i>=0;i--)
        {
            if(dp[s][i]<e)
            {
                ans=ans+(1ll<<i);
                s=dp[s][i];
            }
        }
        printf("%lld\n",ans+1);
    }
    return 0;
}

Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C

#include<bits/stdc++.h>
#define ll int
using namespace std;
ll n,l,q;
ll x[100005],a[100005],b[100005];
ll le[100005],ri[100005];

ll read()
{
	ll sum=0;int 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;
}

void pre(int p)
{
	int lll=p,rr=p;
	int mx=x[p]+l,mn=x[p]-l;
	for(int i=0;i;i++)
	{
		int b=1<<i;
		if(x[p+b]<=mx) rr=p+b;
		else break;
	}
	for(int i=0;i;i++)
	{
		int b=1<<i;
		if(x[p-b]>=mn) lll=p-b;
		else break;
	}
	while(x[rr+1]<=mx) rr++;
	while(x[lll-1]>=mn) lll++;
	le[p]=lll;
	ri[p]=rr;
}

int main()
{
	n=read();
	for(int i=1;i<=n;i++) x[i]=read();
	l=read(),q=read();
	for(int i=1;i<=n;i++) pre(i);
	for(int i=1;i<=q;i++)
	{
		int ans=1;
		int s=read(),e=read();
		if(s<e)
		{
			while(ri[s]<e)
			{
				s=ri[s];
				ans++;
			}
		}
		else
		while(le[s]>e)
		{
			s=le[s];
			ans++;
		}
		printf("%d\n",ans);
	}
}


Compiler output:
main.c:1:9: fatal error: bits/stdc++.h: No such file or directory
    1 | #include<bits/stdc++.h>
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn=100010;
int n,x[maxn],l,q,a,b,vis[maxn],nextnext[maxn][20];
inline int read()
{
	int x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9')
	{
		if(ch=='-')
			f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9')
	{
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int query(int s,int e)
{
	int ans=0;
	while(s<e)
	{
		for(int i=19; i>=0; i--)
		{
			if(nextnext[s][i]<=e&&nextnext[s][i])
			{
				s=nextnext[s][i];
				ans+=(1<<i);
				break;
			}
			if(i==0)
			{
				s=nextnext[s][i];
				ans+=(1<<i);
				break;
			} 
		}
		return ans;
	}
	int main()
	{
		n=read();
		for(int i=1; i<=n; i++)
			x[i]=read();
		l=read();
		for(int i=1; i<=n; i++)
			nextnext[i][0]=upper_bound(x+1+1,x+n+1,x[i]+l)-x-1;
		for(int i=1; i<=19; i++)
			for(int j=1; (long long)l*(1<<i)+x[j]<=x[n]; j++)
				nextnext[j][i]=nextnext[nextnext[j][i-1]][i-1];
		q=read();
		while(q--)
		{
			a=read(),b=read();
			if(a>b)
				swap(a,b);
			printf("%d\n",query(a,b));
		}
		return 0;
	}

Compiler output:
a.cc: In function 'int query(int, int)':
a.cc:49:17: warning: empty parentheses were disambiguated as a function declaration [-Wvexing-parse]
   49 |         int main()
      |                 ^~
a.cc:49:17: note: remove parentheses to default-initialize a variable
   49 |         int main()
      |                 ^~
      |                 --
a.cc:49:17: note: or replace parentheses with braces to value-initialize a variable
a.cc:50:9: error: a function-definition is not allowed here before '{' token
   50 |         {
      |         ^
a.cc:69:10: error: expected '}' at end of input
   69 |         }
      |          ^
a.cc:28:1: note: to match this '{'
   28 | {
      | ^
a.cc:69:10: warning: control reaches end of non-void function [-Wreturn-type]
   69 |         }
      |          ^
Language: C++

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fre(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout)
using namespace std;

inline int read(){
	int sum=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){sum=sum*10+ch-'0';ch=getchar();}
	return f*sum;
}

const int N=100005;
struct node{int l,r,pre,nxt,to2,sp2,to1,sp1;}a[N];
struct ques{int l,r,id,ans;}q[N];
int n,m,L,p[N];
int bl[N],gap;

inline bool cmp(ques a,ques b){
	return a.l!=b.l? a.l<b.l:a.r<b.r;
}

inline bool cmp1(ques a,ques b){return a.id<b.id;}

inline int work2(int l,int r){
	int ans=0;
	while(bl[l]!=bl[r]) ans+=a[l].sp2,l=a[l].to2;
	while(l<r) ans++,l=a[l].nxt;
	return ans;
}

inline int work1(int l,int r){
	int ans=0;
	while(bl[l]!=bl[r]) ans+=a[l].sp1,l=a[l].to1;
	while(l>r) ans++,l=a[l].pre;
	return ans;
}

signed main(){
	n=read();gap=sqrt(n);
	for(int i=1;i<=n;i++) p[i]=read();
	for(int i=1;i<=n;i++) bl[i]=(i-1)/gap+1;
	L=read();m=read();
	for(int i=1;i<=m;i++) q[i].l=read(),q[i].r=read();
	for(int i=1;i<=m;i++) q[i].id=i;
	for(int i=1;i<=m;i++) if(q[i].l>q[i].r) swap(q[i].l,q[i].r);
	for(int i=1;i<=n;i++){
		int k=p[i]+L;
		k=upper_bound(p+1,p+n+1,k)-p-1;
		a[i].nxt=k;
		if(!a[k].l||i<a[k].l) a[k].l=i;
		a[k].r=max(a[k].r,i);
		a[i].pre=lower_bound(p+1,p+n+1,p[i]-L)-p;
	}
	for(int i=1;i<=n;i++){
		int p=i;
		while(bl[p]==bl[i]&&bl[p]!=bl[n]&&a[p].nxt!=p) p=a[p].nxt,a[i].sp2++;
		a[i].to2=p;
		p=i;
		while(bl[p]==bl[i]&&bl[p]!=bl[1]&&a[p].pre!=p) p=a[p].pre,a[i].sp1++;
		a[i].to1=p;
	}
	for(int i=1;i<=m;i++){
		if(q[i].l<q[i].r) q[i].ans=work2(q[i].l,q[i].r);
		else q[i].ans=work1(q[i].l,q[i].r);
	}
	for(int i=1;i<=m;i++) printf("%d\n",q[i].ans);
	return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:42:22: error: 'sqrt' was not declared in this scope
   42 |         n=read();gap=sqrt(n);
      |                      ^~~~
Language: C++

#include <iostream>
using namespace std;

int d[100002][20];

int power2(int n){
    int res = 1;
    for(int i = 0; i < n; i++) res *= 2;
    return res;
}

int main()
{
    int n;
    cin >> n;
    int x[100002];
    for(int i = 0; i < n; i++) cin >> x[i];
    int l;
    cin >> l;
    for(int i = 0; i < n; i++){
        d[i][0] = (upper_bound(x, x + n, x[i] + l) - x) - 1;
    }
    for(int j = 1; j < 20; j++){
        for(int i = 0; i < n; i++){
            d[i][j] = d[d[i][j - 1]][j - 1];
        }
    }
    int q;
    cin >> q;
    for(int i = 0; i < q; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b) swap(a, b);
        int ans = 0;
        while(d[a][0] < b){
            for(int j = 0; j < 20; j++){
                if(d[a][j] >= b){
                    a = d[a][j - 1];
                    ans += power2(j - 1);
                    break;
                }
            }
        }
        ans++;
        cout << ans << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:21:20: error: 'upper_bound' was not declared in this scope
   21 |         d[i][0] = (upper_bound(x, x + n, x[i] + l) - x) - 1;
      |                    ^~~~~~~~~~~
Language: C++

#include <assert.h>
#include <limits.h>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <complex>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using ll = long long;
using P = std::pair<ll, ll>;

#define rep(i, a, b) for (ll(i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(i) std::cout <<"debug "<< i << "\n"

//const ll MOD = 998244353;
const ll MOD = 1e9+7;

ll max[20][100010];
 
int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  //問題文中の添え字が0-indexか1-indexか確認!

  ll n,l,q;

  std::cin>>n;
  std::vector<ll> x(n);
  rep(i,0,n)std::cin>>x[i];

  std::cin>>l>>q;

  rep(i,0,n)max[0][i]=(ll)(std::upper_bound(all(x),x[i]+l)-x.begin())-1;

  rep(k,1,20){
    rep(i,0,n){
      max[k][i]=max[k-1][max[k-1][i]];
    }
  }



  rep(sdf,0,q){
    ll a,b;
    std::cin>>a>>b;
    a--;b--;
    if(a>b)std::swap(a,b);
    ll now=a,temp=0;
    for(ll i=(1<<19),pow=19;i>0;i/=2,pow--){
      if(max[pow][now]<b){
        temp+=i;
        now=max[pow][now];
      }
    }
    std::cout<<ans+1<<"\n";
  }

  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:66:16: error: 'ans' was not declared in this scope; did you mean 'abs'?
   66 |     std::cout<<ans+1<<"\n";
      |                ^~~
      |                abs
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>
#include<random>



#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()
using namespace std;
int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 500050;


vector<int>G[200020];
bool visited[200020];

int dp[100010][30];
vector<int>a;
int N, L, Q;
int func(int n,int k){
	if (dp[n][k] != 0)return dp[n][k];
	int pos = a[n];
	if (k == 0) {
		int nex = pos + L;
		auto itr = ub(a, nex);
		itr--;
		int res = itr - a.begin();
		dp[n][k] = res;
		return res;
	}
	else {
		int b = func(n, k - 1);
		int res = func(b, k - 1);
		dp[n][k] = res;
		return res;
	}
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	cin >> N;
	a.resize(N);
	REP(i, N) {
		cin >> a[i];
	}
	a.pb(INF);
	cin >> L >> Q;
	REP(i, Q) {
		int a, b; cin >> a >> b;
		a--, b--;
		if (a > b)swap(a, b);
		int ans = 0;
		bool ok = false;
		REPR(j, 29, 0) {
			if (func(a, j) < b) {
				ans+=1<<j;
				a = func(a, j);
			}
		}
		ans++;
		//pe("ans:");
		print(ans);
	}
}


Compiler output:
a.cc:93:30: error: macro "REPR" passed 3 arguments, but takes just 2
   93 |                 REPR(j, 29, 0) {
      |                              ^
a.cc:25:9: note: macro "REPR" defined here
   25 | #define REPR(i, n) for(int i = n;i >= 0;i--)
      |         ^~~~
a.cc: In function 'int main()':
a.cc:93:17: error: 'REPR' was not declared in this scope
   93 |                 REPR(j, 29, 0) {
      |                 ^~~~
Language: C++

#include<bits/stdc++.h>
using namespace std;
typedef int long long
typedef pair<int,int> ii;
int n,rmq[200005][20],x[200005],l,q;
signed main()
{
	queue<ii> que;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		cin>>x[i]; 
	}
	cin>>l>>q;
	for(int j=0;j<=18;j++)
	{
		for(int i=1;i<=n;i++)
		{
			rmq[i][j]=999999;
		}
	}
	int cnt=0;
	while(1)
	{
		if(cnt==n) break;
		cnt++;
		que.push(ii(x[cnt],cnt));
		while(1)
		{
			if(x[cnt]-que.front().first>l)
			{
				rmq[que.front().second][0]=cnt-1;
				que.pop();
			}
			else break;
		}
	}
	while(!que.empty())
	{
		rmq[que.front().second][0]=n;
		que.pop();
	}
	rmq[n][0]=999999;
	for(int j=1;(1<<j)<=n;j++)
	{
		for(int i=1;i+(1<<j)<n;i++)
		{
			if(rmq[i][j-1]!=n)
			rmq[i][j]=rmq[rmq[i][j-1]][j-1];
		}
	}
	cout<<rmq[5][1]<<" "<<rmq[7][0]<<"\n";
	while(q--)
	{
		int u,v,res=0;
		cin>>u>>v;
		if(u>v) swap(u,v);
		for(int i=20;i>=0;i--)
		{
			if(rmq[u][i]<v)
			{
				res+=(1<<i);
				u=rmq[u][i];
			}
		}
		if(u<v) res++;
		cout<<res<<"\n";
	}
}

Compiler output:
a.cc:4:1: error: duplicate 'typedef'
    4 | typedef pair<int,int> ii;
      | ^~~~~~~
      | -------
a.cc:4:23: error: invalid declarator before 'ii'
    4 | typedef pair<int,int> ii;
      |                       ^~
a.cc: In function 'int main()':
a.cc:8:15: error: 'ii' was not declared in this scope
    8 |         queue<ii> que;
      |               ^~
a.cc:8:17: error: template argument 1 is invalid
    8 |         queue<ii> que;
      |                 ^
a.cc:8:17: error: template argument 2 is invalid
a.cc:27:21: error: request for member 'push' in 'que', which is of non-class type 'int'
   27 |                 que.push(ii(x[cnt],cnt));
      |                     ^~~~
a.cc:30:39: error: request for member 'front' in 'que', which is of non-class type 'int'
   30 |                         if(x[cnt]-que.front().first>l)
      |                                       ^~~~~
a.cc:32:41: error: request for member 'front' in 'que', which is of non-class type 'int'
   32 |                                 rmq[que.front().second][0]=cnt-1;
      |                                         ^~~~~
a.cc:33:37: error: request for member 'pop' in 'que', which is of non-class type 'int'
   33 |                                 que.pop();
      |                                     ^~~
a.cc:38:20: error: request for member 'empty' in 'que', which is of non-class type 'int'
   38 |         while(!que.empty())
      |                    ^~~~~
a.cc:40:25: error: request for member 'front' in 'que', which is of non-class type 'int'
   40 |                 rmq[que.front().second][0]=n;
      |                         ^~~~~
a.cc:41:21: error: request for member 'pop' in 'que', which is of non-class type 'int'
   41 |                 que.pop();
      |                     ^~~
Language: C++

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;
import java.util.TreeMap;

public class Main {
	  static int MOD=1000000007;
	  static long p[][]=new long[405][405];
	  static long sum[][]=new long[405][405];
	  static long dp[][]=new long[35][100005];
	  static long a[]=new long[100005];
	  static long b[]=new long[405];
      public static void main(String[] args) {
    	  Scanner in=new Scanner( new BufferedReader(new InputStreamReader(System.in)))	;
          int n=in.nextInt();
         
         for(int i=0;i<=30;i++)
        	 dp[i]=new long[100005];
          for(int i=1;i<=n;i++)
          {
        	  a[i]=in.nextLong();
          }
          int L=in.nextInt();
          for(int i=1;i<=n;i++)
          {
        	  int pos=find(1,n,a[i]+L);
        	  //System.out.println("pos:"+pos);
        	  dp[0][i]=pos;
          }
          for(int i=1;i<=30;i++)
          {
        	  for(int j=1;j<=n;j++)
        	  {
        		  dp[i][j]=dp[i-1][(int) dp[i-1][j]];
        	  }
          }
          int q=in.nextInt();
          while(q-->0)
          {
        	  int l=in.nextInt();
        	  int r=in.nextInt();
        	  if(l>r) {int t=l;l=r;r=t;}
        	  long ans=0;
        	  for(int i=30;i>=0;i--)
        	  {
        		  if(dp[i][l]<r)
        		  {
        			  ans+=(1<<i);
        			  l=(int) dp[i][l];
        		  }
        	  }
        	  System.out.println(ans+1);
          }
    	  return;
      }
	private static int find(int l, int r, long v) {
		// TODO 自动生成的方法存根
		while(l<r)
		{
			int mid=(l+r+1)>>1;
		    if(a[mid]<=v)
		    	l=mid;
		    else
		    	r=mid-1;
		}
		return l;
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.BufferedReader;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.InputStreamReader;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Scanner;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.TreeMap;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:6:1: error: expected unqualified-id before 'public'
    6 | public class Main {
      | ^~~~~~
Language: C++

#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

const ll INF = 1e18;
const ll MOD = 1e9 + 7;

int main()
{
    int n, l, q, x[112345], a[112345], b[112345];

    int root[112345];
    int cld[112345];

    cin >> n;
    REP(i, n)
    cin >> x[i];
    cin >> l >> q;
    REP(i, q)
    {
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        if (a[i] > b[i])
            swap(a[i], b[i]);
    }

    memset(cld, -1, sizeof(cld));
    memset(root, -1, sizeof(root));

    for (int i = 0; i < n; i++)
    {
        if (root[i] != -1)
            continue;

        root[i] = i;

        int cur = i;
        int j = i + 1;

        while (j < n)
        {
            if (x[j + 1] - x[cur] > l || j == n - 1)
            {
                cld[cur] = j;
                if (root[j] != -1)
                    break;
                root[j] = i;
                cur = j;
            }
            j++;
        }
    }

    vector<int> sum[112345];
    bool used[112345];
    fill(used, used + n, false);

    for (int i = 0; i < n; i++)
    {
        int r = root[i];

        if (used[r])
            continue;

        used[r] = true;

        sum[r].push_back(0);

        int j = i;

        while (true)
        {
            if (j == n - 1)
                break;

            int nex = cld[j];

            sum[r].push_back(sum[r][sum[r].size() - 1] + x[nex] - x[j]);

            j = nex;
        }
    }

    REP(i, q)
    {
        int rt = root[a[i]];
        int d = x[b[i]] - x[a[i]];

        int l = 0, r = sum[rt].size();

        while (r - l > 1)
        {
            int mid = (r + l) / 2;

            if (sum[rt][mid] >= d + (x[a[i]] - x[rt]))
                r = mid;
            else
                l = mid;
        }

        int l_ = -1, r_ = sum[rt].size();

        while (r_ - l_ > 1)
        {
            int mid = (r_ + l_) / 2;

            if (sum[rt][mid] >= (x[a[i]] - x[rt]))
                r_ = mid;
            else
                l_ = mid;
        }

        cout << r - r_ << endl;
    }

    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:44:5: error: 'memset' was not declared in this scope
   44 |     memset(cld, -1, sizeof(cld));
      |     ^~~~~~
a.cc:9:1: note: 'memset' is defined in header '<cstring>'; this is probably fixable by adding '#include <cstring>'
    8 | #include <queue>
  +++ |+#include <cstring>
    9 |
Language: C++

#include <bits/stdc++.h>
#define sp ' '
#define nyan "(=^・ω・^=)"
#define mkp make_pair
#define intmax 2147483647
#define llmax 9223372036854775807
#define lP pair<ll,ll>
#define iP pair<int,int>
typedef long long ll;
using namespace std;
const int mod = 1000000007;
const int mod998 = 998244353;


int N, L, Q, x[100000], a, b, p, l[100000][18], r[100000][18];

int fl(int x) {
	if (x == -1) {
		if (a == b) {
			return 0;
		}
		else {
			return 1;
		}
	}
	if (l[a][x] >= b) {
		return fl(x - 1);
	}
	else {
		a = l[a][x];
		return (1 << x) + fl(x - 1);
	}
}
int fr(int x) {
	if (x == -1) {
		if (a == b) {
			return 0;
		}
		else {
			return 1;
		}
	}
	if (r[a][x] =< b) {
		return fr(x - 1);
	}
	else {
		a = r[a][x];
		return (1 << x) + fr(x - 1);
	}
	return 0;
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> x[i];
	}
	cin >> L >> Q;
	for (int i = 0; i < N; ++i) {
		for (; p < N && x[p] <= x[i] + L; ++p);
		l[i][0] = p - 1;
	}
	p = N - 1;
	for (int i = N - 1; i >= 0; --i) {
		for (; p >= 0 && x[i] - L<=x[p]; --p);
		r[i][0] = p + 1;
	}
	for (int i = 1; i < 18; ++i) {
		for (int j = 0; j < N; ++j) {
			l[j][i] = l[l[j][i - 1]][i - 1];
			r[j][i] = r[r[j][i - 1]][i - 1];
		}
	}
	while (Q--) {
		cin >> a >> b;
		--a;
		--b;
		if (a < b) {
			cout << fl(17) << endl;
		}
		else {
			cout << fr(17) << endl;
		}
	}
	return 0;
}

Compiler output:
a.cc: In function 'int fr(int)':
a.cc:43:22: error: expected primary-expression before '<' token
   43 |         if (r[a][x] =< b) {
      |                      ^
Language: C++

#include<cstdio>
#include<algorithm>
#include"lib/graph.hpp"
int x[1001]={};
int main(){
    int n,l,q;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)scanf("%d",&x[i]);
    scanf("%d%d",&l,&q);
    if(n>1000||q>1000){
        printf("0\n");
        return 0;
    }
    Graph g(n+1);
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(std::abs(x[i]-x[j])<=l){
                g.addEdge(i,j);
            }
        }
    }
    for(int i=0;i<q;i++){
        int a,b;
        scanf("%d%d",&a,&b);
        weight minl[1001];
        g.dijkstra(minl,a);
        printf("%lld\n",minl[b]);
    }
    return 0;
}

Compiler output:
a.cc:3:9: fatal error: lib/graph.hpp: No such file or directory
    3 | #include"lib/graph.hpp"
      |         ^~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include<bits/stdc++.h>

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
typedef struct aaaaa{
  int x,y,t;
}Grid;
using namespace std;
int main(){
  int n;cin>>n;
  vector<ll>ori(n);
  vector<vector<ll> >vvll(n);
  map<ll,int>mli;
  bool used[n+10]={};
  for(int i=0;i<n;i++)
    cin>>ori[i];
  ll L;cin>>L;
  int q;cin>>q;
  ori.pb(llINF);
  int cnt=0;
  for(int i=0;i<n;i++){
    if(used[i])continue;
    vvll[cnt].pb(ori[i]);
    ll hoge=ori[i];
    mli[i]=cnt;
    while(hoge!=llINF){
      auto po = upper_bound(ALL(ori),hoge+L);
      if(*po == llINF){
	if(ori[ori.size()-2]-hoge<=L){
	  mli[ori.size()-2]=cnt;
	  used[ori.size()-2]=true;
	  vvll[cnt].pb(ori[ori.size()-2]);
	  break;
	}
      }
      int num=(po-ori.begin())-1);
      used[num]=true;
      hoge = ori[num];
      mli[num]=cnt;
      vvll[cnt].pb(ori[num]);
    }
    cnt++;
  }
  /* for(int i=0;i<vvll.size();i++){
    for(int j=0;j<vvll[i].size();j++)
      cout<<vvll[i][j]<<" ";
    cout<<endl;
    }*/

  for(int i=0;i<q;i++){
    int le,ri;cin>>le>>ri;
    //cout<<mli[min(le,ri)-1]<<endl;
    //cout<<ori[min(le,ri)-1]<<" "<<ori[max(le,ri)-1]<<endl;
    auto a = lower_bound(ALL(vvll[mli[min(le,ri)-1]]),ori[min(le,ri)-1]);
    auto b = lower_bound(ALL(vvll[mli[min(le,ri)-1]]),ori[max(le,ri)-1]);
    cout<<(b-a)<<endl;
  }
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:45:33: error: expected ',' or ';' before ')' token
   45 |       int num=(po-ori.begin())-1);
      |                                 ^
Language: C++

# include <cstdio>
# include <iostream>
# include <algorithm>
# define Maxn 100005
using namespace std;
inline int read()
{
	int ok=1,k=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		ok=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return ok*k;
}
struct node{
	int x;
	int xh;
}sd[Maxn];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int f[Maxn],next[Maxn];
int main()
{
	int n,maxn;
	n=read();
	for(int i=1;i<=n;i++)
	{
		sd[i].xh=i;
	    f[i]=read();
		sd[i].x=f[i];
	}
	int ll;
	ll=read();
	sort(sd+1,sd+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		int tot=f[i]+ll;
		int l=1,r=n;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(sd[mid].x>tot)
			r=mid-1;
			else
			l=mid+1; 
		}
		next[i]=sd[r].xh;
	}
	int m;
	m=read();
	for(int i=1;i<=m;i++)
	{
		int l,r,ans=0;
		l=read();
		r=read();
		if(f[l]>f[r])
		swap(l,r);
		while(f[l]<f[r])
		{
			ans++;
			l=next[l];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:17: error: reference to 'next' is ambiguous
   57 |                 next[i]=sd[r].xh;
      |                 ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/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:31:13: note:                 'int next [100005]'
   31 | int f[Maxn],next[Maxn];
      |             ^~~~
a.cc:71:27: error: reference to 'next' is ambiguous
   71 |                         l=next[l];
      |                           ^~~~
/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:31:13: note:                 'int next [100005]'
   31 | int f[Maxn],next[Maxn];
      |             ^~~~
Language: C++

# include "stdio.h"
# include "iostream"
# include "algorithm"
# define Maxn 100005
using namespace std;
inline int read()
{
	int ok=1,k=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		ok=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return ok*k;
}
struct node{
	int x;
	int xh;
}sd[Maxn];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int f[Maxn],next[Maxn];
int main()
{
	int n,maxn;
	n=read();
	for(int i=1;i<=n;i++)
	{
		sd[i].xh=i;
	    f[i]=read();
		sd[i].x=f[i];
	}
	int ll;
	ll=read();
	sort(sd+1,sd+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		int tot=f[i]+ll;
		int l=1,r=n;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(sd[mid].x>tot)
			r=mid-1;
			else
			l=mid+1; 
		}
		next[i]=sd[r].xh;
	}
	int m;
	m=read();
	for(int i=1;i<=m;i++)
	{
		int l,r,ans=0;
		l=read();
		r=read();
		if(f[l]>f[r])
		swap(l,r);
		while(f[l]<f[r])
		{
			ans++;
			l=next[l];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:17: error: reference to 'next' is ambiguous
   57 |                 next[i]=sd[r].xh;
      |                 ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/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:31:13: note:                 'int next [100005]'
   31 | int f[Maxn],next[Maxn];
      |             ^~~~
a.cc:71:27: error: reference to 'next' is ambiguous
   71 |                         l=next[l];
      |                           ^~~~
/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:31:13: note:                 'int next [100005]'
   31 | int f[Maxn],next[Maxn];
      |             ^~~~
Language: C

# include "cstdio"
# include "iostream"
# include "algorithm"
# define Maxn 100005
using namespace std;
inline int read()
{
	int ok=1,k=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		ok=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return ok*k;
}
struct node{
	int x;
	int xh;
}sd[Maxn];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int f[Maxn],next[Maxn];
int main()
{
	int n,maxn;
	n=read();
	for(int i=1;i<=n;i++)
	{
		sd[i].xh=i;
	    f[i]=read();
		sd[i].x=f[i];
	}
	int ll;
	ll=read();
	sort(sd+1,sd+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		int tot=f[i]+ll;
		int l=1,r=n;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(sd[mid].x>tot)
			r=mid-1;
			else
			l=mid+1; 
		}
		next[i]=sd[r].xh;
	}
	int m;
	m=read();
	for(int i=1;i<=m;i++)
	{
		int l,r,ans=0;
		l=read();
		r=read();
		if(f[l]>f[r])
		swap(l,r);
		while(f[l]<f[r])
		{
			ans++;
			l=next[l];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Compiler output:
main.c:1:11: fatal error: cstdio: No such file or directory
    1 | # include "cstdio"
      |           ^~~~~~~~
compilation terminated.
Language: C++

# include "cstdio"
# include "iostream"
# include "algorithm"
# define Maxn 100005
using namespace std;
inline int read()
{
	int ok=1,k=0;
	char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
		ok=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		k=k*10+c-'0';
		c=getchar();
	}
	return ok*k;
}
struct node{
	int x;
	int xh;
}sd[Maxn];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int f[Maxn],next[Maxn];
int main()
{
	int n,maxn;
	n=read();
	for(int i=1;i<=n;i++)
	{
		sd[i].xh=i;
	    f[i]=read();
		sd[i].x=f[i];
	}
	int ll;
	ll=read();
	sort(sd+1,sd+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		int tot=f[i]+ll;
		int l=1,r=n;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(sd[mid].x>tot)
			r=mid-1;
			else
			l=mid+1; 
		}
		next[i]=sd[r].xh;
	}
	int m;
	m=read();
	for(int i=1;i<=m;i++)
	{
		int l,r,ans=0;
		l=read();
		r=read();
		if(f[l]>f[r])
		swap(l,r);
		while(f[l]<f[r])
		{
			ans++;
			l=next[l];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:17: error: reference to 'next' is ambiguous
   57 |                 next[i]=sd[r].xh;
      |                 ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/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:31:13: note:                 'int next [100005]'
   31 | int f[Maxn],next[Maxn];
      |             ^~~~
a.cc:71:27: error: reference to 'next' is ambiguous
   71 |                         l=next[l];
      |                           ^~~~
/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:31:13: note:                 'int next [100005]'
   31 | int f[Maxn],next[Maxn];
      |             ^~~~
Language: C++

# include "cstdio"
# include "iostream"
# include "algorithm"
# define Maxn 100005
using namespace std;
#define BF_N 1<<17
char buf[BF_N]; int sl,sr;
char gc(){
	return sl==sr&&(sr=(sl=0)+fread(buf,1,BF_N,stdin),sl==sr)?EOF:buf[sl++];
}
int read(){
	int ans=0,k=1; char c=gc();
	while(!isdigit(c)){if(c=='-')k=-1; c=gc();}
	while(isdigit(c)){ans=ans*10+c-'0'; c=gc();}
	return k*ans;
}

struct node{
	int x;
	int xh;
}sd[Maxn];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int f[Maxn],next[Maxn];
int main()
{
	int n,maxn;
	n=read();
	for(int i=1;i<=n;i++)
	{
		sd[i].xh=i;
	    f[i]=read();
		sd[i].x=f[i];
	}
	int ll;
	ll=read();
	sort(sd+1,sd+n+1,cmp);
	for(int i=1;i<=n;i++)
	{
		int tot=f[i]+ll;
		int l=1,r=n;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(sd[mid].x>tot)
			r=mid-1;
			else
			l=mid+1; 
		}
		next[i]=sd[r].xh;
	}
	int m;
	m=read();
	for(int i=1;i<=m;i++)
	{
		int l,r,ans=0;
		l=read();
		r=read();
		if(f[l]>f[r])
		swap(l,r);
		while(f[l]<f[r])
		{
			ans++;
			l=next[l];
		}
		printf("%d\n",ans);
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:52:17: error: reference to 'next' is ambiguous
   52 |                 next[i]=sd[r].xh;
      |                 ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:2:
/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:26:13: note:                 'int next [100005]'
   26 | int f[Maxn],next[Maxn];
      |             ^~~~
a.cc:66:27: error: reference to 'next' is ambiguous
   66 |                         l=next[l];
      |                           ^~~~
/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:26:13: note:                 'int next [100005]'
   26 | int f[Maxn],next[Maxn];
      |             ^~~~
Language: C++

#include<bits/stdc++.h>

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)

using namespace std;

typedef long long ll;

#define MAX 100010
ll N,Q,L;
ll x[MAX],a,b;

int nex[MAX][70];

void compute() {
  rep(i,N) {
    nex[i][0] = ( upper_bound(x,x+N,x[i]+L) - x ) - 1;
    assert( nex[i][0] != 0 );
  }

  rep(j,67) rep(i,N) nex[i][j+1] = nex[nex[i][j]][j];
  cin >> Q;
  rep(_,Q) {
    cin >> a >> b;
    --a, --b;
    if( !( a < b ) ) swap(a,b);
    //cout << "[*] " << a << " -> " << b << endl;
    ll cost = 0;
    while( a != b ) {
      int go = 0;
      go = upper_bound(nex[a],nex[a]+67,b) - nex[a] - 1;
      cost += (1LL<<go);
      //cout << "  " << a <<" -[" << go << "]->" << nex[a][go] << endl;
      a = nex[a][go];
    }
    cout << cost << endl;
  }
}

int main() {


Compiler output:
a.cc: In function 'int main()':
a.cc:41:13: error: expected '}' at end of input
   41 | int main() {
      |            ~^
Language: C++

#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;


long long N, x[100000], L;
int next[100000], before[100000];
int Q;


int main(){
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
    cin >> L;


    // dist [l, r) <= L
    int r = 0;
    for(int l = 0; l < N; l++){
        while(r < N && x[r] - x[l] <= L){
            r++;
        }
        next[l] = r - 1;
    }

        

    
    cin >> Q;
    for(int i = 0; i < Q; i++){
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a > b){
            int tmp = a;
            a = b;
            b = tmp;
        }
        int cnt = 0;
        while(a < b){
            a = next[a];
            cnt++;
        }
        cout << cnt << endl;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:26:9: error: reference to 'next' is ambiguous
   26 |         next[l] = r - 1;
      |         ^~~~
In file included from /usr/include/c++/14/string:47,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 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:8:5: note:                 'int next [100000]'
    8 | int next[100000], before[100000];
      |     ^~~~
a.cc:45:17: error: reference to 'next' is ambiguous
   45 |             a = next[a];
      |                 ^~~~
/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:8:5: note:                 'int next [100000]'
    8 | int next[100000], before[100000];
      |     ^~~~
Language: C++

#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int main() {
  int N;cin >> N;
  vint x(N);
  repeat(i,N) cin >> x[i];
  x.push_back(INF);
  ll L;cin >> L;
  vector<vint> rmax(20,vint(N,0));
  repeat(i,N){
    rmax[0][i] = upper_bound(x.begin(),x.end(),x[i]+L)-x.begin()-1;
  }
  repeat(k,18){
    repeat(i,N){
      rmax[k+1][i] = rmax[k][rmax[k][i]];
    }
  }
  debugArray(rmax[0],N);
  int Q;cin >> Q;
  repeat(q,Q){
    int a,b;cin >> a >> b;
    a--;b--;
    if(a>b) swap(a,b);
    ll ans = 0;
    for(int k=18;k>=0;k--){
      //debug(a);
      if(rmax[k][a] >= b) continue;
      ans |= 1<<k;
      a = rmax[k][a];
    }
    ans++;
    cout << ans <<endl;
  }
  cerr << bitset<20>(524287) << endl;
  return 0;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:59:11: error: 'bitset' was not declared in this scope
   59 |   cerr << bitset<20>(524287) << endl;
      |           ^~~~~~
a.cc:14:1: note: 'std::bitset' is defined in header '<bitset>'; this is probably fixable by adding '#include <bitset>'
   13 | #include <functional>
  +++ |+#include <bitset>
   14 | 
a.cc:59:30: error: invalid operands of types 'int' and '<unresolved overloaded function type>' to binary 'operator<<'
   59 |   cerr << bitset<20>(524287) << endl;
      |                     ~~~~~~~~~^~~~~~~
Language: C++

#include <bits/stdc++.h>

using namespace std;
int hotel[200005];
int jump[200005][20];

/* Phan chuan bi LCA */
void pre_process()
{
    for(int i=1;i<=n;i++)
    {
        int p = upper_bound(hotel,hotel+n+2,hotel[i]+k) - hotel ;
        jump[i][0] = p-1;
    }

    for(int j=1;j<20;j++)
    {
        for(int i=1;i<=n;i++)
        {
            if(jump[i][j-1]!=-1)
                jump[i][j] = jump[jump[i][j-1]][j-1];
        }
    }
}

/* Phan tinh LCA */
int solve(int u,int v)
{
    if(u==v)
        return 0;
    int ans = 0;
    for(int i=17;i>=0;i--)
    {
        if(jump[u][i]<v)
        {
            u = jump[u][i];
            ans+=(1<<i);
        }
    }

    return ans+1;
}

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

    int n,k,q;
    cin>>n;

    hotel[n+1] = 2e9;
    memset(jump,-1,sizeof jump);

    for(int i=1;i<=n;i++)
    {
        cin>>hotel[i];
    }
    cin>>k;
    cin>>q;

    while(q--)
    {
        int u,v;
        cin>>u>>v;
        if(u>v)
            swap(u,v);

        cout<<solve(u,v)<<'\n';
    }

}


Compiler output:
a.cc: In function 'void pre_process()':
a.cc:10:20: error: 'n' was not declared in this scope
   10 |     for(int i=1;i<=n;i++)
      |                    ^
a.cc:12:54: error: 'k' was not declared in this scope
   12 |         int p = upper_bound(hotel,hotel+n+2,hotel[i]+k) - hotel ;
      |                                                      ^
a.cc:18:24: error: 'n' was not declared in this scope
   18 |         for(int i=1;i<=n;i++)
      |                        ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int n, x[100010], l, q, a, b, dp[100010][20];

int main() {
    memset(dp, -1, sizeof(dp));
    scanf("%d", &n);
    for(int i = 0; i < n; i++) scanf("%d", &x[i]);
    scanf("%d", &l);
    for(int i = n-1; i >= 0; i--) {
        int L = i, R = n;
        while(L + 1 < R) {
            int M = (L + R)/2;
            if(x[M] - x[i] > l) R = M;
            else L = M;
        }
        dp[i][0] = L;a
    }
    for(int j = 1; (1<<j) < n; j++) {
        for(int i = 0; i < n; i++) {
            if(dp[i][j-1] != -1) dp[i][j] = dp[dp[i][j-1]][j-1];
        }
    }
    scanf("%d", &q);
    while(q--) {
        scanf("%d%d", &a, &b); int ans = 0;
        if(a > b) swap(a, b);
        a--, b--;
        for(int i = 19; i >= 0; i--) {
            if(dp[a][i] != -1 && x[dp[a][i]] < x[b]) ans += (1<<i), a = dp[a][i];
        }
        printf("%d\n", ans+1);
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:18:23: error: expected ';' before '}' token
   18 |         dp[i][0] = L;a
      |                       ^
      |                       ;
   19 |     }
      |     ~
Language: C++

#include<bits/stdc++.h>
using namespace std;

int main()
{
    int n, a[200001], sum[200001], maxi[200001], q, dis, c, b, itr = 1;
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    cin >> dis;
    for(int i = 1; i < n; i++){
        int l = i + 1, r = n;
        while(l != r){
            int mid = (l + r) / 2;
            if(a[mid] - a[i] < dis) l = mid + 1;
            else r = mid;
        }
        if(a[l] - a[i] > dis) l--;
        maxi[i] = l;
    }
    maxi[n] = n;
    sum[1] = 0;
    while(itr < n){
        int itr2 = itr;
        itr = maxi[itr];
        for(int i = itr2 + 1; i <= itr; i++) sum[i] = sum[itr2] + 1;
    }
    cin >> q;
    for(int i = 0; i < q; i++){
        cin >> c >> b;
        if(sum[b] == sum[c]) cout << 1 << endl;
        else if(abs(b - c) <= l * (sum[b] - sum[c])) cout << abs(sum[b] - sum[c]) << endl;
        else cout << abs(sum[b] - sum[c]) + 1 << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:31:31: error: 'l' was not declared in this scope
   31 |         else if(abs(b - c) <= l * (sum[b] - sum[c])) cout << abs(sum[b] - sum[c]) << endl;
      |                               ^
Language: C++

#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
#define MAXN 100010
int x[MAXN],fa[MAXN][20],step[MAXN],end[MAXN];
vector<int>G[MAXN];
void dfs(int u,int p)
{
	step[u]=step[p]+1;
	for(int i=1,j=2;j<step[u];i++,j<<=1)
		fa[u][i]=fa[fa[u][i-1]][i-1],end[u]=i;
	for(int i=0;i<G[u].size();i++)
		dfs(G[u][i],u);
}
int Solve(int a,int b)
{
	if(a>b) swap(a,b);
	int d=step[a]-step[b];
	int ret=0;
	for(int i=0;(1<<i)<=d;i++)
		if(d&(1<<i))
			a=fa[a][i];
	if(a>=b) return d;
	else if(a<b) return d+1;
}
int main()
{
	int n,L,q,a,b;
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&x[i]);
	scanf("%d",&L);
	int l=1,r=1;
	while(l<n)
	{
		while(r<=n&&x[r]-x[l]<=L) r++;
		fa[l][0]=r-1;
		G[r-1].push_back(l);
		l++;
	}
	dfs(n,0);
	scanf("%d",&q);
	while(q--)
	{
		scanf("%d%d",&a,&b);
		printf("%d\n",Solve(a,b));
	}
}

Compiler output:
a.cc: In function 'void dfs(int, int)':
a.cc:12:46: error: reference to 'end' is ambiguous
   12 |                 fa[u][i]=fa[fa[u][i-1]][i-1],end[u]=i;
      |                                              ^~~
In file included from /usr/include/c++/14/vector:69,
                 from a.cc:2:
/usr/include/c++/14/bits/range_access.h:116:37: note: candidates are: 'template<class _Tp> const _Tp* std::end(const valarray<_Tp>&)'
  116 |   template<typename _Tp> const _Tp* end(const valarray<_Tp>&) noexcept;
      |                                     ^~~
/usr/include/c++/14/bits/range_access.h:115:31: note:                 'template<class _Tp> _Tp* std::end(valarray<_Tp>&)'
  115 |   template<typename _Tp> _Tp* end(valarray<_Tp>&) noexcept;
      |                               ^~~
/usr/include/c++/14/bits/range_access.h:106:5: note:                 'template<class _Tp, long unsigned int _Nm> constexpr _Tp* std::end(_Tp (&)[_Nm])'
  106 |     end(_Tp (&__arr)[_Nm]) noexcept
      |     ^~~
/usr/include/c++/14/bits/range_access.h:85:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(const _Container&)'
   85 |     end(const _Container& __cont) -> decltype(__cont.end())
      |     ^~~
/usr/include/c++/14/bits/range_access.h:74:5: note:                 'template<class _Container> constexpr decltype (__cont.end()) std::end(_Container&)'
   74 |     end(_Container& __cont) -> decltype(__cont.end())
      |     ^~~
In file included from /usr/include/c++/14/bits/stl_vector.h:63,
                 from /usr/include/c++/14/vector:66:
/usr/include/c++/14/initializer_list:99:5: note:                 'template<class _Tp> constexpr const _Tp* std::end(initializer_list<_Tp>)'
   99 |     end(initializer_list<_Tp> __ils) noexcept
      |     ^~~
a.cc:6:37: note:                 'int end [100010]'
    6 | int x[MAXN],fa[MAXN][20],step[MAXN],end[MAXN];
      |                                     ^~~
a.cc: In function 'int Solve(int, int)':
a.cc:26:1: warning: control reaches end of non-void function [-Wreturn-type]
   26 | }
      | ^