#include <bits/stdc++.h>
using namespace std;
set<pair<int, int> > S;
int c[120000], w[120000];
bool b[120000];
int i, m, n;
long long s;
int main() {
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (i = 1; i <= n; i++) scanf("%d", &w[i]);
  for (i = 1; i <= n; i++) {
    if (m >= c[i] % 100) {
      m = m - c[i] % 100;
      if (c[i] % 100) S.insert(make_pair((100 - c[i] % 100) % 100 * w[i], i));
    } else {
      m = m + 100 - c[i] % 100,
      S.insert(make_pair((100 - c[i] % 100) % 100 * w[i], i));
      s = s + (*S.begin()).first, b[(*S.begin()).second] = true,
      S.erase(S.begin());
    }
  }
  printf("%I64d\n", s);
  for (i = 1; i <= n; i++)
    if (!b[i])
      printf("%d %d\n", c[i] / 100, c[i] % 100);
    else
      printf("%d %d\n", (c[i] + (100 - c[i] % 100) % 100) / 100, 0);
  return 0;
}
