Kuo-chan gives Yang-chan an empty sequence A as his birthday gift.
Yang-chan is allowed to perform the following operation:
For example, initially A = []
PUSH 4 ► A = [4]
PUSH 3 ► A = [4, 3]
PUSH 5 ► A = [4, 3, 5]
PUSH 11 ► A = [4, 3, 5, 11]
POP ► A = [4, 5, 11]
POP ► A = [4, 11]
PROGRAMMING TANOSHI 3 ► A = [2, 4]
IP2 SUGOI ► A = [1, 2]
Kuo-chan is curious about what A is after Yang-chan performs some operations to it.
Help him find it out!
The input contains Q lines.
Initially, A is empty.
Each of the Q lines describes the operations Yang-chan performs. Each line is one of four types:
Different testcases have different constraints.
Note: You can include <math.h> to use sqrt(x). sqrt(x) returns the square root of x. Just be careful with roundoff error.
You can also use ceil(x), floor(x) included in <math.h>.
Hint: To speed up the code, you can think about how many operations will an element be performed at most.
Update: 1. Make use of the variable all_operation to store {PROGRAMMING TANOSHI, IP2 SUGOI} operations.
2. You can think that if a number becomes 1 you won't need to do any operation on it anymore.
You should print one line containing the elements of A after the operations. For 1 ≤ i ≤ |A|, the i-th number should be A[ i ].