Run time erroe!

giving run time error for test cases.
please find out the error.
link to my code - https://ide.codingblocks.com/s/230533

@pulkit_pandey09 you have to consider cases where k > n

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.

can you please find out the error.link to my code-https://ide.codingblocks.com/s/230533

@pulkit_pandey09 while taking data input you are decrementing n as n-- then again you are using the same n (which has become 0 now) for taking modulo which is causing you Run Error.
and check the cases when k=0.