Part of 2021 Ukraine National Mathematical Olympiad
Source: Ukrainian Mathematical Olympiad 2021. Day 1, Problem 8.2