Dissolve contest.pm into sensible modules

No real logical changes. TODO: fix up imports, many are useless.