Language: C++

#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main(){
 	string added_symbol[] = {"dream","dreamer","erase","eraser" };
  	string s;
   	cin >> s;
  	
	reverse(s.begin(), s.end());
  	for(int i=0; i<4; i++) reverse(added_symbol[i].begin(), added_symbol[i].end());
  
  	for(int i=0; i<s.length();){
      	int judge = i;
  		for(int j=0; j<4; j++){
          string temp = added_symbol[j];
          s.substr(s.begin(), temp.length());
          if(s.substr(s.begin(), temp.length()) ==  temp ){
          	s.erase(s.begin(), temp.length()); 
            i+=added_symbol[j];
          }
        }
      
      	if(judge == i) break;
    }
  
  	if(s.length() == 0){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:27: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
   19 |           s.substr(s.begin(), temp.length());
      |                    ~~~~~~~^~
      |                           |
      |                           std::__cxx11::basic_string<char>::iterator
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:3208:24: note:   initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::substr(size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 3208 |       substr(size_type __pos = 0, size_type __n = npos) const
      |              ~~~~~~~~~~^~~~~~~~~
a.cc:20:30: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
   20 |           if(s.substr(s.begin(), temp.length()) ==  temp ){
      |                       ~~~~~~~^~
      |                              |
      |                              std::__cxx11::basic_string<char>::iterator
/usr/include/c++/14/bits/basic_string.h:3208:24: note:   initializing argument 1 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::substr(size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 3208 |       substr(size_type __pos = 0, size_type __n = npos) const
      |              ~~~~~~~~~~^~~~~~~~~
a.cc:21:24: error: no matching function for call to 'std::__cxx11::basic_string<char>::erase(std::__cxx11::basic_string<char>::iterator, std::__cxx11::basic_string<char>::size_type)'
   21 |                 s.erase(s.begin(), temp.length());
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:2114:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>& std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(size_type, size_type) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 2114 |       erase(size_type __pos = 0, size_type __n = npos)
      |       ^~~~~
/usr/include/c++/14/bits/basic_string.h:2114:23: note:   no known conversion for argument 1 from 'std::__cxx11::basic_string<char>::iterator' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
 2114 |       erase(size_type __pos = 0, size_type __n = npos)
      |             ~~~~~~~~~~^~~~~~~~~
/usr/include/c++/14/bits/basic_string.h:2134:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(__const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2134 |       erase(__const_iterator __position)
      |       ^~~~~
/usr/include/c++/14/bits/basic_string.h:2134:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/basic_string.h:2154:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::erase(__const_iterator, __const_iterator) [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator; __const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
 2154 |       erase(__const_iterator __first, __const_iterator __last)
      |       ^~~~~
/usr/include/c++/14/bits/basic_string.h:2154:56: note:   no known conversion for argument 2 from 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} to 'std::__cxx11::basic_string<char>::__const_iterator' {aka 'std::__cxx11::basic_string<char>::const_iterator'}
 2154 |       erase(__const_iterator __first, __const_iterator __last)
      |                                       ~~~~~~~~~~~~~~~~~^~~~~~
a.cc:22:14: error: no match for 'operator+=' (operand types are 'int' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   22 |             i+=added_symbol[j];
      |             ~^~~~~~~~~~~~~~~~~