Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-
import bisect

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
#-----

A_list.sort()
B_list.sort()
C_list.sort()

cnt=0
for i in A_list:
    ind_B = bisect.bisect_right(B_list, i) 
    for j in B_list[ind_B:]:
        ind_C = bisect.bisect_right(C_list, j)
        cnt += (N - ind_C)

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
import bisect

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
#-----

A_list.sort()
B_list.sort()
C_list.sort()

cnt=0
for i in B_list:
    ind_A = bisect.bisect_left(A_list, i)
    ind_C = bisect.bisect_right(C_list, i)
    cnt +=  ind_A * (N - ind_C)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
#-----

A_list.sort()
B_list.sort()
C_list.sort()


AB_dic={}
for i in A_list:
    AB_dic[i]=[]
    for j in B_list:
        if j > i:
            AB_dic[i].append(j)

BC_dic={}
for i in B_list:
    BC_dic[i]=[]
    for j in C_list:
        if j > i:
            BC_dic[i].append(j)


cnt=0
for v_A in A_list:
    for v_B in AB_dic[v_A]:
        for v_C in BC_dic[v_B]:
            cnt += 1

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
import bisect

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
#-----

A_list.sort()
B_list.sort()
C_list.sort()

cnt=0
for i in B_list:
    ind_A = bisect.bisect_left(A_list, i)
    ind_C = bisect.bisect_right(C_list, i)
    cnt +=  ind_A * (N - ind_C)

print(cnt)

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
#-----

A_list.sort()
B_list.sort()
C_list.sort()

A_idx=0
B_idx=0
C_idx=0
cnt=0
for i_A in range(A_idx,len(A_list)):

    for i_B in range(B_idx,len(B_list)):
        if B_list[i_B] <= A_list[i_A]:
            B_idx = i_B
        else:
            for i_C in range(C_idx,len(C_list)):
                
                if C_list[i_C] <= A_list[i_A]:
                    C_idx = i_C
                elif C_list[i_C] > B_list[i_B] > A_list[i_A]:
                    cnt += 1

print(cnt)


Fixed submission:
# -*- coding: utf-8 -*-
import bisect

N = int(input().strip())
A_list = list(map(int, input().rstrip().split()))
B_list = list(map(int, input().rstrip().split()))
C_list = list(map(int, input().rstrip().split()))
#-----

A_list.sort()
B_list.sort()
C_list.sort()

cnt=0
for i in B_list:
    ind_A = bisect.bisect_left(A_list, i)
    ind_C = bisect.bisect_right(C_list, i)
    cnt +=  ind_A * (N - ind_C)

print(cnt)