Buggy python submission (verdict: Time Limit Exceeded):
import bisect
def main():
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    Lind = []
    count = 0
    for i in reversed(range(2,N)):
        for j in reversed(range(1,i)):
            if L[i] < 2*L[j]:
                Lind.append([i,j])
    for l in Lind:
        cind = bisect.bisect_left(L,L[l[0]]-L[l[1]])
        for k in range(cind,l[1]):
            if L[l[0]]<L[l[1]]+L[k]:
                count += 1
    print(count)
main()

Fixed submission:
import bisect
def main():
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    
    count = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            c = bisect.bisect_left(L,L[i]+L[j])
            
            count += max(0,c-1 - j)
    
    print(count)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
def main():
    N = int(input())
    L = sorted(list(map(int,input().split())))
    Lind = []
    count = 0
    for i in reversed(range(2,N)):
        for j in reversed(range(1,i)):
            if L[i] < 2*L[j]:
                Lind.append([i,j])
    for l in Lind:
        cind = bisect.bisect_right(L,L[l[0]]-L[l[1]])
        for k in range(cind,l[1]):
            if L[l[0]]<L[l[1]]+L[k]:
                count += 1
    print(count)
main()

Fixed submission:
import bisect
def main():
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    
    count = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            c = bisect.bisect_left(L,L[i]+L[j])
            
            count += max(0,c-1 - j)
    
    print(count)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
def main():
    N = int(input())
    L = sorted(list(map(int,input().split())))
    Lind = []
    count = 0
    for i in reversed(range(2,N)):
        for j in reversed(range(1,i)):
            cind = bisect.bisect_right(L,L[i]-L[j])
            if cind != N-1:
                Lind.append([i,j,cind])
    for l in Lind:
        
        for k in range(cind,l[1]):
            if L[l[0]]<L[l[1]]+L[k]:
                count += 1
    print(count)
main()

Fixed submission:
import bisect
def main():
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    
    count = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            c = bisect.bisect_left(L,L[i]+L[j])
            
            count += max(0,c-1 - j)
    
    print(count)
main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
def main():
    N = int(input())
    L = list(map(int,input().split()))
    L = sorted(L)
    count = 0
    for i in reversed(range(2,N)):
        for j in reversed(range(1,i)):
            cind = bisect.bisect_right(L,L[i]-L[j])
            
            for k in range(cind,j):
                if L[i]<L[j]+L[k]:
                    count += 1
    print(count)
main()

Fixed submission:
import bisect
def main():
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    
    count = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            c = bisect.bisect_left(L,L[i]+L[j])
            
            count += max(0,c-1 - j)
    
    print(count)
main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    L = list(map(int,input().split()))
    count = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            for k in range(j+1,N):
            
                if (L[i]<L[j]+L[k]) and (L[j] < L[i]+L[k]) and (L[k] < L[j]+L[i]):
                    count += 1
    print(count)
main()

Fixed submission:
import bisect
def main():
    N = int(input())
    L = list(map(int,input().split()))
    L.sort()
    
    count = 0
    for i in range(N-2):
        for j in range(i+1,N-1):
            c = bisect.bisect_left(L,L[i]+L[j])
            
            count += max(0,c-1 - j)
    
    print(count)
main()