Nim Game II

In this version of Nim, a player may remove 1, 2, or 3 sticks from a chosen non-empty heap on each turn. The player who takes the last stick wins. Given the heap sizes, determine if the first player has a winning strategy.

Here a move removes one, two, or three sticks from a single heap instead of any number. Each heap is an independent subtraction game with move set {1, 2, 3}. This is the CSES Nim Game II contract. The official task batches 1 <= t <= 2 * 10^5 tests with the sum of all n bounded by 2 * 10^5; this catalog problem is the single-test projection, with one heap array and 1 <= n <= 2 * 10^5 heaps.

The Grundy number of such a heap follows a cycle: 0, 1, 2, 3, 0, 1, 2, 3, and so on, which is exactly the heap size modulo four. The whole position is the disjunctive sum of the heaps, so its Grundy number is the XOR of the per-heap values, and the first player wins when that combined value is non-zero. Computing each size modulo four and XORing the remainders is enough.

Examples
Input: [1,1]
Output: false
Hints

Nim Game II

In this version of Nim, a player may remove 1, 2, or 3 sticks from a chosen non-empty heap on each turn. The player who takes the last stick wins. Given the heap sizes, determine if the first player has a winning strategy.