Anna writes a sequence of 0s and 1s on the board. Anna notices that in every sequence of 200 consecutive digits written on the board, there are as many 0s as there are 1s. She also notices that in every sequence of 202 consecutive digits written on the board, the number of 0s and 1s is not equal. What is the maximum number of digits that Anna could have written on the board?
The exercise asks to find the largest integer $n$ such that there exists a sequence of $n$ digits 0 or 1 satisfying the conditions of the statement. To show that the largest integer sought is an integer $c$, there are necessarily two distinct parts: the analysis, in which we establish that any integer $n$ satisfying the stated property satisfies $n \leqslant c$, and the construction, in which we provide an example of a sequence of $c$ digits satisfying the conditions.

Analysis: Let $a_{1} a_{2} \ldots a_{n}$ be the sequence of digits written on the board, where each $a_{i}$ is either 0 or 1. To understand how restrictive Aline's remarks are on the nature of the sequence, we look at what these remarks imply for a block of 200 consecutive digits, and then for the same block with 2 additional digits.

Let $1 \leqslant k \leqslant n-201$. Consider the block of 200 consecutive digits $\left\{a_{k}, a_{k+1}, \ldots, a_{k+199}\right\}$ and the block of 202 digits $\left\{a_{k}, a_{k+1}, \ldots, a_{k+200}, a_{k+201}\right\}$. The number of 0s and 1s is the same in the block of 200 digits but different in the block of 202 digits. This imposes that $a_{k+200}=a_{k+201}$.

$$
a_{1}, \ldots, \underbrace{a_{k}, a_{k+1}, \ldots, a_{k+199}}_{\text{one hundred } 0 \text{ and one hundred } 1}, \underbrace{a_{k+200}, a_{k+201}}_{\neq\{0,1\},\{1,0\}}, \ldots, a_{n}
$$

This equality is true for any integer $k$. By combining the equalities relative to $k=1,2, \ldots n-201$, we get that $a_{201}=a_{202}=\ldots=a_{n}$. Without loss of generality, we can consider in the following that all these digits are equal to 0.

The sequence is therefore constant from a certain rank. But if $n$ is too large, we will have a sequence of 200 digits with a number of 1s strictly greater than the number of 0s (or vice versa).

![](https://cdn.mathpix.com/cropped/2024_05_10_10c029b6c4865f8b8ca3g-025.jpg?height=168&width=870&top_left_y=2463&top_left_x=593)

To formalize this idea, we consider the block of 200 digits $\left\{a_{n-199}, a_{n-198}, \ldots, a_{n}\right\}$. Since the last $n-200$ digits of this block are 0s, they cannot constitute more than half of this block, otherwise strictly more than half of the digits in the block would be 0s, which is excluded. We deduce that $n-200 \leqslant 100$ and that $n \leqslant 300$.

Construction: The analysis has shown that in any suitable sequence of 300 digits, the digits $a_{201}, \ldots, a_{300}$ are all equal. This inspires the following construction:

$$
\{\underbrace{0,0, \ldots 0}_{100 \text{ digits }}, \underbrace{1,1, \ldots 1}_{100 \text{ digits }}, \underbrace{0,0, \ldots 0}_{100 \text{ digits }}\},
$$

in which we verify that any sequence of 200 consecutive digits contains 100 digits 0 and 100 digits 1, and any sequence of 202 consecutive digits contains 102 digits 1 and 100 digits 0.

Comment from the graders: This is a visibly difficult exercise. It's a pity that only half of those who submitted something included the diagram of the situation, which earns points. The inequality $n \leq 300$ was found by very few. A common mistake is the sequence $00110011 \ldots$, which is false when looking at digits 2 to 203. It comes from the fact that the sequences of numbers considered by students always start with an odd number. Another is the demonstration that the construction presented cannot be extended. This never demonstrates that the $n$ found is maximal. However, it helps to understand the constraints imposed.