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


def main():
    input = sys.stdin.readline
    n = int(input())
    L = map(int, input().split())
    cnt = 0

    ls = itertools.combinations(L, 3)

    for l in ls:
        if sum(l) > max(l)*2:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect
import sys

input = sys.stdin.readline

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

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)

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


def main():
    readline = sys.stdin.readline
    readlines = sys.stdin.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(input())
    L = tuple(map(int, readline().split()))
    cnt = 0

    ls = tuple(itertools.combinations(L, 3))

    for l in ls:
        if sum(l) > max(l)*2:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect
import sys

input = sys.stdin.readline

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

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)

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


def main():
    readline = sys.stdin.readline
    readlines = sys.stdin.readlines
    sys.setrecursionlimit(10 ** 7)

    n = int(input())
    L = tuple(map(int, readline().split()))
    cnt = 0

    ls = tuple(itertools.combinations(L, 3))

    for l in ls:
        if sum(l) > max(l)*2:
            cnt += 1

    print(cnt)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect
import sys

input = sys.stdin.readline

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

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

n = int(input())
L = list(map(int, readline().split()))
cnt = 0

ls = list(itertools.combinations(L, 3))

for l in ls:
    if sum(l) > max(l)*2:
        cnt += 1

print(cnt)


Fixed submission:
import bisect
import sys

input = sys.stdin.readline

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

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

n = int(input())
L = list(map(int, readline().split()))
cnt = 0

ls = list(itertools.combinations(L, 3))

for l in ls:
    if sum(l) > max(l)*2:
        cnt += 1

print(cnt)


Fixed submission:
import bisect
import sys

input = sys.stdin.readline

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

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
import itertools
import sys
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

n = int(input())
L = list(map(int, readline().split()))
cnt = 0

ls = list(itertools.combinations(L, 3))

for l in ls:
    if l[0] < l[1]+l[2] and l[1] < l[2]+l[0] and l[2] < l[0]+l[1]:
        cnt += 1

print(cnt)


Fixed submission:
import bisect
import sys

input = sys.stdin.readline

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

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)

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

n = int(input())
L = list(map(int, input().split()))
cnt = 0

ls = list(itertools.combinations(L, 3))

for l in ls:
    if l[0] < l[1]+l[2] and l[1] < l[2] + l[0] and l[2] < l[0] + l[1]:
        cnt += 1

print(cnt)


Fixed submission:
import bisect
import sys

input = sys.stdin.readline

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

for i in range(0, n-2):
    for j in range(i+1, n-1):
        cnt += bisect.bisect_left(l, l[i] + l[j]) - j-1

print(cnt)