#include <bits/stdc++.h>
using namespace std;
bool r[100010];
int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> c(n), d(n);
  for (int &x : c) scanf("%d", &x);
  for (int &x : d) scanf("%d", &x);
  long long a = 0;
  set<pair<int, int> > p;
  for (int i = 0; i < n; i++) {
    int t = c[i] % 100;
    if (!t) continue;
    m -= t;
    p.insert({(100 - t) * d[i], i});
    if (m < 0) {
      pair<int, int> b = *p.begin();
      a += b.first;
      r[b.second] = 1;
      p.erase(p.begin());
      m += 100;
    }
  }
  printf("%I64d\n", a);
  for (int i = 0; i < n; i++) {
    printf("%d %d\n", c[i] / 100 + r[i], r[i] ? 0 : c[i] % 100);
  }
}
