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

import math

N, M, K = (int(x) for x in input().split())

def nCm(n,m):
    if m < 0 or m > n:
        return 0
    nf = math.factorial(n)
    nm = math.factorial(m)
    nm2 = math.factorial(n-m)
    return (nf//nm//nm2) % 1000000007

c_sum = (M*(N-1)*N*(N+1)*M+N*(M-1)*M*(M+1)*N)//3
c_sum = c_sum//2
c_sum *= nCm(N*M-2, K-2)
c_sum = c_sum % 1000000007

print(c_sum)


### FIXED CODE ###

import math

N, M, K = (int(x) for x in input().split())

def comb(n,k,p):
    if k < 0 or k > n:
        return 0
    if n == 0 or k == 0:
        return 1
    a=math.factorial(n) % p
    b=math.factorial(k) % p
    c=math.factorial(n-k) % p
    return (a*mypow(b,p-2,p)*mypow(c,p-2,p)) % p

def mypow(a,b,p):
    if b == 0: return 1
    if b % 2 == 0:
        d=mypow(a,b//2,p)
        return d*d % p
    if b % 2 == 1:
        return (a*mypow(a,b-1,p )) % p

c_sum = (M*(N-1)*N*(N+1)*M+N*(M-1)*M*(M+1)*N)//3
c_sum = c_sum//2
c_sum *= comb(N*M-2, K-2, 1000000007)
c_sum = c_sum % 1000000007

print(c_sum)
### BUGGY CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(min(k, 50)):
    b = [0]*(n+1)
    for i in range(n):
        b[max(0, i-a[i])] += 1
        b[min(i+a[i]+1, n)] -= 1
    for i in range(1, n+1):
        b[i] += b[i-1]
    for i in range(n):
        a[i] = b[i]
print(*a)

### FIXED CODE ###

n, k = map(int, input().split())
a = list(map(int, input().split()))
for _ in range(min(k, 50)):
    b = [0]*(n+1)
    for i in range(n):
        b[max(0, i-a[i])] += 1
        b[min(i+a[i]+1, n)] -= 1
    for i in range(1, n+1):
        b[i] += b[i-1]
    for i in range(n):
        a[i] = b[i]
print(*a)
### BUGGY CODE ###

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

result = A
for i in range(A+1, B+1):
    result = result ^ i

print(result)


### FIXED CODE ###

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


def f(a):
    if a % 2 == 0:
        return 0^a if (a // 2) % 2 == 0 else 1^a
    else:
        return 0 if ((a+1) // 2) % 2 == 0 else 1

print(f(B)^f(A-1))
### BUGGY CODE ###

H,W,D = map(int,input().split())
d = {}
for i in range(H):
    A = list(map(int,input().split()))
    for j in range(W):
        d[A[j]] = (i,j)
Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    if L == R:
        print(0)
    else:
        ans = 0
        while L < R:
            ans += abs(d[L+D][0]-d[L][0])+abs(d[L+D][1]-d[L][1])
            L+=D
        print(ans)

### FIXED CODE ###

H,W,D = map(int,input().split())
d = {}
for i in range(H):
    A = list(map(int,input().split()))
    for j in range(W):
        d[A[j]] = (i,j)
m = []
for i in range(1,D+1):
    mm = [0]
    for j in range(i+D,H*W+1,D):
        k = (j-i)//D
        dd = mm[k-1]+abs(d[j][0]-d[j-D][0])+abs(d[j][1]-d[j-D][1])
        mm.append(dd)
    m.append(mm)
Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    if L%D != 0:
        mm = m[L%D-1]
        Lq = L//D
        Rq = R//D
        print(mm[Rq]-mm[Lq])
    else:
        mm = m[D-1]
        Lq = L//D
        Rq = R//D
        print(mm[Rq-1]-mm[Lq-1])
### BUGGY CODE ###

N = int(input())
A = [int(a) for a in input().split()]
mod = 10**9+7
SUM = 0

maxA = max(A)
d = 0
while 1:
    if maxA < 2**d:
        break
    d += 1

BitSumB = 0
for i in range(d):
    tmp = 0
    for n in range(N):
        tmp += (A[n] >> i) & 1
    BitSumB += (2**i) * tmp * (N - tmp)



"""
BitA = [[0]*d for _ in range(N)]
for i in range(N):
    BitA[i] = list(map(int, format(bin(A[i])[2:], '0>{}'.format(d))))

BitSumB = 0
for i in range(d):
    tmp = sum([BitA[j][i] for j in range(N)])
    BitSumB += 2 ** (d-i-1) * (tmp * (N - tmp))
    #BitSumB = BitSumB % mod
"""

print(BitSumB % mod)


### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]
mod = 10**9+7
SUM = 0

maxA = max(A)
d = 0
while 1:
    if maxA < 2**d:
        break
    d += 1

BitSumB = 0
for i in range(d):
    tmp = 0
    for n in range(N):
        tmp += (A[n] >> i) & 1
    BitSumB += (2**i) * tmp * (N - tmp)



"""
BitA = [[0]*d for _ in range(N)]
for i in range(N):
    BitA[i] = list(map(int, format(bin(A[i])[2:], '0>{}'.format(d))))

BitSumB = 0
for i in range(d):
    tmp = sum([BitA[j][i] for j in range(N)])
    BitSumB += 2 ** (d-i-1) * (tmp * (N - tmp))
    #BitSumB = BitSumB % mod
"""

print(BitSumB % mod)
### BUGGY CODE ###

#c
n = int(input())
a = list(map(int, input().split()))
import itertools
ans = 0

for i in range(len(a)-1):
    ans += a[i]*sum(a[i+1:])

print(ans % (10**9 + 7))

### FIXED CODE ###

#cやり直し
import numpy
n = int(input())
a = list(map(int, input().split()))
ans = 0
mod = 10**9 +7

before = a[-1]
for i in range(n-1,0,-1):
    
    ans += (a[i-1]*before)%mod
    before += a[i-1]
    
print(ans%mod)
### BUGGY CODE ###

n, m = map(int,input().split())
height = list(map(int,input().split()))
arr = []

for i in range(m):
   x, y = map(int,input().split())
   height_x = height[x-1]
   height_y = height[y-1]
   if height_x > height_y:
      if y not in arr:
         arr.append(y)
   elif height_x < height_y:
      if x not in arr:
         arr.append(x)
   else:
      if x not in arr:
         arr.append(x)
      if y not in arr:
         arr.append(y)
print(n-len(arr))



### FIXED CODE ###

n, m = map(int,input().split())
height = list(map(int,input().split()))
arr = []

for i in range(m):
   x, y = map(int,input().split())
   height_x = height[x-1]
   height_y = height[y-1]
   if height_x > height_y:
      arr.append(y)
   elif height_x < height_y:
      arr.append(x)
   else:
      arr.append(x)
      arr.append(y)
arr = list(set(arr))
print(n-len(arr))
### BUGGY CODE ###

L=list(map(int,input()))
n=len(L)
X=pow(3,n-1)%(10**9+7)
count=1
for i in range(1,n):
    if L[i]==1:
        k=n-i-1
        count+=1
        X+=(pow(3,k)*pow(2,count-1))%(10**9+7)
X+=pow(2,count)%(10**9+7)
print(X%(10**9+7))


### FIXED CODE ###

L=list(map(int,input()))
n=len(L)
def power(a,n):
    x=1
    L=list(format(n,'b'))
    l=len(L)
    for i in range(l):
        if int(L[l-i-1])==1:        
            x=(x*a)%(10**9+7)
        a=(a*a)%(10**9+7)
    return x
X=power(3,n-1)%(10**9+7)
count=1
for i in range(1,n):
    if L[i]==1:
        k=n-i-1
        count+=1
        X+=(power(3,k)%(10**9+7))*(power(2,count-1)%(10**9+7))
X+=power(2,count)%(10**9+7)
print(X%(10**9+7))
### BUGGY CODE ###

S = input()
Q = int(input())
flag = True
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    flag = not flag
  elif flag ^ (string[1] == '1'):
      S = S + string[2]
  else:
      S = string[2] + S
if not flag:
  S = S[::-1]
print(S)

### FIXED CODE ###

from collections import deque
S = deque()
tmp = input()
for i in range(len(tmp)):
  S.append(tmp[i])
Q = int(input())
flag = True
for i in range(Q):
  string = input().split()
  if string[0] == '1':
    flag = not flag
  elif flag ^ (string[1] == '1'):
      S.append(string[2])
  else:
      S.appendleft(string[2])
if not flag:
  S.reverse()
for s in S:
  print(s, end='')
### BUGGY CODE ###

import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

sys.setrecursionlimit(10 ** 7)

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

n, k = na()
a = na()

dp = [[-1] * (n + 1) for _ in range(61)]
for i in range(n):
    dp[0][i] = a[i] - 1
for i in range(60):
    for j in range(n):
        dp[i + 1][j] = dp[i][dp[i][j]]

cur = 0
for i in range(60, -1, -1):
    if k & (1 << i):
        cur = dp[i][cur]

print(cur + 1)

### FIXED CODE ###

import sys

stdin = sys.stdin
inf = 1 << 60
mod = 1000000007

ni      = lambda: int(ns())
nin     = lambda y: [ni() for _ in range(y)]
na      = lambda: list(map(int, stdin.readline().split()))
nan     = lambda y: [na() for _ in range(y)]
nf      = lambda: float(ns())
nfn     = lambda y: [nf() for _ in range(y)]
nfa     = lambda: list(map(float, stdin.readline().split()))
nfan    = lambda y: [nfa() for _ in range(y)]
ns      = lambda: stdin.readline().rstrip()
nsn     = lambda y: [ns() for _ in range(y)]
ncl     = lambda y: [list(ns()) for _ in range(y)]
nas     = lambda: stdin.readline().split()

sys.setrecursionlimit(10 ** 7)

n, k = na()
a = na()

proc = [0] * n
def rec(i, cnt):
    if proc[i]:
        return (cnt, i)
    proc[i] = 1
    return rec(a[i] - 1, cnt + 1)

def rec2(i, arr):
    if proc[i] >= 2:
        return arr
    proc[i] += 1
    arr.append(i)
    return rec2(a[i] - 1, arr)

cnt, i = rec(0, 0)
arr = rec2(i, [])

nk = k
nk -= cnt - len(arr)
if nk < 0:
    ans = 0
    for i in range(k):
        ans = a[ans] - 1
    print(ans + 1)
else:
    print(arr[nk % len(arr)] + 1)
### BUGGY CODE ###

from collections import deque
import sys
input = sys.stdin.readline


def bfs(table, i, j):
    dq = deque()
    seen = []
    if table[i][j] == "#":
        return -1
    h = len(table)
    w = len(table[0])
    ans = 0
    dq.append((i, j, 0))  # x,y,distance
    while dq:
        x, y, dis = dq.popleft()
        ans = max(ans, dis)
        seen.append((x, y))
        if x > 0 and (x - 1, y) not in seen and table[x - 1][y] != "#":
            dq.append((x - 1, y, dis + 1))
        if x < h - 1 and (x + 1, y) not in seen and table[x + 1][y] != "#":
            dq.append((x + 1, y, dis + 1))
        if y > 0 and (x, y - 1) not in seen and table[x][y - 1] != "#":
            dq.append((x, y - 1, dis + 1))
        if y < w - 1 and (x, y + 1) not in seen and table[x][y + 1] != "#":
            dq.append((x, y + 1, dis + 1))
    return ans


def main():
    h, w = [int(i) for i in input().strip().split()]
    grid = [list(input().strip()) for _ in range(h)]
    ans = -1
    for i in range(h):
        for j in range(w):
            if grid[i][j] == ".":
                max_path = bfs(grid, i, j)
                ans = max(ans, max_path)

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from collections import deque
 
def main():
    H,W=map(int,input().split())
    S=[]
    for i in range(H):
        s=input()
        S.append(s)
 
    G=[]
    for i in range(H):
        for j in range(W):
            tmp=[]
            if S[i][j]=="#":
                G.append(tmp)
                continue
            if i-1>=0:
                if S[i-1][j]==".":
                    tmp.append((i-1)*W+j)
            if i+1<=H-1:
                if S[i+1][j]==".":
                    tmp.append((i+1)*W+j)
            if j-1>=0:
                if S[i][j-1]==".":
                    tmp.append(i*W+j-1)
            if j+1<=W-1:
                if S[i][j+1]==".":
                    tmp.append(i*W+j+1)
            G.append(tmp)
 
    res=0
 
    for start in range(H*W):
        dist = 0
        v = [-1 for _ in range(H * W)]
        que=deque([])
        que.append(start)
        v[start]=dist
        while len(que)>0:
            next_index=que.popleft()
            next=G[next_index]
            for i in next:
                if v[i]==-1:
                    que.append(i)
                    v[i]=v[next_index]+1
 
        if max(v)>=res:
            res=max(v)
 
    print(res)
 
 
if __name__=="__main__":
    main()
### BUGGY CODE ###

def main():
    N = int(input())

    A = [int(input()) for _ in range(N)]

    for i in range(len(A)):
        ans = calcMax(A, i)
        print(ans)



def calcMax(A, i):
    ans = max(A)
    if not ans == A[i]:
        return ans

    else:
        tmp = A[i]
        A[i] = 0
        ans = calcMax(A, i)
        A[i] = tmp
        return ans

if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    N = int(input())
    A = [int(input()) for _ in range(N)]

    max1st = max(A)
    max1stIndex = A.index(max1st)

    for i in range(len(A)):
        if i == max1stIndex:
            tmp = A[i]
            A[i] = 0
            print(max(A))
            continue

        print(max1st)




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

n = int(input())
a = list(map(int, input().split()))
q = int(input())
bc = [list(map(int, input().split())) for _ in range(q)]

from collections import Counter
counter = Counter(a)

for b,c in bc:
    if b in counter:
        cnt = counter.pop(b)
        counter[c] += cnt
    print(sum([k*v for k,v in counter.items()]))

### FIXED CODE ###

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

q = int(input())

from collections import Counter

ca = Counter(a)

ans=sum(a)
for _ in range(q):
    b,c = list(map(int, input().split()))
    
    if b in ca:
        cnt = ca.pop(b)
        ca[c] += cnt

        ans -= b * cnt
        ans += c * cnt
    
    print(ans)
### BUGGY CODE ###

import sys

def solve():
    N, Ma, Mb = map(int, input().split())
    table = [tuple(map(int, input().split())) for i in range(N)]

    g1 = half_rekkyo(N, Ma, Mb, table, 0, N // 2)
    g2 = half_rekkyo(N, Ma, Mb, table, N // 2, N - N // 2)

    inf = 100 * 40 + 1
    ans = inf

    if 0 in g1:
        ans = min(ans, g1[0])
    if 0 in g2:
        ans = min(ans, g2[0])

    for v1, c1 in g1.items():
        if -v1 in g2:
            tmp = c1 + g2[-v1]
            ans = min(ans, tmp)

    if ans < inf:
        print(ans)
    else:
        print(-1)

def half_rekkyo(N, Ma, Mb, table, s, m):
    res = dict()

    for comb in range(1, 2**m):
        v = 0
        cost = 0

        for i in range(m):
            if comb & (1 << i):
                a, b, c = table[s + i]
                v += b * Ma - a * Mb
                cost += c

        if v in res:
            res[v] = min(res[v], cost)
        else:
            res[v] = cost

    return res

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None


if __name__ == '__main__':
    solve()

### FIXED CODE ###

import sys

def debug(x, table):
    for name, val in table.items():
        if x is val:
            print('DEBUG:{} -> {}'.format(name, val), file=sys.stderr)
            return None

def solve():
    N, Ma, Mb = map(int, input().split())
    a_w = []
    b_w = []
    costs = []

    for i in range(N):
        a, b, c = map(int, input().split())
        a_w.append(a)
        b_w.append(b)
        costs.append(c)

    dp = [[[-1]*(10*N + 1) for j in range(10*N + 1)]
            for k in range(2)]

    dp[0][0][0] = 0
    dp[1][0][0] = 0

    for i in range(N):
        for a in range(10*N + 1):
            for b in range(10*N + 1):
                if a - a_w[i] >= 0 and b - b_w[i] >= 0:
                    if dp[0][a - a_w[i]][b - b_w[i]] >= 0:
                        if dp[1][a][b] == -1:
                            dp[1][a][b]= dp[0][a - a_w[i]][b - b_w[i]] + costs[i]
                        else:
                            min_ = min(dp[1][a][b],
                                       dp[0][a - a_w[i]][b - b_w[i]] + costs[i])
                            dp[1][a][b] = min_
        
        for k in range(10*N + 1):
            dp[0][k] = dp[1][k][:]

        # for i in range(10*N + 1):
            # print(*dp[0][i], file=sys.stderr)


    min_cost = float('inf')

    for a in range(10*N + 1):
        for b in range(10*N + 1):
            if a != 0 and b != 0:
                if a * Mb == b * Ma and dp[1][a][b] > 0:
                    min_cost = min(min_cost, dp[1][a][b])

    if min_cost == float('inf'):
        ans = -1
    else:
        ans = min_cost

    print(ans)


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

delta = ((1, 0), (0, 1), (-1, 0), (0, -1))
def ds(here, field, count, lb, ub, min_count):
	if count > min_count:
		return min_count
	ans = min_count
	for dx, dy in delta:
		nx, ny = (here[0]+dx,here[1]+dy)
		neighbor = (nx, ny)
		while lb[0] <= nx <= ub[0] and lb[1] <= ny <= ub[1]:
			if field[ny][nx] == 1:
				if (nx, ny) != neighbor:
					field[ny][nx] = 0
					ans = ds((nx-dx,ny-dy),field, count+1, lb, ub, ans)
		    		field[ny][nx] = 1
				break
			if field[ny][nx] == 3:
				if count + 1 < ans:
					ans = count + 1
				break
			nx += dx
			ny += dy
	return ans
while 1:
	w, h = map(int,raw_input().split(" "))
	if w == h == 0: break
	board = [ map(int,raw_input().split(" ")) for _ in range(h)]
	for j in range(h):
		for i in range(w):
			if board[j][i] == 2:
				start = (i,j)
	result = ds(start, board, 0, (0,0), (w-1,h-1), 11)
	print result if result < 11 else -1

### FIXED CODE ###

delta = ((1, 0), (0, 1), (-1, 0), (0, -1))
def ds(here, field, count, lb, ub, min_count):
	if count == min_count:
		return min_count
	ans = min_count
	for dx, dy in delta:
		nx, ny = (here[0]+dx,here[1]+dy)
		neighbor = (nx, ny)
		while lb[0] <= nx <= ub[0] and lb[1] <= ny <= ub[1]:
			if field[ny][nx] == 1:
				if (nx, ny) != neighbor:
					field[ny][nx] = 0
					ans = ds((nx-dx,ny-dy),field, count+1, lb, ub, ans)
		    		field[ny][nx] = 1
				break
			if field[ny][nx] == 3:
				if count + 1 < ans:
					ans = count + 1
				break
			nx += dx
			ny += dy
	return ans
while 1:
	w, h = map(int,raw_input().split(" "))
	if w == h == 0: break
	board = [ map(int,raw_input().split(" ")) for _ in range(h)]
	for j in range(h):
		for i in range(w):
			if board[j][i] == 2:
				start = (i,j)
	result = ds(start, board, 0, (0,0), (w-1,h-1), 11)
	print result if result < 11 else -1
### BUGGY CODE ###

R, G, B, N = map(int, input().split())
ans = 0
r, g0 = 0, 0

while r * R <= N:
  g = g0
#  Nr = N
  Nr = N - r * R
#  print("Nr:", Nr, "r:", r)
  while g * G <= Nr:
#    Ng = Nr
    Ng = Nr - g * G
#    print("Ng:", Ng, "g:", g)
    if Ng % B == 0:
#      b = (Ng/B)
      ans += 1
#      print("ANS:", ans, "r:", r, "g:", g, "b:", b)
    g += 1
  r += 1
print(ans)

### FIXED CODE ###

R, G, B, N = map(int, input().split())
ans = 0
r, g = 0, 0
rmax = N // R
gmax = N // G

if R * G * B == 1:
  for i in range(N + 1):
    ans += N + 1 - i
  print(ans)
  exit()

for i in range(rmax + 1):
  for j in range(gmax + 1):
    if (N - i * R - j * G) < 0:
      break
    if (N - i * R - j * G) % B == 0:
      ans += 1
#      print(ans, i, j)
print(ans)
### BUGGY CODE ###

import queue
import collections

N = int(input())
Ss = []
for i in range(N):
    Ss.append(input())

c = collections.Counter(Ss)
mc = c.most_common()
_, prev = mc[0]
q = queue.PriorityQueue()
for k, v in mc:
    if prev != v:
        break
    q.put(k)
    prev = v

while not(q.empty()):
    print(q.get())


### FIXED CODE ###

import queue
import collections

N = int(input())
Ss = [input() for i in range(N)]

mc = collections.Counter(Ss).most_common()
_, prev = mc[0]
q = queue.PriorityQueue()
for k, v in mc:
    if prev != v:
        break
    q.put(k)
    prev = v

while not(q.empty()):
    print(q.get())
### BUGGY CODE ###

from math import ceil

n,m=map(int,input().split())
a=list(map(int,input().split()))
goukei=sum(a)
sorta=sorted(a, reverse=True)
waribiki=0

for i in range(m):
  waribiki+=ceil(max(a)/2)
  ind=a.index(max(a))
  a[ind]//=2
print(goukei-waribiki)

### FIXED CODE ###

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

import heapq
import math

def _heappush_max(heap, item):
    heap.append(item)
    heapq._siftdown_max(heap, 0, len(heap)-1)
def _heappop_max(heap):
    """Maxheap version of a heappop."""
    lastelt = heap.pop()    # raises appropriate IndexError if heap is empty
    if heap:
        returnitem = heap[0]
        heap[0] = lastelt
        heapq._siftup_max(heap, 0)
        return returnitem
    return lastelt

heapq._heapify_max(a)

for i in range(m):
  temp=math.floor(_heappop_max(a)/2)
  _heappush_max(a,temp)

print(sum(a))
### BUGGY CODE ###

n=int(input())
l=list(map(int,input().split()))
d=[]
for i in l:
    d.append(i)
    d.reverse()
print(*d)


### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
d=[]
s=[]
for i in range(n):
    if(i%2==0):
        d.append(l[i])
    else:
        s.append(l[i])
if(n%2==0):
    s.reverse()
    print(*(s+d))
else:
    d.reverse()
    print(*(d+s))
### BUGGY CODE ###

N, M = map(int, input().split())
A = list(map(int, input().split()))
for _ in range(M):
    A.sort(reverse=True)
    A[0] //= 2
print(sum(A))

### FIXED CODE ###

from queue import PriorityQueue

N, M = map(int, input().split())
A = list(map(int, input().split()))
queue = PriorityQueue()
for a in A:
    queue.put(-a)
for _ in range(M):
    v = -queue.get()
    queue.put(-(v // 2))

total = 0
while not queue.empty():
    total += -(queue.get())
print(total)
### BUGGY CODE ###

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

for t in range(k):
      ok=True
      b=[0]*n
      for i in range(n):
            left=max(0,i-a[i])
            b[left]+=1
            if i+a[i]+1 <= n-1:
                  right=i+a[i]+1
                  b[right]-=1
      for i in range(1,n):
            b[i]=b[i-1]+b[i]
      for i in range(n):
            if a[i]!=b[i]:
                  ok=False
            a[i]=b[i]
      if ok==True:
            break

print(*a)



### FIXED CODE ###

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

for t in range(k):
      ok=True
      b=[0]*n
      for i in range(n):
            left=max(0,i-a[i])
            b[left]+=1
            if i+a[i]+1 <= n-1:
                  right=i+a[i]+1
                  b[right]-=1
      for i in range(1,n):
            b[i]=b[i-1]+b[i]
      for i in range(n):
            if a[i]!=b[i]:
                  ok=False
            a[i]=b[i]
      if ok==True:
            break

print(*a)
### BUGGY CODE ###

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    

dots = XY[:]

import sys
INT_MAX = sys.maxsize

x_dots = [(x, y) for x, y in dots]
x_dots = sorted(x_dots)
y_dots = [(x, y) for x, y in dots]
y_dots = sorted(y_dots, key=lambda x: x[1])

ans = INT_MAX
for l in range(N):
    l_val = x_dots[l][0]
    for r in range(l+1, N+1):
        r_val = x_dots[l:r][-1][0]
        x_dots_set = set(x_dots[l:r])
        for u in range(N):
            u_val = y_dots[u][1]
            for t in range(u+1, N+1):
                #xy_dots =  set(x_dots[l:r]) & set(y_dots[u:t])
                xy_dots =  x_dots_set & set(y_dots[u:t])
                if len(xy_dots) >= K:
                    #print("---")
                    #print(l, r, x_dots[l:r])
                    #print(u, t, y_dots[u:t])
                    #print(x_dots[l:r])
                    #l_val = x_dots[l:r][0][0]
                    #r_val = x_dots[l:r][-1][0]
                    
                    #u_val = y_dots[u:t][0][1]
                    t_val = y_dots[u:t][-1][1]
                    #print((r-l)*(t-u))
                    if ans > (r_val-l_val)*(t_val-u_val):
                        ans = (r_val-l_val)*(t_val-u_val)
                    else:
                        break
print(ans)


#y_dots = sorted(y_dots, key=lambda x: x[1])
#ans = INT_MAX


### FIXED CODE ###

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

XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))
    
dots = XY[:]

import sys
INT_MAX = sys.maxsize

ans = INT_MAX

import itertools
for ((left_x, _), (right_x, _)) in itertools.combinations(dots, 2):
    if left_x > right_x:
        left_x, right_x = right_x, left_x
    for ((_, under_y), (_, top_y)) in itertools.combinations(dots, 2):
        if under_y > top_y:
            under_y, top_y = top_y, under_y
        counter = 0
        for d_x, d_y in dots:
            if  (left_x <= d_x) and (d_x <= right_x) and (under_y <= d_y) and (d_y <= top_y):
                counter += 1
                
        if counter >= K:
            area = (top_y-under_y) * (right_x-left_x)
            if ans > area:
                ans = area
            
print(ans)