Language: C++

import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;
import java.util.Scanner;
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}
public class Main {
    static FastScanner scan=new FastScanner();
    static Scanner scanner=new Scanner(System.in);
    static long gcd (long a, long b) {return b>0?gcd(b,a%b):a;}
    static long lcm (long a, long b) {return a*b/gcd(a,b);}
    static int max(int a,int b) {return a>b?a:b;}
    static int min(int a,int b) {return a<b?a:b;}
    static long factorial(int i) {return i==1?1:i*factorial(i-1);}
    static int lower_bound(int a[],int key) {
        int low=0,high=a.length;
        while(low<high) {
            int mid=((high-low)/2)+low;
            if(a[mid]<=key)low=mid+1;
            else high=mid;
        }
        return high;
        }
    static int upper_bound(int a[],int key) {
        int low=0,high=a.length;
        while(low<high) {
            int mid=((high-low)/2)+low;
            if(a[mid]<key)low=mid+1;
            else high=mid;
        }
        return high;
        }
    static boolean isPrime (long n) {
        if (n==2) return true;
        if (n<2 || n%2==0) return false;
        double d = Math.sqrt(n);
        for (int i=3; i<=d; i+=2)if(n%i==0){return false;}
        return true;
    }
    static int upper_division(int a,int b) {//切り上げ(int)
        if(a%b==0) {
            return a/b;
        }
        else {
            return a/b+1;
        }
    }
    static long lupper_division(long a,long b) {//切り上げ(long)
        if(a%b==0) {
            return a/b;
        }
        else {
            return a/b+1;
        }
    }
    static long lmax(long a,long b) {return Math.max(a, b);}
    static long lmin(long a,long b) {return Math.min(a, b);}
    static int[] setArray(int a) {//配列を作る
        int b[]=new int[a];
        for(int i=0;i<a;i++) {
            b[i]=scan.nextInt();
        }
        return b;
    }
    static String reverce(String str) {//文字列を逆にする
        String strr="";
        for(int i=str.length()-1;i>=0;i--) {
            strr+=str.charAt(i);
        }
        return strr;
    }
    public static void printArray(int[] a) {//配列の空白付き出力
        for(int i=0;i<a.length-1;i++) {
        System.out.print(a[i]+" ");
        }
        System.out.println(a[a.length-1]);
    }
    public static int[][] doublesort(int[][]a) {//二次元配列のソート
        Arrays.sort(a,(x,y)->Integer.compare(x[0],y[0]));
        return a;
    }
    static long modpow(long x,long n,long mo) {//x^n%mo
        long sum=1;
        while(n>0) {
            if((n&1)==1) {
                sum=sum*x%mo;
            }
            x=x*x%mo;
            n>>=1;
        }
        return sum;
    }
    public char[] revch(char ch[]) {//char[]を逆にする
		char ret[]=new char[ch.length];
		for(int i=ch.length-1,j=0;i>=0;i--,j++) {
			ret[j]=ch[i];
		}
		return ret;
	}
	public int[] revint(int ch[]) {//int[]を逆にする
		int ret[]=new int[ch.length];
		for(int i=ch.length-1,j=0;i>=0;i--,j++) {
			ret[j]=ch[i];
		}
		return ret;
	}
    public static void main(String[] args) {
    	String str=scan.next();
		str=reverce(str);
		boolean c=true;
		int ls=str.length();
		while(c) {
			c=false;
			if(ls>=5&&str.subSequence(ls-5,5).equals("dream")){
				ls-=5;
				c=true;
			}
			else if(ls>=5&&str.subSequence(ls-5,5).equals("erase")){
				ls-=5;
				c=true;
			}
			else if(ls>=7&&str.subSequence(ls-7,7).equals("dreamer")){
				ls-=5;
				c=true;
			}
			else if(ls>=6&&str.subSequence(ls-6,6).equals("eraser")){
				ls-=5;
				c=true;
			}
		}
		System.out.println(ls==0?"YES":"NO");
    }
}


Compiler output:
a.cc:1:1: error: 'import' does not name a type
    1 | import java.io.IOException;
      | ^~~~~~
a.cc:1:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:2:1: error: 'import' does not name a type
    2 | import java.io.InputStream;
      | ^~~~~~
a.cc:2:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:3:1: error: 'import' does not name a type
    3 | import java.util.Arrays;
      | ^~~~~~
a.cc:3:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:4:1: error: 'import' does not name a type
    4 | import java.util.NoSuchElementException;
      | ^~~~~~
a.cc:4:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:5:1: error: 'import' does not name a type
    5 | import java.util.Scanner;
      | ^~~~~~
a.cc:5:1: note: C++20 'import' only available with '-fmodules-ts'
a.cc:7:12: error: expected ':' before 'final'
    7 |     private final InputStream in = System.in;
      |            ^~~~~~
      |            :
a.cc:7:13: error: 'final' does not name a type
    7 |     private final InputStream in = System.in;
      |             ^~~~~
a.cc:8:12: error: expected ':' before 'final'
    8 |     private final byte[] buffer = new byte[1024];
      |            ^~~~~~
      |            :
a.cc:8:13: error: 'final' does not name a type
    8 |     private final byte[] buffer = new byte[1024];
      |             ^~~~~
a.cc:9:12: error: expected ':' before 'int'
    9 |     private int ptr = 0;
      |            ^~~~
      |            :
a.cc:10:12: error: expected ':' before 'int'
   10 |     private int buflen = 0;
      |            ^~~~
      |            :
a.cc:11:12: error: expected ':' before 'boolean'
   11 |     private boolean hasNextByte() {
      |            ^~~~~~~~
      |            :
a.cc:11:13: error: 'boolean' does not name a type; did you mean 'bool'?
   11 |     private boolean hasNextByte() {
      |             ^~~~~~~
      |             bool
a.cc:27:12: error: expected ':' before 'int'
   27 |     private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
      |            ^~~~
      |            :
a.cc:28:12: error: expected ':' before 'static'
   28 |     private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
      |            ^~~~~~~
      |            :
a.cc:28:20: error: 'boolean' does not name a type; did you mean 'bool'?
   28 |     private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
      |                    ^~~~~~~
      |                    bool
a.cc:29:11: error: expected ':' before 'boolean'
   29 |     public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
      |           ^~~~~~~~
      |           :
a.cc:29:12: error: 'boolean' does not name a type; did you mean 'bool'?
   29 |     public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
      |            ^~~~~~~
      |            bool
a.cc:30:11: error: expected ':' before 'String'
   30 |     public String next() {
      |           ^~~~~~~
      |           :
a.cc:30:12: error: 'String' does not name a type
   30 |     public String next() {
      |            ^~~~~~
a.cc:40:11: error: expected ':' before 'long'
   40 |     public long nextLong() {
      |           ^~~~~
      |           :
a.cc:64:11: error: expected ':' before 'int'
   64 |     public int nextInt() {
      |           ^~~~
      |           :
a.cc:69:11: error: expected ':' before 'double'
   69 |     public double nextDouble() { return Double.parseDouble(next());}
      |           ^~~~~~~
      |           :
a.cc:70:2: error: expected ';' after class definition
   70 | }
      |  ^
      |  ;
a.cc: In member function 'int FastScanner::readByte()':
a.cc:27:34: error: 'hasNextByte' was not declared in this scope
   27 |     private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
      |                                  ^~~~~~~~~~~
a.cc:27:56: error: 'buffer' was not declared in this scope; did you mean 'buflen'?
   27 |     private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
      |                                                        ^~~~~~
      |                                                        buflen
a.cc: In member function 'long int FastScanner::nextLong()':
a.cc:41:14: error: 'hasNext' was not declared in this scope
   41 |         if (!hasNext()) throw new NoSuchElementException();
      |              ^~~~~~~
a.cc:41:35: error: expected type-specifier before 'NoSuchElementException'
   41 |         if (!hasNext()) throw new NoSuchElementException();
      |                                   ^~~~~~~~~~~~~~~~~~~~~~
a.cc:43:9: error: 'boolean' was not declared in this scope; did you mean 'bool'?
   43 |         boolean minus = false;
      |         ^~~~~~~
      |         bool
a.cc:46:13: error: 'minus' was not declared in this scope
   46 |             minus = true;
      |             ^~~~~
a.cc:50:23: error: expected type-specifier before 'NumberFormatException'
   50 |             throw new NumberFormatException();
      |                       ^~~~~~~~~~~~~~~~~~~~~
a.cc:56:34: error: 'isPrintableChar' was not declared in this scope
   56 |             }else if(b == -1 || !isPrintableChar(b)){
      |                                  ^~~~~~~~~~~~~~~
a.cc:57:24: error: 'minus' was not declared in this scope
   57 |                 return minus ? -n : n;
      |                        ^~~~~
a.cc:59:27: error: expected type-specifier before 'NumberFormatException'
   59 |                 throw new NumberFormatException();
      |                           ^~~~~~~~~~~~~~~~~~~~~
a.cc: In member function 'int FastScanner::nextInt()':
a.cc:66:18: error: 'Integer' was not declared in this scope
   66 |         if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      |                  ^~~~~~~
a.cc:66:73: error: expected type-specifier before 'NumberFormatException'
   66 |         if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
      |                                                                         ^~~~~~~~~~~~~~~~~~~~~
a.cc: In member function 'double FastScanner::nextDouble()':
a.cc:69:41: error: 'Double' was not declared in this scope; did you mean 'double'?
   69 |     public double nextDouble() { return Double.parseDouble(next());}
      |                                         ^~~~~~
      |                                         double
a.cc:69:60: error: 'next' was not declared in this scope; did you mean 'nextInt'?
   69 |     public double nextDouble() { return Double.parseDouble(next());}
      |                                                            ^~~~
      |                                                            nextInt
a.cc: At global scope:
a.cc:71:1: error: expected unqualified-id before 'public'
   71 | public class Main {
      | ^~~~~~