# School Stage (Moscow) of the All-Russian School Olympiad 2025/26 in Artificial Intelligence, Grades 9–11: Solutions

*English translation by SOTA – AI Community of the Russian original. Organisers who would like this translation removed can email sota.ai.community@gmail.com.*

*Original: [sol-ai-9-11-sch-msk-25-26.pdf](https://vos.olimpiada.ru/upload/files/Arhive_tasks/2025-26/school/ai/sol-ai-9-11-sch-msk-25-26.pdf). Running header on every page: "Analysis of the tasks of the school stage of the VsOSh 2025/26 in artificial intelligence — grades 9–11".*

**Maximum score for the olympiad — 112**

## Task 1

Let $k \geq 2$ be an integer. We say that two points on the number line are friends if the difference of their coordinates is divisible by $k$. A non-empty set of points is called a cluster if any two points in this set are friends and no point can be added to it so that this property is preserved.

For which integers $k \geq 2$ can the points of the number line with coordinates

$$
1,\ 7,\ 21,\ 22,\ 28,\ 42,\ 43,\ 49,\ 63
$$

be split into two clusters?

**Answer:** 2, 3, 7

**Scoring criterion:** exact match of the answer — 12 points

**Maximum score for the task — 12**

**Solution.**

Consider the numbers 21, 22, 28. If the whole set splits into exactly two clusters, then at least two of these three lie in the same cluster, so the difference of one of the pairs is divisible by $k$. The possible differences are $1, 6, 7$. Since $k \geq 2$, we have

$$
k \mid 6 \quad \text{or} \quad k \mid 7,
$$

that is, the remaining candidates are $k \in \{2, 3, 6, 7\}$.

Check:

- $k = 2$: all the numbers are even or odd $\Rightarrow$ two clusters.
- $k = 3$: all the numbers leave a remainder of 0 or 1 $\Rightarrow$ two clusters.
- $k = 7$: all the numbers leave a remainder of 0 or 1 $\Rightarrow$ two clusters.
- $k = 6$: already the numbers $42 \equiv 0$, $1 \equiv 1$, $21 \equiv 3$, $22 \equiv 4 \pmod 6$ give four different remainders $\Rightarrow$ not two clusters.

Thus, only $k = 2, 3, 7$ work.

## Task 2

Petya has thought of two natural numbers $a$ and $b$. Vasya is trying to guess them by asking questions. A question from Vasya consists of him naming two natural numbers $x$ and $y$. In reply to a question, Petya reports two numbers $z < t$, one of which is equal to $ax + by$ (he does not say which one).

Vasya asked two questions: for $x = 4$ and $y = 1$, Petya replied 14 and 15; for $x = 1$ and $y = 4$, Petya replied 9 and 11. Which numbers did Petya think of?

**Answer:** $a = 3,\ b = 2$

**Scoring criterion:** exact match of the answer — 12 points

**Maximum score for the task — 12**

**Solution.**

Note that in both questions $x + y = 5$. Hence the correct answers to the two questions (one from each pair) add up to

$$
(ax + by) + (ax' + by') = a(x + x') + b(y + y') = 5(a + b),
$$

that is, their sum is divisible by 5.

Of the pairs $\{14, 15\}$ and $\{9, 11\}$, the only combination whose sum is a multiple of 5 is 14 and 11. Consequently,

$$
4a + b = 14, \qquad a + 4b = 11.
$$

Solving, we obtain $a = 3$, $b = 2$.

## Task 3

A nature reserve plans to introduce automatic monitoring of rare *pink lemurs*. To test the system, a group of 100 animals was selected, in which 10% are pink lemurs (class 1) and the remaining 90% are ordinary lemurs (class 0). We will call this group the *test set*.

For each individual in the test set, AI models made a prediction of which class (0 or 1) that lemur belongs to. To assess the quality of recognition, we introduce the following standard notation:

- $TP$. Predicted class (1), actual class (1).
- $FP$. Predicted class (1), actual class (0).
- $TN$. Predicted class (0), actual class (0).
- $FN$. Predicted class (0), actual class (1).

In total, the test set contains $P = TP + FN$ objects (lemurs) of class 1 and $N = TN + FP$ objects of class 0.

Four AI models (A, B, C and D) recognised the lemurs from the test set. Model A assigned all lemurs to class 0, and model B assigned all lemurs to class 1. Data on the performance of models C and D are given in the table below.

| Model | TP | FP | TN | FN |
|:---:|:---:|:---:|:---:|:---:|
| C | 7 | 8 | 82 | 3 |
| D | 8 | 14 | 76 | 2 |

For models A, B, C, D, we compute the following five *metrics* $M_1, M_2, M_3, M_4, M_5$ (if a division by zero occurs for some model, the corresponding metric is not computed for it).

$$
\begin{aligned}
M_1 &= \frac{TP + TN}{P + N} && \text{(overall accuracy)},\\
M_2 &= \frac{TP}{TP + FN} && \text{(correct on class 1)},\\
M_3 &= \frac{TN}{TN + FP} && \text{(correct on class 0)},\\
M_4 &= \tfrac{1}{2}\,(M_2 + M_3) && \text{(balanced accuracy)},\\
M_5 &= \frac{TP}{TP + FP} && \text{(precision on predictions of 1)}.
\end{aligned}
$$

For each of the metrics $M_1, M_2, \ldots, M_5$, determine for which of the models its maximum value is attained.

**Correct answer:** $M_1$ — model A; $M_2$ — model B; $M_3$ — model A; $M_4$ — model D; $M_5$ — model C.

**Exact match of the answer — 1 point. Maximum score for the task — 12**

*Translator's note: the original prints this scoring line exactly as above; it does not say how the 12 points are distributed.*

**Solution.**

Let us compute the values.

**Model A** (all — class 0):

$$
M_1 = \tfrac{90}{100} = 0.9, \quad M_2 = 0, \quad M_3 = 1, \quad M_4 = \tfrac{1}{2}, \quad M_5 \text{ is undefined (there are no predictions of 1)}.
$$

**Model B** (all — class 1):

$$
M_1 = \tfrac{10}{100} = 0.1, \quad M_2 = 1, \quad M_3 = 0, \quad M_4 = \tfrac{1}{2}, \quad M_5 = \tfrac{10}{100} = 0.1.
$$

**Model C**:

$$
M_1 = \tfrac{7+82}{100} = 0.89,\ M_2 = \tfrac{7}{10} = 0.7,\ M_3 = \tfrac{82}{90} \approx 0.911,\ M_4 \approx 0.806,\ M_5 = \tfrac{7}{7+8} = \tfrac{7}{15} \approx 0.467.
$$

**Model D**:

$$
M_1 = \tfrac{8+76}{100} = 0.84,\ M_2 = \tfrac{8}{10} = 0.8,\ M_3 = \tfrac{76}{90} \approx 0.844,\ M_4 \approx 0.822,\ M_5 = \tfrac{8}{8+14} = \tfrac{8}{22} \approx 0.364.
$$

Comparing, we obtain the maxima: $M_1$ and $M_3$ — for model A, $M_2$ — for B, $M_4$ — for D, $M_5$ — for C.

## Task 4

Vasya was testing a model with real parameters $x$ and $y$. He found out that the loss function is given by the formula

$$
\mathcal{L}(x, y) = x^4 + y^2 + 2x^2y + 4y + 6x^2 - 4x + 14.
$$

Help Vasya determine the values of the parameters $(x^*, y^*)$ for which the value of the loss function is smallest. In your answer, give $x^*$, $y^*$ and the value $\mathcal{L}(x^*, y^*)$.

**Answer:** $x^* = 1,\ y^* = -3,\ \mathcal{L}(x^*, y^*) = 8$

**Scoring criterion:** exact match of the answer — 12 points

**Maximum score for the task — 12**

**Solution.**

Let us complete the squares:

$$
\begin{aligned}
\mathcal{L}(x, y) &= (y + x^2 + 2)^2 - (x^2 + 2)^2 + x^4 + 6x^2 - 4x + 14 \\
&= (y + x^2 + 2)^2 + \left(2x^2 - 4x + 10\right) \\
&= (y + x^2 + 2)^2 + 2(x - 1)^2 + 8.
\end{aligned}
$$

The minimum is attained when the squares are equal to zero:

$$
x - 1 = 0 \Rightarrow x^* = 1, \qquad y + x^2 + 2 = 0 \Rightarrow y^* = -1^2 - 2 = -3.
$$

Then $\mathcal{L}(x^*, y^*) = 8$.

## Task 5

There is a set of training examples: $N$ examples in total, of which exactly two are positive and the rest are negative. A group of 4 examples is chosen at random. It is known that the probability that the group contains both positive examples is 2 times the probability that it contains no positive example at all. Find all possible values of $N$.

**Answer:** 7

**Scoring criterion:** exact match of the answer — 12 points

**Maximum score for the task — 12**

**Solution.**

Let the number of negative examples be $m = N - 2$.

The number of 4-element groups:

$$
\#\text{total} = \frac{N(N-1)(N-2)(N-3)}{24}.
$$

Groups with both positive examples: we need to add 2 of the $m$ negative examples,

$$
\#(2^+) = \frac{m(m-1)}{2}.
$$

Groups without positive examples: we take all quadruples of the $m$ negative examples,

$$
\#(0^+) = \frac{m(m-1)(m-2)(m-3)}{24}.
$$

By the statement,

$$
\frac{\#(2^+)}{\#\text{total}} = 2 \cdot \frac{\#(0^+)}{\#\text{total}} \implies \frac{m(m-1)}{2} = 2 \cdot \frac{m(m-1)(m-2)(m-3)}{24}.
$$

Cancelling (for $m \geq 4$):

$$
\frac{1}{2} = \frac{(m-2)(m-3)}{12} \implies (m-2)(m-3) = 6 \implies m = 5.
$$

Hence $N = m + 2 = 7$.

## Task 6

**Neural network training report** · standard input · standard output · 1 second · 256 megabytes

*Translator's note: in the original, this line is printed run together, without labels. It gives the task title, then "standard input", "standard output", "1 second" and "256 megabytes", i.e. the input file, output file, time limit and memory limit.*

Neural network training is usually divided into epochs. During one epoch of training, the model passes through the training dataset once.

Dima worked on a new project for a long time. Its training took as many as $n$ epochs. After each epoch, Dima wrote down the current time in the format $HH:MM$ (for example, $13:03$). Now Dima wonders what the minimum amount of time spent on training the model could have been.

Dima is very busy with work tasks at the moment, so he has turned to you for help. Compute the minimum amount of time that could have been spent on training the model.

### Input format

The first line of the input contains one integer $n$ ($2 \le n \le 10^4$).

The next $n$ lines give the moments of time at which each successive epoch ended, in the format $HH:MM$ (24-hour format).

### Output format

Output one integer: the minimum number of minutes that could have been spent on training the model. Round the answer down to the nearest whole number of minutes.

### Note

In the first test example, exactly 10 full hours passed $(14 - 24)$. There were also 56 minutes from $13:03$ to $14:00$ (not 57, because $13:03$ could have been $13:03:59$). And another 15 minutes passed from $00:00$ to $00:15$. In total, $10 \cdot 60 + 56 + 15 = 671$.

*Translator's note: the paper does not print the test examples that this note refers to.*

**Scoring criterion:** each test not taken from the statement — 1 point. 20 points in total.

**Maximum score for the task — 20**

**Solution.**

Let the timestamps (in minutes) be $t_1, \ldots, t_n$. The minimum interval between neighbouring timestamps is

$$
\Delta_i = \begin{cases} t_{i+1} - t_i, & t_{i+1} \ge t_i, \\ (24 \cdot 60 - t_i) + t_{i+1}, & t_{i+1} < t_i. \end{cases}
$$

We add up $\Delta_1 + \Delta_2 + \cdots + \Delta_{n-1}$. Training could have started almost immediately before the first timestamp, so the answer is 1 less.

```python
n = int(input())
prev = None
s = 0
day = 24 * 60
for _ in range(n):
    hh, mm = map(int, input().strip().split(':'))
    t = hh * 60 + mm
    if prev is None:
        prev = t
        continue
    if t >= prev:
        s += t - prev
    else:
        s += day - prev + t
    prev = t
print(s - 1)
```

## Task 7

**Special decision tree**

Input file name: standard input<br>
Output file name: standard output<br>
Time limit: 1 second<br>
Memory limit: 256 megabytes

You are given a complete binary decision tree of depth $n$. Exactly $n$ steps are taken from the root to a leaf. At each step, one of two decisions is made: go left or go right. Initially, both options are equally likely: each edge has probability $1/2$.

Someone modified the tree and changed two edge probabilities to 0:

- the first edge is the $a$-th edge on the "always left" path (the edge between levels $a - 1$ and $a$ if you choose left at every step from the root);
- the second edge is the $b$-th edge on the "always right" path (the edge between levels $b - 1$ and $b$ if you choose right at every step from the root).

All the other edges still have probability $1/2$ (except for the edges that have lost their neighbouring edge: their probability is now equal to one).

The outcomes in this tree are its leaves (the vertices on the very bottom level). The probability of each outcome is the product of the probabilities along the path to the corresponding leaf.

You need to determine how many different outcomes (leaves of the tree) still have **non-zero** probability.

### Input format

The only line contains three integers $n$, $a$, $b$ ($1 \le n \le 60$, $1 \le a, b \le n$).

### Output format

Output one integer: the number of leaves that remain reachable (that is, that correspond to paths of non-zero probability).

### Note

*[Figure: see page 5 of the [original PDF](https://vos.olimpiada.ru/upload/files/Arhive_tasks/2025-26/school/ai/sol-ai-9-11-sch-msk-25-26.pdf#page=5). Transcription: a complete binary tree of depth 3 in which the edge from the root to its right child and the edge from the root's left child to its own left child are crossed out in red. Of the eight leaves, the third and fourth from the left are green (reachable); the other six are red and marked with a cross.]*

In the first test example, only 2 outcomes remain reachable.

*Translator's note: the paper does not print the test examples themselves.*

**Solution.**

A complete binary tree of depth $n$ has $2^n$ leaves. If we set to zero the edge on the "always left" path at level $a$, all paths passing through it become impossible: these are exactly the $2^{n-a}$ leaves below this edge. Similarly, setting to zero the edge on the "always right" path at level $b$ removes another $2^{n-b}$ leaves. These sets do not intersect (one cannot go always left and always right at the same time at the start of the path). In total, there remain

$$
2^n - 2^{n-a} - 2^{n-b}.
$$

```python
n, a, b = map(int, input().split())
x = 1
print((x << n) - (x << (n - a)) - (x << (n - b)))
```

*Translator's note: the paper gives no scoring criterion or maximum score for this task. The stated total of 112 points, minus the maxima of the other seven tasks (92 points), leaves 20.*

## Task 8

Using three machine learning models $a_1, a_2, a_3$, we want to distinguish photographs of dogs (class 0) from photographs of cats (class 1). To evaluate the quality of the models, we ran them on a set of images for which the correct answer is known.

In the table (XLSX format, CSV format), each row contains four numbers: column $y$ gives the correct class, and columns $a_1, a_2, a_3$ give the answers of the three models. All the numbers are equal to 0 or 1.

*Translator's note: the PDF contains no links to the data files named here.*

The models are trusted to different degrees; the weights are set as follows:

$$
w_1 = 2, \qquad w_2 = 1, \qquad w_3 = 3.
$$

For each row, the weighted sum is computed:

$$
S = w_1 \cdot a_1 + w_2 \cdot a_2 + w_3 \cdot a_3.
$$

The final answer is $\hat{y} = 1$ if $S \geq 3$, and $\hat{y} = 0$ otherwise.

Find the number of rows in which the final answer $\hat{y}$ matches the correct answer $y$. Give only this number as your answer.

**Answer:** 69

**Scoring criterion:** exact match of the answer — 12 points

**Maximum score for the task — 12**

**Solution.**

**Step 1. Weighted sum.** In cell E2:

```text
=2*B2+1*C2+3*D2
```

Fill down to E101.

**Step 2. Final prediction.** In cell F2:

```text
=IF(E2>=3;1;0)
```

Fill down to F101.

**Step 3. Match with the correct answer.** In cell G2:

```text
=IF(F2=A2;1;0)
```

Fill down to G101.

**Step 4. Counting the matches.** In any free cell (for example, H2):

```text
=SUM(G2:G101)
```

This number shows in how many rows the final answer $\hat{y}$ matched the correct class $y$.

*Translator's note: the original writes these spreadsheet formulas with the Russian-language names of the IF and SUM functions. The semicolons are argument separators, as in the original; spreadsheets set to English use commas instead, e.g. `=IF(E2>=3,1,0)`.*
