~/algor $ cat problems/stack-minimumli-stack
Min stack
Easy
1000 ms
128 MB
22%
An empty stack and $n$ commands are given. Execute the commands in order.
push x— add the integer $x$ to the stack (nothing is printed);pop— remove the most recently added element and print it;min— print the smallest element of the stack (without removing it).
If the stack is empty, error is printed instead of pop and min.
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains one command.
Output
For each of the pop and min commands, the answer on a separate line: an integer or error.
Note
$1 \le n \le 10^{5}$
$-10^{9} \le x \le 10^{9}$
at least one command prints an answer
Examples
Input #1
7 push 5 push 2 min push 8 pop pop min
Output #1
2 8 2 5
Input #2
2 min pop
Output #2
error error