x, k, d = list(map(int, input().split()))



pm = 1 if x >= 0 else -1

a = abs(x)//d

b = a if abs(x-pm*a*d) < abs(x-pm*(a+1)*d) else a+1

c = min(b, k)

e = x-pm*c*d

if k < b or (k-b) % 2 == 0:

    print((abs(e)))

else:

    print((min(abs(e+d), abs(e-d))))
x, k, d = list(map(int, input().split()))



t = min(abs(x)//d, k)

u = abs(x)-d*t

print((abs(u-d*((k-t)%2))))

x, k, d = list(map(int, input().split()))
pm = 1 if x >= 0 else -1
a = abs(x) // d
b = a if abs(x - pm * a * d) < abs(x - pm * (a + 1) * d) else a + 1
c = min(b, k)
e = x - pm * c * d
if k < b or (k - b) % 2 == 0:
    print((abs(e)))
else:
    print((min(abs(e + d), abs(e - d))))

x, k, d = list(map(int, input().split()))
t = min(abs(x) // d, k)
u = abs(x) - d * t
print((abs(u - d * ((k - t) % 2))))

-pm = 1 if x >= 0 else -1 -a = abs(x) // d -b = a if abs(x - pm * a * d) < abs(x - pm * (a + 1) * d) else a + 1 -c = min(b, k) -e = x - pm * c * d -if k < b or (k - b) % 2 == 0: -    print((abs(e))) -else: -    print((min(abs(e + d), abs(e - d)))) +t = min(abs(x) // d, k) +u = abs(x) - d * t +print((abs(u - d * ((k - t) % 2))))