final code used for judging