#include <bits/stdc++.h>
using namespace std;
int n, m, a[100005], b[100005], c[100005];
bool pan[100005];
long long ans;
struct node {
  int id;
  bool operator<(node x) const { return c[id] > c[x.id]; }
};
priority_queue<node> q;
int main() {
  int i;
  scanf("%d%d", &n, &m);
  for (i = 1; i <= n; i++) {
    scanf("%d", &a[i]);
  }
  for (i = 1; i <= n; i++) {
    scanf("%d", &b[i]);
    if (a[i] % 100 != 0) {
      c[i] = (100 - a[i] % 100) * b[i];
    }
  }
  for (i = 1; i <= n; i++) {
    if (a[i] % 100 == 0) {
      pan[i] = 1;
      continue;
    }
    q.push({i});
    if (m >= a[i] % 100) {
      m -= a[i] % 100;
    } else {
      m += 100;
      ans += c[q.top().id];
      pan[q.top().id] = 1;
      q.pop();
      m -= a[i] % 100;
    }
  }
  printf("%lld\n", ans);
  for (i = 1; i <= n; i++) {
    if (pan[i] == 1) {
      printf("%d %d\n", (a[i] + 99) / 100, 0);
    } else {
      printf("%d %d\n", a[i] / 100, a[i] % 100);
    }
  }
  return 0;
}
