Some Algorithms for online programming contests