Language: C++

#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long
int n,z;
ll t[111111];
ll nex[50][111111];
int q;

ll che(int x){

	ll l=x+1,r=n,mid=(r+l)/2;
	
	while(r-l>1){
		ll ab=t[mid]-t[x];
		if(ab>z)r=mid;
		else l=mid;
		mid=(r+l)/2;
	}

	return l;
}

int main(){
	cin>>n;
	rep(i,n)cin>>t[i];
	cin>>z;

	rep(i,n){
		nex[0][i]=che(i);
	}

	rep(i,40){
		rep(j,n){
			if(nex[i][j]==n)nex[i+1][j]=n;
			else nex[i+1][j]=nex[i][nex[i][j]];
		}
	}


	cin>>q;
	rep(i,q){
		int a,b;
		cin>>a>>b;
		if(a>b)swap(a,b);
		a--;b--;
		ll l=0,r=n,mid=(r+l)/2;
		ll tmp=a;
		
		while(r-l>1){
			tmp=a;
			ll one=1;
			rep(j,40){
				if((one<<j)&mid)tmp=nex[j][tmp];
			}

			if(tmp>=b)r=mid;
			else l=mid;
			mid=(r+l)/2;
		}
		cout<<r<<endl;
	}
	return 0;
}


Compiler output:
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:19:1: note: in expansion of macro 'll'
   19 | ll t[111111];
      | ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:20:1: note: in expansion of macro 'll'
   20 | ll nex[50][111111];
      | ^~
a.cc:16:12: error: '__int64' does not name a type; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:23:1: note: in expansion of macro 'll'
   23 | ll che(int x){
      | ^~
a.cc: In function 'int main()':
a.cc:39:22: error: 't' was not declared in this scope
   39 |         rep(i,n)cin>>t[i];
      |                      ^
a.cc:43:17: error: 'nex' was not declared in this scope
   43 |                 nex[0][i]=che(i);
      |                 ^~~
a.cc:43:27: error: 'che' was not declared in this scope
   43 |                 nex[0][i]=che(i);
      |                           ^~~
a.cc:48:28: error: 'nex' was not declared in this scope
   48 |                         if(nex[i][j]==n)nex[i+1][j]=n;
      |                            ^~~
a.cc:16:12: error: '__int64' was not declared in this scope; did you mean '__int64_t'?
   16 | #define ll __int64
      |            ^~~~~~~
a.cc:60:17: note: in expansion of macro 'll'
   60 |                 ll l=0,r=n,mid=(r+l)/2;
      |                 ^~
a.cc:61:20: error: expected ';' before 'tmp'
   61 |                 ll tmp=a;
      |                    ^~~
a.cc:63:23: error: 'r' was not declared in this scope
   63 |                 while(r-l>1){
      |                       ^
a.cc:63:25: error: 'l' was not declared in this scope
   63 |                 while(r-l>1){
      |                         ^
a.cc:64:25: error: 'tmp' was not declared in this scope; did you mean 'tm'?
   64 |                         tmp=a;
      |                         ^~~
      |                         tm
a.cc:65:28: error: expected ';' before 'one'
   65 |                         ll one=1;
      |                            ^~~
a.cc:67:37: error: 'one' was not declared in this scope
   67 |                                 if((one<<j)&mid)tmp=nex[j][tmp];
      |                                     ^~~
a.cc:67:45: error: 'mid' was not declared in this scope
   67 |                                 if((one<<j)&mid)tmp=nex[j][tmp];
      |                                             ^~~
a.cc:67:53: error: 'nex' was not declared in this scope
   67 |                                 if((one<<j)&mid)tmp=nex[j][tmp];
      |                                                     ^~~
a.cc:70:37: error: 'mid' was not declared in this scope
   70 |                         if(tmp>=b)r=mid;
      |                                     ^~~
a.cc:71:32: error: 'mid' was not declared in this scope
   71 |                         else l=mid;
      |                                ^~~
a.cc:72:25: error: 'mid' was not declared in this scope
   72 |                         mid=(r+l)/2;
      |                         ^~~
a.cc:74:23: error: 'r' was not declared in this scope
   74 |                 cout<<r<<endl;
      |                       ^