Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
from copy import deepcopy
def main():
    n = int(input())
    a = list(map(int, input().split()))
    a2 = deepcopy(a)

    for j1 in range(1, n):
        a2[j1] -= j1
    r = 0
    for i1 in range(n - 1):
        r += a2[i1+1:].count(-(a[i1]+i1))
    print(r)

if __name__ == '__main__':
    main()

Fixed submission:
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    l1 = []
    for ea in a:
        l1.append(cnt - ea)
        cnt += 1
    l1c = Counter(l1)
    r = 0
    for i2 in range(n):
        r += l1c[i2 + a[i2]]
    print(int(r))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.read
readlines = sys.stdin.readlines
def main():
    n = int(input())
    a = tuple(map(int, input().split()))

    r = 0
    for i1 in range(n - 1):
        for i2 in range(1, n - i1):
            r += a[i1+i2] == i2 - a[i1]
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    l1 = []
    for ea in a:
        l1.append(cnt - ea)
        cnt += 1
    l1c = Counter(l1)
    r = 0
    for i2 in range(n):
        r += l1c[i2 + a[i2]]
    print(int(r))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    l1 = []
    for ea in a:
        l1.append(cnt - ea)
        cnt += 1
    l1c = Counter(l1)
    r = 0
    for ea2 in a:
        r += l1c[ea2 + a[ea2]]
    print(int(r))

if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    l1 = []
    for ea in a:
        l1.append(cnt - ea)
        cnt += 1
    l1c = Counter(l1)
    r = 0
    for i2 in range(n):
        r += l1c[i2 + a[i2]]
    print(int(r))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    tmpa = list(map(int, input().split()))
    a2 = [[0]*n for _ in range(n)]
    for i1 in range(n):
        for i2 in range(i1+1,n):
            if tmpa[i1] + tmpa[i2] == (i2 - i1):
                a2[i1][i2] = 1
    r = 0
    for row in a2:
        r += sum(row)
    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    l1 = []
    for ea in a:
        l1.append(cnt - ea)
        cnt += 1
    l1c = Counter(l1)
    r = 0
    for i2 in range(n):
        r += l1c[i2 + a[i2]]
    print(int(r))

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    a = list(map(int, input().split()))
    r = 0
    for i1 in range(n-1):
        tall = a[i1]
        for i2 in range(i1 + tall+1, n):
            r += (i2 - i1) == tall + a[i2]

    print(r)

if __name__ == '__main__':
    main()


Fixed submission:
from collections import Counter

def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = 0
    l1 = []
    for ea in a:
        l1.append(cnt - ea)
        cnt += 1
    l1c = Counter(l1)
    r = 0
    for i2 in range(n):
        r += l1c[i2 + a[i2]]
    print(int(r))

if __name__ == '__main__':
    main()