Buggy python submission (verdict: Runtime Error):
# -*- coding: utf-8 -*-

commands = {"insert": lambda x, l: insert(x, l),
            "delete": lambda x, l: delete(x, l),
            "deleteFirst": lambda l: deleteFirst(l),
            "deleteLast": lambda l: deleteLast(l)}


# ??£??????????????????????????????x?????????????´?????¶?????¶????
def insert(x, l):
    l = [x] + l
    return l


# ??????x??????????????????????´??????£??????????????????????????????
def delete(x, l):
    for i in xrange(len(l)):
        if l[i] == x:
            l.pop(i)
            break
    return l


# ?????????????????????????´????????????????
def deleteFirst(l):
    l.pop(0)
    return l


# ????????????????°????????´????????????????
def deleteLast(l):
    l.pop()
    return l


if __name__ == '__main__':
    N = input()
    functions, args = [], []
    for i in xrange(N):
        command = raw_input().split()
        functions.append(command[0])
        args.append(command[1])

    result = []
    for i in xrange(len(functions)):
        result = commands[functions[i]](args[i], result)
    print ' '.join(result)

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list)))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

commands = {"insert": lambda x, l: insert(x, l),
            "delete": lambda x, l: delete(x, l),
            "deleteFirst": lambda x, l: deleteFirst(x, l),
            "deleteLast": lambda x, l: deleteLast(x, l)}


# ??£??????????????????????????????x?????????????´?????¶?????¶????
def insert(x, l):
    l = [x] + l
    return l


# ??????x??????????????????????´??????£??????????????????????????????
def delete(x, l):
    for i in xrange(len(l)):
        if l[i] == x:
            l.pop(i)
            break
    return l


# ?????????????????????????´????????????????
def deleteFirst(x, l):
    l.pop(0)
    return l


# ????????????????°????????´????????????????
def deleteLast(x, l):
    l.pop()
    return l


if __name__ == '__main__':
    N = input()
    functions, args = [], []
    for i in xrange(N):
        command = raw_input().split()
        functions.append(command[0])
        if command[0] == "deleteFirst" or command[0] == "deleteLast":
            args.append(0)
        else:
            args.append(int(command[1]))

    result = []
    for i in xrange(len(functions)):
        result = commands[functions[i]](args[i], result)
    print ' '.join(map(str, result))

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list)))

Buggy python submission (verdict: Time Limit Exceeded):
# -*- coding: utf-8 -*-

functions = {"insert": lambda x, l: insert(x, l),
             "delete": lambda x, l: delete(x, l),
             "deleteFirst": lambda x, l: deleteFirst(x, l),
             "deleteLast": lambda x, l: deleteLast(x, l)}


# ??£??????????????????????????????x?????????????´?????¶?????¶????
def insert(x, l):
    l = [x] + l
    return l


# ??????x??????????????????????´??????£??????????????????????????????
def delete(x, l):
    for i in xrange(len(l)):
        if l[i] == x:
            l.pop(i)
            break
    return l


# ?????????????????????????´????????????????
def deleteFirst(x, l):
    l.pop(0)
    return l


# ????????????????°????????´????????????????
def deleteLast(x, l):
    l.pop()
    return l


if __name__ == '__main__':
    N = input()
    commands, args = [], []
    column = [raw_input().split() for i in xrange(N)]

    for i in xrange(N):
        # command = raw_input().split()
        commands.append(column[i][0])
        if column[i][0] == "deleteFirst" or column[i][0] == "deleteLast":
            args.append(0)
        else:
            args.append(int(column[i][1]))

    result = []
    for i in xrange(len(commands)):
        result = functions[commands[i]](args[i], result)
    print ' '.join(map(str, result))

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list)))

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python
# -*- coding: utf-8 -*-


''' ???????????£???????????? '''

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        self.list = []

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        self.list = [x] + self.list

    def delete(self, x):
        """ ??????x??????????????????????´??????????"""
        for i in range(len(self.list)):
            if self.list[i] == x:
                self.list.pop(i)
                break

    def deleteFirst(self):
        """ ?????????????????????????´??????????"""
        self.list.pop(0)

    def deleteLast(self):
        """ ????????????????°????????´??????????"""
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    dll = DoublyLinkedList()

    for i in range(N):
        command = input().split()

        if len(command) == 1:
            functions[command[0]](dll)
        elif len(command) == 2:
            functions[command[0]](dll, int(command[1]))

    print(' '.join(map(str, dll.list)))

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list)))

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´??????????"""
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´??????????"""
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´??????????"""
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    dll = DoublyLinkedList()

    for i in range(N):
        command = input().split()

        if len(command) == 1:
            functions[command[0]](dll)
        elif len(command) == 2:
            functions[command[0]](dll, int(command[1]))

    print(' '.join(map(str, dll.list)))

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list)))

Buggy python submission (verdict: Runtime Error):
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        # if x in self.list:
        self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    dll = DoublyLinkedList()

    for i in range(N):
        command = input().split()

        if len(command) == 1:
            functions[command[0]](dll)
        elif len(command) == 2:
            functions[command[0]](dll, int(command[1]))

    print(' '.join(map(str, dll.list)))

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list)))

Buggy python submission (verdict: Time Limit Exceeded):
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    dll = DoublyLinkedList()

    for i in range(N):
        command = input().split()

        if len(command) == 1:
            functions[command[0]](dll)
        elif len(command) == 2:
            functions[command[0]](dll, int(command[1]))

    print(' '.join(map(str, dll.list)))

Fixed submission:
#! /usr/bin/env python
# -*- coding: utf-8 -*-

''' ???????????£???????????? '''

from collections import deque

functions = {"insert": lambda obj, x: obj.insert(x),
             "delete": lambda obj, x: obj.delete(x),
             "deleteFirst": lambda obj: obj.deleteFirst(),
             "deleteLast": lambda obj: obj.deleteLast()}


class DoublyLinkedList(object):
    """ Doubly Linked List """

    def __init__(self):
        # self.list = []
        self.list = deque()

    def insert(self, x):
        """ ???????????????x?????????????´?????????\ """
        # self.list = [x] + self.list
        self.list.appendleft(x)

    def delete(self, x):
        """ ??????x??????????????????????´?????????? """
        # for i in range(len(self.list)):
        #     if self.list[i] == x:
        #         self.list.pop(i)
        #         break
        if x in self.list:
            self.list.remove(x)

    def deleteFirst(self):
        """ ?????????????????????????´?????????? """
        # self.list.pop(0)
        self.list.popleft()

    def deleteLast(self):
        """ ????????????????°????????´?????????? """
        self.list.pop()


if __name__ == '__main__':
    N = int(input())

    q = deque()
    for i in range(N):
        command = input().split()
        if command[0] == 'insert':
            q.appendleft(command[1])
        elif command[0] == 'delete':
            if command[1] in q:
                q.remove(command[1])
        elif command[0] == 'deleteFirst':
            q.popleft()
        elif command[0] == 'deleteLast':
            q.pop()

    print(' '.join(map(str, q)))

    # dll = DoublyLinkedList()
    # for i in range(N):
    #     command = input().split()
    #     if len(command) == 1:
    #         functions[command[0]](dll)
    #     elif len(command) == 2:
    #         functions[command[0]](dll, int(command[1]))
    # print(' '.join(map(str, dll.list)))