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

n = int(input())
n = str(n)
k = 0
pay = 0
n_list = []
for i in n[::-1]:
    n_list.append(int(i))
n_list.append(0)
for i in range(len(n_list) - 1):
    num = n_list[i]
    if (num <= 5 and n_list[i + 1] < 5) or num < 5:
        pay += num * 10 ** k
    else:
        n_list[i + 1] += 1
    k += 1
pay += n_list[-1] * 10 ** k
oturi = pay - int(n)
ans = 0

for i in str(pay):
    ans += int(i)
for i in str(oturi):
    ans += int(i)
print(ans)

### FIXED CODE ###

n = input()
k = 0
pay = 0
n_list = []
for i in n[::-1]:
    n_list.append(int(i))
n_list.append(0)
ans = 0
for i in range(len(n_list) - 1):
    num = n_list[i]
    if num < 5:
        ans += num
    elif (num <= 5 and n_list[i + 1] < 5):
        ans += num
    else:
        n_list[i + 1] += 1
        ans += 10 - num

ans += n_list[-1]
print(ans)
### BUGGY CODE ###

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

m = 2020202020
for i in range(N):
  a = sum(A[0:i])
  b = sum(A[i:])
  ab = abs(a-b)
  if ab < m:
    m = ab
print(m)

  

### FIXED CODE ###

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

m = 2020202020
b = sum(A)
a = 0
for i in range(N):
  a += A[i]
  b -= A[i]
  ab = abs(a-b)
  if ab < m:
    m = ab
print(m)
### BUGGY CODE ###

N=int(input())
C,S,F=[0]*(N-1),[0]*(N-1),[0]*(N-1)
for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())
for i in range(N-1): #一周につき一つの駅([0]..[N-3])から[N-1]までの計算
    arrivalTime=S[i]+C[i]#最初発車駅の次の駅に着く時間
    for j in range(i+1,N-1):
        leaveTime=S[j]#現在考慮中の駅から初めて発車する時間
        while arrivalTime > leaveTime:
            leaveTime+=F[j]
        arrivalTime=leaveTime+C[j]
    print(arrivalTime)
print(0)#[N-1]駅

### FIXED CODE ###

N=int(input())
C,S,F=[0]*(N-1),[0]*(N-1),[0]*(N-1)
for i in range(N-1):
    C[i],S[i],F[i]=map(int,input().split())
for i in range(N-1): #一周につき一つの駅([0]..[N-2])から[N-1]までの計算
    arrivalTime=S[i]+C[i]#最初発車駅の次の駅に着く時間
    for j in range(i+1,N-1):
        leaveTime=S[j]#現在考慮中の駅から初めて発車する時間
        if arrivalTime <leaveTime:
            pass
        elif arrivalTime % F[j]==0:
            leaveTime=arrivalTime
        else:
            leaveTime=arrivalTime+F[j]- arrivalTime % F[j]
        '''
        while arrivalTime > leaveTime:
            leaveTime+=F[j]
        '''
        arrivalTime=leaveTime+C[j]
    print(arrivalTime)
print(0)#[N-1]駅
### BUGGY CODE ###

r,g,b,n = map(int,input().split())
c = 0
for i in range(n+1):
    for j in range(n+1):
        if (n-i*r-j*g) >= 0 and (n-i*r-j*g)%b == 0:
            c += 1
print(c)

### FIXED CODE ###

r,g,b,n = map(int,input().split())
c = 0
for i in range(n+1):
    for j in range(n+1):
        if (n-i*r-j*g) >= 0 and (n-i*r-j*g)%b == 0:
            c += 1
print(c)
### BUGGY CODE ###

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

def list_seki(l):
    S = 1
    for i in range(0, len(l)):
        S *= l[i]
    return S

def hikaku(l):
    for i in range(1, len(l)):
        if l[i-1]<l[i]:
            print("Yes")
        else:
            print("No")

D = []
for x in range(K, N+1):
    before = list_seki(A[x-K:x])
    D.append(before)

hikaku(D)

### FIXED CODE ###

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

for x in range(K-1, N-1):
    if A[x-K+1] < A[x+1]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

N, M = list(map(int, input().split()))
BA = []
for _ in range(N):
    a, b = list(map(int, input().split()))
    BA.append((b, a))

ans = 0
MAX = 10 ** 5 + 1
schedule = [i for i in range(M + 1)]
BA.sort(reverse=True)
x = None
for b, a in BA:
    if a < M:
        if schedule[a] == MAX:
            x = min(schedule[a+1:])
            if x == MAX:
                continue
        else:
            x = a
    elif a == M and schedule[a] != MAX:
        x = a
    else:
        continue
    schedule[x] = MAX
    ans += b
print(ans)

### FIXED CODE ###

class Node:
    
    def __init__(self, i):
        self.end = i + 1
        self.days = {i}


N, M = list(map(int, input().split()))
BA = []
for i in range(N):
    a, b = list(map(int, input().split()))
    BA.append((b, a))

ans = 0
schedule = {}


def concat(node1, node2, x):
    if len(node1.days) < len(node2.days):
        node1, node2 = node2, node1
    else:
        node1.end = node2.end
    node1.days |= node2.days
    for i in node2.days:
        schedule[i] = node1
    schedule[x] = node1
    node1.days.add(x)

BA.sort(reverse=True)
for b, a in BA:
    if a <= M:
        if a in schedule:
            w = schedule[a]
            x = w.end
            if x <= M:
                ans += b
                if x + 1 in schedule:
                    concat(w, schedule[x + 1], x)
                else:
                    schedule[x] = w
                    w.days.add(x)
                    w.end += 1
        else:
            ans += b
            if a + 1 in schedule:
                w = schedule[a + 1]
                if a - 1 in schedule:
                    concat(schedule[a - 1], w, a)
                else:
                    schedule[a] = w
                    w.days.add(a)
            elif a - 1 in schedule:
                w = schedule[a - 1]
                schedule[a] = w
                w.days.add(a)
                w.end += 1
            else:
                schedule[a] = Node(a)
print(ans)
### BUGGY CODE ###

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

left   = [[0] * 2005 for i in range(2005)]
right  = [[0] * 2005 for i in range(2005)]
top    = [[0] * 2005 for i in range(2005)]
bottom = [[0] * 2005 for i in range(2005)]

for h in range(H):
	cur = 0
	for w in range(W):
		if grid[h][w] == '#':
			left[h][w] = -1
			cur = 0
		else:
			left[h][w] = cur
			cur += 1
	cur = 0
	for w in range(W-1, -1, -1):
		if grid[h][w] == '#':
			right[h][w] = -1
			cur = 0
		else:
			right[h][w] = cur
			cur += 1

for w in range(W):
	cur = 0
	for h in range(H):
		if grid[h][w] == '#':
			top[h][w] = -1
			cur = 0
		else:
			top[h][w] = cur
			cur += 1

	cur = 0
	for h in range(H-1, -1, -1):
		if grid[h][w] == '#':
			bottom[h][w] = -1
			cur = 0
		else:
			bottom[h][w] = cur
			cur += 1

ans = 0
for h in range(H):
	for w in range(W):
		if grid[h][w] == '.':
			ans = max(ans, left[h][w] + right[h][w] + top[h][w] + bottom[h][w] + 1)
print(ans)

### FIXED CODE ###

H, W = map(int, input().split())
grid = [input() for _ in range(H)]

left   = [[0] * 2005 for i in range(2005)]
right  = [[0] * 2005 for i in range(2005)]
top    = [[0] * 2005 for i in range(2005)]
bottom = [[0] * 2005 for i in range(2005)]

for h in range(H):
	cur = 0
	for w in range(W):
		if grid[h][w] == '#':
			left[h][w] = -1
			cur = 0
		else:
			left[h][w] = cur
			cur += 1
	cur = 0
	for w in range(W-1, -1, -1):
		if grid[h][w] == '#':
			right[h][w] = -1
			cur = 0
		else:
			right[h][w] = cur
			cur += 1

for w in range(W):
	cur = 0
	for h in range(H):
		if grid[h][w] == '#':
			top[h][w] = -1
			cur = 0
		else:
			top[h][w] = cur
			cur += 1

	cur = 0
	for h in range(H-1, -1, -1):
		if grid[h][w] == '#':
			bottom[h][w] = -1
			cur = 0
		else:
			bottom[h][w] = cur
			cur += 1

ans = 0
for h in range(H):
	for w in range(W):
		if grid[h][w] == '.':
			ans = max(ans, left[h][w] + right[h][w] + top[h][w] + bottom[h][w] + 1)
print(ans)
### BUGGY CODE ###

import sys

input = sys.stdin.readline

N, C = map(int, input().split())
stc = [[int(x) for x in input().split()] for _ in range(N)]

T = 10 ** 5 + 1
A = [[0] * T for _ in range(C)]
for s, t, c in stc:
    A[c - 1][s] += 1
    A[c - 1][t] -= 1

for i in range(C):
    for j in range(1, T):
        A[i][j] += A[i][j - 1]
        if A[i][j] == 1 and A[i][j - 1] == 0:
            A[i][j - 1] = 1

ans = 0
for j in range(1, T):
    cnt = 0
    for i in range(C):
        cnt += A[i][j]
    ans = max(ans, cnt)
print(ans)


### FIXED CODE ###

N, C = map(int, input().split())
tv = [list(map(int, input().split())) for _ in range(N)]

max_t = max(tv, key=lambda x: x[1])[1]
channels = [[0 for _ in range(max_t)] for _ in range(C)]

for s, t, c in tv:
    channels[c - 1][s - 1:t] = [1] * (t - s + 1)

ans = 0
for T in list(zip(*channels)):
    ans = max(ans, sum(T))
print(ans)
### BUGGY CODE ###

from itertools import accumulate
n,k = map(int,input().split())
p = list(map(int,input().split()))

def expect_dice(n):
    s = 0
    for i in range(1,n+1):
        s += i
    return s/n 
for i in range(len(p)):
    p[i] = expect_dice(p[i])
    
p = [0] + p
p = list(accumulate(p))

ans = []
for i in range(n-k+1):
    ans.append(p[i+k] - p[i])
    
print(max(ans))

### FIXED CODE ###

#累積和の利用！！！！！！！！
from itertools import accumulate
n,k = map(int,input().split())
p = list(map(int,input().split()))

m = [(e + 1) / 2 for e in p]
    
m = [0] + m
m = list(accumulate(m))

ans = []
for i in range(n-k+1):
    ans.append(m[i+k] - m[i])
    
print(max(ans))
### BUGGY CODE ###

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


def main():
	Ls = []
	Rs = []
	for i in range(M):
		inputs = list(map(int,input().split()))
		Ls.append(inputs[0])
		Rs.append(inputs[1])

	result = set()
	for i in range(1, M + 1):
		Li = Ls[i - 1]
		LiPlus = [j for j in range(Li + 1, Rs[i - 1] + 1)]
		if len(result) == 0:
			result = set([Li] + LiPlus)
			continue
		result = result & set([Li] + LiPlus)

	print(len(result))

if __name__ == '__main__':
	main()

### FIXED CODE ###

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


def main():
	Ls = []
	Rs = []
	for i in range(M):
		inputs = list(map(int,input().split()))
		Ls.append(inputs[0])
		Rs.append(inputs[1])

	maxL = max(Ls)
	minR = min(Rs)

	if maxL > minR:
		print(0)
	else:
		print(minR - maxL + 1)

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

N=int(input())
A=list(map(int,input().split()))
a=1
for i in range(1,N):
    if A[i]<min(A[:i]):
        a+=1
print(a)

### FIXED CODE ###

#min関数は計算量食うので使わない
N=int(input())
A=list(map(int,input().split()))
a=0
m=A[0]
for i in range(N):
    if A[i]<=m:
        a+=1
        m=A[i]#今のA[i]より前に小さい値がある場合に現時点の最小値としてmに記録する
print(a)
### BUGGY CODE ###



import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n, *a = map(int, read().split())

val=1
for x in a:
    val*=x

print(val if val<=10**18 else '-1')

### FIXED CODE ###


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

    if 0 in A:
        print(0)
        return

    prod = 1
    for a in A:
        prod *= a
        if prod > 1000000000000000000:
            print(-1)
            return

    print(prod)
    return

main ()
### BUGGY CODE ###

def notempty(b):
    return any(map(lambda x: len(x), b))


n = int(input())
a = [list(reversed(list(map(lambda x:int(x) - 1, input().split()))))
     for _ in range(n)]
cnt = 0
while notempty(a):
    flg = 0
    cnt += 1
    li = [True] * n
    for i in range(n):
        if len(a[i]) and li[i] and len(a[[i][-1]]) and li[a[i][-1]] and a[a[i][-1]][-1] == i:
            5
            tmp = a[i][-1]
            a[i].pop()
            a[tmp].pop()
            li[i], li[tmp] = False, False
            flg = 1
    if not flg:
        print(-1)
        exit(0)
print(cnt)


### FIXED CODE ###

n = int(input())
g = [[] for _ in range(n ** 2)]
inv = [0] * (n ** 2)
for i in range(n):
    a = list(map(lambda x: int(x)-1, input().split()))
    for j in range(n - 2):
        p, q = min(i, a[j]), max(i, a[j])
        r, s = min(i, a[j + 1]), max(i, a[j + 1])
        g[p * n + q].append(r * n + s)
        inv[r * n + s] += 1
s = []
for i in range(n):
    for j in range(i + 1, n):
        if inv[i * n + j] == 0:
            s.append(i * n + j)
d = [0] * (n ** 2)
while s:
    p = s.pop()
    for node in g[p]:
        d[node] = max(d[node], d[p] + 1)
        inv[node] -= 1
        if inv[node] == 0:
            s.append(node)
for i in range(n):
    for j in range(i + 1, n):
        if inv[i * n + j] > 0:
            print(-1)
            exit(0)
print(max(d) + 1)
### BUGGY CODE ###

N = int(input())
A = [int(a) for a in input().split(' ')]

counter = 0

l = 0
r = 0
flag = True
check_list = [0 for j in range(20)]

while r < N:

    if flag:
        A_test = A[r]

        for k in range(20):

            if A_test % (2 ** (k+1))  != 0:
                check_list[k] = check_list[k] + 1
                A_test = A_test - (2 ** k)

            if check_list[k] > 1:
                flag = False

        if flag:
            counter = counter + (r - l + 1)

    else:
        ## moving l

        A_test = A[l-1]
        flag = True

        for k in range(20):

            if A_test % (2 ** (k+1))  != 0:
                check_list[k] = check_list[k] - 1
                A_test = A_test - (2 ** k)

            if check_list[k] > 1:
                flag = False

        if flag:
            counter = counter + (r - l + 1)

    if flag:
        r = r + 1
    else:
        l = l + 1

print(counter)

### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split(' ')]

counter = 0

l = 0
r = 0
flag = True
xor = 0
sum = 0

while r < N and l < N:
    if flag:
        xor ^= A[r]
        sum += A[r]
        if xor == sum:
            counter += (r - l + 1)
        else:
            flag = False
    else:
        xor ^= A[l-1]
        sum -= A[l-1]
        if xor == sum:
            counter += r - l + 1
            flag = True

    if flag:
        r += 1
    else:
        l += 1

print(counter)
### BUGGY CODE ###

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

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
inf = 10**9+7
aa = [0]*N

for i in range(N):
  aa[i] = A[i]**2
X = sum(A)**2 - sum(aa)
print((X//2)%inf)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next , now)

dfs(0)
print(*point)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10 ** 6)
import sys
def input():
    return sys.stdin.readline()[:-1]
N , Q = map(int,input().split())
graph = [[] for _ in range(N)]
point = [0] * N
for _ in range(N - 1):
    a , b = map(int,input().split())
    graph[a - 1].append(b - 1)
    graph[b - 1].append(a - 1)
#print(graph)
for _ in range(Q):
    a , b = map(int,input().split())
    a = a - 1
    point[a] += b
# dfsを用いて累積和を計算する
# 初期状態だと前の値がないためデフォルト引数に-1を代入
def dfs(now , prev = -1):
    for next in graph[now]:
        # 次のノードが前に参照した値の時はcontinue
        if next == prev:
            continue
        # 現在の値を次のポイントに加算することで累積和をとる
        point[next] += point[now]
        # 次のノードと現在のノードを引数にdfsを継続する
        dfs(next , now)

dfs(0)
print(*point)
### BUGGY CODE ###

import numpy as np

p = int(input())
aaa = list(map(int, input().split()))

bins = [1]
for i in range(1, p):
    bins.append(bins[-1] * (p - i) * pow(i, p - 2, p) % p)
bins = np.array(bins, dtype=np.int32)

coefs = np.zeros(p, dtype=np.int32)

for i, a in enumerate(aaa):
    if a == 0:
        continue

    coefs[0] += 1

    pows = [1]
    for _ in range(1, p):
        pows.append(pows[-1] * -i % p)
    pows.reverse()
    pows = np.array(pows, dtype=np.int32)

    coefs = (coefs - bins * pows) % p

print(*coefs)


### FIXED CODE ###

p = int(input())
aaa = list(map(int, input().split()))

coefs = [0] * p
coefs[0] = sum(aaa)
invs = [pow(x, p - 2, p) for x in range(p + 1)]
for i, a in enumerate(aaa):
    if a == 0:
        continue

    b = 1
    c = 1
    for j in range(p - 1, -1, -1):
        coefs[j] = (coefs[j] - b * c) % p
        b = -b * i % p
        c = c * j * invs[p - j] % p

print(*coefs)
### BUGGY CODE ###

from sys import stdin, setrecursionlimit
import collections


def initialize_cmb(m, mod=10 ** 9 + 7):
    fac = [0] * m
    finv = [0] * m
    inv = [0] * m
    fac[0] = 1
    finv[0] = 1
    if m > 1:
        fac[1] = 1
        finv[1] = 1
        inv[1] = 1
        for i in range(2, m):
            fac[i] = fac[i-1] * i % mod
            inv[i] = mod - inv[mod % i] * (mod // i) % mod
            finv[i] = finv[i - 1] * inv[i] % mod
    return fac, finv


def cmb(n, k, fac, finv, mod=10 ** 9 + 7):
    if n < k:
        return 0
    if n < 0 or k < 0:
        return 0
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod


def main():
    input = stdin.readline
    s = list(input()[:-1])
    s = list(map(int, s))
    N = len(s)
    mod = [0] * N
    mod[-1] = s[-1] % 2019
    for i in reversed(range(N - 1)):
        mod[i] = (mod[i + 1] + s[i] * 10 ** (N - i - 1)) % 2019

    fac, finv = initialize_cmb(N)

    counter = collections.Counter(mod)

    ans = 0

    for k, v in counter.items():
        if k == 0:
            ans += v
        elif v > 1:
            ans += cmb(v, 2, fac, finv)

    print(ans)


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()


### FIXED CODE ###

from sys import stdin, setrecursionlimit


def main():
    input = stdin.readline
    s = list(input()[:-1])[::-1]
    N = len(s)
    p10 = [1]
    tmp = 1
    for _ in range(N - 1):
        tmp = tmp * 10 % 2019
        p10.append(tmp)
    mod = []
    tmp = 0
    for num, p in zip(s, p10):
        tmp = (tmp + int(num) * p) % 2019
        mod.append(tmp)

    mod.sort()
    mod.insert(0, 0)

    ans = 0
    count = 1
    for i in range(1, N + 1):
        if mod[i] == mod[i - 1]:
            count += 1
        else:
            ans += count * (count - 1) // 2
            count = 1
    ans += count * (count - 1) // 2
    print(ans)


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

N = int(input())
S = []
for i in range(N):
    temp = input()
    val = [0 for k in range(26)]
    for j in range(10):
        val[ord(temp[j])-97] += 1
    S.append(val)

kind = [S[0]]
cnt = [1]
lenkind = 1
for i in range(1, N):
    flg = 0
    for j in range(lenkind):
        if S[i] == kind[j]:
            cnt[j] += 1
            flg = 1
            break
    if flg == 0:
        kind.append(S[i])
        cnt.append(1)
        lenkind += 1

ans = 0
for i in range(lenkind):
    temp = cnt[i]
    ans += (temp*(temp-1) // 2)
print(str(ans))


### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
    temp = input()
    S.append(''.join(sorted(temp)))
S.sort()
row = 1
ans = 0
for i in range(N-1):
    if S[i] == S[i+1]:
        row += 1
    else:
        ans += (row*(row-1) // 2)
        row = 1
if row > 1:
    ans += (row*(row-1) // 2)
print(str(ans))
### BUGGY CODE ###

import sys
import collections
n = int(input())
s = [input() for i in range(n)]
s = sorted(s)
c = set(s)
c = list(c)
li = []
for i in range(len(c)):
    li.append(c[i])
li2 = [0 for i in range(len(li))]
for i in range(n):
    for j in range(len(li)):
        if s[i] == li[j]:
            li2[j]+=1
max_v = max(li2)
li3 = []
for i in range(len(li2)):
    if li2[i] == max_v:
        li3.append(li[i])
li3 = sorted(li3)
for i in range(len(li3)):
    print(li3[i])




### FIXED CODE ###

import sys
import collections
n = int(input())
s = [input() for i in range(n)]
s = sorted(s)
c = collections.Counter(s)
li = []
max_v = -1
for k,j in c.items():
    li.append([k,j])
    if max_v<j:
        max_v = j
li = sorted(li)
for i in range(len(li)):
    if li[i][1] == max_v:
        print(li[i][0])
### BUGGY CODE ###

n = int(input())
H = list(map(int, input().split()))
ans = 0
for i in range(n):
  tmp = 0
  for j in range(i, n-1):
    if H[j] >= H[j+1]:
      tmp += 1
    else:
      break
    ans = max(ans, tmp)
print(ans)

### FIXED CODE ###

n = int(input())
H = list(map(int, input().split()))
TMP = []
ans = 0
for i in range(n-1):
  if H[i] >= H[i+1]:
    TMP.append(1)
  else:
    TMP.append(-1)
tmp = 0
for i in range(n-1):
  if TMP[i] == 1:
    tmp += 1
  else:
    ans = max(ans, tmp)
    tmp = 0
ans = max(ans, tmp)
print(ans)
### BUGGY CODE ###

from collections import Counter
N = int(input())
S = []
ans = 0
for i in range(N):
  s = list(input())
  c = Counter(s)
  S.append(c)
for i in range(N-1):
  for j in range(i+1,N):
    if S[i] == S[j]:
      ans += 1
print(ans)

### FIXED CODE ###

N = int(input())
memo = {}
ans = 0
for i in range(N):
  s = list(input())
  s.sort()
  s = str(s)
  if s in memo.keys():
    memo[s] += 1
  else:
    memo[s] = 1
for v in memo.values():
  if v >= 2:
    ans += v*(v-1)//2
print(ans)
### BUGGY CODE ###

N = int(input())
maxnum = 0
for i in range(N, int("1" + (len(str(N))-1)*"0") - 1-1, -1):
    tmp = list(str(i))
    tmp = [int(item) for item in tmp]
    maxnum = max(sum(tmp), maxnum)

print(maxnum)

### FIXED CODE ###

N = int(input())

if N > 9:
    if (N%(int("1" + (len(str(N)) - 1)*"0"))) == int((len(str(N)) - 1) * "9"):
        tmp = list(str(N))
        tmp = [int(item) for item in tmp]
        print(sum(tmp))
    else:
        tmp = list(str(N - (N%(int("1" + (len(str(N)) - 1)*"0"))) - 1))
        tmp = [int(item) for item in tmp]
        print(sum(tmp))
else:
    print(N)
### BUGGY CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-K):
    if sum(A[i:i+K]) < sum(A[i+1:i+K+1]):
        print("Yes")
    else:
        print("No")



### FIXED CODE ###

N, K = map(int,input().split())
A = list(map(int,input().split()))
for i in range(N-K):
    if  A[i] < A[i+K]:
        print("Yes")
    else:
        print("No")
### BUGGY CODE ###

import sys
from bisect import bisect_left
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *XY = map(int, read().split())

    X = set()
    Y = set()
    for i, (x, y) in enumerate(zip(*[iter(XY)] * 2)):
        X.add(x)
        Y.add(y)

    X = sorted(X)
    Y = sorted(Y)

    P, Q = len(X), len(Y)

    ans = -1
    for i, x1 in enumerate(X):
        for x2 in X[i + 1 :]:
            for j, y1 in enumerate(Y):
                for y2 in Y[j + 1 :]:
                    p = 0
                    for x, y in zip(*[iter(XY)] * 2):
                        if x1 <= x <= x2 and y1 <= y <= y2:
                            p += 1

                    if p >= K and (ans > (x2 - x1) * (y2 - y1) or ans == -1):
                        ans = (x2 - x1) * (y2 - y1)

    print(ans)
    return


if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
from bisect import bisect_left
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N, K, *XY = map(int, read().split())

    X = set()
    Y = set()
    for i, (x, y) in enumerate(zip(*[iter(XY)] * 2)):
        X.add(x - 1)
        Y.add(y - 1)

    X = sorted(X)
    Y = sorted(Y)

    P, Q = len(X), len(Y)

    G = [[0] * Q for _ in range(P)]
    for x, y in zip(*[iter(XY)] * 2):
        G[bisect_left(X, x - 1)][bisect_left(Y, y - 1)] = 1

    csum = [[0] * (Q + 1) for _ in range(P + 1)]
    for i in range(P):
        for j in range(Q):
            csum[i + 1][j + 1] = csum[i + 1][j] + csum[i][j + 1] - csum[i][j] + G[i][j]

    ans = -1
    for x1 in range(P):
        for x2 in range(x1, P + 1):
            for y1 in range(Q):
                for y2 in range(y1, Q + 1):
                    if csum[x2][y2] - csum[x1][y2] - csum[x2][y1] + csum[x1][y1] >= K:
                        if ans > (X[x2 - 1] - X[x1]) * (Y[y2 - 1] - Y[y1]) or ans == -1:
                            ans = (X[x2 - 1] - X[x1]) * (Y[y2 - 1] - Y[y1])

    print(ans)
    return


if __name__ == '__main__':
    main()