<jupyter_start><jupyter_text>A deque is a double-ended queue. It can be used to add or remove elements from both ends.Deques support thread safe, memory efficient appends and pops from either side of the deque with approximately the same  performance in either direction.<jupyter_code>from collections import deque
N = 6                #int(input())  # no of operations
t1 = 'append 1'.split()
t2 = 'append 2'.split()
t3 = 'append 3'.split()
t4 = 'appendleft 4'.split()
t5 = 'pop'.split()
t6 = 'popleft'.split()
d = deque()
getattr(d,t1[0])(*t1[1])
getattr(d,t2[0])(*t2[1])
getattr(d,t3[0])(*t3[1])
getattr(d,t4[0])(*t4[1])
getattr(d,t5[0])(*t5[1])
getattr(d,t6[0])(*t6[1])
d
from collections import deque
d = deque()
for _ in range(int(input())):
    cmd, *args = input().split()
    getattr(d, cmd)(*args)
[print(x, end=' ') for x in d]<jupyter_output>6
append 1
append 2
append 3
appendleft 4
pop
popleft
1 2
{'fraction_non_alphanumeric': 0.16575192096597147, 'fraction_numerical': 0.04610318331503842, 'mean_word_length': 4.883870967741935, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '444928', 'license': 'Apache-2.0', 'n_tokens_mistral': 369, 'n_tokens_neox': 362, 'n_words': 106, 'path': 'notebooks/Collections.deque().ipynb', 'repo_name': 'neso613/python_coding', 'size': '911'}