Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
X.sort()
Y.sort()
y = 0
c = 0
for i in range(N):
    if X[i] > Y[-1]:
        break
    for j in range(y, N):
        if X[i] == Y[j]:
            c += 1
            y = Y[j]
        if X[i] < Y[j]:
            break
print(c)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
X.sort()
Y.sort()
c = 0
for i in range(N):
    if X[i] > Y[-1]:
        break
    for j in range(N):
        if X[i] == Y[j]:
            c += 1
        if X[i] < Y[j]:
            break
print(c)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
X.sort()
Y.sort()
c = 0
for i in range(N):
    if X[i] > Y[-1]:
        break
    for j in range(N):
        if X[i] == Y[j]:
            c += 1
        if X[i] < Y[j]:
            break
print(c)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0

F = []
G = []
for i in range(1, N + 1):
    F.append(i + A[i - 1])
    G.append(i - A[i - 1])
F.sort()
G.sort()
J = 0
for i in range(N):
    j = J + 1
    for j in range(N):
        if F[i] == G[j]:
            ans += 1
            J = j
        if G[j] > F[j]:
            break

print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0

F = []
G = []
for i in range(1, N + 1):
    F.append(i + A[i - 1])
    G.append(i - A[i - 1])
F.sort()
G.sort()
J = 0
for i in range(N):
    j = J + 1
    for j in range(N):
        if F[i] == G[j]:
            ans += 1
            J = j
        if G[j] > F[j]:
            break

print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0

F = []
G = []
for i in range(1, N + 1):
    F.append(i + A[i - 1])
    G.append(i - A[i - 1])
F.sort()
G.sort()
for i in range(N):
    j = 0
    for j in range(N):
        if F[i] == G[j]:
            ans += 1
        if G[j] > F[j]:
            break

print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0

F = []
G = []
for i in range(1, N + 1):
    F.append(i + A[i - 1])
    G.append(i - A[i - 1])

for i in range(N):
    for j in range(N):
        if F[i] == G[j]:
            ans += 1

print(ans)

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = list(map(int, input().split()))
ans = 0

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

Fixed submission:
from collections import Counter
N = int(input())
A = list(map(int, input().split()))
X, Y = [], []
for i in range(N):
    X.append(i + 1 + A[i])
    Y.append(i + 1 - A[i])
XL = Counter(X)
c = 0
for y in Y:
    c += XL.get(y, 0)
print(c)