#include <climits>
#include <iostream>
#include <stdexcept>
#include <string>
#include <vector>
std::vector<std::string> do_split(const std::string& original, const std::vector<bool>& split)
{
if(original.size() != split.size() + 1)
throw std::invalid_argument("Mismatching sizes of string and split");
std::vector<std::string> result;
auto beg = original.cbegin();
for(size_t i = 0; i < split.size(); ++i) {
if(split[i]) {
auto end = std::next(original.cbegin(), i + 1);
result.emplace_back(beg, end);
beg = end;
}
}
result.emplace_back(beg, original.cend());
return result;
}
int main()
{
using split_t = unsigned;
constexpr size_t limit = sizeof(split_t) * CHAR_BIT;
std::string input;
std::cin >> input;
auto size = input.size();
if(size > limit)
throw std::range_error("Line is too long, maximum: " + std::to_string(limit));
std::cout << "Generating splits:\n";
std::vector<bool> split_v(size - 1);
for(split_t split = 0; split < (1u << (size - 1)); ++split) { //Generating all splits
//Stuffing those to the bool vector for fast extraction
for(size_t i = 0; i < size; ++i)
split_v[i] = (split & 1u << i);
//Extracting current split result
std::vector<std::string> res = do_split(input, split_v);
//Output
for(const auto& s: res)
std::cout << s << ' ';
std::cout << '\n';
}
}
I2luY2x1ZGUgPGNsaW1pdHM+CiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0ZGV4Y2VwdD4KI2luY2x1ZGUgPHN0cmluZz4KI2luY2x1ZGUgPHZlY3Rvcj4KCnN0ZDo6dmVjdG9yPHN0ZDo6c3RyaW5nPiBkb19zcGxpdChjb25zdCBzdGQ6OnN0cmluZyYgb3JpZ2luYWwsIGNvbnN0IHN0ZDo6dmVjdG9yPGJvb2w+JiBzcGxpdCkKewogICAgaWYob3JpZ2luYWwuc2l6ZSgpICE9IHNwbGl0LnNpemUoKSArIDEpCiAgICAgICAgdGhyb3cgc3RkOjppbnZhbGlkX2FyZ3VtZW50KCJNaXNtYXRjaGluZyBzaXplcyBvZiBzdHJpbmcgYW5kIHNwbGl0Iik7CgogICAgc3RkOjp2ZWN0b3I8c3RkOjpzdHJpbmc+IHJlc3VsdDsKICAgIGF1dG8gYmVn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