#include <iostream>
#include <set>
#include <vector>
#include <utility>
using namespace std;
int main() {
std::set<int64_t> instance_indices(
{-10, 0, 1, 2, 3, 10, 44, 11, 12, 15, 16, 17, 20, 21, 22}
);
std::vector<std::pair<int64_t, int64_t>> continious_intervals;
int64_t pair_start = *instance_indices.begin();
int64_t prev_value = pair_start;
auto it = instance_indices.begin(); it++;
for (; it != instance_indices.end(); it++) {
if (prev_value + 1 != *it) {
continious_intervals.push_back({pair_start, prev_value});
pair_start = *it;
}
prev_value = *it;
}
continious_intervals.push_back({pair_start, prev_value});
for(auto it = continious_intervals.begin(); it != continious_intervals.end(); it++) {
cout << "(" << it->first << " , " << it->second << ")" << endl;
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c2V0PgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8dXRpbGl0eT4KCgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKCmludCBtYWluKCkgewoJc3RkOjpzZXQ8aW50NjRfdD4gaW5zdGFuY2VfaW5kaWNlcygKCQl7LTEwLCAwLCAxLCAyLCAzLCAxMCwgNDQsIDExLCAxMiwgMTUsIDE2LCAxNywgMjAsIDIxLCAyMn0KCSk7CgkKCXN0ZDo6dmVjdG9yPHN0ZDo6cGFpcjxpbnQ2NF90LCBpbnQ2NF90Pj4gY29udGluaW91c19pbnRlcnZhbHM7CgoJaW50NjRfdCBwYWlyX3N0YXJ0ID0gKmluc3RhbmNlX2luZGljZXMuYmVnaW4oKTsKCWludDY0X3QgcHJldl92YWx1ZSA9IHBhaXJfc3RhcnQ7CglhdXRvIGl0ID0gaW5zdGFuY2VfaW5kaWNlcy5iZWdpbigpOyBpdCsrOwoJZm9yICg7IGl0ICE9IGluc3RhbmNlX2luZGljZXMuZW5kKCk7IGl0KyspIHsKCQlpZiAocHJldl92YWx1ZSArIDEgIT0gKml0KSB7CgkJCWNvbnRpbmlvdXNfaW50ZXJ2YWxzLnB1c2hfYmFjayh7cGFpcl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