stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#define sz(x) ((int)(x).size())

#define rep(i,a,b) for (int i=(a); i<(b); i++)

#define per(i,a,b) for (int i=(b-1); i>=(a); i--)

#define debug(x) cout << #x << " => " << x << endl

using namespace std;



#define fi first

#define se second

#define mp make_pair

typedef pair<int,int> pii;



#define pb push_back

typedef vector<int> vi;



typedef long long ll;

typedef long double ld;



const int MAX_N = 7 + 100000;

///----------------------------------------------

bool f[MAX_N];

int main() {

	

	///read

	string str; cin>>str;

	

	///work

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

	memset(f,false,sizeof(f));

	rep(i,0,sz(str)) {

		rep(j,0,4) if (i+1>=sz(tab[j])) {

			if (i-sz(tab[j])==-1 || f[i-sz(tab[j])])

				if (str.substr(i-sz(tab[j])+1,sz(tab[j]))==tab[j]) {

					f[i]=true;

					break;

				}

		}

		//debug(f[i]);

	}

	

	///print

	puts(f[sz(str)-1] ? "YES" : "NO");









}


// Faster C++ solution for the same problem (measured speedup: 5.878339766428092x):
#include<cstdio>

#include<cstring>

using namespace std;

char s[100005];

int dp[100005],len;

int f(int n){

	if (dp[n]) return 1;

	if (n<5) return 0;

	char tmp[10];

	for (int i=0; i<5; i++) tmp[i]=s[i+n-5];

	tmp[5]='\0';

	if (strcmp(tmp,"dream")==0&&f(n-5)) return 1;

	else if (strcmp(tmp,"erase")==0&&f(n-5)) return 1;

	if (n<6) return 0;

	for (int i=0; i<6; i++) tmp[i]=s[i+n-6];

	tmp[6]='\0';

	if (strcmp(tmp,"eraser")==0&&f(n-6)) return 1;	

	if (n<7) return 0;

	for (int i=0; i<7; i++) tmp[i]=s[i+n-7];

	tmp[7]='\0';

	if (strcmp(tmp,"dreamer")==0&&f(n-7)) return 1;

	return 0;	

}

int main(){

	scanf("%s",s);

	len=strlen(s);

	dp[0]=1;

	for (int i=1; i<=len; i++) dp[i]=0;

	if (f(len)) printf("YES\n");

	else printf("NO\n");

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include<cstdio>

#include<string>

using namespace std;

string S;

int i;

int check(string str){

    int t = i;

    for(int j = str.size()-1;j >= 0;--j){

        if(t < 0) return 0;

        if(str[j] != S[t--]) return 0;

    }

    return 1;

}

int main(){

    string S1 = "dream";

    string S2 = "dreamer";

    string S3 = "erase";

    string S4 = "eraser";

    while(cin >> S){

        // 01234 56789 10

        // dream erase r



        // dreaeeraser

        for(i = S.size()-1;i >= 0;){

            if(check(S1)){

                i -= S1.size();

                continue;

            }

            if(check(S2)){

                i -= S2.size();

                continue;

            }

            if(check(S3)){

                i -= S3.size();

                continue;

            }

            if(check(S4)){

                i -= S4.size();

                continue;

            }

            break;

        }

        if(i != -1) cout << "NO" << endl;

        else cout << "YES" << endl;

    }

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.377554941583638x):
#include <cstdio>

#include <cstring>

#include <algorithm>

int  a,b,c,d,i,j,k,x,y,z,ans;

char f[100005];

int main(){

	scanf("%s",f);

	c=0;

	while (true){

		d=c+4;

		if ((f[c]=='d') and (f[c+1]=='r') and (f[c+2]=='e') and (f[c+3]=='a') and (f[c+4]=='m')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-3){

				if ((f[d+1]=='e') and (f[d+2]=='r')){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if ((f[d+1]=='e') and (f[d+2]=='r')){

				if (f[d+3]=='a') c+=5; else c+=7;

			}

			else {

				c+=5;

			}

		}

		else if ((f[c]=='e') and (f[c+1]=='r') and (f[c+2]=='a') and (f[c+3]=='s') and (f[c+4]=='e')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-2){

				if (f[d+1]=='r'){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if (f[d+1]=='r') c+=6;

			else {

				c+=5;

			}

		}

		else {

			printf("NO\n");

			return 0;					

		}

	}

}
// Slower C++ solution:
#include <bits/stdc++.h>

using namespace std;

 

const int DIM = 1e5 + 5;

 

int dp[DIM];

 

int main( void ) {

    

    string str;

    cin >> str;

    

    dp[0] = 1;

    for( int i = 0; i < str.length(); i ++ ) {

        if( dp[i] == 0 )

            continue;

        

        if( str.length() - i >= 5 && str.substr( i, 5 ) == "dream" )

            dp[i + 5] = 1;

        if( str.length() - i >= 5 && str.substr( i, 5 ) == "erase" )

            dp[i + 5] = 1;

        

        if( str.length() - i >= 7 && str.substr( i, 7 ) == "dreamer" )

            dp[i + 7] = 1;

        if( str.length() - i >= 6 && str.substr( i, 6 ) == "eraser" )

            dp[i + 6] = 1;

    }

    

    if( dp[str.length()] == 1 )

        cout << "YES" << endl;

    else

        cout << "NO" << endl;

    

    return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.377218650428618x):
#include <cstdio>

#include <cstring>

#include <algorithm>

int  a,b,c,d,i,j,k,x,y,z,ans;

char f[100005];

int main(){

	scanf("%s",f);

	c=0;

	while (true){

		d=c+4;

		if ((f[c]=='d') and (f[c+1]=='r') and (f[c+2]=='e') and (f[c+3]=='a') and (f[c+4]=='m')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-3){

				if ((f[d+1]=='e') and (f[d+2]=='r')){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if ((f[d+1]=='e') and (f[d+2]=='r')){

				if (f[d+3]=='a') c+=5; else c+=7;

			}

			else {

				c+=5;

			}

		}

		else if ((f[c]=='e') and (f[c+1]=='r') and (f[c+2]=='a') and (f[c+3]=='s') and (f[c+4]=='e')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-2){

				if (f[d+1]=='r'){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if (f[d+1]=='r') c+=6;

			else {

				c+=5;

			}

		}

		else {

			printf("NO\n");

			return 0;					

		}

	}

}
// Slower C++ solution:
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include <iostream>

using namespace std;



char s1[4][11] = {"dream", "dreamer", "erase", "eraser"};

int l1[4] = {5, 7, 5, 6};



char s[101010];

bool f[101010];



int main()

{

	scanf("%s", s);

	int l = strlen(s);

	f[0] = 1;

	for(int i = 0; i < l; ++i)

	{

		if(f[i])

		{

//			cout<<i<<endl;

			for(int j = 0; j < 4; ++j)

			{

				bool flag = 0;

				for(int k = 0; k < l1[j]; ++k)

					if(s1[j][k] != s[i + k])

					{

						flag = 1;

						break;

					}

				if(!flag)

					f[i + l1[j]] = 1;

			}

		}

	}

	if(f[l])

		puts("YES");

	else

		puts("NO");

	

	return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.266671922130203x):
#include <cstdio>

#include <cstring>

#include <algorithm>

int  a,b,c,d,i,j,k,x,y,z,ans;

char f[100005];

int main(){

	scanf("%s",f);

	c=0;

	while (true){

		d=c+4;

		if ((f[c]=='d') and (f[c+1]=='r') and (f[c+2]=='e') and (f[c+3]=='a') and (f[c+4]=='m')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-3){

				if ((f[d+1]=='e') and (f[d+2]=='r')){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if ((f[d+1]=='e') and (f[d+2]=='r')){

				if (f[d+3]=='a') c+=5; else c+=7;

			}

			else {

				c+=5;

			}

		}

		else if ((f[c]=='e') and (f[c+1]=='r') and (f[c+2]=='a') and (f[c+3]=='s') and (f[c+4]=='e')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-2){

				if (f[d+1]=='r'){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if (f[d+1]=='r') c+=6;

			else {

				c+=5;

			}

		}

		else {

			printf("NO\n");

			return 0;					

		}

	}

}
// Slower C++ solution:
#include <iostream>

#include <fstream>

#include <sstream>

#include <algorithm>

#include <cstdio>

#include <cassert>

#include <cmath>

#include <cstdlib>

#include <cstring>

#include <string>

#include <deque>

#include <queue>

#include <vector>

#include <list>

#include <map>

#include <set>

#include <bitset>

#include <stack>

#include <iomanip>

#include <utility>

#include <functional>

using namespace std;

//orz jzm

#define ll long long

#define ull unsigned ll

const ll PR=19260817;

int main() {

	string s;

	cin>>s;

	reverse(s.begin(), s.end());

	int i=0, l=s.length();

	while (i<l) {

		if (s[i]=='m') {

			if (s.substr(i, 5)!="maerd") {

				cout<<"NO"<<endl;

				return 0;

			}

			i+=5;

		}

		else if (s[i]=='e') {

			if (s.substr(i, 5)!="esare") {

				cout<<"NO"<<endl;

				return 0;

			}

			i+=5;

		} else if (s[i]=='r') {

			if (i+2>=l||s[i+1]!='e') {

				cout<<"NO"<<endl;

				return 0;

			}i+=2;

			if (s[i]=='m') {

				if (s.substr(i, 5)!="maerd") {

					cout<<"NO"<<endl;

					return 0;

				}i+=5;

			} else if (s[i]=='s') {

				if (s.substr(i, 4)!="sare") {

					cout<<"NO"<<endl;

					return 0;

				}i+=4;

			} else {

				cout<<"NO"<<endl;

				return 0;

			}

		} else {

			cout<<"NO"<<endl;

			return 0;

		}

	}

	cout<<"YES"<<endl;

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.37326016124307x):
#include <cstdio>

#include <cstring>

#include <algorithm>

int  a,b,c,d,i,j,k,x,y,z,ans;

char f[100005];

int main(){

	scanf("%s",f);

	c=0;

	while (true){

		d=c+4;

		if ((f[c]=='d') and (f[c+1]=='r') and (f[c+2]=='e') and (f[c+3]=='a') and (f[c+4]=='m')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-3){

				if ((f[d+1]=='e') and (f[d+2]=='r')){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if ((f[d+1]=='e') and (f[d+2]=='r')){

				if (f[d+3]=='a') c+=5; else c+=7;

			}

			else {

				c+=5;

			}

		}

		else if ((f[c]=='e') and (f[c+1]=='r') and (f[c+2]=='a') and (f[c+3]=='s') and (f[c+4]=='e')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-2){

				if (f[d+1]=='r'){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if (f[d+1]=='r') c+=6;

			else {

				c+=5;

			}

		}

		else {

			printf("NO\n");

			return 0;					

		}

	}

}
// Slower C++ solution:
/*

	专 业 爆 搜

			--InterestingLSY 

*/

#include <iostream>

#include <cstdio>

#include <cmath>

#include <vector>

#include <cstring>

#include <stack>

#include <queue>

#include <algorithm>

#include <set>

#include <map>

#define pb push_back

#define mp make_pair

#define INF 9999999

#define LINF 9999999999999999

#define SINF "%"

#define uint unsigned int

#define msn(a,v) memset(a,v,sizeof(a))

#define ms(a) msn(a,0)

#define NONE -1

#define ll long long

#define ull unsigned ll

#define uchar unsigned char

#define sint short int

#define usint unsigned sint

#define xsize(a) sizeof(a)/1024/1024

#define fr(aaaaa,bbbbb) for(aaaaa = 1;aaaaa <= bbbbb;aaaaa++)

#define frr(aaaaa,bbbbb,ccccc) for(aaaaa = ccccc;aaaaa <= bbbbb;aaaaa++)

using namespace std;

#define MAXN 100100



char s[MAXN];

int n;

string ss[5];

int lens[5];



bool kmp(int pos,int id){

	for(int i = 0;i < lens[id];i++){

		if(s[pos+i] != ss[id][i])

			return 0;

	}

	return 1;

}



bool dp[MAXN];

bool dfs(int pos){

	if(pos == n) return 1;

	bool ans = 0;

	for(int i = 1;i <= 4;i++)

		if(pos + i < n  &&  kmp(pos,i)){

			ans = dfs(pos + lens[i]);

			if(ans)

				return 1;

		}

	return 0;

}



int main(){

	//freopen("C.txt","r",stdin);

	ss[1] = "dream"; ss[2] = "dreamer";

	ss[3] = "erase"; ss[4] = "eraser";

	for(int i = 1;i <= 4;i++)

		lens[i] = ss[i].length();

	

	scanf("%s",&s);

	n = strlen(s);

	

	if(dfs(0)) printf("YES\n");

	else printf("NO\n");

	

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.308982839899598x):
#include <cstdio>

#include <cstring>

#include <algorithm>

int  a,b,c,d,i,j,k,x,y,z,ans;

char f[100005];

int main(){

	scanf("%s",f);

	c=0;

	while (true){

		d=c+4;

		if ((f[c]=='d') and (f[c+1]=='r') and (f[c+2]=='e') and (f[c+3]=='a') and (f[c+4]=='m')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-3){

				if ((f[d+1]=='e') and (f[d+2]=='r')){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if ((f[d+1]=='e') and (f[d+2]=='r')){

				if (f[d+3]=='a') c+=5; else c+=7;

			}

			else {

				c+=5;

			}

		}

		else if ((f[c]=='e') and (f[c+1]=='r') and (f[c+2]=='a') and (f[c+3]=='s') and (f[c+4]=='e')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-2){

				if (f[d+1]=='r'){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if (f[d+1]=='r') c+=6;

			else {

				c+=5;

			}

		}

		else {

			printf("NO\n");

			return 0;					

		}

	}

}
// Slower C++ solution:
#include <bits/stdc++.h>



using namespace std;



int dp[100005];



int main()

{

	dp[0] = 1;

	string s;

	cin >> s;

	for(int i = 0; i < s.size(); i++) {

	 	if(dp[i] != 0 && (s.size() - i >= 7) && s.substr(i, 7) == "dreamer")	dp[i + 7] = 1;

	 	if(dp[i] != 0 && (s.size() - i >= 6) && s.substr(i, 6) == "eraser")	dp[i + 6] = 1;

	 	if(dp[i] != 0 && (s.size() - i >= 5) && (s.substr(i, 5) == "dream" || s.substr(i, 5) == "erase"))	dp[i + 5] = 1;



	}

	if(dp[s.size()] == 1)

		cout << "YES" << endl;

	else

		cout << "NO" << endl;



	return 0;

}	

// Faster C++ solution for the same problem (measured speedup: 5.387338448811041x):
#include <cstdio>

#include <cstring>

#include <algorithm>

int  a,b,c,d,i,j,k,x,y,z,ans;

char f[100005];

int main(){

	scanf("%s",f);

	c=0;

	while (true){

		d=c+4;

		if ((f[c]=='d') and (f[c+1]=='r') and (f[c+2]=='e') and (f[c+3]=='a') and (f[c+4]=='m')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-3){

				if ((f[d+1]=='e') and (f[d+2]=='r')){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if ((f[d+1]=='e') and (f[d+2]=='r')){

				if (f[d+3]=='a') c+=5; else c+=7;

			}

			else {

				c+=5;

			}

		}

		else if ((f[c]=='e') and (f[c+1]=='r') and (f[c+2]=='a') and (f[c+3]=='s') and (f[c+4]=='e')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-2){

				if (f[d+1]=='r'){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if (f[d+1]=='r') c+=6;

			else {

				c+=5;

			}

		}

		else {

			printf("NO\n");

			return 0;					

		}

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define sz(x) ((int)(x).size())

#define rep(i,a,b) for (int i=(a); i<(b); i++)

#define per(i,a,b) for (int i=(b-1); i>=(a); i--)

#define debug(x) cout << #x << " => " << x << endl

using namespace std;



#define fi first

#define se second

#define mp make_pair

typedef pair<int,int> pii;



#define pb push_back

typedef vector<int> vi;



typedef long long ll;

typedef long double ld;



const int MAX_N = 7 + 100000;

///----------------------------------------------

bool f[MAX_N];

int main() {

	

	///read

	string str; cin>>str;

	

	///work

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

	memset(f,false,sizeof(f)); f[0]=true;

	rep(i,0,sz(str)) {

		rep(j,0,4) if (i+1>=sz(tab[j])) {

			if (i-sz(tab[j])==-1 || f[i-sz(tab[j])])

				if (str.substr(i-sz(tab[j])+1,sz(tab[j]))==tab[j]) {

					f[i]=true;

					break;

				}

		}

		//debug(f[i]);

	}

	

	///print

	puts(f[sz(str)-1] ? "YES" : "NO");









}


// Faster C++ solution for the same problem (measured speedup: 5.889013516305956x):
#include <cstdio>

#include <cstring>

#include <algorithm>

int  a,b,c,d,i,j,k,x,y,z,ans;

char f[100005];

int main(){

	scanf("%s",f);

	c=0;

	while (true){

		d=c+4;

		if ((f[c]=='d') and (f[c+1]=='r') and (f[c+2]=='e') and (f[c+3]=='a') and (f[c+4]=='m')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-3){

				if ((f[d+1]=='e') and (f[d+2]=='r')){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if ((f[d+1]=='e') and (f[d+2]=='r')){

				if (f[d+3]=='a') c+=5; else c+=7;

			}

			else {

				c+=5;

			}

		}

		else if ((f[c]=='e') and (f[c+1]=='r') and (f[c+2]=='a') and (f[c+3]=='s') and (f[c+4]=='e')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-2){

				if (f[d+1]=='r'){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if (f[d+1]=='r') c+=6;

			else {

				c+=5;

			}

		}

		else {

			printf("NO\n");

			return 0;					

		}

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define sz(x) ((int)(x).size())

#define rep(i,a,b) for (int i=(a); i<(b); i++)

#define per(i,a,b) for (int i=(b-1); i>=(a); i--)

#define debug(x) cout << #x << " => " << x << endl

using namespace std;



#define fi first

#define se second

#define mp make_pair

typedef pair<int,int> pii;



#define pb push_back

typedef vector<int> vi;



typedef long long ll;

typedef long double ld;



const int MAX_N = 7 + 100000;

///----------------------------------------------

bool f[MAX_N];

int main() {

	

	///read

	string str; cin>>str;

	

	///work

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

	memset(f,false,sizeof(f));

	rep(i,0,sz(str)) {

		rep(j,0,4) if (i+1>=sz(tab[j])) {

			if (i-sz(tab[j])==-1 || f[i-sz(tab[j])])

				if (str.substr(i-sz(tab[j])+1,sz(tab[j]))==tab[j]) {

					f[i]=true;

					break;

				}

		}

		//debug(f[i]);

	}

	

	///print

	puts(f[sz(str)-1] ? "YES" : "NO");









}


// Faster C++ solution for the same problem (measured speedup: 5.888203974448375x):
#include <cstdio>

#include <cstring>

#include <algorithm>

int  a,b,c,d,i,j,k,x,y,z,ans;

char f[100005];

int main(){

	scanf("%s",f);

	c=0;

	while (true){

		d=c+4;

		if ((f[c]=='d') and (f[c+1]=='r') and (f[c+2]=='e') and (f[c+3]=='a') and (f[c+4]=='m')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-3){

				if ((f[d+1]=='e') and (f[d+2]=='r')){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if ((f[d+1]=='e') and (f[d+2]=='r')){

				if (f[d+3]=='a') c+=5; else c+=7;

			}

			else {

				c+=5;

			}

		}

		else if ((f[c]=='e') and (f[c+1]=='r') and (f[c+2]=='a') and (f[c+3]=='s') and (f[c+4]=='e')){

			if (d==strlen(f)-1){

				printf("YES\n");

				return 0;

			}

			else if (d==strlen(f)-2){

				if (f[d+1]=='r'){

					printf("YES\n");

					return 0;	

				}

				else {

					printf("NO\n");

					return 0;					

				}

			}

			else if (f[d+1]=='r') c+=6;

			else {

				c+=5;

			}

		}

		else {

			printf("NO\n");

			return 0;					

		}

	}

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define sz(x) ((int)(x).size())

#define rep(i,a,b) for (int i=(a); i<(b); i++)

#define per(i,a,b) for (int i=(b-1); i>=(a); i--)

#define debug(x) cout << #x << " => " << x << endl

using namespace std;



#define fi first

#define se second

#define mp make_pair

typedef pair<int,int> pii;



#define pb push_back

typedef vector<int> vi;



typedef long long ll;

typedef long double ld;



const int MAX_N = 7 + 100000;

///----------------------------------------------

bool f[MAX_N];

int main() {

	

	///read

	string str; cin>>str;

	

	///work

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

	memset(f,false,sizeof(f)); f[0]=true;

	rep(i,0,sz(str)) {

		rep(j,0,4) if (i+1>=sz(tab[j])) {

			if (i-sz(tab[j])==-1 || f[i-sz(tab[j])])

				if (str.substr(i-sz(tab[j])+1,sz(tab[j]))==tab[j]) {

					f[i]=true;

					break;

				}

		}

		//debug(f[i]);

	}

	

	///print

	puts(f[sz(str)-1] ? "YES" : "NO");









}


// Faster C++ solution for the same problem (measured speedup: 1.1176248026915605x):
#include<bits/stdc++.h>

using namespace std;

#define FOR(i, s, e) for(int i = (s); i < (e); i++)

#define FOE(i, s, e) for(int i = (s); i <= (e); i++)

#define FOD(i, s, e) for(int i = (s); i >= (e); i--)

#define ll long long



char s[1000010];

int n, del[1000010];



/* FUCK, I think dreamer as dreamr */



int check(int x, int y)

{

	if (s[x] == 'e' && s[x + 1] == 'r' && s[x + 2] == 'a' && s[x + 3] == 's' && s[x + 4] == 'e' && s[x + 5] == 'r')

	{

		if (y == 1) return 1;

	}

	if (s[x] == 'e' && s[x + 1] == 'r' && s[x + 2] == 'a' && s[x + 3] == 's' && s[x + 4] == 'e')

	{

		if (y == 0) return 1;

	}

	if (s[x] == 'd' && s[x + 1] == 'r' && s[x + 2] == 'e' && s[x + 3] == 'a' && s[x + 4] == 'm' && s[x + 5] == 'e' && s[x + 6] == 'r')

	{

		if (y == 3)	return 1;

	}

	if (s[x] == 'd' && s[x + 1] == 'r' && s[x + 2] == 'e' && s[x + 3] == 'a' && s[x + 4] == 'm')

	{

		if (y == 2) return 1;

	}

	return 0;

}



int dp[100005];



int main ()

{

	scanf("%s", s);

	n = strlen(s);

	

	dp[0] = 1;

	FOE(i, 1, n)

	{

		if (i >= 5 && check(i - 5, 0)) dp[i] = dp[i - 5];

		if (i >= 5 && check(i - 5, 2)) dp[i] = dp[i - 5];

		if (i >= 6 && check(i - 6, 1)) dp[i] = max(dp[i], dp[i - 6]);

		if (i >= 7 && check(i - 7, 3)) dp[i] = max(dp[i], dp[i - 7]);

	}

	

	int ok = dp[n];

	if (ok == 1) printf("YES\n");

	else printf("NO\n");

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#define sz(x) ((int)(x).size())

#define rep(i,a,b) for (int i=(a); i<(b); i++)

#define per(i,a,b) for (int i=(b-1); i>=(a); i--)

#define debug(x) cout << #x << " => " << x << endl

using namespace std;



#define fi first

#define se second

#define mp make_pair

typedef pair<int,int> pii;



#define pb push_back

typedef vector<int> vi;



typedef long long ll;

typedef long double ld;



const int MAX_N = 7 + 100000;

///----------------------------------------------

bool f[MAX_N];

int main() {

	

	///read

	string str; cin>>str;

	

	///work

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

	memset(f,false,sizeof(f));

	rep(i,0,sz(str)) {

		rep(j,0,4) if (i+1>=sz(tab[j])) {

			if (i-sz(tab[j])==-1 || f[i-sz(tab[j])])

				if (str.substr(i-sz(tab[j])+1,sz(tab[j]))==tab[j]) {

					f[i]=true;

					break;

				}

		}

		//debug(f[i]);

	}

	

	///print

	puts(f[sz(str)-1] ? "YES" : "NO");









}


// Faster C++ solution for the same problem (measured speedup: 1.1174711667631758x):
#include<bits/stdc++.h>

using namespace std;

#define FOR(i, s, e) for(int i = (s); i < (e); i++)

#define FOE(i, s, e) for(int i = (s); i <= (e); i++)

#define FOD(i, s, e) for(int i = (s); i >= (e); i--)

#define ll long long



char s[1000010];

int n, del[1000010];



/* FUCK, I think dreamer as dreamr */



int check(int x, int y)

{

	if (s[x] == 'e' && s[x + 1] == 'r' && s[x + 2] == 'a' && s[x + 3] == 's' && s[x + 4] == 'e' && s[x + 5] == 'r')

	{

		if (y == 1) return 1;

	}

	if (s[x] == 'e' && s[x + 1] == 'r' && s[x + 2] == 'a' && s[x + 3] == 's' && s[x + 4] == 'e')

	{

		if (y == 0) return 1;

	}

	if (s[x] == 'd' && s[x + 1] == 'r' && s[x + 2] == 'e' && s[x + 3] == 'a' && s[x + 4] == 'm' && s[x + 5] == 'e' && s[x + 6] == 'r')

	{

		if (y == 3)	return 1;

	}

	if (s[x] == 'd' && s[x + 1] == 'r' && s[x + 2] == 'e' && s[x + 3] == 'a' && s[x + 4] == 'm')

	{

		if (y == 2) return 1;

	}

	return 0;

}



int dp[100005];



int main ()

{

	scanf("%s", s);

	n = strlen(s);

	

	dp[0] = 1;

	FOE(i, 1, n)

	{

		if (i >= 5 && check(i - 5, 0)) dp[i] = dp[i - 5];

		if (i >= 5 && check(i - 5, 2)) dp[i] = dp[i - 5];

		if (i >= 6 && check(i - 6, 1)) dp[i] = max(dp[i], dp[i - 6]);

		if (i >= 7 && check(i - 7, 3)) dp[i] = max(dp[i], dp[i - 7]);

	}

	

	int ok = dp[n];

	if (ok == 1) printf("YES\n");

	else printf("NO\n");

	

	return 0;

}