Buggy python submission (verdict: Time Limit Exceeded):

import bisect

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



cnt = 0
for i in range(0, len(L)-2):
    l1 = L[i]
    rest = L[i+1:]
    for i2 in range(0, len(rest)-1):
        l2 = rest[i2]
        if l2 < l1 / 2:
            break
        if l2 < l1 / 2:
            break
        rest2 = rest[i2+1:]
        cnt += bisect.bisect_left(rest2, l2+l1) - bisect.bisect_left(rest2, l2-l1)

print(cnt)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):

import bisect

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



cnt = 0
for i in range(0, len(L)-2):
    l1 = L[i]
    rest = L[i+1:]
    for i2 in range(0, len(rest)-1):
        l2 = rest[i2]
        if l2 < l1 / 2:
            break
        if l2 < l1 / 2:
            break
        rest2 = rest[i2+1:]
        cnt += bisect.bisect_left(rest2, l2+l1) - bisect.bisect_left(rest2, l2-l1)

print(cnt)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
L = np.sort(np.array(list(map(int, input().split(" ")))))[::-1]

cnt = 0
for i in range(0, len(L)-2):
    l1 = L[i]
    rest = L[i+1:]
    for i2 in range(0, len(rest)-1):
        l2 = rest[i2]
        if l2 < l1 / 2:
            break
        rest2 = rest[i2+1:]
        if sum(rest2 > l1 - l2) == 0:
            break
        else:
            cnt += sum(rest2 > l1 - l2)

print(cnt)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
L = np.sort(np.array(list(map(int, input().split(" ")))))[::-1]

cnt = 0
for i in range(0, len(L)-2):
    l1 = L[i]
    rest = L[i+1:]
    for i2 in range(0, len(rest)-1):
        l2 = rest[i2]
        rest2 = rest[i2+1:]
        if sum(rest2 > l1 - l2) == 0:
            break
        else:
            cnt += sum(rest2 > l1 - l2)

print(cnt)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np

N = int(input())
L = np.sort(np.array(list(map(int, input().split(" ")))))[::-1]

cnt = 0
for i in range(0, len(L)-2):
    l1 = L[i]
    rest = L[i+1:]
    for i2 in range(0, len(rest)-1):
        l2 = rest[i2]
        rest2 = rest[i2+1:]
        cnt += sum(rest2 > l1 - l2)

print(cnt)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import numpy as np

N = int(input())
L = np.sort(np.array(list(map(int, input().split(" ")))))[::-1]

xx = itertools.combinations(L, 3)
cnt = 0
for x in xx:
    if x[0] < x[1] + x[2]:
        cnt += 1
print(cnt)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)

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

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

xx = itertools.combinations(L, 3)
cnt = 0
for x in xx:
    if x[0] < x[1] + x[2] and \
       x[1] < x[2] + x[0] and \
       x[2] < x[0] + x[1]:
        cnt += 1
print(cnt)

Fixed submission:
from bisect import bisect_right
N = int(input())
L = list(map(int, input().split()))
L.sort()
ans = 0
for i in range(N):
    for j in range(i):
        m = L[i]-L[j]
        k = bisect_right(L, m)
        n = max(0, j-k)
        ans+=n
print(ans)