Harryxun/stf_run huggingface dataset:
import sys

n,m = map(int,input().split())
a_arr = []
b_arr = []
c_arr = []

dic_arr = [{}]
dic_arr[0][0] = 0

for i in range(m):
  a,b = map(int,input().split())
  a_arr.append(a)
  b_arr.append(b)
  tmp_arr = list(map(int, input().split()))
  
  arr = []
  for i in range(1, n+1):
    if i in tmp_arr:
      arr.append('1')
    else:
      arr.append('0')
  
  c_arr.append(int(''.join(arr),2))

for i in range(m):
  a = a_arr[i]
  b = b_arr[i]
  c = c_arr[i]
  
  dic_arr.append(dic_arr[i].copy())
  
  for k,v in dic_arr[i+1].items():
    if (k|c) in dic_arr[i].keys():
      dic_arr[i+1][k|c] = min(dic_arr[i][k|c],a+v)
    else:
      dic_arr[i+1][k|c] = a+v

if ((2**n)-1) in dic_arr[m]:
  print(dic_arr[m][(2**n) -1])
else:
  print(-1)

### FIXED CODE ###

n,m = map(int,input().split())
 
dic = {0:0}
 
for i in range(m):
  a,b = map(int,input().split())
  tmp_arr = list(map(int, input().split()))
  
  arr = []
  for j in range(1, n+1):
    if j in tmp_arr:
      arr.append('1')
    else:
      arr.append('0')
  
  c = int(''.join(arr),2)
  
  dic2 = dic.copy()
  
  for k,v in dic.items():
    if (k|c) in dic2.keys():
      dic2[k|c] = min(dic2[k|c],a+v)
    else:
      dic2[k|c] = a+v
 
  dic = dic2
 
if ((2**n)-1) in dic.keys():
  print(dic[(2**n) -1])
else:
  print(-1)
n = int(input())
a = list(map(int, input().split()))
arr = [0 for i in range(n)]
for i in a:
    arr[a - 1] += 1
for i in range(n):
    print(arr[i])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
arr = [0 for i in range(n)]
for i in a:
    arr[i - 1] += 1
for i in range(n):
    print(arr[i])
if X >=30:
  print("Yes")
else:
  print("No")

### FIXED CODE ###

a = int(input())
if a >=30:
  print("Yes")
else:
  print("No")
"""
B - AcCepted
文字列 S が与えられます。S のそれぞれの文字は英大文字または英小文字です。 S
が次の条件すべてを満たすか判定してください。

S の先頭の文字は大文字の A である。
Sの先頭から 3 文字目と末尾から 2 文字目の間（両端含む）に大文字の C がちょうど 1
個含まれる。
以上の A, C を除く S のすべての文字は小文字である。
"""

s = input()

ans = True
if s[0] != "A":
    ans = False
    #print("s[0] is not A")
else:
    cnt_C = 0
    length = len(s)

    for n in range(1, length):
        check_char = s[n]
        
        if check_char.islower() is False:
            if check_char != "C" or n == 1 or n == (length - 1):
                ans = False
            
            cnt_C += 1

if cnt_C != 1:
    ans = False

if ans:
    print("AC")
else:
    print("WA")

### FIXED CODE ###

"""
B - AcCepted
文字列 S が与えられます。S のそれぞれの文字は英大文字または英小文字です。 S
が次の条件すべてを満たすか判定してください。

S の先頭の文字は大文字の A である。
Sの先頭から 3 文字目と末尾から 2 文字目の間（両端含む）に大文字の C がちょうど 1
個含まれる。
以上の A, C を除く S のすべての文字は小文字である。
"""

s = input()

cnt_C = 0
ans = True
if s[0] != "A":
    ans = False
    #print("s[0] is not A")
else:
    length = len(s)

    n = 1
    for check_char in s[1:]:
        #print(check_char)
        
        if check_char.islower() is False:
            if check_char != "C" or n == 1 or n == (length - 1):
                ans = False
            
            cnt_C += 1
        
        n += 1

if cnt_C != 1:
    ans = False

if ans:
    print("AC")
else:
    print("WA")
a,b = list(map(int,input().split(" ")))

l = [input() for i in range(b)]

l.sort()
print("".join(l))

### FIXED CODE ###

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

l = [input() for i in range(a)]

l.sort()
print("".join(l))
if __name__ == '__main__':
    print(x ** 3)


### FIXED CODE ###

num = int(input())
print(num ** 3)
A, B, K = map(int, input().split())

ab = set(list(range(A,B+1,1)))
a = set(list(range(A,A+K,1)))&ab
b = set(list(range(B-K+1,B+1,1)))&ab
ans=list(a|b)
ans = sorted(ans)

for ansi in ans:
  print(ansi)


### FIXED CODE ###

A, B, K= map(int, input().split())

for i in range(A,min([A+K+1,B+1]),1):
  if i<A+K:
    print(i)
    
for i in range(max([A+K, B-K-1]),B+1,1):
  if i>B-K:
    print(i)
N, K =map(int, input().split())
l = [map(int, input().split())]

l = sorted(l)[::-1]
ans = 0
for i in range(K):
  ans += l[i]

print(ans)

### FIXED CODE ###

N, K = map(int, input().split())
l = list(map(int, input().split()))

l = sorted(l)[::-1]
print(sum(l[0:K]))
def calc(x, y):
    x2 = x
    y2 = y - 1
    x4 = x - 1
    y4 = y
    x5 = x + 1
    y5 = y
    x7 = x
    y7 = y + 1
    return x2, y2, x4, y4, x5, y5, x7, y7

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))

for i in range(h * w):
    x = i // h
    y = i % h
    c = 0
    if s[x][y] == "#":
        x2, y2, x4, y4, x5, y5, x7, y7 = calc(x, y)
        aaa = [[x2, y2], [x4, y4], [x5, y5], [x7, y7]]
        for (xx, yy) in aaa:
            if ((xx >= 0) & (xx < h) & (yy >= 0) & (yy < w)):
                if s[xx][yy] == "#":
                    c += 1
        if c == 0:
            ans = "No"
            break
        else:
            ans = "Yes"
print(ans)

### FIXED CODE ###

def calc(x, y):
    x2 = x
    y2 = y - 1
    x4 = x - 1
    y4 = y
    x5 = x + 1
    y5 = y
    x7 = x
    y7 = y + 1
    return x2, y2, x4, y4, x5, y5, x7, y7

h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(list(input()))
ans = "Yes"
for i in range(h * w):
    x = i // h
    y = i % h
    c = 0
    if s[y][x] == "#":
        x2, y2, x4, y4, x5, y5, x7, y7 = calc(x, y)
        aaa = [[x2, y2], [x4, y4], [x5, y5], [x7, y7]]
        for (xx, yy) in aaa:
            if ((xx >= 0) & (xx < w) & (yy >= 0) & (yy < h)):
                if s[yy][xx] == "#":
                    c += 1
        if c == 0:
            ans = "No"
            break
print(ans)
from typing import List


class Solution:
    def solve(self, N: int, M: int) -> str:
        if N == M:
            return 'Yes'
        else:
            return 'No'


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(N, M))


### FIXED CODE ###


class Solution:
    def solve(self, N: int, M: int) -> str:
        if N == M:
            return 'Yes'
        else:
            return 'No'


if __name__ == '__main__':

    # standard input
    N, M = map(int, input().split())

    # solve
    solution = Solution()
    print(solution.solve(N, M))
#080-C 
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=IL()
F=[int(input().replace(" ",""), 2) for _ in range(n)]
P=[IL() for i in range(n)]
ans=-pow(10,10)
for i in range(1,pow(2,10)):
    t=0
    for f,p in zip(F,P):
        t+=p[bin(f&i).count("1")]
    ans=max(ans,t)
print(ans)

### FIXED CODE ###

#080-C 
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(input())
def S(): return list(input())
n=I()
F=[int(input().replace(" ",""), 2) for _ in range(n)]
P=[IL() for i in range(n)]
ans=-pow(10,10)
for i in range(1,pow(2,10)):
    t=0
    for f,p in zip(F,P):
        t+=p[bin(f&i).count("1")]
    ans=max(ans,t)
print(ans)
a b=int(input('a b'))
if (a*b)%2 ==0:
print('Even')
else:
  print('Odd')

### FIXED CODE ###

a,b=map(int,input().split())
if (a*b)%2 ==0:
  print('Even')
else:
  print('Odd')
s=input()
t=input()
cnt=0
for i in range(3)
if s[i]==t[i]:
  cnt +=1
print(cnt)

### FIXED CODE ###

s = input()
t = input()
cnt = 0
for i in range(3):
  if s[i] == t[i]:
  	cnt += 1
print(cnt)
str = input()
splited = str.split('')
print(splited)

### FIXED CODE ###

str = input()
splited = list(str)

cccount = 0
count = 0
for s in splited:
  if s == 'R':
    count = count + 1
    if count > cccount:
      cccount = count
  else:
      count = 0
    
print(cccount)
A, B, K = map(int, input().split())

ans = [i for i in range(1, A+1) if A % i == 0 and B % i == 0]
print(ans[K])


### FIXED CODE ###

A, B, K = map(int, input().split())

ans = [i for i in range(1, min(A, B) + 1) if A % i == 0 and B % i == 0]
print(ans[-K])
import math

a , b = (int(x) for x in input().split())

print((a * b) // math.gcd(a, b))




### FIXED CODE ###

import fractions

a , b = (int(x) for x in input().split())

result = fractions.gcd(a, b)

print((a * b) // result)
a,b,c=input().split()
print('YES' if a[::-1]==b[1] and b[::-1]==c[1] else 'NO')

### FIXED CODE ###

a,b,c=input().split()
print('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')
# -*- coding: utf-8 -*-

n = input()

l = []

for i in range(n):
    inpt = raw_input().split()
    l.append((inpt[0], inpt[1]), i)

l.sort(key=lambda xrange:(x[0], -x[1]))

for i in l:
    print (l[2] + 1)


### FIXED CODE ###

# -*- coding: utf-8 -*-

n = input()

l = []

for i in range(n):
    inpt = raw_input().split()
    l.append((inpt[0], int(inpt[1]), i + 1))

l.sort(key=lambda x:(x[0], -x[1]))

for i in l:
    print (i[2])
import sys
A,B,C,D = map(int, input().split())
if A+B+C+D==7:
    print("A+B+C+D==7")
    sys.exit()
if A-B+C+D==7:
    print("A-B+C+D==7")
    sys.exit()
if A+B-C+D==7:
    print("A+B-C+D==7")
    sys.exit()
if A+B+C-D==7:
    print("A+B+C-D==7")
    sys.exit()

if A-B-C+D==7:
    print("A-B-C+D==7")
    sys.exit()
if A-B+C-D==7:
    print("A-B+C-D==7")
    sys.exit()
if A-B-C+D==7:
    print("A-B-C+D==7")
    sys.exit()
if A-B-C-D==7:
    print("A-B-C-D==7")
    sys.exit()


### FIXED CODE ###

import sys
A,B,C,D = map(int, list(input()))
if A+B+C+D==7:
    print("{}+{}+{}+{}=7".format(A,B,C,D))
    sys.exit()
if A+B-C+D==7:
    print("{}+{}-{}+{}=7".format(A,B,C,D))
    sys.exit()
if A+B+C-D==7:
    print("{}+{}+{}-{}=7".format(A,B,C,D))
    sys.exit()
if A+B-C-D==7:
    print("{}+{}-{}-{}=7".format(A,B,C,D))
    sys.exit()
if A-B+C+D==7:
    print("{}-{}+{}+{}=7".format(A,B,C,D))
    sys.exit()
if A-B-C+D==7:
    print("{}-{}-{}+{}=7".format(A,B,C,D))
    sys.exit()
if A-B+C-D==7:
    print("{}-{}+{}-{}=7".format(A,B,C,D))
    sys.exit()
if A-B-C-D==7:
    print("{}-{}-{}-{}=7".format(A,B,C,D))
    sys.exit()
n = input()
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2] - a[1::2]))

### FIXED CODE ###

n = int(input())
a = sorted(list(map(int, input().split())), reverse=True)
print(sum(a[::2]) - sum(a[1::2]))
import math

n = int(input())
als = list(map(int, input().split()))

ans = "not coprime"

a, b = als[1], als[0]
if a < b:
    tmp = b
    b = a
    a = tmp 
while a % b != 0:
    a, b = b, a % b

for i in range(2, n):
    a = als[i]
    if a < b:
        tmp = b
        b = a
        a = tmp 
    while a % b != 0:
        a, b = b, a % b
    if b == 1:
        ans = "setwise coprime"
        break

existeven = False

failed = False

for i in range(n):
    if als[i] >= 2 and als[i]%2 == 0:
        if existeven:
            failed = True
            break
        else:
            existeven = True

if not failed:
    for i in range(3, int(math.sqrt(maxa))+1, 2):
        existfactrial = False
        failed = False
        for j in range(n):
            if als[j] >= i and als[j]%i == 0:
                if existfactrial:
                    failed = True
                    break
                else:
                    existfactrial = True
        if failed:
            break
    if not failed:
        ans = "pairwise coprime"

print(ans)
        

    

### FIXED CODE ###

import math
from collections import deque

n = int(input())
als = list(map(int, input().split()))

ans = "not coprime"

a, b = als[1], als[0]
if a < b:
    a,b = b,a
while a % b != 0:
    a, b = b, a % b
    if n == 2 and b == 1:
        ans = "pairwise coprime"
        failed = True

for i in range(2, n):
    a = als[i]
    if a < b:
        a,b = b,a 
    while a % b != 0:
        a, b = b, a % b
if b == 1:
    ans = "setwise coprime"
    # break

existeven = False

failed = False

for i in range(n):
    if als[i] >= 2 and als[i]%2 == 0:
        if existeven:
            failed = True
            break
        else:
            existeven = True

maxa = max(als)

afterchecklist = deque([])


if not failed:
    for i in range(3, int(math.sqrt(maxa))+2, 2):
        existfactrial = False
        failed = False
        for j in range(n):
            if als[j] >= i and als[j]%i == 0:
                afterchecklist.append(als[j]/i)
                if existfactrial:
                    failed = True
                    break
                else:
                    existfactrial = True
        if failed:
            break
    if not failed:
        for i in list(afterchecklist):
            existfactrial = False
            failed = False
            for j in range(n):
                if i != 1 and als[j] >= i and als[j]%i == 0:
                    if existfactrial:
                        failed = True
                        break
                    else:
                        existfactrial = True
            if failed:
                break
        if not failed:
            ans = "pairwise coprime"

print(ans)
# C
n = int(input())
A = list(map(int, input().split()))
b = sum(A)
for i in range(n-1):
    if A[i] <= A[(i+1)]:
        continue
    else:
        s = A[i] - A[(i+1)]
        s = s + A[(i+1)]
        A.pop(A[(i+1)])
        A.insert((i+1),s)

print(sum(A) - b)


### FIXED CODE ###

# 自分の改造
n = int(input())
A = list(map(int, input().split()))
s = 0 
M = 0
for i in range(n-1):
    if A[i] <= A[(i+1)] and M <= A[(i+1)]:
        M = 0
        continue
    else:
        if M == 0:
            s += A[i] - A[(i+1)]
            M = A[(i+1)] + (A[i] - A[(i+1)])
        else:
            s += M - A[(i+1)]
print(s)
def gcd(a,b):
	if b == 0 :
		return a
	else :
		return gcd(b,a%b)
 
def lcm(a,b):
	return a*b/gcd(a,b)
 
n = int(input())
arr = []
for i in range(n):
 
	arr.append(int(input()))
 
 
def mlcm():
 	if n = 1:
 		return arr[0]
 		
	ans = lcm(arr[0],arr[1])
 
	i = 2
	while i<n:
		ans = lcm(ans,arr[i])
		i+=1
 
	return ans
 
print mlcm()

### FIXED CODE ###

def gcd(a,b):
	if b == 0 :
		return a
	else :
		return gcd(b,a%b)
 
def lcm(a,b):
	return a*b/gcd(a,b)
 
n = int(input())
arr = []
for i in range(n):
 
	arr.append(int(input()))
 
 
def mlcm():
 	if n == 1:
 		return arr[0]

	ans = lcm(arr[0],arr[1])
 
	i = 2
	while i<n:
		ans = lcm(ans,arr[i])
		i+=1
 
	return ans
 
print mlcm()
s = input()

res = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    res = res.replace(s[i], "")
if len(s) == 0:
    print("None")
else:
    print(res[0])

### FIXED CODE ###

s = input()

res = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(s)):
    res = res.replace(s[i], "")
if len(res) == 0:
    print("None")
else:
    print(res[0])
#coding: utf-8

a = input()

print((24 - a) + 24)

### FIXED CODE ###

#coding: utf-8

a = int(input())

print(24 - a + 24)
a = int(input())
b = int(input())
h = int(input())
print(in(((a+b)*h)/2))

### FIXED CODE ###

a = int(input())
b = int(input())
h = int(input())
print(int(((a+b)*h)/2))
N = int(input())

for i in range(25)
    for j in range(15)
        if N == 4*i + 7*j:
            print('Yes')
            break

print('No')


### FIXED CODE ###

N = int(input())

for i in range(25):
    for j in range(15):
        if N == 4*i + 7*j:
            print('Yes')
            exit()

print('No')
table = []
r, c = map(int, input().strip().split())
[table.append(input().strip().split()) for i in range(r)]

print(table)
for j in range(r + 1):
    for k in range(c + 1):
        if j == r and k != c:
            lastrow = sum(map(int, [table[x][k] for x in range(r)]))
            table[-1].append(lastrow)
        if k == c:
            print(sum(map(int, table[j])))
            break
        print(table[j][k],end=' ')

### FIXED CODE ###

table = []
r, c = map(int, input().strip().split())
[table.append(input().strip().split()) for i in range(r)]
table.append([])

for j in range(r + 1):
    for k in range(c + 1):
        if j == r and k != c:
            lastrow = sum(map(int, [table[x][k] for x in range(r)]))
            table[-1].append(lastrow)
        if k == c:
            print(sum(map(int, table[j])))
            break
        print(table[j][k],end=' ')
import sys
input = sys.stdin.readline
from fractions import gcd
import numpy as np
n=int(input())
A=list(map(int,input().split()))
B=np.array(A)
mod=10**9+7
if n==1:
    print(1)
else:
    g=A[0]
    l=A[0]
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
    ans=int(l*((1/B).sum()))
    print(ans%mod)

### FIXED CODE ###

import sys
input = sys.stdin.readline
from fractions import gcd
n=int(input())
A=list(map(int,input().split()))
mod=10**9+7
def gyaku(a):
    return pow(a,mod-2,mod)
if n==1:
    print(1)
else:
    gya=[0]*(n)
    g=A[0]
    l=A[0]
    gya[0]=gyaku(A[0])
    for i in range(n-1):
        g=gcd(l,A[i+1])
        l*=(A[i+1]//g)
        gya[i+1]=gyaku(A[i+1])
    ans=0
    for i in range(n):
        ans+=l*gya[i]
        ans%=mod
    print(ans)
import numpy as np

info = np.array(input().split(" "), dtype="int64")
o = info[1] + info[2]
if o == 0:
    print(0)
else:
    q, mod = divmod(info[0], o)
    if mod > info[1]:
        print((q+1)* info[1])
    else:
        print(q*info[1] + mod)

### FIXED CODE ###

s = list(input())
if s[0] == s[1] and s[1] == s[2]:
    print("No")
else:
    print("Yes")
def func(amat, bmat, nm):
    ans = [[0 for i in range(nm[0])] for j in range(nm[2])]
    for i in range(nm[0]):
        for j in range(nm[1]):
            for l in range(nm[2]):
                ans[i][l] += amat[i][j] * bmat[j][l]
    for i in ans:
        print("{0} {1} {2}".format(i[0], i[1], i[2]))


if __name__ == '__main__':
    nm = [int(i) for i in input().split(' ')]
    amat = [[0 for i in range(nm[1])] for j in range(nm[0])]
    bmat = [[0 for i in range(nm[2])] for i in range(nm[1])]

    for i in range(nm[0]):
        a = input().split(' ')
        for j in range(nm[1]):
            amat[i][j] = int(a[j])

    for i in range(nm[1]):
        b = input().split(' ')
        for j in range(nm[2]):
            bmat[i][j] = int(b[j])

    func(amat, bmat, nm)

### FIXED CODE ###

def func(amat, bmat, nm):
    ans = [[0 for i in range(nm[2])] for j in range(nm[0])]
    for i in range(nm[0]):
        for j in range(nm[1]):
            for l in range(nm[2]):
                ans[i][l] += amat[i][j] * bmat[j][l]
    for i in ans:
        print(' '.join(map(str, i)))


if __name__ == '__main__':
    nm = [int(i) for i in input().split(' ')]
    amat = [[0 for i in range(nm[1])] for j in range(nm[0])]
    bmat = [[0 for i in range(nm[2])] for i in range(nm[1])]

    for i in range(nm[0]):
        a = input().split(' ')
        for j in range(nm[1]):
            amat[i][j] = int(a[j])

    for i in range(nm[1]):
        b = input().split(' ')
        for j in range(nm[2]):
            bmat[i][j] = int(b[j])

    func(amat, bmat, nm)
# coding: utf-8
import time
import re
import math
import fractions

def main():
    list=[int(input()) for a in range(5)]
    index=0
    mn=1e9
    for a in range(len(list)):
        if list[a]<mn:
            mn=list[a]
            index=a
    print(sum(list(map(lambda x:math.ceil(x/10)*10),list))-(10-mn%10))

    
    
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B



### FIXED CODE ###

# coding: utf-8
import time
import re
import math
import fractions

def main():
    lst=[int(input()) for a in range(5)]
    index=0
    mx=0
    total=0
    for a in range(len(lst)):
        if math.ceil(lst[a]/10)*10-lst[a]>mx:
            mx=math.ceil(lst[a]/10)*10-lst[a]
            index=a
    #print(index)
    for a in range(len(lst)):
        if a==index:
            total+=lst[a]
        else:
            total+=math.ceil(lst[a]/10)*10
    print(total)
    
start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#"YNeos"[True::2]
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global n,A,s,memo,mx,mn,L,B
def MAXI(a):
    m=max(a)
    for i in range(3):
        if a[i]==m:
            id=i
    return m,id

tot=0
N=int(input())
i=0
while i<N:   
    if i==0:
        x=[int(a) for a in input().split()]
        m,id=MAXI(x)
        tot+=m
        i=i+1
    elif i==(N-1):
        x=[int(a) for a in input().split()]
        MAX=0
        for j in range(3):
            if j!=id:
                if x[j]>MAX:
                    MAX=x[j]
        tot+=MAX
        i=i+1
    else:
        x=[int(a) for a in input().split()]
        y=[int(a) for a in input().split()]
        i=i+2
        MAX=0
        for j in range(3):
            if j!=id:
                for k in range(3):
                    if k!=j:
                        s=x[j]+y[k]
                        if s>MAX:
                            MAX=s
                            id1=k                        
        tot+=MAX
        id=id1                            
print(tot)
    


### FIXED CODE ###

def fragOptimalJump(h,n):
    dp=[0]*(n+1)
    dp[2]=abs(h[1]-h[2])
    for i in range(3,n+1):
        dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
    return dp[n]
  
N=int(input())
read = [int(n) for n in input().split()]
H=[0]+read
print(fragOptimalJump(H,N))
#!/usr/bin/env python
# coding: utf-8

# In[4]:


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


# In[6]:


ans = 0
for b in B:
    while i<N and A[i]<b:
        i+=1
    while j<N and C[j]<=b:
        j+=1
    ans += i*(N-j)
print(ans)


# In[ ]:






### FIXED CODE ###

#!/usr/bin/env python
# coding: utf-8

# In[8]:


from bisect import bisect_left,bisect


# In[6]:


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


# In[9]:


ans = 0
for b in B:
    i = bisect_left(A,b)
    j = bisect(C,b)
    ans += i*(N-j)
print(ans)


# In[ ]:
x,a = map(int,input())

if(x<a):
  print(0)
else:
  print(10)

### FIXED CODE ###

x,a = map(int,input().split())

if(x<a):
  print(0)
else:
  print(10)
s = input()
all = "abcdefghijklmnopqrstuvwxyz"
ans = sorted(set(s)^set(all)) 
print("None" if ans == 0 else ans[0])

### FIXED CODE ###

s = input()
all = "abcdefghijklmnopqrstuvwxyz"
ans = sorted(set(s)^set(all)) 
print("None" if len(ans) == 0 else ans[0])
from collections import defaultdict
from itertools import product, combinations
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

cand = [[1]]
for i in range(M-1):
    tmp = []
    while cand:
        x = cand.pop()
        for i in range(x[-1], M + 1):
            tmp.append(x + [i])
    cand = tmp

ans = 0
for X in cand:
    score = 0
    for a, b, c, d in abcd:
        if X[b - 1] - X[a - 1] == c:
            score += d
    ans = max(ans, score)
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)

N, M, Q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(Q)]

cand = [[1]]
for i in range(N-1):
    tmp = []
    while cand:
        x = cand.pop()
        for i in range(x[-1], M + 1):
            tmp.append(x + [i])
    cand = tmp

ans = 0
for X in cand:
    score = 0
    for a, b, c, d in abcd:
        if X[b - 1] - X[a - 1] == c:
            score += d
    ans = max(ans, score)
print(ans)
n,a,b = map(int,input().split())

mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

fac = [0]*(10**9+10)
fac[0] = 1
fac[1] = 1
for i in range(2,10**9+1):
    fac[i] = fac[i-1] * i % mod

c = pow(2,n,mod)
c -= 1
c -= ( fac[n] * modinv(fac[a]) )%mod * modinv(fac[n-a]) % mod
c -= ( fac[n] * modinv(fac[b])) % mod * modinv(fac[n-b]) % mod
print(c%mod)

### FIXED CODE ###

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

mod = 10**9+7
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

def com(n,k,mod=10**9+7):
    u = 1
    s = 1
    for i in range(n,n-k,-1):
        u = u*i % mod
    for i in range(k,0,-1):
        s = s*i % mod
    return u * modinv(s)

c = pow(2,n,mod)
c -= 1
c -= com(n,a)
c -= com(n,b)
print(c%mod)