Buggy python submission (verdict: Time Limit Exceeded):

from bisect import bisect_right
N = int(input())
L = sorted(list(map(int,input().split())))
count = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        ma = bisect_right(L[j+1:], L[i] + L[j] -1)
        if ma >= 0:
            count += ma
print(count)


Fixed submission:

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

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import bisect
N = int(input())
L = sorted(list(map(int,input().split())))
count = 0
for i in range(N-2):
    for j in range(i+1,N-1):
        ma = bisect.bisect_right(L[j+1:], L[i] + L[j] -1)
        if ma >= 0:
            count += ma
print(count)



Fixed submission:

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

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


Fixed submission:

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

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        maxi = L[i] + L[j] -1
        #mini = abs(L[i] - L[j]) +1
        # mi = bisect.bisect_left(L[j+1:],mini)
        ma = bisect.bisect_right(L[j+1:], maxi)
        #print("mi"+str(mi)+"ma"+str(ma))
        if ma >= 0:
            count += ma
print(count)


Fixed submission:

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

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        #print(L[i])
        #print(L[j])
        maxi = L[i] + L[j] -1
        mini = abs(L[i] - L[j]) +1
        #print("maxi"+str(maxi)+"mini"+str(mini))
        #cL = copy.copy(L)
        #del cL[:j+1]
        #print(cL)
        mi = bisect.bisect_left(L[j+1:],mini)
        ma = bisect.bisect_right(L[j+1:], maxi)
        #print("mi"+str(mi)+"ma"+str(ma))
        if ma >= mi:
            count += ma-mi
print(count)


Fixed submission:

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

Buggy python submission (verdict: Time Limit Exceeded):
import copy
import bisect
N = int(input())
L = list(map(int,input().split()))
count = 0
L.sort()
for i in range(N-2):
    for j in range(i+1,N-1):
        #print(L[i])
        #print(L[j])
        maxi = L[i] + L[j] -1
        mini = abs(L[i] - L[j]) +1
        #print("maxi"+str(maxi)+"mini"+str(mini))
        cL = copy.copy(L)
        del cL[:j+1]
        #print(cL)
        mi = bisect.bisect_left(cL,mini)
        ma = bisect.bisect_right(cL, maxi)
        #print("mi"+str(mi)+"ma"+str(ma))
        if ma >= mi:
            count += ma-mi
print(count)


Fixed submission:

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

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


Fixed submission:

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

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


Fixed submission:

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

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


Fixed submission:

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