Harryxun/stf_run huggingface dataset:
n,m=map(int,input().split())
l,r=[list(map(int,input().split())) for i in range(m)]

lm=max(l)
mr=min(r)
x=mr-lm+1

if x>=:
  print(x)
else:
  print(0)


### FIXED CODE ###

n,m=map(int,input().split())
lm,mr=0,n
for i in range(m):
  l,r=map(int,input().split())
  lm=max(lm,l)
  mr=min(mr,r)
  x=mr-lm+1

if x>=0:
  print(x)
else:
  print(0)
i = int(input())
l = [int(n) for n in input().split(' ')]

t = 0
bool = True
while bool:
    t += 1
    for j in l:
        if j % 2 == 1:
            bool = False
            break
        else:
            l /= 2
print(t-1)

### FIXED CODE ###

i = int(input())
l = [int(n) for n in input().split(' ')]

t = 0
bool = True
while bool:
    t += 1
    for j in range(len(l)):
        if l[j] % 2 == 1:
            bool = False
            break
        else:
            l[j] /= 2
print(t-1)
A=int(input())
B=int(input())
c=int(input())
D=int(input())
print(min(A,B)+min(C,D))

### FIXED CODE ###

A=int(input())
B=int(input())
C=int(input())
D=int(input())
print(min(A,B)+min(C,D))
N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
data = {}
SUM = sum(A)
for i in range(N):
    if A[i] in data:
        data[A[i]] += 1
    else:
        data[A[i]] = 1
for i in range(Q):
    if B[i] in data:
        SUM += data[B[i]]*(C[i]-B[i])
        data[C[i]] += data[B[i]]
        data[B[i]] = 0
    print(SUM)

### FIXED CODE ###

N = int(input())
A = list(map(int, input().split()))
Q = int(input())
B, C = [], []
for i in range(Q):
    b, c = map(int, input().split())
    B.append(b)
    C.append(c)
data = {}
SUM = sum(A)
for i in range(N):
    if A[i] in data:
        data[A[i]] += 1
    else:
        data[A[i]] = 1
for i in range(Q):
    if B[i] in data:
        SUM += data[B[i]]*(C[i]-B[i])
        if C[i] in data:
            data[C[i]] += data[B[i]]
        else:
            data[C[i]] = data[B[i]]
        data[B[i]] = 0
    print(SUM)
N = str(input())
if N == N[::-1]
	print('Yes')
else
	print('No')

### FIXED CODE ###

N = str(input())
if N == N[::-1]:
    print('Yes')
else:
    print('No')
n, m = map(int,input().split())
s = [list(map(int,input().split())) for _ in range(m)]
s.sort(key=lambda x: x[0])
if m == 0:
    print(10**(n-1))
for i in range(1,1000):
    num = str(i)
    count = 0
    if s[-1][0] > len(num):
        continue
    for j in range(m):
        if num[s[j][0]-1] == str(s[j][1]):
            count += 1
        else:
            break
    if n == count:
        print(num)
        quit()
print(-1)

### FIXED CODE ###

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

for i in range(10**n):
    i = str(i)
    flag = True
    if len(i) == n:
        for j in range(m):
            if i[sc[j][0]-1] != str(sc[j][1]):
                flag = False
        if flag:
            print(i)
            quit()

print(-1)
import numpy as np

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

A = np.arange(N)+L
if A[0] < 0 and A[N] > 0:
    print(np.sum(A))
elif A[0] < 0 and A[N] < 0:
    print(np.sum(A)-A[N])
else:
    print(np.sum(A)-A[0])

### FIXED CODE ###

import numpy as np

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

A = np.arange(N)+L

if A[0] <= 0 and A[N-1] >= 0:
    print(np.sum(A))
elif A[0] < 0 and A[N-1] < 0:
    print(np.sum(A)-A[N-1])
else:
    print(np.sum(A)-A[0])
# python3だとTLE,pypy3だとAC

def get(i, j):
    global dp
    global p
    if i < 0 or j < 0:
        return 0.0
    if dp[i][j] == 0.0:
        dp[i][j] = get(i - 1, j) * (1 - p[i - 1]) + \
            get(i - 1, j - 1) * p[i - 1]
    return dp[i][j]


def main():
    N = int(input())
    global dp
    global p
    p = list(map(float, input().split()))
    dp = [[0.0] * (N + 1) for _ in range(N + 1)]
    dp[0][0] = 1.0
    for i in range(N, 0, -1):
        get(N, i)
    print(sum(dp[N][N//2+1:]))


if __name__ == "__main__":
    main()


### FIXED CODE ###

def main():
    N = int(input())
    p = list(map(float, input().split()))
    dp = [[0 for _ in range(N + 1)] for _ in range(N + 1)]
    p_mul = 1
    dp[0][0] = 1
    for i in range(1, N + 1):
        p_mul *= (1-p[i-1])
        dp[i][0] = p_mul
    for i in range(1, N+1):
        for j in range(1, N+1):
            dp[i][j] = dp[i - 1][j] * \
                (1 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1]
    print(sum(dp[N][N//2+1:]))


if __name__ == "__main__":
    main()
n = int(input())
s = []

for num in range(2, n-1):
    a = num
    b = n - num
    a_s = sum(list(map(int, str(a))))
    b_s = sum(list(map(int, str(b))))
    c = a_s + b_s
    s.append(c)

print(min(s))


### FIXED CODE ###

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

for num in range(1, n//2+1):
    a = num
    b = n - num
    a_s = sum(list(map(int, str(a))))
    b_s = sum(list(map(int, str(b))))
    c = a_s + b_s
    s.append(c)

print(min(s))
#
# AIZU ONLINE JUDGE: List of Top 3 Hills
# cf. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0001&lang=jp
#

import sys

file = sys.argv[1]
lis = open(file, "r").readlines()
lis = map((lambda x: int(x)), lis)
lis.sort()
lis.reverse()

for height in lis[0:3]:
    print height

### FIXED CODE ###

import sys

file = sys.stdin
lis = file.readlines()
lis = map(int, lis)
lis.sort()
lis.reverse()

for height in lis[0:3]:
    print height
"""
4
1 2 2 1

2


5
3 1 2 3 1

5
"""

_ = int(input())
first = list(map(int, input().split()))
count = 0


def water(base_list):
    global count
    count += 1
    separated = []
    each = []
    for i in base_list:
        if i - 1 == 0:
            separated.append(each)
            each = []
        else:
            each.append(i-1)
    if each:
        separated.append(each)

    new_separated = []
    for i in separated:
        if i:
            new_separated.append(i)

    if new_separated:
        for i in new_separated:
            water(i)
    else:
        return


water(first)

print(count)


### FIXED CODE ###

"""
4
1 2 2 1

2


5
3 1 2 3 1

5


8
4 23 75 0 23 96 50 100

221
"""

_ = int(input())
first = list(map(int, input().split()))
count = 0


def water(base_list):
    global count
    count += 1
    separated = []
    each = []
    for i in base_list:
        hoge = i - 1
        if hoge == 0:
            separated.append(each)
            each = []
        else:
            each.append(hoge)
    if each:
        separated.append(each)

    new_separated = []
    for i in separated:
        if i:
            new_separated.append(i)

    if new_separated:
        for i in new_separated:
            water(i)
    else:
        return


def plus_one(i):
    return i + 1


first = list(map(plus_one, first))


water(first)

print(count - 1)
a,b,c,d=map(int,input().split())
while a or c >0:
  c=c-b
  if c<=0:
    print('Yes')
    break
  a=a-d
  if a<=0:
    print('No')
    break


### FIXED CODE ###

S,W=map(int,input().split())
if S<=W:
  print('unsafe')
else:
  print('safe')
N = int(input())

array = []
r = 2
result = 11

while True:
    while True:
        if N % r == 0:
            array.append(r)
            N //= r
        else:
            break
    if N == 1:
        break

    r += 1

for i in range(2 ** len(array)):
    bin_i = bin(i)[2:]
    bin_i = '0' * (len(array) - len(bin_i)) + bin_i
    A = 1
    B = 1
    for j in range(len(bin_i)):
        if bin_i[j] == '1':
            A *= array[j]
        else:
            B *= array[j]

    result = min(result, max(len(str(A)), len(str(B))))

print(result)


### FIXED CODE ###

N = int(input())
array = []

for i in range(1, int(N**0.5)+1):
    if N % i == 0:
        array.append(len(str(N//i)))

print(min(array))
n = int(input())
s = str(input())
d = Counter(s)
S = list(set(s))
ans = 1
for t in S:
    ans *= d[t] + 1
print(ans - 1)


### FIXED CODE ###

from collections import Counter

n = int(input())
s = str(input())
d = Counter(s)
S = list(set(s))
ans = 1
for t in S:
    ans *= d[t] + 1
print((ans - 1) % (10** 9 + 7))
import sys
import math
import numpy as np
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,D = IL()
print(max(A*B, C*D))

### FIXED CODE ###

import sys
MAX_INT = int(10e12)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

A,B,C,D = IL()
print(max(A*B, C*D))
A,B,C,D,E,F = map(int,input().split())
smax =int(F*E/(100+E))
wmax =F-smax
temp = []
for a in range(wmax//min(A*100,B*100)+1):
    for b in range(wmax // min(A*100, B*100)+1):
        for c in range(smax // min(C, D)+1):
            for d in range(smax // min(C, D)+1):
                if a == 0 and b== 0:
                    pass
                elif (c*C+d*D)/(100*a*A+100*b*B)<=E/(100+E) and 100*a*A+100*b*B <=wmax and c*C+d*D <=smax:
                    temp.append([100*a*A+100*b*B,c*C+d*D])
maxn =[]
for i in temp:
    maxn.append(i[1]/i[0])
print(' '.join(map(str,temp[maxn.index(max(maxn))])))

### FIXED CODE ###

from math import ceil
A,B,C,D,E,F = map(int,input().split())
am,bm,cm,dm=ceil(31/A),ceil(31/B),ceil(F*E/(100+E)/C)+1,ceil(F*E/(100+E)/D)+1
temp = []
for a in range(am):
    for b in range(bm):
        for c in range(cm):
            for d in range(dm):
                w = 100*a*A+100*b*B
                s = c*C+d*D
                if w + s > F:
                    break
                else:
                    if w / 100 * E >= s:
                        temp.append([w+s,s])
print(*sorted(temp, key=lambda x: (100*x[1] / x[0] if x[0] else 0))[-1])
n = int(input())
a = 0
for i in range(9):
    for j in range(9):
        if n == i*j:
            ans += 1
if ans >=1:
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
a = 0
for i in range(9):
    for j in range(9):
        if n == (i+1)*(j+1):
            a += 1
if a == 0:
    print("No")
else:
    print("Yes")
import math

def kock(n, x1, y1, x1, y2):
    if n == 0:
        return

    angle = math.radians(60)

    sx = (2*x1 + x2)/3
    sy = (2*y1 + y2)/3
    tx = (2*x2 + x1)/3
    ty = (2*y2 + y1)/3
    ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
    uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy

    kock(n-1, x1, y1, sx, sy)
    print sx, sy
    kock(n-1, sx, sy, ux, uy)
    print ux, uy
    kock(n-1, ux, uy, tx, ty)
    print tx, ty
    kock(n-1, tx, ty, x2, y2)

n = input()

p1x = 0.
p1y = 0.
p2x = 100.
p2y = 0.

print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y

### FIXED CODE ###

import math

def kock(n, x1, y1, x2, y2):
    if n == 0:
        return

    angle = math.radians(60)

    sx = (2*x1 + x2)/3
    sy = (2*y1 + y2)/3
    tx = (2*x2 + x1)/3
    ty = (2*y2 + y1)/3
    ux = (tx - sx)*math.cos(angle) - (ty - sy)*math.sin(angle) + sx
    uy = (tx - sx)*math.sin(angle) + (ty - sy)*math.cos(angle) + sy

    kock(n-1, x1, y1, sx, sy)
    print sx, sy
    kock(n-1, sx, sy, ux, uy)
    print ux, uy
    kock(n-1, ux, uy, tx, ty)
    print tx, ty
    kock(n-1, tx, ty, x2, y2)

n = input()

p1x = 0.
p1y = 0.
p2x = 100.
p2y = 0.

print p1x, p1y
kock(n, p1x, p1y, p2x, p2y)
print p2x, p2y
import numpy as np

if __name__=="__main__":
    inputs_number  = lambda : [int(x) for x in input().split(" ")]
    N, Ma, Mb = inputs_number()
    drugs = np.array([inputs_number() for i in range(N)])

    inf = 100*N + 1
    dp = np.ones((N,N*10,N*10)) * inf
    dp[0,0,0] = 0
    for i in range(0, N-1):
	for ca in range(N*10):
            for cb in range(N*10):
		if(dp[i,ca,cb]==inf):
                    continue
		dp[i+1,ca,cb]=np.min([dp[i+1,ca,cb],dp[i,ca,cb]]);
		dp[i+1,ca+drugs[i,0],cb+drugs[i,1]]=np.min([dp[i+1,ca+drugs[i,0],cb+drugs[i,1]],dp[i,ca,cb]+drugs[i,2]]);

    ans = inf
    for i in range(1, N):
	for ca in range(1, N*10):
            for cb in range(1, N*10):
		if(Ma*cb == Mb*ca and dp[i,ca,cb] < ans):
                    ans = dp[i,ca,cb]
    if(ans==inf):
	ans = -1
    print(int(ans))

### FIXED CODE ###

import numpy as np
import copy

if __name__=="__main__":
    inputs_number  = lambda : [int(x) for x in input().split()]
    N, Ma, Mb = inputs_number()
    drugs = [inputs_number() for i in range(N)]
    inf = 100*N + 1
    dp = np.ones((2,N*10+1,N*10+1)).astype(np.int32) * inf
    dp = dp.tolist()
    dp[0][0][0] = 0.0

    for i in range(N):
        for ca in range(10*i+1):
            for cb in range(10*i+1):
                if(dp[0][ca][cb]==inf):
                    continue
                dp[1][ca][cb]=min([dp[1][ca][cb], dp[0][ca][cb]])
                dp[1][ca+drugs[i][0]][cb+drugs[i][1]]=min([dp[1][ca+drugs[i][0]][cb+drugs[i][1]], dp[0][ca][cb]+drugs[i][2]])
        dp[0] = copy.copy(dp[1])
        dp[1] = (np.ones((N*10+1,N*10+1)).astype(np.int32) * inf).tolist()
    ans = inf
    for ca in range(1, N*10+1):
        for cb in range(1, N*10+1):
            if(Ma*cb==Mb*ca and dp[0][ca][cb]<ans):
                ans = dp[0][ca][cb]
    if(ans==inf):
        ans = -1
    print(int(ans))
a = int(input())
b ^ int(input())
if a == b:
  print("EQUAL")
elif a > b:
  print("LESS")
else:
  print("GREATER")

### FIXED CODE ###

a = int(input())
b = int(input())
if a == b:
  print("EQUAL")
elif a > b:
  print("GREATER")
else:
  print("LESS")
N = input()
sum = 0

for i in N:
    sum += i
if N % sum == 0:
    print("Yes")
else:
    print("No")


### FIXED CODE ###

N = input()
sum = 0

for i in N:
    sum += int(i)
if int(N) % sum == 0:
    print("Yes")
else:
    print("No")
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 998244353

def power(x, y):
   if y == 0:
       return 1
   elif y == 1:
       return x % mod
   elif y % 2 == 0:
       return power(x, y/2) ** 2 % mod
   else:
       return power(x, (y-1)/2) ** 2 * x % mod

N = INT()
a = [INT() for _ in range(N)]

sum_a = sum(a)
dp = [[0]*(sum_a+1) for _ in range(N+1)]
dp[0][0] = 1

dp2 = [[0]*(sum_a+1) for _ in range(N+1)]
dp2[0][0] = 1

for i, x in enumerate(a):
	for j in range(sum_a+1):
		if j+x >= sum_a+1:
			continue
		dp[i+1][j] = (dp[i+1][j] + dp[i][j]*2)%mod # 赤以外に塗り分ける
		dp[i+1][j+x] = (dp[i+1][j+x] + dp[i][j])%mod # 赤に塗り分ける
		dp2[i+1][j] = (dp2[i+1][j] + dp2[i][j])%mod
		dp2[i+1][j+x] = (dp2[i+1][j+x] + dp2[i][j])%mod
# print(dp)
# print(dp2)
if sum_a%2 == 0:
	print((power(3, N)-3*sum([dp[N][i] for i in range(sum_a+1) if i >= sum_a//2])+3*dp2[N][sum_a//2])%mod)
else:
	print((power(3, N)-3*sum([dp[N][i] for i in range(sum_a+1) if i >= sum_a//2+1]))%mod)


### FIXED CODE ###

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

A, B , C = MAP()

if A<= C <= B or B<=C<=A:
	print("Yes")
else:
	print('No')
import numpy as np
N,K,Q = [int(i) for i in input().split()]
mem_point = np.array([K for i in range(N)])
_points = np.array([-1 for i in range(N)])
for rounds in range(Q):
  anser = int(input())
  temp = _points.copy()
  temp[anser-1] = 0
  mem_point += temp
for point in mem_point:
  if 0 < point:
    print("Yes")
  else:
    print("No")


### FIXED CODE ###

S = input()
check = ["Sunny", "Cloudy", "Rainy"]
if "Sunny" == S:
  print("Cloudy")
elif "Cloudy" == S:
  print("Rainy")
else:
  print("Sunny")
# -*- coding: utf-8 -*-

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict


x=S_LIST()


print(x.index("0")+1)

### FIXED CODE ###

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

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())#整数値　複数の入力
def S_MAP(): return map(str, input().split())#文字　複数の入力
def LIST(): return list(map(int, input().split()))#整数　複数の入力　配列
def S_LIST(): return list(map(str, input().split()))#文字　複数の入力　配列


x=S_LIST()


print(x.index("0")+1)
import sys
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())

H,W,D = Is()
d = dict()
for i in range(H):
    s = Is()
    for j,e in enumerate(s):
        d[e] = (i,j)
Q = I()

m = [[0]*H*W for i in range(H*W)] 
def calc(l,r):
    if m[l][r] != 0:
        return m[l][r]
    else:
        maho = 0
        for k in range(l,r,D):
            maho += abs(d[k+D][0] - d[k][0]) + abs(d[k+D][1] - d[k][1])
        m[l][r] = maho
        return maho
    
for q in range(Q):
    l,r = Is()
    maho = calc(l,r)
    print(maho)


### FIXED CODE ###

import sys,collections;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
print(n//3)
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ans=0
ati=[0]
bti=[0]
for i in range(n):
  ati.append(ati[i]+a[i])
for i in range(m):
  bti.append(bti[i]+b[i])
x=0
y=0
while 1:
  if x==m and ati[x]+bti[y+1]<k:
    y+=1
  elif y==n and ati[x+1]+bti[y]<k:
    x+=1
  elif  ati[x+1]>bti[y+1]:
    y+=1
  elif y<n-1 and x<m-1 and ati[x+1]<bti[y+1]:
    x+=1
  else:
    ans=x+y
    break
  z=ati[x]+bti[y]
  if z>k:
    ans=x+y-1
    break
print(ans)


### FIXED CODE ###

n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
ruia=[0]
ruib=[0]
mx=0
for (i,j) in zip(a,range(n)):
  ruia.append(ruia[j]+i)

for (i,j) in zip(b,range(m)):
  ruib.append(ruib[j]+i)
ans=0
for i in range(n+1):
  if ruia[i] > k:
    break
  while ruib[m] > k - ruia[i]:
    m -= 1
  ans = max(ans, i + m)
print(ans)
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]

class UnionFind:
    par = []
    def __init__(self, n):
        for i in range(n):
            self.par.append(i)

    def root(self, x):
        if self.par[x] == x:
            return x
        return self.root(self.par[x])

    def unite(self, x, y):
        if x > y:
            x, y = y, x
        rx = self.root(x)
        ry = self.root(y)
        if rx != ry:
            self.par[ry] = rx

    def same(self, x, y):
        rx = self.root(x)
        ry = self.root(y)
        return rx == ry

    def return_par(self):
        return self.par

uf = UnionFind(n)
for a, b in ab:
    uf.unite(a-1, b-1)
par = uf.return_par()
d = dict()
for p in par:
    if p not in d.keys():
        d[p] = 1
    else:
        d[p] += 1
print(max(d.values()))


### FIXED CODE ###

from collections import deque
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(m)]
t = dict()
for i in range(1, n+1):
    t[i] = set()
for a, b in ab:
    t[a].add(b)
    t[b].add(a)

q = deque()
s = set()
ans = 0
for i in range(1, n+1):
    if i not in s:
        q.append(i)
        s.add(i)
        tmp = [i]
        while q:
            v = q.popleft()
            for ti in t[v]:
                if ti not in s:
                    tmp.append(ti)
                    q.append(ti)
                    s.add(ti)
    ans = max(ans, len(tmp))
print(ans)
from math import gcd
k = int(input())
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            f = gcd(i, j)
            ans += gcd(f, l)
print(ans)

### FIXED CODE ###

# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint
import itertools

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""


def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1:
        arr.append([temp, 1])

    if arr == []:
        arr.append([n, 1])

    return arr


# a^n
def power(a, n, mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod


# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n - 1
    while (tmp >= l):
        a = a * tmp % mod
        tmp -= 1
    return a


inf = 10 ** 18
mod = 10 ** 9 + 7

n,a,b,c = lr()
l = [ir() for i in range(n)]
l.sort(reverse=True)

def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n%b)
    return str(n%b)

ans = inf

for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            now = [l[i],l[j],l[k]]
            ret = [0 for w in range(5-(n-3))]
            pre = 0
            for g in range(n):
                if g!=i and g!=j and g!=k:
                    ret.append(l[g])
            for h in range(4**(n-3)):
                now = [l[i], l[j], l[k]]
                pre = 0
                judge = base10to(h, 4)
                tmp = ''
                for w in range(5-len(judge)):
                    tmp = ''.join([tmp,'0'])
                judge = ''.join([tmp,judge])

                for p,t in enumerate(judge):
                    if t == '1':
                        now[0]+=ret[p]
                        pre+=10
                    elif t == '2':
                        now[1]+=ret[p]
                        pre+=10
                    elif t == '3':
                        now[2]+=ret[p]
                        pre+=10
                now.sort(reverse=True)
                ans = min(ans,pre+abs(a-now[0])+abs(b-now[1])+abs(c-now[2]))
print(ans)