Problem p02265 (C++) — buggy submission, verdict: Runtime Error

/**
 * ???????????£????????????
??\\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x
??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst: ?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
??\\???
??\\????????\\????????¢?????§?????????????????????

n
command1
command2
...
commandn
???????????????????????° n ?????????????????????????¶???? n
??????????????????????????????????????????????¨?4?????????????????????????????§?????????????????´??°??¨????????????

??????
??¨??????????????????????????????????????£?????????????????????????????????????????????????????????????????£?¶???????????????????????????????????????§????????£??????????????????????????????

??¶?´?
????????°??? 2,000,000 ????¶?????????????
delete ??????????????°??? 20 ????¶?????????????
0 ??? ???????????? ??? 10^9???
?????????????¨???§????????????????´???°??? 106????¶?????????????
delete, deleteFirst, ????????? deleteLast
??????????????????????????¨?????????????????????????????\\??????????´?????????¨?????????
??\\?????? 1
7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
????????? 1
6 1 2
??\\?????? 2
9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast
????????? 2
1

 */

#include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
#include <sstream>

void printList(const std::list<unsigned int> &l) {
  std::ostringstream oss;
  std::copy(l.begin(), --l.end(),
            std::ostream_iterator<unsigned int>(oss, " "));
  oss << l.back();
  std::cout << oss.str() << std::endl;
}

int main(int argc, char const *argv[]) {
  std::string Param;
  std::istringstream iss;
  std::list<unsigned int> List;
  unsigned int n;
  std::string Command;
  unsigned int x;
  getline(std::cin, Param);
  iss.str(Param);
  iss >> n;
  iss.clear();
  for (size_t i = 0; i < n; i++) {
    getline(std::cin, Param);
    iss.str(Param);
    iss >> Command >> x;
    iss.clear();
    if (Command == "insert") {
      List.push_front(x);
    } else if (Command == "delete") {
      auto itr = std::find(List.begin(), List.end(), x);
      if (itr != List.end()) {
        List.erase(itr);
      }
    } else if (Command == "deleteFirst") {
      List.pop_front();
    } else if (Command == "deleteLast") {
      List.pop_back();
    }
  }
  printList(List);

  return 0;
}

Error: 0

Fixed submission:

/**
 * ???????????£????????????
??\\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x
??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst: ?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
??\\???
??\\????????\\????????¢?????§?????????????????????

n
command1
command2
...
commandn
???????????????????????° n ?????????????????????????¶???? n
??????????????????????????????????????????????¨?4?????????????????????????????§?????????????????´??°??¨????????????

??????
??¨??????????????????????????????????????£?????????????????????????????????????????????????????????????????£?¶???????????????????????????????????????§????????£??????????????????????????????

??¶?´?
????????°??? 2,000,000 ????¶?????????????
delete ??????????????°??? 20 ????¶?????????????
0 ??? ???????????? ??? 10^9???
?????????????¨???§????????????????´???°??? 106????¶?????????????
delete, deleteFirst, ????????? deleteLast
??????????????????????????¨?????????????????????????????\\??????????´?????????¨?????????
??\\?????? 1
7
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
????????? 1
6 1 2
??\\?????? 2
9
insert 5
insert 2
insert 3
insert 1
delete 3
insert 6
delete 5
deleteFirst
deleteLast
????????? 2
1

 */

#include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
#include <sstream>

void printList(const std::list<unsigned int> &l) {
  std::ostringstream oss;
  std::copy(l.begin(), --l.end(),
            std::ostream_iterator<unsigned int>(oss, " "));
  oss << l.back();
  std::cout << oss.str() << std::endl;
}

int main(int argc, char const *argv[]) {
  std::string Param;
  std::istringstream iss;
  std::list<unsigned int> List;
  unsigned int n;
  std::string Command;
  unsigned int x;
  getline(std::cin, Param);
  iss.str(Param);
  iss >> n;
  iss.clear();
  for (size_t i = 0; i < n; i++) {
    getline(std::cin, Param);
    iss.str(Param);
    iss >> Command >> x;
    iss.clear();
    if (Command == "insert") {
      List.push_front(x);
    } else if (Command == "delete") {
      auto itr = std::find(List.begin(), List.end(), x);
      List.erase(itr);
    } else if (Command == "deleteFirst") {
      List.pop_front();
    } else if (Command == "deleteLast") {
      List.pop_back();
    }
  }
  printList(List);

  return 0;
}