some algorithm code for ACM