Buggy python submission (verdict: Runtime Error):
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1] + [0]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1]
    ans = 0
    for i in range(n):
        ans += acc[bisect(b, a[i])]
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1] + [0]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()

Buggy python submission (verdict: Runtime Error):
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1]
    ans = 0
    for i in range(n):
        ans += acc[bisect(b, a[i])]
    print(ans)


if __name__ == "__main__":
    main()


Fixed submission:
import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1] + [0]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()