Add some missing includes and make the 'count' variable less ambiguous

This will let DFHack compile with compilers that are more strict in regard to their default inclusion of std::min, std::max, and std::greater.

Also makes the count variable in plugins/misery.cpp less ambiguous, as it could've referred to std::count too earlier.