Petya loves computer games. Finally a game that he's been waiting for so long came out!

The main character of this game has n different skills, each of which is characterized by an integer a_{i} from 0 to 100. The higher the number a_{i} is, the higher is the i-th skill of the character. The total rating of the character is calculated as the sum of the values ​​of $\lfloor \frac{a_{i}}{10} \rfloor$ for all i from 1 to n. The expression ⌊ x⌋ denotes the result of rounding the number x down to the nearest integer.

At the beginning of the game Petya got k improvement units as a bonus that he can use to increase the skills of his character and his total rating. One improvement unit can increase any skill of Petya's character by exactly one. For example, if a_4 = 46, after using one imporvement unit to this skill, it becomes equal to 47. A hero's skill cannot rise higher more than 100. Thus, it is permissible that some of the units will remain unused.

Your task is to determine the optimal way of using the improvement units so as to maximize the overall rating of the character. It is not necessary to use all the improvement units.


-----Input-----

The first line of the input contains two positive integers n and k (1 ≤ n ≤ 10^5, 0 ≤ k ≤ 10^7) — the number of skills of the character and the number of units of improvements at Petya's disposal.

The second line of the input contains a sequence of n integers a_{i} (0 ≤ a_{i} ≤ 100), where a_{i} characterizes the level of the i-th skill of the character.


-----Output-----

The first line of the output should contain a single non-negative integer — the maximum total rating of the character that Petya can get using k or less improvement units.


-----Examples-----
Input
2 4
7 9

Output
2

Input
3 8
17 15 19

Output
5

Input
2 2
99 100

Output
20



-----Note-----

In the first test case the optimal strategy is as follows. Petya has to improve the first skill to 10 by spending 3 improvement units, and the second skill to 10, by spending one improvement unit. Thus, Petya spends all his improvement units and the total rating of the character becomes equal to  lfloor frac{100}{10} rfloor +  lfloor frac{100}{10} rfloor = 10 + 10 =  20.

In the second test the optimal strategy for Petya is to improve the first skill to 20 (by spending 3 improvement units) and to improve the third skill to 20 (in this case by spending 1 improvement units). Thus, Petya is left with 4 improvement units and he will be able to increase the second skill to 19 (which does not change the overall rating, so Petya does not necessarily have to do it). Therefore, the highest possible total rating in this example is $\lfloor \frac{20}{10} \rfloor + \lfloor \frac{19}{10} \rfloor + \lfloor \frac{20}{10} \rfloor = 2 + 1 + 2 = 5$.

In the third test case the optimal strategy for Petya is to increase the first skill to 100 by spending 1 improvement unit. Thereafter, both skills of the character will be equal to 100, so Petya will not be able to spend the remaining improvement unit. So the answer is equal to $\lfloor \frac{100}{10} \rfloor + \lfloor \frac{100}{10} \rfloor = 10 + 10 = 20$.

Difficulty: interview

Starter code:

Solutions:
import sys

def solve():
    n,k, = rv()
    a, = rl(1)
    res = 0
    count = [0] * 10
    for i in range(n):
        if a[i] < 100:
            count[10 - (a[i] % 10) - 1] += 1
        res += a[i] // 10
    for i in range(10):
        while count[i] > 0 and k >= i + 1:
            res += 1
            count[i] -= 1
            k -= i + 1
    already = res * 10
    possible = n * 100
    diff = possible - already
    if diff > 0:
        actual = min(diff, k)
        res += actual // 10
    print(res)






def prt(l): return print(' '.join(map(str, l)))
def rs(): return map(str, input().split())
def rv(): return map(int, input().split())
def rl(n): return [list(map(int, input().split())) for _ in range(n)]  
if sys.hexversion == 50594544 : sys.stdin = open("test.txt")
solve()

import sys


#sys.stdin = open('input.txt')
#sys.stdout = open('output.txt', 'w')

n, k = [int(i) for i in input().split()]
skill = [[int(i) % 10, int(i)] for i in input().split()]

skill.sort(reverse = True)
ans = 0
for i in range(n):
	ans += skill[i][1] // 10
#print(skill)
#print(k)
for i in range(n):
	if skill[i][1] == 100:
		continue
	toup = 10 - skill[i][0]
	if k >= toup:
		k -= toup
		ans += 1
		skill[i][1] += toup

#print(skill)		

maxadd = 0
for i in range(n):
	maxadd += (100 - skill[i][1]) // 10
#print(maxadd)
ans += min(k // 10, maxadd)
print(ans)


n, k = list(map(int, str.split(input())))
a = sorted(map(int, str.split(input())), key=lambda x: x % 10, reverse=True)
rating = 0
for i in range(n):

    delta = 10 - (a[i] % 10)
    if k >= delta and a[i] < 100:

        a[i] += delta
        k -= delta

    rating += a[i] // 10

for i in range(n):

    if k < 10:

        break

    while a[i] < 100 and k >= 10:

        a[i] += 10
        k -= 10
        rating += 1

print(rating)


n, k = list(map(int, input().split()))
a = list(map(int, input().split()))
if sum(a) + k >= n * 100:
    print(n * 10)
    return
adds = []
ans = 0
for i in range(n):
    ans += a[i] // 10
    if a[i] != 100:
        adds.append(10 - (a[i] % 10))
adds.sort()
for i in range(len(adds)):
    if k <= 0:
        break
    else:
        k -= adds[i]
        ans += 1
ans += k // 10
print(ans)


n,k=list(map(int,input().split()))
ki=[0]*11
su=0
for x in input().split():
    t=int(x)
    ki[10-t%10]+=1
    su+=t//10
for i in range(1,10):
    t=min(k//i,ki[i])
    su+=t
    k-=t*i
t=k//10
su+=min(t,n*10-su)
print(su)


n, k = list(map(int, input().split()))
A = list(map(int, input().split()))
A.sort(reverse=True, key=lambda x: x % 10)

for i, a in enumerate(A):
    if k <= 0 or a % 10 == 0:
        break
    new = min(k, 10 - a % 10, 100 - a)
    A[i] += new
    k -= new

if k:
    for i, a in enumerate(A):
        if k <= 0:
            break
        new = min(100-a, k)
        A[i] += new
        k -= new

ans = sum(a//10 for a in A)
print(ans)


n, k = [int(i) for i in input().split()]
skills = [int(i) for i in input().split()]
def fornextlvl(x):
    return 10*(1+((x-1)//10))-x
left = sorted([(fornextlvl(skills[i]), i) for i in range(n)])
left.reverse()

while k > 0 and len(left):
    w = left.pop()
    if w[0] > k: break
    k -= w[0]
    skills[w[1]] += w[0]
# Every skill must be a multiple of 10 by now 

for i in range(n):
    t = min(k, (100-skills[i]))
    skills[i] += t
    k -= t
    if k == 0: break

print(sum([i//10 for i in skills]))

n, k = list(map(int, input().split(' ')[:2]))
a = list(map(int, input().split(' ')[:n]))
b = [0 for i in range(101)]

rating = 0

for i in a:
    b[i]+=1
    rating += i // 10

for last_dig in range(9, 0, -1):
    for first_dig in range(10):
        v = first_dig * 10 + last_dig
        need_for_one = 10 - last_dig
        can_use = min(b[v], k // need_for_one)
        k -= can_use * need_for_one
        b[v] -= can_use
        b[(first_dig + 1) * 10] += can_use
        rating += can_use

z = k // 10

for first_dig in range(10):
    v = first_dig * 10
    can_use = min(z, b[v])
    b[first_dig * 10] -= can_use
    b[(first_dig + 1)* 10] += can_use
    z -= can_use
    rating += can_use

print(rating)


#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import time


(n, k) = (int(i) for i in input().split())
A      = [int(i) for i in input().split()]

start = time.time()
A     = sorted(A, key = lambda x: -divmod(x, 10)[1])
B     = [divmod(i, 10)[1] for i in A]

i = 0

while(k > 0 and i < len(A)):
    if B[i] == 0:
        break

    if k+B[i]-10 > 0:
        A[i] += 10 - B[i]
        k    -= 10 - B[i]
    else:
        A[i] += k
        k = 0
    i += 1

if k > 0:
    for i in range(len(A)):
        if k > 100 - A[i]:
            k    -= 100 - A[i]
            A[i]  = 100
        else:
            A[i] += k
            k = 0
            break

ans = sum([divmod(i, 10)[0] for i in A])
print(ans)
finish = time.time()
#print(finish - start)


__author__ = 'User'
n, k = list(map(int, input().split()))
arr = list(map(int, input().split()))
mx = [0] * n
score = 0
for i in range(n):
    if arr[i] != 100:
        mx[i] = (10 - arr[i] % 10, i)
    else:
        mx[i] = (-1, i)
    score += arr[i] // 10
mx.sort()
i = 0
#print(mx, k)
#print(score)
while i < n and k >= mx[i][0]:
    if mx[i][0] != -1:
        k -= mx[i][0]
        arr[mx[i][1]] += mx[i][0]
        score += 1
    i += 1
#print(arr, k)
#print(score)
if i == n:
    i = 0
    k -= k % 10
    while k >= 10 and i < n:
        if arr[i] != 100:
            d = 100 - arr[i]
            if k >= d:
                k -= d
                #arr[i] += d
                #print("d", d)
                score += d // 10
            else:
                #arr[i] += k
                score += k // 10
                k = 0
        i += 1
print(score)
#print(arr)







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

arr = list()
for i in range(n):
    arr.append(((10 - a[i] + (a[i] // 10 * 10)) % 10, a[i]))
arr.sort()

ans = 0
for i in range(n):
    if arr[i][1] >= 100 or k - arr[i][0] < 0:
        ans += arr[i][1] // 10
        continue
    k -= arr[i][0]
    ans += (arr[i][1] + arr[i][0]) // 10

t = 10 * n - ans
ans += min(k // 10, t)
print(ans)

n, k = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
assert len(l) == n
assert all(0 <= x <= 100 for x in l)
f = [10-l[i]%10 for i in range(n) if l[i]%10]
f.sort()
cur = sum(x // 10 for x in l)
for x in f:
    if k >= x:
        cur += 1
        k -= x
print(min(cur + k // 10, 10 * n))
#print(cur + k // 10)


from sys import stdin
input = stdin.readline
n, k = list(map(int, input().split()))
l = list(map(int, input().split()))
skills = 0
remain = 0
for i in range(n):
    skills += l[i] // 10
    a = round(l[i], -1)
    if a < l[i]:
        a += 10
    if a < 100:
        remain += (100-a)//10
    if l[i] >= 100:
        l[i] = 0
        continue
    b = a - l[i]
    l[i] = b
spent = 0
l.sort()

for i in range(len(l)):
    if spent + l[i] <= k and l[i] != 0:
        skills += 1
        spent += l[i]


skills += min(remain, (k - spent) // 10)
print(skills)


n, k = list(map(int, input().split()))
sum = 0
arr = list(map(int, input().split()))

for i in range (0, n):
    sum = sum + arr[i] // 10
    temp = arr[i] // 10
    arr[i] =  temp * 10 + 10 - arr[i]
    
arr.sort()

for i in range (0, n):
    if k >= arr[i]:
        k = k - arr[i]
        sum = sum + 1
    else:
        break

sum = sum + k // 10
if sum > 10*n:
    sum = 10 *n
print(sum)
            


def main():
    mode="filee"
    if mode=="file":f=open("test.txt","r")
    #f.readline()
    #input()
    get = lambda :[int(x) for x in (f.readline() if mode=="file" else input()).split()]
    [n,k]=get()
    a=get()
    b=[]
    s=0
    for i in a:
        if i==100:
            s+=10
            continue
        b.append([i%10,i])
    b.sort()
    b.reverse()
    if len(b)>0 and k>0:
        for i in b:
            if k>=10-i[0]:
                hold=min(10-i[0],k)
                k-=hold
                i[1]+=hold
                i[0]+=hold
            else:
                k=0
                break
    if k>0 and len(b)>0:
        k-=(k%10)
        for i in b:
            if i[1]==100:
                continue
            if k==0:
                break
            hold=min(100-i[1],k)
            k-=hold
            i[1]+=hold
    for i in b:
        s+=i[1]//10
    print(s)
    if mode=="file":f.close()


def __starting_point():
    main()

__starting_point()

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a.sort(key=lambda x: (x % 10), reverse=True)
i = 0
while (i < n and k > 0 and a[i] % 10 > 0):
    t = max(0, k - 10 + a[i] % 10)
    a[i] = a[i] // 10 * 10 + min(10, a[i] % 10 + k)
    k = t
    i += 1
i = 0
while (i < n and k > 0):
    t = 100 - a[i]
    a[i] += min(k, t)
    k = max(0, k - t)
    i += 1
ans = 0
for i in a:
    ans += i // 10
print(ans)

n, k = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
assert len(l) == n
assert all(0 <= x <= 100 for x in l)
f = [10-l[i]%10 for i in range(n) if l[i]%10]
f.sort()
cur = sum(x // 10 for x in l)
for x in f:
    if k >= x:
        cur += 1
        k -= x
print(min(cur + k // 10, 10 * n))
#print(cur + k // 10)


n, m = list(map(int, input().split()))
a = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += a[i] // 10
    a[i] %= 10
a.sort()
a = a[::-1]
i = 0
while i != n and a[i] != 0 and m > 0:
    c = 10 - a[i]
    if m >= c:
        m -= c
        ans += 1
    else:
        m = 0
    i += 1
ans += m // 10
if ans < 10 * n:
    print(ans)
else:
    print(10 * n)


from copy import deepcopy
n, k = map(int, input().split())
l = list(map(int, input().split()))
k1 = deepcopy(l)
ans = 0
v = 0
l = deepcopy(k1)
for i in range(n):
    l[i] = [l[i], i]
for i in range(n):
    if l[i][0] == 100:
        l[i][0] = -1
        k1[i] = -1
    else:
        l[i][0] %= 10
cur = 10**9
l.sort(reverse = True)
for i in range(n):
    if l[i][0] >= 0:
        cur = 10 - (l[i][0] % 10)
        if k < cur:
            break
        else:
            k -= cur
            k1[l[i][1]] += cur
g = 0
for i in range(n):
    if k1[i] >= 0:
        g += 10 - k1[i] // 10

for i in range(n):
    if k1[i] >= 0:
        ans += k1[i] // 10
    else:
        ans += 10
    
print(ans + min(g, k // 10))

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

def f(a):
	return (a/10 + 1 - a/10.0)

x = sorted(x)
x = sorted(x,key = lambda a: (int(a/10) + 1 - a/10.0))
improved,i,flag = 0,0,0

while k>0:
	if i==n or x[i]==100:
		break
	if (int(x[i]/10) + 1 - x[i]/10.0)*10 > k:
		x[i]+=k
		k=0
		break
	k -= (int(x[i]/10) + 1 - x[i]/10.0)*10
	x[i] += (int(x[i]/10) + 1 - x[i]/10.0)*10
	i+=1
i=0
while k>0:
	if i==n:
		break
	if x[i]+k <= 100:
		x[i]+=k
		k=0
		break
	k-=100-x[i]
	x[i]=100
	i+=1
for i in range(0,n):
	improved+=int(x[i]/10)
print(improved)


n,k= map(int,input().split(" "))
mas = list(map(int,input().split(" ")))
submas= [10-i%10 if i<100 else 11 for i in mas]
summ=0
for i in mas:
    summ+=i//10
submas.sort()

for i in submas:
    if k>=i and i<=10:
        k-=i
        summ+=1
    else:
        break
if k>=10:
    for i in range(n):
        if mas[i]<100:
            mas[i]=mas[i]+10-mas[i]%10
        if k>=100-mas[i]:
            summ+=(100-mas[i])//10
            k-=(100-mas[i])
        else:
            summ+=k//10
            break
print(summ)

num_skills, improvement = list(map(int, input().split()))
skills = list(map(int, input().split()))
skills.sort(key = lambda skill: 10 - skill % 10)

for i, skill in enumerate(skills):
  if skill == 100:
    continue
  delta = min(improvement, 10 - skill % 10)
  skills[i] += delta
  improvement -= delta
  if improvement == 0:
    break

for i, skill in enumerate(skills):
  delta = min(improvement, 100 - skill)
  skills[i] += delta
  improvement -= delta
  if improvement == 0:
    break

result = 0
for skill in skills:
  result += skill // 10
print(result)


import math as m

def solve():
    n, k = (int(i) for i in input().split())

    ai = [int(i) for i in input().split()]

    cnt = 0

    if(k > 100 * len(ai) - sum(ai)):
        k = 100 * len(ai) - sum(ai)

    for i in range(len(ai)):
        cnt += m.floor(ai[i] / 10)
        ai[i] = ai[i] % 10

    ai.sort(reverse=True)

    for i in range(len(ai)):
        diff = 10- ai[i]
        if diff <= k:
            k -= diff
            cnt += 1

    cnt += m.floor(k / 10)

    return cnt

print(solve())



n, k = (int(x) for x in input().split())
a = [int(x) for x in input().split()]
a.sort(key=lambda x: -(x % 10))
for i in range(n):
	if a[i] % 10 == 0:
		break
	add = min(k, 10 - a[i] % 10)
	a[i] += add
	k -= add
for i in range(n):
	add = min(k, 100 - a[i])
	a[i] += add
	k -= add
print(sum(x // 10 for x in a))


inp = input().split()
n = int(inp[0])
k = int(inp[1])
a = input().split()
b = []
x = 0
temp = []

for i in a:
    temp = []
    x = int(i)
    if x == 100:
        temp.append(0)
        temp.append(x)
    else:
        temp.append(10 - x % 10)
        temp.append(x)
    b.append(temp)
#print(b)
b.sort()
#print(b)
j = 0
ss = 0
c = []
for t in b:
    if t[0] == 0:
        pass
    elif (t[0] <= k) and (k != 0) :
        k -= t[0]
        t[1] += t[0]
        t[0] = 0
    c.append(t[1] // 10)
c.sort()
j = 0
k = k // 10
#print(c, k)
while j < n:
    #print(c[j], k)
    if ((10 - c[j]) <= k):
        k -= (10 - c[j])
        c[j] = 10
    else:
        c[j] += k
        k = 0
    ss += c[j]
    j += 1
#print(c)
print(ss)