Algolymp Summer School (a 8-a) | Longest walk

This was the problem page during the contest. Access the current page here.