Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
for i in range(n):
  a = lst[i]
  if a >= n - 1:
    continue
  if a not in dic:
    dic[a] = set()
  dic[a].add(i)
#print(dic)
count = 0
for a in dic.keys():
  set_ = dic[a]
  for index in set_:
    b = a + index
    if b > n:
      continue
    for c in dic.keys():
      j = b + c
      if j in dic[c]:
        count += 1
print(count)


Fixed submission:
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
count = 0
for i in range(n):
  num = lst[i]
  a = i + num
  if a not in dic:
    dic[a] = 1
  else:
    dic[a] += 1
  b = i - num
  if b in dic:
    count += dic[b]
print(count)

Buggy python submission (verdict: Runtime Error):
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
for i in range(n):
  a = lst[i]
  if a >= n - 1:
    continue
  if a not in dic:
    dic[a] = set()
  dic[a].add(i)
#print(dic)
count = 0
for a in dic.keys():
  set_ = dic[a]
  for index in set_:
    b = a + index
    if b > n:
      continue
    for j in dic.keys():
      j = b + c
      if c in dic[c]:
        count += 1
print(count)


Fixed submission:
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
count = 0
for i in range(n):
  num = lst[i]
  a = i + num
  if a not in dic:
    dic[a] = 1
  else:
    dic[a] += 1
  b = i - num
  if b in dic:
    count += dic[b]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
for i in range(n):
  a = lst[i]
  if a >= n - 1:
    continue
  if a not in dic:
    dic[a] = set()
  dic[a].add(i)
#print(dic)
count = 0
for a in dic.keys():
  set_ = dic[a]
  for index in set_:
    b = a + index
    if b > n:
      continue
    for c in range(n - b):
      if c in dic:
        j = b + c
        if j in dic[c]:
          count += 1
print(count)

Fixed submission:
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
count = 0
for i in range(n):
  num = lst[i]
  a = i + num
  if a not in dic:
    dic[a] = 1
  else:
    dic[a] += 1
  b = i - num
  if b in dic:
    count += dic[b]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [int(i) for i in input().split()]

count = 0
for i in range(n):
  a = lst[i]
  if n - 1 <= a + i:
    continue
  for j in range(i + a, n):
    b = lst[j]
    if j - i == a + b:
      count += 1
print(count)


Fixed submission:
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
count = 0
for i in range(n):
  num = lst[i]
  a = i + num
  if a not in dic:
    dic[a] = 1
  else:
    dic[a] += 1
  b = i - num
  if b in dic:
    count += dic[b]
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lst = [int(i) for i in input().split()]

count = 0
for i in range(n):
  a = lst[i]
  if n - i - 1 <= a:
    continue
  for j in range(i + 1, n):
    if j - i > a:
      b = lst[j]
      if j - i == a + b:
        count += 1
print(count)

Fixed submission:
n = int(input())
lst = [int(i) for i in input().split()]

dic = {}
count = 0
for i in range(n):
  num = lst[i]
  a = i + num
  if a not in dic:
    dic[a] = 1
  else:
    dic[a] += 1
  b = i - num
  if b in dic:
    count += dic[b]
print(count)