#include <bits/stdc++.h>
using namespace std;
int main() {
  int arr[5], i, j, sum = 0;
  vector<tuple<int, int>> v;
  for (i = 0; i < 5; i++) {
    cin >> arr[i];
    if (arr[i] % 10 == 0)
      sum = sum + arr[i];
    else
      v.push_back(make_tuple(arr[i] % 10, arr[i]));
  }
  sort(v.begin(), v.end());
  for (i = 1; i < 5; i++) {
    if (get<1>(v[i]) != 0) {
      sum = sum + get<1>(v[i]) + (10 - get<0>(v[i]));
      cout << get<0>(v[i]) << " " << get<1>(v[i]) << endl;
    }
  }
  cout << sum + get<1>(v[0]);
}
