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

h, w, d = [int(i) for i in input().split()]
a = [[int(j)-1 for j in input().split()] for i in range(h)]

q = int(input())#moving num
l = [0 for i in range(q)]#start number
r = [0 for i in range(q)]#finish number

for i in range(q):
    tmp = input().split()
    l[i]=int(tmp[0])-1
    r[i]=int(tmp[1])-1
loc = [[0, 0] for i in range(h*w)]
for i in range(h):
    for j in range(w):
        loc[a[i][j]][0] = i
        loc[a[i][j]][1] = j
cost = 0
index = 0
for i in range(q):
    cost = 0
    max = int((r[i]-l[i])/d)
    for j in range(max):
        index = l[i]+j*d
        cost += abs(loc[index+d][0]-loc[index][0])
        cost += abs(loc[index+d][1]-loc[index][1])
    print(cost)



### FIXED CODE ###

import math
def func(h, w, d, a, query):
    imos = [0 for _ in range(h*w)]
    pos = [[0, 0] for _ in range(h*w)]
    for i in range(h):
        for j in range(w):
            pos[a[i][j]] = [i, j]
    for i in range(d):
        for j in range(math.ceil((h*w-i)/d)):
            if j == 0:
                continue
            else:
                imos[i + d * j] = imos[i + d * (j-1)]\
                                  + abs(pos[i + d * j][0] - pos[i + d * (j-1)][0])\
                                  + abs(pos[i + d * j][1] - pos[i + d * (j-1)][1])
    for i in range(len(query)):
        print(imos[query[i][1]] - imos[query[i][0]])
    return
h, w, d = [int(i) for i in input().split()]
a = [[0 for _ in range(w)] for _ in range(h)]
for i in range(h):
    a[i] = [int(i) - 1 for i in input().split()]
q = int(input())
query = [[0, 0] for _ in range(q)]
for i in range(q):
    query[i] = [int(i) - 1 for i in input().split()]
func(h, w, d, a, query)
"""
func(3, 3, 2, [[0, 3, 2], [1, 4, 6], [7, 8, 5]], [[3, 7]])
print("ans: 5\n")
func(4, 2, 3, [[2, 6], [0, 3], [4, 1], [5, 7]], [[1, 1], [1, 1]])
print("ans: 0, 0\n")
func(5, 5, 4, [[12, 24, 6, 14, 16], [15, 21, 19, 1, 8], [13, 10, 11, 0, 18], [9, 5, 22, 7, 17], [2, 20, 4, 23, 3]], [[12, 12], [1, 9], [12, 12]])
print("ans: 0, 5, 0")
"""
# print("func({}, {}, {}, {}, {})".format(h, w, d, a, query))
### BUGGY CODE ###

N=int(input())
A=list(map(int, input().split()))
print(*[A.count(i) for i in range(1, N+1)], sep='\n')

### FIXED CODE ###

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

nums=[0]*(N+1)
for i in range(N-1):
    nums[A[i]]+=1
    
print(*nums[1:], sep='\n')
### BUGGY CODE ###

s = input("")
Q = int(input())
c = 0
for i in range(Q):
    t = input()
    if len(t) == 1:
        c += 1
    elif t[2] == "1":
        if c%2 == 0:
            s = t[4] + s
        else:
            s = s + t[4]
    else:
        if c%2 == 0:
            s = s + t[4]
        else:
            s = t[4] + s

if c%2 == 0:
    print(s)
else:
    print(s[::-1])

### FIXED CODE ###

s = input("")
Q = int(input())
c = 0
before = []
after = []
for i in range(Q):
    t = input()
    if len(t) == 1:
        c += 1
    elif t[2] == "1":
        if c%2 == 0:
            before.append(t[4])
        else:
            after.append(t[4])
    else:
        if c%2 == 0:
            after.append(t[4])
        else:
            before.append(t[4])

if c%2 == 0:
    print("".join(before[::-1]),end="")
    print(s,end="")
    print("".join(after),end="")
else:
    print("".join(after[::-1]),end="")
    print(s[::-1],end="")
    print("".join(before),end="")
### BUGGY CODE ###

import sys
f = sys.stdin

_, d = map(int, f.readline().split())

x,y = {},{}
for line in f:
    xi, yi, bi = map(int, line.split())
    if bi not in x:
        x[bi],y[bi] = [],[]
    x[bi].append(xi)
    y[bi].append(yi)

b = sorted(x.keys())

xmin,xmax,ymin,ymax = [None for _ in range(len(b))],[None for _ in range(len(b))],[None for _ in range(len(b))],[None for _ in range(len(b))]
for i in range(len(b)):
    xmin[i],xmax[i],ymin[i],ymax[i] = min(x[b[i]]),max(x[b[i]]),min(y[b[i]]),max(y[b[i]])

max_size = i = j = 0
while j < len(b) - 1:
    for k in range(j,-1,-1):
        if b[k] + d < b[j]:
            break
        i = k
    for k in range(i,len(b)):
        if b[i] + d < b[k]:
            break
        j = k
    size = (max(xmax[i:j + 1]) - min(xmin[i:j + 1])) * (max(ymax[i:j + 1]) - min(ymin[i:j + 1]))
    max_size = max(max_size,size)
    j+=1
    
print(max_size)

### FIXED CODE ###

import math
def segmentTree(dat, f, sentinel):
        pad = 2 ** math.ceil(math.log(len(dat),2))
        dat = [0] * pad + dat + [sentinel] * (pad - len(dat))
        for i in range(pad - 1, 0, -1):
            dat[i] = f(dat[i * 2],dat[i * 2 + 1])
        return dat

def get_lr(b,d):
    l = r = 0
    while r < len(b):
        while b[l] + d < b[r]:
            l += 1
        for r in range(r,len(b)):
            if b[l] + d < b[r]:
                r -= 1
                break
        r += 1
        yield l,r
        l += 1
    
import sys
f = sys.stdin

_, d = map(int, f.readline().split())

xyb = []
for line in f:
    xyb.append(tuple(map(int, line.split())))
from operator import itemgetter
xyb.sort(key=itemgetter(2))

x = [xybi[0] for xybi in xyb]
y = [xybi[1] for xybi in xyb]
b = [xybi[2] for xybi in xyb]

xmax = segmentTree(x,max,sentinel = 0)
xmin = segmentTree(x,min,sentinel = 2000000)
ymax = segmentTree(y,max,sentinel = 0)
ymin = segmentTree(y,min,sentinel = 2000000)


pad = len(xmax) // 2
max_size = 0
def create_index(l,r):
    index = []
    ia = index.append
    while l < r:
        if r & 1:
            r -= 1
            ia(r)
        if l & 1:
            ia(l)
            l += 1
        l >>= 1
        r >>= 1
    return index

for l,r in get_lr(b,d):
    l += pad 
    r += pad
    index = create_index(l,r)

    now_xmax = max(xmax[i] for i in index)
    now_ymax = max(ymax[i] for i in index)
    if max_size < now_xmax * now_ymax:
        max_size = max(max_size,((now_xmax - min(xmin[i] for i in index)) * (now_ymax - min(ymin[i] for i in index))))
print(max_size)
### BUGGY CODE ###

n = int(input())
l = [input() for i in range(n)]

mylist = []
for s in l:
    s_list = [ c for c in s]
    mylist.append("".join(sorted(s_list)))

myset = set(mylist)
mylist2 = list(myset)

ans=0
for i in range(len(mylist2)):
    count = mylist.count(mylist2[i])
    mylist3 = list(range(count))
    ans += sum(mylist3)
    mylist.remove(mylist2[i])

print(ans)


### FIXED CODE ###

n = int(input())
i = 0
sortedSet = {}
while i < n:
    temp = ''.join(sorted(input()))

    if temp in sortedSet:
        sortedSet[temp]+=1
    else:
        sortedSet[temp]=1
    i += 1

result = 0
for v in sortedSet.values():
    result = int(result + v*(v-1)/2)

print(result)
### BUGGY CODE ###

x, k, d = map(int, input().split())
  
x = abs(x)

g = k - int(x / d)
if g > 0:
  if g % 2 == 1:
    g -= 1
  k = k - g

for i in range(k):
  if x < 0:
    x += d
  else:
    x -= d

print(abs(x))

### FIXED CODE ###

x, k, d = map(int, input().split())
  
x = abs(x)

if x > k * d:
  print(x - k * d)
else:
  f = int(x / d)
  x = x - f * d
  g = (k - f) % 2
  if g == 1:
    x = x - d
  print(abs(x))
### BUGGY CODE ###

MOD=1000000007
s = [int(x) if x!="?" else -1 for x in input()]
n=len(s)
dp=[[0 for j in range(13)] for i in range(n+1)]
dp[0][0]=1
for i in range(n):
  if i%5==0:
    for m in range(13):
      dp[i][m] =dp[i][m]%MOD
  
  for j in range(13):
    #　i+1番目が？のときは０〜９の可能性
    if s[i]==-1:
      for k in range(10):
        dp[i+1][((j*10)%13+k)%13]+=dp[i][j]
        

    #  i+1番目が?じゃないとき
    else:
      dp[i+1][((j*10)%13+s[i])%13]+=dp[i][j]

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

### FIXED CODE ###

MOD=1000000007
s = [int(x) if x!="?" else -1 for x in input()]
n=len(s)
count=0
dp=[[0 for j in range(13)] for i in range(n+1)]
dp[0][0]=1
for i in range(n):
  if count%50==0:
    for m in range(13):
      dp[i][m] =dp[i][m]%MOD
  
  for j in range(13):
    #　i+1番目が？のときは０〜９の可能性
    if s[i]==-1:
      count+=1
      for k in range(10):
        dp[i+1][(j*10+k)%13]+=dp[i][j]
        

    #  i+1番目が?じゃないとき
    else:
      dp[i+1][(j*10+s[i])%13]+=dp[i][j]

print(dp[n][5]%MOD)
### BUGGY CODE ###

num = int(input())
p = map(int, input().split())
pList = list(p)
ret = 0

for i in range(num):
    check = True
    for j in range(i):
        if pList[i] >= pList[j]:
            check = False
            break
    if check == True:
        ret = ret + 1

print("{}".format(ret))

### FIXED CODE ###

num = int(input())
p = map(int, input().split())
pList = list(p)
ret = 0

min = pList[0]
for i in range(num):
    if pList[i] <= min:
        min = pList[i]
        ret = ret + 1

print("{}".format(ret))
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
def ans(l):
    max = 0
    b = set(l)
    for i in b:
        s = l.count(i)
        if s>max:
            max = s
    return n/2 - max
if a.count(a[0])==n:
    p = int(n/2)
else:
    p = int(ans(a[::2]) + ans(a[1::2]))
print(p)


### FIXED CODE ###

from collections import Counter
n = int(input())
a = [int(i) for i in input().split()]

if len(set(a)) == 1:
    p = int(n/2)
else:
    b0 = set(a[::2])
    if len(b0)==1:
        q0 = 0
        mark00 = a[0]
        count00, count01 = int(n/2), 0
    else:
        c = Counter(a[::2])
        q0 =  int(n/2) - c.most_common(1)[0][1]
        mark00, mark01 = c.most_common(2)[0][0], c.most_common(2)[1][0]
        count00, count01 = c.most_common(2)[0][1], c.most_common(2)[1][1]

    b1 = set(a[1::2])
    if len(b1)==1:
        q1 = 0
        mark10 = a[1]
        count10, count11 = int(n/2), 0
    else:
        c = Counter(a[1::2])
        q1 =  int(n/2) - c.most_common(1)[0][1]
        mark10, mark11 = c.most_common(2)[0][0], c.most_common(2)[1][0]
        count10, count11 = c.most_common(2)[0][1], c.most_common(2)[1][1]
    if mark00==mark10:
        if count00+count01>count10+count11:
            p = n - (count00+count01)
        else:
            p = n - (count10+count11)
    else:
        p = n - (count00 + count10)

print(p)
### BUGGY CODE ###

import itertools

N, K = (int(i) for i in input().split())  
heights = [int(input()) for i in range(N)] 
heights_lists = list(itertools.combinations(heights, K))

min_diff = max(heights) - min(heights) 
for heights_one in heights_lists:
    if min_diff > (max(heights_one) - min(heights_one) ):
        min_diff = (max(heights_one) - min(heights_one) )

print(min_diff)


### FIXED CODE ###

import itertools

N, K = (int(i) for i in input().split())  
heights = [int(input()) for i in range(N)] 

heights.sort()
min_diff = max(heights) - min(heights) 
for i in range(N-K+1):
    diff = heights[i+K-1] - heights[i]
    if diff < min_diff:
        min_diff = diff

print(min_diff)
### BUGGY CODE ###

import numpy as np

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

MOD = 10**9 + 7

# format関数で10進数から2進数に変換
max_digits = len(format(max(a), 'b'))  # 最大桁数

# 各位の1の数を記録していく
counter = []
for i in range(n):
    counter.append(list(format(a[i], 'b').zfill(max_digits))[::-1])  # 逆順にする 
cnt_arr = np.array(counter, dtype='int')

ans = 0
for i in range(max_digits):
    # 各位ごとの合計は2**k × 1の数 × 0の数
    one_num = np.count_nonzero(cnt_arr[:, i])
    ans += (2**i * one_num * (n - one_num)) % MOD
print(ans % MOD)

### FIXED CODE ###

import numpy as np
n = int(input())
a = np.array(list(map(int, input().split())))

max_digits = 60
MOD = 10**9 + 7

ans = 0
for i in range(max_digits):
    one_num = np.count_nonzero((a >> i) & 1)
    radix_mod = 2**i % MOD
    ans += (radix_mod * one_num * (n - one_num)) % MOD
print(ans%MOD)
### BUGGY CODE ###

from numpy.linalg import solve

N = int(input())
dam = list(map(int, input().split()))

mountains = []

for i in range(N):
    mount = [0] * N
    if i != N - 1:
        mount[i] = 0.5
        mount[i+1] = 0.5
    else:
        mount[0] = 0.5
        mount[i] = 0.5
    mountains.append(mount)

print(' '.join([str(int(x)) for x in solve(mountains, dam)]))


### FIXED CODE ###

N = int(input())
dam = list(map(int, input().split()))

mountains = [0] * N

x2 = 0
for i in range(N):
    if i % 2:
        x2 -= dam[i]
    else:
        x2 += dam[i]

mountains[0] = x2 // 2
for i in range(N-1):
    mountains[i+1] = dam[i] - mountains[i]

print(' '.join([str(x*2) for x in mountains]))
### BUGGY CODE ###

from bisect import bisect_right

n,m=map(int,input().split())
lis=list(map(int,input().split()))
lists=sorted(lis)

cnt=0
while cnt<m:
    y=lists[-1]//2
    del lists[-1]
    
    indexes=bisect_right(lists,y)
    #indexesというところに新しいyの値を代入しておきたい
    lists.insert(indexes,y)

    cnt+=1
print(sum(lists))

### FIXED CODE ###

from bisect import bisect_right
import heapq
n,m=map(int,input().split())
lists=list(map(int,input().split()))
uselists=[]
for _ in lists:
    uselists.append(-_)

heapq.heapify(uselists)

cnt=0
while cnt<m:
    y=heapq.heappop(uselists)

    z=(-y)//2
    heapq.heappush(uselists,-z)
    

    cnt+=1
anslist=[]
for j in uselists:
    anslist.append(-j)
print(sum(anslist))
### BUGGY CODE ###

while True:
    n = int(raw_input())
    if n == 0:
        break
    c = 0
    key = 0
    while c < n:
        sc = str(key+1)
        if sc.count("4") + sc.count("6") > 0:
            key += 1
        else:
            c += 1
            key += 1
    print key

### FIXED CODE ###

ref = ["0","1","2","3","5","7","8","9"]
while True:
    n = int(raw_input())
    if n == 0: break
    ans = ""
    for i in str(oct(n))[1:]:
        ans += ref[int(i)]
    print ans
### BUGGY CODE ###

N,Q = map(int,input().split())
Ki_p = [0 for i in range(N+1)]
Ki_c = [[] for i in range(N+1)]
Ki_co = [0 for i in range(N+1)]
v = set([1])
re = []

for i in range(N-1):
    a,b = map(int,input().split())
    if a in v:
        Ki_p[b] = a
        Ki_c[a] += [b]
        v.add(b)
    elif b in v:
        Ki_p[a] = b
        Ki_c[b] += [a]
        v.add(a)
    else:  re.append([a,b])

while len(re) > 0:
    for i in range(len(re)):
        a,b = (x for x in re.pop(0))
        if a in v:
            Ki_p[b] = a
            Ki_c[a] += [b]
            v.add(b)
        elif b in v:
            Ki_p[a] = b
            Ki_c[b] += [a]
            v.add(a)
        else:  re.append([a,b])

for i in range(Q):
    p,x = map(int,input().split())
    Ki_co[p] += x

ans = [0 for i in range(N+1)]
vc = [1]
for i in range(N):
    vi = vc.pop(0)
    ans[vi] = Ki_co[vi] + ans[Ki_p[vi]]
    vc += Ki_c[vi]

print(' '.join(map(str,ans[1:N+1])))

### FIXED CODE ###

N,Q = map(int,input().split())
Ki_p = [0 for i in range(N+1)]
Ki_c = [[] for i in range(N+1)]
Ki_co = [0 for i in range(N+1)]
 
for i in range(N-1):
    a,b = map(int,input().split())
    Ki_p[b] = a
    Ki_c[a] += [b]
 
for i in range(Q):
    p,x = map(int,input().split())
    Ki_co[p] += x
 
ans = [0 for i in range(N+1)]
q = {1}
for i in range(N):
    vi = q.pop()
    ans[vi] = Ki_co[vi] + ans[Ki_p[vi]]
    q |= set(Ki_c[vi])
    
print(' '.join(map(str,ans[1:N+1])))
### BUGGY CODE ###

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

from bisect import insort
while M>0:
  a = A.pop(-1)
  a /= 2
  insort(A,a)
  M-=1
ans = 0
for a in A:
  ans += int(a)
print(ans)
  

### FIXED CODE ###

N,M=map(int,input().split())
A=list(map(lambda x: -int(x),input().split()))
import heapq
heapq.heapify(A)
for _ in range(M):
  a = heapq.heappop(A)
  a /= 2
  heapq.heappush(A,a)
ans = 0
for a in A:
  ans += int((-1)*a)
print(ans)
### BUGGY CODE ###

from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

road = [[float("inf")]*N for _ in range(N)]

for i in range(M):
    a, b, c = map(int, input().split())
    road[a-1][b-1] = c
    road[b-1][a-1] = c

for j in range(N):
    road[j][j] = 0

road = warshall_floyd(road)

# print(road)
ans = float("inf")

for v in permutations(r, len(r)):
    # print("v", v)
    tmp = 0
    for i in range(len(r)-1):
        tmp += road[v[i]-1][v[i+1]-1]
    # print(tmp)
    ans = min(ans, tmp)

print(ans)

### FIXED CODE ###

from itertools import permutations

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(N):
        for i in range(N):
            for j in range(N):
                d[i][j] = min(d[i][j], d[i][k] + d[k][j])
    return d

N, M, R = map(int, input().split())
r = list(map(int, input().split()))

road = [[float("inf")]*N for _ in range(N)]

for i in range(M):
    a, b, c = map(int, input().split())
    road[a-1][b-1] = c
    road[b-1][a-1] = c

for j in range(N):
    road[j][j] = 0

road = warshall_floyd(road)

# print(road)
ans = float("inf")

for v in permutations(r, len(r)):
    # print("v", v)
    tmp = 0
    for i in range(len(r)-1):
        tmp += road[v[i]-1][v[i+1]-1]
    # print(tmp)
    ans = min(ans, tmp)

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

k, q = map(int, input().split())
D = list(map(int, input().split()))

def solve(n, x, m):
	ds = [x%m for x in D]
	nums = [(n-1)//k + (i < ((n-1)%k)) for i in range(k)]
	zero = sum([num for num, d in zip(nums, ds) if d == 0])
	cum = x%m + sum([num * d for num, d in zip(nums, ds)])
	decr = cum // m
	return n-1 - zero - decr

for _ in range(q):
	n, x, m = map(int, input().split())
	print(solve(n, x, m))

### FIXED CODE ###

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

k, q = map(int, input().split())
D = list(map(int, input().split()))

def solve(n, x, m):
	ds = [x%m for x in D]
	nums = [(n-1)//k + (i < ((n-1)%k)) for i in range(k)]
	zero = sum([num for num, d in zip(nums, ds) if d == 0])
	cum = x%m + sum([num * d for num, d in zip(nums, ds)])
	decr = cum // m
	return n-1 - zero - decr

for _ in range(q):
	n, x, m = map(int, input().split())
	print(solve(n, x, m))
### BUGGY CODE ###

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)


def dfs(v, parent, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to == parent:
            continue
        dfs(to, v, d + cost)


depth = defaultdict(int)
tree = defaultdict(list)
n = int(input())
for i in range(n - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append((b, c))
    tree[b].append((a, c))

q, k = map(int, input().split())
k -= 1

dfs(k, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(depth[x] + depth[y])


### FIXED CODE ###

import sys
from collections import defaultdict

sys.setrecursionlimit(10 ** 7)


def dfs(v, parent, d):
    depth[v] = d
    for to, cost in tree[v]:
        if to == parent:
            continue
        dfs(to, v, d + cost)


depth = defaultdict(int)
tree = defaultdict(list)
n = int(input())
for i in range(n - 1):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    tree[a].append((b, c))
    tree[b].append((a, c))

q, k = map(int, input().split())
k -= 1

dfs(k, -1, 0)
for i in range(q):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    print(depth[x] + depth[y])
### BUGGY CODE ###

N, M = map(int, input().split())
edges = []
G = [[10**8]*N for _ in range(N)]   # 1-indexed
for _ in range(M):
    A, B, C = map(int, input().split())
    # 無向グラフ
    G[A-1][B-1] = C
    G[B-1][A-1] = C
    edges.append((A-1, B-1, C))

for k in range(N):
    for i in range(N):
        for j in range(N):
            if i == j:
                G[i][j] = 0
            if G[i][j] > G[i][k]+G[j][k]:
                G[i][j] = G[i][k]+G[j][k]

ans = 0
for A, B, C in edges:
    flg = False
    for i in range(N):
        for j in range(N):
            if G[i][A]+C+G[B][j] == G[i][j]:
                flg = True
    if flg is False:
        ans += 1
print(ans)


### FIXED CODE ###

N, M = map(int, input().split())
edges = []
G = [[10**8]*N for _ in range(N)]   # 1-indexed
for _ in range(M):
    A, B, C = map(int, input().split())
    # 無向グラフ
    G[A-1][B-1] = C
    G[B-1][A-1] = C
    edges.append((A-1, B-1, C))

for k in range(N):
    for i in range(N):
        for j in range(N):
            if i == j:
                G[i][j] = 0
            if G[i][j] > G[i][k]+G[j][k]:
                G[i][j] = G[i][k]+G[j][k]

ans = 0
for A, B, C in edges:
    flg = False
    for i in range(N):
        for j in range(N):
            if G[i][A]+C+G[B][j] == G[i][j]:
                flg = True
    if flg is False:
        ans += 1
print(ans)
### BUGGY CODE ###

x, y, z, k = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort(reverse=True); B.sort(reverse=True); C.sort(reverse=True)

ans = []
for i in A:
    for j in B:
        for l in C:
            ans.append(i+j+l)
ans.sort(reverse=True)

for i in range(k):
    print(ans[i])


### FIXED CODE ###

x, y, z, k = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

A.sort(reverse=True); B.sort(reverse=True); C.sort(reverse=True)

ans = []
for i in A:
    for j in B:
        ans.append(i+j)
ans.sort(reverse=True)
ans = ans[:k]
ans1 = []
for i in C:
    for j in ans:
        ans1.append(i+j)
ans1.sort(reverse=True)
for i in range(k):
    print(ans1[i])
### BUGGY CODE ###

from collections import defaultdict
import math
N, X, Y = list(map(int, input().split()))
res = defaultdict(int)
x = []
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i >= j:
            continue
        if i == X and Y == j:
            key = 1
        else:
            key = int(min(j - i, math.fabs(X - i) + math.fabs(Y - j) + 1))
        res[key] += 1


for i in range(1, N):
    print(res[i])


### FIXED CODE ###

N, X, Y = list(map(int, input().split()))
res = [0] * N
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i >= j:
            continue
        if i == X and Y == j:
            key = 1
        else:
            key = int(min(j - i, abs(X - i) + abs(Y - j) + 1))
        res[key] += 1

for i in range(1, N):
    print(res[i])
### BUGGY CODE ###

n = int(input())
a = [int(i) for i in input().split()]
x = sum(a)
answer = abs(x-2*a[0])
for i in range(1,n):
	y = sum(a[i:])
	if answer>abs(x-2*y):
		answer = abs(x-2*y)
print(answer)

### FIXED CODE ###

n = int(input())
a = [int(i) for i in input().split()]
x,y = a[0],sum(a)-a[0]
answer = abs(x-y)
for i in range(1,n-1):
	x += a[i]
	y -= a[i]
	if answer > abs(x-y):
		answer = abs(x-y)
print(answer)
### BUGGY CODE ###

from functools import reduce


def gcd(v1, v2):
    v3 = v1 % v2
    if v3 == 0:
        return v2
    return gcd(v2, v3)


def main():
    N = int(input())
    A = [int(v) for v in input().split()]

    max_gcd = max(reduce(gcd, A[1:]), reduce(gcd, A[:N-1]))

    for i in range(1, N - 1):
        v1 = reduce(gcd, A[:i])
        v2 = reduce(gcd, A[i + 1:])

        #print(A[:i], A[i+1:])

        max_gcd = max(max_gcd, gcd(v1, v2))

    #print(reduce(gcd, A))

    print(max_gcd)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from functools import reduce


def gcd(v1, v2):
    v3 = v1 % v2
    if v3 == 0:
        return v2
    return gcd(v2, v3)


def main():
    N = int(input())
    A = [int(v) for v in input().split()]

    max_gcd = max(reduce(gcd, A[1:]), reduce(gcd, A[:N-1]))

    left = [1] * N
    left[0] = A[0]
    for i in range(1, N):
        left[i] = gcd(A[i], left[i - 1])

    right = [1] * N
    right[N-1] = A[N-1]
    for i in range(N - 2, -1, - 1):
        right[i] = gcd(A[i], right[i + 1])

    # print(left)
    # print(right)

    max_gcd = max(right[1], left[N-2])
    for i in range(1, N - 1):
        max_gcd = max(max_gcd, gcd(left[i - 1], right[i + 1]))

    print(max_gcd)


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

import sys
input = sys.stdin.readline

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

dp = [None] * N
for n in range(N):
    if n == 0:
        min_num = 0
    else:
        l = min(n, K)
        min_num = 10 ** 10
        for k in range(1, l + 1):
            min_num = min(abs(A[n] - A[n - k]) + dp[n - k], min_num)
    dp[n] = min_num

print(dp[-1])


### FIXED CODE ###

import sys

N, K = map(int, sys.stdin.readline().split())
A = list(map(int, sys.stdin.readline().split()))

dp = [0] + [None] * (N - 1)
for n, a in enumerate(A):
    if n:
        l = max(0, n - K)
        dp[n] = min(abs(a - a2) + d for a2, d in zip(A[l : n], dp[l : n]))

print(dp[-1])