Buggy python submission (verdict: Time Limit Exceeded):
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

#m = bisect.bisect_left(l, a + b)
#count += (m - j - 1)
    
count = 0        
for i in range(n-1):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]
    L_temp = L[k+1:]
    count += (bisect.bisect_left(L_temp, a + b)) 
print(count)

Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()
 
def binary_search(list, item):
    low = 0
    high = len(list) - 1
    
    while low <= high:
        if item > list[high]:
          return high+1
          break
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
          return mid
        elif guess > item:
          high = mid -1
          if list[mid-1] < item:
            return mid-1
            break
        elif guess < item:
          low = mid + 1
          if list[mid+1] > item:
            return mid+1
            break
        else:
          print('error')
 
    return 0
 
 
count = 0        
for i in range(n-1):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]
    L_temp = L[k+1:]
    binary_search(L_temp, a+b)
    count = count + binary_search(L_temp, a+b)
    
print(count)

Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)

Buggy python submission (verdict: Runtime Error):
=int(input()) 
L=list(map(int, input().split())) 
L.sort()
 
def binary_search(list, item):
    low = 0
    high = len(list) - 1
    
    while low <= high:
        if item > list[high]:
          return high+1
          break
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
          return mid
        elif guess > item:
          high = mid -1
          if list[mid-1] < item:
            return mid-1
            break
        elif guess < item:
          low = mid + 1
          if list[mid+1] > item:
            return mid+1
            break
        else:
          print('error')
 
    return 0
 
 
count = 0        
for i in range(n-1):
  for k in range(i+1,n-1):
    a,b =L[i],L[k]
    L_temp = L[k+1:]
    binary_search(L_temp, a+b)
    count = count + binary_search(L_temp, a+b)
    
print(count)

Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

def binary_search(list, item):
    low = 0
    high = len(list) - 1
    
    while low <= high:
        if item > list[high]:
          return high+1
          break
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
          return mid
        elif guess > item:
          high = mid -1
          if list[mid-1] < item:
            return mid-1
            break
        elif guess < item:
          low = mid + 1
          if list[mid+1] > item:
            return mid+1
            break
        else:
          print('error')

    return 0


count = 0        
for i in range(n-1):
  for k in range(i+1,n-1):
    a,b =L[i],L[k]
    L_temp = L[k+1:]
    binary_search(L_temp, a+b)
    count = count + binary_search(L_temp, a+b)
    
print(count)


Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input()) 
L=list(map(int, input().split())) 
L.sort(reverse = True)
L = np.array(L)
count = 0
            
for i in range(n-1):
  for k in range(i+1,n-1):
    a,b =L[i],L[k]
    L_temp = L[k+1:]
    count = count + np.count_nonzero(L_temp+b > a)
    
print(count)

Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):

n=int(input()) 
L=list(map(int, input().split())) 
L.sort(reverse = True)
 
count = 0
            
for i in range(n-1):
  for k in range(i+1,n-1):
    a,b =L[i],L[k]
    L_temp = L[k+1:]
    count = count + sum([1 for x in L_temp if b+x>a])
    
print(count)

Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input()) 
L=list(map(int, input().split())) 
le =len(L)

count = 0
            
for i in range(le-1):
  for k in range(i+1,le-1):
    a,b =L[i],L[k]
    L_temp = L[k+1:]
    count = count + sum([1 for x in L_temp if a+b>x and a+x>b and b+x>a])
    
print(count)

Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input()) 
 
L=list(map(int, input().split())) 
 
comb = list(itertools.combinations(L, 3))

count = 0

for i in comb:
  if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1]:
    count = count+1
print(count)

Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
n=int(input()) 
 
L=list(map(int, input().split())) 
 
comb = list(itertools.combinations(L, 3))

count = 0

for i in comb:
  if i[0]+i[1]>i[2] and i[1]+i[2]>i[0] and i[2]+i[0]>i[1]:
    count = count+1
print(count)

Fixed submission:
import bisect
n=int(input()) 
L=list(map(int, input().split())) 
L.sort()

count = 0        
for i in range(n-2):
  a = L[i]
  for k in range(i+1,n-1):
    b = L[k]

    count += bisect.bisect_left(L, a + b) - k -1
print(count)