基于List
m=int(input())
stk=[]
while m:
m-=1
tmp=input().split()
ty=tmp[0]
if ty=='push': stk.append(int(tmp[1]))
if ty=='pop': stk.pop()
if ty=='empty':
ans='YES' if len(stk)==0 else 'NO'
print(ans)
if ty=='query':
print(stk[-1])
YES!
YES!