#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     gets(ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=1;j<=(len);j++)
     {
          m=ch[j-1]-96;
          l=a[m];
          sum+=j*l;

     }
     for(j=len+1;j<=len+k;j++)
     {
          sum+=j*max;
     }
     printf("%d",sum);
}


#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     scanf("%s\n",ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=0;j<(len+k);j++)
     {
          m=ch[j]-96;
          l=a[m];
          if(j<len-1)
          {
          sum+=(j+1)*l;
          }
          else if(j==len-1)
          sum+=(len+k)*l;
          else
          {
               sum+=max*(j+1);
          }
     }
     printf("%d",sum);
}


#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     scanf("%s\n",ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=1;j<=(len+k);j++)
     {
          m=ch[j-1]-96;
          l=a[m];
          if(j<len)
          {
          sum+=(j)*l;
          }
          else if(j==len)
          sum+=(len+k)*l;
          else
          {
               sum+=max*(j-1);
          }
     }
     printf("%d",sum);
}


#include <stdio.h>
#include <string.h>

int main(void)
{
    int ara[30], k, i, max=0, l, ans=0;
    char str[1111];

    scanf("%s", str);
    scanf("%d", &k);
    for(i=1; i<27; i++)
    {
        scanf("%d", &ara[i]);

        if(ara[i]>max) max=ara[i];
    }
    l=strlen(str);

    for(i=1; i<=l; i++)
    {
        ans+=(i*ara[str[i-1]-'a'+1]);
    }
    for(; i<=(l+k); i++)
    {
        ans+=(max*i);
    }
    printf("%d\n", ans);

    return 0;
}


#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     scanf("%s",ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=1;j<=(len+k);j++)
     {
          if(j<len)
          {
               m=ch[j-1]-96;
          l=a[m];
          sum+=(j)*l;
          }
          else if(j==len)
          {
               m=ch[j-1]-96;
          l=a[m];
          sum+=(len+k)*l;
          }
          else
          {
               sum+=max*(j-1);
          }
     }
     printf("%d",sum);
}


#include <stdio.h>
#include <string.h>
int main()
{
     char ch[1001];
     gets(ch);
     int len=strlen(ch);
     int k;
     printf("\n");
     scanf("%d\n",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0,sum1=0;
     for(j=1;j<=(len);j++)
     {
          m=ch[j-1]-96;
          l=a[m];
          sum+=j*l;

     }
     for(j=len+1;j<=(len+k);j++)
     {
          sum1+=j*max;
     }
     printf("%d",sum+sum1);
}


#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     scanf("%s",ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=1;j<=(len+k);j++)
     {
          if(j<len)
          {
               l=a[ch[j-1]-'a'+1];
          sum+=(j)*l;
          }
          else if(j==len)
          {
               l=[ch[j-1]-'a'+1]
          sum+=(len+k)*l;
          }
          else
          {
               sum+=max*(j-1);
          }
     }
     printf("%d",sum);
}


#include <stdio.h>
#include <string.h>
int main()
{
     char ch[10001],q,w;
     gets(ch);
     int len=strlen(ch);
     int k;
     scanf("%d\n",&k);
     char ch1[len+k];
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          {
          max=a[j];
          q=j+96;
          }
     }
     for(i=0;i<len+k;i++)
     {
          if(i<len-1)
          {
               ch1[i]=ch[i];
          }
          else if(i==len+k)
          {
               ch1[i]=ch[len-1];
          }
          else
          {
               ch1[i]=q;
          }
     }
     int sum=0;
     for(i=0;i<len+k;i++)
     {
          m=ch1[i]-96;
          l=a[m];
          sum+=(l*(i+1));
     }
     printf("%d",sum);
}


#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     scanf("%s",ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=1;j<=(len+k);j++)
     {
          if(j<len)
          {
               l=a[ch[j-1]-'a'+1];
          sum+=(j)*l;
          }
          else if(j==len)
          {
               l=a[ch[j-1]-'a'+1];
          sum+=(len+k)*l;
          }
          else
          {
               sum+=max*(j-1);
          }
     }
     printf("%d",sum);
}


#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     scanf("%s\n",ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=1;j<=(len+k);j++)
     {
          if(j<len)
          {
               m=ch[j-1]-96;
          l=a[m];
          sum+=(j+1)*l;
          }
          else if(j==len)
          {
               m=ch[j-1]-96;
          l=a[m];
          sum+=(len+k)*l;
          }
          else
          {
               sum+=max*(j-1);
          }
     }
     printf("%d",sum);
}


#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     scanf("%s",ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=1;j<=(len);j++)
     {
          m=ch[j-1]-96;
          l=a[m];
          sum+=j*l;

     }
     for(j=len+1;j<=len+k;j++)
     {
          sum+=j*max;
     }
     printf("%d",sum);
}


#include <stdio.h>
#include <string.h>
int main()
{
     char ch[10001],ch1[100000],q,w;
     gets(ch);
     int len=strlen(ch);
     int k;
     printf("\n");
     scanf("%d\n",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          {
          max=a[j];
          q=ch[j];
          }
     }
     for(i=0;i<len+k;i++)
     {
          if(i<len-1)
          {
               ch1[i]=ch[i];
          }
          else if(i==len+k)
          {
               ch1[i]=ch[len-1];
          }
          else
          {
               ch1[i]=q;
          }
     }
     int sum=0;
     for(i=0;i<len+k;i++)
     {
          m=ch1[i]-96;
          l=a[m];
          sum+=(l*(i+1));
     }
     printf("%d",sum);
}


#include <string.h>
#include <stdio.h>
int main()
{
     char ch[1001];
     scanf("%s\n",ch);
     int len=strlen(ch);
     int k;
     scanf("%d",&k);
     int i,j,a[26];
     for(i=1;i<=26;i++)
     {
          scanf("%d",&a[i]);

     }
     int max=0,m,l;
     for(j=1;j<=26;j++)
     {
          if(a[j]>max)
          max=a[j];
     }
     int sum=0;
     for(j=1;j<=(len+k);j++)
     {
          m=ch[j-1]-96;
          l=a[m];
          if(j<len)
          {
          sum+=(j+1)*l;
          }
          else if(j==len)
          sum+=(len+k)*l;
          else
          {
               sum+=max*(j-1);
          }
     }
     printf("%d",sum);
}


#pragma warning(disable:4996)
#include <stdio.h>
#include <malloc.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#define forn(i,n) for (i = 0; i<n; i++)

int lol(const void *x1, const void *x2)
{
	return *(int*)x1 - *(int*)x2;
}

int gcd(int a, int b)
{
	int c;
	while (b)
	{
		c = a % b;
		a = b;
		b = c;
	}
	return a;
}
int main(void)
{
	char ch[1001], c;
	int k, a[26];
	int i = 0, length, max = -1;
	int f = 0;
	do
	{
		scanf("%c", &c);
		if (c != '\n')
			ch[i++] = c;
	} while (c != '\n');
	ch[i] = '\0';
	length = i;
	scanf("%i", &k);
	forn(i, 26)
	{
		scanf("%i", &a[i]);
		if (a[i] > max)
			max = a[i];
	}
	forn(i, length)
		f += a[ch[i] - 'a'] * (i+1);
	forn(i, k)
		f += max * (length + i + 1);
	printf("%i", f);
	return 0;
}


#include <stdio.h>
#include <string.h>

int arr[26];

int main()
{
    int k, i, max = - 1, sum = 0;
	char str[1001];
	scanf("%s %d", str, &k);

	for(i=0; i<26; i++){
        scanf("%d", &arr[i]);
        if(arr[i] > max)
            max = arr[i];
	}

	for(i=0; i<strlen(str); i++)
        sum = sum + arr[str[i]-'a'] * (i + 1);

    for(i=i; i<(strlen(str) + k); i++)
        sum = sum + max * (i + 1);

    printf("%d", sum);

	return 0;
}


#include <stdio.h>
#include <string.h>

int arr[26];

int main()
{
    int k, i, max = - 1, sum = 0, p;
	char str[1001];
	scanf("%s %d", str, &k);

	for(i=0; i<26; i++){
        scanf("%d", &arr[i]);
        if(arr[i] > max)
            max = arr[i];
	}

	for(i=0; i<strlen(str); i++)
        sum = sum + arr[str[i]-'a'] * (i + 1);

    for(p=i; p<(strlen(str) + k); p++)
        sum = sum + max * (p + 1);

    printf("%d", sum);

	return 0;
}


#include <stdio.h>

int main(void) {
    char s[1000];
    scanf("%s",s);
    int b[1000],i=0;
    while(s[i]!=0)
    {
        b[i]=(int)s[i]-97;
        i++;

    }
     int k;
    scanf(" %d",&k);
    int a[26];
    for(int j=0;j<26;j++)
    {
        scanf(" %d",&a[j]);

    }long long sum=0;
    for(int j=0;j<i;j++)
    {
        sum=sum+a[b[j]]*(j+1);
    }
    int max=a[0];
     for(int j=0;j<26;j++)
    {
        if(a[j]>max)
        {
            max=a[j];
        }
     }
    for(int j=i;j<i+k;j++)
    {
        sum=sum+max*(j+1);
    }
    printf("%lld",sum);

	return 0;
}


#include <stdio.h>

int main(void) {
    char s[10000];
    scanf("%s",s);
    int b[10000],i=0;
    while(s[i]!=0)
    {
        b[i]=(int)s[i]-97;
        i++;

    }
     int k;
    scanf(" %d",&k);
    int a[26];
    for(int j=0;j<26;j++)
    {
        scanf(" %d",&a[j]);

    }long long sum=0;
    for(int j=0;j<i;j++)
    {
        sum=sum+a[b[j]]*(j+1);
    }
    if(k>0)
    {
    int max=a[0];
     for(int j=0;j<26;j++)
    {
        if(a[j]>max)
        {
            max=a[j];
        }
     }
    for(int j=i;j<i+k;j++)
    {
        sum=sum+max*(j+1);
    }
    }
    printf("%lld",sum);

	return 0;
}

#include <stdio.h>

int main(void) {
    char s[10000];
    scanf("%s",s);
    int b[10000],i=0;
    while(s[i]!=0)
    {
        b[i]=(int)s[i]-97;
        i++;

    }
     int k;
    scanf(" %d",&k);
    int a[26];
    for(int j=0;j<26;j++)
    {
        scanf(" %d",&a[j]);

    }long long sum=0;
    for(int j=0;j<i;j++)
    {
        sum=sum+a[b[j]]*(j+1);
    }
    if(k>0)
    {
    int max=a[0];
     for(int j=0;j<26;j++)
    {
        if(a[j]>max)
        {
            max=a[j];
        }
     }
    for(int j=i;j<i+k;j++)
    {
        sum=sum+max*(j+1);
    }
    }
    printf("%lld",sum);

	return 0;
}


#include <stdio.h>

int main(void) {
    char s[10000];
    scanf("%s",s);
    int b[10000],i=0;
    while(s[i]!=0)
    {
        b[i]=(int)s[i]-97;
        i++;

    }
     int k;
    scanf(" %d",&k);
    int a[26];
    for(int j=0;j<26;j++)
    {
        scanf(" %d",&a[j]);

    }long long sum=0;
    for(int j=0;j<i;j++)
    {
        sum=sum+a[b[j]]*(j+1);
    }
    if(k>0)
    {
    int max=a[0];
     for(int j=0;j<26;j++)
    {
        if(a[j]>max)
        {
            max=a[j];
        }
     }
    for(int j=i;j<i+k;j++)
    {
        sum=sum+max*(j+1);
    }
    }
    printf("%lld",sum);

	return 0;
}


#include <stdio.h>
#include <string.h>

#define N 1000

int main() {
	static char s[N + 1];
	static int w[26];
	int k, n, i, max, sum;

	scanf("%s%d", s, &k);
	n = strlen(s);
	max = 0;
	for (i = 0; i < 26; i++) {
		scanf("%d", &w[i]);
		if (max < w[i])
			max = w[i];
	}
	sum = 0;
	for (i = 0; i < n; i++)
		sum += w[s[i] - 'a'] * (i + 1);
	for (i = n; i < n + k; i++)
		sum += max * (i + 1);
	printf("%d\n", sum);
	return 0;
}


#include <stdio.h>
#include <string.h>

char s[1005];
int n, k, a[26];

int max(int a, int b){return a > b ? a : b;}

int main(){
	scanf("%s%d", s, &k); n = strlen(s);
	for(int i=0;i<26;i++) scanf("%d", &a[i]);
	int mx = 0; for(int i=0;i<26;i++) mx = max(a[i], mx);
	long long ans = 1LL * mx * (n + 1 + n + k) * k / 2;
	for(int i=0;s[i];i++)
		ans += a[s[i] - 'a'] * (i + 1);
	printf("%d\n", ans);
	return 0;
}


#include <stdio.h>
#include <string.h>

char s[1005];
int n, k, a[26];

int max(int a, int b){return a > b ? a : b;}

int main(){
	scanf("%s%d", s, &k); n = strlen(s);
	for(int i=0;i<26;i++) scanf("%d", &a[i]);
	int mx = 0; for(int i=0;i<26;i++) mx = max(a[i], mx);
	int ans = mx * (n + 1 + n + k) * k / 2;
	for(int i=0;s[i];i++)
		ans += a[s[i] - 'a'] * (i + 1);
	printf("%d\n", ans);
	return 0;
}


#include<stdio.h>
#include<string.h>
int main()
{
    long long int x,i,s=0,k,m=0,n[125],p;
    char a[10005];
    scanf("%s %lld",a,&x);
    for(i=97;i<=122;i++)
    {
         scanf("%lld",&n[i]);
         if(m<n[i]) m=n[i];
    }
    p=strlen(a);
    for(i=1;i<=p;i++)
    {
        k=a[i-1];
        s=s+(i*n[k]);
    }
    for(i=1;i<=x;i++)
        s=s+(p+2)*m;
    printf("%lld",s);
}


#include<stdio.h>
#include<string.h>
int main(){
    char s[1005];int k;
    scanf("%s\n%d",s,&k);
    int w[26],n=strlen(s),m=0,t=0;
    for(int i=0;i<26;i++){
        scanf("%d",&w[i]);
        if(w[i]>m)m=w[i];
    }
    for(int i=0;i<n;i++)
        t+=w[s[i]-'a']*(i+1);
    for(int i=0;i<k;i++) t+=(n+i+1)*m;
    printf("%d",t);
}


#include <stdio.h>
#include <string.h>

int main()
{
    int n, k, i, max=0, a[26], sum=0, l, j;
    char s[1001];
    scanf("%s%d",s,&k);
    l = strlen(s);
    for(i=0; i<26; i++)
    {
        scanf("%d", &a[i]);
        if(max<a[i])
            max=a[i];
    }
    for(i=0; s[i]!='\0'; i++)
    {
        sum += (i+1)*a[s[i]-'a'];
    }
    for(j=i; j<l+k; j++)
        sum += (j+1)*max;
    printf("%d\n", sum);

    return 0;
}


#include<stdio.h>

int main()
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r", stdin);
		freopen("output.txt","w", stdout);
	#endif
	char str[1000];int k,i,j,max=0;int arr[26];int long long unsigned count=0;
	scanf("%s",str);
	scanf("%d",&k);
	for(i=0;i<26;i++)
	{
		scanf("%d",&arr[i]);
		if(arr[i]>max)
			max=arr[i];
	}
	i=1;
	char *ptr=str;
	while (*ptr)
	{
		j=*ptr++-'a';
		count+=(i++*arr[j]);
	}
	for(j=i;j<i+k;j++)
		count+=(j*max);
	printf("%lld",count);

	return 0;
}


#include <stdio.h>
#include <string.h>
int main()
{
    char lol[1001];
    int k,shit[26],a=0,b=0;
    scanf("%s %d" , lol , &k);
    for(int i=0;i<26;i++)
    {
        scanf("%d" ,&shit[i]);
        if(b<shit[i])b=shit[i];
    }
    for(int i=0;i<strlen(lol);i++)
    {
        a=a+(i+1)*(shit[lol[i]-97]);
    }
    for(int i=1;i<=k;i++)
    {
    	a=a+(strlen(lol)+i)*b;
    }
    printf("%d " , a );

    return 0;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n, b[N];
pii a[N];
ll k;
int chk(int x) {
	ll tot = 0;
	REP(i,1,n) tot+=min(a[i].x,x);
	return tot<=k;
}
int main() {
	scanf("%d%lld", &n, &k);
	REP(i,1,n) scanf("%d", &a[i].x),a[i].y=i;
	int l=0,r=1e9,ans;
	while (l<=r) {
		if (chk(mid)) ans=mid,l=mid+1;
		else r=mid-1;
	}
	REP(i,1,n) k-=b[i]=min(a[i].x,ans);
	sort(a+1,a+1+n);
	PER(i,1,n) if (b[a[i].y]<a[i].x&&k) ++b[a[i].y],--k;
	REP(i,1,n) printf("%d ", b[i]);hr;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,a[N],b[N];
ll k;
ll calc(ll a, ll b) {
	return -1+a-3*b-3*b*b;
}
int chk(ll x) {
	ll tot = 0;
	REP(i,1,n) {
		if (-3+12ll*a[i]-12*x<0) throw;
		b[i] = floor(-0.5+sqrt(-3+12ll*a[i]-12*x)/6)+1;
		b[i] = min(b[i], a[i]);
		tot += b[i];
		if (b[i]!=a[i]&&calc(a[i],b[i])>=x) throw;
	}
	return tot;
}
int main() {
	scanf("%d%lld", &n, &k);
	ll l = 1e18, r = -1e18, ans;
	REP(i,1,n) {
		scanf("%d", a+i);
		r = max(r, a[i]-1ll);
		l = min(l, -1+4ll*a[i]-3ll*a[i]*a[i]);
	}
	int ok = 0;
	while (l<=r) {
		if (chk(mid)<=k) ans=mid,r=mid-1,ok=1;
		else l=mid+1;
	}
	if (!ok) throw;
	k -= chk(ans);
	REP(i,1,n) if (k&&a[i]>b[i]&&calc(a[i],b[i])==ans-1) --k,++b[i];
	REP(i,1,n) printf("%d ", b[i]);hr;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,a[N],b[N];
ll k;
ll calc(ll a, ll b) {
	return -1+a-3*b-3*b*b;
}
int chk(ll x) {
	ll tot = 0;
	REP(i,1,n) {
		if (-3+12ll*a[i]-12*x<0) throw;
		b[i] = floor(-0.5+sqrt(-3+12ll*a[i]-12*x)/6)+1;
		b[i] = min(b[i], a[i]);
		tot += b[i];
		if (b[i]!=a[i]&&calc(a[i],b[i])>=x) throw;
	}
	return tot;
}
int main() {
	scanf("%d%lld", &n, &k);
	ll l = 1e18, r = -1e18, ans;
	REP(i,1,n) {
		scanf("%d", a+i);
		r = max(r, a[i]-1);
		l = min(l, -1+4ll*a[i]-3ll*a[i]*a[i]);
	}
	while (l<=r) {
		if (chk(mid)<=k) ans=mid,r=mid-1;
		else l=mid+1;
	}
	k -= chk(ans);
	REP(i,1,n) if (k&&a[i]>b[i]&&calc(a[i],b[i])==ans-1) --k,++b[i];
	REP(i,1,n) printf("%d ", b[i]);hr;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,a[N],b[N];
ll k;
ll calc(ll a, ll b) {
	return -1+a-3*b-3*b*b;
}
int chk(ll x) {
	ll tot = 0;
	REP(i,1,n) {
		if (-3+12ll*a[i]-12*x<0) return 0;
		b[i] = floor(-0.5+sqrt(-3+12ll*a[i]-12*x)/6)+1;
		b[i] = min(b[i], a[i]);
		tot += b[i];
		if (b[i]!=a[i]&&calc(a[i],b[i])>=x) throw;
	}
	return tot;
}
int main() {
	scanf("%d%lld", &n, &k);
	ll l = -1e18, r = 1e18, ans;
	REP(i,1,n) scanf("%d", a+i);
	while (l<=r) {
		if (chk(mid)<=k) ans=mid,r=mid-1;
		else l=mid+1;
	}
	k -= chk(ans);
	REP(i,1,n) if (k&&a[i]>b[i]&&calc(a[i],b[i])==ans-1) --k,++b[i];
	REP(i,1,n) printf("%d ", b[i]);hr;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,a[N],b[N];
ll k;
ll calc(ll a, ll b) {
	return -1+a-3*b-3*b*b;
}
ll chk(ll x) {
	ll tot = 0;
	REP(i,1,n) {
		if (calc(a[i],a[i-1])<=x) {
			tot += b[i] = a[i];
			continue;
		}
		if (-3+12ll*a[i]-12*x<0) throw;
		b[i] = floor(-0.5+sqrt(-3+12ll*a[i]-12*x)/6)+1;
		b[i] = min(b[i], a[i]);
		tot += b[i];
		if (b[i]!=a[i]&&calc(a[i],b[i])>=x) throw;
	}
	return tot;
}
int main() {
	scanf("%d%lld", &n, &k);
	ll l = 1e18, r = -1e18, ans;
	REP(i,1,n) {
		scanf("%d", a+i);
		r = max(r, a[i]-1ll);
		l = min(l, -1+4ll*a[i]-3ll*a[i]*a[i]);
	}
	while (l<=r) {
		if (chk(mid)<=k) ans=mid,r=mid-1;
		else l=mid+1;
	}
	k -= chk(ans);
	REP(i,1,n) if (k&&a[i]>b[i]&&calc(a[i],b[i])==ans-1) --k,++b[i];
	REP(i,1,n) printf("%d ", b[i]);hr;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,a[N],b[N];
ll k;
ll calc(ll a, ll b) {
	return -1+a-3*b-3*b*b;
}
ll chk(ll x) {
	ll tot = 0;
	REP(i,1,n) {
		if (calc(a[i],a[i]-1)>=x) {
			b[i] = a[i];
			tot += b[i];
			continue;
		}
		if (x>=a[i]) {
			b[i] = 0;
			continue;
		}
		double mx = floor(-0.5+sqrt(-3+12ll*a[i]-12*x)/6)+1;
		if (mx>a[i]) mx = a[i];
		b[i] = mx;
		tot += b[i];
		if (b[i]!=a[i]&&calc(a[i],b[i])>=x) throw;
	}
	return tot;
}
int main() {
	scanf("%d%lld", &n, &k);
	ll l = 1e18, r = -1e18, ans;
	REP(i,1,n) {
		scanf("%d", a+i);
		r = max(r, calc(a[i],0));
		l = min(l, calc(a[i],a[i]-1));
	}
	while (l<=r) {
		if (chk(mid)<=k) ans=mid,r=mid-1;
		else l=mid+1;
	}
	k -= chk(ans);
	REP(i,1,n) if (k&&a[i]>b[i]&&calc(a[i],b[i])==ans-1) --k,++b[i];
	REP(i,1,n) printf("%d ", b[i]);hr;
}


#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(_i,_a,_n) for(int _i=_a;_i<=_n;++_i)
#define PER(_i,_a,_n) for(int _i=_n;_i>=_a;--_i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(_a) ({REP(_i,1,n) cout<<_a[_i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head

#ifdef __APPLE__
const int N = 1e2+50;
#else
const int N = 1e6+50;
#endif

int n,a[N],b[N];
ll k;
ll calc(ll a, ll b) {
	return -1+a-3*b-3*b*b;
}
int chk(ll x) {
	ll tot = 0;
	REP(i,1,n) {
		if (-3+12*a[i]-12*x<0) return 0;
		b[i] = floor(-0.5+sqrt(-3+12*a[i]-12*x)/6)+1;
		b[i] = min(b[i], a[i]);
		tot += b[i];
		if (b[i]!=a[i]&&calc(a[i],b[i])>=x) throw;
	}
	return tot;
}
int main() {
	scanf("%d%lld", &n, &k);
	ll l = -1e18, r = 1e18, ans;
	REP(i,1,n) scanf("%d", a+i);
	while (l<=r) {
		if (chk(mid)<=k) ans=mid,r=mid-1;
		else l=mid+1;
	}
	k -= chk(ans);
	REP(i,1,n) if (k&&a[i]>b[i]&&calc(a[i],b[i])==ans-1) --k,++b[i];
	REP(i,1,n) printf("%d ", b[i]);hr;
}


#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;

vl A,B;

ll f(ll i, ll b){
    return b*(A[i] - b*b);
}

ll g(ll i, ll b){
    return A[i] - (3*b*b + 3*b + 1);
}

bool exact[MAXN] = {0};

ll getx(ll i, ll x){
    ll l = 0;
    ll r = A[i]+1;

    while(l < r-1){
        ll mid = (l+r)/2;
        if(g(i, mid) >= x){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    exact[i] = (g(i,l) == x);
    return l;
}

ll totk(ll x){
    ll ans = 0;
    rep(c1,0,n){
        ans += getx(c1, x);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n >> k;
   // n = 100000;
   // k = 100000000000001;
    rep(c1,0,n){
        cin >> a;
        //a = 1000000000;
        A.push_back(a);
    }

    ll l = -4*big*big;
    ll r = 4*big*big;

    while(l < r-7){
        ll mid = l/2 + r/2;
       // cerr << l << " " << r << "\n";
        ll tt = totk(mid);
        if(tt >= k){
            l = mid;
        }
        else{
            r = mid;
        }
    }

    while(totk(l+1) >= k){
        l++;
    }

    totk(l);

    ll ans = 0;
    vl B(n);
    rep(c1,0,n){
        B[c1] = getx(c1, l) - exact[c1];
        ans += B[c1];
    }

    ll tot = 0;

    //assert(ans <= k);
    rep(c1,0,n){
        if(exact[c1] && ans < k){
            ans++;
            B[c1]++;
        }
        cout << B[c1] << " ";
        tot += B[c1];
    }cout << "\n";
   // assert(tot == k);
/*
    ll sum = 0;
    ll tot = 0;
    rep(c1,0,n){
        sum += f(c1, B[c1]);
        tot += B[c1];
        assert(B[c1] <= A[c1]);
    }

    assert(tot == k);

    cerr << "TOT: " << tot << "\n";
    cerr << sum << "\n";
    */

    return 0;
}


#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;

vl A,B;

ll f(ll i, ll b){
    return b*(A[i] - b*b);
}

ll g(ll i, ll b){
    return A[i] - (3*b*b + 3*b + 1);
}

bool exact[MAXN] = {0};

ll getx(ll i, ll x){
    ll l = 0;
    ll r = A[i]+1;

    while(l < r-1){
        ll mid = (l+r)/2;
        if(g(i, mid) >= x){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(g(i, l) == x)exact[i] = 1;
    return l;
}

ll totk(ll x){
    ll ans = 0;
    rep(c1,0,n){
        ans += getx(c1, x);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n >> k;
   // n = 100000;
   // k = 100000000000001;
    rep(c1,0,n){
        cin >> a;
        //a = 1000000000;
        A.push_back(a);
    }

    ll l = -4*big*big;
    ll r = 4*big*big;

    while(l < r-7){
        ll mid = l/2 + r/2;
       // cerr << l << " " << r << "\n";
        ll tt = totk(mid);
        if(tt >= k){
            l = mid;
        }
        else{
            r = mid;
        }
    }

    while(totk(l+1) >= k){
        l++;
    }

    totk(l);

    ll ans = 0;
    vl B(n);
    rep(c1,0,n){
        B[c1] = getx(c1, l) - exact[c1];
        ans += B[c1];
    }

    ll tot = 0;

    rep(c1,0,n){
        if(exact[c1] && ans < k){
            ans++;
            B[c1]++;
        }
        cout << B[c1] << " ";
        tot += B[c1];
    }cout << "\n";
    assert(tot == k);
/*
    ll sum = 0;
    ll tot = 0;
    rep(c1,0,n){
        sum += f(c1, B[c1]);
        tot += B[c1];
        assert(B[c1] <= A[c1]);
    }

    assert(tot == k);

    cerr << "TOT: " << tot << "\n";
    cerr << sum << "\n";
    */

    return 0;
}


#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;

vl A,B;

ll f(ll i, ll b){
    return b*(A[i] - b*b);
}

ll g(ll i, ll b){
    return A[i] - (3*b*b + 3*b + 1);
}

bool exact[MAXN] = {0};

ll getx(ll i, ll x){
    ll l = 0;
    ll r = A[i]+1;

    while(l < r-1){
        ll mid = (l+r)/2;
        if(g(i, mid) >= x){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(g(i, l) == x)exact[i] = 1;
    return l;
}

ll totk(ll x){
    ll ans = 0;
    rep(c1,0,n){
        ans += getx(c1, x);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n >> k;
   // n = 100000;
   // k = 100000000000001;
    rep(c1,0,n){
        cin >> a;
        //a = 1000000000;
        A.push_back(a);
    }

    ll l = -4*big*big;
    ll r = 4*big*big;

    while(l < r-1){
        ll mid = l/2 + r/2 + (l%2 + r%2)/2;
       // cerr << l << " " << r << "\n";
        ll tt = totk(mid);
        if(tt >= k){
            l = mid;
        }
        else{
            r = mid;
        }
    }

    totk(l);

    ll ans = 0;
    vl B(n);
    rep(c1,0,n){
        B[c1] = getx(c1, l) - exact[c1];
        ans += B[c1];
    }

    rep(c1,0,n){
        if(exact[c1] && ans < k){
            ans++;
            B[c1]++;
        }
        cout << B[c1] << " ";
    }cout << "\n";

/*
    ll sum = 0;
    ll tot = 0;
    rep(c1,0,n){
        sum += f(c1, B[c1]);
        tot += B[c1];
        assert(B[c1] <= A[c1]);
    }

    assert(tot == k);

    cerr << "TOT: " << tot << "\n";
    cerr << sum << "\n";
    */

    return 0;
}


#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;

vl A,B;

ll f(ll i, ll b){
    return b*(A[i] - b*b);
}

ll g(ll i, ll b){
    return A[i] - (3*b*b + 3*b + 1);
}

bool exact[MAXN] = {0};

ll getx(ll i, ll x){
    ll l = 0;
    ll r = A[i]+1;

    while(l < r-1){
        ll mid = (l+r)/2;
        if(g(i, mid) >= x){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(g(i, l) == x)exact[i] = 1;
    return l;
}

ll totk(ll x){
    ll ans = 0;
    rep(c1,0,n){
        ans += getx(c1, x);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n >> k;
   // n = 100000;
   // k = 100000000000001;
    rep(c1,0,n){
        cin >> a;
        //a = 1000000000;
        A.push_back(a);
    }

    ll l = -4*big*big;
    ll r = 4*big*big;

    while(l < r-7){
        ll mid = l/2 + r/2;
       // cerr << l << " " << r << "\n";
        ll tt = totk(mid);
        if(tt >= k){
            l = mid;
        }
        else{
            r = mid;
        }
    }

    while(totk(l+1) >= k){
        l++;
    }

    totk(l);

    ll ans = 0;
    vl B(n);
    rep(c1,0,n){
        B[c1] = getx(c1, l) - exact[c1];
        ans += B[c1];
    }

    ll tot = 0;

    assert(ans <= k);
    rep(c1,0,n){
        if(exact[c1] && ans < k){
            ans++;
            B[c1]++;
        }
        cout << B[c1] << " ";
        tot += B[c1];
    }cout << "\n";
   // assert(tot == k);
/*
    ll sum = 0;
    ll tot = 0;
    rep(c1,0,n){
        sum += f(c1, B[c1]);
        tot += B[c1];
        assert(B[c1] <= A[c1]);
    }

    assert(tot == k);

    cerr << "TOT: " << tot << "\n";
    cerr << sum << "\n";
    */

    return 0;
}


#pragma GCC optimize("O3")   //
#include <bits/stdc++.h>
using namespace std;

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define per(i, b, a) for(int i = b - 1; i >= a; i--)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef long double ld;
typedef unsigned long long ull;

unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
std::mt19937 eng(seed);

uniform_int_distribution<> DD(0, (1ll << 31));

ll random2(){
    return (ll(DD(eng))*(1ll << 31) + ll(DD(eng))) & ((1ll << 62ll)-1);
}

ll n,m,k,q,T;

const ll big = 1000000007;
const ll big2 = 1000000009;
const ll mod =  998244353;

const int MAXN = 300001;

vl A,B;

ll f(ll i, ll b){
    return b*(A[i] - b*b);
}

ll g(ll i, ll b){
    return A[i] - (3*b*b + 3*b + 1);
}

bool exact[MAXN] = {0};

ll getx(ll i, ll x){
    ll l = 0;
    ll r = A[i]+1;

    while(l < r-1){
        ll mid = (l+r)/2;
        if(g(i, mid) >= x){
            l = mid;
        }
        else{
            r = mid;
        }
    }
    if(g(i, l) == x)exact[i] = 1;
    return l;
}

ll totk(ll x){
    ll ans = 0;
    rep(c1,0,n){
        ans += getx(c1, x);
    }
    return ans;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    //freopen("input.txt","r",stdin);
    //freopen("autput.txt","w",stdout);

    ll a,b,c,d,e;

    cin >> n >> k;
   // n = 100000;
   // k = 100000000000001;
    rep(c1,0,n){
        cin >> a;
        //a = 1000000000;
        A.push_back(a);
    }

    ll l = -4*big*big;
    ll r = 4*big*big;

    while(l < r-7){
        ll mid = l/2 + r/2;
       // cerr << l << " " << r << "\n";
        ll tt = totk(mid);
        if(tt >= k){
            l = mid;
        }
        else{
            r = mid;
        }
    }

    while(totk(l+1) >= k){
        l++;
    }

    totk(l);

    ll ans = 0;
    vl B(n);
    rep(c1,0,n){
        B[c1] = getx(c1, l) - exact[c1];
        ans += B[c1];
    }

    rep(c1,0,n){
        if(exact[c1] && ans < k){
            ans++;
            B[c1]++;
        }
        cout << B[c1] << " ";
    }cout << "\n";

/*
    ll sum = 0;
    ll tot = 0;
    rep(c1,0,n){
        sum += f(c1, B[c1]);
        tot += B[c1];
        assert(B[c1] <= A[c1]);
    }

    assert(tot == k);

    cerr << "TOT: " << tot << "\n";
    cerr << sum << "\n";
    */

    return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld MX = 0;
	for(lld i : a)
		MX = max(MX, i);

	lld X = binsearch(a,k,f(MX,MX),f(MX,0));

	vector<lld> b = gen(a,X);

	init(a,b);
	int res = calc(b);

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 5e18;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld X = binsearch(a,k,-INF,INF);

	vector<lld> b = gen(a,X);

	init(a,b);
	lld res = calc(b);

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld X = binsearch(a,k,-INF*INF,INF*INF);

	vector<lld> b = gen(a,X);

	init(a,b);
	lld res = calc(b);

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;
/*
	lld MX = 0;
	for(lld i : a)
		MX = max(MX, i);
*/
	lld X = binsearch(a,k,-INF*INF,INF*INF);

	vector<lld> b = gen(a,X);

	init(a,b);
	int res = calc(b);

	if(k-res >= 3*n){
		cout << "-> " << k-res << "\n";
		return 0;
	}

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld MX = 0;
	for(lld i : a)
		MX = max(MX, i);

	lld X = binsearch(a,k,f(MX,MX),f(MX,0));

	vector<lld> b = gen(a,X);

	init(a,b);
	int res = calc(b);

	assert(k-res <= n);

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;
/*
	lld MX = 0;
	for(lld i : a)
		MX = max(MX, i);
*/
	lld X = binsearch(a,k,-INF*INF,INF*INF);

	vector<lld> b = gen(a,X);

	init(a,b);
	int res = calc(b);

	if(k-res >= 3*n){
		cout << "-> " << k-res << " " << calc(gen(a,X-1)) << "\n";
		return 0;
	}

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld X = binsearch(a,k,-INF*INF,INF*INF);

	vector<lld> b = gen(a,X);

	init(a,b);
	lld res = calc(b);

	if(k-res >= (lld) 3*n){
		cout << "-> " << X << " " << calc(gen(a,X)) << " " << calc(gen(a,X-1)) << "\n";
		return 0;
	}

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = (b+e+1+2*INF)/2-INF;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = (b+e+2*INF)/2-INF;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld X = binsearch(a,k,-INF*INF,INF*INF);

	vector<lld> b = gen(a,X);

	init(a,b);
	int res = calc(b);
	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 4e18;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld X = binsearch(a,k,-INF,INF);

	vector<lld> b = gen(a,X);

	init(a,b);
	lld res = calc(b);

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return (b == 1 ? 0 : b);

	lld m = b+(e-b+1)/2;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = b+(e-b)/2;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld MX = 0;
	for(lld i : a)
		MX = max(MX, i);

	lld X = binsearch(a,k,f(MX,MX),f(MX,0));

	vector<lld> b = gen(a,X);

	init(a,b);
	int res = calc(b);

	if(k-res >= 3*n){
		cout << "-> " << k-res << "\n";
		return 0;
	}

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include<bits/stdc++.h>
using namespace std;
using lld = long long;

const lld INF = 1e9;

lld calc(const vector<lld>& b){
	lld sum = 0;
	for(lld i : b)
		sum += i;
	return sum;
}

lld f(lld a, lld b){
	return a - 3ll*b*b + 3ll*b - 1ll;
}

lld calc(lld x, lld p, lld b, lld e){
	if(b == e)
		return b;

	lld m = (b+e+1+2*INF)/2-INF;
	if(f(x,m) >= p)
		return calc(x,p,m,e);
	return calc(x,p,b,m-1);
}

vector<lld> gen(vector<lld>& a, lld p){
	vector<lld> b;
	for(lld i : a)
		b.push_back(calc(i,p,0,i));
	return b;
}

lld binsearch(vector<lld>& a, lld K, lld b, lld e){
	if(b == e)
		return b;

	lld m = (b+e+2*INF)/2-INF;
	if(calc(gen(a,m)) <= K)
		return binsearch(a,K,b,m);
	return binsearch(a,K,m+1,e);
}

priority_queue<pair<lld,int> > q;
void init(vector<lld>& a, vector<lld>& b){
	for(int i=0;i<a.size();i++)
		if(b[i] < a[i])
			q.push({f(a[i],b[i]), i});
}

void repair(vector<lld>& a, vector<lld>& b){
	auto x = q.top();
	q.pop();

	int i = x.second;
	b[i]++;
	if(b[i] < a[i])
		q.push({f(a[i], b[i]), i});
}

int main(void){
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);

	int n;
	lld k;
	cin >> n >> k;

	vector<lld> a(n);
	for(lld& i : a)
		cin >> i;

	lld MX = 0;
	for(lld i : a)
		MX = max(MX, i);

	lld X = binsearch(a,k,f(MX,MX),f(MX,0));

	vector<lld> b = gen(a,X);

	init(a,b);
	int res = calc(b);

	assert(k-res <= n);

	for(lld i=0;i<k-res;i++)
		repair(a,b);

	for(lld i : b)
		cout << i << " ";
	cout << "\n";

	return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll
#define double long double
int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e30;
    while (r!=l)
    {
        double m=(l+r)/2;
        if ((m==l) or (m==r))
            return {m, -1.0};
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll
#define double long double
int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e18;
    while (r-l>0.000000000001)
    {
        double m=(l+r)/2;
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll
#define double long double
int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e10;
    while (r-l>0.0001)
    {
        double m=(l+r)/2;
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll
#define double long double
int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e18;
    while (r-l>0.0000001)
    {
        double m=(l+r)/2;
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll
#define double long double
int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e18;
    while (r>l+0.000001)
    {
        double m=(l+r)/2;
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll
#define double long double
int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e30;
    while (r!=l)
    {
        double m=(l+r)/2;
        if ((m==l) or (m==r))
            return {l, r};
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll

int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e10;
    while (r-l>0.0001)
    {
        double m=(l+r)/2;
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll
#define double long double
int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=-1e30;
    double r=1e30;
    while (r!=l)
    {
        double m=(l+r)/2;
        if ((m==l) or (m==r))
            return {l, r};
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll
#define double long double
int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e30;
    while (r>l+0.000001)
    {
        double m=(l+r)/2;
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back

using namespace std;
const int nmax=5e5+100;
typedef long long ll;
#define int ll

int n, k;
int a[nmax];

int border(int i, double M)
{
    int res=(1.0+sqrt(1+ 4.0/3.0*(a[i]+M)))/2.0;
    if (res<0) return 0;
    if (res>a[i]) return a[i];
    return res;
}

int need(double M)
{
    int s=0;
    for (int i=1; i<=n; i++)
    {
        s+=border(i, M);
        if (s>k)
            return k+1;
    }
    return s;
}

pair<double, double> finder()
{
    double l=0;
    double r=1e18;
    while (r-l>0.0000001)
    {
        double m=(l+r)/2;
        int ans=need(m);
        if (ans>k)
            r=m;
        else if (ans<k)
            l=m;
        else
            return {m, -1.0};
    }
    return {l, r};
}

main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin>>n>>k;
    for (int i=1; i<=n; i++)
        cin>>a[i];

//    int ans=0;
//    for (int i=1; i<=n; i++)
//    {
//        int x;
//        cin>>x;
//        ans+=x*(a[i]-x*x);
//    }
//    cout<<ans<<"\n";

    auto M=finder();
    if (M.second==-1.0)
    {
        for (int i=1; i<=n; i++)
            cout<<border(i, M.first)<<" ";
        cout<<"\n";
        exit(0);
    }
    vector<int> low, high;
    for (int i=1; i<=n; i++)
    {
        low.push_back(border(i, M.first));
        high.push_back(border(i, M.second));
    }
    int left=k-need(M.first);
    for (int i=0; i<n; i++)
    {
        if ((left==0) or (low[i]==high[i]))
            cout<<low[i]<<" ";
        else
            left--, cout<<low[i]+1<<" ";
    }
        cout<<"\n";
    return 0;
}


// InterestingLSY
// codeforces&github: interestingLSY, qq: 2659723130
// 《幽灵公主》是真的好看！
#ifdef intLSY
#include <intlsy/stdc++.h>
#else
#include <bits/stdc++.h>
#endif
#include <bits/c++0x_warning.h>
using namespace std;
#define il inline
#define elif else if

// Type
#define ld double
#define ll long long
#define ull unsigned ll

// Vector
#define vc vector
#define Pb push_back
#define Pf push_front
#define Eb emplace_back
#define All(x) x.begin(),x.end()
#define AllRev(x) x.rbegin(),x.rend()

// Memory
#define Ms(_data) memset(_data,0,sizeof(_data))
#define Msn(_data,_num) memset(_data,_num,sizeof(_data))

// Pair
#define F first
#define S second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>

// Loop
#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )
#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )
#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )
#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )
#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )
#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )
#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )

// Read
struct InputReader{
	static constexpr int MAXSZ = 1048576;
	char buf[MAXSZ]; int p, ed;
	bool detectedEOF = false;
	il InputReader(){ p = MAXSZ; }
	il void Flush(){ p = 0; ed = fread(buf,1,MAXSZ,stdin); }
	il void GetChar( char &c ){
		if(p >= MAXSZ) Flush();
		if( p == ed ){ detectedEOF = true; }
		c = buf[p++];
	}
	il void ReadNum( char &c ){ GetChar(c); while( !isdigit(c) && c != '-' && !detectedEOF ) GetChar(c); }
	il void ReadAlpha( char &c ){ GetChar(c); while( !isalpha(c) && !detectedEOF ) GetChar(c); }
	il void ReadInt( int &ans ){
		ans = 0; int nega = 1;
		char c; ReadNum(c); if(detectedEOF) return;
		if( c == '-' ){
			nega = -1;
			GetChar(c);
		}
		while( isdigit(c) && !detectedEOF ){
			ans = ans*10 + c-'0';
			GetChar(c);
		}
		ans *= nega;
	}
	il void Readll( ll &ans ){
		ans = 0; int nega = 1;
		char c; ReadNum(c); if(detectedEOF) return;
		if( c == '-' ){
			nega = -1;
			GetChar(c);
		}
		while( isdigit(c) && !detectedEOF ){
			ans = ans*10 + c-'0';
			GetChar(c);
		}
		ans *= nega;
	}
	il void ReadString( string &x ){
		x.clear(); char ch; GetChar(ch);
		while( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;
		while( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){
			x += ch;
			GetChar(ch);
		}
	}
	il void ReadCString( char s[] ){
		int len = 0; char ch; GetChar(ch);
		while( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;
		while( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){
			s[len++] = ch;
			GetChar(ch);
		}
		s[len] = '\0';
	}
	il void SpecialRead( char &c ){
		GetChar(c); if(detectedEOF) return;
		while( !isdigit(c) && !isalpha(c) && c != '#' && c != '.' && c != '=' && c != 'B' && !detectedEOF ) GetChar(c);
	}
}In;
il void Read( int &x ){ In.ReadInt(x); }
il void Read( int &x, int &y ){ In.ReadInt(x); In.ReadInt(y); }
il void Read( int &x1 , int &x2 , int &x3 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); }
il void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); In.ReadInt(x4); }
il void Read( ll &x ){ In.Readll(x); }
il void Read( ll &x, ll &y ){ In.Readll(x); In.Readll(y); }
il void Read( ll &x1 , ll &x2 , ll &x3 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); }
il void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); In.Readll(x4); }
template<typename T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }
#define iRead(k) int k; Read(k);
#define iRead2(a,b) iRead(a); iRead(b);
#define iRead3(a,b,c) iRead2(a,b); iRead(c);
#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);
#define lRead(k) ll k; Read(k);
#define lRead2(a,b) lRead(a); lRead(b);
#define lRead3(a,b,c) lRead2(a,b); lRead(c);
#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);

// File
#define Fin(a) freopen(a,"r",stdin)
#define Fout(a) freopen(a,"w",stdout)
il void FILEIO(){
	#ifdef intLSY
		Fin("in.in");
	#endif
}
il void FILEIO( string pname ){
	#ifndef intLSY
		Fin((pname+".in").c_str());
		Fout((pname+".out").c_str());
	#else
		Fin("in.in");
	#endif
}
il void FILEIO_OICONTEST( string pname ){
	Fin((pname+".in").c_str());
	#ifndef intLSY
		Fout((pname+".out").c_str());
	#endif
}
void Printtime(){
	#ifdef intLSY
		double _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;
		fprintf(stderr,"\n\nTime usage:\n%.0lf ms\n",_timeuse);
	#endif
}
void END(){ Printtime(); exit(0); }
template<typename T>void END( T mes ){ cout << mes << endl; END(); }

// Debug
#define B cerr << "BreakPoint" << endl;
#define O(x) cerr << #x << " " << (x) << endl;
#define o(x) cerr << #x << " " << (x) << "  ";
template<typename T0>
void P( T0 t0 ){
	cerr << t0 << endl;
}
template<typename T0, typename... Ts>
void P( T0 t0 , Ts... ts ){
	cerr << t0 << " ";
	P(ts...);
}
#define Msz(x) cerr << "Sizeof " << #x << " " << sizeof(x)/1024/1024 << " MB" << endl;
template<typename T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\n' ){
	if( s > t ) return;
	for( int i = s ; i < t ; i++ )
		cout << a[i] << sp;
	cout << a[t] << ed;
	cout.flush();
}
template<typename T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\n' ){
	if( t == -1 ) t = a.size()-1;
	for( int i = s ; i <= t ; i++ )
		cout << a[i] << sp;
	cout << ed;
	cout.flush();
}

// Optimize
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Mymax(a,b) (a) = max((a),(b))
#define Mymin(a,b) (a) = min((a),(b))
#define MyMax(a,b) (a) = Max((a),(b))
#define MyMin(a,b) (a) = Min((a),(b))
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define Sqr(x) ((x)*(x))
#define Lowbit(a) ((a)&(-(a)))
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
constexpr int MAXN = 131072;

int n; ll k;
ll a[MAXN];

ll CountOne( ll a , ll lim ){
	ll l = 0, r = a, ans = 0;
	while( l <= r ){
		ll mid = l+r >> 1;
		if( a - 3*mid*mid + 3*mid - 1 >= lim ){
			ans = mid;
			l = mid+1;
		}else{
			r = mid-1;
		}
	}
	return ans;
}

ll Count( ll lim ){
	ll cnt = 0;
	For(i,n){
		ll tcnt = CountOne(a[i],lim);
		cnt += tcnt;
	}
	return cnt;
}
ll BinarySearch(){
	ll l = -4e18, r = 4e18, ans = LLONG_MAX;
	while( l <= r ){
		ll mid = l+r >> 1;
		if( Count(mid) <= k ){
			ans = mid;
			r = mid-1;
		}else{
			l = mid+1;
		}
	}
	return ans;
}

ll ansl[MAXN];
void Solve(){
	ll lim = BinarySearch();
	static vc<pli> avail;
	For(i,n){
		ansl[i] = CountOne(a[i],lim);
		if( ansl[i] != a[i] ){
			ll x = ansl[i]+1;
			avail.Pb({a[i]-3*x*x+3*x-1,i});
			if( x != a[i] ){
				++x;
				avail.Pb({a[i]-3*x*x+3*x-1,i});
			}
		}
	}
	sort(All(avail),[]( const pli &a , const pli &b ){
		return a.F > b.F;
	});
	ll left = k - Count(lim);
	// if( k == 49985284073162 ) cout << avail.size() << " " << left << endl;
	assert( (ll)avail.size() >= left );
	For0(i,left)
		++ansl[avail[i].S];
}

int main(){
	FILEIO();

	Read(n); Read(k);
	Read(a,1,n);

	Solve();

	For(i,n)
		printf("%lld ",ansl[i]);
	putchar(10);

	END();
}


// InterestingLSY
// codeforces&github: interestingLSY, qq: 2659723130
// 《幽灵公主》是真的好看！
#ifdef intLSY
#include <intlsy/stdc++.h>
#else
#include <bits/stdc++.h>
#endif
#include <bits/c++0x_warning.h>
using namespace std;
#define il inline
#define elif else if

// Type
#define ld double
#define ll long long
#define ull unsigned ll

// Vector
#define vc vector
#define Pb push_back
#define Pf push_front
#define Eb emplace_back
#define All(x) x.begin(),x.end()
#define AllRev(x) x.rbegin(),x.rend()

// Memory
#define Ms(_data) memset(_data,0,sizeof(_data))
#define Msn(_data,_num) memset(_data,_num,sizeof(_data))

// Pair
#define F first
#define S second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>

// Loop
#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )
#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )
#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )
#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )
#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )
#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )
#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )

// Read
struct InputReader{
	static constexpr int MAXSZ = 1048576;
	char buf[MAXSZ]; int p, ed;
	bool detectedEOF = false;
	il InputReader(){ p = MAXSZ; }
	il void Flush(){ p = 0; ed = fread(buf,1,MAXSZ,stdin); }
	il void GetChar( char &c ){
		if(p >= MAXSZ) Flush();
		if( p == ed ){ detectedEOF = true; }
		c = buf[p++];
	}
	il void ReadNum( char &c ){ GetChar(c); while( !isdigit(c) && c != '-' && !detectedEOF ) GetChar(c); }
	il void ReadAlpha( char &c ){ GetChar(c); while( !isalpha(c) && !detectedEOF ) GetChar(c); }
	il void ReadInt( int &ans ){
		ans = 0; int nega = 1;
		char c; ReadNum(c); if(detectedEOF) return;
		if( c == '-' ){
			nega = -1;
			GetChar(c);
		}
		while( isdigit(c) && !detectedEOF ){
			ans = ans*10 + c-'0';
			GetChar(c);
		}
		ans *= nega;
	}
	il void Readll( ll &ans ){
		ans = 0; int nega = 1;
		char c; ReadNum(c); if(detectedEOF) return;
		if( c == '-' ){
			nega = -1;
			GetChar(c);
		}
		while( isdigit(c) && !detectedEOF ){
			ans = ans*10 + c-'0';
			GetChar(c);
		}
		ans *= nega;
	}
	il void ReadString( string &x ){
		x.clear(); char ch; GetChar(ch);
		while( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;
		while( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){
			x += ch;
			GetChar(ch);
		}
	}
	il void ReadCString( char s[] ){
		int len = 0; char ch; GetChar(ch);
		while( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;
		while( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){
			s[len++] = ch;
			GetChar(ch);
		}
		s[len] = '\0';
	}
	il void SpecialRead( char &c ){
		GetChar(c); if(detectedEOF) return;
		while( !isdigit(c) && !isalpha(c) && c != '#' && c != '.' && c != '=' && c != 'B' && !detectedEOF ) GetChar(c);
	}
}In;
il void Read( int &x ){ In.ReadInt(x); }
il void Read( int &x, int &y ){ In.ReadInt(x); In.ReadInt(y); }
il void Read( int &x1 , int &x2 , int &x3 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); }
il void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); In.ReadInt(x4); }
il void Read( ll &x ){ In.Readll(x); }
il void Read( ll &x, ll &y ){ In.Readll(x); In.Readll(y); }
il void Read( ll &x1 , ll &x2 , ll &x3 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); }
il void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); In.Readll(x4); }
template<typename T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }
#define iRead(k) int k; Read(k);
#define iRead2(a,b) iRead(a); iRead(b);
#define iRead3(a,b,c) iRead2(a,b); iRead(c);
#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);
#define lRead(k) ll k; Read(k);
#define lRead2(a,b) lRead(a); lRead(b);
#define lRead3(a,b,c) lRead2(a,b); lRead(c);
#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);

// File
#define Fin(a) freopen(a,"r",stdin)
#define Fout(a) freopen(a,"w",stdout)
il void FILEIO(){
	#ifdef intLSY
		Fin("in.in");
	#endif
}
il void FILEIO( string pname ){
	#ifndef intLSY
		Fin((pname+".in").c_str());
		Fout((pname+".out").c_str());
	#else
		Fin("in.in");
	#endif
}
il void FILEIO_OICONTEST( string pname ){
	Fin((pname+".in").c_str());
	#ifndef intLSY
		Fout((pname+".out").c_str());
	#endif
}
void Printtime(){
	#ifdef intLSY
		double _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;
		fprintf(stderr,"\n\nTime usage:\n%.0lf ms\n",_timeuse);
	#endif
}
void END(){ Printtime(); exit(0); }
template<typename T>void END( T mes ){ cout << mes << endl; END(); }

// Debug
#define B cerr << "BreakPoint" << endl;
#define O(x) cerr << #x << " " << (x) << endl;
#define o(x) cerr << #x << " " << (x) << "  ";
template<typename T0>
void P( T0 t0 ){
	cerr << t0 << endl;
}
template<typename T0, typename... Ts>
void P( T0 t0 , Ts... ts ){
	cerr << t0 << " ";
	P(ts...);
}
#define Msz(x) cerr << "Sizeof " << #x << " " << sizeof(x)/1024/1024 << " MB" << endl;
template<typename T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\n' ){
	if( s > t ) return;
	for( int i = s ; i < t ; i++ )
		cout << a[i] << sp;
	cout << a[t] << ed;
	cout.flush();
}
template<typename T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\n' ){
	if( t == -1 ) t = a.size()-1;
	for( int i = s ; i <= t ; i++ )
		cout << a[i] << sp;
	cout << ed;
	cout.flush();
}

// Optimize
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Mymax(a,b) (a) = max((a),(b))
#define Mymin(a,b) (a) = min((a),(b))
#define MyMax(a,b) (a) = Max((a),(b))
#define MyMin(a,b) (a) = Min((a),(b))
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define Sqr(x) ((x)*(x))
#define Lowbit(a) ((a)&(-(a)))
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
constexpr int MAXN = 131072;

int n; ll k;
ll a[MAXN];

ll CountOne( ll a , ll lim ){
	ll l = 0, r = a, ans = 0;
	while( l <= r ){
		ll mid = l+r >> 1;
		if( a - 3*mid*mid + 3*mid - 1 >= lim ){
			ans = mid;
			l = mid+1;
		}else{
			r = mid-1;
		}
	}
	return ans;
}

ll Count( ll lim ){
	ll cnt = 0;
	For(i,n){
		ll tcnt = CountOne(a[i],lim);
		cnt += tcnt;
	}
	return cnt;
}
ll BinarySearch(){
	ll l = -1e18, r = 1e18, ans = LLONG_MAX;
	while( l <= r ){
		ll mid = l+r >> 1;
		if( Count(mid) <= k ){
			ans = mid;
			r = mid-1;
		}else{
			l = mid+1;
		}
	}
	return ans;
}

ll ansl[MAXN];
void Solve(){
	ll lim = BinarySearch();
	static vc<pli> avail;
	For(i,n){
		ansl[i] = CountOne(a[i],lim);
		if( ansl[i] != a[i] ){
			ll x = ansl[i]+1;
			avail.Pb({a[i]-3*x*x+3*x-1,i});
		}
	}
	sort(All(avail),[]( const pli &a , const pli &b ){
		return a.F > b.F;
	});
	ll left = k - Count(lim);
	assert( avail.size() >= left );
	For0(i,left)
		++ansl[avail[i].S];
}

int main(){
	FILEIO();

	Read(n); Read(k);
	Read(a,1,n);

	Solve();

	For(i,n)
		printf("%lld ",ansl[i]);
	putchar(10);

	END();
}


// InterestingLSY
// codeforces&github: interestingLSY, qq: 2659723130
// 《幽灵公主》是真的好看！
#ifdef intLSY
#include <intlsy/stdc++.h>
#else
#include <bits/stdc++.h>
#endif
#include <bits/c++0x_warning.h>
using namespace std;
#define il inline
#define elif else if

// Type
#define ld double
#define ll long long
#define ull unsigned ll

// Vector
#define vc vector
#define Pb push_back
#define Pf push_front
#define Eb emplace_back
#define All(x) x.begin(),x.end()
#define AllRev(x) x.rbegin(),x.rend()

// Memory
#define Ms(_data) memset(_data,0,sizeof(_data))
#define Msn(_data,_num) memset(_data,_num,sizeof(_data))

// Pair
#define F first
#define S second
#define pii pair<int,int>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>

// Loop
#define For(i,j) for( int (i) = 1 ; (i) <= (j) ; ++(i) )
#define For0(i,j) for( int (i) = 0 ; (i) < (j) ; ++(i) )
#define Forx(i,j,k) for( int (i) = (j) ; (i) <= (k) ; ++(i) )
#define Forstep(i,j,k,st) for( int (i) = (j) ; (i) <= (k) ; (i) += (st) )
#define fOR(i,j) for( int (i) = (j) ; (i) >= 1 ; --(i) )
#define fOR0(i,j) for( int (i) = (j)-1 ; (i) >= 0 ; --(i) )
#define fORx(i,j,k) for( int (i) = (k) ; (i) >= (j) ; --(i) )

// Read
struct InputReader{
	static constexpr int MAXSZ = 1048576;
	char buf[MAXSZ]; int p, ed;
	bool detectedEOF = false;
	il InputReader(){ p = MAXSZ; }
	il void Flush(){ p = 0; ed = fread(buf,1,MAXSZ,stdin); }
	il void GetChar( char &c ){
		if(p >= MAXSZ) Flush();
		if( p == ed ){ detectedEOF = true; }
		c = buf[p++];
	}
	il void ReadNum( char &c ){ GetChar(c); while( !isdigit(c) && c != '-' && !detectedEOF ) GetChar(c); }
	il void ReadAlpha( char &c ){ GetChar(c); while( !isalpha(c) && !detectedEOF ) GetChar(c); }
	il void ReadInt( int &ans ){
		ans = 0; int nega = 1;
		char c; ReadNum(c); if(detectedEOF) return;
		if( c == '-' ){
			nega = -1;
			GetChar(c);
		}
		while( isdigit(c) && !detectedEOF ){
			ans = ans*10 + c-'0';
			GetChar(c);
		}
		ans *= nega;
	}
	il void Readll( ll &ans ){
		ans = 0; int nega = 1;
		char c; ReadNum(c); if(detectedEOF) return;
		if( c == '-' ){
			nega = -1;
			GetChar(c);
		}
		while( isdigit(c) && !detectedEOF ){
			ans = ans*10 + c-'0';
			GetChar(c);
		}
		ans *= nega;
	}
	il void ReadString( string &x ){
		x.clear(); char ch; GetChar(ch);
		while( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;
		while( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){
			x += ch;
			GetChar(ch);
		}
	}
	il void ReadCString( char s[] ){
		int len = 0; char ch; GetChar(ch);
		while( !isdigit(ch) && !isalpha(ch) && ch != '#' && ch != '.' && !detectedEOF ) GetChar(ch); if(detectedEOF) return;
		while( (isdigit(ch) || isalpha(ch) || ch == '#' || ch == '.') && !detectedEOF ){
			s[len++] = ch;
			GetChar(ch);
		}
		s[len] = '\0';
	}
	il void SpecialRead( char &c ){
		GetChar(c); if(detectedEOF) return;
		while( !isdigit(c) && !isalpha(c) && c != '#' && c != '.' && c != '=' && c != 'B' && !detectedEOF ) GetChar(c);
	}
}In;
il void Read( int &x ){ In.ReadInt(x); }
il void Read( int &x, int &y ){ In.ReadInt(x); In.ReadInt(y); }
il void Read( int &x1 , int &x2 , int &x3 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); }
il void Read( int &x1 , int &x2 , int &x3 , int &x4 ){ In.ReadInt(x1); In.ReadInt(x2); In.ReadInt(x3); In.ReadInt(x4); }
il void Read( ll &x ){ In.Readll(x); }
il void Read( ll &x, ll &y ){ In.Readll(x); In.Readll(y); }
il void Read( ll &x1 , ll &x2 , ll &x3 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); }
il void Read( ll &x1 , ll &x2 , ll &x3 , ll &x4 ){ In.Readll(x1); In.Readll(x2); In.Readll(x3); In.Readll(x4); }
template<typename T> void Read( T a[] , int st , int ed ){ Forx(i,st,ed) Read(a[i]); }
#define iRead(k) int k; Read(k);
#define iRead2(a,b) iRead(a); iRead(b);
#define iRead3(a,b,c) iRead2(a,b); iRead(c);
#define iRead4(a,b,c,d) iRead2(a,b); iRead2(c,d);
#define lRead(k) ll k; Read(k);
#define lRead2(a,b) lRead(a); lRead(b);
#define lRead3(a,b,c) lRead2(a,b); lRead(c);
#define lRead4(a,b,c,d) lRead2(a,b); lRead2(c,d);

// File
#define Fin(a) freopen(a,"r",stdin)
#define Fout(a) freopen(a,"w",stdout)
il void FILEIO(){
	#ifdef intLSY
		Fin("in.in");
	#endif
}
il void FILEIO( string pname ){
	#ifndef intLSY
		Fin((pname+".in").c_str());
		Fout((pname+".out").c_str());
	#else
		Fin("in.in");
	#endif
}
il void FILEIO_OICONTEST( string pname ){
	Fin((pname+".in").c_str());
	#ifndef intLSY
		Fout((pname+".out").c_str());
	#endif
}
void Printtime(){
	#ifdef intLSY
		double _timeuse = clock()* 1000.0 / CLOCKS_PER_SEC;
		fprintf(stderr,"\n\nTime usage:\n%.0lf ms\n",_timeuse);
	#endif
}
void END(){ Printtime(); exit(0); }
template<typename T>void END( T mes ){ cout << mes << endl; END(); }

// Debug
#define B cerr << "BreakPoint" << endl;
#define O(x) cerr << #x << " " << (x) << endl;
#define o(x) cerr << #x << " " << (x) << "  ";
template<typename T0>
void P( T0 t0 ){
	cerr << t0 << endl;
}
template<typename T0, typename... Ts>
void P( T0 t0 , Ts... ts ){
	cerr << t0 << " ";
	P(ts...);
}
#define Msz(x) cerr << "Sizeof " << #x << " " << sizeof(x)/1024/1024 << " MB" << endl;
template<typename T>void Print( T a[] , int s , int t , char sp = ' ' , char ed = '\n' ){
	if( s > t ) return;
	for( int i = s ; i < t ; i++ )
		cout << a[i] << sp;
	cout << a[t] << ed;
	cout.flush();
}
template<typename T>void Print( T a , int s = 0 , int t = -1 , char sp = ' ' , char ed = '\n' ){
	if( t == -1 ) t = a.size()-1;
	for( int i = s ; i <= t ; i++ )
		cout << a[i] << sp;
	cout << ed;
	cout.flush();
}

// Optimize
#define Max(a,b) ((a)>(b)?(a):(b))
#define Min(a,b) ((a)<(b)?(a):(b))
#define Mymax(a,b) (a) = max((a),(b))
#define Mymin(a,b) (a) = min((a),(b))
#define MyMax(a,b) (a) = Max((a),(b))
#define MyMin(a,b) (a) = Min((a),(b))
#define INF (0x3f3f3f3f)
#define LINF ((long long)(0x3f3f3f3f3f3f3f3f))
#define Sqr(x) ((x)*(x))
#define Lowbit(a) ((a)&(-(a)))
///////////////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////
constexpr int MAXN = 131072;

int n; ll k;
ll a[MAXN];

ll CountOne( ll a , ll lim ){
	ll l = 0, r = a, ans = 0;
	while( l <= r ){
		ll mid = l+r >> 1;
		if( a - 3*mid*mid + 3*mid - 1 >= lim ){
			ans = mid;
			l = mid+1;
		}else{
			r = mid-1;
		}
	}
	return ans;
}

ll Count( ll lim ){
	ll cnt = 0;
	For(i,n){
		ll tcnt = CountOne(a[i],lim);
		cnt += tcnt;
	}
	return cnt;
}
ll BinarySearch(){
	ll l = -1e18, r = 1e18, ans = LLONG_MAX;
	while( l <= r ){
		ll mid = l+r >> 1;
		if( Count(mid) <= k ){
			ans = mid;
			r = mid-1;
		}else{
			l = mid+1;
		}
	}
	return ans;
}

ll ansl[MAXN];
void Solve(){
	ll lim = BinarySearch();
	static vc<pli> avail;
	For(i,n){
		ansl[i] = CountOne(a[i],lim);
		if( ansl[i] != a[i] ){
			ll x = ansl[i]+1;
			avail.Pb({a[i]-3*x*x+3*x-1,i});
			if( x != a[i] ){
				++x;
				avail.Pb({a[i]-3*x*x+3*x-1,i});
			}
		}
	}
	sort(All(avail),[]( const pli &a , const pli &b ){
		return a.F > b.F;
	});
	ll left = k - Count(lim);
	assert( (ll)avail.size() >= left );
	For0(i,left)
		++ansl[avail[i].S];
}

int main(){
	FILEIO();

	Read(n); Read(k);
	Read(a,1,n);

	Solve();

	For(i,n)
		printf("%lld ",ansl[i]);
	putchar(10);

	END();
}