Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = sorted(list(map(int,input().split())))
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        ab = lis[i]+lis[j]
        if ab>lis[n-1]:
            count += n-1-j
        elif ab<=lis[j+1]:
            next
        else:
            l = j+1
            r = n-1
            m = int((r+l)/2)
            while r-l>1:
                if ab>lis[m]:
                    l = m
                else:
                    r = m
                m = int((r+l)/2)
            count += l-j
print(count)

Fixed submission:
import bisect
n = int(input())
lis = sorted(list(map(int,input().split())))
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        index = bisect.bisect_left(lis,lis[i]+lis[j])
        count += index-1-j
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n = int(input())
lis = sorted(list(map(int,input().split())))
count = 0
for i in range(n-2):
    a = i
    for j in range(1,n-1-i):
        c = n-j
        m = int((c+a)/2)
        l = i
        r = c
        if lis[a]+lis[c-1]>lis[c]:
            while r-l>1:
                if lis[m]+lis[a]>lis[c]:
                    r = m
                else:
                    l = m
                m = int((r+l)/2)
            count += c-r
print(count)

Fixed submission:
import bisect
n = int(input())
lis = sorted(list(map(int,input().split())))
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        index = bisect.bisect_left(lis,lis[i]+lis[j])
        count += index-1-j
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
N = int(input())
Ls = np.sort(list(map(int, input().split())))
count = 0
for i in range(N-2):
    a = Ls[i]
    for k in range(N-i-2):
        ab = a + Ls[i+1:N-1-k]
        c = Ls[N-k-1]
        count = count + np.count_nonzero(ab - c > 0)
print(count)

Fixed submission:
import bisect
n = int(input())
lis = sorted(list(map(int,input().split())))
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        index = bisect.bisect_left(lis,lis[i]+lis[j])
        count += index-1-j
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Ls = list(map(int, input().split()))
Ls.sort()
count = 0
for i in range(N-2):
    a = Ls[i]
    for k in range(i+1,N-1):
        ab = a + Ls[k]
        count += len(list(filter(lambda c: c<ab, Ls[k+1:N])))
print(count)

Fixed submission:
import bisect
n = int(input())
lis = sorted(list(map(int,input().split())))
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        index = bisect.bisect_left(lis,lis[i]+lis[j])
        count += index-1-j
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
Ls = list(map(int, input().split()))
count = 0
for i in range(N-2):
    a = Ls[i]
    for k in range(i+1,N-1):
        b = Ls[k]
        count = count + len(list(filter(lambda c: a+b>c and b+c>a and c+a>b, Ls[k+1:N])))
print(count)

Fixed submission:
import bisect
n = int(input())
lis = sorted(list(map(int,input().split())))
count = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        index = bisect.bisect_left(lis,lis[i]+lis[j])
        count += index-1-j
print(count)