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

c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l[j+1:], l[i]+l[j])
 
print(c)



Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

Buggy python submission (verdict: Runtime Error):
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split())).sort
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j], j+1)
 
print(c)


Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split())))

c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += max(0, bisect_left(l[j+1:], l[i]+l[j]))

print(c)


Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split())))

c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l[j+1:], l[i]+l[j])

print(c)


Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_left

n = int(input())
l = sorted(list(map(int, input().split())))

c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += max(0, bisect_left(l[j+1:], l[i]+l[j]))

print(c)


Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

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

c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += sum(abs(l[i]-l[j]) < x < l[i]+l[j] for x in l[j+1:])

print(c)


Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

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

c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += sum(abs(l[i]-l[j]) < x < l[i]+l[j] for x in l[j+1:])

print(c)


Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

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

c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += sum(l[i]+l[j] > x for x in l[j+1:])

print(c)


Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)

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

def check(a,b,c):
  return (a+b>c and b+c>a and c+a>b)

c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      c += 1 if check(l[i], l[j], l[k]) else 0
      
print(c)


Fixed submission:
from bisect import bisect_left
 
n = int(input())
l = list(map(int, input().split()))
l.sort()
 
c = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    c += bisect_left(l, l[i]+l[j]) - j - 1
 
print(c)