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

import copy
H, W = map(int, input().split())
M = [list(input()) for _ in range(H)]

black = []
for i in range(H):
  for j in range(W):
    if M[i][j] == '#':
      black.append((i, j))
ans = 0
while True:
  ans += 1
  next_black = []
  while black:
    bi, bj = black.pop(0)
    for i, j in [(bi - 1, bj), (bi + 1, bj), (bi, bj - 1), (bi, bj + 1)]:
      if i >= 0 and i < H and j >= 0 and j < W:
        if M[i][j] == '.':
          M[i][j] = '#'
          next_black.append((i, j))
  if next_black:
     black = copy.copy(next_black)
  else:
     break
print(ans - 1)

### FIXED CODE ###

from collections import deque
import copy
 
def main():
    h, w = map(int, input().split())
    a = [[j == "#" for j in input()] for _ in range(h)]
 
 
    que = deque([(i, j) for i in range(h) for j in range(w) if a[i][j]])
 
    count = 0
    while True:
        count += 1
        nque = deque()
        while que:
            y, x = que.popleft()
            if x > 0 and not a[y][x-1]:
                a[y][x-1] = True
                nque.append((y,x-1))
            if x < w-1 and not a[y][x+1]:
                a[y][x+1] = True
                nque.append((y,x+1))
            if y > 0 and not a[y-1][x]:
                a[y-1][x] = True
                nque.append((y-1,x))
            if y < h-1 and not a[y+1][x]:
                a[y+1][x] = True
                nque.append((y+1,x))
 
        if nque:
            que = copy.copy(nque)
        else:
            break
 
    print(count - 1)

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

#! cat input | python3 main.py

n, k = map(int, input().split())
a = list(map(int, input().split()))
if n == 1:
    if a[0] == k:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
    __import__("sys").exit()
a.sort()
ma = max(a)
def prim_fact(n):
    facts = []
    t = 2
    while True:
        if n % t == 0:
            facts.append(t)
            n //= t
        else:
            t += 1
        if t > n:
            if n != 1:
                facts.append(n)
            break
    return facts


def f(a, k, ma):
    minv = float("inf")
    for i, v in enumerate(a[1:]):
        if v - a[i] != 0:
            minv = min(minv, v - a[i])
    minv = min(minv, a[0])

    sets = []
    setn = set()
    for v in a:
        s = set(prim_fact(v))
        sets.append(s)
        for i in s: setn.add(i)
    for v in setn:
        for s in sets:
            if v not in s:
                break
        else:
            minv = min(minv, v)
            break
    else:
        return False

    if minv == 1:
        return False

    a = a[:]
    for i in range(0, ma + minv, minv):
        if i == k:
            return False
        if i < a[0]:
            continue
        if i == a[0]:
            del a[0]
        else:
            return False
    return True

if ma < k:
    print("IMPOSSIBLE")
elif f(a, k, ma):
    print("IMPOSSIBLE")
else:
    print("POSSIBLE")


### FIXED CODE ###

a, b = map(int, input().split())
array = list(map(int, input().split()))
impossible = "IMPOSSIBLE"
possible = "POSSIBLE"

array = list(set(array))

if len(array) == 1:
    if b == array[0]:
        print(possible)
    else:
        print(impossible)
    exit(0)

array.sort()

btw = [v1 - v2 for v1, v2 in zip(array[1:], array[0:])]
n = sorted(btw)[0]

same = len(set(btw)) == 1 or all([v % n == 0 for v in btw])

if b in array:
    print(possible)
elif array[-1] < b:
    print(impossible)
elif same and (b - array[0]) % n == 0:
    print(possible)
else:
    print(impossible)
### BUGGY CODE ###

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

ans = 1
for n in a:
    ans = ans * n

if ans > 10**18:
    print(-1)
else:
    print(ans)

### FIXED CODE ###

import collections
import sys


def pow2(x, n):
    ret = 1
    while (n > 0):
        if (n & 1):
            ret *= x
        x *= x
        n = n >> 1
    return ret


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

if 0 in a:
    print(0)
    sys.exit(0)

c = collections.Counter(a)

l = sorted(list(c.keys()))

ans = 1
for num in l:
    ans *= pow2(num, c[num])
    if ans > 1000000000000000000:
        print(-1)
        sys.exit(0)
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [0]*m
for i in range(m):
  a[i] = int(input())
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1

for j in range(2,n+1):
  if j in a:
    dp[j] = 0
  else:
    dp[j] = dp[j-1]+dp[j-2]
print(dp[n]%1000000007)

### FIXED CODE ###

import sys
input = sys.stdin.readline
n,m = map(int,input().split())
a = [0]*m
#for i in range(m):
 # a[i] = int(input())
a = set([int(input()) for i in range(m)])
dp = [0]*(n+1)
dp[0] = 1
if 1 in a:
  dp[1] = 0
else:
  dp[1] = 1

for j in range(2,n+1):
  dp[j] = (dp[j-1]+dp[j-2])%1000000007
  if j in a:
    dp[j] = 0
print(dp[n])
### BUGGY CODE ###

import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return sys.stdin.readline()[:-1]

def main():
    n = II()
    s = S()
    m = [[0 for i in range(n)] for i in range(n)]
    first = [[INF for i in range(n)] for i in range(n)]
    # set 1st index value
    lcs = 0
    for i, c in enumerate(s):
        # print(c, s[0])
        if c == s[0]:
            m[i][0] = 1
            first[i][0] = i
    # print(m)
    for i in range(1, n):
        for j in range(1, n):
            if i <= j:
                continue
            if s[i] == s[j]:
                if first[i-1][j-1] > j:
                    m[i][j] = m[i-1][j-1] + 1
                    if first[i-1][j-1] == INF:
                        first[i][j] = i
                    else:
                        first[i][j] = first[i-1][j-1]
            else:
                m[i][j] = 0

    # print(m)
    m[0][0] = 0
    print(max(sum(m, [])))


if __name__ == '__main__':
    main()

### FIXED CODE ###


import sys

sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7

def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return sys.stdin.readline()[:-1]

def main():
    n = II()
    s = S()
    inf = n + 2
    m = [[0 for i in range(n)] for i in range(n)]
    first = [[inf for i in range(n)] for i in range(n)]
    # set 1st index value
    lcs = 0
    for i, c in enumerate(s):
        # print(c, s[0])
        if c == s[0]:
            m[i][0] = 1
            first[i][0] = i
            if i != 0:
                lcs = 1
    for i in range(1, n):
        for j in range(1, n):
            if i <= j:
                continue
            if s[i] == s[j]:
                if first[i-1][j-1] > j:
                    m[i][j] = m[i-1][j-1] + 1
                    lcs = max(m[i][j], lcs)
                    if first[i-1][j-1] == inf:
                        first[i][j] = i
                    else:
                        first[i][j] = first[i-1][j-1]
            else:
                m[i][j] = 0

    # print(m)
    print(lcs)


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

n,k = map(int,input().split())
a = list(map(int,input().split()))
z = 0
b = [1]
for i in range(n*3):
  j = [a[b[i]-1]]
  b.extend(j)
for i in range(n):
  if b.count(i+1)>=3:
    z = z + 1
if k <= n:
  y = b[k]
else:
  l = (k-n)%z
  y = b[n+l]
print(y)

### FIXED CODE ###

n,k = map(int,input().split())
a = list(map(int,input().split()))
z = 0
b = [1]
c = [0]*n
for i in range(n*3):
  j = [a[b[i]-1]]
  b.extend(j)
  c[a[b[i]-1]-1] = c[a[b[i]-1]-1]+1
  if c[a[b[i]-1]-1] == 2:
    z = z + 1
if k <= n:
  y = b[k]
else:
  l = (k-n)%z
  y = b[n+l]
print(y)
### BUGGY CODE ###

def main():
    N = int(input())
    num_list = [int(i) for i in input().split()]
    order_list = []

    for order in range(1,N+1):
        num = num_list.index(order)+1
        order_list.append(num)
    
    print(" ".join(map(str,order_list)))

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    N = int(input())
    num_list = [int(i) for i in input().split()]
    order_list = [0 for i in range(N)]

    for index,num in enumerate(num_list):
        order_list[num-1] = index+1
    
    print(" ".join(map(str,order_list)))

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

N=int(input())
A = list(map(int,input().split()))
mod=1000000007
ans=0
for i in range(N-1):
  for j in range(i+1,N):
    a=A[i]*A[j]
    a%=mod
    ans+=a
    ans%=mod
print(ans)

### FIXED CODE ###

N=int(input())
A = list(map(int,input().split()))
mod=1000000007
ans=0
sumA=sum(A)
for i in range(N-1):
  sumA-=A[i]
  a=A[i]*sumA
  a%=mod
  ans+=a
  ans%=mod
print(ans)
### BUGGY CODE ###

# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
C = Counter(A)

# dp[i][j][k] := 3個残りがi個、2個残りがj個、1個残りがk個である状態にするまでの操作回数の期待値
dp = list3d(N+1, N+1, N+1, 0.0)
# 全て残0なら残り回数は0
dp[0][0][0] = 0.0
for i in range(N+1):
    for j in range(N+1):
        for k in range(N+1):
            if i == j == k == 0:
                continue
            # 今現在残っている皿を取る確率
            tmp = (i + j + k) / N
            # そのために必要な回数
            res = 1 / tmp
            # それ以降に必要な回数
            if i and j < N: 
                res += (i/N) / tmp * dp[i-1][j+1][k]
            if j and k < N: 
                res += (j/N) / tmp * dp[i][j-1][k+1]
            if k: 
                res += (k/N) / tmp * dp[i][j][k-1]
            dp[i][j][k] = res
print(dp[C[3]][C[2]][C[1]])


### FIXED CODE ###

# -*- coding: utf-8 -*-

import sys
from collections import Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N = INT()
A = LIST()
C = Counter(A)

# dp[i][j][k] := 3個残りがi個、2個残りがj個、1個残りがk個である状態にするまでの操作回数の期待値
dp = list3d(N+1, N+1, N+1, INF)
# 全て残0なら残り回数は0
dp[0][0][0] = 0.0
for i in range(N+1):
    for j in range(N+1):
        # 枝刈り
        if i+j > N:
            break
        for k in range(N+1):
            # 枝刈り
            if i+j+k > N:
                break
            if i == j == k == 0:
                continue
            # 今現在残っている皿を取る確率
            tmp = (i + j + k) / N
            # そのために必要な回数
            res = 1 / tmp
            # それ以降に必要な回数
            if i and j < N: 
                res += (i/N) / tmp * dp[i-1][j+1][k]
            if j and k < N: 
                res += (j/N) / tmp * dp[i][j-1][k+1]
            if k: 
                res += (k/N) / tmp * dp[i][j][k-1]
            dp[i][j][k] = res
print(dp[C[3]][C[2]][C[1]])
### BUGGY CODE ###

import sys

N = int(sys.stdin.readline().strip())
X = sys.stdin.readline().strip()

def popcount(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n //= 2
    return cnt

def f(n):
    cnt = 0
    while n != 0:
        n = n % popcount(n)
        cnt += 1
    return cnt

nX = int(X, 2)
pcnt = X.count('1')
MOD1 = pcnt + 1
MOD2 = pcnt - 1

nXp = nX % MOD1
if MOD2 != 0:
    nXm = nX % MOD2

delta = 2**(N-1)

for i in range(0, N):
    if X[i] == '0':
        k = (nXp + (delta % MOD1)) % MOD1
        print(f(k) + 1)
    else:
        if MOD2 == 0:
            print(0)
        else:
            k = (nXm - (delta%MOD2)) %MOD2
            print(f(k) + 1)
    delta //= 2

### FIXED CODE ###

import sys

N = int(sys.stdin.readline().strip())
X = sys.stdin.readline().strip()

def popcount(n):
    cnt = 0
    while n > 0:
        cnt += n & 1
        n //= 2
    return cnt

def f(n):
    cnt = 0
    while n != 0:
        n = n % popcount(n)
        cnt += 1
    return cnt

#nX = int(X, 2)
pcnt = X.count('1')
MOD1 = pcnt + 1
MOD2 = pcnt - 1

nXp = 0
nXm = 0

pow1 = [1] * N
pow2 = [0] * N
for i in range(1, N):
    pow1[i] = (pow1[i-1] * 2) % MOD1
if MOD2 != 0:
    pow2[0] = 1
    for i in range(1, N):
        pow2[i] = (pow2[i-1] * 2) % MOD2

for i in range(N):
    if X[i] == '1':
        nXp += pow1[N-1-i]
nXp %= MOD1

if MOD2 != 0:
    for i in range(N):
        if X[i] == '1':
            nXm += pow2[N-1-i]

    nXm %= MOD2
    

for i in range(0, N):
    if X[i] == '0':
        k = (nXp + pow1[N-1-i]) % MOD1
        print(f(k) + 1)
    else:
        if MOD2 == 0:
            print(0)
        else:
            k = (nXm - pow2[N-1-i]) % MOD2
            print(f(k) + 1)
### BUGGY CODE ###

n=int(input())
dic ={}


for i in range(n):
  s=sorted(input())
  s="".join(s)
  if s in list(dic.keys()):
    dic[s]+=1
  else:
    dic[s]=1
ans=0
for i in dic.values():
  ans += i*(i-1)//2
print(ans)

### FIXED CODE ###

from collections import Counter
n=int(input())
#dic ={}

s=["".join(sorted(input())) for i in range(n)]
ans=0
c = Counter(s)
#print(c)
for i in c.values():
  ans += i*(i-1)//2
print(ans)
### BUGGY CODE ###

n, m = map(int, input().split())
card = []
cntAppearance = []
for i in range(n):
        cntAppearance.append(0)
for _ in range(m):
        l ,r = map(int, input().split())
        for i in range(l,r+1):
                card.append(i)
for j in card:
        cntAppearance[j-1] += 1
cnt = 0
for i in cntAppearance:
        if i == m:
                cnt += 1
print(cnt)

### FIXED CODE ###

n, m = map(int, input().split())
cnt = 0
id = []
for _ in range(m):
        l= list(map(int, input().split()))
        if len(id) == 0:
                id = l
        else:
                if id[0] < l[0]:
                        id[0] = l[0]
                elif id[1] > l[1]:
                        id[1] = l[1]
if id[1] < id[0]:
        cnt = 0
else:
        cnt = id[1]-id[0]+1
print(cnt)
### BUGGY CODE ###

import sys

L, R = map(int, input().split())

ans = sys.maxsize

for i in range(L, R+1):
    for j in range(i+1, R+1):
        minNum = (i * j) % 2019
        ans = min(ans, minNum)

print(ans)

### FIXED CODE ###

import sys

L, R = map(int, input().split())

ans = sys.maxsize

for i in range(L, R+1):
    for j in range(i+1, R+1):
        minNum = (i * j) % 2019
        if minNum == 0:
            ans = minNum
            break
        else:
            ans = min(ans, minNum)
    else:
        continue
    break

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

# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/08/2020

from sys import stdin,stdout
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007

def bfs(node, d):
    queue = [node, None]
    count = 0
    while len(queue):
        cur = queue.pop(0)
        if not cur:
            if len(queue):
                queue.append(None)
            count += 1
        else:
            for neigh in d.get(cur, []):
                queue.append(neigh)
    return count - 1

n, m = iia()
d = {}
indegree = [0] * (n + 1)
for i in range(m):
    a, b = iia()
    d.setdefault(a, []).append(b)
    indegree[b] += 1

res = 0
for i in range(1, n + 1):
    if indegree[i] == 0:
        res = max(res, bfs(i, d))
print(res)
    
    

### FIXED CODE ###

# Author: S Mahesh Raju
# Username: maheshraju2020
# Date: 01/08/2020

from sys import stdin, stdout
import sys
from math import gcd, ceil, sqrt
from collections import Counter
from bisect import bisect_left, bisect_right
ii1 = lambda: int(stdin.readline().strip())
is1 = lambda: stdin.readline().strip()
iia = lambda: list(map(int, stdin.readline().strip().split()))
isa = lambda: stdin.readline().strip().split()
mod = 1000000007
sys.setrecursionlimit(100000)
n, m = iia()
dp = [-1] * (n + 1)
d = {}
for i in range(m):
    a, b = iia()
    d.setdefault(a, []).append(b)

def dfs(cur):
    if dp[cur] != -1:
        return dp[cur]
    t = 0
    for i in d.get(cur, []):
        t = max(1 + dfs(i), t)
    dp[cur] = t
    return dp[cur]

res = 0
for i in range(1, n + 1):
    res = max(res, dfs(i))
print(res)
### BUGGY CODE ###

# D - Multiple of 2019
s = input()[::-1]
length = len(s)
a = []
d = []
for i in range(length):
    a.append(int(s[i]) * pow(10, i) % 2019)
d.append(a[0])
for i in range(length-1):
    d.append((d[i] + a[i+1]) % 2019)
print(sum(d[i] == d[j] for i in range(length-1) for j in range(i+1, length)) + d.count(0))

### FIXED CODE ###

import numpy as np

s = input()[::-1]
length = len(s)
a = np.zeros(length, dtype=int)
d = np.zeros(length, dtype=int)
ans = np.zeros(2019, dtype=int)
x = 10

a[0] = int(s[0])
d[0] = a[0]
ans[d[0]] += 1

for i in range(1, length):
    a[i] = int(s[i]) * x % 2019
    d[i] = (d[i-1] + a[i]) % 2019
    ans[d[i]] += 1
    x = x * 10 % 2019

ans_c = ans[np.nonzero(ans)]

print(int(sum([ans_c[i] * (ans_c[i]-1) for i in range(ans_c.shape[0])]) / 2) + ans[0])
### BUGGY CODE ###

N,Q=map(int,input().split())
S=list(input())
TD= [list(input().split()) for _ in range(Q)]

def solve(place):
    if place == -1:
        return ('Left')
    elif place == N:
        return ('Right')
    for td in TD:
        char,to=td
        if S[place]!=char:continue

        if to=='L':place-=1
        elif to=='R':place+=1

        if place==-1:
            return('Left')
        elif place==N:
            return('Right')
    return('Not Drop')

l,r=-1,N
L,R=-1,N

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Left':
        L=m
        l,r=m,r
    elif solve(m)=='Not Drop' or solve(m)=='Right':
        l,r=l,m

l,r=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Right':
        R=m
        l,r=l,m
    elif solve(m)=='Not Drop' or solve(m)=='Left':
        l,r=m,r


print(max(R-L-1,0))


### FIXED CODE ###

N,Q=map(int,input().split())
S=list(input())
S=[0]+S+[N+1]
TD=[list(input().split()) for _ in range(Q)]

def solve(place):
    if place == 0:
        return ('Left')
    elif place == N+1:
        return ('Right')
    for td in TD:
        char,to=td
        if S[place]!=char:continue

        if to=='L':place-=1
        elif to=='R':place+=1

        if place==0:
            return('Left')
        elif place==N+1:
            return('Right')
    return('Not Drop')

l,r=0,N+1
L,R=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Left':
        L=m
        l,r=m,r
    else:
        l,r=l,m

l,r=0,N+1

while abs(r-l)>1:
    m=(l+r)//2
    if solve(m)=='Right':
        R=m
        l,r=l,m
    else:
        l,r=m,r

print(max(R-L-1,0))
### BUGGY CODE ###

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

A.sort(reverse=True)

for i in range(M):
    A[0] = A[0]//2
    
    if N!=1:
        for i in range(N-1):
            if A[i+1]>A[i]:
                tmp = A[i+1]
                A[i+1] = A[i]
                A[i] = tmp
            else:
                break
print(sum(A))

### FIXED CODE ###

#!/usr/bin/env python3
import heapq
# import bisect

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

heapq.heapify(a)
for i in range(m):
    value = heapq.heappop(a)
    value = (value+1)//2
    heapq.heappush(a, value)

# print(a)
print(-sum(a))
### BUGGY CODE ###

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n, k=I()
h = l()
h.sort(reverse=True)

for i in range(k):
  if h:
    del h[0]
  else:
    break

print(sum(h))

### FIXED CODE ###

import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def v(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 6)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")
al = "abcdefghijklmnopqrstuvwxyz"
AL = al.upper()

n, k=I()
h = l()
h.sort(reverse=True)

print(sum(h[k:]))
### BUGGY CODE ###

n,k = map(int,input().split())
lis = list(map(int,input().split()))
ans = [10 ** 9 for i in range(n+5)]
ans[0] = 0
for i in range(n):
    for step in range(1,k+1):
        if i + step < n:ans[i+step] = min(ans[i+step],ans[i] + abs(lis[i+step]-lis[i]))
print(ans[n-1])

### FIXED CODE ###

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

dp = [10 ** 10 for i in range(n+k+1)]

dp[0] = 0
for i in range(n):
    for j in range(1,min(n-i,k+1)):
        dp[i+j] = min(dp[i+j],dp[i]+abs(lis[i+j]-lis[i]))
print(dp[n-1])
### BUGGY CODE ###

X,K,D=map(int,input().split())
flag=True
X=abs(X)
I=X//D
for i in range(I):
    X-=D
K-=I
if K<1:
    for i in range(abs(K)):
        X+=D
    flag=False
ans=X
if flag:
    if K%2!=0:
        ans-=D
        ans=abs(ans)
        if ans>abs(X+D):
            ans+=D
            ans+=D
print(abs(ans))

### FIXED CODE ###

X,K,D=map(int,input().split())
X=abs(X)
straight=min(K,X//D)
K-=straight
X-=straight*D
if K%2==0:
    print(X)
else:
    print(D-X)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
import heapq

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

heapq.heapify(l)

for i in range(m):
    b,c = map(int,input().split())
    cnt = 0
    while cnt < b:
        x = heapq.heappop(l)
        if x < c:
            x = c
        heapq.heappush(l,x)
        cnt += 1
print(sum(l))

### FIXED CODE ###

from collections import Counter
import heapq

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

hq  = sorted(tuple(Counter(l).items()), key=lambda x:x[0])

heapq.heapify(hq)
# print(hq)
BC = [list(map(int, input().split())) for i in range(m)]
BC = sorted(BC,key = lambda x:-x[1])

for b,c in BC:
    while b > 0:
        x,y = heapq.heappop(hq)
        if x < c:
            if b < y:
                heapq.heappush(hq,(c,b))
                heapq.heappush(hq,(x,y-b))
                b = 0
            else:
                heapq.heappush(hq,(c,y))
                b -= y
        else:
            heapq.heappush(hq,(x,y))
            break
    # print(hq)

ans = 0
for i in range(len(hq)):
    ans += hq[i][0]*hq[i][1]
print(ans)