[problem:476175A]
Author: Error_Yuan
Hint
Solution
[problem:476175B]
Author: wyrqwq
Hint 1
Hint 2
Solution
[problem:476175C]
Author: Error_Yuan
Hint
Tutorial
And, in the last round, it is everyone will pass his potato to the next person (if he can). Thus, according to the claim you can solve the problem by simulating the last round. Time complexity is $$$\mathcal{O}(n)$$$.