Language: C++

int main()
{
	long long N, Q, L;
	vector<long long> loc(1);
	cin >> N;
	long long t;
	for (long long i = 0; i < N; ++i){
		cin >> t;
		loc.push_back(t);
	}
	cin >> L >> Q;
	vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 }));
	for (long long i = 1; i < N; ++i){
		for (long long j = i+1; j <= N; ++j){
			long long dist = loc[j] - loc[j - 1];
			if (days[i][j - 1].second>=dist){
				days[i][j] = { days[i][j - 1].first, days[i][j - 1].second - dist };
			}
			else{
				days[i][j] = { days[i][j - 1].first + 1, L - dist };
			}
		}
	}
	vector<long long> a(Q), b(Q);
	for (long long i = 0; i < Q; ++i){
		cin >> a[i] >> b[i];
	}
	for (long long i = 0; i < Q; ++i){
		if (a[i] <= b[i]){
			cout << days[a[i]][b[i]].first << endl;
		}
		else{
			cout << days[b[i]][a[i]].first << endl;
		}
	}
	cin >> N;
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:4:9: error: 'vector' was not declared in this scope
    4 |         vector<long long> loc(1);
      |         ^~~~~~
a.cc:4:16: error: expected primary-expression before 'long'
    4 |         vector<long long> loc(1);
      |                ^~~~
a.cc:5:9: error: 'cin' was not declared in this scope
    5 |         cin >> N;
      |         ^~~
a.cc:9:17: error: 'loc' was not declared in this scope
    9 |                 loc.push_back(t);
      |                 ^~~
a.cc:12:23: error: 'pair' was not declared in this scope
   12 |         vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 }));
      |                       ^~~~
a.cc:12:28: error: expected primary-expression before 'long'
   12 |         vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 }));
      |                            ^~~~
a.cc:12:114: error: expected primary-expression before ')' token
   12 |         vector<vector<pair<long long, long long>>> days(N + 1, vector<pair<long long, long long>>(N + 1, { 0, 0 }));
      |                                                                                                                  ^
a.cc:15:42: error: 'loc' was not declared in this scope
   15 |                         long long dist = loc[j] - loc[j - 1];
      |                                          ^~~
a.cc:16:29: error: 'days' was not declared in this scope
   16 |                         if (days[i][j - 1].second>=dist){
      |                             ^~~~
a.cc:24:16: error: expected primary-expression before 'long'
   24 |         vector<long long> a(Q), b(Q);
      |                ^~~~
a.cc:26:24: error: 'a' was not declared in this scope
   26 |                 cin >> a[i] >> b[i];
      |                        ^
a.cc:26:32: error: 'b' was not declared in this scope
   26 |                 cin >> a[i] >> b[i];
      |                                ^
a.cc:29:21: error: 'a' was not declared in this scope
   29 |                 if (a[i] <= b[i]){
      |                     ^
a.cc:29:29: error: 'b' was not declared in this scope
   29 |                 if (a[i] <= b[i]){
      |                             ^
a.cc:30:25: error: 'cout' was not declared in this scope
   30 |                         cout << days[a[i]][b[i]].first << endl;
      |                         ^~~~
a.cc:30:33: error: 'days' was not declared in this scope
   30 |                         cout << days[a[i]][b[i]].first << endl;
      |                                 ^~~~
a.cc:30:59: error: 'endl' was not declared in this scope
   30 |                         cout << days[a[i]][b[i]].first << endl;
      |                                                           ^~~~
a.cc:33:25: error: 'cout' was not declared in this scope
   33 |                         cout << days[b[i]][a[i]].first << endl;
      |                         ^~~~
a.cc:33:33: error: 'days' was not declared in this scope
   33 |                         cout << days[b[i]][a[i]].first << endl;
      |                                 ^~~~
a.cc:33:59: error: 'endl' was not declared in this scope
   33 |                         cout << days[b[i]][a[i]].first << endl;
      |                                                           ^~~~