alexjercan/bugnet huggingface dataset:
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

// ALSD_1_3_C.cpp
// Doubly Linked List
#include <deque>
#include <iostream>

using namespace std;

int main() {
  int n;
  string cmd;
  int num;
  deque<int> nums;
  cin >> n;
  while (n--) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> num;
      nums.push_front(num);
    } else if (cmd == "delete") {
      cin >> num;
      for (int i = 0; i < nums.size(); i++) {
        if (nums[i] == num) {
          nums.erase(nums.begin() + i);
          break;
        }
      }

    } else if (cmd == "deleteFirst") {
      nums.pop_front();
    } else if (cmd == "deleteLast") {
      nums.pop_back();
    }
  }

  for (int i = 0; i < nums.size(); i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << nums[i];
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

// ALSD_1_3_C.cpp
// Doubly Linked List
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  string cmd;
  int num;
  vector<int> nums;
  cin >> n;
  while (n--) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> num;
      nums.insert(nums.begin(), num);
    } else if (cmd == "delete") {
      cin >> num;
      for (int i = 0; i < nums.size(); i++) {
        if (nums[i] == num) {
          nums.erase(nums.begin() + i);
          break;
        }
      }

    } else if (cmd == "deleteFirst") {
      nums.erase(nums.begin());
    } else if (cmd == "deleteLast") {
      nums.erase(nums.end() - 1);
    }
  }

  for (int i = 0; i < nums.size(); i++) {
    if (i > 0) {
      cout << " ";
    }
    cout << nums[i];
  }
  cout << endl;
  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Runtime Error

#include <cstdlib>
#include <iostream>
#include <list>
#include <string>
using namespace std;

int main() {
  int numCom;
  list<int> lis;

  //	cin >> numCom;
  scanf("%d", &numCom);
  for (int i = 0; i < numCom; i++) {
    string str;
    cin >> str;
    if (str[0] == 'i') {
      int x;
      //			cin >> x;
      scanf("%d", &x);
      lis.push_front(x);
    } else if (str[6] == 'F') {
      lis.pop_front();
    } else if (str[6] == 'L') {
      lis.pop_back();
    } else if (str[0] == 'd') {
      int x;
      //			cin >> x;
      scanf("%d", &x);
      for (list<int>::iterator ite = lis.begin(); ite != lis.end(); ite++) {
        if (*ite == x) {
          lis.erase(ite);
          break;
        }
      }
    }
  }

  int i = 0;
  for (list<int>::iterator ite = lis.begin(); ite != lis.end(); ite++) {
    if (i++)
      cout << " ";
    cout << *ite;
  }
  cout << endl;

  return 0;
}

Error: -11

Fixed submission:

#include <cstdlib>
#include <iostream>
#include <list>
#include <string>
using namespace std;

int main() {
  int numCom;
  list<int> lis;

  //	cin >> numCom;
  scanf("%d", &numCom);
  for (int i = 0; i < numCom; i++) {
    string str;
    cin >> str;
    if (str[0] == 'i') {
      int x;
      //			cin >> x;
      scanf("%d", x);
      lis.push_front(x);
    } else if (str[6] == 'F') {
      lis.pop_front();
    } else if (str[6] == 'L') {
      lis.pop_back();
    } else if (str[0] == 'd') {
      int x;
      //			cin >> x;
      scanf("%d", x);
      for (list<int>::iterator ite = lis.begin(); ite != lis.end(); ite++) {
        if (*ite == x) {
          lis.erase(ite);
          break;
        }
      }
    }
  }

  int i = 0;
  for (list<int>::iterator ite = lis.begin(); ite != lis.end(); ite++) {
    if (i++)
      cout << " ";
    cout << *ite;
  }
  cout << endl;

  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <list>

using namespace std;

int main(void) {
  int w;
  string c;
  list<int> myList;
  list<int>::iterator it;
  cin >> w;
  for (int i = 0; i < w; i++) {
    cin >> c;
    if (c == "insert") {
      int x;
      cin >> x;
      myList.push_front(x);
    } else if (c == "delete") {
      int x;
      cin >> x;
      for (it = myList.begin(); it != myList.end(); it++) {
        if (*it == x) {
          myList.erase(it);
          break;
        }
      }
    } else if (c == "deleteLast") {
      myList.pop_back();
    } else if (c == "deleteFirst") {
      myList.pop_front();
    }
  }

  for (it = myList.begin(); it != myList.end(); it++) {
    if (it == myList.begin()) {
      cout << *it;
    } else {
      cout << ' ' << *it;
    }
  }
  cout << endl;

  return 0;
}


Error: TLE

Fixed submission:

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

vector<int> myVector;
vector<int>::iterator it;

void deleteNorm(int a);

void insert(int a);

void deleteFirst();

void deleteLast();

int main() {
  int x, k;
  string y;
  cin >> x;
  for (int i = 0; i < x; i++) {
    cin >> y;
    if (y == "insert") {
      cin >> k;
      insert(k);
    } else if (y == "delete") {
      cin >> k;
      deleteNorm(k);
    } else if (y == "deleteFirst") {
      deleteFirst();
    } else if (y == "deleteLast") {
      deleteLast();
    }
  }

  for (int j : myVector) {
    cout << j << " ";
  }
  return 0;
}

void deleteFirst() { myVector.erase(myVector.begin()); }

void deleteLast() { myVector.pop_back(); }

void insert(int a) { myVector.insert(myVector.begin(), a); }

void deleteNorm(int a) {
  myVector.erase(remove(myVector.begin(), myVector.end(), a), myVector.end());
  myVector.pop_back();
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  list<int> s;
  list<int>::iterator it, endit;
  int n;
  cin >> n;
  pair<string, int> p;
  string str;
  for (int i = 0; i < n; i++) {
    cin >> str;
    if (str != "deleteFirst" && str != "deleteLast") {
      cin >> p.second;
      p.first = str;
      if (p.first == "insert")
        s.push_front(p.second);
      else if (p.first == "delete") {
        it = s.begin(), endit = s.end();
        for (; it != endit; ++it) {
          if (*it == p.second) {
            s.erase(it);
            break;
          }
        }
      }
    } else if (str == "deleteFirst") {
      s.pop_front();
    } else
      s.pop_back();
  }
  cout << s.front();
  s.pop_front();
  for (; !s.empty();) {
    cout << " " << s.front();
    s.pop_front();
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

int main() {
  list<int> s;
  list<int>::iterator it, endit;
  int n;
  cin >> n;
  pair<string, int> p;
  string str;
  for (int i = 0; i < n; i++) {
    cin >> str;
    if (str != "deleteFirst" && str != "deleteLast") {
      cin >> p.second;
      p.first = str;
      if (p.first == "insert")
        s.push_front(p.second);
      else if (p.first == "delete") {
        it = s.begin(), endit = s.end();
        for (; it != endit; ++it) {
          if (*it == p.second) {
            s.erase(it);
            break;
          }
        }
      }
    } else if (str == "deleteFirst") {
      s.pop_front();
    } else
      s.pop_back();
  }
  cout << s.front();
  s.pop_front();
  for (; !s.empty();) {
    cout << " " << s.front();
    s.pop_front();
  }
  cout << endl;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define pb emplace_back
typedef long long ll;
typedef pair<int, int> pint;

list<int> ls;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, x;
  cin >> n;
  string s;
  rep(i, n) {
    cin >> s;
    if (s == "insert") {
      cin >> x;
      ls.push_front(x);
    } else if (s == "deleteFirst")
      ls.pop_front();
    else if (s == "deleteLast")
      ls.pop_back();
    else {
      cin >> x;
      for (list<int>::iterator it = ls.begin(); it != ls.end(); ++it) {
        if (*it == x) {
          ls.erase(it);
          break;
        }
      }
    }
  }
  int cnt = 0;
  int sz = ls.size();
  for (list<int>::iterator it = ls.begin(); it != ls.end(); ++it) {
    cout << *it << (cnt + 1 == sz ? "" : " ");
    ++cnt;
  }
  cout << endl;
  return 0;
}


Error: TLE

Fixed submission:

#include <bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define pb emplace_back
typedef long long ll;
typedef pair<int, int> pint;

list<int> ls;
int main() {
  ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
  int n, x;
  cin >> n;
  string s;
  rep(i, n) {
    cin >> s;
    if (s == "insert") {
      cin >> x;
      ls.push_front(x);
    } else if (s == "deleteFirst")
      ls.pop_front();
    else if (s == "deleteLast")
      ls.pop_back();
    else {
      cin >> x;
      for (list<int>::iterator it = ls.begin(); it != ls.end(); ++it) {
        if (*it == x) {
          ls.erase(it);
          break;
        }
      }
    }
  }
  int cnt = 0;
  for (list<int>::iterator it = ls.begin(); it != ls.end(); ++it) {
    cout << *it << (cnt + 1 == ls.size() ? "" : " ");
    ++cnt;
  }
  cout << endl;
  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <list>
#include <string>

using namespace std;

void Output(list<int> ilist) {
  list<int>::iterator it = ilist.begin();
  cout << *it;
  it++;
  while (it != ilist.end()) {
    cout << " " << *it;
    it++;
  }
  cout << endl;
}

list<int> DealDelete(int &key, list<int> &ilist) {
  list<int>::iterator it = ilist.begin();

  while (it != ilist.end()) {
    if (*it == key) {
      ilist.erase(it);
      return ilist;
    }
    it++;
  }
  return ilist;
}

void Deal(string &command,
          list<int> &ilist) //??\\???????????£??????????????¨????±???????
{
  if (command == "insert") {
    int key;
    cin >> key;
    ilist.push_front(key);
  } else if (command == "delete") {
    int key;
    cin >> key;
    DealDelete(key, ilist);
  } else if (command == "deleteFirst") {
    ilist.pop_front();
  } else {
    ilist.pop_back();
  }
  return;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  list<int> ilist;

  cin >> n;

  for (int i = 0; i < n; i++) {
    string command;
    cin >> command;
    Deal(command, ilist); //??\\???????????????
  }
  Output(ilist); //??¨?????????
}

Error: TLE

Fixed submission:

#include <iostream>
#include <list>
#include <string>

using namespace std;

void Output(list<int> ilist) {
  list<int>::iterator it = ilist.begin();
  cout << *it;
  it++;
  while (it != ilist.end()) {
    cout << " " << *it;
    it++;
  }
  cout << endl;
}

list<int> DealDelete(int &key, list<int> &ilist) {
  list<int>::iterator it = ilist.begin();

  while (it != ilist.end()) {
    if (*it == key) {
      ilist.erase(it);
      return ilist;
    }
    it++;
  }
  return ilist;
}

list<int> Deal(string &command,
               list<int> &ilist) //??\\???????????£??????????????¨????±???????
{
  if (command == "insert") {
    int key;
    cin >> key;
    ilist.push_front(key);
  } else if (command == "delete") {
    int key;
    cin >> key;
    DealDelete(key, ilist);
  } else if (command == "deleteFirst") {
    ilist.pop_front();
  } else {
    ilist.pop_back();
  }
  return ilist;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  int n;
  list<int> ilist;

  cin >> n;

  for (int i = 0; i < n; i++) {
    string command;
    cin >> command;
    Deal(command, ilist); //??\\???????????????
  }
  Output(ilist); //??¨?????????
}
Problem p02265 (C++) — buggy submission, verdict: Runtime Error

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string s;
  int n, i, a;
  list<int> li;
  list<int>::iterator p = li.begin();
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s;
    if (s == "insert") {
      cin >> a;
      li.push_front(a);
    } else if (s == "delete") {
      cin >> a;
      p = find(li.begin(), li.end(), a);
      if (p != li.end())
        li.erase(p);

    } else if (s == "deleteFirst") {
      li.pop_front();
    } else if (s == "deleteLast") {
      li.pop_back();
    }
  }
  p = li.begin();

  while (p != li.end()) {
    cout << *p;
    p++;
    if (p != li.end())
      cout << " ";
    else
      cout << endl;
  }

  return 0;
}

Error: 0

Fixed submission:

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

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string s;
  int n, i, a;
  list<int> li;
  list<int>::iterator p = li.begin();
  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> s;
    if (s == "insert") {
      cin >> a;
      li.push_front(a);
    } else if (s == "delete") {
      cin >> a;
      p = find(li.begin(), li.end(), a);
      li.erase(p);

    } else if (s == "deleteFirst") {
      li.pop_front();
    } else if (s == "deleteLast") {
      li.pop_back();
    }
  }
  p = li.begin();

  while (p != li.end()) {
    cout << *p;
    p++;
    if (p != li.end())
      cout << " ";
    else
      cout << endl;
  }

  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <list>
using namespace std;

int main() {
  list<int> ltiNumber;
  list<int>::iterator itlti;
  list<int>::iterator itltEND = ltiNumber.end();
  char acCommand[80];
  int iMaxCommand, iNumber;

  cin >> iMaxCommand;
  for (int i = 0; i < iMaxCommand; i++) {
    cin >> acCommand;
    if (acCommand[0] == 'i') {
      cin >> iNumber;
      ltiNumber.push_front(iNumber);
    } else if (acCommand[6] == 'F')
      ltiNumber.pop_front();
    else if (acCommand[6] == 'L')
      ltiNumber.pop_back();
    else if (acCommand[0] == 'd') {
      cin >> iNumber;
      for (itlti = ltiNumber.begin(); itlti != itltEND; ++itlti) {
        if (*itlti == iNumber) {
          ltiNumber.erase(itlti);
          break;
        }
      }
    }
  }

  int i = 0;
  for (itlti = ltiNumber.begin(); itlti != itltEND; ++itlti) {
    if (i++)
      cout << " ";
    cout << *itlti;
  }
  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

int main() {
  list<int> ltiNumber;
  list<int>::iterator itlti;
  list<int>::iterator itltEND = ltiNumber.end();
  string sCommand;
  int iMaxCommand, iNumber;

  cin >> iMaxCommand;
  for (int i = 0; i < iMaxCommand; i++) {
    cin >> sCommand;
    if (sCommand == "insert") {
      cin >> iNumber;
      ltiNumber.push_front(iNumber);
    } else if (sCommand == "delete") {
      cin >> iNumber;
      for (itlti = ltiNumber.begin(); itlti != itltEND; ++itlti)
        if (*itlti == iNumber) {
          ltiNumber.erase(itlti);
          break;
        }
    } else if (sCommand == "deleteFirst")
      ltiNumber.pop_front();
    else if (sCommand == "deleteLast")
      ltiNumber.pop_back();
    else
      ;
  }

  int i = 0;
  for (itlti = ltiNumber.begin(); itlti != itltEND; ++itlti) {
    if (i++)
      cout << " ";
    cout << *itlti;
  }
  cout << endl;

  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <list>
#include <string>

int getValue(std::string text) {
  char number[11];
  std::snprintf(number, text.length(), "%s\\n", text.c_str());
  return std::atoi(number);
}

int main() {

  const int BUF_SIZE = 24;

  int commandCount;
  std::scanf("%d\\n", &commandCount);

  std::list<int> list;
  while (commandCount--) {
    char command[BUF_SIZE];
    std::fgets(command, sizeof(command), stdin);
    std::string command_str(command);

    if (command_str.substr(0, 6) == "insert") {
      auto number = command_str.substr(7);
      int value = getValue(number);
      list.emplace_front(value);
    } else if (command_str.substr(0, 11) == "deleteFirst") {
      list.pop_front();
    } else if (command_str.substr(0, 10) == "deleteLast") {
      list.pop_back();
    } else if (command_str.substr(0, 6) == "delete") {
      auto number = command_str.substr(7);
      int value = getValue(number);
      const auto deleteItr = std::find(list.begin(), list.end(), value);
      if (deleteItr != list.end()) {
        list.erase(deleteItr);
      }
    }
  }

  auto itr = list.cbegin();
  const auto endItr = list.cend();
  std::printf("%d", *itr);
  for (++itr; itr != endItr; ++itr) {
    std::printf(" %d", *itr);
  }
  std::puts("");

  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <iostream>
#include <list>
#include <string>

int main() {

  int commandCount;
  std::cin >> commandCount;

  std::list<int> list;
  while (commandCount--) {
    std::string command;
    std::cin >> command;
    int value;

    if (command == "insert") {
      std::cin >> value;
      list.emplace_front(value);
    }
    if (command == "delete") {
      std::cin >> value;
      const auto deleteItr = std::find(list.begin(), list.end(), value);
      if (deleteItr != list.end()) {
        list.erase(deleteItr);
      }
    }
    if (command == "deleteFirst") {
      list.pop_front();
    }
    if (command == "deleteLast") {
      list.pop_back();
    }
  }

  auto itr = list.cbegin();
  const auto endItr = list.cend();
  std::cout << *itr;
  for (++itr; itr != endItr; ++itr) {
    std::cout << " " << *itr;
  }
  std::cout << std::endl;

  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <fstream>
#include <iostream>
#include <list>
#include <sstream>
#include <string>

using namespace std;
int main() {
  int n;
  std::istream &c_in = cin;
  string s;
  getline(c_in, s);
  sscanf(s.c_str(), "%d", &n);

  std::list<long> dq;
  for (int i = 0; i < n; ++i) {
    getline(c_in, s);

    int value;
    if (s[0] == 'i') { //"insert"
      // sscanf(s.substr(6).c_str(),"%d",&value);
      sscanf(&(s[7]), "%d", &value);
      dq.push_front(value);
    } else if (s[0] == 'd') { // deletexx
      char s6 = s[6];
      if (s6 == ' ') { // delete
        sscanf(&(s[7]), "%d", &value);
        std::list<long>::iterator it = find(dq.begin(), dq.end(), value);
        if (it != dq.end()) {
          dq.erase(it);
        }
      } else if (s6 == 'F') { //"deleteFirst"
        // if (!dq.empty())
        { dq.pop_front(); }
      } else // if (s6 == 'L')
      {      //"deleteLast"
        // if (!dq.empty())
        { dq.pop_back(); }
      }
    }
  }
  if (!dq.empty()) {
    std::list<long>::iterator it = dq.begin(), ite = dq.end();
    cout << *it;
    it++;
    ite = dq.end();
    for (; it != ite; ++it) {
      // cout << " " << *it;
      // sprintf_s(buf,32," %d",*it);
      // cout << buf;
      printf(" %d", *it);
    }
  }
  cout << std::endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <fstream>
#include <iostream>
#include <list>
#include <sstream>
#include <string>

using namespace std;
int main() {
  int n;
  std::istream &c_in = cin;
  string s;
  getline(c_in, s);
  sscanf(s.c_str(), "%d", &n);

  std::list<long> dq;
  for (int i = 0; i < n; ++i) {
    getline(c_in, s);

    int value;
    if (s[0] == 'i') { //"insert"
      sscanf(s.substr(6).c_str(), "%d", &value);
      dq.push_front(value);
    } else if (s[0] == 'd') { // deletexx
      if (s[6] == ' ') {      // delete
        sscanf(s.substr(6).c_str(), "%d", &value);
        std::list<long>::iterator it = find(dq.begin(), dq.end(), value);
        if (it != dq.end()) {
          dq.erase(it);
        }
      } else if (s[6] == 'F') { //"deleteFirst"
        if (!dq.empty()) {
          dq.pop_front();
        }
      } else if (s[6] == 'L') { //"deleteLast"
        if (!dq.empty()) {
          dq.pop_back();
        }
      }
    }
  }
  if (!dq.empty()) {
    std::list<long>::iterator it = dq.begin(), ite = dq.end();
    cout << *it;
    it++;
    for (; it != ite; ++it) {
      printf(" %d", *it);
    }
  }
  cout << std::endl;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <iostream>
#include <list>
#include <string>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it, l;
  int n, x;
  cin >> n;
  while (n--) {
    cin >> str;
    if (str == "insert") {
      cin >> x;
      data.push_front(x);
    } else if (str == "delete") {
      cin >> x;
      for (it = data.begin(), l = data.end(); it != l; ++it) {
        if (*it == x) {
          data.erase(it);
          break;
        }
      }
    } else if (str == "deleteFirst")
      data.pop_front();
    else
      data.pop_back();
  }
  for (it = data.begin(), l = data.end(); it != l; ++it) {
    cout << (it == data.begin() ? "" : " ") << *it;
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <list>
#include <string>
using namespace std;
int main() {
  string str;
  list<int> data;
  list<int>::iterator it, l;
  int n, x;
  bool flg = false;
  cin >> n;
  while (n--) {
    cin >> str;
    if (str == "insert") {
      cin >> x;
      data.push_front(x);
    } else if (str == "delete") {
      cin >> x;
      for (it = data.begin(), l = data.end(); it != l; it++) {
        if (*it == x) {
          data.erase(it);
          break;
        }
      }
    } else if (str == "deleteFirst")
      data.pop_front();
    else
      data.pop_back();
  }
  for (it = data.begin(), l = data.end(); it != l; it++, flg = true) {
    cout << (flg ? " " : "") << *it;
  }
  cout << endl;
}
Problem p02265 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it, l;
  int n, x;
  cin >> n;
  while (n--) {
    cin >> str;
    if (str == "insert") {
      cin >> x;
      data.push_front(x);
    } else if (str == "delete") {
      cin >> x;
      it = find(data.begin(), data.end(), x);
      if (it != data.end())
        data.erase(it);
    } else if (str == "deleteFirst")
      data.pop_front();
    else
      data.pop_back();
  }
  for (it = data.begin(), l = --data.end(); it != l; ++it) {
    cout << *it << " ";
  }
  cout << *it << endl;
}

Error: 0

Fixed submission:

#include <algorithm>
#include <iostream>
#include <list>
#include <string>
using namespace std;
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  string str;
  list<int> data;
  list<int>::iterator it, l;
  int n, x;
  cin >> n;
  while (n--) {
    cin >> str;
    if (str == "insert") {
      cin >> x;
      data.push_front(x);
    } else if (str == "delete") {
      cin >> x;
      data.erase(find(data.begin(), data.end(), x));
    } else if (str == "deleteFirst")
      data.pop_front();
    else
      data.pop_back();
  }
  for (it = data.begin(), l = --data.end(); it != l; ++it) {
    cout << *it << " ";
  }
  cout << *it << endl;
}