Wrong Answer

My code works perfectly fine.
Not sure why it is saying WA. My code might not work for some inputs but I am not able to find any such inputs.

Any help will be appreciated!

can’t help much with C
are you sure the logic is flawless?

Try using this:-> https://test-case-generator.herokuapp.com/
Generate random test cases and try to solve for them.

Also, always run your code on corner cases.