from math import ceil

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

max_wait = 0

max_idx = 0

for i in range(5):

    cur = ceil(ord[i] / 10) * 10 - ord[i]

    if max_wait < cur:

        max_wait = cur

        max_idx = i

ans = 0

for i in range(5):

    if i != max_idx:

        ans += ceil(ord[i] / 10) * 10

ans += ord[max_idx]

print(ans)
ant = [int(eval(input())) for _ in range(5)]



minidx = 0

minval = 124

i = 0

for a in ant:

    while 10 < a:

        a %= 10

        if a == 0:

            a = 10

    if a < minval:

        minidx = i

        minval = a

    i += 1



ans = 0

for i in range(5):

    if i == minidx:

        continue

    fact = 10

    while fact - ant[i] < 0:

        fact += 10

    ans += fact



ans += ant[minidx]

print(ans)
from math import ceil

ord = [int(eval(input())) for _ in range(5)]
max_wait = 0
max_idx = 0
for i in range(5):
    cur = ceil(ord[i] / 10) * 10 - ord[i]
    if max_wait < cur:
        max_wait = cur
        max_idx = i
ans = 0
for i in range(5):
    if i != max_idx:
        ans += ceil(ord[i] / 10) * 10
ans += ord[max_idx]
print(ans)

ant = [int(eval(input())) for _ in range(5)]
minidx = 0
minval = 124
i = 0
for a in ant:
    while 10 < a:
        a %= 10
        if a == 0:
            a = 10
    if a < minval:
        minidx = i
        minval = a
    i += 1
ans = 0
for i in range(5):
    if i == minidx:
        continue
    fact = 10
    while fact - ant[i] < 0:
        fact += 10
    ans += fact
ans += ant[minidx]
print(ans)

-from math import ceil - -ord = [int(eval(input())) for _ in range(5)] -max_wait = 0 -max_idx = 0 -for i in range(5): -    cur = ceil(ord[i] / 10) * 10 - ord[i] -    if max_wait < cur: -        max_wait = cur -        max_idx = i +ant = [int(eval(input())) for _ in range(5)] +minidx = 0 +minval = 124 +i = 0 +for a in ant: +    while 10 < a: +        a %= 10 +        if a == 0: +            a = 10 +    if a < minval: +        minidx = i +        minval = a +    i += 1 -    if i != max_idx: -        ans += ceil(ord[i] / 10) * 10 -ans += ord[max_idx] +    if i == minidx: +        continue +    fact = 10 +    while fact - ant[i] < 0: +        fact += 10 +    ans += fact +ans += ant[minidx]