peterverebics/CodeNet_Python_428 huggingface dataset:
# Judge status: Wrong Answer
N, A, B = map(int, input().split())

if N==1 and A==B:
  ans = 1
elif N==1:
  ans = 0
elif A > B:
  ans = 0
else:
  ans = (B-A) * (N-2) + 1
# Judge status: Accepted
a, b, t = map(int, input().split())

the_number_of_times = (t + 0.5) // a
the_number_of_biscuits = int(b * the_number_of_times)

print(the_number_of_biscuits)
# Judge status: Accepted
import sys
input = sys.stdin.readline

def main():
    K = int(input())
    
    if K%2==0 or K%5==0:
        print(-1)
        return
    
    if K % 7:
        L = 9*K
    else:
        L = 9*K//7
    a = 1
    for i in range(1,K+10):
        a = (a * 10) % L
        if a == 1:
            print(i)
            return
    print(-1)
main()
# Judge status: Accepted
n,r=map(int,input().split())

if n>=10:
    print(r)
else:
    print(r+(100*(10-n)))
# Judge status: Accepted
N, M = map(int, input().split())
student = [tuple(map(int, input().split())) for _ in range(N)]
checkpoint = [tuple(map(int, input().split())) for _ in range(M)]

closest = {}
for s in student:
    min_dist = 'INF'
    ans = 1
    for c in checkpoint:
        dist = abs(s[0]-c[0]) + abs(s[1]-c[1])
        if min_dist == 'INF' or dist < min_dist:
            min_dist = dist
            closest[s] = ans
        ans += 1

for s in student:
    print(closest[s])
# Judge status: Accepted
import sys
from collections import Counter
from collections import deque
import heapq
import math
import fractions
import bisect
import itertools
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

n=int(input())
a=lmp()
sa=0
sb=sum(a)
ans=float("inf")
for i in range(n-1):
    sa+=a[i]
    sb-=a[i]
    ans=min(ans,abs(sa-sb))
print(ans)
# Judge status: Wrong Answer
S=input()
print("S"[0:2])
# Judge status: Accepted
a=list(map(int,input().split()))

a=sorted(a)

if a[0]+a[1]==a[2]:
  print("Yes")
else:
  print("No")
# Judge status: Accepted
import math
n = int(input())
a = list(map(int,input().split()))

b = [0]*n 
c = 0
s = [0]*(n+1)

for i in reversed(range(1,n+1)):
	for k in range(1,math.floor(n/i)+1):
		j = int(k*i)
		s[i] += b[j-1]
	if s[i]%2 != a[i-1]:
		b[i-1] += 1
		c += 1
print(c)
L = [i+1 for i in range(n) if b[i] == 1]
print(*L)
# Judge status: Accepted
def main():
    N = int(input())
    num = 0
    for i in range(1, N + 1):
        if i % 2 == 1:
            count = 0
            for j in range(1, N + 1):
                if i % j == 0:
                    count += 1
            if count == 8:
                num += 1
    print(num)
main()
# Judge status: Accepted
A=list(map(int,input().split()))
B=0
B=A[0]+A[1]+A[2]
if B>=22:
    print("bust")
else:
    print("win")
# Judge status: Accepted
a, b = map(int, input().split())

cnt = 0
for i in range(a, b+1):
    tmp = str(i)
    if tmp == tmp[::-1]:
        cnt += 1

print(cnt)
# Judge status: Accepted
number = input().split(" ")
ans = set(number)
if len(ans) == 2:
	print("Yes")
else:
	print("No")
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
p = 0

for i in list(set(a)):
    ans = a.count(i)
    print(ans)
    a = [s for s in a if s != i]
    p = p + ans
    if p == n-1:
        break
for s in range (n-i):
    print(0)
# Judge status: Accepted
n = int(input())
W = [input() for i in range(n)]
flg = 1

Word = [W[0]]
for i in range(1,n):
    s = W[i-1]
    t = W[i]
    
    if(s[-1] != t[0] or t in Word): 
        flg = 0
        break
    Word.append(t)
    
if (flg): print("Yes")
else: print("No")
# Judge status: Wrong Answer
a,b=sorted(map(int,input().split()))
#ユークリッドの互除法
def gcd(a,b):
    if b==0:
        return a
    #余りが0になったら最後の割る数を出力=lcm
    else:
        return (gcd(b,a%b))
print(a*b/gcd(a,b))
#ユークリッドの互除法)
# Judge status: Accepted
import math


if __name__ == '__main__':
    a, b = list(map(int, input().split(" ")))
    for i in range(1, 1500):
        # print(i)
        if math.floor(i * 0.08) == a and math.floor(i * 0.1) == b:
            print(i)
            exit()
    print(-1)
# Judge status: Accepted
x,y  = map(int,input().split())

g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]

if x in g1 and y in g1:
  print('Yes')
elif x in g2 and y in g2:
  print('Yes')
elif x in g3 and y in g3:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
import sys
n,m=map(int,input().split())
if m != 0:
  a=set(map(int,sys.stdin.read().split()))
else:
  a=set()

modx=10**9+7

dp=[0]*(n+10)
dp[0]=1

for i in range(n+1):
  if i+1 not in a:
    dp[i+1]= (dp[i]+dp[i+1]) % modx
  if i+2 not in a:
    dp[i+2]= (dp[i]+dp[i+2]) % modx

print(dp[n])
# Judge status: Wrong Answer
from fractions import gcd
def lcm(x,y):
    return (x*y)//gcd(x,y)

n=int(input())
t=[int(input()) for i in range(n)]
ans=0

if n==1:
    print(t[0])
    exit()
for i in range(n-1):
    tt=lcm(t[i],t[i+1])
    ans=max(ans,tt)
print(ans)
# Judge status: Accepted
a, b, c = list(input().split())
s = a[0] + b[0] + c[0]
ans = s.upper()
print(ans)
# Judge status: Wrong Answer
import itertools

def resolve():
    n = int(input())
    l = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

    init = ['a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a', 'a']
    print(''.join(init[0:n]))
    for str in itertools.combinations_with_replacement(l[0:n], n):
        if len(list(set(str))) != 1:
            print(''.join(str))
            
resolve()
# Judge status: Wrong Answer
# coding: utf-8
# Your code here!
X,K,D=map(int,input().split())

move=min(X//D,K)
ans=X-move*D

if move==K:
    print(ans)
else:
    if (K-move)%2==0:
        print(ans)
    else:
        print(abs(ans-D))
# Judge status: Accepted
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections


n = int(input())
a = list(map(int,input().split()))
n1 = 0
n2 = 0
n4 = 0
for i in range(n):
    if a[i]%4 == 0:
        n4+=1
    elif a[i]%2 == 0:
        n2 +=1
    else:
        n1+=1

if n2 == 1:
    n2 = 0

if n4*2 + n2 >= n or n4*2 + 1 == n:
    print("Yes")
else:
    print("No")
# Judge status: Accepted
N = int(input())
li = []
for i in range(N-1):
    c, s, f = map(int, input().split())
    li.append((c,s,f))
for i in range(N-1):
    t = 0
    for j in range(i, N-1):
        t = max(li[j][1], t)
        t += (li[j][2] - t)%li[j][2]
        t += li[j][0]
    print(t)
print(0)
# Judge status: Accepted
h = int(input().rstrip())
w = int(input().rstrip())
n = int(input().rstrip())

if h > w:
    div = h
else:
    div = w

if n % div > 0:
    ans = int(n / div) + 1
else:
    ans = int(n / div)

print(ans)
# Judge status: Accepted
N = int(input())
H = [int(i) for i in input().split()]

is_true = True
before_tmp = 1
for i in range(N - 1):
    # 差分を計算
    tmp = H[i + 1] - H[i]
    if tmp < 0 and (tmp <= -2 or before_tmp <= -1):
        is_true = False
        break
    # 0の場合は飛ばす
    if tmp != 0:
        before_tmp = tmp

if is_true:
    print('Yes')

else:
    print('No')
# Judge status: Accepted
from sys import setrecursionlimit
from collections import Counter
from collections import defaultdict
from collections import deque
from heapq import heapify
from heapq import heappop
from heapq import heappush
from time import time
setrecursionlimit(10**9)
mod=10**9+7
inf=10**18

n=int(input())

cnt=0
for i in range(1,n+1):
    wk=n//i
    if n%i==0:
        wk-=1
    cnt+=wk

print(cnt)
# Judge status: Accepted
from math import gcd
A, B, C, D = map(int, input().split())

if C == 1 or D == 1:
    print(0)
    exit()

def check(A, B, x):
    return B//x - (A-1)//x

print((B - A + 1) - (check(A, B, C) + check(A, B, D) - check(A, B, C*D//gcd(C, D))) )
# Judge status: Accepted
n = int(input())
b = list(map(int,input().split()))

a = []
a.append(b[0])

for i in range(n-1):
    if i==n-2:
        a.append(b[i])
    else:
        if b[i]<b[i+1]:
            a.append(b[i])
        else:
            a.append(b[i+1])

print(sum(a))
# Judge status: Wrong Answer
N = int(input())
A = list(map(int, input().split()))

ans = 1
for a in A:
    ans *= a
    if ans > 10**18:
        print(-1)
        break
else:
    print(ans)
# Judge status: Accepted
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ans = 0
    for x in range(1, N+1):
        if (K-1)*x + 1 >= N:
            ans = x
            break
    print(ans)
main()
# Judge status: Wrong Answer
N = int(input())
P = list(map(int, input().split()))

ans = 0
cnt = 0

f = 0
for i, v in enumerate(P):
    if not f:
        if i+1 == v:
            f = 1
    else:
        cnt += 1
        if i+1 == v:
            ans += cnt
            f = 0
            cnt = 0
    # print(f"i{i} v{v} ans{ans} cnt{cnt} f{f}")
print(ans + f)
# Judge status: Accepted
import math
N,K = list(map(int,input().split()))
H = list(map(int,input().split()))
H = sorted(H,reverse=True)
print(sum(H[K:]))
# Judge status: Accepted
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
from fractions import gcd

def main():
    mod=10**9+7
    a,b,c=MI()
    d=gcd(a,b)
    if c%d==0:
        print("YES")
    else:
        print("NO")

main()
# Judge status: Accepted
from collections import Counter
N = int(input())
stics = [int(i) for i in input().split()]

c = Counter(stics)

cnt = [k for k, v in c.items() if v >= 2]

if len(cnt) < 2:
    print(0)
else :
    cnt = sorted(cnt, reverse=True)
    if c[cnt[0]] >= 4:
        print(cnt[0] * cnt[0])
    else :
        print(cnt[0] * cnt[1])
# Judge status: Accepted
import collections
def main():
    N = int(input())
    A = list(map(int, input().split()))

    B = [a+i for i, a in enumerate(A)]
    C = [a-i for i, a in enumerate(A)]

    
    c = collections.Counter(C)

    ans = 0
    for b in B:
        ans += c.get(-b, 0)
    print(ans)


if __name__ == '__main__':
    main()
# Judge status: Wrong Answer
N = int(input())
print((N // 10) ** 2 + N % 5 + 8)
# Judge status: Accepted
import copy
N,x = map(int,input().split())
a = list(map(int,input().split()))
b = copy.deepcopy(a)
ans = 0
if a[0]>x:
    ans+=a[0]-x
    a[0] = x
for i in range(N-1):
    if a[i]+a[i+1]>x:
        ans += (a[i]+a[i+1])-x
        a[i+1] -= (a[i]+a[i+1])-x

print(ans)
# Judge status: Accepted
n,l=map(int,input().split())
m=[]
k=[]
for i in range(1,n+1):
    m.append(l+i-1)

for j in range(len(m)):
    k.append(abs(sum(m)-(sum(m)-m[j])))

for d in range(len(k)):
    if min(k)==k[d]:
        print(sum(m)-m[d])
# Judge status: Accepted
n = int(input())

ans = 0

i = 2
num = n
while i * i <= n:
  cnta = 0
  cntb = 0
  while num % i == 0:
    num //= i
    if cnta == cntb:
      ans += 1
      cnta = 0
      cntb += 1
    else:
      cnta += 1
  i += 1
  
if (ans == 0 and n != 1) or num != 1:
  ans += 1
print(ans)
# Judge status: Accepted
k, s = map(int, input().split())
c = 0
for x in range(min(s, k)+1):
    for y in range(min(s-x, k)+1):
        if s-x-y <= k:
            c += 1
print(c)
# Judge status: Accepted
from collections import Counter
n = int(input())
A = list(map(int,input().split()))
Acount = Counter(A)

total = 0
for key in Acount.keys():
    total += Acount[key] * (Acount[key] - 1) // 2

for i in range(n):
    tmp = total
    tmp -= Acount[A[i]]*(Acount[A[i]]-1) // 2
    tmp += (Acount[A[i]]-1)*(Acount[A[i]]-2) // 2
    print(tmp)
# Judge status: Accepted
n,a,b = map(int,input().split())

mod = 10**9 + 7

def comb(n:int,k:int,MOD:int):
    """return nCk (mod MOD)
    """
    nCk = 1
    for i in range(n-k+1, n+1):
        nCk *= i
        nCk %= MOD
    for i in range(1,k+1):
        nCk *= pow(i,MOD-2,MOD)
        nCk %= MOD
    return nCk

all = pow(2,n,mod)-1
comb_a = comb(n,a,mod)
comb_b = comb(n,b,mod)
answer = (all -comb_a -comb_b) % mod

print(answer)
# Judge status: Wrong Answer
N = int(input())

if N%2 == 1 or N == 0:
  print(0)
else:
  print(N//10)
# Judge status: Wrong Answer
n = int(input())
a = list(map(int, input().split()))
a.sort()
Alice = list()
Bob = list()
print(a)
for i in range(n):
    if i % 2 == 0:
        Alice.append(a[i])
    else:
        Bob.append(a[i])

print(sum(Alice) - sum(Bob))
# Judge status: Wrong Answer
H,K=map(int,input().split())
H=list(map(int,input().split()))
H.sort()
print(sum(H[0:len(H)-K+1]))
# Judge status: Accepted
import numpy as np

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

# N, K = 10, 4
# P = [17, 13, 13, 12, 15, 20, 10, 13, 17, 11]

exp = []
for i in range(N):
    exp.append((1 + P[i]) / 2)

cum_exp = np.cumsum(exp)

max = cum_exp[K-1]
for i in list(range(K, N)):
    val = cum_exp[i] - cum_exp[i - K]
    if val > max:
        max = val

print(max)
# Judge status: Accepted
def f(x):
    if x == 1:
        return 1
    return 2 * f(x // 2) + 1


H = int(input())
print(f(H))
# Judge status: Accepted
from math import ceil
A,B,C=map(int, input().split())
L=sorted([A,B,C])
n1=L[0]
n2=L[1]
n3=L[2]

fir=ceil((n2-n1)/2)
if n1+2*fir!=n2:
    sec=1
else:
    sec=0

ans=n3+sec-(n1+2*fir)+fir+sec
print(ans)
#print(fir, sec)
#6+1-(4)
# Judge status: Accepted
N, K = map(int, input().split())
s = list(input())
s[K - 1] = s[K - 1].lower()
print(''.join(s))
# Judge status: Accepted
a,b=map(str,input().split())
a_num,b_num=map(int,input().split())
delete_one=input()

if a==delete_one:
    a_num-=1
else:
    b_num-=1
print(a_num,b_num)
# Judge status: Accepted
x,y=map(int,input().split())
print(-(x%y==0) or x)
# Judge status: Wrong Answer
H1,M1,H2,M2,K=map(int, input().split())

M1 += H1*60
M2 += H2*60
out = int((M2-M1-1)/K)
print(out*K)
# Judge status: Wrong Answer
from collections import deque

s = input()
q = deque(list(s))

while q:
  if len(q) >= 5:
    subs = q.popleft()+q.popleft()+q.popleft()+q.popleft()+q.popleft()
    if subs != 'erase' and subs != 'dream':
      print('NO')
      exit()
    if subs == 'erase' and len(q) != 0 and q[0] == 'r':
      q.popleft()
  else:
    print('NO')
    exit()
    
print('YES')
# Judge status: Accepted
s = list(map(int,input()))
ans = 10**12

for i in range(len(s)-2):
    x = s[i]*100+s[i+1]*10+s[i+2]
    ans = min(ans,abs(x-753))
    
print(ans)
# Judge status: Accepted
n,d = map(int, input().split())
x = 2*d + 1
print((n+x-1)//x)
# Judge status: Accepted
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
import sys
def main(N, A):
    dp = [0] * (N + 1)
    dp[0] = 1000
    for i in range(1, N + 1):
        dp[i] = dp[i - 1]
        for j in range(1, i):
            dp[i] = max(dp[i], (dp[j] // A[j - 1]) * A[i - 1] + dp[j] % A[j - 1])
    print(dp[N])

if __name__ == '__main__':
    input = sys.stdin.readline
    N = int(input())
    *A, = map(int, input().split())
    main(N, A)
# Judge status: Accepted
l = list(map(int,input().split()))
l.remove(max(l))

print(int(l[0]*l[1]/2))
# Judge status: Accepted
n,x,y=map(int,input().split())
x-=1
y-=1
k=[0]*n
for i in range(n-1):
  for j in range(i+1,n):
    m=min(j-i,abs(i-x)+1+abs(y-j))
    k[m]+=1
for i in range(1,n):print(k[i])
# Judge status: Accepted
S=input()
ans=10**5
for i in range(len(S)-3+1):
    t=S[i:i+3]
    ans=min(ans,abs(753-int(t)))
print(ans)
# Judge status: Accepted
a, b, c, d, e, k = [int(input()) for _ in range(6)]
print('Yay!' if e - a <= k else ':(')
# Judge status: Wrong Answer
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

A,B,C,K = I()
num = abs(A-B)
if num > 10**18:
    print('Unfair')
else:
    print(num)
# Judge status: Accepted
n=int(input())
flag=True
for i in range(26):
    for j in range(16):
        if 4*i+7*j==n:
            print("Yes")
            flag=False
            exit()
if flag:
    print("No")
# Judge status: Accepted
a,b,c = map(int,input().split())
if a+b>=c:
  print('Yes')
else:
  print('No')
# Judge status: Accepted
# B - Bounding

N, X = map(int, input().split())
L = [int(l) for l in input().split()]
D = 0
cnt = 1
for i in range(N):
    D = D + L[i]
    if D <= X:
        cnt += 1

print(cnt)
# Judge status: Wrong Answer
a, b, c = [int(x) for x in input().split()]

if 2 * (a + b) >= c:
    print('Yes')
else:
    print('No')
# Judge status: Accepted
import sys
K = int(input())

if K%2 == 0 or K%5 == 0:
    print(-1)
    sys.exit()

dp = 7
ans = 1

while(ans <= 10000000):
    if dp % K == 0:
        print(ans)
        sys.exit()
    ans += 1
    dp = (dp * 10 + 7) % K
# Judge status: Accepted
def has_duplicates(seq):
    return len(seq) != len(set(seq))


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

flg = has_duplicates(a)

if not flg:
    print('YES')
else:
    print('NO')
# Judge status: Accepted
s = input()

n = 0
m = 0
for i in range(len(s)):
    if s[i] == 'A':
        n = i
        break
for i in reversed(range(len(s))):
    if s[i] == 'Z':
        m = i
        break
print(m-n+1)
# Judge status: Wrong Answer
s = str(input())


t = set([s[0], s[1], s[2], s[3]])

if len(t)<4:
    print('Bad')
else:
    print('Good')
# Judge status: Wrong Answer
N = int(input())
ans = N*(N-1)/2
print(int(ans))
# Judge status: Wrong Answer
N = int(input())
sub_yes = 0
max_yes = 0
for i in range(N):
    d1,d2 = map(int,input().split())
    if d1 == d2:
        sub_yes += 1
        if sub_yes > max_yes:
            max_yes = sub_yes
    else:
        if sub_yes > max_yes:
            max_yes = sub_yes
        sub_yes = 0
if max_yes >= 3:
    print("yes")
else:
    print("no")
# Judge status: Accepted
# coding: utf-8
A, B, X = map(int, input().split())
# print(A, B, X)
if X - A >= 0 and B >= X - A:
    print('YES')
else:
    print('NO')
# Judge status: Wrong Answer
# 初期入力
import sys
input = sys.stdin.readline  #文字列では使わない
N,K = map(int, input().split())
A = list(map(int, input().split()))
aa =1
DP =[0]*(N-K+1)
for i in A[:K]:
    aa *=i
DP[0] =aa

for i in range(N -K):
    DP[i+1] =DP[i]*A[i+K]//A[i]
    if DP[i+1] >DP[i]:
        print("Yes")
    else:
        print("No")
print(DP)
# Judge status: Accepted
from collections import defaultdict
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
input = sys.stdin.readline


def inp():
    return int(input())


def inpl():
    return list(map(int, input().split()))


N = inp()
aa = inpl()


ajs = []
ais = []

for i, a in enumerate(aa):
    ajs.append(a - i)
    ais.append(-a - i)


cnt = defaultdict(int)
ans = 0
for ai, aj in zip(ais, ajs):
    ans += cnt[aj]
    cnt[ai] += 1


print(ans)
# Judge status: Accepted
n=int(input())
s=input()
ans='No'
if n%2==0:
  if s[:n//2]==s[n//2:]:
    ans='Yes'
print(ans)
# Judge status: Accepted
a=input().split(' ')
#print(a[0])
b=int(a[0])
d=int(a[1])
c=input().split(' ')
count=0
for i in c:
    count+=int(i)
    
#print(count)
if b-count>=0:
    print(b-count)
else:
    print(-1)
# Judge status: Wrong Answer
N = int(input())
AB = [list(map(int,input().split())) for _ in range(N)]
AB.reverse()
count = 0

for a,b in AB:
  num_a = a + count
  if num_a%b != 0 or num_a == 0:
    count += (b - (num_a % b))
  else:
    pass
print(count)
# Judge status: Wrong Answer
s = input()

ss = s.split(" ")

N = int(ss[0])
A = int(ss[1])
B = int(ss[2])

if A == 0:
  print(0)
elif B == 0:
  print(N)
else:
  if N <= ( A + B ) :
    print(A)
  else:
    ans = 0
    div = N //( A + B ) 
    mod = N % ( A + B )
    ans = div * A

    if mod > A :
      ans += A
    else :
      ans += mod
    
    print(ans)
# Judge status: Accepted
n = int(input())
A = [int(input()) for _ in range(5)]
ans = (n - 1) // min(A) + 1 + 4
print(ans)
# Judge status: Accepted
# input
D = int(input())

S = ("a", "b", "c", "d", "e", "f", "g", "h", "i", "j")

# process
def f(x):
    if x == 0:
        return ["a"]

    else:
        t =  f(x - 1)
        r = []
        for s in t:
            num = len(set(list(s)))
            for i in range(num+1):
                r.append(s+S[i])
        return r

ans = f(D-1)

# output
print(" ".join(map(str, ans)))
# Judge status: Accepted
n,k,q=map(int,input().split())
l=[0]*n
for i in range(q):
    a=int(input())
    l[a-1]+=1
for i in range(n):
    if k-(q-l[i])>0:
        print("Yes")
    else:
        print("No")
# Judge status: Wrong Answer
# ABC 167 C
N,M,X = map(int,input().split())
C =[]
for m in range(N):
    C.append([int(i) for i in input().split()])
C.sort(key=lambda x:x[0])

from itertools import combinations
import numpy as np


ans = 10**5 +1

for m in range(1,N+1):
    P=list(combinations(C,m))
    tmp =np.sum(P,axis=1)
    for t in tmp:

        if min(t[1:])>=X and ans > t[0]:
            ans = t[0]
        
          
if min(t[1:])<X:
    print(-1)
else:
    print(ans)
# Judge status: Wrong Answer
n,m=map(int,input().split())
a=[]
b=[]
for i in range(n):
	a.append(input())
for i in range(m):
	b.append(input())

check = False
for i in range(n):

	if b[0]in a[i]:
		index=a[i].index(b[0])
		check=True
		for k in range(m):
			if i+k>=n:
				check=False
				break

			if not b[k]in a[i+k] or a[i+k].index(b[k])!=index:
				check=False
				break
	if check:
		break

print("Yes" if check else "No")
# Judge status: Accepted
# 2020/01/26
# AtCoder Beginner Contest 153 - A

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

# Calc
sum = 0
for i in range(n):
    sum = sum + a[i]

if sum >= h:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)
# Judge status: Accepted
from bisect import bisect_right,bisect_left
n=int(input())
a=[int(input()) for _ in range(n)]
INF=float('INF')
l=[INF]*n
for i in a[::-1]:
    l[bisect_right(l,i)]=i
print(bisect_left(l,INF))
# Judge status: Wrong Answer
n = int(input())
a_L = list(map(int,input().split()))

import collections

L = collections.Counter(a_L)

L = sorted(L.items(),key=lambda x:x[0],reverse=True)

flag = 0
#print(L)
for k,v in L:
    #print(k,v)
    if v >= 2:
        if flag== 0:
            tmp = k
            flag += 1
        elif flag == 1:
            print(tmp*k)
            #print("ans",tmp,k)
            exit()

print(0)
# Judge status: Accepted
import sys
 
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nas = lambda: stdin.readline().split()

a, b, k = na()

cnt = 0
ans = 0
for i in range(min(a, b), 0, -1):
    if a % i == 0 and b % i == 0:
        cnt += 1
    if cnt == k:
        ans = i
        break

print(ans)
# Judge status: Accepted
import numpy as np
i4 = np.int32

nin = np.fromstring(open(0).read(), i4, sep=' ')
N = nin[0]
ab = nin[1:].reshape(-1, 2).T
a = np.sort(ab[0])
b = np.sort(ab[1])
i = N // 2
if N % 2:
    print(b[i] - a[i] + 1)
else:
    nmin = a[i - 1] + a[i]
    nmax = b[i - 1] + b[i]
    print(nmax - nmin + 1)
# Judge status: Accepted
s=list(input())

for ss in s:
  if s.count(ss)!=2:
    print("No")
    exit()
    
print("Yes")
# Judge status: Wrong Answer
mod = pow(10,9)+7
N = int(input())

A =map(lambda x:int(bin(int(x))[2:]) ,input().split())

counter = 0
for a in A:
    counter += a

A = str(counter)
L = len(A)
tmp = 0
for i in range(L):
    tmp += int(A[i])*(N-int(A[i]))*(2**(L-i-1))
    
print(tmp%mod)
# Judge status: Accepted
import math
a = input("").split(" ")
a = [int(aa) for aa in a]
n = int(str(a[0])+str(a[1]))
r = math.sqrt(n)
if r**2 == int(r)**2:
    print("Yes")
else:
    print("No")
# Judge status: Wrong Answer
# 初期入力
import sys
input = sys.stdin.readline
N = int(input())
A1 = list(map(int, input().split()))
A2 = list(map(int, input().split()))

count =[0]*N
for i in range(N-1):
    count[i] =sum(A1[:i+1]) +sum(A2[i:])
print(max(count))
# Judge status: Wrong Answer
K = int(input())
S = input()

if K > len(S):
  print(S)
else:
  print(S[:K+1]+'...')
# Judge status: Accepted
n, k = map(int, input().split())
s = list(map(str, input().split()))[0]

ans = 0
w = 0
for i in range(n-1):
    if s[i+1] == s[i]:
        ans += 1
    else:
        w += 1

p = (w // 2) * [2] + (w % 2) * [1]

print(ans + sum(p[:k]))