alexjercan/bugnet huggingface dataset:
Problem p03545 (Python) — buggy submission, verdict: Runtime Error

n = input()
num = [int(n[0]), int(n[1]), int(n[2]), int(n[3])]
if sum(num) == 7:
    print(str(num[0]) + "+" + str(num[1]) + "+" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] + num[1] + num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "+" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] + num[1] - num[2] + num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "-" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "-" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] - num[1] + num[2] + num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "+" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] - num[1] + num[2] - num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "+" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] - num[1] - num[2] + num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "-" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] - num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "-" + str(num[2]) + "-" + str(num[3]) + "=7")


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03545/Python/s160277968.py", line 4, in <module>
    elif num[0] + num[1] + num[2] - num[3] == 7:
IndexError: list index out of range


Fixed submission:

num = list(map(int, input().split()))
if sum(num) == 7:
    print(str(num[0]) + "+" + str(num[1]) + "+" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] + num[1] + num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "+" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "-" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] + num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "+" + str(num[1]) + "-" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] - num[1] + num[2] + num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "+" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] - num[1] + num[2] - num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "+" + str(num[2]) + "-" + str(num[3]) + "=7")
elif num[0] - num[1] - num[2] + num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "-" + str(num[2]) + "+" + str(num[3]) + "=7")
elif num[0] - num[1] - num[2] - num[3] == 7:
    print(str(num[0]) + "-" + str(num[1]) + "-" + str(num[2]) + "-" + str(num[3]) + "=7")
Problem p03547 (Python) — buggy submission, verdict: Runtime Error

x, y = map(ord, input().split())
if x == y:
    print("=")
elif x < y:
    print("<")
else:
    print(">")


Error: TypeError: ord() takes exactly one argument (0 given)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03547/Python/s065466728.py", line 1, in <module>
    x, y = map(ord(), input().split())
TypeError: ord() takes exactly one argument (0 given)


Fixed submission:

x, y = map(ord(), input().split())
if x == y:
    print("=")
elif x < y:
    print("<")
else:
    print(">")
Problem p03547 (Python) — buggy submission, verdict: Runtime Error

X, Y = input().split()
X = ord(X)
Y = ord(Y)
if X < Y:
    print("<")
elif X > Y:
    print(">")
else:
    print("=")


Error: ValueError: invalid literal for int() with base 10: 'A'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03547/Python/s221456569.py", line 1, in <module>
    X, Y = map(int, input().split())
ValueError: invalid literal for int() with base 10: 'A'


Fixed submission:

X, Y = map(int, input().split())
X = ord(X)
Y = ord(Y)
if X < Y:
    print("<")
elif X > Y:
    print(">")
else:
    print("=")
Problem p03547 (Python) — buggy submission, verdict: Runtime Error

X, Y = input().split(" ")
print("<" if X < Y else "=" if X == Y else ">")


Error: ValueError: invalid literal for int() with base 10: 'A'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03547/Python/s372452784.py", line 1, in <module>
    X, Y = map(int, input().split(" "))
ValueError: invalid literal for int() with base 10: 'A'


Fixed submission:

X, Y = map(int, input().split(" "))
print("<" if X < Y else "=" if X == Y else ">")
Problem p03547 (Python) — buggy submission, verdict: Runtime Error

import sys

input = sys.stdin.readline


def main():
    x, y = input().split()
    table = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6}
    x = table[x]
    y = table[y]
    if x < y:
        print("<")
    elif x == y:
        print("=")
    else:
        print(">")


if __name__ == "__main__":
    main()


Error: ValueError: invalid literal for int() with base 10: 'A'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03547/Python/s204322259.py", line 20, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03547/Python/s204322259.py", line 7, in main
    x, y = map(int, input().split())
ValueError: invalid literal for int() with base 10: 'A'


Fixed submission:

import sys

input = sys.stdin.readline


def main():
    x, y = map(int, input().split())
    table = {"A": 1, "B": 2, "C": 3, "D": 4, "E": 5, "F": 6}
    x = table[x]
    y = table[y]
    if x < y:
        print("<")
    elif x == y:
        print("=")
    else:
        print(">")


if __name__ == "__main__":
    main()
Problem p03547 (Python) — buggy submission, verdict: Runtime Error

X, Y = input().split()

num = {"A": 10, "B": 11, "C": 12, "D": 13, "E": 14, "F": 15}

if num[X] > num[Y]:
    print(">")

elif num[X] < num[Y]:
    print("<")

else:
    print("=")


Error: ValueError: invalid literal for int() with base 10: 'A'
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03547/Python/s743521997.py", line 1, in <module>
    X, Y, Z = map(int, input().split())
ValueError: invalid literal for int() with base 10: 'A'


Fixed submission:

X, Y, Z = map(int, input().split())
ans = 0

while X > Y + Z:
    X -= Y + Z
    ans += 1
if X < Z:
    ans -= 1
print(ans)
Problem p03555 (Python) — buggy submission, verdict: Runtime Error

a = input()
b = input()
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
    print("YES")
else:
    print("NO")


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03555/Python/s798720527.py", line 3, in <module>
    if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
IndexError: list index out of range


Fixed submission:

a = list(map(str, input().split()))
b = list(map(str, input().split()))
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
    print("YES")
else:
    print("NO")
Problem p03555 (Python) — buggy submission, verdict: Runtime Error

word1, word2 = [input() for i in range(2)]
if word1[0] == word2[2] and word1[1] == word2[1] and word1[2] == word2[0]:
    print("YES")
else:
    print("NO")


Error: ValueError: not enough values to unpack (expected 2, got 1)
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03555/Python/s482109922.py", line 1, in <module>
    a, b = input().split()
ValueError: not enough values to unpack (expected 2, got 1)


Fixed submission:

a, b = input().split()
if a[0] == b[2] and a[1] == b[1] and a[2] == b[0]:
    print("YES")
else:
    print("NO")
Problem p03555 (Python) — buggy submission, verdict: Runtime Error

C1 = list(input())
C2 = list(input())

if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
    print("YES")
else:
    print("NO")


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03555/Python/s162905241.py", line 4, in <module>
    if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
IndexError: list index out of range


Fixed submission:

C1 = list(input().split())
C2 = list(input().split())

if C1[0] == C2[2] and C1[1] == C2[1] and C1[2] == C2[0]:
    print("YES")
else:
    print("NO")
Problem p03556 (Python) — buggy submission, verdict: Runtime Error

import numpy

n = int(input())

for i in range(n):
    a = int(numpy.sqrt(n - i))
    b = n - i
    if a**2 == b:
        print(b)
        break
    else:
        pass


Error: TLE

Fixed submission:

import numpy as np

n = input()

for i in range(n):
    a = int(np.sqrt(n - i))
    b = n - i
    if a**2 == b:
        print(b)
        break
    else:
        pass
Problem p03556 (Python) — buggy submission, verdict: Runtime Error

n = int(input())

for i in range(1, n + 1):
    if i**2 <= n:
        ans = min(n, i**2)
    else:
        break

print(ans)


Error: 0

Fixed submission:

n = int(input())

for i in range(1, n):
    if i**2 <= n:
        ans = min(n, i**2)
    else:
        break

print(ans)
Problem p03556 (Python) — buggy submission, verdict: Time Limit Exceeded

import numpy as np

N = int(input())

ans = int(np.sqrt(N))
print(ans**2)


Error: TLE

Fixed submission:

N = int(input())

for n in range(1, N + 1)[::-1]:
    if n * n <= N:
        print(str(n * n))
        break
    else:
        pass
Problem p03556 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
ans = 1
for i in range(N):
    if i * i > N:
        ans = (i - 1) ** 2
        break
print(ans)


Error: 0

Fixed submission:

N = int(input())
for i in range(N):
    if i * i > N:
        ans = (i - 1) ** 2
        break
print(ans)
Problem p03556 (Python) — buggy submission, verdict: Runtime Error

N = int(input())
tmp = 1
for i in range(N, 1, -1):
    tmp = int(pow(i, 0.5))
    if tmp * tmp == i:
        break
print(tmp * tmp)


Error: 0

Fixed submission:

N = int(input())
for i in range(N, 1, -1):
    tmp = int(pow(i, 0.5))
    if tmp * tmp == i:
        break
print(i)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

import bisect

n = int(input())
a = sorted(list(map(int, input().split())))
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))

ans = 0
for i in b:
    a_pos = bisect.bisect_left(a, i)
    c_pos = n - bisect.bisect_right(c, i)
    ans += a_pos * c_pos

print(ans)


Error: TLE

Fixed submission:

from collections import deque

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

q = deque()
for i in a:
    q.append([i])

ans = 0
while q:
    now = q.popleft()
    n = len(now)
    if n == 3:
        ans += 1
    elif n == 2:
        for x in c:
            if now[-1] < x:
                q.append(now + [x])
    elif n == 1:
        for y in b:
            if now[-1] < y:
                q.append(now + [y])

print(ans)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

from bisect import bisect_left
from bisect import bisect_right


N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
y_low = {}
i = 0
for y in B:
    x = bisect_left(A, y)
    z = bisect_right(C, y)
    ans += x * (N - z)
print(ans)


Error: TLE

Fixed submission:

from bisect import bisect_right

N = int(input())
A = sorted(map(int, input().split()))
B = sorted(map(int, input().split()))
C = sorted(map(int, input().split()))

ans = 0
y_low = {}
i = 0
for x in A:
    y_low[i] = bisect_right(B, x)
    i += 1
for y_lowi in y_low.values():
    for y in B[y_lowi:]:
        z_low = bisect_right(C, y)
        ans += N - z_low
print(ans)
Problem p03557 (Python) — buggy submission, verdict: Runtime Error

# それぞれソート済みとして, 整数でAi<BjかつBj<Ckとなるjを求める(にぶたん)

N = int(input())
A = list(sorted(list(map(int, input().split()))))
B = list(sorted(list(map(int, input().split()))))
C = list(sorted(list(map(int, input().split()))))


def lower_bound(arr, target):
    # targetを超える最小の値のインデックス
    if target > arr[-1]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] > target:
            right = mid
        else:
            left = mid + 1
    return right


def upper_bound(arr, target):
    # target以上の最小の値のインデックス
    if target < arr[0]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] >= target:
            right = mid
        else:
            left = mid + 1
    return right


count = 0

for b in B:
    ai = upper_bound(A, b)
    ci = lower_bound(C, b)
    if ai is not None and ci is not None:
        count += ai * (N - ci)

print(count)


Error: 0

Fixed submission:

# それぞれソート済みとして, 整数でAi<BjかつBj<Ckとなるjを求める(にぶたん)

N = int(input())
A = list(sorted(list(map(int, input().split()))))
B = list(sorted(list(map(int, input().split()))))
C = list(sorted(list(map(int, input().split()))))


def lower_bound(arr, target):
    # targetを超える最小の値のインデックス
    if target > arr[-1]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] > target:
            right = mid
        else:
            left = mid + 1
    return right


def upper_bound(arr, target):
    # target以上の最小の値のインデックス
    if target < arr[0]:
        return None
    left, right = 0, len(arr)
    while left < right:
        mid = (left + right) // 2
        if arr[mid] >= target:
            right = mid
        else:
            left = mid + 1
    return right


count = 0

for b in B:
    ai = upper_bound(A, b)
    ci = N - lower_bound(C, b)
    if ai is not None and ci is not None:
        count += ai * ci

print(count)
Problem p03557 (Python) — buggy submission, verdict: Runtime Error

#!/usr/bin/env python3

import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)
B = sorted(B)
C = sorted(C)

res = 0
for b in B:
    index_a = bisect.bisect_left(A, b)
    index_c = bisect.bisect_right(C, b)
    res += index_a * (N - index_c)

print(res)


Error: 0

Fixed submission:

#!/usr/bin/env python3

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)
B = sorted(B)
C = sorted(C)


def is_ok(array, index, value):
    if array[index] >= value:
        return True
    return False


def bs_general(array, value, is_ok):
    left = -1
    right = len(array)
    while abs(right - left) > 1:
        mid = (left + right) // 2
        if is_ok(array, mid, value):
            right = mid
        else:
            left = mid
    return right


res = 0
for b in B:
    index_a = bs_general(A, b, is_ok)
    index_c = bs_general(C, b, is_ok)
    if C[index_c] == b:
        res += index_a * (N - index_c - 1)
    else:
        res += index_a * (N - index_c)

print(res)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

from bisect import bisect
from itertools import accumulate

n = int(input())
a_list = sorted(map(int, input().split()))
b_list = sorted(map(int, input().split()))
c_list = sorted(map(int, input().split()))

b_c_table_ = list(accumulate(reversed(tuple(n - bisect(c_list, b) for b in b_list))))
b_c_table_.reverse()
b_c_table_ += [0]

print(sum(b_c_table_[bisect(b_list, a)] for a in a_list))


Error: TLE

Fixed submission:

from bisect import bisect

n = int(input())
a_list = sorted(map(int, input().split()))
b_list = sorted(map(int, input().split()))
c_list = sorted(map(int, input().split()))

b_c_table = [n - bisect(c_list, b) for b in b_list]

ans = 0
for a in a_list:
    i = bisect(b_list, a)
    ans += sum(b_c_table[i:n])
print(ans)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

from bisect import bisect_left, bisect_right  # 2文探索法モジュール

N = int(input())
a = sorted(list(map(int, input().split())))  # ソートしておく
b = list(map(int, input().split()))
c = sorted(list(map(int, input().split())))  # ソートしておく

count = 0
for b_item in b:
    i = bisect_left(a, b_item)  # リストaのb_itemより小さい要素の数
    j = N - bisect_right(c, b_item)  # リストcのb_itemより大きい要素の数
    count += i * j
print(count)


Error: TLE

Fixed submission:

N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

count = 0
for i in range(N):
    for j in range(N):
        if a[i] >= b[j]:
            continue
        for k in range(N):
            if b[j] < c[k]:
                count += 1
print(count)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

import bisect

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

A = sorted(A)
C = sorted(C)

counter = 0

for k in range(N):
    i = bisect.bisect_left(A, B[k])
    j = N - bisect.bisect_right(C, B[k])
    counter += i * j

print(counter)


Error: TLE

Fixed submission:

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

counter = 0

for a in A:
    for b in B:
        if a < b:
            for c in C:
                if b < c:
                    counter = counter + 1
                else:
                    pass
        else:
            pass

print(counter)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

import bisect

n = int(input())
al = sorted(list(map(int, input().split())))
bl = sorted(list(map(int, input().split())))
cl = sorted(list(map(int, input().split())))
ans = 0

for b in bl:
    i = bisect.bisect_left(al, b)
    j = bisect.bisect_right(cl, b)
    ans += i * (n - j)

print(ans)


Error: TLE

Fixed submission:

import bisect

n = int(input())
al = sorted(list(map(int, input().split())))
bl = sorted(list(map(int, input().split())))
cl = sorted(list(map(int, input().split())))

a_len = len(al)
b_len = len(bl)
c_len = len(cl)

ans = 0
for a in al:
    b_index = bisect.bisect_right(bl, a)
    if b_index >= b_len:
        break
    tmp_bl = bl[b_index:]
    for b in tmp_bl:
        c_index = bisect.bisect_right(cl, b)
        if c_index >= c_len:
            break
        ans += c_len - c_index
        # print(f'a:{a}, b_index:{b_index}, c_index:{c_index}, ans:{ans}')

print(ans)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

from bisect import bisect_left, bisect_right

N = int(input())
A = sorted(list(map(int, input().split())))
B = list(map(int, input().split()))
C = sorted(list(map(int, input().split())))

ans = 0
for b in B:
    max_index_A = bisect_left(A, b)
    max_index_C = N - bisect_right(C, b)
    ans += (max_index_A) * (max_index_C)

print(ans)


Error: TLE

Fixed submission:

from bisect import bisect_left

N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = list(map(int, input().split()))

ans = 0
for c in C:
    max_index_B = bisect_left(B, c)
    for i in range(max_index_B):
        ans += bisect_left(A, B[i])

print(ans)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

# https://atcoder.jp/contests/abc077/tasks/arc084_a
# C - Snuke Festival
import bisect

N = int(input().split()[0])
a_list = sorted(list(map(int, input().split())))
b_list = sorted(list(map(int, input().split())))
c_list = sorted(list(map(int, input().split())))

comb_n = 0
comb_n_list = []

# 自分より大きい個数
start_c_index = 0
start_a_index = 0

for i in range(N):  # 10 ** 5
    b = b_list[i]
    a_n = bisect.bisect_left(a_list, b)
    c_n = N - bisect.bisect_right(c_list, b)
    comb_n += a_n * c_n
ans = comb_n
print(ans)


Error: TLE

Fixed submission:

# https://atcoder.jp/contests/abc077/tasks/arc084_a
# C - Snuke Festival

N = int(input().split()[0])
a_list = sorted(list(map(int, input().split())))
b_list = sorted(list(map(int, input().split())))
c_list = sorted(list(map(int, input().split())))

comb_n = 0

for i in range(N):  # 10 ** 5
    b = b_list[i]
    c_n = len([c for c in c_list if c > b])  # 10 ** 5
    a_n = len([a for a in a_list if a < b])  # 10 ** 5
    comb_n += a_n * c_n

ans = comb_n
print(ans)
Problem p03557 (Python) — buggy submission, verdict: Time Limit Exceeded

import bisect


n = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))


cnt = 0

for b in B:
    mid = bisect.bisect_left(A, b)
    bottom = n - bisect.bisect_right(C, b)
    cnt += mid * bottom

print(cnt)


Error: TLE

Fixed submission:

n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

cnt = 0

for a in A:
    for b in B:
        for c in C:
            if a < b < c:
                cnt += 1

print(cnt)
Problem p03557 (Python) — buggy submission, verdict: Runtime Error

import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1] + [0]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()


Error: IndexError: list index out of range
Traceback (most recent call last):
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03557/Python/s915162350.py", line 33, in <module>
    main()
  File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03557/Python/s915162350.py", line 27, in main
    ans += acc[pos]
IndexError: list index out of range


Fixed submission:

import sys
from bisect import bisect
from itertools import accumulate


def main():
    input = sys.stdin.buffer.readline
    n = int(input())
    a = sorted(map(int, input().split()))
    b = sorted(map(int, input().split()))
    c = sorted(map(int, input().split()))
    # 各中部パーツを乗せられる下部パーツの個数
    # b_c_cnt = [len(c[bisect(c, b[i]) :]) for i in range(n)]
    b_c_cnt = [0] * n
    past = 0
    for i in range(n):
        pos = bisect(c, b[i], lo=past)
        past = pos
        b_c_cnt[i] = n - pos

    # b_c_cntに後ろから累積和をとる
    acc = list(accumulate(b_c_cnt[::-1]))[::-1]
    ans = 0
    past = 0
    for i in range(n):
        pos = bisect(b, a[i], lo=past)
        ans += acc[pos]
        past = pos
    print(ans)


if __name__ == "__main__":
    main()