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