Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

typedef vector<string> V;

class Solver {
    private:
        void search(string &line, bool has_used[], V &candidates, unsigned cur = 0) {
            char c = line[min(cur, line.length() - 1)];
            if (cur == line.length()) {
                candidates.push_back(line);
                return;
            }
            if (c == 'a') {
                search(line, has_used, candidates, cur + 1);
            }
            if (has_used[c - 'a']) {
                search(line, has_used, candidates, cur + 1);
            }
            if (!has_used[c + 1 - 'a']) {
                line[cur] = c + 1;
                has_used[c + 1 - 'a'] = true;
                search(line, has_used, candidates, cur + 1);
                line[cur] = c;
                has_used[c + 1 - 'a'] = false;
            }
        }
    public:
        V enumerate(string line) {
            V candidates;
            bool has_used[27];
            for (int i = 0; i < 26; ++i) {
                has_used[i] = false;
            }
            has_used[26] = true;
            search(line, has_used, candidates);
            return candidates;
        }
};

int main() {
    Solver s;
    string line;
    V candidates;
    while (true) {
        cin >> line;
        if (line == "#") {
            return 0;
        }
        candidates = s.enumerate(line);
        cout << candidates.size() << endl;
        if (candidates.size() < 10) {
            for (unsigned i = 0; i < candidates.size(); ++i) {
                cout << candidates[i] << endl;
            }
        } else {
            for (unsigned i = 0; i < 5; ++i) {
                cout << candidates[i] << endl;
            }
            for (unsigned i = 0; i < 5; ++i) {
                cout << candidates[candidates.size() - 5 + i] << endl;
            }
        }
    }
}

Compiler output:
a.cc: In member function 'void Solver::search(std::string&, bool*, V&, unsigned int)':
a.cc:13:30: error: no matching function for call to 'min(unsigned int&, std::__cxx11::basic_string<char>::size_type)'
   13 |             char c = line[min(cur, line.length() - 1)];
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/string:51,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:13:30: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
   13 |             char c = line[min(cur, line.length() - 1)];
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:13:30: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
   13 |             char c = line[min(cur, line.length() - 1)];
      |                           ~~~^~~~~~~~~~~~~~~~~~~~~~~~