Becarefull D can be negative value, and don't forget use long long. As I know there are no tricky input here. If you still can't get AC, send me your code I'll try to help. :lol: i am sure that there is no input with d<0 because i when i ran my code it gave different ans for d<0 and d>0 but got ac ...