Buggy python submission (verdict: Runtime Error):
def push(lists, d, x):
    if d == 0:
        lists.insert(0, x)
    else:
        lists.insert(len(lists), x)

    return lists

def randomAccess(lists, p):
    print(lists[p])

def pop(lists, d):
    if d == 0:
        lists.pop(0)
    else:
        lists.pop(len(lists) - 1)
    return lists

if __name__ == '__main__':
    l = list()
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, j[2])


Fixed submission:
from collections import deque

def push(duque, d, x):
    if d == 1:
        duque.append(x)
    else:
        duque.appendleft(x)
    return duque

def randomAccess(duque, p):
    print(duque[p])

def pop(duque, d):
    if d == 1:
        duque.pop()
    else:
        duque.popleft()
    return duque

if __name__ == '__main__':
    l = deque([])
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))

Buggy python submission (verdict: Time Limit Exceeded):
def push(lists, d, x):
    if d == 0:
        lists.insert(0, x)
    else:
        lists.insert(len(lists), x)

    return lists

def randomAccess(lists, p):
    print(lists[p])

def pop(lists, d):
    if d == 0:
        lists.pop(0)
    else:
        lists.pop(len(lists) - 1)
    return lists

if __name__ == '__main__':
    l = list()
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))


Fixed submission:
from collections import deque

def push(duque, d, x):
    if d == 1:
        duque.append(x)
    else:
        duque.appendleft(x)
    return duque

def randomAccess(duque, p):
    print(duque[p])

def pop(duque, d):
    if d == 1:
        duque.pop()
    else:
        duque.popleft()
    return duque

if __name__ == '__main__':
    l = deque([])
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))

Buggy python submission (verdict: Time Limit Exceeded):
def push(lists, d, x):
    if d == 0:
        lists.insert(0, x)
    else:
        lists.insert(len(lists), x)

    return lists

def randomAccess(lists, p):
    print(lists[p])

def pop(lists, d):
    if d == 0:
        lists.pop(0)
    else:
        lists.pop(len(lists) - 1)
    return lists

if __name__ == '__main__':
    l = list()
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))


Fixed submission:
from collections import deque

def push(duque, d, x):
    if d == 1:
        duque.append(x)
    else:
        duque.appendleft(x)
    return duque

def randomAccess(duque, p):
    print(duque[p])

def pop(duque, d):
    if d == 1:
        duque.pop()
    else:
        duque.popleft()
    return duque

if __name__ == '__main__':
    l = deque([])
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))

Buggy python submission (verdict: Runtime Error):
from collections import deque

def push(duque, d, x):
    if d == 0:
        duque.append(x)
    else:
        duque.insert(len(duque), x)
    return duque.appendleft(x)

def randomAccess(duque, p):
    print(duque.index(p))

def pop(duque, d):
    if d == 0:
        duque.pop()
    else:
        duque.popleft()
    return duque

if __name__ == '__main__':
    l = deque([])
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))


Fixed submission:
from collections import deque

def push(duque, d, x):
    if d == 1:
        duque.append(x)
    else:
        duque.appendleft(x)
    return duque

def randomAccess(duque, p):
    print(duque[p])

def pop(duque, d):
    if d == 1:
        duque.pop()
    else:
        duque.popleft()
    return duque

if __name__ == '__main__':
    l = deque([])
    n = int(input())
    for i in range(n):
        j= input().split()

        if int(j[0]) == 0:
            push(l, int(j[1]), int(j[2]))
        elif int(j[0]) == 1:
            randomAccess(l, int(j[1]))
        else:
            pop(l, int(j[1]))