Harryxun/stf_run huggingface dataset:
import sys

for line in sys.stdin.readlines():
    S = map(int, line.strip().split())

    h = S/60

    S1 = S%h
    m = S1/60

    s = S1/m

    print "%d:%d:%d", h, m, s

### FIXED CODE ###

S =input()
h = int(int(S / 60) / 60)
m = int(S/60) % 60
s = S % (60*60) % 60
print "%d:%d:%d" % (h, m, s)
r = int(input())

if r < 1200:
    print("ABC")
elif r 2800:
    print("ARC")
else:
    print("AGC")


### FIXED CODE ###


r = int(input())

if r < 1200:
    print("ABC")
elif r < 2800:
    print("ARC")
else:
    print("AGC")
import math
a, b ,x = list(map(int,input().split()))

if x > a*a*b/2:
    theta = math.atan(2*(a*a*b-x)/a/a/a)
else:
    theta = math.atan(a*a*b/2/x)

print(math.degrees(theta))


### FIXED CODE ###

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

if (a >= 10) or (b >= 10):
  print(-1)
else:
  print(a*b)
N = int(input())
H = list(map(int, input().split()))

for i in range(N):
    if i != N-1:
        if H[i] > H[i+1]:
            H[i] -= 1
    if i == N:
        if H[i] < H[i-1]:
            H[i-1] -= 1

for i in range(N):
    if i < N-1:
        if H[i] > H[i+1]:
            print("No")
            exit()
    if i == N:
        if H[i-1] > H[i]:
            print("No")
            exit()
print("Yes")


### FIXED CODE ###

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

A -= B
C -= A

if C < 0:
    print(0)
else:
    print(C)
S, W = [int(s) for s in input.split()]
if W >= S:
  print("unsafe")
else:
  print("safe")

### FIXED CODE ###

S, W = [int(s) for s in input().split()]
if W >= S:
  print("unsafe")
else:
  print("safe")
from itertools import permutations
n,m=map(int,input().split())
side=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  side[a].append(b)
  side[b].append(a)
route=[i for i in range(2,n+1)]
ans=0
for x in permutations(route):
  x=(1)+x
  for i in range(n-1):
    if x[i+1] not in side[x[i]]:
      break
  else:
    ans+=1
print(ans)

### FIXED CODE ###

from itertools import permutations
n,m=map(int,input().split())
side=[[] for _ in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  side[a].append(b)
  side[b].append(a)
route=[i for i in range(2,n+1)]
ans=0
for x in permutations(route):
  x=list(x)
  x.insert(0,1)
  for i in range(n-1):
    if x[i+1] not in side[x[i]]:
      break
  else:
    ans+=1
print(ans)
def gmax(a,b):
  if a<b:
  	a,b=b,a
  while a%b!=0:
    tmp=a
    a=b
    b=tmp%b
  return b
 
n=int(input())
x=[]
for i in range(n):
  x.append(int(input()))
    
g=gmax(x[0],x[1])
l=x[0]*x[1]//g
 
for j in range(2,len(x)):
  g=gmax(x[j],l)
  l=x[j]*l//g
  
print(l)

### FIXED CODE ###

def gmax(a,b):
  if a<b:
  	a,b=b,a
  while a%b!=0:
    tmp=a
    a=b
    b=tmp%b
  return b
 
n=int(input())
x=[]
for i in range(n):
  x.append(int(input()))

if len(x)!=1:
  g=gmax(x[0],x[1])
  l=x[0]*x[1]//g

  for i in range(2,len(x)):
    g=gmax(x[i],l)
    l=(x[i]*l)//g
else:
  l=x[0]
print(l)
import sys
 
if sys.argv[1] == sys.argv[2]:
  return "Yes"
 
return "No"

### FIXED CODE ###

test_passed, test_all_cnt  = input().split()
 
print("Yes" if test_passed == test_all_cnt else "No")
a=input()
print(a[0]+str(len(s)-2)+a[-1])


### FIXED CODE ###

a=input()
print(a[0]+str(len(a)-2)+a[-1])
n = int(input())
a = int(input())
b = int(input())
if n == 1:
    print('Hello World')
else:
    print(a+b) 

### FIXED CODE ###

n = int(input())
for i in range(n-1):
    a = int(input())
    b = int(input())
if n == 1:
    print('Hello World')
else:
    print(a+b)
imports sys
l = sys.stdin.readline()
n, k = map(int, l.split())
if n == 0:
  print(1)
  sys.exit(0)
count = 0
while n > 0:
  	n /= k
    count += 1
print(count)

### FIXED CODE ###

import sys
l = sys.stdin.readline()
n, k = map(int, l.split())
if n == 0:
  print(1)
  sys.exit(0)
count = 0
while n > 0:
    n //= k
    count += 1
print(count)
if __name__ == '__main__':
    n, a, b = map(int, input().split())

    count = 0
    for i in range(n+1):
        x = sum(map(int, str(i)))
        if a <= x <= b:
            count = count + i

    print(count)

### FIXED CODE ###

if __name__ == '__main__':
    a, b, c, d = map(int, input().split())

    if a+b == c+d:
        print('Balanced')
    elif a+b > c+d:
        print('Left')
    else:
        print('Right')
input(a)
if a%2==1:
	i=(a+1)/2
	j=(a-1)/2
else:
	i=a/2
	j=a/2
print(i*j)

### FIXED CODE ###

a=int(input())
if a%2==0:
  ans=int((a/2)**2)
else:
  ans=int(((a-1)/2)*((a+1)/2))
print(ans)
n,k=map(int,input().split())
from fractions import gcd
if n<k: n,k=k,n
if n%k==0 and n//k%2==0:
  print(0)
else:
  print(gcd(n,k))

### FIXED CODE ###

n,k=map(int,input().split());x=n%k;print(min(x,k-x))
N = int(input())
 
t = [int(input()) for i in range(N)]
 
M = int(input())
 
a = []
for i in range(2):
    a.append(map(int, raw_input().split()))       
 
cal = sum(t)
 
for j in range(M):
    print(cal - t[a[j][0] - 1] + a[j][1])


### FIXED CODE ###

N = int(input())
 
t = list(map(int, input().split()))
 
M = int(input())
 
cal = sum(t)
 
for j in range(M):
    p, x = map(int, input().split())
    print(cal - t[p - 1] + x)
import math
A,B,C,D = [int(i) for i in input().split()]
def lcm(a,b):
    return a*b/math.gcd(a,b)
lcm = lcm(C,D)
aa = ((B//C)+(1 if A%C == 0 else 0))-(A//C)
bb = ((B//D)+(1 if A%D == 0 else 0))-(A//D)
ll = ((B//lcm)+(1 if A%lcm == 0 else 0))-(A//lcm)
print(int((B-A+1)-(aa+bb-ll)))


### FIXED CODE ###

import math


# 最大公約数gcd,
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


# 最小公倍数lcm
def lcm(a, b):
    return (a * b) // gcd(a, b)


a, b, c, d = (int(i) for i in input().split())

cd = lcm(c, d)
r = b - a + 1

min_c = a // c + (1 if a % c != 0 else 0)
max_c = b // c
min_d = a // d + (1 if a % d != 0 else 0)
max_d = b // d
min_cd = a // cd + (1 if a % cd != 0 else 0)
max_cd = b // cd

c_num = max_c - min_c + 1
d_num = max_d - min_d + 1
cd_num = max_cd - min_cd + 1

print(r - c_num - d_num + cd_num)
import fractions

A,B,K=map(int,input().split())
gcd=math.gcd(A,B)
#print(gcd)
l=[]
for i in range(1,gcd+1):
    if gcd%i==0:
        l.append(i)
print(l[len(l)-K])

### FIXED CODE ###

import fractions

A,B,K=map(int,input().split())
gcd=fractions.gcd(A,B)
#print(gcd)
l=[]
for i in range(1,gcd+1):
    if gcd%i==0:
        l.append(i)
#print(l)
print(l[len(l)-K])
# -*- coding: utf-8 -*-

s = list(input())
ans = []

for j in range(len(s)):
    if (s[j]) == "B":
        l = len(ans)
        if l == 0:
            continue
        else:
            del ans[j-1]
    else:
        ans.append(s[j])

print("".join(ans))

### FIXED CODE ###

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

s = list(input())
ans = []

for j in range(len(s)):
    # print("j=%d word=%s length=%d ans=%s" % (j, s[j], len(ans), "".join(ans)))
    if (s[j]) == "B":
        l = len(ans)
        if l == 0:
            continue
        else:
            del ans[-1]
    else:
        ans.append(s[j])

print("".join(ans))
import math
targ = int(input())
while True:
    y,z =0,0
    minans = float("inf")
    if (targ ** ( 1 / 3)) == int(targ ** ( 1 / 3)):
        z = int(targ ** ( 1 / 3))
        targ = 0
    elif (targ ** ( 1 / 2)) == int(targ ** ( 1 / 2)):
        y = int(targ ** ( 1 / 2))
        targ = 0
    else:
        for n in range(math.ceil(targ ** ( 1 / 3))):
            if minans == 0:
                break
            for m in range(math.ceil(targ ** ( 1 / 2))):
                if (n ** 3) + (m **2) > targ:
                    break
                if minans > targ - (n ** 3 + m ** 2):
                    minans = targ - (n ** 3 + m ** 2)
                    y,z = m,n
    if minans != float("inf"):
        print(minans + y + z)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break
            

### FIXED CODE ###

import math
targ = int(input())
y,z = 0,0
while True:
    minans = float("inf")
    for n in range(math.ceil(targ ** ( 1 / 3))+1):
        if minans == 0:
            break
        if targ - n**3 >= 0:
            m = int((targ - n**3) **(1/2))
        else:
            m = 0
        if (n ** 3) + (m **2) > targ:
            break
        if minans > targ - (n ** 3 + m**2) + n + m:
            minans = targ - (n ** 3 + m**2) + n + m
    if minans != float("inf"):
        print(minans)
    else:
        print(y + z)
    targ = int(input())
    if targ == 0:
        break
n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))

def check(i, m):
    if m == 0:
        return 'yes'
    elif i >= n:
        return 'no'
    res = check(i+1, m) + check(i+1, m - seq[i])
    return res

for m in mlist:
    if('yes' in check(0, m)):
        print('yes')
    else:
        print('no')


### FIXED CODE ###

n = int(input())
seq = list(map(int, input().split()))
q = int(input())
mlist = list(map(int, input().split()))
mins = min(seq)
sums = 0
for a in seq:
    sums += a

def check(i, m):
    global mins
    if m == 0:
        return True
    elif i >= n or mins > m:
        return False
    res = check(i+1, m) or check(i+1, m - seq[i])
    return res

for m in mlist:
    if (mins > m or sums < m):
        print('no')
    elif(check(0,m)):
        print('yes')
    else:
        print('no')
N,M,C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = []
for i in range(N):
    A.append(list(map(int,input(),split())))
S = []
count = 0
for i in range(N):
    for j in range(M):
        S.append(A[j]*B[j])
    if sum(S) > -1 * C:
        count += 1
    S = []
print(count)

### FIXED CODE ###

N,M,C = list(map(int,input().split()))
B = list(map(int,input().split()))
A = []
for i in range(N):
    A.append(list(map(int,input().split())))
S = []
count = 0
for i in range(N):
    for j in range(M):
        S.append(A[i][j]*B[j])
    if sum(S) > -1 * C:
        count += 1
    S = []
print(count)
n,a,b = [int(input()) for i in range(3)]
t=0
for i in range(1,n+1):
    orign=i
    total = 0
    for ii in range(len(str(i))):
        total += i%10
        i=int(i/10)
    if total>=a and total<=b:
        t+=orign
print(t)

### FIXED CODE ###

n,a,b = map(int, input().split())
t=0
for i in range(1,n+1):
    orign=i
    total = 0
    for ii in range(len(str(i))):
        total += i%10
        i=int(i/10)
    if total>=a and total<=b:
        t+=orign
print(t)
h,n=map(int,input().split())
ab=[list(map(int,input().split())) for _ in range(n)]
 
dp=[0]*h
for i in range(h):
    _min = 10**10
    for g in range(n):
        if i>=ab[g][0]:
            _min = min(ab[g][1]+dp[i-ab[g][0]], _min)
        else:
            _min = min(ab[g][1], _min)
    dp[i]=_min
print(dp[-1])

### FIXED CODE ###

h=int(input())

ans=0
i=0
while True:
    ans+=(2**i)
    h//=2
    i+=1
    if h==0:
        break
print(ans)
N = int(input())
x = N % 10
if x　in [2,4,5,7,9]:
  print('hon')
elif x in [0,6,1,8]:
  print('pon')
else:
  print('bon')

### FIXED CODE ###

mylist1 = [2,4,5,7,9]
mylist2 = [0,1,6,8]
N  = int(input())
X = N % 10
if X in mylist1:
  print('hon')
elif X in mylist2:
  print('pon')
else:
  print('bon')
user1 = eval(input().replace(" ",","))
user = list(eval(input().replace(" ",",")))
sum = 0
for i in user:
    sum = sum + i
print(list(user1)[0] - sum)

### FIXED CODE ###

N,M = (input()).split()
task = input().split()
list1 = []
sum = 0
for i in task:
    list1.append(i)
for j in list1:
    sum = sum + int(j)
result = int(N) - sum
if result < 0:
    print(-1)
else:
    print(result)
import math
n, k = map(int, input().split())
a_in = list(map(int, input().split()))

diff_list = [0 for num in range(n)]
diff_list[0] = a_in[0]
for i in range(1, n):
    diff_list[i] = a_in[i] - a_in[i-1]

itr = k
if k > 10*math.log(n):
    itr = 10*math.log(n)
for i in range(itr):
    new_list = [0 for num in range(n)]
    d_sum = 0
    for j, d in enumerate(diff_list):
        d_sum += d
        if j-d_sum > 0:
            new_list[j-d_sum] += 1
        else:
            new_list[0] += 1
        if d_sum+j+1 < n:
            new_list[j+d_sum+1] -= 1
    # print(new_list)
    diff_list = new_list.copy()

ans = 0
for d in diff_list:
    ans += d
    print(ans, end= ' ')


### FIXED CODE ###

n, k = map(int, input().split())
a_in = list(map(int, input().split()))

diff_list = [0 for num in range(n)]
diff_list[0] = a_in[0]
for i in range(1, n):
    diff_list[i] = a_in[i] - a_in[i-1]

itr = k
if k > 41:
    itr = 41
for i in range(itr):
    new_list = [0 for num in range(n)]
    d_sum = 0
    for j, d in enumerate(diff_list):
        d_sum += d
        if j-d_sum > 0:
            new_list[j-d_sum] += 1
        else:
            new_list[0] += 1
        if d_sum+j+1 < n:
            new_list[j+d_sum+1] -= 1
    # print(new_list)
    diff_list = new_list.copy()

ans = 0
for d in diff_list:
    ans += d
    print(ans, end= ' ')
from bisect import bisect_left, insort_left
import sys
def main():
	readlines = sys.stdin.readline
	x,y,a,b,c = map(int,input().split())

	p = list(map(int,input().split()))
	q = list(map(int,input().split()))
	r = list(map(int,input().split()))

	p.sort()
	q.sort()
	r.sort(reverse=True)

	p = p[a-x:]
	q = q[b-y:]
	a = len(p)
	b = len(q)
	ans = sum(p) + sum(q)
	p_count = 0
	q_count = 0

	for i in range(c):
		if p[p_count] < r[i] and q[q_count] < r[i]:
			if p[p_count] < q[q_count] and p_count != a:
				ans -= p[p_count]
				ans += r[i]
				#insort_left(p,r[i])
				if p_count < a:
					p_count += 1
			elif p[p_count] > q[q_count] and q_count != b:
				ans -= q[q_count]
				ans += r[i]
				#insort_left(q,r[i])
				if q_count < b:
					q_count += 1
		elif p[p_count] < r[i] and p_count != a:
			ans -= p[p_count]
			ans += r[i]
			#insort_left(p,r[i])
			if p_count < a:
				p_count += 1
		elif q[q_count] < r[i] and q_count != b:
			ans -= q[q_count]
			ans += r[i]
			#insort_left(q,r[i])
			if q_count < b:
				q_count += 1
		else:
			break

	print(ans)
if __name__ == '__main__':
	main()

### FIXED CODE ###

x,y,a,b,c = map(int,input().split())

p = list(map(int,input().split()))
q = list(map(int,input().split()))
r = list(map(int,input().split()))

p.sort()
q.sort()
r.sort(reverse=True)

p = p[a-x:]
q = q[b-y:]

p.extend(q)
p.sort()

ans = sum(p)
count = 0
for i in range(c):
	if p[i] < r[i]:
		ans += r[i] - p[i]
	else:
		break
print(ans)
S=str(input())
T=str(input())
ls=len(S)
lt=len(T)

ans=''
flag=0
for i in range(ls-lt,-1,-1):
  flag=0
  for j in range(lt):
    if not (S[i+j] == T[j] or S[i+j] == '?'):
      flag=1
      break
  if flag==0:
    loc=i
    break

if flag==0:
  print('UNRESTORABLE')
else:
  i=0
  while i<ls:
    if i==loc:
      ans += T
      i += lt
    elif S[i] == '?':
      ans += 'a'
      i += 1
    else:
      ans += S[i]
      i += 1
  print(ans)


### FIXED CODE ###

S=str(input())
T=str(input())
ls=len(S)
lt=len(T)

ans=''
loc=None
for i in range(ls-lt,-1,-1):
  flag=0
  for j in range(lt):
    if not (S[i+j] == T[j] or S[i+j] == '?'):
      flag=1
      break
  if flag==0:
    loc=i
    break

if loc == None:
  print('UNRESTORABLE')
else:
  i=0
  while i<ls:
    if i==loc:
      ans += T
      i += lt
    elif S[i] == '?':
      ans += 'a'
      i += 1
    else:
      ans += S[i]
      i += 1
  print(ans)
n = int(input())

for i in range(n//2):
    if i**2 > n:
        break
print((i-1)**2)

### FIXED CODE ###

n = int(input())

for i in range(n):
    if i**2 > n:
        break

if n == 1 or n == 2:
    print(1)
else:
    print((i-1)**2)
N, K = map(int,input().split())
li = []

for i in range(N):
        li.append(int(input()))

li.sort()

co = K - 1
hmin = 1000000
for i in range(N):
        if hmin > li[i+co] - li[i]:
                hmin = li[i+co] - li[i]
                if hmin == 0:
                        break
print(hmin)

### FIXED CODE ###

N, K = map(int,input().split())
li = []

for i in range(N):
        li.append(int(input()))

li.sort()

co = K - 1
hmin = li[co] - li[0]
for i in range(N-K+1):
        if hmin > li[i+co] - li[i]:
                hmin = li[i+co] - li[i]
                if hmin == 0:
                        break
print(hmin)
s=input()
if s==="A" or "B":
  print('Yes')
else:
  print("No")

### FIXED CODE ###

s=input()
if s=='AAA' or s=='BBB':
  print('No')
else:
  print('Yes')
T = input()
N = len(T)

if T[0] == "?" and T[1] == "?":
    T2 = list(T)
    T2[0] = "P"
    T2[1] = "D"
    T = "".join(T2)
        
elif T[0] == "?" and T[1] == "D":
    T2 = list(T)
    T2[0] = "P"
    T = "".join(T2)
        
elif T[0] == "?" and T[1] == "P":
    T2 = list(T)
    T2[0] = "D"
    T = "".join(T2)
        
elif T[0] == "D" and T[1] == "?" and T[2] == "D":
    T2 = list(T)
    T2[1] = "P"
    T = "".join(T2)
        
elif T[0] == "D" and T[1] == "?" and T[2] == "P":
    T2 = list(T)
    T2[1] = "D"
    T = "".join(T2)
elif T[0] == "P" and T[1] == "?":
    T2 = list(T)
    T2[1] = "D"
    T = "".join(T2)

if T[-1] == "?":
    T2 = list(T)
    T2[-1] = "D"
    T = "".join(T2)


for i in range(2,N-1):
    if T[i-2] == "P" and T[i-1] == "D" and T[i+1] == "D" and T[i] == "?":
        T2 = list(T)
        T2[i] = "P"
        T = "".join(T2) 
        continue
    elif T[i] == "?":
        T2 = list(T)
        T2[i] = "D"
        T = "".join(T2) 

        
print(T)

### FIXED CODE ###

T = list(input())
N = len(T)
if T[-1] == "?":
    T[-1] = "D"

if N == 1 and T[0] == "?":
    T[0] = D
elif N == 2:
    if T[0] == "?" and T[1] == "?":
        T[0] = "P"
        T[1] = "D"
                
    elif T[0] == "?" and T[1] == "D":
        T[0] = "P"
                
    elif T[0] == "?" and T[1] == "P":
        T[0] = "D"
        
    elif T[0] == "P" and T[1] == "?":
        T[1] = "D"
        
elif N > 2:        
    if T[0] == "?" and T[1] == "?":
        T[0] = "P"
        T[1] = "D"
          
    elif T[0] == "?" and T[1] == "D":
        T[0] = "P"
            
    elif T[0] == "?" and T[1] == "P":
        T[0] = "D"
            
    elif T[0] == "D" and T[1] == "?" and T[2] == "D":
        T[1] = "P"
            
    elif T[0] == "D" and T[1] == "?" and T[2] == "P":
        T[1] = "D"
    
    elif T[0] == "P" and T[1] == "?":
        T[1] = "D"
        
    for i in range(2,N-1):
        if T[i-2] == "P" and T[i-1] == "D" and T[i+1] == "D" and T[i] == "?":
            T[i] = "P"
            continue
        
        elif T[i] == "?":
            T[i] = "D"
        

ans = "".join(T)         
print(ans)
S= input()
print(S[;2])

### FIXED CODE ###

S= input()
print(S[:3])
a,b = map(int,input().split())
lis = [0]*b
for i in range(a):
  c = int(input())
  d = input().split()
  
  for l in range(c):
    lis[int(d[l])-1] += 1
    
count = 0
for i in range(b):
  if(lis[i] == 0):
    count += 1

print(count)

### FIXED CODE ###

a,b = map(int,input().split())
lis = [0]*a
for i in range(b):
  c = int(input())
  d = input().split()
  
  for l in range(c):
    lis[int(d[l])-1] += 1
    
count = 0
for i in range(a):
  if(lis[i] == 0):
    count += 1

print(count)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

a.append(10**9+1)
b.append(10**9+1)

i,j,ans=0,0,0
while k>=0:
    print(i,j)
    if a[i]>10**9:
        k-=b[j]
        j+=1
    elif b[i]>10**9:
        k-=a[i]
        i+=1
    elif a[i]>b[j]:
        k-=b[j]
        j+=1
    else:
        k-=a[i]
        i+=1
    if k<0:
        break
    ans+=1

print(ans)
    

### FIXED CODE ###

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

a,b=[0],[0]
for i in range(n):
    a.append(a[i]+A[i])
for i in range(m):
    b.append(b[i]+B[i])

j,ans=m,0
for i in range(n+1):
    if a[i]>k:
        break
    while b[j] > k-a[i]:
        j-=1
    ans=max(ans,i+j)
print(ans)
def main():
    n = int(input())
    for i in range(n):
        a, b, c=(int(input().split()))
        if a+b<=c or a+c<=b or b+c<=a:
            print("YES")
        else:
            print("NO")
            
main()


### FIXED CODE ###

def main():
    n = int(input())
    for i in range(n):
        a=[int(x) for x in input().split()]
        a.sort()
        if a[0] ** 2 + a[1] ** 2 != a[2] ** 2:
            print("NO")
        else:
            print("YES")

main()
# https://atcoder.jp/contests/abc077/tasks/arc084_a

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()

    ans = 0

    for b in B:
        i = bisect.bisect_left(A, b)
        j = bisect.bisect_right(C, b)

        ans += i * (N - j)

    print(ans)


if __name__ == '__main__':
    main()
# https://atcoder.jp/contests/abc077/tasks/arc084_a

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()

    ans = 0

    for b in B:
        i = bisect.bisect_left(A, b)
        j = bisect.bisect_right(C, b)

        ans += i * (N - j)

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

# https://atcoder.jp/contests/abc077/tasks/arc084_a

import itertools
import collections
import bisect

def main():
    N = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    B.sort()
    C.sort()

    ans = 0

    for b in B:
        i = bisect.bisect_left(A, b)
        j = bisect.bisect_right(C, b)

        ans += i * (N - j)

    print(ans)


if __name__ == '__main__':
    main()
def gcd(m,n) :
    x = max(m,n)
    y = min(m,n)
    if x%y == 0 :
        return y
    else :
        while x%y != 0 :
            z = x%y
            x = y
            y = z
        else :
            return z

def lcm(m,n) :
    return int(m*n/gcd(m,n))

N,M = map(int,input().split())
S = list(input())
T = list(input())
L = lcm(N,M)
A = []
B = []
flag = 0
counter = 0
for i in range(N) :
    A.append(i*L//N+1)
for j in range(M) :
    b = j*L//M+1
    if j % (N//M) == 0 :
        index = N*j//M
        if S[index] == T[j] :
            counter += 1
        else :
            flag = 1
            break
    else :
        counter += 1
if flag == 1 :
    print(-1)
else :
    if counter == M :
        print(L)
#print(A)
#print(counter)
#print(flag)

### FIXED CODE ###

def gcd(m,n) :
    x = max(m,n)
    y = min(m,n)
    if x%y == 0 :
        return y
    else :
        while x%y != 0 :
            z = x%y
            x = y
            y = z
        else :
            return z

def lcm(m,n) :
    return int(m*n/gcd(m,n))

N,M = map(int,input().split())
S = list(input())
T = list(input())
L = lcm(N,M)
A = []
B = []
flag = 0
counter = 0
if N >= M :
    for i in range(N) :
        A.append(i*L//N+1)
    for j in range(M) :
        b = j*L//M+1
        if j*N % M == 0 :
            index = N*j//M
            if S[index] == T[j] :
                counter += 1
            else :
                flag = 1
                break
        else :
            counter += 1
    if flag == 1 :
        print(-1)
    else :
        if counter == M :
            print(L)
else :
    for i in range(M) :
        A.append(i*L//M+1)
    for j in range(N) :
        b = j*L//N+1
        if j*M % N == 0 :
            index = M*j//N
            if T[index] == S[j] :
                counter += 1
            else :
                flag = 1
                break
        else :
            counter += 1
    if flag == 1 :
        print(-1)
    else :
        if counter == N :
            print(L)
#! /usr/bin/env python3
input()
l = 10**18
a = 1
for i in map(int, input()):
    a *= i
    if a > l:
        a = -1
        break
print(a)

### FIXED CODE ###

#! /usr/bin/env python3
input()
l = 10**18
a = 1
*b, = map(int, input().split())
if 0 in b:
    a = 0
else:
    for i in b:
        a *= i
        if a > l:
            a = -1
            break
print(a)
a=list(map(int,input().split())
return len(set(a))

### FIXED CODE ###

l = list(map(int, input().split()))
s = set(l)

print(len(s))