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

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

def isAsc(lst):
  for i in range(1,len(lst)):
    if lst[i-1]>lst[i]:
      return False
  else:
    return True

min_a=min(alist)
max_a=max(alist)

answer_list=[]
if max_a>0 and max_a>-min_a:
  while(not isAsc(alist)):
    desc_index=-1
    desc_diff=0
    
    for i in range(1,N):
      if alist[i-1]>alist[i]:
        desc_index=i
        desc_diff=alist[i-1]-alist[i]
        break
  
    max_a=-10**9
    max_index=-1
    for i in range(N):
      if alist[i]>max_a:
        max_a=alist[i]
        max_index=i    
      
    while(alist[i-1]>alist[i]):
      alist[i]+=max_a
      answer_list.append((max_index+1,i+1))
else:
  while(not isAsc(alist)):
    desc_index=-1
    desc_diff=0
    
    for i in reversed(range(1,N)):
      if alist[i-1]>alist[i]:
        desc_index=i-1
        desc_diff=alist[i-1]-alist[i]
        break
  
    min_a=10**9
    min_index=-1
    for i in range(N):
      if alist[i]<min_a:
        min_a=alist[i]
        min_index=i    
      
    while(alist[i-1]>alist[i]):
      alist[i-1]+=min_a
      answer_list.append((min_index+1,i))

#print(answer_list)
print(len(answer_list))
for x,y in answer_list:
  print(x,y)

### FIXED CODE ###

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

def isAsc(lst):
  for i in range(1,len(lst)):
    if lst[i-1]>lst[i]:
      return False
  else:
    return True

min_a=min(alist)
max_a=max(alist)

answer_list=[]
if max_a>0 and max_a>-min_a:
  while(not isAsc(alist)):
    desc_index=-1
    
    for i in range(1,N):
      if alist[i-1]>alist[i]:
        desc_index=i
        break
  
    max_a=-10**9
    max_index=-1
    for i in range(N):
      if alist[i]>max_a:
        max_a=alist[i]
        max_index=i    
      
    while(alist[desc_index-1]>alist[desc_index]):
      alist[desc_index]+=max_a
      answer_list.append((max_index+1,desc_index+1))
else:
  while(not isAsc(alist)):
    desc_index=-1
    
    for i in reversed(range(1,N)):
      if alist[i-1]>alist[i]:
        desc_index=i-1
        break
  
    min_a=10**9
    min_index=-1
    for i in range(N):
      if alist[i]<min_a:
        min_a=alist[i]
        min_index=i    
      
    while(alist[desc_index]>alist[desc_index+1]):
      alist[desc_index]+=min_a
      answer_list.append((min_index+1,desc_index+1))

#print(answer_list)
print(len(answer_list))
for x,y in answer_list:
  print(x,y)
### BUGGY CODE ###

n = int(input())
a = []
for i in range(n):
    a.append(list(input()))

for i in range(n):
    a.append(a[i])


x = 0

for i in range(n):
    for j in range(n):
        for k in range(j+1):
            if a[i+j][k]==a[i+k][j]:
                continue
            else:
                break
        else:
            continue
        break
    else:
        x += 1

print(n*x)

 

### FIXED CODE ###

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

def check(S, A, B):
    for i in range(N):
        for j in range(i+1, N):
            if S[i][j] != S[j][i]:
                return 0
    return 1

cnt = 0
for i in range(N):
    cnt += check(S[i:] + S[:i], 0, 0)
print(cnt * N)
### BUGGY CODE ###

N = int(input())

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

sum_water = sum(A)
A = A[1:] + A[0:N-2]
X = []
for i in range(N):
    tmp=sum_water
    for j in range((N-1)//2):
        tmp-=A[i+j*2]*2
    X.append(tmp)
for i in range(len(X)-1):
    print(X[i], end="")
    print(" ", end="")
print(X[-1])

### FIXED CODE ###

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

sum_water = sum(A)

tmp=sum_water
for j in range((N-1)//2):
    tmp-=A[j*2+1]*2
print(tmp, end="")
print(" ", end="")

for i in A[:-1]:
    tmp = 2*i - tmp
    print(tmp, end="")
    print(" ", end="")
### BUGGY CODE ###

'''
1枚抜いてDPをN枚についてやれば良い, がこれでは間に合わない
そこで必要不要の境界を二分探索で探す
するとO(N^2K)→O(NKlogN)となって間に合う

もう1つの方法は分からない
'''

def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N,K = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)
    def dp(num):
        dp = [[0]*(K) for _ in range(N)]
        dp[0][0] = 1
        b = a[:num]+a[num+1:] #N-1個
        for i in range(N-1):
            for j in range(K):
                if b[i]<=j:
                    dp[i+1][j] = dp[i][j-b[i]] or dp[i][j]
                else:
                    dp[i+1][j]=dp[i][j]
        return any(dp[N-1][K-a[num]:])

    left = 0
    right = N-1
    while left<=right:
        mid = (left+right)//2
        if dp(mid):
            right = mid-1
        else:
            left = mid+1
    print(right+1)

if __name__ == '__main__':
    main()


### FIXED CODE ###

'''
1枚抜いてDPをN枚についてやれば良い, がこれでは間に合わない
そこで必要不要の境界を二分探索で探す
するとO(N^2K)→O(NKlogN)となって間に合う

もう1つの方法は分からない
'''

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    N,K = map(int, input().split())
    a = list(map(int, input().split()))
    a = sorted(a)
    a = a[:bisect_left(a, K)]
    n = len(a)


    import numpy as np
    def dp(omit):
        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


    # def dp(num):
    #     dp = [[0]*(K) for _ in range(n)]
    #     dp[0][0] = 1
    #     b = a[:num]+a[num+1:] #N-1個
    #     for i in range(n-1):
    #         for j in range(K):
    #             if b[i]<=j:
    #                 dp[i+1][j] = dp[i][j-b[i]] or dp[i][j]
    #             else:
    #                 dp[i+1][j]=dp[i][j]
    #     return any(dp[n-1][K-a[num]:])

    left = 0
    right = n-1
    while left<=right:
        mid = (left+right)//2
        if dp(mid):
            right = mid-1
        else:
            left = mid+1
    print(right+1)

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

import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])

### FIXED CODE ###

import sys

def chmin(a,i,b):
  if a[i] > b:
    a[i] = b
    #print(a)
    return True
  else:
    return False

n,k = map(int,input().split())
h = list( map(int,input().split()))
dp = [sys.maxsize for i in range(n)]

dp[0] = 0
#print(n,h)
#print(dp)

for i in range(len(dp)):
  for j in range(k+1):
    if i - j >= 0:
      #chmin(dp,i, abs(h[i]-h[i-j])+dp[i-j])
      dp[i] = min(dp[i], abs(h[i]-h[i-j])+dp[i-j])

#print(dp)   
print(dp[-1])
### BUGGY CODE ###

N, M = list(map(int, input().split()))
H = list(map(int, input().split()))
A_B = [list(map(int, input().split())) for i in range(M)]
A = [A_B[i][0] for i in range(M)]
B = [A_B[i][1] for i in range(M)]
N_set = [{0} for i in range(N)]
ans = 0

for i in range(N):
    for j in range(M):
        if i+1 == A[j] or i+1 == B[j]:
            N_set[i].add(H[A[j] - 1])
            N_set[i].add(H[B[j] - 1])

    N_set[i].remove(0)
    N_set[i] = list(N_set[i])
    if len(N_set[i]) == 0:
        ans += 1
        continue
    if len(N_set[i]) == 1:
        continue
    if H[i] == max(N_set[i]):
        ans += 1

# for i in range(N):
#     N_set[i].remove(0)
#     N_set[i] = list(N_set[i])


# for i in range(N):
#     N_set[i].remove(0)
#     N_set[i] = list(N_set[i])
#     if len(N_set[i]) == 0:
#         ans += 1
#         continue
#     if len(N_set[i]) == 1:
#         continue
#     if H[i] == max(N_set[i]):
#         ans += 1
print(ans)



### FIXED CODE ###

N, M = list(map(int, input().split()))
h = list(map(int, input().split()))
ma = [0] * N

for i in range(M):
    a, b = list(map(int, input().split()))
    ma[a-1] = max(ma[a-1], h[b-1])
    ma[b-1] = max(ma[b-1], h[a-1])

ans = 0
for i in range(N):
    if ma[i] < h[i]:
        ans += 1

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

S = input()
q = int(input())

tail = len(S)-1

for _ in range(q):
    # print(S)
    Q = list(input().split())
    if Q[0] == "1":
        S = S[::-1]
    else:
        if Q[1] == "1":
            S = Q[2] + S
        else:
            S = S + Q[2]
print(S)


### FIXED CODE ###

from collections import deque

S = input()
q = int(input())

is_s0_head = True
tail = len(S)-1

queue = deque(S)

for _ in range(q):
    # print(queue)
    Q = list(input().split())
    if Q[0] == "1":
        is_s0_head = not is_s0_head
    else:
        if Q[1] == "1":
            if is_s0_head:
                queue.appendleft(Q[2])
            else:
                queue.append(Q[2])
        else:
            if is_s0_head:
                queue.append(Q[2])
            else:
                queue.appendleft(Q[2])

if is_s0_head:
    print("".join(list(queue)))
else:
    print("".join(list(queue)[::-1]))
### BUGGY CODE ###

from math import ceil
H,N = list(map(int, input().split()))
A = []
for _ in range(N):
  A.append(list(map(int, input().split())))
  
# 1回iを使ってから、のこりをjで仕留める、を全探索でよい気がする
# だめだった

# dp[i] : HPをi減らすために必要なmin魔力
dp = [1e9] * (10010)
dp[0] = 0
for i in range(1,H+1):
  for a in A:
    ap, mp = a
    down = max(0, i - ap)
    dp[i] = min(dp[i], dp[down] + mp)
      
print(min(dp[H:]))

### FIXED CODE ###

from math import ceil
H,N = list(map(int, input().split()))
A = []
for _ in range(N):
  A.append(list(map(int, input().split())))
  
# 1回iを使ってから、のこりをjで仕留める、を全探索でよい気がする
# だめだった

# dp[i] : HPをi減らすために必要なmin魔力
dp = [1e9] * (10010)
dp[0] = 0
for i in range(1,H+1):
  for a in A:
    ap, mp = a
    down = max(0, i - ap)
    dp[i] = min(dp[i], dp[down] + mp)
      
print(min(dp[H:]))
### BUGGY CODE ###

from collections import deque

H, W = map(int,input().split())
S = [input() for i in range(H)]
ans = 10**9

if S[0][0] == "#":
    q = deque([(0,0,1, "#")])
else:
    q = deque([(0,0,0, None)])
while q:
    i, j, cnt, prev = q.popleft()
    if i == H - 1 and j == W - 1:
        ans = min(ans, cnt)
    for ni, nj in [(i+1, j), (i, j+1)]:
        if 0 <= ni < H and 0 <= nj < W:
            if S[ni][nj] == "#":
                if prev == "#":
                    q.append((ni,nj, cnt, "#"))
                else:
                    q.append((ni,nj, cnt+1, "#"))
            else:
                q.append((ni,nj, cnt, "."))
print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int,input().split())
S = [input() for i in range(H)]
dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1 if S[0][0] == "#" else 0
for i in range(1, H):
    if S[i][0] == "#":
        if S[i-1][0] == "#":
            dp[i][0] =  dp[i-1][0]
        else:
             dp[i][0] = dp[i-1][0] + 1
    else:
        dp[i][0] =  dp[i-1][0]

for j in range(1, W):
    if S[0][j] == "#":
        if S[0][j-1] == "#":
            dp[0][j] =  dp[0][j-1]
        else:
             dp[0][j] = dp[0][j-1] + 1
    else:
        dp[0][j] =  dp[0][j-1]

for i in range(1,H):
    for j in range(1,W):
        up = dp[i-1][j] + (1 if S[i-1][j] != "#" and S[i][j] == "#" else 0) 
        left = dp[i][j-1] + (1 if S[i][j-1] != "#" and S[i][j] == "#" else 0)
        dp[i][j] = min(up, left)
print(dp[-1][-1])
### BUGGY CODE ###

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

for i in range(N):
    if i == 0:
        multiple = inputs[0]
    else:
        multiple *= inputs[i]

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

### FIXED CODE ###

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

if inputs.count(0) >= 1:
    multiple = 0
    
else:
    for i in range(N):
        if i == 0:
            multiple = inputs[0]
        else:
            multiple *= inputs[i]

        if multiple > 10**18:
            multiple = '-1'
            break

print(multiple)
### BUGGY CODE ###

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

r, g, b, n = map(int, input().split())

count = 0

for i in range(0, n//r+1):
    for j in range(0, n//g+1):
        if (n - i*r - j*g) % b == 0 and (n - i*r - j*g) >= 0:
            count += 1

# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1


print(count)


### FIXED CODE ###

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

r, g, b, n = map(int, input().split())

count = 0

for i in range(n//r+1):
    for j in range((n-i*r)//g+1):
        if (n - i*r - j*g) % b == 0:
            count += 1

# やってはいけないやつ
# for i in range(0, n+1):
#     for j in range(0, n+1):
#         for k in range(0, n+1):
#             if r*i + g*j + b*k == n:
#                 count += 1

print(count)
### BUGGY CODE ###

def prep_array(X, Y):
    c = [[0]*1001 for _ in range(1000+1)]
    return c


def calc_lcs(X, Y, c):
    m = len(X)
    n = len(Y)
    X = ' ' + X
    Y = ' ' + Y

    pre_row = c[0]
    for i in range(1, m+1):
        row = c[i]
        for j in range(1, n+1):
            if X[i] == Y[j]:
                row[j] = pre_row[j - 1] + 1
            elif pre_row[j] >= row[j - 1]:
                row[j] = pre_row[j]
            else:
                row[j] = row[j - 1]
        pre_row = row
    return check_max(c)


def check_max(array):
    max_lcs = 0
    for row in array:
        temp_max = max(row)
        if temp_max > max_lcs:
            max_lcs = temp_max
    return max_lcs


if __name__ == '__main__':
    # ??????????????\???
    num = int(input())
    # f = open('input.txt')
    # num = int(f.readline())

    for _ in range(num):
        X = input()
        Y = input()
        # X = f.readline().strip()
        # Y = f.readline().strip()

        # ???????????????
        result = calc_lcs(X, Y, prep_array(X, Y))

        # ???????????¨???
        print(result)

### FIXED CODE ###

# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_10_C

最長共通部分列
"""


c = []
def prep_array(X, Y):
    global c
    """ 値が0の2次元配列を用意する。サイズは入力データの最大値を想定して縦横(1000+1)以上必要。 """
    # from array import array
    # c = [array('I', [0] * (len(X)+1)) for _ in range(len(Y)+1)]  #  arrayで用意
    c = [[0]*(len(Y)+2) for _ in range(len(X)+2)] #  リストで用意
    return c


def check_max(array):
    """ 2次元配列の中の最大の値を返す """
    max_lcs = 0
    for row in array:
        temp_max = max(row)
        if temp_max > max_lcs:
            max_lcs = temp_max
    return max_lcs


def calc_lcs4(X, Y, c):
    """
    Y[j]のアクセス方法を変更
    リストの値を一旦変数に保存するように変更
    最長共通部分長を関数内で計算するように変更
    4/5 のテストデータを使用してプロファイリングすると実効時間は 5.6秒
    """
    X = ' ' + X
    Y = ' ' + Y
    m = len(X)
    n = len(Y)
    max_lcs = 0

    pre_row = c[0]
    for i in range(1, m):
        row = c[i]
        XX = X[i]
        for j, YY in enumerate(Y):
            if XX == YY:
                pr_j1 = pre_row[j - 1]
                row[j] = pr_j1 + 1
                if pr_j1+1 > max_lcs:
                   max_lcs = pr_j1 + 1
            else:
                pr_j = pre_row[j]
                r_j1 = row[j-1]
                if pr_j >= r_j1:
                    row[j] = pr_j
                else:
                    row[j] = r_j1
        pre_row = row
    return max_lcs


if __name__ == '__main__':
    # データの入力
    num = int(input())
    #f = open('input.txt')
    #num = int(f.readline())

    for _ in range(num):
        X = input().strip()
        Y = input().strip()

        # 処理の実行
        result = calc_lcs4(X, Y, prep_array(X, Y))

        # 結果の表示
        print(result)
### BUGGY CODE ###

import math
from decimal import *
A,B = list(map(int, input().split()))
ans = -1
for x in range(1, 50000):
    a = math.floor(x * Decimal(0.08))
    b = math.floor(x * Decimal(0.1))
    if a == A and b == B:
        ans = x
        break
print(ans)

### FIXED CODE ###

import math
from decimal import *
A,B = list(map(int, input().split()))
ans = -1
for x in range(1, 10001):
    a = math.floor(x * Decimal(0.08))
    b = math.floor(x * Decimal(0.1))
    if a == A and b == B:
        ans = x
        break
print(ans)
### BUGGY CODE ###

N, K = [int(n) for n in input().split(" ")]
lst = [int(n) for n in input().split(" ")]

sum_max = 0

for i in range(0,N-K+1):
    temp = 0
    for j in range(i,i+K):
        temp += (lst[j]+1)/2
    if temp > sum_max:
        sum_max = temp
print(sum_max)
  

### FIXED CODE ###

N, K = [int(n) for n in input().split(" ")]
lst = [int(n) for n in input().split(" ")]

sum_max = 0
temp = 0

for i in range(K):
    temp += (lst[i]+1)/2
    sum_max = temp
for j in range(0,N-K):
        temp += (lst[j+K]-lst[j])/2
        if temp > sum_max:
            sum_max = temp
            
print(sum_max)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()

cache = {}
def dfs(s):
    if s in cache:
        return cache[s]
    if len(s) <= 1:
        cache[s] = len(s)
        return cache[s]
    if len(s) == 2:
        if s[0] == s[1]:
            cache[s] = 1
            return cache[s]
        else:
            cache[s] = 2
            return cache[s]
    if len(s) >= 3:
        if s[0] == s[1]:
            cache[s] = max(1 + dfs(s[2:]), 2 + dfs(s[3:]))
            return cache[s]
        else:
            cache[s] = max(1 + dfs(s[1:]), 1 + dfs(s[2:]))
            return cache[s]

ans = 0
if len(s) == 1:
    print(ans)
    sys.exit(0)
print(dfs(s))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

s = input().strip()
if len(s) == 1:
    print(0)
    sys.exit(0)
if len(s) == 2 and s[0] == s[1]:
    print(0)
    sys.exit(0)

# [i][0]: index iが1文字分割
# [i][1]: index iが2文字分割
dp = [[0] * 2 for _ in range(len(s))]
# 3文字以上では1文字/2文字の仮想結果が使われる
# 1文字
dp[0][0] = dp[0][1] = 1
# 2文字
if s[0] == s[1]:
    # 実際には常に2文字分割になる
    dp[1][0] = dp[1][1] = 1
else:
    dp[1][0] = 2
    dp[1][1] = 1

# 3文字以上
for i in range(2, len(s)):

    # [i][0]: 末尾の分割を1文字にする場合

    # 末尾2文字が同じ場合
    # - 1つ前を2文字分割にしなくてはならない
    if s[i] == s[i-1]:
        dp[i][0] = dp[i-1][1] + 1
    # 末尾2文字が異なる場合
    # - 1つ前が1文字分割
    # - 1つ前が2文字分割
    else:
        dp[i][0] = max(dp[i-1][0] + 1, dp[i-1][1] + 1)


    # [i][1]: 末尾の分割を2文字にする場合
    # 末尾前の2文字が末尾の2文字と同じ場合
    # 末尾前を1文字分割にしなくてはならない
    if s[i-3:i-1] == s[i-1:i+1]:
        dp[i][1] = dp[i-2][0] + 1
    # 末尾前の2文字が末尾の2文字と異なる場合
    # - 末尾前が1文字分割
    # - 末尾前が2文字分割
    else:
        dp[i][1] = max(dp[i-2][0] + 1, dp[i-2][1] + 1)

print(max(dp[-1][0], dp[-1][1]))
### BUGGY CODE ###

a, b, c, x, y = map(int,input().split())

ans = max(x,y)*2*c
s = max(x,y)

while True:
    tmp = 0
    tmp -= c*2
    s -= 1
    if x > s:
        tmp += a
    if y > s:
        tmp += b
    if tmp > 0:
        print(ans)
        exit()
    else:
        ans += tmp

### FIXED CODE ###

a,b,c,x,y = map(int,input().split())

ans = 0

if a+b > c*2:
    ans += c*min(x,y)*2
    if x>y:
        ans += min(a*(x-y), c*(x-y)*2)
    else:
        ans += min(b*(y-x), c*(y-x)*2)
        
else:
    ans += a*x + b*y
    
print(ans)
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    x, y = zip(*(
        map(int, input().split())
        for _ in range(N)
    ))

    f(N, K, x, y)


def f(N, K, x, y):
    """
    TLEのため、考察はpypy3のD directoryに移行
    codeの見た目のためにgeneratorを使ったが遅いので愚直にloop
    """
    sorted_x = sorted(x)
    sorted_y = sorted(y)
    ans = (sorted_x[-1] - sorted_x[0]) * (sorted_y[-1] - sorted_y[0])
    for xi in range(N):
        for xj in range(xi + 1, N):
            for yi in range(N):
                for yj in range(yi + 1, N):
                    min_x, max_x = sorted_x[xi], sorted_x[xj]
                    min_y, max_y = sorted_y[yi], sorted_y[yj]
                    contains_count = 0
                    for x3, y3 in zip(x, y):
                        if min_x <= x3 <= max_x and min_y <= y3 <= max_y:
                            contains_count += 1
                    if contains_count >= K:
                        s = (max_x - min_x) * (max_y - min_y)
                        ans = min(ans, s)

    print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N, K = map(int, input().split())
    x, y = zip(*(
        map(int, input().split())
        for _ in range(N)
    ))

    f(N, K, x, y)


def f(N, K, x, y):
    ans = abs(max(x) - min(x)) * abs(max(y) - min(y))
    if K == N:
        print(ans)
        return

    def r(x, y, x_start=0, y_start=0):
        for xi in range(x_start, N):
            for yi in range(y_start, N):
                yield x[xi], y[yi], xi, yi

    # for x1, y1 in zip(x, y):
    #     for x2, y2 in zip(x, y):
    # for x1, y1 in r(x, y):
    #     for x2, y2 in r(x, y):
    sorted_x = sorted(x)
    sorted_y = sorted(y)
    for min_x, min_y, xi, yi in r(sorted_x, sorted_y):
        for max_x, max_y, _, _ in r(sorted_x, sorted_y, x_start=xi+1, y_start=yi+1):

            # s = abs(x1-x2) * abs(y1-y2)
            # if s == 0:
            #     continue

            # min_x = min(x1, x2)
            # max_x = max(x1, x2)
            # min_y = min(y1, y2)
            # max_y = max(y1, y2)

            contains_count = 0
            for x3, y3 in zip(x, y):
                if min_x <= x3 <= max_x and min_y <= y3 <= max_y:
                    contains_count += 1
            if contains_count >= K:
                s = (max_x - min_x) * (max_y - min_y)
                ans = min(ans, s)

    print(ans)


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

L, R = map(int, input().split())
l = []
frag = False
if R - L >= 2019:
    l.append(0)
    frag = True
for i in range(L, R):
    if frag: break
    for j in range(i+1, R+1):
        l.append((i*j) % 2019)
        n = len(l)
        if n % 2 == 0:
            if l[:n//2] == l[n//2:]:
                frag = True
                break
print(min(l))

### FIXED CODE ###

L, R = map(int, input().split())
if R - L >= 2018:
	print(0)
else:
	ans = 2019
	for i in range(L, R):
		for j in range(i + 1, R + 1):
			ans = min(ans, i * j % 2019)
	print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6 + 2)

n = int(input())
a = list(map(int, input().split()))
d = [None]*3001**2
def judge(l,r):
  if l >= r:
    return a[l]
  v = l + r*3001
  if d[v] is not None: return d[v]
  res1 = a[l] - judge(l+1,r)
  res2 = a[r] - judge(l,r-1)
  if res1 < res2: res1, res2 = res2, res1
  d[v] = res1
  return res1

print(judge(0,n-1))


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
dp = [[None]*n for _ in range(n)]
for d in range(n):
  for l in range(n-d):
    r = l + d
    if d:
      dp[l][r] = max(a[l] - dp[l+1][r], a[r] - dp[l][r-1])
    else:
      dp[l][r] = a[l]
print(dp[0][n-1])
### BUGGY CODE ###

N = int(input())
search_max = int(N*N)
 
min_number = 10**12
for x in range(1, search_max + 1):
    if N % x == 0:
        y = N // x
        if x + y < min_number:
         
            min_number = x + y
print(min_number-2)

### FIXED CODE ###

N = int(input())
search_max = int(N**0.5)
 
min_number = 10**12
for x in range(1, search_max + 1):
    if N % x == 0:
        y = N // x
        if x + y < min_number:
         
            min_number = x + y
print(min_number-2)