Buggy python submission (verdict: Time Limit Exceeded):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
import numpy as np

n = int(readline())
a = np.array(readline().split(), dtype=np.int64)
b = np.array(readline().split(), dtype=np.int64)
c = np.array(readline().split(), dtype=np.int64)

a.sort()
b.sort()
c.sort()

cnt=0
for i in range(n):
  B=b[i]
  AA=np.searchsorted(a, B-0.1, side='right')
  CC=n-np.searchsorted(c, B+0.1)
  cnt+=AA*CC
print(cnt)

Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#cnt=0
#for i in range(n):
 # B=b[i]
  #A=[a[i] for i in range(n) if a[i]<B]
  #C=[c[i] for i in range(n) if c[i]>B]
  #cnt+=len(A)*len(C)
#print(cnt)
cnt=0
#真ん中のパーツをまず考える
for i in range(n):
  B=b[i]
  if B<=a[0] or B>=c[-1]:
    continue
  #Bより小さいAの最大値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if a[(i_small+i_large)//2] <B:
      i_small=(i_small+i_large)//2
    else:
      i_large=(i_small+i_large)//2
 
  A=i_large
  if a[-1]<B:
    A+=1

  #Bより大きいCの最小値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if c[(i_small+i_large)//2] >B:
      i_large=(i_small+i_large)//2
    else:
      i_small=(i_small+i_large)//2
  C=n-i_large
  if c[0]>B:
    C+=1

  cnt+=A*C
if n>1:
  print(cnt)
else:
  if a[0]<b[0]<c[0]:
    print(1)
  else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=np.array(sorted(list(map(int,input().split()))))
b=sorted(list(map(int,input().split())))
c=np.array(sorted(list(map(int,input().split()))))
#cnt=0
#for i in range(n):
 # B=b[i]
  #A=[a[i] for i in range(n) if a[i]<B]
  #C=[c[i] for i in range(n) if c[i]>B]
  #cnt+=len(A)*len(C)
#print(cnt)

cnt=0
for i in range(n):
  B=b[i]
  AA=np.searchsorted(a, B-0.1, side='right')
  CC=n-np.searchsorted(c, B+0.1)
  cnt+=AA*CC
print(cnt)

Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#cnt=0
#for i in range(n):
 # B=b[i]
  #A=[a[i] for i in range(n) if a[i]<B]
  #C=[c[i] for i in range(n) if c[i]>B]
  #cnt+=len(A)*len(C)
#print(cnt)
cnt=0
#真ん中のパーツをまず考える
for i in range(n):
  B=b[i]
  if B<=a[0] or B>=c[-1]:
    continue
  #Bより小さいAの最大値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if a[(i_small+i_large)//2] <B:
      i_small=(i_small+i_large)//2
    else:
      i_large=(i_small+i_large)//2
 
  A=i_large
  if a[-1]<B:
    A+=1

  #Bより大きいCの最小値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if c[(i_small+i_large)//2] >B:
      i_large=(i_small+i_large)//2
    else:
      i_small=(i_small+i_large)//2
  C=n-i_large
  if c[0]>B:
    C+=1

  cnt+=A*C
if n>1:
  print(cnt)
else:
  if a[0]<b[0]<c[0]:
    print(1)
  else:
    print(0)

Buggy python submission (verdict: Time Limit Exceeded):
import numpy as np
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))

cnt=0
for i in range(n):
  B=b[i]
  AA=np.searchsorted(a, B-0.1, side='right')
  CC=n-np.searchsorted(c, B+0.1)
  cnt+=AA*CC
print(cnt)

Fixed submission:
n=int(input())
a=sorted(list(map(int,input().split())))
b=sorted(list(map(int,input().split())))
c=sorted(list(map(int,input().split())))
#cnt=0
#for i in range(n):
 # B=b[i]
  #A=[a[i] for i in range(n) if a[i]<B]
  #C=[c[i] for i in range(n) if c[i]>B]
  #cnt+=len(A)*len(C)
#print(cnt)
cnt=0
#真ん中のパーツをまず考える
for i in range(n):
  B=b[i]
  if B<=a[0] or B>=c[-1]:
    continue
  #Bより小さいAの最大値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if a[(i_small+i_large)//2] <B:
      i_small=(i_small+i_large)//2
    else:
      i_large=(i_small+i_large)//2
 
  A=i_large
  if a[-1]<B:
    A+=1

  #Bより大きいCの最小値のインデックスを探す
  i_small=0
  i_large=n-1
  while i_large-i_small>1:
    if c[(i_small+i_large)//2] >B:
      i_large=(i_small+i_large)//2
    else:
      i_small=(i_small+i_large)//2
  C=n-i_large
  if c[0]>B:
    C+=1

  cnt+=A*C
if n>1:
  print(cnt)
else:
  if a[0]<b[0]<c[0]:
    print(1)
  else:
    print(0)