Ported the code into formal competition template.