Buggy python submission (verdict: Time Limit Exceeded):
# ABC-143-D
#尺取り方でやってみる。
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0

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

Fixed submission:
N = int(input())
L_list = list(map(int, input().split()))
sum = 0

L_list.sort()

from bisect import bisect_left

for i in range(N):
    for j in range(i+1, N):
        t = L_list[i]+L_list[j]
        idx = bisect_left(L_list, t)
        sum += max(0, idx-(j+1))
        
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
# ABC-143-D
N = int(input())
L = sorted(list(map(int, input().split())))
ans = 0

def binary_search(j, a_plus_b):
    left = j + 1
    right = N-1
    while right-left > 1:
        tmp = (left+right)//2
        if L[tmp] < a_plus_b:
            left = tmp
        else:
            right = tmp
    if L[(left+right)//2] >= a_plus_b:
        return j
    else:
        return (left+right)//2

for i in range(0, N-2):
    for j in range(i+1, N-1):
        a_plus_b = L[i] + L[j]
        #この部分をbinary_search関数でうまくできないかもっと考えたい
        if a_plus_b > L[-1]:
            ans += N - (j + 1)
        else:
            ans += binary_search(j, a_plus_b) - j

print(ans)

Fixed submission:
N = int(input())
L_list = list(map(int, input().split()))
sum = 0

L_list.sort()

from bisect import bisect_left

for i in range(N):
    for j in range(i+1, N):
        t = L_list[i]+L_list[j]
        idx = bisect_left(L_list, t)
        sum += max(0, idx-(j+1))
        
print(sum)

Buggy python submission (verdict: Runtime Error):
N = map(int, input())
L_list = list(map(int, input().split()))
sum = 0

L_list.sort()

from bisect import bisect_left
# print(bisect_left(L_list, 3))

for i in range(N):
    for j in range(i+1, N):
        t = L_list[i]+L_list[j]
        idx = bisect_left(L_list, t)
        sum += max(0, idx-(j+1))
        
print(sum)

Fixed submission:
N = int(input())
L_list = list(map(int, input().split()))
sum = 0

L_list.sort()

from bisect import bisect_left

for i in range(N):
    for j in range(i+1, N):
        t = L_list[i]+L_list[j]
        idx = bisect_left(L_list, t)
        sum += max(0, idx-(j+1))
        
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
N = map(int, input())
data = list(map(int, input().split()))
sum = 0

#L_list = [3 4 2 1]なら[3,4,2],[3,4,1],[3,2,1],[4,2,1]の4通り
def listExcludedIndices(data, indices=[]):
  return [x for i, x in enumerate(data) if i not in indices]

L_combinations = []

for i in range(len(data)):
  for j in range(i, len(data) - 1):
    for k in range(j, len(data) - 2):
      jData = listExcludedIndices(data, [i])
      kData = listExcludedIndices(jData, [j])
      L_combinations.append([data[i], jData[j], kData[k]])

# print(L_combinations)
for L_combination in L_combinations:
    if L_combination[0] < L_combination[1] + L_combination[2] and L_combination[1] < L_combination[2] + L_combination[0] and L_combination[2] < L_combination[0] + L_combination[1]:
        sum += 1

print(sum)

Fixed submission:
N = int(input())
L_list = list(map(int, input().split()))
sum = 0

L_list.sort()

from bisect import bisect_left

for i in range(N):
    for j in range(i+1, N):
        t = L_list[i]+L_list[j]
        idx = bisect_left(L_list, t)
        sum += max(0, idx-(j+1))
        
print(sum)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
N = map(int, input())
L_list = list(map(int, input().split()))
sum = 0
#L_list = [3 4 2 1]なら[3,4,2],[3,4,1],[3,2,1],[4,2,1]の4通り
L_combinations = list(itertools.combinations(L_list,3))
for L_combination in L_combinations:
    if L_combination[0] < L_combination[1] + L_combination[2] and L_combination[1] < L_combination[2] + L_combination[0] and L_combination[2] < L_combination[0] + L_combination[1]:
        sum += 1

print(sum)

Fixed submission:
N = int(input())
L_list = list(map(int, input().split()))
sum = 0

L_list.sort()

from bisect import bisect_left

for i in range(N):
    for j in range(i+1, N):
        t = L_list[i]+L_list[j]
        idx = bisect_left(L_list, t)
        sum += max(0, idx-(j+1))
        
print(sum)