Language: C++

#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<string> ans;
int n;
vector<char> al;

void dfs(string s = "a", int cnt = 1) {
    if (cnt == n) {
        ans.pb(s);
        return;
    }
    for (int i = 0; i <= (s[s.size() - 1] - 'a') + 1; i++) {
        dfs(s + al[i], cnt + 1);
    }
}


int main(void) {
    cin >> n;

    for (char c = 'a'; c <= 'z'; c++) al.pb(c);

    dfs();

    sort(rng(ans));

    rep (i, ans.size()) cout << ans[i] << endl;
    return 0;
}
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", ans);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

vector<string> ans;
int n;
vector<char> al;

void dfs(string s = "a", int cnt = 1) {
    if (cnt == n) {
        ans.pb(s);
        return;
    }
    for (int i = 0; i <= (s[s.size() - 1] - 'a') + 1; i++) {
        dfs(s + al[i], cnt + 1);
    }
}


int main(void) {
    cin >> n;

    for (char c = 'a'; c <= 'z'; c++) al.pb(c);

    dfs();

    sort(rng(ans));

    rep (i, ans.size()) cout << ans[i] << endl;
    return 0;
}


Compiler output:
a.cc:56:24: error: redefinition of 'template<class T> bool chmin(T&, const T&)'
   56 | template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
      |                        ^~~~~
a.cc:12:24: note: 'template<class T> bool chmin(T&, const T&)' previously declared here
   12 | template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
      |                        ^~~~~
a.cc:57:24: error: redefinition of 'template<class T> bool chmax(T&, const T&)'
   57 | template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
      |                        ^~~~~
a.cc:13:24: note: 'template<class T> bool chmax(T&, const T&)' previously declared here
   13 | template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
      |                        ^~~~~
a.cc:62:16: error: redefinition of 'std::vector<std::__cxx11::basic_string<char> > ans'
   62 | vector<string> ans;
      |                ^~~
a.cc:18:16: note: 'std::vector<std::__cxx11::basic_string<char> > ans' previously declared here
   18 | vector<string> ans;
      |                ^~~
a.cc:63:5: error: redefinition of 'int n'
   63 | int n;
      |     ^
a.cc:19:5: note: 'int n' previously declared here
   19 | int n;
      |     ^
a.cc:64:14: error: redefinition of 'std::vector<char> al'
   64 | vector<char> al;
      |              ^~
a.cc:20:14: note: 'std::vector<char> al' previously declared here
   20 | vector<char> al;
      |              ^~
a.cc:66:6: error: redefinition of 'void dfs(std::string, int)'
   66 | void dfs(string s = "a", int cnt = 1) {
      |      ^~~
a.cc:22:6: note: 'void dfs(std::string, int)' previously defined here
   22 | void dfs(string s = "a", int cnt = 1) {
      |      ^~~
a.cc:77:5: error: redefinition of 'int main()'
   77 | int main(void) {
      |     ^~~~
a.cc:33:5: note: 'int main()' previously defined here
   33 | int main(void) {
      |     ^~~~