output_description: Print the minimum possible absolute value of the coordinate of the
  destination.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      X K D
attempt: import sys
  from io import StringIO
  import unittest
  
  
  def resolve():
  
      # スペース区切りの整数の入力
      X, K, D = map(int, input().split())
      # 文字列の入力
      if abs(X) - K * D > 0:
          print("{}".format(abs(X) - K * D))
      else:
          mod = abs(X) % D
          modk = int(abs(X) / D)
          if (K - modk) % 2 == 0:
              print("{}".format(mod))
          else:
              print("{}".format(D - mod))
  
      # 出力
  
  
  class TestClass(unittest.TestCase):
      def assertIO(self, input, output):
          stdout, stdin = sys.stdout, sys.stdin
          sys.stdout, sys.stdin = StringIO(), StringIO(input)
          resolve()
          sys.stdout.seek(0)
          out = sys.stdout.read()[:-1]
          sys.stdout, sys.stdin = stdout, stdin
          self.assertEqual(out, output)
  
      def test_入力例_1(self):
          input = """6 2 4"""
          output = """2"""
          self.assertIO(input, output)
  
      def test_入力例_2(self):
          input = """7 4 3"""
          output = """1"""
          self.assertIO(input, output)
  
      def test_入力例_3(self):
          input = """10 1 2"""
          output = """8"""
          self.assertIO(input, output)
  
      def test_入力例_4(self):
          input = """1000000000000000 1000000000000000 1000000000000000"""
          output = """1000000000000000"""
          self.assertIO(input, output)
  
  
  if __name__ == "__main__":
      resolve()
  
problem_description: Statement
  
  Takahashi, who lives on the number line, is now at coordinate X. He will make
  exactly K moves of distance D in the positive or negative direction.
  
  More specifically, in one move, he can go from coordinate x to x + D or x - D.
  
  He wants to make K moves so that the absolute value of the coordinate of the
  destination will be the smallest possible.
  
  Find the minimum possible absolute value of the coordinate of the destination.
samples: [{"input": "6 2 4", "output": "2\n    \n\nTakahashi is now at coordinate 6. It is optimal to make the following moves:\n\n  * Move from coordinate 6 to (6 - 4 =) 2.\n  * Move from coordinate 2 to (2 - 4 =) -2.\n\nHere, the absolute value of the coordinate of the destination is 2, and we\ncannot make it smaller.\n\n* * *"}, {"input": "7 4 3", "output": "1\n    \n\nTakahashi is now at coordinate 7. It is optimal to make, for example, the\nfollowing moves:\n\n  * Move from coordinate 7 to 4.\n  * Move from coordinate 4 to 7.\n  * Move from coordinate 7 to 4.\n  * Move from coordinate 4 to 1.\n\nHere, the absolute value of the coordinate of the destination is 1, and we\ncannot make it smaller.\n\n* * *"}, {"input": "10 1 2", "output": "8\n    \n\n* * *"}, {"input": "1000000000000000 1000000000000000 1000000000000000", "output": "1000000000000000\n    \n\nThe answer can be enormous."}]