Moved #include <algorithm> outside

Moved `#include <algorithm>` outside the `#if PY_MAJOR_VERSION >= 3` block.