x, k, d = [int(s) for s in input().split()]
x = abs(x)
q, m = divmod(x, d)
if q >= k:
    x -= k * d
else:
    x = m
    if (k - q) & 1:
        x = d - x
print(x) int(s) for s in input().split() for s in input().split() s input().split() ().split () input split for s in input().split() int(s) int s x, k, d = [int(s) for s in input().split()] x [int(s) for s in input().split()] k d x = abs(x) x abs(x) abs x q, m = divmod(x, d) q divmod(x, d) divmod x d m if q >= k:
    x -= k * d
else:
    x = m
    if (k - q) & 1:
        x = d - x q >= k q k x -= k * d x k * d k d x = m x m if (k - q) & 1:
        x = d - x (k - q) & 1 k - q k q 1 x = d - x x d - x d x print(x) print x d = [int(s) for s in input().split()] [int(s) for s in input().split()] d x = d - x d - x x x, k, d = [int(s) for s in input().split()] [int(s) for s in input().split()] x x -= k * d k * d x k, d = [int(s) for s in input().split()] [int(s) for s in input().split()] k x = abs(x) abs(x) x q, m = divmod(x, d) divmod(x, d) q m = divmod(x, d) divmod(x, d) m x = m m x
x, k, d = [int(s) for s in input().split()]
x = abs(x)
q, m = divmod(x, d)
if q >= k:
    x -= k * d
else:
    x = m
    if (k - q) & 1:
        x = d - x
print(x)