Language: C++

#include <iostream>
#include <string>

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.end());
  
  	for(int i=0; i<s.length();){
  		for(int j=0; j<4; j++){
          string temp = added_symbol[j];
          if(temp == s.substr(s.begin(), added_symbol[j])){
          	s.erase(s.begin(), added_symbol[j]); 
            i+=added_symbol[j];
          }
        }
    }
  
  	if(s.length() == 0){
      cout << "YES" << endl;
    }else{
      cout << "NO" << endl;
    }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:9: error: 'reverse' was not declared in this scope
   11 |         reverse(s.begin(), s.end());
      |         ^~~~~~~
a.cc:12:78: error: request for member 'end' in 'added_symbol', which is of non-class type 'std::string [4]' {aka 'std::__cxx11::basic_string<char> [4]'}
   12 |         for(int i=0; i<4; i++) reverse(added_symbol[i].begin(), added_symbol.end());
      |                                                                              ^~~
a.cc:17:38: error: cannot convert 'std::__cxx11::basic_string<char>::iterator' to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
   17 |           if(temp == s.substr(s.begin(), added_symbol[j])){
      |                               ~~~~~~~^~
      |                                      |
      |                                      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:18:24: error: no matching function for call to 'std::__cxx11::basic_string<char>::erase(std::__cxx11::basic_string<char>::iterator, std::string&)'
   18 |                 s.erase(s.begin(), added_symbol[j]);
      |                 ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/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::string' {aka 'std::__cxx11::basic_string<char>'} 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:19:14: error: no match for 'operator+=' (operand types are 'int' and 'std::string' {aka 'std::__cxx11::basic_string<char>'})
   19 |             i+=added_symbol[j];
      |             ~^~~~~~~~~~~~~~~~~