Harryxun/stf_run huggingface dataset:
n=int(input())
a=[]

x,y,k=-1,-1,-1
n=-1
for _ in range(n):
    a.append(list(map(int,input().split())))
    if a[_][2] != 0:
        n=i
for i in range(101):
    for j in range(101):
        h=a[0][2]+abs(a[0][0]-i)+abs(a[0][1]-j)
        d=True

        for l in range(n):
            if a[l][2] > 0 and h != a[l][2]+abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            if a[l][2]==0 and h>abs(a[l][0]-i)+abs(a[l][1]-j):
                d=False
            
        if d:
            x,y,k=i,j,h
            print(x,y,k)
            exit()



### FIXED CODE ###

n=int(input())
xyh=[]

x,y,h=-1,-1,-1
nonzero=-1

for i in range(n):
    xyh.append(list(map(int,input().split())))
    if xyh[i][2] != 0:
        nonzero = i

for px in range(101):
    for py in range(101):
        nh = xyh[nonzero][2]+abs(xyh[nonzero][0]-px)+abs(xyh[nonzero][1]-py)
        ok = True

        for nn in range(n):
            if xyh[nn][2] > 0 and nh != xyh[nn][2]+abs(xyh[nn][0]-px) + abs(xyh[nn][1]-py):
                ok=False
            if xyh[nn][2] == 0 and nh > abs(xyh[nn][0]-px) +abs(xyh[nn][1]-py):
                ok=False
        
        if ok:
            x,y,h = px,py,nh
            print(x,y,h)
            exit()
A, B = map(int, input(). split())
answer = None
flag = False
for i in range(1009):
  
  if (A == (i*0.08)//1) and (B == (i*0.1)//1):
    answer = i
    print(answer)
    flag = True
   
    if flag:
        break
if (answer = None):
  print(-1)
    


### FIXED CODE ###

A, B = map(int, input(). split())
answer = None
flag = False
for i in range(1, 1009):
  
  if (A == (i*0.08)//1) and (B == (i*0.1)//1):
    answer = i
    print(answer)
    flag = True
   
    if flag:
        break
if answer is None:
  answer = -1
  print(answer)
N,K = map(int, input().split())
S = input()
print(S[:,K+1]+S[K+1].lower()+S[K+2,:])

### FIXED CODE ###

N,K = map(int, input().split())
S = input()
print(S[:K-1]+S[K-1].lower()+S[K:])
a,b,c,d=map(int,raw_input().split())
if a+b<c+d:
  print "Right"
elif a+b>c+d:
  print "Left"
elif a+b=c+d:
  print "Balanced"

### FIXED CODE ###

a,b,c,d=map(int,raw_input().split())
if a+b<c+d:
  print "Right"
elif a+b>c+d:
  print "Left"
else:
  print "Balanced"
H,W = map(int,input().split())
grid = [list(input()) for _ in range(H)]
#print(grid)
MOD = 10**9+7
dp = [[0]*W for i in range(H)]
dp[0][0] = 1
for i in range(H):
    for j in range(W):
        if i+1 < H and grid[i+1][j] == '.':
            dp[i+1][j] += dp[i][j]
            dp[i+1][j] %= MOD
        if j+1 < W and grid[i][j+1] == '.':
            dp[i][j+1] += dp[i][j]
            dp[i][j+1] %= MOD
print(dp[H-1][W-1])

### FIXED CODE ###

N = int(input())
h = list(map(int,input().split()))
dp = [0]*(N+1)
# dp[i+1]はindexでiの足場までのコストの最小値
# dp[N]は求める値
dp[2] = abs(h[1]-h[0])
for i in range(2,N):
    dp[i+1] = min(dp[i] + abs(h[i]-h[i-1]),dp[i-1] + abs(h[i]-h[i-2]))
print(dp[N])
n = int(input())
print(floor(n*(n-1)*0.5))

### FIXED CODE ###

n = int(input())
print(n*(n-1)//2)
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N = input()
    M = [int(c) for c in N]

    lm=len(M)
    cnt=0
    if set(M[1:])=={9}:
        for i in M:
            cnt+=i
        print(cnt)
    else:
        print(9*(lm-1)+M[0]-1)

resolve()

### FIXED CODE ###

# import string
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    N = input()
    M = [int(c) for c in N]
    lm=len(M)
    NN=int(N)
    if lm==1:
        print(NN)
    else:
        if set(M[1:])=={9}:
            print(M[0]+(lm-1)*9)
        else:

            print(M[0]-1+(lm-1)*9)



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

r = []
ans = 0
for i in range(N):
    ans += S[i]
    if S[i]%10!=0:
        r.append(S[i])

r.sort()
if ans%10==0:
    if len(rr)>0:
        ans -= r[0]
    else:
        ans = 0

print(ans)



### FIXED CODE ###

N = int(input())
S = [int(input()) for _ in range(N)]
sumS = sum(S)
T = list(filter(lambda x : x%10!=0, S))
T.sort()
if len(T)==0:
    print(0)
else:
    for t in T:
        if sumS%10!=0:
            break
        else:
            sumS -= t
    print(sumS)
a, b = map(int, input.split())
ans = int((b-1)/(a-1))+1
print(ans)


### FIXED CODE ###

a, b = map(int, input().split())
if b == 1:
  print(0)
  exit()
for i in range(1,21):
  if (a-1)*i+1 >= b:
    print(i)
    exit()
print(0)
a = set(map(int,input()))
print(len(a))

### FIXED CODE ###

a = set(map(int,input().split()))
print(len(a))
N, K = map(int, input().split())
c = 0
n = 1
w = 1
z = 1
while w<=K
  d = int(input())
  List = list(map(int, input().split()))
  w = w+1
while w<=N
  if n in List:
    n = n+1
    z = z+1
  else:
    c = c+1
    n = n+1
    z = z+1
print(c)

### FIXED CODE ###

def resolve():
    N, K = map(int, input().split())
    A = []
    for i in range(K):
        d = int(input())
        a = list(map(int, input().split()))
        A.extend(a)
    print(N - len(set(A)))
resolve()
a, b = int(input("", ""))

if (a >= 1) or (b <= 100):
    num = a * b
    length = (a * 2) + (b * 2)
    print(num + " " + length, end="\n")
else:
    pass

### FIXED CODE ###

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

if (a >= 1) or (b <= 100):
    num = str(a * b)
    length = str((a * 2) + (b * 2))
    print(num + " " + length, end="\n")
else:
    pass
N = int(input())
A = list(map(int, input().split()))

ans = []
mx = max(A)
mi = min(A)

if abs(mi) > abs(mx):
    x = A.index(mi)
    for y in range(N):
        if y == x:
            continue
        A[y] += mi
        ans.append((x, y))
else:
    x = A.index(mx)
    for y in range(N):
        if x == y:
            continue
        A[y] += mx
        ans.append((x, y))

if max(A) * min(A) < 0:
    exit()

for i in range(N - 1):
    l, r = A[i], A[i + 1]

    if l > r:
        if r > 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        if l < 0:
            A[i] += r
            ans.append((i + 1, i))

print(len(ans))
for x, y in ans:
    print(x + 1, y + 1)

if list(sorted(A)) != A:
    print(A)
    1 / 0


### FIXED CODE ###

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

ans = []
mx = max(A)
mi = min(A)

if mx * mi < 0:
    if abs(mi) > abs(mx):
        x = A.index(mi)
        for y in range(N):
            if y == x:
                continue
            A[y] += mi
            ans.append((x, y))
    else:
        x = A.index(mx)
        for y in range(N):
            if x == y:
                continue
            A[y] += mx
            ans.append((x, y))

for i in range(N - 1)[::(-1)**(min(A) < 0)]:
    l, r = A[i], A[i + 1]

    if l > r:
        if r >= 0:
            A[i + 1] += l
            ans.append((i, i + 1))
        elif l <= 0:
            A[i] += r
            ans.append((i + 1, i))

print(len(ans))
for x, y in ans:
    print(x + 1, y + 1)

if list(sorted(A)) != A:
    print(A)
    1 / 0
values = input()
values = [int(x) for x in values]

sum = 0

for val in values:
  sum += val
  
if val >= 22:
  print("bust")
else:
  print("win")

### FIXED CODE ###

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

sum = 0

for val in values:
    sum += val

if sum >= 22:
    print("bust")
else:
    print("win")
n=int(input())
l=list(map(int,input().split()))
if 2* max(s) < sum(l):
  print("Yes")
else:
  print("No")

### FIXED CODE ###

n=int(input())
l=list(map(int,input().split()))
if 2* max(l) < sum(l):
  print("Yes")
else:
  print("No")
n,k = map(int,input().split())
p = list(map(int,input().split()))
p.sort()
print(sum(p[:k]))

### FIXED CODE ###

# -*- coding: utf-8 -*-
a = str(input())
 
if 'a' <= a <= 'z':
  print('a')
if 'A' <= a <= 'Z':
  print('A')
X=int(input())
Y=int(input())
Z=int(input())
b=X
X=Z
Z=b
c=Z
Z=Y
Y=c
print(X,Y,Z)

### FIXED CODE ###

A,B,C=map(int,input().split())
print(C,A,B)
N, M = map(int, input().split())

group = []

MOD = 1000000007

if M == 0:
    group.append(N)
else:
    pre_a = int(input())
    group.append(pre_a)

    for i in range(M-1):
        a = int(input())
        tmp = a - pre_a - 1
        pre_a = a
        group.append(tmp)
    group.append(N - pre_a)

if 0 in group:
    print(0)
else:
    fiv = [0 for i in range(max(group))]
    fiv[0] = 1
    fiv[1] = 1
    for i in range(2, len(fiv)):
        fiv[i] = (fiv[i-1] + fiv[i-2]) % MOD
    ans = 1
    for g in group:
        ans *= fiv[g-1]
    print(ans%MOD)


### FIXED CODE ###

import sys
input = sys.stdin.readline

def main():
    N, M =map(int, input().split())
    a = [int(input()) for i in range(M)]

    sep = []
    pre = -1
    ok = True
    for t in a:
        tmp = t - pre - 1
        if tmp == 0:
            ok = False
            break
        sep.append(tmp)
        pre = t
    sep.append(N-pre)
    # print(sep)

    if not ok:
        print(0)
        return
    max_sep = max(sep)

    MOD = 1000000007
    fib = [1] * (max_sep)
    for i in range(2, max_sep):
        fib[i] = fib[i-2] + fib[i-1]
        fib[i] %= MOD
    
    ans = 1
    for s in sep:
        ans *= fib[s-1]
        ans %= MOD
    print(ans)


if __name__ == "__main__":
    main()
a,*b,c=input()
print(a+str(len(b))+C)

### FIXED CODE ###

a,*b,c=input()
print(a+str(len(b))+c)
from copy import deepcopy
H,W,A,B = map(int,input().split())
L = []
line = ["0" for j in range(W)]
for i in range(H) :
    tmp = deepcopy(line)
    for j in range(i,i+A) :
        tmp[j] = "1"
    L.append(tmp)
#print(L)
for j in range(W) :
    zero = 0
    one = 0
    for i in range(H) :
        if L[i][j] == "1" :
            one += 1
        else :
            zero += 1
    
    if min(one, zero) != B :
        print("No")
        break
else :
    for i in range(H) :
        print("".join(L[i]))


### FIXED CODE ###

H,W,A,B = map(int,input().split())

if (A >= W//2 + 1) or (B >= H//2 + 1) :
    print("No")
else :

    L = [["0"]*W for i in range(H)]

    for i in range(H) :
        for j in range(W) :
            if ((i < H-B) and (j < W-A)) or ((i >= H-B) and (j >= W-A)) :
                L[i][j] = "1"


    for j in range(W) :
        zero = 0
        one = 0
        for i in range(H) :
            if L[i][j] == "0" :
                zero += 1
            else :
                one += 1
        if min(zero,one) != B :
            print("No")
            break
    else :
        for i in range(H) :
            print("".join(L[i]))
import sys

for v in iter(sys.stdin,''):
    h,w = map(int,v.split())

    for i in range(h+1):
        print('#'*w)
 
    print('')

### FIXED CODE ###

import sys

for v in iter(sys.stdin.readline,''):
    h,w = map(int,v.split())

    if h == 0 and w == 0:
        break

    for i in range(h):
        print('#'*w)
    print('')
p, q = map(int, input().split())

def lcm(a, b):
    return (a * b) // math.gcd(a, b)

print(lcm(p, q))

### FIXED CODE ###

p, q = map(int, input().split())
import fractions
 
def lcm(a, b):
    return (a * b) // fractions.gcd(a, b)

print(lcm(p, q))
while True:
    n=sum(list(map(int, list(input())))
    if n == 0:
        break
    print(n)

### FIXED CODE ###

while True:
    n=sum(list(map(int, list(input()))))
    if n == 0:
        break
    print(n)
from math import log2

N = int(input())
L = list(map(int, input().split()))

res = 0

for l in L:
    while (l % 2 == 0):
        res += 1
        l = l //  2
    
print(res)

### FIXED CODE ###

from math import log2

N = int(input())
L = list(map(int, input().split()))

res = 0

for num in L:
    l = num
    while (l % 2 == 0):
        res += 1
        l = l //  2
    
print(res)
N,K = map(int,input().split())
A = [int(x) for x in input().split()]

nums = []
nums_2 = []
for i in range(N):
  num = int(A[i])
  s = 0
  k = 0
  for j in range(i,N):
    if A[j] < num:
      s += 1
  nums.append(s)
  for t in range(N):
    if A[t] < num:
      k += 1
  nums_2.append(k)

result = 0
for i in range(N):
  result += ((K*(K-1))/2)*(nums_2[i]) + K*nums[i]


print(int(result%(10E9+7)))

### FIXED CODE ###

month,day = map(int,input().split())

if day < 22:
  print(0)
else:
  s = 0
  for j in range(month+1):
    for i in range(22,day+1):
      num_1 = i%10
      num_2 = (i-num_1)/10
      if  num_1< 2:
        continue
      elif num_1 * num_2 == j:
        s += 1
  print(s)
import math
[print(i) for i in [math.ceil(((4.9*(a/9.8)**2)+5)/5) for a in float(input())]]



### FIXED CODE ###

import math,sys
[print(i) for i in [math.ceil(((4.9*(float(a)/9.8)**2)+5)/5) for a in sys.stdin]]
N = input()
a = list(map(input().split(N+1))
i = 0
for x in a:
	if x%2!=0 and a[x]%2!=0:
    	i+=1
     
    print(i)


### FIXED CODE ###

N = int(input())
a = list(map(int,input().split()))
i=0
for x,y in enumerate (a):
    b=x+1
    if b%2!=0 and y%2!=0:
        i+=1
print(i)
n = int(input())
 
hats = [0, 0, 0]
count = 1
mod = 1000000007
 
for a in map(int, input().split()):
  count *= hats.count(a)
  count %= mod
  try:
    hats[hats.index(a)] += 1
  except ValueError:
    count = 0
    break
  
print(count)

### FIXED CODE ###

# -*- coding: utf-8 -*-
m_1, d_1 = map(int, input().split())
m_2, d_2 = map(int, input().split())

if m_1 == m_2:
  print(0)
else:
  print(1)
# coding: utf-8
import os
import time
import re
import math

N=int(input())
print(180*(N-2)

### FIXED CODE ###

# coding: utf-8
import os
import time
import re
import math
 
N=int(input())
print(180*(N-2))
# solution
import io

nim = int(input())

a, b = input().split()

for _a, _b in zip(a, b):
    print(_a + _b, end="")

### FIXED CODE ###

val = {1, 2, 3}
val.remove(int(input()))
val.remove(int(input()))
print(list(val)[0])
n,m = map(int,input().split()）
ab = [list(map(int,input().split())) for _ in range(n)]
ab = sorted(ab, key=lambda ab:ab[0])

ans = 0
total = 0
for i in range(n):
  num = m-toal
  if ab[i][1]<=num:
    total += ab[i][1]
    ans += ab[i][0]*ab[i][1]
  else:
    total += num
    ans += num*ab[i][1]
    break
print(ans)


### FIXED CODE ###

n,m = map(int,input().split())
drink = [list(map(int,input().split())) for _ in range(n)]
drink = sorted(drink, key=lambda drink:drink[0])
money = 0
total = 0
for i in range(n):
  if total+drink[i][1]<m:
    total += drink[i][1]
    money += drink[i][1]*drink[i][0]
  else:
    money += drink[i][0]*(m-total)
    print(money)
    exit()
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from math import factorial

fac = [0] * (10**6+1)
ifac = [0] * (10**6+1)
d = 10**9 + 7

def mpow(x, n):
    ans = 1
    while n != 0:
        if n&1:
            ans = ans * x % d
        x = x*x % d
        n = n >> 1
    return ans

def comb(a, b):
    if a == 0 and b == 0:
        return 1
    if a < b or a < 0:
        return 0
    tmp = ifac[a-b] * ifac[b] % d
    return tmp * fac[a] % d

def main():
    global fac, ifac
    x, y = map(int, input().strip().split())
    if (x + y) % 3 != 0:
        print(0)
        return
    k = (x+y) // 3
    q = x - k

    fac[0] = 1
    ifac[0] = 1
    for i in range(10**6+1):
        fac[i+1] = fac[i]*(i+1) % d
        ifac[i+1] = ifac[i]*mpow(i+1, d-2) % d

    print(comb(k, q) % d)

if __name__ == '__main__':
    main()


### FIXED CODE ###

import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30
from math import factorial

fac = [0] * (10**6+5)
ifac = [0] * (10**6+5)
d = 10**9 + 7

def mpow(x, n):
    ans = 1
    while n != 0:
        if n&1:
            ans = ans * x % d
        x = x*x % d
        n = n >> 1
    return ans

def comb(a, b):
    if a == 0 and b == 0:
        return 1
    if a < b or a < 0:
        return 0
    tmp = ifac[a-b] * ifac[b] % d
    return tmp * fac[a] % d

def main():
    global fac, ifac
    x, y = map(int, input().strip().split())
    if (x + y) % 3 != 0:
        print(0)
        return
    k = (x+y) // 3
    q = x - k
    if x - 2 * q < 0 or q < 0:
        print(0)
        return

    fac[0] = 1
    ifac[0] = 1
    for i in range(10**6+1):
        fac[i+1] = fac[i]*(i+1) % d
        ifac[i+1] = ifac[i]*mpow(i+1, d-2) % d

    print(comb(k, q) % d)

if __name__ == '__main__':
    main()
n,m=map(int, input().split())
a=list(map(int, input().split()))
bc = [list(map(int, input().split())) for i in range(m)]
a.sort()
bc.sort(reverse=True, key=lambda x:x[1])
count=0
for i in range(m):
    for j in range(count,count+bc[i][0]):
        if a[j]<bc[i][1]:
            a[j]=bc[i][1]
            count+=1
print(sum(a))

### FIXED CODE ###

n,m=map(int, input().split())
a=list(map(int, input().split()))
bc = [list(map(int, input().split())) for i in range(m)]
x=[]
for i in range(n):
    x.append([a[i],1])
for i in range(m):
    x.append([bc[i][1],bc[i][0]])
x.sort(reverse=True)
ans=0
count=n
for i in range(n):
    if x[i][1]<count:
        ans+=x[i][0]*x[i][1]
    else:
        ans+=x[i][0]*count
    count-=x[i][1]
    if count<=0:
        break
print(ans)
N, M = map(int, input().split())
A = list(map(int, input().split()))
C = []
for i in range(M):
  b, c = map(int, input().split())
  for i in range(b):
    C.append(c)

A.sort()
C.sort(reverse=True)
j = 0
while A[j] < C[j]:
  A[j] = C[j]
  j += 1
  
print(sum(A))

### FIXED CODE ###

import sys
from operator import itemgetter

def solve():
    input = sys.stdin.readline
    N, M = map(int, input().split())
    A = [int(a) for a in input().split()]
    A.sort()
    change = [[int(i) for i in input().split()] for _ in range(M)]
    change.sort(key = itemgetter(1), reverse = True)

    ai = 0
    for i in range(M):
        cb, c = change[i]
        if ai >= N or c < A[ai]: break
        for _ in range(cb):
            if ai >= N: break
            if A[ai] <= c:
                A[ai] = c
                ai += 1
            else: break
    print(sum(A))
    return 0

if __name__ == "__main__":
    solve()
N = int(input()) 
for i in range(N) :
   p = list(map(int,input().split(" ")))
   p.sort()
   if p[0]**2 + p[1]**2== p[2]**2:
     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 numpy as np

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

a = np.array(a)

a_abs = list(map(abs,a))
a_abs = np.array(a_abs)

a_sort = sorted(a_abs,reverse=True)

a_arg = np.argsort(-a_abs)

a_arg_k = a_arg[0:k]
a_arg_k_ = a_arg[k:]

a_pow = 1

if all([1 if i < 0 else 0 for i in a]) and (k % 2 != 0):
    for i in range(n,k-1,-1):
        a_pow *= a[a_arg[i-1]]

else:
    for i in range(k):
        a_pow *= a[a_arg[i]]
    
    if a_pow < 0:
        a_pow_p = 1
        for i in reversed(a_arg_k):
            if a[i] < 0:
                for j in a_arg_k_:
                    if a[j] > 0:
                        a_pow_p = a_pow/a[i]*a[j]
                        break
                break
                
        a_pow_m = 1
        for i in reversed(a_arg_k):
            if a[i] > 0:
                for j in a_arg_k_:
                    if a[j] < 0:
                        a_pow_m = a_pow/a[i]*a[j]
                        break
                break
        if a_pow_p > a_pow_m:
            a_pow = a_pow_p
        else:
            a_pow = a_pow_m

output = a_pow % (10**9 + 7)
print(output)

### FIXED CODE ###

N = int(input())

if N % 1000 == 0:
    print(0)
else:
    hasu = N - (N // 1000)*1000
    print(1000-hasu)
N = int(input())
S = [0]*N
for i in range(N):
    S[i] = input()

prize = [S[1]]
flag = 0
for i in range(N):
    for j in range(len(prize)):
        if(S[i] == prize[j]):
            flag = 1
    if(flag==0):
        prize = prize + [S[i]]
    flag = 0


print(len(prize))


### FIXED CODE ###

N = int(input())
S = []
for i in range(N):
    S.append(input())

S.sort()

dup = 0;
for i in range(N):
    if i!=0:
        if S[i] == S[i-1]:
            dup += 1

print(N-dup)
n = int(input())
a = int(input())
b = int(input())

print("{}".format(min(n*a, b)))

### FIXED CODE ###

n, a, b = input().split()
n = int(n)
a = int(a)
b = int(b)
print("{}".format(min(n*a, b)))
from sys import stdin

n, k = [int(x) for x in stdin.readline().rstrip().split()]
v = list(map(int, input().split()))

l = [ [(0, [])]*(k+1) for _ in range(k+1)]

left=0
right=0
for i in range(k+1):
  left=0
  for j in range(k+1):
    if i==0 and j==0:
        continue
#    if k <= (left+right):
    if k < (i+j):
        break
    if j==0:
      item = v[(n-1)-right]
      right +=1
      l[i][j] = (l[i-1][j][0]+item,l[i-1][j][1]+[item])
      continue
    item = v[left]
    left +=1
    l[i][j] = (l[i][j-1][0]+item,l[i][j-1][1]+[item])

#for i in range(k+1):
#  print(l[i])

ans = 0
for i in range(k+1):
  for j in range(k+1):
    if k < (i+j):
      break
    value = l[i][j][0]
    if ( k != (i+j)):
        itemlist = l[i][j][1]
        itemlist.sort()
        #print(itemlist)
        for ii in range (k-(i+j)):
           if len(itemlist) <= ii:
               break
           if 0 < itemlist[ii]:
               break
           value -= itemlist[ii]
        #print(i,j,value)
    ans = max(ans, value)

print(ans)


### FIXED CODE ###

from sys import stdin

n, k = [int(x) for x in stdin.readline().rstrip().split()]
v = list(map(int, input().split()))

l = [ [(0, [])]*(k+1) for _ in range(k+1)]

left=0
right=0
for i in range(k+1):
  left=0
  for j in range(k+1):
    if i==0 and j==0:
        continue
#    if k <= (left+right):
    if len(v) < (i+j):
        break
    if k < (i+j):
        break
    if j==0:
      item = v[(n-1)-right]
      right +=1
      l[i][j] = (l[i-1][j][0]+item,l[i-1][j][1]+[item])
      continue
    item = v[left]
    left +=1
    l[i][j] = (l[i][j-1][0]+item,l[i][j-1][1]+[item])

#for i in range(k+1):
#  print(l[i])

ans = 0
for i in range(k+1):
  for j in range(k+1):
    if k < (i+j):
      break
    value = l[i][j][0]
    if ( k != (i+j)):
        itemlist = l[i][j][1]
        itemlist.sort()
        #print(itemlist)
        for ii in range (k-(i+j)):
           if len(itemlist) <= ii:
               break
           if 0 < itemlist[ii]:
               break
           value -= itemlist[ii]
        #print(i,j,value)
    ans = max(ans, value)

print(ans)
x = 3
print x**3:

### FIXED CODE ###

x = raw_input()
x = int(x)
print x*x*x
import math
N,K=map(int,input().split())
A=list(map(int,input().split()))
def check(x):
  if x==0:
    return 0
  else:
    t=0
    for i in range(N):
      t+=math.ceil(A[i]/x)-1
    if t<=K:
      return 10
    else:
      return 0
low=1
high=max(A)
sig=(low+high)//2
while True:
  if check(sig)==10:
    if check(sig-1)==0:
      ans=sig
      break
    else:
      high=sig-1
      sig=(low+high)//2
  else:
    low=sig+1
    sig=(high+low)//2
print(ans)


### FIXED CODE ###

X=int(input())
if X>=30:
  print("Yes")
else:
  print("No")
A,B=map(str,input().split())
A=int(A)
B=list(B)
if '.' in B:
    B.remove('.')
else:
    B.append('0')
    B.append('0')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
ans.pop(len(ans)-1)
ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)

### FIXED CODE ###

A,B=map(str,input().split())
A=int(A)
B=list(B)
if len(B)<=2:
    B.append('0')
    B.append('0')
elif B[-3]=='.':
        B.remove('.')
elif B[-2]=='.' :
    B.remove('.')
    B.append('0')
else:
    B.append('0')
    B.append('0')
n=len(B)
b=sum(10**(n-1-j)*int(B[j]) for j in range(n))
ans=list(str(A*b))
if len(ans)<=2:
    ans='0'
else:
    ans.pop(len(ans)-1)
    ans.pop(len(ans)-1)
n2=len(ans)
trueans=sum(10**(n2-1-j)*int(ans[j]) for j in range(n2))
print(trueans)