#C68. Object Transformation Challenge

    ID: 50599 Type: Default 1000ms 256MiB

Object Transformation Challenge

Object Transformation Challenge

You are given an object with a single property value. Your task is to apply a series of transformation operations to this object. The available operations are:

  • increment: Increase value by 1.
  • double: Multiply value by 2.
  • decrement: Decrease value by 1.

The operations are provided in order, and you must apply them sequentially. For instance, starting with an object { value: 2 } and applying the operations increment, double, and decrement will produce the object { value: 5 } because:

\(2 + 1 = 3\), then \(3 \times 2 = 6\), and finally \(6 - 1 = 5\).

Read the description carefully and solve the problem using the appropriate input and output methods as described below.

inputFormat

The input is given via stdin and consists of multiple lines:

  1. The first line contains an integer (A), representing the initial value of the object.
  2. The second line contains an integer (N), the number of operations to perform.
  3. The next (N) lines each contain a string that is either "increment", "double", or "decrement", representing the operation to apply.

outputFormat

Output a single integer to stdout representing the final value of the object after performing all the operations.## sample

2
3
increment
double
decrement
5

</p>