import math

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

if y >= 0:

    x = y

else:

    x = -y

i = math.floor(x / d)

if i >= k:

    p = x - k * d

elif i == x / d:

    if i + k == 2 * int((i + k) / 2):

        p = 0

    else:

        p = d

else:

    if (2 * i + 1) * d == 2 * x:

        p = x - i * d

    else:

        if i + k == 2 * int((i + k) / 2):

            p = x - i * d

        else:

            p = (i + 1) * d - x

print((int(p)))
y, k, d = list(map(int, input().split()))

x = abs(y)

i = int(x / d)

if i >= k:

    p = x - k * d

elif i == x / d:

    if (i + k) % 2 == 0:

        p = 0

    else:

        p = d

else:

    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0):

        p = x - i * d

    else:

        p = (i + 1) * d - x

print((int(p)))
import math

y, k, d = list(map(int, input().split()))
if y >= 0:
    x = y
else:
    x = -y
i = math.floor(x / d)
if i >= k:
    p = x - k * d
elif i == x / d:
    if i + k == 2 * int((i + k) / 2):
        p = 0
    else:
        p = d
else:
    if (2 * i + 1) * d == 2 * x:
        p = x - i * d
    else:
        if i + k == 2 * int((i + k) / 2):
            p = x - i * d
        else:
            p = (i + 1) * d - x
print((int(p)))

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

-import math - -if y >= 0: -    x = y -else: -    x = -y -i = math.floor(x / d) +x = abs(y) +i = int(x / d) -    if i + k == 2 * int((i + k) / 2): +    if (i + k) % 2 == 0: -    if (2 * i + 1) * d == 2 * x: +    if ((2 * i + 1) * d == 2 * x) or ((i + k) % 2 == 0): -        if i + k == 2 * int((i + k) / 2): -            p = x - i * d -        else: -            p = (i + 1) * d - x +        p = (i + 1) * d - x