# Group By: Official Solution

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

*Task 4 of the municipal stage (Moscow) of the All-Russian School Olympiad (VsOSh) 2025/26 in artificial intelligence, grades 9–11: official answer and solution (the statement is in a separate file). Original: [ans-ai-9-11-mun-msk-25-26.pdf](https://vos.olimpiada.ru/upload/files/Arhive_tasks/2025-26/mun/ai/ans-ai-9-11-mun-msk-25-26.pdf).*

**Answer:** 363

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

**Maximum score for the task — 100**

**Solution.** A solution to the task in Python:

```python
import pandas as pd

df = pd.read_csv("tests.csv")
df["score"] = df["score"].fillna(0)

mask_neg = df["score"] < 0
df.loc[mask_neg, "score"] = 0

mask_high = df["score"] > 100
df.loc[mask_high, "score"] = 100

df = df[df["cheat_flag"] == False]

df = df[df["attempt_no"] == 1]

mean_by_student = df.groupby("student_id")["score"].mean()

cond = (mean_by_student >= 60) & (mean_by_student < 80)
answer = cond.sum()
print(answer)
```
