#pragma once
 
#include <algorithm>
 
template<typename T, typename Iterator>
Iterator Find(const T &value, Iterator first, Iterator last) {
    using category = typename std::iterator_traits<Iterator>::iterator_category;
    if (std::is_same<std::random_access_iterator_tag, category>()) {
        Iterator tmp = std::lower_bound(first, last, value);
        if (*tmp == value) {
            return tmp;
        }
    } else {
        for (auto v = first; v != last; ++v) {
            if (*v == value) {
                return v;
            }
        }
    }
    return last;
}