Language: C++

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

int main(){
	string devide[4] = {"dream", "dreamer", "erase", "eraser"};
	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	for(int i=0; i<4; ++i) reverese(devide[i].begin(), devide[i].end());

	bool flag = true;
	for(int i=0; i<S.size();){
		bool flag2 = false;
		for(int j=0; j<4; ++j){
			string d = devide[j]
			if(S.substr(i, d.size())==d){
				flag2 = true;
				i += d.size();
			}
			if (!flag2){
				flag = false;
				break;
			}
		}
	}
	if (flag){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}
}

Compiler output:
a.cc: In function 'int main()':
a.cc:6:9: error: 'string' was not declared in this scope
    6 |         string devide[4] = {"dream", "dreamer", "erase", "eraser"};
      |         ^~~~~~
a.cc:6:9: note: suggested alternatives:
In file included from /usr/include/c++/14/iosfwd:41,
                 from /usr/include/c++/14/ios:40,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/stringfwd.h:77:33: note:   'std::string'
   77 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
In file included 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:
/usr/include/c++/14/string:76:11: note:   'std::pmr::string'
   76 |     using string    = basic_string<char>;
      |           ^~~~~~
a.cc:7:15: error: expected ';' before 'S'
    7 |         string S;
      |               ^~
      |               ;
a.cc:8:9: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    8 |         cin >> S;
      |         ^~~
      |         std::cin
/usr/include/c++/14/iostream:62:18: note: 'std::cin' declared here
   62 |   extern istream cin;           ///< Linked to standard input
      |                  ^~~
a.cc:8:16: error: 'S' was not declared in this scope
    8 |         cin >> S;
      |                ^
a.cc:9:9: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
    9 |         reverse(S.begin(), S.end());
      |         ^~~~~~~
      |         std::reverse
In file included from /usr/include/c++/14/algorithm:86,
                 from a.cc:3:
/usr/include/c++/14/pstl/glue_algorithm_defs.h:249:1: note: 'std::reverse' declared here
  249 | reverse(_ExecutionPolicy&& __exec, _BidirectionalIterator __first, _BidirectionalIterator __last);
      | ^~~~~~~
a.cc:10:41: error: 'devide' was not declared in this scope
   10 |         for(int i=0; i<4; ++i) reverese(devide[i].begin(), devide[i].end());
      |                                         ^~~~~~
a.cc:10:32: error: 'reverese' was not declared in this scope
   10 |         for(int i=0; i<4; ++i) reverese(devide[i].begin(), devide[i].end());
      |                                ^~~~~~~~
a.cc:16:31: error: expected ';' before 'd'
   16 |                         string d = devide[j]
      |                               ^~
      |                               ;
a.cc:28:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   28 |                 cout<<"YES"<<endl;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:28:30: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   28 |                 cout<<"YES"<<endl;
      |                              ^~~~
      |                              std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~
a.cc:30:17: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   30 |                 cout<<"NO"<<endl;
      |                 ^~~~
      |                 std::cout
/usr/include/c++/14/iostream:63:18: note: 'std::cout' declared here
   63 |   extern ostream cout;          ///< Linked to standard output
      |                  ^~~~
a.cc:30:29: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   30 |                 cout<<"NO"<<endl;
      |                             ^~~~
      |                             std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~