Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter
from bisect import bisect, bisect_left
from fractions import Fraction

def comb(n, k):
    if n < 0 or k < 0:
        pdt = 0
    else:
        pdt = 1
        for s in range(1, k + 1):
            pdt *= Fraction(n - s + 1, s)
    return pdt.numerator

input = sys.stdin.readline
N = int(input())
L = sorted([int(x) for x in input().split()])
c = 0
Lcnt = Counter(L)
Lset = sorted(list(set(L)))
Nset = len(Lset)
for i in range(Nset):
    if Lcnt[Lset[i]] >= 3:
        c += comb(Lcnt[Lset[i]], 3)
        if i == Nset - 1:
            break

    if Lcnt[Lset[i]] >= 2:
        fl = bisect(L, Lset[i])
        fr = bisect_left(L, Lset[i] * 2)
        c += comb(Lcnt[Lset[i]], 2) * (fr - fl)
    for j in range(i + 1, Nset):
        fl = bisect(L, Lset[j])
        fr = min(bisect_left(L, Lset[i] + Lset[j]), len(L) - 1)
        c += Lcnt[Lset[i]] * Lcnt[Lset[j]] * (fr - fl)

if Lcnt[Lset[-1]] >= 2:
    c += Lcnt[Lset[-2]] * comb(Lcnt[Lset[-1]], 2)
print(c)

Fixed submission:
import sys
from bisect import bisect, bisect_left

input = sys.stdin.readline
N = int(input())
L = sorted([int(x) for x in input().split()])
c = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        f = bisect_left(L, L[i] + L[j])
        c += f - j - 1
print(c)

Buggy python submission (verdict: Runtime Error):
import sys
from collections import Counter
from bisect import bisect, bisect_left
from fractions import Fraction

def comb(n, k):
    if n < 0 or k < 0:
        pdt = 0
    else:
        pdt = 1
        for s in range(1, k + 1):
            pdt *= Fraction(n - s + 1, s)
    return pdt.numerator

input = sys.stdin.readline
N = int(input())
L = sorted([int(x) for x in input().split()])
c = 0
D = {}
Lcnt = Counter(L)
Lset = sorted(list(set(L)))
imoset = [0] * len(Lset)
t = 0
for i, lset in enumerate(Lset):
    t += lset
    imoset[i] = t
Nset = len(Lset)
for i in range(Nset):
    if Lcnt[Lset[i]] >= 3:
        c += comb(Lcnt[Lset[i]], 3)

    if Lcnt[Lset[i]] >= 2:
        fl = bisect(L, Lset[i])
        fr = bisect_left(L, Lset[i] * 2)
        c += comb(Lcnt[Lset[i]], 2) * (fr - fl)
    for j in range(i + 1, Nset):
        fl = bisect(L, Lset[j])
        fr = bisect_left(L, Lset[i] + Lset[j])
        c += Lcnt[Lset[i]] * Lcnt[Lset[j]] * (fr - fl)

if Lcnt[Lset[-1]] >= 2:
    c += Lcnt[Lset[-2]] * comb(Lcnt[Lset[-1]], 2)
print(c)

Fixed submission:
import sys
from bisect import bisect, bisect_left

input = sys.stdin.readline
N = int(input())
L = sorted([int(x) for x in input().split()])
c = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        f = bisect_left(L, L[i] + L[j])
        c += f - j - 1
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = int(input())
L = [int(x) for x in input().split()]
c = 0
for l in itertools.combinations(L, 3):
  if sum(l) - max(l) > max(l):
    c += 1
print(c)

Fixed submission:
import sys
from bisect import bisect, bisect_left

input = sys.stdin.readline
N = int(input())
L = sorted([int(x) for x in input().split()])
c = 0
for i in range(N - 2):
    for j in range(i + 1, N - 1):
        f = bisect_left(L, L[i] + L[j])
        c += f - j - 1
print(c)