#B3614. Implement a Custom Stack

    ID: 11274 Type: Default 1000ms 256MiB

Implement a Custom Stack

Implement a Custom Stack

You are required to implement a stack that supports the following operations:

  • push(x): Push the number \(x\) onto the stack.
  • pop(): Remove the top element of the stack. If the stack is empty, do not remove any element and output "Empty".
  • query(): Output the top element of the stack. If the stack is empty, output "Anguei!".
  • size(): Output the current number of elements in the stack.

The operations that require output (i.e. pop() when the stack is empty, query(), and size()) should each produce an output on a new line.

inputFormat

The input starts with an integer \(N\) (\(1 \leq N \leq 10^5\)) indicating the number of operations. The following \(N\) lines each contain one of the following commands:

  • push x: push the integer \(x\) onto the stack.
  • pop: pop the top element from the stack. If the stack is empty, output "Empty".
  • query: output the top element. If the stack is empty, output "Anguei!".
  • size: output the current number of elements in the stack.

outputFormat

For every operation that produces output, print the result on a new line. For the pop operation, only output a message when the stack is empty. For the query and size operations, always print the result.

sample

5
push 3
push 5
query
pop
query
5

3

</p>