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

x=abs(x)

sa=x//d

ans=x

pbk,mbk=0,0

bk1,bk2,bk3=1,1,1

mansbk,pansbk=0,0

if sa>=k:

  ans=x-d*k

else:

  ans=x-d*sa

  k=k-sa

  for i in range(k):

    mansbk=abs(ans-d)

    pansbk=abs(ans+d)

    if mansbk!=pansbk:

      ans=min(mansbk,pansbk)

      if bk3!=1:

        bk1=min(mansbk,pansbk)

        bk2=max(mansbk,pansbk)

        ans=mbk if (k-i)%2==0 else bk1

        break

      else:

        bk3=max(mansbk,pansbk) 

    else:

      ans=0 if (k-i)%2==0 else d

      break

    pbk=max(mansbk,pansbk)

    mbk=min(mansbk,pansbk)

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

x=abs(x)

m=min(k,x//d)

x-=d*m

k-=m

k%=2

x-=d*k

print((abs(x)))
x, k, d = list(map(int, input().split()))
x = abs(x)
sa = x // d
ans = x
pbk, mbk = 0, 0
bk1, bk2, bk3 = 1, 1, 1
mansbk, pansbk = 0, 0
if sa >= k:
    ans = x - d * k
else:
    ans = x - d * sa
    k = k - sa
    for i in range(k):
        mansbk = abs(ans - d)
        pansbk = abs(ans + d)
        if mansbk != pansbk:
            ans = min(mansbk, pansbk)
            if bk3 != 1:
                bk1 = min(mansbk, pansbk)
                bk2 = max(mansbk, pansbk)
                ans = mbk if (k - i) % 2 == 0 else bk1
                break
            else:
                bk3 = max(mansbk, pansbk)
        else:
            ans = 0 if (k - i) % 2 == 0 else d
            break
        pbk = max(mansbk, pansbk)
        mbk = min(mansbk, pansbk)
print(ans)

x, k, d = list(map(int, input().split()))
x = abs(x)
m = min(k, x // d)
x -= d * m
k -= m
k %= 2
x -= d * k
print((abs(x)))

-sa = x // d -ans = x -pbk, mbk = 0, 0 -bk1, bk2, bk3 = 1, 1, 1 -mansbk, pansbk = 0, 0 -if sa >= k: -    ans = x - d * k -else: -    ans = x - d * sa -    k = k - sa -    for i in range(k): -        mansbk = abs(ans - d) -        pansbk = abs(ans + d) -        if mansbk != pansbk: -            ans = min(mansbk, pansbk) -            if bk3 != 1: -                bk1 = min(mansbk, pansbk) -                bk2 = max(mansbk, pansbk) -                ans = mbk if (k - i) % 2 == 0 else bk1 -                break -            else: -                bk3 = max(mansbk, pansbk) -        else: -            ans = 0 if (k - i) % 2 == 0 else d -            break -        pbk = max(mansbk, pansbk) -        mbk = min(mansbk, pansbk) -print(ans) +m = min(k, x // d) +x -= d * m +k -= m +k %= 2 +x -= d * k +print((abs(x)))