#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) { return b == 0 ? a : gcd(b, a % b); }
const int MAXN = 5000;
int n, shave;
int cost[MAXN], have[MAXN + 1], use[MAXN], pay[MAXN];
void run() {
  scanf("%d%d", &n, &shave);
  for (int i = (0); i < (n); ++i) scanf("%d", &cost[i]);
  have[0] = shave;
  for (int i = (0); i < (n); ++i) {
    if (cost[i] < 10 || i == n - 1) {
      use[i] = min(have[i], cost[i] / 2);
    } else {
      use[i] = min(have[i], cost[i] % 10);
    }
    pay[i] = cost[i] - use[i];
    have[i + 1] = have[i] - use[i] + pay[i] / 10;
  }
  for (int step = 10; step >= 1; --step) {
    int bound = INT_MAX;
    for (int i = n - 1; i >= 0; --i) {
      int pen = i == n - 1 ? 0 : 1;
      if (have[i] - use[i] >= step && bound >= step + pen && pay[i] % 10 == 0 &&
          2 * (use[i] + step) <= cost[i]) {
        int cur = min(min((have[i] - use[i]) / step,
                          bound == INT_MAX ? bound : bound / (step + pen)),
                      (cost[i] - 2 * use[i]) / (2 * step));
        use[i] += cur * step;
        bound -= cur * (step + pen);
      }
      bound = min(bound, have[i] - use[i]);
    }
    for (int i = (0); i < (n); ++i)
      pay[i] = cost[i] - use[i], have[i + 1] = have[i] - use[i] + pay[i] / 10;
  }
  int ret = 0;
  for (int i = (0); i < (n); ++i) ret += pay[i];
  printf("%d\n", ret);
  for (int i = (0); i < (n); ++i) {
    if (i != 0) printf(" ");
    printf("%d", use[i]);
  }
  puts("");
}
int main() {
  run();
  return 0;
}
