DRANGE wrong answer

can anyone fix my code. CodeChef: Practical coding for everyone
The link to the problem : DRANGE Problem - CodeChef
thanks in advance.