Language: C++

#include<iostream>
#include<stack>
#include<cstdlib>
#include<string>
#include <utility>
#include<queue>
#include<algorithm>
#include<list>

using namespace std;

void print_list(const list<int>& dlist){
  const list<int>::const_iterator itEnd = dlist.end();
  for(list<int>::const_iterator it =dlist.begin();it !=itEnd-1;++it){
    cout << *it << " ";
  }
  cout << it* <<endl;
}

//void delete_list(list<int> &dlist,int key){
 // list<int>::iterator find_ptr = find_list(dlist,key);

//}

int main(){
  
  int n = 0;
  cin >> n;

  string command;
  int num;

  list<int> dlist;

  for(int i=0;i<n;i++){
   cin >> command ;
     if(command=="insert"){
        cin >> num;
        dlist.push_front(num);
     }
     else if(command =="delete"){
        cin >> num;
        //delete_list(dlist);
        list<int>::iterator find_ptr = find(dlist.begin(),dlist.end(),num);
        
        dlist.erase(find_ptr);
     }
     else if(command =="deleteFirst"){
      dlist.pop_front();
     }
     else{
     dlist.pop_back();
     } 

     
  }


  print_list(dlist);


  return 0;
}


Compiler output:
a.cc: In function 'void print_list(const std::__cxx11::list<int>&)':
a.cc:14:61: error: no match for 'operator-' (operand types are 'const std::__cxx11::list<int>::const_iterator' and 'int')
   14 |   for(list<int>::const_iterator it =dlist.begin();it !=itEnd-1;++it){
      |                                                        ~~~~~^~
      |                                                        |     |
      |                                                        |     int
      |                                                        const std::__cxx11::list<int>::const_iterator
In file included from /usr/include/c++/14/string:48,
                 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/c++/14/bits/stl_iterator.h:618:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__y.base() - __x.base())) std::operator-(const reverse_iterator<_Iterator>&, const reverse_iterator<_IteratorR>&)'
  618 |     operator-(const reverse_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:618:5: note:   template argument deduction/substitution failed:
a.cc:14:62: note:   'const std::__cxx11::list<int>::const_iterator' is not derived from 'const std::reverse_iterator<_Iterator>'
   14 |   for(list<int>::const_iterator it =dlist.begin();it !=itEnd-1;++it){
      |                                                              ^
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note: candidate: 'template<class _IteratorL, class _IteratorR> constexpr decltype ((__x.base() - __y.base())) std::operator-(const move_iterator<_IteratorL>&, const move_iterator<_IteratorR>&)'
 1790 |     operator-(const move_iterator<_IteratorL>& __x,
      |     ^~~~~~~~
/usr/include/c++/14/bits/stl_iterator.h:1790:5: note:   template argument deduction/substitution failed:
a.cc:14:62: note:   'const std::__cxx11::list<int>::const_iterator' is not derived from 'const std::move_iterator<_IteratorL>'
   14 |   for(list<int>::const_iterator it =dlist.begin();it !=itEnd-1;++it){
      |                                                              ^
a.cc:17:11: error: 'it' was not declared in this scope; did you mean 'int'?
   17 |   cout << it* <<endl;
      |           ^~
      |           int
a.cc:17:15: error: expected primary-expression before '<<' token
   17 |   cout << it* <<endl;
      |               ^~