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(" ")))
m = 0

A.sort()
B.sort()
C.sort(reverse=True)

for j in B:
    for i in range(N):
        if A[i] >= j:
            break
        if A[N-1] < j:
            i = N
    for k in range(N):
        if j >= C[k]:
            break
        if j < C[N-1]:
            k = N
    m =  m + i * k

print(m)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A.sort()
B.sort()
C.sort()
C.reverse()
 
ans = 0
ai = 0
ci = N-1
for b in B:
    while ai < N and A[ai] < b:
        ai += 1
    while ci >= 0 and C[ci] <= b:
        ci -= 1
    ans += ai * (ci+1)
 
print(ans)

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(" ")))
m = 0

A.sort()
B.sort()
C.sort(reverse=True)

for j in range(N):
    for i in range(N):
        if A[i] >= B[j]:
            break
        if A[N-1] < B[j]:
            i = N
    for k in range(N):
        if B[j] >= C[k]:
            break
        if B[j] < C[N-1]:
            k = N
    m =  m + i * k

print(m)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A.sort()
B.sort()
C.sort()
C.reverse()
 
ans = 0
ai = 0
ci = N-1
for b in B:
    while ai < N and A[ai] < b:
        ai += 1
    while ci >= 0 and C[ci] <= b:
        ci -= 1
    ans += ai * (ci+1)
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
m = 0

for n in range(N):
    A[n] = int(A[n])
    B[n] = int(B[n])
    C[n] = int(C[n])

A.sort()
B.sort()
C.sort(reverse=True)

for j in range(N):
    for i in range(N):
        if A[i] >= B[j]:
            break
        if A[N-1] < B[j]:
            i = N
    for k in range(N):
        if B[j] >= C[k]:
            break
        if B[j] < C[N-1]:
            k = N
    m =  m + i * k

print(m)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A.sort()
B.sort()
C.sort()
C.reverse()
 
ans = 0
ai = 0
ci = N-1
for b in B:
    while ai < N and A[ai] < b:
        ai += 1
    while ci >= 0 and C[ci] <= b:
        ci -= 1
    ans += ai * (ci+1)
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
m = 0

for n in range(N):
    A[n] = int(A[n])
    B[n] = int(B[n])
    C[n] = int(C[n])

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]:
                m =  m + 1

print(m)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A.sort()
B.sort()
C.sort()
C.reverse()
 
ans = 0
ai = 0
ci = N-1
for b in B:
    while ai < N and A[ai] < b:
        ai += 1
    while ci >= 0 and C[ci] <= b:
        ci -= 1
    ans += ai * (ci+1)
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
m = 0

for n in range(N):
    A[n] = int(A[n])
    B[n] = int(B[n])
    C[n] = int(C[n])

A.sort()
B.sort()
C.sort()

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]:
                m =  m + N - k
                break

print(m)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A.sort()
B.sort()
C.sort()
C.reverse()
 
ans = 0
ai = 0
ci = N-1
for b in B:
    while ai < N and A[ai] < b:
        ai += 1
    while ci >= 0 and C[ci] <= b:
        ci -= 1
    ans += ai * (ci+1)
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
m = 0

for n in range(N):
    A[n] = int(A[n])
    B[n] = int(B[n])
    C[n] = int(C[n])

A.sort()
B.sort()
C.sort()

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

print(m)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A.sort()
B.sort()
C.sort()
C.reverse()
 
ans = 0
ai = 0
ci = N-1
for b in B:
    while ai < N and A[ai] < b:
        ai += 1
    while ci >= 0 and C[ci] <= b:
        ci -= 1
    ans += ai * (ci+1)
 
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
N = int(input())
A = input().split(" ")
B = input().split(" ")
C = input().split(" ")
m = 0

for n in range(N):
    A[n] = int(A[n])
    B[n] = int(B[n])
    C[n] = int(C[n])

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

print(m)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))
 
A.sort()
B.sort()
C.sort()
C.reverse()
 
ans = 0
ai = 0
ci = N-1
for b in B:
    while ai < N and A[ai] < b:
        ai += 1
    while ci >= 0 and C[ci] <= b:
        ci -= 1
    ans += ai * (ci+1)
 
print(ans)