Harryxun/sft_time huggingface dataset:
### BUGGY CODE ###

import math
n = int(input())
for i in range(1, n+1):
    ans = 0
    for x in range(1, int(math.sqrt(n))):
        x2 = x*x
        for y in range(1, int(math.sqrt(n))):
            y2 = y*y
            xy = x * y
            tmp = x2 + y2 + xy
            if tmp >= i:
                break
            for z in range(1, int(math.sqrt(n))):
                if tmp + z*z + y*z + z*x == i:
                    ans += 1
                    break
    print(ans)


### FIXED CODE ###

import math
n = int(input())
# ans = [0 for _ in range(n)]
ans = [0] * n

for x in range(1, int(math.sqrt(n+1))):
    x2 = x*x
    for y in range(1, int(math.sqrt(n+1))):
        y2 = y*y
        xy = x * y
        tmp = x2 + y2 + xy
        if tmp >= n:
            break
        for z in range(1, int(math.sqrt(n+1))):
            tmp2 = tmp + z*z + y*z + z*x
            if tmp2 > n:
                break
            try:
                ans[tmp2 - 1] += 1
                # print(x, y, z)
            except:
                pass
for i in range(n):
    print(ans[i])
### BUGGY CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()
    F = LI()

    A.sort()
    F.sort(reverse=True)

    # 時間tで感触できるか
    def can_complete(t):
        return sum([max(i-t//j, 0) for i, j in zip(A, F)]) <= K

    # for j in range(20):
    #     print(can_complete(j))

    ng = -1
    ok = max(A)*max(F)
    while abs(ok-ng)>1:
        m = (ng+ok)//2
        if can_complete(m):
            ok = m
        else:
            ng = m
    print(ok)

if __name__ == '__main__':
    resolve()


### FIXED CODE ###

import sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**20
def I(): return int(input())
def F(): return float(input())
def S(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LS(): return input().split()

def resolve():
    N, K = LI()
    A = LI()
    F = LI()

    A.sort()
    F.sort(reverse=True)

    # 時間tで感触できるか
    def can_complete(t):
        return sum([max(i-t//j, 0) for i, j in zip(A, F)]) <= K

    # for j in range(20):
    #     print(can_complete(j))

    ng = -1
    ok = max(A)*max(F)
    while abs(ok-ng)>1:
        m = (ng+ok)//2
        if can_complete(m):
            ok = m
        else:
            ng = m
    print(ok)

if __name__ == '__main__':
    resolve()
### BUGGY CODE ###

# from math import factorial,sqrt,ceil
from itertools import permutations as permus
# from fractions import gcd
from collections import deque,Counter
import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
S = input()

Sset = Counter(S)
iter = permus(list("RGB")) 

total = Sset["R"]*Sset["G"]*Sset["B"]

Slen = len(S)
# hikukazu = 0
ans = 0
for i in range(Slen):
    for j in range(i,Slen):
        for k in range(j,Slen):
            if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
                if not j-i == k-j:
                    ans += 1

# ans = total - hikukazu
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))


### FIXED CODE ###

# from math import factorial,sqrt,ceil
from itertools import permutations as permus
# from fractions import gcd
from collections import deque,Counter
import re
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# from scipy.sparse.csgraph import shortest_path, dijkstra, floyd_warshall, bellman_ford, johnson
# from scipy.sparse import csr_matrix

# strlist = "abcdefghijklmnopqrstuvwxyz"
N = int(input())
S = input()

Sset = Counter(S)
iter = permus(list("RGB")) 

total = Sset["R"]*Sset["G"]*Sset["B"]

Slen = len(S)
hikukazu = 0
for i in range(Slen):
    for num in range(1,Slen//2+1):
        j = i+num
        k = i+num*2
        if k>Slen-1:
            break
        if S[i]!=S[j] and S[i]!=S[k] and S[k]!=S[j]:
            hikukazu += 1

ans = total - hikukazu
print(ans)
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する
# print("{:.10f}".format(ans))
# print("{:0=10d}".format(ans))
### BUGGY CODE ###

import numpy as np
MOD = 10**9 + 7
def solve(s, p=13):
    s = s[::-1]
    n = len(s)
    dp = np.zeros((n, p), dtype=int)
    if s[0] == "?":
        dp[0, :10] = 1
    else:
        dp[0, int(s[0])] = 1
    for i in range(1,n):
        if s[i] == "?":
            v = list(range(10))
        else:
            v = [int(s[i])]
        for x in v:
            for j in range(p):
                k = (j + x * (10**i)) % p
                dp[i, k] = (dp[i, k] + dp[i-1, j]) % MOD
    return dp[n-1, 5]

s = input()
print(solve(s))

### FIXED CODE ###

MOD = 10**9 + 7

def solve(s, p=13):
    a = [0] * p
    a[0] = 1
    for c in s:
        b = [0] * p
        for i in range(p):
            b[(i*10)%p] = a[i] % MOD
        b += b
        if c == "?":
            for i in range(p):
                a[i] = sum(b[i+4:i+p+1])
        else:
            for i in range(p):
                a[i] = b[i+p-int(c)]
    return a[5] % MOD

s = input()
print(solve(s))
### BUGGY CODE ###

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

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

# dp[i] = 足場iに移動するのに必要な最小コスト
dp = [0 for _ in range(N)]


def get_costs(i):
    """足場iに1回で辿り着くためのコストをイテレータで返す"""
    # 足場iへ1回で行く方法は1～KのK通り
    for k in range(1, K + 1):
        # 出発点がマイナスになるようなルートはスキップ
        if i - k < 0:
            continue
        # print(f"i:{i} k:{k} cost:{dp[i - k] + abs(h[i] - h[i - k])}")
        # K歩進んだときのコストを返す
        yield dp[i - k] + abs(h[i] - h[i - k])


# DP配列更新
for i in range(1, N):
    # 最小コストで更新する
    dp[i] = min(list(get_costs(i)))

print(dp[-1])


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-
import numpy as np

N, K = map(int, input().split())
h = list(map(int, input().split()))
# 高速化のためにnumpy使う
h = np.array(h)

# dp[i] = 足場iに移動するのに必要な最小コスト
dp = [0 for _ in range(N)]
# 高速化のためにnumpy使う
dp = np.array(dp)

# DP配列更新
"""
TLEだったやつ
for i in range(1, N):
    # 最小コストで更新する
    max_k = min([i, K]) + 1
    dp[i] = min([dp[i - k] + abs(h[i] - h[i - k]) for k in range(1, max_k)])
"""
for i in range(1, N):
    # 最小コストで更新する
    # K個まとめて移動コストを計算することで高速化
    # ただしマイナスからスタートするような値はスキップする
    s = max(0, i - K)
    dp[i] = np.min(dp[s:i] + np.abs(h[s:i] - h[i]))

print(dp[-1])
### BUGGY CODE ###

import sys, bisect, copy
# import numpy as np
# import scipy
from collections import defaultdict
input = sys.stdin.readline
mod = 998244353
def main():
    n,s = map(int,input().split())
    a = list(map(int, input().split()))
    dp = [[defaultdict(int) for _ in range(s+1)] for _ in range(n+1)]
    dp1 = [[defaultdict(int) for _ in range(s+1)] for _ in range(n+1)]
    dp2 = [0 for _ in range(n+1)]
    dp2[0] = 1
    for i in range(n):
        dp2[i+1] = dp2[i]*2
        dp2[i+1] %= mod
    dp[0][0][0] = 1
    dp1[0][0][0] = 1
    ans = 0
    for i in range(n):
        for j in range(s,-1,-1):
            if j-a[i] < 0:
                continue
            if not dp1[i][j-a[i]]:
                continue
            for e in dp[i][j-a[i]]:
                if not dp1[i][j-a[i]][e]:
                    continue
                dp[i+1][j][e+1] += dp[i][j-a[i]][e]
                dp1[i+1][j][e+1] = 1
            if j == s and len(dp[i+1][j]):
                for e in dp[i+1][j]:
                    ans += dp[i+1][j][e]*dp2[n-e]
                    ans %= mod
        for j in range(s-1,-1,-1):
            for e in dp[i][j]:
                dp[i+1][j][e] += dp[i][j][e]
                dp1[i+1][j][e] = 1
    print(ans)
if __name__ == "__main__":
    main()

### FIXED CODE ###

import sys
from collections import defaultdict
input = sys.stdin.readline
mod = 998244353
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2] != 1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]
def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return ( m + x%m ) % m
def main():
    n,s = map(int,input().split())
    a = list(map(int, input().split()))
    dp = [[0 for _ in range(s+1)] for _ in range(n+1)]
    dp[0][0] = pow(2,n,mod)
    MODINV2 = mod_inv(2,mod)
    ans = 0
    for i in range(n):
        for j in range(s,-1,-1):
            if j-a[i] < 0:
                continue
            dp[i+1][j] += dp[i][j-a[i]]*MODINV2
            dp[i+1][j] %= mod
        for j in range(s,-1,-1):
            if j == s:
                ans += dp[i+1][j]
                ans %= mod
            else:
                dp[i+1][j] += dp[i][j]
                dp[i+1][j] %= mod
    print(ans)
if __name__ == "__main__":
    main()
### BUGGY CODE ###

# coding: utf-8
from pdb import set_trace
from collections import Counter

N = int(input())
L = sorted(list(map(int, input().split(" "))), reverse=True)
C = dict(Counter(L))
L = sorted(list(set(L)), reverse=True)

if N<3 or len(L)<3:
    print(0)
    exit()
li = []
for xa, a in enumerate(L[:-2]):
    for xb, b in enumerate(L[xa+1:-1]):
        for xc, c in enumerate(L[xa+2:]):
            if a+b<c:
                break
            if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
                _li = sorted([xa, xb+xa+1, xc+xa+2])
                if _li in li:
                    continue
                li.append(_li)
cnt = 0
for l in li:
    a = C[L[l[0]]]
    b = C[L[l[1]]]
    c = C[L[l[2]]]
    cnt += (a * b * c)
print(cnt)

### FIXED CODE ###

# coding: utf-8
from pdb import set_trace
#from collections import Counter
import itertools

N = int(input())
L = list(map(int, input().split(" ")))
# print(L)

# C = dict(Counter(L))
# L = sorted(list(set(L)), reverse=True)

# if N<3 or len(L)<3:
#     print(0)
#     exit()
# li = []
# for xa, a in enumerate(L[:-2]):
#     for xb, b in enumerate(L[xa+1:-1]):
#         for xc, c in enumerate(L[xa+2:]):
#             if a+b<c:
#                 break
#             if a+b>c and b+c>a and c+a>b and a!=b and b!=c and c!=a:
#                 _li = sorted([xa, xb+xa+1, xc+xa+2])
#                 if _li in li:
#                     continue
#                 li.append(_li)
# cnt = 0
# for l in li:
#     a = C[L[l[0]]]
#     b = C[L[l[1]]]
#     c = C[L[l[2]]]
#     cnt += (a * b * c)
# print(cnt)
cnt = 0
TRI = list(itertools.combinations(L, 3))
for tri in TRI:
    a, b, c = tri
    if a==b or b==c or c==a:
        continue
    elif a+b>c and a+c>b and b+c>a:
        cnt += 1
print(cnt)
### BUGGY CODE ###

def main():
	s = tuple(input())
	length = len(s)

	dp = [[0 for _ in range(13)]for _ in range(length+1)]
	MOD = 10**9+7
	if s[-1] == '?':
		for i in range(10):
			dp[1][i] = 1
	else:
		dp[1][int(s[-1])] = 1

	for i in range(1,length):
		if s[-i-1] != '?':
			num = (int(s[-i-1]) * (10**i)) % 13
			for j in range(13):
				dp[i+1][j] = dp[i][(13-num+j)%13]
				dp[i+1][j] %= MOD
		else:
			num = (10**i) % 13
			a = 0
			for j in range(10):
				for k in range(13):
					dp[i+1][k] += dp[i][(13-a+k)%13]
					dp[i+1][k] %= MOD
				a += num

	print(dp[length][5] % MOD)

if __name__ == '__main__':
	main()

### FIXED CODE ###

INF = 10 ** 9 + 7

S = input()
# dp[i][j]はうしろからi桁を13で割った余りがjであるものの個数
dp = [[0] * 13 for _ in range(len(S) + 1)]
dp[0][0] = 1
mul = 1

for i in range(len(S)):
    x = S[-(i + 1)]
    if x == "?":
        for k in range(10):
            for j in range(13):
                dp[i + 1][(mul * k + j) % 13] += dp[i][j]
                dp[i + 1][(mul * k + j) % 13] %= INF
    else:
        k = int(x)
        for j in range(13):
            dp[i + 1][(mul * k + j) % 13] += dp[i][j]
            dp[i + 1][(mul * k + j) % 13] %= INF
    mul = mul * 10 % 13  # 計算量削減のためここで13で割っている

print(dp[len(S)][5])
### BUGGY CODE ###

N = int(input())
As = list(map(int,input().split()))
As.sort(reverse=True)
first_d = As[0]
for d in range(first_d):
    cnt = 0
    for i in range(N):
        if As[i] % (first_d-d) == 0:
            cnt += 1
    if cnt >= N-1:
        ans = first_d-d
        break
print(ans)

### FIXED CODE ###

N = int(input())
As = list(map(int,input().split()))
As.sort(reverse=True)
first_d = As[0]
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

if N == 2:
    print(max(As))
else:
    first = make_divisors(As[0])
    second = make_divisors(As[1])
    third  = make_divisors(As[2])
    div_list = list((set(first) & set(second)) | (set(first) & set(third)) | (set(third) & set(second)))
    div_list.sort(reverse=True)
    
    for d in range(len(div_list)):
        cnt = 0
        for i in range(N):
            if As[i] % (div_list[d]) != 0:
                cnt += 1
                if cnt > 1:
                    break
        if cnt <= 1 :
            ans = div_list[d]
            break
    print(ans)
### BUGGY CODE ###

first_input = list(map(int, input().split()))
number = first_input[0]
steps = first_input[1]

scaffolds = list(map(int, input().split()))

start_cost = scaffolds[0]

costs = [start_cost for i in range(number)]

for i in range(number):
    next_step = i
    next_scaffold = scaffolds[next_step]
    last_costs = [-1 for i in range(steps)]
    for j in range(steps):
        
        last_step = next_step - (j + 1)
        if -1 < last_step:
            last_costs[j] = abs(scaffolds[next_step] - scaffolds[last_step]) + costs[last_step]
    target_costs = [k for k in last_costs if 0 <= k]
    if 0 < len(target_costs):
        next_cost = min(target_costs)
    else:
        next_cost = scaffolds[next_step]

    if -1 < next_cost:
        costs[i] = next_cost

print(costs[number - 1] - start_cost)

### FIXED CODE ###

first_input = list(map(int, input().split()))
number = first_input[0]
steps = first_input[1]

scaffolds = list(map(int, input().split()))

start_cost = scaffolds[0]

costs = []

for i in range(number):
    next_step = i
    next_scaffold = scaffolds[next_step]
    target_cost = -1
    for j in range(steps):
        
        last_step = next_step - (j + 1)
        if -1 < last_step:
            cost = abs(scaffolds[next_step] - scaffolds[last_step]) + costs[last_step]
            if target_cost == -1 or cost < target_cost:
                target_cost = cost

    if 0 < target_cost:
        next_cost = target_cost
    else:
        next_cost = scaffolds[next_step]

    
    costs.append(next_cost)

print(costs[number - 1] - start_cost)
### BUGGY CODE ###

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

n, q = map(int,input().split())
s = list(input())
l = [0] * q
r = [0] * q
for i in range(q):
    l[i],r[i] = map(int,input().split())

aclist = []

for i in range(n):
    if s[i-1] == "A" and s[i] == "C":
        aclist.append(i-1)

def account(num,arr):
    cnt = 0
    for i in range(len(arr)):
        if arr[i] + 1 <= num - 1:
            cnt += 1
    return cnt

for i in range(q):
    ans = account(r[i],aclist) - account(l[i],aclist)
    print(ans)


### FIXED CODE ###

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

n, q = map(int,input().split())
s = list(input())
l = [0] * q
r = [0] * q
for i in range(q):
    l[i],r[i] = map(int,input().split())

aclist = []

cnt = 0
for i in range(n):
    if s[i-1] == "A" and s[i] == "C":
        cnt += 1
        aclist.append(cnt)
    else:
        aclist.append(cnt)

for i in range(q):
    print(aclist[r[i]-1] - aclist[l[i]-1])
### BUGGY CODE ###

import math
n = int(input())
l = [0 for i in range(n)]
for x in range(1, math.ceil(n)+1):
    for y in range(1, math.ceil(n)+1):
        for z in range(1, math.ceil(n)+1):
            s = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if s <= n:
                l[s-1] += 1
for i in range(n):
    print(l[i])

### FIXED CODE ###

#import math
n = int(input())
l = [0 for i in range(n)]
for x in range(1, 101):
    for y in range(1, 101):
        for z in range(1, 101):
            s = x**2 + y**2 + z**2 + x*y + y*z + z*x;
            if s <= n:
                l[s-1] += 1
for i in range(n):
    print(l[i])
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
answer = []

for x, y in enumerate(a):
  sum = 0
  present = 0
  for s, t in enumerate(a):
    if s != x:
      cost = abs(t-present)
      sum += cost
      present = t
  sum += abs(present-0)
  answer.append(sum)
  print(sum)


### FIXED CODE ###

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


sum = 0
present = 0
for s, t in enumerate(a):
  sum += abs(t-present)
  present = t
sum += abs(present-0)

for i, each in enumerate(a):
  if i == 0:
    prev = 0
    tmp = each
    next = a[i+1]
  elif i == len(a)-1:
    prev = a[i-1]
    tmp = each
    next = 0
  else:
    prev = a[i-1]
    tmp = each
    next = a[i+1]

  before = abs(prev-tmp) + abs(tmp - next)
  after = abs(prev - next)

  print(sum - before + after)
### BUGGY CODE ###

import math
N = int(input())

def factorization(n):
  a = 1
  temp = n
  for i in range(2, int(math.sqrt(n))+1):
    if temp%i == 0:
      cnt = 1
      while temp%i==0:
        cnt += 1
        temp //= i
      a *= cnt
  if temp != 1:
    a *= 2
  return a

if N <= 4*(10**5):
  ans = 0
  for i in range(1, N):
    ans += factorization(i)
elif 4*(10**5) < N <= 6*(10**5):
  ans = 5221424
  for i in range(4*(10**5), N):
    ans += factorization(i)
elif 6*(10**5) < N <= 8*(10**5):
  ans = 8075420
  for i in range(6*(10**5), N):
    ans += factorization(i)
elif 8*(10**5) < N <= 9*(10**5):
  ans = 10997400
  for i in range(8*(10**5), N):
    ans += factorization(i)
else:
  ans = 12478098
  for i in range(9*(10**5), N):
    ans += factorization(i)
print(ans)

### FIXED CODE ###

import math
N = int(input())

def factorization(n):
  a = 1
  temp = n
  for i in range(2, int(math.sqrt(n))+1):
    if temp%i == 0:
      cnt = 1
      while temp%i==0:
        cnt += 1
        temp //= i
      a *= cnt
  if temp != 1:
    a *= 2
  return a

if N <= 4*(10**5):
  ans = 0
  for i in range(1, N):
    ans += factorization(i)
elif 4*(10**5) < N <= 6*(10**5):
  ans = 5221424
  for i in range(4*(10**5), N):
    ans += factorization(i)
elif 6*(10**5) < N <= 8*(10**5):
  ans = 8075420
  for i in range(6*(10**5), N):
    ans += factorization(i)
elif 8*(10**5) < N <= 9*(10**5):
  ans = 10997400
  for i in range(8*(10**5), N):
    ans += factorization(i)
else:
  ans = 12478098
  for i in range(9*(10**5), N):
    ans += factorization(i)
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	n = int(input())
	
	p = 1
	for i in range(1, n+1):
		p = p * i
		
	print(p % 1000000007)
	
if __name__ == "__main__":
	main()
	

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys

def main():
	n = int(input())
	
	p = 1
	for i in range(1, n+1):
		p = (p * i) % 1000000007
		
	print(p)
	
if __name__ == "__main__":
	main()
### BUGGY CODE ###

N = int(input())
po = 1
for i in range(1,N+1):
    po *= i
print(po%(1000000007))

### FIXED CODE ###

import math
N = int(input())
po = math.factorial(N)
print(po%(1000000007))
### BUGGY CODE ###

import math

n = int(input())

c = {"Vacant":0, "Male":1, "Female":2}
d = [0] * n

print(0)
d[0] = c[input()]

lb = 1
ub = n
while ub - lb > 1:
    mid = (ub + lb) // 2
    print(mid)
    d[mid] = c[input()]
    len1 = mid - lb
    le2 = ub - mid -1
    if len1 % 2:
        if d[lb-1] == d[mid]:
            lb = mid + 1
        else:
            ub = mid
    else:
        if d[lb-1] == d[mid]:
            ub = mid
        else:
            lb = mid + 1


### FIXED CODE ###

n = int(input())

lb, ub = 0, n
print(lb, flush=True)
s = str(input())
if s == 'Vacant':
    exit()
for i in range(19):
    mid = (lb + ub) // 2
    print(mid, flush=True)
    t = str(input())
    if t == 'Vacant':
        exit()
    if (mid - lb) % 2 == 0 and s == t:
        lb = mid
    elif (mid - lb) % 2 == 0 and s != t:
        ub = mid
    elif s == t:
        ub = mid
    else:
        lb, s = mid, t
### BUGGY CODE ###

n = input()
top = map(int, raw_input().split())
top.sort()
middle = map(int, raw_input().split())
middle.sort()
under = map(int, raw_input().split())
under.sort()
cnt = 0
for i in top[::-1]:
    for j in middle[::-1]:
        if j <= i: break
        for k in under[::-1]:
            if k <= j: break
            cnt += 1
            # print '{} {} {}'.format(i,j,k)

print cnt

### FIXED CODE ###

# coding:utf-8

INF = float('inf')


def inpl(): return list(map(int, input().split()))


N = int(input())
A = sorted(inpl())
B = sorted(inpl())
C = sorted(inpl())

ans = 0
i_a = 0
i_c = 0
for i_b in range(N):
    while i_a < N and A[i_a] < B[i_b]:
        i_a += 1
    while i_c < N and C[i_c] <= B[i_b]:
        i_c += 1

    ans += i_a * (N - i_c)

print(ans)
### BUGGY CODE ###

import numpy as np
n, m, k = [int(n) for n in input().split()]
A = [int(n) for n in input().split()]
B = [int(n) for n in input().split()]

A = np.cumsum([0] + A)
B = np.cumsum([0] + B)
n_read = 0
for i, a in enumerate(A):
    if a > k:
        break
    if B[-1] + a > k:
        for j, b in enumerate(B[::-1]):
            if a + b <= k:
                n_read = max(n_read,  i + len(B) - j - 1)
                break
    else:
        n_read = max(n_read, i + len(B) - 1)
print(n_read)


### FIXED CODE ###

from numpy import cumsum
n, m, k = list(map(int, input().split()))
A = list(map(int, input().split()))
B = list(map(int, input().split()))

A = cumsum([0] + A)
B = cumsum([0] + B)
n_read = 0
l = len(B) - 1
for i, a in enumerate(A):
    if a > k:
        break
    for j, b in enumerate(B[l::-1]):
        if a + b <= k:
            l -= j
            n_read = max(n_read, i + l)
            break
print(n_read)
### BUGGY CODE ###

import sys
import numpy as np
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))


def solve():
    n, k =read(); arr = read()
    dp = np.array([-1 for i in range(n)]); dp[0] = 0
    for i in range(n):
    	for j in range(1, k+1):
    		if i-j >-1:
    			tem = dp[i-j]+abs(arr[i-j] - arr[i])
    			if dp[i] == -1:
    				dp[i] = tem
    			else:
    				dp[i] = min(dp[i], tem)
    print(dp[-1])

    

if __name__ == "__main__":
	solve()

### FIXED CODE ###

import sys
# import numpy as np
inp = sys.stdin.readline
read = lambda: list(map(int, inp().strip().split()))
# import profile

def solve():
    n, k =read(); arr = read()
    dp = [-1]*n; dp[0] = 0
    for i in range(n):
    	for j in range(1, k+1):
    		if i-j >-1:
    			tem = dp[i-j]+abs(arr[i-j] - arr[i])
    			if dp[i] == -1:
    				dp[i] = tem
    			elif dp[i] > tem:
    				dp[i] = tem
    				# dp[i] = min(dp[i], tem)
    print(dp[-1])

def one():
	l = [0]*10**7
def two():
	l = [0 for i in range(10**7)]

if __name__ == "__main__":
	solve()
	# cProfile.run(solve())
	# profile.run(one())
	# cProfile.run()