<commit_before>// Time:  O(nlogn)
// Space: O(k),  k is the max size of heights with the same width.

class Solution {
public:
    int maxEnvelopes(vector<pair<int, int>>& envelopes) {
        vector<int> result;

        sort(envelopes.begin(), envelopes.end());
        for (int i = 0; i < envelopes.size();) {
            int w = envelopes[i].first;
            int same_count = 0;
            while (i < envelopes.size() && envelopes[i].first == w) {
                ++i, ++same_count;
            }

            for (int j = i - 1; j >= i - same_count; --j) {
                const auto target = envelopes[j].second;
                auto it = lower_bound(result.begin(), result.end(), target);
                if (it == result.end()) {
                    result.emplace_back(target);
                } else {
                    *it = target;
                }
            }
        }

        return result.size();
    }
};<commit_msg>Update russian-doll-envelopes.cpp<commit_after>// Time:  O(nlogn)
// Space: O(k),  k is the max size of heights with the same width.

class Solution {
public:
    int maxEnvelopes(vector<pair<int, int>>& envelopes) {
        vector<int> result;

        sort(envelopes.begin(), envelopes.end());
        for (int i = 0; i < envelopes.size();) {
            int w = envelopes[i].first;
            int same_count = 0;
            while (i < envelopes.size() && envelopes[i].first == w) {
                ++i, ++same_count;
            }

            for (int j = i - 1; j >= i - same_count; --j) {  // Insert from larger h.
                const auto target = envelopes[j].second;
                auto it = lower_bound(result.begin(), result.end(), target);
                if (it == result.end()) {
                    result.emplace_back(target);
                } else {
                    *it = target;
                }
            }
        }

        return result.size();
    }
};
{'fraction_non_alphanumeric': 0.14093264248704662, 'fraction_numerical': 0.0031088082901554403, 'mean_word_length': 1.4630102040816326, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 11, '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': '901120', 'n_tokens_mistral': 613, 'n_tokens_neox': 552, 'n_words': 151}