Part of 2017 Poland - Second Round
Source: Polish Mathematical Olympiad Second Round, Day 1, Problem 3