Language: C++

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

int main()
{
  string s;
  cin >> s;
  int n;
  while(n = s.size()) {
    if (s.end(5) == "erase" || s.end(5) == "dream") s = s.substr(0, l - 5);
    else if (s.end(6) == "eraser") s = s.substr(0, l - 6);
    else if (s.end(7) == "dreamer") s = s.subdtr(0, l - 7);
    else cout << "NO" << endl;
  }
  cout << "YES" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:14: error: no matching function for call to 'std::__cxx11::basic_string<char>::end(int)'
   11 |     if (s.end(5) == "erase" || s.end(5) == "dream") s = s.substr(0, l - 5);
      |         ~~~~~^~~
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:978:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator]'
  978 |       end() _GLIBCXX_NOEXCEPT
      |       ^~~
/usr/include/c++/14/bits/basic_string.h:978:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:987:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
  987 |       end() const _GLIBCXX_NOEXCEPT
      |       ^~~
/usr/include/c++/14/bits/basic_string.h:987:7: note:   candidate expects 0 arguments, 1 provided
a.cc:11:37: error: no matching function for call to 'std::__cxx11::basic_string<char>::end(int)'
   11 |     if (s.end(5) == "erase" || s.end(5) == "dream") s = s.substr(0, l - 5);
      |                                ~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:978:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator]'
  978 |       end() _GLIBCXX_NOEXCEPT
      |       ^~~
/usr/include/c++/14/bits/basic_string.h:978:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:987:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
  987 |       end() const _GLIBCXX_NOEXCEPT
      |       ^~~
/usr/include/c++/14/bits/basic_string.h:987:7: note:   candidate expects 0 arguments, 1 provided
a.cc:11:69: error: 'l' was not declared in this scope
   11 |     if (s.end(5) == "erase" || s.end(5) == "dream") s = s.substr(0, l - 5);
      |                                                                     ^
a.cc:12:19: error: no matching function for call to 'std::__cxx11::basic_string<char>::end(int)'
   12 |     else if (s.end(6) == "eraser") s = s.substr(0, l - 6);
      |              ~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:978:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator]'
  978 |       end() _GLIBCXX_NOEXCEPT
      |       ^~~
/usr/include/c++/14/bits/basic_string.h:978:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:987:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
  987 |       end() const _GLIBCXX_NOEXCEPT
      |       ^~~
/usr/include/c++/14/bits/basic_string.h:987:7: note:   candidate expects 0 arguments, 1 provided
a.cc:12:52: error: 'l' was not declared in this scope
   12 |     else if (s.end(6) == "eraser") s = s.substr(0, l - 6);
      |                                                    ^
a.cc:13:19: error: no matching function for call to 'std::__cxx11::basic_string<char>::end(int)'
   13 |     else if (s.end(7) == "dreamer") s = s.subdtr(0, l - 7);
      |              ~~~~~^~~
/usr/include/c++/14/bits/basic_string.h:978:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; iterator = std::__cxx11::basic_string<char>::iterator]'
  978 |       end() _GLIBCXX_NOEXCEPT
      |       ^~~
/usr/include/c++/14/bits/basic_string.h:978:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_string.h:987:7: note: candidate: 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::const_iterator std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::end() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; const_iterator = std::__cxx11::basic_string<char>::const_iterator]'
  987 |       end() const _GLIBCXX_NOEXCEPT
      |       ^~~
/usr/include/c++/14/bits/basic_string.h:987:7: note:   candidate expects 0 arguments, 1 provided
a.cc:13:43: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'subdtr'; did you mean 'substr'?
   13 |     else if (s.end(7) == "dreamer") s = s.subdtr(0, l - 7);
      |                                           ^~~~~~
      |                                           substr
a.cc:13:53: error: 'l' was not declared in this scope
   13 |     else if (s.end(7) == "dreamer") s = s.subdtr(0, l - 7);
      |                                                     ^