Harryxun/stf_run huggingface dataset:
from collections import Counter

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

c=Counter(s)
m=max(c.values())
ans = sorted(k for k,v in c.items() if v == m)
print("\n".join(ans))

### FIXED CODE ###

from collections import Counter

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

c=Counter(S)
m=max(c.values())
ans = sorted(k for k,v in c.items() if v == m)
print("\n".join(ans))
a,b,c,d=map(int.input().split())
if a*b>=c*d:
  print(a*b)
else:
  print(c*d)

### FIXED CODE ###

a,b,c,d=map(int,input().split())
if a*b>=c*d:
  print(a*b)
else:
  print(c*d)
n=int(input())
h=list(map(int,input().split()))
ans="Yes"
hmax=h[0]
for i in range(1,n):
    if a[i]<hmax-1:
        ans="No"
        break
    else:
        hmax=max(hmax,a[i])
print(ans)

### FIXED CODE ###

n=int(input())
h=list(map(int,input().split()))
ans="Yes"
hmax=h[0]
for i in range(1,n):
    if h[i]<hmax-1:
        ans="No"
        break
    else:
        hmax=max(hmax,h[i])
print(ans)
s=list(input().split(""))
t=list(input().split(""))
ans = 0
for i in range(3):
  if s[i]==t[i]
  ans+=1
print(ans)

### FIXED CODE ###

s=list(str(input()))
t=list(str(input()))
ans = 0
for i in range(3):
  if s[i]==t[i]:
    ans+=1
print(ans)
import sys

# input処理を高速化する
input = sys.stdin.readline

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

    # dp[i][j] := 最初の i 枚のコインを投げたときに、表が j 枚となる確率
    # 次のコインが表: dp[i+1][j+1] += dp[i][j]∗p[i]
    # 次のコインが裏: dp[i+1][j] += dp[i][j]∗(1.0−p[i])
    dp = [[0] * (N+1) for i in range(N+1)]

    # 初期条件
    dp[0][0] = 1.0

    for i in range(N):
        for j in range(N):
            dp[i+1][j+1] += dp[i][j] * lst_p[i]
            dp[i+1][j] += dp[i][j] * (1.0 - lst_p[i])
    
    ans = sum(dp[(N//2+1):])

    print(ans)

main()

### FIXED CODE ###

import sys

# input処理を高速化する
input = sys.stdin.readline

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

    # dp[i][j] := 最初の i 枚のコインを投げたときに、表が j 枚となる確率
    # 次のコインが表: dp[i+1][j+1] += dp[i][j]∗p[i]
    # 次のコインが裏: dp[i+1][j] += dp[i][j]∗(1.0−p[i])
    dp = [[0] * (N+1) for i in range(N+1)]

    # 初期条件
    dp[0][0] = 1.0

    for i in range(N):
        for j in range(N):
            dp[i+1][j+1] += dp[i][j] * lst_p[i]
            dp[i+1][j] += dp[i][j] * (1.0 - lst_p[i])
    
    ans = 0
    for i in range((N+1)//2, N+1):
        ans += dp[N][i]

    print(ans)

main()
from collections import deque

N, K =map(int, input().split())
V=list(map(int, input().split()))
Vd = deque(V)

score = 0

for a in range(min(K,N)+1):

  for b in range(K-a+1):
    hou = []
    Vd = deque(V)
    for _ in range(a):
      hou.append(Vd.popleft())
    for _ in range(b):
      hou.append(Vd.pop())
    hou.sort()
    for _ in range(K-a-b):
      if hou:
        if hou[0]>0:
          break
        hou.pop(0)
    score = max(score,sum(hou))
    
print(score)
      

### FIXED CODE ###

from collections import deque

N, K =map(int, input().split())
V=list(map(int, input().split()))
Vd = deque(V)
score = 0

for a in range(min(K,N)+1):
  for b in range(min(K-a+1,N-a+1)):
    hou = []
    Vd = deque(V)
    for _ in range(a):
      hou.append(Vd.popleft())
    for _ in range(b):
      hou.append(Vd.pop())
    hou.sort()
    for _ in range(K-a-b):
      if hou:
        if hou[0]>0:
          break
        hou.pop(0)
    score = max(score,sum(hou))
    
print(score)
N = int(input())

total = 0
for i in range(1,n+1):
    total += N

    if N % total == 0:
        print('Yes')
    else:
        print('No')


### FIXED CODE ###

def f(n):
  return sum(map(int, str(n)))

X = int(input())

if X % f(X) == 0: 
  print("Yes")
else:
  print("No")
S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3] or S[3]==S[4]:
    print('Bad')
else:
    print('Good')

### FIXED CODE ###

S = input()
if S[0]==S[1] or S[1]==S[2] or S[2]==S[3]:
    print('Bad')
else:
    print('Good')
# -*- coding: utf-8 -*-

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]
 
    tokens = lines[0].split(" ")
    n = int(tokens[0])
    tokens = lines[1].split(" ")
    s = tokens[0]

    return (n, s)


def solve(n, s):

    d = dict([(c, 0) for c in "abcddfghijklmnopqrstuvwxyz"])

    for c in s:
        d[c] = d[c] + 1

    count = 1
    for v in [v for v in d.values() if v > 0]:
        count = count * (v+1)
    

    return (count - 1) %(10**9+7)

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()


### FIXED CODE ###

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

import sys

def parse_input(lines_as_string = None):


    lines = []
    if lines_as_string is None:
        lines.append(input())
        lines.append(input())
    else:
        lines = [e for e in lines_as_string.split("\n")][1:-1]
 
    tokens = lines[0].split(" ")
    n = int(tokens[0])
    tokens = lines[1].split(" ")
    s = tokens[0]

    return (n, s)


def solve(n, s):

    d = dict([(c, 0) for c in "abcdefghijklmnopqrstuvwxyz"])

    for c in s:
        d[c] = d[c] + 1

    count = 1
    for v in [v for v in d.values() if v > 0]:
        count = count * (v+1)
    

    return (count - 1) %(10**9+7)

def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
import math
N = int(input())
li = list(map(int, input().split()))
ans = math.inf
for i in li:
    cnt = 0
    if i%2==0:
        tudukeru = True
    else:
        tudukeru = False
        ans = 0
    while tudukeru:
        if i%2 == 0:
            i = i//2
            cnt += 1
        else:
            tudukeru = False
            if cnt < ans:
                ans = cnt
print(ans)

### FIXED CODE ###

N = int(input())
li = list(map(int, input().split()))
ans = float('inf')
for i in li:
    cnt = 0
    if i%2==0:
        tudukeru = True
    else:
        tudukeru = False
        ans = 0
    while tudukeru:
        if i%2 == 0:
            i = i//2
            cnt += 1
        else:
            tudukeru = False
            if cnt < ans:
                ans = cnt
print(ans)
n, m = map(int, input().split())
color = [0] * n 
path = [[] for _ in range(m)]

for i in range(m):
    a, b = map(int, input().split())
    path[a-1].append(b)
    path[b-1].append(a)

def rec(c, p, crnt, d):
    d += 1
    if c[crnt]:
        if len(list(filter(lambda x: x == 1, c))) == m and d == m+1:
            return 1
        else:
            return 0
    else:
        c[crnt] = 1
        sm = 0
        for i in p[crnt]:
            sm += rec(c, p, i-1, d)
        return sm

print(rec(color, path, 0, 0))


### FIXED CODE ###

from itertools import permutations
n, m = map(int, input().split())
v = [set(map(int, input().split())) for _ in range(m)]

ans = 0
x = [i for i in range(2, n+1)]
cand = permutations(x)
for i in cand:
    crnt = 1
    for nxt in i:
        if set([crnt, nxt]) in v:
            crnt = nxt
        else:
            break
    else:
        ans += 1
print(ans)
import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
import math
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = rl()
a=rl()
a.sort()
b=[0]*(2*10**5+1)
ans=[]
def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

for i in a:
    f=True
    if b[i]==-1:
        b[i]=1
        continue
    for j in make_divisors(i):
        if b[j]==1:
            f=False
            break
    if f:
        b[i]=-1
cnt=0
for i in b:
    if i==1:
        cnt+=1
print(cnt)

### FIXED CODE ###

import sys
import time
#from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
#import heapq
import math
start=time.time()
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))
n = rl()
a=rl()
a.sort()
b=[0]*2*10**6
for i in a:
    if b[i]==0:
        b[i]=-1
        for j in range(2,10**6):
            if i*j>10**6:
                break
            b[i*j]+=1
        continue
    
    if b[i]==-1:
        b[i]=1
cnt = 0
for i in a:
    if b[i]==-1:
        cnt+=1
print(cnt)
def tax(p, x):
	return p * (100 + x) // 100

while True:
	x, y, s = map(int, input().split())
	if (x, y, s) == (0, 0, 0):
		break
	r = 0
	for i in range(1, s):
		for j in range(1, s):
			if (tax(i, x) + tax(j, x)) == s:
				r = max((tax(i, y) + tax(j, y)), r)
	print(r)

### FIXED CODE ###


def tax(p, x):
	return p * (100 + x) // 100

while True:
	x, y, s = map(int, input().split())
	if (x, y, s) == (0, 0, 0):
		break
	r = 0
	for i in range(1, s):
		for j in range(1, s):
			t = tax(i, x) + tax(j, x)
			if t > s:
				break
			if (t) == s:
				r = max((tax(i, y) + tax(j, y)), r)
	print(r)
# -*- coding: utf-8 -*-
a, b = map(int, input().split())

k = a+b
if k%2==0:
  return k/2
else:
  return 'IMPOSSIBLE'
      


### FIXED CODE ###

# -*- coding: utf-8 -*-
a, b = map(int, input().split())
 
k = a+b
if k%2==0:
  print(k//2)
else:
  print('IMPOSSIBLE')
s = print()
p = print()

s *= 2
if s.find(p) != -1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

s = input()
p = input()

s *= 2
if s.find(p) != -1:
    print("Yes")
else:
    print("No")
b=10
sum=0
for _ in range(5):
	a=int(input())
    sum+=a-a%10
  	if b>a:
      b=a
sum+=40+b
print(sum)

### FIXED CODE ###

b=10
sum=0
for _ in range(5):
  a=int(input())
  if a%10 !=0:
      sum += (a+10-a%10)
      if b>(a%10):
          b=a%10
  else:
      sum += a
print(sum-10+b)
a,b,c = map(int, input().split())

x = a % b
y = c % b

if y % x == 0:
  print("YES")
else :
  print("NO")


### FIXED CODE ###

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

for i in range(1,b+1):
  if (a*i)%b == c:
    print("YES")
    exit()
    
print("NO")
def main():

    H, W = map(int, input().split())
    ans = 0
    if W % 2 == 0 and H % 2 == 0:
        return (W//2) * (H//2) + (W//2) * (H//2)
    if W % 2 == 1 and H % 2 == 0:
        return ((W+1)//2) * (H//2) + (W//2) * (H//2)
    if W % 2 == 0 and H % 2 == 1:
        return (W//2) * ((H+1)//2) + (W//2) * (H//2)
    if W % 2 == 1 and H % 2 == 1:
        return ((W+1)//2) * ((H+1)//2) + (W//2) * (H//2)

if __name__ == '__main__':
    print(main())


### FIXED CODE ###


def main():

    N = int(input())
    cur = [['a', set(['a'])]]
    for _ in range(N-1):
        temp = []
        for s, u in cur:
            for c in 'abcdefghij':
                 if c not in u:
                     temp.append([s + c, u | {c}])
                     break
                 else:
                    temp.append([s + c, u])
        cur = temp
    for s, _ in cur:
        print(s)

if __name__ == '__main__':
    main()
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	to = [[] for _ in range(N)]
	e_colors = [[] for _ in range(N)]
	ans_colors = []
	max_color = 0
	for i in range(N-1):
		a,b = MI()
		a -= 1
		b -= 1
		to[a].append(b)
		to[b].append(a)
		l = max(len(to[a]),len(to[b]))
		if(l>max_color):
			max_color = l
		ch=[False]*max_color
		for j in e_colors[a]:
			ch[j-1]=True
		for j in e_colors[b]:
			ch[j-1]=True
		for j in range(l):
			if(ch[j]==False):
				e_colors[a].append(j+1)
				e_colors[b].append(j+1)
				ans_colors.append(j+1)
				break
	print(l)
	for i in range(N-1):
		print(ans_colors[i])

main()

### FIXED CODE ###

import sys,math

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N = II()
	to = [[] for _ in range(N)]
	ans = {}
	order = []
	for i in range(N-1):
		a,b = MI()
		a -= 1;b -= 1
		ans[str(a)+"-"+str(b)] = 0
		order.append(str(a)+"-"+str(b))
		to[a].append(b);to[b].append(a)
	
	def bfs():
		from collections import deque
		hist = [True]*N
		que = deque()
		que.append(0)
		e_colors = [0]*N
		max_c = 0
		while len(que) > 0:
			n = que.popleft()
			hist[n]=False
			for i in to[n]:
				if(hist[i]):
					ch = e_colors[n] | e_colors[i]
					index = int(math.log2(~ch & -~ch))
					e_colors[n] += 1 << index
					e_colors[i] += 1 << index
					ans[str(min(n,i))+"-"+str(max(n,i))] = index+1
					if(max_c < index+1): max_c = index+1
					que.append(i)
		print(max_c)
		for i in order:
			print(ans[i])

	bfs()


main()
ow = list(map(int, input().split()))
N = row[0]
Y = row[1]

order = []
order.append(int(Y/1e+4))
Y -= int(Y/1e+4) * 1e+4
order.append(int(Y/5e+3))
Y -= int(Y/5e+3) * 5e+3
order.append(int(Y/1e+3))
if sum(order) > N:
    print("-1 -1 -1")
else:
    print(order[0], order[1], order[2])

### FIXED CODE ###

row = list(map(int, input().split()))
N = row[0]
Y = row[1]
Flag = 0
for x in range(N+1):
    for y in range(N+1):
        z = N - x - y
        if Y == x*10000 + y*5000 + z*1000 and z >= 0:
            print(x, y, z)
            Flag = 1
            break
    if Flag == 1:
        break
if Flag == 0:
    print(-1, -1, -1)
from sys import stdin
 
while True:
    (a, op, b) = stdin.readline().split(' ')
    a = int(a)
    b = int(b)
    if op == "?":
        break;
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    elif op == "/":
        print(a // b)

### FIXED CODE ###

while True:
    (a, op, b) = input().split()
    a = int(a)
    b = int(b)
    if op == '?':
        break
    elif op == '+':
        print(a + b)
        pass
    elif op == '-':
        print(a - b)
        pass
    elif op == '*':
        print(a * b)
        pass
    else:
        print(a // b)
n = int(input())
b = list(range(n**2))
a = list(map(int, input().split()))
flg = False
cnt = 0
for i, v in enumerate(a, 1):
    if flg:
        flg = False
        continue

    if i is v:
        cnt += 1
        flg = True
print(cnt)


### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
flg = False
cnt = 0
for i, v in enumerate(a, 1):
    if flg:
        flg = False
        continue

    if i == v:
        cnt += 1
        flg = True
print(cnt)
a, b, k = map(int, input().split())

s = []

for i in range(1, max(a, b)):
    if a % i == 0 and b % i == 0:
        s.append(i)

sorted(s, reverse=True)

print(s[len(s) - k])


### FIXED CODE ###

a, b, k = map(int, input().split())

s = []

for i in range(1, max(a, b)+1):
    if a % i == 0 and b % i == 0:
        s.append(i)

sorted(s)

s = s[::-1]

print(s[k-1])
n = int(input())
a = list(map(int,input().split()))
p = []
q = []
d = collections.defaultdict(int)
e = collections.defaultdict(int)
for i in range(n):
    p.append(a[i]+i+1)
for i in range(n):
    q.append(-a[i]+i+1)
ans = 0
for i in range(n):
    d[p[i]] += 1
    e[q[i]] += 1
for i in d.keys():
    ans += d[i]*e[i]
print(ans)

### FIXED CODE ###

import collections

n=int(input())
arr=list(map(int,input().split()))
ans=0
cnt=collections.defaultdict(int)
for i in range(1,n+1):
	ans+=cnt[i-arr[i-1]] #すでに見た要素について、i-Aiと等しいものの個数を数える
	cnt[i+arr[i-1]]+=1 #i+Aiを付け加える
print(ans)
# coding: utf-8

n, k = map(int, input().rstrip().split())    # 2 <= n <= 10^5, 1 <= k <= 100
h = list(map(int, input().rstrip().split()))

dp = [0]
for i in range(1, n):
    dp.append(min(dp[j] + abs(h[i] - h[j]) \
        for j in range(max(i - k, 0), i)))
print(dp[-1])


### FIXED CODE ###

# coding: utf-8

n = int(input())    # 2 <= n <= 10^5
h = list(map(int, input().rstrip().split()))
dp = [0]
for i in range(1, n):
    dp.append(min( \
        dp[i - 1] + abs(h[i - 1] - h[i]), \
        float('inf') if i < 2 else dp[i - 2] + abs(h[i - 2] - h[i])))
print(dp[- 1])
#2019/10/24
S = list(map(int, list(open(0).read())))
# print(S)
print(S[::2].count(0) + S[1::2].count(1) if S[0]==1 else S[::2].count(1) + S[1::2].count(0)) 

### FIXED CODE ###

#2019/10/24
# S = list(map(int, list(open(0).read())))
S = list(map(int, input()))
# print(S)
print(S[::2].count(0) + S[1::2].count(1) if S[0]==1 else S[::2].count(1) + S[1::2].count(0))
# abc177_c.py
from numba import jit
@numba
def solve():
    N = int(input())
    A = list(map(int,input().split()))
    ans = 0
    mod = 10**9+7
    for i in range(N-1):
        for j in range(i+1,N):
            if i != j:
                ans+=A[i]*A[j]
                ans%=mod
    return ans%mod

print(solve())

### FIXED CODE ###

def solve():
    N = int(input())
    A = list(map(int, input().split()))
    square = []
    for i in A:
        square.append(i**2)
    return (sum(A)**2 - sum(square))//2 % (10**9+7)


print(solve())
K = int(input())
S = input()

if len(S) =< len(K):
    print(S)
    
else:
    print((str[1:S])+'...')

### FIXED CODE ###

K = int(input())
S = input()
 
if len(S) <= K:
    print(S)
    
else:
    print(S[0:K]+'...')
ef solve(string):
    n, k = map(int, string.split("\n")[0].split(" "))
    ins = list(map(int, string.split("\n")[1:]))
    ins.sort()
    return str(min([ins[i + k - 1] - ins[i] for i in range(len(ins) - k + 1)]))


if __name__ == '__main__':
    n, k = map(int, input().split(" "))
    ins = [input() for _ in range(n)]
    print(solve("{} {}\n{}".format(n, k, "\n".join(ins))))



### FIXED CODE ###

def solve(string):
    n, k = map(int, string.split("\n")[0].split(" "))
    ins = list(map(int, string.split("\n")[1:]))
    ins.sort()
    return str(min([ins[i + k - 1] - ins[i] for i in range(len(ins) - k + 1)]))


if __name__ == '__main__':
    n, k = map(int, input().split(" "))
    ins = [input() for _ in range(n)]
    print(solve("{} {}\n{}".format(n, k, "\n".join(ins))))
# coding: utf-8

n, k = map(int, input().rstrip().split())    # 2 <= n <= 10^5, 1 <= k <= 100
h = list(map(int, input().rstrip().split()))

dp = [0] * 100010
for i in range(1, n):
    c = float('inf')
    for j, d in enumerate(dp[:i]):
        c_ = d + abs(h[i - j] - h[i])
        if c_ < c:
            c = c_
    dp[i] = c
print(dp[i])


### FIXED CODE ###

# coding: utf-8

n = int(input())    # 2 <= n <= 10^5
h = list(map(int, input().rstrip().split()))
dp = [0]
for i in range(1, n):
    dp.append(min( \
        dp[i - 1] + abs(h[i - 1] - h[i]), \
        float('inf') if i < 2 else dp[i - 2] + abs(h[i - 2] - h[i])))
print(dp[- 1])
N = int(input())
a = [110]
a = list(map(int, input().sprit()))
a.sort(reverse=True)
 
Alis = 0
Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += a[j]
 
print(Alis-Bob)

### FIXED CODE ###

N = int(input())
a = [110]
a = list(map(int, input().split()))
a.sort(reverse=True)
 
Alis = 0
Bob = 0
for j in range(N):
  if j % 2 == 0:
    Alis += a[j]
  else:
    Bob += a[j]
    
print(Alis-Bob)
import sys
sys.setrecursionlimit(10000)

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

ans = [None]*(N-1)
def rec(cur, color):
    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1

rec(0,0)
print(max(ans))
[print(a) for a in ans]


### FIXED CODE ###

import sys
sys.setrecursionlimit(1000000)

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

ans = [None]*(N-1)
def rec(cur, color):
    cnt = 1
    for (to, j) in G[cur]:
        if cnt == color:
            cnt += 1
        ans[j] = cnt
        rec(to, cnt)
        cnt += 1

rec(0,0)
print(max(ans))
[print(a) for a in ans]
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(K+1):
    for j in range(K-i+1):
        dp[i][j] = [V[:i]+V[N-j:]+[0]]
        dp[i][j][0].sort()

#print(dp)

for i in range(K):
    for j in range(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))

### 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=map(int,input.split())
if a==b:
  print('Draw')
elif a==1:
  print('Alice')
elif b==1:
  print('Bob')
elif a>b:
  print('Alice')
elif a<b:
  print('Bob')


### FIXED CODE ###

a,b=map(int,input().split())
if a==b:
  print('Draw')
elif a==1:
  print('Alice')
elif b==1:
  print('Bob')
elif a>b:
  print('Alice')
elif a<b:
  print('Bob')
X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split())).sort(reverse = True)
q= list(map(int, input().split())).sort(reverse = True)
r= list(map(int, input().split())).sort(reverse = True)
ls = []
for i in range(X):
    ls.append(p[i])
for i in range(Y):
    ls.append(q[i])
    
while(r != []):
    for i in range(len(r)):
        minimum = min(ls)
        if r[i] >= min(ls):
            ls[ls.index(minimum)] = r[i]
        r.pop(0)
print(sum(ls))

### FIXED CODE ###

X, Y, A, B, C = map(int, input().split())
p = list(map(int, input().split()))
q= list(map(int, input().split()))
r= list(map(int, input().split()))
p.sort(reverse = True)
q.sort(reverse = True)
r.sort(reverse = True)
ls = []
for i in range(X):
    ls.append(p[i])
for i in range(Y):
    ls.append(q[i])
ls.extend(r)
ls.sort(reverse = True)
print(sum(ls[:X+Y]))
a, op, b = map(input().split())
if op == '+':
  print(int(a)+int(b)
else:
  print(int(a)-int(b))

### FIXED CODE ###

a, op, b = input().split()
if op == '+':
  print(int(a)+int(b))
else:
  print(int(a)-int(b))
for e in iter(input,'0 0'):
 N,M=map(int,e.split())
 k=p=1
 S=[int(input()) for _ in[0]*N]
 for d in[int(input())for _ in[0]*M]:
  p+=n if n-1<=p+i else i+S[p+i]
  if n<=p:break
  k+=1
 print(k)


### FIXED CODE ###

import sys
r=sys.stdin.readline
for e in iter(r,'0 0\n'):
 N,M=map(int,e.split())
 k,p=1,0
 S=[int(r())for _ in[0]*N]
 for d in[int(r())for _ in[0]*M]:
  p+=d;
  if p<N:p+=S[p]
  if N<=p+1:break
  k+=1
 print(k)