Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
List = list(map(int,input().split()))
List.sort()
counter = 0
for i in range(N-2):
  for j in range(N-i-2):
    k = i + j + 2
    while k < N:
      if List[i+j+1] + List[i] > List[k]:
        counter += 1
        k += 1
      else:
          break
print(counter)

Fixed submission:
import bisect
N = int(input())
List = list(map(int,input().split()))
List.sort()
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    ans += bisect.bisect_left(List,List[i]+List[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L = sorted(L, reverse =True)
counter = 0
for i in range(N):
  for j in range(N-1-i):
    for k in range(N -2 -i -j):
      a = L[i]
      b = L[i+j+1]
      c = L[i+j+k+2]
      if c <= a-b:
        break
      elif b < a + c:
        counter += 1
    
print(counter)

Fixed submission:
import bisect
N = int(input())
List = list(map(int,input().split()))
List.sort()
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    ans += bisect.bisect_left(List,List[i]+List[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = list(map(int,input().split()))
L = sorted(L, reverse =True)
counter = 0
for i in range(N):
  for j in range(N-1-i):
    for k in range(N -2 -i -j):
      a = L[i]
      b = L[i+j+1]
      c = L[i+j+k+2]
      if c <= a-b:
        break
      elif b < a + c:
        counter += 1
    
print(counter)

Fixed submission:
import bisect
N = int(input())
List = list(map(int,input().split()))
List.sort()
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    ans += bisect.bisect_left(List,List[i]+List[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int,input().split()))
counter = 0
for i in range(N):
  for j in range(N-1-i):
    for k in range(N -2 -i -j):
      a = S[i]
      b = S[i+j+1]
      c = S[i+j+k+2]
      if (a + b > c) and (c > abs(a - b)):
        counter += 1
    
print(counter)

Fixed submission:
import bisect
N = int(input())
List = list(map(int,input().split()))
List.sort()
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    ans += bisect.bisect_left(List,List[i]+List[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int,input().split()))
counter = 0
for i in range(N):
  for j in range(N-1-i):
    for k in range(N -2 -i -j):
      a = S[i]
      b = S[i+j+1]
      c = S[i+j+k+2]
      if (a + b > c) and (c > abs(a - b)):
        counter += 1
    
print(counter)

Fixed submission:
import bisect
N = int(input())
List = list(map(int,input().split()))
List.sort()
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    ans += bisect.bisect_left(List,List[i]+List[j])-(j+1)
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
S = list(map(int,input().split()))
counter = 0
for i in range(N):
  for j in range(N-1-i):
    for k in range(N -2 -i -j):
      a = S[i]
      b = S[i+j+1]
      c = S[i+j+k+2]
      if (a + b > c) and (c > abs(a - b)) and (a + b > c):
        counter += 1
    
print(counter)

Fixed submission:
import bisect
N = int(input())
List = list(map(int,input().split()))
List.sort()
ans = 0
for i in range(N-1):
  for j in range(i+1, N):
    ans += bisect.bisect_left(List,List[i]+List[j])-(j+1)
print(ans)