<commit_before>#include <iterator>
#include <iostream>

template<class RandomIt, typename T>
RandomIt binsearch(RandomIt fst, RandomIt lst, const T &v) {
    if (fst == lst)
        return lst;

    auto l = fst, r = lst - 1;

    while (l <= r) {
        const auto mid = std::next(l, std::distance(l, r) / 2);

        if (*mid == v) {
            return mid;
        }

        if (v < *mid) {
            r = mid - 1;
        } else {
            l = mid + 1;
        }
    }

    return lst;
}<commit_msg>Fix naming in binsearch, use std::next and std::prev<commit_after>#include <iterator>

template<class RandomIt, class Val>
RandomIt binsearch(RandomIt fst, RandomIt lst, const Val& val) {
    if (fst == lst) return lst;

    auto lft = fst, rgt = std::prev(lst);

    while (lft <= rgt) {
        const auto mid = std::next(lft, std::distance(lft, rgt) / 2);

        if (val == *mid)
            return mid;

        if (val < *mid)
            rgt = std::prev(mid);
        else
            lft = std::next(mid);
    }

    return lst; // not found
}
{'fraction_non_alphanumeric': 0.14030131826741996, 'fraction_numerical': 0.004708097928436911, 'mean_word_length': 1.896457765667575, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2438093', 'n_tokens_mistral': 386, 'n_tokens_neox': 367, 'n_words': 112}