Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
import bisect
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


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

    result = 0
    # print(l)
    for i in range(n-2):
        for j in range(i + 1, n - 1):
            target = l[j + 1:]
            count = sum(1 for x in target if x < (l[i] + l[j]))
            # count = np.count_nonzero(target < (l[i] + l[j]))
            # print(l[i], l[j], target, count)
            result += count

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
input = sys.stdin.readline


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

    result = 0
    # print(l)
    for i in range(n-2):
        for j in range(i + 1, n - 1):
            target = l[j + 1:]
            count = sum(1 for x in target if x < (l[i] + l[j]))
            # count = np.count_nonzero(target < (l[i] + l[j]))
            # print(l[i], l[j], target, count)
            result += count

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
import numpy as np
input = sys.stdin.readline


def main():
    n = int(input())
    l = np.array(list(map(int, input().split())))
    l = np.sort(l)

    result = 0
    # print(l)
    for i in range(n-2):
        for j in range(i + 1, n - 1):
            target = l[j + 1:]
            count = sum(1 for x in target if x < (l[i] + l[j]))
            # count = np.count_nonzero(target < (l[i] + l[j]))
            # print(l[i], l[j], target, count)
            result += count

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
import numpy as np
input = sys.stdin.readline


def main():
    n = int(input())
    l = np.array(list(map(int, input().split())))
    l = np.sort(l)

    result = 0
    # print(l)
    for i in range(n-2):
        for j in range(i + 1, n - 1):
            target = l[j + 1:]
            count = np.count_nonzero(target < (l[i] + l[j]))
            # print(l[i], l[j], target, count)
            result += count

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
import numpy as np
input = sys.stdin.readline


def main():
    n = int(input())
    l = list(map(int, input().split()))
    index = np.argsort(l)

    result = 0
    for i in range(n-2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                a = l[index[i]]
                b = l[index[j]]
                c = l[index[k]]
                if c < a + b:
                    result += 1
                else:
                    break

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
import numpy as np
input = sys.stdin.readline


def main():
    n = int(input())
    l = list(map(int, input().split()))
    index = np.argsort(l)

    result = 0
    for i in range(n-2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                a = l[index[i]]
                b = l[index[j]]
                c = l[index[k]]
                if b < a + c and c < a + b:
                    result += 1

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import sys
import numpy as np
input = sys.stdin.readline


def main():
    n = int(input())
    l = list(map(int, input().split()))
    index = np.argsort(l)

    result = 0
    for i in range(n-2):
        for j in range(i + 1, n):
            for k in range(j + 1, n):
                a = l[index[i]]
                b = l[index[j]]
                c = l[index[k]]
                if b < a + c and c < a + b:
                    result += 1

    print(result)


if __name__ == '__main__':
    main()


Fixed submission:
# -*- coding: utf-8 -*-
import bisect
import sys
input = sys.stdin.readline


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

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

    print(result)


if __name__ == '__main__':
    main()