Harryxun/stf_run huggingface dataset:
N = int(input())
palette = [1]
colors = [None] * N
ends = [None] * N
edges = {}

for edge in range(1,N):
    ends[edge] = [int(n) for n in input().split()]

for edge in range(1,N):
    a, b = ends[edge]
    if a not in edges:
        edges[a] = [edge]
    else:
        edges[a].append(edge)
    if b not in edges:
        edges[b] = [edge]
    else:
        edges[b].append(edge)


def color_edges(parent, root):
    current_palette = palette[:]
    if parent > 0:
        del current_palette[current_palette.index(colors[parent])]
    for edge in edges[root]:
        if edge == parent:
            continue
        if len(current_palette) > 0:
            colors[edge] = current_palette[0]
            del current_palette[0]
        else:
            color = len(palette) + 1
            palette.append(color)
            colors[edge] = color
    for edge in edges[root]:
        if edge == parent:
            continue
        a, b = ends[edge]
        if a == root:
            color_edges(edge, b)
        else:
            color_edges(edge, a)

color_edges(0, 1)

print(len(palette))
for edge in range(1,N):
    print(colors[edge])


### FIXED CODE ###

import sys

sys.setrecursionlimit(100000)

N = int(input())
palette = 1
colors = {}
ends = {}
edges = {}

for edge in range(1,N):
    ends[edge] = [int(n) for n in input().split()]

    a, b = ends[edge]
    if a not in edges:
        edges[a] = [edge]
    else:
        edges[a].append(edge)
    if b not in edges:
        edges[b] = [edge]
    else:
        edges[b].append(edge)


def color_edges(parent, root):
    ng = {}
    global palette
    if parent > 0:
        ng[colors[parent]] = True
    for edge in edges[root]:
        if edge in colors:
            color = colors[edge]
        elif palette - len(ng) > 0:
            color = 1
            while color in ng:
                color += 1
            colors[edge] = color
        else:
            palette += 1
            color = palette
            colors[edge] = color

        ng[color] = True
    for edge in edges[root]:
        if edge == parent:
            continue
        a, b = ends[edge]
        if a == root:
            color_edges(edge, b)
        else:
            color_edges(edge, a)

max_edges = 1
root = 1
for node in range(1,N+1):
    if len(edges[node]) > max_edges:
        max_edges = len(edges[node])
        root = node

color_edges(0, root)

print(palette)
for edge in range(1,N):
    print(colors[edge])
n = int(input())
l = map(int,input().split())
if sum(l) > 2*max(l):
    print("Yes")
else:
    print("No")

### FIXED CODE ###

n = int(input())
l = list(map(int,input().split()))
if sum(l) > 2*max(l):
    print("Yes")
else:
    print("No")
import numpy as np
n,c = map(int,input().split())
d = [0]*(10**5)
for _ in range(n):
    s,t,c = map(int,input().split())
    d[s-1] += 1
    d[t] -= 1
d = np.cumsum(d)
print(max(d))

### FIXED CODE ###

import numpy as np
n,C = map(int,input().split())
ch = [[] for _ in range(30)]
for _ in range(n):
    s,t,c = map(int,input().split())
    if s>t:
        s,t = t,s
    ch[c-1].append((s,t))

lst = []
for i in range(30):
    if len(ch[i])!=0:    
        for i, (ns,nt) in enumerate(ch[i]):
            if i==0:
                s,t = ns, nt
            else:
                if ns == t:
                    t = nt
                else:
                    lst.append((s,t))
                    s,t = ns, nt
        else:
            lst.append((s,t))
    
d = [0]*(10**6)
for s,t in lst:
    d[s-1] += 1
    d[t] -= 1
d = np.cumsum(d)
print(min(max(d), C))
import numpy as np

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

A = np.zeros(N, dtype = int)
B = np.zeros(N, dtype = int)

for i in range(N):
    A[i],B[i] = map(int,input().split())
    
dp = np.zeros(H+1, dtype = int)
dp[0] = 0
for i in range(1,H+1):
    dp[i] = np.amin([dp[np.amax(i-A,0)] + B])

print(int(dp[H]))

### FIXED CODE ###

import numpy as np

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

A = np.zeros(N, dtype = int)
B = np.zeros(N, dtype = int)

for i in range(N):
    A[i],B[i] = map(int,input().split())
    
dp = np.full(H+1, np.inf)

dp[0] = 0
for i in range(1,H+1):
    dp[i] = np.amin( dp[np.maximum(i-A,0)] + B )

print(int(dp[H]))
n,X,Y = map(int,input().split())

import heapq
def dijkstra_heap(s,edge):
    #始点sから各頂点への最短距離
    d = [10**20] * n
    used = [True] * n #True:未確定
    d[s] = 0
    used[s] = False
    edgelist = []
    for a,b in edge[s]:
        heapq.heappush(edgelist,a*(10**6)+b)
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        #まだ使われてない頂点の中から最小の距離のものを探す
        if not used[minedge%(10**6)]:
            continue
        v = minedge%(10**6)
        d[v] = minedge//(10**6)
        used[v] = False
        for e in edge[v]:
            if used[e[1]]:
                heapq.heappush(edgelist,(e[0]+d[v])*(10**6)+e[1])
    return d

E = []
for i in range(n-1):
    E.append([i,i+1,1])
E.append([X-1,Y-1,1])

edge = [[] for i in range(n)]
#edge[i] : iから出る道の[重み,行先]の配列
for i in range(w):
    for e in E:
        x,y,z = map(int,e)
        edge[x].append([z,y])
        edge[y].append([z,x])

for i in range(1,n):
    cnt = 0
    for j in range(n):
        tmp = dijkstra_heap(j,edge)
        for t in tmp[j:]:
            if t==i:
                cnt += 1
    print(cnt)

### FIXED CODE ###

N, X, Y = map(int, input().split())
ans = [0]*(N-1)
for i in range(1, N):
    for j in range(i+1, N+1):
        d = min(j-i, abs(X-i)+abs(j-Y)+1)
        ans[d-1] += 1

print(*ans, sep='\n')
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
// }}} End Header

int main() {
	int n, x, ans=0, sum = 0;
	cin >> n >> x;
	vector<int> m(n);
	rep(i,n){
		cin >> m[i];
		sum+=m[i];
	}
	x-=sum;
	sort(all(m));
	cout << n+x/m[0] << endl;
	return 0;
}

### FIXED CODE ###

n, x = map(int, input().split())
m = [int(input()) for i in range(n)]
sum = 0
min = 1000000
for i in range(n):
    sum+=m[i]
    if min > m[i]: min = m[i]
x-=sum
print(n+int(x/min))
def main():
  import sys
  input=sys.stdin.readline
  h,w,k=map(int,input().split())
  H=range(h)
  W=range(w)
  dp=[[[0]*w for j in H] for i in range(4)]
  for _ in range(k):
    r,c,v=map(int,input().split())
    dp[r-1][c-1][0]=v
  if dp[0][0][0]!=0:
    dp[1][0][0]=dp[0][0][0]
    dp[0][0][0]=0
  for y in H:
    for x in W:
      v=dp[0][y][x]
      dp[0][y][x]=0
      for i in range(4):
        if 0<x:
          if dp[i][y][x]<dp[i][y][x-1]:
            dp[i][y][x]=dp[i][y][x-1]
          if 0<i and v!=0 and dp[i][y][x]<dp[i-1][y][x-1]+v:
            dp[i][y][x]=dp[i-1][y][x-1]+v
        if 0<y:
          if dp[0][y][x]<dp[i][y-1][x]:
            dp[0][y][x]=dp[i][y-1][x]
          if v!=0 and dp[1][y][x]<dp[i][y-1][x]+v:
            dp[1][y][x]=dp[i][y-1][x]+v
  print(max([dp[i][h-1][w-1] for i in range(4)]))
main()

### FIXED CODE ###

def main():
  import sys
  input=sys.stdin.readline
  h,w,k=map(int,input().split())
  H=range(h)
  W=range(w)
  dp=[[[0]*w for j in H] for i in range(4)]
  for _ in range(k):
    r,c,v=map(int,input().split())
    dp[0][r-1][c-1]=v
  if dp[0][0][0]!=0:
    dp[1][0][0]=dp[0][0][0]
    dp[0][0][0]=0
  for y in H:
    for x in W:
      v=dp[0][y][x]
      dp[0][y][x]=0
      for i in range(4):
        if 0<x:
          if dp[i][y][x]<dp[i][y][x-1]:
            dp[i][y][x]=dp[i][y][x-1]
          if 0<i and v!=0 and dp[i][y][x]<dp[i-1][y][x-1]+v:
            dp[i][y][x]=dp[i-1][y][x-1]+v
        if 0<y:
          if dp[0][y][x]<dp[i][y-1][x]:
            dp[0][y][x]=dp[i][y-1][x]
          if v!=0 and dp[1][y][x]<dp[i][y-1][x]+v:
            dp[1][y][x]=dp[i][y-1][x]+v
  print(max([dp[i][h-1][w-1] for i in range(4)]))
main()
a,b,c = map(int,input().split())
k = int(input())
print(sum(a,b,c)+(max(a,b,c)*(2**k-1)))

### FIXED CODE ###

a,b,c = map(int,input().split())
k = int(input())
print(sum([a,b,c])+(max(a,b,c)*(2**k-1)))
n=int(input())
for p in range(2, 1000000):
    if n % p != 0:
        print(n)
        break
    else:
       n=n+1

### FIXED CODE ###

A, B = (input().split())
print(B+A)
s = input()

for i in range(len(s)):
    if s[i] == s[i + 1] and (s[i + 1] == s[i + 2] or (s[i + 1] != s[i + 2] and s[i + 2] == s[i])):
        print(i+1, i + 4)
        quit()
print(-1,-1)
        

### FIXED CODE ###

#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    s = S()
    for i in range(len(s) - 1):
        if s[i] == s[i+1]:
            print(i + 1, i + 2)
            return
    for i in range(len(s) - 2):
        if s[i] == s[i + 2]:
            print(i + 1, i + 3)
            return
    print(-1, -1)

    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    D()
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


def Z_algo(S):
    LCP = [0] * n
    c = 0  # 最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        # i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i + LCP[i - c] < c + LCP[c]:
            LCP[i] = LCP[i - c]
        else:
            j = max(0, c + LCP[c] - i)
            while i + j < n and S[j] == S[i + j]:
                j += 1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP


n = int(readline())
s = read().rstrip().decode()
ans = 0
for i in range(n):
    m = Z_algo(s[i:])[1:] + [0] * 1
    ans = max(ans, max(m[n // 2 - i:]))
print(ans)


### FIXED CODE ###

def Z_algo(S):
    n = len(S)
    LCP = [0] * n
    c = 0  # 最も末尾側までLCPを求めたインデックス
    for i in range(1, n):
        # i番目からのLCPが以前計算したcからのLCPに含まれている場合
        if i + LCP[i - c] < c + LCP[c]:
            LCP[i] = LCP[i - c]
        else:
            j = max(0, c + LCP[c] - i)
            while i + j < n and S[j] == S[i + j]:
                j += 1
            LCP[i] = j
            c = i
    LCP[0] = n
    return LCP


n = int(input())
s = input()
ans = 0
for i in range(n):
    lcp = Z_algo(s[i:])
    for j, p in enumerate(lcp):
        tmp = min(j, p)
        ans = max(ans, tmp)
print(ans)
#２分探索
A = [1,5,7,15,26,45,60,256] #データ

x = int(input()) #探索するデータ

li = 0           #探索範囲の左端
ri = len(A) -1   #探索範囲の右端

while (li != ri):       #探索範囲が２つ以上あるかぎり繰り返す
	mi = (li + ri) // 2 #中央のindexの計算
	if A[mi] < x:       #もし中央の値 < x ならば
		li = mi+1       #左半分を消去
	elif A[mi] > x:     #もし中央の値 > x　ならば
		ri = mi-1       #右半分消去
	else:               #xを発見！!(*´꒳`*)!!
		li = mi
		ri = mi
if A[li] == x:
	print("発見！",li)
else:
	print("ないよ！")

### FIXED CODE ###

S = input()
if S == "SUN" :
	answer = 7
elif S == "MON" :
	answer = 6
elif S == "TUE" :
	answer = 5
elif S == "WED" :
	answer = 4
elif S == "THU" :
	answer = 3
elif S == "FRI" :
	answer = 2
elif S == "SAT" :
	answer = 1
 
print(answer)
import sys
from heapq import *
H,O=[],[]
for e in sys.stdin:
 c=e[1]
 if'n'==c:heappush(H,-int(e[7:]))
 elif'x'==c:O+=[-heappop(H)]
print('\n'.join(map(str,O)))


### FIXED CODE ###

import sys
from heapq import*
H=[]
O=[]
for e in sys.stdin:
 if'i'==e[0]:heappush(H,-int(e[7:]))
 elif't'==e[2]:O+=[-heappop(H)]
 else:print('\n'.join(map(str,O)))
# coding: utf-8
# Your code here!
A,V = int(input().split())
B,W = int(input().split())
T = int(input())

dis=abs(A-B)
dis1=(V-W)*T
if dis<=dis1:
    print("YES")
else:
    print("NO")


### FIXED CODE ###

# coding: utf-8
# Your code here!
A,V = map(int,input().split())
B,W = map(int,input().split())
T = int(input())

dis=abs(A-B)
dis1=(V-W)*T

if dis<=dis1:
    print("YES")
else:
    print("NO")
n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
def f(L):
    global A
    if A[L[-1]-1] not in L:
        L.append(A[L[-1]-1])
        return f(L)
    else:
        return L
P = f(L)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j
if k+1 <= j:
    print(P[k])
else:
    print(P[j+(k-j)%l])

### FIXED CODE ###

import sys
sys.setrecursionlimit(10**6)

n, k = map(int, input().split())
A = list(map(int, input().split()))
L = [1]
S = {1}

def f(L, S):
    last = L[-1]-1
    if A[last] not in S:
        L.append(A[last])
        S |= {A[last]}
        return f(L, S)
    else:
        return L
P = f(L, S)
a = A[P[-1]-1]
j = P.index(a)
r = len(P)
l = r - j

if k+1 <= j:
    print(P[k])
else:
    print(P[j+(k-j)%l])
# マジで納得がいかねぇので01がなんのケースなのかわざわざ調べてやる

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

if n == 1 or m == 1:  # どうせこれだろ
    print(f"kasu")
    print(1 / 0)


### FIXED CODE ###

# 書けばわかる 裏になるのは奇数回訪れる場所
n, w = map(int, input().split())
print(abs(n*w-(2*n+2*w-4)))
x = input()
a = x.split(' ')[0]
b = x.split(' ')[1]
if a > b:
    print('a < b')
elif a < b:
    print('a > b')
else:
    print('a == b')


### FIXED CODE ###

line = int(input())

h = int(line / 3600)

m = int(line % 3600 / 60)

s = int(line % 3600 % 60)

print(str(h) + ':' + str(m) + ':' + str(s))
a = int(input())
toprint = False
while a > 0 :
 	last_digit = a % 10
 	a = a // 10
 	if last_digit == 7 :
   		toprint = True
 
	if toprint == True :
 		print ("Yes")
	else :
 		print ("No")

### FIXED CODE ###

a = int(input())
toprint = False
while a > 0 :
 last_digit = a % 10
 a = a // 10
 if last_digit == 7 :
   toprint = True
 
if toprint == True :
 print ("Yes")
else :
 print ("No")
from fractions import gcd
from math import ceil
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=len(bin(a[0]))-bin(a[0]).rfind("1")
for i in range(1,n):
  if c!=len(bin(a[i+1]))-bin(a[i+1]).rfind("1"):
    print(0)
    exit()
g=a[0]
for i in range(n-1):
   g=(g//gcd(g,a[i+1]))*(a[i+1]//gcd(g,a[i+1]))*gcd(g,a[i+1])
g//=2
print(ceil((m//g)/2))


### FIXED CODE ###

from fractions import gcd
from math import ceil
n,m=map(int,input().split())
a=list(map(int,input().split()))
c=len(bin(a[0]))-bin(a[0]).rfind("1")
for i in range(1,n):
  if c!=len(bin(a[i]))-bin(a[i]).rfind("1"):
    print(0)
    exit()
g=a[0]
for i in range(n-1):
   g=(g//gcd(g,a[i+1]))*(a[i+1]//gcd(g,a[i+1]))*gcd(g,a[i+1])
g//=2
print(ceil((m//g)/2))
mod=10**9+7
s=input()
n=len(s)
Sum_A=[0]*(n+1)
Sum_B=[0]*(n+1)
Sum_C=[0]*(n+1)
Sum_q=[0]*(n+1)
for i in range(1, n+1):
    Sum_A[i]=Sum_A[i-1]
    Sum_C[i]=Sum_C[i-1]
    Sum_q[i]=Sum_q[i-1]
    if s[i-1]=='A':
        Sum_A[i]+=1
    elif s[i-1]=='C':
        Sum_C[i]+=1
    elif s[i-1]=='?':
        Sum_q[i]+=1
ans=0
def count(x, q):
    return int(x*pow(3, q, mod)+q*pow(3, (q-1), mod))
for i in range(n):
    if s[i]=='B' or s[i]=='?':
        ans+=count(Sum_A[i], Sum_q[i])*count(Sum_C[n]-Sum_C[i+1], Sum_q[n]-Sum_q[i+1])
        ans%=mod
print(ans)


### FIXED CODE ###

mod=10**9+7
s=input()
n=len(s)
Sum_A=[0]*(n+1)
Sum_B=[0]*(n+1)
Sum_C=[0]*(n+1)
Sum_q=[0]*(n+1)
for i in range(1, n+1):
    Sum_A[i]=Sum_A[i-1]
    Sum_C[i]=Sum_C[i-1]
    Sum_q[i]=Sum_q[i-1]
    if s[i-1]=='A':
        Sum_A[i]+=1
    elif s[i-1]=='C':
        Sum_C[i]+=1
    elif s[i-1]=='?':
        Sum_q[i]+=1
ans=0
def count(x, q):
    return int(x*pow(3, q, mod)+q*pow(3, (q-1), mod)) if q>0 else int(x*pow(3, q, mod))
for i in range(n):
    if s[i]=='B' or s[i]=='?':
        ans+=count(Sum_A[i], Sum_q[i])*count(Sum_C[n]-Sum_C[i+1], Sum_q[n]-Sum_q[i+1])
        ans%=mod
print(ans)
import re

if re.match("keyence",S) or re.match("^(.*)(keyence)$",S) or re.match("^k(.*)(eyence)$",S) or re.match("^(ke)(.*)(yence)$",S) or re.match("^(key)(.*)(ence)$",S) or re.match("^(keye)(.*)(nce)$",S) or re.match("^(keyen)(.*)(ce)$",S) or re.match("^(keyenc)(.*)(e)$",S)  or re.match("^(keyence)(.*)$",S):
    print("YES")
else:
    print("NO")

### FIXED CODE ###

import re

S=input()

if re.match("keyence",S) or re.match("^(.*)(keyence)$",S) or re.match("^k(.*)(eyence)$",S) or re.match("^(ke)(.*)(yence)$",S) or re.match("^(key)(.*)(ence)$",S) or re.match("^(keye)(.*)(nce)$",S) or re.match("^(keyen)(.*)(ce)$",S) or re.match("^(keyenc)(.*)(e)$",S)  or re.match("^(keyence)(.*)$",S):
    print("YES")
else:
    print("NO")
import sys
sys.setrecursionlimit(2000)
n = int(input())

def factorization(n):
    arr = []
    temp = n
    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])
    # 上のループを通した後にtempが1じゃなかったら、だけど、nが素数以外にそんなケースある？
    if temp!=1:
        arr.append([temp, 1])
    
    # 素数だったときの処理
    if arr == []:
        arr.append([n,1])

    return arr

def factorial(n):
    if n == 1:
        return 1
    return n * factorial(n-1)
F = factorial(n)
factor_ls = factorization(F)
ls = [factor[1] for factor in factor_ls]
num_factor = 1
for i in ls:
    num_factor *= (i + 1)
print(num_factor % (10**9 + 7))


### FIXED CODE ###

mod = 1000000000 + 7

def factorization(n):
    arr = []
    temp = n
    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

n = int(input())
dat = [0] * 2000 # 約数として求められたある数の合計

# N! の各要素の素因数分解をする
res = 1
for i in range(1, n + 1):
    d = factorization(i)
    for j in range(len(d)):
        dat[d[j][0]] += d[j][1]

for i in range(2, n + 1):
    res *= (dat[i] + 1)
    res %= mod

print(res)
S=list(input())
E=[]
O=[]
for i in range(len(S)):
  if i%2==0:
    E.append(S[i])
  else:
    O.append(S[i])
if R in E or L in O:
  print("No")
else:
  print("Yes")
S=list(input())
E=[]
O=[]
for i in range(len(S)):
  if i%2==0:
    E.append(S[i])
  else:
    O.append(S[i])
if "R" in E or "L" in O:
  print("No")
else:
  print("Yes")
提出情報

### FIXED CODE ###

S=input()
if all(c  in 'RUD' for c in S[::2]) and all(c in 'LUD' for c in S[1::2]):
  print("Yes")
else:
  print("No")
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
BA = [[] for i in range(N)]
for i in range(N):
    a,b = LI()
    BA[i] = (b,a)

BA.sort()
part_A = [0 for i in range(N)]
for i in range(N):
    B,A = BA[i]
    part_A[i] = A + part_A[i-1]

for i in range(N):
    B,A = BA[i]
    if B - part_A < 0:
        print("No")
        break
else:
    print("Yes")


### FIXED CODE ###

# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
BA = [[] for i in range(N)]
for i in range(N):
    A,B = LI()
    BA[i] = [B,A]


BA.sort()
part_A = [0 for i in range(N)]
for i in range(N):
    B,A = BA[i]
    part_A[i] = A + part_A[i-1]

for i in range(N):
    B,A = BA[i]
    if B - part_A[i]>= 0:
        pass
    else:
        print("No")
        break
else:
    print("Yes")
import sys

for l in sys.stdin:
  items = [int(x) for x in l.split(' ')]
  a = items[0]
  b = items[1]
  if a <= b:
    return a
  else:
    return a - 1

### FIXED CODE ###

import sys

for l in sys.stdin:
  items = [int(x) for x in l.split(' ')]
  a = items[0]
  b = items[1]
  if a <= b:
    print a
  else:
    print a - 1
a,b,q=(input().split())
a,b,q=int(a),int(b),int(q)
s=[int(input()) for i in range(a)]
t=[int(input()) for i in range(b)]
x=[int(input()) for i in range(q)]
dist=['' for i in range(8)]
dist1=['' for i in range(2)]
dist2=['' for i in range(4)]
sp1=['' for i in range(2)]
tp1=['' for i in range(4)]

import bisect
for k in range(q):

    p1=bisect.bisect_left(s,x[k])

    if 0 < p1 < a:
        dist1[0]=x[k]-s[p1-1]
        dist1[1]=s[p1]-x[k]
        sp1[0]=s[p1-1]
        sp1[1]=s[p1]
    elif p1==0:
        dist1[0]=s[0]-x[k]
        dist1[1]=s[0]-x[k]
        sp1[0]=s[0]
        sp1[1]=s[0]        
    elif p1==a:
        dist1[0]=x[k]-s[a-1]
        dist1[1]=x[k]-s[a-1]
        sp1[0]=s[a-1]
        sp1[1]=s[a-1]
        
    for i in range(2):     
        p11=bisect.bisect_left(t,sp1[i])

        if 0 < p11 < b:
            dist2[0+2*i]=sp1[i]-t[p11-1]
            dist2[1+2*i]=t[p11]-sp1[i]
        if p11==0:
            dist2[0+2*i]=t[0]-sp1[i]
            dist2[1+2*i]=t[0]-sp1[i]
        elif p11==b:
            dist2[0+2*i]=sp1[i]-t[b-1]
            dist2[1+2*i]=sp1[i]-t[b-1]
        
    dist[0]=dist1[0]+dist2[0]
    dist[1]=dist1[0]+dist2[1]
    dist[2]=dist1[1]+dist2[2]
    dist[3]=dist1[1]+dist2[3]
                
    p1=bisect.bisect_left(t,x[k])

    if 0 < p1 < b:
        sp1[0]=t[p1-1]
        sp1[1]=t[p1]
        dist1[0]=x[k]-t[p1-1]
        dist1[1]=t[p1]-x[k]
    elif p1==0:
        sp1[0]=t[0]
        sp1[1]=t[0]
        dist1[0]=t[0]-x[k]
        dist1[1]=t[0]-x[k]
    elif p1==b:
        sp1[0]=t[b-1]
        sp1[1]=t[b-1]
        dist1[0]=x[k]-t[b-1]
        dist1[1]=x[k]-t[b-1]
        
    for i in range(2):    
        p11=bisect.bisect_left(s,sp1[i])

        if 0 < p11 < a:
            dist2[0+2*i]=sp1[i]-s[p11-1]
            dist2[1+2*i]=s[p11]-sp1[i]
        elif p11==0:
            dist2[0+2*i]=s[0]-sp1[i]
            dist2[1+2*i]=s[0]-sp1[i]
        elif p11==a:
            dist2[0+2*i]=sp1[i]-s[a-1]
            dist2[1+2*i]=sp1[i]-s[a-1]

    dist[4]=dist1[0]+dist2[0]
    dist[5]=dist1[0]+dist2[1]
    dist[6]=dist1[1]+dist2[2]
    dist[7]=dist1[1]+dist2[3]
    
    ans=min(dist[0],dist[1],dist[2],dist[3],dist[4],dist[5],dist[6],dist[7])

    print(ans)



### FIXED CODE ###

import itertools

n,a,b,c=(input().split())
n,a,b,c=int(n),int(a),int(b),int(c)
l=[int(input()) for i in range(n)]
#print(n,a,b,c,l)

ansans=float('inf')
ans=float('inf')

mylist=list(itertools.product(range(4),repeat=n))
#print(len(mylist))
#mylist=[1,2,2,2,3]
for j in range(len(mylist)):
    x,y,z=0,0,0
    for i in range(n):
        if mylist[j][i]==1:
            x+=l[i]
        elif mylist[j][i]==2:
            y+=l[i]
        elif mylist[j][i]==3:
            z+=l[i]
        
    if mylist[j].count(1)>0 and mylist[j].count(2)>0 and mylist[j].count(3) > 0:
        ans=0
        ans+=abs(a-x)+abs(b-y)+abs(c-z)
        compo=0
        for i in range(1,4):
            compo+=mylist[j].count(i)-1
        ans+=10*compo

    if ans < ansans:
        ansans = ans

print(ansans)