#include <bits/stdc++.h>
using namespace std;
const int maxn = (int)3e5 + 1, maxd = 26, mod = (int)1e9 + 7;
int main() {
  int t = 1;
  for (int Case = 1; Case <= t; ++Case) {
    int n;
    long long k;
    static int a[maxn];
    scanf("%d%lld", &n, &k);
    for (int i = 0; i < n; ++i) scanf("%d", a + i);
    const long long INF = (long long)4e18;
    auto calc_cost = [&](int bi, int ai) {
      return bi * (ai - (long long)bi * bi);
    };
    auto calc_diff = [&](int bi, int ai) {
      return bi < ai ? ai - bi * (bi + 1LL) * 3 - 1 : -INF;
    };
    static int b[maxn];
    auto gen = [&](long long lim) {
      for (int i = 0; i < n; ++i) {
        int L = 0, R = a[i];
        while (L < R) {
          int M = (L + R) / 2;
          if (calc_diff(M, a[i]) < lim) {
            R = M;
          } else {
            L = M + 1;
          }
        }
        b[i] = L;
      }
    };
    long long L = -INF, R = INF;
    while (L < R) {
      long long M = L + (R - L + 1) / 2;
      gen(M);
      long long cnt = 0;
      for (int i = 0; i < n; ++i) cnt += b[i];
      if (cnt < k) {
        R = M - 1;
      } else {
        L = M;
      }
    }
    gen(L + 1);
    long long rem = k;
    priority_queue<pair<long long, int> > Q;
    for (int i = 0; i < n; ++i) {
      rem -= b[i];
      if (b[i] < a[i]) Q.push(make_pair(calc_diff(b[i], a[i]), i));
    }
    for (; rem > 0; --rem) {
      int i = Q.top().second;
      Q.pop();
      if ((++b[i]) < a[i]) Q.push(make_pair(calc_diff(b[i], a[i]), i));
    }
    for (int i = 0; i < n; ++i) printf("%d%c", b[i], " \n"[i == n - 1]);
  }
  return 0;
}
