Language: C++

#include<iostream>
#include<vector>
#include<map>
#include<set>
using namespace std;

map<string, vector<string>> word;
set<int> size;

string stoi(const string& str) {
    string result = "";
    for(const auto& c: str) {
        if('a' <= c && c <= 'o') result += (c - 'a') / 3 + '2';
        if('p' <= c && c <= 's') result += '7';
        if('t' <= c && c <= 'v') result += '8';
        if('w' <= c && c <= 'z') result += '9';
    }
    return result;
}

void dfs(string str, vector<string>& list) {
    if(str.empty()) {
        for(int i = 0; i < list.size(); ++i) cout << (i ? " " : "") << list[i];
        cout << "." << endl;
    }

    for(const auto& s: size) {
        if(str.size() < s) break;
        if(!word.count(str.substr(0, s))) continue;
        for(const auto& w: word[str.substr(0, s)]) {
            list.push_back(w);
            dfs(str.substr(s), list);
            list.pop_back();
        }
    }
}

int main() {
    int n;
    while(cin >> n, n) {
        word.clear();
        size.clear();
        for(int i = 0; i < n; ++i) {
            string s;
            cin >> s;
            word[stoi(s)].push_back(s);
            size.insert(s.size());
        }
        vector<string> list;
        string str;
        cin >> str;
        dfs(str, list);
        cout << "--" << endl;
    }
}

Compiler output:
a.cc: In function 'void dfs(std::string, std::vector<std::__cxx11::basic_string<char> >&)':
a.cc:27:24: error: reference to 'size' is ambiguous
   27 |     for(const auto& s: size) {
      |                        ^~~~
In file included from /usr/include/c++/14/string:53,
                 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/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:8:10: note:                 'std::set<int> size'
    8 | set<int> size;
      |          ^~~~
a.cc: In function 'int main()':
a.cc:42:9: error: reference to 'size' is ambiguous
   42 |         size.clear();
      |         ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:8:10: note:                 'std::set<int> size'
    8 | set<int> size;
      |          ^~~~
a.cc:46:22: error: call of overloaded 'stoi(std::string&)' is ambiguous
   46 |             word[stoi(s)].push_back(s);
      |                  ~~~~^~~
a.cc:10:8: note: candidate: 'std::string stoi(const std::string&)'
   10 | string stoi(const string& str) {
      |        ^~~~
In file included from /usr/include/c++/14/string:54:
/usr/include/c++/14/bits/basic_string.h:4164:3: note: candidate: 'int std::__cxx11::stoi(const std::string&, std::size_t*, int)'
 4164 |   stoi(const string& __str, size_t* __idx = 0, int __base = 10)
      |   ^~~~
a.cc:47:13: error: reference to 'size' is ambiguous
   47 |             size.insert(s.size());
      |             ^~~~
/usr/include/c++/14/bits/range_access.h:272:5: note: candidates are: 'template<class _Tp, long unsigned int _Nm> constexpr std::size_t std::size(const _Tp (&)[_Nm])'
  272 |     size(const _Tp (&)[_Nm]) noexcept
      |     ^~~~
/usr/include/c++/14/bits/range_access.h:262:5: note:                 'template<class _Container> constexpr decltype (__cont.size()) std::size(const _Container&)'
  262 |     size(const _Container& __cont) noexcept(noexcept(__cont.size()))
      |     ^~~~
a.cc:8:10: note:                 'std::set<int> size'
    8 | set<int> size;
      |          ^~~~