X,K,D=list(map(int,input().split()))

 

x=min(K,abs(X)//D)

 

if X>0:

    X_=X-(D*x)

else:

    X_=X+(D*x)

 

k=K-x

if k%2!=0:

    ans=min(abs(X_-D),abs(X_+D))

else:

    ans=abs(X_)

print(ans)
X,K,D=list(map(int,input().split()))



X=abs(X)

k=min(K,X//D)

X_=X-(k*D)

K_=K-k



if K_%2!=0:

    ans=min(abs(X_-D),abs(X_+D))

else:

    ans=abs(X_)



print(ans)
X, K, D = list(map(int, input().split()))
x = min(K, abs(X) // D)
if X > 0:
    X_ = X - (D * x)
else:
    X_ = X + (D * x)
k = K - x
if k % 2 != 0:
    ans = min(abs(X_ - D), abs(X_ + D))
else:
    ans = abs(X_)
print(ans)

X, K, D = list(map(int, input().split()))
X = abs(X)
k = min(K, X // D)
X_ = X - (k * D)
K_ = K - k
if K_ % 2 != 0:
    ans = min(abs(X_ - D), abs(X_ + D))
else:
    ans = abs(X_)
print(ans)

-x = min(K, abs(X) // D) -if X > 0: -    X_ = X - (D * x) -else: -    X_ = X + (D * x) -k = K - x -if k % 2 != 0: +X = abs(X) +k = min(K, X // D) +X_ = X - (k * D) +K_ = K - k +if K_ % 2 != 0: