l = 1024
memory = __import__('array').array('i', (-1 for _ in range(l)))
bp, ep = 0, 1
def pushframe():
global bp, ep
if ep + 2 > l:
raise Exception('Memory overflow')
...
...
def popframe():
global bp, ep
if ep <= 0:
raise Exception('Memory empty')
...
...
def push(item):
global ep
if ep + 1 > l:
raise Exception('Memory overflow')
...
...
def pop():
global ep
if ep - 1 <= bp:
raise Exception('Stack empty')
...
...
push(int(input()))
push(int(input()))
pushframe()
push(int(input()))
push(int(input()))
push(int(input()))
push(int(input()))
pushframe()
push(int(input()))
push(int(input()))
print(memory[ep - 1])
print(memory[ep - 6]) # 指针越界
print(memory[ep - 2])
popframe()
print(memory[ep - 1])
pop()
print(memory[ep - 1])
print(memory[ep - 3])
pop()
print(memory[ep - 1])
popframe()