Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

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

    L = sorted(L)

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

    print(ans)

if __name__ == '__main__':
    main()



Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

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

    L = sorted(L)

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

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

def main():
    N = int(input())
    L = list(map(int, input().split()))
    
    L = sorted(L)
    
    ans = 0
    for i in range(N-2):
        for j in range(N-1):
            if j > i:
                b = L[j] - L[i]
                c = L[i] + L[j]
                mi = bisect.bisect_left(L[j+1:], b)
                ma = bisect.bisect_left(L[j+1:], c)
                ans += ma - mi
    
    print(ans)
    
if __name__ == '__main__':
    main()



Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

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

    L = sorted(L)

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

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

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

L = sorted(L)

ans = 0
for i in range(N-2):
    for j in range(N-1):
        if j > i:
            b = L[j] - L[i]
            c = L[i] + L[j]
            mi = bisect.bisect_left(L[j+1:], b)
            ma = bisect.bisect_left(L[j+1:], c)
            ans += ma - mi

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

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

    L = sorted(L)

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

    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

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

L = sorted(L)

ans = 0
for i in range(N-2):
    for j in range(N-1):
        if j > i:
            b = L[j] - L[i]
            c = L[i] + L[j]
            mi = bisect.bisect_left(L[j+1:], b)
            ma = bisect.bisect_left(L[j+1:], c)
            ans += ma - mi

print(ans)

Fixed submission:
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

import bisect

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

    L = sorted(L)

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

    print(ans)

if __name__ == '__main__':
    main()