Buggy python submission (verdict: Time Limit Exceeded):
def bin_search1(L1,L2,l,N):#長すぎる辺の個数を返す
    low = 0
    high = N-1
    while high-low>1:
        mid = (low+high)//2
        if (L1+L2<=l[mid]):#長すぎ
            high = mid
        else:
            low = mid
    if L1+L2>l[high]:#全部ok
        return 0
    elif L1+L2<=l[low]:#全部ng
        return N
    else:
        return N-high

def bin_search2(L1,L2,l,N):#短すぎる辺の個数を返す
    low = 0
    high = N-1
    while high-low>1:
        mid = (low+high)//2
        if (abs(L1-L2)>=l[mid]):
            low = mid
        else:
            high = mid
    if abs(L1-L2)<l[low]:
        return 0
    elif abs(L1-L2)>=l[high]:
        return N
    else:
        return high

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N):
    for j in range(N):
        if i!=j:
            L_temp = L#修正面倒なため
            a = L[i]
            b = L[j]
            if i<j:
                L_temp.pop(j)
                L_temp.pop(i)
                ans += (N-2-bin_search1(a,b,L_temp,N-2)-bin_search2(a,b,L_temp,N-2))
                L.insert(i,a)
                L.insert(j,b)
            else:
                L_temp.pop(i)
                L_temp.pop(j)
                ans += (N-2-bin_search1(a,b,L_temp,N-2)-bin_search2(a,b,L_temp,N-2))
                L.insert(j,b)
                L.insert(i,a)
                
ans = ans//6

print(ans)

Fixed submission:
from bisect import bisect＿left

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        ans += bisect_left(L,L[i]+L[j])-(j+1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def bin_search1(L1,L2,l):#長すぎる辺の個数を返す
    low = 0
    high = len(l)-1
    while high-low>1:
        mid = (low+high)//2
        if (L1+L2<=l[mid]):#長すぎ
            high = mid
        else:
            low = mid
    if L1+L2>l[high]:#全部ok
        return 0
    elif L1+L2<=l[low]:#全部ng
        return len(l)
    else:
        return len(l)-high

def bin_search2(L1,L2,l):#短すぎる辺の個数を返す
    low = 0
    high = len(l)-1
    while high-low>1:
        mid = (low+high)//2
        if (abs(L1-L2)>=l[mid]):
            low = mid
        else:
            high = mid
    if abs(L1-L2)<l[low]:
        return 0
    elif abs(L1-L2)>=l[high]:
        return len(l)
    else:
        return high

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N):
    for j in range(N):
        if i!=j:
            L_temp = L#修正面倒なため
            a = L[i]
            b = L[j]
            if i<j:
                L_temp.pop(j)
                L_temp.pop(i)
                ans += (N-2-bin_search1(a,b,L_temp)-bin_search2(a,b,L_temp))
                L.insert(i,a)
                L.insert(j,b)
            else:
                L_temp.pop(i)
                L_temp.pop(j)
                ans += (N-2-bin_search1(a,b,L_temp)-bin_search2(a,b,L_temp))
                L.insert(j,b)
                L.insert(i,a)
                
ans = ans//6

print(ans)

Fixed submission:
from bisect import bisect＿left

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        ans += bisect_left(L,L[i]+L[j])-(j+1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def bin_search1(L1,L2,l):#長すぎる辺の個数を返す
    low = 0
    high = len(l)-1
    while high-low>1:
        mid = (low+high)//2
        if (L1+L2<=l[mid]):#長すぎ
            high = mid
        else:
            low = mid
    if L1+L2>l[high]:#全部ok
        return 0
    elif L1+L2<=l[low]:#全部ng
        return len(l)
    else:
        return len(l)-high

def bin_search2(L1,L2,l):#短すぎる辺の個数を返す
    low = 0
    high = len(l)-1
    while high-low>1:
        mid = (low+high)//2
        if (abs(L1-L2)>=l[mid]):
            low = mid
        else:
            high = mid
    if abs(L1-L2)<l[low]:
        return 0
    elif abs(L1-L2)>=l[high]:
        return len(l)
    else:
        return high

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N):
    for j in range(N):
        if i!=j:
            L_temp = L#修正面倒なため
            a = L[i]
            b = L[j]
            if i<j:
                L_temp.pop(j)
                L_temp.pop(i)
                ans += (N-2-bin_search1(a,b,L_temp)-bin_search2(a,b,L_temp))
                L.insert(i,a)
                L.insert(j,b)
            else:
                L_temp.pop(i)
                L_temp.pop(j)
                ans += (N-2-bin_search1(a,b,L_temp)-bin_search2(a,b,L_temp))
                L.insert(j,b)
                L.insert(i,a)

           
         
        
ans = ans//6

print(ans)

Fixed submission:
from bisect import bisect＿left

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        ans += bisect_left(L,L[i]+L[j])-(j+1)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def bin_search1(L1,L2,l):#長すぎる辺の個数を返す
    low = 0
    high = len(l)-1
    while high-low>1:
        mid = (low+high)//2
        if (L1+L2<=l[mid]):#長すぎ
            high = mid
        else:
            low = mid
    if L1+L2>l[high]:#全部ok
        return 0
    elif L1+L2<=l[low]:#全部ng
        return len(l)
    else:
        return len(l)-high

def bin_search2(L1,L2,l):#短すぎる辺の個数を返す
    low = 0
    high = len(l)-1
    while high-low>1:
        mid = (low+high)//2
        if (abs(L1-L2)>=l[mid]):
            low = mid
        else:
            high = mid
    if abs(L1-L2)<l[low]:
        return 0
    elif abs(L1-L2)>=l[high]:
        return len(l)
    else:
        return high

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N):
    for j in range(N):
        if i!=j:
            L_temp = L.copy()
            if i<j:
                L_temp.pop(j)
                L_temp.pop(i)
            else:
                L_temp.pop(i)
                L_temp.pop(j)

            ans += (N-2-bin_search1(L[i],L[j],L_temp)-bin_search2(L[i],L[j],L_temp))
         
        
ans = ans//6

print(ans)

Fixed submission:
from bisect import bisect＿left

N = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0

for i in range(N-1):
    for j in range(i+1,N):
        ans += bisect_left(L,L[i]+L[j])-(j+1)

print(ans)