Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()
    max_l = max(l_list)

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            if b - a > max_l:
                break
            for k, c in enumerate(l_list[i+1+j+1:]):
                # if is_ok(a, b, c):
                if c < a + b:
                    ans += 1
                else:
                    break
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect


def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            x = a + b
            temp = bisect.bisect_left(l_list, x)
            ans += temp - (i + 1 + j + 1)
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()
    max_l = max(l_list)

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            if b - a > max_l:
                break
            for k, c in enumerate(l_list[i+1+j+1:]):
                # if is_ok(a, b, c):
                if c < a + b:
                    ans += 1
                else:
                    break
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect


def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            x = a + b
            temp = bisect.bisect_left(l_list, x)
            ans += temp - (i + 1 + j + 1)
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def is_ok(a, b, c):
    # if a < b + c:
    #     if b < c + a:
    if c < a + b:
        return True
    return False


def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            for k, c in enumerate(l_list[i+1+j+1:]):
                if is_ok(a, b, c):
                    ans += 1
                else:
                    break
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect


def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            x = a + b
            temp = bisect.bisect_left(l_list, x)
            ans += temp - (i + 1 + j + 1)
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def is_ok(a, b, c):
    if a < b + c:
        if b < c + a:
            if c < a + b:
                return True
    return False


def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            for k, c in enumerate(l_list[i+1+j+1:]):
                # if i == j or j == k or k == i:
                #     continue
                if is_ok(a, b, c):
                    ans += 1
                else:
                    break
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect


def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            x = a + b
            temp = bisect.bisect_left(l_list, x)
            ans += temp - (i + 1 + j + 1)
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def is_ok(a, b, c):
    if a < b + c:
        if b < c + a:
            if c < a + b:
                return True
    return False


def main():
    n = int(input())
    l_list = list(map(int, input().split()))

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            for k, c in enumerate(l_list[i+1+j+1:]):
                # if i == j or j == k or k == i:
                #     continue
                if is_ok(a, b, c):
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect


def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            x = a + b
            temp = bisect.bisect_left(l_list, x)
            ans += temp - (i + 1 + j + 1)
    print(ans)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
def is_ok(a, b, c):
    if a < b + c:
        if b < c + a:
            if c < a + b:
                return True
    return False


def main():
    n = int(input())
    l_list = list(map(int, input().split()))

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            for k, c in enumerate(l_list[i+1+j+1:]):
                # if i == j or j == k or k == i:
                #     continue
                if is_ok(a, b, c):
                    ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Fixed submission:
import bisect


def main():
    n = int(input())
    l_list = list(map(int, input().split()))
    l_list.sort()

    ans = 0
    for i, a in enumerate(l_list):
        for j, b in enumerate(l_list[i+1:]):
            x = a + b
            temp = bisect.bisect_left(l_list, x)
            ans += temp - (i + 1 + j + 1)
    print(ans)


if __name__ == '__main__':
    main()