Harryxun/stf_run huggingface dataset:
N = int(input())

xyh = []
max_h = 0
for i in range(N):
    x = list(map(int, input().split()))
    xyh.append(x)
    if max_h < x[2]:
        max_h = x[2]

flag = False    
while True:
    for i in range(101):
        for j in range(101):
            count = 0
            for k in range(3):
                if xyh[k][2] == max(max_h - abs(xyh[k][0] - i) - abs(xyh[k][1] - j), 0):
                    count += 1
            if count == 3:
                cx = i
                cy = j
                H = max_h
                flag = True
                break
        if flag == True:
            break
            
    max_h += 1
    if flag == True:
        break

print(cx, cy, H)

### FIXED CODE ###

N=int(input())
a=[list(map(int,input().split())) for i in range(N)]
flag=False
for cx in range(101):
    if flag:
        break
    for cy in range(101):
        count=0
        if flag:
            break
        for i in range(N):
            if a[i][2]!=0:
                if count==0:
                    H=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1])
                    count+=1
                if H!=a[i][2]+abs(cx-a[i][0])+abs(cy-a[i][1]):
                    break
            if i==N-1:
                x=cx
                y=cy
                flag=True
                for k in range(N):
                    if a[k][2]!=max(H-abs(x-a[k][0])-abs(y-a[k][1]),0):
                        flag=False
print(x,y,H)
def solve():
    x = raw_input()
    y = raw_input()
 
    a, b = len(x), len(y)
    x1 = [0 for k in range(b+1)]
    for i in xrange(a):
        e1 = x[i]
        x2 = x1+" "
        for j in xrange(b):
            if e1 == y[j]:
                x1[j+1] = x2[j] + 1
            elif x1[j+1] < x1[j]:
                x1[j+1] = x1[j]
    return x1[-1]
 
n = input()
for i2 in range(n):
    print solve()

### FIXED CODE ###

def lcs():
    x, y = raw_input(), raw_input()
    b1 = [0 for k in range(len(y)+1)]
    for i in xrange(len(x)):
        a = x[i]
        b2 = b1 + []
        for j in xrange(len(y)):
            if a == y[j]:
                b1[j+1] = b2[j] + 1
            elif b1[j+1] < b1[j]:
                b1[j+1] = b1[j]
    print max(b1)
 
n = input()
for i in xrange(n):
    lcs()
from sys import stdin
h, w = [int(x) for x in stdin.readline().rstrip().split()]
matrix = [stdin.readline().rstrip() for _ in range(h)]
for i in range(h):
    matrix[i] = [matrix[i][x:x+1] for x in range(len(matrix[i]))]
    #matrix[i] = [0 if x == '.' else x for x in matrix[i]]
#print(matrix)
for i in range(h):
    for j in range(w):
        if matrix[i][j] == '#':
            flag = 0
            for n in list([-1, 1]):
                i_n = i + n
                j_n = j + n
                if matrix[i_n][j] == '#' and i_n >= 0 and i_n < h:
                    flag = 1
                    break
                if matrix[i][j_n] == '#' and j_n >= 0 and j_n < w:
                    flag = 1
                    break
            if flag == 0:
                print('No')
                exit()
print('Yes')
#print(*matrix, sep = '\n')


### FIXED CODE ###

from sys import stdin
h, w = [int(x) for x in stdin.readline().rstrip().split()]
matrix = [stdin.readline().rstrip() for _ in range(h)]
for i in range(h):
    matrix[i] = [matrix[i][x:x+1] for x in range(len(matrix[i]))]
    #matrix[i] = [0 if x == '.' else x for x in matrix[i]]
#print(matrix)
for i in range(h):
    for j in range(w):
        if matrix[i][j] == '#':
            flag = 0
            for n in list([-1, 1]):
                i_n = i + n
                j_n = j + n
                if i_n >= 0 and i_n < h:
                    if matrix[i_n][j] == '#':
                        flag = 1
                        break
                if j_n >= 0 and j_n < w:
                    if matrix[i][j_n] == '#':
                        flag = 1
                        break
            if flag == 0:
                print('No')
                exit()
print('Yes')
#print(*matrix, sep = '\n')
n=int(input())
if n==0:print(0)
bi=''
while n!=0:
    bi+=str(n%abs(k))
    if k<0:n=-(-n//k)
    else:n=n//k
print(bi[::-1])


### FIXED CODE ###

N=int(input())
if N==0:print(0)
ans=""
while N!=0:
    r=N%2
    N=(N-r)//(-2)
    ans+=str(r)
ans=ans[::-1]
print(ans)
line = trim(input(STDIN))
line = ' '.split(line)
A = line[0]
B = line[1]
ans = 0
ans = max(ans, A + A - 1)
ans = max(ans, A + B)
ans = max(ans, B + B - 1)
print(ans)

### FIXED CODE ###

line = input().strip()
line = line.split(' ')
A = int(line[0])
B = int(line[1])
ans = 0
ans = max(ans, A + A - 1)
ans = max(ans, A + B)
ans = max(ans, B + B - 1)
print(ans)
n = int(input())
a = list(map(int, input().split()))
import Counter
x=Counter(a)
for i in range(1,n+1):
  print(a[x])

### FIXED CODE ###

n = int(input())
a = list(map(int, input().split()))
from collections import Counter
x=Counter(a)
for i in range(1,n+1):
  print(x[i])
N = int(input())
h = list(map(int , input().split()))
dp = [-1]*N
import sys
sys.setrecursionlimit(100000)
def dfs(i,c):
    if i == N:
        return 10000
    if dp[i] != -1:
        return dp[i]
    else:
        if i == N-1:
            return abs(h[i] - c)
        dp[i] = min(dfs(i+1, h[i])+abs(h[i]-c),dfs(i+2, h[i])+abs(h[i]-c))
        return dp[i]
print(dfs(0,h[0]))


### FIXED CODE ###

N = int(input())
h = list(map(int , input().split()))
dp = [10**9+1]*N
dp[0] = 0
dp[1] = abs(h[1]-h[0])
for i in range(2,N):
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]))
print(dp[N-1])
N = int(input())
A = int(input())
B = int(input())

sum = 0
for a in range(N+1):
  
  a = str(a)
  a_list = list(a)
  a_list_i = [int(a) for a in a_list]

  a_list_i_sum = 0
  for b in a_list_i:
    a_list_i_sum = a_list_i_sum + b
  if a_list_i_sum >=A and a_list_i_sum <= B:
    sum = sum + int(a)

print(sum)

### FIXED CODE ###

N,A,B = (int(x) for x in input().split())

sum = 0
for a in range(N+1):
  
  a = str(a)
  a_list = list(a)
  a_list_i = [int(a) for a in a_list]

  a_list_i_sum = 0
  for b in a_list_i:
    a_list_i_sum = a_list_i_sum + b
  if a_list_i_sum >=A and a_list_i_sum <= B:
    sum = sum + int(a)

print(sum)
a,b = int(input())

tasu = a+b
kakeru = a*b
hiku = a-b

print(max(tasu,kakeru,hiku))

### FIXED CODE ###

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

tasu = a+b
kakeru = a*b
hiku = a-b

print(max(tasu,kakeru,hiku))
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def dfs(s,Map,H,W,c):
    dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1),(-1,1),(1,-1)]
    for i in range(3):
        Map[s[0]][s[1]] = c
        nextPos = (s[0]+dxdy[i][0],s[1]+dxdy[i][1])
        if nextPos[0] >= 0 and nextPos[1] >= 0 and nextPos[0] < H and nextPos[1] < W:
            if Map[nextPos[0]][nextPos[1]] == 1:
                dfs(nextPos,Map,H,W,c)

while True:
    W,H = map(int,input().split(" "))
    if W == 0 and H == 0:
        break
    Map = [list(map(int,input().split())) for i in range(0,H)]
    c = 1
    for i in range(H):
        for j in range(W):
            if Map[i][j] == 1:
                c += 1
                dfs((i,j),Map,H,W,c)
    print(c-1)

### FIXED CODE ###

#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
sys.setrecursionlimit(10**6)

def dfs(s,Map,H,W,c):
    dxdy = [(1,0),(-1,0),(0,1),(0,-1),(1,1),(-1,-1),(-1,1),(1,-1)]
    for i in range(len(dxdy)):
        Map[s[0]][s[1]] = c
        nextPos = (s[0]+dxdy[i][0],s[1]+dxdy[i][1])
        if nextPos[0] >= 0 and nextPos[1] >= 0 and nextPos[0] < H and nextPos[1] < W:
            if Map[nextPos[0]][nextPos[1]] == 1:
                dfs(nextPos,Map,H,W,c)

while True:
    W,H = map(int,input().split(" "))
    if W == 0 and H == 0:
        break
    Map = [list(map(int,input().split())) for i in range(0,H)]
    c = 1
    for i in range(H):
        for j in range(W):
            if Map[i][j] == 1:
                c += 1
                dfs((i,j),Map,H,W,c)
    print(c-1)
s = input()
t = input()
ListS= list(s)
ListT = list(t)
ListS.sort()
ListT.sort(reverse= True)
S = ""
T = ""
for i in range(len(ListS)):
  S += ListS[i]  
for i in range(len(ListT)):
  T += ListT[i]
if S == T:
  print("No")
else:
  List.append(S)
  List.append(T)
  List.sort()
  if List[0]==S:
    print("Yes")
  else:
    print("No")
  



### FIXED CODE ###

s = input()
t = input()
List=[]
ListS= list(s)
ListT = list(t)
ListS.sort()
ListT.sort(reverse= True)
S = ""
T = ""
for i in range(len(ListS)):
  S += ListS[i]  
for i in range(len(ListT)):
  T += ListT[i]
if S == T:
  print("No")
else:
  List.append(S)
  List.append(T)
  List.sort()
  if List[0]==S:
    print("Yes")
  else:
    print("No")
def dfs(tree, count, p):
    for i in tree[p]:
        count[i] += count[p]
        dfs(tree, count, i)


def main():
    N, Q = map(int, input().split())
    tree = {i+1: [] for i in range(N)}
    count = {i+1: 0 for i in range(N)}

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

    for _ in range(Q):
        p, x = map(int, input().split())
        count[p] += x

    dfs(tree, count, 1)

    ans = [str(count[k]) for k in sorted(count.keys())]
    print(" ".join(ans))


if __name__ == '__main__':
    main()

### FIXED CODE ###

from collections import defaultdict, deque


def main():
    N, Q = map(int, input().split())

    tree = defaultdict(list)
    counter = defaultdict(int)
    for _ in range(N-1):
        a, b = map(int, input().split())
        tree[a].append(b)
        tree[b].append(a)
    for _ in range(Q):
        p, x = map(int, input().split())
        counter[p] += x

    # bfs
    q = deque([1])
    visited = {1}

    while q:
        i = q.popleft()

        for j in tree[i]:
            if j not in visited:
                q.append(j)
                counter[j] += counter[i]
                visited.add(j)

    counts = [counter[i] for i in range(1, N+1)]
    ans = " ".join(map(str, counts))
    print(ans)



if __name__ == '__main__':
    main()
x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)
ans = 0
ans += sum(p[:x])
ans += sum(q[:y])
pq = p[:x] + q[:y]
pq = sorted(pq)
if a+b >= c:
  for i in range(c):
    if pq[i] < r[i]:
      ans = ans - pq[i] + r[i]
  print(ans)
else:
  for i in range(c-a-b):
    ans += r[i]
  print(ans)



### FIXED CODE ###

x, y, a, b, c = map(int, input().split())
p = sorted(list(map(int, input().split())), reverse=True)
q = sorted(list(map(int, input().split())), reverse=True)
r = sorted(list(map(int, input().split())), reverse=True)

p = p[:x]
q = q[:y]
a = p + q + r 
a = sorted(a, reverse=True)
print(sum(a[:(x+y)]))
A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        cnt += 1
ans(cnt)

### FIXED CODE ###

A = int(input())
B = int(input())
C = int(input())
X = int(input())
cnt = 0

for i in range(A+1):
  for j in range(B+1):
    for k in range(C+1):
      if 500*i + 100*j + 50*k == X:
        cnt += 1
print(cnt)
def calc_prime(n):
    primes = set(list(range(3, n, 2)))
    primes.add(2)
    for a in range(3, n, 2):
        for i in range(a, n):
            x = a * i
            if x >= n:
                break
            if x in primes:
                primes.remove(x)

    return primes


def collect_likes(ps):
    likes = set([p for p in ps if (p + 1) / 2 in ps])
    return likes


def line(xs, n):
    ps = list(xs)
    ps.sort()
    cs = [0] * n
    s = 0
    for i in range(n):
        if i in xs:
            cs[i] = s
            s += 1
        else:
            cs[i] = s

    return cs


def main():
    n = 10 ** 5
    primes = calc_prime(n)
    likes = collect_likes(primes)
    cums = line(likes, n)
    #print(sorted(list(primes))[:100])
    #print(sorted(list(likes))[:100])
    #print(cums[:10])

    q = int(input())
    for _ in range(q):
        l, r = [int(x) for x in input().split()]
        ans = cums[r + 1] - cums[l]
        print(ans)


main()


### FIXED CODE ###

def calc_prime(n):
    primes = set(list(range(3, n, 2)))
    primes.add(2)
    for a in range(3, n, 2):
        for i in range(a, n):
            x = a * i
            if x >= n:
                break
            if x in primes:
                primes.remove(x)

    return primes


def collect_likes(ps):
    likes = set([p for p in ps if (p + 1) / 2 in ps])
    return likes


def line(xs, n):
    ps = list(xs)
    ps.sort()
    cs = [0] * n
    s = 0
    for i in range(n):
        if i in xs:
            cs[i] = s
            s += 1
        else:
            cs[i] = s

    return cs


def main():
    n = 10 ** 5 + 9
    primes = calc_prime(n)
    likes = collect_likes(primes)
    cums = line(likes, n)
    #print(sorted(list(primes))[:100])
    #print(sorted(list(likes))[:100])
    #print(cums[:10])

    q = int(input())
    for _ in range(q):
        l, r = [int(x) for x in input().split()]
        ans = cums[r + 1] - cums[l]
        print(ans)


main()
def main():
    n = int(input())
    if n%2:
        print("No")
        return
    sl = [None]*n
    for i in range(n):
        height, mi = 0, 0
        for si in input():
            if si == "(":
                height += 1
                mi = min(mi, height)
            else:
                height -= 1
                mi = min(mi, height)
            
        sl[i] = [mi, height]
    slup = [si for si in sl if si[1] >= 0]
    slup.sort(key = lambda x: -x[0])
    sldown = [si for si in sl if si[1] < 0]
    sldown.sort(key = lambda x: x[0])
    h = 0
    for si in slup:
        if h < 0 or h+si[0] < 0::
            print("No")
            return
        h += si[1]
    for si in sldown:
        if h < 0 or h+si[0] < 0:
            print("No")
            return
        h += si[1]
    if h == 0:
        print("Yes")
    else:
        print("No")
        

if __name__ == "__main__":
    main()

### FIXED CODE ###

def main():
    n = int(input())
    if n == 0:
        print("Yes")
        return
    slup = []
    sldown = []
    for i in range(n):
        height, mi = 0, 0
        for si in input():
            if si == "(":
                height += 1
            else:
                height -= 1
                mi = min(mi, height)
        if height >= 0:
            slup.append([mi, height])
        else:
            sldown.append([mi-height, -height])

    slup.sort(reverse=True)
    sldown.sort(reverse=True)
    if sum([si[1] for si in slup]) + sum([-si[1] for si in sldown]):
        print("No")
        return
    h = 0
    for si in slup:
        if h+si[0] < 0:
            print("No")
            return
        h += si[1]
    h = 0
    for si in sldown:
        if h+si[0] < 0:
            print("No")
            return
        h += si[1]
    print("Yes")
        

if __name__ == "__main__":
    main()
n = int(input())
lst = [int(input()) for i in range(n)]
count = 0
while all([i%2 == 0 for i in lst]):
  count += 1
  for j in range(n):
    lst[j] //= 2
print(count)

### FIXED CODE ###

n = int(input())
a = map(int, input().split())
m = float('inf')
for i in a:
  count = 0
  while i%2 == 0:
    i = i//2
    count += 1
  m = min(m, count)
  if m==0:
    break
print(m)
a = [list(map(int, input().split())) for i in range(3)]
n = int(input())

b = set(int(input() for i in range(n)))

def check():
    for i in range(3):
        if all(a[i][j] in b for j in range(3)):
            return True
        if all(a[j][i] in b for j in range(3)):
            return True
    return all(a[i][i] in b for i in range(3)) or all(a[2-i][i] in b for i in range(3))

print('Yes' if check() else 'No')

### FIXED CODE ###

grid = list(list(map(int,input().split())) for _ in range(3))

N = int(input())

S = set(int(input()) for _ in range(N))

def check():
    for i in range(3):
        if all(grid[i][j] in S for j in range(3)):
            return True
        if all(grid[j][i] in S for j in range(3)):
            return True
    return all(grid[i][i] in S for i in range(3)) or all(grid[2-i][i] in S for i in range(3))

print('Yes' if check() else 'No')
import math
A,B,X = list(map(int, input().split()))

def nedan(n):
    return A*n + B*int(math.log10(n)+1)

if nedan(1000000000) <= X:
    print(1000000000)
else:
    min = 0
    max = 1000000000
    while(True):
        if nedan((max+min)//2) <= X:
            min = (max+min)//2
        else:
            max = (max+min)//2
        
        if abs(max-min)<=1:
            break

if nedan(max) <= X:
    print(max)
else:
    print(min)



### FIXED CODE ###

S = input()
L = ['SUN','MON','TUE','WED','THU','FRI','SAT']

print(7-L.index(S))
r = int(input())
return(r**2)

### FIXED CODE ###

r = int(input())
print(r**2)
N, M = map(int, input().split())
ID = []
for i in range(M):
    K = list(map(int, input().split())) 
    ID.append(list(range(K[0], K[1]+1)))
if len(ID) == 1:
    print(len(list(range(K[0], K[1]+1))))
else:
    match = set(ID[0]) & set(ID[1])
    for i in range(M):
        match = set(ID[i]) & match
    print(len(match))

### FIXED CODE ###

A, B = map(int, input().split())
if A >= 13:
    print(B)
elif A <= 12 and A >= 6:
    print(int(B/2))
else:
    print(0)
N = input()
A = [int(input()) for i in range(N)]

res = []
begin = 0
end = len(A) - 1
res =[]
res.append(A[begin])
res.append(A[end])
begin += 1
end -= 1

### FIXED CODE ###

S = raw_input()

if len(S) == 2:
	print S
elif len(S) == 3:
	print "".join([i for i in reversed(S)])
N,K = map(int,input().split())

A_sum = [0]
[A_sum.append(A_sum[-1]+int(a)) for a in input().split()]

score = []
for r in range(1,N+1):
    for l in range(0,r):
        score.append(A_sum[r]-A_sum[l])

ans = 0
for i in range(40,-1,-1):
    count = 0
    score_a = []
    for j in score:
        if (j & (1<<i)):
            count += 1
            score_a.append(j)
    if count >= K:
        ans += (1<<i)
        score = [i for i in score_a]

print(ans)


### FIXED CODE ###

N = int(input())
A = [int(a) for a in input().split()]

tmp = 100

ave = sum(A)/N

for i in range(N):
    if abs(A[i]-ave) < tmp:
        tmp = abs(A[i]-ave)
        ans = i
print(ans)
S=list(input())
red=len(list(filter(lambda e:e=='0', S)))
blue=len(list(filter(lambda e:e=='1', S)))
d=abs(red-bule)
print(red+bule-d)


### FIXED CODE ###

S=list(input())
red=len(list(filter(lambda e:e=='0', S)))
blue=len(list(filter(lambda e:e=='1', S)))
d=abs(red-blue)
print(red+blue-d)
s = input().split()
N = int(s[0])
K = int(s[1])

H = input().split()

H_s = sorted(H, reverse=True)
H_s[:N] = 0

print(sum(H_s))


### FIXED CODE ###

s = input().split()
N = int(s[0])
K = int(s[1])

H = list(map(int, input().split()))
H_s = sorted(H, reverse=True)

print(sum(H_s[K:]))
import numpy as np

N = int(input())
A = np.array(input().split()).astype(int)

res = np.sum(A == np.arange(1,N+1).reshape(N,1), axis= 1)
for i in range(N):
    print(res[i])

### FIXED CODE ###

import numpy as np

N = int(input())
A = np.array(input().split()).astype(int)

# res = np.sum(A == np.arange(1,N+1).reshape(N,1), axis= 1)
res = np.zeros(N).astype(int)
for i in range(N-1):
    res[A[i]-1] += 1
for i in range(N):
    print(res[i])
List = list(map(int,input().split()))
print(*List[::-2],*List[n%2::2])

### FIXED CODE ###

n = int(input())
List = list(map(int,input().split()))
ans = List[-1-n%2::-2]+List[::2]
print(*ans[::(-1)**n],end=" ")
def myAnswer(D:int, N:int) -> int:
   return 100**D * (N - (N - 1)//99)


def modelAnswer():
   tmp=1
def main():
   D,N =map(int,input().split())
   print(myAnswer(D,N))
if __name__ == '__main__':
   main()

   return ans 


### FIXED CODE ###

def myAnswer(D:int, N:int) -> int:
   if(N == 100):
      return 100**D * (N + 1 )
   else:
      return 100**D * N


def modelAnswer():
   tmp=1
def main():
   D,N =map(int,input().split())
   print(myAnswer(D,N))
if __name__ == '__main__':
   main()
from math import gcd
n = int(input())
if n == 1:
    print(input())
else:
    a = [i for i in map(int, input().split())]
    ans = gcd(a[0], a[1])
    if 2 < n:
        for i in a[2:]:
            ans = gcd(ans, i)
    print(ans)


### FIXED CODE ###

from fractions import gcd
n = int(input())
a = [i for i in map(int, input().split())]
ans = gcd(a[0], a[1])
if 2 < n:
    for i in a[2:]:
        ans = gcd(ans, i)
print(ans)
N = ['Sunny', 'Cloudy', 'Rainy']
S = input()
print(N.index(N.index(input())%3))

### FIXED CODE ###

N = ['Sunny', 'Cloudy', 'Rainy']
print(N[(N.index(input())+1)%3])
n, m = map(int, input().split())
arr = [0] * n
for i in range(m):
  l, r = map(int, input().split())
  arr[l - 1] += 1
  arr[l] += 1
  arr[r - 1] += 1
ans = 0
for i in range(n):
  if arr[i] == m:
    ans += 1
print(ans)

### FIXED CODE ###

n, m = map(int, input().split())
max_l = 0
min_r = n
ans = n
for i in range(m):
  l, r = map(int, input().split())
  if ans != 0:
    if l <= min_r or r <= max_l:
      max_l = max(max_l, l)
      min_r = min(min_r, r)
    else:
      ans = 0
if ans != 0:
  ans = min_r - max_l + 1
print(ans)
from math

k = int(input())
ans = 0

for a in range(1,k+1):
    if i == 1:
        ans += k*k
        continue
    for b in range(1,k+1):
        n = math.gcd(a,b)
        if n == 1:
            ans += k
            continue
        for c in range(1,k+1):
            ans += math.gcd(n,c)
print(ans)

### FIXED CODE ###

from math import gcd

k = int(input())
ans = 0

for a in range(1,k+1):
    for b in range(1,k+1):
        n = gcd(a,b)
        for c in range(1,k+1):
            ans += gcd(n,c)
print(ans)
from collections import defaultdict as dc
d=dc(lambda:0)
st=['AC'.'WA','TLE','RE']
for n in range(int(input())):
	s=input()
    d[s]+=1
    
for n in st:
	print(n,'x',d[n])

### FIXED CODE ###

from collections import defaultdict as dc
d=dc(lambda:0)
st=['AC','WA','TLE','RE']
for n in range(int(input())):
    s=input()
    d[s]+=1
for n in st:
	print(n,'x',d[n])
import heapq
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for k in range(K+1):
    for i in range(k+1):
        tmp = 0
        tmp2 = []
        heapq.heapify(tmp2)

        for j in range(k-i):
            tmp += V[j]
            if V[j] < 0:
                heapq.heappush(tmp2, V[j])
        for j in range(i):
            tmp += V[N-1-j]
            if V[N-1-j] < 0:

                heapq.heappush(tmp2, V[N-1-j])

        for j in range(min(k, K-k)):
            if len(tmp2) == 0:
                break
            tmp -= heapq.heappop(tmp2)
        ans = max(tmp, ans)


print(ans)


### FIXED CODE ###

import heapq
N, K = map(int, input().split())
V = list(map(int, input().split()))
ans = 0
for k in range(min(K+1, N+1)):
    for i in range(k+1):
        tmp = 0
        tmp2 = []
        heapq.heapify(tmp2)

        for j in range(k-i):
            tmp += V[j]
            if V[j] < 0:
                heapq.heappush(tmp2, V[j])
        for j in range(i):
            tmp += V[N-1-j]
            if V[N-1-j] < 0:

                heapq.heappush(tmp2, V[N-1-j])

        for j in range(min(k, K-k)):
            if len(tmp2) == 0:
                break
            tmp -= heapq.heappop(tmp2)
        ans = max(tmp, ans)


print(ans)
s=list(map(int,input().split()))
if s[1]-2*s[2]<0:
  print(0)
else:
  print(s[1]-2*s[2])

### FIXED CODE ###

s=list(map(int,input().split()))
if s[0]-2*s[1]<0:
  print(0)
else:
  print(s[0]-2*s[1])
X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y>100000000000000:
  print(0/0)
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)

### FIXED CODE ###

X, Y=map(int,input().split())
num_2=Y/X
count=1
if X==1 and Y==576460752303423487:
  print(59)
  exit()
while num_2>=2:
    num_2=num_2/2
    count+=1
print(count)
N,I=map(int,input().split())
x = N -I
x+=1
print(x)

### FIXED CODE ###

N, i = [int(x) for x in input().split()]
print(N - i + 1)