Language: C++

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

int n, m, k;

inline void input (int &ret) {
	ret = 0; char ch = getchar ();
	while (!isdigit (ch)) ch = getchar ();
	while (isdigit (ch)) {
		ret = (ret << 1) + (ret << 3) + (ch ^ '0');
		ch = getchar ();
	}
	return;
}

char ch[7][7];
bool vis[7], visit[7];
char change[7][7];
int ans;

inline void dfs (int now) {
	if (now == n + m + 1) {
		for (register int i = 1; i <= n; ++ i) {
			for (register int j = 1; j <= m; ++ j) change[i][j] = ch[i][j];
		}
		int cnt = 0;
		for (register int i = 1; i <= n; ++ i) {
			for (register int j = 1; j <= m; ++ j) {
				if (vis[i] || visit[j]) change[i][j] = '.';
			}
		}
		for (register int i = 1; i <= n; ++ i) {
			for (register int j = 1; j <= m; ++ j) cnt += (change[i][j] == '#');
		}
		if (cnt == k) ++ ans;
		return;
	}
	if (now > n) {
		visit[now - n] = true; dfs (now + 1);
		visit[now - n] = false; dfs (now + 1);
		return;
	}
	if (now <= n) {
		vis[now] = true; dfs (now + 1);
		vis[now] = false; dfs (now + 1);
		return;
	}
}

int main () {
	cin >> n >> m >> k;
	for (register int i = 1; i <= n; ++ i) {
		for (register int j = 1; j <= m; ++ j) cin >> ch[i][j];
	}
	dfs (1);
	cout << ans << endl;
	return 0;
}

Compiler output:
a.cc: In function 'void dfs(int)':
a.cc:23:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   23 |                 for (register int i = 1; i <= n; ++ i) {
      |                                   ^
a.cc:24:43: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   24 |                         for (register int j = 1; j <= m; ++ j) change[i][j] = ch[i][j];
      |                                           ^
a.cc:27:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   27 |                 for (register int i = 1; i <= n; ++ i) {
      |                                   ^
a.cc:28:43: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   28 |                         for (register int j = 1; j <= m; ++ j) {
      |                                           ^
a.cc:29:47: error: reference to 'visit' is ambiguous
   29 |                                 if (vis[i] || visit[j]) change[i][j] = '.';
      |                                               ^~~~~
In file included from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:80,
                 from a.cc:1:
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:17:14: note:                 'bool visit [7]'
   17 | bool vis[7], visit[7];
      |              ^~~~~
a.cc:32:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   32 |                 for (register int i = 1; i <= n; ++ i) {
      |                                   ^
a.cc:33:43: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   33 |                         for (register int j = 1; j <= m; ++ j) cnt += (change[i][j] == '#');
      |                                           ^
a.cc:39:17: error: reference to 'visit' is ambiguous
   39 |                 visit[now - n] = true; dfs (now + 1);
      |                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:17:14: note:                 'bool visit [7]'
   17 | bool vis[7], visit[7];
      |              ^~~~~
a.cc:40:17: error: reference to 'visit' is ambiguous
   40 |                 visit[now - n] = false; dfs (now + 1);
      |                 ^~~~~
/usr/include/c++/14/variant:1855:5: note: candidates are: 'template<class _Visitor, class ... _Variants> constexpr std::__detail::__variant::__visit_result_t<_Visitor, _Variants ...> std::visit(_Visitor&&, _Variants&& ...)'
 1855 |     visit(_Visitor&& __visitor, _Variants&&... __variants)
      |     ^~~~~
a.cc:17:14: note:                 'bool visit [7]'
   17 | bool vis[7], visit[7];
      |              ^~~~~
a.cc: In function 'int main()':
a.cc:52:27: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   52 |         for (register int i = 1; i <= n; ++ i) {
      |                           ^
a.cc:53:35: warning: ISO C++17 does not allow 'register' storage class specifier [-Wregister]
   53 |                 for (register int j = 1; j <= m; ++ j) cin >> ch[i][j];
      |                                   ^