x, k, d = map(int, input().split())
x = abs(x)
num = x // d
if num >= k:
    ans = x - k*d
else:
    if (k-num)%2 == 0:
        ans = x - num*d
    else:
        ans = min(abs(x - num*d - d), abs(x - num*d + 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 num = x // d num x // d x d if num >= k:
    ans = x - k*d
else:
    if (k-num)%2 == 0:
        ans = x - num*d
    else:
        ans = min(abs(x - num*d - d), abs(x - num*d + d)) num >= k num k ans = x - k*d ans x - k*d x k*d k d if (k-num)%2 == 0:
        ans = x - num*d
    else:
        ans = min(abs(x - num*d - d), abs(x - num*d + d)) (k-num)%2 == 0 (k-num)%2 k-num k num 2 0 ans = x - num*d ans x - num*d x num*d num d ans = min(abs(x - num*d - d), abs(x - num*d + d)) ans min(abs(x - num*d - d), abs(x - num*d + d)) min abs(x - num*d - d) abs x - num*d - d x - num*d x num*d num d d abs(x - num*d + d) abs x - num*d + d x - num*d x num*d num d d print(ans) print ans x, k, d = map(int, input().split()) map(int, input().split()) x k, d = map(int, input().split()) map(int, input().split()) k d = map(int, input().split()) map(int, input().split()) d ans = min(abs(x - num*d - d), abs(x - num*d + d)) min(abs(x - num*d - d), abs(x - num*d + d)) ans num = x // d x // d num ans = x - k*d x - k*d ans ans = x - num*d x - num*d ans x = abs(x) abs(x) x
x, k, d = map(int, input().split())
x = abs(x)
num = x // d
if num >= k:
    ans = x - k*d
else:
    if (k-num)%2 == 0:
        ans = x - num*d
    else:
        ans = min(abs(x - num*d - d), abs(x - num*d + d))

print(ans)