Language: C++

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))

typedef long long lint;
typedef pair<int, int> pii;

int n;
string group[110];

vector<string> split_all(string s, string t) {
	vector<string> res;
	for (int p = 0; (p = s.find(t)) != -1;) {
		res.push_back(s.substr(0, p));
		s = s.substr(p + (int)t.size());
	}
	res.push_back(s);
	return res;
}

string gname[110];
string member[110];
int link[110][110];

string rec(int i) {
	string res = member[i];
	
	for_(j,0,n) {
		if (link[i][j] != -1) {
			string add = rec(j);
			int p = res.find(gname[j]);
			res = res.substr(0, p) + add + res.substr(p + (int)gname[j].size());
		}
	}
	
	return res;
}

void solve() {
	for_(i,0,n) {
		vector<string> split = split_all(group[i], ":");
		gname[i] = split[0];
		member[i] = split[1].substr(0, (int)split[1].size() - 1);
	}
	
	minit(link, -1);
	for_(i,0,n) for_(j,0,n) {
		if (i == j) continue;
		link[i][j] = member[i].find(gname[j]);
	}
	/*
	for_(i,0,n) {
		for_(j,0,n) cout << link[i][j] << "  ";
		cout << endl;
	}
	*/
	
	string all_member = rec(0);
	//cout << all_member << endl;
	vector<string> split_member = split_all(all_member, ",");
	
	set<string> ans;
	int m_size = (int)split_member.size();
	for_(i,0,m_size) {
		ans.insert(split_member[i]);
	}
	
	cout << ans.size() << endl;
}

int main() {
	while (cin >> n , n) {
		for_(i,0,n) cin >> group[i];
		solve();
	}
	return 0;
}

Compiler output:
a.cc:26:18: error: 'int link [110][110]' redeclared as different kind of entity
   26 | int link[110][110];
      |                  ^
In file included from /usr/include/x86_64-linux-gnu/bits/sigstksz.h:24,
                 from /usr/include/signal.h:328,
                 from /usr/include/c++/14/csignal:42,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:116,
                 from a.cc:1:
/usr/include/unistd.h:819:12: note: previous declaration 'int link(const char*, const char*)'
  819 | extern int link (const char *__from, const char *__to)
      |            ^~~~
a.cc: In function 'std::string rec(int)':
a.cc:32:27: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   32 |                 if (link[i][j] != -1) {
      |                           ^
a.cc:32:30: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   32 |                 if (link[i][j] != -1) {
      |                              ^
a.cc:32:32: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
   32 |                 if (link[i][j] != -1) {
      |                     ~~~~~~~~~~~^~~~~
a.cc: In function 'void solve()':
a.cc:49:15: error: ISO C++ forbids applying 'sizeof' to an expression of function type [-fpermissive]
   49 |         minit(link, -1);
      |               ^
a.cc:6:38: note: in definition of macro 'minit'
    6 | #define minit(a,b) memset(a,b,sizeof(a))
      |                                      ^
a.cc:49:15: error: invalid conversion from 'int (*)(const char*, const char*) noexcept' to 'void*' [-fpermissive]
   49 |         minit(link, -1);
      |               ^~~~
      |               |
      |               int (*)(const char*, const char*) noexcept
a.cc:6:27: note: in definition of macro 'minit'
    6 | #define minit(a,b) memset(a,b,sizeof(a))
      |                           ^
In file included from /usr/include/c++/14/cstring:43,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:121:
/usr/include/string.h:61:28: note:   initializing argument 1 of 'void* memset(void*, int, size_t)'
   61 | extern void *memset (void *__s, int __c, size_t __n) __THROW __nonnull ((1));
      |                      ~~~~~~^~~
a.cc:52:23: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                 link[i][j] = member[i].find(gname[j]);
      |                       ^
a.cc:52:26: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   52 |                 link[i][j] = member[i].find(gname[j]);
      |                          ^
a.cc:52:28: error: assignment of read-only location '*(link + (((sizetype)i) + ((sizetype)j)))'
   52 |                 link[i][j] = member[i].find(gname[j]);
      |                 ~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~