stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <vector>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <iomanip>

#define ll long long

using namespace std;



int N;

vector<char> vector_of_chars = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'};



int num_of_char(char ch)

{

  for (int i = 0; i < N; i++)

  {

    if (ch == vector_of_chars[i])

    {

      return i;

    }

  }

  cout << "SWW" << endl;

  return 10;

}



char next_c(char ch)

{

  int num = num_of_char(ch);

  if (num >= N)

  {

    return 'z';

  }

  return vector_of_chars[num + 1];

}



// int largest_num_of_char(string str)

// {

//   int ret = 0;

//   for (int i = 0; i < str.size(); i++)

//   {

//     ret = max(ret, num_of_char(str[i]));

//   }

//   return ret;

// }



vector<int> next_vector_of_int(vector<int> vec);



// vector<int> string_to_vector_of_int(string str)

// {

//   vector<int> vec = {};

//   for (int i = 0; i < str.size(); i++)

//   {

//     vec.push_back(num_of_char(str[i]));

//   }

//   return vec;

// }



string vector_of_int_to_string(vector<int> vec)

{

  string str = "";

  for (int i = 0; i < vec.size(); i++)

  {

    str.push_back(vector_of_chars[vec[i]]);

  }

  return str;

}



// vecの0~i番目の中で最大の整数

int largest_int(vector<int> vec, int i)

{

  int ret = 0;

  for (int j = 0; j <= i; j++)

  {

    ret = max(ret, vec[j]);

  }

  return ret;

}



int main()

{

  cin >> N;

  vector_of_chars.resize(N);



  vector<int> last_vector_of_int = {};

  for (int i = 0; i < N; i++)

  {

    last_vector_of_int.push_back(i);

  }



  vector<int> vec(N, 0);



  while (vec != last_vector_of_int)

  {

    cout << vector_of_int_to_string(vec) << endl;

    vec = next_vector_of_int(vec);

  }

  cout << vector_of_int_to_string(last_vector_of_int) << endl;

  return 0;

}



vector<int> next_vector_of_int(vector<int> vec)

{

  vector<int> next_v = vec;



  while (true)

  {

    // 左からi番目(0-index)の整数を+1できるか？

    bool ok = false;

    for (int i = N - 1; i > 0; i--)

    {

      int lar = largest_int(vec, i - 1);

      if (vec[i] <= lar)

      {

        next_v[i]++;

        if (i != N - 1)

        {

          for (int j = i + 1; j < N; j++)

          {

            next_v[j] = 0;

          }

        }

        ok = true;

        break;

      }

    }

    if (ok)

    {

      break;

    }

  }



  return next_v;

}

// Optimized solution to the same problem (faster):
#include <iostream>

#include <vector>

#include <string>

#include <cstring>

#include <cmath>

#include <algorithm>

#include <iomanip>

#define ll long long

using namespace std;



int N;



void dfs(string s, char mx)

{

  if (s.length() == N)

  {

    cout << s << endl;

  }

  else

  {

    for (char c = 'a'; c <= mx; c++)

    {

      dfs(s + c, (mx == c) ? mx + 1 : mx);

    }

  }

}



int main()

{

  cin >> N;

  dfs("", 'a');

  return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
// pana1-4

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef pair<ll, P>IP;

typedef vector<ll> V;

typedef vector<V> V2;

typedef vector<vector<P> > G;

void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}

void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}

#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)

#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)

#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)

#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)

template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}

template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

const ll INF = 1145141919;

const ll MOD = 1000000007;

const ll NUM = 101010;



ll v[10];

void inc(ll pos){

    v[pos]++;

    if(pos == 0)return;

    ll flg = 0;

    for(ll i = 0; i < pos; i++){

        if(v[i] + 1 >= v[pos])return;

    }

    v[pos] = 0;

    inc(pos - 1);

}





int main(){



    ll N;

    cin >> N;

    for(;v[0] == 0;){

        rep(i, N)cout << (char)(v[i] + 'a');

        cout << endl;

        inc(N - 1);

    }



    return 0;

}

// Optimized solution to the same problem (faster):
//

#include "bits/stdc++.h"

using namespace std;

typedef long long ll;

typedef pair<ll, ll> P;

typedef pair<ll, P>IP;

typedef vector<ll> V;

typedef vector<V> V2;

typedef vector<vector<P> > G;

void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}

void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}

#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)

#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)

#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)

#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)

template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}

template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

const ll INF = 1145141919;

const ll MOD = 1000000007;

const ll NUM = 101010;



void inc(string &s, ll pos){

    s[pos]++;

    if(pos == 0)return;

    rep(i, pos)if(s[i] + 1 >= s[pos])return;

    s[pos] = 'a';

    inc(s, pos - 1);

}



int main(){



    ll N;

    cin >> N;

    string ans(N, 'a');

    while(ans[0] == 'a'){

        cout << ans << endl;

        inc(ans, N - 1);

    }



    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>



#define rep(i, n) for (int i = 0; i < (n); i++)



using namespace std;



using int64 = int64_t;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  if (n == 1) {

    cout << 'a';

  }

  queue<string> q;

  q.push("a");

  while (true) {

    string s = q.front();

    q.pop();

    if ((int)s.length() == n + 1) break;

    char mxS = *max_element(s.begin(), s.end());

    for (char c = 'a'; c <= mxS + 1; c++) {

      string ss = s;

      ss += c;

      if ((int)ss.length() == n) {

        cout << ss << '\n';

      }

      q.push(ss);

    }

  }

  return 0;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>



#define rep(i, n) for (int i = 0; i < (n); i++)



using namespace std;



using int64 = int64_t;



int main() {

  ios::sync_with_stdio(false);

  cin.tie(0);

  int n;

  cin >> n;

  if (n == 1) {

    cout << 'a';

  }

  queue<string> q;

  q.push("a");

  while (true) {

    string s = q.front();

    q.pop();

    if ((int)s.length() == n) break;

    char mxS = *max_element(s.begin(), s.end());

    for (char c = 'a'; c <= mxS + 1; c++) {

      string ss = s;

      ss += c;

      if ((int)ss.length() == n) {

        cout << ss << '\n';

      }

      q.push(ss);

    }

  }

  return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

vector<string> vs;

int n;

void dfs(string s,int cnt,char c){

  if(cnt==n){

    vs.push_back(s);

    return;

  }

  for(int i=0;i<c-'a'+2;i++){

    char x=i+'a';

    dfs(s+x,cnt+1,max(c,x));

  }

}

int main(){

  cin >> n;

  string s="a";

  dfs(s,1,'a');

  sort(vs.begin(),vs.end());

  for(auto& x:vs)cout << x << endl;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

vector<string> vs;

int n;

void dfs(string s,int cnt,char c){

  if(cnt==n){

    cout << s << endl;

    return;

  }

  for(int i=0;i<c-'a'+2;i++){

    char x=i+'a';

    dfs(s+x,cnt+1,max(c,x));

  }

}

int main(){

  cin >> n;

  string s="a";

  dfs(s,1,'a');

  sort(vs.begin(),vs.end());

  for(auto& x:vs)cout << x << endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

#define MOD 1000000007

#define MAX 100



int main(){

  int N;

  cin>>N;

  vector<vector<pair<string,int>>> S(N);

  S.at(0).push_back(make_pair("a",1));

  for(int i=1;i<N;i++){

    for(auto T :S.at(i-1)){

      for(int j=0;j<T.second+1;j++){

        string TT=T.first;

        TT.push_back((char)('a'+j));

        S.at(i).push_back(make_pair(TT,max(T.second,j+1)));

      }

    }

  }

  sort(S.at(N-1).begin(),S.at(N-1).end());

  int n=S.at(N-1).size();

  for(int i=0;i<n;i++){

    cout<<S.at(N-1).at(i).first<<endl;

  }

}


// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

using ll=long long;

#define MAX 300003

#define MOD 1000000007

#define INF 1000000000000000000

using Graph=vector<vector<int>>;



int N;



void dfs(string S,int n){

  if(S.size()==N){

    cout<<S<<endl;

    return ;

  }

  for(int i=0;i<=n;i++){

    char c=(char)('a'+i);

    S.push_back(c);

    dfs(S,max(n,i+1));

    S.pop_back();

  }

}



int main(){

  string S;

  cin>>N;

  dfs(S,0);

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <cstdio>

using namespace std;

int n;

int ans[11];

bool vis[30];

void dfs(int x) {

	if (x == n) {

		for (int i = 1; i <= n; i++) {

			cout << (char)(ans[i] + 'a');

		}

		puts("");

		return;

	}

	for (int i = 0; i <= 26; i++) {

		if (vis[i]) {

			ans[x + 1] = i;

			dfs(x + 1);

		} else {

			vis[i] = 1;

			ans[x + 1] = i;

			dfs(x + 1);

			vis[i] = 0;

			break;

		}

		

	}

}

int main() {

	cin >> n;

	dfs(0);

	return 0;

}

// Optimized solution to the same problem (faster):
# include <bits/stdc++.h>

# define rr register

const int N=15;

int a[N];

int n;

int ans;

inline int read(void){

	int res,f=1;

	char c;

	while((c=getchar())<'0'||c>'9')

		if(c=='-')f=-1;

	res=c-48;

	while((c=getchar())>='0'&&c<='9')

		res=res*10+c-48;

	return res*f;	

}

void dfs(int i,int maxx){

	if(i>n){

		for(rr int j=1;j<=n;++j){

			putchar(a[j]+'a'-1);

		}

		puts("");

		return;

	}



	for(rr int j=1;j<=maxx;++j){

		a[i]=j;		

		dfs(i+1,maxx);		

	}



	a[i]=maxx+1;

	dfs(i+1,maxx+1);

	return;

}

int main(void){

//	freopen("testdata.out","w",stdout);

	n=read();

	if(n==1){

		printf("a");

		return 0;

	}

	dfs(1,0);

	

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

typedef long long ll;



vector<string> ans;

int n;



void dfs(string &s, char c, int i){

    if(i == n){

        ans.push_back(s);

        return;

    }

    for(char a = 'a'; a <= c+1; a++){

        s += a;

        dfs(s, max(a,c), i+1);

        s.pop_back();

    }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> n;

    string tmp = "a";

    dfs(tmp, 'a', 1);

    sort(ans.begin(), ans.end());

    for(string &s : ans)    cout << s << endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<iostream>

#include<vector>

#include<algorithm>

using namespace std;

typedef long long ll;



vector<string> ans;

int n;



void dfs(string &s, char c, int i){

    if(i == n){

        ans.push_back(s);

        return;

    }

    for(char a = 'a'; a <= c+1; a++){

        s += a;

        dfs(s, max(a,c), i+1);

        s.pop_back();

    }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> n;

    string tmp = "a";

    dfs(tmp, 'a', 1);

    //sort(ans.begin(), ans.end());

    for(string &s : ans)    cout << s << endl;

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):


/**

 *    Coded by : lucky_21

 *               --------Lokesh Singh

**/



#include<bits/stdc++.h>

using namespace std;



#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define     F           first

#define     S           second

#define     pb          push_back

#define     lb          lower_bound

#define     ub          upper_bound

#define     pii         pair<int,int>

#define     all(x)      x.begin(),x.end()

#define     fix         fixed<<setprecision(10)

#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)

#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)

#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)



typedef double d;

typedef long long ll;



const int N=2e5+5;

const int mod=1e9+7;



int n;

vector<string>v;

void rec(int i,string s){

    int maxi=-1;

    bool ok[10]{0};

    for(char c:s){

        ok[c-'a']=1;

        maxi=max(maxi,int(c-'a'));

    }

    rep(j,0,maxi){

        if(!ok[j]) return;

    }

    if(i==n){

        v.pb(s);

        return;

    }

    rep(j,0,i){

        rec(i+1,s+char('a'+j));

    }

}

signed main(){

    FastIO;

    cin>>n;

    rec(0,"");

    sort(all(v));

//    cout<<v.size();

    for(string s:v) cout<<s<<'\n';

    return 0;

}


// Optimized solution to the same problem (faster):


/**

 *    Coded by : lucky_21

 *               --------Lokesh Singh

**/



#include<bits/stdc++.h>

using namespace std;



#include <ext/pb_ds/tree_policy.hpp>

#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;

template<class T> using oset=tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;



#define     F           first

#define     S           second

#define     pb          push_back

#define     lb          lower_bound

#define     ub          upper_bound

#define     pii         pair<int,int>

#define     all(x)      x.begin(),x.end()

#define     fix         fixed<<setprecision(10)

#define     rep(i,a,b)  for(int i=int(a);i<=int(b);i++)

#define     repb(i,b,a) for(int i=int(b);i>=int(a);i--)

#define     FastIO      ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)



typedef double db;

typedef long long ll;



const int N=2e5+5;

const int mod=1e9+7;



int n;

void solve(string s,char mx){

    if(s.size()==n){

        cout<<s<<'\n';

        return;

    }

    for(char c='a';c<=mx;c++){

        solve(s+c,(c==mx?mx+1:mx));

    }

}

signed main(){

    FastIO;

    cin>>n;

    solve("",'a');

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <vector>

#include <list>

#include <map>

#include <set>

#include <queue>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstring>



using namespace std;



#define MAX 100000

#define INF 2140000000

#define MOD 1000000007



vector<string> ans;



void fun(string s, int k, int dist, int n) {

	if (k == n) {

		ans.push_back(s);

	}

	else {

		for (int i = 0; i < dist; ++i) {

			string temp = s + (char)('a' + i);



			if (i == dist - 1) {

				fun(temp, k + 1, dist + 1, n);

			}

			else {

				fun(temp, k + 1, dist, n);

			}

		}

	}



	return;

}



int main() {

	int n;

	cin >> n;



	string s = "a";



	fun(s, 1, 2, n);



	sort(ans.begin(), ans.end());



	for (int i = 0; i < (int) ans.size(); ++i) {

		cout << ans[i] << endl;

	}



	return 0;

}

// Optimized solution to the same problem (faster):
#include <vector>

#include <list>

#include <map>

#include <set>

#include <queue>

#include <deque>

#include <stack>

#include <bitset>

#include <algorithm>

#include <functional>

#include <numeric>

#include <utility>

#include <sstream>

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <cmath>

#include <cstdlib>

#include <ctime>

#include <cstring>



using namespace std;



#define MAX 100000

#define INF 2140000000

#define MOD 1000000007



vector<string> ans;



void fun(string s, int k, int dist, int n) {

	if (k == n) {

		cout << s << endl;

	}

	else {

		for (int i = 0; i < dist; ++i) {

			string temp = s + (char)('a' + i);



			if (i == dist - 1) {

				fun(temp, k + 1, dist + 1, n);

			}

			else {

				fun(temp, k + 1, dist, n);

			}

		}

	}



	return;

}



int main() {

	int n;

	cin >> n;



	string s = "a";



	fun(s, 1, 2, n);



	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include "bits/stdc++.h"

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000



vector<string> v;

int N; 

void dfs(string& S, int p, int depth) {

    //cout << S << " " << depth << endl;

    if (depth >= N) {

        v.push_back(S);

        return;

    }

    rep(i, p + 1) {

        S += 'a' + i;

        dfs(S, max(i + 1, p), depth + 1);

        S.pop_back();

    }

}





int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> N;

    string S = "";

    dfs(S, 0, 0);

    sort(v.begin(), v.end());

    rep(i, v.size()) {

        cout << v[i] << endl;

    }





    return 0;

}


// Optimized solution to the same problem (faster):
#include <iostream>

#include <fstream>

#include <set>

#include <map>

#include <string>

#include <vector>

#include <queue>

#include <deque>

#include <stack>

#include <functional>

#include <algorithm>

#include <climits>

#include <cmath>

#include <iomanip>

using namespace std;

#define ll long long int

#define rep(i,n) for( int i = 0; i < n; i++ )

#define rrep(i,n) for( int i = n; i >= 0; i-- )

#define REP(i,s,t) for( int i = s; i <= t; i++ )

#define RREP(i,s,t) for( int i = s; i >= t; i-- )

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define INF 2000000000

#define mod 1000000007

#define INF2 1000000000000000000



vector<string> T;

int N;

void dfs(string S = "", int depth = 0, int c = 1) {

    if (depth >= N) {

        T.push_back(S);

        return;

    }

    rep(i, c) {

        S.push_back('a' + i);

        dfs(S, depth + 1, max(c, i + 2));

        S.pop_back();

    }

}



int main(void)

{

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin >> N;

    dfs();

    for(auto& e: T) {

        cout << e << endl;

    }



    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}

template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}



int n; 

vector<string> result;





int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin>>n;

    queue<string> q;

    q.push("a");

    while(true){

        string str = q.front(); 

        if(str.length() > n-1) {

            break;

        } else{

            q.pop();

            set<char> cset;

            for(auto a : str){

                cset.insert(a);

            }

            char tmp;

            for(auto  a : cset){

                q.push(str+a);

                tmp = a;

            }

            tmp = tmp+1;

            q.push(str + tmp);

        }

    }

    vector<string> ans;

    while(!q.empty()){

        ans.push_back(q.front());

        q.pop();

    }

    sort(ans.begin(), ans.end());

    for(auto a : ans){

        cout << a << endl;

    }

 

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

#define all(x) (x).begin(),(x).end()

template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}

template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}



int n;

vector<string> ans;



void dfs(string s, char mxc){

    if(s.size() == n){

        ans.push_back(s);

        return;

    }

    char adc = 'a'-1;

    while(true){

        adc++;

        string t = s + adc;

        dfs(t, max(adc,mxc));

        if(adc == mxc+1) break;

    }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin>>n;

    dfs("a", 'a');



    for(auto a : ans){

        cout<<a<<endl;

    }

    

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}

template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}



vector<string> ansv;

int n;



void dfs(string str, int cur){

    if(cur == n) {

        ansv.push_back(str);

        return;

    }

    cur++;

    char last = 'a';

    for(char c : str){

        last = max(last, c);

        dfs(str+c, cur);

    }

    last+=1;

    dfs(str+last, cur);

}

void dfs2(string s, char c) {

    if(s.length()==n) ansv.push_back(s);

    else{

        for(char cc = 'a'; cc<=c; cc++){

            dfs2(s+cc, (cc==c ? (char)(c+1) : c));

        }

    }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin>>n;

    dfs2("", 'a');

    sort(ansv.begin(), ansv.end());

    for(auto a : ansv){

        cout << a <<endl;

    }



}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

typedef pair<int, int> P;

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

#define all(x) (x).begin(),(x).end()

template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}

template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}



int n;

vector<string> ans;



void dfs(string s, char mxc){

    if(s.size() == n){

        ans.push_back(s);

        return;

    }

    char adc = 'a'-1;

    while(true){

        adc++;

        string t = s + adc;

        dfs(t, max(adc,mxc));

        if(adc == mxc+1) break;

    }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);

    cin>>n;

    dfs("a", 'a');



    for(auto a : ans){

        cout<<a<<endl;

    }

    

}

// Fastest known solution for this problem: