Олимпиадный тренинг

Задача 38600. simple stack


Задача

Темы: Стек
Implement a "stack" data structure. Write a program that describes the stack and simulates how the stack works by implementing all the methods listed here.  The program reads a sequence of commands and, depending on the command, performs one or another operation. After executing each command, the program should print one line. Possible commands for the program:

push n
Push the number n onto the stack (the value of n is given after the command). The program should print ok.
pop
Remove the last element from the stack. The program should output its value.
back
The program should output the value of the last element without removing it from the stack.
size
The program should print the number of elements on the stack.
clear
The program should clear the stack and print ok.
exit
The program should print bye and exit.
Input
Stack management commands are entered in the format described earlier, 1 per line.

It is guaranteed that the set of input commands satisfies the following requirements: the maximum number of elements on the stack at any time does not exceed 100, all pop and back commands are correct, that is, when they are executed, the stack contains at least one element.

Imprint
It is required to display the protocol of work with the stack, 1 message per line
Examples
# Input Output
1 push 3
push 14

clear
push 1
back
push 2
back
pop

pop

exit
ok
ok
2
ok
ok
1
ok
2
2
1
1
0
bye

Запрещенные операторы:stack;queue;deque