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

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <list>
using namespace std;

#define NMAX 2000000 + 10

int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  int n, x;
  string inp;
  list<int> data;
  list<int>::iterator iter, fun;

  cin >> n;

  while (n--) {
    cin >> inp;

    if (inp[6] == 'F')
      data.pop_front();
    else if (inp[6] == 'L')
      data.pop_back();
    else {
      cin >> x;
      if (inp[0] == 'i')
        data.push_front(x);
      else {
        fun = find(data.begin(), data.end(), x);
        if (fun != data.end())
          data.erase(fun);
      }
    }
  }

  iter = data.begin();
  cout << *iter++;
  while (iter != data.end()) {
    cout << " " << *iter++;
  }
  cout << endl;
  return 0;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <sstream>
using namespace std;

int main(int argc, char *argv[]) {
  int n, key;
  list<int> li;

  cin >> n;

  while (n-- > 0) {
    string str;
    cin >> str;

    //
    if (str.length() >= 10) {
      if (str[6] == 'F')
        li.pop_front();
      else
        li.pop_back();
    } else {
      cin >> key;

      if (str[0] == 'i') {
        li.push_front(key);
      } else {
        list<int>::iterator itli;
        itli = find(li.begin(), li.end(), key);
        if (itli != li.end()) {
          li.erase(itli);
        }
      }
    }
    //
    /*
      if(str=="insert"){
      cin>>key;
      li.push_front(key);
      }
      else if(str=="delete"){
      cin>>key;
      list<int>::iterator itli;
      itli=find(li.begin(),li.end(),key);
      if(itli!=li.end()){
      li.erase(itli);
      }
      }
      else if(str=="deleteFirst")
      li.pop_front();
      else
      li.pop_back();
    */
  }

  if (!li.empty()) {
    cout << li.front();
    li.pop_front();
    while (!li.empty()) {
      cout << " " << li.front();
      li.pop_front();
    }
    puts("");
  }
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <sstream>
using namespace std;

int main(int argc, char *argv[]) {
  std::ios_base::sync_with_stdio(false);
  int n, key;
  list<int> li;
  string str;
  list<int>::iterator itli;

  cin >> n;

  while (n--) {
    cin >> str;

    if (str[6] == 'F')
      li.pop_front();
    else if (str[6] == 'L')
      li.pop_back();
    else {
      cin >> key;
      if (str[0] == 'i')
        li.push_front(key);
      else {
        itli = find(li.begin(), li.end(), key);
        if (itli != li.end())
          li.erase(itli);
      }
    }
  }

  itli = li.begin();
  cout << *itli++;
  while (itli != li.end()) {
    cout << " " << *itli++;
  }
  cout << endl;
}

Error: TLE

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <sstream>
using namespace std;

int main(int argc, char *argv[]) {
  int n, key;
  list<int> li;
  string str;
  list<int>::iterator itli;

  cin >> n;

  while (n--) {
    cin >> str;

    //
    if (str[6] == 'F')
      li.pop_front();
    else if (str[6] == 'L')
      li.pop_back();
    else {
      cin >> key;
      if (str[0] == 'i')
        li.push_front(key);
      else {
        itli = find(li.begin(), li.end(), key);
        if (itli != li.end())
          li.erase(itli);
      }
    }
    //
    /*
      if(str=="insert"){
      cin>>key;
      li.push_front(key);
      }
      else if(str=="delete"){
      cin>>key;
      list<int>::iterator itli;
      itli=find(li.begin(),li.end(),key);
      if(itli!=li.end()){
      li.erase(itli);
      }
      }
      else if(str=="deleteFirst")
      li.pop_front();
      else
      li.pop_back();
    */
  }

  itli = li.begin();
  cout << *itli++;
  while (itli != li.end()) {
    cout << " " << *itli++;
  }
  cout << endl;
}
Problem p02265 (C++) — buggy submission, verdict: Runtime Error

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

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

  int n, x;
  string cmd;
  cin >> n;
  list<int> lst;
  REP(i, n) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> x;
      lst.push_front(x);
    } else if (cmd == "delete") {
      cin >> x;
      auto it = find(ALL(lst), x);
      if (it != lst.end())
        lst.erase(it);
    } else if (cmd == "deleteFirst") {
      lst.pop_front();
    } else if (cmd == "deleteLast") {
      lst.pop_back();
    }
  }
  for (auto it = lst.begin(); it != lst.end(); ++it) {
    if (it != lst.begin())
      cout << " ";
    cout << *it;
  }
  cout << endl;
}


Error: 0

Fixed submission:

#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a), i##_max = (b); i < i##_max; ++i)
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;

constexpr int INF = 1 << 30;
constexpr int MOD = 1000000007;

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

  int n, x;
  string cmd;
  cin >> n;
  list<int> lst;
  REP(i, n) {
    cin >> cmd;
    if (cmd == "insert") {
      cin >> x;
      lst.push_front(x);
    } else if (cmd == "delete") {
      cin >> x;
      lst.erase(find(ALL(lst), x));
    } else if (cmd == "deleteFirst") {
      lst.pop_front();
    } else if (cmd == "deleteLast") {
      lst.pop_back();
    }
  }
  for (auto it = lst.begin(); it != lst.end(); ++it) {
    if (it != lst.begin())
      cout << " ";
    cout << *it;
  }
  cout << endl;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

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

using namespace std;

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

  list<int> lst;
  string s;
  int n, num;
  list<int>::iterator it, en = lst.end();

  cin >> n;
  while (n--) {
    cin >> s;
    if (s == "insert") {
      cin >> num;
      lst.push_front(num);
    } else if (s == "delete") {
      cin >> num;
      for (it = lst.begin(); it != en; it++) {
        if (*it == num) {
          lst.erase(it);
          break;
        }
      }
    } else if (s == "deleteFirst") {
      lst.pop_front();
    } else {
      lst.pop_back();
    }
  }

  en--;
  for (it = lst.begin(); it != en; it++) {
    cout << *it << " ";
  }
  cout << *en << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

using namespace std;

int main() {
  list<int> lst;
  string s;
  int n, num;
  list<int>::iterator it, en = lst.end();

  scanf("%d", &n);
  while (n--) {
    cin >> s;
    if (s == "insert") {
      scanf("%d", &num);
      lst.push_front(num);
    } else if (s == "delete") {
      scanf("%d", &num);
      for (it = lst.begin(); it != en; it++) {
        if (*it == num) {
          lst.erase(it);
          break;
        }
      }
    } else if (s == "deleteFirst") {
      lst.pop_front();
    } else {
      lst.pop_back();
    }
  }

  en--;
  for (it = lst.begin(); it != en; it++) {
    printf("%d ", *it);
  }
  printf("%d\\n", *en);

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

#include <iostream>
#include <list>

#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

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

  list<int> data;
  list<int>::iterator it;
  int key, n, i;
  string command;

  cin >> n;
  rep(i, n) {
    cin >> command;
    if (command == "insert") {
      cin >> key;
      data.push_front(key);
    } else if (command == "delete") {
      cin >> key;
      it = data.begin();
      while (it != data.end()) {
        if (*it == key) {
          data.erase(it);
          break;
        }
        it++;
      }
    } else if (command == "deleteFirst") {
      data.pop_front();
    } else if (command == "deleteLast") {
      data.pop_back();
    }
  }

  it = data.begin();
  while (it != data.end()) {
    cout << *it;
    it++;
    if (it != data.end())
      cout << " ";
  }
  cout << endl;

  return 0;
}


Error: TLE

Fixed submission:

#include <iostream>
#include <list>

#define REP(i, a, b) for (i = a; i < b; i++)
#define rep(i, n) REP(i, 0, n)

using namespace std;

int main() {
  list<int> data;
  list<int>::iterator it;
  int key, n, i;
  string command;

  cin >> n;
  rep(i, n) {
    cin >> command;
    if (command == "insert") {
      cin >> key;
      data.push_front(key);
    } else if (command == "delete") {
      cin >> key;
      it = data.begin();
      while (it != data.end()) {
        if (*it == key) {
          data.erase(it);
          break;
        }
        it++;
      }
    } else if (command == "deleteFirst") {
      data.pop_front();
    } else if (command == "deleteLast") {
      data.pop_back();
    }
  }

  it = data.begin();
  while (it != data.end()) {
    cout << *it;
    it++;
    if (it != data.end())
      cout << " ";
  }
  cout << endl;

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

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

  int n;
  int entersuji;
  cin >> n;
  list<int> suji;
  std::string command;
  for (int i = 0; i < n; i++) {
    cin >> command;
    if (command == "insert") {
      cin >> entersuji;
      suji.insert(suji.begin(), entersuji);
    }
    if (command == "delete") {
      cin >> entersuji;
      list<int>::iterator itr = std::find(suji.begin(), suji.end(), entersuji);
      if (itr != suji.end()) {
        suji.erase(itr);
      }
    }
    if (command == "deleteLast") {
      suji.pop_back();
    }

    if (command == "deleteFirst") {
      suji.pop_front();
    }
  }

  list<int>::iterator It = suji.begin();
  std::cout << *It;
  for (++It; It != suji.end(); ++It) {
    std::cout << " " << *It;
  }
  cout << endl;

  return 0;
}

Error: TLE

Fixed submission:

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

  int n;
  int entersuji;
  int del = 0;
  cin >> n;
  vector<int> suji;
  std::string command;
  for (int i = 0; i < n; i++) {
    cin >> command;
    if (command == "insert") {
      cin >> entersuji;
      suji.insert(suji.begin(), entersuji);
    }
    if (command == "delete") {
      cin >> entersuji;
      vector<int>::iterator itr =
          std::find(suji.begin(), suji.end(), entersuji);
      if (itr != suji.end()) {
        suji.erase(itr);
      }
    }
    if (command == "deleteLast") {
      suji.pop_back();
    }

    if (command == "deleteFirst") {
      suji.erase(suji.begin());
    }
  }
  for (int j = 0; j < suji.size(); j++) {
    if (j != 0) {
      cout << " ";
    }
    cout << suji[j];
  }
  cout << endl;
  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

#include <cstdio>
#include <iostream>
#include <string>

using namespace std;

class Node {
public:
  Node *prev;
  Node *next;
  int key;
};

Node *nil;

void init() {
  nil->key = 0;
  nil->prev = nil;
  nil->next = nil;
}

void print() {
  Node *cur = nil->next;
  int isf = 0;
  while (true) {
    if (cur == nil) {
      break;
    }
    if (isf++ > 0) {
      cout << " ";
    }
    cout << cur->key;
    cur = cur->next;
  }
  cout << endl;
}

void insert(int key) {
  Node *node = new Node;
  node->key = key;
  node->next = nil->next;
  nil->next->prev = node;
  nil->next = node;
  node->prev = nil;
}

Node *listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return (cur);
}

void deleteNode(Node *t) {
  if (t == nil) {
    return;
  }
  t->prev->next = t->next;
  t->next->prev = t->prev;
  delete (t);
}

void deleteKey(int key) { deleteNode(listSearch(key)); }

void deleteFirst() { deleteNode(nil->next); }

void deleteLast() { deleteNode(nil->prev); }

void solve() {
  int n;
  cin >> n;
  nil = new Node;
  init();
  for (int i = 0; i < n; ++i) {
    char command[12];
    scanf("%s", command);
    if (command[6] == 'F') {
      deleteFirst();
    } else if (command[6] == 'L') {
      deleteLast();
    } else {
      int key;
      scanf("%d", &key);
      if (command[0] == 'i') {
        insert(key);
      } else if (command[0] == 'd') {
        deleteKey(key);
      }
    }
  }
  print();
  delete nil;
}

int main() {
  solve();
  return (0);
}

Error: TLE

Fixed submission:

#include <iostream>
#include <string>

using namespace std;

class Node {
public:
  Node *prev;
  Node *next;
  int key;
};

Node *nil;

void init() {
  nil->key = 0;
  nil->prev = nil;
  nil->next = nil;
}

void print() {
  Node *cur = nil->next;
  int isf = 0;
  while (true) {
    if (cur == nil) {
      break;
    }
    if (isf++ > 0) {
      cout << " ";
    }
    cout << cur->key;
    cur = cur->next;
  }
  cout << endl;
}

void insert(int key) {
  Node *node = new Node;
  node->key = key;
  node->next = nil->next;
  nil->next->prev = node;
  nil->next = node;
  node->prev = nil;
}

Node *listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return (cur);
}

void deleteNode(Node *t) {
  if (t == nil) {
    return;
  }
  t->prev->next = t->next;
  t->next->prev = t->prev;
  delete (t);
}

void deleteKey(int key) { deleteNode(listSearch(key)); }

void deleteFirst() { deleteNode(nil->next); }

void deleteLast() { deleteNode(nil->prev); }

void solve() {
  int n;
  cin >> n;
  nil = new Node;
  init();
  for (int i = 0; i < n; ++i) {
    string command;
    cin >> command;
    if (command == "deleteFirst") {
      deleteFirst();
    } else if (command == "deleteLast") {
      deleteLast();
    } else {
      int key;
      cin >> key;
      if (command == "insert") {
        insert(key);
      } else if (command == "delete") {
        deleteKey(key);
      }
    }
  }
  print();
  delete nil;
}

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

#include <iostream>
#include <list>
#include <stdio.h>
using namespace std;
int main() {
  int n, num;
  list<int> b;
  char a[10];
  list<int>::iterator it;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%s", a);
    if (a[5] == 't') {
      scanf("%d", &num);
      b.push_front(num);
    } else if (a[6] == 'L') {
      b.pop_back();
    } else if (a[6] == 'F') {
      b.pop_front();
    } else {
      scanf("%d", &num);
      it = b.begin();
      for (; it != b.end(); it++) {
        if (*it == num) {
          b.erase(it);
          break;
        }
      }
    }
  }
  it = b.begin();
  for (; it != b.end(); it++) {
    if (it != b.begin())
      printf(" ");
    printf("%d", *it);
  }
  printf("\\n");
  return 0;
}

Error: TLE

Fixed submission:

#include <iostream>
#include <list>
#include <stdio.h>
using namespace std;
int main() {
  int n, num;
  list<int> b;
  char a[10];
  list<int>::iterator it;
  cin >> n;
  for (int i = 0; i < n; i++) {
    scanf("%s", a);
    if (a[5] == 't') {
      scanf("%d", &num);
      b.push_front(num);
    } else if (a[6] == 'L') {
      b.pop_back();
    } else if (a[6] == 'F') {
      b.pop_front();
    } else {
      scanf("%d", &num);
      it = b.begin();
      for (int j = 0; j < b.size(); j++) {
        if (*it == num) {
          b.erase(it);
          break;
        }
        it++;
      }
    }
  }
  it = b.begin();
  for (int i = 0; i < b.size(); i++) {
    if (i)
      printf(" ");
    printf("%d", *it);
    it++;
  }
  printf("\\n");
  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

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

char s[100];
int main() {
  int n;
  scanf("%d", &n);
  list<int> ls;
  rep(i, n) {
    scanf("%s", s);
    if (!strcmp(s, "insert")) {
      int x;
      scanf("%d", &x);
      ls.push_front(x);
    } else if (!strcmp(s, "delete")) {
      int x;
      scanf("%d", &x);
      auto it = find(ls.begin(), ls.end(), x);
      if (it != ls.end())
        ls.erase(it);
    } else if (!strcmp(s, "deleteFirst"))
      ls.pop_front();
    else
      ls.pop_back();
  }
  for (auto it = ls.begin(); it != ls.end(); it++) {
    printf("%d", *it);
    if (it != --ls.end())
      printf(" ");
  }
  printf("\\n");
}

Error: TLE

Fixed submission:

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

int main() {
  int n;
  scanf("%d", &n);
  list<int> ls;
  rep(i, n) {
    string s;
    cin >> s;
    if (s == "insert") {
      int x;
      scanf("%d", &x);
      ls.push_front(x);
    }
    if (s == "delete") {
      int x;
      scanf("%d", &x);
      auto it = find(ls.begin(), ls.end(), x);
      if (it != ls.end())
        ls.erase(it);
    }
    if (s == "deleteFirst")
      ls.pop_front();
    if (s == "deleteLast")
      ls.pop_back();
  }
  for (auto it = ls.begin(); it != ls.end(); it++) {
    printf("%d", *it);
    if (it != --ls.end())
      printf(" ");
  }
  printf("\\n");
}
Problem p02265 (C++) — buggy submission, verdict: Time Limit Exceeded

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

const int len = 1000050;

inline int prev(int pos) { return (pos == 0) ? len - 1 : pos - 1; }

inline int next(int pos) { return (pos == len - 1) ? 0 : pos + 1; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> list(len);
  int first = 0, last = 0;

  string op;
  int key;
  for (int i = 0; i < n; i++) {
    cin >> op;
    if (op == "insert") {
      cin >> key;
      first = prev(first);
      list[first] = key;
    } else if (op == "deleteFirst") {
      while (list[first] == -1) {
        first = next(first);
      }
      first = next(first);
    } else if (op == "deleteLast") {
      while (list[prev(last)] == -1) {
        last = prev(last);
      }
      last = prev(last);
    } else {
      cin >> key;
      for (int j = first; j != last; j = next(j)) {
        if (list[j] == key) {
          list[j] = -1;
          break;
        }
      }
    }
  }

  bool nospace = true;
  for (int i = first; i != last; i = next(i)) {
    if (list[i] == -1)
      continue;
    if (nospace) {
      cout << list[i];
      nospace = false;
    } else {
      cout << " " << list[i];
    }
  }
  cout << endl;
}

Error: TLE

Fixed submission:

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

const int len = 1000050;

inline int prev(int pos) { return (pos == 0) ? len - 1 : pos - 1; }

inline int next(int pos) { return (pos == len - 1) ? 0 : pos + 1; }

int main() {
  int n;
  cin >> n;
  vector<int> list(len);
  int first = 0, last = 0;

  string op;
  int key;
  for (int i = 0; i < n; i++) {
    cin >> op;
    if (op == "insert") {
      cin >> key;
      first = prev(first);
      list[first] = key;
    } else if (op == "deleteFirst") {
      while (list[first] == -1) {
        first = next(first);
      }
      first = next(first);
    } else if (op == "deleteLast") {
      while (list[prev(last)] == -1) {
        last = prev(last);
      }
      last = prev(last);
    } else {
      cin >> key;
      for (int j = first; j != last; j = next(j)) {
        if (list[j] == key) {
          list[j] = -1;
          break;
        }
      }
    }
  }

  bool nospace = true;
  for (int i = first; i != last; i = next(i)) {
    if (list[i] == -1)
      continue;
    if (nospace) {
      cout << list[i];
      nospace = false;
    } else {
      cout << " " << list[i];
    }
  }
  cout << endl;
}
Problem p02265 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <list>
#include <stdlib.h>
using namespace std;

int main() {
  int key;
  int n;
  char cmd[20];
  list<int> v;

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%s %d", cmd, &key);
    if (cmd[0] == 'i') {
      v.push_front(key);
    } else if (cmd[0] == 'd') {
      if (cmd[6] == 'F') {
        v.pop_front();
      } else if (cmd[6] == 'L') {
        v.pop_back();
      } else {
        for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
          if (*it == key) {
            v.erase(it);
            break;
          }
        }
      }
    }
  }

  int i = 0;
  for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
    if (i++)
      printf(" ");
    printf("%d", *it);
  }
  printf("\\n");
  //	system("pause");
  return 0;
}


Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <list>
using namespace std;

int main() {
  int key;
  int n;
  char cmd[20];
  list<int> v;

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%s %d", cmd, key);
    if (cmd[0] == 'i') {
      v.push_front(key);
    } else if (cmd[0] == 'd') {
      if (cmd[6] == 'F') {
        v.pop_front();
      } else if (cmd[6] == 'L') {
        v.pop_back();
      }
    } else {
      for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (*it == key) {
          v.erase(it);
          break;
        }
      }
    }
  }

  int i = 0;
  for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
    if (i++)
      printf(" ");
    printf("%d", *it);
  }
  printf("\\n");
  return 0;
}
Problem p02265 (C++) — buggy submission, verdict: Runtime Error

#include <algorithm>
#include <cstdio>
#include <list>
using namespace std;
int main() {
  int n;
  int i, j = 0, x;
  char com[10];
  list<int> v;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &x);
      v.push_front(x);
    } else if (com[6] == 'F') {
      v.pop_front();
    } else if (com[6] == 'L') {
      v.pop_back();
    } else if (com[0] == 'd') {
      scanf("%d", &x);
      for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (*it == x) {
          v.erase(it);
          break;
        }
      }
    }
  }
  for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
    if (j++)
      printf(" ");
    printf("%d", *it);
  }
  printf("\\n");
  return 0;
}

Error: -11

Fixed submission:

#include <algorithm>
#include <cstdio>
#include <list>
using namespace std;
int main() {
  int n;
  int i, j = 0, x;
  char com[10];
  list<int> v;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
    scanf("%s", com);
    if (com[0] == 'i') {
      scanf("%d", &x);
      v.push_front(x);
    } else if (com[6] == 'F') {
      v.pop_front();
    } else if (com[6] == 'L') {
      v.pop_back();
    } else if (com[0] == 'd') {
      scanf("%d", x);
      for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
        if (*it == x) {
          v.erase(it);
          break;
        }
      }
    }
  }
  for (list<int>::iterator it = v.begin(); it != v.end(); it++) {
    if (j++)
      printf(" ");
    printf("%d", *it);
  }
  return 0;
}