~/algor $ cat problems/stack-buyruqlari
Stack commands
Easy
1000 ms
128 MB
20%
An empty stack and $n$ commands are given. In a stack the last element added comes out first: pop and top work with the most recently added element. Execute the commands in order.
push x— add the integer $x$ (nothing is printed);pop— remove the element and print it;top— print the element without removing it;size— print the number of elements.
If the stack is empty, error is printed instead of pop and top (the stack does not change).
Input
The first line contains a positive integer $n$. Each of the next $n$ lines contains one command.
Output
For each of the pop, top and size 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}$
Examples
Input #1
6 push 5 push 8 top pop top size
Output #1
8 8 5 1
Input #2
3 pop push 2 size
Output #2
error 1