Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right, bisect_left

n = int(input())

a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

i_list = []
j_list = []

for x in b:
  i = bisect_left(a, x)
  i_list.append(len(a[:i]))

for x in b:
  j = bisect_right(c, x)
  j_list.append(len(c[j:]))

ans = 0

for i, j in zip(i_list, j_list):
  ans += i*j

print(ans)

Fixed submission:
from bisect import bisect_right, bisect_left

n = int(input())

a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for x in b:
  ans += bisect_left(a, x) * (n - bisect_right(c, x))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right, bisect_left

n = int(input())

a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))


i_list = []
j_list = []

for x in b:
  i = bisect_left(a, x)
  i_list.append(len(a[:i]))

for x in b:
  j = bisect_right(c, x)
  j_list.append(len(c[j:]))

ans = 0

for i, j in zip(i_list, j_list):
  ans += i*j

print(ans)

Fixed submission:
from bisect import bisect_right, bisect_left

n = int(input())

a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for x in b:
  ans += bisect_left(a, x) * (n - bisect_right(c, x))

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
from bisect import bisect_right, bisect_left

n = int(input())

a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

ans = 0

for x in b:
  i = bisect_left(a, x)
  j = bisect_right(c, x)

  ans += len(a[:i]) * len(c[j:])

print(ans)

Fixed submission:
from bisect import bisect_right, bisect_left

n = int(input())

a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for x in b:
  ans += bisect_left(a, x) * (n - bisect_right(c, x))

print(ans)

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

n = int(input())

a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

ans = 0

for x in a:
  i = bisect_right(b, x)
  for y in b[i:]:
    j = bisect_right(c, y)
    for z in c[j:]:
      ans += 1

print(ans)


Fixed submission:
from bisect import bisect_right, bisect_left

n = int(input())

a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for x in b:
  ans += bisect_left(a, x) * (n - bisect_right(c, x))

print(ans)

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

n = int(input())

a = sorted(list(map(int, input().split())))
b = sorted(list(map(int, input().split())))
c = sorted(list(map(int, input().split())))

ans = 0

for x in a:
  i = bisect_right(b, x)
  for y in b[i:]:
    j = bisect_right(c, y)
    for z in c[j:]:
      ans += 1

print(ans)

Fixed submission:
from bisect import bisect_right, bisect_left

n = int(input())

a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for x in b:
  ans += bisect_left(a, x) * (n - bisect_right(c, x))

print(ans)