#pragma once

#include <algorithm>
#include <iterator>
#include <typeinfo>

template<typename T, typename Iterator>
Iterator Find(const T& value, Iterator first, Iterator last) {
    if (std::is_same_v<typename Iterator::iterator_category,
            std::random_access_iterator_tag>) {
        auto f = std::lower_bound(first, last, value);
        if (f != last && !(value < *f)) {
            return f;
        }
    } else {
        while (first != last) {
            if (*first == value) {
                return first;
            }
            first++;
        }
    }
    return last;
}