#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, int s>using va = vector<array<T, s>>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define rrep(i,a) for(int i=a-1;i>=0;i--)
#define rrep1(i,a) for(int i=a;i;i--)
const ll mod = 1000000007;
#define REP rep
template<class T>using heap = priority_queue<T, vector<T>, greater<T>>;
template<class T>using pque = priority_queue<T, vector<T>, function<T(T, T)>>;
template <class T>
inline void hash_combine(size_t & seed, const T & v) {
	hash<T> hasher;
	seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
namespace std {
	template<typename S, typename T> struct hash<pair<S, T>> {
		inline size_t operator()(const pair<S, T> & v) const {
			size_t seed = 0;
			hash_combine(seed, v.first);
			hash_combine(seed, v.second);
			return seed;
		}
	};
	// Recursive template code derived from Matthieu M.
	template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1>
	struct HashValueImpl{
		static void apply(size_t& seed, Tuple const& tuple){
			HashValueImpl<Tuple, Index - 1>::apply(seed, tuple);
			hash_combine(seed, std::get<Index>(tuple));
		}
	};
	template <class Tuple>
	struct HashValueImpl<Tuple, 0>{
		static void apply(size_t& seed, Tuple const& tuple){
			hash_combine(seed, std::get<0>(tuple));
		}
	};
	template <typename ... TT>
	struct hash<std::tuple<TT...>>{
		size_t operator()(std::tuple<TT...> const& tt) const{
			size_t seed = 0;
			HashValueImpl<std::tuple<TT...> >::apply(seed, tt);
			return seed;
		}
	};
}
template<class T>int id(vector<T> &a, T b) {
	return lower_bound(ALL(a), b) - a.begin();
}
//end of lib
int main() {
	string s;
	cin >> s;
	queue<string> que;
	que.push(s);
	string c = "ABC";
	while (!que.empty()) {
		auto s = que.front(); que.pop();
		if (s.size() <= 3) {
			if (s == "ABC") {
				cout << "Yes" << endl;
				return 0;
			}
			else continue;
		}
		rep(k, 3){
			string t;
			int r = 0;
			int n = 0;
			int m = 0;
			for (auto x : s) {
				if (x == c[m])m++;
				else if (x == 'A')m = 1;
				else m = 0;
				if (x == c[k])n++;
				if (m == 3) {
					t.pop_back();
					t.pop_back();
					t.push_back(c[k]);
					r++;
					m = 0;
				}
				else t.push_back(x);
			}
			if (r) {
				if (r == n)que.push(t);
			}
			else break;
		}
	}
	cout << "No" << endl;
}
### Prompt

Please provide a Cpp coded solution to the problem described below:

ABC Gene

There is a gene sequence represented by the string `ABC`. You can rewrite this gene sequence by performing the following operations several times.

* Choose one of the letters `A`,` B`, `C`. Let this be x. Replace all x in the gene sequence with `ABC` at the same time.



Given a string S consisting only of `A`,` B`, and `C`. Determine if the gene sequence can be matched to S.

Constraints

* 1 ≤ | S | ≤ 5,000
* S consists only of `A`,` B`, and `C`.



Input Format

Input is given from standard input in the following format.


S


Output Format

Output `Yes` if the gene sequence can be matched to S, and` No` if it cannot be matched.

Sample Input 1


ABC


Sample Output 1


Yes


The gene sequence is `ABC` from the beginning.

Sample Input 2


AABCC


Sample Output 2


Yes


If you select `B` and perform the operation, it becomes` ABC` → `AABCC`.

Sample Input 3


AABCABC


Sample Output 3


No


For example, even if you select `C` and perform an operation, it does not change from` AABCC` to `AABCABC`. Since all `C`s are replaced with` ABC` at the same time, the actual result is `AABCC` →` AABABCABC`.





Example

Input

ABC


Output

Yes

### Response

```cpp
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
//cin.sync_with_stdio(false);
//streambuf
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<double, double> pdd;
using vi = vector<int>;
using vll = vector<ll>;
using vpii = vector<pii>;
using ti3 = tuple<int, int, int>;
using vti3 = vector<ti3>;
template<class T, int s>using va = vector<array<T, s>>;
template<class T, class T2> using umap = unordered_map<T, T2>;
template<class T> using uset = unordered_set<T>;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define ALL(a) a.begin(),a.end()
#define rep(i,a) for(int i=0;i<a;i++)
#define rep1(i,a) for(int i=1;i<=a;i++)
#define rrep(i,a) for(int i=a-1;i>=0;i--)
#define rrep1(i,a) for(int i=a;i;i--)
const ll mod = 1000000007;
#define REP rep
template<class T>using heap = priority_queue<T, vector<T>, greater<T>>;
template<class T>using pque = priority_queue<T, vector<T>, function<T(T, T)>>;
template <class T>
inline void hash_combine(size_t & seed, const T & v) {
	hash<T> hasher;
	seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
}
namespace std {
	template<typename S, typename T> struct hash<pair<S, T>> {
		inline size_t operator()(const pair<S, T> & v) const {
			size_t seed = 0;
			hash_combine(seed, v.first);
			hash_combine(seed, v.second);
			return seed;
		}
	};
	// Recursive template code derived from Matthieu M.
	template <class Tuple, size_t Index = std::tuple_size<Tuple>::value - 1>
	struct HashValueImpl{
		static void apply(size_t& seed, Tuple const& tuple){
			HashValueImpl<Tuple, Index - 1>::apply(seed, tuple);
			hash_combine(seed, std::get<Index>(tuple));
		}
	};
	template <class Tuple>
	struct HashValueImpl<Tuple, 0>{
		static void apply(size_t& seed, Tuple const& tuple){
			hash_combine(seed, std::get<0>(tuple));
		}
	};
	template <typename ... TT>
	struct hash<std::tuple<TT...>>{
		size_t operator()(std::tuple<TT...> const& tt) const{
			size_t seed = 0;
			HashValueImpl<std::tuple<TT...> >::apply(seed, tt);
			return seed;
		}
	};
}
template<class T>int id(vector<T> &a, T b) {
	return lower_bound(ALL(a), b) - a.begin();
}
//end of lib
int main() {
	string s;
	cin >> s;
	queue<string> que;
	que.push(s);
	string c = "ABC";
	while (!que.empty()) {
		auto s = que.front(); que.pop();
		if (s.size() <= 3) {
			if (s == "ABC") {
				cout << "Yes" << endl;
				return 0;
			}
			else continue;
		}
		rep(k, 3){
			string t;
			int r = 0;
			int n = 0;
			int m = 0;
			for (auto x : s) {
				if (x == c[m])m++;
				else if (x == 'A')m = 1;
				else m = 0;
				if (x == c[k])n++;
				if (m == 3) {
					t.pop_back();
					t.pop_back();
					t.push_back(c[k]);
					r++;
					m = 0;
				}
				else t.push_back(x);
			}
			if (r) {
				if (r == n)que.push(t);
			}
			else break;
		}
	}
	cout << "No" << endl;
}
```