output_description: Print the answer.
  
  * * *
input_description: Input is given from Standard Input in the following format:
  
      
      
      W H K
attempt: from math import gcd
  
  input1 = input().split()
  W = int(input1[0])
  H = int(input1[1])
  K = int(input1[2])
  
  
  def NumOfGrid(tup1: list, tup2: list):
      return gcd((abs(tup1[0] - tup2[0]), abs(tup1[1] - tup2[1]))) - 1
  
  
  def Sur(p1, p2, p3):
      p22 = [(p2[0] - p1[0]), (p2[1] - p1[1])]
      p23 = [(p3[0] - p1[0]), (p3[1] - p1[1])]
      return abs(p22[0] * p23[1] - p23[0] * p22[1]) / 2
  
  
  def Koshiten(p1: list, p2: list, p3: list):
      return int(
          Sur(p1, p2, p3)
          - (NumOfGrid(p1, p2) + NumOfGrid(p2, p3) + NumOfGrid(p3, p1) - 3)
          - 1
      )
  
  
  def Triangles(p1, p2, p3, K):
      if Koshiten(p1, p2, p3) <= K:
          return True
      else:
          return False
  
  
  Result = 0
  
  for a in range(2, H):
      p1 = [0, a]
      for b in range(2, W):
          p2 = [b, H]
          for c in range(2, W):
              p3 = [c, 0]
              if Triangles(p1, p2, p3, K) == True:
                  Result += 1
          for c in range(2, H):
              p3 = [W, c]
              if Triangles(p1, p2, p3, K) == True:
                  Result += 1
  print(Result)
  
problem_description: Statement
  
  In a two-dimensional plane, we have a rectangle R whose vertices are (0,0),
  (W,0), (0,H), and (W,H), where W and H are positive integers. Here, find the
  number of triangles \Delta in the plane that satisfy all of the following
  conditions:
  
    * Each vertex of \Delta is a grid point, that is, has integer x\- and y-coordinates.
    * \Delta and R shares no vertex.
    * Each vertex of \Delta lies on the perimeter of R, and all the vertices belong to different sides of R.
    * \Delta contains at most K grid points strictly within itself (excluding its perimeter and vertices).
samples: [{"input": "2 3 1", "output": "12\n    \n\nFor example, the triangle with the vertices (1,0), (0,2), and (2,2) contains\njust one grid point within itself and thus satisfies the condition.\n\n* * *"}, {"input": "5 4 5", "output": "132\n    \n\n* * *"}, {"input": "100 100 1000", "output": "461316"}]