criyle/codenet-compile-errors huggingface dataset:
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
 
using namespace std;

int main(){
    string devide[4]={"dream","dreamer","erase","eraser"};
    for(int i=0;i<4;i++)reverse(devide[i].begin(),devide.end());
    string S; cin>>S;
    for(int i=0;i<S.size();i++){
        bool can2=0;
        for(int j=0;j<4;j++){
            string d = devide[j];
            if(S.substr(i,d.size())==d){
                can2=1;
                i+=d.size();
            }
        }
        if(!can2){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:58: error: request for member 'end' in 'devide', which is of non-class type 'std::string [4]' {aka 'std::__cxx11::basic_string<char> [4]'}
   12 |     for(int i=0;i<4;i++)reverse(devide[i].begin(),devide.end());
      |                                                          ^~~
Language: C++

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
 
using namespace std;

int main(){
    string devide[4]={"dream","dreamer","erase","eraser"};
    fot(int i=0;i<4;i++)reverse(devide[i].begin(),devide.end());
    string S; cin>>S;
    for(int i=0;i<S.size();i++){
        bool can2=0;
        for(int i=0;i<4;i++){
            string d = devide[i];
            if(S.substr(i.d.size())==d){
                can2=1;
                i+=d.size();
            }
        }
        if(!can2){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:9: error: expected primary-expression before 'int'
   12 |     fot(int i=0;i<4;i++)reverse(devide[i].begin(),devide.end());
      |         ^~~
a.cc:12:17: error: 'i' was not declared in this scope
   12 |     fot(int i=0;i<4;i++)reverse(devide[i].begin(),devide.end());
      |                 ^
a.cc:18:27: error: request for member 'd' in 'i', which is of non-class type 'int'
   18 |             if(S.substr(i.d.size())==d){
      |                           ^
Language: Java

import java.util.Scanner;

public static void main(String[] args) {
  Scanner sc = new Scanner(System.in);
  StringBuffer str = new StringBuffer(sc.next());
  String S = str.reverse().toString();
  sc.close();
  System.out.println(solve(S));
}

public static String solve(String S) {
  int index = 0;
  while(index+5<S.length()) {
    if(S.substring(index,index+5).equals("esare")) {
      index += 5;
    }else if(S.substring(index,index+5).equals("maerd")) {
      index += 5;
    }else if(S.substring(index,index+6).equals("resare")) {
      index += 6;
    }else if(S.substring(index,index+7).equals("remaerd")) {
      index += 7;
    }else {
      return "No";
    }
  }
  return "Yes";
}

Compiler output:
Main.java:3: error: unnamed classes are a preview feature and are disabled by default.
public static void main(String[] args) {
              ^
  (use --enable-preview to enable unnamed classes)
1 error
Language: Java

import java.util.Scanner;

public class AssignmentD {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		StringBuffer str = new StringBuffer(sc.next());
		String S = str.reverse().toString();
		sc.close();
		System.out.println(solve(S));
	}
	
	public static String solve(String S) {
		int index = 0;
		while(index+5<S.length()) {
			if(S.substring(index,index+5).equals("esare")) {
				index += 5;
			}else if(S.substring(index,index+5).equals("maerd")) {
				index += 5;
			}else if(S.substring(index,index+6).equals("resare")) {
				index += 6;
			}else if(S.substring(index,index+7).equals("remaerd")) {
				index += 7;
			}else {
				return "No";
		}
		}
		return "Yes";
	}
}

Compiler output:
Main.java:3: error: class AssignmentD is public, should be declared in a file named AssignmentD.java
public class AssignmentD {
       ^
1 error
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;

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

  for (int i = 0; i < s.size();) {
    string t = s.substr(i, 7);
    if (t = "remaerd")
      i += 7;
    else if (t = "resare")
      i += 6;
    else if (t = "maerd")
      i += 5;
    else if (t = "esare")
      i += 5;
    else {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:11: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"remaerd"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   12 |     if (t = "remaerd")
      |         ~~^~~~~~~~~~~
      |           |
      |           std::__cxx11::basic_string<char>
a.cc:14:16: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"resare"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   14 |     else if (t = "resare")
      |              ~~^~~~~~~~~~
      |                |
      |                std::__cxx11::basic_string<char>
a.cc:16:16: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"maerd"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   16 |     else if (t = "maerd")
      |              ~~^~~~~~~~~
      |                |
      |                std::__cxx11::basic_string<char>
a.cc:18:16: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"esare"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   18 |     else if (t = "esare")
      |              ~~^~~~~~~~~
      |                |
      |                std::__cxx11::basic_string<char>
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  string s;
  cin >> s;

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

  for (int i = 0; i < s.size();) {
    string t = s。substr(i, 7);
    if (t = "remaerd")
      i += 7;
    else if (t = "resare")
      i += 6;
    else if (t = "maerd")
      i += 5;
    else if (t = "esare")
      i += 5;
    else {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;
}

Compiler output:
a.cc:11:16: error: extended character 。 is not valid in an identifier
   11 |     string t = s。substr(i, 7);
      |                ^
a.cc: In function 'int main()':
a.cc:11:16: error: 's\U00003002substr' was not declared in this scope
   11 |     string t = s。substr(i, 7);
      |                ^~~~~~~~~
a.cc:12:11: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"remaerd"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   12 |     if (t = "remaerd")
      |         ~~^~~~~~~~~~~
      |           |
      |           std::__cxx11::basic_string<char>
a.cc:14:16: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"resare"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   14 |     else if (t = "resare")
      |              ~~^~~~~~~~~~
      |                |
      |                std::__cxx11::basic_string<char>
a.cc:16:16: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"maerd"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   16 |     else if (t = "maerd")
      |              ~~^~~~~~~~~
      |                |
      |                std::__cxx11::basic_string<char>
a.cc:18:16: error: could not convert 't.std::__cxx11::basic_string<char>::operator=(((const char*)"esare"))' from 'std::__cxx11::basic_string<char>' to 'bool'
   18 |     else if (t = "esare")
      |              ~~^~~~~~~~~
      |                |
      |                std::__cxx11::basic_string<char>
Language: C++

//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  string s;cin>>s;
  while(true){
    if(s.substr(n-7)=="dreamer")s.erase(n-7);
    else if(s.substr(n-5)=="dream")s.erase(n-5);
    else if(s.substr(n-6)=="eraser")s.erase(n-6);
    else if(s.substr(n-5)=="erase")s.erase(n-5);
    else break;
  }
  if(s.size()==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:17: error: 'n' was not declared in this scope
   18 |     if(s.substr(n-7)=="dreamer")s.erase(n-7);
      |                 ^
Language: C++

#include <bits/stdc++.h>
using namespace std;


int test1(string s) {
  int r=0;
  
  if (s.substr(0,6)=="dreamer") r=7;
  else if (s.substr(0,4)=="dream") r=5;
  else if (s.substr(0,5)=="eraser") r=6;
  else if (s.substr(0,4)=="erase") r=5;
  
  return r;
}

int main() {
  string str;
  cin >> str;

  int r;
  while(str.size()>0) {
    r=test1(str);
    if(r==0) break;
    
    if(r>5) {
      if (test1(str.substr(r-1))==0) r=5;}
    str=str.substr(r-1);
  }
  
  if(r==0) cout << "NO" <<endl;
  else cout << "YES" <<endl
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:31:28: error: expected ';' before '}' token
   31 |   else cout << "YES" <<endl
      |                            ^
      |                            ;
   32 | }
      | ~
Language: C++

#include <bits/stdc++.h>
using namespace std;


int test1(string s) {
  int r=0;
  
  if (s.substr(0,6)=="dreamer") r=7;
  else if (s.substr(0,4)=="dream") r=5;
  else if (s.substr(0,5)=="eraser") r=6;
  else if (s.substr(0,4)=="erase") r=5;
  
  return r;
}

int main() {
  string str;
  cin >> str;

  int r;
  while(str.size()>0) {
    r=test1(str);
    if(r==0) break;
    
    if(r>5) {
      if test1(str.substr(r-1))==0) r=5;}
    str=str.substr(r-1);
  }
  
  if(r==0) cout << "NO" <<endl;
  else cout << "YES" <<endl
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:26:10: error: expected '(' before 'test1'
   26 |       if test1(str.substr(r-1))==0) r=5;}
      |          ^~~~~
      |          (
a.cc:31:28: error: expected ';' before '}' token
   31 |   else cout << "YES" <<endl
      |                            ^
      |                            ;
   32 | }
      | ~
Language: C++

#include <bits/stdc++.h>
using namespace std;


int test1(string s) {
  int r=0;
  
  if s.substr(0,6)=="dreamer" r=7;
  else if s.substr(0,4)=="dream" r=5;
  else if s.substr(0,5)=="eraser" r=6;
  else if s.substr(0,4)=="erase" r=5;
  
  return r;
}

int main() {
  string str;
  cin >> str;

  int r;
  while(str.size()>0) {
    r=test1(str);
    if(r==0) break;
    
    if(r>5) {
      if test1(str.substr(r-1))==0) r=5;}
    str=str.substr(r-1);
  }
  
  if(r==0) cout << "NO" <<endl;
  else cout << "YES" <<endl
}
  


Compiler output:
a.cc: In function 'int test1(std::string)':
a.cc:8:6: error: expected '(' before 's'
    8 |   if s.substr(0,6)=="dreamer" r=7;
      |      ^
      |      (
a.cc:9:3: error: 'else' without a previous 'if'
    9 |   else if s.substr(0,4)=="dream" r=5;
      |   ^~~~
a.cc:9:11: error: expected '(' before 's'
    9 |   else if s.substr(0,4)=="dream" r=5;
      |           ^
      |           (
a.cc:10:3: error: 'else' without a previous 'if'
   10 |   else if s.substr(0,5)=="eraser" r=6;
      |   ^~~~
a.cc:10:11: error: expected '(' before 's'
   10 |   else if s.substr(0,5)=="eraser" r=6;
      |           ^
      |           (
a.cc:11:3: error: 'else' without a previous 'if'
   11 |   else if s.substr(0,4)=="erase" r=5;
      |   ^~~~
a.cc:11:11: error: expected '(' before 's'
   11 |   else if s.substr(0,4)=="erase" r=5;
      |           ^
      |           (
a.cc: In function 'int main()':
a.cc:26:10: error: expected '(' before 'test1'
   26 |       if test1(str.substr(r-1))==0) r=5;}
      |          ^~~~~
      |          (
a.cc:31:28: error: expected ';' before '}' token
   31 |   else cout << "YES" <<endl
      |                            ^
      |                            ;
   32 | }
      | ~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  string str;
  cin >> str;

  int r;
  while(str.size()>0) {
    r=test1(str);
    if(r==0) break;
    
    if(r>5) {
      if test1(str.substr(r-1))==0) r=5;}
    srt=str.substr(r-1);
  }
  
  if(r==0) cout << "NO" <<endl;
  else cout << "YES" <<endl
}

int test1(string s) {
  int r=0;
  
  if s.substr(0,6)=="dreamer" r=7;
  else if s.substr(0,4)=="dream" r=5;
  else if s.substr(0,5)=="eraser" r=6;
  else if s.substr(0,4)=="erase" r=5;
  
  return r;
}
  


Compiler output:
a.cc: In function 'int main()':
a.cc:10:7: error: 'test1' was not declared in this scope
   10 |     r=test1(str);
      |       ^~~~~
a.cc:14:10: error: expected '(' before 'test1'
   14 |       if test1(str.substr(r-1))==0) r=5;}
      |          ^~~~~
      |          (
a.cc:15:5: error: 'srt' was not declared in this scope; did you mean 'str'?
   15 |     srt=str.substr(r-1);
      |     ^~~
      |     str
a.cc:19:28: error: expected ';' before '}' token
   19 |   else cout << "YES" <<endl
      |                            ^
      |                            ;
   20 | }
      | ~                           
a.cc: In function 'int test1(std::string)':
a.cc:25:6: error: expected '(' before 's'
   25 |   if s.substr(0,6)=="dreamer" r=7;
      |      ^
      |      (
a.cc:26:3: error: 'else' without a previous 'if'
   26 |   else if s.substr(0,4)=="dream" r=5;
      |   ^~~~
a.cc:26:11: error: expected '(' before 's'
   26 |   else if s.substr(0,4)=="dream" r=5;
      |           ^
      |           (
a.cc:27:3: error: 'else' without a previous 'if'
   27 |   else if s.substr(0,5)=="eraser" r=6;
      |   ^~~~
a.cc:27:11: error: expected '(' before 's'
   27 |   else if s.substr(0,5)=="eraser" r=6;
      |           ^
      |           (
a.cc:28:3: error: 'else' without a previous 'if'
   28 |   else if s.substr(0,4)=="erase" r=5;
      |   ^~~~
a.cc:28:11: error: expected '(' before 's'
   28 |   else if s.substr(0,4)=="erase" r=5;
      |           ^
      |           (
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main() {
  string str;
  cin >> str;

  int r
  while(str.size()>0) {
    r=test1(str);
    if(r==0) break;
    
    if(r>5) {
      if test1(str.substr(r-1))==0) r=5;}
    srt=str.substr(r-1);
  }
  
  if(r==0) cout << "NO" <<endl;
  else cout << "YES" <<endl
}

int test1(string s) {
  int r=0;
  
  if s.substr(0,6)=="dreamer" r=7;
  else if s.substr(0,4)=="dream" r=5;
  else if s.substr(0,5)=="eraser" r=6;
  else if s.substr(0,4)=="erase" r=5;
  
  return r;
}
  

Compiler output:
a.cc: In function 'int main()':
a.cc:9:3: error: expected initializer before 'while'
    9 |   while(str.size()>0) {
      |   ^~~~~
a.cc:18:6: error: 'r' was not declared in this scope
   18 |   if(r==0) cout << "NO" <<endl;
      |      ^
a.cc:19:28: error: expected ';' before '}' token
   19 |   else cout << "YES" <<endl
      |                            ^
      |                            ;
   20 | }
      | ~                           
a.cc: In function 'int test1(std::string)':
a.cc:25:6: error: expected '(' before 's'
   25 |   if s.substr(0,6)=="dreamer" r=7;
      |      ^
      |      (
a.cc:26:3: error: 'else' without a previous 'if'
   26 |   else if s.substr(0,4)=="dream" r=5;
      |   ^~~~
a.cc:26:11: error: expected '(' before 's'
   26 |   else if s.substr(0,4)=="dream" r=5;
      |           ^
      |           (
a.cc:27:3: error: 'else' without a previous 'if'
   27 |   else if s.substr(0,5)=="eraser" r=6;
      |   ^~~~
a.cc:27:11: error: expected '(' before 's'
   27 |   else if s.substr(0,5)=="eraser" r=6;
      |           ^
      |           (
a.cc:28:3: error: 'else' without a previous 'if'
   28 |   else if s.substr(0,4)=="erase" r=5;
      |   ^~~~
a.cc:28:11: error: expected '(' before 's'
   28 |   else if s.substr(0,4)=="erase" r=5;
      |           ^
      |           (
Language: C++

#abc049 c
s=input()
divide=["dream","dreamer","erase","eraser"]

s=s[::-1]
for i,x in enumerate(divide):
    divide[i]=x[::-1]

ans=True
i=0
while i<len(s):
    flag=False
    for x in divide:
        lx=len(x)
        if s[i:i+lx] in divide:
             flag=True
             i+=lx
    if flag==False:
        ans=False
        break
if flag:
     print("YES")
else:
     print("NO")


Compiler output:
a.cc:1:2: error: invalid preprocessing directive #abc049
    1 | #abc049 c
      |  ^~~~~~
a.cc:2:1: error: 's' does not name a type
    2 | s=input()
      | ^
Language: C++

#include <iostream>
#include <vector>

int main()
{
    std::vector<std::string> candidates = {"dream", "dreamer", "erase", "eraser"};
    for (auto &c : candidates)
    {
        std::reverse(c.begin(), c.end());
    }

    std::string S;
    std::cin >> S;
    std::reverse(S.begin(), S.end());

    while (0 < S.size())
    {
        bool canReplace = false;
        // 一致する文字列を探す
        for (auto &c : candidates)
        {
            auto str = S.substr(0, c.size());
            if (str == c)
            {
                S = S.substr(c.size(), S.size());
                canReplace = true;
                continue;
            }
        }

        if (!canReplace)
        {
            std::cout << "No";
            return 0;
        }
    }

    std::cout << "Yes";
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:14: error: 'reverse' is not a member of 'std'
    9 |         std::reverse(c.begin(), c.end());
      |              ^~~~~~~
a.cc:14:10: error: 'reverse' is not a member of 'std'
   14 |     std::reverse(S.begin(), S.end());
      |          ^~~~~~~
Language: C++

int main(){
	string s;
	cin >> s;
	reverse(s.begin(),s.end());
	string divide[4] = {"maerd","remaerd","esare","resare"};
	rep(i,s.size()){
		bool ok = false;
		rep(j,4){
			if(s.substr(i, divide[j].size()) == divide[j]){
				ok = true;
				i += divide[j].size() - 1;
			}
		}
		if(!ok){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:2:9: error: 'string' was not declared in this scope
    2 |         string s;
      |         ^~~~~~
a.cc:3:9: error: 'cin' was not declared in this scope
    3 |         cin >> s;
      |         ^~~
a.cc:3:16: error: 's' was not declared in this scope
    3 |         cin >> s;
      |                ^
a.cc:4:9: error: 'reverse' was not declared in this scope
    4 |         reverse(s.begin(),s.end());
      |         ^~~~~~~
a.cc:5:15: error: expected ';' before 'divide'
    5 |         string divide[4] = {"maerd","remaerd","esare","resare"};
      |               ^~~~~~~
      |               ;
a.cc:6:13: error: 'i' was not declared in this scope
    6 |         rep(i,s.size()){
      |             ^
a.cc:6:9: error: 'rep' was not declared in this scope
    6 |         rep(i,s.size()){
      |         ^~~
a.cc:19:9: error: 'cout' was not declared in this scope
   19 |         cout << "YES" << endl;
      |         ^~~~
a.cc:19:26: error: 'endl' was not declared in this scope
   19 |         cout << "YES" << endl;
      |                          ^~~~
Language: C++

if(c=="remaerd"){
        size-=7;
        if(size>0){
            t.erase(t.begin(),t.begin()+7);
            dp(t,size,ans);
        }
        else{
            if(size==0){
                *ans="YES";
            }
        }
    }

Compiler output:
a.cc:1:1: error: expected unqualified-id before 'if'
    1 | if(c=="remaerd"){
      | ^~
Language: C++

#include <bits/stdc++.h>
using namespace std;
int main(){
string s;
cin >> s;
reverse(s.begin(), s.end());
string vec[4] = {"dream", "dreamer", "erase", "eraser"};
for (int i=0; i<4; i++){
    reverse(vec[i].begin(), vec[i].end());
}

int i=0; bool can=false;
while(i<s.size()){
    can=false;
    for(int j=0; j<4; j++){
        if(vec.substr(i, vec[j].size())==vec[j]){
            i+=vec[j].size();
            can=true;
        }
    if(can) break;
    }
}

if(can) cout << "YES" << endl;
else cout << "NO" << endl;

}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:16: error: request for member 'substr' in 'vec', which is of non-class type 'std::string [4]' {aka 'std::__cxx11::basic_string<char> [4]'}
   16 |         if(vec.substr(i, vec[j].size())==vec[j]){
      |                ^~~~~~
Language: C++

#include <iostream>
#include <string>

std::string divide[4] = {"dream", "dreamer", "erase", "eraser"};

int main(int argc, char *argv[]) {
  std::string S;
  std::cin >> S;

  std::reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) {
    reverse(divide[i].begin(), divide[i].end());
  }

  bool can = true;
  for (int i = 0; i < S.size();) {
    bool can2 = false;
    for (int j = 0; j < 4; ++j) {
      std::string d = divide[j];
      if (S.substr(i, d.size()) == d) {
        can2 = true;
        i += d.size();
      }
    }
    if (!can2) {
      can = false;
      break;
    }
  }

  std::cout << (can ? "YES" : "NO") << std::endl;
}


Compiler output:
a.cc: In function 'int main(int, char**)':
a.cc:10:8: error: 'reverse' is not a member of 'std'
   10 |   std::reverse(S.begin(), S.end());
      |        ^~~~~~~
a.cc:12:5: error: 'reverse' was not declared in this scope
   12 |     reverse(divide[i].begin(), divide[i].end());
      |     ^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>

using namespace std;


int main(){
    string s;
    string divide[4] = {"dream", "dreamer", "erase", "eraser"};

    cin>>s;

    //各文字列を反転させ、後ろから考える
    reverse(s.begin(), s.end());
    for (int i = 0; i < 4; i++){
        reverse(divide[i].begin(), divide[i].end());
    }

    bool canDivide = false;
    bool ans = true;

    for(int i=0;i<s.size()){
        canDivide = false;
        for (int j = 0; j < 4; j++){
            if(s.substr(i, divide[j].size()) == divide[j]){
                // cout<<"j:"<<j<<", before s:"<<s;
                canDivide = true;
                // cout<<", after s:"<<s<<endl;
                i += divide[j].size();
            }
        }
        if(canDivide==false){
            ans = false;
            break;
        }
    }

    if(ans==true) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

}



Compiler output:
a.cc: In function 'int main()':
a.cc:26:27: error: expected ';' before ')' token
   26 |     for(int i=0;i<s.size()){
      |                           ^
      |                           ;
Language: C++

#include <bits/stdc++.h>
using namespace std;

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

int main(){
    string s;
    cin >> s;

    reverse(s.bigin(),s.end());
    for(int i=0; i<4; i++) reverse(divide[i].begin(),divide[i].end());

    bool can = true;
    for(int i=0; i<s.size();){
        bool can2 = false;
        for(int j=0; j<4; j++){
            string d = divide[j];
            if(s.substr(i,d.size()) == d){
                can2 = true;
                i += d.size();
            }
        }
        if(!can2){
            can = false;
            break;
        }
    }

    if(can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:10:15: error: 'std::string' {aka 'class std::__cxx11::basic_string<char>'} has no member named 'bigin'; did you mean 'begin'?
   10 |     reverse(s.bigin(),s.end());
      |               ^~~~~
      |               begin
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<(int)(N);i++

bool c(vector<char> &N,int i){
  char front=N.at(i-1);
  if(front=='d'){
      if(N.at(i)=='r')
        return true;
      else
        return false;
    }
  else if(front=='r'){
      if(N.at(i)=='e'||N.at(i)=='d'||N.at(i)=='a')
        return true;
      else
        return false;
  }
  
  else if(front=='e'){
      if(N.at(i)=='a'||N.at(i)=='r'||N.at(i)=='d')
        return true;
      else
        return false;
  }
  else if(front=='a'){
      if(N.at(i)=='m'||N.at(i)=='s')
        return true;
      else
        return false;
  }
  else if(front=='m'){
      if(N.at(i)=='e'||N.at(i)=='d')
        return true;
      else
        return false;
  }
  else if(front=='s'){
      if(N.at(i)=='e')
        return true;
      else
        return false;
  }
}
  
int main(){
  vector<char> N;
  bool check=true;
  rep(i,N)
    cin>>N.at(i);
  rep(i,N){
    if(check==false){
      cout<<"NO"<<endl;
      break;
    }
    if(i=0){
      if(N.at(i)=='d'||N.at(i)=='e')
        continue;
      else{
        check=false;
        break;
      }
    }
    if(check=true)
    check=c(N,i);
  }
  if(check=true)
    cout<<"YES"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:3:32: error: invalid cast from type 'std::vector<char>' to type 'int'
    3 | #define rep(i,N) for(int i=0;i<(int)(N);i++
      |                                ^~~~~~~~
a.cc:49:3: note: in expansion of macro 'rep'
   49 |   rep(i,N)
      |   ^~~
a.cc:50:5: error: expected ')' before 'cin'
   50 |     cin>>N.at(i);
      |     ^~~
a.cc:3:21: note: to match this '('
    3 | #define rep(i,N) for(int i=0;i<(int)(N);i++
      |                     ^
a.cc:49:3: note: in expansion of macro 'rep'
   49 |   rep(i,N)
      |   ^~~
a.cc:3:32: error: invalid cast from type 'std::vector<char>' to type 'int'
    3 | #define rep(i,N) for(int i=0;i<(int)(N);i++
      |                                ^~~~~~~~
a.cc:51:3: note: in expansion of macro 'rep'
   51 |   rep(i,N){
      |   ^~~
a.cc:51:11: error: expected ')' before '{' token
   51 |   rep(i,N){
      |           ^
a.cc:3:21: note: to match this '('
    3 | #define rep(i,N) for(int i=0;i<(int)(N);i++
      |                     ^
a.cc:51:3: note: in expansion of macro 'rep'
   51 |   rep(i,N){
      |   ^~~
a.cc: In function 'bool c(std::vector<char>&, int)':
a.cc:44:1: warning: control reaches end of non-void function [-Wreturn-type]
   44 | }
      | ^
Language: C++

S = input()
temp = ['dream', 'dreamer', 'erase', 'eraser']

while(1):
    for i in temp:
        if S.startswith(i):
            S = S.lstrip(i)
            break
    else:
        break

print(S)
if len(S) == 0:
    print('YES')
else:
    print('NO')


Compiler output:
a.cc:2:9: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
    2 | temp = ['dream', 'dreamer', 'erase', 'eraser']
      |         ^~~~~~~
a.cc:2:18: warning: multi-character literal with 7 characters exceeds 'int' size of 4 bytes
    2 | temp = ['dream', 'dreamer', 'erase', 'eraser']
      |                  ^~~~~~~~~
a.cc:2:29: warning: multi-character literal with 5 characters exceeds 'int' size of 4 bytes
    2 | temp = ['dream', 'dreamer', 'erase', 'eraser']
      |                             ^~~~~~~
a.cc:2:38: warning: multi-character literal with 6 characters exceeds 'int' size of 4 bytes
    2 | temp = ['dream', 'dreamer', 'erase', 'eraser']
      |                                      ^~~~~~~~
a.cc:14:11: warning: multi-character character constant [-Wmultichar]
   14 |     print('YES')
      |           ^~~~~
a.cc:16:11: warning: multi-character character constant [-Wmultichar]
   16 |     print('NO')
      |           ^~~~
a.cc:1:1: error: 'S' does not name a type
    1 | S = input()
      | ^
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  string s;
  cin>>s;
  vector<string>div={"dream","dreamer","erase","eraser"};
  reverse(s.begin(),s.end());
  rep(i,4){reverse(div[i].begin(),div[i].end());}
  bool ex=true;
  rep(i,s.size()){
    bool ex2=false;
    rep(j,4){
      string d=div[j];
      if(d==substr(i,d.size()){
         ex2=true;
         i+=d.size();
      }
    }
      if(ex2==false){
        ex=false;
        break;
      }
  }
  if(ex==true)
         cout<<"YES"<<endl;
  else
         cout<<"NO"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:19:13: error: 'substr' was not declared in this scope; did you mean 'strstr'?
   19 |       if(d==substr(i,d.size()){
      |             ^~~~~~
      |             strstr
a.cc:19:31: error: expected ')' before '{' token
   19 |       if(d==substr(i,d.size()){
      |         ~                     ^
      |                               )
a.cc:23:5: error: expected primary-expression before '}' token
   23 |     }
      |     ^
Language: C++

#include <iostream>
using namespace std;
int main()
{
	string divide[4] = { "dream", "dreamer", "erase", "eraser" };
	string S;
	cin >> S;
 
	reverse(S.begin(), S.end());
	for (int i = 0; i < 4; ++i) reverse(divide[i].begin(), divide[i].end());
 
	bool can = true;
	for (int i = 0; i < S.size();) {
		bool can2 = false;
		for (int j = 0; j < 4; ++j)
		{
			string d = divide[j];
			if (S.substr(i, d.size()) == d) {
				can2 = true;
				i += d.size();
			}
		}
		if (!can2) {
			can = false;
			break;
		}
	}
 
	if (can) cout << "YES" << endl;
	else cout << "NO" << endl;
    return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:9:9: error: 'reverse' was not declared in this scope
    9 |         reverse(S.begin(), S.end());
      |         ^~~~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
typedef long long ll;
#define _GLIBCXX_DEBUG
int main()	{
  string s;
  cin>>s;
  vector<string>tdiv(4)={"dream","dreamer","erase","eraser"};
  reverse(s.begin(),s.end());
  rep(i,4){
    reverse(tdiv[i].begin(),tdiv[i].end());
  }
  bool candiv=true;
  rep(i,s.size()){
    bool candiv2=false;
    rep(j,4){
      if(s.substr(i,tdiv[j].size())==tdiv[j]){
        candiv2=true;
        i+=tdiv[j].size();
      }
    }
    if(candiv2==false){
      candiv=false;
      break;
    }
  }
  if(candiv==true)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:11:24: error: expected ',' or ';' before '=' token
   11 |   vector<string>tdiv(4)={"dream","dreamer","erase","eraser"};
      |                        ^
Language: C++

#include <string>
#include <iostream>
#include <vector>
#include <type_traits>
#include <algorithm>s

using namespace std;

int main() {
    string s;
    cin >> s;
    string divide[4] = { "dream", "dreamer", "erase", "eraser" };
    reverse(s.begin(), s.end());
    for (auto i = 0; i < 4; i++) reverse(divide[i].begin(), divide[i].end());

    bool can = true;
    for (int i = 0; i < s.size(); i++) {
        bool can2 = false;
        for (int j = 0; j < 4; j++) {
            string d = divide[j];
            if (s.substr(i, d.size()) == d) {
                can2 = true;
                i += d.size();
            }
        }
        if (!can) {
            can = false;
            break;
        }
    }
    if (can) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Compiler output:
a.cc:5:10: fatal error: algorithm>: No such file or directory
    5 | #include <algorithm>s
      |          ^~~~~~~~~~~~
compilation terminated.
Language: C++

#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main()　{
	string S;
  	cin >> S;
  	string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  	
  	reverse(S.begin(), S.end());
  	for(int i = 0; i <4; i++;) reverse(divide[i].begin(), divide[i].end());
  
  	bool can = true;
  
  	for(int i = 0; i < S.size()) {
    	bool can2 = false;
      	for (int j = 0; j< 4; j++) {
        	string d = divide[j];
          	if (S.substr(i, d.size()) == d) {
            	can2 = true;
              	i += d.size();
            }
        }
      	
      	if (!can2) {
        	can = false;
          	break;
        }
    }
  
  	if (can) cout << "YES" << endl;
  	else cout << "NO" << endl;
}


Compiler output:
a.cc:5:11: error: extended character 　 is not valid in an identifier
    5 | int main()　{
      |           ^
a.cc:5:11: error: expected initializer before '\U00003000'
    5 | int main()　{
      |           ^~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

int main(){
    string S;
    cin>>S;
    reverse(S.begin(),S.end());
    for(int=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());

    bool can=1;

    for(int i=0;i<S.size();){
        bool can2=0;
        for(int j=0;j<4;j++){
            string d = divide[4];
            if((S.substr(i,d.size()))==d){
                can2=true;
                i+=d.size();
            }
        }
        if(!can2){
            can=0;
            break;
        }
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:12:12: error: expected unqualified-id before '=' token
   12 |     for(int=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
      |            ^
a.cc:12:12: error: expected ';' before '=' token
   12 |     for(int=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
      |            ^
      |            ;
a.cc:12:12: error: expected primary-expression before '=' token
a.cc:12:15: error: 'i' was not declared in this scope
   12 |     for(int=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
      |               ^
a.cc:12:18: error: expected ')' before ';' token
   12 |     for(int=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
      |        ~         ^
      |                  )
a.cc:12:19: error: 'i' was not declared in this scope
   12 |     for(int=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());
      |                   ^
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string divide[4]={"dream","dreamer","erase","eraser"}

int main(){
    string S;
    cin>>S;
    reverse(S.begin(),S.end());
    for(int=0;i<4;i++) reverse(divide[i].begin(),divide[i].end());

    bool can=1;

    for(int i=0;i<S.size();){
        bool can2=0;
        for(int j=0;j<4;j++){
            string d = divide[4];
            if((S.substr(i,d.size()))==d){
                can2=true;
                i+=d.size();
            }
        }
        if(!can2){
            can=0;
            break;
        }
    }
    if(can)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}

Compiler output:
a.cc:8:1: error: expected ',' or ';' before 'int'
    8 | int main(){
      | ^~~
Language: C++

#include <stdio#include <bits/stdc++.h>
using namespace std;

int main() {
  string S;
  cin >> S;

  vector<string> devide = {"maerd", "remaerd", "esare", "resare"};

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

  int i = 0;
  bool can = true;
  while (i < S.size() && can == true) {
    for (int j = 0; i < 4; j++) {
      string d = devide.at(j);
      if (S.substr(i, d.size()) == d) {
        i += d.size();
        break;
      }
      else {
        can = false;
      }
    }
  }

  if (can) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Compiler output:
a.cc:1:10: fatal error: stdio#include <bits/stdc++.h: No such file or directory
    1 | #include <stdio#include <bits/stdc++.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  string S, T;
  T = "";
  cin >> S;
  vector<string> vec = {"dream", "dreamer", "erase", "eraser"};
  reverse(S.begin(), S.end());
  for(int i = 0; i < 4; i++){
  	string s = vec.at(i);
    reverse(s.begin(), s.end());
  }
  bool F = false;
  for(int i = 0; i < S.size(); ){
    bool f = false;
    for(int j = 0; j < 4; j++){
  		string t = S.substr(i, vec.at(j).size());
      	if(t == vec.at(j)){
        	i += t.size();
          	f = true;
        }
    }
    if(!f){
      F = true;
      break;
    }
  }
  if(F){
  	cout << "NO" << enddl;
  }else{
  	cout << "YES" << endl;
  }
}


Compiler output:
a.cc: In function 'int main()':
a.cc:30:25: error: 'enddl' was not declared in this scope
   30 |         cout << "NO" << enddl;
      |                         ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  string S, T;
  T = "";
  cin >> S;
  vector<string> vec = {"dream", "dreamer", "erase", "eraser"};
  reverse(S.begin(), S.end());
  for(int i = 0; i < 4; i++){
  	string s = vec.at(i);
    reverse(s.begin(), s.end());
  }
  bool F = false;
  for(int i = 0; i < S.size(); ){
    bool f = false;
    for(int j = 0; j < 4; j++){
  		string t = S.substr(i, vec.at(j));
      	if(t == vec.at(j)){
        	i += t.size();
          	f = true;
        }
    }
    if(!f){
      F = true;
      break;
    }
  }
  if(F){
  	cout << "NO" << enddl;
  }else{
  	cout << "YES" << endl;
  }
}

Compiler output:
a.cc: In function 'int main()':
a.cc:18:46: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type' {aka 'std::__cxx11::basic_string<char>'} to 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'}
   18 |                 string t = S.substr(i, vec.at(j));
      |                                        ~~~~~~^~~
      |                                              |
      |                                              __gnu_cxx::__alloc_traits<std::allocator<std::__cxx11::basic_string<char> >, std::__cxx11::basic_string<char> >::value_type {aka std::__cxx11::basic_string<char>}
In file included from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bitset:52,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:52,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_string.h:3208:45: note:   initializing argument 2 of 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc> std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::substr(size_type, size_type) const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]'
 3208 |       substr(size_type __pos = 0, size_type __n = npos) const
      |                                   ~~~~~~~~~~^~~~~~~~~~
a.cc:30:25: error: 'enddl' was not declared in this scope
   30 |         cout << "NO" << enddl;
      |                         ^~~~~
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  for(int i = 0; i < 4; i++){
    reverse((divide[i]).begin(), (divide[i]).end());
  }
  bool can = true;
  for(int i = 0; i < s.size()){
    bool can2 = false;
    for(int j = 0; j < 4; j++){
      if(s.substr(i, divide[j].size()) == divide[j]){
        can2 = true;
        i+=(divide[j]).size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:30: error: expected ';' before ')' token
   13 |   for(int i = 0; i < s.size()){
      |                              ^
      |                              ;
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  string divide[4] = {"dream", "dreamer", "erase", "eraser"};
  for(int i = 0; i < 4; i++){
    reverse((divide[i]).begin(), (divide[i]).end());
  }
  bool can = true;
  for(int i = 0; i < s.size()){
    bool can2 = false;
    for(int j = 0; j < 4; j++){
      if(s.substr(i, divide[j].size()) == divide[j]){
        can2 = true;
        i+=d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:30: error: expected ';' before ')' token
   13 |   for(int i = 0; i < s.size()){
      |                              ^
      |                              ;
a.cc:18:12: error: 'd' was not declared in this scope
   18 |         i+=d.size();
      |            ^
Language: C++

#include <bits/stdc++.h>
using namespace std;

int main(){
  string s;
  cin >> s;
  reverse(s.begin(), s.end());
  string divide = {"dream", "dreamer", "erase", "eraser"};
  for(int i = 0; i < 4; i++){
    reverse(divide[i].begin(), divide[i].end());
  }
  bool can = true;
  for(int i = 0; i < s.size()){
    bool can2 = false;
    for(int j = 0; j < 4; j++){
      if(s.substr(i, divide[j].size()) == divide[j]){
        can2 = true;
        i+=d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:8:57: error: could not convert '{"dream", "dreamer", "erase", "eraser"}' from '<brace-enclosed initializer list>' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
    8 |   string divide = {"dream", "dreamer", "erase", "eraser"};
      |                                                         ^
      |                                                         |
      |                                                         <brace-enclosed initializer list>
a.cc:10:23: error: request for member 'begin' in 'divide.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
   10 |     reverse(divide[i].begin(), divide[i].end());
      |                       ^~~~~
a.cc:10:42: error: request for member 'end' in 'divide.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)i))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
   10 |     reverse(divide[i].begin(), divide[i].end());
      |                                          ^~~
a.cc:13:30: error: expected ';' before ')' token
   13 |   for(int i = 0; i < s.size()){
      |                              ^
      |                              ;
a.cc:16:32: error: request for member 'size' in 'divide.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)j))', which is of non-class type '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'}
   16 |       if(s.substr(i, divide[j].size()) == divide[j]){
      |                                ^~~~
a.cc:18:12: error: 'd' was not declared in this scope
   18 |         i+=d.size();
      |            ^
Language: C++

#include <iostream>
#include <string>
#include <vector>
using namespace std;

bool IsComposable(const vector<string>& keys, string &strings, int i) {
	if (i == strings.length()) return true;
	for (string key : keys) {
		if (strings.substr(i, key.length()) == key) return IsComposable(keys, strings,i+ key.length());
	}
	return false;
}

int main() {
	vector<string> keys = { "dream", "dreamer", "erase", "eraser" };
	for (string & key : keys) reverse(key.begin(), key.end());

	string S;
	cin >> S;
	reverse(S.begin(), S.end());
	if (IsComposable(keys, S, 0)) cout << "YES" << endl;
	else cout << "NO" << endl;


}

Compiler output:
a.cc: In function 'int main()':
a.cc:16:35: error: 'reverse' was not declared in this scope
   16 |         for (string & key : keys) reverse(key.begin(), key.end());
      |                                   ^~~~~~~
a.cc:20:9: error: 'reverse' was not declared in this scope
   20 |         reverse(S.begin(), S.end());
      |         ^~~~~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

int main() {
  string S;
  cin >> S;

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(divs[i].begin(), divs[i].end())

  bool flag = true;
  for (int i = 0; i < S.size();) {
    bool flag2 = false;
    for (int j = 0; j < 4; ++j) {
      string d = divs[j];
      if (S.substr(i, d.size()) == d) {
        flag2 = true;
        i += d.size();
      }
    }
    if (!flag2) {
      flag = false;
      break;
    }
  }
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:13:70: error: expected ';' before 'bool'
   13 |   for (int i = 0; i < 4; ++i) reverse(divs[i].begin(), divs[i].end())
      |                                                                      ^
      |                                                                      ;
   14 | 
   15 |   bool flag = true;
      |   ~~~~                                                                
a.cc:26:7: error: 'flag' was not declared in this scope; did you mean 'flag2'?
   26 |       flag = false;
      |       ^~~~
      |       flag2
a.cc:30:7: error: 'flag' was not declared in this scope
   30 |   if (flag) cout << "YES" << endl;
      |       ^~~~
Language: C++

#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

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

int main() {
  string S;
  cin >> S;

  reverse(S.begin(), S.end());
  for (int i = 0; i < 4; ++i) reverse(div[i].begin(), div[i].end())

  bool flag = true;
  for (int i = 0; i < S.size();) {
    bool flag2 = false;
    for (int j = 0; j < 4; ++j) {
      string d = div[j];
      if (S.substr(i, d.size()) == d) {
        flag2 = true;
        i += d.size();
      }
    }
    if (!flag2) {
      flag = false;
      break;
    }
  }
  if (flag) cout << "YES" << endl;
  else cout << "NO" << endl;
}


Compiler output:
a.cc:6:13: error: 'std::string div [4]' redeclared as different kind of entity
    6 | string div[4] = {"dream", "dreamer", "erase", "eraser"};
      |             ^
In file included from /usr/include/c++/14/cstdlib:79,
                 from /usr/include/c++/14/ext/string_conversions.h:43,
                 from /usr/include/c++/14/bits/basic_string.h:4154,
                 from /usr/include/c++/14/string:54,
                 from /usr/include/c++/14/bits/locale_classes.h:40,
                 from /usr/include/c++/14/bits/ios_base.h:41,
                 from /usr/include/c++/14/ios:44,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/stdlib.h:992:14: note: previous declaration 'div_t div(int, int)'
  992 | extern div_t div (int __numer, int __denom)
      |              ^~~
a.cc: In function 'int main()':
a.cc:13:42: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   13 |   for (int i = 0; i < 4; ++i) reverse(div[i].begin(), div[i].end())
      |                                          ^
a.cc:13:58: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   13 |   for (int i = 0; i < 4; ++i) reverse(div[i].begin(), div[i].end())
      |                                                          ^
a.cc:19:21: error: invalid types '<unresolved overloaded function type>[int]' for array subscript
   19 |       string d = div[j];
      |                     ^
a.cc:26:7: error: 'flag' was not declared in this scope; did you mean 'flag2'?
   26 |       flag = false;
      |       ^~~~
      |       flag2
a.cc:30:7: error: 'flag' was not declared in this scope
   30 |   if (flag) cout << "YES" << endl;
      |       ^~~~
Language: C++

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

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

int main(){
	string s;
	cin >> s;
	
	  reverse(s.begin(),s.end());
	rep(i,4) reverse(divide[i].begin(),divide.end());
	
	bool can = true;
	
	for(int i = 0; i < s.size();){
	  
	  bool can2 = false;
	  
	  rep(j,4){
	    if(divide[j] == s.substr(i,divide[j].size())){
	      can2 = true;
	      i += divide[j].size;
	    }
	    if(!can2){
	      can = false;
	      break;
	    }
	    
	  }
	}
	if(can) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Compiler output:
a.cc: In function 'int main()':
a.cc:14:51: error: request for member 'end' in 'divide', which is of non-class type 'std::string [4]' {aka 'std::__cxx11::basic_string<char> [4]'}
   14 |         rep(i,4) reverse(divide[i].begin(),divide.end());
      |                                                   ^~~
a.cc:25:30: error: invalid use of member function 'std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size_type std::__cxx11::basic_string<_CharT, _Traits, _Alloc>::size() const [with _CharT = char; _Traits = std::char_traits<char>; _Alloc = std::allocator<char>; size_type = long unsigned int]' (did you forget the '()' ?)
   25 |               i += divide[j].size;
      |                    ~~~~~~~~~~^~~~
      |                                  ()