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

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

x = abs(x)
div = min(x//d, k)
if (k - div) % 2 == 0:
    ans = abs(x - d * div)
else:
    ans = abs(x - d * div - d)
print(ans)