What is the problem C. Tram in codeforces 746 and how to solve it?