Solutions for ACM.TIMUS and SPOJ problems