Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    if i==-1:
        abl[j]=0
        continue
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    if k==n:
        bcl[j]=0
        continue
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
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()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[]
i=0
for j in range(n):
    i=n-1
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl.append(0)
    else:
        abl.append(i+1)
bcl=[]
j=0
for j in range(n):
    k=0
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl.append(0)
    else:
        bcl.append(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    if i==-1:
        abl[j]=0
        continue
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    if k==n:
        bcl[j]=0
        continue
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
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()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[]
i=0
for j in range(n):
    i=n-1
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl.append(0)
    else:
        abl.append(i+1)
bcl=[]
j=0
for j in range(n):
    k=0
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl.append(0)
    else:
        bcl.append(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    if i==-1:
        abl[j]=0
        continue
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    if k==n:
        bcl[j]=0
        continue
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)

Buggy python submission (verdict: Runtime Error):
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))

al=sorted(a)
bl=sorted(b)
cl=sorted(c)
print(al)
print(bl)
print(cl)
j=0
k=0
ans=0
saved_j=0
saved_k=0
for i in range(n):
    j=saved_j
    while al[i]>=bl[j]:
        j+=1
        saved_j=j
    #print("j",j)
    while j!=n:
        k=saved_k
        while bl[j]>=cl[k]:
            if k==n-1:
                break
            k+=1
        if j==saved_j:
            saved_k=k
        #print("k",k)
        ans+=n-k
        j+=1
        #print("暫定",ans)
print(ans)


Fixed submission:
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=list(map(int,input().split()))
al=sorted(a)
bl=sorted(b)
cl=sorted(c)
 
abl=[0]*n
bcl=[0]*n
i=n-1
for j in range(n-1,-1,-1):
    if i==-1:
        abl[j]=0
        continue
    while al[i]>=bl[j]:
        i-=1
        if i==-1:
            break
    if i==-1:
        abl[j]=0
    else:
        abl[j]=i+1
j=0
bcl=[0]*n
k=0
for j in range(n):
    if k==n:
        bcl[j]=0
        continue
    while cl[k]<=bl[j]:
        k+=1
        if k==n:
            break
    if k==n:
        bcl[j]=0
    else:
        bcl[j]=(n-k)
ans=0
for s in range(n):
    ans+=abl[s]*bcl[s]
print(ans)