several useful algorithms in python & c++