Harryxun/stf_run huggingface dataset:
x,y = map(str,input().split())
a = {'1':300000,'2':200000,'3':100000}
if x == y == '1':
    print(1000000)
else:
    print(a[x]+a[y])

### FIXED CODE ###

x,y = map(str,input().split())
a = {'1':300000,'2':200000,'3':100000}
if int(x) > 3 or int(y) > 3:
    if int(x) <= 3:
        print(a[x])
    elif int(y) <= 3:
        print(a[y])
    else:
        print(0)
else:
    if x == y == '1':
        print(1000000)
    else:
        print(a[x]+a[y])
N = int(input())

point = [0] * N
dist = [0] * N
absolute = lambda x : x if x >= 0 else -x

for i in range(N) :
    x, y = map(int, input().split())
    point[i] = (x, y)
    dist[i] = absolute(x) + absolute(y)

maxDist = dist[-1]
mask = maxDist % 2

for i in range(N) :
    if dist[i] % 2 != mask :
        print('-1')
        break
    maxDist = max(maxDist, dist[i])
else :  # 実現可能
    print(maxDist) # 腕の数
    out = [1] * maxDist
    print(*out)

    for i, (x, y) in enumerate(point) :
        if x < 0 :
            holizon = ['L'] * absolute(x)
        elif x > 0 :
            holizon = ['R'] * absolute(x)
        else :
            holizon = ['']

        if y < 0 :
            vertical = ['D'] * absolute(y)
        elif y > 0 :
            vertical = ['U'] * absolute(y)
        else :
            vertical = ['']

        R = (maxDist - dist[i]) // 2
        if R > 0 :
            last = ['LR'] * R
        else :
            last = ['']

        print(''.join(holizon + vertical + last))



### FIXED CODE ###

N=int(input())

point = []
parity = {}
for _ in range(N) :
    x, y = map(int, input().split())
    point.append((x, y))
    parity[(x + y) % 2] = 1

if len(set(parity)) == 2 :
    print('-1')
else :
    m = 38
    parity = 1 if (1 in parity) else 0
    print(m + 1 - parity)
    if parity == 1 :  # 距離が奇数
        print(*[1 << i for i in range(m)])
    else :
        print(1, *[1 << i for i in range(m)])

    def arm(x, y, m) :
        if abs(x) >= abs(y) :
            if x >= 0 :
                return ('R', x - (1<<m), y)
            else :
                return ('L', x + (1<<m), y)
        else :
            if y >= 0 :
                return ('U', x, y - (1<<m))
            else :
                return ('D', x, y + (1<<m))

    for x, y in point :
        ans = []
        for i in range(m-1, -1, -1) :
            mode, x, y = arm(x, y, i)
            ans.append(mode)
        if parity == 0 :  # 偶数の場合一つ足す
            if x == 1 :
                ans.append('R')
            elif x == -1 :
                ans.append('L')
            elif y == 1 :
                ans.append('U')
            elif y == -1 :
                ans.append('D')
        print(''.join(ans[::-1]))
N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
b=a[0]+a[1]+a[2]
print(b)

### FIXED CODE ###

N,L=map(int,input().split())
l=[input() for i in range(N)]
a=sorted(l)
print(*a,sep='')
a = input()
s = "Sunny"
c = "Cloudy"
r = "Rainy"

if a == s:
		print(c)
else a == c:
		print(r)
		
else:
		print(s)

### FIXED CODE ###

a = input()
s = "Sunny"
c = "Cloudy"
r = "Rainy"
 
if a == s:
		print(c)
elif a == c:
		print(r)
		
else:
		print(s)
n=input()

print(n*n*n)

### FIXED CODE ###

n=int(input())
print(n**3)
n, T = map(int, input().split())
a = set()
min_ = 1001
for i in range(n):
    c, t = map(int, input().split())
    a.add(c)
    if t <= T and c <= min_:
        min_ = c
    a.remove(c)
if min_ == 1001:
    print('TLE')
else:
    print(min_)

### FIXED CODE ###

n = int(input())
if n == 1:
    print('Hello World')
else:
    a = int(input())
    b = int(input())
    print(a + b)
import sys
input = sys.stdin.readline
h,n=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(n)]
#i-1番目までの魔法で、j以上のだめを得与えるのに最低限必要な魔力
infi=10**12
dp=[[infi]*(h+1) for i in range(n+1)]
#shoki化
for i in range(n+1):
    dp[i][0]=0
for i in range(n):
    if AB[i][0]+1<h+1:
        for j in range(AB[i][0]+1):
            dp[i+1][j]=min(dp[i][j], AB[i][1])
        for j in range(AB[i][0]+1, h+1):
            dp[i+1][j]=min(dp[i][j], dp[i+1][j-AB[i][0]]+AB[i][1])
    else:
        for j in range(AB[i][0]+1):
            dp[i+1][j]=min(dp[i][j], AB[i][1])
print(dp[n][h])

### FIXED CODE ###

import sys
input = sys.stdin.readline
h,n=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(n)]
#i-1番目までの魔法で、j以上のだめを得与えるのに最低限必要な魔力
infi=10**12
dp=[[infi]*(h+1) for i in range(n+1)]
#shoki化
for i in range(n+1):
    dp[i][0]=0
for i in range(n):
    if AB[i][0]+1<h+1:
        for j in range(AB[i][0]+1):
            dp[i+1][j]=min(dp[i][j], AB[i][1])
        for j in range(AB[i][0]+1, h+1):
            dp[i+1][j]=min(dp[i][j], dp[i+1][j-AB[i][0]]+AB[i][1])
    else:
        for j in range(h+1):
            dp[i+1][j]=min(dp[i][j], AB[i][1])
print(dp[n][h])
import math

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

if input == math.sqrt(input)**2 :
  print('Yes')
else: 
  print('No')


### FIXED CODE ###

import math, sys
 
a, b = map(str, input().split())
input = int(a + b)

for i in range(1000):
  if input == i**2 :
    print('Yes')
    sys.exit(0)

print('No')
N=int(input())
if N==1:
    print("Hello World")
elif N==2:
    A=int(input())
    B=int(input())
    print(str(A+B)

### FIXED CODE ###

N=int(input())
if N==1:
    print("Hello World")
elif N==2:
    A=int(input())
    B=int(input())
    print(str(A+B))
for i in range(m):
  a,b=map(int,input().split())
  link[a-1].append(b-1)
  link[b-1].append(a-1)
s=list(range(1,n))
res=0
for perm in list(itertools.permutations(s)):
  last=0
  ok=True
  for i in range(n-1):
    if perm[i] not in link[last]:
      ok=False
      break
    else:
      last=perm[i]
  if ok==True:
    res=res+1
print(res)

### FIXED CODE ###

import itertools
n,m=map(int,input().split())
link=[[]for j in range(n)]
for i in range(m):
  a,b=map(int,input().split())
  link[a-1].append(b-1)
  link[b-1].append(a-1)
s=list(range(1,n))
res=0
for perm in list(itertools.permutations(s)):
  last=0
  ok=True
  for i in range(n-1):
    if perm[i] not in link[last]:
      ok=False
      break
    else:
      last=perm[i]
  if ok==True:
    res=res+1
print(res)
num1 = int(input().split())
num2 = list(map(int, input().split()))

num2.sort(reverse=True)
N=num1[0]
M=num1[1]
A=num2[M-1]

if A<N/M/4:
    print('No')
else:
    print('Yes')

### FIXED CODE ###

n,m = map(int,input().split())
li = list(map(int,input().split()))
  
li.sort(reverse=True)
  
a=li[m-1]
b=sum(li)

if a>=b/4/m:
  print('Yes')
else:
  print('No')
def abc054_c_one_stroke_paths():
    import copy
    N, E = map(int, input().split())

    # create graph G
    G = {}
    for m in range(M):
        a, z = map(int, input().split())
        G[a] = G.get(a, [])
        G[a].append(z)
        G[z] = G.get(z, [])
        G[z].append(a)

    # print(G)

    # find all paths
    if G.get(1, 0) == 0:
        print(0)
        return

    paths = []

    def solve(a, path):
        path.append(a)
        if len(path) == N:
            paths.append(path)
            return
        for z in G.get(a):
            p = copy.copy(path)
            if z in p:
                continue
            solve(z, p)

    solve(1, [])
    # print(paths)
    print(len(paths))


##########
if __name__ == "__main__":
    abc054_c_one_stroke_paths()


### FIXED CODE ###

def abc054_c_one_stroke_paths():
    import copy
    N, M = map(int, input().split())

    # create graph G
    G = {}
    for m in range(M):
        a, z = map(int, input().split())
        G[a] = G.get(a, [])
        G[a].append(z)
        G[z] = G.get(z, [])
        G[z].append(a)

    # print(G)

    # find all paths
    if G.get(1, 0) == 0:
        print(0)
        return

    paths = []

    def solve(a, path):
        path.append(a)
        if len(path) == N:
            paths.append(path)
            return
        for z in G.get(a):
            p = copy.copy(path)
            if z in p:
                continue
            solve(z, p)

    solve(1, [])
    # print(paths)
    print(len(paths))


##########
if __name__ == "__main__":
    abc054_c_one_stroke_paths()
import heapq

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

heapq.heapify(v)

res = 0
for _ in range(int(N/2)+1):
  a = heapq.heappop(v)
  b = heapq.heappop(v)
  res = (a+b)/2
  heapq.heappush(v, res)
    
print(res)

### FIXED CODE ###

import heapq

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

heapq.heapify(v)

res = 0
for _ in range(N-1):
  a = heapq.heappop(v)
  b = heapq.heappop(v)
  res = (a+b)/2
  heapq.heappush(v, res)
    
print(res)
N,K = input().split()
N = int(N)
K = int(K)
N_list = list()

for i in range(1,N+1):
	N_list.append(i)

for i in range(K):
	d = int(input())
	a_list = input().split()
	N_list += a_list
	N_list = map(N_list)

print(N_list)



### FIXED CODE ###

N,K = map(int,input().split())
check = N*[0]

for i in range(K):
	d = int(input())
	a = list(map(int,input().split()))
	for i in a:
		check[i-1] = 1

print(check.count(0))
import sys

A, B, C, X, Y = sys.argv[1], sys.argv[2], sys.argv[3], sys.argv[4], sys.argv[5]
A = int(A)
B = int(B)
C = int(C)
X = int(X)
Y = int(Y)

strat1 = A*X + B*Y  # simple strategy
strat2 = 2*C*X + abs(Y-X)*B  # more A, add back B
strat3 = 2*C*Y + abs(X-Y)*A  # more B, add back A
strat4 = 2*C*max(X,Y) # overbuy C

print min(strat1, strat2, strat3, strat4)


### FIXED CODE ###

A, B, C, X, Y = map(int, raw_input().split())

strat1 = A*X + B*Y  # simple strategy
strat2 = 2*C*X + abs(Y-X)*B  # more A, add back B
strat3 = 2*C*Y + abs(X-Y)*A  # more B, add back A
strat4 = 2*C*max(X,Y) # overbuy C

print min(strat1, strat2, strat3, strat4)
a, b, c = map(int, input().split())
if a <= b <= c:
    print("{} {} {}", format(a, b, c))
elif a <= c <= b:
    print("{} {} {}", format(a, c, b))
elif b <= a <= c:
    print("{} {} {}", format(b, a, c))
elif b <= c <= a:
    print("{} {} {}", format(b, c, a))
elif c <= a <= b:
    print("{} {} {}", format(c, a, b))
elif c <= b <= a:
    print("{} {} {}", format(c, b, a))

### FIXED CODE ###

a, b, c = map(int, input().split())
if a <= b <= c:
    print(a, b, c)
elif a <= c <= b:
    print(a, c, b)
elif b <= a <= c:
    print(b, a, c)
elif b <= c <= a:
    print(b, c, a)
elif c <= a <= b:
    print(c, a, b)
elif c <= b <= a:
    print(c, b, a)
l = input().split()
def shiritori (letter):
    if letter[0][-1:] == letter[1][:1]:
        if letter[1][-1:] == letter[2][:1]:
            return('YES')
        else return('NO')
    else return('NO')
shiritori(l)

### FIXED CODE ###

l = input().split()
def shiritori (letter):
    if letter[0][-1:] == letter[1][:1]:
        if letter[1][-1:] == letter[2][:1]:
            return(print('YES'))
        else:
            return(print('NO'))
    else:
        return(print('NO'))
shiritori(l)
a = input()
k = int(input())
b = list(a)
if k == 1:
    print(b[0])
else:
    for i in range(100):
        if int(b[i]) != 1:
            print(b[i])
            break

### FIXED CODE ###

a = input()
k = int(input())
b = list(a)
if k == 1:
    print(b[0])
    exit()
else:
    for i in range(k):
        if int(b[i]) != 1:
            print(b[i])
            exit()
print(1)
n,m,x=[int(i) for i in input().split()]
c=[]
arr=[[] for i in range(n)]
for i in range(n):
    l=[int(i) for i in input().split()]
    c.append(l[0])
    arr[i]=l[1:]

inf=10**18
ans=inf

limit=2**n
for bit in range(1,limit):
    sum=[0 for i in range(n)]
    cost=0
    for i in range(n):
        if (1<<i & bit):
            cost+=c[i]
            for j in range(m):
                sum[j]+=arr[i][j]
    flag=1
    for i in range(m):
        if sum[i]<x:
            flag=0
            break
    if flag==0:
        continue
    ans=min(ans,cost)
if ans!=inf:
    print(ans)
else:
    print(-1)


### FIXED CODE ###

n,m,x=[int(i) for i in input().split()]
c=[]
arr=[[] for i in range(n)]
for i in range(n):
    l=[int(i) for i in input().split()]
    c.append(l[0])
    arr[i]=l[1:]

inf=10**18
ans=inf

limit=2**n
for bit in range(1,limit):
    sum=[0 for i in range(m)]
    cost=0
    for i in range(n):
        if (1<<i & bit):
            cost+=c[i]
            for j in range(m):
                sum[j]+=arr[i][j]
    flag=1
    for i in range(m):
        if sum[i]<x:
            flag=0
            break
    if flag==0:
        continue
    ans=min(ans,cost)
if ans!=inf:
    print(ans)
else:
    print(-1)
a, b, c = int(input[0]), int(input[1]), int(input[2])
print(a+b+c)

### FIXED CODE ###

input_ = input()
a, b, c = int(input_[0]), int(input_[1]), int(input_[2])
print(a+b+c)
n=int(input())
l=[list(map(int,input().split())) for i in range(n-1)]
l.sort()
#print(l)
r=[0]*n
for i in range(n-1):
    r[l[i][0]-1]+=1
    r[l[i][1]-1]+=1
aa=0
c=0

for i in range(n):
    if aa<=r[i]:
        aa=r[i]
        c=i+1

A=1;print(max(r))
p=[0]*(n-1)
w=[[] for _ in range(n)]
for i in range(n-1):
    if l[i][0]==c or l[i][1]==c:
        p[i]=A
        w[l[i][0]-1].append(A)
        w[l[i][1]-1].append(A)
        A+=1

box=set([i for i in range(1,max(r)+1)])
for i in range(n-1):
    if l[i][0]!=c and l[i][1]!=c:
        B=box-set(w[l[i][0]-1]+w[l[i][1]-1])
        #print(B)
        w[l[i][0]-1].append(list(B)[0])
        w[l[i][1]-1].append(list(B)[0])
        p[i]=list(B)[0]

#print(r,c,w)
#print(p)

for i in range(n-1):
    print(p[i])

### FIXED CODE ###

n = int(input())
l=[list(map(int,input().split()))+[i+1] for i in range(n-1)]
l.sort()
flg = [0 for _ in range(n+1)]
ans = [0 for _ in range(n)]
#print(l)
t=0
count=0
for i in range(n-1):
    a,b,c=l[i]
    if t!=a:
        t=a
        count=1
    if flg[a]==count:
        count+=1
    flg[b]=count
    ans[c]=count
    count+=1
    #print(flg,ans)
print(max(flg))
for i in range(1,n):
    print(ans[i])
x = input()
x = int(x)
y = input()
y = int(y)

if x < 10 and y < 10:
	print(x * y)
else:
	print(-1)



### FIXED CODE ###

x, y = map(int, input().split())

if x < 10 and y < 10:
	print(x * y)
else:
	print(-1)
from fractions import gcd

N, K = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    possible = (As[0] == K)
else:
    g = As[1] - As[0]
    for A in As[2:]:
        g = gcd(g, A - As[0])

    possible = ((K-As[0]) % g == 0) and (min(As) <= K <= max(As))

if possible:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")

### FIXED CODE ###

from fractions import gcd

N, K = map(int, input().split())
As = list(map(int, input().split()))
if len(As) == 1:
    possible = (As[0] == K)
else:
    g = max(abs(As[1] - As[0]), 1)
    for A in As[2:]:
        g = gcd(g, A - As[0])

    possible = ((K-As[0]) % g == 0) and (min(As) <= K <= max(As))

if possible:
    print("POSSIBLE")
else:
    print("IMPOSSIBLE")
N, D = list(map(int, input().split()))
count = 0
for i in range(N):
  x, y = list(map(int, input().split()))
  if (x**2 + y**2) <= d**2:
    count += 1
print(count)

### FIXED CODE ###

import math
n, d = list(map(int, input().split()))
count = 0
for _ in range(n):
  x, y = list(map(int, input().split()))
  if math.sqrt(x**2 + y**2) <= d:
    count += 1
print(count)
N = int(input())
x=int(input())
y=[x]


for i in range(1,N):
    x=int(input())
    a=0
    flag=1
    while a < i:
        if y[a]==x:
            del y[a]
            flag=-1
            break
        a+=1
    if flag==1:
        y.append(x)

print(len(y))


### FIXED CODE ###


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

x.sort()
i=0
while i < N-1:
    if x[i]==x[i+1]:
        del x[i+1]
        del x[i]
        N-=2
        continue
    i+=1
print(len(x))
x,k,d=map(int,input().split())

if x==0 and k%2==0:print(0)
if x==0 and k%2==1:print(d)

if x>0 and x>=k*d:print(x-k*d)
if x>0 and x<k*d:
    if ((x-x%d)//d)%2==k%2:print(x%d)
    else:print(abs(x%d-d))
if x<0 and -x>=k*d:print(-x-k*d)
if x<0 and -x<k*d:
    fewa

### FIXED CODE ###

x,k,d=map(int,input().split())

if x==0 and k%2==0:print(0)
if x==0 and k%2==1:print(d)

if x>0 and x>=k*d:print(x-k*d)
if x>0 and x<k*d:
    if ((x-x%d)//d)%2==k%2:print(x%d)
    else:print(abs(x%d-d))
if x<0 and -x>=k*d:print(-x-k*d)
if x<0 and -x<k*d:
    if ((abs(x)-abs(x)%d)//d)%2==k%2:print(-x%d)
    else:print(abs(-x%d-d))
s=input()
ans='WA'
if s[0]=='A':
  if S[2:-1].count('C')==1:
    c=s.index('C')
    if s[1:c].islower() and s[c:].islower:
      ans='AC'
print(ans)

### FIXED CODE ###

s=input()
ans='WA'
if s[0]=='A':
  if s[2:-1].count('C')==1:
    c=s.index('C')
    if s[1:c].islower() and s[c+1:].islower():
      ans='AC'
print(ans)
N = intpu()
seq = list(map(int, input().split()))

for i in range(len(seq)-1):
    if seq[i] <= min(seq[i+1:]):
        continue
    elif seq[i] > min(seq[i+1:]):
        j = seq.index(min(seq[i+1:]))
        if seq[i] > min(seq[i+1:j]+seq[j+1:]):
            print("NO")
            break
        seq[i], seq[j] = seq[j], seq[i]
else:
    print("YES")


### FIXED CODE ###

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

is_switched = False
for i in range(len(seq)-1):
    if seq[i] <= min(seq[i+1:]):
        continue
    elif seq[i] > min(seq[i+1:]):
        if is_switched:
            print("NO")
            break
        j = seq.index(min(seq[i+1:]))
        seq[i], seq[j] = seq[j], seq[i]
        is_switched = True
else:
    print("YES")
#お札が合計N枚ある時に合計金額がY円になる枚数の組み合わせ　存在しない場合は（-1,-1,-1）
  
n=int(input())
y=int(input())
a,b,c=-1,-1,-1

for i in range(n):
	for j in range(n-i):
		if 10000*i + 5000*j + 1000*(n-i-j) ==y:
			a,b,c=i,j,(n-i-j)

print(a,b,c)

### FIXED CODE ###

#お札が合計N枚ある時に合計金額がY円になる枚数の組み合わせ　存在しない場合は（-1,-1,-1）
  
n,y=map(int,input().split())
a,b,c=-1,-1,-1

for i in range(n+1):
	for j in range(n-i+1):
		if 10000*i + 5000*j + 1000*(n-i-j) ==y:
			a,b,c=i,j,(n-i-j)

print(a,b,c)
def gcd(b, s):
    return s if b % s == 0 else gcd(s, b % s)

# 一人消してgcd
n = int(input())
nl = sorted(list(map(int, input().split(' '))))
rl = nl[::-1]
sumnl = [nl[0]]
sumrl = [rl[0]]
for i in range(1, len(nl)):
    sumnl.append(gcd(sumnl[-1], nl[i]))
    sumrl.append(gcd(sumrl[-1], rl[i]))
sumrl = sumrl[::-1]
print(max([gcd(sumnl[i],sumrl[i+2]) for i in range(len(sumrl) - 2)]))

### FIXED CODE ###

import sys
sys.setrecursionlimit(100001)

def gcd(b, s):
    return s if b % s == 0 else gcd(s, b % s)

# 一人消してgcd
n = int(input())
nl = sorted(list(map(int, input().split(' '))))
rl = nl[::-1]
sumnl = [nl[0]]
sumrl = [rl[0]]
for i in range(1, len(nl)):
    sumnl.append(gcd(sumnl[-1], nl[i]))
    sumrl.append(gcd(sumrl[-1], rl[i]))
sumrl = sumrl[::-1]
if len(sumnl) == 1:
    print(sumnl[0])
else:
    print(max([sumnl[-2]] + [gcd(sumnl[i],sumrl[i+2]) for i in range(len(sumrl) - 2)] + [sumrl[1]]))
N,K=map(int,input().split())
V=list(map(int,input().split()))
R=min(N,K)
L=[]
for r in range(R+1):
    for A in range(R -r + 1):
        B = R - r-A
        I = sorted((V[:A] + V[::-1][:B]))
        p=K-A-B
        for i in range(len(I)):
            if I[i] >= 0:
                p = i
                break
        for ii in range(min(p,K-A-B)):
            if len(I)>0:
                I.pop(0)
            else:break
            L.append(sum(I))
print(max(L))








### FIXED CODE ###

N,K=map(int,input().split())
V=list(map(int,input().split()))
R=min(N,K)
L=[]
for r in range(R+1):
    for A in range(R -r + 1):
        B = R - r-A
        I = sorted((V[:A] + V[::-1][:B]))
        p=K-A-B
        for i in range(len(I)):
            if I[i] >= 0:
                p = i
                break
        for ii in range(min(p,K-A-B)):
            if len(I)>0:
                I.pop(0)
            else:break
        L.append(sum(I))
print(max(L))
n, k = map(int, input().split())
num = abs(n - k)
tmp = n % num
print(min(tmp, abs(tmp - k)))

### FIXED CODE ###

n, k = map(int, input().split())
num = abs(n - k)
if num == 0:
    print(0)
    exit()
tmp = n % k
print(min(tmp, abs(tmp - k)))
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
if sum(a)+sum(b)<=k:
    print(n+m)
    exit()
num = 0
cnt = -1
for i in range(n+m):
    if num>k:
        break
    elif a == []:
        num += b[0]
        cnt +=1
        del b[0]
    elif b == []:
        num += a[0]
        cnt += 1
        del a[0]
    elif a[0] <= b[0]:
        num += a[0]
        cnt += 1
        del a[0]
    else:
        num += b[0]
        cnt += 1
        del b[0]
print(cnt)

### FIXED CODE ###

a = int(input())
print(a+a**2+a**3)
#%%
import sys
INPUT = sys.stdin.readline

def SINGLE_INT(): return int(INPUT())
def MULTIPLE_INT_LIST(): return list(map(int, INPUT().split()))
def MULTIPLE_INT_MAP(): return map(int, INPUT().split())
def SINGLE_STRING(): return INPUT()
def MULTIPLE_STRING(): return INPUT().split()

#%%

N, A, B, C = MULTIPLE_INT_MAP()
materials = MULTIPLE_INT_LIST()
INF = 10 ** 9

#%%

def dfs(cursor, a, b, c):  # cursor:カーソル a,b,c:現在の竹の長さ
    if cursor == N:  # cursorが最後まで行ったら終了する。
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(a, b, c) != 0 else INF
    # なぜ30を減じているのかというと、
    # dfs(0,0,0,0)で始まる以上、最初に選ばれるa,b,cを決定する際にもコストが10増加してしまうからである。

    # a,b,cのいずれかに1本も竹を利用していない場合は不適であるため、三項演算子を利用してその場合のコストをINFとする。

    # 再帰(4**N)
    # カーソルの当たっている竹に対して、(A or B or Cに合成する) or (合成しない)の場合に分ける
    no_compound = dfs(cursor+1, a, b, c)
    compound_to_a = dfs(cursor+1, a + materials[cursor], b, c) + 10
    compound_to_b = dfs(cursor+1, a, b + materials[cursor], c) + 10
    compound_to_c = dfs(cursor+1, a, b, c + materials[cursor]) + 10

    return min(no_compound, compound_to_a, compound_to_b, compound_to_c)

print(dfs(0, 0, 0, 0))

### FIXED CODE ###

#%%
import itertools

#%%

N, A, B, C = map(int, input().split())
materials = [int(input()) for _ in range(N)]



iterobj = itertools.product(range(4),repeat=N)

ans = 10**8

for use in iterobj:

    if 1 in use and 2 in use and 3 in use:

        synth = [0,0,0,0]

        for m, u in  zip(materials, use):
            synth[u] += m

        mp = 10 * (use.count(1) + use.count(2) + use.count(3) - 3)

        mp += abs(A-synth[1]) + abs(B-synth[2]) + abs(C-synth[3])

        ans = min(ans, mp)

print(ans)
i = 0

while True:
  i += 1
  n = input()
  if n = 0: break
  print('Case ' +str(i) +':' + n)



### FIXED CODE ###

case = 0
while 1:
    case += 1
    n = int(input())
    if n == 0: break
     
    print("Case {}: {}".format(case, n))
from bisect  import bisect_left

n = int(input())
a = list(map(int,input().split()))
a.sort()
b = [2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 
     131072, 262144, 524288, 1048576, 2097152, 4194304, 8388608, 16777216, 33554432, 
     67108864, 134217728, 268435456, 536870912]

t = []
bIdx = 0
for aa in a :
    while b[bIdx] <= aa:
        bIdx += 1   
    t.append(b[bIdx]-aa)
t.reverse()

u = [0 for i in range(len(t))]

#print(a)        
#print(t)
sum = 0
for i in range (len(a)-1,-1,-1):
    k = bisect_left(a,t[i])
    #print(t[i],k)
    if a[k] == t[i] and u[k] == 0 and k != i:
        #print(a[i],t[i],i)
        sum += 1
        u[k] += 1
print(sum)

### FIXED CODE ###

from bisect  import bisect_left

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

sum = 0
for i in range (len(a)-1,-1,-1):

    b = 1
    while b <= a[i]:
        b = b<<1
    t = b - a[i]
    #print("2^",t)

    k = bisect_left(a,t)
    if a[k] == t and k < i:
        sum += 1
        a[k] -= 0.1
        a[i] += 0.1
print(sum)
n,r=int(input())

if n<10:
  print(r+100*(10-n))
else:
  print(r)

### FIXED CODE ###

n,r=map(int,input().split())
 
if n<10:
  print(r+100*(10-n))
else:
  print(r)