#include <algorithm>
#include <iostream>
using namespace std;
int main() {
const auto foo = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
auto bar = cbegin(foo);
for (auto it = bar + 3; it < cend(foo); bar = it, it = bar + 3) {
for_each(bar, it, [](const auto& i) { cout << i << endl; });
}
for_each(bar, cend(foo), [](const auto& i) { cout << i << endl; });
}
I2luY2x1ZGUgPGFsZ29yaXRobT4KI2luY2x1ZGUgPGlvc3RyZWFtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4oKSB7Cgljb25zdCBhdXRvIGZvbyA9IHsgMSwgMiwgMywgNCwgNSwgNiwgNywgOCwgOSwgMTAgfTsKCWF1dG8gYmFyID0gY2JlZ2luKGZvbyk7CgoJZm9yIChhdXRvIGl0ID0gYmFyICsgMzsgaXQgPCBjZW5kKGZvbyk7IGJhciA9IGl0LCBpdCA9IGJhciArIDMpIHsKCQlmb3JfZWFjaChiYXIsIGl0LCBbXShjb25zdCBhdXRvJiBpKSB7IGNvdXQgPDwgaSA8PCBlbmRsOyB9KTsKCX0KCglmb3JfZWFjaChiYXIsIGNlbmQoZm9vKSwgW10oY29uc3QgYXV0byYgaSkgeyBjb3V0IDw8IGkgPDwgZW5kbDsgfSk7Cn0=