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

N = int(input()) # それぞれのパーツの数
A = list(map(int, input().split())) # 小さい
B = list(map(int, input().split())) # 中くらい
C = list(map(int, input().split())) # 大きい

# Cは並び替え不要
A.sort()
B.sort()

total = 0
for c in C:
    b_count = bisect.bisect_left(B, c) # bの数量
    for b in B[:b_count]:
        a_count = bisect.bisect_left(A, b) # aの数量
        total += a_count

print(total)


Fixed submission:
import bisect
import itertools

N = int(input()) # それぞれのパーツの数
A = list(map(int, input().split())) # 小さい
B = list(map(int, input().split())) # 中くらい
C = list(map(int, input().split())) # 大きい

# Cは並び替え不要
A.sort()
B.sort()

# Bの各要素でAを二分探索して返ってきたindexを先に保有しておく
b_counts = [0] * N
for i in range(N):
    b_count = bisect.bisect_left(A, B[i])
    b_counts[i] = b_count

cumsum_b_counts = list(itertools.accumulate(b_counts))
cumsum_b_counts = [0] + cumsum_b_counts

# Cの各要素でBを二分探索。上記で保有しておいたb_countsを活用する
total = 0
for c in C:
    count = bisect.bisect_left(B, c)
    total += cumsum_b_counts[count]

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) # 各リストの数
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=False)
A.append(float('inf'))
B.sort(reverse=False)

# A > B > Cである組み合わせの数を求める
count = 0
for ic in range(N):
    bottom_a = 0
    for ib in range(N):
        if B[ib] >= C[ic]:
            break
        
        top_a = N
        count_a = 0
        while top_a >= bottom_a:
            middle_a = (top_a + bottom_a) // 2

            if A[middle_a] == B[ib]:
                count_a = middle_a - 1
                break
            if A[middle_a] < B[ib] and B[ib] < A[middle_a + 1]:
                count_a = middle_a
                break
            if A[middle_a] > B[ib]:
                top_a = middle_a
            if A[middle_a] < B[ib]:
                bottom_a = middle_a + 1

        count += count_a + 1
        bottom_a = count_a

print(count)




Fixed submission:
import bisect
import itertools

N = int(input()) # それぞれのパーツの数
A = list(map(int, input().split())) # 小さい
B = list(map(int, input().split())) # 中くらい
C = list(map(int, input().split())) # 大きい

# Cは並び替え不要
A.sort()
B.sort()

# Bの各要素でAを二分探索して返ってきたindexを先に保有しておく
b_counts = [0] * N
for i in range(N):
    b_count = bisect.bisect_left(A, B[i])
    b_counts[i] = b_count

cumsum_b_counts = list(itertools.accumulate(b_counts))
cumsum_b_counts = [0] + cumsum_b_counts

# Cの各要素でBを二分探索。上記で保有しておいたb_countsを活用する
total = 0
for c in C:
    count = bisect.bisect_left(B, c)
    total += cumsum_b_counts[count]

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) # 各リストの数
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A.sort(reverse=False)
A.insert(0, 0)
A.append(float('inf'))
B.sort(reverse=False)

# A > B > Cである組み合わせの数を求める
count = 0
for ic in range(N):
    bottom_a = 0
    for ib in range(N):
        if B[ib] >= C[ic]:
            break
        
        top_a = N
        count_a = 0
        while top_a >= bottom_a:
            middle_a = (top_a + bottom_a) // 2

            if A[middle_a] == B[ib]:
                count_a = middle_a - 1
                break
            if A[middle_a] < B[ib] and B[ib] < A[middle_a + 1]:
                count_a = middle_a
                break
            if A[middle_a] > B[ib]:
                top_a = middle_a
            if A[middle_a] < B[ib]:
                bottom_a = middle_a + 1

        count += count_a
        bottom_a = count_a

print(count)




Fixed submission:
import bisect
import itertools

N = int(input()) # それぞれのパーツの数
A = list(map(int, input().split())) # 小さい
B = list(map(int, input().split())) # 中くらい
C = list(map(int, input().split())) # 大きい

# Cは並び替え不要
A.sort()
B.sort()

# Bの各要素でAを二分探索して返ってきたindexを先に保有しておく
b_counts = [0] * N
for i in range(N):
    b_count = bisect.bisect_left(A, B[i])
    b_counts[i] = b_count

cumsum_b_counts = list(itertools.accumulate(b_counts))
cumsum_b_counts = [0] + cumsum_b_counts

# Cの各要素でBを二分探索。上記で保有しておいたb_countsを活用する
total = 0
for c in C:
    count = bisect.bisect_left(B, c)
    total += cumsum_b_counts[count]

print(total)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input()) # 各リストの数
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A, reverse=False)
A.insert(0, 0)
A.append(float('inf'))
B = sorted(B, reverse=False)
# A > B > Cである組み合わせの数を求める

count = 0
for ic in range(N):
    bottom_a = 0
    for ib in range(N):
        if B[ib] >= C[ic]:
            break
        
        top_a = N
        count_a = 0
        while top_a >= bottom_a:
            middle_a = (top_a + bottom_a) // 2

            if A[middle_a] == B[ib]:
                count_a = middle_a - 1
                break
            if A[middle_a] < B[ib] and B[ib] < A[middle_a + 1]:
                count_a = middle_a
                break
            if A[middle_a] > B[ib]:
                top_a = middle_a
            if A[middle_a] < B[ib]:
                bottom_a = middle_a + 1

        count += count_a
        bottom_a = count_a

print(count)


Fixed submission:
import bisect
import itertools

N = int(input()) # それぞれのパーツの数
A = list(map(int, input().split())) # 小さい
B = list(map(int, input().split())) # 中くらい
C = list(map(int, input().split())) # 大きい

# Cは並び替え不要
A.sort()
B.sort()

# Bの各要素でAを二分探索して返ってきたindexを先に保有しておく
b_counts = [0] * N
for i in range(N):
    b_count = bisect.bisect_left(A, B[i])
    b_counts[i] = b_count

cumsum_b_counts = list(itertools.accumulate(b_counts))
cumsum_b_counts = [0] + cumsum_b_counts

# Cの各要素でBを二分探索。上記で保有しておいたb_countsを活用する
total = 0
for c in C:
    count = bisect.bisect_left(B, c)
    total += cumsum_b_counts[count]

print(total)