Language: C++

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

int n;
ll a, ans;
map<ll, ll> L, R;

void solve(){
    ans = 0;
    map<ll, ll>::iterator it;
    for(it = L.begin(); it != L.end(); it++){
        pair<ll, ll> p = *it;
        if(R.find(p.first) == R.end()) continue;
        ans += p.second * R.find(p.first)->second;
    }
    cout << ans << endl;
}

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a;
        if(L.find(i + a) == L.end()) {
            L.insert(make_pair(a + i, 1));
        }else {
            L.find(i + a)->second++;
        }
        if(R.find(i - a) == R.end()) {
            R.insert(make_pair(i - a, 1));
        }else {
            R.find(i - a)->second++;
        }
    }
    solve();
    return 0;
}

Compiler output:
a.cc:5:1: error: expected initializer before 'int'
    5 | int n;
      | ^~~
a.cc:6:1: error: 'll' does not name a type
    6 | ll a, ans;
      | ^~
a.cc:7:5: error: 'll' was not declared in this scope
    7 | map<ll, ll> L, R;
      |     ^~
a.cc:7:9: error: 'll' was not declared in this scope
    7 | map<ll, ll> L, R;
      |         ^~
a.cc:7:11: error: template argument 1 is invalid
    7 | map<ll, ll> L, R;
      |           ^
a.cc:7:11: error: template argument 2 is invalid
a.cc:7:11: error: template argument 3 is invalid
a.cc:7:11: error: template argument 4 is invalid
a.cc: In function 'void solve()':
a.cc:10:5: error: 'ans' was not declared in this scope; did you mean 'abs'?
   10 |     ans = 0;
      |     ^~~
      |     abs
a.cc:11:9: error: 'll' was not declared in this scope
   11 |     map<ll, ll>::iterator it;
      |         ^~
a.cc:11:15: error: template argument 1 is invalid
   11 |     map<ll, ll>::iterator it;
      |               ^
a.cc:11:15: error: template argument 3 is invalid
a.cc:11:15: error: template argument 4 is invalid
a.cc:11:27: error: expected initializer before 'it'
   11 |     map<ll, ll>::iterator it;
      |                           ^~
a.cc:12:9: error: 'it' was not declared in this scope; did you mean 'int'?
   12 |     for(it = L.begin(); it != L.end(); it++){
      |         ^~
      |         int
a.cc:12:16: error: request for member 'begin' in 'L', which is of non-class type 'int'
   12 |     for(it = L.begin(); it != L.end(); it++){
      |                ^~~~~
a.cc:12:33: error: request for member 'end' in 'L', which is of non-class type 'int'
   12 |     for(it = L.begin(); it != L.end(); it++){
      |                                 ^~~
a.cc:14:14: error: request for member 'find' in 'R', which is of non-class type 'int'
   14 |         if(R.find(p.first) == R.end()) continue;
      |              ^~~~
a.cc:14:21: error: request for member 'first' in 'p', which is of non-class type 'int'
   14 |         if(R.find(p.first) == R.end()) continue;
      |                     ^~~~~
a.cc:14:33: error: request for member 'end' in 'R', which is of non-class type 'int'
   14 |         if(R.find(p.first) == R.end()) continue;
      |                                 ^~~
a.cc:15:18: error: request for member 'second' in 'p', which is of non-class type 'int'
   15 |         ans += p.second * R.find(p.first)->second;
      |                  ^~~~~~
a.cc:15:29: error: request for member 'find' in 'R', which is of non-class type 'int'
   15 |         ans += p.second * R.find(p.first)->second;
      |                             ^~~~
a.cc:15:36: error: request for member 'first' in 'p', which is of non-class type 'int'
   15 |         ans += p.second * R.find(p.first)->second;
      |                                    ^~~~~
a.cc: In function 'int main()':
a.cc:21:12: error: 'n' was not declared in this scope; did you mean 'yn'?
   21 |     cin >> n;
      |            ^
      |            yn
a.cc:23:16: error: 'a' was not declared in this scope
   23 |         cin >> a;
      |                ^
a.cc:24:14: error: request for member 'find' in 'L', which is of non-class type 'int'
   24 |         if(L.find(i + a) == L.end()) {
      |              ^~~~
a.cc:24:31: error: request for member 'end' in 'L', which is of non-class type 'int'
   24 |         if(L.find(i + a) == L.end()) {
      |                               ^~~
a.cc:25:15: error: request for member 'insert' in 'L', which is of non-class type 'int'
   25 |             L.insert(make_pair(a + i, 1));
      |               ^~~~~~
a.cc:27:15: error: request for member 'find' in 'L', which is of non-class type 'int'
   27 |             L.find(i + a)->second++;
      |               ^~~~
a.cc:29:14: error: request for member 'find' in 'R', which is of non-class type 'int'
   29 |         if(R.find(i - a) == R.end()) {
      |              ^~~~
a.cc:29:31: error: request for member 'end' in 'R', which is of non-class type 'int'
   29 |         if(R.find(i - a) == R.end()) {
      |                               ^~~
a.cc:30:15: error: request for member 'insert' in 'R', which is of non-class type 'int'
   30 |             R.insert(make_pair(i - a, 1));
      |               ^~~~~~
a.cc:32:15: error: request for member 'find' in 'R', which is of non-class type 'int'
   32 |             R.find(i - a)->second++;
      |               ^~~~