Buggy python submission (verdict: Runtime Error):
N=int(input())
s=0
L=[i for i in range(N)]
A=list(map(int,input().split()))
dic1={[i,i+a]:0 for i,a in zip(L,A)}
dic2={[i,i-a]:0 for i,a in zip(L,A)}
for p in range(N):
    z=[k for k,v in dic1.items() if k[2]==p]
    w=[k for k,v in dic2.items() if k[2]==p]
    s+=len(z)*len(w)
print(s)

Fixed submission:
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())
s=0
L=[i for i in range(N)]
A=list(map(int,input().split()))
dic1={i:i+a for i,a in zip(L,A)}
dic2={i:i-a for i,a in zip(L,A)}
for p in range(N):
    z=[k for k,v in dic1.items() if v==p ]
    w=[k for k,v in dic2.items() if v==p ]
    s+=len(z)*len(w)
print(s)

Fixed submission:
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: Runtime Error):
N=int(input())
s=0
L=[i for i in range(N)]
A=list(map(int,input().split()))
dic1={i:i+a for i,a in zip(L,A)}
dic2={i:i-a for i,a in zip(L,A)}
for p in range(N)
    z=[k for k,v in dic1.items() if v==p ]
    w=[k for k,v in dic2.items() if v==p ]
    for i,j in zip(z,w):
        if j>i:
            s+=1
print(s)

Fixed submission:
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: Runtime Error):
N=int(input())
s=0
L=[i for i in range(N)]
A=list(map(int,input().split()))
dic1={i:i+a for i,a in zip(L,A)}
dic2={i:i-a for i,a in zip(L,A)}
for p in range(N)
    z=[k for k,v in dic1.items() if v==p ]
    w=[k for k,v in dic2.items() if v==p ]
    for i,j in zip(z,w)
        if j>i:
            s+=1
print(s)

Fixed submission:
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):
from collections import deque
N=int(input())
A=deque(map(int,input().split()))
B=deque([])
x=A.popleft()
B.append(x)
s=0
for i in range(N-1):
    x=A.popleft()
    for j in range(i+1):
        if B[j]+x-i-1+j==0:
           s+=1
    B.append(x)
print(s)

Fixed submission:
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)