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

def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

N = int(input())
L = list(map(int, input().split()))
# L.sort(reverse=True)
L_sort = heapsort(L)
# print (L)
answer = 0
for i in itertools.combinations(L_sort, 3):
    # print(i)
    if i[2] < i[0] + i[1]:
        answer += 1
print(answer)

Fixed submission:
import itertools
import heapq
from bisect import bisect_left


def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

N = int(input())
L = list(map(int, input().split()))
L.sort()
# L_sort = heapsort(L)
# print (L)
answer = 0
for i, a in enumerate(L[0:N-2]):
    for j, b in enumerate(L[i+1:N-1]):
        index = bisect_left(L, a+b)
        answer += max(index - (j+i+1) -1, 0)
        # print(L, a+b, index, j+i+1, answer)
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = list(map(int, input().split()))
L.sort()
answer = 0

for i in itertools.combinations(L, 3):
    # print(i)
    if i[2] < i[0] + i[1]:
        answer += 1
print(answer)

Fixed submission:
import itertools
import heapq
from bisect import bisect_left


def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

N = int(input())
L = list(map(int, input().split()))
L.sort()
# L_sort = heapsort(L)
# print (L)
answer = 0
for i, a in enumerate(L[0:N-2]):
    for j, b in enumerate(L[i+1:N-1]):
        index = bisect_left(L, a+b)
        answer += max(index - (j+i+1) -1, 0)
        # print(L, a+b, index, j+i+1, answer)
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = list(map(int, input().split()))
answer = 0

for i in itertools.combinations(L, 3):
    if i[0] >= i[1] + i[2]:
        continue
    elif i[1] >= i[0] + i[2]:
        continue
    elif i[2] >= i[1] + i[0]:
        continue
    else:
        answer += 1
print(answer)

Fixed submission:
import itertools
import heapq
from bisect import bisect_left


def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

N = int(input())
L = list(map(int, input().split()))
L.sort()
# L_sort = heapsort(L)
# print (L)
answer = 0
for i, a in enumerate(L[0:N-2]):
    for j, b in enumerate(L[i+1:N-1]):
        index = bisect_left(L, a+b)
        answer += max(index - (j+i+1) -1, 0)
        # print(L, a+b, index, j+i+1, answer)
print(answer)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = list(map(int, input().split()))
answer = 0
for i in itertools.combinations(L, 3):
    if i[0] < i[1] + i[2] and i[1] < i[0] + i[2] and i[2] < i[1] + i[0]:
        answer += 1
print(answer)

Fixed submission:
import itertools
import heapq
from bisect import bisect_left


def heapsort(iterable):
    h = []
    for value in iterable:
        heapq.heappush(h, value)
    return [heapq.heappop(h) for i in range(len(h))]

N = int(input())
L = list(map(int, input().split()))
L.sort()
# L_sort = heapsort(L)
# print (L)
answer = 0
for i, a in enumerate(L[0:N-2]):
    for j, b in enumerate(L[i+1:N-1]):
        index = bisect_left(L, a+b)
        answer += max(index - (j+i+1) -1, 0)
        # print(L, a+b, index, j+i+1, answer)
print(answer)