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

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

num_triangles = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(a=L, x=L[i]+L[j], lo=j+1)
        num_triangles += idx-j-1
print(num_triangles)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        endpt = bisect_left(l, l[i] + l[j])
        ans += endpt-j-1

print(ans)

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

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

L.sort()

num_triangles = 0
for i in range(N-2): # stick 1
    for j in range(i+1, N-1): # stick 2; must be larger than 1
        # if a<b then we require c<b+a
        idx = bisect_left(a=L, x=L[i]+L[j], lo=j+1) # find the index at which c<b+a
        num_triangles += idx-(j+1) # c can be, at minimum, b=c
print(num_triangles)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        endpt = bisect_left(l, l[i] + l[j])
        ans += endpt-j-1

print(ans)

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

N = int(input())
L = [int(i) for i in input().split()]

L.sort()

num_triangles = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        idx = bisect_left(a=L, x=L[i]+L[j], lo=j+1)        
        num_triangles += idx-(j+1) 
print(num_triangles)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        endpt = bisect_left(l, l[i] + l[j])
        ans += endpt-j-1

print(ans)

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

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

L.sort()

num_triangles = 0
for i in range(N-2): # stick 1
    for j in range(i+1, N-1): # stick 2; must be larger than 1
        # if a<b then we require c<b+a
        idx = bisect_left(a=L, x=L[i]+L[j], lo=j+1) # find the index at which c<b+a
        num_triangles += max(0, idx-(j+1)) # c can be, at minimum, b=c
print(num_triangles)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        endpt = bisect_left(l, l[i] + l[j])
        ans += endpt-j-1

print(ans)

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

N = int(input())
L = [int(i) for i in input().split()]

L.sort()

num_triangles = 0
for i in range(N-2): # stick 1
    for j in range(i+1, N-1): # stick 2; must be larger than 1
        # if a<b then we require c<b+a
        idx = bisect_left(a=L, x=L[i]+L[j]) # find the index at which c<b+a
        num_triangles += max(0, idx-(j+1)) # c can be, at minimum, b=c
print(num_triangles)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        endpt = bisect_left(l, l[i] + l[j])
        ans += endpt-j-1

print(ans)

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

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

L.sort()

num_triangles = 0
for i in range(N-2): # stick 1
    for j in range(i+1, N-1): # stick 2; must be larger than 1
        # if a<b then we require c<b+a
        idx = bisect_left(a=L, x=L[i]+L[j]) # find the index at which c<b+a
        num_triangles += max(0, idx-(j+1)) # c can be, at minimum, b=c
print(num_triangles)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        endpt = bisect_left(l, l[i] + l[j])
        ans += endpt-j-1

print(ans)

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

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

L.sort()

num_triangles = 0
for i in range(N): # stick 1
    for j in range(i+1, N): # stick 2; must be larger than 1
        # if a<b then we require c<b+a
        idx = bisect_left(a=L, x=L[i]+L[j]) # find the index at which c<b+a
        num_triangles += max(0, idx-(j+1)) # c can be, at minimum, b=c
print(num_triangles)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        endpt = bisect_left(l, l[i] + l[j])
        ans += endpt-j-1

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from itertools import combinations

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

def satisfy_conditions(L):
    a = L[0]
    b = L[1]
    c = L[2]
    if a < b + c and b < c + a and c < a + b:
        return True
    else:
        return False

num_triangles = 0

stick_combos = combinations(L, 3)
for stick_combo in stick_combos:
    if satisfy_conditions(stick_combo):
        num_triangles += 1
print(num_triangles)


Fixed submission:
from bisect import bisect_left

n = int(input())
l = list(map(int, input().split()))
l.sort()

ans = 0
for i in range(n):
    for j in range(i+1, n):
        endpt = bisect_left(l, l[i] + l[j])
        ans += endpt-j-1

print(ans)