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

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, C = MAP()
D = [LIST() for _ in range(C)]
c = [LIST() for _ in range(N)]

group0 = []
group1 = []
group2 = []
for i in range(N):
	for j in range(N):
		if (i+j)%3 == 0:
			group0.append(c[i][j]-1)
		elif (i+j)%3 == 1:
			group1.append(c[i][j]-1)
		elif (i+j)%3 == 2:
			group2.append(c[i][j]-1)
# print(group0)
# print(group1)
# print(group2)

ans = INF
for i in range(C):
	for j in range(C):
		for k in range(C):
			tmp = 0
			if i == j or j == k or k == i:
				continue
			else:
				for item0 in group0:
					tmp += D[item0][i]
				for item1 in group1:
					tmp += D[item1][j]
				for item2 in group2:
					tmp += D[item2][k]
				ans = min(ans, tmp)
print(ans)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, C = MAP()
D = [LIST() for _ in range(C)]
c = [LIST() for _ in range(N)]

group0 = []
group1 = []
group2 = []
for i in range(N):
	for j in range(N):
		if (i+j)%3 == 0:
			group0.append(c[i][j]-1)
		elif (i+j)%3 == 1:
			group1.append(c[i][j]-1)
		elif (i+j)%3 == 2:
			group2.append(c[i][j]-1)
# print(group0)
# print(group1)
# print(group2)

color_0 = []
inv_0 = {}
for i in range(C):
	tmp = 0
	for item0 in group0:
		tmp += D[item0][i]
	color_0.append((tmp, i))
	inv_0[i] = tmp
color_0 = sorted(color_0)[0:3]
color_0_lis = [x[1] for x in color_0]

color_1 = []
inv_1 = {}
for i in range(C):
	tmp = 0
	for item1 in group1:
		tmp += D[item1][i]
	color_1.append((tmp, i))
	inv_1[i] = tmp
color_1 = sorted(color_1)[0:3]
color_1_lis = [x[1] for x in color_1]

color_2 = []
inv_2 = {}
for i in range(C):
	tmp = 0
	for item2 in group2:
		tmp += D[item2][i]
	color_2.append((tmp, i))
	inv_2[i] = tmp
color_2 = sorted(color_2)[0:3]
color_2_lis = [x[1] for x in color_2]
# print(color_0)
# print(color_0_lis)
# print(color_1)
# print(color_1_lis)
# print(color_2)
# print(color_2_lis)
ans = INF
for i in color_0_lis:
	for j in color_1_lis:
		for k in color_2_lis:
			tmp = 0
			if i == j or j == k or k == i:
				continue
			else:
				tmp += inv_0[i]
				tmp += inv_1[j]
				tmp += inv_2[k]
				ans = min(ans, tmp)
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
from collections import defaultdict
from bisect import bisect_left

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
A = LIST()

# 部分和DPを変形させて、その値になるのに使われた値の集合を持っておく
dp = defaultdict(set)
dp[0].add(0)
for i in range(N):
    for j in range(K-1, -1, -1):
        if len(dp[j]):
            dp[j+A[i]] |= dp[j]
            dp[j+A[i]].add(A[i])

# 和がK未満の集合はこの後のチェックで使わないので削る
dp = sorted(dp.items())
keys, sets = zip(*dp)
idx = bisect_left(keys, K)
keys = keys[idx:]
sets = sets[idx:]

ans = 0
for i in range(N):
    for k, s in zip(keys, sets):
        # A[i]減らしたらK未満になる状況で、一度でもA[i]が使われていれば必要
        if k-A[i] < K and A[i] in s:
            break
    else:
        # 該当するどの集合でも、一度も使われていなければ不要
        ans += 1
print(ans)


### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
import numpy as np

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def bisearch_min(mn, mx, func):
    """ 条件を満たす最小値を見つける二分探索 """

    ok = mx
    ng = mn
    while ng+1 < ok:
        mid = (ok+ng) // 2
        if func(mid):
            # 下を探しに行く
            ok = mid
        else:
            # 上を探しに行く
            ng = mid
    return ok

N, K = MAP()
A = LIST()

def check(omit):
    # 部分和DP
    dp = np.zeros((N+1, K), dtype=np.bool)
    dp[0,0] = 1
    for i in range(N):
        # まとめて遷移
        dp[i+1] |= dp[i]
        if i != omit and A[i] < K:
            dp[i+1,A[i]:] |= dp[i,:K-A[i]]
    # 今回の値A[omit]を足してKに到達できるような部分和があれば、これは必要
    for j in range(max(0, K-A[omit]), K):
        if dp[N,j]:
            return True
    # なければ不要
    return False

A.sort()
print(bisearch_min(-1, N, check))
### BUGGY CODE ###

N = int(input())
H = list(map(lambda x:int(x), input().split()))

idx = sorted(range(N), key=lambda k: H[k], reverse=True)

ans = 0
for i in idx:
  count = 0
  if (i != 0) and (H[i-1] > H[i]): continue
    
  if i != N-1:
    for j in range(i, N-1):
      if H[j] >= H[j+1]:
        count += 1
      else:
        break
    ans = max(ans, count)

print(ans)


### FIXED CODE ###

N = int(input())
H = list(map(lambda x:int(x), input().split()))
count = 0
ans = 0
for i in range(N-1):
  if H[i] >= H[i+1]:
    count += 1
  else:
    count = 0
  ans = max(ans, count)

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

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

tmp = ''
rev = False
for _ in range(q):
    query = input().split()

    if query[0] == '1' and not(rev):
        rev = True
    elif query[0] == '1' and rev:
        rev = False

    elif query[0] == '2' and query[1] == '1' and not(rev):
        s = ''.join([query[2], s])

    elif query[0] == '2' and query[1] == '1' and rev:
        s = ''.join([s, query[2]])

    elif query[0] == '2' and query[1] == '2' and not(rev):
        s = ''.join([s, query[2]])

    elif query[0] == '2' and query[1] == '2' and rev:
        s = ''.join([query[2], s])

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

print(s)


### FIXED CODE ###

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

sl = ['']*(q*2+2)
sl[q] = s
m = q-1
u = q+1
rev = False
for _ in range(q):
    query = input().split()

    if query[0] == '1' and not(rev):
        rev = True
    elif query[0] == '1' and rev:
        rev = False

    elif query[0] == '2' and query[1] == '1' and not(rev):
        sl[m] = query[2]
        m -= 1

    elif query[0] == '2' and query[1] == '1' and rev:
        sl[u] = query[2]
        u += 1

    elif query[0] == '2' and query[1] == '2' and not(rev):
        sl[u] = query[2]
        u += 1

    elif query[0] == '2' and query[1] == '2' and rev:
        sl[m] = query[2]
        m -= 1

if rev:
    sl[q] = s[::-1]
    sl.reverse()
    print(''.join(sl))
else:
    print(''.join(sl))
### BUGGY CODE ###

import sys
input=sys.stdin.readline
import collections

def main():
    N = int(input())
    Q = []
    for _ in range(N):
        q = collections.deque(map(int, input().split()))
        Q.append(q)

    days = 0
    while True:
        gamed = [0 for _ in range(N)]
        b = False
        for i in range(len(Q)):
            if len(Q[i]) == 0 or gamed[i] != 0:
                continue
            j = Q[i][0] - 1
            if len(Q[j]) != 0 and gamed[j] == 0:
                if Q[j][0] == i+1:
                    Q[i].popleft()
                    Q[j].popleft()
#                    print("game:", j+1, i+1, days)
                    b = True
                    gamed[i] = 1
                    gamed[j] = 1
                    continue
        days += 1
        if not b:
            print(-1)
            return
        if all(len(q) == 0 for q in Q):
            break

    print(days)
if __name__ == '__main__':
    main()


### FIXED CODE ###

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

def main():
    N = int(input())
    Q = [deque(map(int, input().split())) for _ in range(N)]
    games = N*(N-1)//2

    days = 0
    nxt = [i for i in range(N)] # 翌日に対戦相手を更新する選手のリスト
    opp = [0]*N # 選手毎の、次の対戦相手のリスト
    while 1:
        days += 1
        for i in nxt:
            opp[i] = Q[i].popleft() - 1 if Q[i] else -1

        tmp = set() # 次の日の更新のため、試合をした選手をメモ
        for i in nxt:
            if i not in tmp and i == opp[opp[i]]:
#                print("game:", i+1, opp[i]+1, days)
                tmp.add(i)
                tmp.add(opp[i])
                games -= 1
        if games == 0:
            break
        elif not tmp:
            print(-1)
            return
        nxt = tmp
    print(days)

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

import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [list(input()) for _ in range(H)]
for i, j in itertools.product(range(H), range(W)):
    if A[i][j] == 'S':
        break
Q = collections.deque([[i, j, 0]])
aH = []
aW = []
while Q:
    h, w, dist = Q.popleft()
    A[h][w] = '#'
    aH += [h]
    aW += [w]
    if dist < K:
        for nh, nw in [[h - 1, w], [h + 1, w], [h, w - 1], [h, w + 1]]:
            if 0 <= nh < H and 0 <= nw < W and A[nh][nw] == '.':
                Q += [[nh, nw, dist + 1]]
print(1 + min([
    math.ceil(_ / K)
    for _ in (min(aH), H - 1 - max(aH), min(aW), W - 1 - max(aW))
]))


### FIXED CODE ###

import itertools, math, collections, sys
input = sys.stdin.readline
H, W, K = [int(_) for _ in input().split()]
A = [input() for _ in range(H)]
for h in range(H):
    if 'S' in A[h]:
        w = A[h].index('S')
        break
visited = [[False] * W for _ in range(H)]
ans = min([h, H - 1 - h, w, W - 1 - w])
res = K - 1
Q = collections.deque([[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                       [h, w + 1, res]])
while Q:
    h, w, res = Q.popleft()
    if 0 <= h < H and 0 <= w < W and A[h][w] == '.' and not visited[h][w]:
        visited[h][w] = True
        ans = min([ans, h, H - 1 - h, w, W - 1 - w])
        if res:
            res -= 1
            Q += [[h - 1, w, res], [h + 1, w, res], [h, w - 1, res],
                  [h, w + 1, res]]
print(1 + math.ceil(ans / K))
### BUGGY CODE ###

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

a = [0]*m
b = [0]*m
for i in range(m):
  l,r = map(int, input().split())
  a[i] = l
  b[i] = r
  
s = 0
for i in range(a[m-1], b[m-1]+1):
  t = 0
  for j in range(m):
    if a[j] <= i and i <= b[j]:
      t += 1
    else:
      break
  if t == m:
    s += 1
print(s)

### FIXED CODE ###

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

a = [0]*m
b = [0]*m
for i in range(m):
  l,r = map(int, input().split())
  a[i] = l
  b[i] = r

x = min(b)
y = max(a)
if x >= y:
  print(x-y+1)
else:
  print(0)
### BUGGY CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
for i in range(n-1):
    if i==0:
        print(max(a[1:]))
    else:
        max1 = max(a[:i])
        max2 = max(a[i+1:])
        print(max(max1, max2))
print(max(a[:n]))


### FIXED CODE ###

n = int(input())
a = [int(input()) for i in range(n)]
a_sort = sorted(a.copy())
for i in range(n):
    print(a_sort[-2] if a[i] == a_sort[-1] else a_sort[-1])
### BUGGY CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import defaultdict
import bisect


def solve():
    n, m, q = map(int, input().split())
    d = defaultdict(list)
    for i in range(m):
        l, r = map(int, input().split())
        bisect.insort_left(d[l], r)
    table = [[0 for i in range(n + 1)] for j in range(n + 1)]
    dk = [p for p in d.keys()]
    dk.sort()
    for i in range(1, n + 1):
        dk = [p for p in dk if i <= p]
        for j in range(1, n + 1):
            tans = 0
            for k in [p for p in dk if p <= j]:
                tans += bisect.bisect_right(d[k], j)
            table[i][j] = tans
    for i in range(q):
        l, r = map(int, input().split())
        print(table[l][r])


if __name__ == "__main__":
    solve()


### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import bisect
import array


def solve():
    n, m, q = map(int, input().split())
    nl = [[0 for i in range(n + 1)] for j in range(n + 1)]
    for e in [input().split() for _ in range(m)]:
        l, r = int(e[0]), int(e[1])
        nl[l][r] += 1
    table = [array.array("i", [0] * (n + 2)) for j in range(n + 2)]
    ran = array.array("i", range(n + 1))
    for i in ran:
        for j in ran:
            table[i][j + 1] = table[i][j] + nl[i][j]

    for i, e in enumerate([input().split() for _ in range(q)]):
        l, r = int(e[0]), int(e[1])
        ans = 0
        for j in range(l, r + 1):
            ans += table[j][r + 1] - table[j][l]
        print(ans)


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

import fractions
N=int(input())
A=list(map(int,input().split()))
L=[0]
R=[0]
ans=1
for i in range(N):
    if i==N-1:
        pass
    else:
        R.append(fractions.gcd(R[-1], A[::-1][i]))
        L.append(fractions.gcd(L[-1], A[i]))
for j in range(N):
    ans=max(ans,fractions.gcd(L[j],R[(N-1)-j]))
print(ans)

### FIXED CODE ###

from  fractions import gcd
N=int(input())
A=list(map(int,input().split()))
L=[0]
R=[0]
ans=1
for i in range(N-1):
    R.append(gcd(R[-1], A[-1-i]))
    L.append(gcd(L[-1], A[i]))
print(max(gcd(l,r)for l,r in zip(L,R[::-1])))
### BUGGY CODE ###

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

dp=[[0 for i in range(N+1)] for j in range(N+1)]

for i in range(N):
  for j in range(i+1,N):
    if S[i]==S[j]:
      dp[i][j]=dp[i-1][j-1]+1
#print(dp)

ans=0
for i in range(N):
  for j in range(i+1,N):
    if ans<dp[i][j]:
      if j-i>=dp[i][j]:
        ans=dp[i][j]

print(ans)

### FIXED CODE ###

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

T = [[0 for _ in range(N)] for _ in range(N)]

for i in range(N):
  for j in range(i + 1, N):
    if S[i] == S[j]:
      T[i][j] += T[i - 1][j - 1] + 1

answer = 0
for i in range(N):
  for j in range(N):
    if T[i][j] and j - i >= T[i][j]:
      answer = max(answer, T[i][j])
print(answer)
### BUGGY CODE ###

def e_get_everything(INF=float('inf')):
    # 参考: http://drken1215.hatenablog.com/entry/2019/09/29/103500
    N, M = [int(i) for i in input().split()]
    A, B, C = [], [], []
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        A.append(a)
        B.append(b)
        # 開けられる宝箱の集合Cはビット列に変換しておく
        C.append(sum(1 << (t - 1) for t in [int(i) for i in input().split()]))

    # dp[i][S]: i番目まで(i番は含まない)の鍵からいくつか選んで、
    # 開いた宝箱の集合がS(ビット列で表す)で表されるような場合にかかる費用の最小値
    dp = [[INF] * (1 << N) for _ in range(M + 1)]
    dp[0][0] = 0  # 鍵を選ばず、開ける宝箱がないとき、費用は0とする

    for i in range(M):
        for j in range(1 << N):
            # i番目の鍵を使わない場合
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
            # i番目の鍵を使う場合
            next_j = j | C[i]  # C[i] で指定される宝箱(のいくつか)が新たに開く
            dp[i + 1][next_j] = min(dp[i + 1][next_j], dp[i][j] + A[i])
    # M個の鍵を使ってすべての宝箱を開けるとき、費用が有限値に更新されたか？
    return dp[M][(1 << N) - 1] if dp[M][(1 << N) - 1] != INF else -1

print(e_get_everything())

### FIXED CODE ###

def e_get_everything(INF=float('inf')):
    # 参考: http://drken1215.hatenablog.com/entry/2019/09/29/103500
    N, M = [int(i) for i in input().split()]
    A, B, C = [], [], []
    for _ in range(M):
        a, b = [int(i) for i in input().split()]
        A.append(a)
        B.append(b)
        # 開けられる宝箱の集合Cはビット列に変換しておく
        C.append(sum(1 << (t - 1) for t in [int(i) for i in input().split()]))

    # dp[i][S]: i番目まで(i番は含まない)の鍵からいくつか選んで、
    # 開いた宝箱の集合がS(ビット列で表す)で表されるような場合にかかる費用の最小値
    dp = [[INF] * (1 << N) for _ in range(M + 1)]
    dp[0][0] = 0  # 鍵を選ばず、開ける宝箱がないとき、費用は0とする

    for i in range(M):
        for j in range(1 << N):
            # i番目の鍵を使わない場合
            dp[i + 1][j] = min(dp[i + 1][j], dp[i][j])
            # i番目の鍵を使う場合
            next_j = j | C[i]  # C[i] で指定される宝箱(のいくつか)が新たに開く
            dp[i + 1][next_j] = min(dp[i + 1][next_j], dp[i][j] + A[i])
    # M個の鍵を使ってすべての宝箱を開けるとき、費用が有限値に更新されたか？
    return dp[M][(1 << N) - 1] if dp[M][(1 << N) - 1] != INF else -1

print(e_get_everything())
### BUGGY CODE ###

# 1行目は入力ワード数
# word を1行ずつ入力し、最も投票数が多かったwordを出力

import collections

def check(input_list):

    vote_dict = collections.Counter(input_list)

    result_list = [k for k, v in vote_dict.items() if v == max(vote_dict.values())]
    result_list.sort()
    
    return result_list

if __name__ == '__main__':
    num = int(input())
    input_list = [input() for a in range(num)]

    for str in check(input_list):
        print(str)


### FIXED CODE ###

import collections

def check(input_list):

    vote_dict = collections.Counter(input_list)
    max_value = max(vote_dict.values())

    result_list = [k for k, v in vote_dict.items() if v == max_value]
    result_list.sort()
    
    return result_list

if __name__ == '__main__':
    num = int(input())
    input_list = [input() for a in range(num)]

    for str in check(input_list):
        print(str)
### BUGGY CODE ###

N, K, Q = map(int, input().split())
A = []
result = [K] * N

for _ in range(Q):
    A.append(int(input()) - 1)

for i in range(len(A)):
    result = list(map(lambda x: x-1, result))
    result[A[i]] += 1

for i in list(map(lambda x: "Yes" if x > 0 else "No", result)):
    print(i)

### FIXED CODE ###

N, K, Q = map(int, input().split())
A = []
result = [K] * N
answers = [0] * N

for _ in range(Q):
    A.append(int(input()) - 1)


for i in A:
    answers[i] += 1

result = list(map(lambda x: x-Q, result))

for i in range(N):
    result[i] += answers[i]

for i in list(map(lambda x: "Yes" if x > 0 else "No", result)):
    print(i)
### BUGGY CODE ###

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

a = 0
ans = 0

for i in range(N//2,N+1):
  a = int(A*i/B) - A*int(i/B)
  if ans < a:
    ans = a
  
print(int(ans))

### FIXED CODE ###

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

c = 0
ans = 0

if N < 1000001:
  for i in range(1,N+1):
    c = int(A*i/B) - A*int(i/B)
    if ans < c:
      ans = c

elif N < B:
  ans = int(A*N/B) - A*int(N/B)
      
else:
  count = B-1
  for i in range(10000):
    c = int(A*count/B) - A*int(count/B)
    if ans < c:
      ans = c
    count += B
    
print(int(ans))
### BUGGY CODE ###

import numpy as np

def main():
    SpotNum = int(input())
    SpotCoordinate = [int(i) for i in input().split()]
    
    SpotCoordinate.insert(0, 0)
    SpotCoordinate.append(0)
    
    DiffSpotCoordinate = abs(np.diff(SpotCoordinate))
#    print(DiffSpotCoordinate)
    
    for i in range(SpotNum):
        Diff = abs(SpotCoordinate[i] - SpotCoordinate[i+2] )
#        print(Diff)
        result = Diff + sum(DiffSpotCoordinate[:i]) + sum(DiffSpotCoordinate[i+2:])
#        print(RmSpotCoodinate)
#        print(sum(abs(np.diff(RmSpotCoordinate))))
        print(result)
if __name__=="__main__":
    main()

### FIXED CODE ###

import numpy as np

def main():
    SpotNum = int(input())
    SpotCoordinate = [int(i) for i in input().split()]
    
    SpotCoordinate.insert(0, 0)
    SpotCoordinate.append(0)
    
    DiffSpotCoordinate = abs(np.diff(SpotCoordinate))
#    print(DiffSpotCoordinate)
    
#    SumTable = [0 for i in range(100000)]
##    print(SumTable)
#    
#    Diff = abs(SpotCoordinate[0] - SpotCoordinate[2] )
#    result = Diff + sum(DiffSpotCoordinate[2:])
#    print(result)
#    
#    for i in range(1,SpotNum):
#        if(SumTable == []):
#            SumTable[i-1] = sum(DiffSpotCoordinate[:i])
##            print(SumTable[i-1])
#        else:
#            SumTable[i-1] = SumTable[i-2] + sum(DiffSpotCoordinate[i-1:i])
##            print(SumTable[i-1])
#            
#        Diff = abs(SpotCoordinate[i] - SpotCoordinate[i+2] )
##        print(Diff)
#        
#        result = Diff + SumTable[i-1] + sum(DiffSpotCoordinate[i+2:])
##        print(RmSpotCoodinate)
##        print(sum(abs(np.diff(RmSpotCoordinate))))
#        print(result)
    
    SumDiffSpotCoordinate = sum(DiffSpotCoordinate)
    for i in range(1,SpotNum+1):
        result = SumDiffSpotCoordinate - DiffSpotCoordinate[i-1] - DiffSpotCoordinate[i] + abs(SpotCoordinate[i-1] - SpotCoordinate[i+1])
        print(result)
        
if __name__=="__main__":
    main()
### BUGGY CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = [0]*N
sum_A = 0
for _ in range(M):
  BC = list(map(int,input().split()))
  for _ in range(BC[0]):
    bc.append(BC[1])
bc.sort(reverse=True)
for i in range(len(A)):
  if A[i] < bc[i]:
    sum_A += bc[i]
  else:
    sum_A += A[i]
print(sum_A)
  
  

### FIXED CODE ###

N, M = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
bc = []
bc = [list(map(int,input().split())) for _ in range(M)]
bc.sort(key=lambda x:x[1],reverse=True)
ai = 0
for b,c in bc:
  cc = b
  while ai<N and cc >0:
    if A[ai] < c:
      A[ai] = c
      cc -= 1
    ai +=1
    if ai == N:
        break
print(sum(A))
### BUGGY CODE ###

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

minus_count = 0
rember_list = []
for i, x in enumerate(c_list):
    if i == 0:
        rember_list.append(x)
        continue
    min_rember = min(rember_list)
    if x > min_rember:
        minus_count += 1
    rember_list.append(x)

print(len(c_list) - minus_count)

### FIXED CODE ###

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

minus_count = 0
rember_number = 0
for i, x in enumerate(c_list):
    if i == 0:
        rember_number = x
        continue
    else:
        if x < rember_number:
            rember_number = x
        if x > rember_number:
            minus_count += 1

print(len(c_list) - minus_count)
### BUGGY CODE ###

import itertools
n,k=map(int,input().split())
xy=[list(map(int,input().split())) for i in range(n)]
t=[i for i in range(n)]
s=list(itertools.permutations(t,k))
#print(s)
l=len(s)
inf=10000000000
x_min=inf
y_min=inf
x_max=-inf
y_max=-inf
for i in range(n):
    x,y=xy[i]
    if x<x_min:x_min=x
    if y<y_min:y_min=y
    if x>x_max:x_max=x
    if y>y_max:y_max=y
area=(x_max-x_min)*(y_max-y_min)
#print(area)
for i in range(l):
    x_min=inf
    y_min=inf
    x_max=-inf
    y_max=-inf
    for j in range(k):
        x,y=xy[s[i][j]]
        if x<x_min:x_min=x
        if y<y_min:y_min=y
        if x>x_max:x_max=x
        if y>y_max:y_max=y
    #print(area)
    area=min((x_max-x_min)*(y_max-y_min),area)
print(area)


### FIXED CODE ###

n,k=map(int,input().split())
x,y=[[0,0] for i in range(n)],[[0,0] for i in range(n)]
xy=[list(map(int,input().split())) for i in range(n)]
for i in range(n):
    x_sub,y_sub=xy[i]
    x[i][0]=x_sub
    x[i][1]=i
    y[i][0]=y_sub
    y[i][1]=i
x.sort()
y.sort()
ans=(10**18)*5
for i1 in range(n):
    for l1 in range(n-i1,1,-1):
        for i2 in range(n):
            for l2 in range(n-i2,1,-1):
                x_sub1=x[i1][0]
                x_sub2=x[i1+l1-1][0]
                y_sub1=y[i2][0]
                y_sub2=y[i2+l2-1][0]
                z=[0]*n
                for i in range(n):
                    if x_sub1<=xy[i][0]<=x_sub2 and y_sub1<=xy[i][1]<=y_sub2:
                        z[i]=1
                if sum(z)>=k:
                    ans=min((x_sub2-x_sub1)*(y_sub2-y_sub1),ans)
                else:
                    break
print(ans)