Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int, input().split()))

L=[0]*2*n
c=0

for i,a in enumerate(A):
  L[i+a]+=1
  if 2*n>i-a>0:
    c+=L[i-a]

print(c)


Fixed submission:
n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)

Buggy python submission (verdict: Runtime Error):
n=int(input())
A=list(map(int, input().split()))

L=[0]*2*n
c=0

for i,a in enumerate(A):
  L[i+a]+=1
  c+=L[i-a]

print(c)


Fixed submission:
n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)

Buggy python submission (verdict: Runtime Error):
import math

n=int(input())
A=list(map(int, input().split()))
L=[0]*2*n
R=[0]*2*n
c=0
x=0
for i,a in enumerate(A):
  L[i+a]+=1
  R[i-a]+=1
  c+=L[i-a]

print(c)


Fixed submission:
n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n=int(input())
A=list(map(int, input().split()))
L=['null']*n
R=['null']*n
c=0

for i,a in enumerate(A):
  L[i]=i+a
  R[i]=i-a
  c+=L.count(R[i])
print(c)


Fixed submission:
n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math

n=int(input())
A=list(map(int, input().split()))
B=[0]*n
c=0

for i,a in enumerate(A):
  B[i]=i-A[i]
  A[i]=i+A[i]
  
for i in range(n):
  a=A.count(i)
  b=B.count(i)
  c+=a*b
  
print(c)

Fixed submission:
n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math

N=int(input())
A=list(map(int, input().split()))
c=0

for i in range(1,N):
  for j in range(N-i):
    #print(A[j],A[i+j])
    if A[j]+A[i+j]==i:
      c+=1
print(c)

Fixed submission:
n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math

N=int(input())
A=list(map(int, input().split()))
c=0

for i in range(N):
  for j in range(1,N-i):
    #print(i,j,A[i],A[j])
    if A[i]+A[i+j]==j:
      c+=1
print(c)

Fixed submission:
n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import math

N=int(input())
A=list(map(int, input().split()))
c=0

for i in range(N):
  for j in range(i,N):
    if A[i]+A[j]==abs(j-i):
      c+=1
print(c)

Fixed submission:
n=int(input())
A=list(map(int, input().split()))
d={}
c=0

for i,a in enumerate(A):
  if i+a not in d:
    d[i+a]=1
  else:
    d[i+a]+=1
  if i-a in d:
    c+=d[i-a]

print(c)