Test cases are giving me wrong answer

Sir some of the test cases are giving me wrong answer please tell where I am going wrong in my code

Modified code

mistake is while Taking MOD