Buggy python submission (verdict: Time Limit Exceeded):
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

    def __repr__(self):
        return str(self.num);

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def __repr__(self):
        s = "";
        current = self.first;
        while current:
            s += str(current);
            current = current.nxt;
            if current:
                s += " ";
        return s;

    def insert(self, num):
        node = Node(num);
        first = self.first;
        if first:
            first.prev = node;
            node.nxt = first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt:
                    current.nxt = None;
                    nxt.prev = prev;
                if not nxt:
                    self.last = prev;
                if not prev:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        first = self.first;
        if first:
            nxt = first.nxt;
            if nxt:
                self.first = nxt;
                nxt.prev = None;
                first.nxt = None;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        last = self.last;
        if last:
            prev = last.prev;
            if prev:
                prev.nxt = None;
                last.prev = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

def main():
    double_linked_list = Double_Linked_List();
    count = int(input());
    for i in range(count):
        command = input().split();
        command_name = command[0];

        if command_name == "deleteFirst":
            double_linked_list.delete_first();
        elif command_name == "deleteLast":
            double_linked_list.delete_last();
        elif command_name == "delete":
            num = int(command[1]);
            double_linked_list.delete(num);
        elif command_name == "insert":
            num = int(command[1]);
            double_linked_list.insert(num);
    print(double_linked_list);

main();



Fixed submission:
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    from sys import stdin
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = stdin.readline().strip().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();

Buggy python submission (verdict: Time Limit Exceeded):
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

    def __repr__(self):
        return str(self.num);

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def __repr__(self):
        s = "";
        current = self.first;
        while current:
            s += str(current.num);
            current = current.nxt;
            if current:
                s += " ";
        return s;

    def insert(self, num):
        node = Node(num);
        first = self.first;
        if first:
            first.prev = node;
            node.nxt = first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt:
                    current.nxt = None;
                    nxt.prev = prev;
                if not nxt:
                    self.last = prev;
                if not prev:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        first = self.first;
        if first:
            nxt = first.nxt;
            if nxt:
                self.first = nxt;
                nxt.prev = None;
                first.nxt = None;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        last = self.last;
        if last:
            prev = last.prev;
            if prev:
                prev.nxt = None;
                last.prev = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

def main():
    double_linked_list = Double_Linked_List();
    count = int(input());
    for i in range(count):
        command = input().split();
        command_name = command[0];

        if command_name == "deleteFirst":
            double_linked_list.delete_first();
        elif command_name == "deleteLast":
            double_linked_list.delete_last();
        elif command_name == "delete":
            num = int(command[1]);
            double_linked_list.delete(num);
        elif command_name == "insert":
            num = int(command[1]);
            double_linked_list.insert(num);
    print(double_linked_list);

main();



Fixed submission:
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    from sys import stdin
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = stdin.readline().strip().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();

Buggy python submission (verdict: Time Limit Exceeded):
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

    def __repr__(self):
        return str(self.num);

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        first = self.first;
        if first:
            first.prev = node;
            node.nxt = first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt:
                    current.nxt = None;
                    nxt.prev = prev;
                if not nxt:
                    self.last = prev;
                if not prev:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        first = self.first;
        if first:
            nxt = first.nxt;
            if nxt:
                self.first = nxt;
                nxt.prev = None;
                first.nxt = None;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        last = self.last;
        if last:
            prev = last.prev;
            if prev:
                prev.nxt = None;
                last.prev = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        current = self.first;
        while current:
            ret.append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    double_linked_list = Double_Linked_List();
    count = int(input());
    for i in range(count):
        command = input().split();
        command_name = command[0];

        if command_name == "deleteFirst":
            double_linked_list.delete_first();
        elif command_name == "deleteLast":
            double_linked_list.delete_last();
        elif command_name == "delete":
            num = command[1];
            double_linked_list.delete(num);
        elif command_name == "insert":
            num = command[1];
            double_linked_list.insert(num);
    print(double_linked_list.get_content());

main();


Fixed submission:
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    from sys import stdin
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = stdin.readline().strip().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();

Buggy python submission (verdict: Time Limit Exceeded):
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

    def __repr__(self):
        return str(self.num);

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        first = self.first;
        if first is not None:
            first.prev = node;
            node.nxt = first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        first = self.first;
        if first is not None:
            nxt = first.nxt;
            if nxt is not None:
                self.first = nxt;
                nxt.prev = None;
                first.nxt = None;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        last = self.last;
        if last is not None:
            prev = last.prev;
            if prev is not None:
                prev.nxt = None;
                last.prev = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        current = self.first;
        while current is not None:
            ret.append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    double_linked_list = Double_Linked_List();
    count = int(input());
    for i in range(count):
        command = input().split();
        command_name = command[0];

        if command_name == "deleteFirst":
            double_linked_list.delete_first();
        elif command_name == "deleteLast":
            double_linked_list.delete_last();
        elif command_name == "delete":
            num = command[1];
            double_linked_list.delete(num);
        elif command_name == "insert":
            num = command[1];
            double_linked_list.insert(num);
    print(double_linked_list.get_content());

main();


Fixed submission:
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    from sys import stdin
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = stdin.readline().strip().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();

Buggy python submission (verdict: Time Limit Exceeded):
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

    def __repr__(self):
        return str(self.num);

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        first = self.first;
        if first is not None:
            first.prev = node;
            node.nxt = first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        first = self.first;
        if first is not None:
            nxt = first.nxt;
            if nxt is not None:
                self.first = nxt;
                nxt.prev = None;
                first.nxt = None;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        last = self.last;
        if last is not None:
            prev = last.prev;
            if prev is not None:
                prev.nxt = None;
                last.prev = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = input().split();
        command_name = command[0];

        if command_name == "insert":
            num = command[1];
            insert(num);
        if command_name == "delete":
            num = command[1];
            delete(num);
        elif command_name == "deleteFirst":
            delete_first();
        elif command_name == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();


Fixed submission:
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    from sys import stdin
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = stdin.readline().strip().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();

Buggy python submission (verdict: Runtime Error):
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        first = self.first;
        if first is not None:
            first.prev = node;
            node.nxt = first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        first = self.first;
        if first is not None:
            nxt = first.nxt;
            if nxt is not None:
                self.first = nxt;
                nxt.prev = None;
                first.nxt = None;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        last = self.last;
        if last is not None:
            prev = last.prev;
            if prev is not None:
                prev.nxt = None;
                last.prev = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in xrange(count):
        command = input().split();
        command_name = command[0];

        if command_name == "insert":
            num = command[1];
            insert(num);
        if command_name == "delete":
            num = command[1];
            delete(num);
        elif command_name == "deleteFirst":
            delete_first();
        elif command_name == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();



Fixed submission:
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    from sys import stdin
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = stdin.readline().strip().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();

Buggy python submission (verdict: Time Limit Exceeded):
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        first = self.first;
        if first is not None:
            first.prev = node;
            node.nxt = first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        first = self.first;
        if first is not None:
            nxt = first.nxt;
            if nxt is not None:
                self.first = nxt;
                nxt.prev = None;
                first.nxt = None;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        last = self.last;
        if last is not None:
            prev = last.prev;
            if prev is not None:
                prev.nxt = None;
                last.prev = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = input().split();
        command_name = command[0];

        if command_name == "insert":
            num = command[1];
            insert(num);
        if command_name == "delete":
            num = command[1];
            delete(num);
        elif command_name == "deleteFirst":
            delete_first();
        elif command_name == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();



Fixed submission:
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    from sys import stdin
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = stdin.readline().strip().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();

Buggy python submission (verdict: Time Limit Exceeded):
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = input().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();









Fixed submission:
class Node(object):
    def __init__(self, num, prev = None, nxt = None):
        self.num = num;
        self.prev = prev;
        self.nxt = nxt;

class Double_Linked_List(object):
    def __init__(self):
        self.first = self.last = None;

    def insert(self, num):
        node = Node(num);
        if self.first is not None:
            self.first.prev = node;
            node.nxt = self.first;
            self.first = node;
        else:
            self.first = node;
            self.last = node;

    def delete(self, num):
        current = self.first;
        while current is not None:
            if current.num == num:
                prev = current.prev;
                nxt = current.nxt;
                if prev is not None:
                    current.prev = None;
                    prev.nxt = nxt;
                if nxt is not None:
                    current.nxt = None;
                    nxt.prev = prev;
                if nxt is None:
                    self.last = prev;
                if prev is None:
                    self.first = nxt;
                break;
            else:
                current = current.nxt;

    def delete_first(self):
        if self.first is not None:
            nxt = self.first.nxt;
            if nxt is not None:
                self.first.nxt = None;
                nxt.prev = None;
                self.first = nxt;
            else:
                self.first = None;
                self.last = None;

    def delete_last(self):
        if self.last is not None:
            prev = self.last.prev;
            if prev is not None:
                self.last.prev = None;
                prev.nxt = None;
                self.last = prev;
            else:
                self.first = None;
                self.last = None;

    def get_content(self):
        ret = [];
        append = ret.append;
        current = self.first;
        while current is not None:
            append(current.num);
            current = current.nxt;
        return " ".join(ret);

def main():
    from sys import stdin
    double_linked_list = Double_Linked_List();
    count = int(input());
    delete_first = double_linked_list.delete_first;
    delete_last = double_linked_list.delete_last;
    delete = double_linked_list.delete;
    insert = double_linked_list.insert;
    for i in range(count):
        command = stdin.readline().strip().split();
        if command[0] == "insert":
            insert(command[1]);
        if command[0] == "delete":
            delete(command[1]);
        elif command[0] == "deleteFirst":
            delete_first();
        elif command[0] == "deleteLast":
            delete_last();
    print(double_linked_list.get_content());

main();