#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 2;
priority_queue<pair<int, int>, vector<pair<int, int> >,
               greater<pair<int, int> > >
    q;
int a[N], b[N], c[N];
long long int total = 0;
vector<pair<int, int> > ans;
int n, m;
int main() {
  ios_base::sync_with_stdio(0);
  cin >> n >> m;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    c[i] = a[i] % 100;
  }
  for (int i = 1; i <= n; i++) {
    cin >> b[i];
  }
  ans.push_back({0, 0});
  int prev = 0;
  for (int i = 1; i <= n; i++) {
    if (c[i] == 0) {
      ans.push_back({a[i] / 100, 0});
      continue;
    }
    if (prev != i) q.push({b[i] * (100 - c[i]), i});
    prev = i;
    if (m >= c[i]) {
      m -= c[i];
      ans.push_back(make_pair(a[i] / 100, c[i]));
    } else {
      pair<int, int> temp = q.top();
      q.pop();
      long long int wei = temp.first;
      int idx = temp.second;
      if (idx == i) {
        ans.push_back(make_pair((a[i] / 100) + 1, 0));
        m += (100 - c[i]);
        total += wei;
      } else {
        ans[idx].first = (a[idx] / 100) + 1;
        ans[idx].second = 0;
        m += 100;
        total += wei;
        i--;
      }
    }
  }
  cout << total << endl;
  for (int i = 1; i <= n; i++)
    cout << ans[i].first << " " << ans[i].second << endl;
}
