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

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)
    index2_right = bisect.bisect_right(a[2], i)
    if ( i > a[0][index0_left-1] and a[2][index2_right+1] > i):
        count += (index0_left -1 + 1)*(n - index2_right)

print(count)


Fixed submission:
import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)

    index2_right = bisect.bisect_right(a[2], i)

    count += (index0_left -1 + 1)*(n - index2_right)

print(count)

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

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)
    while i == a[0][index0_left-1]:
        if index0_left == 0:
            break
        index0_left -= 1

    index2_right = bisect.bisect_right(a[2], i)
    while a[2][index2_right+1] == i:
        if index2_right > n:
            break
        index2_right += 1

    if ( i > a[0][index0_left-1] and a[2][index2_right+1] > i):
        count += (index0_left)*( n - index2_right)
        
print(count)

Fixed submission:
import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)

    index2_right = bisect.bisect_right(a[2], i)

    count += (index0_left -1 + 1)*(n - index2_right)

print(count)

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

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)
    while i == a[0][index0_left-1]:
        if index0_left == 0:
            break
        index0_left -= 1

    index2_right = bisect.bisect_right(a[2], i)
    while a[2][index2_right+1] == i:
        if index2_right > n:
            break
        index2_right += 1

    if ( i > a[0][index0_left-1] and a[2][index2_right+1] > i):
        count += (index0_left)*( n - index2_right)



Fixed submission:
import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)

    index2_right = bisect.bisect_right(a[2], i)

    count += (index0_left -1 + 1)*(n - index2_right)

print(count)

Buggy python submission (verdict: Time Limit Exceeded):
# using sort

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Brute force
for i in a[0]:
    for j in a[1]:
        if i < j:
            index = 0
            for k in a[2]:
                if j < k:
                    count += n - index
                    break
                else:
                    index += 1

print(count)

Fixed submission:
import bisect

n = int(input())
count = 0
a = [[0 for i in range(n)] for i in range(3)]

for i in range(3):
    a[i] = [int(x) for x in input().split()]
    a[i].sort()

# Binary Search
for i in a[1]:
    index0_left = bisect.bisect_left(a[0], i)

    index2_right = bisect.bisect_right(a[2], i)

    count += (index0_left -1 + 1)*(n - index2_right)

print(count)