#include namespace algorithm { template OutputIt find_mismatch_permutation(InputIt first, InputIt last, size_t range, OutputIt dest) { using input_value_type = typename std::iterator_traits::value_type; using output_value_type = typename std::iterator_traits::value_type; static_assert(std::is_integral_v, "InputIt must point to an integral type"); static_assert(std::is_integral_v, "OutputIt must point to an integral type"); static_assert(std::is_convertible_v, "InputIt value type must be convertible to OutputIt value type"); using value_type = typename std::iterator_traits::value_type; auto dst = dest; for (value_type i = 0; i < range; ++i) { auto iter = std::find(first, last, i); if (iter == last) { *dst = i; dst++; } } return dst; } } // namespace algorithm