Изменения
Дек
,→Циклический дек на динамическом массиве
head = 0
tail = n - 1
n *= n * 2
d[tail] = x
tail = (tail + 1) % n
'''if''' (size() < n / 4)
'''T''' newDeque[n / 2]
'''int''' size deque_size = size()
'''for''' i = 0 '''to''' size - 1
newDeque[i] = d[head]
d = newDeque
head = 0
tail = sizedeque_size n /= n / 2
tail = (tail - 1 + n) % n
'''return''' d[tail]
head = 0
tail = n - 1
n *= n * 2
head = (head - 1 + n) % n
d[head] = x
'''if''' (size() < n / 4)
'''T''' newDeque[n / 2]
'''int''' size deque_size = size()
'''for''' i = 0 '''to''' size - 1
newDeque[i] = d[head]
d = newDeque
head = 0
tail = sizedeque_size n /= n / 2
'''T''' ret = d[head]
head = (head + 1) % n