Polycarp invited all his friends to the tea party to celebrate the holiday. He has n cups, one for each of his n friends, with volumes a_1, a_2, ..., a_{n}. His teapot stores w milliliters of tea (w ≤ a_1 + a_2 + ... + a_{n}). Polycarp wants to pour tea in cups in such a way that:  Every cup will contain tea for at least half of its volume  Every cup will contain integer number of milliliters of tea  All the tea from the teapot will be poured into cups  All friends will be satisfied. 

Friend with cup i won't be satisfied, if there exists such cup j that cup i contains less tea than cup j but a_{i} > a_{j}.

For each cup output how many milliliters of tea should be poured in it. If it's impossible to pour all the tea and satisfy all conditions then output -1.


-----Input-----

The first line contains two integer numbers n and w (1 ≤ n ≤ 100, $1 \leq w \leq \sum_{i = 1}^{n} a_{i}$).

The second line contains n numbers a_1, a_2, ..., a_{n} (1 ≤ a_{i} ≤ 100).


-----Output-----

Output how many milliliters of tea every cup should contain. If there are multiple answers, print any of them.

If it's impossible to pour all the tea and satisfy all conditions then output -1.


-----Examples-----
Input
2 10
8 7

Output
6 4 

Input
4 4
1 1 1 1

Output
1 1 1 1 

Input
3 10
9 8 10

Output
-1



-----Note-----

In the third example you should pour to the first cup at least 5 milliliters, to the second one at least 4, to the third one at least 5. It sums up to 14, which is greater than 10 milliliters available.

Difficulty: MEDIUM
Tags: Greedy algorithms

Sorting

Constructive algorithms
Skill types: Sorting

Greedy algorithms

Starter code:

Solutions:
(n, w) = input().split()
(n, w) = (int(n), int(w))
x = [int(i) for i in input().split()]
need = 0
ans = []
for i in range(0, n):
	need += (x[i] + 1) // 2
	ans.append([(x[i] + 1) // 2, x[i], i])
if w < need:
	print(-1)
else:
	w -= need
	ans.sort(key=lambda x: x[1], reverse=1)
	for i in range(n):
		now = ans[i][1] - ans[i][0]
		if w >= now:
			w -= now
			ans[i][0] = ans[i][1]
		else:
			ans[i][0] += w
			break
	ans.sort(key=lambda x: x[2])
	for i in range(n):
		print(ans[i][0], end=' ')


import math
(n, w) = map(int, input().split())
volumes = []
possible = True
teacups = [0] * n
vals = list(map(int, input().split()))
for i in range(n):
	poured = math.ceil(vals[i] / 2)
	w -= poured
	if w < 0:
		possible = False
		break
	volumes.append((vals[i], i))
	teacups[i] = poured
if not possible:
	print(-1)
else:
	svolumes = sorted(volumes, reverse=True)
	for j in svolumes:
		extra = j[0] - teacups[volumes.index(j)]
		if w - extra < 0:
			teacups[j[1]] += w
			break
		w -= extra
		teacups[j[1]] += extra
	print(' '.join((str(t) for t in teacups)))


from math import ceil

def selected_sum(l, p):
	r = 0
	for i in l:
		r += l[p]
	return r

def solve(n, w, a):
	(l, s) = ([], [])
	for i in range(n):
		l.extend([ceil(a[i] / 2)])
	dif = w - sum(l)
	if dif < 0:
		return -1
	for i in range(n):
		for j in range(i):
			if a[i] > a[j] and l[i] < l[j]:
				s.append([l[j] - l[i], i])
	if selected_sum(s, 0) > dif:
		return -1
	for k in s:
		l[k[1]] += k[0]
	S = [i[0] for i in sorted(enumerate(a), key=lambda x: x[1])]
	dif = w - sum(l)
	if dif < 0:
		return -1
	if dif == 0:
		return l
	while sum(l) != w:
		if l[S[i]] < A[S[i]]:
			l[S[i]] += min(A[S[i]] - l[S[i]], dif)
			dif = w - sum(l)
			if i == 0 and dif > 0:
				return -1
			i -= 1
	return l
(N, W) = [int(i) for i in input().split()]
A = [int(i) for i in input().split()]
if solve(N, W, A) == -1:
	print(solve(N, W, A))
else:
	for (i, item) in enumerate(solve(N, W, A)):
		if i != len(solve(N, W, A)) - 1:
			print(str(item) + ' ', end='')
		else:
			print(item)


import math

def main():
	a = input()
	a = a.split()
	n = int(a[0])
	w = int(a[1])
	b = input()
	b = b.split()
	arr2 = []
	arr = []
	add = 0
	for i in range(0, n):
		b[i] = int(b[i])
		arr2.append(b[i])
		if b[i] % 2 == 0:
			add += b[i] / 2
			arr.append(b[i] / 2)
		else:
			add += math.floor(b[i] / 2) + 1
			arr.append(b[i] / float(2) + 1)
	arr2.sort()
	left = w - add
	i = n - 1
	if left < 0:
		print(-1)
	else:
		while left > 0:
			if arr2[i] % 2 == 0:
				if left >= arr2[i] / 2:
					left = left - arr2[i] / 2
					for k in range(0, n):
						if arr[k] == arr2[i] / 2:
							arr[k] = arr2[i]
							break
				else:
					for k in range(0, n):
						if arr[k] == arr2[i] / 2:
							arr[k] = arr[k] + left
							break
					left = 0
			elif left > math.floor(arr2[i] / 2):
				left = left - math.floor(arr2[i] / 2)
				for k in range(0, n):
					if arr[k] == arr2[i] / float(2) + 1:
						arr[k] = arr2[i]
						break
			else:
				for k in range(0, n):
					if arr[k] == arr2[i] / float(2) + 1:
						arr[k] = arr[k] + left
						break
				left = 0
			i = i - 1
		for z in range(0, n):
			print(math.floor(arr[z]), end=' ')
main()


import copy

def f(n, w, L):
	D = dict()
	count = 0
	for i in range(n):
		D[i] = -1 * (-1 * L[i] // 2)
		count += D[i]
	if count > w:
		return -1
	E = dict()
	M = copy.deepcopy(L)
	M.sort()
	N = copy.deepcopy(L)
	j = n - 1
	while j > -1:
		m = max(N)
		i = N.index(m)
		E[j] = i
		N[i] = -1
		j -= 1
	remaining = w - count
	k = n - 1
	while remaining > 0:
		i = E[k]
		diff = L[i] - D[i]
		if remaining >= diff:
			D[i] = L[i]
		else:
			D[i] += remaining
		remaining -= diff
		k -= 1
	s = ''
	for i in range(n):
		s += str(D[i]) + ' '
	return s

def run():
	i = 0
	for line in iter(input, ''):
		if i == 0:
			a = line.split(' ')
			(n, w) = (int(a[0]), int(a[1]))
		else:
			line = line.split(' ')
			L = list(map(int, line))
			break
		i += 1
	print(f(n, w, L))
run()


def solve():
	(n, w) = map(int, input().split())
	a = list(map(int, input().split()))
	mp = [[a[i], i] for i in range(n)]
	mp.sort()
	ans = [[mp[i][1], 0] for i in range(n)]
	mi = 0
	for i in range(n):
		t = max(mi, mp[i][0] // 2 + mp[i][0] % 2)
		ans[i][1] = t
		w -= t
		mi = t
	if w < 0:
		print(-1)
	else:
		for i in range(-1, -n - 1, -1):
			if w > mp[i][0] - ans[i][1]:
				w -= mp[i][0] - ans[i][1]
				ans[i][1] = mp[i][0]
			else:
				ans[i][1] += w
				break
		ans.sort()
		for i in range(n):
			print(ans[i][1], end=' ')
solve()


(n, w) = (int(i) for i in input().split())
mas = [int(i) for i in input().split()]

def qer():
	global w
	for (i, size) in enumerate(mas):
		q = round(size / 2 + 0.1)
		rer[size, i] = q
		w -= q
		if w < 0:
			return {1: -1}
	for (size, i) in sorted(rer, reverse=True):
		o = size - rer[size, i]
		rer[size, i] += min(w, o)
		w -= min(o, w)
		if w == 0:
			break
	return rer
rer = {}
print(*qer().values())


import math

def fillTea(water, cups):
	curW = water
	for i in range(len(cups)):
		curW -= math.ceil(cups[i] / 2)
		cups[i] = [cups[i], i, math.ceil(cups[i] / 2)]
	cups = sorted(cups, key=lambda l: l[0], reverse=True)
	if curW < 0:
		return ['-1']
	curCup = 0
	while curW > 0:
		curP = min(cups[curCup][0] - cups[curCup][2], curW)
		cups[curCup][2] += curP
		curW -= curP
		curCup += 1
	cups = sorted(cups, key=lambda l: l[1], reverse=False)
	for i in range(len(cups)):
		cups[i] = str(cups[i][2])
	if curW < 0:
		return ['-1']
	return cups

def __starting_point():
	[n, w] = [int(x) for x in input().split()]
	cups = [int(x) for x in input().split()]
	print(' '.join(fillTea(w, cups)))
__starting_point()


(n, w) = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]
a_index = [(x, i) for (i, x) in enumerate(a)]
a_index.sort(reverse=True)
res = [0] * len(a)
for (x, i) in a_index:
	need = (x + 1) // 2
	res[i] = need
	w -= need
	if w < 0:
		print(-1)
		return
if w > 0:
	for (x, i) in a_index:
		if w == 0:
			break
		need = min(w, x - res[i])
		res[i] += need
		w -= need
print(res[0], end='')
for i in range(1, len(res)):
	print(' ' + str(res[i]), end='')
print()


(n, w) = [int(s) for s in input().split()]
a = [int(s) for s in input().split()]
b = [elem // 2 + elem % 2 for elem in a]
if sum(b) > w:
	print(-1)
elif sum(b) == w:
	print(' '.join([str(e) for e in b]))
else:
	for i in range(len(a)):
		a[i] = [a[i], i]
	a.sort(reverse=True)
	d = w - sum(b)
	i = 0
	while d > 0:
		j = a[i][1]
		m = min(d, a[i][0] - b[j])
		b[j] += m
		d -= m
		i += 1
	print(' '.join([str(e) for e in b]))


import sys

def drinking(n, w, a):
	if sum(a) / 2 > w:
		print(-1)
		sys.exit()
	sorted_a = []
	for i in range(len(a)):
		sorted_a.append([i, a[i]])
	sorted_a = sorted(sorted_a, key=lambda tup: tup[1])
	for i in range(len(sorted_a)):
		if sorted_a[i][1] // 2 * 2 >= sorted_a[i][1]:
			w -= sorted_a[i][1] // 2
			sorted_a[i][1] -= sorted_a[i][1] // 2
		else:
			w -= sorted_a[i][1] // 2 + 1
			sorted_a[i][1] -= sorted_a[i][1] // 2 + 1
	i = len(sorted_a) - 1
	if w < 0:
		print(-1)
		sys.exit()
	while w > 0:
		if w >= sorted_a[i][1]:
			w -= sorted_a[i][1]
			sorted_a[i][1] = 0
		if w < sorted_a[i][1]:
			sorted_a[i][1] -= w
			w = 0
		if i > 0:
			i -= 1
		else:
			i = len(sorted_a) - 1
	sorted_a = sorted(sorted_a, key=lambda tup: tup[0])
	for i in range(len(sorted_a)):
		a[i] -= sorted_a[i][1]
	for i in range(len(a)):
		if a[i] == 0:
			print(-1)
			sys.exit()
	return a
(n, w) = map(int, input().split())
a = [int(i) for i in input().split()]
result = ' '.join(map(str, drinking(n, w, a)))
print(result)


from sys import stdin, stdout
(n, w) = map(int, stdin.readline().strip().split())
arr = sorted([(int(num), i) for (i, num) in enumerate(stdin.readline().strip().split())], key=lambda t: t[0], reverse=False)
outputs = [-1] * n
condn = True
for i in arr:
	req = i[0] // 2 if i[0] % 2 == 0 else i[0] // 2 + 1
	if req <= w:
		w -= req
		outputs[i[1]] = req
	else:
		condn = False
		break
if condn:
	for i in range(n - 1, -1, -1):
		req = arr[i][0] // 2
		if w == 0:
			break
		outputs[arr[i][1]] += min(req, w)
		w -= min(req, w)
	stdout.write(' '.join(list(map(str, outputs))))
else:
	stdout.write('-1')


(n, w) = map(int, input().split())
sizes = list(map(int, input().split()))
res = [(s + 1) // 2 for s in sizes]
threshold = sum(res)
if threshold > w:
	print(-1)
else:
	indices = sorted(range(n), key=sizes.__getitem__, reverse=True)
	w -= threshold
	for i in indices:
		transferendum = min(w, sizes[i] - res[i])
		(res[i], w) = (res[i] + transferendum, w - transferendum)
		if w == 0:
			break
	print(*res)


(q, w) = map(int, input().split())
s = list(map(int, input().split()))
p = list(map(lambda x: (x + x % 2) // 2, s))
h = {}
for i in range(len(s)):
	h[s[i]] = []
for i in range(len(s)):
	h[s[i]].append(p[i])
lp = sum(p)
if lp > w:
	print(-1)
else:
	w -= lp
	p = sorted(h.keys(), reverse=True)
	lkl = s.copy()
	while w > 0:
		i = max(s)
		if sum(h[i]) == i * len(h[i]):
			s.pop(s.index(i))
		if min(h[i]) < i:
			if i - min(h[i]) > w:
				h[i][h[i].index(min(h[i]))] += w
				w = 0
			else:
				kj = h[i].index(min(h[i]))
				w -= i - h[i][kj]
				h[i][kj] = i
	kl = []
	for i in lkl:
		kl.append(h[i].pop(0))
	print(*kl)


(n, w) = map(int, input().split())
Cup = list(map(int, input().split()))
Water = []
for a in Cup:
	Water.append((a + 1) // 2)
res = w - sum(Water)
if res < 0:
	print(-1)
else:
	while res > 0:
		i = Cup.index(max(Cup))
		num = min(res, Cup[i] - Water[i])
		Water[i] += num
		res -= num
		Cup[i] = 0
	s = str(Water[0])
	for c in range(1, len(Water)):
		s += ' ' + str(Water[c])
	print(s)


(n, totaltea) = map(int, input().split())
ar = list(map(int, input().split()))
ans = [0] * n
for i in range(n):
	ans[i] = (ar[i] + 1) // 2
if sum(ans) > totaltea:
	print(-1)
else:
	for i in range(n):
		ar[i] = [ar[i], i]
	ar = sorted(ar)[::-1]
	remain = totaltea - sum(ans)
	for i in range(n):
		if remain == 0:
			break
		k = min(remain, ar[i][0] - ans[ar[i][1]])
		ans[ar[i][1]] += k
		remain -= k
	if remain != 0:
		print(-1)
	else:
		print(*ans)


def main():
	(n, w) = map(int, input().split())
	a = map(int, input().split())
	a = sorted([(x, i) for (i, x) in enumerate(a)])
	f = []
	for (ai, _) in a:
		x = (ai + 1) // 2
		f.append(x)
		w -= x
	if w < 0:
		print(-1)
		return
	i = n - 1
	while w > 0:
		if f[i] < a[i][0]:
			f[i] += 1
			w -= 1
		i -= 1
		if i == -1:
			i = n - 1
	ans = [0] * n
	for i in range(n):
		ans[a[i][1]] = f[i]
	for x in ans:
		print(x, end=' ')
main()


class node:

	def _init_(self):
		self.ind = 0
		self.val = 0
		self.ans = 0

def cmp1(a):
	return a.val

def cmp2(a):
	return a.ind
(n, w) = map(int, input().strip().split())
a = input()
b = list(map(int, a.strip().split()))
hand = []
sum = 0
for i in range(n):
	x = node()
	x.ind = i
	x.val = b[i]
	x.ans = int((b[i] + 1) / 2)
	hand.append(x)
	sum += x.ans
if sum > w:
	print(-1)
else:
	w -= sum
	hand.sort(key=cmp1, reverse=True)
	for i in range(n):
		temp = hand[i].val - hand[i].ans
		if w > temp:
			w -= temp
			hand[i].ans += temp
		else:
			hand[i].ans += w
			break
	hand.sort(key=cmp2)
	for i in range(n):
		print(hand[i].ans, end=' ')
	print()


def mp():
	return list(map(int, input().split()))

def lt():
	return list(map(int, input().split()))

def pt(x):
	print(x)

def ip():
	return input()

def it():
	return int(input())

def sl(x):
	return [t for t in x]

def spl(x):
	return x.split()

def aj(liste, item):
	liste.append(item)

def bin(x):
	return '{0:b}'.format(x)

def listring(l):
	return ' '.join([str(x) for x in l])

def ptlist(l):
	print(' '.join([str(x) for x in l]))
(n, w) = mp()
a = lt()
b = [int((a[i] + 1) / 2) for i in range(n)]
if sum(b) <= w:
	d = w - sum(b)
	c = sorted([i for i in range(n)], key=lambda x: a[x], reverse=True)
	while d > 0:
		i = c[0]
		r = min(d, a[i] - b[i])
		d -= r
		b[i] += r
		c.pop(0)
	ptlist(b)
else:
	pt(-1)


f = lambda : map(int, input().split())
(n, w) = f()
t = list(f())
if sum(t) < w:
	print(-1)
else:
	p = [(a + 1) // 2 for a in t]
	d = w - sum(p)
	if d < 0:
		print(-1)
	else:
		p = sorted(zip(t, p, range(n)))
		for (a, b, i) in p[::-1]:
			if d == 0:
				t[i] = b
			elif a > b + d:
				(d, t[i]) = (0, b + d)
			else:
				d -= a - b
		print(' '.join(map(str, t)))


(n, chainik) = map(int, input().split(' '))
chashki = list(map(int, input().split(' ')))
nalito = {}

def nalit():
	global chainik
	for (i, razmer) in enumerate(chashki):
		tmp = int(round(razmer / 2 + 0.1))
		nalito[razmer, i] = tmp
		chainik -= tmp
		if chainik < 0:
			return [-1]
	for (razmer, i) in sorted(nalito, reverse=True):
		ostatok = razmer - nalito[razmer, i]
		pribvaka = min(ostatok, chainik)
		nalito[razmer, i] += pribvaka
		chainik -= pribvaka
		if chainik == 0:
			break
	return [nalito[razmer, i] for (i, razmer) in enumerate(chashki)]
print(*nalit())


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
d = dict()
for (i, ai) in enumerate(a):
	d[ai, i] = (ai + 1) // 2
s = sum(d.values())
if w < s:
	print(-1)
else:
	delta = w - s
	for (ai, i) in sorted(d.keys())[::-1]:
		dai = ai - d[ai, i]
		d1 = min(delta, dai)
		d[ai, i] += d1
		delta -= d1
		if delta <= 0:
			break
	b = [0] * n
	for (ai, i) in d:
		b[i] = d[ai, i]
	print(' '.join(map(str, b)))


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
b = [(ai + 1) // 2 for ai in a]
w -= sum(b)
if w < 0:
	print(-1)
else:
	ind = sorted(range(n), key=lambda i: a[i], reverse=True)
	for i in ind:
		d = a[i] - b[i]
		if w <= d:
			b[i] += w
			break
		w -= d
		b[i] = a[i]
	print(*b)


import sys
from itertools import accumulate

def solve():
	(n, w) = map(int, input().split())
	a = [int(i) for i in input().split()]
	b = [0] * n
	for (i, ai) in enumerate(a):
		tmp = (ai + 1) // 2
		w -= tmp
		b[i] += tmp
		if w < 0:
			print(-1)
			return
	ag = [(ai, i) for (i, ai) in enumerate(a)]
	ag.sort(reverse=True)
	for i in range(n):
		v = ag[i][0]
		k = ag[i][1]
		rem = v - b[k]
		if w > rem:
			w -= rem
			b[k] = v
		else:
			b[k] += w
			break
	print(*b)

def __starting_point():
	solve()
__starting_point()


import sys
from bisect import bisect_left as lb
from collections import deque
from queue import PriorityQueue as pq
from math import *
input_ = lambda : sys.stdin.readline().strip('\r\n')
ii = lambda : int(input_())
il = lambda : list(map(int, input_().split()))
ilf = lambda : list(map(float, input_().split()))
ip = lambda : input_()
fi = lambda : float(input_())
ap = lambda ab, bc, cd: ab[bc].append(cd)
li = lambda : list(input_())
pr = lambda x: print(x)
prinT = lambda x: print(x)
f = lambda : sys.stdout.flush()
inv = lambda x: pow(x, mod - 2, mod)
mod = 10 ** 9 + 7
(n, w) = il()
a = il()
s = 0
for i in a:
	s += -(-i // 2)
if w < s:
	print(-1)
	exit(0)
ans = [0 for i in range(n)]
b = []
for i in range(n):
	ans[i] = -(-a[i] // 2)
	w -= ans[i]
	b.append([a[i], i])
b.sort(reverse=True)
for i in range(n):
	mx = min(w, b[i][0] - ans[b[i][1]])
	ans[b[i][1]] += mx
	w -= mx
	if w <= 0:
		break
print(*ans)


import sys
input = sys.stdin.readline
from collections import defaultdict as dc
from collections import Counter
from bisect import bisect_right, bisect_left
import math
from operator import itemgetter
from heapq import heapify, heappop, heappush
from queue import PriorityQueue as pq
(n, w) = map(int, input().split())
l = list(map(int, input().split()))
s = [0] * n
f = 1
for i in range(n):
	t = math.ceil(l[i] / 2)
	if t > w:
		f = 0
		break
	s[i] += t
	w -= t
if f == 0:
	print(-1)
elif w == 0:
	print(*s)
else:
	x = dc(list)
	for i in range(n):
		x[l[i]].append(i)
	p = sorted(set(l), reverse=True)
	n = len(p)
	i = 0
	while i < n and w > 0:
		for j in x[p[i]]:
			if w <= 0:
				break
			t = min(w, l[j] - s[j])
			s[j] += t
			w -= t
		i += 1
	print(*s)


def find(A, w):
	B = [(A[i], i) for i in range(len(A))]
	B = sorted(B)
	A = sorted(A)
	dp = [0] * len(A)
	dp[0] = (A[0] + 1) // 2
	w -= dp[0]
	for i in range(1, len(dp)):
		dp[i] = max(dp[i - 1], (A[i] + 1) // 2)
		if dp[i] > A[i]:
			return [-1]
		w -= dp[i]
	if w < 0:
		return [-1]
	for i in range(len(dp) - 1, -1, -1):
		if w > 0:
			add = min(w, A[i] - dp[i])
			dp[i] += add
			w -= add
	ans = [0] * len(A)
	for i in range(len(B)):
		ans[B[i][1]] = dp[i]
	return ans
(n, w) = list(map(int, input().strip().split(' ')))
A = list(map(int, input().strip().split(' ')))
print(*find(A, w))


(n, w) = map(int, input().split())
arr = list(map(float, input().split()))
r = sorted(list(range(n)), key=lambda x: arr[x])
ans = [0] * n
for i in r:
	crt = int((arr[i] + 1) // 2)
	ans[i] += crt
	w -= crt
if w < 0:
	print(-1)
	exit(0)
for i in reversed(r):
	crt = int(min(w, arr[i] - ans[i]))
	w -= crt
	ans[i] += crt
	if w == 0:
		break
print(' '.join(map(str, ans)))


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
ans = [(x + 1) // 2 for x in a]
w -= sum(ans)
if w < 0:
	print(-1)
	exit(0)
while w > 0:
	i = a.index(max(a))
	while w > 0 and a[i] != ans[i]:
		ans[i] += 1
		w -= 1
	a[i] = 0
print(*ans)


(n, w) = map(int, input().split())
l = list(map(int, input().split()))
ans = []
for i in range(n):
	ans.append(l[i] // 2 + l[i] % 2)
	w -= l[i] // 2 + l[i] % 2
	l[i] = (l[i], i)
if w < 0:
	print(-1)
else:
	l = list(reversed(list(sorted(l))))
	for i in range(n):
		(w, ans[l[i][1]]) = (max(0, w - abs(ans[l[i][1]] - l[i][0])), min(l[i][0], ans[l[i][1]] + w))
		if w == 0:
			break
	for i in range(n):
		print(ans[i], end=' ')


from fractions import gcd
from heapq import *
import math
from collections import defaultdict, Counter, deque
from bisect import *
import itertools
import fractions
MOD = 10 ** 9 + 7

def main():
	(n, w) = map(int, input().split())
	a = list(map(int, input().split()))
	l = [[a[i], i] for i in range(n)]
	l = sorted(l, key=lambda x: x[0], reverse=True)
	ans = [0] * n
	for i in range(n):
		ans[i] = (a[i] + 1) // 2
	if sum(ans) > w:
		print(-1)
		exit()
	w -= sum(ans)
	for (v, i) in l:
		if w >= v - ans[i]:
			w -= v - ans[i]
			ans[i] = a[i]
		else:
			ans[i] += w
			break
	print(*ans)
main()


import math
(n, w) = input().split(' ')
n = int(n)
w = int(w)
lis = [[int(j), 0] for j in input().split(' ')]
for i in range(n):
	lis[i][1] = i
lis = sorted(lis, key=lambda a: a[0], reverse=True)
f = True
ans = [0 for i in range(n)]
for i in range(n):
	w -= math.ceil(lis[i][0] / 2)
	ans[lis[i][1]] = math.ceil(lis[i][0] / 2)
	if w < 0:
		f = False
		break
if f == True:
	if w == 0:
		for i in range(n):
			print(ans[i], end=' ')
	else:
		for i in range(n):
			if w == 0:
				break
			if w >= lis[i][0] - ans[lis[i][1]]:
				w -= lis[i][0] - ans[lis[i][1]]
				ans[lis[i][1]] = lis[i][0]
			else:
				ans[lis[i][1]] += w
				w = 0
		for i in range(n):
			print(ans[i], end=' ')
else:
	print(-1)


f = input().split()
(n, w) = (int(f[0]), int(f[1]))
(l, v) = ([], [])
v = [int(x) for x in input().split()]
for i in range(0, n):
	l.append([v[i], int(0), i])
l.sort()
i = n - 1
while i >= 0:
	x = int(l[i][0] / 2) + int(l[i][0] % 2)
	l[i][1] += x
	w -= x
	i -= 1
if w < 0:
	print(-1)
else:
	i = n - 1
	while i >= 0:
		x = l[i][0] - l[i][1]
		if x > 0 and w > 0:
			if w - x >= 0:
				l[i][1] += x
				w -= x
			else:
				l[i][1] += w
				w = 0
		(l[i][0], l[i][2]) = (l[i][2], l[i][0])
		i -= 1
	l.sort()
	for x in l:
		print(x[1], end=' ')


(n, w) = map(int, input().split())
arr = [int(x) for x in input().split()]
arr2 = [(x + 1) // 2 for x in arr]
s = sum(arr2)
if w < s:
	print(-1)
else:
	w -= s
	while w > 0:
		m = max(arr)
		v = arr.index(m)
		while arr2[v] < arr[v] and w > 0:
			arr2[v] += 1
			w -= 1
		arr[v] = -1
	for i in range(n):
		print(arr2[i], end=' ')


import math
(n, w) = [int(x) for x in input().split()]
s = input().split()
a = sorted([[int(s[x]), x] for x in range(n)], key=lambda x: x[0], reverse=True)
b = [[math.ceil(x[0] / 2), x[1]] for x in a]
sm = sum([x[0] for x in b])
if sm > w:
	print(-1)
else:
	w -= sm
	i = 0
	while w:
		if b[i][0] < a[i][0]:
			b[i][0] += 1
			w -= 1
		else:
			i += 1
	for i in [x[0] for x in sorted(b, key=lambda x: x[1])]:
		print(i, end=' ')


import math
(n, w) = [int(x) for x in input().split()]
l = [int(x) for x in input().split()]
qw = l[:]
l.sort(reverse=True)
q = [int(math.ceil(x / 2)) for x in l]
sm = sum(q)
if w < sm:
	print(-1)
else:
	rem = w - sm
	er = q[:]
	for x in range(len(q)):
		if rem + q[x] > l[x]:
			rem = rem - (l[x] - q[x])
			q[x] = l[x]
		else:
			e = []
			q[x] = q[x] + rem
			for qq in qw:
				inx = l.index(qq)
				e.append(q[inx])
				print(e[-1], end=' ')
				l[inx] = -111


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in a:
	s += (i + 1) // 2
if s > w:
	print(-1)
else:
	ml = []
	diff = sum(a) - w
	j = 1
	for i in a:
		ml.append([i, j])
		j += 1
	ml.sort()
	f = 0
	while diff > 0:
		for i in ml:
			minq = (i[0] + 1) // 2
			curr = i[0]
			sub = min(diff, curr - minq)
			i[0] -= sub
			diff -= sub
			if diff <= 0:
				f = 1
				break
		if f == 1:
			break
	ml.sort(key=lambda x: x[1])
	for k in ml:
		print(k[0], end=' ')


import math
(n, w) = map(int, input().split())
A = list(map(int, input().split()))
B = [0] * n
sm = 0
for i in range(n):
	su = int(math.ceil(A[i] / 2))
	B[i] = (A[i], i, su)
	sm += su
if sm > w:
	print('-1')
else:
	rem = w - sm
	B = sorted(B, reverse=True)
	C = [0] * n
	for x in B:
		l = x[0] - x[2]
		if l <= rem:
			C[x[1]] = l + x[2]
			rem -= l
		else:
			C[x[1]] = rem + x[2]
			rem = 0
	ans = ''
	for i in range(n):
		ans += str(C[i]) + ' '
	print(ans)


(n, w) = map(int, input().split())
a = [(-aa, i) for (i, aa) in enumerate(map(int, input().split()))]
a.sort()
a = [(-aa, i) for (aa, i) in a]
b = [[(aa + 1) // 2, i] for (aa, i) in a]
s = sum([aa for (aa, i) in b])
if s > w:
	print(-1)
	exit()
else:
	w -= s
while w > 0:
	c = False
	for i in range(n):
		if b[i][0] < a[i][0]:
			c = True
			b[i][0] += 1
			w -= 1
			if w == 0:
				break
	if c == False:
		break
if w != 0:
	print(-1)
	exit()
c = [(i, bb) for (bb, i) in b]
c.sort()
d = [str(bb) for (i, bb) in c]
print(' '.join(d))


n = list(map(int, input().split(' ')))
a = list(map(int, input().split(' ')))
c = n[1]
b = []
for i in a:
	b.append((i + 1) // 2)
s = sum(b)
if c < s:
	print(-1)
else:
	c = c - s
	(t, i) = ([], 0)
	while c > 0:
		(x, y) = (0, 0)
		for j in range(len(a)):
			if a[j] > x and j not in t:
				x = a[j]
				y = j
		k = min(a[y] // 2, c)
		b[y] += k
		c -= k
		t.append(y)
	d = ' '.join((str(l) for l in b))
	print(d)


line = input().split()
n = int(line[0])
w = int(line[1])
minsum = 0
a = input().split()
for i in range(n):
	a[i] = int(a[i])
	minsum += (a[i] + 1) // 2
if minsum > w:
	print('-1')
else:
	vols = [str((a[i] + 1) // 2) for i in range(n)]
	extra = w - minsum
	while extra > 0:
		maxcup = -1
		maxsize = 0
		for i in range(n):
			if a[i] > maxsize:
				maxcup = i
				maxsize = a[i]
		if maxcup == -1:
			print(1 + ' ')
		vols[maxcup] = str(min(maxsize, (maxsize + 1) // 2 + extra))
		extra -= int(vols[maxcup]) - (maxsize + 1) // 2
		a[maxcup] = -1
	print(' '.join(vols))


l = input().split()
(n, w) = (int(l[0]), int(l[1]))
arr = list(map(int, input().split()))
sort = sorted([i for i in range(len(arr))], key=lambda x: arr[x])
ans = list(map(lambda x: x + (x & 1) >> 1, arr))
s = sum(ans)
if s <= w:
	r = w - s
	while r:
		x = sort.pop()
		y = min(arr[x] - ans[x], r)
		ans[x] += y
		r -= y
	print(' '.join(map(str, ans)))
else:
	print('-1')


import sys, math
Tests = 1
for _ in range(Tests):
	(n, w) = map(int, sys.stdin.readline().split())
	a = list(map(int, sys.stdin.readline().split()))
	s = 0
	for i in range(n):
		s += (a[i] + 1) // 2
	if w < s:
		print(-1)
	else:
		ans = [0] * n
		for i in range(n):
			ans[i] = (a[i] + 1) // 2
		w -= s
		while w > 0:
			ind = a.index(max(a))
			t = min(w, a[ind] - ans[ind])
			ans[ind] += t
			w -= t
			a[ind] = 0
		print(*ans)


from collections import deque as de
import math
from math import sqrt as sq
from math import floor as fl
from math import ceil as ce
from sys import stdin, stdout
import re
from collections import Counter as cnt
from functools import reduce
from itertools import groupby as gb
from bisect import bisect_left as bl, bisect_right as br

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))

class My_stack:

	def __init__(self):
		self.data = []

	def my_push(self, x):
		return self.data.append(x)

	def my_pop(self):
		return self.data.pop()

	def my_peak(self):
		return self.data[-1]

	def my_contains(self, x):
		return self.data.count(x)

	def my_show_all(self):
		return self.data

	def isEmpty(self):
		return len(self.data) == 0
arrStack = My_stack()

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def binarytodecimal(n):
	return int(n, 2)

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def get_prime_factors(number):
	prime_factors = []
	while number % 2 == 0:
		prime_factors.append(2)
		number = number / 2
	for i in range(3, int(math.sqrt(number)) + 1, 2):
		while number % i == 0:
			prime_factors.append(int(i))
			number = number / i
	if number > 2:
		prime_factors.append(int(number))
	return prime_factors

def get_frequency(list):
	dic = {}
	for ele in list:
		if ele in dic:
			dic[ele] += 1
		else:
			dic[ele] = 1
	return dic

def Log2(x):
	return math.log10(x) / math.log10(2)

def getProduct(n):
	product = 1
	while n != 0:
		product = product * (n % 10)
		n = n // 10
	return product

def lcm(x, y):
	lcm = x * y // math.gcd(x, y)
	return lcm

def isPowerOfTwo(n):
	return math.ceil(Log2(n)) == math.floor(Log2(n))

def checkisap(list):
	d = list[1] - list[0]
	for i in range(2, len(list)):
		temp = list[i] - list[i - 1]
		if temp != d:
			return False
	return True

def primes_method5(n):
	out = {}
	sieve = [True] * (n + 1)
	for p in range(2, n + 1):
		if sieve[p]:
			out[p] = 1
			for i in range(p, n + 1, p):
				sieve[i] = False
	return out

def getSum(n):
	strr = str(n)
	list_of_number = list(map(int, strr.strip()))
	return sum(list_of_number)

def ceildiv(x, y):
	return (x + y - 1) // y

def di():
	return map(int, input().split())

def ii():
	return int(input())

def li():
	return list(map(int, input().split()))

def si():
	return list(map(str, input()))

def indict():
	dic = {}
	for (index, value) in enumerate(input().split()):
		dic[int(value)] = int(index) + 1
	return dic

def frqdict():
	dic = {}
	for (index, value) in enumerate(input()):
		if value not in dic:
			dic[value] = 1
		else:
			dic[value] += 1
	return dic
(n, w) = di()
a = []
fuls = 0
halfs = 0
for (index, value) in enumerate(input().split()):
	fuls += int(value)
	halfs += ce(int(value) / 2)
	a.append(int(value))
if w < halfs:
	print(-1)
elif w == halfs:
	for i in range(n):
		print(ce(a[i] / 2), end=' ')
elif w == fuls:
	print(*a, sep=' ')
else:
	ans = []
	for i in range(n):
		ans.append([a[i], ce(a[i] / 2), i])
	ans.sort(reverse=True)
	diff = w - halfs
	ch = 1
	ans2 = []
	for i in range(n):
		if ch:
			halfele = ans[i][1]
			fulfele = ans[i][0]
			elediff = fulfele - halfele
			if diff > elediff:
				diff -= elediff
				ans[i][1] = fulfele
			elif diff == elediff:
				ans[i][1] = fulfele
				ch = 0
			else:
				ans[i][1] += diff
				ch = 0
		ans2.append([ans[i][2], ans[i][1]])
	ans2.sort()
	for i in range(n):
		print(ans2[i][1], end=' ')


(n, w) = map(int, input().split())
ai = list(map(int, input().split()))
ai2 = list(range(n))
ai3 = [0] * n
summ = 0
odd_num = 0
for num in ai:
	summ += num - num % 2
	odd_num += num % 2
for i in range(n):
	for j in range(i + 1, n):
		if ai[j] > ai[i]:
			temp = ai[i]
			ai[i] = ai[j]
			ai[j] = temp
			temp = ai2[i]
			ai2[i] = ai2[j]
			ai2[j] = temp
w -= summ // 2 + odd_num
if w < 0:
	print(-1)
else:
	for i in range(n):
		temp = min(w, ai[i] // 2)
		w -= temp
		ai3[ai2[i]] = ai[i] // 2 + ai[i] % 2 + temp
	for num in ai3:
		print(num, end=' ')


import sys
input = sys.stdin.readline
from math import ceil

def solve(n, w, a):
	res = [0] * n
	for (i, ai) in enumerate(a):
		if ai & 1:
			v = int(ceil(ai / 2))
		else:
			v = ai // 2
		if v <= w:
			res[i] = v
			w -= v
		else:
			return []
	for (i, ai) in enumerate(a):
		for (j, aj) in enumerate(a):
			if i == j or ai <= aj:
				continue
			if res[i] < res[j]:
				v = res[j] - res[i]
				if v <= w:
					res[i] += v
					w -= v
				else:
					return []
	if w == 0:
		return res
	res_sort = sorted([(r, i) for (i, r) in enumerate(a)], reverse=True)
	for (cur, idx) in res_sort:
		v = min(w, a[idx] - res[idx])
		res[idx] += v
		w -= v
	if w == 0:
		return res
	else:
		return []
(n, w) = map(int, input().split())
a = list(map(int, input().split()))
res = solve(n, w, a)
if res:
	print(*res)
else:
	print(-1)


(n, w) = map(int, input().split())
a = input().split()
a = [(int(a[i]), i) for i in range(n)]
a.sort()
o = [0] * n
for i in range(n):
	x = (a[i][0] + 1) // 2
	w -= x
	o[a[i][1]] += x
	if w < 0:
		print(-1)
		exit()
j = n - 1
while j >= 0 and w > 0:
	x = min(a[j][0] - o[a[j][1]], w)
	w -= x
	o[a[j][1]] += x
	j -= 1
if w != 0:
	print(-1)
	exit()
print(' '.join(map(str, o)))


(n, w) = map(int, input().split())
cups = list(map(int, input().split()))
if sum(((cup + 1) // 2 for cup in cups)) > w:
	print(-1)
	exit(0)
fill = [0] * n
for i in range(n):
	pour = min(w, (cups[i] + 1) // 2)
	fill[i] = pour
	w -= pour
while w > 0:
	m = -1
	for i in range(n):
		if fill[i] != cups[i] and (m == -1 or cups[m] < cups[i]):
			m = i
	pour = min(w, cups[m] - fill[m])
	fill[m] = fill[m] + pour
	w -= pour
print(*fill)


import math

class Glass:

	def __init__(self, pos, size, fill=0):
		(self.s, self.p, self.f) = (size, pos, fill)
(n, w) = map(int, input().split())
gls = []
sizes = [int(i) for i in input().split()]
for i in range(n):
	g = Glass(i, sizes[i])
	l = math.ceil(g.s / 2)
	if w >= l:
		(g.f, w) = (l, w - l)
		gls.append(g)
	else:
		print(-1)
		exit(0)
gls.sort(key=lambda y: y.s)
for i in range(n - 1, -1, -1):
	emp = gls[i].s - gls[i].f
	if w > 0:
		gls[i].f += min(emp, w)
		w -= min(emp, w)
	else:
		break
gls.sort(key=lambda y: y.p)
for i in range(n):
	print(gls[i].f, end=' ')


import math
import re
(n, w) = map(int, input().split())
a = list(map(int, input().split()))
a1 = [math.ceil(el / 2) for el in a]
s = w - sum(a1)
if s < 0:
	print(-1)
elif s == 0:
	print(' '.join(map(str, a1)))
else:
	for i in range(n):
		if a[i] == 1:
			a1[i] = 0
			a[i] = 0
	a2 = sorted(a, reverse=True)
	while s > 0:
		i = a.index(a2[0])
		if a[i] - a1[i] < s:
			s -= a[i] - a1[i]
			a1[i] = a[i]
		else:
			a1[i] += s
			s = 0
		del a2[0]
		a[i] = -1
	for i in range(n):
		if a1[i] == 0:
			a1[i] = 1
	print(' '.join(map(str, a1)))


import math
import sys
(n, w) = list(map(int, input().split()))
a = list(map(int, input().split()))
a = [[a[i], i] for i in range(len(a))]
a.sort()
a = a[::-1]
res = [0] * n
for i in range(n):
	if w >= math.ceil(a[i][0] / 2):
		res[i] += math.ceil(a[i][0] / 2)
		w -= math.ceil(a[i][0] / 2)
	else:
		print(-1)
		sys.exit(0)
for i in range(n):
	to_add = 0
	if w >= a[i][0] - res[i]:
		to_add = a[i][0] - res[i]
	else:
		to_add = w
	w -= to_add
	res[i] += to_add
sorted_res = [None] * n
for i in range(n):
	sorted_res[a[i][1]] = res[i]
print(' '.join(map(str, sorted_res)))


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
arr = []
ans = [0 for _ in range(n)]
for i in range(n):
	ans[i] += (a[i] + 1) // 2
	w -= (a[i] + 1) // 2
	arr.append((a[i], i))
if w < 0:
	print(-1)
else:
	arr = list(reversed(sorted(arr)))
	for (a, i) in arr:
		d = min(w, a - ans[i])
		ans[i] += d
		w -= d
	print(' '.join(map(str, ans)))


import math
l = input()
n = int(l.split()[0])
w = int(l.split()[1])
l = input()
a = []
aux = 0
for i in l.split():
	a.append([int(i), aux])
	aux += 1
	w -= int(math.ceil(float(a[-1][0] / 2)))
a.sort(reverse=True, key=lambda x: x[0])
if w < 0:
	print(-1)
else:
	pos = 0
	nxt = ' '
	while w > 0 and (not pos >= n):
		if w > math.floor(float(a[pos][0] / 2)):
			w -= int(math.floor(float(a[pos][0] / 2)))
		else:
			a[pos][0] = int(math.ceil(float(a[pos][0] / 2)) + w)
			w = 0
		pos += 1
	for i in range(pos, n):
		a[i][0] = int(math.ceil(float(a[i][0] / 2)))
	a.sort(key=lambda x: x[1])
	nxt = ' '
	for i in a:
		if i[1] == n - 1:
			nxt = ''
		print(str(i[0]) + nxt, end='')
	print()


(n, w) = input().split()
n = int(n)
w = int(w)
l = list(map(int, input().split()))
a = []
s = 0
for i in range(0, n):
	a.append([l[i], i])
	s = s + (l[i] + 1) // 2
l.sort()
a.sort(key=lambda x: x[0])
for i in range(0, n):
	a[i][0] = (l[i] + 1) // 2
k = w - s
if k < 0:
	print(-1)
else:
	for i in range(n - 1, -1, -1):
		if k > l[i] - a[i][0]:
			k = k - l[i] + a[i][0]
			a[i][0] = l[i]
		else:
			a[i][0] += k
			k = 0
			break
	if k == 0:
		a.sort(key=lambda x: x[1])
		for i in range(0, n):
			print(a[i][0], end=' ')
	else:
		print('-1')


(n, w) = map(int, input().split())
A = list(map(int, input().split()))
Ar = [0] * n
for i in range(n):
	Ar_i = A[i] / 2
	if Ar_i % 1 != 0:
		Ar_i += 0.5
	w -= Ar_i
	Ar[i] = int(Ar_i)
if w < 0:
	print(-1)
	exit()
while w > 0:
	o = A.index(max(A))
	o = (o, A[o], Ar[o])
	o = (o[0], o[1], o[2], o[1] - o[2])
	if o[3] <= w:
		Ar[o[0]] = o[1]
		w -= o[3]
	else:
		Ar[o[0]] += int(w)
		w = 0
	A[o[0]] = -float('Inf')
print(' '.join(map(str, Ar)))


(n, w) = map(int, input().split())
l = [int(i) for i in input().split()]
ans = []
sm = 0
from math import ceil
for i in range(n):
	ans.append([ceil(l[i] / 2), l[i], i])
	sm += ans[i][0]
if sm > w:
	print(-1)
else:
	ans.sort(key=lambda x: x[1], reverse=True)
	w = w - sm
	for i in range(n):
		if w == 0:
			continue
		if w >= l[ans[i][2]] - ans[i][0]:
			w -= l[ans[i][2]] - ans[i][0]
			ans[i][0] += l[ans[i][2]] - ans[i][0]
		else:
			ans[i][0] += w
			w = 0
	ans1 = [0] * n
	for i in range(n):
		ans1[ans[i][2]] = ans[i][0]
	print(*ans1)


(n, w) = map(int, input().split())
A = list(map(int, input().split()))
order = sorted(range(n), key=lambda i: A[i])
A = list(map(lambda p: A[p], order))
use = [0 for _ in range(n)]
for i in range(n):
	use[i] = (A[i] + 1) // 2
	w -= use[i]
if w < 0:
	print(-1)
	exit()
for i in range(n)[::-1]:
	add = min(w, A[i] - use[i])
	w -= add
	use[i] += add
if w > 0:
	print(-1)
	exit()
ans = [0] * n
for i in range(n):
	ans[order[i]] = use[i]
for i in range(n):
	if i > 0:
		print(' ', end='')
	print(ans[i], end='')
print()


R = lambda : map(int, input().rstrip().split())
(n, w) = R()
a = list(R())
b = sorted(((v, i) for (i, v) in enumerate(a)))
half = 0
for x in a:
	half += (x + 1) // 2
if w < half:
	print(-1)
	exit()
ans = [0] * n
left = w - half
i = n - 1
while left > 0 and i >= 0:
	y = b[i]
	x = min(left, y[0] - (y[0] + 1) // 2)
	left -= x
	ans[y[1]] = x
	i -= 1
for i in range(n):
	ans[i] += (a[i] + 1) // 2
print(' '.join(map(str, ans)))


(n, w) = list(map(int, input().split()))
a = list(map(int, input().split()))
s = sum(a)
l = []
a2 = []
for i in range(n):
	a2.append([a[i], i])
a2.sort()

def m(x):
	if x % 2 == 1:
		return x // 2 + 1
	return x // 2

def f():
	if s / 2 > w:
		print(-1)
		return
	if w > s:
		print(-1)
		return
	t = m(a2[0][0])
	last = t
	l.append(t)
	for i in range(1, n):
		if last > a2[i][0]:
			print(-1)
			return
		if last < m(a2[i][0]):
			last = m(a2[i][0])
		t += last
		l.append(last)
	if t > w:
		print(-1)
		return
	add = w - t
	x = min(a2[-1][0] - l[-1], add)
	l[-1] += x
	add -= x
	last = l[-1]
	for i in range(n - 2, -1, -1):
		if add == 0:
			break
		x = min(a2[i][0], last)
		x = x - l[i]
		x = min(x, add)
		if x < 0:
			continue
		l[i] += x
		add -= x
	if add != 0:
		print(-1)
		return
	for i in range(n):
		for u in range(n):
			if a2[u][1] == i:
				print(l[u], end=' ')
f()


from collections import deque
import math
(n, k) = map(int, input().split())
arr = list(map(int, input().split()))
q = deque()
v = [False] * n
for i in range(n):
	var = int(math.ceil(arr[i] / 2))
	if k >= var:
		q.append(var)
		k -= var
	else:
		print(-1)
		exit()
for _ in range(n):
	m = 0
	ind = 0
	for i in range(n):
		if v[i] == True:
			continue
		else:
			if arr[i] > m:
				ind = i
			m = max(m, arr[i])
	v[ind] = True
	if k >= arr[ind] - q[ind]:
		k -= arr[ind] - q[ind]
		q[ind] = arr[ind]
	else:
		q[ind] += k
		print(*q)
		exit()
print(*q)


(n, w) = map(int, input().split())
a = sorted([(n, i) for (i, n) in enumerate(map(int, input().split()))])
tea = [0] * n
for i in range(n):
	tea[a[i][1]] += (a[i][0] + 1) // 2
w -= sum(tea)
i = n - 1
while w > 0:
	x = min(a[i][0] - tea[a[i][1]], w)
	tea[a[i][1]] += x
	w -= x
	i -= 1
if w < 0:
	print(-1)
else:
	print(*tea)


(n, w) = (int(i) for i in input().split())
arr = [int(i) for i in input().split()]

def function():
	global w
	for (i, size) in enumerate(arr):
		t = round(size / 2 + 0.1)
		dic[size, i] = t
		w -= t
		if w < 0:
			return {1: -1}
	for (size, i) in sorted(dic, reverse=True):
		o = size - dic[size, i]
		dic[size, i] += min(w, o)
		w -= min(o, w)
		if w == 0:
			break
	return dic
dic = {}
print(*function().values())


import math as mt
import sys, string, bisect
input = sys.stdin.readline
import random
from collections import deque, defaultdict
L = lambda : list(map(int, input().split()))
Ls = lambda : list(input().split())
M = lambda : map(int, input().split())
I = lambda : int(input())

def check(n):
	n = list(set(list(str(n))))
	if len(n) == 1:
		return True
	n.sort()
	if n[0] == '0':
		if len(n) <= 2:
			return True
		else:
			return False
	else:
		return False
(n, w) = M()
l = L()
s = 0
x = []
y = []
for i in range(n):
	y.append((l[i], i))
	s += (l[i] + 1) // 2
	x.append((l[i] + 1) // 2)
if w < s or w > sum(l):
	print(-1)
else:
	y.sort(reverse=True, key=lambda x: x[0])
	w -= s
	if w > 0:
		i = 0
		while i < n and w != 0:
			index = y[i][1]
			max = y[i][0]
			p = max - x[index]
			if w > p:
				w -= p
				x[index] += p
			else:
				x[index] += w
				w = 0
			i += 1
		if w > 0:
			print(-1)
		else:
			print(*x)
	else:
		print(*x)


def main():
	(n, w) = map(int, input().split())
	a = list(map(int, input().split()))
	res1 = [0 for i in range(n)]
	maxes = a[:]
	maxes.sort()
	for i in range(n):
		res1[i] = (a[i] + 1) // 2
	w -= sum(res1)
	if w < 0:
		print(-1)
		return
	i = -1
	while w > 0:
		maxi = a.index(maxes[i])
		if w > a[maxi] - res1[maxi]:
			w -= a[maxi] - res1[maxi]
			res1[maxi] = a[maxi]
			a[maxi] = 0
			maxes[i] = 0
		else:
			res1[maxi] += w
			w = 0
		i -= 1
	print(*res1)
main()


from sys import stdin
import math
input = stdin.readline
T = 1
for t in range(1, T + 1):
	(n, k) = map(int, input().split())
	_input = list(map(int, input().split()))
	idx = dict()
	sum_x = 0
	sum_y = 0
	ans = []
	for i in range(len(_input)):
		ans.append(int(_input[i] / 2) if _input[i] % 2 == 0 else int(_input[i] / 2) + 1)
		sum_x += int(_input[i] / 2) if _input[i] % 2 == 0 else int(_input[i] / 2) + 1
		sum_y += _input[i]
		idx[i] = _input[i]
	if k < sum_x or k > sum_y:
		print(-1)
		exit(0)
	k -= sum_x
	sorted_idx = sorted(idx.items(), key=lambda x: x[1], reverse=True)
	for i in range(len(sorted_idx)):
		diff = sorted_idx[i][1] - ans[sorted_idx[i][0]]
		if diff >= k:
			ans[sorted_idx[i][0]] += k
			k = 0
		else:
			k -= diff
			ans[sorted_idx[i][0]] += diff
	for i in ans:
		print(i, end=' ')


import math
(n, w) = input().split(' ')
n = int(n)
w = int(w)
in_str = input().split(' ')
a_list = [[i, int(in_str[i]), math.ceil(int(in_str[i]) / 2)] for i in range(n)]
for a in a_list:
	w -= a[2]
if w < 0:
	print(-1)
else:
	a_list.sort(key=lambda x: x[1], reverse=True)
	for i in range(n):
		if w > a_list[i][1] - a_list[i][2]:
			w -= a_list[i][1] - a_list[i][2]
			a_list[i][2] = a_list[i][1]
		else:
			a_list[i][2] += w
			break
	a_list.sort(key=lambda x: x[0])
	print(' '.join([str(x[2]) for x in a_list]))


(cilv_sk, tejas_daudz) = [int(x) for x in input().split()]
s = input().split()
tilpumi = [[int(s[i]), i] for i in range(cilv_sk)]
aizpildijums = [0 for i in range(cilv_sk)]
for i in range(cilv_sk):
	cur_t = tilpumi[i][0] // 2 + tilpumi[i][0] % 2
	aizpildijums[i] = cur_t
	tejas_daudz -= cur_t
	if tejas_daudz < 0:
		print(-1)
		exit(0)
tilpumi.sort(key=lambda a: a[0], reverse=True)
for i in range(cilv_sk):
	starp = tilpumi[i][0] - aizpildijums[tilpumi[i][1]]
	if starp < tejas_daudz:
		aizpildijums[tilpumi[i][1]] += starp
		tejas_daudz -= starp
	else:
		aizpildijums[tilpumi[i][1]] += tejas_daudz
		tejas_daudz = 0
		break
if tejas_daudz != 0:
	print(-1)
else:
	for i in aizpildijums:
		print(i, end=' ')


I = lambda : list(map(int, input().split()))
(n, k) = I()
(a, q) = (I(), [])
for i in range(n):
	o = a[i] / 2
	r = (a[i] + 1) // 2
	k -= r
	q += [[i, o]]
q.sort(key=lambda x: x[1], reverse=1)
for i in range(n):
	q[i][1] = (q[i][1] * 2 + 1) // 2
a.sort(reverse=1)
if k > 0:
	for i in range(n):
		o = a[i] - q[i][1]
		if k >= o:
			k -= o
			q[i][1] += o
		else:
			q[i][1] += k
			k = 0
			break
if k != 0:
	print(-1)
else:
	for i in range(n):
		a[q[i][0]] = int(q[i][1])
	print(*a)


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for i in range(n):
	s += (a[i] + 1) // 2
	a[i] = [a[i], i]
if s > w:
	print(-1)
else:
	res = [[(a[i][0] + 1) // 2, i] for i in range(n)]
	w -= s
	a.sort(reverse=True)
	i = 0
	while w > 0:
		res[a[i][1]][0] = min(a[i][0], res[a[i][1]][0] + w)
		w -= a[i][0] // 2
		i += 1
	for i in range(n):
		print(res[i][0], end=' ')


import math
(n, m) = map(int, input().split())
x = list(map(int, input().split()))
if sum(x) == m:
	print(*x)
else:
	y = x.copy()
	y.sort()
	c = 0
	d = {}
	for i in range(len(y)):
		c += math.ceil(y[i] / 2)
		d[y[i]] = math.ceil(y[i] / 2)
	if m < c:
		print('-1')
	elif m == c:
		for i in range(len(x)):
			print(d[x[i]], end=' ')
	else:
		ff = max(x)
		fuxx = 0
		m -= c
		t = {}
		one = {}
		for i in range(len(y) - 1, -1, -1):
			if m == 0:
				break
			if y[i] - d[y[i]] > m:
				fuxx = d[y[i]] + m
				one[y[i]] = fuxx
				m = 0
				break
			else:
				try:
					t[y[i]] += 1
				except:
					t[y[i]] = 1
				m -= y[i] - d[y[i]]
		for i in range(len(x)):
			try:
				print(one[x[i]], end=' ')
				del one[x[i]]
			except:
				try:
					if t[x[i]] > 0:
						print(x[i], end=' ')
						t[x[i]] -= 1
					else:
						raise ValueError('arg is True')
				except:
					print(d[x[i]], end=' ')


import sys
(n, w) = map(int, input().split())
a = sorted(((x, i) for (i, x) in enumerate(map(int, input().split()))), reverse=True)
ans = [0] * n
for (x, i) in a:
	ans[i] = x + 1 >> 1
w -= sum(ans)
if w < 0:
	print('-1')
	exit()
for i in range(n):
	x = min(w, a[i][0] - ans[a[i][1]])
	ans[a[i][1]] += x
	w -= x
print(*ans)


from math import ceil
(n, w) = map(int, input().split(' '))
a = list(map(int, input().split(' ')))
indexed = [(a[i], i) for i in range(n)]
indexed.sort()
b = [0] * n
for i in range(n):
	(volume, idx) = indexed[i]
	b[idx] = ceil(volume / 2)
	w -= b[idx]
if w > 0:
	for i in range(n):
		(volume, idx) = indexed[n - i - 1]
		extra = min(w, volume - b[idx])
		b[idx] += extra
		w -= extra
		if w == 0:
			break
print(-1 if w < 0 else ' '.join(map(str, b)))


import math
(n, w) = map(int, input().split())
w2 = w
A = list(map(int, input().split()))
B = [[0 for j in range(3)] for i in range(n)]
count = 0
for i in range(n):
	B[i][0] = i + 1
	B[i][1] = A[i]
	B[i][2] = math.ceil(A[i] / 2)
	count += math.ceil(A[i] / 2)
if count > w:
	print(-1)
else:
	w = w - count
	B = sorted(B, key=lambda B: B[1])
	for i in range(n - 1, -1, -1):
		if w - (B[i][1] - B[i][2]) > 0:
			w = w - (B[i][1] - B[i][2])
			B[i][2] = B[i][1]
		else:
			B[i][2] = B[i][2] + w
			w = 0
	for i in range(n):
		w2 -= B[i][2]
	if w2 > 0:
		print(-1)
		exit(0)
	B = sorted(B, key=lambda B: B[0])
	for i in range(n):
		print(B[i][2], end=' ')


(n, w) = map(int, input().split())
arr = [[i, int(x)] for (i, x) in enumerate(input().split())]
arr.sort(reverse=True, key=lambda a: a[1])
res = []
pos = True
for a in arr:
	if w <= 0:
		pos = False
		break
	res.append([a[0], (a[1] + 1) // 2])
	w -= (a[1] + 1) // 2
while w > 0:
	for i in range(n):
		ex = min(w, arr[i][1] - res[i][1])
		w -= ex
		res[i][1] += ex
		if w == 0:
			break
res.sort(key=lambda a: a[0])
if pos:
	print(' '.join(map(lambda a: str(a[1]), res)))
else:
	print(-1)


(n, ch) = map(int, input().split(' '))
mas = list(map(int, input().split(' ')))
mas_nach = mas.copy()
for i in range(len(mas)):
	ch -= round(mas[i] / 2 + 1 / 100)
	mas[i] = mas[i] // 2
if ch < 0:
	print(-1)
	exit()

def max_and_nom(massiv):
	nom = 0
	maxx = -1
	for i in range(len(massiv)):
		if massiv[i] >= maxx:
			maxx = massiv[i]
			nom = i
	return [maxx, nom]

def raspred_chai(mas, ch, mas_nach):
	for i in range(len(mas)):
		if mas[max_and_nom(mas_nach)[1]] >= ch:
			mas[max_and_nom(mas_nach)[1]] = mas[max_and_nom(mas_nach)[1]] - ch
			return mas
		else:
			ch -= mas[max_and_nom(mas_nach)[1]]
			mas[max_and_nom(mas_nach)[1]] = 0
			mas_nach[max_and_nom(mas_nach)[1]] = 0
	print(-1)
	exit()
mas1 = raspred_chai(mas, ch, mas_nach.copy())
for i in range(len(mas_nach)):
	mas_nach[i] = mas_nach[i] - mas1[i]
print(*mas_nach)


from math import *
(n, k) = map(int, input().split())
l = list(map(int, input().split()))
d = [0] * n
f = 0
for i in range(n):
	x = ceil(l[i] / 2)
	if k >= x:
		d[i] += x
		k = k - x
	else:
		f = 1
		break
if f == 1:
	print(-1)
else:
	if k > 0:
		while k > 0:
			x = l.index(max(l))
			t = min(k, l[x] - d[x])
			d[x] += t
			l[x] = 0
			k = k - t
	print(*d)


def luckyYear():
	n = int(input())
	original = n
	p = -1
	f = 0
	while n > 0:
		f = n % 10
		n //= 10
		p += 1
	f += 1
	f *= 10 ** p
	print(f - original)

def averageSleepTime():
	(n, k) = list(map(int, input().split()))
	sleep = list(map(int, input().split()))
	run = 0
	for i in range(k):
		run += sleep[i]
	runavg = [run]
	for i in range(k, n):
		run = run - sleep[i - k] + sleep[i]
		runavg.append(run)
	print('{:.10f}'.format(sum(runavg) / (n - k + 1)))

def teaParty():
	(n, w) = list(map(int, input().split()))
	tea = list(map(int, input().split()))
	fill = []
	[fill.append((t + 1) // 2) for t in tea]
	if sum(tea) < w or sum(fill) > w:
		print(-1)
		return
	w -= sum(fill)
	sortedPos = [i[0] for i in sorted(enumerate(tea), key=lambda x: x[1])]
	for i in sortedPos[::-1]:
		if w <= 0:
			break
		value = min(tea[i] - fill[i], w)
		fill[i] += value
		w -= value
	print(' '.join(map(str, fill)))
teaParty()


(n, w) = [int(inp) for inp in input().split()]
cap = [int(a) for a in input().split(' ')]
val = [0] * n
for i in range(n):
	cap[i] = (cap[i], i)
cap.sort()
cap.reverse()
for i in range(n):
	val[i] = cap[i][0] // 2 + int(cap[i][0] % 2 != 0)
	w -= val[i]
if w < 0:
	print(-1)
	exit()
for i in range(n):
	v = min(w, cap[i][0] - val[i])
	val[i] += v
	w -= v
res = [0] * n
for i in range(n):
	res[cap[i][1]] = val[i]
for r in res:
	print(r, end=' ')


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
b = [0] * n
P = []
for i in range(n):
	P.append((a[i], i))
P = sorted(P, reverse=True)
for i in range(n):
	k = a[i] // 2 + int(a[i] % 2 != 0)
	b[i] += k
	w -= k
if w < 0:
	print(-1)
	exit()
i = 0
while w > 0:
	k = a[P[i][1]] - b[P[i][1]]
	b[P[i][1]] += min(w, k)
	w -= min(w, k)
	i += 1
print(*b)


import math
(n, w) = map(int, input().split())
vol = list(map(int, input().split()))
myList = []
for j in range(0, len(vol)):
	myList.append(math.ceil(vol[j] / 2))
if w < sum(myList):
	print(-1)
else:
	num = w - sum(myList)
	while num > 0:
		con = vol.index(max(vol))
		while myList[con] < vol[con] and num > 0:
			myList[con] += 1
			num -= 1
		vol[con] -= 1
	for t in myList:
		print(t, end=' ')


desc = input().split()
num = int(desc[0])
w = int(desc[1])
cups = list(map(int, input().split()))
halfsums = 0
resmilk = []
maxel = cups[0]
maxin = 0
maxls = []
for i in range(num):
	if cups[i] > maxel:
		maxel = cups[i]
		maxin = i
	if cups[i] % 2 == 0:
		thiscup = cups[i] // 2
	else:
		thiscup = cups[i] // 2 + 1
	halfsums += thiscup
	resmilk.append(thiscup)
if halfsums > w:
	print(-1)
else:
	while halfsums != w:
		if cups[maxin] - resmilk[maxin] < w - halfsums:
			halfsums += cups[maxin] - resmilk[maxin]
			resmilk[maxin] = cups[maxin]
			maxls.append(maxin)
			for i in range(num):
				if i not in maxls:
					maxin = i
					maxel = cups[i]
					break
			for i in range(num):
				if i not in maxls and cups[i] > maxel:
					maxin = i
					maxel = cups[i]
		else:
			resmilk[maxin] += w - halfsums
			halfsums = w
	for e in resmilk:
		print(e, end=' ')


(n, w) = map(int, input().split())
l = list(map(int, input().split()))
Half = [(i + 1) // 2 for i in l]
pos = [[l[i], (l[i] + 1) // 2, i] for i in range(n)]
pos.sort(reverse=True)
if w < sum(Half):
	print(-1)
	quit()
extra = w - sum(Half)
for i in range(n):
	if extra > 0:
		rem = pos[i][0] - pos[i][1]
		if rem >= extra:
			Half[pos[i][2]] += extra
			extra = 0
			break
		else:
			extra -= rem
			Half[pos[i][2]] = pos[i][0]
print(*Half)


(N, W) = map(int, input().split())
A = list(map(int, input().split()))
ord = sorted([i for i in range(N)], key=lambda x: A[x])
vol = [A[i] + 1 >> 1 for i in range(N)]
W -= sum(vol)
if W < 0:
	print(-1)
	exit(0)
for i in range(N - 1, -1, -1):
	if A[ord[i]] - vol[ord[i]] >= W:
		vol[ord[i]] += W
		break
	else:
		W -= A[ord[i]] - vol[ord[i]]
		vol[ord[i]] = A[ord[i]]
print(*vol)


(n, w) = map(int, input().split())
cup = list(map(int, input().split()))
ncup = []
for (i, c) in enumerate(cup):
	ncup.append([c, i])
ncup.sort()
tea = []
for (c, i) in ncup:
	t = c // 2 if c % 2 == 0 else c // 2 + 1
	w -= t
	tea.append([t, i])
for i in range(len(ncup) - 1, -1, -1):
	if w < 0:
		break
	add = min(w, ncup[i][0] - tea[i][0])
	w -= add
	tea[i][0] += add
if w != 0:
	print(-1)
else:
	tea.sort(key=lambda a: a[1])
	for (t, i) in tea:
		print(t, end=' ')
print()


(n, w) = map(int, input().split())
A = [(int(x), i) for (i, x) in enumerate(input().split())]
A.sort()
A.reverse()
B = [(x[0] + 1) // 2 for x in A]
left = w - sum(B)
if left < 0:
	print(-1)
else:
	for i in range(len(B)):
		to_add = min([left, A[i][0] - B[i]])
		B[i] += to_add
		left -= to_add
	assert left == 0
	result = [-1] * n
	for i in range(len(B)):
		result[A[i][1]] = B[i]
	print(' '.join(map(str, result)))


from math import *
(n, w) = map(int, input().split())
mas = list(map(int, input().split()))
mas2 = []
su = 0
for i in range(n):
	su += ceil(mas[i] / 2)
	mas2.append([ceil(mas[i] / 2), mas[i], i])
if su > w:
	print(-1)
	exit()
else:
	mas2.sort()
	ost = w - su
	x = len(mas2) - 1
	while ost > 0:
		while ost > 0 and mas2[x][0] < mas2[x][1]:
			ost -= 1
			mas2[x][0] += 1
		x -= 1
ans = [0] * n
for i in range(n):
	ans[mas2[i][2]] = mas2[i][0]
print(*ans)


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
pair = list()
cnt = 0
for i in range(n):
	cnt += int(a[i] / 2)
	if a[i] % 2:
		cnt += 1
if cnt > w:
	print(-1)
else:
	for i in range(n):
		pair.append((a[i], i))
	for i in range(n):
		x = int(a[i] / 2)
		if a[i] % 2:
			x += 1
		a[i] = x
		w -= a[i]
	pair.sort()
	pair.reverse()
	for i in range(n):
		x = pair[i][0]
		y = pair[i][1]
		p = x - a[y]
		if w >= p:
			a[y] += p
			w -= p
		else:
			a[y] += w
			w = 0
		if w == 0:
			break
	for i in range(n):
		print(a[i], end=' ')


(_, tea) = [int(x) for x in input().split(' ')]
sizes = [int(x) for x in input().split(' ')]
currsize = [0] * len(sizes)
nums = [i for i in range(len(sizes))]
nums = [x for (_, x) in sorted(zip(sizes, nums))]
sizes.sort()
for i in range(len(sizes)):
	tea -= (sizes[i] + 1) // 2
	currsize[i] = (sizes[i] + 1) // 2
if tea < 0:
	print(-1)
else:
	index = len(sizes) - 1
	while tea > 0 and index >= 0:
		if tea > sizes[index] - currsize[index]:
			tea -= sizes[index] - currsize[index]
			currsize[index] = sizes[index]
			index -= 1
		else:
			currsize[index] += tea
			tea = 0
	if tea != 0:
		print(-1)
	else:
		currsize = [x for (_, x) in sorted(zip(nums, currsize))]
		out = ''
		for i in currsize:
			out += str(i) + ' '
		print(out[:-1])


import math
import heapq
(n, w) = map(int, input().split())
a = list(map(int, input().split()))
aans = [0] * len(a)
heapa = []
for (i, x) in enumerate(a):
	half = math.ceil(x / 2)
	w -= half
	aans[i] = half
	heapq.heappush(heapa, (x, x - half, i))
if w < 0:
	print('-1')
else:
	for i in reversed(sorted(heapa)):
		extra = min(w, i[1])
		w -= extra
		aans[i[2]] += extra
		if w == 0:
			break
	print(' '.join((str(x) for x in aans)))


[n, w] = map(int, input().strip().split())
ais = list(map(int, input().strip().split()))
ni = list(range(n))
ni.sort(key=lambda i: ais[i], reverse=True)
vis = [-(-a // 2) for a in ais]
s = sum(vis)
if s > w:
	print(-1)
else:
	w -= s
	for i in ni:
		d = ais[i] - vis[i]
		d = min(d, w)
		vis[i] += d
		w -= d
		if w == 0:
			break
	print(' '.join(map(str, vis)))


(n, w) = list(map(int, input().split()))
a = list(map(int, input().split()))
b = [(x + 1) // 2 for x in a]
w -= sum(b)
if w > 0:
	a = [(a[i], i) for i in range(n)]
	a.sort(reverse=True)
	for i in range(n):
		x = min(a[i][0] - b[a[i][1]], w)
		w -= x
		b[a[i][1]] += x
		if w == 0:
			break
if w >= 0:
	print(*b)
else:
	print(-1)


def main():
	(n, w) = map(int, input().split())
	aa = list(map(int, input().split()))
	(x, y) = (sum(aa), sum((a & 1 for a in aa)))
	if x < w or x + y > w * 2:
		print(-1)
		return
	res = [r + 1 if r * 2 < a else r for (r, a) in ((a * w // x, a) for a in aa)]
	for i in sorted(range(n), key=aa.__getitem__, reverse=True)[:w - sum(res)]:
		res[i] += 1
	print(*res)
main()


class Node:

	def __init__(self, value, id):
		self.value = value
		self.id = id
		self.ans = 0

def solve():
	(sum1, sum2) = (0, 0)
	for x in p:
		tmp = int((x.value + 1) / 2)
		sum1 += tmp
		sum2 += x.value
		x.ans += tmp
	if sum1 > w or sum2 < w:
		return -1
	sum = w - sum1
	for i in range(n - 1, -1, -1):
		if sum == 0:
			break
		tmp = p[i].value - p[i].ans
		if sum >= tmp:
			p[i].ans += tmp
			sum -= tmp
		else:
			p[i].ans += sum
			sum = 0
	p.sort(key=lambda x: x.id)
	return 0
while True:
	try:
		(n, w) = map(int, input().split(' '))
	except:
		break
	p = [Node(int(x), i + 1) for (i, x) in enumerate(input().split(' '))]
	p.sort(key=lambda x: x.value)
	if solve() == -1:
		print('-1')
	else:
		for i in range(n):
			if i:
				print(' ', end='')
			print(p[i].ans, end='')
		print()


from sys import exit
(n, w) = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
for i in range(n):
	a[i] = (a[i], i)
a.sort(reverse=True)
ch = [0] * n
for i in range(n):
	ch[a[i][1]] = (a[i][0] + 1) // 2
	w -= ch[a[i][1]]
	if w < 0:
		print(-1)
		exit(0)
for i in range(n):
	if w > 0:
		add = min(w, a[i][0] - ch[a[i][1]])
		ch[a[i][1]] += add
		w -= add
print(*ch)


(n, w) = input().strip().split()
(n, w) = (int(n), int(w))
list1 = list(map(int, input().strip().split(' ')))
list2 = []
for x in list1:
	if x % 2 == 0:
		list2.append(x // 2)
	else:
		list2.append(1 + x // 2)
s = sum(list2)
if w < s:
	print(-1)
else:
	r = w - s
	while r > 0:
		m = max(list1)
		y = list1.index(m)
		while list2[y] < list1[y] and r > 0:
			list2[y] += 1
			r -= 1
		list1[y] = 0
	print(*list2)


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
b = []
for i in range(n):
	b.append(a[i] // 2 + a[i] % 2)
	w -= a[i] // 2 + a[i] % 2
if w < 0:
	print(-1)
else:
	while w > 0:
		m = (a[0], 0)
		for i in range(n):
			if a[i] > m[0]:
				m = [a[i], i]
		if w >= a[m[1]] - b[m[1]]:
			w -= a[m[1]] - b[m[1]]
			b[m[1]] = a[m[1]]
			a[m[1]] = 0
		else:
			b[m[1]] += w
			w = 0
	print(' '.join(map(str, b)))


import sys
import bisect
from bisect import bisect_left as lb
input_ = lambda : sys.stdin.readline().strip('\r\n')
from math import log
from math import gcd
from math import atan2, acos
from random import randint
sa = lambda : input_()
sb = lambda : int(input_())
sc = lambda : input_().split()
sd = lambda : list(map(int, input_().split()))
sflo = lambda : list(map(float, input_().split()))
se = lambda : float(input_())
sf = lambda : list(input_())
flsh = lambda : sys.stdout.flush()
mod = 10 ** 9 + 7
mod1 = 998244353
gp = []
cost = []
dp = []
mx = []
ans1 = []
ans2 = []
special = []
specnode = []
a = 0
kthpar = []

def dfs(root, par):
	if par != -1:
		dp[root] = dp[par] + 1
	for i in range(1, 20):
		if kthpar[root][i - 1] != -1:
			kthpar[root][i] = kthpar[kthpar[root][i - 1]][i - 1]
	for child in gp[root]:
		if child == par:
			continue
		kthpar[child][0] = root
		dfs(child, root)
ans = 0
b = []

def hnbhai(tc):
	(n, w) = sd()
	a = sd()
	p = []
	ans = [0] * n
	for i in range(n):
		p.append([a[i], i])
		w += -a[i] // 2
		ans[i] -= -a[i] // 2
	if w < 0:
		print(-1)
		return
	p.sort(reverse=True)
	while w > 0:
		for i in range(n):
			if w > 0 and ans[p[i][1]] < p[i][0]:
				ans[p[i][1]] += 1
				w -= 1
			else:
				break
	print(*ans)
for _ in range(1):
	hnbhai(_ + 1)


(n, w) = map(int, input().split())
a = [(int(x), i) for (i, x) in enumerate(input().split())]
a.sort()
b = [0] * n
for i in range(len(a)):
	(x, pos) = a[i]
	b[pos] = (x + 1) // 2
	w -= b[pos]
if w < 0:
	print(-1)
else:
	for i in reversed(range(len(a))):
		(x, pos) = a[i]
		k = min(x - b[pos], w)
		w -= k
		b[pos] += k
	print(' '.join(map(str, b)))


from math import *
from itertools import *
(n, w) = map(int, input().split())
p = list(map(int, input().split()))
q = list(sorted([[p[i], i] for i in range(len(p))], key=lambda l: l[0]))
res = sum((ceil(q[i][0] / 2) for i in range(len(q))))
if res > w:
	print(-1)
else:
	res_list = list(repeat(0, len(p)))
	for i in range(len(q)):
		res_list[q[i][1]] = ceil(q[i][0] / 2)
	for i in range(len(q) - 1, -1, -1):
		tmp = min(w - res, p[q[i][1]] - res_list[q[i][1]])
		res_list[q[i][1]] += tmp
		w -= tmp
	for i in range(len(res_list)):
		print(res_list[i])


import sys
import math

def IO():
	sys.stdin = open('pyinput.txt', 'r')
	sys.stdout = open('pyoutput.txt', 'w')

def GCD(a, b):
	if b == 0:
		return a
	else:
		return GCD(b, a % b)

def LCM(a, b):
	return a * (b // GCD(a, b))

def scan(TYPE_1, TYPE_2=0):
	if TYPE_1 == int:
		return map(int, sys.stdin.readline().strip().split())
	elif TYPE_1 == float:
		return map(float, sys.stdin.readline().strip().split())
	elif TYPE_1 == list and TYPE_2 == float:
		return list(map(float, sys.stdin.readline().strip().split()))
	elif TYPE_1 == list and TYPE_2 == int:
		return list(map(int, sys.stdin.readline().strip().split()))
	elif TYPE_1 == str:
		return sys.stdin.readline().strip()
	else:
		print('ERROR!!!!')

def main():
	(n, k) = scan(int)
	a = scan(list, int)
	idx = []
	for i in range(n):
		idx.append((a[i], i))
	idx.sort()
	ans = [(i + 1) // 2 for i in a]
	x = sum(ans)
	if x > k:
		print(-1)
		return
	k -= x
	i = n - 1
	while k > 0:
		x = idx[i][1]
		inc = min(a[x] - ans[x], k)
		ans[x] += inc
		k -= inc
		i -= 1
	print(*ans)
main()


import sys
input = sys.stdin.buffer.readline

def solution():
	(n, w) = map(int, input().split())
	l = list(map(int, input().split()))
	a = []
	z = [0] * n
	ans = 0
	for i in range(n):
		if l[i] % 2 == 0:
			ans += l[i] // 2
			a.append([l[i], l[i] // 2, i])
		else:
			ans += l[i] // 2 + 1
			a.append([l[i], l[i] // 2 + 1, i])
	if ans > w:
		print(-1)
		exit(0)
	x = w - ans
	a.sort(reverse=True)
	i = 0
	while x > 0 and i < n:
		d = a[i][0] - a[i][1]
		if x <= d:
			a[i][1] += x
			x = 0
		else:
			a[i][1] = a[i][0]
			x -= d
		i += 1
	a.sort(key=lambda x: x[2])
	for i in range(n):
		print(a[i][1], end=' ')
solution()


(n, w) = map(int, input().split())
a = list(map(int, input().split()))
s = 0
for ai in a:
	s += (ai + 1) // 2
if w < s:
	print(-1)
	exit()
ia = [(i, a[i]) for i in range(n)]
ia.sort(key=lambda t: t[1], reverse=True)
ans = [-1] * n
for (i, ai) in ia:
	ans[i] = (ai + 1) // 2
	w -= ans[i]
for (i, ai) in ia:
	if w - (ai - ans[i]) > 0:
		w -= ai - ans[i]
		ans[i] = ai
	else:
		ans[i] += w
		break
print(*ans)


import sys, math, queue
MOD = 10 ** 9 + 7
sys.setrecursionlimit(1000000)
(n, w) = map(int, input().split())
b = list(map(int, input().split()))
a = sorted([(b[i], i) for i in range(n)], reverse=True)
ans = [-1 for i in range(n)]
for i in range(n):
	ans[a[i][1]] = (a[i][0] + 1) // 2
	w -= ans[a[i][1]]
for i in range(n):
	if w > 0:
		d = b[a[i][1]] - ans[a[i][1]]
		ans[a[i][1]] += min(w, d)
		w -= min(w, d)
	else:
		break
if w < 0:
	print(-1)
else:
	print(*ans)


from sys import stdin, stdout
from math import ceil
(n, w) = map(int, stdin.readline().split())
values = list(map(int, stdin.readline().split()))
fill = [0 for i in range(n)]
for i in range(n):
	values[i] = (values[i], i)
values.sort()
label = 1
for i in range(n - 1, -1, -1):
	if ceil(values[i][0] / 2) <= w:
		fill[i] = ceil(values[i][0] / 2)
		w -= ceil(values[i][0] / 2)
	else:
		label = 0
if not label:
	stdout.write(str('-1'))
else:
	for i in range(n - 1, -1, -1):
		cnt = min(w, values[i][0] - fill[i])
		fill[i] += min(w, values[i][0] - fill[i])
		w -= cnt
	ans = [0 for i in range(n)]
	if w:
		stdout.write('-1')
	else:
		for i in range(n):
			ans[values[i][1]] = fill[i]
		stdout.write(' '.join(list(map(str, ans))))


import math
(n, w) = map(int, input().split())
a = list(map(int, input().split()))
l = []
for i in range(n):
	l.append([a[i], i, math.ceil(a[i] / 2)])
l.sort(reverse=True)
s = 0
for i in range(n):
	s += l[i][2]
if w < s:
	print(-1)
else:
	rest = w - s
	for i in range(n):
		if rest != 0:
			t = l[i][2]
			l[i][2] = min(l[i][0], l[i][2] + rest)
			rest = rest - (l[i][2] - t)
		else:
			break
	ans = [0] * n
	for i in range(n):
		ans[l[i][1]] = l[i][2]
	print(*ans)


import sys
import os
import math
(n, w) = map(int, input().split())
A = list(map(int, input().split()))
pours = [None] * n
B = []
for (i, a) in enumerate(A):
	B.append((a, i))
B.sort()
for b in B:
	cup = b[0]
	i = b[1]
	pour_amount = math.ceil(cup / 2)
	pours[i] = pour_amount
	w -= pour_amount
if w < 0:
	print(-1)
else:
	for i in range(n - 1, -1, -1):
		(cup, idx) = B[i]
		if cup > pours[idx]:
			re_pour_amount = min(w, cup - pours[idx])
			pours[idx] += re_pour_amount
			w -= re_pour_amount
	print(*pours)


from sys import stdout
(n, w) = map(int, input().split())
a = [int(i) for i in input().split()]
a = sorted([(a[i], i) for i in range(n)])
b = [0] * n
for i in a:
	b[i[1]] += i[0] // 2 + (1 if i[0] % 2 else 0)
	w -= b[i[1]]
	if w < 0:
		print(-1)
		exit()
for i in range(-1, -n - 1, -1):
	if w <= 0:
		break
	k = min(w, a[i][0] - b[a[i][1]])
	b[a[i][1]] += k
	w -= k
stdout.write(str(b[0]))
for i in b[1:]:
	stdout.write(' ' + str(i))


import math
(n, w) = list(map(int, input().split()))
a = list(map(int, input().split()))
store = {}
sum_min = 0
ans = []
flag = False
for (i, item) in enumerate(a):
	sum_min += math.ceil(item / 2)
	if sum_min > w:
		print('-1')
		flag = True
		break
	ans.append(math.ceil(item / 2))
	store[i] = item
if not flag:
	store = sorted(store.items(), key=lambda kv: (kv[1], kv[0]), reverse=True)
	for item in store:
		if sum_min < w:
			d = min(a[item[0]] - ans[item[0]], w - sum_min)
			ans[item[0]] += d
			sum_min += d
		else:
			break
	if sum_min < w:
		print('-1')
	else:
		print(*ans)


from operator import itemgetter
import math
line1 = input()
line1 = line1.split(' ')
(n, w) = (int(line1[0]), int(line1[1]))
line2 = input()
line2 = line2.split(' ')
A = []
for i in range(0, n):
	A.append([int(line2[i]), 0, False, i + 1])
A.sort(reverse=True, key=itemgetter(0))
left1_2 = n
while w:
	if not w or not left1_2:
		break
	for i in range(0, n):
		if not w or not left1_2:
			break
		if A[i][2] == False:
			A[i][1] += 1
			w -= 1
			if A[i][1] >= math.ceil(A[i][0] / 2):
				left1_2 -= 1
				A[i][2] = True
vacant = 0
for i in range(0, n):
	vacant += A[i][0] - A[i][1]
while 1:
	if not vacant or not w:
		break
	for i in range(0, n):
		if A[i][1] < A[i][0]:
			if not vacant or not w:
				break
			w -= 1
			vacant -= 1
			A[i][1] += 1
A.sort(key=itemgetter(3))
flag = True
if w:
	print(-1)
	flag = False
else:
	for i in range(0, n):
		if A[i][1] < math.ceil(A[i][0] / 2):
			print(-1)
			flag = False
			break
if flag:
	for i in A:
		print(i[1], end=' ')