Language: C++

#include<ctime>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<cmath> 
#include<cstring> 
#include<cassert>
#include<string>
#include<sstream>
#include<fstream>
#include<deque>
#include<queue>
#include<vector>
#include<map>
#include<list>
#include<stack>
#include<set>
#include<bitset>
#include<iomanip>
#include<utility>
#include<functional>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cwchar>
#include<cwctype>
#include<exception>
#include<locale>
#include<numeric>
#include<new>
#include<stdexcept>
#include<limits>
using namespace std;

#define ll long long
#define INF 1e9
#define rep(i,n) for(int (i)=0;(i)<n;i++)
#define REP(i,n) for(int (i)=1;(i)<=n;i++)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
#define pii pair<int,int>
#define sz(s) s.size()
#define all(s) (s.begin(),s.end())

const int maxn=100005;
const int mod=1e9+7;
int n,A[2];
int s[maxn];
int tree[maxn*4][2],tag[maxn*4][2];
int next[maxn][2];

void Push(int node,int set){
	if(tag[node][set]){
		tree[node][set]=(tree[node][set]+tag[node][set])%mod;
		tag[node*2][set]=(tag[node*2][set]+tag[node][set])%mod;
		tag[node*2+1][set]=(tag[node*2+1][set]+tag[node][set])%mod;
		tag[node][set]=0;
	}
}

void Pull(int node,int set){
	tree[node][set]=(tree[node][set]+tree[node*2][set])%mod;
	tree[node][set]=(tree[node][set]+tree[node*2+1][set])%mod;
}

void update(int l,int r,int vl,int vr,int node,int val,int set){
	if(vl>vr)return;
	if(l>vr||r<vl)return;
	if(l>=vl&&r<=vr){
		tag[node][set]=(tag[node][set]+val)%mod;
		Push(node,set);
		return;
	}
	Push(node,set);
	int mid=(l+r)>>1;
	update(l,mid,vl,vr,node*2,val,set);
	update(mid+1,r,vl,vr,node*2+1,val,set);
	Pull(node,set);
}

int query(int l,int r,int vl,int vr,int node,int set){
	if(l>vr||r<vl)return 0;
	if(l>=vl&&r<=vr)return (tree[node][set]+tag[node][set])%mod;
	Push(node,set);
	int mid=(l+r)>>1;
	return (query(l,mid,vl,vr,node*2,set)+query(mid+1,r,vl,vr,node*2+1,set))%mod;
}

int main(){
	ios::sync_with_stdio(false);
	cin>>n>>A[0]>>A[1];
	rep(i,n)cin>>s[i];
	next[n-1][0]=next[n-1][1]=n-1;
	for(int i=n-2;i>=0;i--){
		rep(j,2){
			if(s[i+1]-s[i]>=A[j])next[i][j]=next[i+1][j];
			else next[i][j]=i;
		}
	}
	rep(i,2)update(0,n-1,0,0,1,1,i);
	rep(i,n){
		rep(j,2){
			int cur=query(0,n-1,i,i,1,j);
			int low=lower_bound(s,s+n,s[i]+A[j])-s;
			int high=next[i+1][j^1];
//			cout<<i<<" "<<j<<" "<<cur<<endl;
			update(0,n-1,max(low-1,i+1),high,1,cur,j^1);
//			cout<<"update:"<<(j^1)<<" "<<max(low-1,i+1)<<" "<<high<<endl;
//			update(0,n-1,max(low,i+2),min(high+1,n-1),1,cur,j);
//			cout<<"update:"<<j<<" "<<max(low,i+2)<<" "<<min(high+1,n-1)<<endl;
		}
	}
	cout<<(query(0,n-1,n-1,n-1,1,0)+query(0,n-1,n-1,n-1,1,1))%mod;
	return 0;
} 

Compiler output:
a.cc: In function 'int main()':
a.cc:103:9: error: reference to 'next' is ambiguous
  103 |         next[n-1][0]=next[n-1][1]=n-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: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:60:5: note:                 'int next [100005][2]'
   60 | int next[maxn][2];
      |     ^~~~
a.cc:103:22: error: reference to 'next' is ambiguous
  103 |         next[n-1][0]=next[n-1][1]=n-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:60:5: note:                 'int next [100005][2]'
   60 | int next[maxn][2];
      |     ^~~~
a.cc:106:46: error: reference to 'next' is ambiguous
  106 |                         if(s[i+1]-s[i]>=A[j])next[i][j]=next[i+1][j];
      |                                              ^~~~
/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:60:5: note:                 'int next [100005][2]'
   60 | int next[maxn][2];
      |     ^~~~
a.cc:106:57: error: reference to 'next' is ambiguous
  106 |                         if(s[i+1]-s[i]>=A[j])next[i][j]=next[i+1][j];
      |                                                         ^~~~
/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:60:5: note:                 'int next [100005][2]'
   60 | int next[maxn][2];
      |     ^~~~
a.cc:107:30: error: reference to 'next' is ambiguous
  107 |                         else next[i][j]=i;
      |                              ^~~~
/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:60:5: note:                 'int next [100005][2]'
   60 | int next[maxn][2];
      |     ^~~~
a.cc:115:34: error: reference to 'next' is ambiguous
  115 |                         int high=next[i+1][j^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:60:5: note:                 'int next [100005][2]'
   60 | int next[maxn][2];
      |     ^~~~