Language: C++

#include <algorithm>
#include <cmath>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cassert>
#include <functional>

using namespace std;

#define LOG(...) printf(__VA_ARGS__)
//#define LOG(...)
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define CLR(a) memset((a), 0 ,sizeof(a))

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

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

struct UnionFind {
	vector<int> v;
	UnionFind(int n) : v(n) { for (int i = 0; i < n; i++) v[i] = i; }
	int  find(int x) { return v[x] == x ? x : v[x] = find(v[x]); }
	void unite(int x, int y) { v[find(x)] = find(y); }
};
bool cal(string &s, int &idx) {
	bool res = true;
	bool sub = false;
	while (idx < (int)s.length()) {
		if (s[idx] == '(') {
			idx++;
			if (sub)
				return !cal(s, idx);
			else
				return cal(s, idx);
		}
		if (s[idx] == '-') {
			sub = !sub;
			idx++;
		}
		if (s[idx] == 'T' || s[idx] == 'F') {
			bool st1 = ((s[idx] == 'T' && !sub) || (s[idx] == 'F' && sub));
			idx++;
			sub = false;
			int calc;
			if (s[idx] == '*')
				calc = 0;
			if (s[idx] == '+')
				calc = 1;
			if (s[idx] == '>')
				calc = 2;
			idx++;
			if (s[idx] == '-') {
				sub = !sub;
				idx++;
			}
			bool st2;
			if (s[idx] == 'T' || s[idx] == 'F') {
				st2 = ((s[idx] == 'T' && !sub) || (s[idx] == 'F' && sub));
			}
			else {
				idx++;
				st2 = cal(s, idx);
			}
			if (calc == 0)
				res = (st1&&st2);
			if (calc == 1)
				res = (st1 || st2);
			if (calc == 2)
				res = !(st1 && !st2);
			idx++;
			return res;
		}
		if (s[idx] == ')') {
			idx++;
			return res;
		}
	}
	return res;
}

int main() {
	string s;
	while (cin >> s, s != "#") {
		string ans = "YES";
		auto pos = s.find("->");
		while (pos != string::npos) {
			s.replace(pos, 2, ">");
			pos = s.find("->", pos + 1);
		}
		pos = s.find("--");
		while (pos != string::npos) {
			s.replace(pos, 2, "");
			pos = s.find("--", pos + 1);
		}
		int eq;
		REP(k, s.length())
			if (s[k] == '=')
				eq = k;

		REP(i, 2048) {
			string s2 = s;
			REP(j, 11) {
				REP(k, s2.length()) {
					if (s2[k] == 'a' + j)
						if ((i >> j) & 1) {
							s2[k] = 'T';
						}
						else {
							s2[k] = 'F';
						}
				}
			}
			int idx1 = 0, idx2 = 0;
			if (cal((string)s2.substr(0, eq), idx1) != cal((string)s2.substr(eq + 1, s2.length() - eq - 1), idx2)) {
				ans = "NO";
				break;
			}
		}
		cout << ans << endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:141:33: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
  141 |                         if (cal((string)s2.substr(0, eq), idx1) != cal((string)s2.substr(eq + 1, s2.length() - eq - 1), idx2)) {
      |                                 ^~~~~~~~~~~~~~~~~~~~~~~~
a.cc:52:18: note:   initializing argument 1 of 'bool cal(std::string&, int&)'
   52 | bool cal(string &s, int &idx) {
      |          ~~~~~~~~^
a.cc:141:72: error: cannot bind non-const lvalue reference of type 'std::string&' {aka 'std::__cxx11::basic_string<char>&'} to an rvalue of type 'std::__cxx11::basic_string<char>'
  141 |                         if (cal((string)s2.substr(0, eq), idx1) != cal((string)s2.substr(eq + 1, s2.length() - eq - 1), idx2)) {
      |                                                                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:52:18: note:   initializing argument 1 of 'bool cal(std::string&, int&)'
   52 | bool cal(string &s, int &idx) {
      |          ~~~~~~~~^