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

x = abs(x)

ans = 0

if x >= k * d:

    ans = x - d * k

else:

    i = x // d

    j = k - i

    if (j % 2 == 0):

        ans = x - d * i

    else:

        ans = x - d * (i + 1)

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

x = abs(x)

ans = 0

if x // d > k:

    ans = x - d * k

else:

    e = x // d

    k -= e

    x -= e * d

    if (k % 2 == 1):

        x = abs(x - d)

    ans = x

print(ans)

x, k, d = list(map(int, input().split()))
x = abs(x)
ans = 0
if x >= k * d:
    ans = x - d * k
else:
    i = x // d
    j = k - i
    if j % 2 == 0:
        ans = x - d * i
    else:
        ans = x - d * (i + 1)
print((abs(ans)))

x, k, d = list(map(int, input().split()))
x = abs(x)
ans = 0
if x // d > k:
    ans = x - d * k
else:
    e = x // d
    k -= e
    x -= e * d
    if k % 2 == 1:
        x = abs(x - d)
    ans = x
print(ans)

-if x >= k * d: +if x // d > k: -    i = x // d -    j = k - i -    if j % 2 == 0: -        ans = x - d * i -    else: -        ans = x - d * (i + 1) -print((abs(ans))) +    e = x // d +    k -= e +    x -= e * d +    if k % 2 == 1: +        x = abs(x - d) +    ans = x +print(ans)