Help me in solving WELLLEFT problem

My issue

Test Case: 20 6 18
Why is the answer 180 ?
shouldn’t it be 165 ?

cook your dish here

T = int(input())
while T:
N,K,H = map(int,input().split())
if N < H and N == 1:
print(0)
else:
sum = 0
if H%K == 0:
D = H/K
else:
D = H//K+1
X = H - D - 1
sum += (X**2 - X)/2 + X
sum += (N - H + 1)*N
print(int(sum))
T = T - 1

Thanks for helping!

Problem Link: Amphibian Escape Practice Coding Problem

you are missing the cases in which the D can be lower than what you.ve calculated. for example try a=17 and b=16 in this testcase. it satisfies the condition but is not considered in your code.