Basic algorithms for competetive programming