#include <bits/stdc++.h>
using namespace std;
template <typename G>
struct triple {
  G first, second, T;
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long n, k;
  cin >> n >> k;
  vector<triple<long long> > v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i].first;
    v[i].second = i;
  }
  sort(v.begin(), v.end(), [](triple<long long> x, triple<long long> y) {
    return x.first < y.first;
  });
  auto val = [&](long long x, bool final) {
    vector<int> equal;
    long long temp = 0;
    for (int i = 0; i < n; i++) {
      long long l = 1, r = v[i].first, ans = 0;
      while (l <= r) {
        long long mid = (l + r) >> 1;
        if (v[i].first - 3 * mid * mid + 3 * mid - 1 >= x) {
          ans = mid;
          l = mid + 1;
        } else
          r = mid - 1;
      }
      v[i].T = ans;
      temp += v[i].T;
      if (final && v[i].first - 3 * ans * ans + 3 * ans - 1 == x)
        equal.push_back(i);
    }
    if (final && temp > k) {
      sort(equal.begin(), equal.end(), [&](int a, int b) {
        return v[a].first - 3 * v[a].T * v[a].T + 3 * v[a].T - 1 >
               v[b].first - 3 * v[b].T * v[b].T + 3 * v[b].T - 1;
      });
      while (!equal.empty() && temp > k) {
        --temp;
        --v[equal.back()].T;
        equal.pop_back();
      }
    }
    return temp;
  };
  long long mx = v.back().first;
  long long l = -3.0 * mx * mx + 4 * mx - 1, r = mx - 1, ans = l;
  while (l <= r) {
    long long mid = (l + r) >> 1;
    if (val(mid, false) >= k) {
      ans = mid;
      l = mid + 1;
    } else
      r = mid - 1;
  }
  val(ans, true);
  sort(v.begin(), v.end(), [](triple<long long> x, triple<long long> y) {
    return x.second < y.second;
  });
  for (int i = 0; i < n; i++) cout << v[i].T << " \n"[i == n - 1];
  return 0;
}
