Recently Maxim has found an array of n integers, needed by no one. He immediately come up with idea of changing it: he invented positive integer x and decided to add or subtract it from arbitrary array elements. Formally, by applying single operation Maxim chooses integer i (1 ≤ i ≤ n) and replaces the i-th element of array a_{i} either with a_{i} + x or with a_{i} - x. Please note that the operation may be applied more than once to the same position.

Maxim is a curious minimalis, thus he wants to know what is the minimum value that the product of all array elements (i.e. $\prod_{i = 1}^{n} a_{i}$) can reach, if Maxim would apply no more than k operations to it. Please help him in that.


-----Input-----

The first line of the input contains three integers n, k and x (1 ≤ n, k ≤ 200 000, 1 ≤ x ≤ 10^9) — the number of elements in the array, the maximum number of operations and the number invented by Maxim, respectively.

The second line contains n integers a_1, a_2, ..., a_{n} ($|a_{i}|\leq 10^{9}$) — the elements of the array found by Maxim.


-----Output-----

Print n integers b_1, b_2, ..., b_{n} in the only line — the array elements after applying no more than k operations to the array. In particular, $a_{i} \equiv b_{i} \operatorname{mod} x$ should stay true for every 1 ≤ i ≤ n, but the product of all array elements should be minimum possible.

If there are multiple answers, print any of them.


-----Examples-----
Input
5 3 1
5 4 3 5 2

Output
5 4 3 5 -1 

Input
5 3 1
5 4 3 5 5

Output
5 4 0 5 5 

Input
5 3 1
5 4 4 5 5

Output
5 1 4 5 5 

Input
3 2 7
5 4 2

Output
5 11 -5

Difficulty: interview

Starter code:

Solutions:
import heapq as hq
from math import ceil
n, k, x = [int(i) for i in input().strip().split(' ')]
arr = [int(i) for i in input().strip().split(' ')]
is_neg = False
for i in arr:
    if i < 0:
        is_neg = True if is_neg == False else False

narr = [[abs(i), pos, i < 0] for pos, i in enumerate(arr)]
hq.heapify(narr)
if is_neg:
    while k > 0:
        hq.heapreplace(narr, [narr[0][0]+x, narr[0][1], narr[0][2]])
        k -= 1
else:
    minode = hq.heappop(narr)
    mi = minode[0]
    kswitch = ceil(mi/x) #make the off number of negatives
    if kswitch > k:
        kswitch = k
    else:
        minode[2] = False if minode[2] == True else True
    k -= kswitch

    hq.heappush(narr, [abs(mi-kswitch*x), minode[1], minode[2]])
    while k > 0:
        hq.heapreplace(narr, [narr[0][0]+x, narr[0][1], narr[0][2]])
        k -= 1

narr = sorted(narr, key=lambda x:x[1])
arr = [str(i[0]*(-1 if i[2] else 1)) for i in narr]
print(" ".join(arr))

import heapq

inp = list(map(int, input().split()))
n = inp[0]
k = inp[1]
x = inp[2]

a = [int(i) for i in input().strip().split(' ')]

isPositive = True
nodes = [[abs(val), val, index] for index, val in enumerate(a)]

for el in a:
    if el < 0:
        isPositive = not isPositive

heapq.heapify(nodes)

for i in range(k):
    minNode = nodes[0]
    val = minNode[1]
    isCurPositive = val >= 0
    newVal = val
    if isPositive == isCurPositive:
        newVal -= x
    else:
        newVal += x

    minNode[1] = newVal
    if val >= 0 > newVal or val < 0 <= newVal:
        isPositive = not isPositive

    heapq.heapreplace(nodes, [abs(newVal), newVal, minNode[2]])

result = [None] * n
for node in nodes:
    result[node[2]] = str(node[1])

print(" ".join(result))


import heapq

n,k,v = list(map(int, input().split()))
num = list(map(int, input().split()))

sign = len([x for x in num if x<0])
minx,mini = min([[abs(x),i] for i,x in enumerate(num)])

if sign%2==0:
    if num[mini]<0:
        c = min(minx//v+1, k)
        k -= c
        num[mini] += v*c
    elif num[mini]>=0:
        c = min(minx//v+1, k)
        k -= c
        num[mini] -= v*c


heap = []
heapq.heapify(heap)
for i,x in enumerate(num):
    heapq.heappush(heap, [abs(x), i])

while k:
    absx,curi = heapq.heappop(heap)
    #print(curi, num[curi])
    if num[curi]>=0:
        num[curi] += v
    else:
        num[curi] -= v
    heapq.heappush(heap, [abs(num[curi]),curi])
    k -= 1
    
print(' '.join([str(x) for x in num]))


def main():
    from heapq import heapify, heappop, heappushpop,heappush
    n, k, x = map(int, input().split())
    l, sign, h = list(map(int, input().split())), [False] * n, []
    helper = lambda: print(' '.join(str(-a if s else a) for a, s in zip(l, sign)))
    for i, a in enumerate(l):
        if a < 0:
            sign[i] = True
            h.append((-a, i))
        else:
            h.append((a, i))
    heapify(h)
    a, i = heappop(h)
    if 1 - sum(sign) % 2:
        j = min(a // x + (1 if a % x else 0), k)
        a -= j * x
        if a > 0:
            l[i] = a
            return helper()
        k -= j
        a = -a
        sign[i] ^= True
    for _ in range(k):
        a, i = heappushpop(h, (a, i))
        a += x
    l[i] = a
    for a, i in h:
        l[i] = a
    helper()


def __starting_point():
    main()

__starting_point()

import heapq
s = input().split()
n = int(s[0])
k = int(s[1])
x = int(s[2])
neg=0
zeroes=0
numbers = list(map(int,input().split()))
num = []
for i in numbers:
	if(i<0):
		neg+=1
	elif(i==0):
		zeroes+=1

for i,x1 in enumerate(numbers):
	num.append([abs(x1),i])
heapq.heapify(num)
temp=[]
steps=0
if(neg%2==0):
	temp = heapq.heappop(num)
	# print(temp[1],temp[0])
	# print(numbers[temp[1]],x)
	if(numbers[temp[1]]<0):
		steps = min(abs(numbers[temp[1]])//x+1,k)
		k-=steps
		numbers[temp[1]]+=steps*x
		heapq.heappush(num,[abs(numbers[temp[1]]),temp[1]])
	else:
		steps = min((abs(numbers[temp[1]])//x)+1,k)
		# print(steps)
		k-=steps
		numbers[temp[1]]-=steps*x
		heapq.heappush(num,[abs(numbers[temp[1]]),temp[1]])

while(k>0):
	temp = heapq.heappop(num)
	# print(temp[1],temp[0])
	if(numbers[temp[1]]<0):
		# steps = (numbers[temp[1]]//x+1)
		# k-=steps
		numbers[temp[1]]-=x
		heapq.heappush(num,[abs(numbers[temp[1]]),temp[1]])
	else:
		# steps = (numbers[temp[1]]//x+1)
		# k-=steps
		numbers[temp[1]]+=x
		heapq.heappush(num,[abs(numbers[temp[1]]),temp[1]])
	k-=1
for i in numbers:
	print(i,end=" ")



import heapq

n, k, X = list(map(int, input().split()))
a       = list(map(int, input().split()))
Q       = []
sit     = 0

for i, x in enumerate(a):
    if x < 0:
        sit += 1
    heapq.heappush(Q, (abs(x), x, i))    
        
sit = sit % 2

while k > 0:
    (val, x, i) = heapq.heappop(Q)
    change = None
    
    if x < 0:
        if sit == 1:
            change = x - X
        else:
            change = x + X
    else:
        if sit == 1:
            change = x + X
        else:
            change = x - X
    
    if (x * change < 0) or (x < 0 and change == 0) or (x == 0 and change < 0):
        sit = (sit+1) % 2
        
    heapq.heappush(Q, (abs(change), change, i))
    k-=1
    
ans = [0] * n
for (val, x, i) in Q:
    ans[i] = str(x)
print(' '.join(ans))    

#5 3 1
#5 4 3 5 2

#5 3 1
#5 4 3 5 5

#5 3 1
#5 4 4 5 5

#3 2 7
#5 4 2


import heapq

n, k, x = [int(val) for val in input().split()]
a = [int(val) for val in input().split()]

data = [(val, 1, i) if val >= 0 else (-1 * val, -1, i) for i, val in enumerate(a)]
heapq.heapify(data)
sign = sum([1 if s == -1 else 0 for _, s, _ in data])

if sign % 2 == 1:
    for i in range(k):
        e = heapq.heappop(data)
        heapq.heappush(data, (e[0] + x, e[1], e[2]))
else:
    e = heapq.heappop(data)
    if e[0] <  k * x:
        s = (e[0] // x) + 1
        k -= s
        heapq.heappush(data, (s * x - e[0], -1 * e[1], e[2]))
        for i in range(k):
            e = heapq.heappop(data)
            heapq.heappush(data, (e[0] + x, e[1], e[2]))
    else:
        heapq.heappush(data, (e[0] - k * x, e[1], e[2]))

output = [0] * n
for val, s, i in data:
    output[i] = s * val
print(' '.join([str(val) for val in output]))