Language: Java

#include <bits/stdc++.h>
using namespace std;

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    while(true){
        string enc;
        cin >> enc;
        if(enc=="#") break;
        if([&](){
            for(const char ch:enc) if(ch=='z') return true;
        }()){
            cout << 0 << endl;
            continue;
        }

        int num=0;
        set<string> s1,s2;
        function<void(const int,string&,vector<bool>&)> rec=[&](const int k,string &res,vector<bool> &done){
            if(k==enc.size()){
                ++num;
                s1.insert(res);
                s2.insert(res);
                if(s1.size()>10){
                    auto it=s1.end();
                    --it;
                    s1.erase(it);
                }
                if(s2.size()>10) s2.erase(s2.begin());
                return;
            }
            if(!done[enc[k]-'a']){
                ++res[k];
                done[enc[k]-'a']=true;
                rec(k+1,res,done);
                --res[k];
                done[enc[k]-'a']=false;
            }
            if(enc[k]=='a' or done[enc[k]-'a'-1]) rec(k+1,res,done);
        };
        string res=enc;
        vector<bool> done(26,false);
        rec(0,res,done);

        cout << num << endl;
        if(num<=10) for(const auto &dec:s1) cout << dec << endl;
        else{
            {
                int i=0;
                for(auto it=s1.begin(); i!=5; ++i,++it) cout << *it << endl;
            }
            {
                int i=0;
                for(auto it=s2.begin(); i!=5; ++i,++it) cout << *it << endl;
            }
        }
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Compiler output:
Main.java:1: error: illegal character: '#'
#include <bits/stdc++.h>
^
Main.java:1: error: class, interface, enum, or record expected
#include <bits/stdc++.h>
         ^
Main.java:4: error: illegal character: '#'
#define rep(i,x,y) for(int i=(x);i<(y);++i)
^
Main.java:4: error: class, interface, enum, or record expected
#define rep(i,x,y) for(int i=(x);i<(y);++i)
        ^
Main.java:4: error: class, interface, enum, or record expected
#define rep(i,x,y) for(int i=(x);i<(y);++i)
                                 ^
Main.java:4: error: class, interface, enum, or record expected
#define rep(i,x,y) for(int i=(x);i<(y);++i)
                                       ^
Main.java:5: error: illegal character: '#'
#define debug(x) #x << "=" << (x)
^
Main.java:5: error: illegal character: '#'
#define debug(x) #x << "=" << (x)
                 ^
Main.java:7: error: illegal character: '#'
#ifdef DEBUG
^
Main.java:8: error: illegal character: '#'
#define _GLIBCXX_DEBUG
^
Main.java:9: error: illegal character: '#'
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
^
Main.java:10: error: illegal character: '#'
#else
^
Main.java:11: error: illegal character: '#'
#define dump(x)
^
Main.java:12: error: illegal character: '#'
#endif
^
Main.java:15: error: class, interface, enum, or record expected
typedef pair<int,int> pii;
^
Main.java:18: error: class, interface, enum, or record expected
const int inf=1<<30;
^
Main.java:19: error: class, interface, enum, or record expected
const long long int infll=1LL<<58;
^
Main.java:20: error: class, interface, enum, or record expected
const double eps=1e-9;
^
Main.java:21: error: class, interface, enum, or record expected
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
^
Main.java:23: error: class, interface, enum, or record expected
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
^
Main.java:25: error: class, interface, enum, or record expected
    for (const auto &v : vec) {
    ^
Main.java:27: error: class, interface, enum, or record expected
    }
    ^
Main.java:29: error: class, interface, enum, or record expected
    return os;
    ^
Main.java:30: error: class, interface, enum, or record expected
}
^
Main.java:35: error: class, interface, enum, or record expected
        cin >> enc;
        ^
Main.java:36: error: class, interface, enum, or record expected
        if(enc=="#") break;
        ^
Main.java:37: error: class, interface, enum, or record expected
        if([&](){
        ^
Main.java:39: error: class, interface, enum, or record expected
        }()){
        ^
Main.java:41: error: class, interface, enum, or record expected
            continue;
            ^
Main.java:42: error: class, interface, enum, or record expected
        }
        ^
Main.java:45: error: class, interface, enum, or record expected
        set<string> s1,s2;
        ^
Main.java:46: error: class, interface, enum, or record expected
        function<void(const int,string&,vector<bool>&)> rec=[&](const int k,string &res,vector<bool> &done){
        ^
Main.java:49: error: class, interface, enum, or record expected
                s1.insert(res);
                ^
Main.java:50: error: class, interface, enum, or record expected
                s2.insert(res);
                ^
Main.java:51: error: class, interface, enum, or record expected
                if(s1.size()>10){
                ^
Main.java:53: error: class, interface, enum, or record expected
                    --it;
                    ^
Main.java:54: error: class, interface, enum, or record expected
                    s1.erase(it);
                    ^
Main.java:55: error: class, interface, enum, or record expected
                }
                ^
Main.java:57: error: class, interface, enum, or record expected
                return;
                ^
Main.java:58: error: class, interface, enum, or record expected
            }
            ^
Main.java:61: error: class, interface, enum, or record expected
                done[enc[k]-'a']=true;
                ^
Main.java:62: error: class, interface, enum, or record expected
                rec(k+1,res,done);
                ^
Main.java:63: error: class, interface, enum, or record expected
                --res[k];
                ^
Main.java:64: error: class, interface, enum, or record expected
                done[enc[k]-'a']=false;
                ^
Main.java:65: error: class, interface, enum, or record expected
            }
            ^
Main.java:67: error: class, interface, enum, or record expected
        };
        ^
Main.java:68: error: unnamed classes are a preview feature and are disabled by default.
        string res=enc;
        ^
  (use --enable-preview to enable unnamed classes)
Main.java:69: error: illegal start of type
        vector<bool> done(26,false);
                          ^
Main.java:70: error: class, interface, enum, or record expected
        rec(0,res,done);
        ^
Main.java:72: error: class, interface, enum, or record expected
        cout << num << endl;
        ^
Main.java:73: error: class, interface, enum, or record expected
        if(num<=10) for(const auto &dec:s1) cout << dec << endl;
        ^
Main.java:74: error: class, interface, enum, or record expected
        else{
        ^
Main.java:77: error: class, interface, enum, or record expected
                for(auto it=s1.begin(); i!=5; ++i,++it) cout << *it << endl;
                ^
Main.java:77: error: class, interface, enum, or record expected
                for(auto it=s1.begin(); i!=5; ++i,++it) cout << *it << endl;
                                        ^
Main.java:77: error: class, interface, enum, or record expected
                for(auto it=s1.begin(); i!=5; ++i,++it) cout << *it << endl;
                                              ^
Main.java:78: error: class, interface, enum, or record expected
            }
            ^
Main.java:81: error: class, interface, enum, or record expected
                for(auto it=s2.begin(); i!=5; ++i,++it) cout << *it << endl;
                ^
Main.java:81: error: class, interface, enum, or record expected
                for(auto it=s2.begin(); i!=5; ++i,++it) cout << *it << endl;
                                        ^
Main.java:81: error: class, interface, enum, or record expected
                for(auto it=s2.begin(); i!=5; ++i,++it) cout << *it << endl;
                                              ^
Main.java:82: error: class, interface, enum, or record expected
            }
            ^
Main.java:89: error: class, interface, enum, or record expected
    std::cin.tie(0);
    ^
Main.java:90: error: class, interface, enum, or record expected
    cout << fixed << setprecision(8);
    ^
Main.java:91: error: class, interface, enum, or record expected
    solve();
    ^
Main.java:92: error: class, interface, enum, or record expected
    return 0;
    ^
Main.java:93: error: class, interface, enum, or record expected
}
^
65 errors