stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <iostream>

#include <cmath>

#include <cstdio>

#include <cstring>

#include <string>

#include <map>

#include <iomanip>

#include <algorithm>

#include <queue>

#include <stack>

#include <set>

#include <vector>

//const int maxn = 1e5+5;

#define ll long long

#define MAX INT_MAX

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



using namespace std;

string s;

int k,flag;





int main()

{

    cin>>s;

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

    {

        k=i;

        flag=0;

        if((s[k]=='d'&&s[k+1]=='r'&&s[k+2]=='e'&&s[k+3]=='a'&&s[k+4]=='m'&&s[k+5]!='e')||(s[k]=='d'&&s[k+1]=='r'&&s[k+2]=='e'&&s[k+3]=='a'&&s[k+4]=='m'&&s[k+5]=='e'&&s[k+6]=='r'&&s[k+7]=='a'&&s[k+8]=='s'&&s[k+9]=='e')||(s[k]=='d'&&s[k+1]=='r'&&s[k+2]=='e'&&s[k+3]=='a'&&s[k+4]=='m'&&s[k+5]=='e'&&s[k+6]=='r'&&s[k+7]=='a'&&s[k+8]=='s'&&s[k+9]=='e'&&s[k+10]=='e'))

        {

            flag=1;

            i=k+4;

        }

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

        {

            flag=1;

            i=k+6;

        }

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

        {

            flag=1;

            i=k+4;

        }

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

        {

            flag=1;

            i=k+5;

        }

        else

        {

            cout<<"NO";

            return 0;

        }

    }

    cout<<"YES";

    return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
  #include<iostream>

using namespace std;

int main(){

	string s;

	   cin>>s;

	   long long  t;

	    while((t=s.find("eraser"))!=s.npos)

	   {

	       s=s.replace(t,6,"");

	   }

	   while((t=s.find("erase"))!=s.npos)

	   {

	       s=s.replace(t,5,"");

	   }

	    while((t=s.find("dreamer"))!=s.npos)

	   {

	       s=s.replace(t,7,"");

	   }

	   while((t=s.find("dream"))!=s.npos)

	   {

	       s=s.replace(t,5,"");

	   }

	   

	   if(s.length()==0)

	    cout<<"YES";

	   else

	    cout<<"NO";

	    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

using namespace std;



const int MAXN = 1e5 + 10;

bool dp[MAXN];

string t;



int main() {

	cin >> t;

	dp[0] = 1;

	for (int i = 1; i <= t.size(); i++) {

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

			dp[i] |= dp[i - 5];

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

			dp[i] |= dp[i - 7];

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

			dp[i] |= dp[i - 5];

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

			dp[i] |= dp[i - 6];

	}

	if (dp[t.size()])

		cout << "YES";

	else

		cout << "NO";

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



#define int long long



const int N = 1e5 + 10;

int dp[N];

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



bool check(int i, int indx) {

	if (i + ar[indx].size() - 1 >= (int)s.size())

		return 0;

		

	for (int j = 0; j < ar[indx].size(); j++)

		if (s[i + j] != ar[indx][j])

			return 0;

	return 1;

}



int32_t main() {

	ios::sync_with_stdio(0);

	cin.tie(0);

	

	cin >> s;

	dp[(int)s.size()] = 1;

	for (int i = (int)s.size() - 1; i >= 0; i--)

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

			if (check(i, j))

				dp[i] |= dp[i + ar[j].size()];

	cout << (dp[0]? "YES\n": "NO\n");

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>





using namespace std;



typedef long long ll;

typedef pair<int, int> pii;

typedef pair<ll, ll> pll;





const int D = 1000 * 1000 * 1000 + 7;









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



int main() {

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

		reverse(t[i].begin(), t[i].end());

	cin >> s;

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

	int pt = 0;

	while (pt < s.size()) {

		bool b = false;

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

			if (s.size() - pt >= t[i].size() && s.substr(pt, t[i].size()) == t[i])

				pt += t[i].size(), b = true;

		if (!b)

			return cout << "NO", 0;

	}

	cout << "YES";

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

char s[100002];

int dp[100002];

int main(){

    scanf("%s", s+1);

    int n = strlen(s+1);

    dp[0] = 1;

    for(int i=1;i<=n;i++){

        if(i >= 5){

            if(s[i-4] == 'd' && s[i-3] == 'r' && s[i-2] == 'e' && s[i-1] == 'a' && s[i] == 'm'){

                dp[i] |= dp[i-5];

            }

            if(s[i-4] == 'e' && s[i-3] == 'r' && s[i-2] == 'a' && s[i-1] == 's' && s[i] == 'e'){

                dp[i] |= dp[i-5];

            }

        }

        if(i >= 6){

            if(s[i-5] == 'e' && s[i-4] == 'r' && s[i-3] == 'a' && s[i-2] == 's' && s[i-1] == 'e' && s[i] == 'r'){

                dp[i] |= dp[i-6];

            }   

        }

        if(i >= 7){

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

                dp[i] |= dp[i-7];

            }   

        }

    }

    if(dp[n]) printf("YES\n");

    else printf("NO\n");

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

#include <ext/pb_ds/assoc_container.hpp>

#include <ext/pb_ds/tree_policy.hpp>

  

using namespace std;

using namespace __gnu_pbds;

 

#define ll long long

#define uint unsigned int

#define ull  unsigned long long

#define pb push_back

#define mk make_pair

#define ins insert

#define all(x) (x).begin(), (x).end()

#define rall(x) (x).rbegin(),(x).rend()

#define X first

#define Y second

#define umap unordered_map

#define speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)

#define setvalue(d,s,e,n) for(int qwe = s; qwe < e; ++qwe) d[qwe] = n

#define mset multiset

#define pqueue priority_queue

   

template<class T> using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

        

const int  N = 2e5 + 314;

const int INF = 1e9;

const double PI = acos(-1);

const int MOD = 1e9 + 7;

const double eps = 1e-9;

const long long LINF = 1e18 + 3141;



void solve(){

    string s, t;

    cin >> s;

    string cur = "";

    int n = (int)s.size();

    

    for(int i = n - 1; i >= 0; --i) {

        cur = s[i] + cur;

        if(cur.size() == 8) {

            cout << "NO";

            return;

        }else {

            if(cur == "dream"){

                cur = "";

            }else if(cur == "dreamer") {

                cur = "";

            }else if(cur == "erase") {

                cur = "";

            }else if(cur == "eraser") {

                cur = "";

            }

        }

    }

    if(cur != "") {

        cout << "NO";

    }else{

        cout << "YES";

    }

}

 

int main(){

    speed();

    int t = 1;

    // cin >> t;

    while(t--)solve();

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



char s[1 << 20];

int dp[1 << 20];



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	cin >> (s + 1);

	int n = strlen(s + 1); 

	dp[0] = 1;

	for (int i = 0; i < n; i++) {

		if (dp[i]) {

			if (strncmp(s + i + 1, "dream", 5) == 0) dp[i + 5] = 1;

			if (strncmp(s + i + 1, "dreamer", 7) == 0) dp[i + 7] = 1;

			if (strncmp(s + i + 1, "erase", 5) == 0) dp[i + 5] = 1;

			if (strncmp(s + i + 1, "eraser", 6) == 0) dp[i + 6] = 1;

		}

	}

	if (dp[n]) cout << "YES" << endl;

	else cout << "NO" << endl;

	return 0;

}




// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;



int main() {

	ios::sync_with_stdio(0);

	cin.tie(0); cout.tie(0);

	string s; cin >> s;

	vector<string> pat;

	pat.push_back("dream");

	pat.push_back("dreamer");

	pat.push_back("erase");

	pat.push_back("eraser");

	vector<bool> f(s.length() + 1, false);

	f[0] = true;

	for (int i = 1; i <= s.length(); i++) {

		for (auto p : pat) {

			if (i >= p.length() && s.substr(i - p.length(), p.length()) == p && f[i - p.length()]) {

				f[i] = true;

			}

		}

	}

	cout << (f[s.length()] ? "YES\n" : "NO\n");

	return 0;

}


// Optimized solution to the same problem (faster):
#include<cstdio>

#include<string.h>

using namespace std;

char s[1000000];

int len;

bool b=true;

int main(){

	scanf("%s",&s);

	len=strlen(s);

	for (int i=0;i<len;i++){

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

			i+=6;

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

				i+=4;

			}else if ((s[i-1]=='e')&&(s[i]=='r')&&(s[i+1]=='a')&&(s[i+2]=='s')&&(s[i+3]=='e')){

				i+=3;

			}

		}else if ((s[i]=='d')&&(s[i+1]=='r')&&(s[i+2]=='e')&&(s[i+3]=='a')&&(s[i+4]=='m')){

			i+=4;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')&&(s[i+5]=='r')){

			i+=5;

		}else if ((s[i]=='e')&&(s[i+1]=='r')&&(s[i+2]=='a')&&(s[i+3]=='s')&&(s[i+4]=='e')){

			i+=4;

		}else {

			b=false;

		}

		if (b==false){

			break;

		}

	}

if (b==true){

	printf("YES");

}else{

	printf("NO");

}

return 0;}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

string s,a="dream",b="dreamer",c="erase",d="eraser";

int check(int x)

{

	bool flag=1;

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

	{

		if(s[x+i]!=a[i])flag=0;

	}

	if(flag)return x+a.length();

	

	flag=1;

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

	{

		if(s[x+i]!=b[i])flag=0;

	}

	if(flag)return x+b.length();

	

	flag=1;

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

	{

		if(s[x+i]!=c[i])flag=0;

	}

	if(flag)return x+c.length();

	

	flag=1;

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

	{

		if(s[x+i]!=d[i])flag=0;

	}

	if(flag)return x+d.length();

	return -1;

}

int main()

{

	cin>>s;

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

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

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

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

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

	for(int i=0;i<s.length();)

	{

		int nx=check(i);

		if(nx==-1){return puts("NO"),0;}

		else i=nx;

		if(i==s.length()-1)break;

	}

	puts("YES");

}

// Optimized solution to the same problem (faster):
#include<cstdio>



char str[100005];



int main(){

    bool flag = true;

    int r = 0;

    scanf("%s",str);

    for(int i=0;str[i];i++){

        if(str[i]=='d'){

            if(r)r=0;

            if(str[i+1]=='r'&&str[i+2]=='e'&&str[i+3]=='a'&&str[i+4]=='m'){

                r = 1;

                if(str[i+5]=='e'){

                    if(str[i+6]=='r'){

                        i+=4;

                    }else {

                        flag = false;break;

                    }

                }else {

                    i+=4;

                }

            }else {

                flag = false;

                break;

            }

        }else if(str[i]=='e'){

            if(str[i+1]=='r'){

                if(str[i+2]=='a'&&str[i+3]=='s'&&str[i+4]=='e'){

                    if(str[i+5]=='r'){

                        i += 5;

                    }else {

                        i += 4;

                    }

                }else if(r){

                    i += 1;

                }else {

                    flag = false;

                    break;

                }

            }else {

                flag = false;

                break;

            }

            r = 0;

        }else {

            flag = false;

            break;

        }

    }

    if(flag)

        puts("YES");

    else

        puts("NO");

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

using namespace std;

#include <algorithm>

#include <string>

#include <vector>

#define ll long long

struct s

{

    int timu;

    int time;

};

int main()

{



    string s1,s2,s3,s4,s5;

    cin>>s1;

    s2="dream";

    s3="dreamer";

    s4="erase";

    s5="eraser";

    int flag=1;

    int p1,p2,p3,p4;

    int f1,f2,f3,f4;

    ll l;

    while(1)

    {

        flag=0;

        f1=0;f2=0;f3=0;f4=0;

        l=s1.length();

        p1=l-5;

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

        {

            if(s1[p1+i]!=s2[i])

            {

                f1=1;

            }

        }

        if(f1==0)

        {

            s1.erase(p1,5);flag=1;

        }



        l=s1.length();

        p2=l-7;

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

        {

            if(s1[p2+i]!=s3[i])

            {

                f2=1;

            }

        }

        if(f2==0)

        {

            s1.erase(p2,7);flag=1;

        }



        l=s1.length();

        p3=l-5;

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

        {

            if(s1[p3+i]!=s4[i])

            {

                f3=1;

            }

        }

        if(f3==0)

        {

            s1.erase(p3,5);

            flag=1;

        }



        l=s1.length();

        p4=l-6;

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

        {

            if(s1[p4+i]!=s5[i])

            {

                f4=1;

            }

        }

        if(f4==0)

        {

            s1.erase(p4,6);flag=1;

        }



        if(flag==0&&s1.size()!=0)

        {

            cout<<"NO"<<endl;

            return 0;

        }

        if(s1.size()==0)

        {

            cout<<"YES"<<endl;

            return 0;

        }



    }



}


// Optimized solution to the same problem (faster):
#include <cstdio>

#include <cstring>



using namespace std;



int main()

{

  char s[100015];

  int len;

  char c;

  int i;

  bool begin;



  fgets(s, 100015, stdin);

  len = strlen(s) - 1;



#if 0

  printf("string is %s\n", s);

  printf("len %d\n", len);

#endif



  begin = true;

  

  for (i = 0; i<len; i++) {

    if (begin) {

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

        if ((s[i+1] != 'r') ||

            (s[i+2] != 'e') ||

            (s[i+3] != 'a') ||

            (s[i+4] != 'm')) {

           printf("NO\n");

           return 0;

        }

        

        if ((s[i+5] == 'e') &&

            (s[i+6] == 'r') &&

            (s[i+7] != 'a')) {

          i+=6;

        } else {

          i+=4;

        }

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

        if ((s[i+1] != 'r') ||

            (s[i+2] != 'a') ||

            (s[i+3] != 's') ||

            (s[i+4] != 'e')) {

           printf("NO\n");

           return 0;

        }

        if (s[i+5] == 'r') {

          i+=5;

        } else {

          i+=4;

        }



      } else {

        printf("NO\n");

        return 0;

      }

    }

  }



  printf("YES\n");



  return 0;

}


// Fastest known solution for this problem: