P8791 [Lанqiao Cup 2022 National AC] Memory Space.
Description
Xiao Lan recently likes to calculate how much memory space the variables defined in his code take up.
To simplify the problem, there are only three types of variables:
`int`: an integer variable. One `int` variable takes $4$ Byte of memory space.
`long`: a long integer variable. One `long` variable takes $8$ Byte of memory space.
`String`: a string variable. The space used depends on the string length. Let the string length be $L$, then the string takes $L$ Byte of memory space. If the string length is $0$, then it takes $0$ Byte of memory space.
There are only two forms of variable definition statements. The first form is:
```
type var1=value1,var2=value2...;
```
This defines several variables of type `type`: `var1`, `var2`, ..., and initializes them with `value1`, `value2`, ....
Multiple variables are separated by `,`, and the statement ends with `;`. `type` can be `int`, `long`, or `String`. For example, `int a=1,b=5,c=6;` takes $12$ Byte; `long a=1,b=5;` takes $16$ Byte; `String s1="",s2="hello",s3="world";` takes $10$ Byte.
The second form is:
```
type[] arr1=new type[size1],arr2=new type[size2]…;
```
This defines several one-dimensional array variables of type `type`: `arr1`, `arr2`, ..., and the array sizes are `size1`, `size2`, .... Multiple variables are separated by `,`, and the statement ends with `;`. Here `type` can only be `int` or `long`. For example, `int[] a1=new int[10]` takes $40$ Byte; `long[] a1=new long[10],a2=new long[10];` takes $160$ Byte.
It is known that Xiao Lan has $T$ variable definition statements. Please help him count the total memory space used.
The result should be formatted as $\texttt{aGBbMBcKBdB}$, where $a$, $b$, $c$, $d$ are the computed values, and $\texttt{GB}$, $\texttt{MB}$, $\texttt{KB}$, $\texttt{B}$ are the units. Prefer using larger units: $1\texttt{GB}=1024\texttt{MB}$, $1\texttt{MB}=1024\texttt{KB}$, $1\texttt{KB}=1024\texttt{B}$, where `B` means Byte. If some of $a$, $b$, $c$, $d$ are $0$, then you do not need to output those numbers and their units.
The problem guarantees that each line contains only one variable definition statement, and every statement satisfies the formats described above. All variable names are valid and do not repeat. The testdata is very regular and similar to the examples above: except for one space after the type, and one space after `new` when defining arrays, there will be no extra spaces.
Input Format
The first line contains an integer $T$, meaning there are $T$ variable definition statements.
The next $T$ lines each contain one variable definition statement.
Output Format
Output one line containing a string that represents the total size of memory space used by all statements.
Explanation/Hint
**Sample Explanation**
In Sample 1, the space used is $131072 \times 8 = 1048576$, which converts to exactly $1\texttt{MB}$. The numbers before the other three units $\texttt{GB}$, $\texttt{KB}$, $\texttt{B}$ are all $0$, so they are not printed.
In Sample 2, the space used is $4 \times 2 + 8 \times 2 + 10 + 8 \times 100000 \times 2$ B, which converts to $1\texttt{MB}538\texttt{KB}546\texttt{B}$.
**Constraints and Conventions**
For all test cases, $1 \leq T \leq 10$. The length of each variable definition statement does not exceed $1000$. The length of every variable name does not exceed $10$, and all names consist of lowercase letters and digits. For integer variables, the initialized values are decimal integers within their representable ranges, and the initialized values will not be variables. For `String` variables, the initialized content length does not exceed $50$, and the content contains only lowercase letters and digits, and the initialized values will not be variables. For array variables, the array length is an integer in the range $[0, 2^{30}]$, and the array length will not be a variable. The total memory space used by all variables defined in the $T$ statements is greater than $0$ B and less than $1024$ GB.
Lanqiao Cup 2022 National Final, Group A, Problem C (Group C, Problem D).
Translated by ChatGPT 5