Ignore all my comments (Small)

Remove every nested /* */ comment block from the document with a single left to right scan and print the rest unchanged.

Medium4StackStringSimulationNo attempts yetTime limit5sMemory limit512 MB

Problem

Igor writes his comments in C style /* ... */ blocks, and he wants that one comment format everywhere, in Python, in Haskell, in HTML or XML documents. What he needs for that is a comment pre-processor: a program that deletes every comment block, meaning a /*, then the comment text, then a */. The processed text then goes to whatever compiler or renderer it belongs to.

The pre-processor is not a plain search and replace.

Comment blocks nest the way brackets nest in most programming languages, so a comment can hold another comment. The block below has one outer comment with two comments inside it.

printf("Hello /* a comment /* a comment inside comment */ 
        inside /* another comment inside comment */ 
        string */ world");

After the pre-processing step it becomes:

printf("Hello  world");

A comment can appear anywhere in the text, including inside a string "/*...*/", inside a numeric constant 12/*...*/34, and inside a character escape \/*...*/n.

Stated formally:

text:
  text-piece
  text-piece remaining-text
text-piece:
  char-sequence-without-/*
  empty-string
remaining-text:
  comment-block text

comment-block:
  /* comment-content */
comment-content:
  comment-piece
  comment-piece remaining-comment
comment-piece:
  char-sequence-without-/*-or-*/
  empty-string
remaining-comment:
  comment-block comment-content

char:
  letters
  digits
  punctuations
  whitespaces

Given a text, delete every comment-block in it.

Input

The input is one text document that may contain comment blocks written with /* and */. The document is valid: it follows the text rule above, so every block that opens also closes. The input always ends with a newline.

Output

First print the line

Case #1:

Then print the document with every comment block deleted. Do not delete any space or blank line that sits outside a comment.

Limits

The document is smaller than 2 KB (2048 bytes).

It contains only these characters:

  • letters a-z, A-Z
  • digits 0-9
  • punctuation ~ ! @ # % ^ & * ( ) - + = : ; " ' < > , . ? | / \ { } [ ] _
  • whitespace: the space character and the newline character

Hint

The pre-processor deletes comments in a single left to right pass. A block that appears only because another block was deleted is not deleted again. For example,

//*no recursion*/* file header */

becomes

/* file header */

A * that already belongs to a /* or a */ cannot be reused by another /* or */. So /*/ is not a complete comment block: the leading /* opens a comment and the remaining / becomes comment content.