Language: C++

// ABC049_C 
#include <iostream> 
#include <string> 
using  namespace std;

int main () {
     // input
    string str;
    cin >> str;
    
    // calculation
    string five, six, seven;
    unsigned  long len = str.length ();
    
    if (len < 5 ) {
        cout << "NO" << " \ n " ;
         return  0 ;
    } else  if (len == 5 ) {
         if (str == "dream" || str == "erase" ) {
            cout << "YES" << " \ n " ;
             return  0 ;
        } else {
            cout << "NO" << " \ n " ;
             return  0 ;
        }
    } else  if (len == 6 ) {
         if (str == "eraser" ) {
            cout << "YES" << " \ n " ;
             return  0 ;
        } else {
            cout << "NO" << " \ n " ;
             return  0 ;
        }
    } else  if (len == 7 ) {
         if (str == "dreamer" ) {
            cout << "YES" << " \ n " ;
             return  0 ;
        } else {
            cout << "NO" << " \ n " ;
             return  0 ;
        }
    } else {
         while (str.length ()! = 0 ) {
            = Str.Substr five (Str.Size () - 1 - 4 , 5 );
             an if (five == "dream" || five == "erase" ) {
                Str.Erase (Str.End () - 5 , Str.End ());
            } else {
                = Str.Substr six (Str.Size () - 1 - 5 , 6 );
                 an if (six == "eraser" ) {
                    Str.Erase (Str.End () - 6 , Str.End ());
                } else {
                    = Str.Substr seven (Str.Size () - 1 - 6 , 7 );
                     an if (seven == "dreamer" ) {
                        Str.Erase (Str.End () - 7 , Str.End ());
                    } else {
                        cout << "NO" << " \ n " ;
                         return  0 ;
                    }
                }
            }
        }
        cout << "YES" << " \ n " ;
         return  0 ;
    }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:16:25: warning: unknown escape sequence: '\040'
   16 |         cout << "NO" << " \ n " ;
      |                         ^~~~~~~
a.cc:20:30: warning: unknown escape sequence: '\040'
   20 |             cout << "YES" << " \ n " ;
      |                              ^~~~~~~
a.cc:23:29: warning: unknown escape sequence: '\040'
   23 |             cout << "NO" << " \ n " ;
      |                             ^~~~~~~
a.cc:28:30: warning: unknown escape sequence: '\040'
   28 |             cout << "YES" << " \ n " ;
      |                              ^~~~~~~
a.cc:31:29: warning: unknown escape sequence: '\040'
   31 |             cout << "NO" << " \ n " ;
      |                             ^~~~~~~
a.cc:36:30: warning: unknown escape sequence: '\040'
   36 |             cout << "YES" << " \ n " ;
      |                              ^~~~~~~
a.cc:39:29: warning: unknown escape sequence: '\040'
   39 |             cout << "NO" << " \ n " ;
      |                             ^~~~~~~
a.cc:43:30: error: expected ')' before '!' token
   43 |          while (str.length ()! = 0 ) {
      |                ~             ^
      |                              )
a.cc:43:32: error: expected primary-expression before '=' token
   43 |          while (str.length ()! = 0 ) {
      |                                ^
a.cc:62:26: warning: unknown escape sequence: '\040'
   62 |         cout << "YES" << " \ n " ;
      |                          ^~~~~~~