Harryxun/stf_run huggingface dataset:
inf = float('inf')

N,W = map(int,input().split())
w, v = [], []
for _ in range(N):
    wi, vi = map(int,input().split())
    w.append(wi)
    v.append(vi)

M = N*sum(v)

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

for i in range(1,N+1):
    for j in range(M+1):
        if j - v[i-1] >= 0:
            dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1])
        else:
            dp[i][j] = dp[i-1][j]

for j in range(M+1)[::-1]:
    if dp[N][j] <= W:
        ans = j
        break

print(ans)

### FIXED CODE ###

N,W = map(int,input().split())
value,weight = [],[]
def chmin(a,b):
    if (a > b):
        a = b
        return True
    return False
for i in range(N):
    w,v = map(int,input().split())
    value.append(v)
    weight.append(w)
# dp[i][v]: i番目までの品物から価値vを超えるように選んだ時の重さの最小値
dp = [[float("inf")] * (sum(value)+1) for i in range(N+1)]
dp[0][0] = 0
for i in range(1,N+1):
    for v in range(sum(value)+1):
        if v - value[i-1] >= 0:
            dp[i][v] = min(dp[i-1][v-value[i-1]] + weight[i-1],dp[i-1][v])
        else:
            dp[i][v] = dp[i-1][v]
ans = 0
for v in range(sum(value),-1,-1):
    if dp[N][v] <= W:
        ans = v
        break
print(ans)
s=input()
cnt=0
lis=[]
for i in range(len(s)):
  if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
    cnt+=1
  else:
    lis.append(cnt)
    cnt=0
print(max(lis))

### FIXED CODE ###

s=input()
cnt=0
t=0
for i in range(len(s)):
  if s[i]=='A' or s[i]=='T' or s[i]=='C' or s[i]=='G':
    t+=1
    cnt=max(t,cnt)
  else:
    t=0
print(cnt)
print(' '.swapcase(0<1200))

### FIXED CODE ###

s = input()
print(s.swapcase())
import math

n = input()
while n != 0:
    if n == 0:
        break
    tmp = map(float, raw_input().split())
    sum = 0
    for i in xrange(len(tmp)):
        sum += tmp[i]
    ave = sum / n
    u = 0
    for i in xrange(n):
        u += (tmp[i] - ave)**2
    u = u / n
    print "%.8f" % math.sqrt(u)
    n = input()
~               

### FIXED CODE ###

import math

n = input()
while n != 0:
    if n == 0:
        break
    tmp = map(float, raw_input().split())
    ave = 0
    for i in xrange(len(tmp)):
        ave += tmp[i] / n
    u = 0
    for i in xrange(n):
        u += (tmp[i] - ave)**2
    print "%.8f" % math.sqrt(u/n)
    n = input()
N = input()
S = input()

N = int(N)

if N % 2 == 1:
  print("No")
elif list(S)[0:N//2] == list(S)[N//2:N]:
  print("Yes")
else:
  print("No")


### FIXED CODE ###

r = input()
r = int(r) ** 2
print(r)
N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        print(-1)
        break

if len(ans) == 1:
    print(0)
else:
    if ans[0] == 0:
        ans = [-1]
    elif ans[0] == -1:
        ans[0] = 1
    for i in range(M):
        if ans[i] == -1:
            ans[i] = 0
    print(int(''.join(map(str,ans))))

### FIXED CODE ###

N, M = map(int, input().split())
ans = [-1]*N
for i in range(M):
    s, c = map(int, input().split())
    if ans[s-1] == -1:
        ans[s-1] = c
    elif ans[s-1] != c:
        print(-1)
        exit()
if N == 1:
    if ans[0] == -1:
        print(0)
    else:
        print(int(''.join(map(str,ans))))
else:
    if ans[0] == 0:
        print(-1)
        exit()
    elif ans[0] == -1:
        ans[0] = 1
    for i in range(N):
        if ans[i] == -1:
            ans[i] = 0
    print(int(''.join(map(str,ans))))
n = int(input())
a = [int(input()) for _ in range(n)]

i = 0
cnt = 0
while not i == 1:
    i = a[i] - 1
    cnt += 1
    if i >= n or cnt > 100000:
        exit("-1")
print(cnt)

### FIXED CODE ###

n = int(input())
a = [int(input()) for _ in range(n)]

i = 0
cnt = 0
while not i == 1:
    i = a[i] - 1
    cnt += 1
    if i >= n or cnt > 100000:
        print(-1)
        exit()
print(cnt)
a,b = input().split()
if a == b:
	print("H"):
else:
	print("D")
	

### FIXED CODE ###

a,b = input().split()
if a == b:
	print("H")
else:
	print("D")
mod=10**9+7
N=int(input())
C=[0]
C.extend(sorted(list(map(int,input().split())),reverse=True)) # 1-indexed

# print(C)

ans=0
for j in range(1,N+1):
    tmp=C[j]*(j+1)*pow(2,N-2,mod)%mod
    # print(tmp)
    ans=(ans+tmp)%mod
    # print(j,ans)
ans=ans*pow(2,N,mod)%mod

print(ans)

### FIXED CODE ###

# inverse x^(-1)
def inv(x):
    global mod
    return pow(x,mod-2,mod)

mod=10**9+7
N = int(input())
C = [0]
C.extend(sorted(list(map(int,input().split())), reverse=True)) # 1-indexed, 降順

# print(C)
# C[i]が最後からj番目に操作される（コストが C[i]*j 掛かる）のは，c[1]~C[i-1]にj-1個操作すべきもの，すなわち，C[i]以上のものがあるとき。
# C[i+1]~C[N]の選び方は自由。
# ⇒ combi(i-1, j-1)*2**(N-i) を掛ける。
# 総和を計算すると，結局，2**N * Σ[i=1->N](2**(N-i)*Ci*(2**(i-2)*(i-1) + 2**(i-1))) になる

pow2 = [1]
for k in range(1, N+1):    
    pow2.append(pow2[-1] * 2 % mod)

# print(pow2)

ans=0
for i in range(1, N+1):
    temp = pow2[N - i] * C[i] * ((0 if i == 1 else (pow2[i - 2] * (i - 1))) + pow2[i - 1]) % mod
    ans = (ans + temp) % mod

ans = ans * pow2[N] % mod

print(ans)
#!/usr/bin/env python3
N, M = map(int, input().rstrip().split())
A = list(map(int, input().rstrip().split()))

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

Index = sorted(range(M), key=lambda i: C[i], reverse=True)

sum = 0
A.sort()
for index in Index:
    if A[0] >= C[index]:
        break
    count = 0
    i = 0
    while True:
        if i >= len(A):
            break
        if A[i] < C[index] and count < B[index]:
            sum += C[index]
            A.pop(i)
            # print(A)
            count += 1
            continue
        if A[i] >= C[index] or count >= B[index]:
            break
        i += 1

if A:
    for a in A:
        sum += a

print(sum)


### FIXED CODE ###

#!/usr/bin/env python3
N, M = map(int, input().rstrip().split())
A = list(map(int, input().rstrip().split()))

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

Index = sorted(range(M), key=lambda i: C[i], reverse=True)

sum = 0
A.sort()
for index in Index:
    if A and A[0] >= C[index]:
        break
    count = 0
    i = 0
    while True:
        if i >= len(A):
            break
        if A[i] < C[index] and count < B[index]:
            sum += C[index]
            A.pop(i)
            # print(A)
            count += 1
            continue
        if A[i] >= C[index] or count >= B[index]:
            break
        i += 1

if A:
    for a in A:
        sum += a

print(sum)
import collections
n = int(input())
Lista = [str(input()) for i in range(n)]
m = int(input())
Listb = [str(input()) for j in range(m)]
lst = []
for k in range(m):
  if Listb[k] in Lista:
    Lista.remove(Listb[k])
lst = collections.Counter(Lista)
print(lst.most_common()[0][1])



### FIXED CODE ###

import collections
n = int(input())
Lista = [str(input()) for i in range(n)]
m = int(input())
Listb = [str(input()) for j in range(m)]
lst = []
for k in range(m):
  if Listb[k] in Lista:
    Lista.remove(Listb[k])
if len(Lista) > 0:
  lst = collections.Counter(Lista)
  print(lst.most_common()[0][1])
elif len(Lista) == 0:
  print(0)
s,w = map(int,input().split())

if s > w:
    print('safe')
elif s =< w:
    print('unsafe')

### FIXED CODE ###

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

if s <= w:
    print('unsafe')
else:
    print('safe')
#!/usr/bin/env python3

import math


def distance(p1, p2):
    """returns the distance between p1 and p2

    >>> d = distance((0, 0), (1, 1))
    >>> print("{0:.5f}".format(d))
    1.41421
    """
    (x1, y1) = p1
    (x2, y2) = p2
    return math.sqrt((x2-x1)**2 + (y2-y1)**2)


def run():
    x1, y1, x2, y2 = [int(i) for i in input().split()]

    print("{0:.5f}".format(distance((x1, y1), (x2, y2))))


if __name__ == '__main__':
    run()


### FIXED CODE ###

import math


def distance(p1, p2):
    """returns the distance between p1 and p2

    >>> d = distance((0, 0), (1, 1))
    >>> print("{0:.5f}".format(d))
    1.41421
    """
    (x1, y1) = p1
    (x2, y2) = p2
    return math.sqrt((x2-x1)**2 + (y2-y1)**2)


def run():
    x1, y1, x2, y2 = [float(i) for i in input().split()]

    print(distance((x1, y1), (x2, y2)))


if __name__ == '__main__':
    run()
s,t=map(input().split())
a,b=map(input().split())
u=input()
if s==u:
    a-=1
else:
    b-=1
print(a+b)


### FIXED CODE ###

s,t=input().split()
a,b=map(int,input().split())
u=input()
if s==u:
    a-=1
else:
    b-=1
print(a,b)
a,b,c = map(int(), input().split())
print("Yes" if (a-c)*(b-c) < 0 else "No")


### FIXED CODE ###

a,b,c = map(int, input().split())
print("Yes" if (a-c)*(b-c) < 0 else "No")
n=int(input())
s=list(map(input().split()))
if s.count("Y")==0:
    print("Three")
else:
    print("Four")


### FIXED CODE ###

n=int(input())
s=list(input().split())
if s.count("Y")==0:
    print("Three")
else:
    print("Four")
n, k = map(int, input().split())
li = list(map(int, input().split()))
 
check = [0] * (n+10)
res = []
next = 0
 
for i in range(k):
    if check[next] == 0:
        check[next] = 1
        next = li[next]-1
    elif check[next] == 1:
        check[next] += 1
        res.append(next+1)
        next = li[next]-1
    else:
        cnt = len(res)
        k -= check.count(1)
        amari = k%cnt
        print(res[amari])
        break
else:
    print(next+1)
amari=k%n
	ans=li[amari-1]
	print(ans)
n, k = map(int, input().split())
li = list(map(int, input().split()))
 
check = [0] * (n+10)
res = []
next = 0
 
for i in range(n+10):
    if check[next] == 0:
        check[next] = 1
        next = li[next]-1
    elif check[next] == 1:
        check[next] += 1
        res.append(next+1)
        next = li[next]-1
    else:
        cnt = len(res)
        k -= check.count(1)
        amari = k%cnt
        print(res[amari])
        break
else:
  amari=k%n
  ans=li[amari-1]
  print(ans)


### FIXED CODE ###

n, k = map(int, input().split())
li = list(map(int, input().split()))
 
check = [0] * (n+10)
res = []
next = 0
 
for i in range(k):
    if check[next] == 0:
        check[next] = 1
        next = li[next]-1
    elif check[next] == 1:
        check[next] += 1
        res.append(next+1)
        next = li[next]-1
    else:
        cnt = len(res)
        k -= check.count(1)
        amari = k%cnt
        print(res[amari])
        break
else:
    print(next+1)
#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

# = list(map(int,input().split()))

# = [list(map(int,input().split())) for _ in range(XXXX)]

t = list(input())

#print(t)

#pdはプラス2カウントできるので、できるだけpdを作るように置き換える。

for i in range(len(t)):
    if t[i] == "?":
        if i == 0:
            if t[i+1] == "D":
                t[i] = "P"
            else:
                t[i] = "D"
        elif i == len(t)-1:
            t[i] = "D"
        elif t[i-1] == "P":
            t[i] = "D"
        elif t[i+1] == "P":
            t[i] = "D"
        elif t[i+1] == "D":
            t[i] = "P"
        elif t[i+1] == "?":
            t[i] = "P"
            t[i+1] = "D"

print("".join(t))

### FIXED CODE ###

#from pprint import pprint
#from collections import deque
#from collections import defaultdict
#from collections import Counter
#from copy import deepcopy
#from itertools
#import sys 
#sys.setrecursionlimit(N) #N回まで再起を許可する。

# = map(int,input().split())

# = list(map(int,input().split()))

# = [list(map(int,input().split())) for _ in range(XXXX)]

t = list(input())

#print(t)

#pdはプラス2カウントできるので、できるだけpdを作るように置き換える。


for i in range(len(t)):
    if t[i] == "?":
        if i == len(t)-1:
            t[i] = "D"
        elif i == 0:
            if t[i+1] == "D":
                t[i] = "P"
            else:
                t[i] = "D"
        elif t[i-1] == "P":
            t[i] = "D"
        elif t[i+1] == "P":
            t[i] = "D"
        elif t[i+1] == "D":
            t[i] = "P"
        elif t[i+1] == "?":
            t[i] = "P"
            t[i+1] = "D"

print("".join(t))
n = int(input())
A = sorted(list(map(int, input().split())))
M = 10**6 + 1
L = [0]*M
ans = 0
for a in A:
    L[a] += 1
    if L[a] == 1:
        # k>=2として k*aは全て不適
        for i in range(2*a, M+1, a):
            L[i] += 2
# flagの数が答え
print(L.count(1))

### FIXED CODE ###

n = int(input())
A = sorted(list(map(int, input().split())))
M = 10**6 + 1
L = [0]*M
for a in A:
    L[a] += 1
    if L[a] == 1:
        # k>=2として k*aは全て不適
        for i in range(2*a, M, a):
            L[i] += 2
# flagの数が答え
print(L.count(1))
l = input().split()
n = int(l.join())

if n%4 == 0:print("Yes")
else:print("No")

### FIXED CODE ###

l = input().split()
n = int("".join(l))

if n%4 == 0:print("YES")
else:print("NO")
n, k = map(int, input().split())
l = sort(list(map(int, input().split())), reverse=True)
print(sum(l[:k]))


### FIXED CODE ###

n, k = map(int, input().split())
l = sorted(list(map(int, input().split())), reverse=True)
print(sum(l[:k]))
import math

r= float(input().rstrip().split(' ')

a = r * r * pi

b = 2 * pi * r

print(a, b)

### FIXED CODE ###

import math

r= float(input())

a = r * r * math.pi

b = 2 * math.pi * r

print(a, b)
N,x,MOD = map(int, input().split())
s = x
t_s = 0
for i in range(2,MOD + 1):
  if N == 1:
    break
  x = (x*x)%MOD
  s += x
  if i == N:
    break
res = N - i
init = x
t_s = x
cnt = 1
for i in range(MOD):
  if N == 1:
    break
  x = (x*x)%MOD
  if x == init:
    break
  cnt += 1
  t_s += x
if not N == 1:
  bai = res // cnt
  res = res %  cnt
  s += t_s * bai
if res > 0:
  for i in range(res):
    x = (x*x)%MOD
    s += x
print(s)

### FIXED CODE ###

N,x,MOD = map(int, input().split())
s = x
flag = False
sflag = False
if N == 1:
  flag = True
  sflag = True
  print(s)
for i in range(1,MOD):
  x = (x*x) % MOD
  s += x
  if N == (i+1):
    flag = True
    break
if flag == True:
  if sflag == False:
    print(s)
else:
  t_s = 0
  cnt = 0
  init = x
  for i in range(MOD):
    x = (x*x) % MOD
    t_s += x
    cnt += 1
    if x == init:
      break
  bi = (N-MOD)//cnt
  res = (N-MOD)%cnt
  s += t_s * bi
  for i in range(res):
    x = (x*x) % MOD
    s += x
  print(s)
"""
9 5
-4 -3 -2 -1 0 1 2 3
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Am = []
Ap = []
for a in A:
    if a < 0:
        Am.append(a)
    else:
        Ap.append(a)

mod = 10**9 + 7

ans = 1

if N == K:
    for a in A:
        ans *= a
        ans %= mod

elif A[-1] < 0:
    if K % 2 = 1
        for i in range(K):
            ans *= Am[-1-i]
            ans %= mod
    else:
        for i in range(K):
            ans *= Am[i]
            ans %= mod

else:
    if K%2 == 1:
        ans *= Ap[-1]
        ans %= mod
        K -= 1
        del Ap[-1]
    Amd = []     
    Apd = []
    for i in range(len(Ap)//2):
        Apd.append(Ap[-1-(2*i)]*Ap[-1-(2*i+1)])
    for i in range(len(Am)//2):
        Amd.append(Am[2*i]*Am[2*i+1])
    Apd.append(-1)
    Amd.append(-1)
    
    ip = 0
    im = 0
    while K > 0:
        if Apd[ip] >= Amd[im]:
            ans *= Apd[ip]
            ip += 1
        else:
            ans *= Amd[im]
            im += 1
        ans %= mod
        K -= 2


ans %= mod
print(ans)




### FIXED CODE ###

"""
9 5
-4 -3 -2 -1 0 1 2 3
"""

N,K = map(int,input().split())
A = list(map(int,input().split()))
A.sort()
Am = []
Ap = []
for a in A:
    if a < 0:
        Am.append(a)
    else:
        Ap.append(a)

mod = 10**9 + 7

ans = 1

if N == K:
    for a in A:
        ans *= a
        ans %= mod

elif A[-1] < 0:
    if K % 2 == 1:
        for i in range(K):
            ans *= Am[-1-i]
            ans %= mod
    else:
        for i in range(K):
            ans *= Am[i]
            ans %= mod

else:
    if K%2 == 1:
        ans *= Ap[-1]
        ans %= mod
        K -= 1
        del Ap[-1]
    Amd = []     
    Apd = []
    for i in range(len(Ap)//2):
        Apd.append(Ap[-1-(2*i)]*Ap[-1-(2*i+1)])
    for i in range(len(Am)//2):
        Amd.append(Am[2*i]*Am[2*i+1])
    Apd.append(-1)
    Amd.append(-1)
    
    ip = 0
    im = 0
    while K > 0:
        if Apd[ip] >= Amd[im]:
            ans *= Apd[ip]
            ip += 1
        else:
            ans *= Amd[im]
            im += 1
        ans %= mod
        K -= 2


ans %= mod
print(ans)
import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

for i in range(1, n):
    a[i] += a[i-1]
for i in range(1, m):
    b[i] += b[i-1]

I = bisect.bisect_right(a, k)
ans = bisect.bisect_right(b, k)
li = list(range(I))
li = li[::-1]
for i in li:
    tmp = bisect.bisect_right(b, k-a[i])
    if a[i] + b[tmp-1] <= k && tmp != 0:
        ans = max(ans, i+tmp+1)

print(ans)

### FIXED CODE ###

import bisect
n, m, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

a2 = [0] * (n + 1)
b2 = [0] * (m + 1)
for i in range(0, n):
    a2[i+1] = a[i] + a2[i]
for i in range(0, m):
    b2[i+1] = b[i] + b2[i]

ans = 0
for i in range(n+1):
    tmp = bisect.bisect_right(b2, k-a2[i]) - 1
    if a2[i] + b2[tmp] <= k and tmp >= 0:
        ans = max(ans, i+tmp)

print(ans)
x,y = list(map(int,input().split()))
if x < 10 and y < 10:
	print(x*y)
    exit()
else:
  print('-1')


### FIXED CODE ###

x,y = list(map(int,input().split()))
if x < 10 and y < 10:
	print(x*y)
else:
  print('-1')
N=int(input())
h=list(map(int,input().split()))
memo=[-1]*N
def a(j):
    if j==0:
        return 0
    elif j==1:
        return abs(h[1]-h[0])
    else:
        if memo[j]==-1:
            memo[j]=min(a(j-1)+abs(h[j]-h[j-1]),a(j-2)+abs(h[j]-h[j-2]))
        return memo[j]
print(a(N-1))

### FIXED CODE ###

N=int(input())
h=list(map(int,input().split()))
a=[0]*N
for j in range(1,N):
    if j==1:
        a[1]=a[0]+abs(h[1]-h[0])
    else:
        a[j]=min(a[j-1]+abs(h[j]-h[j-1]),a[j-2]+abs(h[j]-h[j-2]))
print(a[-1])
N,M,K = map(int,input().split())
# dp = [[0]*(K+2) for _ in range(2)]

# print (1)
# dp[0][0] = M
# MOD = 998244353
# for n in range(N-1):
#     n = n % 2
#     a = (n+1) % 2
#     dp[a] = [0]*(K+2) 
#     for k in range(K+1):
        
        
        
#         dp[a][k] += dp[n][k] * (M-1)
#         dp[a][k+1] += dp[n][k]
#         dp[a][k] %= MOD
#         dp[a][k+1] %= MOD
# #print (dp)
# print(sum(dp[(N+1)%2][:-1]))
import numpy as np
old = np.zeros(K+1).astype(np.int)
MOD = 998244353
old[0] = M
for n in range(N-1):
    new = old*(M-1)
    new[1:] += old[:K]
    new %= MOD
    old = new
print (sum(new)%MOD)

### FIXED CODE ###

N,M,K = map(int,input().split())
MOD = 998244353
ans = 0


fact = [1] * (N+1) # 階乗を格納するリスト
factinv = [1] * (N+1) # 階乗を格納するリスト



for i in range(N):
    fact[i+1] = fact[i] * (i+1) % MOD # 階乗を計算
    factinv[i+1] = pow(fact[i+1], MOD-2, MOD)# MODを法とした逆元

def nCk(n,k): # 組み合わせ(MOD)を返却する
    return fact[n] * factinv[n-k] * factinv[k] % MOD

def solve(k):
    r = M * pow(M-1,N-1-k,MOD) * nCk(N-1,k)
    return r

for k in range(K+1):
    ans += solve(k)
    ans %= MOD
print (ans)
h = list(map(int,input().split()))

ans = 0

cnt= 0

for i in range(n-2):
    if h[i]>=h[i+1]:
        cnt +=1
        if cnt > ans:
            ans = cnt
        else:
            cnt = 0
            
print(ans)

### FIXED CODE ###

n = int(input())

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

ans = 0

cnt= 0

for i in range(n-1):
    if h[i]>=h[i+1]:
        cnt +=1
        if cnt > ans:
            ans = cnt
    else:
        cnt = 0
            
print(ans)
N = int(input())
pow = 1
for i in range(1,N+1):
        pow = pow*i10**9+7
print(pow)

### FIXED CODE ###

N = int(input())
pow = 1
num = 10**9+7
for i in range(1,N+1):
        pow = pow*i%num
print(pow%num)
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
M = list(map(int, input().split()))

def exhastive_search(target, head, sum):
    for i in range(head, N):
        sum += A[i]
        if target == sum:
            return True
        elif target > sum:
            if exhastive_search(target, i+1, sum):
                return True
            sum -= A[i]
        else:
            sum -= A[i]
    return False


for target in M:
    sum = 0
    result = "no"
    for i in range(N):
        if exhastive_search(target, i, sum):
            result = "yes"
            break
    print(result)


### FIXED CODE ###

def solve(dp, a, i, m):
  if m in dp[i]:
    return dp[i][m]

  if m == 0:
    dp[i][m] = True
  elif i >= len(a):
    dp[i][m] = False
  elif solve(dp, a, i+1, m):
    dp[i][m] = True
  elif solve(dp, a, i+1, m-a[i]):
    dp[i][m] = True
  else:
    dp[i][m] = False

  return dp[i][m]

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

dp = {}
for i in range(N+1):
  dp[i] = {}

for m in M:
  if solve(dp, A, 0, m):
    print('yes')
  else:
    print('no')
n = int(input())
a = sorted([int(i) for i in input().split()])

MAX_VAL = 2*10**5
prime = [1] * (MAX_VAL+1)
prime[0] = prime[1] = 0
for i in range(2, int(MAX_VAL**0.5)+1):
    if prime[i]:
        for k in range(2*i, MAX_VAL+1, i):
            prime[k] = 0

res = []
for i in range(n):
    prev = a[i-1] if i > 0 else -1
    next = a[i+1] if i < n-1 else -1
    if a[i] == prev or a[i] == next:
        continue
    if prime[a[i]]:
        res.append(a[i])
        continue

    for v in res:
        if a[i] % v == 0:
            break
    else:
        res.append(a[i])

print(len(res))


### FIXED CODE ###

import numpy as np

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

non_divisible = np.ones(a[-1]+1, dtype=np.int8)
non_divisible[0] = 0
for i in range(n):
    if i != 0 and a[i] == a[i-1]:
        non_divisible[a[i]] = 0
    elif non_divisible[a[i]]:
        non_divisible[a[i]*2::a[i]] = 0

res = 0
for aa in a:
    if non_divisible[aa]:
        res += 1

print(res)
n = input()
a = n / 1.08
if float(n%1.08):
      x = int(a)
else:
      x = int(a) + 1
v = int(x * 1.08)
if v == n:
  print(x)
else:
  print(":(")

### FIXED CODE ###

M1, D1 = map(int, input().split())
M2, D2 = map(int, input().split())

if D2-D1 == 1:
  print(0)
else:
  print(1)
s = int(input())
l = 10**9+7
list_1 = [0, 1, 1, 1]
list_2 = [0, 1, 2]
for i in range(3, s):
  list_2.append((list_2[i-1] + list_1[i])%l)
  list_1.append(list_2[i-2])
if s = 1 or s = 2:
  print(0)
else:
  print(list_1[s-1])


### FIXED CODE ###

s = int(input())
l = 10**9+7
list_1 = [0, 1, 1, 1]
list_2 = [0, 1, 2]
for i in range(3, s):
  list_2.append((list_2[i-1] + list_1[i])%l)
  list_1.append(list_2[i-2])
if s == 1 or s == 2:
  print(0)
else:
  print(list_1[s-1])
N,K = map(int, input().split())
l = input()
lrev = l[::-1]
print(sum(lrev[:K]))


### FIXED CODE ###

N,K = map(int, input().split())
l = list(map(int,input().split()))
l.sort()
lrev = l[::-1]
print(sum(lrev[:K]))