Fix raw_input to input (it's Python 3)
Fix distance function to be usable