#include <bits/stdc++.h>
using namespace std;
int n, m;
int c[100005], w[100005];
int ans1[100005], ans2[100005];
struct node {
  int x, y;
  node() { ; }
  node(int _x, int _y) {
    x = _x;
    y = _y;
  }
  friend bool operator<(const node &aa, const node &bb) { return aa.y > bb.y; }
};
priority_queue<node> q;
int main() {
  scanf("%d%d", &n, &m);
  for (int i = 1; i <= n; i++) scanf("%d", &c[i]);
  for (int i = 1; i <= n; i++) scanf("%d", &w[i]);
  long long ans = 0;
  for (int i = 1; i <= n; i++) {
    ans1[i] = c[i] / 100;
    c[i] %= 100;
    if (!c[i]) continue;
    if (m >= c[i]) {
      m -= c[i];
      ans2[i] = c[i];
      q.push(node(i, (100 - c[i]) * w[i]));
    } else {
      if (!q.empty()) {
        node tmp = q.top();
        if (tmp.y < (100 - c[i]) * w[i]) {
          m += 100 - c[i];
          ans2[i] = c[i];
          ans1[tmp.x]++;
          ans2[tmp.x] = 0;
          ans += tmp.y;
          q.pop();
          q.push(node(i, (100 - c[i]) * w[i]));
        } else
          ans += (100 - c[i]) * w[i], m += 100 - c[i], ans1[i]++;
      } else
        ans += (100 - c[i]) * w[i], m += 100 - c[i], ans1[i]++;
    }
  }
  printf("%I64d\n", ans);
  for (int i = 1; i <= n; i++) {
    printf("%d %d\n", ans1[i], ans2[i]);
  }
  return 0;
}
