func (r SortedIntSet) Select(key int) (k int, ok bool) {
	x := r.nodeselect(r.root, key)
	if x == nil {
		return
	}
	return x.key, true
}
Select key of rank k, meaning the k-th biggest int in the sorted set.
package codegen
func (r SortedIntSet) compare(a, b int) int { return int(a) - int(b) }
type SortedIntSet struct {
	root *nodeInt
}
func NewSortedIntSet() *SortedIntSet { return &SortedIntSet{} }
func (r SortedIntSet) IsEmpty() bool {
	return r.root == nil
}
func (r SortedIntSet) Size() int { return r.root.size() }
func (r *SortedIntSet) Clear() { r.root = nil }
func (r *SortedIntSet) Put(k int) (already bool) {
	r.root, already = r.put(r.root, k)
	return
}
func (r *SortedIntSet) put(h *nodeInt, k int) (_ *nodeInt, already bool) {
	if h == nil {
		n := &nodeInt{key: k, n: 1, colorRed: true}
		return n, already
	}
	cmp := r.compare(k, h.key)
	if cmp < 0 {
		h.left, already = r.put(h.left, k)
	} else if cmp > 0 {
		h.right, already = r.put(h.right, k)
	} else {
		already = true
	}
	if h.right.isRed() && !h.left.isRed() {
		h = r.rotateLeft(h)
	}
	if h.left.isRed() && h.left.left.isRed() {
		h = r.rotateRight(h)
	}
	if h.left.isRed() && h.right.isRed() {
		r.flipColors(h)
	}
	h.n = h.left.size() + h.right.size() + 1
	return h, already
}
func (r SortedIntSet) Contains(k int) bool {
	return r.loopContains(r.root, k)
}
func (r SortedIntSet) loopContains(h *nodeInt, k int) (ok bool) {
	for h != nil {
		cmp := r.compare(k, h.key)
		if cmp == 0 {
			return true
		} else if cmp < 0 {
			h = h.left
		} else if cmp > 0 {
			h = h.right
		}
	}
	return
}
func (r SortedIntSet) Min() (k int, ok bool) {
	if r.root == nil {
		return
	}
	h := r.min(r.root)
	return h.key, true
}
func (r SortedIntSet) min(x *nodeInt) *nodeInt {
	if x.left == nil {
		return x
	}
	return r.min(x.left)
}
func (r SortedIntSet) Max() (k int, ok bool) {
	if r.root == nil {
		return
	}
	h := r.max(r.root)
	return h.key, true
}
func (r SortedIntSet) max(x *nodeInt) *nodeInt {
	if x.right == nil {
		return x
	}
	return r.max(x.right)
}
func (r SortedIntSet) Floor(key int) (k int, ok bool) {
	x := r.floor(r.root, key)
	if x == nil {
		return
	}
	return x.key, true
}
func (r SortedIntSet) floor(h *nodeInt, k int) *nodeInt {
	if h == nil {
		return nil
	}
	cmp := r.compare(k, h.key)
	if cmp == 0 {
		return h
	}
	if cmp < 0 {
		return r.floor(h.left, k)
	}
	t := r.floor(h.right, k)
	if t != nil {
		return t
	}
	return h
}
func (r SortedIntSet) Ceiling(key int) (k int, ok bool) {
	x := r.ceiling(r.root, key)
	if x == nil {
		return
	}
	return x.key, true
}
func (r SortedIntSet) ceiling(h *nodeInt, k int) *nodeInt {
	if h == nil {
		return nil
	}
	cmp := r.compare(k, h.key)
	if cmp == 0 {
		return h
	}
	if cmp > 0 {
		return r.ceiling(h.right, k)
	}
	t := r.ceiling(h.left, k)
	if t != nil {
		return t
	}
	return h
}