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

N = int(input())
S = input()
R = 0
G = 0
B = 0
notToAllow = 0


for i in range(0,N):
    if S[i] == "R":
        R = R + 1
    elif S[i] == "G":
        G = G + 1
    else:
        B = B + 1

total = R*G*B

for i in range(0,N):
    for j in range(0,N):
        if(j+j+i < N) and (j+j < N) and (i+j < N):
            if ((S[i] != S[i+j]) and (S[i] != S[i+j+j]) and (S[i+j] != S[i+j+j])):
                notToAllow = notToAllow + 1

print(R*G*B - notToAllow)


### FIXED CODE ###

N = int(input())
S = input()
R = 0
G = 0
B = 0
notToAllow = 0


for i in range(0,N):
    if S[i] == "R":
        R = R + 1
    elif S[i] == "G":
        G = G + 1
    else:
        B = B + 1

total = R*G*B

for i in range(0,N):
    for j in range(0,(N//2)+1):
        if(j+j+i < N):
            if ((S[i] != S[i+j])):
                if(S[i] != S[i+j+j]):
                    if(S[i+j] != S[i+j+j]):
                        notToAllow = notToAllow + 1

print(R*G*B - notToAllow)
### BUGGY CODE ###

N,Q = map(int,input().split())
S = input()
lr = []
for i in range(Q):
    lr.append(list(map(int,input().split())))

cl = [0 for i in range(len(S))]

for i in range(1,len(S)):
    if S[i] == 'C' and S[i-1] == 'A':
        cl[i] = cl[i-1] + 1


#print(cl) 
#print(S)

for l,r in lr:
    sub = cl[l-1:r]
    res = sub.count(1)
    if sub[0] == 1:
        res -= 1
    print(res)


### FIXED CODE ###

def main():
    N,Q = map(int,input().split())
    S = input()
    lr = []
    for i in range(Q):
        lr.append(list(map(int,input().split())))

    cl = [0 for _ in range(len(S))]

    for i in range(1,len(S)):
        if S[i] == 'C' and S[i-1] == 'A':
            cl[i] = cl[i-1] + 1
        else:
            cl[i] = cl[i-1]


    #print(cl) 
    #print(S)

    for l,r in lr:
        res = cl[r-1] - cl[l-1] 
        print(res)


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

from collections import deque


n,m = map(int, input().split())
graph = [[] for _ in range(n)]
for i in range(1,m+1):
    a,b = map(int, input().split())
    graph[a-1].append(b)
    graph[b-1].append(a)

q = deque([1])
prev=[1]
siru = [0] * (n-1)
while q:

    now = q.popleft()
    
    next = graph[now-1]

    
    for n in next:
        if not n in prev: 
            q.append(n)
            prev.append(n)
            siru[n-2] = now

if 0 in siru:
    print("No")
else:
    print("Yes")
    for i in range(len(siru)):
        print(siru[i])
    
        

### FIXED CODE ###

from collections import deque

def main():
    n,m = map(int, input().split())
    graph = [[] for _ in range(n)]
    for i in range(m):
        a,b = map(int, input().split())
        graph[a-1].append(b)
        graph[b-1].append(a)
    
    q = deque([1])
    prev=[1]
    siru = [0] * n
    siru[0] = 1
    while q:
    
        now = q.popleft()
        
        next = graph[now-1]
    
        
        for n in next:
            if not siru[n-1]: 
                q.append(n)
                siru[n-1] = now
    
    
    print("Yes")
    print("\n".join(map(str, siru[1:])))
if __name__ == "__main__":
    main()
### BUGGY CODE ###

from sys import stdin
import math


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


def main():
    N = int(stdin.readline())
    s = [stdin.readline().rstrip().split() for _ in range(N)]

    s_flat = [flatten for inner in s for flatten in inner]

    a = []
    b = set()
    sum = 0

    for S in s_flat:
        new_S = ''.join(sorted(S))
        a.append(new_S)
        b.add(new_S)

    for X in b:
        if a.count(X) == 1:
            pass
        else:
            sum += combinations_count(a.count(X), 2)

    print(sum)


if __name__ == "__main__":
    main()


### FIXED CODE ###

from sys import stdin


def main():
    N = int(stdin.readline())
    s = [stdin.readline().rstrip().split() for _ in range(N)]

    s_flat = [flatten for inner in s for flatten in inner]

    s_dict = {}
    sum = 0

    for S in s_flat:
        new_S = ''.join(sorted(S))
        if not s_dict.get(new_S):
            s_dict[new_S] = 1
        else:
            sum += s_dict[new_S]
            s_dict[new_S] = s_dict[new_S] + 1

    print(sum)


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

import math
N = int(input())
for h in range(1,3500):
    for n in range(1,3500):
        d = N*n+N*h-4*h*n
        if d!=0:
            w = N*h*n/d
            if w.is_integer(): 
                w = int(max(w,-w))
                ans = [h,n,w]
print(ans)

### FIXED CODE ###

import math
N = int(input())
for h in range(1,3501):
    for n in range(1,h):
        d = 4*h*n-N*n-N*h
        if d>0:
            w = N*h*n/d
            if w.is_integer():ans = [h,n,int(w)]
print(ans[0],ans[1],ans[2])
### BUGGY CODE ###

n=int(input())
s=input()
num_s=[]
value=[]
for f_s in s:
    if(f_s=="E"):
        num_s.append(0)
    else:
        num_s.append(1)
for n in range(len(s)):
    value.append(sum(num_s[:n])+abs(sum(num_s[n:])-len(num_s[n:])))
print(min(value))

### FIXED CODE ###

n=int(input())
s=input()
num_s=[]
value=[]
left=0
for f_s in s:
    if(f_s=="E"):
        num_s.append(0)
    else:
        num_s.append(1)
right=sum(num_s[1:])
len_s=n-1
value.append(len_s-right)
for p in range(1,n):
    left+=num_s[p-1]
    right-=num_s[p]
    len_s-=1
    value.append(left+len_s-right)
print(min(value))
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**7) 

def dfs(G,v,p):
    for next in G[v]:
        if next == p:
            continue
        dfs(G,next,v)
    
    for c in G[v]:
        if c == p:
            continue
        subtree[v].append(c)
        subtree[v]+=subtree[c]

N,Q = map(int, input().split())
counter = [0]*N
G = [[] for _ in range(N)]

for _ in range(N-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

subtree = [[] for _ in range(N)]
dfs(G,0,-1)
#print(subtree)
for _ in range(Q):
    p,x = map(int, input().split())
    p-=1
    counter[p]+=x
    for i in subtree[p]:
        counter[i]+=x
counter = map(str,counter)
print(' '.join(counter))

### FIXED CODE ###

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

def dfs(G,v,p):
    for next in G[v]:
        if next == p:
            continue
        counter[next]+=counter[v]
        dfs(G,next,v)
    

N,Q = map(int, input().split())
counter = [0]*N
G = [[] for _ in range(N)]

for _ in range(N-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    G[a].append(b)
    G[b].append(a)

#print(subtree)
for _ in range(Q):
    p,x = map(int, input().split())
    p-=1
    counter[p]+=x
dfs(G,0,-1)
counter = map(str,counter)
print(' '.join(counter))
### BUGGY CODE ###

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

scores = [0] * (N-K+1)

num = A[0]
for i in range(1, K):
    num *= A[i]
scores[0] = num

for i in range(K, N):
    num //= A[i-K]
    num *= A[i]
    scores[i-K+1] = num

check = scores[0]

for k in range(1, N-K+1):
    if scores[k-1] < scores[k]:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

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

for i in range(K, N):
    if A[i-K] < A[i]:
        print('Yes')
    else:
        print('No')
### BUGGY CODE ###

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

cnt=0
for i in range(n):
  xor_tmp=0
  add_tmp=0
  for j in range(i+1):
    xor_tmp^=lst[i-j]
    add_tmp+=lst[i-j]
    if xor_tmp!=add_tmp:
      break
    else:
      cnt+=1
print(cnt)

### FIXED CODE ###

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

res=0
xor_sum=0
add_sum=0
right=0
for left in range(n):
  while right<n and xor_sum^A[right]==add_sum+A[right]:
    xor_sum^=A[right]
    add_sum+=A[right]
    right+=1
  res+=(right-left)
  if right==left:
    right+=1
  else:
    xor_sum^=A[left]
    add_sum-=A[left]
print(res)
### BUGGY CODE ###

from sys import setrecursionlimit 
setrecursionlimit(10**6)

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

fr = [set() for _ in range(n)]
bl = [set() for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    fr[a-1].add(b-1)
    fr[b-1].add(a-1)
    
for i in range(k):
    c ,d = map(int, input().split())
    bl[c-1].add(d-1)
    bl[d-1].add(c-1)
    

def connectedcomponents():
    visited = []
    cc = []
    for i in range(n):
        visited.append(False)
    for v in range(n):
        if visited[v] == False:
            temp = set()
            cc.append(dfs(fr,v,temp,visited))
    return cc
            

def dfs(fr, v, temp, visited):
    visited[v] = True
    temp.add(v)
    for i in fr[v]:
        if visited[i] == False:
            temp = dfs(fr, i, temp, visited)
    return temp

cc = connectedcomponents()

ans = []
for i in range(n):
    for component in cc:
        if i in component:
            aa = len(component) - len(component & fr[i]) - len(component & bl[i]) - 1
            ans.append(aa)
print(*ans)

### FIXED CODE ###


from sys import setrecursionlimit 
setrecursionlimit(10**6)

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

fr = [set() for _ in range(n)]
bl = [set() for _ in range(n)]

for i in range(m):
    a, b = map(int, input().split())
    fr[a-1].add(b-1)
    fr[b-1].add(a-1)
    
for i in range(k):
    c ,d = map(int, input().split())
    bl[c-1].add(d-1)
    bl[d-1].add(c-1)
    

def connectedcomponents():
    visited = []
    cc = [0]*n
    for i in range(n):
        visited.append(False)
    for v in range(n):
        if visited[v] == False:
            temp = set()
            for i in dfs(fr,v,temp,visited):
                cc[i] = dfs(fr,v,temp,visited)
    return cc
            

def dfs(fr, v, temp, visited):
    visited[v] = True
    temp.add(v)
    for i in fr[v]:
        if visited[i] == False:
            temp = dfs(fr, i, temp, visited)
    return temp

cc = connectedcomponents()

ans = []
for i in range(n):
    aa = len(cc[i]) - len(cc[i] & fr[i]) - len(cc[i] & bl[i]) - 1
    ans.append(aa)
print(*ans)
### BUGGY CODE ###

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

ans = 0

for i in range(N):
    x = i
    y = 0
    
    for j in range(N**2):
        dx = j//N
        dy = j%N
        
        if S[(x+dx)%N][(y+dy)%N]!=S[(x+dy)%N][(y+dx)%N]:
            break
    else:
        ans += N
        
print(ans)

### FIXED CODE ###

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

ans = 0

for k in range(N):
    symmetry = True
    
    for i in range(N-1):
        for j in range(i+1,N):
            
            if S[(k+i)%N][j]!=S[(k+j)%N][i]:
                symmetry = False
                
    if symmetry:
        ans += N
        
print(ans)
### BUGGY CODE ###

N ,W = map(int,input().split())
w = [0] * N
v = [0] * N
dp = [[0] * (W + 1) for i in range(N + 1)]
for i in range(N):
    w[i],v[i] = map(int,input().split())

for j in range(W + 1):
    for i in range(N):
        if j - w[i] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])
print(dp[N][W])
    

### FIXED CODE ###

N ,W = map(int,input().split())
w = [0] * N
v = [0] * N
dp = [[0] * (W + 1) for i in range(N + 1)]
for i in range(N):
    w[i],v[i] = map(int,input().split())

for j in range(W + 1):
    for i in range(N):
        if j - w[i] >= 0:
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j - w[i]] + v[i])
        dp[i + 1][j] = max(dp[i][j], dp[i + 1][j])
print(dp[N][W])
### BUGGY CODE ###

N, Q=map(int, input().split())
import sys
sys.setrecursionlimit(10**6)
tree=[[] for _ in range(N)]
for i in range(N-1):
  a,b=map(int, input().split())
  tree[a-1].append(b-1)
  tree[b-1].append(a-1)

add=[0]*N
for i in range(Q):
  p,x=map(int, input().split())
  add[p-1]+=x

ans=[0]*N
def dfs(start, pre, preval):
  addval=preval+add[start]
  ans[start]+=addval
  for next_node in tree[start]:
    if next_node==pre:
      continue
    dfs(next_node, start,addval)
dfs(0,-1,0)  
for a in ans:
  print(a, end=" ")

### FIXED CODE ###

from collections import deque 
N,Q=map(int, input().split())
G=[[] for _ in range(N)]
for i in range(N-1):
    a,b=map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)
X=[0]*N
for i in range(Q):
    p,x=map(int, input().split())
    X[p-1]+=x
que=deque([(0,-1)])
#print(que)
while que:
    now, pre=que.pop()
    for nex in G[now]:
        if nex==pre:
            continue
        else:
            X[nex]+=X[now]
            que.append((nex,now))

print(" ".join(map(str, X)))
### BUGGY CODE ###

n,x,y = map(int,input().split())
cnt_l = [0 for i in range(0,n)]
from collections import deque
def bfs(start):
    queue = deque()
    queue.append([start,0])
    isNotSearched = [False]*(n+1)
    
    while(len(queue)>0):
        i,cnt = queue.popleft()
        
        if(isNotSearched[i]):
            continue
        
        isNotSearched[i]=True
        cnt_l[cnt]+=1
        pre = (i-1)
        nex = (i+1)
        if(i==x):
            queue.append([y,cnt+1])
        if(i==y):
            queue.append([x,cnt+1])
        if(pre>=1):
            queue.append([pre,cnt+1])
        if(nex<=n):
            queue.append([nex,cnt+1])
            
        

        
for i in range(1,n+1):
    bfs(i)


for i in range(1,n):
    print(cnt_l[i]//2)
    


### FIXED CODE ###

n,x,y = map(int,input().split())
cnt_l = [0]*n
from collections import deque
def bfs(start):
    queue = deque()
    queue.append(start)
    isSearched = [-1]*(n+1)
    isSearched[start] = 0
    while(len(queue)>0):
        i = queue.popleft()
        cnt = isSearched[i]
        if(i==x):
            nex_l = (i-1,y,i+1)
        elif(i==y):
            nex_l = (i-1,x,i+1)
        else:
            nex_l = (i-1,i+1)

        cnt += 1
        for j in nex_l:
            if(j < 1 or n < j):
                continue
            if(isSearched[j]!=-1):
                continue
            queue.append(j)
            isSearched[j] = cnt
            cnt_l[cnt] += 1
            
        
 
        
for i in range(1,n+1):
    bfs(i)
 
 
for i in range(1,n):
    print(cnt_l[i]//2)
### BUGGY CODE ###

n=int(input())
p=list(map(int,input().split()))
ans=1
for i in range(1,n):
  if p[i]<min(p[0:i]):
    ans+=1

print(ans)

### FIXED CODE ###

n=int(input())
p=list(map(int,input().split()))
ans = 0
mi = p[0]
 
for i in range(n):
    if p[i] <= mi:
        ans += 1
        mi = p[i]
    
print(ans)
### BUGGY CODE ###

import math
n= int(input())
lis= list(map(int,input().split()))
lis.sort(reverse=True)
ans=0
while lis:
  a =lis.pop(0)
  num = 2**math.ceil(math.log(a,2))-a
  if num==0:num=a
  if num in lis:
    lis.remove(num)
    ans +=1
print(ans)


### FIXED CODE ###

from collections import Counter
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
c=Counter(a)
ans=0
for i in a:
  if c[i]==0:
    continue
  pt=2**len(format(i,'b'))
  c[i]-=1
  if c[pt-i]>=1:
    ans+=1
    c[pt-i]-=1
print(ans)
### BUGGY CODE ###

import sys
sys.setrecursionlimit(10**6)

h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done = [0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j]: continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l += 1

        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(w):
    done = [0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l += 1

        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1

ans = 0

for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j]-1)

print(ans)

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

h,w = map(int,input().split())

s = [input() for _ in range(h)]
cnt = [[0] * w for _ in range(h)]

for i in range(h):
    done = [0] * w

    for j in range(w):
        if s[i][j] == '#': continue
        if done[j]: continue

        l = 0
        while j+l < w:
            if s[i][j+l] == '#': break
            l += 1

        for k in range(l):
            cnt[i][j+k] += l
            done[j+k] = 1

for j in range(w):
    done = [0] * h

    for i in range(h):
        if s[i][j] == '#': continue
        if done[i] :continue

        l = 0
        while i+l < h:
            if s[i+l][j] == '#': break
            l += 1

        for k in range(l):
            cnt[i+k][j] += l
            done[i+k] = 1

ans = 0

for i in range(h):
    for j in range(w):
        ans = max(ans, cnt[i][j]-1)

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

def nearestdis(x,y):
    lst_new = [abs(j-x) for j in y]
    return(min(lst_new))
    
a,b,q = map(int,input().split())
lst_s = [int(input()) for i in range(a)]
lst_t = [int(input()) for i in range(b)]
lst_x = [int(input()) for i in range(q)]


for i in lst_x:
    lst_ans = []
    lst_s_x = [abs(j-i) for j in lst_s]
    lst_t_x = [abs(j-i) for j in lst_t]
    min_s = min(lst_s_x)
    min_t = min(lst_t_x)
    if i-min_s in lst_s:
        lst_ans.append(min_s+nearestdis(i-min_s,lst_t))
    if i+min_s in lst_s:
        lst_ans.append(min_s+nearestdis(i+min_s,lst_t))
    if i-min_t in lst_t:
        lst_ans.append(min_t+nearestdis(i-min_t,lst_s))
    if i+min_t in lst_t:
        lst_ans.append(min_t+nearestdis(i+min_t,lst_s))
    print(min(lst_ans))

### FIXED CODE ###

from bisect import bisect
a,b,q=map(int,input().split())
INF=10**11+7
ls=[-INF]+[int(input()) for _ in range(a)]+[INF]
lt=[-INF]+[int(input()) for _ in range(b)]+[INF]
lq=[int(input()) for _ in range(q)]
for i in lq:
    inds=bisect(ls,i)
    indt=bisect(lt,i)
    s1,s2=i-ls[inds-1],ls[inds]-i
    t1,t2=i-lt[indt-1],lt[indt]-i
    print(min(max(s1,t1),max(s2,t2),min(2*s1+t2,s1+2*t2),min(2*t1+s2,t1+2*s2)))
### BUGGY CODE ###

def kaiten(parts):
    _parts = []
    for i in range(len(parts)):
        _parts.append('L' if parts[-1-i] == 'R' else 'R')
    return _parts

def occurrences(string, sub):
    count = start = 0
    while True:
        start = string.find(sub, start) + 1
        if start > 0:
            count += 1
        else:
            return count

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

for _ in range(k):
    l = s.find('LR')
    r = s.find('RL', l)
    l2 = s.find('RL')
    r2 = s.find('LR', l2)
    _s = list(s)
    if 0 <= l and l < r:
        p = _s[l+1:r+1]
        _s[l+1:r+1] = kaiten(p)
    elif 0 <= l2 and l2 < r2:
        p = _s[l2+1:r2+1]
        _s[l2+1:r2+1] = kaiten(p)
    elif 0 <= l:
        p = _s[l+1:]
        _s[l+1:] = kaiten(p)
    elif 0 <= r:
        p = _s[:r+1]
        _s[:r+1] = kaiten(p)
    elif 0 <= l2:
        p = _s[l2+1:]
        _s[l2+1:] = kaiten(p)
    elif 0 <= r2:
        p = _s[:r2+1]
        _s[:r2+1] = kaiten(p)
    s = ''.join(_s)

score = occurrences(s, 'LL') + occurrences(s, 'RR')
print(score)


### FIXED CODE ###

n, k = map(int, input().split())
s = input()
h = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        h += 1
print(min(h + 2 * k, n - 1))
### BUGGY CODE ###

N, K = map(int, input().split())
H = list(map(int, input().split()))
dp = [float('inf')] * N
dp[0] = 0
for i in range(1, N):
    for j in range(1, K + 1):
        if i - j < 0:
            break
        dp[i] = min(dp[i], dp[i - j] + abs(H[i - j] - H[i]))
print(dp[N - 1])

### FIXED CODE ###

N, K, *H = map(int, open(0).read().split())
H.extend([float('inf')] * K)
dp = [float('inf')] * (N + K)
dp[0] = 0
for i, hi in enumerate(H[1:], 1):
    dp[i] = min(dp[i - k] + abs(H[i - k] - hi) for k in range(1, K + 1))
print(dp[N - 1])
### BUGGY CODE ###

n, a, b = map(int, input().split())
p=10**9+7
k = 1
for i in range(n):
  k = 2*k % p
N = k - 1

fact = [1]
k = 1
for i in range(1, 10**5+1):
    k = k*i%p
    fact.append(k)
    
def extgcd(a,b):
    r = [1,0,a]
    w = [0,1,b]
    while w[2]!=1:
        q = r[2]//w[2]
        r2 = w
        w2 = [r[0]-q*w[0],r[1]-q*w[1],r[2]-q*w[2]]
        r = r2
        w = w2
    return [w[0],w[1]]

def mod_inv(a,m):
    x = extgcd(a,m)[0]
    return (m+x%m)%m

def mod_e(n,p):
    res = 0
    while n >= p:
        res += n//p
        n = n//p
    return res

def mod_fact(n,p):
    if n==0:
        return 1
    res = mod_fact(n//p,p)
    
    if n//p %2 != 0:
        return res*(p-fact[n%p])%p
    return res*fact[n%p]%p

def mod_comb(n,k,p):
    a1 = mod_fact(n,p)
    a2 = mod_fact(k,p)
    a3 = mod_fact(n-k,p)
    return a1 * mod_inv(a2*a3%p,p) %p
  
A = mod_comb(n,a,p)
B = mod_comb(n,b,p)

if a == b:
  print((N-A) % p)
else:
  print((N-A-B) % p)

### FIXED CODE ###

def ncr(n, r, p): 
    num = den = 1 
    for i in range(r): 
        num = (num * (n - i)) % p 
        den = (den * (i + 1)) % p 
    return (num * pow(den, p - 2, p)) % p
  
p = 10**9+7
n,a,b = map(int,(input().split()))

bb = ncr(n,a,p)+ncr(n,b,p)+1
print((pow(2,n,p)-(bb%p))%p)
### BUGGY CODE ###

sentence_len, request_len = map(int, input().split())
sentence = input()
rule = 'AC'
for i in range(request_len):
    start, end = map(int, input().split())
    start, end = start-1, end
    target_sentence = sentence[start:end]
    answer = target_sentence.count(rule)
    print(answer)


### FIXED CODE ###

from itertools import accumulate

N, Q = map(int, input().split())
S = input()

t = [0] * N

for i in range(1, N):
    s = S[i - 1:i + 1]
    if s == 'AC':
        t[i] += 1

T = list(accumulate(t))

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

# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,x=MI()
lis=[LI() for i in range(n)]
lis.sort()
s=[]
for i in range(n):
    for j in range(n):
        for k in range(n):
            for l in range(n):
                xl=min(lis[i][0],lis[j][0])
                xu=max(lis[i][0],lis[j][0])
                yl=min(lis[k][1],lis[l][1])
                yu=max(lis[k][1],lis[l][1])
                count=0
                for m in range(n):
                    if xl<=lis[m][0]<=xu and yl<=lis[m][1]<=yu:
                        count+=1
                if count>=x:
                    s.append((xu-xl)*(yu-yl))
                    #print(i,j,k,l)
print(min(s))
                    

    
            
        
        
    

    
        
    
    
    

### FIXED CODE ###

# coding: utf-8
# hello worldと表示する
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=[LI() for i in range(n)]
lis.sort()
sq=[]
for i in range(n):
    for j in range(i+1,n+1):
        new_lis=lis[i:j]
        hor=new_lis[-1][0]-new_lis[0][0]
        #print(new_lis)
        if len(new_lis)<k:
            continue
        new_lis.sort(key=lambda x:x[1])
        #print(new_lis)
        u=len(new_lis)
        for i in range(u-k+1):
            sq.append(hor*(new_lis[i+k-1][1]-new_lis[i][1]))
#print(sq)
print(min(sq))