P8032 [COCI 2015/2016 #7] Nizovi
Description
Arrays in a programming language are defined as follows:
- The beginning and end of an array are marked with curly braces ($\texttt \{$ and $\texttt \}$), respectively.
- Inside each pair of braces, there are several (**possibly $0$**) comma-separated **elements** (there is no comma after the last element of each array).
- Each element can be either a **word** (a string consisting of lowercase letters) or another array.
- Some valid arrays are: $\texttt {\{\}}, \texttt{\{a,b,c\}}, \texttt{\{abc,znj,\{novi,niz\},pozz\}}$.
You need to apply the following formatting style to make the program look nicer:
- Start a new line whenever you encounter a word or a curly brace.
- A comma should be placed directly after an array element.
- Every time you encounter a $\texttt{\{}$, increase the indentation by $2$ spaces.
- Every time you encounter a $\texttt{\}}$, decrease the indentation by $2$ spaces.
Given an array, output it in the above formatting style.
Input Format
A string $S$ representing the given array.
Output Format
The array formatted in the required style.
Explanation/Hint
**Constraints**
- For $50\%$ of the testdata, elements contain only words.
- For $100\%$ of the testdata, $1 \le |S| \le 1500$.
**Hints and Notes**
The checker is from the [Testlib library](https://github.com/MikeMirzayanov/testlib/blob/master/checkers/fcmp.cpp), see the attachment.
**Translated from [COCI 2015-2016](https://hsin.hr/coci/archive/2015_2016/) [#7](https://hsin.hr/coci/archive/2015_2016/contest7_tasks.pdf) _Task 1 Nizovi_.**
**The score for this problem follows the original COCI settings, with a full score of $50$.**
Translated by ChatGPT 5