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



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

L.sort()

ans = 0

for c_i in range(2, N):
    min_a_i = 0
    while L[c_i] >= L[min_a_i] + L[c_i - 1] and min_a_i < c_i - 1:
        min_a_i += 1
    
    for b_i in range(min_a_i + 1, c_i):
        a_i = min_a_i
        while L[a_i] + L[b_i] <= L[c_i] and a_i < b_i:
            a_i += 1
        
        ans += b_i - a_i

print(ans)

Fixed submission:
N = int(input().strip())
L = [int(str) for str in input().split()]

L.sort()

ans = 0

for a in range(N - 2):
    c = a + 1
    for b in range(a + 1, N - 1):
        while c < N - 1 and L[c + 1] < L[a] + L[b]:
            c += 1
        ans += c - b

print(ans)

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



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

L.sort()

ans = 0

for c_i in range(2, N):
    a_i = 0
    while L[c_i] >= L[a_i] + L[c_i - 1] and a_i < c_i - 1:
        a_i += 1
    
    ans += sum([1 if L[comb[0]] + L[comb[1]] > L[c_i] else 0 for comb in itertools.combinations(range(a_i, c_i), 2)])

print(ans)

Fixed submission:
N = int(input().strip())
L = [int(str) for str in input().split()]

L.sort()

ans = 0

for a in range(N - 2):
    c = a + 1
    for b in range(a + 1, N - 1):
        while c < N - 1 and L[c + 1] < L[a] + L[b]:
            c += 1
        ans += c - b

print(ans)

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


def check(a):
    if sum(a) > 2 * sum(a):
        return False
    else:
        return a[0] < a[1] + a[2] and a[1] < a[0] + a[2] and a[2] < a[0] + a[1]

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

# print(sum([1 if check(comb) else 0 for comb in itertools.combinations(L, 3)]))

ans = 0
for comb in itertools.combinations(L, 3):
    ans += 1 if check(comb) else 0

print(ans)

Fixed submission:
N = int(input().strip())
L = [int(str) for str in input().split()]

L.sort()

ans = 0

for a in range(N - 2):
    c = a + 1
    for b in range(a + 1, N - 1):
        while c < N - 1 and L[c + 1] < L[a] + L[b]:
            c += 1
        ans += c - b

print(ans)

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


def check(a):
    if sum(a) > 2 * sum(a):
        return False
    else:
        return a[0] < a[1] + a[2] and a[1] < a[0] + a[2] and a[2] < a[0] + a[1]

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

print(sum([1 if check(comb) else 0 for comb in itertools.combinations(L, 3)]))

Fixed submission:
N = int(input().strip())
L = [int(str) for str in input().split()]

L.sort()

ans = 0

for a in range(N - 2):
    c = a + 1
    for b in range(a + 1, N - 1):
        while c < N - 1 and L[c + 1] < L[a] + L[b]:
            c += 1
        ans += c - b

print(ans)

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


def check(a):
    return a[0] < a[1] + a[2] and a[1] < a[0] + a[2] and a[2] < a[0] + a[1]

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

print(sum([1 if check(comb) else 0 for comb in itertools.combinations(L, 3)]))

Fixed submission:
N = int(input().strip())
L = [int(str) for str in input().split()]

L.sort()

ans = 0

for a in range(N - 2):
    c = a + 1
    for b in range(a + 1, N - 1):
        while c < N - 1 and L[c + 1] < L[a] + L[b]:
            c += 1
        ans += c - b

print(ans)