#include <bits/stdc++.h>
using namespace std;
const int Maxn = 1000010, inf = 0x3f3f3f;
int c[Maxn], w[Maxn], book[Maxn], v[Maxn];
int n, m;
long long ans;
struct date {
  int id;
  bool operator<(date x) const { return v[id] > v[x.id]; }
};
priority_queue<date> 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]);
    if (c[i] % 100 == 0) continue;
    v[i] = (100 - (c[i] % 100)) * w[i];
  }
  for (int i = 1; i <= n; i++) {
    if (c[i] % 100 == 0) continue;
    q.push({i});
    if (m >= c[i] % 100) {
      m -= c[i] % 100;
    } else {
      m += 100;
      int temp = q.top().id;
      ans += v[temp], book[temp] = 1;
      q.pop();
      m -= c[i] % 100;
    }
  }
  printf("%lld\n", ans);
  for (int i = 1; i <= n; i++) {
    if (book[i]) {
      printf("%d %d\n", c[i] / 100 + 1, 0);
    } else {
      printf("%d %d\n", c[i] / 100, c[i] % 100);
    }
  }
  return 0;
}
