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



x, cnt = abs(x), abs(x) // d

if k % 2 == cnt % 2:

    ans = abs(x - d * min(k,cnt))

elif k % 2 != cnt % 2:

    ans = abs(x - d * min(k,(cnt + 1)))

print(ans)

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



x, cnt = abs(x), abs(x) // d

ans = abs(x - d * min(k, cnt + (k % 2 != cnt % 2)))

print(ans)

x, k, d = list(map(int, input().split()))
x, cnt = abs(x), abs(x) // d
if k % 2 == cnt % 2:
    ans = abs(x - d * min(k, cnt))
elif k % 2 != cnt % 2:
    ans = abs(x - d * min(k, (cnt + 1)))
print(ans)

x, k, d = list(map(int, input().split()))
x, cnt = abs(x), abs(x) // d
ans = abs(x - d * min(k, cnt + (k % 2 != cnt % 2)))
print(ans)

-if k % 2 == cnt % 2: -    ans = abs(x - d * min(k, cnt)) -elif k % 2 != cnt % 2: -    ans = abs(x - d * min(k, (cnt + 1))) +ans = abs(x - d * min(k, cnt + (k % 2 != cnt % 2)))