#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
template <class T>
inline void amin(T &x, const T &y) {
  if (y < x) x = y;
}
template <class T>
inline void amax(T &x, const T &y) {
  if (x < y) x = y;
}
template <class Iter>
void rprintf(const char *fmt, Iter begin, Iter end) {
  for (bool sp = 0; begin != end; ++begin) {
    if (sp)
      putchar(' ');
    else
      sp = true;
    printf(fmt, *begin);
  }
  putchar('\n');
}
int N;
long long K;
long long A[100011];
long long X[100011];
long long B[100011];
void MAIN() {
  scanf("%d%lld", &N, &K);
  for (int i = 0, i_len = (N); i < i_len; ++i) scanf("%lld", A + i);
  for (int i = 0, i_len = (N); i < i_len; ++i) {
    long long hint = sqrt(A[i] / 3.0);
    X[i] = hint;
    long long best = hint * (A[i] - hint * hint);
    long long x = hint - 1;
    while (x >= 0) {
      long long tmp = x * (A[i] - x * x);
      if (best < tmp) {
        X[i] = x;
        best = tmp;
        x--;
      } else {
        break;
      }
    }
    x = hint + 1;
    while (x <= A[i]) {
      long long tmp = x * (A[i] - x * x);
      if (best < tmp) {
        X[i] = x;
        best = tmp;
        x++;
      } else {
        break;
      }
    }
  }
  long long sum = 0;
  for (int i = 0, i_len = (N); i < i_len; ++i) sum += X[i];
  if (sum == K) {
    rprintf("%lld", X, X + N);
  } else if (sum < K) {
    long long cnt = 0;
    auto ok = [&](long long MID) {
      cnt = 0;
      for (int i = 0, i_len = (N); i < i_len; ++i) {
        long long lo = X[i], hi = A[i] + 1;
        while (hi - lo > 1) {
          long long c = (lo + hi) / 2;
          long long diff = A[i] - 3 * c * c + 3 * c - 1;
          assert(diff <= 0);
          if (MID <= diff) {
            lo = c;
          } else {
            hi = c;
          }
        }
        B[i] = lo;
        cnt += lo;
      }
      return K <= cnt;
    };
    long long lo = -1, hi = 1;
    while (!ok(lo)) {
      hi = lo;
      lo += lo;
    }
    while (hi - lo > 1) {
      long long mid = (lo + hi) / 2;
      (ok(mid) ? lo : hi) = mid;
    }
    ok(lo);
    for (int i = 0, i_len = (N); i < i_len; ++i)
      if (cnt > K) {
        long long c = B[i];
        long long diff = A[i] - 3 * c * c + 3 * c - 1;
        if (diff == lo) {
          B[i]--;
          cnt--;
        }
      }
    rprintf("%lld", B, B + N);
  } else {
    long long cnt = 0;
    auto ok = [&](long long MID) {
      cnt = 0;
      for (int i = 0, i_len = (N); i < i_len; ++i) {
        long long lo = -1, hi = X[i];
        while (hi - lo > 1) {
          long long c = (lo + hi) / 2;
          long long diff = A[i] - 3 * c * c - 3 * c - 1;
          assert(diff >= 0);
          if (diff <= MID) {
            hi = c;
          } else {
            lo = c;
          }
        }
        B[i] = hi;
        cnt += hi;
      }
      return K >= cnt;
    };
    long long lo = -1, hi = 1;
    while (!ok(hi)) {
      lo = hi;
      hi += hi;
    }
    while (hi - lo > 1) {
      long long mid = (lo + hi) / 2;
      (ok(mid) ? hi : lo) = mid;
    }
    ok(hi);
    for (int i = 0, i_len = (N); i < i_len; ++i)
      if (cnt < K) {
        long long c = B[i];
        long long diff = A[i] - 3 * c * c - 3 * c - 1;
        if (diff == lo) {
          B[i]++;
          cnt++;
        }
      }
    rprintf("%lld", B, B + N);
  }
}
int main() {
  int TC = 1;
  for (int tc = 0, tc_len = (TC); tc < tc_len; ++tc) MAIN();
  return 0;
}
