All test cases not passing

THIS PROGRAM WAS GIVING WRONG OUTPUT