Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]

ans = 0
AA = list(tuple(A))
CC = list(tuple(C))

for i in range(N):
  AA = list(tuple(A))
  CC = list(tuple(C))
  b = B[i]
  
  AA.append(b)
  AA.sort()
  idx_b_AA = AA.index(b)
  
  CC.append(b)
  CC.sort(reverse=True)
  idx_b_CC = CC.index(b)
  
  ans += idx_b_AA * idx_b_CC

print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = tuple(sorted([int(a) for a in input().split()], reverse=True))
B = tuple(sorted([int(b) for b in input().split()], reverse=True))
C = tuple(sorted([int(c) for c in input().split()], reverse=True))
ans = 0

for i in range(N):
  for j in range(N):
    if A[i] >= B[j]:
      break
    for k in range(N):
      if B[j] >= C[k]:
        break
      else:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted([int(a) for a in input().split()])
B = sorted([int(b) for b in input().split()])
C = sorted([int(c) for c in input().split()])
ans = 0

for i in range(N):
  for j in range(N):
    if C[i] <= B[j]:
      break
    for k in range(N):
      if B[j] <= A[k]:
        break
      else:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted([int(a) for a in input().split()], reverse=True)
B = sorted([int(b) for b in input().split()], reverse=True)
C = sorted([int(c) for c in input().split()], reverse=True)
ans = 0

for i in range(N):
  for j in range(N):
    if A[i] >= B[j]:
      break
    for k in range(N):
      if B[j] >= C[k]:
        break
      else:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted([int(a) for a in input().split()])
B = sorted([int(b) for b in input().split()])
C = sorted([int(c) for c in input().split()])
ans = 0

for i in range(N):
  for j in range(N):
    for k in range(N):
      if A[i] < B[j] < C[k]:
        ans += (N - k)
        break
print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted([int(a) for a in input().split()], reverse=True)
B = sorted([int(b) for b in input().split()], reverse=True)
C = sorted([int(c) for c in input().split()], reverse=True)
ans = 0

for i in range(N):
  for j in range(N):
    if A[i] >= B[j]:
      break
    for k in range(N):
      if B[j] >= C[k]:
        break
      else:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = sorted([int(a) for a in input().split()], reverse=True)
B = sorted([int(b) for b in input().split()], reverse=True)
C = sorted([int(c) for c in input().split()], reverse=True)
ans = 0

for i in range(N):
  for j in range(N):
    if A[i] >= B[j]:
      continue
    for k in range(N):
      if B[j] < C[k]:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
ans = 0

for i in range(N):
  for j in range(N):
    if A[i] >= B[j]:
      continue
    for k in range(N):
      if A[i] < B[j] < C[k]:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
ans = 0

for i in range(N):
  for j in range(N):
    for k in range(N):
      if A[i] < B[j] < C[k]:
        ans += 1

print(ans)

Fixed submission:
N = int(input())
A = sorted([int(a) for a in input().split()])
B = [int(b) for b in input().split()]
C = sorted([int(c) for c in input().split()])
ans = 0

import bisect
for i in range(N):
  b = B[i]
  end_A = bisect.bisect_left(A, b)
  start_C = bisect.bisect_right(C, b)
  ans += end_A * (N - start_C)

print(ans)