x,k,d = map(int, input().split())
lists = []
x = abs(x)

step = int(x/d) 

if step >= k:
  answer = x - k * d
elif step < k:
  k_left = k - int(step)
  if k_left % 2 == 0:
    answer = x % d
  if k_left % 2 == 1:
    answer = abs(x - step * d - d)

print(answer) x,k,d = map(int, input().split()) x map(int, input().split()) map int input().split() ().split () input split k d lists = [] lists [] x = abs(x) x abs(x) abs x step = int(x/d) step int(x/d) int x/d x d if step >= k:
  answer = x - k * d
elif step < k:
  k_left = k - int(step)
  if k_left % 2 == 0:
    answer = x % d
  if k_left % 2 == 1:
    answer = abs(x - step * d - d) step >= k step k answer = x - k * d answer x - k * d x k * d k d elif step < k:
  k_left = k - int(step)
  if k_left % 2 == 0:
    answer = x % d
  if k_left % 2 == 1:
    answer = abs(x - step * d - d) step < k step k k_left = k - int(step) k_left k - int(step) k int(step) int step if k_left % 2 == 0:
    answer = x % d
   k_left % 2 == 0 k_left % 2 k_left 2 0 answer = x % d answer x % d x d if k_left % 2 == 1:
    answer = abs(x - step * d - d) k_left % 2 == 1 k_left % 2 k_left 2 1 answer = abs(x - step * d - d) answer abs(x - step * d - d) abs x - step * d - d x - step * d x step * d step d d print(answer) print answer k_left = k - int(step) k - int(step) k_left answer = x % d x % d answer lists = [] [] lists answer = x - k * d x - k * d answer x,k,d = map(int, input().split()) map(int, input().split()) x d = map(int, input().split()) map(int, input().split()) d k,d = map(int, input().split()) map(int, input().split()) k step = int(x/d) int(x/d) step x = abs(x) abs(x) x answer = abs(x - step * d - d) abs(x - step * d - d) answer
x,k,d = map(int, input().split())
lists = []
x = abs(x)

step = int(x/d) 

if step >= k:
  answer = x - k * d
elif step < k:
  k_left = k - int(step)
  if k_left % 2 == 0:
    answer = x % d
  if k_left % 2 == 1:
    answer = abs(x - step * d - d)

print(answer)