Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
tmp = list(map(int,input().split()))
A = []  
[bisect.insort_right(A, x) for x in tmp]
B = list(map(int,readline().rstrip().split()))
#B = []
#[bisect.insort_right(B,x) for x in tmp ]
C = list(map(int,readline().rstrip().split()))
#C = []
#[bisect.insort_right(C,x) for x in tmp]

A.sort()
B.sort()
C.sort()

listb = []
for i , b in enumerate(B[::-1]):
    if i == 0:
        listb.append(N - bisect.bisect_right(C,b))
    else:
        listb.append(N - bisect.bisect_right(C,b) + listb[i-1])

ans = 0
for a in A :
    indexb = bisect.bisect_right(B,a)
    if indexb == N :
        break
    ans += listb[N-1 - indexb]

print(ans)

Fixed submission:
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
A = list(map(int,input().split()))
#A = []  
#[bisect.insort_right(A, x) for x in tmp]
B= list(map(int,readline().rstrip().split()))
#B = []
#[bisect.insort_right(B,x) for x in tmp ]
C = list(map(int,readline().rstrip().split()))
#C = []
#[bisect.insort_right(C,x) for x in tmp]

A.sort()
C.sort()

ans = 0
for b in B :
    indA = bisect.bisect_left(A,b)
    indC = bisect.bisect_right(C,b)
    ans += indA * (N-indC)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
tmp = list(map(int,input().split()))
A = []  
[bisect.insort_right(A, x) for x in tmp]
tmp = list(map(int,readline().rstrip().split()))
B = []
[bisect.insort_right(B,x) for x in tmp ]
tmp = list(map(int,readline().rstrip().split()))
C = []
[bisect.insort_right(C,x) for x in tmp]

ans = 0
for b in B :
    indA = bisect.bisect_left(A,b)
    indC = bisect.bisect_right(C,b)
    ans += indA * (N-indC)

print(ans)

Fixed submission:
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
A = list(map(int,input().split()))
#A = []  
#[bisect.insort_right(A, x) for x in tmp]
B= list(map(int,readline().rstrip().split()))
#B = []
#[bisect.insort_right(B,x) for x in tmp ]
C = list(map(int,readline().rstrip().split()))
#C = []
#[bisect.insort_right(C,x) for x in tmp]

A.sort()
C.sort()

ans = 0
for b in B :
    indA = bisect.bisect_left(A,b)
    indC = bisect.bisect_right(C,b)
    ans += indA * (N-indC)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
tmp = list(map(int,input().split()))
A = []  
[bisect.insort_right(A, x) for x in tmp]
tmp = list(map(int,readline().rstrip().split()))
B = []
[bisect.insort_right(B,x) for x in tmp ]
tmp = list(map(int,readline().rstrip().split()))
C = []
[bisect.insort_right(C,x) for x in tmp]

listb = []
for i , b in enumerate(B[::-1]):
    if i == 0:
        listb.append(N - bisect.bisect_right(C,b))
    else:
        listb.append(N - bisect.bisect_right(C,b) + listb[i-1])

ans = 0
for a in A :
    indexb = bisect.bisect_right(B,a)
    if indexb == N :
        break
    ans += listb[N-1 - indexb]

print(ans)

Fixed submission:
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
A = list(map(int,input().split()))
#A = []  
#[bisect.insort_right(A, x) for x in tmp]
B= list(map(int,readline().rstrip().split()))
#B = []
#[bisect.insort_right(B,x) for x in tmp ]
C = list(map(int,readline().rstrip().split()))
#C = []
#[bisect.insort_right(C,x) for x in tmp]

A.sort()
C.sort()

ans = 0
for b in B :
    indA = bisect.bisect_left(A,b)
    indC = bisect.bisect_right(C,b)
    ans += indA * (N-indC)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
tmp = list(map(int,input().split()))
A = []  
[bisect.insort_right(A, x) for x in tmp]
tmp = list(map(int,readline().rstrip().split()))
B = []
[bisect.insort_right(B,x) for x in tmp ]
tmp = list(map(int,readline().rstrip().split()))
C = []
[bisect.insort_right(C,x) for x in tmp]

ans = 0
for a in A :
    indexb = bisect.bisect_right(B,a)
    if indexb == N :
        break
    for ib in range( indexb , N):
        indexc = bisect.bisect_right(C,B[ib])
        if indexc == N :
            break
        ans += (N-indexc)

print(ans)

Fixed submission:
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
A = list(map(int,input().split()))
#A = []  
#[bisect.insort_right(A, x) for x in tmp]
B= list(map(int,readline().rstrip().split()))
#B = []
#[bisect.insort_right(B,x) for x in tmp ]
C = list(map(int,readline().rstrip().split()))
#C = []
#[bisect.insort_right(C,x) for x in tmp]

A.sort()
C.sort()

ans = 0
for b in B :
    indA = bisect.bisect_left(A,b)
    indC = bisect.bisect_right(C,b)
    ans += indA * (N-indC)

print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
tmp = list(map(int,input().split()))
A = []  
[bisect.insort_right(A, x) for x in tmp]
tmp = list(map(int,readline().rstrip().split()))
B = []
[bisect.insort_right(B,x) for x in tmp ]
tmp = list(map(int,readline().rstrip().split()))
C = []
[bisect.insort_right(C,x) for x in tmp]

ans = 0
for a in A :
    indexb = bisect.bisect_right(B,a)
    if indexb == N :
        break
    for ib in range( indexb , N):
        indexc = bisect.bisect_right(C,B[ib])
        if indexc == N :
            break
        ans += (N-indexc)

print(ans)

Fixed submission:
#import numpy as np
import sys
from collections import defaultdict
import math
import itertools
import bisect
read = sys.stdin.buffer.read
readline = sys.stdin.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10000)

N = int(readline())
A = list(map(int,input().split()))
#A = []  
#[bisect.insort_right(A, x) for x in tmp]
B= list(map(int,readline().rstrip().split()))
#B = []
#[bisect.insort_right(B,x) for x in tmp ]
C = list(map(int,readline().rstrip().split()))
#C = []
#[bisect.insort_right(C,x) for x in tmp]

A.sort()
C.sort()

ans = 0
for b in B :
    indA = bisect.bisect_left(A,b)
    indC = bisect.bisect_right(C,b)
    ans += indA * (N-indC)

print(ans)