#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
long long ans;
int n, m, c[N], w[N], v[N];
bool pay[N];
struct node {
  int id;
  bool operator<(node x) const { return v[id] > v[x.id]; }
};
priority_queue<node> q;
inline int read() {
  int x = 0, f = 1;
  char ch = getchar();
  while (!isdigit(ch)) {
    if (ch == '-') f = -1;
    ch = getchar();
  }
  while (isdigit(ch)) {
    x = x * 10 + (ch ^ 48);
    ch = getchar();
  }
  return x * f;
}
int main() {
  n = read();
  m = read();
  for (int i = 1; i <= n; i++) c[i] = read();
  for (int i = 1; i <= n; i++) w[i] = read();
  for (int i = 1; i <= n; i++)
    if (c[i] % 100) v[i] = (100 - (c[i] % 100)) * w[i];
  for (int i = 1; i <= n; i++) {
    if (c[i] % 100 == 0) {
      pay[i] = true;
      continue;
    }
    q.push({i});
    if (m >= c[i] % 100)
      m -= c[i] % 100;
    else {
      if (m < c[i] % 100)
        m += 100, ans += v[q.top().id], pay[q.top().id] = true, q.pop();
      m -= c[i] % 100;
    }
  }
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++) {
    if (pay[i])
      printf("%d %d\n", (c[i] + 99) / 100, 0);
    else
      printf("%d %d\n", c[i] / 100, c[i] % 100);
  }
  return 0;
}
