Kuznecovv.

On the island, there live knights, liars, and yes-men; each knows who everyone else is. All 2018 residents were lined up and asked to answer "Yes" or "No" to the question: "Are there more knights than liars on the island?". The residents answered in turn, and everyone could hear their answers. Knights answered truthfully, liars lied. Each yes-man answered the same way as the majority of those who answered before them, and if the number of "Yes" and "No" answers was equal, they gave either of these answers. It turned out that there were exactly 1009 "Yes" answers. What is the maximum number of yes-men that could be among the residents of the island?

#
Let's call knights and liars principled people.

Evaluation. First method. (Buchaev Abdulkadyr) We will track the balance - the difference between the number of "Yes" and "No" answers. At the beginning and at the end, the balance is zero, and with each answer, it changes by 1. Zero values of the balance divide the sequence of residents into groups. Within each group, the balance retains its sign. Sycophants always increase the absolute value of the balance. Therefore, to make the balance zero, there must be no fewer principled residents than sycophants. This is true for each group, and thus for all the island's residents.

Second method. A sycophant cannot increase the minimum of the current number of "Yes" and "No" answers. Since this minimum increased from 0 to 1009, and with each answer, it changed by no more than one unit, there must be at least 1009 principled residents.

Example. First, all 1009 sycophants said "No," and then 1009 knights said "Yes."

## Answer

1009 sycophants.