- This is a data structure for backtrack programming. It maintains a set of integers in [0, n).
- NewResidue(n) returns a set containing integers 0, 1, ..., n-1. Slice returns all integers in the set.
- If 0 <= x < n is not in the set: Contains(x) returns false; Remove(x) returns false with no other effect.
- If 0 <= x < n is in the set: Contains(x) returns true; Remove(x) removes x from the set and returns true.
- Undo reverts the effect of the most recent call to Remove that returned true and has not yet been reverted.
- There is a stack of removed integers. Remove(x) removes x from the set and pushes x onto the stack.
- If the stack is not empty, Undo pops x off the stack, inserts x into the set, and returns true.
- If the stack is empty, Undo returns false with no other effect.

To receive a hint, submit unfixed code.