Language: C++

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

string div[4] = {"dream", "dreamer", "erase", "eraser"};

int main() {
  string S;
  cin >> S;

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(div[i].begin(), div[i].end())

  bool flag = true;
  for (int i = 0; i < S.size();) {
    bool flag2 = false;
    for (int j = 0; j < 4; ++j) {
      string d = div[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:5:1: error: 'string' does not name a type; did you mean 'stdin'?
    5 | string div[4] = {"dream", "dreamer", "erase", "eraser"};
      | ^~~~~~
      | stdin
a.cc: In function 'int main()':
a.cc:8:3: error: 'string' was not declared in this scope
    8 |   string S;
      |   ^~~~~~
a.cc:8:3: 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:9:3: error: 'cin' was not declared in this scope; did you mean 'std::cin'?
    9 |   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:9:10: error: 'S' was not declared in this scope
    9 |   cin >> S;
      |          ^
a.cc:11:3: error: 'reverse' was not declared in this scope; did you mean 'std::reverse'?
   11 |   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:12:44: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   12 |   for (int i = 0; i < 4; ++i) reverse(div[i].begin(), div[i].end())
      |                                            ^
a.cc:12:46: error: request for member 'begin' in '*(div + ((sizetype)i))', which is of non-class type 'div_t(int, int) noexcept'
   12 |   for (int i = 0; i < 4; ++i) reverse(div[i].begin(), div[i].end())
      |                                              ^~~~~
a.cc:12:60: warning: pointer to a function used in arithmetic [-Wpointer-arith]
   12 |   for (int i = 0; i < 4; ++i) reverse(div[i].begin(), div[i].end())
      |                                                            ^
a.cc:12:62: error: request for member 'end' in '*(div + ((sizetype)i))', which is of non-class type 'div_t(int, int) noexcept'
   12 |   for (int i = 0; i < 4; ++i) reverse(div[i].begin(), div[i].end())
      |                                                              ^~~
a.cc:18:13: error: expected ';' before 'd'
   18 |       string d = div[j];
      |             ^~
      |             ;
a.cc:19:23: error: 'd' was not declared in this scope
   19 |       if (S.substr(i, d.size()) == d) {
      |                       ^
a.cc:25:7: error: 'flag' was not declared in this scope; did you mean 'flag2'?
   25 |       flag = false;
      |       ^~~~
      |       flag2
a.cc:29:7: error: 'flag' was not declared in this scope
   29 |   if (flag) cout << "YES" << endl;
      |       ^~~~
a.cc:29:13: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   29 |   if (flag) 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:29:30: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   29 |   if (flag) 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:8: error: 'cout' was not declared in this scope; did you mean 'std::cout'?
   30 |   else 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:24: error: 'endl' was not declared in this scope; did you mean 'std::endl'?
   30 |   else cout << "NO" << endl;
      |                        ^~~~
      |                        std::endl
/usr/include/c++/14/ostream:744:5: note: 'std::endl' declared here
  744 |     endl(basic_ostream<_CharT, _Traits>& __os)
      |     ^~~~