a=int(input())
stack=[]
length=0
for i in range(a):
st=list(map(str, input().split()))
if st[0]=="push":
stack.append(int(st[1]))
length+=1
elif st[0]=="pop":
if len(stack)<1:
print(-1)
else:
pop=stack[-1]
print(pop)
del stack[-1]
length-=1
elif st[0]=="size":
print(length)
elif st[0]=="empty":
if length==0:
print("1")
else:
print("0")
elif st[0]=="top":
if length>=1:
print(stack[-1])
else:
print("-1")
https://www.acmicpc.net/problem/10828
ㄹㅇ모르겟다
1. sys readline, write 써라 2. del 쓰지 마라
sys붙이고해결됨 ㄳ