#include <bits/stdc++.h>
using namespace std;
struct Number {
  int n;
  int diff;
};
bool cmp(Number n1, Number n2) { return n1.diff < n2.diff; }
int main() {
  int n = 5;
  Number arr[n];
  for (int i = 0; i < n; i++) {
    cin >> arr[i].n;
    if (arr[i].n % 10 == 0) {
      arr[i].diff = 0;
      continue;
    }
    int ps = ((arr[i].n) / 10) * 10 + 10;
    arr[i].diff = ps - arr[i].n;
  }
  sort(arr, arr + n, cmp);
  for (int i = 0; i < n; i++) cout << arr[i].n << " " << arr[i].diff << "\n";
  int ans = 0;
  for (int i = 0; i < n - 1; i++) {
    ans += arr[i].n;
    ans += arr[i].diff;
  }
  ans += arr[n - 1].n;
  cout << ans;
}
