Problem

Source: South African Mathematics Olympiad 2021, Problem 6

Tags: game, combinatorics, number theory



Jacob and Laban take turns playing a game. Each of them starts with the list of square numbers $1, 4, 9, \dots, 2021^2$, and there is a whiteboard in front of them with the number $0$ on it. Jacob chooses a number $x^2$ from his list, removes it from his list, and replaces the number $W$ on the whiteboard with $W + x^2$. Laban then does the same with a number from his list, and the repeat back and forth until both of them have no more numbers in their list. Now every time that the number on the whiteboard is divisible by $4$ after a player has taken his turn, Jacob gets a sheep. Jacob wants to have as many sheep as possible. What is the greatest number $K$ such that Jacob can guarantee to get at least $K$ sheep by the end of the game, no matter how Laban plays?