The season for Snuke Festival has come again this year. First of all, Ringo will perform a ritual to summon Snuke. For the ritual, he needs an altar, which consists of three parts, one in each of the three categories: upper, middle and lower.
He has N parts for each of the three categories. The size of the i-th upper part is A_i, the size of the i-th middle part is B_i, and the size of the i-th lower part is C_i.
To build an altar, the size of the middle part must be strictly greater than that of the upper part, and the size of the lower part must be strictly greater than that of the middle part. On the other hand, any three parts that satisfy these conditions can be combined to form an altar.
How many different altars can Ringo build? Here, two altars are considered different when at least one of the three parts used is different.

-----Constraints-----
 - 1 \leq N \leq 10^5
 - 1 \leq A_i \leq 10^9(1\leq i\leq N)
 - 1 \leq B_i \leq 10^9(1\leq i\leq N)
 - 1 \leq C_i \leq 10^9(1\leq i\leq N)
 - All input values are integers.

-----Input-----
Input is given from Standard Input in the following format:
N
A_1 ... A_N
B_1 ... B_N
C_1 ... C_N

-----Output-----
Print the number of different altars that Ringo can build.

-----Sample Input-----
2
1 5
2 4
3 6

-----Sample Output-----
3

The following three altars can be built:
 - Upper: 1-st part, Middle: 1-st part, Lower: 1-st part
 - Upper: 1-st part, Middle: 1-st part, Lower: 2-nd part
 - Upper: 1-st part, Middle: 2-nd part, Lower: 2-nd part
[{"code": "n = int(input())\na_list = sorted([int(x) for x in input().split()])\nb_list = sorted([int(x) for x in input().split()])\nc_list = sorted([int(x) for x in input().split()])\n\nimport bisect\nsum = 0\nfor b in b_list:\n    b_num = bisect.bisect_left(a_list,b)\n    c_num = bisect.bisect_right(c_list,b)\n    sum += b_num*(len(c_list)-c_num)\nprint(sum)", "passed": true, "time": 0.35, "memory": 14100.0, "status": "done"}, {"code": "N = int(input())\nA = [int(a) for a in input().split(\" \")]\nB = [int(b) for b in input().split(\" \")]\nC = [int(c) for c in input().split(\" \")]\n\nA.sort()\nB.sort()\nC.sort()\n\ncombiBC = [0] * len(B)\n# combiBC[i] : number of combination of B, C when B[i] is selected\n\nic = 0\nlc = len(C)\nfor ib in range(len(B)):\n\tb = B[ib]\n\twhile ic < lc:\n\t\tc = C[ic]\n\t\tif b >= c:\n\t\t\tic += 1\n\t\telse:\n\t\t\tcombiBC[ib] = lc - ic\n\t\t\tbreak\n\nsumCombiBC = []\nfor i in range(len(combiBC)):\n\tif i == 0:\n\t\tsumCombiBC.append(combiBC[-1])\n\telse:\n\t\tsumCombiBC.insert(0, combiBC[-i-1] + sumCombiBC[0])\n\ncnt = 0\nib = 0\nfor ia in range(len(A)):\n\ta = A[ia]\n\twhile ib < len(B):\n\t\tb = B[ib]\n\t\tif a >= b:\n\t\t\tib += 1\n\t\telse:\n\t\t\tcnt += sumCombiBC[ib]\n\t\t\tbreak\n\nprint(cnt)", "passed": true, "time": 0.38, "memory": 14364.0, "status": "done"}, {"code": "from bisect import bisect_left, bisect_right\nN = int(input())\nA, B, C = [sorted(map(int, input().split())) for _ in range(3)]\nprint(sum(bisect_left(A,b)*(N-bisect_right(C,b)) for b in B))", "passed": true, "time": 0.33, "memory": 14160.0, "status": "done"}, {"code": "import bisect\n\nn = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nans = 0\n\nfor b in B:\n    a = bisect.bisect_left(A, b)\n    c = bisect.bisect_right(C, b)\n    ans += a*(n-c)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14124.0, "status": "done"}, {"code": "import bisect\nN=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\na=sorted(A)\nb=sorted(B)\nc=sorted(C)\nans=0\nfor i in range(len(b)):\n    index_a=bisect.bisect_left(a,b[i])\n    index_c=bisect.bisect_right(c,b[i])\n    ans+=(index_a*(len(c)-index_c))\nprint(ans)", "passed": true, "time": 0.16, "memory": 14104.0, "status": "done"}, {"code": "N = int(input())\n\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nans = i = j = 0\n\nimport bisect\n\nfor b in B:\n    i = bisect.bisect_left(A,b)\n    j = N - bisect.bisect_right(C,b)\n    ans += i * j\nprint(ans)", "passed": true, "time": 0.36, "memory": 14236.0, "status": "done"}, {"code": "import sys\nimport math\nimport itertools\nimport collections\nfrom collections import deque\nfrom collections import defaultdict\n\nsys.setrecursionlimit(1000000)\nMOD = 10 ** 9 + 7\nMOD2 = 998244353\nINF = float('inf')\ninput = lambda: sys.stdin.readline().strip()\n\nNI = lambda: int(input())\nNMI = lambda: map(int, input().split())\nNLI = lambda: list(NMI())\nSI = lambda: input()\n\ndef main():\n    N = NI()\n    A = NLI()\n    B = NLI()\n    C = NLI()\n    \n    A = sorted(A)\n    C = sorted(C)\n    \n    ans = 0\n    \n    for b in B:\n        \n\n        A_ng = -1       #ng:\u3068\u308a\u5f97\u308b\u6700\u5c0f\u306e\u5024-1\n        A_ok = len(A)  #ok:\u3068\u308a\u5f97\u308b\u6700\u5927\u306e\u5024+1\n\n        while (abs(A_ok - A_ng) > 1):\n            A_mid = (A_ok + A_ng) // 2\n\n            if A[A_mid] >= b:#\u8a08\u7b97\u306e\u7d50\u679c\u3001mid\u304c\u6761\u4ef6\u3092\u6e80\u305f\u3059\u306a\u3089ok\u306bmid\u3092\u4ee3\u5165\u3002\u305d\u3046\u3067\u306a\u3051\u308c\u3070ng\u306bmid\u3092\u4ee3\u5165\u3002\n                A_ok = A_mid\n            else:\n                A_ng = A_mid\n                \n        C_ng = -1      #ng:\u3068\u308a\u5f97\u308b\u6700\u5c0f\u306e\u5024-1\n        C_ok = len(C)  #ok:\u3068\u308a\u5f97\u308b\u6700\u5927\u306e\u5024+1\n\n        while (abs(C_ok - C_ng) > 1):\n            C_mid = (C_ok + C_ng) // 2\n\n            if C[C_mid] > b:#\u8a08\u7b97\u306e\u7d50\u679c\u3001mid\u304c\u6761\u4ef6\u3092\u6e80\u305f\u3059\u306a\u3089ok\u306bmid\u3092\u4ee3\u5165\u3002\u305d\u3046\u3067\u306a\u3051\u308c\u3070ng\u306bmid\u3092\u4ee3\u5165\u3002\n                C_ok = C_mid\n            else:\n                C_ng = C_mid\n                \n                \n        len_C = len(C)\n        \n        ans += A_ok * (len_C-C_ok)\n        \n    print(ans)\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.36, "memory": 14228.0, "status": "done"}, {"code": "import bisect\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\n\nA.sort()\nC.sort()\n\nans = 0\nfor b in B:\n    l = bisect.bisect_left(A, b)\n    r = bisect.bisect_right(C, b)\n    ans += l * (len(C) - r)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14224.0, "status": "done"}, {"code": "import bisect\nn = int(input())\n\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\n\nans = 0\nfor i in range(n):\n    B = b[i]\n    b_in = bisect.bisect_left(a,B)\n    if b_in == 0:\n        continue\n    c_in = bisect.bisect_right(c,B)\n    c_cnt = n - c_in\n    ans += b_in*c_cnt\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14380.0, "status": "done"}, {"code": "# \u4e8c\u5206\u63a2\u7d22\nimport bisect\n\n#################\nn=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\n\n#\u30ea\u30b9\u30c8\u3092\u30bd\u30fc\u30c8\na=sorted(a)\nb=sorted(b)\nc=sorted(c)\n\ncount=0\n#a[i]\u306e\u500b\u6570\nfor i in range(n):\n    a_count = bisect.bisect_left(a, b[i])\n    c_count = bisect.bisect_right(c, b[i])\n    count+=a_count*(len(c)-c_count)\n\nprint(count)\n", "passed": true, "time": 0.17, "memory": 14076.0, "status": "done"}, {"code": "import bisect\nN = int(input())\nlsA = list(map(int,input().split()))\nlsB = list(map(int,input().split()))\nlsC = list(map(int,input().split()))\nlsA.sort()\nlsB.sort()\nlsC.sort()\nans = 0\nfor i in range(N):\n    B = lsB[i]\n    indexA = bisect.bisect(lsA,B-1)\n    indexC = N - bisect.bisect(lsC,B)\n    ans += indexA*indexC\nprint(ans)", "passed": true, "time": 0.33, "memory": 14304.0, "status": "done"}, {"code": "from bisect import bisect,bisect_left\nN=int(input())\nA=sorted(list(map(int,input().split())))\nB=sorted(list(map(int,input().split())))\nC=sorted(list(map(int,input().split())))\nans=0\nfor b in B:\n  i=bisect_left(A,b)\n  j=bisect(C,b)\n  ans+=i*(N-j)\nprint(ans)", "passed": true, "time": 0.14, "memory": 14252.0, "status": "done"}, {"code": "import bisect\n\nn = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort()\nB.sort()\nC.sort()\n\ncnt = 0\nfor b in B:\n    i = bisect.bisect_left(A, b)\n    j = bisect.bisect_right(C, b)\n    cnt += i * (n-j)\n\nprint(cnt)", "passed": true, "time": 0.23, "memory": 14224.0, "status": "done"}, {"code": "def binary_search(lst, t, i):\n    left = -1\n    right = len(lst)\n\n    while abs(right - left) > 1:\n        mid = (left + right) // 2\n        if i == 0:\n            if lst[mid] < t:\n                left = mid\n            else:\n                right = mid\n        elif i == 1:\n            if lst[mid] > t:\n                right = mid\n            else:\n                left = mid\n\n    return left\n\n\ndef main():\n    n = int(input())\n    A = sorted(list(map(int, input().split())))\n    B = sorted(list(map(int, input().split())))\n    C = sorted(list(map(int, input().split())))\n    ans = 0\n\n    for b in B:\n        a = binary_search(A, b, 0)\n        c = binary_search(C, b, 1)\n        ans += (a + 1) * (n - c - 1)\n\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14276.0, "status": "done"}, {"code": "import math\nfrom math import gcd,pi,sqrt\nINF = float(\"inf\")\n\nimport sys\nsys.setrecursionlimit(10**6)\nimport itertools\nfrom collections import Counter,deque\ndef i_input(): return int(input())\ndef i_map(): return list(map(int, input().split()))\ndef i_list(): return list(i_map())\ndef i_row(N): return [i_input() for _ in range(N)]\ndef i_row_list(N): return [i_list() for _ in range(N)]\ndef s_input(): return input()\ndef s_map(): return input().split()\ndef s_list(): return list(s_map())\ndef s_row(N): return [s_input for _ in range(N)]\ndef s_row_str(N): return [s_list() for _ in range(N)]\ndef s_row_list(N): return [list(s_input()) for _ in range(N)]\n\ndef main():\n    n = i_input()\n    a = i_list()\n    b = i_list()\n    c = i_list()\n    a.sort()\n    b.sort()\n    c.sort()\n\n    al = []\n    bl = [0]\n    import bisect\n\n    for k,i in enumerate(b):\n        x = bisect.bisect(c, i)\n        bl.append(bl[k]+(n-x))\n\n    ans = 0\n\n    for i in a:\n        x = bisect.bisect(b,i)\n        ans += bl[-1] - bl[x]\n    print(ans)\n\n\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.16, "memory": 14352.0, "status": "done"}, {"code": "import bisect\n\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\nfor b in B:\n    a = bisect.bisect_left(A,b)\n    c = bisect.bisect_right(C,b)\n    ans += a*(N-c)\n\nprint(ans)", "passed": true, "time": 0.23, "memory": 14328.0, "status": "done"}, {"code": "def bs_left(list, target):\n    low = 0\n    high = len(list)\n\n    while low < high:\n        mid = (low + high) // 2\n        if target > list[mid]:\n            low = mid + 1\n        else:\n            high = mid\n    return low\n\ndef bs_right(list, target):\n    low = 0\n    high = len(list)\n    while low < high:\n        mid = (low + high) // 2\n        if target < list[mid]:\n            high = mid\n        else:\n            low = mid + 1\n    return low\n\nn = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nC.sort()\n\nans = 0\nfor b in B:\n    ans += (bs_left(A, b) * (n - bs_right(C, b)))\nprint(ans)\n\n", "passed": true, "time": 0.14, "memory": 14340.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\na_index = 0\nb_index = 0\nc_index = 0\n\nbc = []\nwhile(b_index < len(b) and c_index < len(c)):\n    if b[b_index] < c[c_index]:\n        bc.append(len(c)-c_index)\n        b_index += 1\n    else:\n        c_index += 1\n    # print(b_index, c_index)\n\nif len(bc) == 0:\n    print((0))\n    return\n\nbc_sum = [bc[-1]]\nfor i in reversed(bc[:-1]):\n    bc_sum.append(i+bc_sum[-1])\nbc_sum = list(reversed(bc_sum))\n\n# print(bc)\n# print(bc_sum)\na_index = 0\nb_index = 0\nc_index = 0\nans = []\nwhile(a_index < len(a) and b_index < len(b) and b_index < len(bc_sum)):\n    if a[a_index] < b[b_index]:\n        # ans.append(sum(bc[b_index:]))\n        ans.append(bc_sum[b_index])\n        a_index += 1\n    else:\n        b_index += 1\n    # print(a_index, b_index)\n\n# print(bc)\nprint((sum(ans)))\n", "passed": true, "time": 0.15, "memory": 14288.0, "status": "done"}, {"code": "n=int(input())\nalist=list(map(int, input().split()))\nblist=list(map(int, input().split()))\nclist=list(map(int, input().split()))\nalist.sort()\nblist.sort()\nclist.sort()\nimport bisect\nans=0\nfor b in blist:\n  num1=n-bisect.bisect(clist,b)\n  num2=bisect.bisect_left(alist,b)\n  ans+=num1*num2\nprint(ans)", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "import bisect\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\n\nfor b in B:\n    a_count = bisect.bisect_left(A, b)\n    c_count = N - bisect.bisect_right(C, b)\n    ans += a_count * c_count\nprint(ans)\n", "passed": true, "time": 0.25, "memory": 14092.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\na_index = 0\nb_index = 0\nc_index = 0\n\nbc = []\nwhile(b_index < len(b) and c_index < len(c)):\n    if b[b_index] < c[c_index]:\n        bc.append(len(c)-c_index)\n        b_index += 1\n    else:\n        c_index += 1\n    # print(b_index, c_index)\n\nif len(bc) == 0:\n    print((0))\n    return\n\nbc_sum = [bc[-1]]\nfor i in reversed(bc[:-1]):\n    bc_sum.append(i+bc_sum[-1])\nbc_sum = list(reversed(bc_sum))\n\nif len(bc_sum) != len(bc):\n    print(bc)\n    print(bc_sum)\n    return\n# print(bc)\n# print(bc_sum)\na_index = 0\nb_index = 0\nc_index = 0\nans = []\nwhile(a_index < len(a) and b_index < len(b) and b_index < len(bc_sum)):\n    if a[a_index] < b[b_index]:\n        # ans.append(sum(bc[b_index:]))\n        ans.append(bc_sum[b_index])\n        a_index += 1\n    else:\n        b_index += 1\n    # print(a_index, b_index)\n\n# print(bc)\nprint((sum(ans)))\n", "passed": true, "time": 0.14, "memory": 14140.0, "status": "done"}, {"code": "#!/usr/bin/env python3\ndef main():\n    from bisect import bisect, bisect_left\n\n    N = int(input())\n    A = sorted([int(x) for x in input().split()])\n    B = [int(x) for x in input().split()]\n    C = sorted([int(x) for x in input().split()])\n\n    print((sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])))\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.22, "memory": 14184.0, "status": "done"}, {"code": "from bisect import bisect_left, bisect_right\n\nn = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\n# print(A)\n# print(B)\n# print(C)\nfor i in range(n):\n    b = B[i]\n    pos_a = bisect_left(A, b)\n    pos_c = bisect_right(C, b)\n    ans += pos_a * (n - pos_c)\n    # print(b, pos_a, pos_c)\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "from bisect import bisect, bisect_left\n\n\ndef bin_search(n):\n\n    a = list(map(int, input().split()))\n    b = list(map(int, input().split()))\n    c = list(map(int, input().split()))\n\n    a.sort()\n    c.sort()\n\n    ans = 0\n\n    for i in range(n):\n        upper_b = bisect_left(a, b[i])\n        under_b = n - bisect(c, b[i])\n        ans += upper_b * under_b\n    return ans\n\n\ndef __starting_point():\n    n = int(input())\n    print((bin_search(n)))\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14116.0, "status": "done"}, {"code": "#\n# abc077 c\n#\nimport sys\nfrom io import StringIO\nimport unittest\nimport bisect\n\n\nclass TestClass(unittest.TestCase):\n    def assertIO(self, input, output):\n        stdout, stdin = sys.stdout, sys.stdin\n        sys.stdout, sys.stdin = StringIO(), StringIO(input)\n        resolve()\n        sys.stdout.seek(0)\n        out = sys.stdout.read()[:-1]\n        sys.stdout, sys.stdin = stdout, stdin\n        self.assertEqual(out, output)\n\n    def test_\u5165\u529b\u4f8b_1(self):\n        input = \"\"\"2\n1 5\n2 4\n3 6\"\"\"\n        output = \"\"\"3\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_2(self):\n        input = \"\"\"3\n1 1 1\n2 2 2\n3 3 3\"\"\"\n        output = \"\"\"27\"\"\"\n        self.assertIO(input, output)\n\n    def test_\u5165\u529b\u4f8b_3(self):\n        input = \"\"\"6\n3 14 159 2 6 53\n58 9 79 323 84 6\n2643 383 2 79 50 288\"\"\"\n        output = \"\"\"87\"\"\"\n        self.assertIO(input, output)\n\n\ndef resolve():\n    N = int(input())\n    A = list(map(int, input().split()))\n    B = list(map(int, input().split()))\n    C = list(map(int, input().split()))\n\n    A.sort()\n    B.sort()\n    C.sort()\n\n    ans = 0\n    for b in B:\n        an = bisect.bisect_left(A, b)\n        cn = N - bisect.bisect_right(C, b)\n        ans += an*cn\n\n    print(ans)\n\n\ndef __starting_point():\n    # unittest.main()\n    resolve()\n\n__starting_point()", "passed": true, "time": 0.16, "memory": 14552.0, "status": "done"}, {"code": "from bisect import bisect\nimport random\n\n\ndef binary_search(L, n, i, j):\n    # print(L, n, i, j)\n    low = i\n    high = j\n\n    while low <= high:\n        mid = (low + high) //2\n        guess = L[mid]\n        # if guess == n:\n            # return mid\n        if guess > n:\n            high = mid -1\n        else:\n            low = mid + 1\n    # print(low)\n    return low\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n# N = 10 ** 5\n# A = [random.randint(1, 10**9) for _ in range(N)]\n# B = [random.randint(1, 10**9) for _ in range(N)]\n# C = [random.randint(1, 10**9) for _ in range(N)]\n\nA.sort()\nB.sort()\nC.sort()\n\nans = 0\ni, j = 0, 0\n\nA_ind = []\nB_cum = [0]\n\nfor a in A:\n    # i = binary_search(B, a, i, N-1)\n    i = bisect(B, a)\n    A_ind.append(i)\n\ns = 0\nfor b in B:\n    # j = binary_search(C, b, j, N-1)\n    j = i = bisect(C, b)\n    s += N-j\n    B_cum.append(s)\n\nfor a in A_ind:\n    ans += B_cum[-1] - B_cum[a]\nprint(ans)\n\n", "passed": true, "time": 0.14, "memory": 14280.0, "status": "done"}, {"code": "# -*- coding: utf-8 -*-\n\ndef get_input() -> tuple:\n    \"\"\"\n    \u6a19\u6e96\u5165\u529b\u3092\u53d6\u5f97\u3059\u308b.\n\n    Returns:\\n\n        tuple: \u6a19\u6e96\u5165\u529b\n    \"\"\"\n    N = int(input())\n    A = list(map(int, input().split()))\n    B = list(map(int, input().split()))\n    C = list(map(int, input().split()))\n\n    return N, A, B, C\n\n\ndef get_lb(l: list, key: int) -> int:\n    \"\"\"\n    l[index] > key\u3068\u306a\u308b\u6700\u5c0f\u306eindex\u3092\u6c42\u3081\u308b.\n\n    Args:\\n\n        l (list): \u30ea\u30b9\u30c8\n        key (int): \u6574\u6570\n\n    Returns:\\n\n        int: l[index] > key\u3068\u306a\u308b\u6700\u5c0f\u306eindex\n    \"\"\"\n    low = -1\n    high = len(l)\n    while 1 < high - low:\n        mid = (low + high) // 2\n        guess = l[mid]\n        if guess > key:\n            high = mid\n        else:\n            low = mid\n    return high\n\n\ndef get_ub(l: list, key: int) -> int:\n    \"\"\"\n    l[index] < key\u3068\u306a\u308b\u6700\u5927\u306eindex\u3092\u6c42\u3081\u308b.\n\n    Args:\\n\n        l (list): \u30ea\u30b9\u30c8\n        key (int): \u6574\u6570\n\n    Returns:\\n\n        int: l[index] < key\u3068\u306a\u308b\u6700\u5927\u306eindex\n    \"\"\"\n    low = -1\n    high = len(l)\n    while 1 < high - low:\n        mid = (low + high) // 2\n        guess = l[mid]\n        if guess < key:\n            low = mid\n        else:\n            high = mid\n    return low\n\n\ndef main(N: int, A: list, B: list, C: list) -> None:\n    \"\"\"\n    \u30e1\u30a4\u30f3\u51e6\u7406.\n\n    Args:\\n\n        N (int): \u30d1\u30fc\u30c4\u306e\u6570(1 <= N <= 10**5)\n        A (list): \u4e0a\u90e8\u306e\u30d1\u30fc\u30c4\u306e\u30b5\u30a4\u30ba(1 <= A_i <= 10**9)\n        B (list): \u4e2d\u90e8\u306e\u30d1\u30fc\u30c4\u306e\u30b5\u30a4\u30ba(1 <= B_i <= 10**9)\n        C (list): \u4e0b\u90e8\u306e\u30d1\u30fc\u30c4\u306e\u30b5\u30a4\u30ba(1 <= C_i <= 10**9)\n    \"\"\"\n    # \u4e8b\u524d\u306b\u30ea\u30b9\u30c8\u3092\u30bd\u30fc\u30c8\u3057\u3066\u304a\u304f\n    A = sorted(A)\n    B = sorted(B)\n    C = sorted(C)\n\n    # \u6c42\u89e3\u51e6\u7406\n    ans = 0\n    for i in range(N):\n        B_i = B[i]\n        ans += (get_ub(A, B_i) + 1) * (N - get_lb(C, B_i))\n\n    # \u7d50\u679c\u51fa\u529b\n    print(ans)\n\n\ndef __starting_point():\n    # \u6a19\u6e96\u5165\u529b\u3092\u53d6\u5f97\n    N, A, B, C = get_input()\n\n    # \u30e1\u30a4\u30f3\u51e6\u7406\n    main(N, A, B, C)\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14340.0, "status": "done"}, {"code": "def solve():\n    def bin_l(arr, key):\n        l = 0\n        r = len(arr) - 1\n        while l <= r:\n            mid = (l + r)//2\n            if arr[mid] > key:\n                r = mid - 1\n            else:\n                l = mid + 1\n            \n        if l < len(arr):\n            return l\n        else:\n            return None\n    \n    def bin_s(arr, key):\n      l = 0\n      r = len(arr) - 1\n      while l <= r:\n        mid = (l + r) // 2\n        if arr[mid] >= key:\n          r = mid - 1\n        else:\n          l = mid + 1\n      \n      if r >= 0 :\n        return r\n      else:\n        return None\n        \n    n = int(input())\n    A = list(map(int,input().split()))\n    B = list(map(int,input().split()))\n    C = list(map(int,input().split()))\n    A = sorted(A)\n    C = sorted(C)\n    \n    sum = 0\n    for b in B:\n        a = bin_s(A, b)\n        c = bin_l(C, b)\n        a = a + 1 if a is not None else None\n        c = n - c if c is not None else None\n        if a is not None and c is not None:\n            sum += a*c\n    \n    print(sum)\n\ndef __starting_point():\n    solve()\n\n__starting_point()", "passed": true, "time": 0.15, "memory": 14192.0, "status": "done"}, {"code": "import bisect\n\nN=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\nans=0\nfor i in range(N):\n    x=bisect.bisect_left(A,B[i])\n    y=N-bisect.bisect_right(C,B[i])\n    ans+=x*y\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14364.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\na_index = 0\nb_index = 0\nc_index = 0\n\nbc = [0]*n\n# bc = []\nwhile(b_index < len(b) and c_index < len(c)):\n    if b[b_index] < c[c_index]:\n        # bc.append(len(c)-c_index)\n        bc[b_index] = len(c)-c_index\n        b_index += 1\n    else:\n        c_index += 1\n    # print(b_index, c_index)\n\nif len(bc) != len(b):\n    return\n\n\nif len(bc) == 0:\n    print((0))\n    return\n\nbc_sum = [bc[-1]]\nfor i in reversed(bc[:-1]):\n    bc_sum.append(i+bc_sum[-1])\nbc_sum = list(reversed(bc_sum))\n\n# print(bc)\n# print(bc_sum)\na_index = 0\nb_index = 0\nc_index = 0\nans = []\nwhile(a_index < len(a) and b_index < len(b) and b_index < len(bc_sum)):\n    if a[a_index] < b[b_index]:\n        # ans.append(sum(bc[b_index:]))\n        ans.append(bc_sum[b_index])\n        a_index += 1\n    else:\n        b_index += 1\n    # print(a_index, b_index)\n\n# print(bc)\nprint((sum(ans)))\n", "passed": true, "time": 0.15, "memory": 14092.0, "status": "done"}, {"code": "from bisect import bisect_left\nfrom itertools import accumulate\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nbs = [0]*N\nfor i in range(N):\n    b = B[i]\n    ai = bisect_left(A, b)\n    bs[i] = ai\nbs = [0]+list(accumulate(bs, lambda x,y:x+y))\nans = 0\nfor i in range(N):\n    c = C[i]\n    bi = bisect_left(B, c)\n    ans += bs[bi]\nprint(ans)", "passed": true, "time": 0.32, "memory": 14088.0, "status": "done"}, {"code": "from bisect import bisect, bisect_left\n\nN = int(input())\nA, B, C = (sorted(map(int, input().split())) for _ in range(3))\n\nans = 0\nfor b in B:\n  ans += bisect_left(A, b) * (N - bisect(C, b))\n\nprint(ans)", "passed": true, "time": 0.36, "memory": 14164.0, "status": "done"}, {"code": "n=int(input())\nA=list(map(int,input().split()))\nB=list(map(int,input().split()))\nC=list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nimport bisect as bi\nans=0\nfor i in range(n):\n    q=B[i]\n    oka= bi.bisect_left(A,q)\n    okb= n- bi.bisect_right(C,q)\n    ans+=oka*okb\nprint(ans)", "passed": true, "time": 0.24, "memory": 14204.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\n\n#\u30ea\u30b9\u30c8\u3092\u30bd\u30fc\u30c8\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\n# x\u4ee5\u4e0a\u306e\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\ndef lower_bound(arr , x):\n    l = 0\n    r = len(c)\n    for j in range(30):\n        mid = (l + r) // 2\n        # print(l , r , mid)\n        if x <= arr[mid]:\n            r = mid\n        else:\n            l = mid\n    return r\n\n\ncount = 0\nfor i in range(n):\n    a_count = lower_bound(a , b[i])\n    c_count = len(c) - lower_bound(c , b[i] + 1)\n    count += a_count * c_count\n\nprint(count)\n", "passed": true, "time": 0.2, "memory": 14268.0, "status": "done"}, {"code": "N = int(input())\nA = sorted(list(map(int,input().split())))\nB = sorted(list(map(int,input().split())))\nC = sorted(list(map(int,input().split())))\nans = 0\nimport bisect\nb = []\nfor i in B:\n    x = bisect.bisect_right(C,i)\n    b.append(N-x)\ny = sum(b)\nc = [y]\nfor i in range(1,N):\n    y -= b[i-1]\n    c.append(y)\nc.append(0)\nfor i in A:\n    a = bisect.bisect_right(B,i)\n    ans += c[a]\nprint(ans)", "passed": true, "time": 0.15, "memory": 14252.0, "status": "done"}, {"code": "def lb(k, a):\n    n = len(a)\n    l, u = 0, n\n    while l < u:\n        m = (l + u) // 2\n        if k < a[m]:\n            u = m\n        else:\n            l = m + 1\n    return l\n\ndef ub(k, a):\n    n = len(a)\n    l, u = -1, n - 1\n    while l < u:\n        m = (l + u + 1) // 2\n        if a[m] < k:\n            l = m\n        else:\n            u = m - 1\n    return l\n\nN = int(input())\nA = sorted([int(x) for x in input().split()])\nB = sorted([int(x) for x in input().split()])\nC = sorted([int(x) for x in input().split()])\n\nres = 0\nfor i in range(N):\n    j = ub(B[i], A)\n    k = lb(B[i], C)\n    res += (j + 1)*(N - k)\n\nprint(res)", "passed": true, "time": 0.14, "memory": 14112.0, "status": "done"}, {"code": "import copy\nimport math\nimport time\nimport statistics\nimport math\nimport itertools\nimport bisect\n\n# a = get_int()\ndef get_int():\n    return int(input())\n# a = get_string()\ndef get_string():\n    return input()\n# a_list = get_int_list()\ndef get_int_list():\n    return [int(x) for x in input().split()]\n# a_list = get_string_list():\ndef get_string_list():\n    return input().split()\n# a, b = get_int_multi()\ndef get_int_multi():\n    return list(map(int, input().split()))\n# a_list = get_string_char_list()\ndef get_string_char_list():\n    return list(str(input()))\n# print(\"{} {}\".format(a, b))\n# for num in range(0, a):\n# a_list[idx]\n# a_list = [0] * a\n'''\nwhile (idx < n) and ():\n\n    idx += 1\n'''\n\ndef main():\n    start = time.time()\n    n = get_int()\n\n    a_list = get_int_list()\n    b_list = get_int_list()\n    c_list = get_int_list()\n\n    a_list.sort()\n    b_list.sort()\n    c_list.sort()\n\n    a_count = []\n    b_count = []\n    b_count2 = []\n\n    idx = 0\n    for a in a_list:\n        idx = bisect.bisect_right(b_list, a, idx)\n        a_count.append(idx)\n\n    idx = 0\n    for b in b_list:\n        idx = bisect.bisect_right(c_list, b, idx)\n        b_count.append(idx)\n\n    ruikei = 0\n    for i in range(n-1, -1, -1):\n        ruikei += n - b_count[i]\n        b_count2.append(ruikei)\n\n    b_count2.sort(reverse=True)\n\n    ans = 0\n    for a in a_count:\n        if a == n:\n            continue\n        ans += b_count2[a]\n\n    print(ans)\n    #print(time.time() - start)\n\ndef __starting_point():\n    main()\n\n\n\n__starting_point()", "passed": true, "time": 0.22, "memory": 14648.0, "status": "done"}, {"code": "from bisect import bisect,bisect_left\nN=int(input())\nA=sorted(list(map(int,input().split())))\nB=sorted(list(map(int,input().split())))\nC=sorted(list(map(int,input().split())))\nans=0\nfor b in B:\n  i=bisect_left(A,b)\n  j=bisect(C,b)\n  ans+=i*(N-j)\nprint(ans)", "passed": true, "time": 0.2, "memory": 14320.0, "status": "done"}, {"code": "#!/usr/bin/env python3\nimport sys\nsys.setrecursionlimit(10**6)\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nb.sort()\nc.sort()\n\na_index = 0\nb_index = 0\nc_index = 0\n\nbc = [0]*n\n# bc = []\nwhile(b_index < len(b) and c_index < len(c)):\n    if b[b_index] < c[c_index]:\n        # bc.append(len(c)-c_index)\n        bc[b_index] = len(c)-c_index\n        b_index += 1\n    else:\n        c_index += 1\n    # print(b_index, c_index)\n\nif len(bc) != len(b):\n    return\n\n\nif len(bc) == 0:\n    print((0))\n    return\n\nbc_sum = [bc[-1]]\nfor i in reversed(bc[:-1]):\n    bc_sum.append(i+bc_sum[-1])\nbc_sum = list(reversed(bc_sum))\n\n# print(bc)\n# print(bc_sum)\na_index = 0\nb_index = 0\nc_index = 0\nans = []\nwhile(a_index < len(a) and b_index < len(b)):\n    if a[a_index] < b[b_index]:\n        # ans.append(sum(bc[b_index:]))\n        ans.append(bc_sum[b_index])\n        a_index += 1\n    else:\n        b_index += 1\n    # print(a_index, b_index)\n\n# print(bc)\nprint((sum(ans)))\n", "passed": true, "time": 0.24, "memory": 14148.0, "status": "done"}, {"code": "import bisect\n \nn = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\nans = 0\n \nfor b in B:\n    a = bisect.bisect_left(A, b)\n    c = bisect.bisect_right(C, b)\n    ans += a*(n-c)\n \nprint(ans)", "passed": true, "time": 0.15, "memory": 14128.0, "status": "done"}, {"code": "import bisect\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\nA.sort()\nB.sort()\nC.sort()\n\npat = 0\n\nfor i in B:\n    numA = bisect.bisect_left(A,i)\n    numC = bisect.bisect(C,i)\n    pat += numA * (len(C)-numC)\n\nprint(pat)", "passed": true, "time": 0.14, "memory": 14044.0, "status": "done"}, {"code": "def II(): return int(input())\ndef LII(): return list(map(int, input().split()))\n\nn=II()\nalist=LII()\nblist=LII()\nclist=LII()\n\nalist.sort()\nblist.sort()\nclist.sort()\n\n#\u3042\u308bb\u3088\u308a\u5c0f\u3055\u3044a\u306e\u6570\ndef count_a(b):\n    ok,ng = -1,n\n    def is_ok(i):\n        return alist[i]<b\n    while abs(ok-ng)>1:\n        mid = (ok+ng)//2\n        if is_ok(mid):\n            ok = mid\n        else:\n            ng = mid\n    return ok+1\n\ndef count_c(b):\n    ok,ng = n,-1\n    def is_ok(i):\n        return clist[i]>b\n    while abs(ok-ng)>1:\n        mid = (ok+ng)//2\n        if is_ok(mid):\n            ok = mid\n        else:\n            ng = mid\n    return n-ok\n\nresult=0\nfor b in blist:\n    result += count_a(b) * count_c(b)\n\nprint(result)", "passed": true, "time": 0.21, "memory": 14216.0, "status": "done"}, {"code": "import bisect\n\n_ = input()\nA = [int(i) for i in input().split()]\nB = [int(i) for i in input().split()]\nC = [int(i) for i in input().split()]\n\nA.sort()\nC.sort()\n\nans = 0\nfor b in B:\n    a = bisect.bisect_left(A, b)\n    c = len(C) - bisect.bisect_right(C, b)\n    ans += a * c\nelse:\n    print(ans)", "passed": true, "time": 0.14, "memory": 14068.0, "status": "done"}, {"code": "n = int(input())\na = sorted(list(map(int,input().split())))\nb = sorted(list(map(int,input().split())))\nc = sorted(list(map(int,input().split())))\nbl = [0]*n\nblli = [0]*n\nal = [0]*n\nalli = [0]*n\nimport bisect\n\nfor i in range(n):\n    bl[i]=n-bisect.bisect(c,b[i])\n\nblli[0] = sum(bl)\nfor i in range(n-1):\n    blli[i+1] = blli[i]-bl[i]\n   \nfor i in range(n):\n    al[i]=n-bisect.bisect(b,a[i])\n\nfor i in range(n):\n    if al[i]!=0:\n        alli[i] = blli[-al[i]]\n\nprint(sum(alli))", "passed": true, "time": 0.14, "memory": 14188.0, "status": "done"}, {"code": "import bisect\nn = int(input())\na, b, c = map(list, [sorted(list(map(int, input().split()))) for i in range(3)])\nans = 0\nfor i in range(n):\n    ans += bisect.bisect_left(a, b[i]) * (n - bisect.bisect_right(c, b[i]))\nprint(ans)", "passed": true, "time": 0.15, "memory": 14080.0, "status": "done"}, {"code": "# coding:UTF-8\nimport sys\nfrom math import factorial\n\nMOD = 10 ** 9 + 7\nINF = 10000000000\n\ndef binary_search_section(list, min, max):\n    low = 0\n    high = len(list) - 1\n    upper = len(list)\n    lower = -1\n    while low <= high:\n        mid = (low + high) // 2\n        guess = list[mid]\n        if guess >= min:\n            high = mid - 1\n        else:\n            low = mid + 1\n            lower = mid\n    low = 0\n    high = len(list) - 1\n    while low <= high:\n        mid = (low + high) // 2\n        guess = list[mid]\n        if guess > max:\n            high = mid - 1\n            upper = mid\n        else:\n            low = mid + 1\n\n    return [lower, upper]\n\ndef main():\n    # ------ \u5165\u529b ------#\n    # 1\u884c\u5165\u529b\n    n = int(input())    # \u6570\u5b57\n    aList = list(map(int, input().split()))     # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n    bList = list(map(int, input().split()))     # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n    cList = list(map(int, input().split()))     # \u30b9\u30da\u30fc\u30b9\u533a\u5207\u308a\u9023\u7d9a\u6570\u5b57\n\n    # ------ \u51e6\u7406 ------#\n    aListSorted = sorted(aList)\n    bListSorted = sorted(bList)\n    cListSorted = sorted(cList)\n\n    result = 0\n    # for a in aListSorted:\n    #     sec = binary_search_section(bListSorted, a+1, bListSorted[-1])\n    #     for j in range(sec[0]+1, len(bListSorted)):\n    #         b = bListSorted[j]\n    #         sec2 = binary_search_section(cListSorted, b+1, cListSorted[-1])\n    #         result += len(cListSorted) - (sec2[0] + 1)\n    for b in bListSorted:\n        sec = binary_search_section(aListSorted, aListSorted[0], b-1)\n        sec2 = binary_search_section(cListSorted, b+1, cListSorted[-1])\n        result += (sec[1] - sec[0] - 1)*(sec2[1] - sec2[0] - 1)\n\n    # ------ \u51fa\u529b ------#\n    print((\"{}\".format(result)))\n    # if flg == 0:\n    #     print(\"YES\")\n    # else:\n    #     print(\"NO\")\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14320.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int, input().split()))\nb=list(map(int, input().split()))\nc=list(map(int, input().split()))\na=sorted(a)\nc=sorted(c)\nans=0\nimport bisect\nfor i in b:\n  t=bisect.bisect_left(a, i)\n  q=bisect.bisect_right(c, i)\n  ans+=t*(n-q)\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14152.0, "status": "done"}, {"code": "import bisect\nn=int(input())\na=sorted(list(map(int,input().split())))\nb=sorted(list(map(int,input().split())))\nc=sorted(list(map(int,input().split())))\nans=0\nfor i in b:\n    A=bisect.bisect_left(a,i)\n    B=len(b)-bisect.bisect_right(c,i)\n    ans+=A*B\nprint(ans)", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort()\nB.sort()\nC.sort()\n\ndef bin_serch(array,num):\n    head = 0\n    tail = len(array)\n    while head < tail:\n        center = (head + tail) // 2\n        if num < array[center]:\n            tail = center\n        else:\n            head = center + 1\n    return head\n\nBC = [0 for _ in range(len(B))]\nfor i in range(len(B)):\n    BC[i] = len(C) - bin_serch(C,B[i])\n    \ns = 0\nfor i in range(len(BC)-1, -1, -1):\n    s += BC[i]\n    BC[i] = s\n\nans = 0\nfor a in A:\n    b = bin_serch(B,a)\n    if b < len(B):\n        ans += BC[b]\n    \nprint(ans)", "passed": true, "time": 0.14, "memory": 14380.0, "status": "done"}, {"code": "import bisect\n\nn = int(input())\nal = sorted(list(map(int, input().split())))\nbl = sorted(list(map(int, input().split())))\ncl = sorted(list(map(int, input().split())))\nans = 0\n\nfor b in bl:\n    i = bisect.bisect_left(al, b)\n    j = bisect.bisect_right(cl, b)\n    ans += i*(n-j)\n\nprint(ans)", "passed": true, "time": 0.22, "memory": 14220.0, "status": "done"}, {"code": "import bisect\n\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\ncnt = 0\n\nfor b in B:\n    a = bisect.bisect_left(A,b)\n    c = bisect.bisect_right(C,b)\n    cnt += a * (len(C)-c)\n\nprint(cnt)", "passed": true, "time": 0.14, "memory": 14328.0, "status": "done"}, {"code": "import bisect\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\na.sort()\nb.sort()\nc.sort()\nans = 0\nfor i in b:\n  p = bisect.bisect_left(a, i)\n  q = bisect.bisect_right(c, i)\n  ans += (p*(n-q))\n  \nprint(ans)", "passed": true, "time": 0.2, "memory": 14368.0, "status": "done"}, {"code": "from bisect import bisect, bisect_left\n\nN = int(input())\nA = sorted(map(int, input().split()))\nB = sorted(map(int, input().split()))\nC = sorted(map(int, input().split()))\n\nC_accum = [0]\nfor b in B:\n  C_accum.append(C_accum[-1] + N - bisect(C, b))\n\nans = 0\nfor a in A:\n  i = bisect(B, a)\n  ans += C_accum[-1] - C_accum[i]\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "import bisect\n\nN=int(input())\nA = sorted(list(map(int,input().split())))\nB = sorted(list(map(int,input().split())))\nC = sorted(list(map(int,input().split())))\n\ncount=0\nfor i in range(N):\n    a_cand = bisect.bisect_right(A,B[i]-1)\n    c_cand = N-bisect.bisect_right(C,B[i])\n    count += a_cand*c_cand\nprint(count)\n", "passed": true, "time": 0.2, "memory": 14268.0, "status": "done"}, {"code": "import bisect\nn=int(input())\na = list(map(int, input(\"\").split()))\nb = list(map(int, input(\"\").split()))\nc = list(map(int, input(\"\").split()))\nout=0\na.sort()\nb.sort()\nc.sort()\nfor i in b:\n    na = bisect.bisect_left(a,i)\n    nc = bisect.bisect(c,i)\n    out += na * (len(c)-nc)\nprint(out)", "passed": true, "time": 0.14, "memory": 14124.0, "status": "done"}, {"code": "import sys\nread = sys.stdin.read\n#readlines = sys.stdin.readlines\nfrom bisect import bisect, bisect_left\nfrom itertools import accumulate\ndef main():\n    data = list(map(int, read().split()))\n    n = data[0]\n    a = data[1:n + 1]\n    b = data[n + 1: n * 2 + 1]\n    c = data[n * 2 + 1:]\n    a.sort()\n    b.sort()\n    c.sort()\n    b2 = [bisect_left(a, be) for be in b]\n    b2a = list(accumulate(b2))\n    b2a = [0] + b2a\n    ans = sum([b2a[bisect_left(b, ce)] for ce in c])\n    print(ans)\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.15, "memory": 14308.0, "status": "done"}, {"code": "import bisect\nn = int(input())\nX = sorted(list(map(int,input().split())))\nY = sorted(list(map(int,input().split())))\nZ = sorted(list(map(int,input().split())))\nprint(sum(bisect.bisect_left(X,b) * (n-bisect.bisect_right(Z,b)) for b in Y))", "passed": true, "time": 0.17, "memory": 14300.0, "status": "done"}, {"code": "import bisect\nn = int(input())\na = sorted(list(map(int, input().split())))\nb = sorted(list(map(int, input().split())))\nc = sorted(list(map(int, input().split())))\nans = 0\nfor i in range(n):\n    aa = bisect.bisect_left(a,b[i])\n    ca = n-bisect.bisect_right(c,b[i])\n    ans += aa * ca\nprint(ans)\n", "passed": true, "time": 0.15, "memory": 14124.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nB.sort()\nC.sort()\nimport bisect\n\nans = 0\n\nfor i in range(N):\n    b = B[i]\n    a_idx = bisect.bisect_left(A, b)\n    # print(b_idx)\n    if a_idx == 0: continue\n    c_idx = bisect.bisect_right(C, b)\n    c_cnt = N - c_idx\n    ans += a_idx * c_cnt\nprint(ans)\n", "passed": true, "time": 0.38, "memory": 14244.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nA_cnt = [1] * N\nA_sum = [i+1 for i in range(N)]\nA_sum.append(0)\nB_cnt = [0] * N\nB_sum = [0] * N\nC_cnt = [0] * N\nC_sum = [0] * N\n\nfor i in range(N):\n    key = B[i]\n    ok = -1\n    ng = N\n    while abs(ok - ng) > 1:\n        mid = (ok + ng) // 2\n        if A[mid] < key:\n            ok = mid\n        else:\n            ng = mid\n    B_cnt[i] = A_sum[ok]\n\nB_sum[0] = B_cnt[0]\nfor i in range(1, N):\n    B_sum[i] = B_sum[i-1] + B_cnt[i]\nB_sum.append(0)\n\nfor i in range(N):\n    key = C[i]\n    ok = -1\n    ng = N\n    while abs(ok - ng) > 1:\n        mid = (ok + ng) // 2\n        if B[mid] < key:\n            ok = mid\n        else:\n            ng = mid\n    C_cnt[i] = B_sum[ok]\n\nC_sum[0] = C_cnt[0]\nfor i in range(1, N):\n    C_sum[i] = C_sum[i-1] + C_cnt[i]\n\nprint((C_sum[-1]))\n\n# print(A)\n# print(B)\n# print(C)\n# print(A_cnt)\n# print(B_cnt)\n# print(C_cnt)\n# print(A_sum)\n# print(B_sum)\n# print(C_sum)\n", "passed": true, "time": 0.2, "memory": 14204.0, "status": "done"}, {"code": "n = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\n\n#\u30ea\u30b9\u30c8\u3092\u30bd\u30fc\u30c8\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\n\n# x\u4ee5\u4e0a\u306e\u30a4\u30c6\u30ec\u30fc\u30bf\u3092\ndef lower_bound(arr , x):\n    l = 0\n    r = len(c)\n    for j in range(30):\n        mid = (l + r) // 2\n        # print(l , r , mid)\n        if x <= arr[mid]:\n            r = mid\n        else:\n            l = mid\n    return r\n\n\ncount = 0\nfor i in range(n):\n    a_count = lower_bound(a , b[i])\n    c_count = len(c) - lower_bound(c , b[i] + 1)\n    count += a_count * c_count\n\nprint(count)\n", "passed": true, "time": 0.22, "memory": 14344.0, "status": "done"}, {"code": "from bisect import bisect_right\nfrom itertools import accumulate\n\n\nN = int(input())\nA = sorted(map(int, input().split()))\nB = sorted(map(int, input().split()))\nC = sorted(map(int, input().split()))\n\nB_to_C = [0] * (N + 1)\nfor i in range(N):\n    idx = bisect_right(C, B[i])\n    B_to_C[i + 1] = N - idx\nB_to_C = list(accumulate(B_to_C))\n\nans = 0\nfor i in range(N):\n    idx = bisect_right(B, A[i])\n    ans += B_to_C[N] - B_to_C[idx]\nprint(ans)\n", "passed": true, "time": 0.22, "memory": 14168.0, "status": "done"}, {"code": "def bin_l(arr, key):\n    l = 0\n    r = len(arr) - 1\n    while l <= r:\n        mid = (l + r)//2\n        if arr[mid] > key:\n            r = mid - 1\n        else:\n            l = mid + 1\n        \n    if l < len(arr):\n        return l\n    else:\n        return None\n\ndef bin_s(arr, key):\n  l = 0\n  r = len(arr) - 1\n  while l <= r:\n    mid = (l + r) // 2\n    if arr[mid] >= key:\n      r = mid - 1\n    else:\n      l = mid + 1\n  \n  if r >= 0 :\n    return r\n  else:\n    return None\n    \nn = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA = sorted(A)\nC = sorted(C)\n\nsum = 0\nfor b in B:\n    a = bin_s(A, b)\n    c = bin_l(C, b)\n    a = a + 1 if a is not None else None\n    c = n - c if c is not None else None\n    if a is not None and c is not None:\n        sum += a*c\n\nprint(sum)", "passed": true, "time": 0.14, "memory": 14388.0, "status": "done"}, {"code": "import bisect\nn=int(input())\na,b,c=map(list,[sorted(list(map(int, input().split()))) for i in range(3)])\nans=0\nfor i in range(n):\n    ans+=bisect.bisect_left(a,b[i])*(n-bisect.bisect_right(c,b[i]))\nprint(ans)", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "import bisect\nN = int(input())\ntop = list(map(int,input().split()))\nmiddle = list(map(int,input().split()))\t\nbottom = list(map(int,input().split()))\t\n\ntop.sort()\nmiddle.sort()\nbottom.sort()\n\nans = 0\nfor i in middle:\n  can_put_upstair = bisect.bisect_left(top,i)\n  can_put_downstair = N - bisect.bisect_right(bottom,i)\n  #print(can_put_upstair,can_put_downstair)\n  ans += can_put_upstair*can_put_downstair\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "import bisect\n \nN=int(input())\nb1=0\nd=0\n\nans=0\n \nA=list(map(int, input().split()))\nA=sorted(A)\nB=list(map(int, input().split()))\nB=sorted(B, reverse=True)\nC=list(map(int, input().split()))\nC=sorted(C)\nD=[]\nE=[]\n\nfor b in B:\n  d=d+len(C)-bisect.bisect_right(C,b)\n  D.append(d)\n\nD=sorted(D, reverse= True)  \nB=sorted(B)\n\nfor a in A:\n  if 0 <= bisect.bisect_right(B,a) <= len(D)-1:\n    ans += D[bisect.bisect_right(B,a)]\nprint(ans)", "passed": true, "time": 0.14, "memory": 14092.0, "status": "done"}, {"code": "def isOK(index, key, in_ls):\n    if key<in_ls[index]: return True\n    else: return False\n\ndef bs(in_ls, key):\n    ng = -1\n    ok = len(in_ls)\n    while 1<abs(ok - ng):\n        mid = (ng + ok)//2\n        if isOK(mid, key, in_ls): ok = mid\n        else: ng = mid\n    return ok\n\ndef main():\n    n = int(input())\n    a_list = list(map(int, input().split(\" \")))\n    b_list = list(map(int, input().split(\" \")))\n    c_list = list(map(int, input().split(\" \")))\n    #a < b < c\n\n    a_sorted = list(sorted(a_list))\n    b_sorted = list(sorted(b_list))\n    c_sorted = list(sorted(c_list))\n\n    bc_dict = {}\n    score = 0\n    score_list = [0 for i in range(n)]\n    for i, b in enumerate(b_sorted[::-1]):\n        ok = bs(c_sorted, b)\n        score+=n - ok\n        score_list[n-i-1]+=score\n\n    total = 0\n    for a in a_sorted:\n        ok = bs(b_sorted, a)\n        if ok==n:\n            continue\n        total+=score_list[ok]\n\n    print(total)\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14336.0, "status": "done"}, {"code": "N = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\nA.sort()\nB.sort()\nC.sort()\n\nimport bisect\nAs = list(range(N+1))\n\nBs = [0] * N\ns = 0\nfor i,b in enumerate(B):\n    ind = bisect.bisect_left(A,b)\n    s += As[ind]\n    Bs[i] = s\nBs = [0] + Bs\nCs = [0] * N\nans = 0\nfor i,c in enumerate(C):\n    ind = bisect.bisect_left(B,c)\n    ans += Bs[ind]\n\nprint(ans)\n\n", "passed": true, "time": 0.23, "memory": 14252.0, "status": "done"}, {"code": "def bin_src_l(arr, key):\n  l = 0\n  r = len(arr) - 1\n  while l <= r:\n    mid = (l + r) // 2\n    if arr[mid] > key:\n      r = mid - 1\n    else:\n      l = mid + 1\n  \n  if l < len(arr):\n    return l\n  else:\n    return None\n\ndef bin_src_s(arr, key):\n  l = 0\n  r = len(arr) - 1\n  while l <= r:\n    mid = (l + r) // 2\n    if arr[mid] >= key:\n      r = mid - 1\n    else:\n      l = mid + 1\n  \n  if r >= 0 :\n    return r\n  else:\n    return None\n\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\nA = sorted(A)\nC = sorted(C)\n\nsum = 0\nfor b in B:\n  a = bin_src_s(A, b)\n  c = bin_src_l(C, b)\n  a = a + 1 if a is not None else None\n  c = N - c if c is not None else None\n  if a is not None and c is not None:\n    sum += a * c\n  \nprint(sum)", "passed": true, "time": 0.14, "memory": 14332.0, "status": "done"}, {"code": "import bisect\nimport sys\n\nN = int(input())\nA = list(map(int, sys.stdin.readline().rstrip().split()))\nB = list(map(int, sys.stdin.readline().rstrip().split()))\nC = list(map(int, sys.stdin.readline().rstrip().split()))\n\nA.sort()\nC.sort()\n\nans = 0\nfor b in B:\n    cnt1 = bisect.bisect_left(A, b)\n    cnt2 = len(C) - bisect.bisect(C, b)\n\n    ans += cnt1 * cnt2\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14360.0, "status": "done"}, {"code": "def abc077c_snuke_festival():\n    import bisect\n    n = int(input())\n    a = sorted(list(map(int, input().split())))\n    b = sorted(list(map(int, input().split())))\n    c = sorted(list(map(int, input().split())))\n    total = 0\n    for i in range(n):\n        b_size = b[i]\n        j = bisect.bisect_left(a, b_size)\n        j = n - j\n        k = bisect.bisect_right(c, b_size)\n\n        total += (n - j) * (n - k)\n    print(total)\n\n\nabc077c_snuke_festival()", "passed": true, "time": 0.14, "memory": 14180.0, "status": "done"}, {"code": "N = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nA.append(float(\"INF\"))\nAB = [0] * (N+1)\nj = 0\nfor i in range(N):\n    while A[j] < B[i]:\n        j += 1\n        if j == N:\n            break\n    AB[i+1] = AB[i] + j\n\nans = 0\nB.append(float(\"INF\"))\nj = 0\nfor i in range(N):\n    while B[j] < C[i]:\n        j += 1\n        if j == N:\n            break\n    ans += AB[j]\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14280.0, "status": "done"}, {"code": "import bisect\n\nimport sys\nstdin=sys.stdin\n\nip=lambda: int(sp())\nfp=lambda: float(sp())\nlp=lambda:list(map(int,stdin.readline().split()))\nsp=lambda:stdin.readline().rstrip()\nyp=lambda:print('Yes')\nnp=lambda:print('No')\n\nn=ip()\na=lp()\nb=lp()\nc=lp()\n\na.sort()\nb.sort()\nc.sort()\nans=0\n\nfor i in range(n):\n  x=bisect.bisect_left(a,b[i])\n  y=bisect.bisect_right(c,b[i])\n  ans+=x*(n-y)\n  \nprint(ans)\n\n\n", "passed": true, "time": 0.14, "memory": 14120.0, "status": "done"}, {"code": "def main():\n    import bisect\n\n    N = int(input())\n    upper = list(map(int, input().split()))\n    middle = list(map(int, input().split()))\n    lower = list(map(int, input().split()))\n\n    upper.sort()\n    middle.sort()\n    lower.sort()\n\n    cnt = 0\n\n    for i in range(N):\n        mid = middle[i]\n        index_up = bisect.bisect_left(upper, mid)\n        index_low = bisect.bisect_right(lower, mid)\n        \n        cnt += index_up * (N - index_low)\n    \n    print(cnt)\n\n\ndef __starting_point():\n    main()\n__starting_point()", "passed": true, "time": 0.14, "memory": 14100.0, "status": "done"}, {"code": "#!/usr/bin/env python3\ndef main():\n    from bisect import bisect\n\n    N = int(input())\n    A = sorted([int(x) for x in input().split()])\n    B = sorted([int(x) for x in input().split()])\n    C = sorted([int(x) for x in input().split()])\n\n    lst = [N - bisect(C, b) for b in B]\n    lst = lst[::-1]\n    tmp_lst = [lst[0]]\n    for i in lst[1:]:\n        tmp_lst.append(i + tmp_lst[-1])\n    tmp_lst = tmp_lst[::-1]\n\n    ans = 0\n    for a in A:\n        res = bisect(B, a)\n        ans += tmp_lst[res] if res < N else 0\n    print(ans)\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14312.0, "status": "done"}, {"code": "#!/usr/bin/env python3\ndef main():\n    from bisect import bisect, bisect_left\n\n    N = int(input())\n    A = sorted([int(x) for x in input().split()])\n    B = sorted([int(x) for x in input().split()])\n    C = sorted([int(x) for x in input().split()])\n\n    print((sum([bisect_left(A, b) * (N - bisect(C, b)) for b in B])))\n\n\ndef __starting_point():\n    main()\n\n__starting_point()", "passed": true, "time": 0.14, "memory": 14212.0, "status": "done"}, {"code": "n = int(input())\nA_list = list(map(int, input().split()))\nB_list = list(map(int, input().split()))\nC_list = list(map(int, input().split()))\nA_list = sorted(A_list)\nB_list = sorted(B_list)\nC_list = sorted(C_list)\ncnt = 0\n\ndef is_ok(arg): #\u3000B\u3000\u3088\u308a\u5c0f\u3055\u3044\u6700\u5927\u306e\u3000A\n    return A_list[arg] < B_list[i]\n\ndef bisect(ng, ok):\n    while (abs(ok - ng) > 1):\n        mid = (ok + ng) // 2\n        if is_ok(mid):\n            ok = mid\n        else:\n            ng = mid\n    return ok\n\ndef is_ok2(arg): #\u3000B\u3000\u3088\u308a\u5927\u304d\u3044\u6700\u5c0f\u306e\u3000A\n    return C_list[arg] > B_list[i]\n\ndef bisect2(ng, ok):\n    while (abs(ok - ng) > 1):\n        mid = (ok + ng) // 2\n        if is_ok2(mid):\n            ok = mid\n        else:\n            ng = mid\n    return ok\n\nfor i in range(n): #B\u3092\u56fa\u5b9a\n    #B\u3088\u308a\u5c0f\u3055\u3044A\u3092\u63a2\u3059\n    A_key = bisect(len(A_list), 0)\n    if A_list[A_key] < B_list[i]:\n        #B\u3088\u308a\u5927\u304d\u3044C\u3092\u63a2\u3059\n        C_key = bisect2(-1, len(C_list)-1)\n        if B_list[i] < C_list[C_key]:\n            #print(A_key, i, C_key, A_list[A_key], B_list[i], C_list[C_key])\n            cnt += (n-C_key)*(A_key+1)\n\nprint(cnt)\n", "passed": true, "time": 0.14, "memory": 14408.0, "status": "done"}, {"code": "import bisect\n\nn = int(input())\na = sorted(list(map(int, input().split())))\nb = sorted(list(map(int, input().split())))\nc = sorted(list(map(int, input().split())))\nans = 0\nfor i in b:\n    an = bisect.bisect_left(a, i)\n    cn = n - bisect.bisect_right(c, i)\n    ans += an * cn\n\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14112.0, "status": "done"}, {"code": "import bisect\nN = int(input())\nA = list(map(int,input().split()))\nB = list(map(int,input().split()))\nC = list(map(int,input().split()))\n\nA = sorted(A)\nB = sorted(B)\nC = sorted(C)\n#print(A,B,C)\nCount_A = [0]*N\nCount_C = [0]*N\nfor i in range(N):\n  # A Count\n  Count_A[i] = bisect.bisect_left(A,B[i])\n  # C Count\n  Count_C[i] = N-bisect.bisect(C,B[i])\n#print(Count_A,Count_C)\nPatterns = 0\nfor i in range(N):\n  Patterns=Patterns+Count_A[i]*Count_C[i]\n  \nprint(Patterns)", "passed": true, "time": 0.14, "memory": 14216.0, "status": "done"}, {"code": "N = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\ndef binary1(L, R, list_, threshold):\n    while L + 1 < R:\n        x = (L + R)//2\n        if list_[x] < threshold:\n            L = x            \n        else:\n            R = x\n    return L\n\ndef binary2(L, R, list_, threshold):\n    while L + 1 < R:\n        x = (L + R)//2\n        if list_[x] > threshold:\n            R = x            \n        else:\n            L = x\n    return L\n\nans = []\nfor b in B:\n    L = -1\n    R = N\n    a = binary1(L, R, A, b) + 1\n    c = N - binary2(L, R, C, b) - 1\n    ans.append(a*c)\nprint((sum(ans)))\n", "passed": true, "time": 0.23, "memory": 14156.0, "status": "done"}, {"code": "import bisect\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nans=0\nfor b in B:\n    a_index = bisect.bisect_left(A, b)\n    c_index = bisect.bisect_right(C, b)\n    ans += a_index * (N-c_index)\n    \nprint(ans)", "passed": true, "time": 0.14, "memory": 14268.0, "status": "done"}, {"code": "import bisect\nn = int(input())\nA = sorted(list(map(int, input().split())))\nB = list(map(int, input().split()))\nC = sorted(list(map(int, input().split())))\n\ncnt = 0\nfor b in B:\n    i = bisect.bisect_left(A, b)\n    j = n-bisect.bisect_right(C, b)\n    cnt += i*j\n\nprint(cnt)\n", "passed": true, "time": 0.14, "memory": 14220.0, "status": "done"}, {"code": "import bisect\nimport itertools\n\nN = int(input()) # \u305d\u308c\u305e\u308c\u306e\u30d1\u30fc\u30c4\u306e\u6570\nA = list(map(int, input().split())) # \u5c0f\u3055\u3044\nB = list(map(int, input().split())) # \u4e2d\u304f\u3089\u3044\nC = list(map(int, input().split())) # \u5927\u304d\u3044\n\n# C\u306f\u4e26\u3073\u66ff\u3048\u4e0d\u8981\nA.sort()\nB.sort()\n\n# B\u306e\u5404\u8981\u7d20\u3067A\u3092\u4e8c\u5206\u63a2\u7d22\u3057\u3066\u8fd4\u3063\u3066\u304d\u305findex\u3092\u5148\u306b\u4fdd\u6709\u3057\u3066\u304a\u304f\nb_counts = [0] * N\nfor i in range(N):\n    b_count = bisect.bisect_left(A, B[i])\n    b_counts[i] = b_count\n\ncumsum_b_counts = list(itertools.accumulate(b_counts))\ncumsum_b_counts = [0] + cumsum_b_counts\n\n# C\u306e\u5404\u8981\u7d20\u3067B\u3092\u4e8c\u5206\u63a2\u7d22\u3002\u4e0a\u8a18\u3067\u4fdd\u6709\u3057\u3066\u304a\u3044\u305fb_counts\u3092\u6d3b\u7528\u3059\u308b\ntotal = 0\nfor c in C:\n    count = bisect.bisect_left(B, c)\n    total += cumsum_b_counts[count]\n\nprint(total)\n\n", "passed": true, "time": 0.14, "memory": 14080.0, "status": "done"}, {"code": "import bisect\n\nn = int(input())\na = list(map(int, input().split()))\nb = list(map(int, input().split()))\nc = list(map(int, input().split()))\n\na.sort()\nc.sort()\n\nans = 0\nfor B in b:\n    i = bisect.bisect_left(a, B)\n    j = bisect.bisect_right(c, B)\n    ans += i * (n - j)\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14132.0, "status": "done"}, {"code": "n=int(input())\na=list(map(int,input().split()))\nb=list(map(int,input().split()))\nc=list(map(int,input().split()))\na=sorted(a)\nb=sorted(b)\nc=sorted(c)\nc.insert(0,-1)\nc.append(10**10)\nB=[0]*n\nans=0\nfor i in range(n):\n    x=b[i]\n    l=0\n    r=n+1\n    while r-l>1:\n        m=(l+r)//2\n        if c[m]>x:\n            r=m\n        elif c[m]<=x:\n            l=m\n    B[i]=n-l\ng=[0]*n\n\n\ng[n-1]=B[n-1]\nfor i in range(n-1):\n    g[-2-i]=g[-1-i]+B[-2-i]\ng.append(0)\n\nb.insert(0,-1)\nb.append(10**10)\nfor i in range(n):\n    x=a[i]\n    l=0\n    r=n+1\n    while r-l>1:\n        m=(l+r)//2\n        if b[m]>x:\n            r=m\n        elif b[m]<=x:\n            l=m\n    ans+=g[l]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14276.0, "status": "done"}, {"code": "def upper_bound(A, x):\n    s, t = -1, len(A)\n    while t - s > 1:\n        m = (s+t)//2\n        if A[m] > x:\n            t = m\n        else:\n            s = m\n    \n    return t\n\ndef lower_bound(A, x):\n    s, t = -1, len(A)\n    while t - s > 1:\n        m = (s+t)//2\n        if A[m] >= x:\n            t = m\n        else:\n            s = m\n    \n    return t\n\n\nN = int(input())\nA = sorted(list(map(int, input().split())))\nB = sorted(list(map(int, input().split())))\nC = sorted(list(map(int, input().split())))\n\nans = 0\nfor b in B:\n    ans += lower_bound(A, b) * (N - upper_bound(C, b))\n\nprint(ans)", "passed": true, "time": 0.14, "memory": 14052.0, "status": "done"}, {"code": "import bisect\nn = int(input())\nA = list(map(int, input().split(' ')))\nB = list(map(int, input().split(' ')))\nC = list(map(int, input().split(' ')))\n\nA.sort()\nB.sort()\nC.sort()\nans = 0\nfor j in range(n):\n    i = bisect.bisect_left(A, B[j])\n    k = n - bisect.bisect_right(C, B[j])\n    ans += int(i*k)\nprint(ans)", "passed": true, "time": 0.16, "memory": 14328.0, "status": "done"}, {"code": "import bisect\nn = int(input())\na = list(map(int,input().split()))\nb = list(map(int,input().split()))\nc = list(map(int,input().split()))\na = sorted(a)\nb = sorted(b)\nc = sorted(c)\nb_ans = [0] * len(b)\nfor i in range(len(b)):\n         b_ans[i] = bisect.bisect_left(a, b[i])\n\nruiseki_b = [0]\nfor i in range(len(b_ans)):\n         ruiseki_b.append(ruiseki_b[i] + b_ans[i])\nans = 0\nfor i in range(len(c)):\n         ans += ruiseki_b[bisect.bisect_left(b, c[i])]\nprint(ans)\n", "passed": true, "time": 0.14, "memory": 14200.0, "status": "done"}, {"code": "from bisect import bisect_left, bisect_right\n\nN = int(input())\nA = list(map(int, input().split()))\nB = list(map(int, input().split()))\nC = list(map(int, input().split()))\n\nA.sort()\nC.sort()\n\ncnt = 0\nfor b in B:\n    cnt += bisect_left(A, b) * (N - bisect_right(C, b))\nprint(cnt)", "passed": true, "time": 0.14, "memory": 14288.0, "status": "done"}]