import sys

from fractions import gcd

from itertools import groupby as gb

from itertools import permutations as perm

from collections import Counter as C

from collections import defaultdict as dd

sys.setrecursionlimit(10**5)



l = [i for i in range(5)]

p = [int(eval(input())) for _ in range(5)]



res = 10**100

for ll in perm(l):

    now = 0

    for ii,i in enumerate(ll):

        now += p[i]

        if now % 10 != 0 and ii!=4:

            now //= 10

            now += 1

            now *= 10

    res = min(res, now)

print(res)

lst = []

for i in range(5):

  n = int(eval(input()))

  lst.append([(n - 1) % 10, n])

lst = sorted(lst)



res = 0

for i in range(5):

  if i == 0:

    res += lst[i][1]

  else:

    res += (lst[i][1] + 9) // 10 * 10

print(res)

import sys
from fractions import gcd
from itertools import groupby as gb
from itertools import permutations as perm
from collections import Counter as C
from collections import defaultdict as dd

sys.setrecursionlimit(10**5)
l = [i for i in range(5)]
p = [int(eval(input())) for _ in range(5)]
res = 10**100
for ll in perm(l):
    now = 0
    for ii, i in enumerate(ll):
        now += p[i]
        if now % 10 != 0 and ii != 4:
            now //= 10
            now += 1
            now *= 10
    res = min(res, now)
print(res)

lst = []
for i in range(5):
    n = int(eval(input()))
    lst.append([(n - 1) % 10, n])
lst = sorted(lst)
res = 0
for i in range(5):
    if i == 0:
        res += lst[i][1]
    else:
        res += (lst[i][1] + 9) // 10 * 10
print(res)

-import sys -from fractions import gcd -from itertools import groupby as gb -from itertools import permutations as perm -from collections import Counter as C -from collections import defaultdict as dd - -sys.setrecursionlimit(10**5) -l = [i for i in range(5)] -p = [int(eval(input())) for _ in range(5)] -res = 10**100 -for ll in perm(l): -    now = 0 -    for ii, i in enumerate(ll): -        now += p[i] -        if now % 10 != 0 and ii != 4: -            now //= 10 -            now += 1 -            now *= 10 -    res = min(res, now) +lst = [] +for i in range(5): +    n = int(eval(input())) +    lst.append([(n - 1) % 10, n]) +lst = sorted(lst) +res = 0 +for i in range(5): +    if i == 0: +        res += lst[i][1] +    else: +        res += (lst[i][1] + 9) // 10 * 10