#C8899. Format Integer with Commas

    ID: 52931 Type: Default 1000ms 256MiB

Format Integer with Commas

Format Integer with Commas

Given a non-negative integer represented as a string, your task is to format it by inserting commas to separate every three digits from the right. In other words, if the number is given as a string s, you need to output a string where commas are inserted between groups of three digits when counting from right to left. For example, the number 123456789 should be formatted as 123,456,789.

Mathematically, for a number with n digits, a comma is inserted after every group of three digits, i.e., the formatted string follows the pattern:

\( s = d_1d_2\ldots d_n \rightarrow \text{formatted as } d_1\ldots d_{n-3k}, d_{n-3k+1}\ldots d_{n-3(k-1)}, \ldots, d_{n-2}d_{n-1}d_n \) where \( k = \lfloor (n-1)/3 \rfloor \).

Please note that if the number of digits is not a multiple of three, the first group may contain fewer than three digits, and numbers with fewer than four digits should not be altered.

inputFormat

The input is provided via standard input (stdin) and consists of a single non-negative integer in string format on each line. There can be multiple test cases. Process each line separately.

outputFormat

For each test case, output the corresponding formatted string (with commas inserted) on a new line via standard output (stdout).

## sample
123
123

</p>