Harryxun/stf_run huggingface dataset:
n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

a     = []
count = 0
point = []
PP = []

for _ in range(1025,2048):
    a.append(list(map(int,list(bin(_)[3:]))))

for k in range(1024):
    for i in range(n):
        for j in range(10):
            if f[i][j]&a[k][j] == 1:
                count += 1
        point.append(p[i][count])
        count = 0
    PP.append(sum(point))
    point = []
print (max(PP))

### FIXED CODE ###

n = int(input())
f = [list(map(int,input().split())) for _ in range(n)]
p = [list(map(int,input().split())) for _ in range(n)]

a     = []
count = 0
point = []
PP = []

for _ in range(2**10+1,2**10*2):
    a.append(list(map(int,list(bin(_)[3:]))))

for k in range(2**10-1):
    for i in range(n):
        for j in range(10):
            if f[i][j]&a[k][j] == 1:
                count += 1
        point.append(p[i][count])
        count = 0
    PP.append(sum(point))
    point = []
print (max(PP))
N = int(input())
    print(int((N*(N-1))//2))

### FIXED CODE ###

N = int(input())
print(int((N*(N-1))//2))
import sys

def fibo(n):
    a, b = 0, 1
    if n == 1:
        return 1
    else:
        for i in range(n):
            a0 = a
            a = b
            b = a0 + b
        return b
        
N, M = map(int, input().split())
a = []

if M = 0:
    print(fibo(N))
    sys.exit()

for i in range(M):
    a.append(int(input()))
    
for j in range(len(a)-1):
    if a[j+1] - a[j] == 1:
        print(0)
        sys.exit()
    
hole = 0
pattern = 1

for i, k in enumerate(a):
    if i == 0:
        pattern *= fibo(k-1)
    else:
        if i > 0:
            pattern *= fibo(a[i]-a[i-1]-2)
        
pattern *= fibo(N-a[-1]-1)
print(pattern % 1000000007)

### FIXED CODE ###

import sys

mod = 10**9 + 7

def fibo(n):
    a, b = 0, 1
    if n == 1:
        return 1
    else:
        for i in range(n):
            a0 = a
            a = b
            b = a0 + b
        return b
        
N, M = map(int, input().split())
a = []
 
if M == 0:
    print(fibo(N) % mod)
    sys.exit()
 
for i in range(M):
    a.append(int(input()))
    
for j in range(len(a)-1):
    if a[j+1] - a[j] == 1:
        print(0)
        sys.exit()
    
hole = 0
pattern = 1
 
for i, k in enumerate(a):
    if i == 0:
        pattern *= fibo(k-1)
    else:
        if i > 0:
            pattern *= fibo(a[i]-a[i-1]-2)
        
pattern *= fibo(N-a[-1]-1)
print(pattern % mod)
mod = 10**9+7
N, M = map(int, input().split())
a = [int(input()) for _ in range(M)]
k = [0]*(N+1)
k[0]=1
cnt = 0
if a[0]!=1:
    k[1]=1
else:
    cnt+=1
for i in range(2, N+1):
    if cnt<M and i ==a[cnt]:
        cnt+=1
        continue
    else:
        k[i]=k[i-1]+k[i-2]
print(k[N]%mod)


### FIXED CODE ###

def solve():
    mod = 10**9+7
    N, M = map(int, input().split())
    k = [0]*(N+1)
    if M==0:
        k[0]=1
        k[1]=1
        for i in range(2, N+1):
            k[i]=(k[i-1]+k[i-2])%mod
        print(k[N]%mod)
        return
    a = [int(input()) for _ in range(M)]
    k[0]=1
    cnt = 0
    if a[0]!=1:
        k[1]=1
    else:
        cnt+=1
    for i in range(2, N+1):
        if cnt<M and i ==a[cnt]:
            cnt+=1
            continue
        else:   
            k[i]=(k[i-1]+k[i-2])%mod
    print(k[N]%mod)
    return
solve()
N, M = map(int, input().split())
X = list(map(int, input().split()))
ans = 0
diff = []
 
X.sort()
 
for i in range(M-1):
  dif = X[i+1] -X[i]
  diff.append(dif)
  
diff.sort()
 
for n in range(N):
  diff.pop(-1)
 
for i in range(len(diff)):
  ans += diff[i]

print(ans)

### FIXED CODE ###

T, X = map(int, input().split())
  
ans = T / X
print(ans)
N, K = map(int, input().split())
D = list(map(int, input().split()))
flg = True
while True:
  num = str(N)
  for i in range(len(num)):
    if num[i] in D:
      flg = False
      break
  if fig is True:
    print(int(num))
    break
  N += 1
  

### FIXED CODE ###

N, K = map(int, input().split())
D = list(map(str, input().split()))
while True:
    flg = True
    num = str(N)
    for i in range(len(num)):
        if num[i] in D:
            flg = False
            break
    if flg is True:
        print(int(num))
        break
    N += 1
n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a_2)
b=[]
out=0
for i in c.values():
    b.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    if b[0]!=b[1] or b[1]!=b[2]:
        out=1
    else:
        pass
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')

### FIXED CODE ###

n=int(input())
a=list(map(int,input().split()))
a_2=[]
for i in range(len(a)):
    a_2.append(bin(a[i]))
import collections
c = collections.Counter(a)
b=[]
d=[]
out=0
for i in c.values():
    b.append(i)
for i in c.keys():
    d.append(i)
if a.count(0)==0:#0がない場合
    if len(b)!=3:
        out=1
    elif b[0]!=b[1] or b[1]!=b[2]:
        out=1
    elif (d[0]^d[1]^d[2])!=0:
        out=1
else:#0あり
    if len(b)>2:
        out=1
    elif len(b)==1:
        pass
    elif len(b)==2:
        if a.count(0)*3==len(a):
            pass
        else:
            out=1
if out==0:
    print('Yes')
elif out==1:
    print('No')
a=str(input())
a=list(a)
count=0
if a%2 == 0:
  for i in range(0,int(a/2)):
    if a[i]==a[len(a)-i-1]:
      count=count+1
else:
  for i in range(0,int(a/2)):
    if a[i]==a[len(a)-i-1]:
      count=count+1
  
print(count)

### FIXED CODE ###

a=str(input())
a=list(a)
count=0
for i in range(0,int(len(a)/2)):
    if a[i]!=a[len(a)-i-1]:
        count=count+1
  
print(count)
n = int(input())
a = list(map(int,input().split()))

for i in range(n):
    if a[i] < 400:
        a[i] = 0
    elif a[i] < 800:
        a[i] = 1
    elif a[i] < 1200:
        a[i] = 2
    elif a[i] < 1600:
        a[i] = 3
    elif a[i] < 2000:
        a[i] = 4
    elif a[i] < 2400:
        a[i] = 5
    elif a[i] < 2800:
        a[i] = 6
    elif a[i] < 3200:
        a[i] = 7
    else:
        a[i] = 8

if a.count(8) > 0:
    print(len(set(a)),len(set(a))+2)
else:
    print(len(set(a))+ '' + len(set(a)))

### FIXED CODE ###

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

for i in range(n):
    if a[i] < 400:
        a[i] = 0
    elif a[i] < 800:
        a[i] = 1
    elif a[i] < 1200:
        a[i] = 2
    elif a[i] < 1600:
        a[i] = 3
    elif a[i] < 2000:
        a[i] = 4
    elif a[i] < 2400:
        a[i] = 5
    elif a[i] < 2800:
        a[i] = 6
    elif a[i] < 3200:
        a[i] = 7
    else:
        a[i] = 8

if a.count(8) > 0:
    print(max(len(set(a))-1,1),len(set(a)) -1 +a.count(8))
else:
    print(len(set(a)),len(set(a)))
a = input()
if a.isupper():
  print("A")
else:
  peint("a")


### FIXED CODE ###

a = input()
if a.isupper():
  print("A")
else:
  print("a")
import math
from functools import reduce
N = int(input())
Alist = list(map(int, input().split()))
def gcd(numbers):
    return reduce(math.gcd, numbers)
print(max([gcd(Alist[:i]+Alist[i+1:]) for i in range(N)]))


### FIXED CODE ###

from fractions import gcd
N = int(input())
Alist = [0]+list(map(int, input().split()))+[0]
Rlist = [0]*(N+2)
Llist = [0]*(N+1)
for i in range(N):
    Llist[i+1] = gcd(Llist[i], Alist[i])
    Rlist[N-i] = gcd(Rlist[N-i+1], Alist[N-i+1])
print(max([gcd(Rlist[i], Llist[i]) for i in range(1,N+1)]))
#!/usr/bin/env python
import sys
sys.setrecursionlimit(10000)

matrix = []
vec = [[1,0],[-1,0],[0,1],[0,-1]]
visited =[]
h = 0
w = 0

def dfs(x,y,fruit):
  global visited
  visited.append((x,y))
  for v in vec:
    nx = x + v[0]
    ny = y + v[1]
    if (not (nx,ny) in visited) and nx in xrange(w) and ny in xrange(h):
      if matrix[ny][nx] == fruit:
        dfs(nx,ny,fruit)
  return 0


while True:
  h,w = map(int,raw_input().rstrip().split(" "))
  if h == 0 and w == 0:
    break
  matrix = []
  visited = []
  ans = 0
  for i in xrange(h):
    s = raw_input().rstrip()
    matrix.append(list(s))
  for i in xrange(h):
    for j in xrange(w):
      if not (j,i) in visited:
        dfs(j,i,matrix[i][j])
        ans+=1
  print ans

### FIXED CODE ###

#!/usr/bin/env python
import sys

sys.setrecursionlimit(20000)

matrix = []
vec = [[1,0],[-1,0],[0,1],[0,-1]]
visited =[]
h = 0
w = 0

def dfs(x,y,fruit):
  #visited.append((x,y))
  visited[y][x] = 1
  for v in vec:
    nx = x + v[0]
    ny = y + v[1]
    if nx in xrange(w) and ny in xrange(h):
      if visited[ny][nx]==0 and matrix[ny][nx] == fruit:
        dfs(nx,ny,fruit)
  return 0


while True:
  h,w = map(int,raw_input().split())
  if h == 0 and w == 0:
    break
#  print h,w
  matrix = []
  visited = []
  ans = 0
  for i in xrange(h):
    s = raw_input().rstrip()
    matrix.append(list(s))
    visited.append([0]*w)
  for i in xrange(h):
    for j in xrange(w):
      #if not (j,i) in visited:
      if visited[i][j] == 0:
        dfs(j,i,matrix[i][j])
        ans+=1
  print ans
x, n = [int(i) for i in input().split()]
flag = [0 for i in range(101)]
if (n != 0):
    p = [int(i) for i in input().split()]

    for i in p:
        flag[i] = 1



for i in range(100):
    if flag[x-i] == 0:
        ans = x-i
        break

    if flag[x+i] == 0:
        ans = x+i
        break
    
print(ans)



### FIXED CODE ###

x, n = [int(i) for i in input().split()]
flag = [0 for i in range(105)]
if (n != 0):
    p = [int(i) for i in input().split()]

    for i in p:
        flag[i] = 1



for i in range(100):
    if x-i >=0:
        if flag[x-i] == 0:
            ans = x-i
            break
    else:
        ans = -1
        break

    if flag[x+i] == 0:
        ans = x+i
        break
    
print(ans)
import sys
input=lambda: sys.stdin.readline().rstrip()
n,s=map(int,input().split())
A=[int(i) for i in input().split()]
mod=998244353
B=[[0]*(s+1) for _ in range(n+1)]
ans=0
for i in range(n):
  a=A[i]
  if a<=s:
    B[i+1][a]+=i+1
  for j in range(s+1):
    B[i+1][j]+=B[i][j]
    if 0<=j-a and j<s:
      B[i+1][j]+=B[i][j-a]
    if j==s:
      B[i+1][j]+=B[i][j-a]*(n-i)
    B[i+1][j]%=mod
print(B[n][s])

### FIXED CODE ###

import sys
input=lambda: sys.stdin.readline().rstrip()
n,s=map(int,input().split())
A=[int(i) for i in input().split()]
mod=998244353
B=[[0]*(s+1) for _ in range(n+1)]
ans=0
for i in range(n):
  a=A[i]
  if a<s:
    B[i+1][a]+=i+1
  elif a==s:
    B[i+1][a]+=(i+1)*(n-i)
  for j in range(s+1):
    if j<=s:
      B[i+1][j]+=B[i][j]
    if 0<=j-a and j<s:
      B[i+1][j]+=B[i][j-a]
    if 0<=j-a and j==s:
      B[i+1][j]+=B[i][j-a]*(n-i)
    B[i+1][j]%=mod
print(B[n][s])
n = int(input)
count = 0
ans = 'No'
for _ in range(n):
	a,b = map(int,input().split(' ')
    if a!=b:
    	ans = 0 
    else:
    	count+=1
    if count ==3:
    	ans = 'Yes'
print(ans)        

### FIXED CODE ###

n = int(input())
count = 0
ans = 'No'
for i in range(n):
    a , b = map(int,input().split(' '))
    if a!=b:
        count = 0 
    else:
        count += 1
    if count == 3:
        ans = 'Yes'
print(ans)
from collections import deque
import sys

sys.setrecursionlimit(10000000000000000)
 
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
    x, y = map(int,input().split())
    nodes.append((x,y))
    par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
 
for i in range(n-1):
    xcost =nodesx[i+1][0]-nodesx[i][0]
    ycost =nodesy[i+1][1]-nodesy[i][1]
    s.append((xcost,(nodesx[i+1],nodesx[i])))
    s.append((ycost,(nodesy[i+1],nodesy[i])))
s.sort()
s = deque(s)
def root(node,par):
    if node == par[node]:
        return node
    else:
        par[node] =root(par[node],par)
        return par[node]
def unite(node1,node2,par):
    par[root(node1,par)] = root(node2,par)
ans = 0
count =0
while count < n-1 :
    cost,(node1,node2) = s.popleft()
    if root(node1,par) != root(node2,par):
        unite(node1,node2,par)
        ans +=cost
        count += 1
print(ans)


### FIXED CODE ###

from collections import deque
import sys
 
sys.setrecursionlimit(2000000000)
 
n = int(input())
nodes = []
done = [0 for _ in range(n)]
par = {}
for _ in range(n):
    x, y = map(int,input().split())
    nodes.append((x,y))
    par[(x,y)]=(x,y)
nodesx = sorted(nodes)
nodesy = sorted(nodes,key=lambda z:z[1])
s = []
m = len(set(nodes))
for i in range(n-1):
    xcost =nodesx[i+1][0]-nodesx[i][0]
    ycost =nodesy[i+1][1]-nodesy[i][1]
    s.append((xcost,(nodesx[i+1],nodesx[i])))
    s.append((ycost,(nodesy[i+1],nodesy[i])))
s.sort()
s = deque(s)
def root(node,par):
    if node == par[node]:
        return node
    else:
        par[node] =root(par[node],par)
        return par[node]
def unite(node1,node2,par):
    par[root(node1,par)] = root(node2,par)
ans = 0
count =0
while count < m-1 :
    cost,(node1,node2) = s.popleft()
    root1 =root(node1,par)
    root2 =root(node2,par)
    if root1 != root2:
        unite(node1,node2,par)
        ans +=cost
        count += 1
print(ans)
a = input()
n = input()

print ((n * n) - a)

### FIXED CODE ###

N = int(input())
A = int(input())

print(N*N-A)
n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis={}
vis[0] = 0
vis[1] = 0
if n > 1:
  vis[2] = abs(arr[0]-arr[1])
if n == 2:
  print(vis[2])
for i in range(2, n+1):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-1]
    vis[i+1] = min(step_1, step_2)
   
print(vis[n])

### FIXED CODE ###

n=int(input())
arr=list(map(int,input().split()))
if n < 2:
  print(0)
vis = [0] * n
vis[0] = 0
vis[1] = abs(arr[0]-arr[1])
for i in range(2, n):
    step_1 = abs(arr[i]-arr[i-1]) + vis[i-1]
    step_2 = abs(arr[i]-arr[i-2]) + vis[i-2]
    vis[i] = min(step_1, step_2)
print(vis[-1])
#inserting X
s=input()
length=len(s)
string=""
for i in range(length):
    if s[i]!="x":
        string=string+s[i]
    else:
        continue

flag=True
length2=len(string)
if length2>=2:
    for i in range(length//2):
        if string[i]!=string[-(i+1)]:
            flag=False
            break
if flag:
    s="x"+s+"X"
    length=len(s)
    checklist=[]
    count=0
    for i in range(length):
        if s[i]=="x":
            count+=1
        else:
            checklist.append(count)
            count=0
    checklist[0]-=1
    ans=0
    for i in range(len(checklist)//2):
        ans+=max(checklist[i],checklist[-(i+1)])
    print(ans)
    
    
else:
    print("-1")
    
    

### FIXED CODE ###

#inserting X
s=input()
length=len(s)
string=""
for i in range(length):
    if s[i]!="x":
        string=string+s[i]
    else:
        continue


flag=True
length2=len(string)
if length2>=2:
    for i in range(length2//2):
        if string[i]!=string[-(i+1)]:
            flag=False
            break
if flag:
    s="x"+s+"X"
    length=len(s)
    checklist=[]
    count=0
    for i in range(length):
        if s[i]=="x":
            count+=1
        else:
            checklist.append(count)
            count=0
    checklist[0]-=1
    ans=0
    for i in range(len(checklist)//2):
        ans+=abs(checklist[i]-checklist[-(i+1)])
    print(ans)
    
else:
    print("-1")
import numpy as np

N=int(input())
A=list(map(int, input().split()))
Q=int(input())
B,C=map(int, input().split())
rep=[i for i, x in enumerate(A) if x == B]
for i in range(len(rep)):
    A[rep[i]]=C
ans=np.cumsum(A)
print(ans[1])

for _ in range(Q-1):
    B,C=map(int, input().split())
    rep=[i for i, x in enumerate(A) if x == B]
    for i in range(len(rep)):
        A[rep[i]]=C
    ans+=(C-B)*len(rep)
    print(ans[1])

### FIXED CODE ###

mod=pow(10,5)+2
N=int(input())
num=[0]*mod
ans=0
A=list(map(int, input().split()))
for i in range(N):
    num[A[i]]+=1
    ans+=A[i]
Q=int(input())
for i in range(Q):
    B,C=map(int, input().split())
    cnt=num[B]
    num[C]+=num[B]
    num[B]=0
    ans+=(C-B)*cnt
    print(ans)
from decimal import *

m = int(input())
ans = 0
num = ""
for i in range(m):
    d, c = input().split()
    d = int(d)
    if len(c) > 3:
        num += c[:10]
        c = int(c[10:])
    if d == 0:
        ans += c
    else:
        k = str(d) * c
        while len(k) > 1:
            if len(k) > 2:
                k = str(int(k[0]) + int(k[1])) + k[2:]
            else:
                k = str(int(k[0]) + int(k[1]))
            ans += 1
        num += k
while len(num) > 1:
    if len(num) > 2:
        num = str(int(num[0]) + int(num[1])) + num[2:]
    else:
        num = str(int(num[0]) + int(num[1]))
    ans += 1
print(ans)

### FIXED CODE ###

import sys
input = sys.stdin.readline
m = int(input())
ans = 0
sum_num = 0
c_sum = 0
for i in range(m):
    d,c = map(int, input().split())
    sum_num += d*c
    c_sum += c
#合計に対して、9減らす行為が何回出来るか
print(c_sum-1 + ((sum_num-1)//9))
N,M = list(map(int,input().split()))
a = [int(input()) for i in range(M)]
dekai = 1000000007
 
def Fib(n):
	a,b = 0,1
	if n == 1:
		return a
	elif n == 2:
		return b
	else:
		for i in range(n-2):
			a,b = b,a+b
		return b


ans = 1
for i in range(M+1):
	if i == 0:
		ans = (ans*Fib(a[0]-(-1)))%dekai
	elif i == M:
		ans = (ans*Fib(N+1-a[M-1]))%dekai
	else:
		ans = (ans*Fib(a[i]-a[i-1]))%dekai
print(ans)

### FIXED CODE ###

N,M = list(map(int,input().split()))
a = [int(input()) for i in range(M)]
dekai = 1000000007
"""
import sympy as sym

def Fib(n):
	x = sym.symbols('x',nonnegative=True,integer=True)
	Fib=1/sym.sqrt(5)*(((1+sym.sqrt(5))/2)**(n-1)-((1-sym.sqrt(5))/2)**(n-1))
	result=Fib.subs(x,n)
	result=result.evalf(int(n*3/14)+1)
	return int(result)


"""
def Fib(n):
	a,b = 0,1
	if n == 1:
		return a
	elif n == 2:
		return b
	else:
		for i in range(n-2):
			a,b = b,a+b
		return b
ans = 1

if M == 0:
	print(Fib(N+1-(-1))%dekai)
	exit()

for i in range(M+1):
	if i == 0:
		ans = (ans*(Fib(a[0]-(-1))%dekai))%dekai
	elif i == M:
		ans = (ans*(Fib(N+1-a[M-1])%dekai))%dekai
	else:
		ans = (ans*(Fib(a[i]-a[i-1])%dekai))%dekai
print(ans)
def main():
    N = int(input())
    E = [0] * N
    for _ in range(N - 1):
        u, v = map(int, input().split())
        u, v = u - 1, v - 1
        if u > v:
            u, v = v, u
        E[v] += 1
    t = 0
    U = [0] * N
    for i in range(N):
        t += E[i]
        U[i] = t

    t = n * (n + 1) * (n + 2 ) // 6
    for i in range(N):
        t += U[i] * i - U[i] * (N - i)
    return t

print(main())


### FIXED CODE ###

def main():
    N = int(input())
    h = 0
    for _ in range(N - 1):
        u, v = map(int, input().split())
        if u > v:
            u, v = v, u
        h += u * (N + 1 - v)

    return N * (N + 1) * (N + 2) // 6 - h

print(main())
x,y=map(int, input().split())
import math
x1=math.ceil(x*12.5)
x2=math.ceil((x+1)*12.5)-1
y1=math.ceil(y*10)
y2=math.ceil((y+1)*10)-1
if x1>y2 or y1>x2:
	print -1
else:
	print (int(max(x1,y1)))

### FIXED CODE ###

x,y=map(int, input().split())
import math
x1=math.ceil(x*12.5)
x2=math.ceil((x+1)*12.5)-1
y1=math.ceil(y*10)
y2=math.ceil((y+1)*10)-1
if x1>y2 or y1>x2:
	print (-1)
else:
	print (int(max(x1,y1)))
a,b=map(int,input().split())#標準入力を行う
  print(a % b)

### FIXED CODE ###

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

if n % k == 0:
	print('0')
else :
	print('1')
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import defaultdict
mod = 10**9+7

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
cnt = defaultdict(int)
for i in range(N):
    for j in range(i+1, N):
        a, b = xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]
        cnt[(a, b)] += 1
        cnt[(-a, -b)] += 1
print(N-max(cnt.values()))


### FIXED CODE ###

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10000000)
from collections import defaultdict
mod = 10**9+7

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
xy.sort()
Ans = N
for i in range(N):
    for j in range(i+1, N):
        a, b = xy[j][0]-xy[i][0], xy[j][1]-xy[i][1]
        ans = N
        for k in range(N):
            for l in range(k+1, N):
                if xy[k][0]+a == xy[l][0] and xy[k][1]+b == xy[l][1]:
                    ans -= 1
        Ans = min(Ans, ans)
print(Ans)
import math

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


if M == 0 and H == 6:

    print(A+B)

elif M == 0 and H == 0:

    print(abs(A-B))

else:

    angulo = abs(11 * M - 60 * H)/2

    angulo = math.radians(angulo)

    print(abs(math.sqrt((A**2 + B ** 2) -  (2 * A * B * math.cos(angulo)))))


### FIXED CODE ###

numero = int(input())

digito_1 = numero % 10

if digito_1 == 2 or digito_1 == 4 or digito_1 == 5 or digito_1 == 7 or digito_1 == 9:
    print("hon")
elif digito_1 == 0 or digito_1 == 1 or digito_1 == 6 or digito_1 == 8:
    print("pon")
elif digito_1 == 3:
    print("bon")
n = inp()
s = input()
res = 0
a = [str(i) for i in range(10)]
for num in itertools.product(a, repeat=3):
    p = 0
    for i,j in enumerate(s):
        if j == num[p]:
            p += 1
            if p == 3:
                break
    if p == 3:
        res += 1
print(res)

### FIXED CODE ###

from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
s = input()
res = 0
a = [str(i) for i in range(10)]
for num in itertools.product(a, repeat=3):
    p = 0
    for i,j in enumerate(s):
        if j == num[p]:
            p += 1
            if p == 3:
                break
    if p == 3:
        res += 1
print(res)
# A Therefore

n = input()

if n[2] in ["2", "4", "5", "7", "9"]:
  print("hon")
elif n[2] in ["0", "1", "6", "8"]:
  print("pon")
else:
  print("bon")

### FIXED CODE ###

# A Therefore

n = input()

if n[-1] in ["2", "4", "5", "7", "9"]:
  print("hon")
elif n[-1] in ["0", "1", "6", "8"]:
  print("pon")
else:
  print("bon")
import string

N = int(input())

alf = {0:"a",1:"b",2:"c",3:"d",4:"e",5:"f",6:"g",7:"h",8:"i",9:"j",10:"k",11:"l",12:"m",13:"n",14:"o",15:"p",16:"q",17:"r",18:"s",19:"t",20:"u",21:"v",22:"w",23:"x",24:"y",25:"z"}

result=""
lis = []

while N>0:
    t = N%26
    lis += [t]
    N = int((N-t)/26)

for i in range(len(lis)):
    result = alf[lis[i]-1] + result

print(result)

### FIXED CODE ###

N = int(input())
Ans = ""
while N>0:
    s = N%26
    if s == 0:
        s = 26
    N = int((N - s)/26)
    Ans = chr(ord("a")+s-1)+Ans

print(Ans)
a = lsit(map(int,input().split()))
if len(set(a))==2:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

a = list(map(int,input().split()))
if len(set(a)) == 2:
    print("Yes")
else:
    print("No")
#coding:utf-8

if __name__ == "__main__":
    N = int(input())
    tmp = input().split()
    Hs = []
    for t in tmp:
        Hs.append(int(t))
    total = 0

    for n in range(N):
        n_count = 0
        for i in range(0, n):
            if Hs[i] > Hs[n]:
                break
            n_count += 1
        if n_count == n:
            total += 1
        
    print(str(total)+"\n")

### FIXED CODE ###

#coding:utf-8

if __name__ == "__main__":
    A, B = map(int, input().split())
    total = 0
    for n in range(2):
        if A < B:
            total += B
            B = B - 1
        else:
            total += A
            A = A - 1
    
    print(total)
import heapq

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

ans = []
for i in range(min(N, K)):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif heapq.heappop(lst) >= 0:
        break
      else:
        ans.append(sum(lst))
print(max(ans))

### FIXED CODE ###

import heapq

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

ans = [V[0]]
for i in range(min(N, K)+1):
  for j in range(i+1):
    #print(i-j, j)
    # i-j個左から、i個右から取る
    lst = V[:i-j] + V[2*N-j:]
    #print(lst)
    heapq.heapify(lst)
    for _ in range(K-i):
      if len(lst) == 0:
        break
      elif min(lst) >= 0:
        ans.append(sum(lst))
        break
      else:
        heapq.heappop(lst)
        ans.append(sum(lst))
        #print(ans)
print(max(ans))