Part of 2017 Federal Competition For Advanced Students, P2
Source: Austria National Competition 2017, Final Round, Part 2, Day 1, Problem 1