Language: C++

#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

//long longしか使わない
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	map<ll, ll>mp;
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		ll plus = a[i] + i;
		ll minus = i - a[i];
		ans += mp[i - a[i]];
		mp[a[i] + i]++;
	}
	cout << ans << endl;
	return 0;
}
#include<bits/stdc++.h>
typedef long long ll;
#define rep(i,n)for(ll i=0;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
#include<string>
#include<vector>
using namespace std;
typedef pair<int, int>P;
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)
//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
map<ll, ll>ins;
void facterize(ll n) {
	ll a = 2;
	while (n >= a * a) {
		if (n % a == 0) {
			ins[a]++;
			ins[a] = ins[a] % 1000000007;
			n /= a;
		}
		else {
			a++;
		}
	}
	ins[n]++;
}

vector<ll>relation[20], money(20, 1);
int dp[110][110];

int keta(int x) {
	int y = 0;
	while (x > 0) {
		y++;
		x /= 10;
	}
	return y;
}

//long longしか使わない
int main() {
	ll n;
	cin >> n;
	vector<ll>a(n);
	map<ll, ll>mp;
	ll ans = 0;
	rep(i, n) {
		cin >> a[i];
	}
	rep(i, n) {
		ll plus = a[i] + i;
		ll minus = i - a[i];
		ans += mp[i - a[i]];
		mp[a[i] + i]++;
	}
	cout << ans << endl;
	return 0;
}


Compiler output:
a.cc:102:10: error: redefinition of 'const ll mod'
  102 | const ll mod = 1000000007;
      |          ^~~
a.cc:13:10: note: 'const ll mod' previously defined here
   13 | const ll mod = 1000000007;
      |          ^~~
a.cc:103:10: error: redefinition of 'const ll INF'
  103 | const ll INF = 1e16;
      |          ^~~
a.cc:14:10: note: 'const ll INF' previously defined here
   14 | const ll INF = 1e16;
      |          ^~~
a.cc:104:10: error: redefinition of 'const ll MAX_N'
  104 | const ll MAX_N = 100010;
      |          ^~~~~
a.cc:15:10: note: 'const ll MAX_N' previously defined here
   15 | const ll MAX_N = 100010;
      |          ^~~~~
a.cc:122:4: error: redefinition of 'll gcd(ll, ll)'
  122 | ll gcd(ll x, ll y) {
      |    ^~~
a.cc:33:4: note: 'll gcd(ll, ll)' previously defined here
   33 | ll gcd(ll x, ll y) {
      |    ^~~
a.cc:126:4: error: redefinition of 'll lcm(ll, ll)'
  126 | ll lcm(ll x, ll y) {
      |    ^~~
a.cc:37:4: note: 'll lcm(ll, ll)' previously defined here
   37 | ll lcm(ll x, ll y) {
      |    ^~~
a.cc:132:12: error: redefinition of 'std::map<long long int, long long int> ins'
  132 | map<ll, ll>ins;
      |            ^~~
a.cc:43:12: note: 'std::map<long long int, long long int> ins' previously declared here
   43 | map<ll, ll>ins;
      |            ^~~
a.cc:133:6: error: redefinition of 'void facterize(ll)'
  133 | void facterize(ll n) {
      |      ^~~~~~~~~
a.cc:44:6: note: 'void facterize(ll)' previously defined here
   44 | void facterize(ll n) {
      |      ^~~~~~~~~
a.cc:148:11: error: redefinition of 'std::vector<long long int> relation [20]'
  148 | vector<ll>relation[20], money(20, 1);
      |           ^~~~~~~~
a.cc:59:11: note: 'std::vector<long long int> relation [20]' previously declared here
   59 | vector<ll>relation[20], money(20, 1);
      |           ^~~~~~~~
a.cc:148:25: error: redefinition of 'std::vector<long long int> money'
  148 | vector<ll>relation[20], money(20, 1);
      |                         ^~~~~
a.cc:59:25: note: 'std::vector<long long int> money' previously declared here
   59 | vector<ll>relation[20], money(20, 1);
      |                         ^~~~~
a.cc:149:5: error: redefinition of 'int dp [110][110]'
  149 | int dp[110][110];
      |     ^~
a.cc:60:5: note: 'int dp [110][110]' previously declared here
   60 | int dp[110][110];
      |     ^~
a.cc:151:5: error: redefinition of 'int keta(int)'
  151 | int keta(int x) {
      |     ^~~~
a.cc:62:5: note: 'int keta(int)' previously defined here
   62 | int keta(int x) {
      |     ^~~~
a.cc:161:5: error: redefinition of 'int main()'
  161 | int main() {
      |     ^~~~
a.cc:72:5: note: 'int main()' previously defined here
   72 | int main() {
      |     ^~~~