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

n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]
#print(n,k,a)

mylist=[0 for i in range(n)]
for i in range(n):
  mylist[i]=a.count(i)
mylist.sort(reverse=True)

val=0
for i in range(0,k):
  val+=mylist[i]
  
print(n-val)

### FIXED CODE ###

import collections

n,k=(int(i) for i in input().split())
a=[int(i) for i in input().split()]

mydata=collections.Counter(a)
mylist=list(mydata.values())
mylist.sort(reverse=True)
#print(mylist)

if len(mylist)<k:
  print(0)
else:
  val=sum(mylist[:k])
  print(n-val)
### BUGGY CODE ###

#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import sys


def solve(s, t):
    v = [0] * (len(s) + 1)
    dp = [v]
    for ti in t:
        u, v = v, v.copy()
        dp.append(v)
        ll, ul = 0, 0
        for j, sj in enumerate(s):
            uj = u[j + 1]
            if sj == ti:
                v[j + 1] = 1 + ul
                ll = 1 + ul
            else:
                if ll > uj:
                    v[j + 1] = ll
                else:
                    ll = uj
            ul = uj
    i = len(t)
    j = len(s)
    k = dp[i][j]
    selected = []
    while k > 0:
        if dp[i - 1][j] == k:
            i -= 1
        elif dp[i][j - 1] == k:
            j -= 1
        else:
            selected.append(t[i - 1])
            k -= 1
            i -= 1
            j -= 1
    return "".join(selected[::-1])


def do_job():
    "Do the work"
    s = input()
    t = input()
    result = solve(s, t)
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())


### FIXED CODE ###

#!/usr/bin/env python3
# vim: set fileencoding=utf-8

# pylint: disable=unused-import, invalid-name, missing-docstring, bad-continuation


"""Module docstring
"""

import sys


def solve(s, t):
    v = [0] * (len(s) + 1)
    dp = [v]
    for _, ti in enumerate(t, 1):
        u, v = v, v.copy()
        dp.append(v)
        ll, ul = 0, 0
        for j, sj in enumerate(s, 1):
            uj = u[j]
            if sj == ti:
                v[j] = 1 + ul
                ll = 1 + ul
            else:
                if ll > uj:
                    v[j] = ll
                else:
                    ll = uj
            ul = uj
    i = len(t)
    j = len(s)
    k = dp[i][j]
    selected = []
    while k > 0:
        if dp[i - 1][j] == k:
            i -= 1
        elif dp[i][j - 1] == k:
            j -= 1
        else:
            selected.append(t[i - 1])
            k -= 1
            i -= 1
            j -= 1
    return "".join(selected[::-1])


def do_job():
    "Do the work"
    s = input()
    t = input()
    result = solve(s, t)
    print(result)


def print_output(testcase, result) -> None:
    "Formats and print result"
    if result is None:
        result = "IMPOSSIBLE"
    print("Case #{}: {}".format(testcase + 1, result))


def main(argv=None):
    "Program wrapper."
    if argv is None:
        argv = sys.argv[1:]
    do_job()
    return 0


if __name__ == "__main__":
    import doctest

    doctest.testmod()
    sys.exit(main())
### BUGGY CODE ###

import math
class SegmentTree:
    def __init__(self, dat, func, sentinel):
        self.pad = 2 ** math.ceil(math.log(len(dat),2)) - 1
        self.dat = [None] * self.pad + dat + [sentinel] * (self.pad + 1 - len(dat))
        self.func = func
        self.sentinel = sentinel
        for i in range(self.pad - 1, -1, -1):
            self.dat[i] = self.func(self.dat[i * 2 + 1],self.dat[i * 2 + 2])
        
    def q(self,s,e):
        return self._q(self.pad + s,self.pad + e,0,self.pad,len(self.dat) - 1)
    def _q(self,a,b,k,l,r):
        if b < l or r < a:
            return self.sentinel
        elif a <= l and r <= b:
            return self.dat[k]
        else:
            vl = self._q(a,b,k * 2 + 1,l,(l+r)//2)
            vr = self._q(a,b,k * 2 + 2,(l+r)//2 + 1,r)
            return self.func(vl,vr)
import sys
f = sys.stdin


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

#内包表記にしないと速度不足
b = sorted([list(map(int, line.split()))[::-1] for line in f])
x = [bi[2] for bi in b]
y = [bi[1] for bi in b]


        
minx = SegmentTree(x,min,sentinel = 2000001)
maxx = SegmentTree(x,max,sentinel = -1)
miny = SegmentTree(y,min,sentinel = 2000001)
maxy = SegmentTree(y,max,sentinel = -1)

max_size = i = j = 0
while j < len(b) - 1:
    for k in range(j,-1,-1):
        if b[k][0] + d < b[j][0]:
            break
        i = k
    for k in range(i,len(b)):
        if b[i][0] + d < b[k][0]:
            break
        j = k
    
    max_size = max(max_size,(maxx.q(i,j) - minx.q(i,j)) * (maxy.q(i,j) - miny.q(i,j)))
    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 ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,W=map(int,input().split())
    w=[0]*(n+1)
    v=[0]*(n+1)
    for i in range(1,n+1):
        w[i],v[i]=map(int,input().split())

    def solve(i,W):
        if(i>n): return 0
        res=0
        if(W>=w[i]): res=solve(i+1,W-w[i])+v[i]
        res=max(res,solve(i+1,W))
        return res

    print(solve(1,W))
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n,w=map(int,input().split())
    W=[0]*n; V=[0]*n
    for i in range(n):
        a,b=map(int,input().split())
        W[i]=a; V[i]=b
    # dp[i][k] iまでの品物で、重さがk以下
    dp=[[0]*(w+1) for _ in range(n+1)]
    for i in range(1,n+1):
        for k in range(w+1):
            if k-W[i-1]>=0:
                dp[i][k]=max(dp[i-1][k-W[i-1]]+V[i-1],dp[i-1][k])
            else:
                dp[i][k]=dp[i-1][k]
    print(dp[n][w])
resolve()
### BUGGY CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import Counter

def kumi(d):
    ans = 0
    for k, v in d.items():
        ans += v * max(0, v-1) // 2
    return ans

def main():
    n = int(input().strip())
    v = list(map(int, input().strip().split()))
    d = dict(Counter(v))
    for i in v:
        d[i] -= 1
        print(kumi(d))
        d[i] += 1


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from collections import Counter
from bisect import bisect_left

def f(i, d, dsum, n):
    return func(i, d) + dsum[i] + dsum[n] - dsum[i+1]

def func(i, w):
    return w[i][1] * max(0, w[i][1]-1) // 2

def main():
    n = int(input().strip())
    v = list(map(int, input().strip().split()))
    d = dict(Counter(v))
    w = []
    for k in sorted(d.keys()):
        w.append([k, d[k]])
    m = len(w)
    c = [0] * (m+1)
    for i in range(1, m+1):
        c[i] = c[i-1] + func(i-1, w)
        # print(func(i-1, w))
    q = [u[0] for u in w]
    # print(c)
    # print(w)
    for i in v:
        g = bisect_left(q, i)
        # print(q)
        # print(i)
        # print('g: ', g)
        w[g][1] -= 1
        print(f(g, w, c, m))
        w[g][1] += 1


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

N,K=map(int,input().split())
A=list(map(int,input().split()))
B=[0]*N

sousa=0
kaisuu=min(K,42)

while sousa<kaisuu:
    for i in range(N):
        ma=i+A[i]+1
        if ma>N:
            ma=N
        mi=i-A[i]
        if mi<0:
            mi=0
        for j in range(mi,ma):
            B[j]+=1
    A=list(B)
    B=[0]*N
    sousa+=1

A=[str(k) for k in A]
print(" ".join(A))

### FIXED CODE ###

import numpy as np

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

B=np.zeros(shape=N+1,dtype=np.int64)
C=np.arange(0,N)

sousa=0
kaisuu=min(K,42)



while sousa<kaisuu:
    np.add.at(B, np.maximum(0,C-A),1)
    np.add.at(B,np.minimum(N,C+A+1),-1)
    A = B.cumsum()[:-1]
    sousa+=1
    
    B *= 0
    
A=[str(k) for k in A]
print(" ".join(A))
### BUGGY CODE ###

i=int(input())
x=[int(x) for x in input().split()]
for i in x:
  if x.count(i)>1:
    c=0
    break
  else:
      c=1
if(c==1):
    print("YES")
elif(c==0):
    print("NO")      

### FIXED CODE ###

i=int(input())
x=[int(x) for x in input().split()]
y=set(x)
if(len(y)==len(x)):
    print("YES")
else:
    print("NO")
### BUGGY CODE ###

n = int(input())
arr = [int(x) for x in input().split()]
ans = arr[0]
for i in range(1,n):
	ans *= arr[i]
if ans>1000000000000000000:
	ans = -1
print(ans)

### FIXED CODE ###

N = int(input())
arr = [int(x) for x in input().split()]
arr.sort()
prod = 1
for i in arr:
	prod *= i
	if prod>10**18:
		prod = -1
		break
print(prod)
### BUGGY CODE ###

#!/usr/bin/env python3

a, b, k = map(int, input().split())
# print(a, b, k)

for i in range(k):
    if a > 0:
        a -= 1
    elif b > 0:
        b -= 1

print(a, b)


### FIXED CODE ###

#!/usr/bin/env python3

a, b, k = map(int, input().split())
# print(a, b, k)

if k >= a + b:
    a = 0
    b = 0
else:
    if k >= a:
        b = b - (k - a)
        a = 0
        # print("k >= a")
        # print(a, b)
    else:
        # print("k < a")
        a = a - k
        b = b
        # print(a, b)

print(a, b)
### BUGGY CODE ###

# coding: utf-8
import sys
import numpy as np

N, W = map(int, sys.stdin.buffer.readline().split())
   
dp = np.zeros((N+1, W+1), dtype=int)

for i in range(1, N+1):
    w, v = map(int, sys.stdin.buffer.readline().split())
    for j in range(W+1):
        if j-w >= 0:
            dp[i,j] = max(dp[i,j], dp[i-1,j-w]+v)
        dp[i,j] = max(dp[i,j], dp[i-1,j])

# for i in range(N+1):
#     print(dp[i])

print(dp[N,W])

### FIXED CODE ###

def main():
    N, W = map(int, input().split())
 
    dp = [-1] * (W + 1)
    dp[0] = 0
    for _ in range(N):
        w, v = map(int, input().split())
        for i in range(W - w, -1, -1):
            if dp[i] == -1:
                continue
            if dp[i + w] < dp[i] + v:
                dp[i + w] = dp[i] + v
    print(max(dp))
 
 
main()
### BUGGY CODE ###

import itertools
while 1:
	n = input()
	if n == 0: break
	xy = sorted([map(int,raw_input().split()) for i in range(n)])
	dxy = [[xy1[0]-xy2[0],xy1[1]-xy2[1]] for xy1,xy2 in itertools.combinations(xy,2)]
	for dx,dy in dxy:
		if dxy.count([dx,dy]) > 1 and (dxy.count([dy,-dx]) > 1 or dxy.count([-dy,-dx]) > 1):
			print dx**2+dy**2
			break
	else:
		print 0

### FIXED CODE ###

while 1:
	n = input()
	if n == 0: break
	xy = [map(int,raw_input().split()) for i in range(n)]
	S = set(map(tuple,xy))
	ans = 0
	for i in range(n-1):
		x1,y1 = xy[i]
		for j in range(i+1,n):
			x2,y2 = xy[j]
			a = (x2-y2+y1,y2+x2-x1)
			b = (x1-y2+y1,y1+x2-x1)
			if a in S and b in S:
				ans = max(ans,(x1-x2)**2 + (y1-y2)**2)
	print ans
### BUGGY CODE ###



n, x, y = map(int, input().split())


def distance(i,j):
    d1 = abs(i-j)
    d2 = abs(i-x)+1+abs(j-y)
    d3 = abs(i-y)+1+abs(j-x)    
    d = min(d1,d2,d3)
    return d

c = []
for i in range(1, n+1):
    for j in range(i+1,n+1):
        c.append(distance(i,j))

d = [0]*(n-1)
for i in c:
    d[i-1] = d[i-1] + 1
for i in d:
    print(i)

### FIXED CODE ###


n, x, y = map(int, input().split())

d = [0]*(n-1)
for i in range(1, n+1):
    for j in range(i+1,n+1):
        c = min(j-i, abs(i-x)+1+abs(j-y))
        d[c-1] = d[c-1] + 1

for i in d:
    print(i)
### BUGGY CODE ###

dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()

    if dst[h][w] == -1: dst[h][w] = d
    else: dst[h][w] = min(dst[h][w], d)

    for i in range(4):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        dq.appendleft((nh, nw, d))

    for i in range(4, 24):
        nh = h + dhw[i][0]; nw = w + dhw[i][1]
        if nh < 0 or H <= nh : continue
        if nw < 0 or W <= nw : continue
        if S[nh][nw] == '#': continue
        if dst[nh][nw] >= 0: continue
        dq.append((nh, nw, d+1))

print(dst[eh][ew])


### FIXED CODE ###

dhw = [(1,0),(0,-1),(0,1),(-1,0),
( 2,-2),( 2,-1),( 2, 0),( 2, 1),( 2, 2),
( 1,-2),( 1,-1),        ( 1, 1),( 1, 2),
( 0,-2),                        ( 0, 2),
(-1,-2),(-1,-1),        (-1, 1),(-1, 2),
(-2,-2),(-2,-1),(-2, 0),(-2, 1),(-2, 2)]

H, W = map(int, input().split())
sh, sw = map(lambda x:int(x)-1, input().split())
eh, ew = map(lambda x:int(x)-1, input().split())
S = [input() for _ in range(H)]

dst = [[-1]*W for _ in range(H)]

from collections import deque
dq = deque([(sh, sw, 0)])
while dq:
    h, w, d = dq.popleft()
    if 0 <= h < H and 0 <= w < W and dst[h][w] < 0 and S[h][w] != '#':
        dst[h][w] = d
    else:
        continue
    for i in range(4): dq.appendleft((h + dhw[i][0], w + dhw[i][1], d))
    for i in range(4, 24): dq.append((h + dhw[i][0], w + dhw[i][1], d+1))

print(dst[eh][ew])
### BUGGY CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort(reverse=True)
f.sort()
z = list(zip(a,f))
ok = max(x*y for x,y in z)
ng = -1
while ok-ng>1:
  mid = (ok+ng)//2
  if sum(x-mid//y for x,y in z if x*y > mid) <= k:
    ok = mid
  else:
    ng = mid
print(ok)

### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
f = list(map(int,input().split()))
a.sort(reverse=True)
f.sort()
z = list(zip(a,f))
ok = max(x*y for x,y in z)
ng = -1
while ok-ng>1:
  mid = (ok+ng)//2
  if sum(x-mid//y for x,y in z if x*y > mid) <= k:
    ok = mid
  else:
    ng = mid
print(ok)
### BUGGY CODE ###

def c_163():
	N = int(input())
	A = input().split()
	A = [int(n) for n in A]
	for i in range(N):
		count = 0
		for j in range(N-1):
			if i+1 == A[j]:
				count += 1
		print(count)

c_163()

### FIXED CODE ###

N = int(input())
A =[int(n) for n in input().split()]
b = [0]*N
for i in A:
  b[i-1]+=1
for i in range(N):
  print(b[i])
### BUGGY CODE ###

import sys
sys.setrecursionlimit(4100000)
def input():
    return sys.stdin.readline().rstrip()

N = int(input())
a = list(map(int, input().split()))
b = []
for i in range(N, 0, -1):
  s = a[i - 1]
  if i * 2 <= N:
    s += sum([1 for k in range(2, N // i + 1) if i * k in b])
  if s % 2 == 1:
  	b.append(i)
print(len(b))
print(*b)


### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
b = []
arr = [-1] * N
for i in range(N, 0, -1):
  s = 0
  j = i * 2
  while j <= N:
    s += arr[j - 1]
    j += i
  if s % 2 != a[i - 1]:
    arr[i - 1] = 1
    b.append(i)
  else:
    arr[i - 1] = 0
print(len(b))
print(*b)
### BUGGY CODE ###

s = list(input())
q = int(input())

rev = True

for i in range(q):
    q = list(input().split())
    if(int(q[0]) == 1):
        rev = rev ^ True
    else:
        n = int(q[1])
        if((n == 1 and rev) or (n == 2 and not rev)):
            s.insert(0, q[2])
        else:
            s.append(q[2])

if not rev:
    s = s[::-1]

print(''.join(s))

### FIXED CODE ###

from collections import deque

s = deque(list(input()))
q = int(input())

rev = True

for i in range(q):
    q = list(input().split())
    if(int(q[0]) == 1):
        rev = rev ^ True
    else:
        n = int(q[1])
        if((n == 1 and rev) or (n == 2 and not rev)):
            s.appendleft(q[2])
        else:
            s.append(q[2])


txt = ''
if rev:
    txt = ''.join(s)
else:
    while not(not s):
        txt += s.pop()

print(txt)
### BUGGY CODE ###

import sys
from collections import defaultdict
import heapq
import numpy as np
input = sys.stdin.readline
n, limit = map(int, input().split())
dic = defaultdict(list)

for _ in range(n):
    a, b = map(int, input().split())
    dic[a].append(b)
#print(dic)

L = []
ans = 0
for i in range(limit+1):
    L += list(np.array(dic[i])*(-1))
    heapq.heapify(L)
    if len(L) >0:
        #print(L)
        ans -= heapq.heappop(L)
        #print(ans)
print(ans)

### FIXED CODE ###

import sys
from collections import defaultdict
import heapq
input = sys.stdin.readline
n, limit = map(int, input().split())
dic = defaultdict(list)

for _ in range(n):
    a, b = map(int, input().split())
    dic[a].append(b)

L = []
ans = 0
for i in range(limit+1):
    for val in dic[i]:
        heapq.heappush(L, -val)
    if len(L):
        ans -= heapq.heappop(L)
print(ans)
### BUGGY CODE ###

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

def f(b):
    r = 0
    for i, ai in enumerate(A):
        r += abs(ai - (b + i + 1))
    return r

mx = (10 ** 9) + 1
mn = (-10 ** 9) - 1

# print(f(0))
while mx - mn > 10:
    m = (mx + mn) // 2
    x = f(m)
    y = f(m+1)
    if x < y:
        mx = m + 1
    else:
        mn = m


ans = []
for i in range(mn, mx+1):
    ans.append(f(i))
print(min(ans))

### FIXED CODE ###

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

def f(b):
    r = 0
    for i, ai in enumerate(A):
        r += abs(ai - (b + i + 1))
    return r


A2 = []
for i, ai in enumerate(A):
    A2.append(ai - (i+1))

SA2 = sorted(A2)
ans = f(SA2[((N+1)//2) - 1])
print(ans)
### BUGGY CODE ###

def binarySearch(a, val):
    left, right = -1, len(a)
    while left + 1 < right:
        mid = (left + right) >> 1
        if a[mid] < val:
            left = mid
        else:
            right = mid
    return a[right] if right < len(a) else 1 << 35

def binarySearch2(a, val):
    left, right = -1, len(a)
    while left + 1 < right:
        mid = (left + right) >> 1
        if a[mid] <= val:
            left = mid
        else:
            right = mid
    return a[left] if left >= 0 else -(1 << 35)

nShrines, nTemples, nQueries = map(int, input().split())
shrines = [int(input()) for _ in range(nShrines)]
temples = [int(input()) for _ in range(nTemples)]
starts = [int(input()) for _ in range(nQueries)]
for start in starts:
    shrineToRight = binarySearch(shrines, start)
    templeToRight = binarySearch(temples, start)
    shrineToLeft = binarySearch2(shrines, start)
    templeToLeft = binarySearch2(temples, start)
    ret = min(
        max(shrineToRight, templeToRight) - start,
        start - min(shrineToLeft, templeToLeft),
        templeToRight - start + templeToRight - shrineToLeft,
        shrineToRight - start + shrineToRight - templeToLeft,
        start - shrineToLeft + templeToRight - shrineToLeft,
        start - templeToLeft + shrineToRight - templeToLeft
    )
    print(ret)


### FIXED CODE ###

def binarySearch(a, val):
    left, right = -1, len(a)
    while left + 1 < right:
        mid = (left + right) >> 1
        if a[mid] < val:
            left = mid
        else:
            right = mid
    return a[right] if right < len(a) else 1 << 35

def binarySearch2(a, val):
    left, right = -1, len(a)
    while left + 1 < right:
        mid = (left + right) >> 1
        if a[mid] <= val:
            left = mid
        else:
            right = mid
    return a[left] if left >= 0 else -(1 << 35)

nShrines, nTemples, nQueries = map(int, input().split())
shrines = [int(input()) for _ in range(nShrines)]
temples = [int(input()) for _ in range(nTemples)]
starts = [int(input()) for _ in range(nQueries)]
ret = []
for start in starts:
    shrineToRight = binarySearch(shrines, start)
    templeToRight = binarySearch(temples, start)
    shrineToLeft = binarySearch2(shrines, start)
    templeToLeft = binarySearch2(temples, start)
    ret.append(min(
        max(shrineToRight, templeToRight) - start,
        start - min(shrineToLeft, templeToLeft),
        templeToRight - start + templeToRight - shrineToLeft,
        shrineToRight - start + shrineToRight - templeToLeft,
        start - shrineToLeft + templeToRight - shrineToLeft,
        start - templeToLeft + shrineToRight - templeToLeft
    ))
print('\n'.join(map(str, ret)))
### BUGGY CODE ###

import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.buffer.readline
N = int(input())
L = list(map(int, input().split()))
L.sort()
dl = []
for i in range(N - 1):
  for j in range(i + 1, N):
    dl.append((L[i] + L[j], i, j, abs(L[i] - L[j])))
dl.sort()
#print(L)
#print(dl)
res = 0
for d in dl:
  ind = bl(L, d[0])
  ind2 = br(L, d[3])
  res += ind - ind2
  if ind2 <= d[1] <= ind:
    res -= 1
  if ind2 <= d[2] <= ind:
    res -= 1
  #print(res, d, ind, ind2)
print(res // 3)

### FIXED CODE ###

import sys
from bisect import bisect_left as bl
from bisect import bisect_right as br
input = sys.stdin.buffer.readline
N = int(input())
L = list(map(int, input().split()))
L.sort()
dl = []
res = 0
for i in range(N - 1):
  for j in range(i + 1, N):
    d0 = L[i] + L[j]
    d1 = i
    d2 = j
    d3 = abs(L[i] - L[j])
    ind = bl(L, d0)
    ind2 = br(L, d3)
    res += ind - ind2
    if ind2 <= d1 <= ind:
      res -= 1
    if ind2 <= d2 <= ind:
      res -= 1
  #print(res, d, ind, ind2)
print(res // 3)
### BUGGY CODE ###

from math import gcd

def gcd_3(a, b, c):
    g = gcd(a, b)
    return gcd(g, c)

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd_3(i, j, k)

print(ans)


### FIXED CODE ###

from math import gcd

def gcd_3(a, b, c):
    g = gcd(a, b)
    return gcd(g, c)

K = int(input())
ans = 0

for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd_3(i, j, k)

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

N = int(input())
a = [int(i) for i in input().split()]
A = 1
if 0 in a:
    A = 0
else:
    for i in range(N):
        A = A * a[i]
if A > 1000000000000000000:
    print(-1)
else:
    print(A)

### FIXED CODE ###

N = int(input())
a = [int(i) for i in input().split()]
A = 1
if 0 in a:
  print(0)
  exit()
for i in range(N):
  A = A * a[i]
  if A > 1000000000000000000:
    print(-1)
    exit()
print(A)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
for i in range(1, n+1):
  print(a.count(i))

### FIXED CODE ###

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