Unlimited stack size
Implement a data structure called a "stack". Write a program that provides a description of the stack and simulates its operations by implementing all the methods specified below. The program will read a sequence of commands and execute the corresponding operation based on the command. After executing each command, the program should output a single line. The possible commands for the program are:
push n
Add the number n to the stack (where n is specified after the command). The program should output ok.
pop
Remove the last element from the stack. The program should output the value of this element.
back
Output the value of the last element without removing it from the stack.
size
Output the number of elements currently in the stack.
clear
Clear all elements from the stack and output ok.
exit
Output bye and terminate the program.
The stack's size should only be limited by the available RAM. Before performing the back and pop operations, the program should ensure there is at least one element in the stack. If the input includes a back or pop operation and the stack is empty, the program should output the string error instead of a numerical value.
Input
As described in the conditions. Refer to the example input data for more details.
Output
As described in the conditions. Refer to the example output data for more details.