Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import math
 
N=int(input())
b1=0

ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B)
C=list(map(int, input().split()))
C=sorted(C)
D=[]

for b in B:
  D.append(len(C)-bisect.bisect_right(C,b))

B.append(math.inf)

for i in range(len(A)):
  b1=bisect.bisect_right(B,A[i])
  for j in range(b1,len(B)-1):
    ans += D[j]

print(ans)

Fixed submission:
import bisect
 
N=int(input())
b1=0
d=0

ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B, reverse=True)
C=list(map(int, input().split()))
C=sorted(C)
D=[]
E=[]

for b in B:
  d=d+len(C)-bisect.bisect_right(C,b)
  D.append(d)

D=sorted(D, reverse= True)  
B=sorted(B)

for a in A:
  if 0 <= bisect.bisect_right(B,a) <= len(D)-1:
    ans += D[bisect.bisect_right(B,a)]
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
import bisect
import math
 
N=int(input())
a1=0
a2=0
b1=0
b2=0
c1=0
c2=0
c3=0
 
ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B)
B.append(math.inf)
C=list(map(int, input().split()))
C=sorted(C)
C.append(math.inf)
for i in range(len(A)):
  a1=A[i]
  b2=bisect.bisect_right(B,a1)
  for j in range(b2,len(B)-1):
    b1=B[j]
    c2=bisect.bisect_right(C,b1)
    c3=len(C)-c2-1
    ans += c3

print(ans)

Fixed submission:
import bisect
 
N=int(input())
b1=0
d=0

ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B, reverse=True)
C=list(map(int, input().split()))
C=sorted(C)
D=[]
E=[]

for b in B:
  d=d+len(C)-bisect.bisect_right(C,b)
  D.append(d)

D=sorted(D, reverse= True)  
B=sorted(B)

for a in A:
  if 0 <= bisect.bisect_right(B,a) <= len(D)-1:
    ans += D[bisect.bisect_right(B,a)]
print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect

N=int(input())
a1=0
a2=0
b1=0
b2=0
c1=0
c2=0
c3=0

ans=0

A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B)
C=list(map(int, input().split()))
C=sorted(C)

for i in range(len(A)):
  a1=A[i]
  b2=bisect.bisect_left(B,a1)

  if a1==B[b2]:
      for j in range(b2+1,len(B)):
        b1=B[j]
        c2=bisect.bisect_left(C,b1)
        c3=len(C)-c2
        if b1==C[c2]:
          c3 -=1
          ans += c3
        else:
          ans += c3

  else:
    for j in range(b2,len(B)):
      b1=B[j]
      c2=bisect.bisect_left(C,b1)
      c3=len(C)-c2
      if b1==C[c2]:
        c3 -=1
        ans += c3
      else:
        ans += c3

print(ans)

Fixed submission:
import bisect
 
N=int(input())
b1=0
d=0

ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B, reverse=True)
C=list(map(int, input().split()))
C=sorted(C)
D=[]
E=[]

for b in B:
  d=d+len(C)-bisect.bisect_right(C,b)
  D.append(d)

D=sorted(D, reverse= True)  
B=sorted(B)

for a in A:
  if 0 <= bisect.bisect_right(B,a) <= len(D)-1:
    ans += D[bisect.bisect_right(B,a)]
print(ans)

Buggy python submission (verdict: Runtime Error):
import bisect

N=int(input())
a1=0
a2=0
b1=0
b2=0
c1=0
c2=0
c3=0

ans=0

A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B)
C=list(map(int, input().split()))
C=sorted(C)

for i in range(len(A)):
  a1=A[i]
  b2=bisect.bisect_left(B,a1)

  if a1==B[b2]:
      for j in range(b2+1,len(B)):
        b1=B[j]
        c2=bisect.bisect_left(C,b1)
        c3=len(C)-c2
        if b1==C[c2]:
          c3 -=1
          ans += c3
        else:
          ans += c3

  else:
    for j in range(b2,len(B)):
      b1=B[j]
      c2=bisect.bisect_left(C,b1)
      c3=len(C)-c2
      if b1==C[c2]:
        c3 -=1
        ans += c3
      else:
        ans += c3

print(ans)

Fixed submission:
import bisect
 
N=int(input())
b1=0
d=0

ans=0
 
A=list(map(int, input().split()))
A=sorted(A)
B=list(map(int, input().split()))
B=sorted(B, reverse=True)
C=list(map(int, input().split()))
C=sorted(C)
D=[]
E=[]

for b in B:
  d=d+len(C)-bisect.bisect_right(C,b)
  D.append(d)

D=sorted(D, reverse= True)  
B=sorted(B)

for a in A:
  if 0 <= bisect.bisect_right(B,a) <= len(D)-1:
    ans += D[bisect.bisect_right(B,a)]
print(ans)