#include <bits/stdc++.h>
using namespace std;
int c[100001];
int w[100001];
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> w[i];
  }
  int ch = m;
  set<pair<long long, int> > s;
  long long cnt = 0;
  for (int i = 0; i < n; i++) {
    if (ch < c[i] % 100) {
      long long mn = (100 - c[i] % 100) * w[i];
      if (s.begin() != s.end() && s.begin()->first < mn) {
        cnt += s.begin()->first;
        ch += 100;
        ch -= c[i] % 100;
        s.erase(s.begin());
        s.insert(make_pair((100 - c[i] % 100) * w[i], i));
      } else {
        ch += 100 - c[i] % 100;
        cnt += mn;
      }
    } else {
      if (c[i] % 100 != 0) {
        s.insert(make_pair((100 - c[i] % 100) * w[i], i));
        ch -= c[i] % 100;
      }
    }
  }
  cout << cnt << endl;
  vector<bool> p(n, 0);
  for (set<pair<long long, int> >::iterator it = s.begin(); it != s.end();
       it++) {
    p[it->second] = 1;
  }
  for (int i = 0; i < n; i++) {
    if (p[i]) {
      cout << c[i] / 100 << " " << c[i] % 100 << endl;
    } else {
      cout << (c[i] + 99) / 100 << " 0" << endl;
    }
  }
  return 0;
}
