Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import bisect

def main():
    n=int(input())
    l=sorted(list(map(int,input().split())))
    ans=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            ans+=bisect.bisect_left(l[j+1:],l[i]+l[j])
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_left

def main():
    n=int(input())
    l=sorted(list(map(int,input().split())))
    ans=0
    for i in range(n-2):
        a=l[i]
        for j in range(i+1,n-1):
            ans+=bisect_left(l,a+l[j])-j-1
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import sys
input = sys.stdin.readline
import numpy as np

def main():
    n=int(input())
    l=sorted(list(map(int,input().split())))
    ans=0
    for i in range(n-2):
        for j in range(i+1,n-1):
            num=np.searchsorted(l[j+1:],l[i]+l[j]-0.5,side='right')
            ans+=num
    print(ans)

if __name__ == '__main__':
    main()

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_left

def main():
    n=int(input())
    l=sorted(list(map(int,input().split())))
    ans=0
    for i in range(n-2):
        a=l[i]
        for j in range(i+1,n-1):
            ans+=bisect_left(l,a+l[j])-j-1
    print(ans)

if __name__ == '__main__':
    main()

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

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_left

def main():
    n=int(input())
    l=sorted(list(map(int,input().split())))
    ans=0
    for i in range(n-2):
        a=l[i]
        for j in range(i+1,n-1):
            ans+=bisect_left(l,a+l[j])-j-1
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
l=list(map(int,input().split()))
l.sort()
L=np.array(l)
cnt=0
for i in range(n-2):
  for j in range(i+1,n-1):
    cnt+=np.count_nonzero(L[j+1:]<L[i]+L[j])
print(cnt)

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_left

def main():
    n=int(input())
    l=sorted(list(map(int,input().split())))
    ans=0
    for i in range(n-2):
        a=l[i]
        for j in range(i+1,n-1):
            ans+=bisect_left(l,a+l[j])-j-1
    print(ans)

if __name__ == '__main__':
    main()

Buggy python submission (verdict: Runtime Error):
import numpy as np
n=int(input())
l=list(map(int,input().split()))
l.sort()
L=np.array(l)
cnt=0
for i in range(n-2):
  for j in range(i+1,n-1):
    cnt+=np.count_nonzero(L[j+1:]<L[i]+L[j])
print(cnt)

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_left

def main():
    n=int(input())
    l=sorted(list(map(int,input().split())))
    ans=0
    for i in range(n-2):
        a=l[i]
        for j in range(i+1,n-1):
            ans+=bisect_left(l,a+l[j])-j-1
    print(ans)

if __name__ == '__main__':
    main()

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

Fixed submission:
import sys
input = sys.stdin.readline
from bisect import bisect_left

def main():
    n=int(input())
    l=sorted(list(map(int,input().split())))
    ans=0
    for i in range(n-2):
        a=l[i]
        for j in range(i+1,n-1):
            ans+=bisect_left(l,a+l[j])-j-1
    print(ans)

if __name__ == '__main__':
    main()