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

x=abs(x)

ans=0

if x>k*d:

    ans=x-(k*d)

else:

    if k%2==(x//d)%2:

        ans=x%d

    else:

        ans=min(abs(x%d-d),abs(x%d+d))

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

x=abs(x)

ans=0

if x>k*d:

    ans=x-(k*d)

else:

    if k%2==(x//d)%2:

        ans=x%d

    else:

        ans=abs(x%d-d)

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

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

-        ans = min(abs(x % d - d), abs(x % d + d)) +        ans = abs(x % d - d)