// 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);
	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});
			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( 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;
struct Item{ ll num; int pos; ll ans; };
Item a[MAXN];

void Solve(){
	ll added = 0;
	For(l,n){
		int len = n-l+1;
		ll can = (a[l].num-added) * len;
		if( can < k ){
			a[l].ans = a[l].num-added;
			added = a[l].num;
			k -= can;
		}else{
			a[l].ans += k/len + (k%len!=0);
			if(k%len) a[l+k%len].ans -= 1;
			break;
		}
	}
}

int main(){
	FILEIO();

	Read(n); Read(k);
	For(i,n){
		Read(a[i].num);
		a[i].pos = i;
	}
	sort(a+1,a+1+n,[]( const Item &a , const Item &b ){
		return a.num < b.num;
	});

	Solve();

	For(i,n)
		a[i].ans += a[i-1].ans;
	sort(a+1,a+1+n,[]( const Item &a , const Item &b ){
		return a.pos < b.pos;
	});

	For(i,n)
		printf("%lld ",a[i].ans);
	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 = -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(){
	cerr << "1" << endl;
	ll lim = BinarySearch();
	cerr << "2" << endl;
	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});
		}
	}
	cerr << "3" << endl;
	sort(All(avail),[]( const pli &a , const pli &b ){
		return a.F > b.F;
	});
	cerr << "4" << endl;
	ll left = k - Count(lim);
	assert( avail.size() >= left );
	cerr << "5" << endl;
	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();
}


#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;
const long long offset = 3e18;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int n,a[N],b[N];
long long k;
long long is(long long a,long long b){return a - 3*b*b + 3*b - 1;}
long long get(long long val){
	long long took = 0;
	for(int i = 0;i < n;i++){
		b[i] = 0;
		long long A = -3,B = 3,C = a[i] - 1 - val;
		long long temp = B*B - 4*C*A;
		if(temp < 0){
			b[i] = a[i];
			took+=a[i];
			continue;
		}
		long double temp1 = sqrt(temp);
		temp1 = -B - temp1;
		temp1/=2*A;
		temp = temp1;
		temp = min(temp,(long long)a[i]);
		while(temp && is(a[i],temp) < val)temp--;
		while(temp < a[i] && is(a[i],temp + 1) >= val)temp++;
		b[i] = temp;
		took+=temp;
	}
	return took;
}
// int main(){
	freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	scanf("%d%lld",&n,&k);
	for(int i = 0;i < n;i++)scanf("%d",a + i);
	long long l = 0,r = 4e18,bst = 0;
	int lol = 0;
	while(l <= r){
		long long mid = (l - offset + r - offset)/2;
		mid+=offset;
		if(get(mid - offset) <= k){
			bst = mid - offset;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	long long rem = k - get(bst);
	for(int i = 0;i < n && rem;i++)
		if(b[i] < a[i] && is(a[i],b[i] + 1) >= bst - 1){
			rem--;
			b[i]++;
		}
	for(int i = 0;i < n;i++)printf("%d ",b[i]);
	puts("");
}

// a - 3b^2 + 3b - 1


#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;
const long long offset = 3e18;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int n,a[N],b[N];
long long k;
long long is(long long a,long long b){return a - 3*b*b + 3*b - 1;}
long long get(long long val){
	long long took = 0;
	for(int i = 0;i < n;i++){
		int l = 0,r = a[i],bst = 0;
		while(l <= r){
			int mid = (l + r)/2;
			if(is(a[i],mid) >= val){
				bst = mid;
				l = mid + 1;
			}
			else r = mid - 1;
		}
		b[i] = bst;
		took+=bst;
	}
	return took;
}
int main(){
// 	freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	scanf("%d%lld",&n,&k);
	for(int i = 0;i < n;i++)scanf("%d",a + i);
	long long l = 0,r = 4e18,bst = 0;
	int lol = 0;
	while(l <= r){
		long long mid = (l - offset + r - offset)/2;
		mid+=offset;
		if(get(mid - offset) <= k){
			bst = mid - offset;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	long long rem = k - get(bst);
	for(int i = 0;i < n && rem;i++)
		if(b[i] < a[i] && is(a[i],b[i] + 1) >= bst - 1){
			rem--;
			b[i]++;
		}
	for(int i = 0;i < n;i++)printf("%d ",b[i]);
	puts("");
}

// a - 3b^2 + 3b - 1


#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;
const long long offset = 3e18;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int n,a[N],b[N];
long long k;
long long is(long long a,long long b){return a - 3*b*b + 3*b - 1;}
long long get(long long val){
	long long took = 0;
	for(int i = 0;i < n;i++){
		long long A = -3,B = 3,C = a[i] - 1 - val;
		long long temp = B*B - 4*A*C;
		if(temp < 0){
			b[i] = a[i];
			took+=a[i];
			continue;
		}
		long double temp1 = sqrt(temp);
		temp1 = -B - temp1;
		temp1/=2*A;
		temp = temp1;
		temp = min(temp,(long long)a[i]);
		b[i] = temp;
		took+=temp;
	}
	return took;
}
int main(){
// 	freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	scanf("%d%lld",&n,&k);
	for(int i = 0;i < n;i++)scanf("%d",a + i);
	long long l = 0,r = 4e18,bst = 0;
	while(l <= r){
		long long mid = (l - offset + r - offset)/2;
		mid+=offset;
		if(get(mid - offset) <= k){
			bst = mid - offset;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	long long rem = k - get(bst);
	for(int i = 0;i < n && rem;i++)
		if(b[i] < a[i] && is(a[i],b[i] + 1) >= bst - 1){
			rem--;
			b[i]++;
		}
	for(int i = 0;i < n;i++)printf("%d ",b[i]);
	puts("");
}

// a - 3b^2 + 3b - 1


#include<bits/stdc++.h>
using namespace std;
const int N = 1e5;
const long long offset = 3e18;
mt19937 rng(std::chrono::system_clock::now().time_since_epoch().count());
int n,a[N],b[N];
long long k;
long long is(long long a,long long b){return a - 3*b*b + 3*b - 1;}
long long get(long long val){
	long long took = 0;
	for(int i = 0;i < n;i++){
		b[i] = 0;
		long long A = -3,B = 3,C = a[i] - 1 - val;
		long long temp = B*B - 4*C*A;
		if(temp < 0){
			b[i] = a[i];
			took+=a[i];
			continue;
		}
		long double temp1 = sqrt(temp);
		temp1 = -B - temp1;
		temp1/=2*A;
		temp = temp1;
		temp = min(temp,(long long)a[i]);
		while(temp && is(a[i],temp) < val)temp--;
		while(temp < a[i] && is(a[i],temp + 1) >= val)temp++;
		b[i] = temp;
		took+=temp;
	}
	return took;
}
int main(){
// 	freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	scanf("%d%lld",&n,&k);
	for(int i = 0;i < n;i++)scanf("%d",a + i);
	long long l = 0,r = 4e18,bst = 0;
	int lol = 0;
	while(l <= r){
		long long mid = (l - offset + r - offset)/2;
		mid+=offset;
		if(get(mid - offset) <= k){
			bst = mid - offset;
			r = mid - 1;
		}
		else l = mid + 1;
	}
	long long rem = k - get(bst);
	for(int i = 0;i < n && rem;i++)
		if(b[i] < a[i] && is(a[i],b[i] + 1) >= bst - 1){
			rem--;
			b[i]++;
		}
	for(int i = 0;i < n;i++)printf("%d ",b[i]);
	puts("");
}

// a - 3b^2 + 3b - 1


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const ll INF = 4e18;
ll n, k;
ll a[100001];
ll ans[100001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

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

	ll l = -INF, r = INF;
	ll sum = 0;
	while (l + 1 < r)
	{
		ll m = (l + r) / 2;

		sum = 0;
		for (int i = 0; i < n; i++)
		{
			ll tl = 0, tr = a[i] + 1;
			while (tl + 1 < tr)
			{
				ll tm = (tl + tr) / 2;
				ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
				if (res >= m) tl = tm;
				else tr = tm;
			}

			sum += tl;
		}

		if (sum > k) l = m;
		else r = m;
	}

	sum = 0;
	for (int i = 0; i < n; i++)
	{
		ll tl = 0, tr = a[i] + 1;
		{
			ll tm = (tl + tr) / 2;
			ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
			if (res >= l) tl = tm;
			else tr = tm;
		}

		ans[i] = tl;
		sum += tl;
	}

	priority_queue <pll> pq;
	for (int i = 0; i < n; i++)
	{
		if (ans[i] == a[i]) continue;
		ll res = ans[i] + 1 - 3 * (ans[i] + 1) * (ans[i] + 1) + 3 * (ans[i] + 1) + 1;
		pq.push({ res, i });
	}

	for (int i = 0; i < k - sum; i++)
	{
		pll tmp = pq.top(); pq.pop();
		ans[tmp.second]++;
	}

	for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const ll INF = 4e18;
ll n, k;
ll a[100001];
ll ans[100001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

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

	ll l = -INF, r = INF;
	ll sum = 0;
	while (l + 1 < r)
	{
		ll m = (l + r) / 2;

		sum = 0;
		for (int i = 0; i < n; i++)
		{
			ll tl = 0, tr = a[i] + 1;
			while (tl + 1 < tr)
			{
				ll tm = (tl + tr) / 2;
				ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
				if (res >= m) tl = tm;
				else tr = tm;
			}

			sum += tl;
		}

		if (sum > k) l = m;
		else r = m;
	}

	sum = 0;
	for (int i = 0; i < n; i++)
	{
		ll tl = 0, tr = a[i] + 1;
		{
			ll tm = (tl + tr) / 2;
			ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
			if (res >= l) tl = tm;
			else tr = tm;
		}

		ans[i] = tl;
		sum += tl;
	}

	priority_queue <pll> pq;
	for (int i = 0; i < n; i++)
	{
		if (ans[i] == a[i]) continue;
		ll res = a[i] - 3 * (ans[i] + 1) * (ans[i] + 1) + 3 * (ans[i] + 1) + 1;
		pq.push({ res, i });
	}

	assert(k - sum < 1e9);

	for (int i = 0; i < k - sum; i++)
	{
		pll tmp = pq.top(); pq.pop();
		int idx = tmp.second;
		ans[idx]++;

		if (ans[idx] != a[idx])
		{
			ll res = a[idx] - 3 * (ans[idx] + 1) * (ans[idx] + 1) + 3 * (ans[idx] + 1) + 1;
			pq.push({ res, idx });
		}
	}

	for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const ll INF = 4e18;
ll n, k;
ll a[100001];
ll ans[100001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

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

	ll l = -INF, r = INF;
	ll sum = 0;
	while (l + 1 < r)
	{
		ll m = (l + r) / 2;

		sum = 0;
		for (int i = 0; i < n; i++)
		{
			ll tl = 0, tr = a[i] + 1;
			while (tl + 1 < tr)
			{
				ll tm = (tl + tr) / 2;
				ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
				if (res >= m) tl = tm;
				else tr = tm;
			}

			sum += tl;
		}

		if (sum > k) l = m;
		else r = m;
	}

	sum = 0;
	for (int i = 0; i < n; i++)
	{
		ll tl = 0, tr = a[i] + 1;
		while (tl + 1 < tr)
		{
			ll tm = (tl + tr) / 2;
			ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
			if (res >= r) tl = tm;
			else tr = tm;
		}

		ans[i] = tl;
		sum += tl;
	}

	priority_queue <pll> pq;
	for (int i = 0; i < n; i++)
	{
		if (ans[i] == a[i]) continue;
		ll res = a[i] - 3 * (ans[i] + 1) * (ans[i] + 1) + 3 * (ans[i] + 1) + 1;
		pq.push({ res, i });
	}

	for (int i = 0; i < k - sum; i++)
	{
		pll tmp = pq.top(); pq.pop();
		int idx = tmp.second;
		ans[idx]++;

		if (ans[idx] != a[idx])
		{
			ll res = a[idx] - 3 * (ans[idx] + 1) * (ans[idx] + 1) + 3 * (ans[idx] + 1) + 1;
			pq.push({ res, idx });
		}
	}

	for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const ll INF = 4e18;
ll n, k;
ll a[100001];
ll ans[100001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

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

	ll l = -INF, r = INF;
	ll sum = 0;
	while (l + 1 < r)
	{
		ll m = (l + r) / 2;

		sum = 0;
		for (int i = 0; i < n; i++)
		{
			ll tl = 0, tr = a[i] + 1;
			while (tl + 1 < tr)
			{
				ll tm = (tl + tr) / 2;
				ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
				if (res >= m) tl = tm;
				else tr = tm;
			}

			sum += tl;
		}

		if (sum > k) l = m;
		else r = m;
	}

	sum = 0;
	for (int i = 0; i < n; i++)
	{
		ll tl = 0, tr = a[i] + 1;
		{
			ll tm = (tl + tr) / 2;
			ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
			if (res >= l) tl = tm;
			else tr = tm;
		}

		ans[i] = tl;
		sum += tl;
	}

	priority_queue <pll> pq;
	for (int i = 0; i < n; i++)
	{
		if (ans[i] == a[i]) continue;
		ll res = a[i] - 3 * (ans[i] + 1) * (ans[i] + 1) + 3 * (ans[i] + 1) + 1;
		pq.push({ res, i });
	}

	for (int i = 0; i < k - sum; i++)
	{
		pll tmp = pq.top(); pq.pop();
		int idx = tmp.second;
		ans[idx]++;

		if (ans[idx] != a[idx])
		{
			ll res = a[idx] - 3 * (ans[idx] + 1) * (ans[idx] + 1) + 3 * (ans[idx] + 1) + 1;
			pq.push({ res, idx });
		}
	}

	for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const ll INF = 4e18;
ll n, k;
ll a[100001];
ll ans[100001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

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

	ll l = -INF, r = INF;
	ll sum = 0;
	while (l + 1 < r)
	{
		ll m = (l + r) / 2;

		sum = 0;
		for (int i = 0; i < n; i++)
		{
			ll tl = 0, tr = a[i] + 1;
			while (tl + 1 < tr)
			{
				ll tm = (tl + tr) / 2;
				ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
				if (res >= m) tl = tm;
				else tr = tm;
			}

			sum += tl;
		}

		if (sum >= k) l = m;
		else r = m;
	}

	sum = 0;
	for (int i = 0; i < n; i++)
	{
		ll tl = 0, tr = a[i] + 1;
		{
			ll tm = (tl + tr) / 2;
			ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
			if (res >= l) tl = tm;
			else tr = tm;
		}

		ans[i] = tl;
		sum += tl;
	}

	priority_queue <pll> pq;
	for (int i = 0; i < n; i++)
	{
		if (ans[i] == a[i]) continue;
		ll res = a[i] - 3 * (ans[i] + 1) * (ans[i] + 1) + 3 * (ans[i] + 1) + 1;
		pq.push({ res, i });
	}

	assert(k - sum < 1e9);

	for (int i = 0; i < k - sum; i++)
	{
		pll tmp = pq.top(); pq.pop();
		int idx = tmp.second;
		ans[idx]++;

		if (ans[idx] != a[idx])
		{
			ll res = a[idx] - 3 * (ans[idx] + 1) * (ans[idx] + 1) + 3 * (ans[idx] + 1) + 1;
			pq.push({ res, idx });
		}
	}

	for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

ll gcd(ll a, ll b) { for (; b; a %= b, swap(a, b)); return a; }

const ll INF = 4e18;
ll n, k;
ll a[100001];
ll ans[100001];

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);

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

	ll l = -INF, r = INF;
	ll sum = 0;
	while (l + 1 < r)
	{
		ll m = (l + r) / 2;

		sum = 0;
		for (int i = 0; i < n; i++)
		{
			ll tl = 0, tr = a[i] + 1;
			while (tl + 1 < tr)
			{
				ll tm = (tl + tr) / 2;
				ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
				if (res >= m) tl = tm;
				else tr = tm;
			}

			sum += tl;
		}

		if (sum > k) l = m;
		else r = m;
	}

	sum = 0;
	for (int i = 0; i < n; i++)
	{
		ll tl = 0, tr = a[i] + 1;
		{
			ll tm = (tl + tr) / 2;
			ll res = a[i] - 3 * tm * tm + 3 * tm + 1;
			if (res >= l) tl = tm;
			else tr = tm;
		}

		ans[i] = tl;
		sum += tl;
	}

	priority_queue <pll> pq;
	for (int i = 0; i < n; i++)
	{
		if (ans[i] == a[i]) continue;
		ll res = a[i] - 3 * (ans[i] + 1) * (ans[i] + 1) + 3 * (ans[i] + 1) + 1;
		pq.push({ res, i });
	}

	for (int i = 0; i < k - sum; i++)
	{
		pll tmp = pq.top(); pq.pop();
		int idx = tmp.second;
		ans[idx]++;
		ll res = a[idx] - 3 * (ans[idx] + 1) * (ans[idx] + 1) + 3 * (ans[idx] + 1) + 1;
		pq.push({ res, idx });
	}

	for (int i = 0; i < n; i++) cout << ans[i] << ' ';
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

const int mxn=1e5+1;
ll arr[mxn], ans[mxn];
int n, k;

ll check(ll delta){
    ll sm=0;
    for(int i=0;i<n;i++){
        ll l=0, r=arr[i]+1;
        while(r-l>1){
            ll m=(r+l)/2;
            if(arr[i]-3ll*m*(m+1)-1 >=delta) l=m;
            else r=m;
        }
        ans[i]=l;
        sm+=l;
    }
    return sm;
}

void solve() {
    cin>>n>>k;
    for (int i = 0; i <n ; ++i) {
        cin>>arr[i];
    }
    // доходы
    ll l=-4e18, r=4e18;
    while(r-l>1){
        ll mm=l+((r-l)>>1);
        if(check(mm)>=k) l=mm;
        else r=mm;
    }
    ll kek=check(l);
    for(int i=0;i<n;i++) {
        if(kek>k && ans[i]>0 && arr[i]-3ll*(ans[i])*(ans[i]+1)-1==l){
            kek--;
            ans[i]--;
        }
        cout<<ans[i]<<" ";
    }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

const int mxn=1e5+1;
ll arr[mxn], ans[mxn];
int n;
ll k;

ll check(ll delta){
    ll sm=0;
    for(int i=0;i<n;i++){
        ll l=0, r=arr[i]+1;
        while(r-l>1){
            ll m=(r+l)/2;
            if(arr[i]-3ll*m*(m+1)-1 >=delta) l=m;
            else r=m;
        }
        ans[i]=l;
        sm+=l;
    }
    return sm;
}

void solve() {
    cin>>n>>k;
    for (int i = 0; i <n ; ++i) {
        cin>>arr[i];
    }
    // доходы
    ll l=-4e18, r=4e18;
    while(r-l>1){
        ll mm=l+((r-l)>>1);
        if(check(mm)>=k) l=mm;
        else r=mm;
    }
    ll kek=check(l);
    for(int i=0;i<n;i++) {
        if(kek>k && ans[i]>0 && arr[i]-3ll*(ans[i])*(ans[i]+1)-1==l){
            kek--;
            ans[i]--;
        }
        cout<<ans[i]<<" ";
    }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

vector<vector<int>> vert;
vector<vector<int>> backw;
vector<int> order;
vector<int> was;
bool isok=true;
void dfs(int v){
    was[v]=1;
    for(int son:vert[v]){
        if(was[son]==1){
            isok=false;
            return;
        }
        if(was[son]==0) dfs(son);
    }

    was[v]=2;
    order.pb(v);
}

void dfs2(int v){
    was[v]=1;
    for(int son:vert[v]){
        if(was[son]==0) dfs2(son);
    }
}
void dfs3(int v){
    was[v]=1;
    for(int son:backw[v]){
        if(was[son]==0) dfs2(son);
    }
}

void solve() {
    int n,m;
    cin>>n>>m;
    vert.assign(n+1, vector<int>(0));
    backw.assign(n+1, vector<int>(0));
    was.resize(n+1,0);
    for(int i=0;i<m;i++){
        int u, v;
        cin>>u>>v;
        vert[u].pb(v);
        backw[v].pb(u);
    }
    for(int i=1;i<n+1;i++){
        if(was[i]==0) dfs(i);
        if(!isok){
            cout<<-1<<endl;
            return;
        }
    }
    was.assign(n+1, 0);
    int kolvo=0;
    vector<char> ans(n+1);
    for(int i=1;i<=n;i++){
        if(was[i]==0){
            ans[i]='A';
            kolvo++;
            dfs2(i);
            dfs3(i);
        }
        else{
            ans[i]='E';
        }
    }
    cout<<kolvo<<endl;
    for(auto &son:ans) cout<<son;

}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

const int mxn=1e5+1;
int arr[mxn], ans[mxn];
int n, k;

ll check(ll delta){
    ll sm=0;
    for(int i=0;i<n;i++){
        ll l=0, r=arr[i]+1;
        while(r-l>1){
            ll m=(r+l)/2;
            if((ll)arr[i]-3*m*(m+1)-1 >=delta) l=m;
            else r=m;
        }
        ans[i]=l;
        sm+=l;
    }
    return sm;
}

void solve() {
    cin>>n>>k;
    for (int i = 0; i <n ; ++i) {
        cin>>arr[i];
    }
    // доходы
    ll l=-4e18, r=4e18;
    while(r-l>1){
        ll mm=l+((r-l)>>1);
        if(check(mm)>=k) l=mm;
        else r=mm;
    }
    ll kek=check(l);
    ll del=kek-k;
    for(int i=0;i<n;i++) {
        if(del!=0){
            ll lol=min((ll)ans[i],del);
            ans[i]-=lol;
            del-=lol;
        }
        cout<<ans[i]<<" ";
    }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
//#pragma GCC target ("sse4")
#pragma optimize("fast-math")

#include <bits/stdc++.h>
#include <stdio.h>

using namespace std;
#define endl '\n'
#define ull unsigned long long
#define si short int
#define ll long long
#define ld long double
#define pb push_back
#define pii pair<int, int>
#define pdd pair<double, double>
#define pil pair<int, ll>
#define pli pair<ll, int>
#define pll pair<ll, ll>
#define piii pair<pair<int, int>, int>
#define all(vec) (vec).begin(), (vec).end()
#define rall(vec) (vec).rbegin(), (vec).rend()
#define piiii pair<pair<int, int>, pair<int, int>>

const int mxn=1e5+1;
int arr[mxn], ans[mxn];
int n, k;

ll check(ll delta){
    ll sm=0;
    for(int i=0;i<n;i++){
        ll l=0, r=arr[i]+1;
        while(r-l>1){
            ll m=(r+l)/2;
            if((ll)arr[i]-3*m*(m+1)-1 >=delta) l=m;
            else r=m;
        }
        ans[i]=l;
        sm+=l;
    }
    return sm;
}

void solve() {
    cin>>n>>k;
    for (int i = 0; i <n ; ++i) {
        cin>>arr[i];
    }
    // доходы
    ll l=-4e18, r=4e18;
    while(r-l>1){
        ll mm=l+((r-l)>>1);
        if(check(mm)>=k) l=mm;
        else r=mm;
    }
    ll kek=check(l);
    for(int i=0;i<n;i++) {
        if(kek>k && ans[i]>0 && (ll)arr[i]-(ll)3*(ans[i])*(ans[i]+1)-1==l){
            kek--;
            ans[i]--;
        }
        cout<<ans[i]<<" ";
    }
}

void testcases(int n) {
    n = 1 - n;
    if (!n) cin >> n;
    for (int i = 0; i < n; i++) {
        solve();
    }
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "r", stdin);
    //f=fopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w");
    //freopen("C:\\Users\\Maximus\\CLionProjects\\Codeforces\\BestTeam\\output.txt", "w", stdout);

    unsigned int beg_time = clock();
    testcases(0);
    // 0 - no t, 1 - with t

    unsigned int end_time = clock();
    //cout << endl << endl << end_time - beg_time;
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

/**
    Thanks you!
**/

const int N = 1e5;
const ll INF = 1e18;

int n;
ll k;
ll a[1 + N], b[1 + N];

bool check (ll d) {
    for (int i = 1; i <= n; i++) {
        if (a[i] <= d) {
            b[i] = 0;
        }
        else {
            b[i] = sqrtl ((a[i] - d) / 3);
            while (b[i] > 0 && a[i] - 3 * b[i] * b[i] < d)
                b[i]--;
            while (a[i] - 3 * b[i] * b[i] > d)
                b[i]++;
            b[i] = min (b[i], a[i]);
        }
    }
    ll sum = 0;
    for (int i = 1; i <= n; i++)
        sum += b[i];
    return sum <= k;
}

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);

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

    ll l = -INF, r = INF;
    ll best = 0;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check (mid))
            best = mid, l = mid + 1;
        else
            r = mid - 1;
    }
    check (best);
    for (int i = 1; i <= n; i++)
        k -= b[i];
    int i = 1;
    while (i <= n && k > 0) {
        if (a[i] != b[i] && a[i] - 3 * b[i] * b[i] == best)
            b[i]++, k--;
        i++;
    }
    for (int i = 1; i <= n; i++)
        cout << b[i] << " ";
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

/**
    Thanks you!
**/

const int N = 1e5;
const ll INF = (ll) 1e18;

int n;
ll k;
ll a[1 + N], b[1 + N];

bool check (ll d) {
    for (int i = 1; i <= n; i++) {
        if (a[i] <= d) {
            b[i] = 0;
        }
        else {
            b[i] = 1ll * sqrtl ((long double)(a[i] - d) / 3);
            while (b[i] > 0 && a[i] - 3 * b[i] * b[i] < d)
                b[i]--;
            while (a[i] - 3 * b[i] * b[i] > d)
                b[i]++;
            b[i] = min (b[i], a[i]);
        }
    }
    ll sum = 0;
    for (int i = 1; i <= n; i++)
        sum += b[i];
    return sum <= k;
}

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);

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

    ll l = -INF, r = INF;
    ll best = 0;
    while (l <= r) {
        ll mid = (l + r) / 2;
        if (check (mid))
            best = mid, r = mid - 1;
        else
            l = mid + 1;
    }
    check (best);
    for (int i = 1; i <= n; i++)
        k -= b[i];
    int i = 1;
    while (i <= n && k > 0) {
        if (a[i] != b[i] && a[i] - 3 * b[i] * b[i] == best)
            b[i]++, k--;
        i++;
    }
    for (int i = 1; i <= n; i++)
        cout << b[i] << " ";
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

/**
    Thanks you!
**/

const int N = 1e5;
const ll INF = 1e18;

int n;
ll k;
ll a[1 + N], b[1 + N];

bool check (ll d) {
    for (int i = 1; i <= n; i++) {
        if (a[i] <= d) {
            b[i] = 0;
        }
        else {
            b[i] = sqrtl ((a[i] - d) / 3);
            while (b[i] > 0 && a[i] - 3 * b[i] * b[i] < d)
                b[i]--;
            while (a[i] - 3 * b[i] * b[i] > d)
                b[i]++;
            b[i] = min (b[i], a[i]);
        }
    }
    ll sum = 0;
    for (int i = 1; i <= n; i++)
        sum += b[i];
    return sum <= k;
}

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);

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

    ll l = -INF, r = INF;
    ll best = 0;
    while (l <= r) {
        int mid = (l + r) / 2;
        if (check (mid))
            best = mid, l = mid + 1;
        else
            r = mid - 1;
    }
    check (best);
    for (int i = 1; i <= n; i++)
        k -= b[i];
    int i = 1;
    while (k) {
        if (a[i] != b[i] && a[i] - 3 * b[i] * b[i] == best)
            b[i]++, k--;
        i++;
    }
    for (int i = 1; i <= n; i++)
        cout << b[i] << " ";
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

/**
    Thanks you!
**/

const int N = 1e5;
const ll INF = (ll) 4e18;

int n;
ll k;
ll a[1 + N], b[1 + N];

bool check (ll d) {
    for (int i = 1; i <= n; i++) {
        if (a[i] <= d) {
            b[i] = 0;
        }
        else {
            b[i] = 1ll * sqrtl ((long double)(a[i] - d) / 3);
            while (b[i] > 0 && a[i] - 3 * b[i] * b[i] < d)
                b[i]--;
            while (a[i] - 3 * b[i] * b[i] > d)
                b[i]++;
            b[i] = min (b[i], a[i]);
        }
    }
    ll sum = 0;
    for (int i = 1; i <= n; i++)
        sum += b[i];
    return sum <= k;
}

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);

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

    ll l = -INF, r = INF;
    ll best = 0;
    while (l <= r) {
        ll mid = (l + r) / 2;
        if (check (mid))
            best = mid, r = mid - 1;
        else
            l = mid + 1;
    }
    check (best);
    for (int i = 1; i <= n; i++)
        k -= b[i];
    int i = 1;
    while (i <= n && k > 0) {
        if (a[i] != b[i] && a[i] - 3 * b[i] * b[i] == best)
            b[i]++, k--;
        i++;
    }
    for (int i = 1; i <= n; i++)
        cout << b[i] << " ";
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
#define pb push_back
#define dbg(x) cerr << #x << " " << x << "\n"

/**
    Thanks you!
**/

const int N = 1e5;
const ll INF = 1e18;

int n;
ll k;
ll a[1 + N], b[1 + N];

bool check (ll d) {
    for (int i = 1; i <= n; i++) {
        if (a[i] <= d) {
            b[i] = 0;
        }
        else {
            b[i] = sqrtl ((a[i] - d) / 3);
            while (b[i] > 0 && a[i] - 3 * b[i] * b[i] < d)
                b[i]--;
            while (a[i] - 3 * b[i] * b[i] > d)
                b[i]++;
            b[i] = min (b[i], a[i]);
        }
    }
    ll sum = 0;
    for (int i = 1; i <= n; i++)
        sum += b[i];
    return sum <= k;
}

int main () {
    ios::sync_with_stdio (false);
    cin.tie (0); cout.tie (0);

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

    ll l = -INF, r = INF;
    ll best = 0;
    while (l <= r) {
        ll mid = (l + r) / 2;
        if (check (mid))
            best = mid, l = mid + 1;
        else
            r = mid - 1;
    }
    check (best);
    for (int i = 1; i <= n; i++)
        k -= b[i];
    int i = 1;
    while (i <= n && k > 0) {
        if (a[i] != b[i] && a[i] - 3 * b[i] * b[i] == best)
            b[i]++, k--;
        i++;
    }
    for (int i = 1; i <= n; i++)
        cout << b[i] << " ";
    cout << "\n";
    return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2 + 1;
    if (calc(mid) >= k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  calc(l);
  auto old_b = b;

  l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int64 cur = calc(l);

  //for (int x : b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';
  //for (int x : old_b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }

  //auto f = [&] () {
  //  int64 res = 0;
  //  for (int i = 0; i < n; ++i) {
  //    res += b[i] * (a[i] - b[i] * b[i]);
  //  }
  //  return res;
  //};
  //assert(cur == k);
  //cout << f() << '\n';
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2 + 1;
    if (calc(mid) > k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  calc(l);
  auto old_b = b;

  l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int64 cur = calc(l);

  //for (int x : b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';
  //for (int x : old_b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }

  //auto f = [&] () {
  //  int64 res = 0;
  //  for (int i = 0; i < n; ++i) {
  //    res += b[i] * (a[i] - b[i] * b[i]);
  //  }
  //  return res;
  //};
  //assert(cur == k);
  //cout << f() << '\n';
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2 + 1;
    if (calc(mid) >= k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  int64 old_k = calc(l);
  auto old_b = b;

  l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int64 cur = calc(l);

  //for (int x : b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';
  //for (int x : old_b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }

  if (cur != k) {
    cout << old_k << ' ' << cur << '\n';
    return;
  }

  //auto f = [&] () {
  //  int64 res = 0;
  //  for (int i = 0; i < n; ++i) {
  //    res += b[i] * (a[i] - b[i] * b[i]);
  //  }
  //  return res;
  //};
  //assert(cur == k);
  //cout << f() << '\n';
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64 * 7, r = inf64 * 7;
  while (l < r) {
    int64 mid = l + (r - l) / 2 + 1;
    if (calc(mid) >= k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  int64 old_k = calc(l);
  auto old_b = b;

  if (old_k < k) {
    cout << old_k << '\n' << k << '\n' << l << '\n';
    return;
  }

  l = -inf64 * 7, r = inf64 * 7;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int64 cur = calc(l);

  //for (int x : b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';
  //for (int x : old_b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }

  //auto f = [&] () {
  //  int64 res = 0;
  //  for (int i = 0; i < n; ++i) {
  //    res += b[i] * (a[i] - b[i] * b[i]);
  //  }
  //  return res;
  //};
  //assert(cur == k);
  //cout << f() << '\n';
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64 * 4, r = inf64 * 4;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  calc(l - 1);
  auto old_b = b;
  int64 cur = calc(l);

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2 + 1;
    if (calc(mid) > k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  calc(l);
  auto old_b = b;

  l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int64 cur = calc(l);

  //for (int x : b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';
  //for (int x : old_b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }

  //auto f = [&] () {
  //  int64 res = 0;
  //  for (int i = 0; i < n; ++i) {
  //    res += b[i] * (a[i] - b[i] * b[i]);
  //  }
  //  return res;
  //};
  //assert(cur == k);
  //cout << f() << '\n';
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64 * 4, r = inf64 * 4;
  while (l < r) {
    int64 mid = l + (r - l) / 2 + 1;
    if (calc(mid) >= k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  int64 old_k = calc(l);
  auto old_b = b;

  if (old_k < k) {
    cout << old_k << '\n' << k << '\n' << l << '\n';
    return;
  }

  l = -inf64 * 4, r = inf64 * 4;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int64 cur = calc(l);

  //for (int x : b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';
  //for (int x : old_b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }

  //auto f = [&] () {
  //  int64 res = 0;
  //  for (int i = 0; i < n; ++i) {
  //    res += b[i] * (a[i] - b[i] * b[i]);
  //  }
  //  return res;
  //};
  //assert(cur == k);
  //cout << f() << '\n';
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2 + 1;
    if (calc(mid) >= k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  int64 old_k = calc(l);
  auto old_b = b;

  if (old_k < k) {
    cout << old_k << '\n' << k << '\n';
    return;
  }

  l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int64 cur = calc(l);

  //for (int x : b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';
  //for (int x : old_b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }

  //auto f = [&] () {
  //  int64 res = 0;
  //  for (int i = 0; i < n; ++i) {
  //    res += b[i] * (a[i] - b[i] * b[i]);
  //  }
  //  return res;
  //};
  //assert(cur == k);
  //cout << f() << '\n';
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <bits/stdc++.h>
#include <cctype>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, std::less<>, rb_tree_tag, tree_order_statistics_node_update>;
using namespace std;
typedef long long int64;
typedef unsigned long long uint64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//*/998244353;
const int base = 2187;
const double eps = 1e-9;
const int N = 300'000;
const int LOGN = 19;

int n, m, k;

void solve(int) {
  int64 k;
  cin >> n >> k;
  vector<int> a(n), b(n);
  for (int& x : a) {
    cin >> x;
  }
  auto calc = [&] (int64 val) {
    int64 res = 0;
    for (int i = 0; i < n; ++i) {
      int64 l = 0, r = a[i];
      while (l < r) {
        int64 mid = (l + r + 1) / 2;
        if (a[i] - 3 * mid * mid + 3 * mid - 1 >= val) {
          l = mid;
        } else {
          r = mid - 1;
        }
      }
      b[i] = (int)l;
      res += l;
    }
    return res;
  };
  int64 l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2 + 1;
    if (calc(mid) >= k) {
      l = mid;
    } else {
      r = mid - 1;
    }
  }
  int64 old_k = calc(l);
  auto old_b = b;

  if (old_k < k) {
    cout << old_k << '\n' << k << '\n' << l << '\n';
    return;
  }

  l = -inf64, r = inf64;
  while (l < r) {
    int64 mid = l + (r - l) / 2;
    if (calc(mid) > k) {
      l = mid + 1;
    } else {
      r = mid;
    }
  }
  int64 cur = calc(l);

  //for (int x : b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';
  //for (int x : old_b) {
  //  cout << x << ' ';
  //}
  //cout << '\n';

  for (int i = 0; cur < k && i < n; ++i) {
    if (b[i] + 1 == old_b[i]) {
      ++cur;
      ++b[i];
    }
  }

  //auto f = [&] () {
  //  int64 res = 0;
  //  for (int i = 0; i < n; ++i) {
  //    res += b[i] * (a[i] - b[i] * b[i]);
  //  }
  //  return res;
  //};
  //assert(cur == k);
  //cout << f() << '\n';
  for (int x : b) {
    cout << x << ' ';
  }
  cout << '\n';
}

void precalc() {
}

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i) {
    solve(i);
  }
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
int direct;
long long a[N], b[N];
struct node{
    long long first;
    int second;
};
bool operator<(node a, node  b) {
    return a.first < b.first;
}
priority_queue<node > q;
long long calc(long long a, long long b, int direct) {
    return a * direct - 3 * direct * b *b - 3 * direct * direct * b - direct * direct * direct;
}
inline void update(int x){
    if (b[x] +direct < 0 || b[x] + direct > a[x]) return;
    q.push({calc(a[x], b[x], direct), x});
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++) {
        scanf("%lld", &a[i]);
        b[i] = sqrtl((long double)a[i] / 3);
        b[i] = min(b[i], a[i]);
        while (b[i] < a[i] && calc(a[i], b[i], 1) >= 0) b[i] ++;
        while (b[i] && calc(a[i], b[i], - 1)  > 0) b[i] --;
        all += b[i];
    }
    if (all != k) {
        if (all > k) direct = -1;
        else
            direct = 1;
        for (int i = 1; i <= n; i ++)
            update(i);
        while (all != k) {
            all += direct;
            auto u = q.top();
            q.pop();
            b[u.second] += direct;
            update(u.second);
        }
    }
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
#include <climits>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
long long a[N], b[N];
long long calc(long long a, long long b, long long c) {
    return (-b - sqrtl((long double) b * b - (long double)4 * a * c)) / (2 * a);
}
long long get(long long v) {
    long long sum = 0;
    for (int i = 1; i <= n; i ++)
        b[i] = min(max(1ll * 0, calc(-3, 3, -1 - v + a[i])), a[i]), sum += b[i];
    return sum;
}
long long calc1(long long a, long long b) {
    return a - b * b * 3 + 3 * b - 1;
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++)
        scanf("%lld", &a[i]);
    long long l = LONG_LONG_MIN, r = LONG_LONG_MIN, s = LONG_LONG_MIN, mid = 0;
    while (l <= r) {
        if (get(mid =  (l / 2 +  r/ 2 + ((l & 1 )&&(r & 1))) ) >= k) l = mid +1, s = max(s, mid);
        else
            r = mid - 1;
    }
    long long delta = get(s) - k;
    for (int i = 1; i <= n && delta; i ++)
        while (b[i] && calc1(a[i], b[i]) == s)
            b[i] --, delta --;
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
int direct;
long long a[N], b[N];
struct node{
    __int128 first;
    int second;
};
bool operator<(node a, node  b) {
    return a.first < b.first;
}
priority_queue<node > q;
inline __int128 calc(__int128 a, __int128 b) {
    return b * ( a - b * b);
}
inline void update(int x){
    if (b[x] +direct < 0 || b[x] + direct > a[x]) return;
    q.push({calc(a[x], b[x] + direct) - calc(a[x], b[x]), x});
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++) {
        scanf("%lld", &a[i]);
        b[i] = sqrtl((long double)a[i] / 3);
        b[i] = min(b[i], a[i]);
        while (b[i] < a[i] && calc(a[i], b[i] + 1) >= calc(a[i], b[i])) b[i] ++;
        while (b[i] && calc(a[i], b[i] - 1) > calc(a[i], b[i])) b[i] --;
        all += b[i];
    }
    if (all != k) {
        if (all > k) direct = -1;
        else
            direct = 1;
        for (int i = 1; i <= n; i ++)
            update(i);
        while (all != k) {
            all += direct;
            auto u = q.top();
            q.pop();
            b[u.second] += direct;
            update(u.second);
        }
    }
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
#include <climits>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
long long a[N], b[N];
long long calc(long long a, long long b, __int128 c) {
    return (-b - sqrtl((long double) b * b - (long double)4 * a * c)) / (2 * a);
}
long long get(__int128 v) {
    long long sum = 0;
    for (int i = 1; i <= n; i ++)
        b[i] = min(max((long long)  0, calc(-3, 3, -1 - v + a[i])), a[i]), sum += b[i];
    return sum;
}
long long calc1(long long a, long long b) {
    return a - b * b * 3 + 3 * b - 1;
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++)
        scanf("%lld", &a[i]);
    __int128 l = LONG_LONG_MIN, r = LONG_LONG_MIN, s = LONG_LONG_MIN, mid = 0;
    while (l <= r) {
        if (get(mid =  (l +  r) / 2) >= k) l = mid +1, s = max(s, mid);
        else
            r = mid - 1;
    }
    long long delta = get(s) - k;
    for (int i = 1; i <= n && delta; i ++)
        while (b[i] && calc1(a[i], b[i]) == s)
            b[i] --, delta --;
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
int direct;
long long a[N], b[N];
bool operator<(pair<__int128, int>a, pair<__int128, int> b) {
    return a.first < b.first;
}
priority_queue<pair<__int128, int> > q;
inline __int128 calc(__int128 a, __int128 b) {
    return b * ( a - b * b);
}
inline void update(int x){
    if (b[x] +direct < 0 || b[x] + direct > a[x]) return;
    q.push({calc(a[x], b[x] + direct) - calc(a[x], b[x]), x});
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++) {
        scanf("%lld", &a[i]);
        b[i] = sqrtl((long double)a[i] / 3);
        b[i] = min(b[i], a[i]);
        while (b[i] < a[i] && calc(a[i], b[i] + 1) >= calc(a[i], b[i])) b[i] ++;
        while (b[i] && calc(a[i], b[i] - 1) > calc(a[i], b[i])) b[i] --;
        all += b[i];
    }
    if (all != k) {
        if (all > k) direct = -1;
        else
            direct = 1;
        for (int i = 1; i <= n; i ++)
            update(i);
        while (all != k) {
            all += direct;
            auto u = q.top();
            q.pop();
            b[u.second] += direct;
            update(u.second);
        }
    }
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
#include <climits>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
long long a[N], b[N];
long long calc(long long a, long long b, long long c) {
    return (-b - sqrtl((long double) b * b - (long double)4 * a * c)) / (2 * a);
}
long long get(long long v) {
    long long sum = 0;
    for (int i = 1; i <= n; i ++)
        b[i] = min(max(1ll * 0, calc(-3, 3, -1 - v + a[i])), a[i]), sum += b[i];
    return sum;
}
long long calc1(long long a, long long b) {
    return a - b * b * 3 + 3 * b - 1;
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++)
        scanf("%lld", &a[i]);
    long long l = LONG_LONG_MIN, r = LONG_LONG_MAX, s = LONG_LONG_MIN, mid = 0;
    while (l <= r) {
        if (get(mid =  (l / 2 +  r/ 2 + ((l & 1 )&&(r & 1))) ) >= k) l = mid +1, s = max(s, mid);
        else
            r = mid - 1;
    }
    long long delta = get(s) - k;
    for (int i = 1; i <= n && delta; i ++)
        while (b[i] && calc1(a[i], b[i]) == s)
            b[i] --, delta --;
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}


#include <algorithm>
#include <cstdio>
#include <queue>
#include <cmath>
using namespace std;
const int N = 1e5 + 10;
int n;
long long k, all;
int direct;
long long a[N], b[N];
priority_queue<pair<__int128, int> > q;
inline __int128 calc(__int128 a, __int128 b) {
    return b * ( a - b * b);
}
inline void update(int x){
    if (b[x] +direct < 0 || b[x] + direct > a[x]) return;
    q.push({calc(a[x], b[x] + direct) - calc(a[x], b[x]), x});
}
int main() {
    scanf("%d %lld", &n, &k);
    for (int i = 1; i <= n; i ++) {
        scanf("%lld", &a[i]);
        b[i] = sqrtl((long double)a[i] / 3);
        b[i] = min(b[i], a[i]);
        while (b[i] < a[i] && calc(a[i], b[i] + 1) >= calc(a[i], b[i])) b[i] ++;
        while (b[i] && calc(a[i], b[i] - 1) > calc(a[i], b[i])) b[i] --;
        all += b[i];
    }
    if (all != k) {
        if (all > k) direct = -1;
        else
            direct = 1;
        for (int i = 1; i <= n; i ++)
            update(i);
        while (all != k) {
            all += direct;
            auto u = q.top();
            q.pop();
            b[u.second] += direct;
            update(u.second);
        }
    }
    for (int i= 1; i <= n; i ++)
        printf("%lld%c", b[i], " \n"[i == n]);
    return 0;
}