Algorithm For Competitive Programming