[algorithms][is_valid] fix some wrong usages of std::size_t (should
have been int)