Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
height = [int(x) for x in input().split()]
cnt =0

for i_index, i in enumerate(height[:-1]):
    if i+i_index >= n:
        continue

    for j_index, j in enumerate(height[i_index+i+1:]):
        if j+i == j_index+i+1:
            cnt += 1
            # print(i,j,j_index)
            
print(cnt)

Fixed submission:
# n = int(input())
# height = [int(x) for x in input().split()]
# cnt =0

# for i_index, i in enumerate(height[:-1]):
#     if i+i_index >= n:
#         continue

#     for j_index, j in enumerate(height[i_index+i+1:]):
#         if j+i == j_index+i+1:
#             cnt += 1
#             # print(i,j,j_index)
            
# print(cnt)
def count(dic,x):
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1
 
N=int(input())
A=list(map(int,input().split()))
dic1={}
dic2={}
s=0
for i in range(N):
    count(dic1,i-A[i])
    count(dic2,i+A[i])
for x in dic1:
    if x in dic2:
        s+=dic1[x]*dic2[x]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
height = [int(x) for x in input().split()]
cnt =0

for i_index, i in enumerate(height[:-1]):
    if i+i_index >= n:
        continue

    for j_index, j in enumerate(height[i_index+i:]):
        if j+i == j_index+i:
            cnt += 1
            # print(i,j,j_index)
            
print(cnt)

Fixed submission:
# n = int(input())
# height = [int(x) for x in input().split()]
# cnt =0

# for i_index, i in enumerate(height[:-1]):
#     if i+i_index >= n:
#         continue

#     for j_index, j in enumerate(height[i_index+i+1:]):
#         if j+i == j_index+i+1:
#             cnt += 1
#             # print(i,j,j_index)
            
# print(cnt)
def count(dic,x):
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1
 
N=int(input())
A=list(map(int,input().split()))
dic1={}
dic2={}
s=0
for i in range(N):
    count(dic1,i-A[i])
    count(dic2,i+A[i])
for x in dic1:
    if x in dic2:
        s+=dic1[x]*dic2[x]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
height = [int(x) for x in input().split()]
cnt =0

for i_index, i in enumerate(height[:-1]):
    if i+i_index >= n:
        continue

    for j_index, j in enumerate(height[i_index+i:]):
        if j+i == j_index+i:
            cnt += 1
            
            

print(cnt)

Fixed submission:
# n = int(input())
# height = [int(x) for x in input().split()]
# cnt =0

# for i_index, i in enumerate(height[:-1]):
#     if i+i_index >= n:
#         continue

#     for j_index, j in enumerate(height[i_index+i+1:]):
#         if j+i == j_index+i+1:
#             cnt += 1
#             # print(i,j,j_index)
            
# print(cnt)
def count(dic,x):
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1
 
N=int(input())
A=list(map(int,input().split()))
dic1={}
dic2={}
s=0
for i in range(N):
    count(dic1,i-A[i])
    count(dic2,i+A[i])
for x in dic1:
    if x in dic2:
        s+=dic1[x]*dic2[x]
print(s)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
height = [int(x) for x in input().split()]
cnt =0
i_index = 0
j_index = 0
for i in height[:n-1]:
    i_index += 1
    j_index = i_index
    for j in height[i_index:]:
        j_index+=1
        if j+i == abs(i_index - j_index):
            cnt += 1

print(cnt)

Fixed submission:
# n = int(input())
# height = [int(x) for x in input().split()]
# cnt =0

# for i_index, i in enumerate(height[:-1]):
#     if i+i_index >= n:
#         continue

#     for j_index, j in enumerate(height[i_index+i+1:]):
#         if j+i == j_index+i+1:
#             cnt += 1
#             # print(i,j,j_index)
            
# print(cnt)
def count(dic,x):
    if x in dic:
        dic[x]+=1
    else:
        dic[x]=1
 
N=int(input())
A=list(map(int,input().split()))
dic1={}
dic2={}
s=0
for i in range(N):
    count(dic1,i-A[i])
    count(dic2,i+A[i])
for x in dic1:
    if x in dic2:
        s+=dic1[x]*dic2[x]
print(s)