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

N = int(input())
A = list(map(int, input().split()))
MOD = 10**9+7

lists = [[] for i in range(len(A))]

_a = A[0]
li = [0 for i in range(61)]
for i in range(len(li))[::-1]:
    quo = _a // pow(2, i)
    li[i] = quo
    _a -= quo*pow(2, i)
lists[0] = li

for i in range(1, len(A)):
    _a = A[i]
    li = [0 for j in range(61)]
    for j in range(len(li))[::-1]:
        quo = _a // pow(2, j)
        li[j] = lists[i-1][j] + quo
        _a -= quo*pow(2, j)
    lists[i] = li

res = []
for j in range(len(A)-1):
    a = A[j]
    lia = [lists[len(lists)-1][i] - lists[j][i] for i in range(61)]
    if j == 0:
        lib = lists[0]
    else:
        lib = [lists[j][i] - lists[j-1][i] for i in range(61)]
    _res = 0
    for i in range(len(li)):
        if lib[i] % 2 == 0:
        # 0のとき
            _res += pow(2, i) * lia[i]
        else:
        # 1のとき
            _res += pow(2, i) * ((N-j-1) - (lia[i]))
        _res %= MOD
    res.append(_res)
print(sum(res) % MOD)


### FIXED CODE ###

import numpy as np

N = int(input())
A = np.array(list(map(int, input().split())))
MOD = 10**9+7

ans = 0
for i in range(60):
    cnt = np.count_nonzero((A >> i) & 1)
    ans += (2**i * cnt*(N-cnt)) % MOD
    ans %= MOD
print(ans)
### BUGGY CODE ###

import math
mat =[]
a, b, n = map(int, input().split())
for x in range(n+1):
    ans = math.floor(a*x/b) - a * math.floor(x/b)
    mat.append(ans)

mat.sort(reverse=True)
print(mat[0])

### FIXED CODE ###

a, b, n = map(int, input().split())
x = min(b-1, n)
s = (a*x) // b - a * (x // b)
print(s)
### BUGGY CODE ###

n = int(input())
num_list = list(map(int, input().split()))
dis = []

for i in range(1,n):
    a = sum(num_list[:i])
    b = sum(num_list[i:])
    dis.append(abs(a-b))

print(min(dis))


### FIXED CODE ###

n = int(input())
num_list = list(map(int, input().split()))
total = sum(num_list)
dis = []
a=0

for i in range(n-1):
    a += num_list[i]
    b = total - a
    dis.append(abs(a-b))

print(min(dis))
### BUGGY CODE ###

Nlist = list(range(int(input())))
lst = []
for i in Nlist:
    lst.append(int(input()))


n=0
for i in Nlist:
    n,lst[i] = lst[i],n
    print(max(lst))
    n,lst[i] = lst[i],n


### FIXED CODE ###

N = int(input())
A = []
for i in range(N):
    A.append(int(input()))
B = sorted(A, reverse = True)

for i in range(N):
    if A[i] == B[0]:
        print(B[1])
    else:
        print(B[0])
### BUGGY CODE ###

N = int(input())
S = input()
maxn = N//2

for i in range(maxn, 0, -1):
  for j in range(N - i):
    s1 = S[j:j+i]
    for k in range(j + i, N):
      s2 = S[k:k+i]
      if s1 == s2:
        print(i)
        exit()
print(0)

### FIXED CODE ###

N = int(input())
s = input()

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

for i in range(N-1, -1, -1):
  for j in range(N-1, -1, -1):
    if s[i] != s[j]:
      dp[i][j] = 0
    else:
      dp[i][j] = dp[i+1][j+1] + 1
    
ans = 0
for i in range(N):
  for j in range(N):
    if i >= j:
      continue
    now = min(dp[i][j], j - i)
    ans = max(ans, now)
print(ans)
### BUGGY CODE ###

n = int(input())
wordlist = [input() for i in range(n)]
wordtuple = tuple(set(wordlist))
checklist = []
ans = []
a = len(wordtuple)
for j in range(a) :
    checklist.append(wordlist.count(wordtuple[j]))
maxnum = max(checklist)
anslist = [i for i, v in enumerate(checklist) if v == maxnum]
for k in anslist :
    ans.append(wordtuple[k])
ans.sort()
for l in range(len(ans)) :
    print(ans[l])

### FIXED CODE ###

n = int(input())
d = {}
for i in range(n) :
    s = input()
    if s not in d :
        d[s] = 1
    else :
        d[s] += 1
m = max(d.values())
ans = []
for i in d :
    if d[i] == m :
        ans.append(i)
ans.sort()
for i in ans:
    print(i)
### BUGGY CODE ###

n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
#print(s)

x = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            x += 1
 
print(x)

### FIXED CODE ###

n = int(input())
s = []
for _ in range(n):
    #s.append(list(input())) # !!!
    #s.append(sorted(list(input()))) # !!!
    #s.append(sorted(input())) # !!!
    s += [''.join(sorted(input()))]
    #''.join(sorted((sorted(input()))
s = sorted(s)
s.append('X')
#print(s)

a = []
x = 1
for i in range(1,n+1):
    if s[i] == s[i-1]:
        x += 1
    else:
        a.append(x)
        x = 1
#print(a)
y = 0

for j in a:
    y += j*(j-1)/2

print(int(y))
### BUGGY CODE ###

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

tomodati=[[] for i in range(n+1)]

group=[0]*(n+1)

block=[0]*(n+1)

tansaku=[]

for i in range(m):
    a,b=map(int,input().split())
    tomodati[a].append(b)
    tomodati[b].append(a)

num=1

for i in range(1,n+1):
    if group[i]==0:
        tansaku.append(i)
        group[i]=num
    while len(tansaku)>0:
        for j in tomodati[tansaku[0]]:
            if group[j]==0:
                group[j]=num
                tansaku.append(j)
        tansaku.pop(0)
    num+=1

for i in range(k):
    c,d=map(int,input().split())
    if group[c]==group[d]:
        block[c]+=1
        block[d]+=1

ans=""

for i in range(1,n+1):
    ans+=str(group.count(group[i])-len(tomodati[i])-block[i]-1)+" "

print(ans)

     

### FIXED CODE ###

from collections import deque
#空のリスト 作った後は普通にappend使えばOK
n,m,k=map(int,input().split())
 
tomodati=[[] for i in range(n+1)]
 
group=[0]*(n+1)

group_cnt=[0]*(n+1)
 
block=[0]*(n+1)
 
tansaku=deque()
 
for i in range(m):
    a,b=map(int,input().split())
    tomodati[a].append(b)
    tomodati[b].append(a)
 
num=1
 
for i in range(1,n+1):
    if group[i]==0:
        tansaku.append(i)
        group[i]=num
        group_cnt[num]+=1
    else:
        continue
    while len(tansaku)>0:
        for j in tomodati[tansaku[0]]:
            if group[j]==0:
                group[j]=num
                group_cnt[num]+=1
                tansaku.append(j)
        tansaku.popleft()
    num+=1
 
for i in range(k):
    c,d=map(int,input().split())
    if group[c]==group[d]:
        block[c]+=1
        block[d]+=1
 
ans=[]
 
for i in range(1,n+1):
    ans.append(group_cnt[group[i]]-len(tomodati[i])-block[i]-1)
 
print(*ans)
### BUGGY CODE ###

from collections import defaultdict
import copy


mod = 10 ** 9 + 7
primes = []
for i in range(2,1002):
  for prime in primes:
    if not i % prime:
      break
  else:
    primes.append(i)

def factorize(n):
  now = n
  fct = defaultdict(int)
  for prime in primes:
    cnt = 0
    if prime ** 2 > n:
      break
    while not now % prime:
      now //= prime
      cnt += 1
    if cnt:
      fct[prime] = cnt
  if now > 1:
    fct[now] = 1
  return fct


n = int(input())
a = list(map(int, input().split()))
fct_a = list()
for i in a:
  fct_a.append(factorize(i))
lcm = defaultdict(int)
for i in fct_a:
  for k,v in i.items():
    lcm[k] = max(lcm[k], v)
ans = 0
for i in fct_a:
  b = 1
  for k,v in lcm.items():
    b *= pow(k,v-i[k])
    b %= mod
  ans += b
ans %= mod
print(ans)

### FIXED CODE ###

import fractions
mod = 10 ** 9 + 7

def lcm(a,b):
    return (a * b) // fractions.gcd(a, b)

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

LCM = 1
for i in a:
    LCM = lcm(LCM,i)

ans = 0
for i in a:
    ans += LCM // i
print(ans % mod)
### BUGGY CODE ###

_input = input().split()
n = int(_input[0])
k = int(_input[1])

input_hp = input().split()

list_monster = []
for i in range(n):
  list_monster.append(int(input_hp[i]))
  
list_monster.sort() 
list_monster.reverse() #降順にソート

#使用できる必殺技の残りカウント
count = k 
  
if n <= k:
  print(0)
  
elif k == 0:
  number = 0
  for i in range(len(list_monster)):
    number += list_monster[i]
  
  print(number)
  
else:
  for i in range(k): #最初に持っていた必殺技の数だけ繰り返す
    count -= 1 #使用ごとに必殺技の残りカウントを減らす
    
    list_monster.pop(0)
    
  number = 0

  for i in range(len(list_monster)):
  	number += list_monster[i]

  print(number)

### FIXED CODE ###

N, K = map(int, input().split())
 
list_monster = list(map(int, input().split()))
list_monster.sort(reverse = True) 
 
if N <= K:
  print(0)
  
elif K == 0:
  print(sum(list_monster))
  
else:
  print(sum(list_monster[K:]))
### BUGGY CODE ###

S = input()
T = input()
dp = [[ "" for _ in range(len(S) + 1 )] for _ in range(len(T) + 1)]

for i in range(1,len(dp)):
    for j in range(1,len(dp[0])):
        if T[i - 1] == S[j-1]:
            dp[i ][j ] = dp[i-1][j-1] + S[j-1]
        else:
            res1 = dp[i - 1][j]
            res2 = dp[i][j - 1]
            l1 = len(res1)
            l2 = len(res2)
            if l1 > l2:
                dp[i ][j] = res1
            else:
                dp[i ][j] = res2
print(dp[-1][-1])

### FIXED CODE ###

S = input()
T = input()
dp = [[ 0] * (len(S) + 1 ) for _ in range(len(T) + 1)]
ma = 0
for i in range(len(dp)-1):
    for j in range(len(dp[0])-1):
        if T[i ] == S[j]:
            dp[i + 1][j + 1] = dp[i][j] + 1
        else:
             dp[i + 1][j + 1]  = max(dp[i][j + 1],dp[i +1][j])
i = len(T) - 1
j = len(S) - 1 
ans = ""
while i >=0 and j >= 0:
    if dp[i][j+1] == dp[i + 1][j + 1]:
        i-=1
    elif dp[i + 1][j] == dp[i + 1][j + 1]:
        j-=1
    else:
        #print(j,i)
        ans = S[j] + ans
        i-=1
        j-=1
print(ans)
### BUGGY CODE ###

import math

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

ans = 0
for x in range(min(B,N+1)):
    ans = max(ans,math.floor((A*x)/B) - A * math.floor(x/B))

print(ans)

### FIXED CODE ###

import math

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

x = min(B-1,N)
ans = math.floor((A*x)/B) - A * math.floor(x/B)

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

N, M = map(int, input().split())
LR = [tuple(map(int, input().split())) for _ in range(M)]

count_dict = {}

for i in range (M):
    l = LR[i][0]
    r = LR[i][1]

    for j in range(l, r+1):
        if j in count_dict:
            count_dict[j] += 1
        else:
            count_dict[j] = 1

total = 0
for i in count_dict.values():
    if i == M:
        total += 1

print(total)

### FIXED CODE ###

N, M = map(int, input().split())
LR = [tuple(map(int, input().split())) for _ in range(M)]

count_dict = {}

gate = set(range(10**5 + 1))

L = 1
R = 10**5

for i in range (M):
    l = LR[i][0]
    r = LR[i][1]

    if l > L:
        L = l
    if r < R:
        R = r

print(len(range(L, R+1)))
### BUGGY CODE ###

# -*- coding: utf-8 -*-
import math
n = int(input())
a = list(map(int, input().split()))
res = 1 
if min(a) == 0:
  res = 0
else:
  for i in range(len(a)):
    res *= a[i]
    if res > 1000000000000000000:
      res = -1
      continue
print(res)

### FIXED CODE ###

# -*- coding: utf-8 -*-
import math
n = int(input())
a = list(map(int, input().split()))
res = 1 
if 0 in a:
  res = 0
else:
  for num in a:
    res *= num
    if res > 10**18:
      res = -1
      break
print(res)
### BUGGY CODE ###

n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))[::-1]
i=0
while True:
    a[i]=a[i]//2
    a=sorted(a)[::-1]
    m-=1
    if m==0:
        break
print(sum(a))

### FIXED CODE ###

import heapq
n,m=map(int,input().split())
a=list(map(lambda i:int(i)*(-1),input().split()))
heapq.heapify(a)
for i in range(m):
    x=heapq.heappop(a)*(-1)
    heapq.heappush(a,(x//2)*(-1))
print((-1)*sum(a))
### BUGGY CODE ###

N = int(input())


for i in range(1, N+1):
    sum = 0

    range_x = int((i-5)**0.5)+1 if i-5 >0 else 0
    s = set()
    for x in range(1, range_x):
        flag = False
        if x in s:
            continue
        range_y = int((i-x**2-x-3)**0.5)+1 if i-x**2-2*x-2 > 0 else 0
        for y in range(x, range_y):
            if y in s:
                continue
            range_z = int((i-x**2-y**2-x*y-x-y)**0.5)+1 if i-x**2-y**2-x*y-x-y > 0 else 0
            for z in range(y, range_z):
                if z in s:
                    continue
                if x**2 + y**2 + z**2 + x*y + y*z + z*x == i:
                    num = len(set([x,y,z]))
                    sum += 6 if num == 3 else 3 if num==2 else 1
                    s = s | set([x,y,z])
                    flag = True
                    break
            if flag:
                break

    print(sum)

### FIXED CODE ###

N = int(input())

ans = [0]*(10**4+1)

for x in range(1, 10**2):
    for y in range(1, 10**2):
        for z in range(1, 10**2):
            n = x**2+y**2+z**2+x*y+y*z+z*x
            if n <10**4+1:
                ans[n] += 1

for i in range(1, N+1):
    print(ans[i])
### BUGGY CODE ###

from collections import deque
n = int(input())
a = deque([int(input()) for _ in range(n)])
for i in range(n):
    ak = a[i]
    del a[i]
    print(max(a))
    a.appendleft(ak)


### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]
max_a = max(a)
set_a = set(a)
max_n = a.count(max_a)
if len(set_a) == 1:
    s_set_a = max_a
else:
    if max_n > 1:
        s_set_a = max_a
    else:
        s_set_a = sorted(set_a)[-2]

for i in range(n):
    if max_a == a[i]:
        print(s_set_a)
    else:
        print(max_a)
### BUGGY CODE ###

from math import log10
n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0
for i in range(len(n)):
    temp = (temp+int(n[-i-1])*10**i) % MOD
    dp[temp] += 1

for item in dp:
    ans += item*(item-1)//2

print(ans)



### FIXED CODE ###

n = input()

MOD = 2019
ans = 0
dp = [0]*MOD
dp[0] = 1
temp = 0

for i in range(len(n)):
    temp = (temp+int(n[-i-1])*int(pow(10, i, MOD))) % MOD
    dp[temp] += 1

for item in dp:
    if item > 1:
        ans += item*(item-1)//2

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

N,M = map(int,input().split())
A = list(set(map(int,input().split())))
num = {}
num2 = [0,2,5,5,4,5,6,3,7,6]
for i in range(1,10):
    if i in A:
        num[i] = num2[i]
num3 = sorted(list(num.items()),key = lambda x:x[1])
A = [str(i[0]) for i in num3]
num = [i[1] for i in num3]
minum = num[0]
dp = [[0 for i in range(N+1)] for j in range(N//minum+1)]
dp[0][0] = '1'
for i in range(1,N//minum+1):
    for j in range(N+1):
        for k in range(len(num)):
            if j-num[k] >= 0 and dp[i-1][j-num[k]] != 0:
                if dp[i][j] != 0:
                    if dp[i-1][j] == 0:
                        dp[i][j] = str(max(int(dp[i][j]),int(''.join(sorted(list(dp[i-1][j-num[k]]+A[k]),reverse=True)))))
                    else:
                        dp[i][j] = str(max(int(dp[i][j]),int(dp[i-1][j]),int(''.join(sorted(list(dp[i-1][j-num[k]]+A[k]),reverse=True)))))
                else:
                    if dp[i-1][j] == 0:
                        dp[i][j] = ''.join(sorted(list(dp[i-1][j-num[k]]+A[k]),reverse=True))
                    else:
                        dp[i][j] = str(max(int(dp[i-1][j]),int(''.join(sorted(list(dp[i-1][j-num[k]]+A[k]),reverse=True)))))
            else:
                if dp[i-1][j] != 0:
                    if dp[i][j] != 0:
                        dp[i][j] = str(max(int(dp[i][j]),int(dp[i-1][j])))
                    else:
                        dp[i][j] = dp[i-1][j]
print(dp[-1][-1][:-1])


### FIXED CODE ###

N,M = map(int,input().split())
A = list(map(int,input().split()))
num = {1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}

def lenmax(a,b):
    if len(a) > len(b):
        return a
    elif len(a) < len(b):
        return b
    return max(a,b)

dp = ['-' for i in range(10**4+10)]
dp[0] = ''
for i in range(N+1):
    if dp[i] == '-':
        continue
    for a in A:
        dp[i+num[a]] = lenmax(dp[i+num[a]],dp[i]+str(a))
print(dp[N])
### BUGGY CODE ###

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

n,q=map(int,readline().split())
s=readline().decode('utf-8')
lst=map(int,read().split())
lr=list(zip(lst,lst))
for l,r in lr:
  print((r-l+1-len(s[l-1:r].replace('AC','')))//2)

### FIXED CODE ###

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

n,q=map(int,readline().split())
s=readline().decode('utf-8')
dic={}
c=0
for idx, i in enumerate(s, 1):
  if i=='C' and s[idx-2]=='A':
    c+=1
  dic[idx]=c
lst=map(int,read().split())
lr=list(zip(lst,lst))

for l,r in lr:
  print(dic[r]-dic[l])
### BUGGY CODE ###

S = str(input())
T = str(input())
alp = "abcdefghijklmnopqrstuvwxyz"
for i in range(0,len(S)):
  if S[i] != T[i]:
    S = S.translate(str.maketrans({S[i]:T[i], T[i]:S[i]}))
  if S == T:
    print("Yes")
    exit()
print("No")

### FIXED CODE ###

S = str(input())
T = str(input())
alp = "abcdefghijklmnopqrstuvwxyz"
for i in range(0,min(len(S),len(alp)*2)):
  if S[i] != T[i]:
    S = S.translate(str.maketrans({S[i]:T[i], T[i]:S[i]}))
  else:
    pass
  if S == T:
    print("Yes")
    exit()
print("No")
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
result = 0
for i in range(n):
  for j in range(i + 1, n):
    result += a[i] * a[j]
result = result % (10**9 + 7)
print(result)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
sum_a = 0
result = 0
for i in range(n):
  sum_a += a[i]
for j in range(n):
  sum_a -= a[j]
  result += sum_a * a[j]
print(result % (10**9 + 7))
### BUGGY CODE ###

n,q=map(int,input().split())
s=input()
ans=[]
for _ in range(q):
    l,r=map(int,input().split())
    k=s[l-1:r]
    ans.append(k.count("AC"))
for i in ans:
    print(i)

### FIXED CODE ###

n,q=map(int,input().split())
s=input()
ans,c=[0]*q,[0]*n
k=0
for i in range(1,n):
    if s[i-1]=="A" and s[i]=="C":
        k+=1
    c[i]=k

for i in range(q):
    l,r=map(int,input().split())
    ans[i]=c[r-1]-c[l-1]
for i in ans:
    print(i)
### BUGGY CODE ###

from scipy.sparse import csr_matrix
from scipy.sparse.csgraph import dijkstra

node_num = int(input())
nodes=input().split()

route_list=[]

for _ in range(node_num):
    route_list.append([ 99999 for _ in range(node_num)])

zero_node=[]
mi_count=0
for i in range(node_num-1):
    if i+2<node_num:
        route_list[i][i+1]=abs(int(nodes[i+1])-int(nodes[i])) if abs(int(nodes[i+1])-int(nodes[i])) != 0 else 0.0000001
        route_list[i][i+2]=abs(int(nodes[i+2])-int(nodes[i])) if abs(int(nodes[i+2])-int(nodes[i])) != 0 else 0.0000001
        if route_list[i][i+1]==1 or route_list[i][i+2]==0.0000001:
            zero_node.append(i)
    else:
        route_list[i][i+1]=abs(int(nodes[i+1])-int(nodes[i])) if abs(int(nodes[i+1])-int(nodes[i])) != 0 else 0.0000001
        if route_list[ i ][ i + 1 ] == 0.0000001:
            zero_node.append(i)

route_list = csr_matrix(route_list)
#print(route_list)
dist_matrix, predecessors = dijkstra(csgraph=route_list, directed=False, indices=0, return_predecessors=True)

dis=dist_matrix[-1]

print(int(dis))

### FIXED CODE ###

N = int(input())
H = [0] + [int(h) for h in input().split()]
dp = [999999999 for _ in range(N + 1)]
dp[0] = 0
dp[1] = 0
dp[2] = abs(H[2] - H[1])
for i in range(3, N + 1):
    dp[i] = min(dp[i], dp[i - 1] + abs(H[i - 1] - H[i]), dp[i - 2] + abs(H[i - 2] - H[i]))

print(dp[N])
### BUGGY CODE ###

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

sum = 0
for i in range(N):
    for j in range(i+1, N):
        RGB = ['R','G','B']
        if not S[i] == S[j]:
            RGB.remove(S[i])
            RGB.remove(S[j])
            sum += S[(j+1):].count(RGB[0])

            # S[k]
            k = 2 * j - i
            if k < len(S):
                if S[k] == RGB[0]:
                    sum -= 1
print(sum)

### FIXED CODE ###

from collections import Counter

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

r = S.count('R')
g = S.count('G')
b = S.count('B')

sum = r*g*b

for i in range(N):
    for j in range(i+1, N):
        k = 2 * j - i
        if k > N - 1:
            break
        if not S[i] == S[j] and not S[j] == S[k] and not S[k] == S[i]:
            sum -= 1
print(sum)
### BUGGY CODE ###

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

xlist,ylist,xylist=[],[],[]
for i in range(N):
  x,y=map(int,input().split())
  xlist.append(x)
  ylist.append(y)
  xylist.append((x,y))

xy_prod_list=[]
for x in xlist:
  for y in ylist:
    xy_prod_list.append((x,y))
xy_prod_list.sort()
#print(xy_prod_list)    

answer=float("inf")
for i in range(len(xy_prod_list)):
  x1,y1=xy_prod_list[i]
  for j in range(i+1,len(xy_prod_list)):
    x2,y2=xy_prod_list[j]    
    
    num_inbox=0
    for x,y in xylist:
      if min(x1,x2)<=x<=max(x1,x2) and min(y1,y2)<=y<=max(y1,y2):
        num_inbox+=1
    
    if num_inbox>=K:
      answer=min(answer,abs(x2-x1)*abs(y2-y1))
    
print(answer)

### FIXED CODE ###

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

xlist,ylist,xylist=[],[],[]
xyset=set()
xydic={}
yxdic={}
for i in range(N):
  x,y=map(int,input().split())
  xlist.append(x)
  ylist.append(y)
  xylist.append((x,y))
  xyset.add((x,y))
  xydic[x]=y
  yxdic[y]=x

xy_prod_list=[]
for x in xlist:
  for y in ylist:
    xy_prod_list.append((x,y))
xy_prod_list.sort()
#print(xy_prod_list)    

num_ld_dic={}
for xx,yy in xy_prod_list:
  num_ld=0
  for x,y in xylist:
    if x<=xx and y<=yy:
      num_ld+=1
  num_ld_dic[(xx,yy)]=num_ld
#print(num_ld_dic)

answer=float("inf")
for i in range(len(xy_prod_list)):
  x1,y1=xy_prod_list[i]
  for j in range(len(xy_prod_list)):
    x2,y2=xy_prod_list[j]
    if x1>=x2 or y1>=y2:
      continue
    
    area=(x2-x1)*(y2-y1)
    if area>answer:
      continue
      
    num_point=num_ld_dic[(x2,y2)]-num_ld_dic[(x1,y2)]-num_ld_dic[(x2,y1)]+num_ld_dic[(x1,y1)]
    if (x1,y1) in xyset:  
      num_point+=1
    else:
      xx=yxdic[y1]
      if x1<=xx<=x2:
        num_point+=1
      yy=xydic[x1]
      if y1<=yy<=y2:
        num_point+=1
      
    if num_point>=K:
      #print((x1,y1),(x2,y2),num_point)
      answer=min(answer,area)
    
print(answer)
### BUGGY CODE ###

n, q = map(int, input().split())
s = input()
count = 0

for i in range(q):
    n_, q_ = map(int, input().split())
    s_ = s[n_-1:q_]
    for j in range(len(s_)-1):
        if s_[j] == "A" and s_[j+1] == "C":
            count += 1
    print(count)
    count = 0


### FIXED CODE ###

n, q = map(int, input().split())
s = input()
flag = False
count = 0
li = []

for i in range(n):
    if s[i] == "A":
        flag = True
    elif s[i] == "C" and flag is True:
        count += 1
        flag = False
    else:
        flag = False
    li.append(count)

for i in range(q):
    l, r = map(int, input().split())
    print(li[r-1] - li[l-1])
### BUGGY CODE ###

# coding: utf-8
# Your code here!

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

# dp = [float('inf') for i in range(len(h))]
dp = [float('inf')] * n
dp[0] = 0
# dp[1] = abs(h[0] - h[1])
# print(dp)

for i in range(len(h)):
    for j in range(1, min(k + 1, n - i)):
        dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]))
            
        # print(dp)
        
print(dp[len(dp) - 1])

### FIXED CODE ###

def main():
    n, k = map(int, input().split())
    h = list(map(int, input().split()))
    a = [0] * n
    a[0] = 0
    for i in range(1, n):
        a[i] = min([a[j] + abs(h[i] - h[j]) for j in range(max(0, i - k), i)])
    print(a[-1])
 
if __name__ == '__main__':
    main()
### BUGGY CODE ###

def op2(f, c, r):
  if r == 0:
    if f == "1":
      slist.insert(0, c)
    elif f == "2":
      slist.append(c)

  if r == 1:
    if f == "2":
      slist.insert(0, c)
    elif f == "1":
      slist.append(c)

S = input()
Q = int(input())
v = [list(input().split()) for i in range(Q)]
rev = 0
slist = [S]

for val in v:
  if val[0] == "1":
    if rev == 0:
      rev = 1
    elif rev == 1:
      rev = 0
  elif val[0] == "2":
    op2(val[1], val[2], rev)

ans = "".join(slist)

if rev == 0:
  print(ans)
else:
  print(ans[::-1])


### FIXED CODE ###

def op2(f, c, r):
  if r == 0:
    if f == "1":
      left.append(c)
    elif f == "2":
      right.append(c)

  if r == 1:
    if f == "1":
      right.append(c)
    elif f == "2":
      left.append(c)

S = input()
Q = int(input())
v = [list(input().split()) for i in range(Q)]
rev = 0
left = []
right = []

for val in v:
  if val[0] == "1":
    if rev == 0:
      rev = 1
    elif rev == 1:
      rev = 0
  elif val[0] == "2":
    op2(val[1], val[2], rev)

nleft = left[::-1]
ans = "".join(nleft + [S] + right)

if rev == 0:
  print(ans)
else:
  print(ans[::-1])