Buggy python submission (verdict: Time Limit Exceeded):
def comp(i,j):
    # i < j <-> 1
    # i > j <-> -1
    # i == j <-> 0
    if len(i) < len(j):
        return 1
    elif len(i) > len(j):
        return -1
    for x in range(len(i)):
        if i[x] == j[x]:
            continue
        elif i[x] > j[x]:
            return -1
        else:
            return 1
    return 0



def bisect_left(array, i):
    __bisect_array = array
    def _bisect_left(i, left, right):
        n = right - left + 1
        mid = (left+right) // 2
        if n == 1:
            if comp(__bisect_array[mid],i) == 1:
                return 1
            else:
                return 0
        if comp(i, __bisect_array[mid]) >= 0:
            return _bisect_left(i,left,mid)
        else:
            return (mid-left+1) + _bisect_left(i,mid+1,right)
    return _bisect_left(i, 0, len(array)-1)

def bisect_right(array, i):
    __bisect_array = array
    def _bisect_right(i, left, right):
        n = right - left + 1
        mid = (right+left) // 2
        if n == 1:
            if comp(i, __bisect_array[mid]) == 1:
                return 0
            else:
                return 1
        if comp(__bisect_array[mid] ,i) >= 0:
            return  (mid-left+1) + _bisect_right(i,mid+1,right)
        else:
           return _bisect_right(i,left,mid)
    return _bisect_right(i, 0, len(array)-1)

N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    l = list(map(str,sorted(l)))
    L.append(l)
ans = 0
for x in L[1]:
    n = bisect_left(L[0],x)
    m = bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Fixed submission:
N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
import bisect
ans = 0
for x in L[1]:
    n = bisect.bisect_left(L[0],x)
    m = bisect.bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def bisect_left(array, i):
    __bisect_array = array
    def _bisect_left(i, left, right):
        n = right - left + 1
        mid = (left+right) // 2
        if n == 1:
            if __bisect_array[mid] < i:
                return 1
            else:
                return 0
        if i <= __bisect_array[mid]:
            return _bisect_left(i,left,mid)
        else:
            return (mid-left+1) + _bisect_left(i,mid+1,right)
    return _bisect_left(i, 0, len(array)-1)

def bisect_right(array, i):
    __bisect_array = array
    def _bisect_right(i, left, right):
        n = right - left + 1
        mid = (right+left) // 2
        if n == 1:
            if i < __bisect_array[mid] :
                return 0
            else:
                return 1
        if __bisect_array[mid] <= i:
            return  (mid-left+1) + _bisect_right(i,mid+1,right)
        else:
           return _bisect_right(i,left,mid)
    return _bisect_right(i, 0, len(array)-1)

N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
ans = 0
for x in L[1]:
    n = bisect_left(L[0],x)
    m = bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Fixed submission:
N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
import bisect
ans = 0
for x in L[1]:
    n = bisect.bisect_left(L[0],x)
    m = bisect.bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def bisect_left(array, i, left, right):
    n = right - left + 1
    mid = (left+right) // 2
    if n == 1:
        if array[mid] < i:
            return 1
        else:
            return 0
    if i <= array[mid]:
        return bisect_left(array,i,left,mid)
    else:
        return (mid-left+1) + bisect_left(array,i,mid+1,right)

def bisect_right(array, i, left, right):
    n = right - left + 1
    mid = (right+left) // 2
    if n == 1:
        if i < array[mid] :
            return 0
        else:
            return 1
    if array[mid] <= i:
        return  (mid-left+1) + bisect_right(array,i,mid+1,right)
    else:
        return bisect_right(array,i,left,mid)

N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
ans = 0
for x in L[1]:
    n = bisect_left(L[0],x,0,N-1)
    m = bisect_right(L[2],x,0,N-1)
    m = N - m
    ans += n*m
print(ans)

Fixed submission:
N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
import bisect
ans = 0
for x in L[1]:
    n = bisect.bisect_left(L[0],x)
    m = bisect.bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def bisect_left(array, i):
    n = len(array)
    mid = n // 2
    if n == 1:
        if array[0] < i:
            return 1
        else:
            return 0
    if i <= array[mid]:
        return bisect_left(array[:mid],i)
    else:
        return mid + bisect_left(array[mid:],i)

def bisect_right(array, i):
    n = len(array)
    mid = n // 2
    if n == 1:
        if i < array[0] :
            return 0
        else:
            return 1
    if array[mid] <= i:
        return  mid + bisect_right(array[mid:],i)
    else:
        return bisect_right(array[0:mid],i)

N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
ans = 0
for x in L[1]:
    n = bisect_left(L[0],x)
    m = bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Fixed submission:
N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
import bisect
ans = 0
for x in L[1]:
    n = bisect.bisect_left(L[0],x)
    m = bisect.bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Buggy python submission (verdict: Time Limit Exceeded):
def bisect_left(array, i):
    n = len(array)
    mid = n // 2
    if n == 1:
        if array[0] < i:
            return 1
        else:
            return 0
    if i <= array[mid]:
        return bisect_left(array[:mid],i)
    else:
        return mid + bisect_left(array[mid:],i)

def bisect_right(array, i):
    n = len(array)
    mid = n // 2
    if n == 1:
        if i < array[0] :
            return 0
        else:
            return 1
    if array[mid] <= i:
        return  mid + bisect_right(array[mid:],i)
    else:
        return bisect_right(array[0:mid],i)

N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
ans = 0
for x in L[1]:
    n = bisect_left(L[0],x)
    m = bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)

Fixed submission:
N = int(input())
L = []
for _ in range(3):
    l = list(map(int,input().split()))
    L.append(sorted(l))
import bisect
ans = 0
for x in L[1]:
    n = bisect.bisect_left(L[0],x)
    m = bisect.bisect_right(L[2],x)
    m = N - m
    ans += n*m
print(ans)