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()))
a.sort()
b.sort()
c.sort()
c.reverse()
#print(a)
#print(b)
#print(c)
pat=0
ikeep=-1
for i in range(n):
  x=b[i]
  if(x!=ikeep):
    ikeep=x
  else:
    pat+=paty*patz
    continue
  for j in range(n):
    y=a[j]
    paty=n
    if(x<=y):
      paty=j
      break
  for j in range(n):
    z=c[j]
    patz=n
    if(z<=x):
      patz=j
      break
  #print(paty,patz)
  pat+=paty*patz
print(pat)


Fixed submission:
import bisect
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()
#print(a)
#print(b)
#print(c)
pat=0
ikeep=-1
for i in range(n):
  x=b[i]
  if(x!=ikeep):
    ikeep=x
  else:
    pat+=paty*patz
    continue
  paty=bisect.bisect_left(a,x)
  patz=n-bisect.bisect_right(c,x)
  #print(paty,patz)
  pat+=paty*patz
print(pat)

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()))
a.sort()
b.sort()
c.sort()
c.reverse()
#print(a)
#print(b)
#print(c)
pat=0
ikeep=-1
for i in range(n):
  x=b[i]
  if(x!=ikeep):
    ikeep=x
  else:
    pat+=paty*patz
    continue
  for j in range(n):
    y=a[j]
    paty=n
    if(x<=y):
      paty=j
      break
  for j in range(n):
    z=c[j]
    patz=n
    if(z<=x):
      patz=j
      break
  #print(paty,patz)
  pat+=paty*patz
print(pat)


Fixed submission:
import bisect
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()
#print(a)
#print(b)
#print(c)
pat=0
ikeep=-1
for i in range(n):
  x=b[i]
  if(x!=ikeep):
    ikeep=x
  else:
    pat+=paty*patz
    continue
  paty=bisect.bisect_left(a,x)
  patz=n-bisect.bisect_right(c,x)
  #print(paty,patz)
  pat+=paty*patz
print(pat)

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()))
a.sort()
b.sort()
c.sort()
b.reverse()
c.reverse()
pat=0
keepi,keepj=-1,-1
for x in range(n):
  i=a[x]
  if(i!=keepi):
    keepi=i
    patj=0
  else:
    pat+=patj
    continue
  for y in range(n):
    j=b[y]
    if(j!=keepj):
        keepj=j
    else:
        patj+=patk
        continue
    if(j<=i):break
    br=0
    for k in range(n):
      if(c[k]<=j):
        #print(i,j,c[k],k)
        patk=k
        br=1
        break
    if(br==0):patk=n
    patj+=patk
  pat+=patj
print(pat)

Fixed submission:
import bisect
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()
#print(a)
#print(b)
#print(c)
pat=0
ikeep=-1
for i in range(n):
  x=b[i]
  if(x!=ikeep):
    ikeep=x
  else:
    pat+=paty*patz
    continue
  paty=bisect.bisect_left(a,x)
  patz=n-bisect.bisect_right(c,x)
  #print(paty,patz)
  pat+=paty*patz
print(pat)

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()))
a.sort()
b.sort()
c.sort()
b.reverse()
c.reverse()
pat=0
for i in a:
  for j in b:
    if(j<=i):break
    br=0
    for k in range(n):
      if(c[k]<=j):
        #print(i,j,c[k],k)
        pat+=k
        br=1
        break
    if(br==0):pat+=n
print(pat)

Fixed submission:
import bisect
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()
#print(a)
#print(b)
#print(c)
pat=0
ikeep=-1
for i in range(n):
  x=b[i]
  if(x!=ikeep):
    ikeep=x
  else:
    pat+=paty*patz
    continue
  paty=bisect.bisect_left(a,x)
  patz=n-bisect.bisect_right(c,x)
  #print(paty,patz)
  pat+=paty*patz
print(pat)