Language: C++

import java.io.*;
import java.util.*;
public class Main {
	public static void main(String args[]) {
		Solver_agc009c solver = new Solver_agc009c();
		solver.input();
		solver.solve();
	}
}
class FastScanner {
	BufferedReader br;
	StringTokenizer st;
	public FastScanner(Reader in) {
		br = new BufferedReader(in);
	}

	String next() {
		while (st == null || !st.hasMoreElements()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				e.printStackTrace();
				throw new RuntimeException("Can't read more inputs.");
			}
		}
		return st.nextToken();
	}
	int nextInt() {
		return Integer.parseInt(next());
	}
	long nextLong() {
		return Long.parseLong(next());
	}
	double nextDouble() {
		return Double.parseDouble(next());
	}
	String readNextLine() {
		String str = "";
		try {
			str = br.readLine();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return str;
	}
}
class Solver_agc009c {
	static FastScanner in = new FastScanner(new InputStreamReader(System.in));
	static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
	final int mod = (int)1e9 + 7;
	int n;
	long a, b, s[];
	int f[], g[], sum_f[], sum_g[];
	void input() {
		n = in.nextInt();
		a = in.nextLong();
		b = in.nextLong();
		s = new long[n + 1];
		for(int i = 0; i < n; i++) s[i] = in.nextLong();
		s[n] = Long.MAX_VALUE;
		f = new int[n + 1];
		g = new int[n + 1];
		sum_f = new int[n + 1];
		sum_g = new int[n + 1];
	}
	int addmod(int a, int b) { return (a + b) % mod; }
	void solve() {
		f[n - 1] = g[n - 1] = 1;
		sum_f[n - 1] = sum_g[n - 1] = 1;
		int l_f = n, r_f = n, l_g = n, r_g = n;
		for(int i = n - 2; i >= 0; i--) {
			while(l_f - 1 > i + 1 && s[l_f - 1] - s[i] >= a) l_f--;
			while(l_g - 1 > i + 1 && s[l_g - 1] - s[i] >= b) l_g--;
			if(s[i + 2] - s[i + 1] < b) r_f = i + 2;
			if(s[i + 2] - s[i + 1] < a) r_g = i + 2;
			if(l_f <= r_f) {
				f[i] = addmod(sum_g[l_f - 1], mod - sum_g[r_f]);
			}
			if(l_g <= r_g) {
				g[i] = addmod(sum_f[l_g - 1], mod - sum_f[r_g]);
			}
			sum_f[i] = addmod(f[i], sum_f[i + 1]);
			sum_g[i] = addmod(g[i], sum_g[i + 1]);
		}
		int ans = addmod(f[0], g[0]);
		for(int i = 1; i < n; i++) {
			if(s[i] - s[i - 1] < a) break;
			ans = addmod(ans, f[i]);
		}
		for(int i = 1; i < n; i++) {
			if(s[i] - s[i - 1] < b) break;
			ans = addmod(ans, g[i]);
		}
		out.println(ans);
		out.close();
	}
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.*;
      | ^~~~~~
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.util.*;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: expected unqualified-id before 'public'
    3 | public class Main {
      | ^~~~~~
a.cc:11:9: error: 'BufferedReader' does not name a type
   11 |         BufferedReader br;
      |         ^~~~~~~~~~~~~~
a.cc:12:9: error: 'StringTokenizer' does not name a type
   12 |         StringTokenizer st;
      |         ^~~~~~~~~~~~~~~
a.cc:13:15: error: expected ':' before 'FastScanner'
   13 |         public FastScanner(Reader in) {
      |               ^~~~~~~~~~~~
      |               :
a.cc:13:34: error: expected ')' before 'in'
   13 |         public FastScanner(Reader in) {
      |                           ~      ^~~
      |                                  )
a.cc:17:9: error: 'String' does not name a type
   17 |         String next() {
      |         ^~~~~~
a.cc:37:9: error: 'String' does not name a type
   37 |         String readNextLine() {
      |         ^~~~~~
a.cc:46:2: error: expected ';' after class definition
   46 | }
      |  ^
      |  ;
a.cc: In member function 'int FastScanner::nextInt()':
a.cc:29:24: error: 'Integer' was not declared in this scope
   29 |                 return Integer.parseInt(next());
      |                        ^~~~~~~
a.cc:29:41: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   29 |                 return Integer.parseInt(next());
      |                                         ^~~~
      |                                         nextInt
a.cc: In member function 'long int FastScanner::nextLong()':
a.cc:32:24: error: 'Long' was not declared in this scope; did you mean 'long'?
   32 |                 return Long.parseLong(next());
      |                        ^~~~
      |                        long
a.cc:32:39: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   32 |                 return Long.parseLong(next());
      |                                       ^~~~
      |                                       nextInt
a.cc: In member function 'double FastScanner::nextDouble()':
a.cc:35:24: error: 'Double' was not declared in this scope; did you mean 'double'?
   35 |                 return Double.parseDouble(next());
      |                        ^~~~~~
      |                        double
a.cc:35:43: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   35 |                 return Double.parseDouble(next());
      |                                           ^~~~
      |                                           nextInt
a.cc: At global scope:
a.cc:48:53: error: expected type-specifier before 'InputStreamReader'
   48 |         static FastScanner in = new FastScanner(new InputStreamReader(System.in));
      |                                                     ^~~~~~~~~~~~~~~~~
a.cc:48:28: error: 'constexpr' needed for in-class initialization of static data member 'FastScanner Solver_agc009c::in' of non-integral type [-fpermissive]
   48 |         static FastScanner in = new FastScanner(new InputStreamReader(System.in));
      |                            ^~
a.cc:48:81: error: non-constant in-class initialization invalid for non-inline static member 'Solver_agc009c::in'
   48 |         static FastScanner in = new FastScanner(new InputStreamReader(System.in));
      |                                                                                 ^
a.cc:48:81: note: (an out of class initialization is required)
a.cc:49:16: error: 'PrintWriter' does not name a type
   49 |         static PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out));
      |                ^~~~~~~~~~~
a.cc:50:9: error: 'final' does not name a type
   50 |         final int mod = (int)1e9 + 7;
      |         ^~~~~
a.cc:52:20: error: flexible array member 'Solver_agc009c::s' not at end of 'class Solver_agc009c'
   52 |         long a, b, s[];
      |                    ^
a.cc:97:2: error: expected ';' after class definition
   97 | }
      |  ^
      |  ;
a.cc: In member function 'void Solver_agc009c::input()':
a.cc:58:17: error: invalid use of array with unspecified bounds
   58 |                 s = new long[n + 1];
      |                 ^
a.cc:60:24: error: 'Long' was not declared in this scope; did you mean 'long'?
   60 |                 s[n] = Long.MAX_VALUE;
      |                        ^~~~
      |                        long
a.cc:61:17: error: invalid use of array with unspecified bounds
   61 |                 f = new int[n + 1];
      |                 ^
a.cc:62:17: error: invalid use of array with unspecified bounds
   62 |                 g = new int[n + 1];
      |                 ^
a.cc:63:17: error: invalid use of array with unspecified bounds
   63 |                 sum_f = new int[n + 1];
      |                 ^~~~~
a.cc:64:17: error: invalid use of array with unspecified bounds
   64 |                 sum_g = new int[n + 1];
      |                 ^~~~~
a.cc: In member function 'int Solver_agc009c::addmod(int, int)':
a.cc:66:53: error: 'mod' was not declared in this scope
   66 |         int addmod(int a, int b) { return (a + b) % mod; }
      |                                                     ^~~
a.cc: In member function 'void Solver_agc009c::solve()':
a.cc:77:63: error: 'mod' was not declared in this scope
   77 |                                 f[i] = addmod(sum_g[l_f - 1], mod - sum_g[r_f]);
      |                                                               ^~~
a.cc:80:63: error: 'mod' was not declared in this scope
   80 |                                 g[i] = addmod(sum_f[l_g - 1], mod - sum_f[r_g]);
      |                                                               ^~~
a.cc:94:17: error: 'out' was not declared in this scope
   94 |                 out.println(ans);
      |                 ^~~