Harryxun/stf_run huggingface dataset:
n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7

import sys
sys.setrecursionlimit(100000)

dp = [0] * (n+1) 
dp[0] = 1
def dps(cnt,cantvisit):
    if cnt == n + 1 :
        return 
    else :
        if cnt == 1 :
            if cnt in cantvisit :
                dp[cnt] = 0
                cnt +=1
            else : 
                dp[cnt] = 1
                cnt += 1
        else :
            if cnt in cantvisit : 
                dp[cnt] = 0 
                cnt += 1
            else :
                dp[cnt] = dp[cnt-1] + dp[cnt-2]
                cnt += 1
    return dps(cnt,cantvisit)
dps(1,para)
print("{}".format(dp[-1]%mod))

### FIXED CODE ###

n,m = map(int,input().split())
para = [int(input()) for i in range(m)]
mod = 10**9+7
dp = [-1]*(n+1)
for i in para:
    dp[i] = 0
for i in range(n+1):
    if  dp[i] != 0 :
        if i == 1 or i==0:
            dp[i] = 1
        else:
            dp[i] = (dp[i-1] + dp[i-2])%mod



print("{}".format(dp[-1]))
n = input()
a = list(map(int, input().split()))
cnt = 0
while all(i%2==0 for i in a):
    a = [i/2 for i in a]
    cnt += 1
print(cnt)

### FIXED CODE ###

print(input().count("1"))
n = int(input())
A = [int(x) for x in input().split()]

p = 10**9 + 7

found = {}
for i, a in enumerate(A):
    if a in found:
        dup = a
        dup_1 = found[a]
        dup_2 = i
    found[a] = i

from functools import lru_cache

@lru_cache(maxsize=None)
def gfp_inv(x, p):
    return pow(x, p - 2, p)

from itertools import chain, accumulate
memo_fact = list(chain([1], accumulate(range(1, 10**5 + 1), lambda a, x: a * x % p)))

def comb(n, m):
    if m < 0 or n < m: return 0
    if n == m: return 1
    return memo_fact[n] * gfp_inv(memo_fact[n - m], p) * gfp_inv(memo_fact[m], p) % p

intv = dup_2 - dup_1 - 1
for k in range(1, n + 2):
    ans = comb(n + 1, k)
    ans -= comb(n + 1 - intv - 2, k - 1)
    print(ans % p)

### FIXED CODE ###

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

p = 10**9 + 7

found = {}
for i, a in enumerate(A):
    if a in found:
        dup = a
        dup_1 = found[a]
        dup_2 = i
    found[a] = i

from functools import lru_cache

@lru_cache(maxsize=None)
def gfp_inv(x, p):
    return pow(x, p - 2, p)

from itertools import chain, accumulate
memo_fact = list(chain([1], accumulate(range(1, 10**5 + 2), lambda a, x: a * x % p)))

def comb(n, m):
    if m < 0 or n < m: return 0
    if n == m: return 1
    return memo_fact[n] * gfp_inv(memo_fact[n - m], p) * gfp_inv(memo_fact[m], p) % p

intv = dup_2 - dup_1 - 1
for k in range(1, n + 2):
    ans = comb(n + 1, k)
    ans -= comb(n + 1 - intv - 2, k - 1)
    print(ans % p)
def main():
    word = input()
    count = {}
    for w in word:
        if w in count:
            count[w] += 1
        else:
            count[w] = 1
    count = sorted(count.items(), key=lambda x: x[1])
    target_list = []
    if count[-1][1] == 1:
        target_list.append(word[len(word) // 2])
    else:
        for i in range(-1, -len(word) - 1, -1):
            if count[i][1] == count[-1][1]:
                target_list.append(count[i][0])
            else:
                break
    answer = float("inf")
    for target in target_list:
        now_ans = 0
        now_word = word
        while len(set(now_word)) > 1:
            tmp = ""
            for i in range(len(now_word) - 1):
                if now_word[i] == target or now_word[i + 1] == target:
                    tmp += target
                else:
                    tmp += now_word[i]
            now_word = tmp
            now_ans += 1
        answer = min(answer, now_ans)
    print(answer)


if __name__ == '__main__':
    main()



### FIXED CODE ###

from string import ascii_lowercase


def main():
    word = input()
    target_list = list(ascii_lowercase)
    answer = float("inf")
    for target in target_list:
        now_ans = 0
        now_word = word
        while len(set(now_word)) > 1:
            tmp = ""
            for i in range(len(now_word) - 1):
                if now_word[i] == target or now_word[i + 1] == target:
                    tmp += target
                else:
                    tmp += now_word[i]
            now_word = tmp
            now_ans += 1
        answer = min(answer, now_ans)
    print(answer)


if __name__ == '__main__':
    main()
S = input()
K = int(input())
a = []
ans = 0
count = 0
for i in range(len(S)-1):
    if S[i] == S[i+1] :
        count += 1
    else:
        if count!=0:
            ans += (count+1)//2
            a.append(count+1)
            count = 0
if count !=0:
    ans += (count+1)//2 
ans = ans*K
if (count+1+a[0])%2 == 0  and len(a)!=0 and S[0]==S[1] :
    ans+=K-1

print(ans)


### FIXED CODE ###

S = input()
K = int(input())
a = []
ans = 0
count = 0
for i in range(len(S)-1):
    if S[i] == S[i+1] :
        count += 1
    else:
        if count!=0:
            ans += (count+1)//2
            a.append(count+1)
            count = 0
if count !=0:
    ans += (count+1)//2 
ans = ans*K
a.append(0)
if len(S) == 1:
    ans = K//2
else:    
    
    if (count+1)%2==1 and a[0]%2 == 1 and S[0]== S[1] and S[0] == S[len(S)-1]:
    
        ans+=K-1
    if S[0]!= S[1] and (count+1)%2 ==1 and  S[0] == S[len(S)-1]:
        ans+=K-1
    if count+1 == len(S):
        if len(S)%2==1:
            ans = (len(S)*K)//2
 
print(ans)
a,b,x = map(int,input())
if (a < x <(a+b)):
    print('YES')
else:
    print('NO')

### FIXED CODE ###

a,b,x = map(int,input().split())
if (a <= x <= (a+b)):
    print('YES')
else:
    print('NO')
r=input()
if r<1200:
  print("ABC")
elif r<2800:
  print("ARC")
else:
  print("AGC")

### FIXED CODE ###

r=int(input())
if r<1200:
  print("ABC")
elif r<2800:
  print("ARC")
else:
  print("AGC")
a,b = map(int,input().split())
s = max(2*a,2*b,a+b)
if s == 2 *a or s==2*b and 2*a != a+b and 2*b != a+b
    print(s-1)
else:
    print(s)

### FIXED CODE ###

a,b = map(int,input().split())
if a >b:
    print(2*a-1)
elif a == b:
    print(a+b)
else:
    print(2*b-1)
from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = 0
for i in range(len(pp)//2+1):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2,(pp[-1-i]-pp[-1-i-K]+K)/2)
print(ans)

### FIXED CODE ###

from itertools import accumulate
N,K = map(int,input().split(" "))
p = list(map(int,input().split(" ")))
pp = list(accumulate(p))
ans = (pp[K-1]+K)/2
for i in range(N-K):
    ans = max(ans,(pp[i+K]-pp[i]+K)/2)
print(ans)
# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)
 
def main():
	N, M = map(int, input().split(" "))
	#N = int(input())
	#S = input()

	A = input().split(" ")
	A = list(A)
	#A = A[:-1]
	A = [int(s) for s in A]

	BC = []
	for i in range(M):
		b, c = map(int, input().split(" "))
		BC.append((c, b))

	BC.sort(reverse=True)
	A.sort()
	A_tmp = A[:]

	ans = 0
	for i in BC:
		#print(A_tmp)
		c, b = i
		if A_tmp[0] >= c:
			continue

		tmp = bisect_left(A_tmp, c)
		if tmp <= b:
			A_tmp[:tmp] = [c] * tmp
			A_tmp = A_tmp[tmp:]
			ans = ans + (c * tmp)

		elif tmp > b:
			A_tmp[:b] = [c] * b
			A_tmp = A_tmp[b:]
			ans = ans + (c * b)
		
		A_tmp.sort()

	print(ans + sum(A_tmp))


if __name__ == "__main__":
	main()

### FIXED CODE ###

# -*- coding: utf-8 -*-
import sys
import math
from bisect import bisect_left
from bisect import bisect_right
import collections
import copy
import heapq
input = sys.stdin.readline
 
# bisect_left(lists, 3)
# bisect_right(lists, 3)

# heapq.heapify(a) #リストaのheap化
# heapq.heappush(a,x) #heap化されたリストaに要素xを追加
# heapq.heappop(a) #heap化されたリストaから最小値を削除＆その最小値を出力

# heapq.heappush(a, -x) #最大値を取り出す時は、pushする時にマイナスにして入れよう
# heapq.heappop(a) * (-1) #取り出す時は、-1を掛けて取り出すこと

def main():
	N, M = map(int, input().split(" "))
	#N = int(input())
	#S = input()

	A = input().split(" ")
	A = list(A)
	#A = A[:-1]
	A = [(int(s) * (-1), 1) for s in A]
	heapq.heapify(A)

	for i in range(M):
		b, c = map(int, input().split(" "))
		heapq.heappush(A, (c * (-1), b))
	
	ans = []
	for i in range(N):
		t, con = heapq.heappop(A)
		for _ in range(con):
			if len(ans) == N:
				print(sum(ans))
				sys.exit()
			ans.append(t * (-1))
	print(sum(ans))


if __name__ == "__main__":
	main()
N,K = map(int, input().split())
sump=0
P = list(map(int,input().split()))
P.sort(reverse=True)
for i in range(K):
    p = P[i]*(P[i]+1)/(2*P[i])
    sump += p
print(f'{sump:.12f}')

### FIXED CODE ###

N,K = map(int, input().split())
P = list(map(int,input().split()))
Px  =[]
for i in range(N):
    Px.append((1+P[i])/2)
temp_num = sum(Px[0:K])
temp_max = sum(Px[0:K])
#print(Px)
for j in range(N-K):
    #print(temp_num)
    temp_num = temp_num-Px[j]+Px[j+K]
    if temp_max <temp_num:
        temp_max=temp_num
print(temp_max)
n =int(input())
print(len([i for i in range(1, n+1) if int(log10(i)+1) % 2 != 0 and i <= n]))

### FIXED CODE ###

from math import log10
n = int(input())
cnt = 0
for i in range(1,n+1):
  if int(log10(i)+1) % 2 != 0 and i <= n:
    cnt += 1
print(cnt)
a = int(input())
import math
print("{:.7f} {:.7f}".format(a ** 2 * math.pi, 2 * a * math.pi))

### FIXED CODE ###

a = float(input())
import math
print("{:.5f} {:.5f}".format(a ** 2 * math.pi, 2 * a * math.pi))
N=int(input())
H=list(map(int,input().split()))
a=[0]*N
for i in range(1,N):
	if(H[i-1]>=H[i]):
		a[i]=a[i-1]+1

import numpy as np
print(np.max(a))


### FIXED CODE ###

N=int(input())
H=list(map(int,input().split()))
a=[0]*N
max_i=0
for i in range(1,N):
	if(H[i-1]>=H[i]):
		a[i]=a[i-1]+1
		if(max_i<a[i]):max_i=a[i]
print(max_i)
a, b = map(int, input().split())
if x + y >= 10: print("error")
else: print(x+y)

### FIXED CODE ###

a, b = map(int, input().split())
if a + b >= 10: print("error")
else: print(a+b)
s = input()

ans = 0

rs = s.copy()
rs = rs[::-1]

for i in range(len(s)//2):
    if s[i] != rs[i]:
        ans += 1
        
print(ans)

### FIXED CODE ###

s = list(input())

ans = 0

rs = s.copy()
rs = rs[::-1]

for i in range(len(s)//2):
    if s[i] != rs[i]:
        ans += 1
        
print(ans)
data = input()
data_list = [c for c in data]
#print(data_list)
count = 0
delete_count = 0
while ('0' in data_list) and ('1' in data_list):
    #print("count" + str(count))
    if data[count] != data[count + 1]:
        data_list.pop(count)
        data_list.pop(count)
        delete_count += 2
    else:
        count += 1

  #  print(data_list)
 #   print("delete_count" + str(delete_count))
    #if delete_count >= len(data_list) // 2:
    #   break

#print(data_list)
print(delete_count)



### FIXED CODE ###

data = input()
data_list = [c for c in data]
# print(data_list)
count = 1
delete_count = 0
number_of_one = data_list.count('1')
number_of_zero = data_list.count('0')

min_num = min(number_of_zero, number_of_one)
print(min_num * 2)
N=int(input())
a=int(input())
if N%500=<a:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

N=int(input())
a=int(input())
if N%500<=a:
    print("Yes")
else:
    print("No")
import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            max(counter.keys()) + 1]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))


### FIXED CODE ###

import collections


def mod_pow(a, n, mod):
    result = 1
    a_n = a
    while n > 0:
        if n & 1:
            result = result * a_n % mod
        a_n = a_n * a_n % mod
        n >>= 1
    return result


def main(n, d):
    MOD = 998244353
    counter = collections.Counter(d)
    if counter[0] != 1 or d[0] != 0:
        return 0
    pows = [mod_pow(a=counter[i - 1], n=counter[i], mod=MOD) for i in
            range(1, max(counter.keys()) + 1)]
    patterns = 1
    for p in pows:
        patterns *= p
        patterns %= MOD
    return patterns


if __name__ == '__main__':
    N = int(input())
    D = list(map(int, input().split()))
    print(main(n=N, d=D))
N, K = map(int, input().split())
number = [0 for i in range(N+1)]
for i in range(N):
  a, b = map(int, input().split())
  number[a] += b
for i in range(N):
  if K - number[i+1] <= 0:
    print(i+1)
  else:
    K -= number[i+1]
   


### FIXED CODE ###

N, K = map(int, input().split())
a = []
b = []
hairetu = []
for i in range(N):
    A, B = map(int, input().split())
    hairetu.append([A, B])

hairetu.sort()
for i in range(N):
    K -= hairetu[i][1]
    if K <= 0:
        print(hairetu[i][0])
        break
s=input()
n=len(s)
t=int(input())
if t==1:
    print(s)
    exit()
ans=set()
for l in range(n-1):
    for r in range(1,min(t,n-l)):
        ans.add(s[l:r])
aa=list(ans)
aa.sort()
print(aa[t-1])

### FIXED CODE ###

s = input()
l = len(s)
k = int(input())
A = set()
for i in range(l):
    for j in range(1, 6):
        if i+j <= l:
            A.add(s[i:i+j])
ANS = sorted(A)
print(ANS[k-1])
a,b,c,d=map(int, input().split)
n=int(input)
oneltr=min(4*a, 2*b, c, 2*a+b)
twoltr=min(8*a, 4*b, 2*c, d, c+2*b, c+b+2*a,c+4*a,4*a+2*b,b+6*a,3*b+2*a)

if(n%2==0) :
                   print(n//2*twoltr)
else :
                    print(oneltr+(n-1)//2*twoltr)


### FIXED CODE ###

a,b,c,d=map(int,input().split())
n=int(input())

twoval=min(8*a,4*a+2*b,4*b,2*b+c,2*c,d)
oneval=min(4*a,2*b,2*a+b,c)

if n%2==0:
    print(twoval*(n//2))
else:
    print(oneval+twoval*((n-1)//2))
b=str(input())
print(b.translate(b.maketrans({'A':'x'},{'C':'y'},{'T':'A'},{'G':'C'},{'x':'C'},{'y':'G'})))

### FIXED CODE ###

b=str(input())
print(b.translate(b.maketrans({'A':'T','C':'G','T':'A','G':'C'})))
N = int(input())
H = list(map(int, input().split()))

dp = [0]*(N+2)
for i in range(N):
    dp[i+1] = min(dp[i+1], dp[i]+abs(H[i+1]-H[i]))
    dp[i+2] = min(dp[i+2], dp[i]+abs(H[i+2]-H[i]))
print(dp[N-1])


### FIXED CODE ###

N = int(input())
h = list(map(int,input().split()))
dp = [0] * N
for i in range(1, N):
    if i == 1:
        dp[i] = abs(h[1] - h[0])
    else:
        dp[i] = min(abs(h[i] - h[i-1])+dp[i-1], abs(h[i] - h[i-2])+dp[i-2])
print(dp[N-1])
s,c = map(int,input().split())
res = 0

if s*2 <= c:
    res += s
    c -= s*2
    res+= c
else:
    res += c//2
    c //= 2
if c:
    res += m//4
print(res)

### FIXED CODE ###

s,c = map(int,input().split())
res = 0
if s*2 <= c:
    res = s
    c -= s*2
    s = 0
else:
    res += c//2
    c = 0

if c:
    res += c//4
print(res)
a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())

def dfs(x, i, m, v):
  	if x < 0: return 0
  	if x == 0: return 1
  	if i == 2: return 1 if x % 50 else 0  	
  	r = 0
  	for k in range(0, m[i] + 1): r += dfs(x - k * v[i], i + 1, m, v)
  	return r
m,v = {0:a,1:b,2:c}, {0:500,1:100,2:50}
print dfs(x,0,m,v)


### FIXED CODE ###

n,mat = raw_input(),[ map(int,raw_input().split()) for i in range(2)]
def f(mat,i,j):
	if i<0 or j <0:
		return -float('inf')
	if i == 0 and j == 0:
		return mat[i][j] 
	return mat[i][j] + max(f(mat,i-1,j),f(mat,i,j-1))
print f(mat,1,len(mat[0])-1)
n, q = map(int, input().split())
s = list(input())
quiz = [list(map(int, input().split())) for _ in range(q)]

cnt_list = [0]*n
jufge = 0

for i in range(n):
    if s[i] == "A":
        judge = 1
        cnt_list[i] = cnt_list[i-1]
    elif judge == 1 and s[i] == "C":
        judge = 0
        cnt_list[i] = cnt_list[i-1] + 1
    else:
        cnt_list[i] = cnt_list[i-1]

for i in range(q):
    print(cnt_list[quiz[i][1] - 1] - cnt_list[quiz[i][0]-1])

### FIXED CODE ###

n, q = map(int, input().split())
s = list(input())
quiz = [list(map(int, input().split())) for _ in range(q)]

cnt_list = [0]*n
judge = 0

for i in range(n):
    if s[i] == "A":
        judge = 1
        cnt_list[i] = cnt_list[i-1]
    elif judge == 1 and s[i] == "C":
        judge = 0
        cnt_list[i] = cnt_list[i-1] + 1
    else:
        judge = 0
        cnt_list[i] = cnt_list[i-1]

for i in range(q):
    print(cnt_list[quiz[i][1] - 1] - cnt_list[quiz[i][0]-1])
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n,m = MAP()
a = [INT() for _ in range(m)]
dp = [0 for _ in range(n+2)]
dp[0] = 0
dp[1] = 1
j = 0
for i in range(2, n+2):
    if a[j] != i - 1:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
    else:
        dp[i] = 0
        if j < m - 1:
            j += 1
print(dp[n+1])

### FIXED CODE ###

import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7

n,m = MAP()
a = [INT() for _ in range(m)]
dp = [0 for _ in range(n+2)]
dp[0] = 0
dp[1] = 1
j = 0
for i in range(2, n+2):
    if j >= m or a[j] != i - 1:
        dp[i] = dp[i-1] + dp[i-2]
        dp[i] %= mod
    else:
        dp[i] = 0
        j += 1
print(dp[n+1])
n = int(input())
a = sorted(list(map(int, 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):
    if a[i] == a[i-1]:
        if res and a[i] == res[-1]:
            res.pop()
        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 = int(input())
x = [int(input()) for i in range(N)]

y=[0]*(100000+1)


for i in range(N):
    if y[x[i]]==0:
        y[x[i]]=1
    else:
        y[x[i]]=0

sum=0
for i in y:
    sum+=i

print(sum)

### FIXED CODE ###


N = int(input())
x = [int(input()) for i in range(N)]

x.sort()
i=0
while i < N-1:
    if x[i]==x[i+1]:
        del x[i+1]
        del x[i]
        N-=2
        continue
    i+=1
print(len(x))
import heapq
import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ansC = []

N, K = LI()
V = LI()
dp = [[[0]]*(K+1) for _ in range(K+1)]
right = [0]*N
left = [0]*N
#right[1] = V[-1]
#left[1] = V[0]

for i in range(min(N,K+1)):
    for j in range(min(N+1,K-i+1)):
        dp[i][j] = [V[:i]+V[N-j:]+[0]]
        dp[i][j][0].sort()

#print(dp)

for i in range(min(N,K)):
    for j in range(min(N,K)):
        if i+j!=0:
            t = K - (i + j)
            for l in range(t):
                if dp[i][j]!=[]:
                    m = dp[i][j][0][0]
#                    print(m)
                    if m < 0:
                        del dp[i][j][0][0]
#            print(i,j)
#            print(dp[i][j])
            if dp[i][j][0]:
#                print(dp[i][j][0])
                ansC.append(sum(dp[i][j][0][::]))

#print(ansC)
print(max(ansC,0))

### FIXED CODE ###

import sys
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
mod = 10**9 + 7
inf = float('inf')
ansC = []

N, K = LI()
V = LI()
dp = [[[0]]*(K+1) for _ in range(K+1)]
right = [0]*N
left = [0]*N
#right[1] = V[-1]
#left[1] = V[0]

for i in range(min(N+1,K+1)):
    for j in range(min(N+1,K-i+1)):
        if i<N-j:
            dp[i][j] = [V[:i]+V[N-j:]+[0]]
        else:
            dp[i][j] = [V+[0]]
        dp[i][j][0].sort()

#print(dp)

for i in range(min(N+1,K+1)):
    for j in range(max(0,min(N+1,K-i+1))):
        if i+j!=0:
            t = max(K - (i + j),0)
            for l in range(t):
                if dp[i][j]!=[]:
                    m = dp[i][j][0][0]
#                    print(m)
                    if m < 0:
                        del dp[i][j][0][0]
#            print(i,j)
#            print(dp[i][j])
            if dp[i][j][0]:
#                print(dp[i][j][0])
                ansC.append(sum(dp[i][j][0][::]))

#print(ansC)
if ansC:
    print(max(ansC))
else:
    print("0")
A,B,K = map(int,input().split())
x = []
if A >= B:
    for i in range(1,A):
        if A % i == 0 and B % i == 0:
            x.append(i)
else:
    for i in range(1,B):
        if A % i == 0 and B % i == 0:
            x.append(i)

print(x[K-1])
  

### FIXED CODE ###

a, b, k = map(int, input().split())
print([i for i in range(1,101) if a%i+b%i<1][-k])
n,m=map(int,input().split());print((min(2*n,m)+m)//4)

### FIXED CODE ###

n=int(input())
print(n*800-n//15*200)
N = int(input())
a = map(int, input().split())
l = [0]*10**5+2
ans = 0
num = 0

for i in a:
    l[i] +=1
    l[i+1] +=1
    l[i+2] +=1


print(max(l))

### FIXED CODE ###

N = int(input())
a = list(map(int, input().split()))
l = [0]*(10**5+2)

for i in a:
    l[i] +=1
    l[i+1] +=1
    l[i+2] +=1

print(max(l))
n=int(input())
for i in range(n):
    p=list(map(int,input().split()))
    p.sort()
    a=x[0]
    b=x[1]
    c=x[2]
    if a*a+b*b==c*c:
        print('YES')
    else:
        print('NO')


### FIXED CODE ###

n=int(input())
for i in range(n):
    a,b,c = input().split()
    x = int(a)
    y = int(b)
    z = int(c)
    p = [x,y,z]
    p.sort()
    if pow(p[0],2) + pow(p[1],2) == pow(p[2],2):
        print('YES')
    else:
        print('NO')
import sys
h,w=map(int,input().split())
maze=[]
for i in range(w):
    maze.append(list(input()))
for i in range(w):
    for j in range(h):
        if maze[i][j]=="#":
            flg=False
            for l,m in [(0,1),(1,0),(-1,0),(0,-1)]:
                if 0<=i+l<w and 0<=j+m<h and maze[i+l][j+m]=="#":
                    flg=True
            if flg==False:
                print("No")
                sys.exit()
print("Yes")

### FIXED CODE ###

import sys
h,w=map(int,input().split())
maze=[]
for i in range(h):
    maze.append(list(input()))
for i in range(h):
    for j in range(w):
        if maze[i][j]=="#":
            flg=False
            for l,m in [(0,1),(1,0),(-1,0),(0,-1)]:
                if 0<=i+l<h and 0<=j+m<w:
                    if maze[i+l][j+m]=="#":
                        flg=True
            if flg==False:
                print("No")
                sys.exit()
print("Yes")
a, b = input(), input()

if a == "H":
    print(b)
else:
    if b == "H":
        print("D")
    else:
        print("H")

### FIXED CODE ###

a, b = map(str, input().split())

if a == "H":
    print(b)
else:
    if b == "H":
        print("D")
    else:
        print("H")