Language: C++

#include <iostream>
#include <string>
using namespace std;
int main(){
  string s;
  cin >> s;
  int n = s.size()-1;
  string ss;
  while(n>=0){
    if(s[n-2] == 'e' s[n-1] == 'a' s[n] == 'm'){
      if(n<4){
        cout << "NO" << endl;
        return 0;
      }
      else{
        for(int i = n-4;i<=n;i++){
          ss.push_back(s[i]);
        }
        if(ss="dream"){
          n-=5;
        }
        else{
          cout << "NO" << endl;
          return 0;
        }
      }
    }else if(s[n-2] == 'm' s[n-1] == 'e' s[n] == 'r'){
      if(n<6){
        cout << "NO" << endl;
        return 0;
      }
      else{
        for(int i = n-6;i<=n;i++){
          ss.push_back(s[i]);
        }
        if(ss="dreamer"){
          n-=7;
        }
        else{
          cout << "NO" << endl;
          return 0;
        }
      }
    }else if(s[n-2] == 'a' s[n-1] == 's' s[n] == 'e'){
      if(n<4){
        cout << "NO" << endl;
        return 0;
      }
      else{
        for(int i = n-4;i<=n;i++){
          ss.push_back(s[i]);
        }
        if(ss="erase"){
          n-=5;
        }
        else{
          cout << "NO" << endl;
          return 0;
        }
      }
    }else if(s[n-2] == 's' s[n-1] == 'e' s[n] == 'r'){
      if(n<5){
        cout << "NO" << endl;
        return 0;
      }
      else{
        for(int i = n-5;i<=n;i++){
          ss.push_back(s[i]);
        }
        if(ss="eraser"){
          n-=6;
        }
        else{
          cout << "NO" << endl;
          return 0;
        }
      }
    }
    ss = "";
  }
  cout << "YES" << endl;
}
        
  

Compiler output:
a.cc: In function 'int main()':
a.cc:10:21: error: expected ')' before 's'
   10 |     if(s[n-2] == 'e' s[n-1] == 'a' s[n] == 'm'){
      |       ~             ^~
      |                     )
a.cc:19:14: error: could not convert 'ss.std::__cxx11::basic_string<char>::operator=(((const char*)"dream"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   19 |         if(ss="dream"){
      |            ~~^~~~~~~~
      |              |
      |              std::__cxx11::basic_string<char>
a.cc:27:27: error: expected ')' before 's'
   27 |     }else if(s[n-2] == 'm' s[n-1] == 'e' s[n] == 'r'){
      |             ~             ^~
      |                           )
a.cc:36:14: error: could not convert 'ss.std::__cxx11::basic_string<char>::operator=(((const char*)"dreamer"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   36 |         if(ss="dreamer"){
      |            ~~^~~~~~~~~~
      |              |
      |              std::__cxx11::basic_string<char>
a.cc:44:27: error: expected ')' before 's'
   44 |     }else if(s[n-2] == 'a' s[n-1] == 's' s[n] == 'e'){
      |             ~             ^~
      |                           )
a.cc:53:14: error: could not convert 'ss.std::__cxx11::basic_string<char>::operator=(((const char*)"erase"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   53 |         if(ss="erase"){
      |            ~~^~~~~~~~
      |              |
      |              std::__cxx11::basic_string<char>
a.cc:61:27: error: expected ')' before 's'
   61 |     }else if(s[n-2] == 's' s[n-1] == 'e' s[n] == 'r'){
      |             ~             ^~
      |                           )
a.cc:70:14: error: could not convert 'ss.std::__cxx11::basic_string<char>::operator=(((const char*)"eraser"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   70 |         if(ss="eraser"){
      |            ~~^~~~~~~~~
      |              |
      |              std::__cxx11::basic_string<char>