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

import sys
from collections import defaultdict

input = sys.stdin.readline


class AtCoder:
    def main(self):
        H, W = map(int, input().split())
        A = [list(input().rstrip()) for _ in range(H)]

        blacks = []
        for h in range(H):
            for w in range(W):
                if A[h][w] == '#':
                    blacks.append((h + 1, w + 1))

        moving_range = ((1, 0), (-1, 0), (0, -1), (0, 1))

        ans = 0
        while blacks:
            next_blacks = []
            for b_h, b_w in blacks:
                for m_h, m_w in moving_range:
                    h, w = b_h + m_h, b_w + m_w
                    if not (0 < h <= H and 0 < w <= W):
                        continue
                    if A[h-1][w-1] == '.':
                        A[h-1][w-1] = '#'
                        next_blacks.append((h, w))
            if len(next_blacks) > 0:
                ans += 1
            blacks = next_blacks

        print(ans)


# Run main
if __name__ == '__main__':
    AtCoder().main()


### FIXED CODE ###

import sys
from collections import defaultdict

input = sys.stdin.readline


class AtCoder:
    def main(self):
        H, W = map(int, input().split())
        A = [list(input().rstrip()) for _ in range(H)]

        blacks = []
        for h in range(H):
            for w in range(W):
                if A[h][w] == '#':
                    blacks.append((h + 1, w + 1))

        moving_range = ((1, 0), (-1, 0), (0, -1), (0, 1))

        ans = 0
        while blacks:
            next_blacks = []
            for b_h, b_w in blacks:
                for m_h, m_w in moving_range:
                    h, w = b_h + m_h, b_w + m_w
                    if not (0 < h <= H and 0 < w <= W):
                        continue
                    if A[h-1][w-1] == '.':
                        A[h-1][w-1] = '#'
                        next_blacks.append((h, w))
            if len(next_blacks) > 0:
                ans += 1
            blacks = next_blacks

        print(ans)


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

N = int(input())
high = [int(x) for x in input().split()]

top = 0

for i in range(N):
    challenge = True
    count = 0

    while challenge == True and i < N-1:
        if high[i] >= high[i+1]:
            count += 1
            if i < N-1:
                i += 1
        else:
            challenge = False
    
    if top < count:
        top = count

print(top)


### FIXED CODE ###

N = int(input())
high = [int(x) for x in input().split()]

top = 0
count = 0

for i in range(N):
    challenge = True
    
    if count > 0:
        count -= 1
    else:
        while challenge == True and i < N-1:
            if high[i] >= high[i+1]:
                count += 1
                if i < N-1:
                    i += 1
            else:
                challenge = False
        
        if top < count:
            top = count

print(top)
### BUGGY CODE ###

def main():
    N, K = list(map(int, input().split()))
    H = list(map(int, input().split()))

    INF = float('inf')

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

    for i in range(N):
        for dist in range(1, min(K, i) + 1):
            c = dp[i - dist] + abs(H[i] - H[i - dist])
            if c < dp[i]:
                dp[i] = c

    print(dp[-1])


if __name__ == '__main__':
    main()


### FIXED CODE ###

import numpy as np


def main():
    N, K = list(map(int, input().split()))
    H = np.array(list(map(int, input().split())))

    INF = float('inf')

    dp = np.array([INF for _ in range(N)])
    dp[0] = 0

    for i in range(1, N):
        max_dist = min(K, i)
        dp[i] = np.min(dp[i - max_dist:i] + np.abs(H[i] - H[i - max_dist:i]))

    print(int(dp[-1]))


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

h, w, d = [int(item) for item in input().split()]
a = [[int(item) for item in input().split()] for _ in range(h)]
q = int(input())
lr = [[int(item) for item in input().split()] for _ in range(q)]

size = h * w
dist = [[0] * ((size)//d + 1) for _ in range(d)]

def get_dist(x, y):
  for i, line in enumerate(a):
    if x in line:
      xid = [i, line.index(x)]
    if y in line:
      yid = [i, line.index(y)]
  distance = abs(xid[0] - yid[0]) + abs(xid[1] - yid[1])
  return distance

for i in range(d):
  for j in range((size)//d + 1):
    if (j-1)*d+i <= 0:
      continue
    if j*d + i > size:
      continue
    dist[i][j] = dist[i][j-1] + get_dist(j*d+i, (j-1)*d+i)

for l, r in lr:
  print(dist[r%d][r//d] - dist[l%d][l//d])
    

### FIXED CODE ###

h, w, d = [int(item) for item in input().split()]
a = [[int(item) for item in input().split()] for _ in range(h)]
q = int(input())
lr = [[int(item) for item in input().split()] for _ in range(q)]

size = h * w
dist = [[0] * ((size)//d + 1) for _ in range(d)]
ilist = [0] * (size+1)
jlist = [0] * (size+1)

for i in range(h):
  for j in range(w):
    ilist[a[i][j]] = i
    jlist[a[i][j]] = j

def get_dist(x, y):
  distance = abs(ilist[x] - ilist[y]) + abs(jlist[x] - jlist[y])
  return distance

for i in range(d):
  for j in range((size)//d + 1):
    if (j-1)*d+i <= 0 or j*d + i > size:
      continue
    dist[i][j] = dist[i][j-1] + get_dist(j*d+i, (j-1)*d+i)

for l, r in lr:
  print(dist[r%d][r//d] - dist[l%d][l//d])
### BUGGY CODE ###

def to_bit(n):
	ret = [0 for i in range(12)]
	i = 0
	while n > 1:
		ret[i] = n % 2
		n = n // 2
	return ret

def to_int(B):
	return sum([B[i] * 2**i for i in range(12)])

N,M = map(int,input().split())
key = []
for i in range(M):
	a,b = map(int,input().split())
	c = list(map(int,input().split()))
	C = [0 for x in range(12)]
	for x in c:
		C[x-1] = 1
	key.append((a, to_int(C)))
dp = [[-1 if j > 0 else 0 for j in range(2**N)] for i in range(M)]
dp[0][key[0][1]] = key[0][0]
for i in range(M-1):
	cost = key[i+1][0]
	bit = key[i+1][1]
	for j in range(2**N):
		if dp[i][j] >= 0:
			if dp[i+1][j] == -1:
				dp[i+1][j] = dp[i][j]
			else:
				dp[i+1][j] = min(dp[i+1][j], dp[i][j])
			I = i+1
			J = j | bit
			if dp[I][J] == -1:
				dp[I][J] = dp[i][j] + cost
			else:
				dp[I][J] = min(dp[I][J], dp[i][j] + cost)
print(dp[M-1][2**N-1])

### FIXED CODE ###

def to_bit(n):
	ret = [0 for i in range(12)]
	i = 0
	while n > 1:
		ret[i] = n % 2
		n = n // 2
	return ret

def to_int(B):
	return sum([B[i] * 2**i for i in range(12)])

N,M = map(int,input().split())
key = []
for i in range(M):
	a,b = map(int,input().split())
	c = list(map(int,input().split()))
	C = [0 for x in range(12)]
	for x in c:
		C[x-1] = 1
	key.append((a, to_int(C)))
dp = [[-1 if j > 0 else 0 for j in range(2**N)] for i in range(M)]
dp[0][key[0][1]] = key[0][0]
for i in range(M-1):
	cost = key[i+1][0]
	bit = key[i+1][1]
	for j in range(2**N):
		if dp[i][j] >= 0:
			if dp[i+1][j] == -1:
				dp[i+1][j] = dp[i][j]
			else:
				dp[i+1][j] = min(dp[i+1][j], dp[i][j])
			I = i+1
			J = j | bit
			if dp[I][J] == -1:
				dp[I][J] = dp[i][j] + cost
			else:
				dp[I][J] = min(dp[I][J], dp[i][j] + cost)
print(dp[M-1][2**N-1])
### BUGGY CODE ###

from itertools import combinations

def triangle_exists(a, b, c):
    return ((a < b + c) and 
            (b < c + a) and
            (c < a + b))

def main():
    N = int(input())
    L = list(map(int, input().split()))

    ans = 0
    for a,b,c in combinations(L, 3):
        if triangle_exists(a, b, c):
            ans += 1
    print(ans)

main()

### FIXED CODE ###

from bisect import bisect_left, bisect_right

def main():
    N = int(input())
    L = sorted(list(map(int, input().split())))

    ans = 0
    for ia in range(N):
        for ib in range(ia+1, N-1):
            a = L[ia]
            b = L[ib]

            c_min = max(a-b, b-a)
            c_max = a + b
            ic_begin = bisect_right(L, c_min, lo=ib+1)
            ic_end   = bisect_left( L, c_max, lo=ib+1)

            ans += ic_end - ic_begin

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

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

i = 1
for a_s in a:
    print(a.index(i)+1)
    i += 1


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split(" ")))
dic = {}
i = 0
for a_s in a:
    dic.setdefault(i, a_s)
    i += 1
for k, v in sorted(dic.items(), key=lambda x: x[1]):
    print(k + 1)
### BUGGY CODE ###

#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP
import numpy as np
L = int(input())
A = [int(input()) for i in range(L)]

DP = np.zeros(5, dtype = int)

def cost(a:int) -> np.array:
    if a:
        return np.array([a,a%2,(a+1)%2,a%2,a])
    else:
        return np.array([0,2,1,2,0])

for i in range(L):
    n  = np.array([np.min(DP[:i+1]) for i in range(5)])
    DP = n + cost(A[i])

print(np.min(DP))

### FIXED CODE ###

#https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_d
#2019-02-10

#DP

L = int(input())
A = [int(input()) for i in range(L)]

DP = [[float("inf") for i in range(5)] for j in range(L+1)]
for i in range(5):
    DP[0][i] = 0

def cost(s, i, A):
    if s == 0 or s == 4:
        return A[i]
    elif s == 1 or s == 3:
        if A[i] > 0:
            if A[i]%2 == 0:
                return 0
            else:
                return 1
        else:
            return 2
    else:
        if A[i]%2 == 1:
            return 0
        else:
            return 1

for i in range(L):
    for j in range(5):
        for k in range(j,5):
            DP[i+1][k] = min(DP[i+1][k], DP[i][j]+ cost(k, i, A))



print(min(DP[L]))
### BUGGY CODE ###

def calc(b,A):
  ret=0
  for i,num in enumerate(A):
    ret += abs( num-(b+i+1) )
  return ret    
##########################

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

L=-1*10**9
R=10**9
i=(L+R)//2

while True:
  s=calc(i-1,A)
  t=calc(i,A)
  u=calc(i+1,A)
  if s<t<u:
    R=i
    i=(L+R)//2
  elif s>t>u:
    L=i
    i=(L+R)//2
  else:
    print(t)
    break

### FIXED CODE ###

def calc(b,A):
  ret=0
  for i,num in enumerate(A):
    ret += abs( num-(b+i+1) )
  return ret    
##########################

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

L=-1*10**9
R=10**9
i=(L+R)//2

while True:
  s=calc(i-1,A)
  t=calc(i,A)
  u=calc(i+1,A)
  if s<t<u:
    R=i
    i=(L+R)//2
  elif s>t>u:
    L=i
    i=(L+R)//2
  else:
    print(t)
    break
### BUGGY CODE ###

N = int(input())
s = []
l_cnt = []
for i in range(N):
  s.append(input())
list_dic = []
for i in range(N):
  se = set(s[i])
  dic = {}
  for sei in se:
    dic[sei] = 0
  for sii in s[i]:
    dic[sii] += 1
  flag = False
  for dic_mir in list_dic:
    if dic == dic_mir:
      flag = True
  if flag == True:
    l_cnt[list_dic.index(dic)] += 1
  else:
    list_dic.append(dic)
    l_cnt.append(0)
ans = 0
for cnt in l_cnt:
  ans += cnt * (cnt+1) // 2
print(ans)

### FIXED CODE ###

N = int(input())
s = []
l_cnt = []
for i in range(N):
  s.append(''.join(sorted(input())))

dic = {}
for x in s:
  if dic.get(x) == None:
    dic[x] = 1
  else:
    dic[x] += 1

print(sum(map(lambda n: n*(n-1)//2,list(dic.values()))))
### BUGGY CODE ###

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

s = input().strip()

def dfs(start, remain):
    if len(remain) == 0:
        return 1
    else:
        ans = 0
        for i in range(1, len(remain)+1):
            if start == remain[:i]:
                continue
            else:
                ans = max(ans, 1 + dfs(remain[:i], remain[i:]))
        return ans

ans = 0
if len(s) == 1:
    print(ans)
    sys.exit(0)
for i in range(1, len(s)):
    ans = max(ans, dfs(s[:i], s[i:]))
print(ans)


### FIXED CODE ###

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

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

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

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

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

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


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

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

# coding:utf-8
# Doubly Linked List

class DLL:

    def __init__(self):
        self.array = []

    def insert(self, x):
        self.array = [x] + self.array
    
    def delete(self, x):
        if x in self.array:
            del self.array[self.array.index(x)]

    def deleteFirst(self):
        del self.array[0]

    def deleteLast(self):
        del self.array[len(self.array)-1]


def main():

    dll = DLL()
    n = int(input())
    ans = ""

    for _ in range(n):
        operation = input().split()
        command = operation[0]
        if command in ["insert", "delete"]:
            key = operation[1]
            eval("dll." + command + '(' + key + ')')

        else:
            eval("dll." + command + "()")
    for value in dll.array:
        ans += str(value) + " "

    print(ans.rstrip())

if __name__ == "__main__":
    main()

### FIXED CODE ###

# coding:utf-8
# Doubly Linked List

from collections import deque

def main():

    n = int(input())
    dll = deque()

    for _ in range(n):
        operation = input().split(' ')
        if operation[0] in ["insert", "delete"]:
            key = operation[1]
            if operation[0] == "insert":
                dll.appendleft(key)
            else:
                try:
                    dll.remove(key)
                except:
                    pass

        else:
            if operation[0][6] == 'F':
                dll.popleft()

            else:
                dll.pop()

    print(' '.join(dll))

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

N = int(input())
A = [int(n) for n in input().split()]

for n in range(0, N):
    cnt = 0
    for a in A:
        if n + 1 == a:
            cnt = cnt + 1
    print(cnt)

### FIXED CODE ###

from collections import defaultdict
N = int(input())
A = [int(n) for n in input().split()]

d = defaultdict(int)
for i in A:
    d[i-1] += 1
for n in range(N):
    print(d[n])
### BUGGY CODE ###

N = int(input())
Ss = input()
Q = int(input())
ks = list(map(int, input().split()))

anss = []
for k in ks:
    numD = numM = numDM = numDMC = 0
    for i, S in enumerate(Ss):
        if S == 'D':
            numD += 1
        elif S == 'M':
            numM += 1
            numDM += numD
        elif S == 'C':
            numDMC += numDM

        if i >= k-1:
            S = Ss[i-k+1]
            if S == 'D':
                numD -= 1
                numDM -= numM
            elif S == 'M':
                numM -= 1
            elif S == 'C':
                pass

    anss.append(numDMC)

print('\n'.join(map(str, anss)))


### FIXED CODE ###

def solve():
    N = int(input())
    Ss = input()
    Q = int(input())
    ks = list(map(int, input().split()))

    anss = []
    for k in ks:
        numD = numM = numDM = numDMC = 0
        for i in range(N):
            S = Ss[i]
            if S == 'D':
                numD += 1
            elif S == 'M':
                numM += 1
                numDM += numD
            elif S == 'C':
                numDMC += numDM

            if i >= k-1:
                S = Ss[i-k+1]
                if S == 'D':
                    numD -= 1
                    numDM -= numM
                elif S == 'M':
                    numM -= 1

        anss.append(numDMC)

    print('\n'.join(map(str, anss)))


solve()
### BUGGY CODE ###

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

for i in range(N):
    popX = X.pop(i)
    Xsort = sorted(X)
    print(Xsort[(N-1)//2])
    X.insert(i,popX)

### FIXED CODE ###

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

X_sort = sorted(X)

mid_r = X_sort[N//2]
mid_l = X_sort[N//2-1]

for i in range(N):
    if X[i] <= mid_l:
        print(mid_r)
    else:
        print(mid_l)
### BUGGY CODE ###

S = input()
N = len(S)
m = 10**9 + 7

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

for i in range(N):
    for j in range(13):
        digit = S[N-1-i]
        if digit == '?':
            for k in range(10):
                d = (j+k*pow(10,i,13)%13)%13
                dp[i+1][d] += dp[i][j]
                dp[i+1][d] %= m

        else:
            k = int(digit)
            d = (j+k*pow(10,i,13)%13)%13
            dp[i+1][d] += dp[i][j]
            dp[i+1][d] %= m
print(dp[N][5])

### FIXED CODE ###

#!/usr/bin/env python3
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right

def main():
    S = input()
    N = len(S)
    p = 10**9 + 7
    dp = [[0]*13 for _ in range(N+1)]
    dp[0][0] = 1

    for i in range(N):
        if S[i] == '?':
            for j in range(13):
                for k in range(10):
                    dp[i+1][(10*j+k)%13] += dp[i][j]
                    dp[i+1][(10*j+k)%13] %= p
        else:
            s = int(S[i])
            for j in range(13):
                dp[i+1][(10*j+s)%13] = dp[i][j]
    print(dp[N][5])
    

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

import sys

sys.setrecursionlimit(100000000)


# p:parent
def bfs(g: {}, v: int, p: int, depth: int, dd: {}):
    d_v = dd.setdefault(v, [])
    d_v.append((p, depth))

    if v in g.keys():
        for next_v in g[v]:
            # next_v が親だったらスルー
            if next_v == p:
                continue
            # 再帰的に探索
            bfs(g, next_v, v, depth + 1, dd)


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

    children = set()
    g = {}
    parent_g = {}
    for i in range(n - 1 + m):
        a, b = map(int, input().split())
        dic_a = g.setdefault(a - 1, [])
        dic_a.append(b - 1)
        children.add(b - 1)
        dic_b = parent_g.setdefault(b - 1, [])
        dic_b.append(a - 1)

    root = -1
    for i in range(n):
        if i not in children:
            root = i
            break
    parent = -1
    depth = 0
    dd = {}
    bfs(g, root, parent, depth, dd)

    for i in range(n):
        v = dd[i]
        if len(v) == 1:
            print(v[0][0]+1)
            continue

        v.sort(key=lambda x: x[1], reverse=True)
        print(v[0][0]+1)



main()


### FIXED CODE ###

import sys
import collections

sys.setrecursionlimit(100000000)


# p:parent
def bfs(g: {}, parent_g: {}, v: int, p: int, depth: int, dd: {}, dq):
    p_ls = parent_g.setdefault(v, [])
    if len(p_ls) > 1:
        p_ls.remove(p)
        return
    dd[v] = (p, depth)

    ls = g.setdefault(v, [])
    for next_v in ls:
        # next_v が親だったらスルー
        if next_v == p:
            continue
        # 探索キューに追加
        dq.append((next_v, v, depth+1))


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

    children = set()
    g = {}
    parent_g = {}
    for i in range(n - 1 + m):
        a, b = map(int, input().split())
        dic_a = g.setdefault(a - 1, [])
        dic_a.append(b - 1)
        children.add(b - 1)
        dic_b = parent_g.setdefault(b - 1, [])
        dic_b.append(a - 1)

    root = -1
    for i in range(n):
        if i not in children:
            root = i
            break
    parent = -1
    depth = 0
    dd = {}

    dq = collections.deque()
    dq.append((root, parent, depth))
    while len(dq) > 0:
        t, p, d = dq.popleft()
        bfs(g, parent_g, t, p, d, dd, dq)

    for i in range(n):
        print(dd[i][0] + 1)
        # if len(v) == 1:
        #     print(v[0][0]+1)
        #     continue
        #
        # v.sort(key=lambda x: x[1], reverse=True)
        # print(v[0][0]+1)



main()
### BUGGY CODE ###

n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n>=m:
    print(0)
else:
    l=[]
    r=[]
    for i in range(m-1):
        l.append(x[i+1]-x[i])
    ll=sorted(l,reverse=True)
    for i in range(n-1):
        r.append(ll.pop(0))
    print(x[m-1]-x[0]-(sum(r)))


### FIXED CODE ###

n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n>=m:
    print(0)
else:
    l=[]
    r=[]
    for i in range(m-1):
        l.append(x[i+1]-x[i])
    ll=sorted(l,reverse=True)
    for i in range(n-1):
        r.append(ll.pop(0))
    print(x[m-1]-x[0]-(sum(r)))
### BUGGY CODE ###

MOD = 10**9+7
N,M = map(int,input().split())
a = [int(input()) for _ in range(M)]
ans = [1,0] if (1 in a) else [1,1]
for i in range(1,N):
  if i+1 in a:
    ans.append(0)
  else:
    ans.append(ans[i-1]+ans[i])
print(ans[N]%MOD)

### FIXED CODE ###

import bisect
def f(x,a):
  global M
  b = bisect.bisect_left(a,x)
  if x==a[min(b,M)]:
    return True
  else:
    return False
MOD = 10**9+7
N,M = map(int,input().split())
a = [-1]+[int(input()) for _ in range(M)]
a.sort()
x = 0
y = 1
for i in range(N):
  if f(i,a) and f(i+1,a):
    print(0)
    exit()
  elif f(i+1,a):
    z = 0
  else:
    z = x + y
  x = y
  y = z
print(z%MOD)
### BUGGY CODE ###

N = int(input())
A = list(map(int,input().split()))
ls = []
k = 0
for i in range(N):
    k = A.index(i+1)+1
    ls.append(k)
print(*ls)

### FIXED CODE ###

N = int(input())
A = list(map(int,input().split()))
ls = [0]*N
for i in range(N):
    ls[A[i]-1] = i+1
print(*ls)
### BUGGY CODE ###

n, k = map(int, input().split())
A = list(map(int, input().split()))
B = []
for i in set(A):
    B.append(A.count(i))
B.sort()
print(sum(B[:len(set(A)) - k]))

### FIXED CODE ###

from collections import Counter
n, k = map(int, input().split())
A = list(map(int, input().split()))
AD = sorted(list(Counter(A).values()))
print(sum(AD[:len(AD) - k]))
### BUGGY CODE ###

n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()

ends = []
start = 0
for base in range(n):
    for start, (x, _) in enumerate(xh[start:], start):
        if x > xh[base][0] + 2 * d:
            # start -= 1 # in range
            break
    else:
        start = n
    ends.append(start)
#     print(start)
# print(ends)

cnt = [0] * (n + 1)

hist = 0
ans = 0
for i, end in enumerate(ends):
    hist += cnt[i]
    atk = (max(0, xh[i][1] - hist * a) + a - 1) // a
    # print(atk, "atk", hist, end=" ")
    ans += atk
    hist += atk

    cnt[i] += atk
    cnt[end] -= atk
    # print(":", cnt)

print(ans)
# print(cnt)
#
# import functools
# import operator
# print(functools.reduce(operator.add, cnt[:-1]), ans)


### FIXED CODE ###

n, d, a = map(int, input().split())
xh = [list(map(int, input().split())) for _ in range(n)]

xh.sort()

ends = [None] * n
start = 0
# loop = 0
d2 = 2 * d
for base in range(n):
    while True:
        if start >= n:
            break

        x = xh[start][0]
        # loop += 1
        if x > xh[base][0] + d2:
            # start -= 1 # in range
            break
        start += 1
    # for start, (x, _) in enumerate(xh[start:], start):
    #     loop += 1
    #     if x > xh[base][0] + 2 * d:
    #         # start -= 1 # in range
    #         break
    # else:
    #     start = n
    ends[base] = start
#     print(start)
# print(ends)
# print(loop, "loop")

cnt = [0] * (n + 1)

hist = 0
ans = 0
for i, end in enumerate(ends):
    hist += cnt[i]
    atk = (max(0, xh[i][1] - hist * a) + a - 1) // a
    # print(atk, "atk", hist, end=" ")
    ans += atk
    hist += atk

    cnt[i] += atk
    cnt[end] -= atk
    # print(":", cnt)

print(ans)
# print(cnt)
#
# import functools
# import operator
# print(functools.reduce(operator.add, cnt[:-1]), ans)
### BUGGY CODE ###

def resolve():
    A, B, C = list(map(int, input().split()))
    ans = 10 * 10
    for h in range(1, B):
        ans = min(ans, abs(2 * h * A * C - A * B*C))
    for w in range(1, A):
        ans = min(ans, abs(2 * h * A * B - A * B*C))

    print(ans)
    return


resolve()

### FIXED CODE ###

def resolve():
    A, B, C = list(map(int, input().split()))
    ans = ''
    if A % 2 == 0 or B % 2 == 0 or C % 2 == 0:
        ans = 0
    else:
        ans = min(B * C, C * A, A * B)

    print(ans)
    return


resolve()