Language: C++

#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())

string s;
string p;


int index = 0;
int parse() {
	if (isalpha(s[index])) {
		return p[s[index++] - 'a'] - '0';
	}
	else {
		int x, y;
		index++;
		char op = s[index++];
		x = parse();
		y = parse();
		index++;
		if (op == '+')return x | y;
		else if (op == '*')return x & y;
		else return x^y;
	}
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);


	

	while(cin>>s>>p){
		int ans = 0;
		index = 0;
		int h = parse();
		rep(x, 10000) {
			p[0] = x / 1 % 10 + '0';
			p[1] = x / 10 % 10 + '0';
			p[2] = x / 100 % 10 + '0';
			p[3] = x / 1000 % 10 + '0';
			index = 0;

			int g = parse();
			if (h == g)ans++;
		}

		cout << h << ' ' << ans << endl;
	}



	return 0;
}


Compiler output:
a.cc:33:5: error: 'int index' redeclared as different kind of entity
   33 | int index = 0;
      |     ^~~~~
In file included from /usr/include/string.h:462,
                 from /usr/include/c++/14/cstring:43,
                 from a.cc:6:
/usr/include/strings.h:50:20: note: previous declaration 'const char* index(const char*, int)'
   50 | extern const char *index (const char *__s, int __c)
      |                    ^~~~~
a.cc: In function 'int parse()':
a.cc:35:22: error: no match for 'operator[]' (operand types are 'std::string' {aka 'std::__cxx11::basic_string<char>'} and '<unresolved overloaded function type>')
   35 |         if (isalpha(s[index])) {
      |                      ^
In file included from /usr/include/c++/14/string:54,
                 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:2:
/usr/include/c++/14/bits/basic_string.h:1247:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; const_reference = const char&; size_type = long unsigned int]'
 1247 |       operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1247:29: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
 1247 |       operator[] (size_type __pos) const _GLIBCXX_NOEXCEPT
      |                   ~~~~~~~~~~^~~~~
/usr/include/c++/14/bits/basic_string.h:1265:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::reference std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::operator[](size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; reference = char&; size_type = long unsigned int]'
 1265 |       operator[](size_type __pos)
      |       ^~~~~~~~
/usr/include/c++/14/bits/basic_string.h:1265:28: note:   no known conversion for argument 1 from '<unresolved overloaded function type>' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
 1265 |       operator[](size_type __pos)
      |                  ~~~~~~~~~~^~~~~
a.cc:36:33: error: no post-increment operator for type
   36 |                 return p[s[index++] - 'a'] - '0';
      |                                 ^~
a.cc:40:22: error: no post-increment operator for type
   40 |                 index++;
      |                      ^~
a.cc:41:34: error: no post-increment operator for type
   41 |                 char op = s[index++];
      |                                  ^~
a.cc:44:22: error: no post-increment operator for type
   44 |                 index++;
      |                      ^~
a.cc: In function 'int main()':
a.cc:61:25: error: overloaded function with no contextual type information
   61 |                 index = 0;
      |                         ^
a.cc:68:33: error: overloaded function with no contextual type information
   68 |                         index = 0;
      |                                 ^