Snackdown elimination round

Problem MAXDIST have very weak input. It even passes the wrong solution. Solution id CodeChef: Practical coding for everyone is giving wrong answer on testcase

1

9

1 2

2 3

3 4

4 5

4 6

4 7

2 9

2 8

I checked this testcase on solution id CodeChef: Practical coding for everyone and CodeChef: Practical coding for everyone. 2nd one is giving correct answer i.e “YES” but first one is giving ans “NO”.
Please check it and if i am wrong reply in comments.

Even CodeChef: Practical coding for everyone of team fast_match is giving wrong answer on this input