Buggy python submission (verdict: Time Limit Exceeded):
import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
res = 0
for i in range(N-2):
    idx = (N-1) - i
    max_, second_max = L[idx], L[idx-1]
    for tmp_idx in range(1, idx):
        second_max = L[tmp_idx]
        tidx = bisect.bisect_right(L, max_ - second_max)
        if len(L[tidx:tmp_idx]) > 0:
            res += len(L[tidx:tmp_idx])
print(res)



Fixed submission:
from bisect import bisect_left
N = int(input())
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        t = l[i] + l[j]
        idx = bisect_left(l, t)
        res += idx-j-1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np
N = int(input())
L = np.array(input().split(), dtype=np.int32)
L = np.sort(L)[::-1]
diff = L[:-2] - (L[1:-1] + L[2:])
idx_list = np.where(diff < 0)[0]
res = 0
for idx in idx_list:
    comb_list = itertools.combinations(L[idx+1:], 2)
    res += sum(L[idx] < comb[0] + comb[1] for comb in comb_list)
print(res)


Fixed submission:
from bisect import bisect_left
N = int(input())
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        t = l[i] + l[j]
        idx = bisect_left(l, t)
        res += idx-j-1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
res = 0
for i in range(N-2):
    if L[i] < L[i+1] + L[i+2]:
        comb_list = itertools.combinations(L[i+1:], 2)
        res +=  sum([L[i] < (comb[0] + comb[1]) for comb in comb_list])
    else: continue
print(res)


Fixed submission:
from bisect import bisect_left
N = int(input())
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        t = l[i] + l[j]
        idx = bisect_left(l, t)
        res += idx-j-1
print(res)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = list(map(int, input().split()))
L.sort(reverse=True)
res = 0
for i in range(N-2):
    if L[i] < L[i+1] + L[i+2]:
        comb_list = itertools.combinations(L[i+1:], 2)
        res +=  sum([L[i] < (comb[0] + comb[1]) for comb in comb_list])
    else: continue
print(res)


Fixed submission:
from bisect import bisect_left
N = int(input())
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        t = l[i] + l[j]
        idx = bisect_left(l, t)
        res += idx-j-1
print(res)

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


Fixed submission:
from bisect import bisect_left
N = int(input())
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        t = l[i] + l[j]
        idx = bisect_left(l, t)
        res += idx-j-1
print(res)

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


Fixed submission:
from bisect import bisect_left
N = int(input())
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        t = l[i] + l[j]
        idx = bisect_left(l, t)
        res += idx-j-1
print(res)

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


Fixed submission:
from bisect import bisect_left
N = int(input())
l = list(map(int, input().split()))
l.sort()
res = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        t = l[i] + l[j]
        idx = bisect_left(l, t)
        res += idx-j-1
print(res)