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

a,b=map(int,input().split())
c=[]
ans=0

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort()
    return divisors

list_a=make_divisors(a)
list_b=make_divisors(b)

for i in list_a:
    if i in list_b:
        c.append(i)

for i in c:
    for j in range(2,i):
        if i%j == 0:
            break
    else:
        ans+=1

print(ans)


### FIXED CODE ###

a,b=map(int,input().split())
ans=1

def factorization(n):
    arr = []
    temp = n
    for i in range(2,int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

a_list=factorization(a)
b_list=factorization(b)

a_new=[a[0] for a in a_list]
b_new=[b[0] for b in b_list]

if a_new[0]==b_new[0]==1:
    ans=0

for i in a_new:
    if i in b_new:
        ans += 1

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

import sys
sys.setrecursionlimit(2147483647)
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
input = lambda:sys.stdin.readline().rstrip()
from functools import lru_cache

@lru_cache(None)
def subsets(U): # O(k * 2^k)
    bits = []
    for i in range(U.bit_length()):
        if (U >> i) & 1:
            bits.append(i)
    k = len(bits)
    res = [None] * (1 << k)
    for use in range(1 << k):
        V = 0
        for i in range(k):
            if (use >> i) & 1:
                V |= 1 << bits[i]
        res[use] = V
    return res

def resolve():
    n = int(input())
    A = tuple(tuple(map(int, input().split())) for _ in range(n))

    # O(n^2 * 2^n)
    state_to_score = [0] * (1 << n)
    for U in range(1 << n):
        for i in range(n):
            if (U >> i) & 1 == 0:
                continue
            for j in range(i):
                if (U >> j) & 1:
                    state_to_score[U] += A[i][j]

    # dp[i][U] : i まで見て U <= {1, ..., n} を grouping したときの max
    # msb(U) = i ならば dp[i][U] = dp[i + 1][U] = ... = dp[n - 1][U] なので dp は使いまわせる
    # dp[i + 1][U | 1 << (i + 1)] = max((V + {i + 1} の score) + dp[i][W]) for all V + W = U
    dp = [-INF] * (1 << n)
    dp[0] = 0
    for i in range(n): # 既に U = 0, ..., 2^i - 1 までは確定している
        for U in range(1 << i): # O(2^i) これから 2^i, ..., 2^(i + 1) - 1 を確定させる
            for V in subsets(U): # O(k * 2^k) where k = popcount(U)
                W = U ^ V
                dp[U | 1 << i] = max(dp[U | 1 << i], state_to_score[V | 1 << i] + dp[W])

    print(dp[-1])
resolve()

### FIXED CODE ###

import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    A=[list(map(int,input().split())) for _ in range(n)]
    N=1<<n
    cost=[0]*N
    for mask in range(N):
        for j in range(n):
            for i in range(j):
                if((mask>>i)&1 and (mask>>j)&1):
                    cost[mask]+=A[i][j]
    dp=[-INF]*N
    dp[0]=0
    for mask in range(1,N):
        mask2=mask
        while(mask2):
            tmp=dp[mask&~mask2]+cost[mask2]
            dp[mask]=max(dp[mask],tmp)
            mask2=(mask2-1)&mask
    print(dp[-1])
resolve()
### BUGGY CODE ###

N = int(input())
*A, = map(int, input().split())
ans = 0
B = [0] * 61
for k, a in enumerate(A):
    la = list(bin(a))[2:]
    j = 0
    for i in range(61-len(la), 61):
        B[i] += int(la[j])
        j += 1

ans = 0
mod = 10**9 + 7
for i, b in enumerate(B):
    ans += b * (len(A)-b) * 2**(60-i) % mod
print(ans % mod)


### FIXED CODE ###

n = int(input())
A = list(map(int, input().split()))
mod = 10**9+7
array = [0] * 60
for a in A:
    for j in range(len(bin(a))-2):
        array[j] += (a >> j) & 1
ans = 0
for i in range(60):
    ans += array[i] * (n-array[i]) * 2**i
print(ans % mod)
### BUGGY CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
n = int(input())
A = []
ans = 0
nodes = set()
adjacent_list = [[] for i in range((n + 2) * n)]
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in range(1, len(tmp)):
        l, g = min(i, tmp[j] - 1), max(i, tmp[j] - 1 )
        pre_l, pre_g = min(i, pre), max(i, pre) 
        adjacent_list[pre_l * n + pre_g].append(l * n + g)
        nodes.add(pre_l * n + pre_g)
        nodes.add(l * n + g)
        pre = tmp[j] - 1
nodes = list(nodes)
#まず、閉路検
seen = [False for i in range((n + 2) * n)]
visited = [False for i in range((n + 2) * n)]
def check(node):
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if len(adjacent_list[node]) == 0:
        return 1
    if node in finish:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = max(tmp, finish[node])
    return finish[node]
finished = set()
for i in nodes:
    check(i)
finish = defaultdict(int)
for i in nodes:
    dfs_path(i)
print(max(max(finish.values()), 1))

### FIXED CODE ###

from collections import defaultdict
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
n = int(input())
A = []
M = [[-1 for _ in range(n)] for _ in range(n)]
cnt = 0
for i in range(n):
    for j in range(i+1,n):
        M[i][j] = cnt
        M[j][i] = cnt
        cnt += 1
ans = 0
nodes = []
adjacent_list = [[] for i in range(n*(n-1)//2)]
for i in range(n):
    tmp = list(map(int, input().split()))
    pre = tmp[0] - 1
    for j in tmp[1:]:
        adjacent_list[M[i][pre]].append(M[i][j-1])
        pre = j - 1
#まず、閉路検
seen = defaultdict(lambda: False)
visited = defaultdict(lambda: False)
def check(node):
    if visited[node]:
        return
    seen[node] = True
    for i in adjacent_list[node]:
        if seen[i] and (not visited[i]):
            print(-1)
            exit()
        check(i)
    visited[node] = True
def dfs_path(node):
    if not adjacent_list[node]:
        return 1
    if finish[node]:
        return finish[node]
    tmp = 0
    for i in adjacent_list[node]:
        tmp = max(tmp, dfs_path(i) + 1)
    finish[node] = tmp
    return finish[node]
finished = set()
finish = [0 for i in range(n*(n-1)//2)]
for i in range(n*(n-1)//2):
    check(i)
    dfs_path(i)
print(max(max(finish), 1))
### BUGGY CODE ###

n = int(input())
lis = list(map(int,input().split()))
d = int(input())
li = list(map(int,input().split()))
for i in range(d):
    if li[i] in lis:
        lis.remove(li[i])
    else:
        print("NO")
        exit()
print("YES")

### FIXED CODE ###

import collections
n = int(input())
d = list(map(int,input().split()))
m = int(input())
t = list(map(int,input().split()))
dcounter = collections.Counter(d)
tcounter = collections.Counter(t)
check = True
for i in tcounter.items():
	if dcounter[i[0]] < i[1]:
		check = False
if check:
	print('YES')
else:
	print('NO')
### BUGGY CODE ###

n=int(input())
l=[0]+list(map(int,input().split()))
for i in range(1,1+n):
  l[i]+=l[i-1]
ans=0
for i in range(n):
  for j in range(i+1,n+1):
    if l[j]-l[i]==0:
      ans+=1
print(ans)

### FIXED CODE ###

n=int(input())
l=[0]+list(map(int,input().split()))
for i in range(1,n+1):
  l[i]+=l[i-1]
d={}
for i in l:
  if i not in d:
    d[i]=1
  else:
    d[i]+=1
ans=0
for a in d.values():
  ans+=a*(a-1)//2
print(ans)
### BUGGY CODE ###

def main():
    a, b, c, k = map(int, input().split())
    res = 0
    for i in range(a):
        res += 1
    # if k-a > 0:
    #     for i in range(k-a):
    #         res += 0
    if k-a-b > 0:
        for i in range(k-a-b):
            res += -1
    print(res)
                
if __name__ == '__main__':
    main()

### FIXED CODE ###

def main():
    a, b, c, k = map(int, input().split())
    res = 0
    if k-a >= 0:
        res += a
    else:
        res += k
    # if k-a-b >= 0:
    #     res += 0
    if k-a-b > 0:
        res += (k-a-b)*-1
    print(res)
                
if __name__ == '__main__':
    main()
### BUGGY CODE ###

import math
x, y = map(int, input().split())

def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

def A(i, j):
    if 0.5*i <= j and j <= 2*i and (i+j)%3==0:
        n, m = (2*j-i)//3, (2*i-j)//3
        return combinations_count(n+m,m)%((10**9)+7)
    else:
        return 0

print(A(x, y))

### FIXED CODE ###

x, y = map(int, input().split())

def combinations_count(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def A(i, j):
    if 0.5*i <= j and j <= 2*i and (i+j)%3==0:
        n, m = (2*j-i)//3, (2*i-j)//3
        return combinations_count(n+m,m)%((10**9)+7)
    else:
        return 0

print(A(x, y))
### BUGGY CODE ###

n, k, c = map(int, input().split())
s = input()

ans = []
for i in range(n):
    if s[i] == "x":
        continue
        
    cur = 0
    count = 0

    while cur < n:
        if s[cur] == "o" and cur != i:
            count += 1
            cur += c

        cur += 1

        if count >= k:
            break

    if count < k:
        ans.append(i+1)

for i in ans:
    print(i)


### FIXED CODE ###

from sys import stdin
def main():
    input = stdin.readline
    n, k, c = map(int, input().split())
    s = input()

    l, r = [], []
    cur = 0
    count = 0

    while cur <= n:
        if s[cur] == "o":
            count += 1
            l.append((count, cur+1))
            cur += c

        cur += 1

    cur = n
    count = k

    while cur >= 0:
        if s[cur] == "o":
            r.append((count, cur+1))
            count -= 1
            cur -= c

        cur -= 1

    ans = (i[1] for i in set(l) & set(r))
    for i in sorted(ans):
        print(i)


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

import sys
input = sys.stdin.readline

n=int(input())
s=input().rsplit()[0]
d=[x=="D" for x in s]
m=[x=="M" for x in s]
c=[x=="C" for x in s]

def calc(k):
	D=M=DM=DMC=0
	for i,fd,fm,fc in zip(range(n),d,m,c):
		if k<=i:
			if d[i-k]:
				D-=1
				DM-=M
			elif m[i-k]:
				M-=1
		if fd:
			D+=1
		elif fm:
			M+=1
			DM+=D
		elif fc:
			DMC+=DM
	return DMC

q=int(input())
ans=[calc(x) for x in map(int,input().split())]
print(*ans,sep="\n")

### FIXED CODE ###

import sys
input = sys.stdin.readline

n=int(input())
s=input().rsplit()[0]

def calc(k):
	D=M=DM=DMC=0
	for i in range(n):
		if k<=i:
			if s[i-k]=="D":
				D-=1
				DM-=M
			elif s[i-k]=="M":
				M-=1
		if s[i]=="D":
			D+=1
		elif s[i]=="M":
			M+=1
			DM+=D
		elif s[i]=="C":
			DMC+=DM
	return DMC

q=int(input())
*k,=map(int,input().split())
ans=[calc(x) for x in k]
print(*ans,sep="\n")
### BUGGY CODE ###

import sys
import copy

input = sys.stdin.readline

N, M = list(map(int,input().split()))
st = [list(map(int,input().split())) for i in range(M)]

neighbor = [[] for i in range(N)]
ineighbor_init = [[] for i in range(N)]
for s,t in st:
	neighbor[s-1].append(t-1)
	ineighbor_init[t-1].append(s-1)

INF = 100100100
ev = [INF]*N
ev[N-1] = 0
for i in range(N-2,-1,-1):
	dlist = []
	for j in neighbor[i]:
		dlist.append(ev[j])
	ev[i] = sum(dlist)/len(dlist) + 1

ans = ev[0]
for i in range(N-1):
	evmax = -1
	if len(neighbor[i])==1: continue
	for j in neighbor[i]:
		if ev[j]>evmax:
			tn = j
			evmax = ev[j]

	ntmp = copy.deepcopy(neighbor)
	ntmp[i].remove(tn)
	evtmp = [INF]*N
	evtmp[N-1] = 0
	for ii in range(N-2,-1,-1):
		dlist = []
		for jj in ntmp[ii]:
			dlist.append(evtmp[jj])
		evtmp[ii] = sum(dlist)/len(dlist) + 1

	if evtmp[0]<ans:
		ans = evtmp[0]

print(ans)

### FIXED CODE ###

import sys
import copy

def main():
	input = sys.stdin.readline

	N, M = list(map(int,input().split()))
	st = [list(map(int,input().split())) for i in range(M)]

	neighbor = [[] for i in range(N)]
	for s,t in st:
		neighbor[s-1].append(t-1)

	INF = 100100100
	ev = [INF]*N
	ev[N-1] = 0
	for i in range(N-2,-1,-1):
		dsum = 0
		dcount = 0
		for j in neighbor[i]:
			dsum += ev[j]
			dcount += 1
		ev[i] = dsum/dcount + 1

	ans = ev[0]
	for i in range(N-1):
		evmax = -1
		if len(neighbor[i])==1: continue
		for j in neighbor[i]:
			if ev[j]>evmax:
				tn = j
				evmax = ev[j]

		# ntmp = copy.deepcopy(neighbor)
		# ntmp[i].remove(tn)
		evtmp = [INF]*N
		evtmp[i+1::] = ev[i+1::]
		for ii in range(i,-1,-1):
			dsum = 0
			dcount = 0
			for jj in neighbor[ii]:
				if ii==i and jj==tn: continue
				dsum += evtmp[jj]
				dcount += 1
			evtmp[ii] = dsum/dcount + 1

		if evtmp[0]<ans:
			ans = evtmp[0]

	print(ans)

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

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



a=input().split()
b=input().split()
m=[]
for i in range(M):
    m.append(input().split())

counta=0
countb=0
nummin=int(a[0])+int(b[0])
for i in m:

    x=int(i[0])-1
    y=int(i[1])-1
    c=int(i[2])
    num=int(a[x])+int(b[y])-c

    if num<nummin:
        nummin=num

for i in a:
    i=int(i)
    for j in b:
        j=int(j)
        if (i+j)<nummin:
            nummin=i+j
print(nummin)


### FIXED CODE ###

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



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

counta=0
countb=0
nummin=int(a[0])+int(b[0])
for i in m:
    
    x=int(i[0])-1
    y=int(i[1])-1
    c=int(i[2])
    num=a[x]+b[y]-c

    if num<nummin:
        nummin=num
if min(a)+min(b)<nummin:
    nummin=min(a)+min(b)

print(nummin)
### BUGGY CODE ###

import numpy as np
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=[list(map(int,input().split())) for i in range(m)]
l.sort(key=lambda x: x[1], reverse=True)
l=np.array(l)


nl=[]
for i in range(m):
  nl.extend([l[i][1]]*l[i][0])


for i in range(min(n,np.sum(l, axis=0)[0])):
  if nl[i]<=a[i]:
    print(sum(nl[0:i])+sum(a[i:n]))
    exit()
if n<np.sum(l, axis=0)[0]:
  print(sum(nl[0:n]))
else:
  print(sum(nl)+sum(a[np.sum(l, axis=0)[0]:n]))

### FIXED CODE ###

import numpy as np
n,m=map(int,input().split())
a=sorted(list(map(int,input().split())))
l=[list(map(int,input().split())) for i in range(m)]
l.sort(key=lambda x: x[1], reverse=True)
l=np.array(l)


nl=[]
k=0
i=0
while k<=n and i<m:
  nl.extend([l[i][1]]*l[i][0])
  k+=l[i][0]
  i+=1


for i in range(min(n,np.sum(l, axis=0)[0])):
  if nl[i]<=a[i]:
    print(sum(nl[0:i])+sum(a[i:n]))
    exit()
if n<np.sum(l, axis=0)[0]:
  print(sum(nl[0:n]))
else:
  print(sum(nl)+sum(a[np.sum(l, axis=0)[0]:n]))
### BUGGY CODE ###

r1, c1, r2, c2 = map(int, input().split())

n = r2 + c2 + 3
mod = 10 ** 9 + 7
f = [1 for _ in range(n)]
f_inv = [1 for _ in range(n)]
for i in range(1, n):
    f[i] = f[i-1] * i % mod
    f_inv[i] = pow(f[i], mod-2, mod)

def comb(n, k):
    return f[n] * f_inv[k] * f_inv[n-k] % mod
def g(r, c):
    return comb(r+c+2, c+1) - 1

ans = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1)
ans %= mod

print(ans)

### FIXED CODE ###

r1, c1, r2, c2 = map(int, input().split())

n = r2 + c2 + 3
mod = 10 ** 9 + 7
f = [1 for _ in range(n)]
f_inv = [1 for _ in range(n)]
for i in range(1, n):
    f[i] = f[i-1] * i % mod
    f_inv[i] = pow(f[i], mod-2, mod)

def comb(n, k):
    return f[n] * f_inv[k] * f_inv[n-k] % mod
def g(r, c):
    return comb(r+c+2, c+1) - 1

ans = g(r2, c2) - g(r2, c1-1) - g(r1-1, c2) + g(r1-1, c1-1)
ans %= mod

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

# coding: utf-8
# Your code here!
MOD = 10**9 + 7
N = int(input())
S = list(input())
if S[0] == "W" or S[2*N-1] == "W":
    print(0)
    exit()

L,R = [0], []
l,r = 1,0
prev = "L"
for i in range(1, 2*N):
    if S[i] == S[i-1]:
        if prev == "L":
            R.append(i)
            r += 1
            prev = "R"
        else:
            L.append(i)
            l += 1
            prev = "L"
    else:
        if prev == "L":
            L.append(i)
            l += 1
        else:
            R.append(i)
            r += 1
    if l < r:
        print(0)
        exit()

if not (len(L) == N and len(R) == N):
    print(0)
    exit()

def fact(n):
    ret = 1
    while n > 1:
        ret *= n
        n -= 1
    return ret
    
R.reverse()
R_border = 0
cnt = 1
l = N-1
while l >= 0:
    while R_border < N-1 and L[l] < R[R_border+1]:
        R_border += 1
    cnt = cnt * (R_border + 1 - (N-1 - l)) % MOD
    l -= 1
print(cnt * fact(N) % MOD)


### FIXED CODE ###

# coding: utf-8
# Your code here!
MOD = 10**9 + 7
N = int(input())
S = list(input())
if S[0] == "W" or S[2*N-1] == "W":
    print(0)
    exit()

L,R = [0], []
total = [0 for i in range(2*N)]
total[0] = 1
l,r = 1,0
prev = "L"
for i in range(1, 2*N):
    if S[i] == S[i-1]:
        if prev == "L":
            R.append(i)
            total[i] = total[i-1] - 1
            r += 1
            prev = "R"
        else:
            L.append(i)
            total[i] = total[i-1] + 1
            l += 1
            prev = "L"
    else:
        if prev == "L":
            L.append(i)
            total[i] = total[i-1] + 1
            l += 1
        else:
            R.append(i)
            total[i] = total[i-1] - 1
            r += 1
    if l < r:
        print(0)
        exit()

if not (len(L) == N and len(R) == N):
    print(0)
    exit()

def fact(n):
    ret = 1
    while n > 1:
        ret = (ret * n) % MOD
        n -= 1
    return ret
    
cnt = 1
for r in R:
    cnt = (cnt * (total[r] + 1)) % MOD
print(cnt * fact(N) % MOD)
### BUGGY CODE ###

n = int(input())
s = 0
while n > 0:
    r = n % 10
    s += r
    n //= 10
if s % 9 == 0:
    print('Yes')
else:
    print('No')

### FIXED CODE ###

n = int(input())
ln = list(str(n))
from collections import Counter
nc = dict(Counter(ln))
s = 0
if n != 0:
    for i in range(1, 10):
        if str(i) in nc:
            s += i * nc[str(i)]
if s % 9 == 0:
    print('Yes')
else:
    print('No')
### BUGGY CODE ###

N,Q = map(int,input().split())
S = list(input())
for i in range(Q):
    l,r = map(int,input().split())
    s = "".join(S[l-1:r])
    print(s.count("AC"))

### FIXED CODE ###

N,Q = map(int,input().split())
S = input()
c = []
count = 0
for i in range(N-1):
    if S[i] == "A" and S[i+1] == "C":
        count += 1
    c.append(count)
for i in range(Q):
    l,r = map(int,input().split())
    if l == 1:
        print(c[r-2]-0)
    else:
        print(c[r-2]-c[l-2])
### BUGGY CODE ###

N = int(input())#整数
A = list(map(int, input().split()))#配列Int型

ans = 0

for i in range(N):
    for j in range(i + 1):
        if A[i] > A[j]:
            ans = A[i] - A[j]
            A[j] += ans
print(ans)

### FIXED CODE ###

N = int(input())#整数
A = list(map(int, input().split()))#配列Int型

ans = 0
max_val = A[0]

for i in range(1, N):
    if max_val > A[i]:
        ans += max_val - A[i]
    else:
        max_val = A[i]
print(ans)
### BUGGY CODE ###

from collections import deque
s=deque(list(input()))
q=int(input())
for i in range(q):
    query=input()
    if query=="1":
        s.reverse()
    elif query[2]=="1":
        s.appendleft(query[-1])
    else:
        s.append(query[-1])
print(*s,sep="")

### FIXED CODE ###

from collections import deque
s=deque(list(input()))
q=int(input())
count=0
for i in range(q):
    query=input()
    if query=="1":
        count+=1
    elif query[2]=="1":
        if count%2==0:
            s.appendleft(query[-1])
        else:
            s.append(query[-1])
    else:
        if count%2==0:
            s.append(query[-1])
        else:
            s.appendleft(query[-1])
if count%2==1:
    s.reverse()
print(*s,sep="")
### BUGGY CODE ###

N,M = map(int, input().split())
A = []
comp = sum(10**(x-1) for x in range(1,N+1))
for m in range(M):
  a, b = map(int, input().split())
  c = list(map(int, input().split()))
  box = sum(10**(x-1) for x in c)
  A.append([box, a])
  ci = len(A)-1
  for i in range(0,len(A)-1):
    A.append([A[0|i][0] + A[ci][0], 
              A[0|i][1] + A[ci][1]])

if max([A[x][1] for x in range(len(A))]) >= comp:
  ans = min([A[x][1] for x in range(len(A))
           if len(str(A[x][0]).replace('0','')) >= len(str(comp))] )
else:
  ans = -1
print(ans)

### FIXED CODE ###

import itertools

N,M = map(int, input().split())
A = []
C = []
comp = sum(1<<int(x) for x in range(N))
for m in range(M):
  a, b = map(int, input().split())
  A.append(a)
  c = list(map(int, input().split()))
  C.append(sum(1<<(int(x)-1) for x in c))

INF = 10**18
dp = [INF] * (1<<N)
dp[0] = 0

for n,(a,c) in itertools.product(range(1<<N),zip(A,C)):
    m = n|c
    x = dp[n]+a
    if dp[m] > x:
      dp[m] = x

answer = dp[-1]
if answer == INF:
    answer = -1
print(answer)
### BUGGY CODE ###

def main():
    N, K = map(int, input().split())
    XY = [tuple(map(int, input().split())) for _ in range(N)]
    XY.sort()
    XY = tuple(XY)

    def count(x_min, x_max, y_min, y_max, i, j):
        OK = 0
        # NG = 0
        a = j - i + 1 - K
        for m in range(i, j + 1):
            if y_min <= XY[m][1] <= y_max:
                OK += 1
            # else:
            #     NG += 1
            # if OK >= K:
            #     return True
            # if NG > a:
            #     return False
        if OK >= K:
            return True
        return False

    ans = 10 ** 20
    for i in range(N - 1):
        a = XY[i][0]
        for j in range(i + K - 1, N):
            b = XY[j][0]
            for k in range(N):
                c = XY[k][1]
                for l in range(N):
                    d = XY[l][1]
                    if c < d:
                        if count(a, b, c, d, i, j):
                            # print ('A')
                            ans = min(ans, (b - a) * (d - c))
    print (ans)
    return

if __name__ == '__main__':
    main()


### FIXED CODE ###

#PythonだとTLEする
N, K = map(int, input().split())
X = [0] * N
Y = [0] * N
for i in range(N):
    x, y = map(int, input().split())
    X[i] = x
    Y[i] = y

def count(x_min, x_max, y_min, y_max):
    cnt = 0
    for i in range(N):
        if x_min <= X[i] <= x_max and y_min <= Y[i] <= y_max:
            cnt += 1
    return cnt

ans = 10 ** 20
for i in range(N):
    for j in range(N):
        for k in range(N):
            for l in range(N):
                # print ('i, j , k, l = ', i, j, k, l)
                if X[i] < X[j] and Y[k] < Y[l]:
                    if count(X[i], X[j], Y[k], Y[l]) >= K:
                        # print ('A')
                        ans = min(ans, (X[j] - X[i]) * (Y[l] - Y[k]))
print (ans)