<commit_before>#ifndef PK_BINARYINDEXEDTREE2D_HPP
#define PK_BINARYINDEXEDTREE2D_HPP


namespace pk
{
namespace detail
{


struct binary_indexed_tree_2d_entry
{
    binary_indexed_tree_2d_entry(const int x_, const int y_) : x(x_), y(y_) {}

    int x;
    int y;
};


struct binary_indexed_tree_2d_subrange
{
    binary_indexed_tree_2d_subrange(const int from_, const int to_) : from(from_), to(to_) {}

    int from;
    int to;
};


} // namespace detail


template<class ValueType, int Range1, int Range2>
class binary_indexed_tree_2d
{
public:
    typedef ValueType value_type;
    typedef detail::binary_indexed_tree_2d_entry entry;
    typedef detail::binary_indexed_tree_2d_subrange subrange;

    binary_indexed_tree_2d(const int real_range_1_, const int real_range_2_)
        : real_range_1(real_range_1_),
          real_range_2(real_range_2_)
    {
        for(int x = 0; x < real_range_1; ++x)
            for(int y = 0; y < real_range_2; ++y)
                data[x][y] = value_type();
    }

    void increase(entry e, const value_type& value)
    {
        while(e.x < real_range_1)
        {
            int y1 = e.y;
            while(y1 < real_range_2)
            {
                data[e.x][y1] += value;
                y1 |= y1 + 1;
            }

            e.x |= e.x + 1;
        }
    }

    void set(const entry& e, const value_type& value)
    {
        const value_type old_value = count_less_equal(e.x, e.y);
        increase(e, value - old_value);
    }

    int count_less_equal(int x, int y) const
    {<commit_msg>fix in binary_indexed_tree_2d::set()<commit_after>#ifndef PK_BINARYINDEXEDTREE2D_HPP
#define PK_BINARYINDEXEDTREE2D_HPP


namespace pk
{
namespace detail
{


struct binary_indexed_tree_2d_entry
{
    binary_indexed_tree_2d_entry(const int x_, const int y_) : x(x_), y(y_) {}

    int x;
    int y;
};


struct binary_indexed_tree_2d_subrange
{
    binary_indexed_tree_2d_subrange(const int from_, const int to_) : from(from_), to(to_) {}

    int from;
    int to;
};


} // namespace detail


template<class ValueType, int Range1, int Range2>
class binary_indexed_tree_2d
{
public:
    typedef ValueType value_type;
    typedef detail::binary_indexed_tree_2d_entry entry;
    typedef detail::binary_indexed_tree_2d_subrange subrange;

    binary_indexed_tree_2d(const int real_range_1_, const int real_range_2_)
        : real_range_1(real_range_1_),
          real_range_2(real_range_2_)
    {
        for(int x = 0; x < real_range_1; ++x)
            for(int y = 0; y < real_range_2; ++y)
                data[x][y] = value_type();
    }

    void increase(entry e, const value_type& value)
    {
        while(e.x < real_range_1)
        {
            int y1 = e.y;
            while(y1 < real_range_2)
            {
                data[e.x][y1] += value;
                y1 |= y1 + 1;
            }

            e.x |= e.x + 1;
        }
    }

    void set(const entry& e, const value_type& value)
    {
        const value_type old_value = count_in_range(subrange(e.x, e.x), subrange(e.y, e.y));
        increase(e, value - old_value);
    }

    int count_less_equal(int x, int y) const
    {
{'fraction_non_alphanumeric': 0.09965090447476992, 'fraction_numerical': 0.01999365280863218, 'mean_word_length': 2.45993413830955, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 5, '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': '5981192', 'n_tokens_mistral': 1184, 'n_tokens_neox': 1147, 'n_words': 244}