Language: C++

#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) sort((a).rbegin(),(a).rend());
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(10) << ans << endl;
using namespace std;
int max_int = 1000000007;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n,m;


struct UnionFind {
    vector<int> par; // 親ノード
    vector<int> rank; // ランク

    UnionFind(int n = 1) {
        init(n);
    }

    void init(int n = 1) {
        par.resize(n); rank.resize(n);
        for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0;
    }

    int root(int x) {
        if (par[x] == x) {
            return x;
        }
        else {
            int r = root(par[x]);
            return par[x] = r;
        }
    }

    bool issame(int x, int y) {
        return root(x) == root(y);
    }

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (rank[x] < rank[y]) swap(x, y);
        if (rank[x] == rank[y]) ++rank[x];
        par[y] = x;
        return true;
    }
};


int judge(string a,int piv,string b){
	REP(i,b.size()){
		if(a[piv+i] != b[i]){
			return 1;
		}
	}
	return 0;
}


/*
eraser
erasee
erased
dreamdream
dreamerdream
dreamererase
dreamerase
 */

signed main(){
	string s;
	cin >> s;
	s += 'x';
	int piv = 0;
	bool ans = true;
	while(piv<s.size()){
		if(s[piv] == 'd'){
			string b = "dream";
			if(judge(s,piv,b) == 0){
				piv += 5;
				c = "er";
				if(judge(s,piv,c) == 0){
					c = "era";
					if(judge(s,piv,c) != 0){
						piv += 2;
					}
				}
			}
			else{
				ans = false;
				break;
			}
		}
		else if(s[piv] == 'e'){
			string b = "erase";
			if(judge(s,piv,b) == 0){
				piv += 5;
				if(s[piv] == 'r') piv++;
			}
			else{
				ans = false;
				break;
			}
		}
		else if(s[piv] == 'x'){
			break;
		}
		else{
			ans = false;
			break;
		}
	}
	(ans)? cout << "YES" : cout << "NO";

    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Compiler output:
a.cc:19:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   19 | void Debug(auto a);
      |            ^~~~
a.cc:20:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   20 | int nibul(auto a,auto b);
      |           ^~~~
a.cc:20:18: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   20 | int nibul(auto a,auto b);
      |                  ^~~~
a.cc:21:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | int nibuu(auto a,auto b);
      |           ^~~~
a.cc:21:18: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
   21 | int nibuu(auto a,auto b);
      |                  ^~~~
a.cc: In function 'int main()':
a.cc:96:33: error: 'c' was not declared in this scope
   96 |                                 c = "er";
      |                                 ^
a.cc: At global scope:
a.cc:133:12: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  133 | void Debug(auto a){
      |            ^~~~
a.cc:140:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  140 | int nibul(auto a,auto b){
      |           ^~~~
a.cc:140:18: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  140 | int nibul(auto a,auto b){
      |                  ^~~~
a.cc:145:11: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  145 | int nibuu(auto a,auto b){
      |           ^~~~
a.cc:145:18: warning: use of 'auto' in parameter declaration only available with '-std=c++20' or '-fconcepts'
  145 | int nibuu(auto a,auto b){
      |                  ^~~~