Miscellaneous code for competitive programming