import random # Randomly tries X points, and picks the Y best. Looks at every point # within distance Z from these. def f(x): if x > n//k or n - x*k > m*(k-1) or x < 0: return -1 result = x*n - (k*x*(x-1))//2 n2 = n - x*k k2 = n2//m + 1 x2 = n2 - m*(n2//m) result += x2*n2 - (k2*x2*(x2-1))//2 n3 = n2 - x2*k2 k3 = k2-1 x3 = m-x2 result += x3*n3 - (k3*x3*(x3-1))//2 return result (n, m, k) = list(map(int, raw_input().split())) X = int(m**0.5) + 2000 Y = 10 Z = X//Y + 2000 lo = max(0, n//k - m + m//k) hi = n//k + 1 values = [] ans = 0 for i in range(0,X): x = random.randint(lo,hi) values.append((f(x),x)) values.sort() values.reverse() for i in range(0,min(X,Y)): x = values[i][1] for j in range(x-Z, x+Z+1): ans = max(ans, f(j)) print(ans)