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

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

ans = 0

for i in range(n):
	d = []
	for j in range(i+1,n):
		index = bisect.bisect_left(l,l[i]+l[j])
		for k in range(i+1,j):
			if l[j] < l[k] + l[i]:
				if [k,j] not in d:
					d.append([k,j])
					ans += 1
		for k in range(j+1,index):
			if l[k] < l[j] + l[i]:
				if [j,k] not in d:
					d.append([j,k])
					ans += 1
print(ans)


Fixed submission:
import bisect

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

l.sort()
#print(l)
ans = 0
for i in range(n-1):
	a = l[i]
	for j in range(i+2,n):
		b = l[j]
		c = bisect.bisect_left(l,b-a+1)
		if j - c > 0:
			if i >= c:
				ans += j-i-1
			else:
				ans += j-c
		#print(i,j,c,ans)

print(ans)

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

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

t = list(itertools.combinations(l,3))

ans = 0

for i in range(len(t)):
	tmp = list(t[i])
	tmp.sort()
	if tmp[0] + tmp[1] > tmp[2]:
		ans += 1

print(ans)


Fixed submission:
import bisect

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

l.sort()
#print(l)
ans = 0
for i in range(n-1):
	a = l[i]
	for j in range(i+2,n):
		b = l[j]
		c = bisect.bisect_left(l,b-a+1)
		if j - c > 0:
			if i >= c:
				ans += j-i-1
			else:
				ans += j-c
		#print(i,j,c,ans)

print(ans)

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

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

ans = 0

d = []

for i in range(n):
	for j in range(i+1,n):
		index = bisect.bisect_left(l,l[i]+l[j])
		for k in range(i+1,index):
			if k == j:
				continue
			if l[j] < l[k] + l[i]:
				if j < k:
					if [i,j,k] not in d:
						d.append([i,j,k])
						ans += 1
				else:
					if [i,k,j] not in d:
						d.append([i,k,j])
						ans += 1

print(ans)


Fixed submission:
import bisect

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

l.sort()
#print(l)
ans = 0
for i in range(n-1):
	a = l[i]
	for j in range(i+2,n):
		b = l[j]
		c = bisect.bisect_left(l,b-a+1)
		if j - c > 0:
			if i >= c:
				ans += j-i-1
			else:
				ans += j-c
		#print(i,j,c,ans)

print(ans)

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

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

ans = 0

d = []

for i in range(n):
	for j in range(i+1,n):
		index = bisect.bisect_left(l,l[i]+l[j])
		for k in range(index):
			if k == i or k == j:
				continue
			if l[j] < l[k] + l[i]:
				tmp = []
				tmp.append(i)
				tmp.append(j)
				tmp.append(k)
				tmp.sort()
				if tmp not in d:
					d.append(tmp)
					ans += 1

print(ans)


Fixed submission:
import bisect

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

l.sort()
#print(l)
ans = 0
for i in range(n-1):
	a = l[i]
	for j in range(i+2,n):
		b = l[j]
		c = bisect.bisect_left(l,b-a+1)
		if j - c > 0:
			if i >= c:
				ans += j-i-1
			else:
				ans += j-c
		#print(i,j,c,ans)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools

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

ans = 0

t = list(itertools.combinations(l,3))

for i in range(len(t)):
	if t[i][0] < t[i][1] + t[i][2] and t[i][1] < t[i][2] + t[i][0] and t[i][2] < t[i][0] + t[i][1]:
		ans += 1

print(ans)


Fixed submission:
import bisect

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

l.sort()
#print(l)
ans = 0
for i in range(n-1):
	a = l[i]
	for j in range(i+2,n):
		b = l[j]
		c = bisect.bisect_left(l,b-a+1)
		if j - c > 0:
			if i >= c:
				ans += j-i-1
			else:
				ans += j-c
		#print(i,j,c,ans)

print(ans)