Buggy python submission (verdict: Runtime Error):
def binary(list_a,item):
  low=0
  high=len(list_a)-1
  while (high-low)>1:
    mid=int((low+high)/2)
    tmp=list_a[mid]
    if tmp>item:
      high=mid
    elif tmp<item:
      low=mid
    elif tmp==item:
      eq=[i for i, x in enumerate(list_a) if x == tmp]
      high=eq[-1]
      low=eq[0]
      return low-1,high+1
  return low,high

def main():
  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 b in B:
    a_low,a_high=binary(A,b)
    c_low,c_high=binary(C,b)
    
    if b>A[a_high]:
      a_low=N-1
    elif b<A[a_low]:
      a_low=0
      
    if b<C[c_low]:
      c_high=0
    elif b>C[c_high]:
      c_high=N
    
    ans+=(a_low+1)*(N-c_high)
  print(ans)
  
if __name__=="__main__":
  main()

Fixed submission:
import bisect

def main():
  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 b in B:
    a=bisect.bisect_left(A,b)
    c=N-bisect.bisect_right(C,b)
    ans+=a*c
  print(ans)
  
if __name__=="__main__":
  main()

Buggy python submission (verdict: Runtime Error):
def binary(list_a,item):
  low=0
  high=len(list_a)-1
  while (high-low)>1:
    mid=int((low+high)/2)
    tmp=list_a[mid]
    if tmp>item:
      high=mid
    elif tmp<item:
      low=mid
    elif tmp==item:
      eq=[i for i, x in enumerate(list_a) if x == tmp]
      high=eq[-1]
      low=eq[0]
      return low-1,high+1
  return low,high


def main():
  N=int(input())
  A=sorted(list(map(int,input().split())))
  B=sorted(list(map(int,input().split())))
  C=sorted(list(map(int,input().split())))
  print(A)
  print(B)
  print(C)
  ans=0
  for b in B:
    a_low,a_high=binary(A,b)
    c_low,c_high=binary(C,b)
    
    if b>A[a_high]:
      a_low=N-1
    elif b<A[a_low]:
      a_low=0
      
    if b<C[c_low]:
      c_high=0
    elif b>C[c_high]:
      c_high=N
    
    print(a_low+1,N-c_high)
    ans+=(a_low+1)*(N-c_high)
  print(ans)
  
if __name__=="__main__":
  main()

Fixed submission:
import bisect

def main():
  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 b in B:
    a=bisect.bisect_left(A,b)
    c=N-bisect.bisect_right(C,b)
    ans+=a*c
  print(ans)
  
if __name__=="__main__":
  main()

Buggy python submission (verdict: Runtime Error):
def binary_search(list_a,item):
  low=0
  high=len(list_a)-1
  while low<=high:
    mid=int((low+high)/2)
    guss=list_a[mid]
    if guss>item:
      high=mid-1
    elif guss<item:
      low=mid+1
    elif guss==item:
      return mid
  return mid

def main():
  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 b in B:
    p=binary_search(A,b)
    if A[p]>b:
      tmp_p=p
    elif A[p]<b:
      tmp_p=p+1
    elif A[p]==b:
      while A[p]==A[p-1]:
        p-=1
      tmp_p=p
    q=binary_search(C,b)
    if C[q]>b:
      tmp_q=N-q
    elif C[q]<b:
      tmp_q=N-q-1
    elif C[q]==b:
      while C[q]==C[q+1]:
        q+=1
      tmp_q=N-q-1
    ans+=tmp_p*tmp_q
  print(ans)
  
if __name__=="__main__":
  main()

Fixed submission:
import bisect

def main():
  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 b in B:
    a=bisect.bisect_left(A,b)
    c=N-bisect.bisect_right(C,b)
    ans+=a*c
  print(ans)
  
if __name__=="__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

def binary_search(list_a,item):
  low=0
  high=len(list_a)-1
  flag=True
  while low<=high:
    mid=int((low+high)/2)
    guss=list_a[mid]
    if guss>item:
      high=mid-1
    elif guss<item:
      low=mid+1
    elif guss==item:
      return mid
  return mid

count=0
for a in A:
  p=binary_search(B,a)
  if B[p]>a:
    temp_p=p
  elif B[p]<=a:
    temp_p=p+1
  for b in B[temp_p:]:
    q=binary_search(C,b)
    if C[q]>b:
      temp_q=q
    elif C[q]<=b:
      temp_q=q+1
    count+=(N-temp_q)


print(count)

Fixed submission:
import bisect

def main():
  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 b in B:
    a=bisect.bisect_left(A,b)
    c=N-bisect.bisect_right(C,b)
    ans+=a*c
  print(ans)
  
if __name__=="__main__":
  main()

Buggy python submission (verdict: Time Limit Exceeded):
N=int(input())
A=sorted(list(map(int,input().split())))
B=sorted(list(map(int,input().split())))
C=sorted(list(map(int,input().split())))

count=0
for a in A:
  for b in B:
    if a>=b:
      continue
    num=0
    for c in C:
      if b<c:
        count+=(N-num)
        break
      num+=1


print(count)

Fixed submission:
import bisect

def main():
  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 b in B:
    a=bisect.bisect_left(A,b)
    c=N-bisect.bisect_right(C,b)
    ans+=a*c
  print(ans)
  
if __name__=="__main__":
  main()