Buggy python submission (verdict: Runtime Error):
n = int(input())
A = list(map(int, input().split()))
L = [i+x for i, x in enumerate(A)]
R = [i-x for i, x in enumerate(A) if i-x > 0]

P = collections.Counter(L)
Q = collections.Counter(R)
 
ans = 0
for k, v in P.item():
    if k in Q:
        ans += v*Q[k]
print(ans)    


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
L = [i+x for i, x in enumerate(A)]
R = [i-x for i, x in enumerate(A) if i-x > 0]

from collections import Counter
P = Counter(L)
Q = Counter(R)
 
ans = 0
for k, v in P.items():
  if k in Q:
    ans += v*Q[k]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A=list(map(int, input().split()))
B=sorted([A[i]+i+1 for i in range(n)])
x=B[0]
y=B[-1]
C=sorted([j+1-A[j] for j in range(n) if x<=j+1-A[j]<=y])
C2=set(C)

t=0
for i in range(n):
  if B[i] in C2:
    t+= C.count(B[i])
print(t)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
L = [i+x for i, x in enumerate(A)]
R = [i-x for i, x in enumerate(A) if i-x > 0]

from collections import Counter
P = Counter(L)
Q = Counter(R)
 
ans = 0
for k, v in P.items():
  if k in Q:
    ans += v*Q[k]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A=list(map(int, input().split()))
B=[A[i]+i+1 for i in range(n)]
x=min(B)
y=max(B)
C=[j+1-A[j] for j in range(n) if x<=j+1-A[j]<=y]
C2=set(C)

t=0
for i in range(n):
  if B[i] in C2:
    t+= C.count(B[i])
print(t)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
L = [i+x for i, x in enumerate(A)]
R = [i-x for i, x in enumerate(A) if i-x > 0]

from collections import Counter
P = Counter(L)
Q = Counter(R)
 
ans = 0
for k, v in P.items():
  if k in Q:
    ans += v*Q[k]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A=list(map(int, input().split()))
B=[A[i]+i+1 for i in range(n)]
C=[j+1-A[j] for j in range(n) if j+1-A[j]>0]
C2=set(C)

t=0
for i in range(n):
  if B[i] in C2:
    t+= C.count(B[i])
print(t)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
L = [i+x for i, x in enumerate(A)]
R = [i-x for i, x in enumerate(A) if i-x > 0]

from collections import Counter
P = Counter(L)
Q = Counter(R)
 
ans = 0
for k, v in P.items():
  if k in Q:
    ans += v*Q[k]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A=list(map(int, input().split()))
B=[A[i]+i+1 for i in range(n)]
C=[j+1-A[j] for j in range(n)]
C2=set(C)

t=0
for i in range(n):
  if B[i] in C2:
    t+= C.count(B[i])
print(t)


Fixed submission:
n = int(input())
A = list(map(int, input().split()))
L = [i+x for i, x in enumerate(A)]
R = [i-x for i, x in enumerate(A) if i-x > 0]

from collections import Counter
P = Counter(L)
Q = Counter(R)
 
ans = 0
for k, v in P.items():
  if k in Q:
    ans += v*Q[k]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
A=list(map(int, input().split()))
t=0
for i in range(n):
  for j in range(i+1, n):
    if abs(i-j)==A[i]+A[j]:
      t+=1
print(t)

Fixed submission:
n = int(input())
A = list(map(int, input().split()))
L = [i+x for i, x in enumerate(A)]
R = [i-x for i, x in enumerate(A) if i-x > 0]

from collections import Counter
P = Counter(L)
Q = Counter(R)
 
ans = 0
for k, v in P.items():
  if k in Q:
    ans += v*Q[k]
print(ans)