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

import collections
INF = 10**18
def bfs(starth,startw):
    d = [[-1]*w for i in range(h)]
    d[starth][startw] = 0
    q = collections.deque([])
    q.append((starth,startw))
    dx = [1,0,-1,0]
    dy = [0,1,0,-1]
    while q:
        p = q.popleft()
        nowh = p[0]
        noww = p[1]
        for i in range(4):
            nexth = nowh + dy[i]
            nextw = noww + dx[i]
            if 0<=nextw<w and 0<=nexth<h:
                if d[nexth][nextw] == -1 and li[nexth][nextw] != "#":
                    q.append([nexth,nextw])
                    d[nexth][nextw] = d[nowh][noww] + 1
    return d
h,w = map(int,input().split())
li = [list(input()) for i in range(h)]
cost = [[INF]*w for i in range(h)]
koho = []
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":
            koho.append([i,j])
for i in range(len(koho)):
    starth = koho[i][0]
    startw = koho[i][1]
    a = bfs(starth,startw)
    for j in range(h):
        for k in range(w):
            cost[j][k] = min(cost[j][k],a[j][k])

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

### FIXED CODE ###

import collections
INF = 10**18
h,w = map(int,input().split())
li = [list(input()) for i in range(h)]
koho = []
d = [[-1]*w for i in range(h)]
q = collections.deque([])
for i in range(h):
    for j in range(w):
        if li[i][j] == "#":
            d[i][j] = 0
            q.append([i,j])
dx = [1,0,-1,0]
dy = [0,1,0,-1]
while q:
    p = q.popleft()
    y = p[0]
    x = p[1]
    for i in range(4):
        nx = x + dx[i]
        ny = y + dy[i]
        if 0<=nx<w and 0<=ny<h:
            if d[ny][nx] == -1:
                q.append([ny,nx])
                d[ny][nx] = d[y][x] + 1
ans = -1
for i in range(h):
    for j in range(w):
        ans = max(ans,d[i][j])
print(ans)
### BUGGY CODE ###

import sys
N, K = map(int, input().split())
input = sys.stdin.readline
wd = [tuple(map(int, input().split())) for i in range(N)]
wd.sort()
d = 0
dp = [0]*N
l = 0
r = wd[0][0] + wd[0][1]*K
while(r - l > 1):
    tmp = (l+r)//2
    num = 0
    for w, d in wd:
        if w <= tmp:
            num += ((tmp - w) // d) + 1
    if num >= K:
        r = tmp
    else:
        l = tmp

print(r)


### FIXED CODE ###

import sys
N, K = map(int, input().split())
input = sys.stdin.readline
wd = [tuple(map(int, input().split())) for i in range(N)]
wd.sort()
d = 0
dp = [0]*N
l = 0
r = wd[0][0] + wd[0][1]*K
while(r - l > 1):
    tmp = (l+r)//2
    num = 0
    for w, d in wd:
        if w <= tmp:
            num += ((tmp - w) // d) + 1
    if num >= K:
        r = tmp
    else:
        l = tmp

print(r)
### BUGGY CODE ###

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

ans=[]
for i in range(1,n):
    x=sum(a[0:i])
    y=sum(a[i:])
    ans.append(abs(x-y))

print(min(ans))

### FIXED CODE ###

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

total=sum(a)

ans=[]
x=0
for i in range(n-1):
    x+=a[i]
    y=total-x
    ans.append(abs(x-y))

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

#055 B
import functools
import operator
prod = functools.partial(functools.reduce, operator.mul)

N = int(input())
lists = []
for i in range(1,N+1):
    lists.append(i)
ans = prod(lists)
print(ans%((10**9)+7))

### FIXED CODE ###

#055 B
N=int(input())
ans = 1
w = (10**9) +7
for i in range(1,N+1):
    ans *=i
    if ans >=w:
        ans %= w
print(ans)
### BUGGY CODE ###

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

B=[-1]*(N+1)

def make_buger(n):
  if n==0:
    return "P"
  elif B[n]!=-1:
    return B[n]
  else:
    if B[n-1]==-1:
      tmp=make_buger(n-1)
      B[n-1]=tmp
    else:
      tmp=B[n-1]
    tmp="B"+tmp+"P"+tmp+"B"
    B[n]=tmp
    return tmp
buger=make_buger(N)
print(buger[-X:].count("P"))


### FIXED CODE ###

N,X=map(int,input().split())
a=[1]
p=[1]
for i in range(N):
    a.append(a[i]*2+3)
    p.append(p[i]*2+1)

def f(n,x):
    if n==0:
        return 0 if x<=0 else 1
    if x<=a[n-1]+1:
        return f(n-1,x-1)
    return p[n-1]+f(n-1,x-a[n-1]-2)+1
print(f(N,X))
### BUGGY CODE ###

import math
N = int(input())
flag = False
for h in range(1, 3501, 1):
    for n in range(1, 3501, 1):
        bumbo = 4 * h * n - N * h - N * n
        bunshi = N * h * n
        if bumbo == 0:
            continue
        wc = math.ceil(bunshi / bumbo)
        wf = math.floor(bunshi / bumbo)
        if wc == wf and wc >= 1:
            ans_h = h
            ans_n = n
            ans_w = wc
            flag = True
            break
    if flag:
        break
print(ans_h, ans_n, ans_w)

### FIXED CODE ###

import math
N = int(input())
flag = False
for h in range(1, 3501, 1):
    for n in range(1, 3501, 1):
        bumbo = 4 * h * n - N * h - N * n
        bunshi = N * h * n
        if bumbo == 0:
            continue
        wc = math.ceil(bunshi / bumbo)
        wf = math.floor(bunshi / bumbo)
        if wc == wf and wc >= 1:
            ans_h = h
            ans_n = n
            ans_w = wc
            flag = True
            break
    if flag:
        break
print(ans_h, ans_n, ans_w)
### BUGGY CODE ###

from operator import mul
from functools import reduce
import copy
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
A = list(map(int,input().split()))
aset = set(A)
aDict = {}
for aName in aset:
    aDict.update({aName:0})
for a in A:
    aDict[a] += 1

for k in range(n):
    ans = 0
    aDict[A[k]] -= 1
    for i in aset:
        if aDict[i] == 1 or aDict[i] == 0:
            continue
        else:
            ans += cmb(aDict[i],2)
    print(ans)
    aDict[A[k]] += 1

### FIXED CODE ###

from operator import mul
from functools import reduce
import copy
def cmb(n,r):
    r = min(n-r,r)
    if r == 0: return 1
    over = reduce(mul, range(n, n - r, -1))
    under = reduce(mul, range(1,r + 1))
    return over // under

n = int(input())
A = list(map(int,input().split()))
aset = set(A)
aDict = {}
for aName in aset:
    aDict.update({aName:0})
for a in A:
    aDict[a] += 1

combNumDict = {}
sum = 0
for i in aset:
    if aDict[i] == 0 or aDict[i] == 1:
        tmpsum = 0
    else:
        tmpsum = cmb(aDict[i],2)
    combNumDict.update({i:tmpsum})
    sum += tmpsum
for i in range(n):
    k = A[i]
    if aDict[k] == 1:
        print(sum)
    else:
        if aDict[k] == 2:
            tmp = 1
        else:
            tmp = cmb(aDict[k],2)-cmb(aDict[k]-1,2)
        print(sum-tmp)
### BUGGY CODE ###

def binarySearch(A, head, tail, key):
	left = head
	right = tail - 1 # 探索範囲:[left, right]
	i = 0
	while left <= right:
		mid = (left + right) // 2
		if key == A[mid]:
			return mid
		elif key < A[mid]:
			right = mid - 1
			i = mid
		else:
			left = mid + 1
			i = mid + 1
	return i

if __name__ == "__main__":
	N = int(input())
	L = list(map(int, input().split()))
	L.sort()
	# print(L)
	sum = 0
	for a in range(N - 2):
		for b in range(a + 1, N - 1):
			key = L[a] + L[b]
			c = binarySearch(L, b + 1, N, key)
			# print(a, b, c, c - b - 1)
			sum += c - b - 1
	print(sum)

### FIXED CODE ###

from bisect import bisect_left

if __name__ == "__main__":
	N = int(input())
	L = list(map(int, input().split()))
	L.sort()
	# print(L)
	sum = 0
	for a in range(N - 2):
		for b in range(a + 1, N - 1):
			key = L[a] + L[b]
			i = bisect_left(L, key)
			# print(a, b, i, i - b)
			sum += i - b - 1
	print(sum)
### BUGGY CODE ###

from collections import deque

H, W = map(int, input().split())
m = [list(input()) for i in range(H)]
ans = 0
q = deque([(h, w, 0) for w in range(W) for h in range(H) if m[h][w] == "#"])
ql = q.popleft
qa = q.append

while q:
  h, w, c = ql()
  ans = max(ans, c)
  for dh, dw in ((-1, 0), (1, 0), (0, -1), (0, 1)):
    if 0 <= h+dh < H and 0 <= w+dw < W and m[h + dh][w + dw] == ".":
      m[h + dh][w + dw] = "#"
      qa((h+dh, w+dw, c+1))

print(ans)

### FIXED CODE ###

from collections import deque

H, W = map(int, input().split())
m = [list(input()) for i in range(H)]
ans = 0
q = deque()

for h in range(H):
  for w in range(W):
    if m[h][w] == "#":
      q.append((h, w, 0))

while q:
  h, w, c = q.popleft()
  ans = max(ans, c)
  for dh, dw in ((-1, 0), (1, 0), (0, -1), (0, 1)):
    if 0 <= h+dh < H and 0 <= w+dw < W and m[h + dh][w + dw] == ".":
      m[h + dh][w + dw] = "#"
      q.append((h+dh, w+dw, c+1))

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

from functools import reduce

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

y = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        y[i] += x & 1
        x = x >> 1

ans = 0
for i,yi in enumerate(y):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)


### FIXED CODE ###

words = lambda t : list(map(t, input().split()))
n = int(input())
xs = words(int)

ys = [0]*60
for x in xs:
    for i in range(60):
        if x == 0:
            continue
        ys[i] += x & 1
        x = x >> 1

ans = 0

for i,yi in enumerate(ys):
    ans += 2**(i) * yi * (n-yi)
    ans %= 10**9 + 7
print(ans)
### BUGGY CODE ###

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

lst=[r,g,b]
lst.sort()
r=lst[2]
g=lst[1]
b=lst[0]

rlim=n//r

blim=n//b

blist=[]
for i in range(blim+1):
    blist.append(i*b)


cnt=0
for i in range(rlim+1):
    glim=(n-i*r)//g
    for j in range(glim+1):
        if (n-i*r-j*g) in blist:
            cnt+=1
print(cnt)

### FIXED CODE ###

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

lst=[r,g,b]
lst.sort()
r=lst[2]
g=lst[1]
b=lst[0]

rlim=n//r
glim=n//g
blim=n//b

"""
blist = [i*b for i in range(blim+1)]

glist = [i*g for i in range(glim+1)]

def binary_search(list, item):
    low = 0
    high = len(list) - 1

    while low <= high:
        mid = (low + high) //2
        guess = list[mid]
        if guess == item:
            return True
        if guess > item:
            high = mid -1
        else:
            low = mid + 1
    return False
"""

cnt=0

for i in range(rlim+1):
    glim=(n-i*r)//g
    for j in range(glim+1):
        if (n-i*r-j*g)%b==0:
            cnt+=1
print(cnt)
### BUGGY CODE ###

def prime_table(n):
    list = [True for _ in xrange(n + 1)]
    i = 2
    while i * i <= n:
        if list[i]:
            j = i + i
        while j <= n:
            list[j] = False
            j += i
        i += 1

    table = [i for i in xrange(n + 1) if list[i] and i >= 2]
    return table

table = prime_table(10000)
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    
    l = [i for i in xrange(1,n+1)]
    r = l[::-1]
    ans = 0
    for j,k in zip(l,r):
        if j in table and k in table:
            ans += 1
    print ans

### FIXED CODE ###

def prime_table_boolean(n):
    list1 = [True for _ in xrange(n + 1)]
    i = 2
    while i * i <= n:
        if list1[i]:
            j = i + i
        while j <= n:
            list1[j] = False
            j += i
        i += 1
    list1[1] = False
    del list1[0]

    #table = [i for i in xrange(n + 1) if list1[i] and i >= 2]
    #return table
    return list1

table = prime_table_boolean(10001)
while True:
    try:
        n = int(raw_input())
    except EOFError:
        break
    
    l = table[:n]
    r = l[::-1]
    ans = 0
    for j,k in zip(l,r):
        if j and k:
            ans += 1
    print ans
### BUGGY CODE ###

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

for _ in range(m):
    num = a.index(max(a))
    a[num] = a[num] // 2

print(sum(a))


### FIXED CODE ###

# priority queueで楽勝だった
import heapq

n, m = map(int, input().split())
a = list(map(lambda x: int(x) * -1, input().split()))
heapq.heapify(a)

for _ in range(m):
    x = -(-a[0] // 2)
    heapq.heapreplace(a, x)
    #print(a)
print(sum(a) * -1)
### BUGGY CODE ###

n = int(input())
a = list(map(int, input().split()))
total = [0] * 31
for i in a:
    for j in range(31):
        if i >> j & 1:
            total[j] += 1
# print(total)
for i in a:
    ans = 0
    for j in range(31):
        if total[j] % 2 != (i >> j & 1):
            ans += 2 ** j
    print(ans, end=" ")
print()


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
total = [0] * 31
for i in a:
    for j in range(31):
        if i >> j & 1:
            total[j] += 1
# print(total)
for i in a:
    ans = 0
    for j in range(31):
        if total[j] % 2 != (i >> j & 1):
            ans += 2 ** j
    print(ans, end=" ")
print()
### BUGGY CODE ###

import sys

N, M = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
A.sort()
C = []

for _ in range(M):
    b, c = map(int, input().split())
    C.extend([c] * b)

C.sort(reverse=True)

res = 0
for i in range(N):
    if i < len(C):
        if A[i] < C[i]:
            res += C[i]
        else:
            res += A[i]
    else:
        res += A[i]
print(res)


### FIXED CODE ###

import sys

N, M = map(int, input().split())
A = list(map(int, sys.stdin.readline().rsplit()))
BC = [list(map(int, sys.stdin.readline().rsplit())) for _ in range(M)]
A.sort()
BC.sort(reverse=True, key=lambda x: x[1])
C = []

for b, c in BC:
    if len(C) >= N:
        break
    for _ in range(b):
        C.append(c)

C.sort(reverse=True)

res = 0
lenC = len(C)
for i in range(N):
    if i < lenC and A[i] < C[i]:
        res += C[i]
    else:
        res += A[i]
print(res)
### BUGGY CODE ###

import math
import collections
import sys

input = sys.stdin.readline
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)]

n=I()
s=input()
r=[]
g=[]
t=[]
for i in range(n):
    if s[i:i+1]=="R":
        r.append(i)
    elif s[i:i+1]=="G":
        g.append(i)
    else:
        t.append(i)
R=len(r)
G=len(g)
ans=R*G*(n-R-G)
for a in r:
    for b in g:
        if 2*b-a in t:
            ans-=1
        if 2*a-b in t:
            ans-=1
        if (a+b)%2==0 and (a+b)//2 in t:
            ans-=1
print(ans)

### FIXED CODE ###

import math
import collections
import sys

input = sys.stdin.readline
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)]

n=I()
s=input()
r=[]
g=[]
t=[]
for i in range(n):
    if s[i:i+1]=="R":
        r.append(i)
    elif s[i:i+1]=="G":
        g.append(i)
    else:
        t.append(i)
R=len(r)
G=len(g)
T=n-R-G
ans=R*G*T
for i in range(n-1):
    for j in range(i+1,n):
        if s[i]!=s[j]:
            if j<2*i-j<=n-1:
                if s[i]!=s[2*i-j] and s[j]!=s[2*i-j]:
                    ans-=1
            if j<2*j-i<=n-1:
                if s[i]!=s[2*j-i] and s[j]!=s[2*j-i]:
                    ans-=1
            if (i+j)%2==0 and j<(i+j)//2 and s[i]!=s[(i+j)//2] and s[j]!=s[(i+j)//2]:
                ans-=1
print(ans)
### BUGGY CODE ###

import sys
import numpy as np
import itertools

input = sys.stdin.readline

N,K = map(int, input().split())
lst_A = np.array(list(map(int, input().split())))

ans = 0
for i in list(itertools.combinations([j for j in range(N)], K)):
	S = lst_A[list(i)]
	ans += max(S)%((10**9)+7)-min(S)

print((ans)% 1000000007)

### FIXED CODE ###

import sys
input = sys.stdin.readline

def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

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

p = 10 ** 9 + 7
fact = [1, 1]
factinv = [1, 1]
inv = [0, 1]
 
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)


fmax = 0
fmin = 0
for i in range(N):
	if(K-1<=N-1-i):
		fmin += lst_A[i] * cmb(N-i-1, K-1,p)
	if(i>=K-1):
		fmax += lst_A[i] * cmb(i,K-1,p)

print((fmax-fmin)% p)
### BUGGY CODE ###

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

ans = 0
sum_rslt = [[0] * n for i in range(n)]
sum_rslt[0] = a_list

xor_rslt = [[0] * n for i in range(n)]
xor_rslt[0] = a_list


for i in range(1, n):
  for j in range(0, n - i):
    sum_rslt[i][j] = sum_rslt[i-1][j] + sum_rslt[0][j+i]
    xor_rslt[i][j] = xor_rslt[i-1][j] ^ xor_rslt[0][j+i]

for i in range(0, n):
  for j in range(0, n - i):
      if (sum_rslt[i][j] == xor_rslt[i][j]):
         # print("l:" + str(j + 1), "r:" + str(i + 1))
          ans = ans + 1

print(ans)

### FIXED CODE ###

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

ans = 0
sum = 0

left = 0
right = 0

while(left < n):
    while(right < n and (sum ^ a[right] == sum + a[right])):
        sum = sum + a[right]
        right = right + 1

    ans = ans + right - left
    if(left == right):
        right = right + 1
    else:
        sum = sum - a[left]

    left = left + 1

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

def move_mass(h_list, h_moved_flag):
  for index in range(0,n-1):
    if h_list[index] > h_list[index+1] and h_moved_flag[index] is False:
      h_list[index] = h_list[index]-1
      h_moved_flag[index] = True
  return h_list, h_moved_flag
################################
n = int(input())
if n == 1:
  print("Yes")
  exit()

h_list = [int(h) for h in input().split()]
h_moved_flag = [False for i in range(n)]
for index in range(1000):
  h_list, h_moved_flag = move_mass(h_list, h_moved_flag)
  
  not_dec_flag = False
  for index in range(0,n-1):
    if h_list[index] > h_list[index+1]:
      not_dec_flag = True
  
  if not_dec_flag == False:
    print("Yes")
    exit()
print("No")

### FIXED CODE ###

from heapq import heappop, heappush
import sys
input = sys.stdin.readline

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

for i in range(1,N):
  dif = H[i] - H[i-1]
  if dif >= 0: continue
  elif dif == -1: H[i] += 1
  else:
    print('No')
    exit()
print('Yes')
### BUGGY CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
import numpy as np

N = INT()
S = list(input())

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


A = list(range(len(S)))
cnt = 0
for x, y in combinations(A, 2):
	if (x+y)//2 == (x+y)/2:
		z = (x+y)//2
		if S[x] != S[y] and S[x] != S[z] and S[y] != S[z]:
			cnt += 1

print(r*g*b-cnt)

### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7
 
N = INT()
S = list(input())
 
r = S.count("R")
g = S.count("G")
b = S.count("B")
 
 
A = list(range(len(S)))
cnt = 0
for x, y in combinations(A, 2):
	if (x+y)//2 == (x+y)/2:
		z = (x+y)//2
		if S[x] != S[y] and S[x] != S[z] and S[y] != S[z]:
			cnt += 1
 
print(r*g*b-cnt)
### BUGGY CODE ###

import time

nk = [int(x) for x in raw_input().strip().split()]
d = []
for i in range(nk[0]):
    d_tmp = raw_input().strip().split()
    d.append([int(d_tmp[0]), int(d_tmp[1]), int(d_tmp[2] == 'B')])

n1 = nk[0]
k1 = nk[1]

check_x = [0] * n1 * 4
check_y = [0] * n1 * 4
for i in range(n1):
    check_x[i * 4] = d[i][0] - k1
    check_x[i * 4 + 1] = d[i][0] - k1 + 1
    check_x[i * 4 + 2] = d[i][0]
    check_x[i * 4 + 3] = d[i][0] + 1
    check_y[i * 4] = d[i][1] - k1
    check_y[i * 4 + 1] = d[i][1] - k1 + 1
    check_y[i * 4 + 2] = d[i][1]
    check_y[i * 4 + 3] = d[i][1] + 1

#d = tuple(d)
n = 0
#t = time.clock()
for i in check_x:
    for j in check_y:
        n_tmp = [0, 0]
        for k in range(n1):
            x = (d[k][0] - i) // k1 % 2
            y = (d[k][1] - j) // k1 % 2
#            if x == y:
#                n_tmp[1 - d[k][2]] += 1
#            else:
#                n_tmp[d[k][2]] += 1
            n_tmp[(x == y) ^ d[k][2]] += 1
        if n_tmp[0] > n:
            n = n_tmp[0]
        if n_tmp[1] > n:
            n = n_tmp[1]
#print time.clock() - t
print n


### FIXED CODE ###

import numpy as np

def getBoundary(p, k, k2):
    if p - k + 1 >= 0:
        return [(p - k + 1, p + 1)]
    else:
        return [(0, p + 1), ((p - k + 1) % k2, k2)]

n, k = map(int, input().strip().split())
k2 = k * 2
b = [[0 for i in range(k2 + 1)] for j in range(k2 + 1)]

for i in range(n):
    x_str, y_str, c_str = input().strip().split()
    x = int(x_str) % k2
    y = (int(y_str) + (c_str == 'B') * k) % k2
    for xb, xe in getBoundary(x % k2, k, k2):
        for yb, ye in getBoundary(y % k2, k, k2):
            b[xb][yb] += 1
            b[xb][ye] -= 1
            b[xe][yb] -= 1
            b[xe][ye] += 1
    for xb, xe in getBoundary((x + k) % k2, k, k2):
        for yb, ye in getBoundary((y + k) % k2, k, k2):
            b[xb][yb] += 1
            b[xb][ye] -= 1
            b[xe][yb] -= 1
            b[xe][ye] += 1

arr_b = np.array(b)
for i in range(k2):
    arr_b[i + 1] += arr_b[i]
for j in range(k2):
    arr_b[:, j + 1] += arr_b[:, j]
print(arr_b.max())
### BUGGY CODE ###

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    temp_list = []
    count = 0
    is_ongoing = True
    while is_ongoing:
        for a in a_list:
            if a % 2 == 0:
                temp_list.append(a/2)
            else:
                is_ongoing = False
                print(count)
                break
        else:
            count += 1
        a_list = temp_list[:]


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n = int(input())
    a_list = list(map(int, input().split()))

    # temp_list = []
    count = 0
    is_ongoing = True
    while is_ongoing:
        for i, a in enumerate(a_list):
            if a % 2 == 0:
                # temp_list.append(a/2)
                a_list[i] /= 2
            else:
                is_ongoing = False
                print(count)
                break
        else:
            count += 1
        # a_list = temp_list[:]


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

n, k=[int(x) for x in input().split()]
a=input().split()
s=set(a)
d={}
for i in s:
  d[i]=a.count(i)
p=len(s)-k
if p<=0:
  print("0")
  exit()
d=sorted(d.items(), key=lambda x:x[1])
r=0
for i in range(p):
  r+=d[i][1]
print(r)

### FIXED CODE ###

n, k=[int(x) for x in input().split()]
a=[int(x) for x in input().split()]
d={i:0 for i in set(a)}
for i in a: d[i]+=1
print(n-sum([t[1] for t in sorted(d.items(), key=lambda x:-x[1])][:k]))
### BUGGY CODE ###

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

d = 0
ans = 0
for i in range(1, N+1):
    d = math.floor((A*i)/B) - A*math.floor(i/B)
    if ans <d:
        ans = d

print(ans)

### FIXED CODE ###

import math

A, B, N = map(int, input().split())
print(math.floor((A * min(B-1, N)) / B) - A * math.floor(min(B-1, N) / B))