CHEFRECP May Cookoff2020 getting wrong ans

link to code
I am getting wrong answer. I feel my logic is correct, but there is some error while running it online.
Can someone pls help me find the bug