#include <bits/stdc++.h>
using namespace std;
const int P = 1e9 + 7;
long long gcd(long long a, long long b) { return b ? gcd(b, a % b) : a; }
long long qpow(long long a, long long n) {
  long long r = 1 % P;
  for (a %= P; n; a = a * a % P, n >>= 1)
    if (n & 1) r = r * a % P;
  return r;
}
void exgcd(long long a, long long b, long long &d, long long &first,
           long long &second) {
  b                          ? exgcd(b, a % b, d, second, first),
      second -= a / b *first : first = 1, second = 0, d = a;
}
long long inv(long long first) {
  return first <= 1 ? 1 : inv(P % first) * (P - P / first) % P;
}
const int N = 4e5 + 10, INF = 0x3f3f3f3f;
int n, m;
int c[N], w[N];
int vis[N];
int main() {
  std::ios::sync_with_stdio(false);
  ;
  cin >> n >> m;
  for (int i = 1; i <= n; ++i) cin >> c[i];
  for (int i = 1; i <= n; ++i) cin >> w[i];
  priority_queue<pair<int, int>, vector<pair<int, int> >,
                 greater<pair<int, int> > >
      q;
  long long ans = 0;
  for (int i = 1; i <= n; ++i)
    if (c[i] % 100) {
      q.push(pair<int, int>((100 - c[i] % 100) * w[i], i));
      if (m < c[i] % 100) {
        vis[q.top().second] = 1;
        m += 100;
        ans += q.top().first;
        q.pop();
      }
      m -= c[i] % 100;
    }
  cout << ans << '\n';
  for (int i = 1; i <= n; ++i) {
    if (vis[i])
      cout << c[i] / 100 + 1 << ' ' << 0 << '\n';
    else
      cout << c[i] / 100 << ' ' << c[i] % 100 << '\n';
  }
}
