This code can be used in traditional school choice settings (strict student preferences, weak school priorities) to compute a random assignment that is ex-post stable (i.e., can be decomposed over weakly stable deterministic matchings), and that sd-dominates upon a given random assignment. More information can be found in our paper Smart Lotteries in School Choice: Ex-Ante Improvement with Ex-Post Stability.