Problem:
Problem A:
CatChecker
外見からねこかどうかわからない動物がいる. あなたは, 鳴き声がねこの鳴き声であればねこであり, そうでなければうさぎであると判定することにした.
ねこの鳴き声は次のように定義される.
"" (empty string) はねこの鳴き声である.
$X$, $Y$ がねこの鳴き声であれば 'm' + $X$ + 'e' + $Y$ + 'w' は猫の鳴き声である. ただし + は文字列の連結を表す.
以上で定義されるものだけがねこの鳴き声である.
BNF で表すとねこの鳴き声 $CAT$ は
$CAT$ := "" (empty string) $|$ 'm' + $CAT$ + 'e' + $CAT$ + 'w'
と定義される.
鳴き声を表す文字列 $S$ が与えられる. 鳴き声から動物が何であるか判定せよ.
Constraints
$S$ will contain between 1 and 500 characters, inclusive. Each character in $S$ will be 'm', 'e' or 'w'.
Input
入力は以下の形式で与えられる:
$S$
Output
$S$ が猫の鳴き声であれば "Cat", そうでなければ "Rabbit" と1 行に出力せよ.
Sample Input 1
mmemewwemeww
Sample Output 1
Cat
Sample Input 2
mewmew
Sample Output 2
Rabbit

Submitted solutions:

code_snippet: #include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;

int N;
string S;
map<pair<int, int>, int> mp;

bool is(int s, int t) {
	if (s == t) return true;
	if (t - s < 3 || S[s] != 'm' || S[t - 1] != 'w') return false;

	P p(s, t);
	int r = mp[p];
	if (r) return r == 1 ? true : false;

	for (int i = s + 1; i < t - 1; i++) {
		if (S[i] == 'e' && is(s + 1, i) && is(i + 1, t - 1)) {
			mp[p] = 1;
			return true;
		}
	}
	mp[p] = -1;
	return false;
}

int main()
{
	cin >> S;
	N = S.size();
	cout << (is(0, N) ? "Cat" : "Rabbit") << endl;
	return 0;
}
accuracy: 1
time_ms: 30
memory_kb: 4192
final_rank: 10

code_snippet: // (⁠◕⁠ᴗ⁠◕⁠✿⁠)

// #pragma GCC target("avx2")
// #pragma GCC optimize("O3")
// #pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define srep(i, s, n) for (ll i = s; i < (n); i++)
#define len(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
using namespace std;
template<typename T> using vc = vector<T>;
template<typename T> using vv = vc<vc<T>>;
template<typename T> using vvv = vv<vc<T>>;
using vi = vc<int>;using vvi = vv<int>; using vvvi = vv<vi>;
using ll = long long;using vl = vc<ll>;using vvl = vv<ll>; using vvvl = vv<vl>;
using ld = long double; using vld = vc<ld>; using vvld = vc<vld>; using vvvld = vc<vvld>;
using uint = unsigned int;
using ull = unsigned long long;
const ld pi = 3.141592653589793;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
// const ll mod = 1000000007;
const ll mod = 998244353;
inline bool inside(ll y, ll x, ll H, ll W) {return 0 <= (y) and (y) < (H) and 0 <= (x) and (x) < (W); }

#define debug(var)  do{std::cout << #var << " : \n";view(var);}while(0)
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vc<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vv<T>& vv){ for(const auto& v : vv){ view(v); } }

int main(){
    string S; cin >> S;
    map<string, bool> memo;
    function<bool(string)> judge = [&](string S) -> bool{
        if (memo.count(S)) return memo[S];
        if (len(S) == 0) return memo[S] = true;
        if (S[0] != 'm' || S.back() != 'w') return memo[S] = false;
        rep(i, len(S) - 1) if (S[i] == 'e'){
            if (judge(S.substr(1, i - 1)) && judge(S.substr(i + 1, len(S) - i - 2))){
                return memo[S] = true;
            }
        }
        return memo[S] = false;
    };
    if (judge(S)) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
}
accuracy: 1
time_ms: 160
memory_kb: 7688
final_rank: 14

code_snippet: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using ull = unsigned long long;
typedef pair<ll,ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
template<class T> using pqmin = priority_queue<T, vector<T>, greater<T>>;
template<class T> using pqmax = priority_queue<T>;
const ll inf=LLONG_MAX/3;
const ll dx[] = {0, 1, 0, -1, 1, -1, 1, -1};
const ll dy[] = {1, 0, -1, 0, 1, 1, -1, -1};
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define si(x) ll(x.size())
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rng(i,l,r) for(ll i=l;i<r;i++)
#define gnr(i,l,r) for(ll i=r-1;i>=l;i--)
#define fore(i, a) for(auto &&i : a)
#define fore2(a, b, v) for(auto &&[a, b] : v)
#define fore3(a, b, c, v) for(auto &&[a, b, c] : v)
template<class T> bool chmin(T& a, const T& b){ if(a <= b) return 0; a = b; return 1; }
template<class T> bool chmax(T& a, const T& b){ if(a >= b) return 0; a = b; return 1; }
template<class T, class U> bool chmin(T& a, const U& b){ return chmin(a, (T)b); }
template<class T, class U> bool chmax(T& a, const U& b){ return chmax(a, (T)b); }
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,...) vector<type>name(__VA_ARGS__)
#define VEC(type,name,size) vector<type>name(size);in(name)
#define VLL(name,size) vector<ll>name(size);in(name)
#define vv(type,name,h,...) vector<vector<type>> name(h,vector<type>(__VA_ARGS__))
#define VV(type,name,h,w) vector<vector<type>> name(h,vector<type>(w));in(name)
#define vvv(type,name,h,w,...) vector<vector<vector<type>>> name(h,vector<vector<type>>(w,vector<type>(__VA_ARGS__)))
#define SUM(...) accumulate(all(__VA_ARGS__),0LL)
template<class T> auto min(const T& a){ return *min_element(all(a)); }
template<class T> auto max(const T& a){ return *max_element(all(a)); }
template<class T, class F = less<>> void sor(T& a, F b = F{}){ sort(all(a), b); }
template<class T> void uniq(T& a){ sor(a); a.erase(unique(all(a)), end(a)); }
void outb(bool x){cout<<(x?"Yes":"No")<<"\n";}
ll max(int x, ll y) { return max((ll)x, y); }
ll max(ll x, int y) { return max(x, (ll)y); }
int min(int x, ll y) { return min((ll)x, y); }
int min(ll x, int y) { return min(x, (ll)y); }
#define lb(c, x) distance((c).begin(), lower_bound(all(c), (x)))
#define lbg(c, x) distance((c).begin(), lower_bound(all(c), (x), greater{}))
#define ub(c, x) distance((c).begin(), upper_bound(all(c), (x)))
#define ubg(c, x) distance((c).begin(), upper_bound(all(c), (x), greater{}))
ll gcd(ll a,ll b){return (b?gcd(b,a%b):a);}
vector<pll> factor(ull x){ vector<pll> ans; for(ull i = 2; i * i <= x; i++) if(x % i == 0){ ans.push_back({i, 1}); while((x /= i) % i == 0) ans.back().second++; } if(x != 1) ans.push_back({x, 1}); return ans; }
vector<ll> divisor(ull x){ vector<ll> ans; for(ull i = 1; i * i <= x; i++) if(x % i == 0) ans.push_back(i); per(i,ans.size() - (ans.back() * ans.back() == x)) ans.push_back(x / ans[i]); return ans; }
vll prime_table(ll n){vec(ll,isp,n+1,1);vll res;rng(i,2,n+1)if(isp[i]){res.pb(i);for(ll j=i*i;j<=n;j+=i)isp[j]=0;}return res;}

template <class T, class S> pair<T, S> operator-(const pair<T, S> &x) { return pair<T, S>(-x.first, -x.second); }
template <class T, class S> pair<T, S> operator-(const pair<T, S> &x, const pair<T, S> &y) { return pair<T, S>(x.fi - y.fi, x.se - y.se); }
template <class T, class S> pair<T, S> operator+(const pair<T, S> &x, const pair<T, S> &y) { return pair<T, S>(x.fi + y.fi, x.se + y.se); }
template <class T> pair<T, T> operator&(const pair<T, T> &l, const pair<T, T> &r) { return pair<T, T>(max(l.fi, r.fi), min(l.se, r.se)); }
template <class T, class S> pair<T, S> operator+=(pair<T, S> &l, const pair<T, S> &r) { return l = l + r; }
template <class T, class S> pair<T, S> operator-=(pair<T, S> &l, const pair<T, S> &r) { return l = l - r; }
template <class T> bool intersect(const pair<T, T> &l, const pair<T, T> &r) { return (l.se < r.se ? r.fi < l.se : l.fi < r.se); }

template <class T> vector<T> &operator++(vector<T> &v) {
		fore(e, v) e++;
		return v;
}
template <class T> vector<T> operator++(vector<T> &v, int) {
		auto res = v;
		fore(e, v) e++;
		return res;
}
template <class T> vector<T> &operator--(vector<T> &v) {
		fore(e, v) e--;
		return v;
}
template <class T> vector<T> operator--(vector<T> &v, int) {
		auto res = v;
		fore(e, v) e--;
		return res;
}
template <class T> vector<T> &operator+=(vector<T> &l, const vector<T> &r) {
		fore(e, r) l.eb(e);
		return l;
}

template<class... Ts> void in(Ts&... t);
[[maybe_unused]] void print(){}
template<class T, class... Ts> void print(const T& t, const Ts&... ts);
template<class... Ts> void out(const Ts&... ts){ print(ts...); cout << '\n'; }
namespace IO{
#define VOID(a) decltype(void(a))
struct S{ S(){ cin.tie(nullptr)->sync_with_stdio(0); fixed(cout).precision(12); } }S;
template<int I> struct P : P<I-1>{};
template<> struct P<0>{};
template<class T> void i(T& t){ i(t, P<3>{}); }
void i(vector<bool>::reference t, P<3>){ int a; i(a); t = a; }
template<class T> auto i(T& t, P<2>) -> VOID(cin >> t){ cin >> t; }
template<class T> auto i(T& t, P<1>) -> VOID(begin(t)){ for(auto&& x : t) i(x); }
template<class T, size_t... idx> void ituple(T& t, index_sequence<idx...>){ in(get<idx>(t)...); }
template<class T> auto i(T& t, P<0>) -> VOID(tuple_size<T>{}){ ituple(t, make_index_sequence<tuple_size<T>::value>{}); }
template<class T> void o(const T& t){ o(t, P<4>{}); }
template<size_t N> void o(const char (&t)[N], P<4>){ cout << t; }
template<class T, size_t N> void o(const T (&t)[N], P<3>){ o(t[0]); for(size_t i = 1; i < N; i++){ o(' '); o(t[i]); } }
template<class T> auto o(const T& t, P<2>) -> VOID(cout << t){ cout << t; }
template<class T> auto o(const T& t, P<1>) -> VOID(begin(t)){ bool first = 1; for(auto&& x : t) { if(first) first = 0; else o(' '); o(x); } }
template<class T, size_t... idx> void otuple(const T& t, index_sequence<idx...>){ print(get<idx>(t)...); }
template<class T> auto o(T& t, P<0>) -> VOID(tuple_size<T>{}){ otuple(t, make_index_sequence<tuple_size<T>::value>{}); }
#undef VOID
}
#define unpack(a) (void)initializer_list<int>{(a, 0)...}
template<class... Ts> void in(Ts&... t){ unpack(IO::i(t)); }
template<class T, class... Ts> void print(const T& t, const Ts&... ts){ IO::o(t); unpack(IO::o((cout << ' ', ts))); }
#undef unpack

int main(){
	cin.tie(0);
	ios::sync_with_stdio(0);
	STR(s);
	ll n=si(s);
	vv(ll,iscat,n,n+1,1);
	rep(r,n+1)per(l,r){
		bool ok=0;
		rng(m,l+1,r-1){
			ok|=s[l]=='m'&&iscat[l+1][m]&&s[m]=='e'&&iscat[m+1][r-1]&&s[r-1]=='w';
		}
		iscat[l][r]=ok;
	}
	if(iscat[0][n])out("Cat");
	else out("Rabbit");
}
accuracy: 1
time_ms: 10
memory_kb: 5104
final_rank: 11

code_snippet: #include <bits/stdc++.h>
//#include <atcoder/all>
//using namespace atcoder;
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
#define all(A) A.begin(),A.end()
#define rep(i, n) for (ll i = 0; i < (ll) (n); i++)
using pqr = priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>;

template<class T>
bool chmax(T& p, T q) {
    if (p < q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}
template<class T>
bool chmin(T& p, T q) {
    if (p > q) {
        p = q;
        return 1;
    }
    else {
        return 0;
    }
}

ll gcd(ll(a), ll(b)) {
    ll c = a;
    while (a % b != 0) {
        c = a % b;
        a = b;
        b = c;
    }
    return b;
}

map<string, bool> F;
bool cat(string S) {
    if (F.count(S))return F[S];
    ll N = S.size();
    if (N == 0)return 1;
    if (N < 3) {
        F[S] = 0;
        return 0;
    }
    if (S[0] != 'm' || S[N - 1] != 'w') {
        F[S] = 0;
        return 0;
    }
    if (N == 3) {
        F[S] = (S[1] == 'e');
        return F[S];
    }
    for (ll j = 1; j < N - 1; j++) {
        if (S[j] == 'e') {
            string P = S.substr(1, j - 1);
            string Q = S.substr(j + 1, N - P.size() - 3);
            if (!F.count(P))F[P] = cat(P);
            if (!F.count(Q))F[Q] = cat(Q);
            if (F[P] && F[Q]) {
                F[S] = 1;
                return 1;
            }
        }
    }
    F[S] = 0;
    return 0;
}

ll mod = 1e9 + 7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    F[""] = 1;
    string S;
    cin >> S;
    cout << (cat(S) ? "Cat" : "Rabbit") << endl;

}
accuracy: 1
time_ms: 230
memory_kb: 10584
final_rank: 17

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

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

  string s;
  cin >> s;
  int n = s.size();
  vector<vector<bool>> dp(n+1,vector<bool>(n+1,false));
  for (int i=0;i<=n;i++) {
    dp[i][i] = true;
  }
  for (int l=1;l<=n;l++) {
    for (int i=0;i+l<=n;i++) {
      for (int j=i+1;j<i+l-1;j++) {
        if (s[i] == 'm' && s[j] == 'e' && s[i+l-1] == 'w' && dp[i+1][j] && dp[j+1][i+l-1]) {
          dp[i][i+l] = true;
        }
      }
    }
  }
  if (dp[0][n]) cout << "Cat" << endl;
  else cout << "Rabbit" << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3524
final_rank: 4

code_snippet: #include<iostream>
using namespace std;

bool dp[510][510];
int main() {
  string s; cin >> s;
  int N = s.size();
  for(int i=0; i<N; i++)
    dp[i][i] = true;
  for(int i=N-1; i>=0; i--) {
    for(int j=N; j-i>=3; j--) {
      for(int k=i; k<j; k++) {
        if(s[i] != 'm') continue;
        if(s[k] != 'e') continue;
        if(s[j-1] != 'w') continue;
        dp[i][j] |= dp[i+1][k] & dp[k+1][j-1];
      }
    }
  }
  cout << (dp[0][N] ? "Cat" : "Rabbit") << endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3448
final_rank: 6

code_snippet: #include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>b)return 0; a=b; return 1;}
#define bitUP(x,a) ((x>>a)&1)
int dx[4]={0,1,0,-1}, dy[4]={1,0,-1,0};
long double eps = 1e-18;
long double pi = acos(-1);

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    string S;
    cin>>S;

    bool flag[510][510]={};
    string s;
    for(int i=0;i<=S.size();i++){
        for(int j=0;j+i<=S.size();j++){
            int e=j+i;
            bool win=false;
            if(i==0) win=true;
            else if(i<=2) win=false;
            else{
                for(int k=j+1;k<e-1;k++){
                    if(S[k]!='e' or S[e-1]!='w' or S[j]!='m') continue;
                    if(i==0 and j==S.size()){
                        //cout<<j+1<<" "<<k<<" "<<k+1<<" "<<e-1<<endl;
                    }
                    if(flag[j+1][k] and flag[k+1][e-1]) win=true;
                }
            }
            flag[j][e]=win;
        }
    }
    //cout<<flag[2][3]<<endl;
    if(flag[0][S.size()]) cout<<"Cat"<<endl;
    else cout<<"Rabbit"<<endl;

}
accuracy: 1
time_ms: 50
memory_kb: 3708
final_rank: 9

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)

 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 
    set <string> st;
    set <string> st2;
    bool iscat(string s){
        if(st.count(s))return false;
        if(st2.count(s))return true;
        lint n=s.size();
        if(s[0]!='m'&&s[n-1]!='w'){
            st.insert(s);
            return false;
        }
        bool x=false;
        string moto=s;
        s=s.substr(1,n-2);
        rep(i,n-2){
            if(s[i]=='e'){
                if(iscat(s.substr(0,i))&&iscat(s.substr(i+1,n-i-2))){
                    x=true;
                    break;
                }
            }
        }
        if(!x)st.insert(moto);
        else st2.insert(moto);
        return x;
    }
    int main(){
       string s;
       cin>>s;
       st2.insert("mew");
       st2.insert("");
       if(iscat(s))cout<<"Cat"<<endl;
       else cout<<"Rabbit"<<endl;
    }
accuracy: 1
time_ms: 480
memory_kb: 14340
final_rank: 20

code_snippet: // I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
const ll MAX = 520;
vector<vector<ll>> memo(MAX,vector<ll>(MAX,-1));
bool is_cat(const string &s,ll st,ll en){
  int n = s.size();
  if(memo[st][en]!=-1){
    return memo[st][en];
  }
  if(st==en) return memo[st][en] = true;
  if(s[st]!='m'||s[en-1]!='w') return memo[st][en] = false;
  ll idx = 1;
  while(idx<n-1){
    if(s[idx]=='e'){
      if(is_cat(s,st+1,idx)&&is_cat(s,idx+1,en-1)){
        return memo[st][en] = true;
      }
    }
    idx++;
  }
  return memo[st][en] = false;
}
signed main(){
  init_io();
  string s;
  cin >> s;
  if(is_cat(s,0,s.size())){
    cout <<"Cat"<<endl;
  }else{
    cout <<"Rabbit"<<endl;
  }
}
accuracy: 1
time_ms: 10
memory_kb: 5596
final_rank: 12

code_snippet: #include<bits/stdc++.h>
using namespace std;
map<string,int>memo;
map<string,bool>valid;
bool dfs(int r, int l, string& s){
    if(r >= l) return true;
    if( (s[r] != 'm'  ) || ( s[l - 1] != 'w' )) return false;
    string substr = s.substr(r,l - r);
//    cout << substr << endl;
    if(memo[substr] > 0) return valid[substr];
    bool f = false;
    for(int i = r; i < l ; ++i){
        if(s[i] ==  'e' && dfs(r + 1,i,s) && dfs(i + 1, l - 1, s)) f = true;
    }
    memo[substr] += 1;
    return valid[substr] = f;
}
int main(){
    string s; cin >> s;
    cout << (dfs(0,(int)s.size(),s) ? "Cat" : "Rabbit") << endl;
   // cout << "hoge" << endl;
}
accuracy: 1
time_ms: 160
memory_kb: 11752
final_rank: 16

code_snippet: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
set<string> cat, rabbit;

bool isCat(string S) {
    //cerr << S << endl;
    if(cat.find(S) != cat.end()) return true;
    if(rabbit.find(S) != rabbit.end()) return false;
    if(S == "") return true;
    if(S[0] != 'm' || S.back() != 'w') {
        rabbit.insert(S);
        return false;
    }
    int n = S.size();
    for(int i = 1; i + 1 < S.size(); i++) {
        if(S[i] != 'e') continue;
        if(!isCat(S.substr(1, i - 1))) continue;
        if(!isCat(S.substr(i + 1, n - i - 2))) continue;
        cat.insert(S);
        return true;
    }
    rabbit.insert(S);
    return false;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    if(isCat(S)) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
    return 0;
}
accuracy: 1
time_ms: 210
memory_kb: 7388
final_rank: 15

code_snippet: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<tuple>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> tiii;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };
const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;

string s;

#define DEBUG 1

int dp[505][505];


bool iscat(int left, int right) {

	if (left > right) return true;
	if (s[left] != 'm' || s[right] != 'w') {
		return dp[left][right] = false;
	}
	if (dp[left][right] != -1) {
		return dp[left][right];
	}

	for (int i = left; i + 1 <= right; i++) {
		if (iscat(left + 1, i - 1) && s[i] == 'e' && iscat(i + 1, right - 1)) {
			return dp[left][right] = true;
		}
	}
	return dp[left][right] = false;
}


int main() {

	cin >> s;
	memset(dp, -1, sizeof(dp));
	if (iscat(0, s.size() - 1)) {
		cout << "Cat" << endl;
	}
	else
	{
		cout << "Rabbit" << endl;
	}
		
	return 0;

}
accuracy: 1
time_ms: 10
memory_kb: 4212
final_rank: 8

code_snippet: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}

map<string,int> ma;//1:cat,-1:rabbit

bool f(string s){
    if(s == "")return true;
    int n = s.size();
    bool ret = false;
    if(ma[s] == 1)ret = true;
    if(ma[s] == 0){
        if(s[0] == 'm' && s[n-1] == 'w'){
            loop(i,1,n-1)if(s[i] == 'e'){
                if(f(s.substr(1,i-1)) && f(s.substr(i+1,n-i-2)))ret = true;
            }
        }
        if(ret) ma[s] = 1;
        else ma[s] = -1;
    }
    return ret;
}

int main(void) {
    int i,j;
    string s;
    cin >> s;
    if(f(s)) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;

}
accuracy: 1
time_ms: 360
memory_kb: 7724
final_rank: 19

code_snippet: #include<iostream>
#include<map>
using namespace std;
map<string,int>M;
bool f(string s)
{
	if(s.size()==0)return true;
	else if(s[0]!='m'||s[s.size()-1]!='w')return false;
	else if(M[s])return M[s]>0;
	else
	{
		for(int i=1;i+1<s.size();i++)
			if(s[i]=='e'&&f(s.substr(1,i-1))&&f(s.substr(i+1,s.size()-i-2)))
			{
				M[s]=1;
				return true;
			}
		M[s]=-1;
		return false;
	}
}
main()
{
	string s;cin>>s;cout<<(f(s)?"Cat":"Rabbit")<<endl;
}
accuracy: 1
time_ms: 360
memory_kb: 7632
final_rank: 18

code_snippet: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
   */

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool dp[505][505];

int main(){
  string s;
  cin>> s;
  
  REP(i,3,s.size()+1){
    REP(left,0,s.size()){
      if((int)s.size()<left+i-1)break;
      int right=left+i-1;
      REP(center,left+1,right){
	if(s[left]=='m'&&s[center]=='e'&&s[right]=='w'){
	  if(!dp[center+1][right-1] &&center!=right-1)continue;
	  if(!dp[left+1][center-1] && center-1!=left)continue;
	  //cout<<"ok: "<<left<<" "<<center<<" "<<right<<endl;
	  dp[left][right]=true;
	}
      }
    }
  }
  /*
  rep(i,s.size()){
    rep(j,s.size())cout<<dp[i][j];
    cout<<endl;
  }
  */
  if(dp[0][s.size()-1])cout<<"Cat"<<endl;
  else cout<<"Rabbit"<<endl;
  return 0;
}
accuracy: 1
time_ms: 20
memory_kb: 3412
final_rank: 5

code_snippet: #include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/

/**********************************************/

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(){
    string s;
    bool dp[505][505];

    cin >> s;

    int n = s.size();
    REP(i, n) REP(j, n) dp[i][j] = false;

    for(int len = 3; len <= n; len++){
        REP(l, n){
            int r = l + len - 1;
            if(r > n) break;

            for(int c = l+1; c < r; c++){
                if(s[l] == 'm' && s[c] == 'e' && s[r] == 'w'){
                    if(l != c-1 && !dp[l+1][c-1]) continue;
                    if(c != r-1 && !dp[c+1][r-1]) continue;
                    dp[l][r] = true;
                }
            }
        }
    }

    if(dp[0][n-1]) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
}
accuracy: 1
time_ms: 40
memory_kb: 3428
final_rank: 7

code_snippet: #include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/

/**********************************************/

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

int main(){
    string s;
    bool dp[505][505];

    cin >> s;

    int n = s.size();
    REP(i, n) REP(j, n) dp[i][j] = false;

    for(int len = 3; len <= n; len += 3){
        REP(l, n){
            int r = l + len - 1;
            if(r > n) break;

            for(int c = l+1; c < r; c++){
                if(s[l] == 'm' && s[c] == 'e' && s[r] == 'w'){
                    if(l != c-1 && !dp[l+1][c-1]) continue;
                    if(c != r-1 && !dp[c+1][r-1]) continue;
                    dp[l][r] = true;
                }
            }
        }
    }

    if(dp[0][n-1]) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3424
final_rank: 1

code_snippet: #include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
string s;
bool dp[505][505];
/**********************************************/

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

    cin >> s;

    int n = s.size();
    REP(i, n) REP(j, n) dp[i][j] = false;
    REP(i, n) dp[i][i] = true;

    for(int i = 0; i < n-2; i++){
        if(s.substr(i, 3) == "mew") dp[i][i+2] = true;
    }
    for(int len = 6; len <= n; len += 3){
        REP(l, n){
            int r = l + len - 1;
            if(r > n) break;

            // m ok e ok w
            for(int c = l+1; c < r; c++){
                if(s[l] == 'm' && s[c] == 'e' && s[r] == 'w'){
                    if(l != c-1 && !dp[l+1][c-1]) continue;
                    if(c != r-1 && !dp[c+1][r-1]) continue;
                    dp[l][r] = true;
                }
            }
        }
    }
    if(dp[0][n-1]) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3452
final_rank: 2

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

int dp[510][510];

//半開区間[0, r)が猫かどうか
bool rec(string s, int l, int r){
    
    if(dp[l][r] != -1) return dp[l][r];

    //空文字列ならok
    if(l == r){
        dp[l][r] = 1;
        return true;
    }
    //cout << l << " " << r << endl;
    if(s[l] != 'm'){
        dp[l][r] = 0;        
        return false;
    }

    if(s[r - 1] != 'w'){
        dp[l][r] = 0;
        return false;
    }

    l++;
    r--;
    //cout << l << r << endl;
    //eの添え字を見つける
    vector<int> idx;
    for(int i = l; i < r; i++){
        if(s[i] == 'e') idx.push_back(i);
    }

    if(idx.size() == 0){
        dp[l - 1][r + 1] = 0;
        return false;
    }

    //各eに対して頑張る
    bool ok = false;
    for(int i = 0; i < idx.size(); i++){
        bool flag1 = rec(s, l, idx[i]);
        bool flag2 = rec(s, idx[i] + 1, r);

        //cout << flag1 << " " << flag2 << endl;
        if(flag1 && flag2){
            ok = true;
            break;
        }
    }

    if(ok) dp[l - 1][r + 1] = 1;
    else dp[l - 1][r + 1] = 0;
    
    return ok;
}

int main(){

    memset(dp, -1, sizeof(dp));

    string s; cin >> s;
    int n = (int)s.size();
    if(rec(s, 0, n)) cout << "Cat" << endl;
    else cout << "Rabbit" << endl;
}
accuracy: 1
time_ms: 80
memory_kb: 4340
final_rank: 13

code_snippet: #include <bits/stdc++.h>
//#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables ***************/
string s;
bool dp[505][505];
/**********************************************/

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

    cin >> s;
    int n = s.size();
    REP(i, n) dp[i][i] = true;
    REP(l, n-2){
        int r = l+2;
        if(s.substr(l, 3) == "mew") dp[l][r] = true;
    }

    for(int len = 6; len <= n; len += 3){
        REP(l, n){
            int r = l + len - 1;
            if(r >= n) break;
            /*
            for(int c = l+3; c < r; c += 3){
                if(dp[l][c-1] && dp[c][r]) dp[l][r] = true;
            }
            */
            for(int c = l+1; c < r; c++){
                if(s[l] == 'm' && s[c] == 'e' && s[r] == 'w'){
                    if(l+1 != c && !dp[l+1][c-1]) continue;
                    if(c+1 != r && !dp[c+1][r-1]) continue;
                    dp[l][r] = true;
                }
            }
        }
    }
    cout << (dp[0][n-1] ? "Cat" : "Rabbit") << endl;
}
accuracy: 1
time_ms: 10
memory_kb: 3472
final_rank: 3