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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""

class Dlist:
    MAX = 1000000
    
    def __init__(self):
        """ ????????????????????? """
        self.si = 0
        self.ei = 0
        self.cnt = 0
        self.data = [0 for r in range(Dlist.MAX)]

    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """
        self.si -= 1
        if self.si < 0:
            self.si = Dlist.MAX - 1
        self.data[self.si] = x
        self.cnt += 1

    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""
        if self.cnt > 0:
            self.hit = False
            for i in range(self.cnt):
                pi = self.si + i
                if pi >= Dlist.MAX:
                    pi -= Dlist.MAX
                if self.data[pi] == x:
                    hit = True
                    break
            if hit == True:
                for j in range(i, self.cnt):
                    pi = self.si + j
                    if pi >= Dlist.MAX:
                        pi -= Dlist.MAX
                    ni = pi + 1
                    if ni >= Dlist.MAX:
                        ni -= Dlist.MAX
                    self.data[pi] = self.data[ni]
                self.ei -= 1
                if self.ei < 0 :
                    self.ei = Dlist.MAX - 1
                self.cnt -= 1
            
    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            self.data[self.si] = 0
            self.si += 1
            if self.si >= Dlist.MAX:
                self.si = 0
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            self.ei -= 1
            if self.ei < 0 :
                self.ei = Dlist.MAX - 1
            self.data[self.ei] = 0
            self.cnt -= 1

    def getList(self):
        return self.data[self.si:self.ei]

# ?????????
num = int(input().strip())
dl = Dlist()

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.insert(cmd[1])
    elif cmd[0] == "delete":
        dl.delete(cmd[1])
    elif cmd[0] == "deleteFirst":
        dl.deleteFirst()
    elif cmd[0] == "deleteLast":
        dl.deleteLast()

#    print("cmd={} si={} ei={} cnt={}".format(cmd[0], dl.si, dl.ei, dl.cnt))
#    print(dl.data)

print(" ".join(map(str,dl.getList())))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""

class Dlist:
    MAX = 1000000
    
    def __init__(self):
        """ ????????????????????? """
        self.si = 0
        self.ei = 0
        self.cnt = 0
        self.data = [0 for r in range(Dlist.MAX)]

    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """
        self.si -= 1
        if self.si < 0:
            self.si = Dlist.MAX - 1
        self.data[self.si] = x
        self.cnt += 1

    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""
        if self.cnt > 0:
            hit = False
            for i in range(self.cnt):
                pi = self.si + i
                if pi >= Dlist.MAX:
                    pi -= Dlist.MAX
                if self.data[pi] == x:
                    hit = True
                    break
            if hit == True:
                for j in range(i, self.cnt):
                    pi = self.si + j
                    if pi >= Dlist.MAX:
                        pi -= Dlist.MAX
                    ni = pi + 1
                    if ni >= Dlist.MAX:
                        ni -= Dlist.MAX
                    self.data[pi] = self.data[ni]
                self.ei -= 1
                if self.ei < 0 :
                    self.ei = Dlist.MAX - 1
                self.cnt -= 1
            
    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            self.data[self.si] = 0
            self.si += 1
            if self.si >= Dlist.MAX:
                self.si = 0
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            self.ei -= 1
            if self.ei < 0 :
                self.ei = Dlist.MAX - 1
            self.data[self.ei] = 0
            self.cnt -= 1

    def getList(self):
        return self.data[self.si:self.ei]

# ?????????
num = int(input().strip())
dl = Dlist()

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.insert(cmd[1])
    elif cmd[0] == "delete":
        dl.delete(cmd[1])
    elif cmd[0] == "deleteFirst":
        dl.deleteFirst()
    elif cmd[0] == "deleteLast":
        dl.deleteLast()

#   print()
#    print(cmd)
#    print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#    print(dl.data)

print(" ".join(map(str,dl.getList())))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""

# ?????????
num = int(input().strip())
dl = []

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.insert(0,cmd[1])
    elif cmd[0] == "delete":
        dl.remove(cmd[1])
    elif cmd[0] == "deleteFirst":
        dl.pop(0)
    elif cmd[0] == "deleteLast":
        dl.pop()

print(" ".join(map(str,dl)))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""

# ?????????
num = int(input().strip())
dl = []

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.insert(0,cmd[1])
    elif cmd[0] == "delete":
        try:
            dl.remove(cmd[1])
        except ValueError:
            i = 1
        else:
            raise
    elif cmd[0] == "deleteFirst":
        dl.pop(0)
    elif cmd[0] == "deleteLast":
        dl.pop()

print(" ".join(map(str,dl)))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""

# ?????????
num = int(input().strip())
dl = []

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.insert(0,cmd[1])
    elif cmd[0] == "delete":
        try:
            dl.remove(cmd[1])
        except ValueError:
            i = 1
    elif cmd[0] == "deleteFirst":
        dl.pop(0)
    elif cmd[0] == "deleteLast":
        dl.pop()

print(" ".join(map(str,dl)))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
from collections import deque
# ?????????
num = int(input().strip())
dl = deque([])

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.appendleft(str(cmd[1]))
    elif cmd[0] == "delete":
        try:
            dl.remove(str(cmd[1]))
        except ValueError:
            i = 1
    elif cmd[0] == "deleteFirst":
        dl.popleft()
    elif cmd[0] == "deleteLast":
        dl.pop()

print(" ".join(map(str,dl)))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
class DListItem:
    NoValue = -1

    def __init__(self,idx,value):
        """ ????????????????????? """
        self.prev = DListItem.NoValue
        self.next = DListItem.NoValue
        self.value = value


class Dlist:
    MAX = 1000000
    
    def __init__(self):
        """ ????????????????????? """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        self.items = {}

    def __iter__(self):
        """ ????????¬?????? """
        if self.cnt != 0:
            self.pos = self.si
        else:
            self.pos = -1

        return self

    def __next__(self):
        """ ?¬???????????????? """
        if self.cnt == 0: # ???????????????
            raise StopIteration()
        elif self.items[self.pos].next == DListItem.NoValue: # ?¬??????????
            raise StopIteration()
        else:
            self.pos = self.items[self.pos].next
        return self.items[self.pos]

 
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        if self.cnt == Dlist.MAX: # ??????????????????
            return -1

        t = DListItem(self.uniqid, x)

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s.prev = self.uniqid
            t.next = self.si
        self.items[self.uniqid] = t
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
        return t
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == DListItem.NoValue:
                    break
                if self.items[i].value == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        n = self.items[i].next
                        p = self.items[i].prev
                        self.items[n].prev = p
                        self.items[p].next = n
                        del self.items[i]
                        self.cnt -= 1
                else:
                    i = self.items[i].next

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            n = self.items[self.si].next
            if n != DListItem.NoValue:
                self.items[n].prev = DListItem.NoValue
            del self.items[self.si]
            self.si = n
            self.cnt -= 1
            if self.cnt < 1:
                self.ei = DListItem.NoValue

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            p = self.items[self.ei].prev
            if p != DListItem.NoValue:
                self.items[p].next = DListItem.NoValue
            del self.items[self.ei]
            self.ei = p
            self.cnt -= 1
            if self.cnt < 1:
                self.si = DListItem.NoValue

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != DListItem.NoValue:
                a.append(self.items[i].value)
                i = self.items[i].next
        return a

    def debugList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != DListItem.NoValue:
                a.append("{} => {}".format(i,self.items[i].value))
                i = self.items[i].next
        return a

# ?????????
num = int(input().strip())
dl = Dlist()

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.insert(cmd[1])
    elif cmd[0] == "delete":
        dl.delete(cmd[1])
    elif cmd[0] == "deleteFirst":
        dl.deleteFirst()
    elif cmd[0] == "deleteLast":
        dl.deleteLast()

#    print()
#    print(cmd)
#    print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#    print(dl.debugList())

print(" ".join(map(str,dl.getList())))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
class DListItem:
    """ ??????????????¢?????????????????? """
    NoValue = -1

    def __init__(self,idx,value):
        """ ????????????????????? """
        self.prev = DListItem.NoValue
        self.next = DListItem.NoValue
        self.index = idx
        self.value = value

class Dlist:
    """ ??????????????????????????? """
    MAX = 1000000

    def __init__(self):
        """ ????????????????????? """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        self.items = []

    def __iter__(self):
        """ ????????¬?????? """
        self.pos = self.si
        return self

    def __next__(self):
        """ ?¬???????????????? """
        if self.cnt == 0: # ???????????????
            raise StopIteration()
        elif self.items[self.pos].next == DListItem.NoValue: # ?¬??????????
            raise StopIteration()
        else:
            self.pos = self.items[self.pos].next
        return self.items[self.pos]

 
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        if self.cnt == Dlist.MAX: # ??????????????????
            return -1

        t = DListItem(self.uniqid, x)

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s.prev = self.uniqid
            t.next = self.si
        self.items.append(t)
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
        return t
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == DListItem.NoValue:
                    break
                if self.items[i].value == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        n = self.items[i].next
                        p = self.items[i].prev
                        self.items[n].prev = p
                        self.items[p].next = n
                        self.items[i].value = DListItem.NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i].next

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            n = self.items[self.si].next
            if n != DListItem.NoValue:
                self.items[n].prev = DListItem.NoValue
            self.items[self.si] = DListItem.NoValue
            self.si = n
            self.cnt -= 1
            if self.cnt < 1:
                self.ei = DListItem.NoValue

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            p = self.items[self.ei].prev
            if p != DListItem.NoValue:
                self.items[p].next = DListItem.NoValue
            self.items[self.ei] = DListItem.NoValue
            self.ei = p
            self.cnt -= 1
            if self.cnt < 1:
                self.si = DListItem.NoValue

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != DListItem.NoValue:
                a.append(self.items[i].value)
                i = self.items[i].next
        return a

    def debugList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != DListItem.NoValue:
                a.append("{} => {}".format(i,self.items[i].value))
                i = self.items[i].next
        return a

# ?????????
num = int(input().strip())
dl = Dlist()

for i in range(num):
    cmd = list(input().strip().split())
    if cmd[0] == "insert":
        dl.insert(cmd[1])
    elif cmd[0] == "delete":
        dl.delete(cmd[1])
    elif cmd[0] == "deleteFirst":
        dl.deleteFirst()
    elif cmd[0] == "deleteLast":
        dl.deleteLast()

#    print()
#    print(cmd)
#    print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#    print(dl.debugList())

print(" ".join(map(str, dl.getList())))

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""

class Dlist:
    """ ??????????????????????????? """
    MAX = 1000000
    NoValue = -1
    Prev = 0
    Next = 1
    Value = 2

    def __init__(self):
        """ ????????????????????? """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        self.items = []

    def __iter__(self):
        """ ????????¬?????? """
        self.pos = self.si
        return self

    def __next__(self):
        """ ?¬???????????????? """
        if self.cnt == 0: # ???????????????
            raise StopIteration()
        elif self.items[self.pos][Dlist.Next] == Dlist.NoValue: # ?¬??????????
            raise StopIteration()
        else:
            self.pos = self.items[self.pos][Dlist.Next]
        return self.items[self.pos]

 
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        if self.cnt == Dlist.MAX: # ??????????????????
            return -1

        t = [Dlist.NoValue, Dlist.NoValue, x]

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s[Dlist.Prev] = self.uniqid
            t[Dlist.Next] = self.si
        self.items.append(t)
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
        return t
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == Dlist.NoValue:
                    break
                if self.items[i][Dlist.Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        n = self.items[i][Dlist.Next]
                        p = self.items[i][Dlist.Prev]
                        self.items[n][Dlist.Prev] = p
                        self.items[p][Dlist.Next] = n
                        self.items[i][Dlist.Value] = Dlist.NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Dlist.Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            n = self.items[self.si][Dlist.Next]
            if n != Dlist.NoValue:
                self.items[n][Dlist.Prev] = Dlist.NoValue
            self.items[self.si][Dlist.Value] = Dlist.NoValue
            self.si = n
            self.cnt -= 1
            if self.cnt < 1:
                self.ei = Dlist.NoValue

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            p = self.items[self.ei][Dlist.Prev]
            if p != Dlist.NoValue:
                self.items[p][Dlist.Next] = Dlist.NoValue
            self.items[self.ei][Dlist.Value] = Dlist.NoValue
            self.ei = p
            self.cnt -= 1
            if self.cnt < 1:
                self.si = Dlist.NoValue

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != Dlist.NoValue:
                a.append(self.items[i][Dlist.Value])
                i = self.items[i][Dlist.Next]
        return a

    def debugList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != Dlist.NoValue:
                a.append("{} => {}".format(i,self.items[i][Dlist.Value]))
                i = self.items[i][Dlist.Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    dl = Dlist()

    for i in range(num):
        cmd = list(input().strip().split())
        if cmd[0] == "insert":
            dl.insert(cmd[1])
        elif cmd[0] == "delete":
            dl.delete(cmd[1])
        elif cmd[0] == "deleteFirst":
            dl.deleteFirst()
        elif cmd[0] == "deleteLast":
            dl.deleteLast()

#       print()
#       print(cmd)
#       print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#       print(dl.debugList())

    print(" ".join(map(str, dl.getList())))

if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

class Dlist:
    """ ??????????????????????????? """
    MAX = 1000000
    NoValue = -1
    Prev = 0
    Next = 1
    Value = 2

    def __init__(self):
        """ ????????????????????? """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        self.items = []

    def __iter__(self):
        """ ????????¬?????? """
        self.pos = self.si
        return self

    def __next__(self):
        """ ?¬???????????????? """
        if self.cnt == 0: # ???????????????
            raise StopIteration()
        elif self.items[self.pos][Dlist.Next] == Dlist.NoValue: # ?¬??????????
            raise StopIteration()
        else:
            self.pos = self.items[self.pos][Dlist.Next]
        return self.items[self.pos]

 
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        if self.cnt == Dlist.MAX: # ??????????????????
            return -1

        t = [Dlist.NoValue, Dlist.NoValue, x]

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s[Dlist.Prev] = self.uniqid
            t[Dlist.Next] = self.si
        self.items.append(t)
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
        return t
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == Dlist.NoValue:
                    break
                if self.items[i][Dlist.Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        n = self.items[i][Dlist.Next]
                        p = self.items[i][Dlist.Prev]
                        self.items[n][Dlist.Prev] = p
                        self.items[p][Dlist.Next] = n
                        self.items[i][Dlist.Value] = Dlist.NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Dlist.Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt > 0:
            n = self.items[self.si][Dlist.Next]
            if n != Dlist.NoValue:
                self.items[n][Dlist.Prev] = Dlist.NoValue
            self.items[self.si][Dlist.Value] = Dlist.NoValue
            self.si = n
            self.cnt -= 1
            if self.cnt < 1:
                self.ei = Dlist.NoValue

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt > 0:
            p = self.items[self.ei][Dlist.Prev]
            if p != Dlist.NoValue:
                self.items[p][Dlist.Next] = Dlist.NoValue
            self.items[self.ei][Dlist.Value] = Dlist.NoValue
            self.ei = p
            self.cnt -= 1
            if self.cnt < 1:
                self.si = Dlist.NoValue

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != Dlist.NoValue:
                a.append(self.items[i][Dlist.Value])
                i = self.items[i][Dlist.Next]
        return a

    def debugList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != Dlist.NoValue:
                a.append("{} => {}".format(i,self.items[i][Dlist.Value]))
                i = self.items[i][Dlist.Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    dl = Dlist()

    istr = sys.stdin.read()
    cmds = list(istr.split("\n"))

    for i in range(num):
        cmd = list(cmds[i].split())
        if cmd[0] == "insert":
            dl.insert(cmd[1])
        elif cmd[0] == "delete":
            dl.delete(cmd[1])
        elif cmd[0] == "deleteFirst":
            dl.deleteFirst()
        elif cmd[0] == "deleteLast":
            dl.deleteLast()

#       print()
#       print(cmd)
#       print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#       print(dl.debugList())

    print(" ".join(map(str, dl.getList())))


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

class Dlist:
    """ ??????????????????????????? """
    MAX = 1000000
    NoValue = -1
    Prev = 0
    Next = 1
    Value = 2

    def __init__(self):
        """ ????????????????????? """
        self.clear()

    def __iter__(self):
        """ ????????¬?????? """
        self.pos = self.si
        return self

    def __next__(self):
        """ ?¬???????????????? """
        if self.cnt == 0: # ???????????????
            raise StopIteration()
        elif self.items[self.pos][Dlist.Next] == Dlist.NoValue: # ?¬??????????
            raise StopIteration()
        else:
            self.pos = self.items[self.pos][Dlist.Next]
        return self.items[self.pos]


    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        self.items = []
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        if self.cnt == Dlist.MAX: # ??????????????????
            return -1

        t = [Dlist.NoValue, Dlist.NoValue, x]

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s[Dlist.Prev] = self.uniqid
            t[Dlist.Next] = self.si
        self.items.append(t)
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
        return t
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == Dlist.NoValue:
                    break
                if self.items[i][Dlist.Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        n = self.items[i][Dlist.Next]
                        p = self.items[i][Dlist.Prev]
                        self.items[n][Dlist.Prev] = p
                        self.items[p][Dlist.Next] = n
                        self.items[i][Dlist.Value] = Dlist.NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Dlist.Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Dlist.Next]
            if n != Dlist.NoValue:
                self.items[n][Dlist.Prev] = Dlist.NoValue
            self.items[self.si][Dlist.Value] = Dlist.NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Dlist.Prev]
            if p != Dlist.NoValue:
                self.items[p][Dlist.Next] = Dlist.NoValue
            self.items[self.ei][Dlist.Value] = Dlist.NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != Dlist.NoValue:
                a.append(self.items[i][Dlist.Value])
                i = self.items[i][Dlist.Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    dl = Dlist()

    istr = sys.stdin.read()
    cmds = list(istr.split("\n"))

    for i in range(num):
        cmd = list(cmds[i].split())
        if cmd[0] == "insert":
            dl.insert(cmd[1])
        elif cmd[0] == "delete":
            dl.delete(cmd[1])
        elif cmd[0] == "deleteFirst":
            dl.deleteFirst()
        elif cmd[0] == "deleteLast":
            dl.deleteLast()

#       print()
#       print(cmd)
#       print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#       print(dl.debugList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

class Dlist:
    """ ??????????????????????????? """
    MAX = 2000000
    NoValue = -1
    Prev = 0
    Next = 1
    Value = 2

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * Dlist.MAX
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        t = [Dlist.NoValue, Dlist.NoValue, x]

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s[Dlist.Prev] = self.uniqid
            t[Dlist.Next] = self.si
        self.items[self.uniqid] = t
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == Dlist.NoValue:
                    break
                if self.items[i][Dlist.Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        n = self.items[i][Dlist.Next]
                        p = self.items[i][Dlist.Prev]
                        self.items[n][Dlist.Prev] = p
                        self.items[p][Dlist.Next] = n
                        self.items[i][Dlist.Value] = Dlist.NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Dlist.Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Dlist.Next]
            if n != Dlist.NoValue:
                self.items[n][Dlist.Prev] = Dlist.NoValue
            self.items[self.si][Dlist.Value] = Dlist.NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Dlist.Prev]
            if p != Dlist.NoValue:
                self.items[p][Dlist.Next] = Dlist.NoValue
            self.items[self.ei][Dlist.Value] = Dlist.NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != Dlist.NoValue:
                a.append(self.items[i][Dlist.Value])
                i = self.items[i][Dlist.Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.split("\n"))
    dl = Dlist()

    for i in range(num):
        cmd = list(cmds[i].split())
        if cmd[0] == "insert":
            dl.insert(cmd[1])
        elif cmd[0] == "delete":
            dl.delete(cmd[1])
        elif cmd[0] == "deleteFirst":
            dl.deleteFirst()
        elif cmd[0] == "deleteLast":
            dl.deleteLast()

#       print()
#       print(cmd)
#       print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#       print(dl.debugList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

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

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

class Dlist:
    """ ??????????????????????????? """
    MAX = 2000000
    NoValue = -1
    Prev = 0
    Next = 1
    Value = 2

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * Dlist.MAX
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = -1
        self.ei = -1
        self.pos = -1
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        t = [Dlist.NoValue, Dlist.NoValue, x]

        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            s = self.items[self.si]
            s[Dlist.Prev] = self.uniqid
            t[Dlist.Next] = self.si
        self.items[self.uniqid] = t
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == Dlist.NoValue:
                    break
                if self.items[i][Dlist.Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        n = self.items[i][Dlist.Next]
                        p = self.items[i][Dlist.Prev]
                        self.items[n][Dlist.Prev] = p
                        self.items[p][Dlist.Next] = n
#                        self.items[i][Dlist.Value] = Dlist.NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Dlist.Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Dlist.Next]
            if n != Dlist.NoValue:
                self.items[n][Dlist.Prev] = Dlist.NoValue
#            self.items[self.si][Dlist.Value] = Dlist.NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Dlist.Prev]
            if p != Dlist.NoValue:
                self.items[p][Dlist.Next] = Dlist.NoValue
#            self.items[self.ei][Dlist.Value] = Dlist.NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != Dlist.NoValue:
                a.append(self.items[i][Dlist.Value])
                i = self.items[i][Dlist.Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.split("\n"))
    dl = Dlist()

    for i in range(num):
        cmd = list(cmds[i].split())
        if cmd[0] == "insert":
            dl.insert(cmd[1])
        elif cmd[0] == "delete":
            dl.delete(cmd[1])
        elif cmd[0] == "deleteFirst":
            dl.deleteFirst()
        elif cmd[0] == "deleteLast":
            dl.deleteLast()

#       print()
#       print(cmd)
#       print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#       print(dl.debugList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()

Fixed submission:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
???????????£????????????
??\?????????????????????????????????????????£???????????????????£??????????????????????

insert x: ??£?????????????????????????????? x ?????????????´?????¶?????¶???????
delete x: ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????
deleteFirst?????????????????????????´???????????????????
deleteLast: ????????????????°????????´???????????????????
"""
import sys

NoValue = -1
Prev = 0
Next = 1
Value = 2

class Dlist:
    """ ??????????????????????????? """

    def __init__(self):
        """ ????????????????????? """
        self.items = [0] * 2000000
        self.clear()

    def clear(self):
        """ ????´?????????????????????¢ """
        self.si = NoValue
        self.ei = NoValue
        self.pos = NoValue
        self.uniqid = 0
        self.cnt = 0
        
    def insert(self,x):
        """ ??£?????????????????????????????? x ?????????????´?????¶?????¶???? """

        n = NoValue
        if self.cnt == 0: # ?????????????´?
            self.ei = self.uniqid
        else:
            self.items[self.si][Prev] = self.uniqid
            n = self.si
        self.items[self.uniqid] = [NoValue, n, x]
        self.si = self.uniqid
        self.uniqid += 1
        self.cnt += 1
    
    def delete(self,x):
        """ ?????? x ??????????????????????´??????£????????????????????????????????????????????????????´?????????¨???????????´????????????????????????"""

        if self.cnt > 0:
            hit = False
            i = self.si
            while hit == False:
                if i == -1:
                    break
                if self.items[i][Value] == x:
                    hit = True
                    if i == self.si:
                        self.deleteFirst() # ?????????????´??????????
                    elif i == self.ei:
                        self.deleteLast() # ????°????????´??????????
                    else:
                        p = self.items[i][Prev]
                        n = self.items[i][Next]
                        self.items[n][Prev] = p
                        self.items[p][Next] = n
#                        self.items[i][Value] = NoValue
                        self.cnt -= 1
                else:
                    i = self.items[i][Next]

    def deleteFirst(self):
        """ ?????????????????????????´???????????????? """
        if self.cnt < 2:
            self.clear()
        else:
            n = self.items[self.si][Next]
            if n != NoValue:
                self.items[n][Prev] = NoValue
#            self.items[self.si][Value] = NoValue
            self.si = n
            self.cnt -= 1

    def deleteLast(self):
        """ ????????????????°????????´???????????????????"""
        if self.cnt < 2:
            self.clear()
        else:
            p = self.items[self.ei][Prev]
            if p != -1:
                self.items[p][Next] = NoValue
#            self.items[self.ei][Value] = NoValue
            self.ei = p
            self.cnt -= 1

    def getList(self):
        a = []
        if self.cnt > 0:
            i = self.si
            while i != -1:
                a.append(self.items[i][Value])
                i = self.items[i][Next]
        return a

def main():
    """ ????????? """
    num = int(input().strip())
    istr = sys.stdin.read()
    cmds = list(istr.splitlines())
    dl = Dlist()

    for i in cmds:
        if i[6] == "F":
            dl.deleteFirst()
        elif i[6] == "L":
            dl.deleteLast()
        elif i[0] == "i":
            dl.insert(i[7:])
        elif i[0] == "d":
            dl.delete(i[7:])

#        print()
#        print(i)
#        print("si={} ei={} cnt={}".format(dl.si, dl.ei, dl.cnt))
#        print(dl.getList())

    print(" ".join(dl.getList()))


if __name__ == '__main__':
    main()