stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include "bits/stdc++.h"

#define int long long

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

#define rep(i, a) range(i, 0, a)

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

using namespace std;

const int MOD = 1e9 + 7, INF = 1e9;

using vi = vector <int>;

using vvi = vector <vi>;

//g++ -std==c++14



int a, b, c, d, e, f;

double ans = -INF;

int ansSugerWater, ansSuger;

map <pair <int, int>, int> mp;



void dfs(int water, int suger){

	if(mp[make_pair(water, suger)])

		return;

	mp[make_pair(water, suger)] = 1;



	if(water + suger > f)

		return;



	double per;

	if(water + suger != 0)

		per = 100.0 * suger / (water + suger);

	else

		per = 0;



	if(ans <= per && suger * 1.0 / e <= water / 100){

		ans = per;

		ansSugerWater = water + suger;

		ansSuger = suger;

	}



	dfs(water + 100 * a, suger);

	dfs(water + 100 * b, suger);

	dfs(water, suger + c);

	dfs(water, suger + d);

}



signed main(){

	cin >> a >> b >> c >> d >> e >> f;



	dfs(0, 0);

	cout << ansSugerWater << " " << ansSuger << endl;

}


// Faster C++ solution for the same problem (measured speedup: 2.2190267419240826x):
#include <bits/stdc++.h>

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

#define rep(i, a) range(i, 0, a)

using namespace std;



int A, B, C, D, E, F, ansSugar, ansSugarWater;

bool used[10000][10000];

double maxConc = 0.0;



void rec(int water = 0, int sugar = 0) {

    if (water * 100 + sugar > F) return;



    if (used[water][sugar]) return;

    used[water][sugar] = true;



    double per = (water + sugar == 0) ? 0.0 : (100.0 * sugar) / (100.0 * water + sugar);



    if (E * water >= sugar) {

        if (maxConc <= per) {

            maxConc = per;

            ansSugarWater = water * 100 + sugar;

            ansSugar = sugar;

        }

    }



    rec(water + A, sugar    );

    rec(water + B, sugar    );

    rec(water    , sugar + C);

    rec(water    , sugar + D);

}



int main() {

    cin >> A >> B >> C >> D >> E >> F;

    rec();

    cout << ansSugarWater << " " << ansSugar << endl;

    return 0;

}
// Slower C++ solution:
#pragma GCC optimize("O3")

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

#include <numeric>

#include <fstream>

#include <functional>

#include <bitset>

using namespace std;



using ll = long long;

using P = pair<int, int>;

using T = tuple<int, int, int>;



template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}

template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}



constexpr int MOD = 1e9 + 7;

constexpr int inf = 1e9;

constexpr long long INF = 1e18;



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



int dx[] = {1, 0, -1, 0};

int dy[] = {0, 1, 0, -1};



vector<pair<string, int>> ans;

vector<string> v = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j"};



int n;



void solve(int len, pair<string, int> s){



    if(len == n){

        ans.emplace_back(s);

        return ;

    }



    int kind = s.second;



    for(int i=0; i<kind+1; i++){

        solve(len + 1, make_pair(s.first + v[i], max(s.second, i + 1)));

    }

    

    return ;

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    cin>>n;



    pair<string, int> pp = make_pair("a", 1);

    solve(1, pp);



    sort(all(ans));



    for(auto i : ans) cout << i.first << endl;



    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.2212503339342389x):
#pragma GCC optimize("O3")

#include <iostream>

#include <iomanip>

#include <cstdio>

#include <string>

#include <cstring>

#include <deque>

#include <list>

#include <queue>

#include <stack>

#include <vector>

#include <utility>

#include <algorithm>

#include <map>

#include <set>

#include <complex>

#include <cmath>

#include <limits>

#include <cfloat>

#include <climits>

#include <ctime>

#include <cassert>

#include <numeric>

#include <fstream>

#include <functional>

#include <bitset>

using namespace std;



using ll = long long;

using P = pair<int, int>;

using T = tuple<int, int, int>;



template <class T> inline T chmax(T &a, const T b) {return a = (a < b) ? b : a;}

template <class T> inline T chmin(T &a, const T b) {return a = (a > b) ? b : a;}



constexpr int MOD = 1e9 + 7;

constexpr int inf = 1e9;

constexpr long long INF = 1e18;



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



int dx[] = {1, 0, -1, 0};

int dy[] = {0, 1, 0, -1};



int n;



void solve(string s, int kinds){

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

        cout << s << endl;

    }

    else{

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

            solve(s + (char)('a' + i), max(i + 1, kinds));

        }

    }

}



int main(){

    cin.tie(0);

    ios::sync_with_stdio(false);



    cin>>n;



    solve("", 0);



    return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

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

#define sz(x) int(x.size())

typedef long long ll;

typedef pair<int,int> P;



int main() {

  int n;

  cin >> n;



  vector<string> res;

  res.emplace_back("a");

  auto dfs = [&](auto& f, int d)->void {

    if (d == n) return ;

    int m = sz(res);

    vector<string> nres;

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

      int k = 0;

      for (int j = 0; j < d; j++) {

        k = max(k, res[i][j] - 'a');

      }

      for (int j = 0; j <= k + 1; j++) {

        nres.emplace_back(res[i] + (char)('a' + j));

      }

    }

    swap(res, nres);

    f(f, d + 1);

  };

  dfs(dfs, 1);

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

  res.erase(unique(res.begin(), res.end()), res.end());

  for (auto e : res) cout << e << endl;

  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1224377392536975x):
#include <bits/stdc++.h>

using namespace std;

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

#define sz(x) int(x.size())

typedef long long ll;

typedef pair<int,int> P;



int main() {

  int n;

  cin >> n;



  vector<string> res;

  res.emplace_back("a");

  auto dfs = [&](auto& f, int d)->void {

    if (d == n) return ;

    int m = sz(res);

    vector<string> nres;

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

      int k = 0;

      for (int j = 0; j < d; j++) {

        k = max(k, res[i][j] - 'a');

      }

      for (int j = 0; j <= k + 1; j++) {

        nres.emplace_back(res[i] + (char)('a' + j));

      }

    }

    swap(res, nres);

    f(f, d + 1);

  };

  dfs(dfs, 1); 

  /*

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

  res.erase(unique(res.begin(), res.end()), res.end());

  */

  for (auto e : res) cout << e << endl;

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

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

#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)

#define all(n) begin(n), end(n)

using ll = long long;

using P = pair<int, int>;

using vi = vector<int>;

using vl = vector<ll>;

using vs = vector<string>;

using vc = vector<char>;

using vb = vector<bool>;

using vd = vector<double>;

vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};



int main() {

  int n;

  cin >> n;

  vector<vector<vs>> a(n + 1, vector<vs>(n + 1));

  a[1][1].push_back("a");

  rep2(i, 1, n) {

    rep2(j, 1, i + 1) {

      for(auto v : a[i][j]) {

        rep2(k, 1, j + 2) {

          a[i + 1][max(k, j)].push_back(v + (char)('a' + k - 1));

        }

      }

    }

  }

  vs ans;

  rep2(j, 1, n + 1) {

    for(auto v : a[n][j]) ans.push_back(v);

  }

  sort(all(ans));

  for(auto v : ans) cout << v << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.238288344754514x):
#include <bits/stdc++.h>

using namespace std;

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

#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)

#define all(n) begin(n), end(n)

using ll = long long;

using P = pair<int, int>;

using vi = vector<int>;

using vl = vector<ll>;

using vs = vector<string>;

using vc = vector<char>;

using vb = vector<bool>;

using vd = vector<double>;

vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};



int n;



void f(string s, int i) {

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

    cout << s << endl;

    return;

  }

  rep2(j, 1, i + 2) {

    string ns = s + (char)('a' + j - 1);

    f(ns, max(i, j));

  }

}



int main() {

  cin >> n;

  f("a", 1);

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

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

#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)

#define all(n) begin(n), end(n)

using ll = long long;

using P = pair<int, int>;

using vi = vector<int>;

using vl = vector<ll>;

using vs = vector<string>;

using vc = vector<char>;

using vb = vector<bool>;

using vd = vector<double>;

vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};



int main() {

  int n;

  cin >> n;

  vector<vector<vs>> a(n + 1, vector<vs>(n + 1));

  a[1][1].push_back("a");

  rep2(i, 1, n) {

    rep2(j, 1, i + 1) {

      for(auto v : a[i][j]) {

        rep2(k, 1, j + 2) {

          a[i + 1][max(k, j)].push_back(v + (char)('a' + k - 1));

        }

      }

    }

  }

  vs ans;

  rep2(j, 1, n + 1) {

    for(auto v : a[n][j]) ans.push_back(v);

  }

  sort(all(ans));

  for(auto v : ans) cout << v << endl;

}


// Faster C++ solution for the same problem (measured speedup: 1.1318892850774767x):
#include <bits/stdc++.h>

using namespace std;

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

#define rep2(i, x, n) for(ll i = x, i##_len = (n); i < i##_len; ++i)

#define all(n) begin(n), end(n)

using ll = long long;

using P = pair<ll, ll>;

using vi = vector<int>;

using vl = vector<ll>;

using vs = vector<string>;

using vc = vector<char>;

using vb = vector<bool>;

using vd = vector<double>;

vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};



ll t(string s) {

  set<char> st;

  for(char c : s) st.insert(c);

  return st.size();

}



vs dfs(ll n) {

  if(n == 1) return {"a"};

  vs ss = dfs(n - 1);

  vs res;

  for(auto s : ss) {

    ll m = t(s) + 1;

    rep(i, m) res.push_back(s + char(i + 'a'));

  }

  return res;

}



int main() {

  ll n;

  cin >> n;

  vs ans = dfs(n);

  for(auto v : ans) cout << v << '\n';

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<string>

#include<algorithm>



std::vector<std::string> ans;



void rec(std::string str, char max_c, int n) {

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

		ans.push_back(str);

		return;

	}

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

		str.push_back(c);

		if (c == max_c + 1) rec(str, max_c + 1, n);

		else rec(str, max_c, n);

		str.pop_back();

	}

}



int main(void) {

	int n;

	std::cin >> n;



	rec("a", 'a', n);



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



	for (int i = 0; i < ans.size(); ++i) std::cout << ans[i] << std::endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.1109673757596636x):
#include<iostream>

#include<vector>

#include<string>

#include<algorithm>



std::vector<std::string> ans;



void rec(std::string str, char max_c, int n) {

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

		ans.push_back(str);

		return;

	}

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

		str.push_back(c);

		if (c == max_c + 1) rec(str, max_c + 1, n);

		else rec(str, max_c, n);

		str.pop_back();

	}

}



int main(void) {

	int n;

	std::cin >> n;



	rec("a", 'a', n);



	for (int i = 0; i < ans.size(); ++i) std::cout << ans[i] << std::endl;

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<vector>

#include<string>

#include<algorithm>



std::vector<std::string> ans;



void rec(std::string str, char max_c, int n) {

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

		ans.push_back(str);

		return;

	}

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

		str.push_back(c);

		if (c == max_c + 1) rec(str, max_c + 1, n);

		else rec(str, max_c, n);

		str.pop_back();

	}

}



int main(void) {

	int n;

	std::cin >> n;



	rec("a", 'a', n);



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



	for (int i = 0; i < ans.size(); ++i) std::cout << ans[i] << std::endl;

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.108027913665761x):
#include<iostream>

#include<vector>

#include<string>

#include<algorithm>



std::vector<std::string> ans;



void rec(std::string str, char max_c, int n) {

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

		ans.push_back(str);

		return;

	}

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

		str.push_back(c);

		rec(str, max_c + (c == max_c + 1), n);

		str.pop_back();

	}

}



int main(void) {

	int n;

	std::cin >> n;



	rec("a", 'a', n);



	for (int i = 0; i < ans.size(); ++i) std::cout << ans[i] << '\n';

	return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

using ll = long long;



void main_()

{

    ll N;

    cin >> N;



    queue<pair<string, char>> que;

    que.emplace("a", 'a');



    while ((ll)que.front().first.size() <= N) {

        auto s = que.front();

        que.pop();

        if ((ll)s.first.size() == N) {

            cout << s.first << "\n";

        }

        for (auto ch = 'a'; ch <= s.second; ch++) {

            que.emplace(s.first + ch, s.second);

        }

        que.emplace(s.first + (char)(s.second + 1), s.second + 1);

    }

}

int main()

{

    cin.tie(nullptr);

    cout.tie(nullptr);

    ios_base::sync_with_stdio(false);

    main_();

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.172258321920071x):
#include <bits/stdc++.h>

using namespace std;

using ll = long long;



void main_()

{

    ll N;

    cin >> N;



    queue<pair<string, char>> que;

    que.emplace("a", 'a');



    while (!que.empty()) {

        auto s = que.front();

        que.pop();

        if ((ll)s.first.size() == N) {

            cout << s.first << "\n";

        } else {

            for (auto ch = 'a'; ch <= s.second; ch++) {

                que.emplace(s.first + ch, s.second);

            }

            que.emplace(s.first + (char)(s.second + 1), s.second + 1);

        }

    }

}

int main()

{

    cin.tie(nullptr);

    cout.tie(nullptr);

    ios_base::sync_with_stdio(false);

    main_();

    return 0;

}
// Slower C++ solution:
#include <iostream>

#include <sstream>

#include <algorithm>

#include <functional>

#include <iterator>

#include <numeric>

#include <cstdint>

#include <cmath>

#include <bitset>

#include <string>

#include <list>

#include <vector>

#include <stack>

#include <queue>

#include <set>

#include <map>



#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )

#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )



using namespace std;



int main()

{

  uint64_t N;

  cin >> N;



  queue<pair<string, uint64_t>> q;

  q.emplace("a", 1);

  vector<string> v;

  while (!q.empty()) {

    pair<string, uint64_t> p = q.front(); q.pop();

    string s = p.first;

    uint64_t k = p.second;



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

      v.emplace_back(s);

      continue;

    }



    N_TIMES(i, k) {

      char c = 'a' + i;

      q.emplace(s + c, k);

    }

    {

      char c = 'a' + k;

      q.emplace(s + c, k + 1);

    }

  }



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



  for (string s : v) {

    cout << s << endl;

  }



  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1720238090870188x):
#include <iostream>

#include <sstream>

#include <algorithm>

#include <functional>

#include <iterator>

#include <numeric>

#include <cstdint>

#include <cmath>

#include <bitset>

#include <string>

#include <list>

#include <vector>

#include <stack>

#include <queue>

#include <set>

#include <map>



#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )

#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )



using namespace std;



int main()

{

  uint64_t N;

  cin >> N;



  queue<pair<string, uint64_t>> q;

  q.emplace("a", 1);

  while (!q.empty()) {

    pair<string, uint64_t> p = q.front(); q.pop();

    string s = p.first;

    uint64_t k = p.second;



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

      cout << s << endl;

      continue;

    }



    N_TIMES(i, k) {

      char c = 'a' + i;

      q.emplace(s + c, k);

    }

    {

      char c = 'a' + k;

      q.emplace(s + c, k + 1);

    }

  }



  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

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

#define COUT(x) cout<<(x)<<"\n"

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

#define YES(x) cout<<(x?"YES":"NO")<<"\n"

#define Yes(x) cout<<(x?"Yes":"No")<<"\n"

#define dump(x) cout<<#x<<" = "<<(x)<<"\n"

#define endl "\n"

using G = vector<vector<int>>;

using M = map<int,int>;

using P = pair<int,int>;

using PQ = priority_queue<int>;

using PQG = priority_queue<int,vector<int>,greater<int>>;

using V = vector<int>;

using ll = long long;

using edge = struct { int to; int cost; };

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1e9;

const int MOD = 1e9+7;

const ll LINF = 1e18;



int n;

vector<string> ans;



void dfs(string s = "", int m = 0) {

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

    ans.push_back(s); return;

  }



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

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

    int nm = i == m ? m + 1 : m;

    dfs(ns, nm);

  }

}



int main() {

  IOS;

  cin >> n;



  dfs();

  sort(ALL(ans));

  REP(i,ans.size()) COUT(ans[i]);



  return 0;

}

// Faster C++ solution for the same problem (measured speedup: 1.1868381864518638x):
#include <bits/stdc++.h>

using namespace std;

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

#define COUT(x) cout<<(x)<<"\n"

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

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

#define YES(x) cout<<(x?"YES":"NO")<<"\n"

#define Yes(x) cout<<(x?"Yes":"No")<<"\n"

#define dump(x) cout<<#x<<" = "<<(x)<<"\n"

#define endl "\n"

using G = vector<vector<int>>;

using M = map<int,int>;

using P = pair<int,int>;

using PQ = priority_queue<int>;

using PQG = priority_queue<int,vector<int>,greater<int>>;

using V = vector<int>;

using ll = long long;

using edge = struct { int to; int cost; };

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const int INF = 1e9;

const int MOD = 1e9+7;

const ll LINF = 1e18;



int n;



void dfs(string s = "", char mx = 'a') {

  if (s.size() == n) { COUT(s); return; }



  int p = mx-'a';

  REP(i,p+1) {

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

    char nmx = (char)('a' + p+(i==p));

    dfs(ns, nmx);

  }

}



int main() {

  IOS;

  cin >> n;

  dfs();

  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;



vector<string> ans;

int n;



void f(string s, int i, int k)

{

  if (i == n) {

    ans.push_back(s);

    return;

  }

  int num = s[i-1] - 'a';

  k = max(k, num+1);

  for (int j=0; j<k+1; j++) {

    f(s, i+1, k);

    s[i]++;

  }

}



int main()

{

  cin >> n;

  string s = "";

  rep(i, n) s.push_back('a');

  f(s, 1, 1);

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

  for (auto v:ans) {

    cout << v << endl;

  }



  return 0;

}


// Faster C++ solution for the same problem (measured speedup: 1.193638852894787x):
#include <bits/stdc++.h>

using namespace std;

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

typedef long long ll;



vector<string> ans;

int n;



void f(string s, int i, int k)

{

  if (i == n) {

    cout << s << endl;

    return;

  }

  int num = s[i-1] - 'a';

  k = max(k, num+1);

  for (int j=0; j<k+1; j++) {

    f(s, i+1, k);

    s[i]++;

  }

}



int main()

{

  cin >> n;

  string s = "";

  rep(i, n) s.push_back('a');

  f(s, 1, 1);

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

  // for (auto v:ans) {

  //   cout << v << endl;

  // }



  return 0;

}
// Slower C++ solution:
#include <bits/stdc++.h>

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

using namespace std;

typedef unsigned long long ull;

typedef long long ll;

const int MOD=1e9+7;

const double pi=acos(-1);





int main(){

  int n;

  cin >> n;

  vector<string>ans;

  queue<string>que;

  que.emplace("a");

  while(!que.empty()){

    string t=que.front();

    que.pop();

    int m=t.size();

    if(m==n){

      ans.push_back(t);

    }

    else{

      char c=*max_element(t.begin(),t.end());

      c++;

      for(auto d='a';d<=c;d++){

        string s=t+d;

        que.emplace(s);

      }

    }

  }

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

  ans.erase(unique(ans.begin(),ans.end()),ans.end());

  rep(i,ans.size()){

    cout << ans[i] << endl;

  }

  

}


// Faster C++ solution for the same problem (measured speedup: 1.2117851610466388x):
#include <bits/stdc++.h>

#define exrep(i, a, b) for(long long i = a; i <= b; i++)

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

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

#define rall(a) a.rbegin(), a.rend()

using namespace std;

typedef unsigned long long ull;

typedef long long ll;

typedef long double ld;

typedef pair<ll, ll> P;

typedef vector<ll> vl;

typedef vector<string> vs;

typedef vector<P> vp;

typedef vector<vector<ll> > vvl;

typedef vector<vector<P> > vvp;

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

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

 

const ll MOD=1e9+7;

const ll INF=1e18;

const int MAX=510000;

const double pi=acos(-1);

int dx[4]={1,0,-1,0};

int dy[4]={0,1,0,-1};



int n;



void dfs(string &s,char mx){

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

    cout << s << endl;

    return ;

  }

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

    string t=s+c;

    dfs(t,max(mx,c));

  }

}

  



int main(){

  cin.tie(0);

  ios::sync_with_stdio(false); 

  

  cin >> n;

  string s="";

  dfs(s,'a'-1);

  return 0;     

}