Functions for competition programming