Remember the problem “lvm” from NOI 2008? (Link here.) With the recent advancements in computing technology, virtual machines now generally run at a much faster speed. Although the Lombok Virtual Machine was state-of-the-art technology then, its slow computing speed, as well as small limits for stack and integer sizes, has made it virtually unusable by the modern user.
Unfortunately, Squeaky the Rat had written many programs in the Lombok programming language back in its heyday, and porting those programs to another language is a very tedious task. Squeaky has tasked you to upgrade the Lombok Virtual Machine, so that his programs can be run faster and with larger constraints.
Help him make a faster version of the Lombok Virtual Machine which will work with the following constraints instead:
- The stack does not grow bigger than 50000 elements
- Every element in the stack will always have a value between -10^9 and 10^9 inclusive
- The input program contains no more than 50000 instructions
Subtask 1 (1%): At most 40000000 instructions are executed before the program terminates
Subtask 2 (9%): At most 200000000 instructions are executed before the program terminates
Subtask 3 (90%): At most 2000000000 instructions are executed before the program terminates
Subtask 4 (0%): Sample testcases
Sample Testcase 1