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

import heapq

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

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

# それぞれソート
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

# 処理済みフラグ
confilm = []

q = [(-(A[0] + B[0] + C[0]) , 0,0,0)]
confilm.append((0,0,0))

for _ in range(K) :
    val , i , j , k = heapq.heappop(q)

    print(-val)

    t = (i+1,j,k)
    if i + 1 < X and not t in confilm :
        heapq.heappush(q,(-(A[i+1] + B[j] + C[k]),) + t)
        confilm.append(t)
    t = (i,j+1,k)
    if j + 1 < Y and not t in confilm :
        heapq.heappush(q,(-(A[i] + B[j+1] + C[k]),) + t)
        confilm.append(t)
    t = (i,j,k+1)
    if k + 1 < Z and not t in confilm :
        heapq.heappush(q,(-(A[i] + B[j] + C[k+1]),) + t)
        confilm.append(t)




### FIXED CODE ###

from heapq import heappop , heappush

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

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

# それぞれソート
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)

# 処理済みフラグ
confilm = []

q = [(-(A[0] + B[0] + C[0]) , 0,0,0)]

for _ in range(K) :
    val , i , j , k = heappop(q)

    print(-val)

    t = (i+1,j,k)
    if i + 1 < X and not t in confilm :
        heappush(q,(-(A[i+1] + B[j] + C[k]),) + t)
        confilm.append(t)

    t = (i,j+1,k)
    if j + 1 < Y and not t in confilm :
        heappush(q,(-(A[i] + B[j+1] + C[k]),) + t)
        confilm.append(t)

    t = (i,j,k+1)
    if k + 1 < Z and not t in confilm :
        heappush(q,(-(A[i] + B[j] + C[k+1]),) + t)
        confilm.append(t)
### BUGGY CODE ###

X = int(input().strip())
states = {0}
for i in range(1,X+1):
  next_set = {s+i for s in states}
  if X in next_set:
    print(i)
    break
  states |= next_set

### FIXED CODE ###

X = int(input().strip())
now_max = 0
for i in range(1,X+1):
  now_max += i
  if X <= now_max:
    print(i)
    break
### BUGGY CODE ###

a,b,c=map(int,input().split())
l=[]
k=0
for i in range(a):
    for g in range(b):
        l.append("1")
    for g in range(c):
        l.append("2")
for j in range(a):
    if l==[]:
        k=0
        break
    elif l[j]== "1":
        k+=1
print(k)

### FIXED CODE ###

n,a,b = map(int, input().split())
g = n//(a+b)
k = n-(a+b)*g
if k >= a:
    print(a+a*g)
else:
    print(a*g + k)
### BUGGY CODE ###

N = int(input())
Xs = []
Ys = []
for i in range(N):
    x, y = map(int, input().split())
    Xs.append((x, i))
    Ys.append((y, i))
Xs.sort()
Ys.sort()
Edges = []
for i in range(1, N):
    (x1, v1), (x2, v2) = Xs[i-1], Xs[i]
    Edges.append((abs(x1-x2), v1, v2))
    (y1, v1), (y2, v2) = Ys[i-1], Ys[i]
    Edges.append((abs(y1-y2), v1, v2))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

import heapq
heapq.heapify(Edges)
uf = UnionFind(N)
ans = 0
while Edges:
    d, a, b = heapq.heappop(Edges)
    if not uf.same(a, b):
        ans += d
        uf.union(a, b)
print(ans)

### FIXED CODE ###

N = int(input())
Xs = []
Ys = []
for i in range(N):
    x, y = map(int, input().split())
    Xs.append((x, i))
    Ys.append((y, i))
Xs.sort()
Ys.sort()
Edges = []
for i in range(1, N):
    (x1, v1), (x2, v2) = Xs[i-1], Xs[i]
    Edges.append((abs(x1-x2), v1, v2))
    (y1, v1), (y2, v2) = Ys[i-1], Ys[i]
    Edges.append((abs(y1-y2), v1, v2))

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

import heapq
heapq.heapify(Edges)
uf = UnionFind(N)
ans = 0
while Edges:
    d, a, b = heapq.heappop(Edges)
    if not uf.same(a, b):
        ans += d
        uf.union(a, b)
print(ans)
### BUGGY CODE ###

n,m=map(int,input().split())
lm=[]
m1=m
while m1!=0:
  lm.append(m1%2)
  m1=m1//2
ln=[]
n1=n-1
while n1!=0:
  ln.append(n1%2)
  n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
lm1=[0 for i in range(len(lm))]
ln1=[0 for i in range(len(ln))]
if lm[0]!=lm[1]:
  lm1[0]=1
if ln[0]!=ln[1]:
  ln1[0]=1
for i in range(1,len(lm)):
  if lm[i]==1 and lm[0]==0:
    lm1[i]=1
for i in range(1,len(ln)):
  if ln[i]==1 and ln[0]==0:
    ln1[i]=1
lmn=[0 for i in range(len(lm))]
for i in range(len(lm)):
  if lm1[i]==ln1[i]:
    pass
  else:
    lmn[i]=1
s=1
ss=0
for i in lmn:
  ss+=s*i
  s*=2
print(ss)

### FIXED CODE ###

n,m=map(int,input().split())
lm=[]
m1=m
if m!=0:
  while m1!=0:
    lm.append(m1%2)
    m1=m1//2
else:
  lm=[0]
ln=[]
n1=n-1
if n!=0:
  while n1!=0:
    ln.append(n1%2)
    n1=n1//2
while len(ln)!=len(lm):
  ln.append(0)
if n!=0:
  lm1=[0 for i in range(len(lm))]
  ln1=[0 for i in range(len(ln))]
  if lm[0]!=lm[1]:
    lm1[0]=1
  if ln[0]!=ln[1]:
    ln1[0]=1
  for i in range(1,len(lm)):
    if lm[i]==1 and lm[0]==0:
      lm1[i]=1
  for i in range(1,len(ln)):
    if ln[i]==1 and ln[0]==0:
      ln1[i]=1
  lmn=[0 for i in range(len(lm))]
  for i in range(len(lm)):
    if lm1[i]==ln1[i]:
      pass
    else:
      lmn[i]=1
  s=1
  ss=0
  for i in lmn:
    ss+=s*i
    s*=2
  print(ss)
else:
  print(m)
### BUGGY CODE ###

n, k = map(int, input().split())
p = list(map(int, input().split()))
q = []
for i in p:
    q.append((1+i) / 2)

ans = 0
for i in range(len(q)):
    ans = max(ans, sum(q[i:i+k]))
print(ans)

### FIXED CODE ###

n, k = map(int, input().split())
p = [(1+int(x)) / 2.0 for x in input().split()]

ans = sum(p[0:k])
tmp = sum(p[0:k])

for i in range(0, n-k):
    tmp = tmp - p[i] + p[i+k]
    ans = max(ans, tmp)

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

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

c = N - K + 1
l = []

for i in range(K, N + 1):
    ans = 1
    for j in range(1, K + 1):
        ans *= A[i - j]
    l.append(ans)

for i in range(c - 1):
    if l[i] < l[i + 1]:
        print("Yes")
    else:
        print("No")

### FIXED CODE ###

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

c = N - K
l = []

for j in range(K, N):
        l.append(A[j - K])
        l.append(A[j])

L = len(l)
for i in range(0, L, 2):
    if l[i + 1] > l[i]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

#
import sys
import math
import numpy as np
import itertools

n = int(input())
a=[]
b=[]
c=[]
d=[]
for j in range(0,n):
    t1,t2,t3,t4 = (int(i) for i in input().split())  
    a.append(t1)
    b.append(t2)
    c.append(t3)
    d.append(t4)
    
for i in range(0,n):
    if a[i] < b[i]:
        print("No")
    elif d[i] < b[i]:
        print("No")
    else:
        flag=1
        for j in range(0,b[i]):
            p= (a[i]+j*d[i]) % b[i]
            if p > c[i] and p != 0 :
                flag=0
        if flag == 1:
            print("Yes")
        else:
            print("No")
    


### FIXED CODE ###

#
import sys

n = int(input())
a=[]
b=[]
c=[]
d=[]
for j in range(0,n):
    t1,t2,t3,t4 = (int(i) for i in input().split())  
    a.append(t1)
    b.append(t2)
    c.append(t3)
    d.append(t4)
    
for i in range(0,n):
    if a[i] < b[i]:
        print("No")
    elif d[i] < b[i]:
        print("No")
    else:
        p= b[i]
        q= d[i]
        while p%q :
            r=q
            q=p%q
            p=r
        if (b[i]-q)+a[i]%q > c[i]:
            print("No")
        else:
            print("Yes")
### BUGGY CODE ###

import sys
N = int(input())
H = input().split()

count = 0
max = 0
flag = []
for i in (range(int(N)-1)):
  if(int(H[i]) >= int(H[i+1])):
    flag.append(i)
  else:
    continue

for i in flag:
  for j in range(i,int(N)):
    if(j == int(N)-1):
      count = j - i
      break

    if(int(H[j]) >= int(H[j+1])):
      continue
    else:
      count = j - i
      break

  if (max < count):
    max = count
    count = 0

print(max)

### FIXED CODE ###

n = int(input())
L = list(map(int,input().split()))
 
count = 0
mcount = 0
for i in range(1,n):
      if L[i - 1] >= L[i]:
            count += 1
            if count >= mcount:
                  mcount = count
      else:
            count = 0
print(mcount)
### BUGGY CODE ###

# Cosmic rays
import math
import heapq

xs, ys, xt, yt = map(int, input().split())
N = int(input())

d = [((xs, ys), 0, 0)]
# node,radius

for _ in range(N):
    x, y, r = map(int, input().split())
    d.append(((x, y), _+1, r))

graph = {i: [] for i in range(N+2)}

d.append(((xt, yt), N+1, 0))
for i in range(N+2):
    for j in range(i+1, N+2):
        p, point, rad = d[i]
        q, point2, rad2 = d[j]
        D = math.hypot(p[0]-q[0], p[1]-q[1])
        if D > (rad+rad2):
            graph[i].append((D-rad-rad2, j))
            graph[j].append((D-rad-rad2, i))
        else:
            graph[i].append((0, j))
            graph[j].append((0, i))


def dijkstra(s, graph):
    n = len(graph)
    dist = [float("inf") for i in range(n+1)]
    dist[s] = 0
    pq = []
    heapq.heapify(pq)
    heapq.heappush(pq, (0, s))
    while pq:
        mini_dis, node = heapq.heappop(pq)
        if dist[node] < mini_dis:
            continue
        for w, point in graph[node]:
            if dist[point] < w:
                continue
            newlen = dist[node]+w
            if newlen < dist[point]:
                heapq.heappush(pq, (newlen, point))
                dist[point] = newlen
    return dist

K=dijkstra(0,graph)[N+1]
print(K)


### FIXED CODE ###

# Cosmic rays
import math
import heapq

xs, ys, xt, yt = map(int, input().split())
N = int(input())

d = [((xs, ys), 0, 0)]
# node,radius

for _ in range(N):
    x, y, r = map(int, input().split())
    d.append(((x, y), _+1, r))

graph = {i: [] for i in range(N+2)}

d.append(((xt, yt), N+1, 0))
for i in range(N+2):
    for j in range(i+1, N+2):
        p, point, rad = d[i]
        q, point2, rad2 = d[j]
        D = math.hypot(p[0]-q[0], p[1]-q[1])
        if D > (rad+rad2):
            graph[i].append((D-rad-rad2, j))
            graph[j].append((D-rad-rad2, i))
        else:
            graph[i].append((0, j))
            graph[j].append((0, i))


def dijkstra(s, graph):
    n = len(graph)
    dist = [float("inf") for i in range(n+1)]
    dist[s] = 0
    pq = []
    heapq.heapify(pq)
    heapq.heappush(pq, (0, s))
    while pq:
        mini_dis, node = heapq.heappop(pq)
        if dist[node] < mini_dis:
            continue
        for w, point in graph[node]:
            if dist[point] < w:
                continue
            newlen = dist[node]+w
            if newlen < dist[point]:
                heapq.heappush(pq, (newlen, point))
                dist[point] = newlen
    return dist

K=dijkstra(0,graph)[N+1]
print(K)
### BUGGY CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = []
for i in range(1,n+1):
  for j in range(n):
    if i == a[j]:
      ans.append(j+1)
      break
print(*ans,sep=' ')

### FIXED CODE ###

n = int(input())
a = list(map(int,input().split()))
ans = [0]*n
for i in range(n):
  ans[a[i]-1] = i+1

print(*ans,sep=' ')
### BUGGY CODE ###

H,N=map(int,input().split())
AB=[]
for i in range(N):
    AB.append(list(map(int,input().split())))
maxA=max(AB)[0]
#dp[i] ひとつ前までの呪文で体力iを削るために必要な最小魔法消費量
dp=[float("inf")]*(H+maxA)
ndp=[float("inf")]*(H+maxA)
dp[0]=0
for j in range(N):
    for i in range(H+1):
        ndp[i]=dp[i]
    cost=AB[j][1]
    fire=AB[j][0]
    for i in range(H+1):
        repeat=0
        while i+fire*repeat<H:
            repeat+=1
            ndp[i+fire*repeat]=min(dp[i]+cost*repeat,ndp[i+fire*repeat])
    dp=ndp[:]

ans=float("inf")
for i in range(H,H+maxA):
    ans=min(ans,dp[i])
print(ans)







### FIXED CODE ###

H,N=map(int,input().split())
AB=[]
for i in range(N):
    AB.append(list(map(int,input().split())))
maxA=max(AB)[0]
#dp[i] 敵に合計iダメージを与えるのに必要な最小魔力量
dp=[float("inf")]*(H+maxA)
dp[0]=0
for i in range(H):
    for fire,cost in AB:
        dp[i+fire]=min(dp[i+fire],dp[i]+cost)

ans=min(dp[H:])
print(ans)
### BUGGY CODE ###

import sys
import heapq

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

n, m = inm()
a = inl()


def solve():
    heapq.heapify(a)
    for i in range(m):
        b, c = inm()
        for j in range(b):
            if a[0] >= c:
                break
            heapq.heappush(a, c)
            heapq.heappop(a)
    return sum(a)


print(solve())


### FIXED CODE ###

n,m = map(int,input().split())
a = list(map(int,input().split()))
assert len(a) == n
cb = [None]*m
for i in range(m):
    b, c = map(int,input().split())
    cb[i] = (c,b)
a.sort(reverse=True)
cb.sort(reverse=True)

def solve():
    ai = 0
    ci = 0
    res = [None]*n
    for i in range(n):
        if ci >= len(cb):
            cx, bx = -100, 1
        else:
            cx, bx = cb[ci]
        ax = a[ai]
        if ax >= cx:
            res[i] = ax
            ai += 1
        else:
            res[i] = cx
            cb[ci] = (cx, bx-1)
            if bx-1 <= 0:
                ci += 1
    return sum(res)

print(solve())
### BUGGY CODE ###

def main():
    N = int(input())
    table = [''.join(sorted(list(input()))) for _ in range(N)]
    sort_table = list(set(list(table)))
    ans = 0
    for i in sort_table:
        n = table.count(i)
        if n <= 1:
            continue
        x = (n * (n - 1)) // 2
        ans += x

    print(ans)


if __name__ == '__main__':
    main()


### FIXED CODE ###

import collections


def main():
    N = int(input())
    table = [''.join(sorted(list(input()))) for _ in range(N)]
    sort_table = set(table)
    cnt_table = collections.Counter(table)
    ans = 0
    for i in sort_table:
        num_of_i = cnt_table[i]
        if num_of_i <= 1:
            continue
        x = (num_of_i * (num_of_i - 1)) // 2
        ans += x

    print(ans)


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

from math import floor
A, B, N = map(int, input().split())
AdB = A/B

m = 0
for x in range(1, N + 1):
    n = floor(x * AdB) - A * floor(x / B)
    if n > m:
        m = floor(x * AdB) - A * floor(x / B)
print(m)


### FIXED CODE ###

from math import floor
A, B, N = map(int, input().split())
print(floor((min(N + 1, B) - 1) * A / B))
### BUGGY CODE ###

# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

K, S = list(map(int, input().split()))

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        # Z
        for k in range(K + 1):
            if i + j + k == S:
                cnt += 1
print(cnt)


### FIXED CODE ###

# 0 ≦ X, Y, Z ≦ K
# X + Y + Z = S
# 2 ≦ K ≦ 2500
# 0 ≦ S ≦ 3K

K, S = list(map(int, input().split()))

cnt = 0
# X
for i in range(K + 1):
    # Y
    for j in range(K + 1):
        Z = S - i - j
        if 0 <= Z and Z <= K:
            cnt += 1
print(cnt)
### BUGGY CODE ###

n,m = map(int,input().split())
a = [int(input()) for i in range(m)]
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
j=0
for i in range(1,n+1):
  for j in range(m):
    dp[a[j]] = 0
    continue
  if i==1:
    dp[1] = dp[0]
    continue
  dp[i] = dp[i-1]+dp[i-2]
  dp[i]%=mod
print(dp[n])

### FIXED CODE ###

n,m = map(int,input().split())
#a = [int(input()) for i in range(m)]
a=set()
for i in range(m):
    tmp=int(input())
    a.add(tmp)
mod = 10**9+7
dp = [0]*(n+1)
dp[0] = 1
j=0
for i in range(1,n+1):
  if i in a:
    #dp[a[j]] = 0 
    continue
  if i==1:
    dp[1] = dp[0]
    continue
  dp[i] = dp[i-1]+dp[i-2]
  dp[i]%=mod
print(dp[n])
### BUGGY CODE ###

N, M = map(int, input().split(" "))
As = list(map(int, input().split(" ")))

for _ in range(M):
  i = As.index(max(As))
  As[i] = As[i]//2

print(sum(As))

### FIXED CODE ###

import heapq
 
N, M = map(int, input().split(" "))
As = [-i for i in map(int, input().split(" "))]
As.sort()
heapq.heapify(As)

for _ in range(M):
  i = - heapq.heappop(As)
  i = i >> 1
  heapq.heappush(As,-i)

print(-sum(As))
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ans = 0
for i in range (N):
 tasizann = 0
 for j in range (N-i-1):
  tasizann = tasizann + A[i+j+1]
  tasizann = tasizann % (10**9 + 7)
 S = A[i] * tasizann
 S = S % (10**9 + 7)
 ans = ans + S
ans = ans % (10**9 + 7)
print (ans)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
tasizann = 0
for i in range (N):
 tasizann = tasizann + A[i]
nijou = tasizann**2
nijouwa = 0
for i in range (N):
 nijouwa =nijouwa + A[i]**2
ans = (nijou - nijouwa)//2
ans = ans % (10**9+7)
print (ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

N, Q=map(int, input().split())

link=[[] for i in range(N+1)]
for i in range(N-1):
  a, b=map(int, input().split())
  link[a].append(b)
  link[b].append(a)

px=[list(map(int, input().split())) for i in range(Q)]

counter=[0]*(N+1)
for i in range(Q):
  counter[px[i][0]]+=px[i][1]
  
def f(num, prenum=-1, p=0):
  counter[num]+=p
  for postnum in link[num]:
    if postnum==prenum:
      continue
    f(postnum, num, counter[num])
    
f(1)

print(*counter[1:])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

def input():
  return sys.stdin.readline()[:-1]

N, Q=map(int, input().split())

link=[[] for i in range(N+1)]
for i in range(N-1):
  a, b=map(int, input().split())
  link[a].append(b)
  link[b].append(a)

px=[list(map(int, input().split())) for i in range(Q)]

counter=[0]*(N+1)
for i in range(Q):
  counter[px[i][0]]+=px[i][1]
  
def f(num, prenum=-1, p=0):
  counter[num]+=p
  for postnum in link[num]:
    if postnum==prenum:
      continue
    f(postnum, num, counter[num])
    
f(1)

print(*counter[1:])
### BUGGY CODE ###

def test(original: list, array: list, index: int,
         remain_count: int, results: set, results_1, results_2):
    # 3桁抽出したら終了
    if len(array) == 1:
        if "".join(array) in results_1:
            return
        results_1.add("".join(array))
    if len(array) == 2:
        if "".join(array) in results_2:
            return
        results_2.add("".join(array))
    if len(array) == 3:
        # print("".join(array))
        results.add("".join(array))
        return
    # 最終桁に到達したら終了
    if index == len(original):
        return
    for i in range(index, len(original), 1):
        new_array = array[:]
        new_array.append(
            original[i])
        test(
            original,
            new_array,
            i + 1,
            remain_count,
            results,
            results_1,
            results_2)

    # この桁を抽出対象としないパターン
    # test(original, array[:], index + 1, remain_count - 1, results)


N = int(input())
S = list(input())

results = set()
results_1 = set()
results_2 = set()

# N個の要素
# N-3個を削除
# 3個の組み合わせが何通りあるか？
test(S, [], 0, N - 3, results, results_1, results_2)

print(len(results))


### FIXED CODE ###

def test(original: list, nums: str, index: int,
         remain_count: int, results: set, results_1, results_2):
    # 3桁抽出したら終了
    if len(nums) == 1:
        if nums in results_1:
            return
        results_1.add(nums)
    if len(nums) == 2:
        if nums in results_2:
            return
        results_2.add(nums)
    if len(nums) == 3:
        # print("".join(array))
        results.add(nums)
        return
    # 最終桁に到達したら終了
    if index == len(original):
        return
    for i in range(index, len(original), 1):
        test(
            original,
            nums + original[i],
            i + 1,
            remain_count,
            results,
            results_1,
            results_2)

    # この桁を抽出対象としないパターン
    # test(original, array[:], index + 1, remain_count - 1, results)


N = int(input())
S = list(input())

results = set()
results_1 = set()
results_2 = set()

# N個の要素
# N-3個を削除
# 3個の組み合わせが何通りあるか？
test(S, "", 0, N - 3, results, results_1, results_2)

print(len(results))
### BUGGY CODE ###

N = int(input())
max_num = 1

for n in range(1,N+1):
  ans = 0
  check = False
  for x in range(1,max_num+1):
    for y in range(x,max_num+1):
      for z in range(y,max_num+1):
        if (x**2 + y**2 + z**2 + x*y + y*z + z*x) == n:
          if x == y and y == x and z == x:
            ans += 1
          elif x == y  or z == x or y == z:
            ans += 3
          elif x != y and y != z and z != x:
            ans += 6
          check = True
          max_num = max(x,y,z)+1
          break
      if check:
        break
    if check:
      break
  print(ans)

### FIXED CODE ###

n = int(input())
ans = [0 for _ in range(10001)]

for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      v = i*i + j*j + k*k + i*j + j*k + k*i
      if v < 10001:
        ans[v] += 1

for i in range(n):
  print(ans[i+1])
### BUGGY CODE ###

import math

k = int(input())
g = []

for a in range(k):
  for b in range(k):
    for c in range(k):
      g.append(math.gcd(math.gcd(a+1,b+1),c+1))

print(sum(g))

### FIXED CODE ###

from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
  for b in range(1,k+1):
    for c in range(1,k+1):
      ans += gcd(gcd(a,b),c)

print(ans)