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

def main():
    n, m, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    sum_A = [A[0]]
    sum_B = [B[0]]

    for i in range(n - 1):
        sum_A.append(sum_A[i] + A[i + 1])

    for i in range(m - 1):
        sum_B.append(sum_B[i] + B[i + 1])

    R = []

    b = m - 1
    flag = False
    while b > -1:
        if sum_B[b] <= k:
            R.append(b + 1)
            flag = True
            break
        else:
            b -= 1

    if not flag:
        R.append(0)

    for i in range(n):
        a = sum_A[i]

        b = m - 1
        flag = False
        while b > -1:
            if sum_B[b] <= k - a:
                R.append(i + 1 + b + 1)
                flag = True
                break
            else:
                b -= 1

        if not flag:
            if 0 <= k - a:
                R.append(i + 1)
            else:
                R.append(0)

    print(max(R))
    # while k > 0 and (a < n or b < m):
    #     if a == n:
    #         time = B[b]
    #     elif b == m:
    #         time = A[a]
    #     else:
    #         time = min(A[a], B[b])

    #     if k - time < 0:
    #         break

    #     r += 1
    #     k -= time
    #     print(k)

    #     if a == n:
    #         b += 1
    #     elif b == m:
    #         a += 1
    #     else:
    #         if A[a] >= B[b]:
    #             b += 1
    #         else:
    #             a += 1

    # print(r)


if __name__ == '__main__':
    main()


### FIXED CODE ###

def main():
    n, m, k = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))

    sum_A = [A[0]]
    sum_B = [B[0]]

    for i in range(n - 1):
        sum_A.append(sum_A[i] + A[i + 1])

    for i in range(m - 1):
        sum_B.append(sum_B[i] + B[i + 1])

    R = []

    b = m - 1
    flag = False
    while b > -1:
        if sum_B[b] <= k:
            R.append(b + 1)
            flag = True
            break
        else:
            b -= 1

    if not flag:
        R.append(0)

    for i in range(n):
        a = sum_A[i]

        flag = False
        while b > -1:
            if sum_B[b] <= k - a:
                R.append(i + 1 + b + 1)
                flag = True
                break
            else:
                b -= 1

        if not flag:
            if 0 <= k - a:
                R.append(i + 1)
            else:
                R.append(0)

    print(max(R))
    # while k > 0 and (a < n or b < m):
    #     if a == n:
    #         time = B[b]
    #     elif b == m:
    #         time = A[a]
    #     else:
    #         time = min(A[a], B[b])

    #     if k - time < 0:
    #         break

    #     r += 1
    #     k -= time
    #     print(k)

    #     if a == n:
    #         b += 1
    #     elif b == m:
    #         a += 1
    #     else:
    #         if A[a] >= B[b]:
    #             b += 1
    #         else:
    #             a += 1

    # print(r)


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

N = int(input())
A = list(map(int, input().split()))
A.sort()
check = [0] * 1000001
res = 0
for i in range(N):
    if not check[A[i]] and (i == N-1 or A[i] != A[i+1]):
        res += 1
    for j in range(A[i], 1000001, A[i]):
        check[j] = 1
print(res)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
A.sort()
check = [0] * 1000001
res = 0
for i in range(N):
    if check[A[i]]:
        continue
    if i == N-1 or A[i] != A[i+1]:
        res += 1
    for j in range(A[i], 1000001, A[i]):
        check[j] = 1
print(res)
### BUGGY CODE ###

print(sum(range(int(input()))))

### FIXED CODE ###

n = int(input())-1
print(((2+n-1)*n ) >> 1)
### BUGGY CODE ###

N = int(input())
S = input()

ans = 0
i = 0
j = 1
c = 1
while j <= N-c:
    c = 1
    for k in range(j, N):
        cnt = 0
        while k+cnt < N and i+cnt < j and S[i+cnt] == S[k+cnt]:
            cnt += 1
        c = max(c, cnt)
    if j-i > c:
        i += 1
        j = i+c
    else:
        j += 1
    ans = max(c, ans)
    
if N <= 26:
    L = []
    for i in range(N):
        L.append(S[i])
    L = set(L)
    if len(L) == N:
        ans = 0
    
print(ans)

### FIXED CODE ###

N = int(input())
S = input()

def z_algo(S):
    N = len(S)
    Z = [0]*N
    i = 1
    j = 0
    Z[0] = N
    while i < N:
        while i+j < N and S[j] == S[i+j]:
            j += 1
        if j == 0:
            i += 1
            continue
        Z[i] = j
        k = 1
        while i+k < N and k < j-Z[k]:
            Z[i+k] = Z[k]
            k += 1
        i += k
        j -= k
    return Z

ans = 0
l = 0
while l < N:
    temp = S[l:]
    z = z_algo(temp)
    for i in range(1, len(temp)):
        ans = max(ans, min(i, z[i]))
    l += 1
    
print(ans)
### BUGGY CODE ###

import sys
input = sys.stdin.readline
def main():
    n = int(input())
    s = input().rstrip()
    dp = [0]*(n-1)
    ans = 0
    for i in range(1, n):
        tmp = 0
        for j in reversed(range(i)):
            if s[i] == s[j]:
                dp[j] = 1
                if 0 < j:
                    dp[j] += dp[j-1]
                if i-j < dp[j]:
                    dp[j] = i-j
                if ans < dp[j]:
                    ans = dp[j]
                if tmp < dp[j]:
                    tmp = dp[j]
            else:
                dp[j] = 0
        if tmp + (n-i) <= ans:
            break
    print(ans)

if __name__ == "__main__":
    main()


### FIXED CODE ###

def check(x, N, S):
    candidate = set()
    for i in range(N - 2*x + 1):
        candidate.add(S[i:i+x])
        if S[i+x:i+2*x] in candidate:
            return True
    return False

def main():
    n = int(input())
    s = input().rstrip()
    l = 0
    r = n
    while l < r:
        mid = (l+r+1) // 2
        if check(mid, n, s):
            l = mid
        else:
            r = mid-1
    print((l+r+1)//2)

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

n = int(input())
ans=0
for i in range(n):
    if i==n-1:
        break
    else:
        ans+=i+1
print(ans)

### FIXED CODE ###

n = int(input())
ans = int((n-1)*n//2)
print(ans)
### BUGGY CODE ###

import sys

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


def dfs(G, v, p, dist):
    """G: graph, v: vertex, p: parent"""
    # Loop for each child
    for c, d in G[v]:
        # Avoid multiple access to parent
        if c == p:
            continue
        dist[c] = dist[v] + d
        dfs(G, c, v, dist)


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

    Q, K = map(int, input().split())
    x = [0] * Q
    y = [0] * Q
    for i in range(Q):
        x[i], y[i] = map(int, input().split())

    for i in range(Q):
        dist_a = [0] * N
        dist_b = [0] * N
        dfs(G, x[i]-1, -1, dist_a)
        dfs(G, K-1, -1, dist_b)
        ans = dist_a[K-1] + dist_b[y[i]-1]
        print(ans)


if __name__ == "__main__":
    main()


### FIXED CODE ###

import sys

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


def dfs(G, v, p, dist):
    """G: graph, v: vertex, p: parent"""
    # Loop for each child
    for c, d in G[v]:
        # Avoid multiple access to parent
        if c == p:
            continue
        dist[c] = dist[v] + d
        dfs(G, c, v, dist)


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

    Q, K = map(int, input().split())
    x = [0] * Q
    y = [0] * Q
    for i in range(Q):
        x[i], y[i] = map(int, input().split())

    dist = [0] * N
    dfs(G, K-1, -1, dist)
    for i in range(Q):
        ans = dist[x[i]-1] + dist[y[i]-1]
        print(ans)


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

import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M = map(int, input().split())
    bridges = [False]*(N-1)
    battles = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int, input().split())
        battles[b-1].append(a-1)
    for i in range(1,N):
        battle = battles[i]
        if len(battle) == 0: continue

        closest_idx = max(battle)
        if True in bridges[closest_idx:i]:
            continue
        else:
            bridges[i-1] = True
    print(bridges.count(True))

if __name__ == '__main__':
    main()

### FIXED CODE ###

import sys
from bisect import *
from collections import *
from copy import deepcopy
from heapq import *
from itertools import *
from math import *
from operator import *
from pprint import *

sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,M = map(int, input().split())
    battles = [[] for _ in range(N)]
    for _ in range(M):
        a,b = map(int, input().split())
        battles[b-1].append(a-1)

    x = -1
    ans = 0
    for i in range(1,N):
        battle = battles[i]
        if len(battle) == 0: continue

        closest_idx = max(battle)
        if x < closest_idx:
            ans += 1
            x = i-1
    print(ans)

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

[N,L] = [int(x) for x in input().split()]
A = {}
B = [0]*N
ANS = {}
count = 0
for i,x in enumerate(input().split()):
    i = int(i)
    x = int(x)
    B[i] = x
    if x in A : A[x] += [i]
    else : A[x] = [i]
for i in sorted(A) :
    for j in A[i] :
        for k in range(L) :
            if j + k not in ANS :
                ANS[j+k] = i
                count += 1
    if count + 2000 > N : break
        
for i in range(L):
    if i not in ANS : ANS[i] = min(B[:i+1])
for i in range(L,N):
    if i not in ANS : ANS[i] = min(B[i+1-L:i+1])
for i in range(L-1,N-1) : print(ANS[i], end=" ")
print(ANS[N-1])

### FIXED CODE ###

def ascend(a,b):
    mini = min(A[a:a+L])
    ans[a] = mini
    for i in range(a+1,b):
        if A[i+L-1] <= mini : mini = A[i+L-1]
        elif A[i-1] == mini : mini = min(A[i:i+L])
        ans[i] = mini

def descend(a,b):
    mini = min(A[b-1:b+L-1])
    ans[b-1] = mini
    for i in range(b-2,a-1,-1):
        if A[i] <= mini : mini = A[i]
        elif A[i+L] == mini: mini = min(A[i:i+L])
        ans[i] = mini
    
[N,L] = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]
ans = [None]*(N-L+1)
count = 0;
if N > 10 ** 4:
    for i in range(100):
        if A[i+1] > A[i] : count += 1
    if count > 80 : descend(0, N-L+1)
    else : ascend(0,N-L+1)
else :
    ascend(0, N-L+1)
for i in ans[:-1] : print(i, end=" ")
print(ans[-1])
### BUGGY CODE ###

H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    cur = 0
    for j in range(len(a)):
        if a[j][i] == '.':
            cur += 1
    if cur == len(a):
        ls.append(i)
ans = a
for i in ls:
    for s in a:
        ans.append(s[:i] + s[i+1:])
print(*ans, sep='\n')

### FIXED CODE ###

H, W = map(int, input().split())
a = []
for i in range(H):
    s = input()
    if s != '.'*W:
        a.append(s)
ls = []
for i in range(W):
    b = ''
    for j in range(len(a)):
        b += a[j][i]
    if b == '.'*len(a):
        ls.append(i)
ans = []
for i in range(len(a)):
    s = ''
    for j in range(W):
        if j in ls:
            continue
        else:
            s += a[i][j]
    ans.append(s)
print(*ans, sep='\n')
### BUGGY CODE ###

n=int(input())
arr=list(map(int,input().split()))
arr.sort()
d={}
ans=0
s1=0
d={i:0 for i in range(1,10**6+1)}
for i in arr:
    if i==1:
        s1+=1
    d[i]+=1
if s1!=0:
    if s1>1:
        print(0)
        quit()
    else:
        print(1)
        quit()
for i in range(n):
    x=arr[i]
    if d[x]==1:
        f=1
        for j in range(2,int(x**0.5)+1):
            y=x//j
            if (d[j]>=1 and x%j==0) or ( d[y]>=1 and x%(y)==0):
                f=0
                break
        if f==1:
             ans+=1
print(ans)

### FIXED CODE ###


import os
import sys
from io import BytesIO, IOBase


def main():
    n = int(input())
    arr = list(map(int, input().split()))
    arr.sort()
    ans = 0
    k=max(arr)
    d = [0]*(k+1)
    if arr[0] == 1:
        if n>1 and arr[1]==1:
            print(0)
            quit()
        else:
            print(1)
            quit()
    for i in range(n):
        d[arr[i]]+=1
    for i in range(n):
        x=arr[i]
        if d[x]==1:
            ans+=1
        for j in range(x,k+1,x):
            d[j]+=1
    print(ans)


# fast-io region

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)


def input():
    return sys.stdin.readline().rstrip("\r\n")


def write(*args, end="\n"):
    for x in args[:-1]:
        sys.stdout.write(str(x) + " ")
    sys.stdout.write(str(args[-1]))
    sys.stdout.write(end)


def r_array():
    return [int(x) for x in input().split()]


def r_int():
    return int(input())


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

def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(resolve(a))

def resolve(a):
    cnt = 0

    for i in range(len(a)):
        cnt += resolve_1(a, i)
    
    return cnt

def resolve_1(a, l):
    cnt = 1
    x = a[l]
    y = a[l]

    for i in range(l + 1, len(a)):
        x = x ^ a[i]
        y = y + a[i]
        if x != y:
            break
        cnt += 1
    
    return cnt


main()

### FIXED CODE ###

def main():
    n = int(input())
    a = list(map(int, input().split()))
    print(resolve(a))

def resolve(a):
    cnt = 0
    base = 0
    skip = 0

    for i in range(len(a)):
        c, base = resolve_1(a, i, skip, base)

        skip = c - 1
        base = base ^ a[i]
        cnt += c

    
    return cnt

def resolve_1(a, i, skip, base):
    cnt = skip

    for j in range(i + skip, len(a)):
        if a[j] & base != 0:
            break
        
        cnt += 1
        base |= a[j]

    return (cnt, base)

main()
### BUGGY CODE ###

N = int(input())
P = list(map(int,input().split()))
count = 1

for i in range(1,N):
    if min(P[:i]) >= P[i]:
        count += 1

print(count)

### FIXED CODE ###

N = int(input())
P = list(map(int,input().split()))
count = 0
min_P = P[0]

for i in range(0,N):
    if P[i] < min_P:
        min_P = P[i]
    if min_P >= P[i]:
        count += 1

print(count)
### BUGGY CODE ###

n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
for i in range(len(s)):
    c[i] = L.count(s[i])
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])

### FIXED CODE ###

n = int(input())
L = sorted(input() for _ in range(n))
s = sorted(set(L))
c = [0] * len(s)
prev = L[0]
cnt = 1
l = 0
for i in range(1, len(L)):
    if L[i] == prev:
        cnt += 1
    else:
        c[l] = cnt
        l += 1
        cnt = 1
        prev = L[i]
c[-1] = cnt
m = max(c)
for j in range(len(c)):
    if c[j] == m:
        print(s[j])
### BUGGY CODE ###

s = input()
q = int(input())
for i in range(q):
    t = input().split(' ')
    if t[0] == '1':
        s = s[::-1]
    else:
        if t[1] == '1':
            s = t[2] + s
        else:
            s = s + t[2]
print(s)

### FIXED CODE ###

from collections import deque
s = list(input())
q = int(input())
rv = False
fr = deque()
re = []
for i in range(q):
    t = input().split(' ')
    if t[0] == '1':
        rv = True if not rv else False
    else:
        if t[1] == '1' and not rv or t[1] == '2' and rv:
            fr.appendleft(t[2])
        else:
            if t[1] == '1' and rv or t[1] == '2' and not rv:
                re.append(t[2])
if rv:
    re.reverse()
    s.reverse()
    fr.reverse()
    print(''.join(re + s) + ''.join(fr))
else:
    print(''.join(fr) + ''.join(s + re))
### BUGGY CODE ###

from collections import deque


N, M = map(int,input().split())
mymap = [ [] for n in range(N) ]
for m in range(M):
    a, b = map(int, input().split())
    mymap[a-1].append(b-1)
    mymap[b-1].append(a-1)
#print(mymap)
myans = 0
for n in range(N):
    mylist = mymap[n]
    #print(mylist)
    myd = deque()
    for mm in mylist:
        myd.append(mm)
    #print(myd)
    check_list = [0 for n in range(N)]
    mycnt = 1
    check_list[n] = 1
    while myd:
        tgt = myd.popleft()
        #print(tgt)
        if check_list[tgt] == 0:
            for e in mymap[tgt]:
                myd.append(e)
            mycnt += 1
            check_list[tgt] = 1
    if myans < mycnt:
        myans = mycnt
print(myans)

### FIXED CODE ###

from collections import deque


N, M = map(int,input().split())
mymap = [ [] for n in range(N) ]
for m in range(M):
    a, b = map(int, input().split())
    mymap[a-1].append(b-1)
    mymap[b-1].append(a-1)
#print(mymap)
myans = 0
check_list = [0 for n in range(N)]

for n in range(N):
    mylist = mymap[n]
    #print(mylist)
    myd = deque()
    for mm in mylist:
        myd.append(mm)
    #print(myd)
    mycnt = 1
    check_list[n] = 1
    while myd:
        tgt = myd.popleft()
        #print(tgt)
        if check_list[tgt] == 0 :
            for e in mymap[tgt]:
                if e > n :
                    myd.append(e)
            mycnt += 1
            check_list[tgt] = 1
    if myans < mycnt:
        myans = mycnt
print(myans)
### BUGGY CODE ###

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

a.sort(reverse=True)
f.sort(reverse=False)

def isok(mid):
    total = 0
    for i in range(n):
        if a[i] * f[i] <= mid:
            continue
        total += a[i] - mid // f[i]
    return total <= k

ng = -1
ok = a[0] * f[-1] + 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2

    if isok(mid):
        ok = mid
    else:
        ng = mid

print(ok)

### FIXED CODE ###

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

a.sort(reverse=True)
f.sort(reverse=False)

def isok(mid):
    total = 0
    for i in range(n):
        if a[i] * f[i] <= mid:
            continue
        total += a[i] - mid // f[i]
    return total <= k

ng = -1
ok = a[0] * f[-1] + 1
while abs(ok - ng) > 1:
    mid = (ok + ng) // 2
    if isok(mid):
        ok = mid
    else:
        ng = mid

print(ok)
### BUGGY CODE ###

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

r = 0
i = 1
while True:
  f = False
  for a in aas:
    if a%2 == 0:
      a /= 2
      r += 1
      f = True
  if not f:
    break
print(r)
  


### FIXED CODE ###

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

r = 0
i = 1

while True:
  f = False
  for a in aas:
    if a%2**i == 0:
      r += 1
      f = True
  if not f:
    break
  i += 1
print(r)
### BUGGY CODE ###

def solve():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**9)
    mod = 10**9+7

    def comb(n, r):
        if 2*r > n: comb(n, n-r)
        return fac[n] * inv[r] * inv[n-r] % mod

    def dfs(v, Pa=-1):
        for u in to[v]:
            if u == Pa: continue
            dfs(u, v)
            size[v] += size[u]
            dp[v] *= dp[u] % mod
            dp[v] *= comb(size[v], size[u]) % mod
        size[v] += 1

    def bfs(v, Pa=-1, P_val=1, P_sz=0):
        ans[v] = P_val * dp[v] * comb(n-1, P_sz) % mod
        for u in to[v]:
            if u == Pa: continue
            val = ans[v] * INV(dp[u]*comb(n-1, size[u])) % mod
            bfs(u, v, val, n-size[u])

    n = int(input())
    to = [[] for _ in range(n)]
    for _ in range(n-1):
        a, b = map(lambda x : int(x)-1, input().split())
        to[a].append(b)
        to[b].append(a)

    fac = [1] * (n+2)
    inv = [1] * (n+2)

    for i in range(2, n+1):
        fac[i] = fac[i-1] * i % mod
    INV = lambda x: pow(x, mod-2, mod)
    inv[n] = INV(fac[n])
    for i in range(n-1, 1, -1):
        inv[i] = inv[i+1] * (i+1) % mod

    dp = [1] * n
    size = [0] * n
    ans = [0] * n

    dfs(0)
    bfs(0)
    print(*ans, sep='\n')
if __name__ == '__main__':
    solve()

### FIXED CODE ###

import sys

def solve():
    input = lambda: sys.stdin.readline().rstrip()
    sys.setrecursionlimit(10 ** 7)
    mod = 10 ** 9 + 7

    def comb(n, r):
        if r > n: return 0
        return fac[n] * inv[r] * inv[n - r] % mod

    def dfs(v, Pa=-1):
        for u in to[v]:
            if u == Pa: continue
            dfs(u, v)
            size[v] += size[u]
            dp[v] *= dp[u] % mod
            dp[v] *= inv[size[u]] % mod
        dp[v] *= fac[size[v]] % mod
        size[v] += 1

    def bfs(v, Pa=-1, P_val=1, P_sz=0):
        ans[v] = P_val * dp[v] * comb(n - 1, P_sz) % mod
        for u in to[v]:
            if u == Pa: continue
            val = ans[v] * INV(dp[u] * comb(n - 1, size[u])) % mod
            bfs(u, v, val, n - size[u])

    n = int(input())
    to = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = map(lambda x: int(x) - 1, input().split())
        to[a].append(b)
        to[b].append(a)

    fac = [1] * (n + 2)
    inv = [1] * (n + 2)

    for i in range(2, n + 1):
        fac[i] = fac[i - 1] * i % mod
    INV = lambda x: pow(x, mod - 2, mod)
    inv[n] = INV(fac[n])
    for i in range(n - 1, 1, -1):
        inv[i] = inv[i + 1] * (i + 1) % mod

    dp = [1] * n
    size = [0] * n
    ans = [0] * n

    dfs(0)
    bfs(0)
    print(*ans, sep='\n')

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

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

def max_pop(ary):
  max = 0
  for a in ary:
    if max < a:
      max = a
  ary.remove(max)
  return ary

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
for _ in range(n):
  a = max_pop(a)
print(sum_ary(a))

### FIXED CODE ###

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

a = sorted(a, reverse=True)

def sum_ary(ary):
  total = 0
  for a in ary:
    total += a
  return total

if n >= len(a):
  print(0)
  exit()
del a[:n]
print(sum_ary(a))