#include <bits/stdc++.h>
using namespace std;
long long c[100005], w[100005], n, k, arr[100005];
bool a[100005];
pair<long long, long long> tree[4 * 100005];
void build(long long node, long long l, long long r) {
  if (l == r)
    tree[node] = make_pair(arr[l], l);
  else {
    long long mid = (l + r) / 2;
    build(node * 2, l, mid);
    build(node * 2 + 1, mid + 1, r);
    tree[node] = ((tree[node * 2].first < tree[node * 2 + 1].first)
                      ? tree[node * 2]
                      : tree[node * 2 + 1]);
  }
}
pair<long long, long long> get(long long node, long long tl, long long tr,
                               long long l, long long r) {
  if (l > r) return make_pair(10000007 + 5, 0);
  if (l == tl && r == tr) return tree[node];
  long long mid = (tl + tr) / 2;
  pair<long long, long long> t1, t2;
  t1 = get(node * 2, tl, mid, l, min(r, mid));
  t2 = get(node * 2 + 1, mid + 1, tr, max(l, mid + 1), r);
  return (t1.first < t2.first) ? t1 : t2;
}
void update(long long node, long long l, long long r, long long pos,
            long long val) {
  if (l == r)
    tree[node] = make_pair(val, l);
  else {
    long long mid = (l + r) / 2;
    if (pos <= mid)
      update(node * 2, l, mid, pos, val);
    else
      update(node * 2 + 1, mid + 1, r, pos, val);
    tree[node] = ((tree[node * 2].first < tree[node * 2 + 1].first)
                      ? tree[node * 2]
                      : tree[node * 2 + 1]);
  }
}
int main() {
  int i, j;
  scanf("%I64d", &n);
  scanf("%I64d", &k);
  for (i = 0; i < n; i++) {
    scanf("%I64d", &c[i]);
  }
  for (i = 0; i < n; i++) {
    scanf("%I64d", &w[i]);
    arr[i] = w[i] * (100 - c[i] % 100);
    if (c[i] % 100 == 0) arr[i] = 10000007;
  }
  build(1LL, 0LL, n - 1);
  long long ans = 0;
  for (i = 0; i < n; i++) {
    if (c[i] % 100 <= k) {
      a[i] = true;
      k -= c[i] % 100;
    } else {
      pair<long long, long long> p = get(1LL, 0LL, n - 1, 0LL, i);
      ans += p.first;
      update(1LL, 0LL, n - 1, p.second, 10000007);
      if (p.second < i) {
        k += 100;
        a[p.second] = false;
        a[i] = true;
        k -= c[i] % 100;
      } else
        k += 100 - c[i] % 100;
    }
  }
  printf("%I64d\n", ans);
  for (i = 0; i < n; i++) {
    if (a[i])
      printf("%I64d %I64d\n", c[i] / 100, c[i] % 100);
    else
      printf("%I64d %I64d\n", c[i] / 100 + 1LL, 0LL);
  }
  return 0;
}
