Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

    ans = 0

    for i in range(N):
        for j in range(i+1, N):
            X = L[i] + L[j]
            l = bisect.bisect_left(L, X, lo=j+1)
            ans += (l-(j+1))
            #print(L[j + 1:l])
    print(ans)
    return 0

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):
        for j in range(i+1, N):
            X = L[i] + L[j]
            l = bisect.bisect_left(L, X, lo=j+1)
            ans += (l-(j+1))
            #print(L[j + 1:l])
    print(ans)
    return 0

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import bisect

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

    ans = 0

    for i in range(N):
        for j in range(i+1, N):
            X = L[i] + L[j]
            l = bisect.bisect_left(L, X, lo=j+1)
            ans += len(L[j+1:l])
            #print(L[j + 1:l])
    print(ans)
    return 0

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):
        for j in range(i+1, N):
            X = L[i] + L[j]
            l = bisect.bisect_left(L, X, lo=j+1)
            ans += (l-(j+1))
            #print(L[j + 1:l])
    print(ans)
    return 0

if __name__ == '__main__':
    main()

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

    L.sort(reverse=True)
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            min = L[i] - L[j] + 1
            max = L[j] - 1
            if min > max:
                break
            tmp = len([k for k in L if (min<=k)&(k<=max)])
            ans += tmp

    print(ans)

    return 0

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):
        for j in range(i+1, N):
            X = L[i] + L[j]
            l = bisect.bisect_left(L, X, lo=j+1)
            ans += (l-(j+1))
            #print(L[j + 1:l])
    print(ans)
    return 0

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)
    ans = 0
    for i in range(N):
        for j in range(i+1, N):
            for k in range(j+1, N):
                if L[i]+L[j] > L[k]:
                    ans += 1
                else:
                    break
    print(ans)
    return 0

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):
        for j in range(i+1, N):
            X = L[i] + L[j]
            l = bisect.bisect_left(L, X, lo=j+1)
            ans += (l-(j+1))
            #print(L[j + 1:l])
    print(ans)
    return 0

if __name__ == '__main__':
    main()