Buggy python submission (verdict: Time Limit Exceeded):
import copy
n =int(input())
a=[]
b=[]
c=[]
a =list(map(int,input().split()))
a.sort()
b =list(map(int,input().split()))
b.sort()
c =list(map(int,input().split()))

c.sort()
c2 = copy.copy(c)
b_limit = 0
c_limit =0
count =0
c_count =0
b_score =[0]*n
for i in a:
    c_count =0
    c = copy.copy(c2)
    if b_limit == 1:
        break
    for j in  reversed(range(len(b))):
        if b[j] <= i:
            if b[j] == max(b):
                b_limit +=1
            break
        else:
            if not b_score[j] == 0:
                count += b_score[j]
                continue
            if len(c) ==0:
                count +=c_count
                if b_score[j] ==0:
                    b_score[j] = c_count
                continue
        for k in reversed(range(len(c))):
            if c[k] <= b[j]:
                count += c_count
                if b_score[j] ==0:
                    b_score[j] = c_count
                break
            c.pop(k)
            c_count +=1
            if k == 0:
                count +=c_count
                if b_score[j] ==0:
                    b_score[j] = c_count
print(count)



Fixed submission:
import bisect

ans =0

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

for i in b:
    s = bisect.bisect_right(c,i)
    s_num = n-s

    t = bisect.bisect_left(a,i)
    t_num = t

    ans += s_num * t_num

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n =int(input())
a=[]
b=[]
c=[]
a =list(map(int,input().split()))
a.sort()
b =list(map(int,input().split()))
b.sort()
c =list(map(int,input().split()))

c.sort()
c2 = copy.copy(c)
b_limit = 0
c_limit =0
count =0
c_count =0
b_score =[0]*n
for i in a:
    c_count =0
    c = copy.copy(c2)
    if b_limit == 1:
        break
    for j in  reversed(range(len(b))):
        if b[j] <= i:
            if b[j] == max(b):
                b_limit +=1
            break
        else:
            if not b_score[j] == 0:
                count += b_score
                continue
            if len(c) ==0:
                count +=c_count
                if b_score[j] ==0:
                    b_score[j] == c_count
                continue
        for k in reversed(range(len(c))):
            if c[k] <= b[j]:
                count += c_count
                if b_score[j] ==0:
                    b_score[j] == c_count
                break
            c.pop(k)
            c_count +=1
            if k == 0:
                count +=c_count
                if b_score[j] ==0:
                    b_score[j] == c_count


print(count)



Fixed submission:
import bisect

ans =0

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

for i in b:
    s = bisect.bisect_right(c,i)
    s_num = n-s

    t = bisect.bisect_left(a,i)
    t_num = t

    ans += s_num * t_num

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import copy
n =int(input())
a=[]
b=[]
c=[]
a =list(map(int,input().split()))
a.sort()
b =list(map(int,input().split()))
b.sort()
c =list(map(int,input().split()))

c.sort()
c2 = copy.copy(c)
b_limit = 0
c_limit =0
count =0
c_count =0

for i in a:
    c_count =0
    c = copy.copy(c2)
    if b_limit == 1:
        break
    for j in  reversed(range(len(b))):
        if b[j] <= i:
            if b[j] == max(b):
                b_limit +=1
            break
        else:
            if len(c) ==0:
                count +=c_count
                continue
        for k in reversed(range(len(c))):
            if c[k] <= b[j]:
                count += c_count
                break
            c.pop(k)
            c_count +=1
            if k == 0:
                count +=c_count


print(count)



Fixed submission:
import bisect

ans =0

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

for i in b:
    s = bisect.bisect_right(c,i)
    s_num = n-s

    t = bisect.bisect_left(a,i)
    t_num = t

    ans += s_num * t_num

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
n =int(input())
a=[]
b=[]
c=[]
a =list(map(int,input().split()))
a.sort()
b =list(map(int,input().split()))
b.sort()
c =list(map(int,input().split()))
c.sort()
b_limit = 0
c_limit =0
count =0

for i in a:
    if b_limit == 1:
        break
    for j in  reversed(b):
        if j <= i:
            if j == max(b):
                b_limit +=1
            break
        for k in reversed(c):
            if k <= j:
                break
            count +=1

print(count)



Fixed submission:
import bisect

ans =0

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

for i in b:
    s = bisect.bisect_right(c,i)
    s_num = n-s

    t = bisect.bisect_left(a,i)
    t_num = t

    ans += s_num * t_num

print(ans)