Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L, reverse=True)

    ans = 0
    for i in range(N):
        tmp = 0
        count = 0

        for j in range((i+1), N):
            if L[i]/2 >= L[j]:
                break
            elif L[i] == L[j]:
                tmp += len(L[j+1::])
                count += 1
                continue
            elif L[i] != L[j]:
                ans += tmp*count

            #for k in range((j+1), N):
            #    if L[i] < (L[j]+L[k]):
            #        ans += 1

                ans += len([t for t in L[j+1::] if L[i] < (L[j]+t)])





    
    print(ans)


if __name__ == '__main__':
    main()



Fixed submission:
import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L)
    
    ans = 0
    for i in range(N-1):
        for j in range((i+1), N):    
            c = bisect.bisect_left(L, L[i] + L[j], j+1)
            ans += c - j - 1

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L, reverse=True)

    ans = 0
    for i in range(N):
        #tmp = 0

        for j in range((i+1), N):
            if L[i]/2 >= L[j]:
                break
            elif L[i] == L[j]:
                ans += len(L[j+1::])
                continue

            #for k in range((j+1), N):
            #    if L[i] < (L[j]+L[k]):
            #        ans += 1

            ans += len([t for t in L[j+1::] if L[i] < (L[j]+t)])





    
    print(ans)


if __name__ == '__main__':
    main()



Fixed submission:
import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L)
    
    ans = 0
    for i in range(N-1):
        for j in range((i+1), N):    
            c = bisect.bisect_left(L, L[i] + L[j], j+1)
            ans += c - j - 1

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L, reverse=True)

    ans = 0
    for i in range(N):

        for j in range((i+1), N):
            if L[i]/2 >= L[j]:
                break 
            #for k in range((j+1), N):
            #    if L[i] < (L[j]+L[k]):
            #        ans += 1

            ans += len([t for t in L[j+1::] if L[i] < (L[j]+t)])


    
    print(ans)


if __name__ == '__main__':
    main()



Fixed submission:
import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L)
    
    ans = 0
    for i in range(N-1):
        for j in range((i+1), N):    
            c = bisect.bisect_left(L, L[i] + L[j], j+1)
            ans += c - j - 1

    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L, reverse=True)

    ans = 0
    for i in range(N):
        for j in range((i+1), N):
            if L[i]/2 >= L[j]:
                break 
            for k in range((j+1), N):
                if L[i] < (L[j]+L[k]):
                    ans += 1

    
    print(ans)


if __name__ == '__main__':
    main()



Fixed submission:
import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))

    L = sorted(L)
    
    ans = 0
    for i in range(N-1):
        for j in range((i+1), N):    
            c = bisect.bisect_left(L, L[i] + L[j], j+1)
            ans += c - j - 1

    print(ans)


if __name__ == '__main__':
    main()