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

namespace chtholly{

typedef long long ll;

#define re0 register int

#define rec register char

#define rel register ll

#define gc getchar

#define pc putchar

#define p32 pc(' ')

#define pl puts("")

/*By Citrus*/

inline int read(){

  int x=0,f=1;char c=gc();

  for (;!isdigit(c);c=gc()) f^=c=='-';

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return f?x:-x;

  }

inline bool read(ll &x){

  x=0;int f=1;char c=gc();

  for (;!isdigit(c)&&~c;c=gc()) f^=c=='-';

  if (!~c) return 0;

  for (;isdigit(c);c=gc()) x=(x<<3)+(x<<1)+(c^'0');

  return x=f?x:-x,1;

  }

template <typename mitsuha>

inline int write(mitsuha x){

  if (!x) return pc(48);

  if (x<0) x=-x,pc('-');

  int bit[20],i,p=0;

  for (;x;x/=10) bit[++p]=x%10;

  for (i=p;i;--i) pc(bit[i]+48);

  }

inline char fuhao(){

  char c=gc();

  for (;isspace(c);c=gc());

  return c;

  }

}using namespace chtholly;

using namespace std;

string s;

int main(){

ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);

cin>>s;

for (;!s.empty();){

  string tmp=s.substr(s.size()-5,5);

  if (tmp=="erase"||tmp=="dream"){

    s.erase(s.size()-5,5);

    continue;

    }

  tmp=s.substr(s.size()-6,6);

  if (tmp=="eraser"){

    s.erase(s.size()-6,6);

    continue;

    }

  tmp=s.substr(s.size()-7,7);

  if (tmp=="dreamer"){

    s.erase(s.size()-7,7);

    continue;

    }

  return puts("NO"),0;

  }

puts("YES");

}

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

#include <cstring>



char str[100010];

bool vis[100010] = {1};

int main() {

	scanf("%s", str);

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

		if (vis[i]) {

			if (strncmp(str + i, "dreamer", 7) == 0)

				vis[i + 7] = 1;

			if (strncmp(str + i, "eraser", 6) == 0)

				vis[i + 6] = 1;

			if (strncmp(str + i, "dream", 5) == 0)

				vis[i + 5] = 1;

			if (strncmp(str + i, "erase", 5) == 0)

				vis[i + 5] = 1;

		}

	}

	puts(vis[strlen(str)] ? "YES" : "NO");

	return 0;

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <cmath>

#include <queue>

#include <stack>

#include <map>

#include <set>

#include <vector>

#include <iomanip>

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

#define rt return

#define dll(x) scanf("%I64d",&x)

#define xll(x) printf("%I64d\n",x)

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

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

#define rep(i,x,n) for(int i=x;i<n;i++)

#define repd(i,x,n) for(int i=x;i<=n;i++)

#define pii pair<int,int>

#define pll pair<long long ,long long>

#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)

#define MS0(X) memset((X), 0, sizeof((X)))

#define MSC0(X) memset((X), '\0', sizeof((X)))

#define pb push_back

#define mp make_pair

#define fi first

#define se second

#define eps 1e-6

#define gg(x) getInt(&x)

#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;

using namespace std;

typedef long long ll;

ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll powmod(ll a,ll b,ll MOD){ll ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}

inline void getInt(int* p);

const int maxn=1000010;

const int inf=0x3f3f3f3f;

/*** TEMPLATE CODE * * STARTS HERE ***/



int main()

{

    //freopen("D:\\common_text\\code_stream\\in.txt","r",stdin);

	//freopen("D:\\common_text\\code_stream\\out.txt","w",stdout);

	string s;

	cin>>s;

	while(1)

	{

		int len=s.length();

		if(len<5)

		{

			cout<<"NO"<<endl;

			break;

		}



        if(len>=11&&s.substr(0,11)=="dreameraser")

		{

			s.erase(0,11);

		}

		else if(len>=10&&s.substr(0,10)=="dreamerase")

		{

			s.erase(0,10);

		}else if(s.substr(0,7)=="dreamer")

		{

			s.erase(0,7);

		}else if(s.substr(0,5)=="dream")

		{

			s.erase(0,5);

		}else if(s.substr(0,6)=="eraser")

		{

			s.erase(0,6);

		}else if(s.substr(0,5)=="erase")

		{

			s.erase(0,5);

		}



		if(s.length()==0)

		{

			cout<<"YES"<<endl;

			break;

		}

		if(len==s.length())

        {

            cout<<"NO"<<endl;

			break;

        }

	}

    return 0;

}



inline void getInt(int* p) {

    char ch;

    do {

        ch = getchar();

    } while (ch == ' ' || ch == '\n');

    if (ch == '-') {

        *p = -(getchar() - '0');

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 - ch + '0';

        }

    }

    else {

        *p = ch - '0';

        while ((ch = getchar()) >= '0' && ch <= '9') {

            *p = *p * 10 + ch - '0';

        }

    }

}




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

#include <cstring>



char str[100010];

bool vis[100010] = {1};

int main() {

	scanf("%s", str);

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

		if (vis[i]) {

			if (strncmp(str + i, "dreamer", 7) == 0)

				vis[i + 7] = 1;

			if (strncmp(str + i, "eraser", 6) == 0)

				vis[i + 6] = 1;

			if (strncmp(str + i, "dream", 5) == 0)

				vis[i + 5] = 1;

			if (strncmp(str + i, "erase", 5) == 0)

				vis[i + 5] = 1;

		}

	}

	puts(vis[strlen(str)] ? "YES" : "NO");

	return 0;

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

#include <cstring>

#include <algorithm>



char s[4][200] = {"dreamer", "dream", "erase", "eraser"};

char str[200000];

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

int len;

bool flg;



void dfs(int idx) {

//    std::cout << cur << " " <<ll <<  std::endl;

    if (flg) return;

    if (idx == len) {

        flg = true;

        return;

    } else if (idx > len) return;

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

        bool fl = true;

        for (int i = 0; i < l[j]; ++i) {

            if (s[j][i] != str[idx + i]) {

                fl = false;

                break;

            }

        }

        if (fl) dfs(idx + l[j]);

    }

}



int main() {

    std::cin >> str;

    len = strlen(str);

    dfs(0);

    puts(flg ? "YES" : "NO");

}

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

#include <cstring>



char str[100010];

bool vis[100010] = {1};

int main() {

	scanf("%s", str);

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

		if (vis[i]) {

			if (strncmp(str + i, "dreamer", 7) == 0)

				vis[i + 7] = 1;

			if (strncmp(str + i, "eraser", 6) == 0)

				vis[i + 6] = 1;

			if (strncmp(str + i, "dream", 5) == 0)

				vis[i + 5] = 1;

			if (strncmp(str + i, "erase", 5) == 0)

				vis[i + 5] = 1;

		}

	}

	puts(vis[strlen(str)] ? "YES" : "NO");

	return 0;

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

#include<iostream>

#include<string>

#include<cmath>

#include<algorithm>

#include<queue>

#include<set>

#include<stack>

#include<cstring>

#include<map>

#include<vector>

#define ll long long int

using namespace std;

int main()

{

   string s;

   cin>>s;

   ll 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";

}


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

#include <cstring>



char str[100010];

bool vis[100010] = {1};

int main() {

	scanf("%s", str);

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

		if (vis[i]) {

			if (strncmp(str + i, "dreamer", 7) == 0)

				vis[i + 7] = 1;

			if (strncmp(str + i, "eraser", 6) == 0)

				vis[i + 6] = 1;

			if (strncmp(str + i, "dream", 5) == 0)

				vis[i + 5] = 1;

			if (strncmp(str + i, "erase", 5) == 0)

				vis[i + 5] = 1;

		}

	}

	puts(vis[strlen(str)] ? "YES" : "NO");

	return 0;

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

#include <iostream>

using namespace std;



const int MAX_N = 1e5 + 5, MOD = 1e9 + 7;

int n;

bool dp[MAX_N];

string s;



int main() {

    cin >> s;

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

   		if (i < 5) {

   			dp[i] = false;

   			continue;

   		}



   		if (i == 5) {

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

   				dp[i] = true;

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

   				dp[i] = true;

   			continue;

   		}



   		if (i == 6) {

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

   				dp[i] = true;

   			continue;

   		}



   		if (i == 7) {

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

   				dp[i] = true;

   			continue;

   		}



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

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

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



   			continue;

   		}





   		if (s[i - 1] == 'e') {

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

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



   			continue;

   		}



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

   			continue;



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

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

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



   			continue;

   		}

   		if (s[i - 3] == 's') {

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

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



   			continue;

   		}

   	}



   	cout << (dp[s.size()]? "YES": "NO");

    return 0;

}

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

#include <cstring>



char str[100010];

bool vis[100010] = {1};

int main() {

	scanf("%s", str);

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

		if (vis[i]) {

			if (strncmp(str + i, "dreamer", 7) == 0)

				vis[i + 7] = 1;

			if (strncmp(str + i, "eraser", 6) == 0)

				vis[i + 6] = 1;

			if (strncmp(str + i, "dream", 5) == 0)

				vis[i + 5] = 1;

			if (strncmp(str + i, "erase", 5) == 0)

				vis[i + 5] = 1;

		}

	}

	puts(vis[strlen(str)] ? "YES" : "NO");

	return 0;

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

#define ll long long



using namespace std;



string s[5]={"dream","dreamer","erase","eraser"},a;



void dfs(int pos)

{

	if(pos==a.size())

	{

		printf("YES");

		exit(0);

	}

	if(a.substr(pos,5)==s[0])dfs(pos+5);

	if(a.substr(pos,5)==s[2])dfs(pos+5);

	if(a.substr(pos,6)==s[3])dfs(pos+6);

	if(a.substr(pos,7)==s[1])dfs(pos+7);

}



int main()

{

	cin>>a;

	dfs(0);

	printf("NO");

	return 0;

}

// Faster C++ solution for the same problem (measured speedup: 5.333941093969145x):
#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;}
// Slower C++ solution:
#include<iostream>



using namespace std;



int main()

{

    int i =0;

    string s;

    cin >> s;

    bool flag = true;

    while(i<s.length())

    {

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

        {

            if(i+5<s.length()&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e'&&s[i+5]=='r')

            {

                i+=6;

            }

            else if(i+4<s.length()&&s[i+1]=='r'&&s[i+2]=='a'&&s[i+3]=='s'&&s[i+4]=='e')

            {

                i+=5;

            }

            else if(i+1<s.length()&&s[i+1]=='r'&&i>1&&s[i-1]=='m')

            {

                i+=2;

            }

            else{

                flag = false;

                break;

            }

        }

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

        {



            if(i+4<s.length()&&s[i+1]=='r'&&s[i+2]=='e'&&s[i+3]=='a'&&s[i+4]=='m')

            {

                i+=5;

            }

            else{

                flag = false;

                break;

            }

        }

        else{

            flag = false;

            break;

        }

    }

    flag?cout<<"YES"<<endl:cout<<"NO"<<endl;

    return 0;

}






// Faster C++ solution for the same problem (measured speedup: 5.31433559129838x):
#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;}
// Slower C++ solution:
#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;

}


// Faster C++ solution for the same problem (measured speedup: 5.305395243352929x):
#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;}
// Slower C++ solution:
  #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;

}

// Faster C++ solution for the same problem (measured speedup: 5.361024738145684x):
#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;}
// Slower C++ solution:
#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";

}

// Faster C++ solution for the same problem (measured speedup: 5.314384828862164x):
#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;}
// Slower C++ solution:
#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");

}

// Faster C++ solution for the same problem (measured speedup: 5.427404434364836x):
#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;}
// Slower C++ solution:
#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;

}

// Faster C++ solution for the same problem (measured speedup: 5.348804870042673x):
#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;}