Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ret = 0
    for a in range(N-2):
        for b in range(a+1,N-1):
#            a<b+c => a-b<c
#            b<c+a => b-a<c
#            c<a+b
# b-a<c<a+b
            rr = bisect_right(L[b+1:], L[a]+L[b]-1)
            ll = 0
            ret += rr - ll

    print(ret)

if __name__ == '__main__':
    main()

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

Buggy python submission (verdict: Time Limit Exceeded):
#!/usr/bin python3
# -*- coding: utf-8 -*-

from bisect import bisect_left, bisect_right

def main():
    N = int(input())
    L = list(map(int, input().split()))
    L.sort()
    ret = 0
    for a in range(N-2):
        for b in range(a+1,N-1):
#            a<b+c => a-b<c
#            b<c+a => b-a<c
#            c<a+b
# b-a<c<a+b
            rr = bisect_right(L[b+1:], L[a]+L[b]-1)
            ll = bisect_left(L[b+1:], L[b]-L[a]+1)
            ret += rr - ll

    print(ret)

if __name__ == '__main__':
    main()

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

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect
N = int(input())
L = list(map(int, input().split()))
L.sort()
ret = 0
for i in range(N-2):
    for j in range(i+1, N-1):
        ret += bisect(L[j+1:],L[i]+L[j]-1)
print(ret)

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

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

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

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

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

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

from itertools import permutations, combinations,combinations_with_replacement,product
nCr = list(combinations(range(N), 3))

ret = 0
for i in nCr:
  if L[i[0]]<L[i[1]]+L[i[2]] and L[i[1]]<L[i[2]]+L[i[0]] and L[i[2]]<L[i[0]]+L[i[1]]:
    ret +=1
print(ret)

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
L = list(map(int, input().split()))
L.sort()
ret = 0
for i in range(0, N-2):
    for j in range(i+1, N-1):
        ret += len([k for k in L[j+1:] if L[i]+L[j]>k])
print(ret)

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
import bisect
N = int(input())
L = [int(i) for i in input().split()]
L.sort()
ret = 0
for i in range(0, N-2):
    for j in range(i+1, N-1):
        ret += bisect.bisect_right(L[j+1:], L[i]+L[j]-1)
print(ret)

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

Buggy python submission (verdict: Time Limit Exceeded):
import sys
N = int(input())
L = [int(i) for i in input().split()]
L.sort()
ret = 0
for i in range(0, N-2):
    for j in range(i+1, N-1):
        ret += len([k for k in L[j+1:] if L[i]+L[j]>k])
print(ret)

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = input().split()
Li = []
for i in L:
  Li.append(int(i))
Li.sort()
ret = 0
for i in range(2, N):
  for j in range(1,i):
    for k in range(0,j):
      if Li[j]+Li[k] > Li[i]:
        ret += j-k
#        print(i)
#        print(j)
#        print(k)
        break
      else:
        pass
print(ret)

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = input().split()
Li = []
for i in L:
  Li.append(int(i))
Li.sort()
ret = 0
for i in range(2, N):
  for j in range(1,i):
    for k in range(0,j):
      if Li[j]+Li[k] > Li[i]:
        ret += j-k
#        print(i)
#        print(j)
#        print(k)
        break
      else:
        pass
print(ret)

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

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
L = input().split()
Li = []
for i in L:
  Li.append(int(i))
ret = 0
for i in range(0, len(Li)-2):
  for j in range(i+1,len(Li)-1):
    for k in range(j+1,len(Li)):
      if Li[i]+Li[j] > Li[k] and Li[j]+Li[k] > Li[i] and Li[k]+Li[i] > Li[j]:
        ret += 1
print(ret)

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