#include <bits/stdc++.h>
using namespace std;
const int N = 1001000;
int n;
long long m;
int c[N], w[N];
long long ans;
bool did[N];
int main() {
  scanf("%d%lld", &n, &m);
  for (int i = 0; i < n; i++) scanf("%d", &c[i]);
  for (int i = 0; i < n; i++) scanf("%d", &w[i]);
  priority_queue<pair<long long, int>, vector<pair<long long, int> >,
                 greater<pair<long long, int> > >
      pq;
  for (int i = 0; i < n; i++) {
    if (c[i] % 100 == 0) continue;
    if (m >= c[i] % 100) {
      pq.push({1ll * w[i] * (100 - c[i] % 100), i});
      m -= c[i] % 100;
    } else {
      if (!pq.empty()) {
        if (pq.top().first <= 1ll * w[i] * (100 - c[i] % 100)) {
          ans += pq.top().first;
          did[pq.top().second] = true;
          pq.pop();
          pq.push({1ll * w[i] * (100 - c[i] % 100), i});
          m = m + 100 - c[i] % 100;
        } else {
          ans += 1ll * w[i] * (100 - c[i] % 100);
          did[i] = true;
          m = m + 100 - c[i] % 100;
        }
      } else {
        ans += 1ll * w[i] * (100 - c[i] % 100);
        did[i] = true;
        m = m + 100 - c[i] % 100;
      }
    }
  }
  printf("%lld\n", ans);
  for (int i = 0; i < n; i++) {
    if (did[i])
      printf("%d 0\n", c[i] / 100 + 1);
    else
      printf("%d %d\n", c[i] / 100, c[i] % 100);
  }
}
