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

l = sorted(l)
res = {}
count = 0
for i in range(len(l)-1):
    tmp_l = l
    a = l.pop(i)
    b = l.pop(i+1)
    count += len([1 for v in tmp_l if v > b - a and v < a + b])
    

print(count)


Fixed submission:
import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


if __name__ == '__main__':
    triangles()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = [int(v) for v in input().split()]

l = sorted(l)

res = {}
comb = list(itertools.combinations(l, 3))
count = 0
for i in range(len(comb)):
    a = comb[i][0]
    b = comb[i][1]
    c = comb[i][2]
    if '{}{}{}'.format(a, b, c) in res:
        count += 1
        continue
    if a + b <= c:
        continue
    elif a + c <= b:
        continue
    elif b + c <= a:
        continue
    else:
        count += 1
        res['{}{}{}'.format(a, b, c)] = 'Good'

print(count)


Fixed submission:
import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


if __name__ == '__main__':
    triangles()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = [int(v) for v in input().split()]

l = sorted(l)

res = {}
comb = list(itertools.combinations(l, 3))
count = 0
for i in range(len(comb)):
    a = comb[i][0]
    b = comb[i][1]
    c = comb[i][2]
    if '{}{}{}'.format(a, b, c) in res:
        count += 1
        continue
    if a + b <= c:
        continue
    elif a + c <= b:
        continue
    elif b + c <= a:
        continue
    else:
        count += 1
        res['{}{}{}'.format(a, b, c)] = 'Good'

print(count)


Fixed submission:
import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


if __name__ == '__main__':
    triangles()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = [int(v) for v in input().split()]

l = sorted(l)

comb = list(itertools.combinations(l, 3))
count = 0
for i in range(len(comb)):
    a = comb[i][0]
    b = comb[i][1]
    c = comb[i][2]
    if a + b <= c:
        continue
    elif a + c <= b:
        continue
    elif b + c <= a:
        continue
    else:
        count += 1

print(count)

Fixed submission:
import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


if __name__ == '__main__':
    triangles()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = [int(v) for v in input().split()]

comb = list(itertools.combinations(l, 3))
count = 0
for i in range(len(comb)):
    a = comb[i][0]
    b = comb[i][1]
    c = comb[i][2]
    if a + b <= c:
        continue
    elif a + c <= b:
        continue
    elif b + c <= a:
        continue
    else:
        count += 1

print(count)

Fixed submission:
import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


if __name__ == '__main__':
    triangles()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = [int(v) for v in input().split()]

comb = list(itertools.combinations(l, 3))
count = 0
for i in range(len(comb)):
    x = comb[i][0] + comb[i][1]
    y = comb[i][1] + comb[i][2]
    z = comb[i][0] + comb[i][2]
    if x > comb[i][2] and y > comb[i][0] and z > comb[i][1]:
        count += 1
    else:
        continue

print(count)


Fixed submission:
import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


if __name__ == '__main__':
    triangles()

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

n = int(input())
l = [int(v) for v in input().split()]

comb = list(itertools.combinations(l, 3))
count = 0
for i in range(len(comb)):
    x = comb[i][0] + comb[i][1]
    y = comb[i][1] + comb[i][2]
    z = comb[i][0] + comb[i][2]
    if x > comb[i][2] and y > comb[i][0] and z > comb[i][1]:
        count += 1
    else:
        continue

print(count)


Fixed submission:
import bisect


def triangles():
    n = int(input())
    l = [int(v) for v in input().split()]
    l.sort()

    count = 0
    for i in range(n):
        for j in range(i + 1, n):
            c = l[i] + l[j]
            index = bisect.bisect_left(l, c)
            count += max(index - j - 1, 0)

    print(count)


if __name__ == '__main__':
    triangles()