{"trustable":false,"sections":[{"title":"","value":{"format":"HTML","content":"\u003cp\u003e\n\tTeX, a typesetting language developed by Donald Knuth, excels at producing beautifully formatted documents from source text and typesetting instructions. In TeX, the use of oriented double-quotes (`` and \u0027\u0027) to enclose quotations is favored over the conventional double-quote (\"). While most keyboards don\u0027t feature a dedicated oriented double-quote key, they typically include a left-single-quote (`) and a right-single-quote (\u0027).\n\nTo achieve the desired quotation format in TeX, users employ two left-single-quotes to create a left-double-quote (``) and two right-single-quotes to create a right-double-quote (\u0027\u0027). However, many typists often use standard double-quotes for their quotations.\u003c/p\u003e\n\u003cp\u003e\n\tIf the source contained\u003c/p\u003e\n\u003cp\u003e\n\t\u003ctt\u003e\u0026quot;To be or not to be,\u0026quot; quoth the bard, \u0026quot;that is the question.\u0026quot;\u003c/tt\u003e\u003c/p\u003e\n\u003cp\u003e\n\tthen the typeset document produced by TeX would not contain the desired form:\u003c/p\u003e\n\u003cp\u003e\n\t``To be or not to be,\u0026quot; quoth the bard, ``that is the question.\u0026quot;\u003c/p\u003e\n\u003cp\u003e\n\tIn order to produce the desired form, the source file must contain the sequence:\u003c/p\u003e\n\u003cp\u003e\n\t\u003ctt\u003e``To be or not to be,\u0026#39;\u0026#39; quoth the bard, ``that is the question.\u0026#39;\u0026#39;\u003c/tt\u003e\u003c/p\u003e\n\u003cp\u003e\n\tYour task is to create a program that transforms text containing double-quote (\") characters into an equivalent text, but with the double-quotes replaced by the two-character sequences required by TeX for oriented double-quotes. Specifically, the program should replace a double-quote (\") with if it begins a quotation and with \u0027\u0027 if it concludes a quotation. Additionally, the program should handle nested quotations correctly, alternating between and \u0027\u0027 as needed. Notice that the question of nested quotations does not arise: The first \u003ctt\u003e\u0026quot;\u003c/tt\u003e must be replaced by \u003ctt\u003e``\u003c/tt\u003e, the next by \u003ctt\u003e\u0026#39;\u0026#39;\u003c/tt\u003e, the next by \u003ctt\u003e``\u003c/tt\u003e, the next by \u003ctt\u003e\u0026#39;\u0026#39;\u003c/tt\u003e, the next by \u003ctt\u003e``\u003c/tt\u003e, the next by \u003ctt\u003e\u0026#39;\u0026#39;\u003c/tt\u003e, and so on.\u003c/p\u003e"}},{"title":"Input","value":{"format":"HTML","content":"\u003cp\u003e\n\tInput will consist of several lines of text containing an even number of double-quote (\u003ctt\u003e\u0026quot;\u003c/tt\u003e) characters. Input is ended with an end-of-file character.\u003c/p\u003e"}},{"title":"Output","value":{"format":"HTML","content":"\u003cp\u003e\n\tThe text must be output exactly as it was input except that:\u003c/p\u003e\n\u003cul\u003e\n\t\u003cli\u003e\n\t\tthe first\u0026nbsp;\u003ctt\u003e\u0026quot;\u003c/tt\u003e\u0026nbsp;in each pair is replaced by two\u0026nbsp;\u003ctt\u003e`\u003c/tt\u003e\u0026nbsp;characters:\u0026nbsp;\u003ctt\u003e``\u003c/tt\u003e\u0026nbsp;and\u003c/li\u003e\n\t\u003cli\u003e\n\t\tthe second\u0026nbsp;\u003ctt\u003e\u0026quot;\u003c/tt\u003e\u0026nbsp;in each pair is replaced by two\u0026nbsp;\u003ctt\u003e\u0026#39;\u003c/tt\u003e\u0026nbsp;characters:\u0026nbsp;\u003ctt\u003e\u0026#39;\u0026#39;\u003c/tt\u003e.\u003c/li\u003e\n\u003c/ul\u003e"}},{"title":"Sample Input","value":{"format":"HTML","content":"\u003cpre\u003e\n\u0026quot;To be or not to be,\u0026quot; quoth the Bard, \u0026quot;that\nis the question\u0026quot;.\nThe programming contestant replied: \u0026quot;I must disagree.\nTo `C\u0026#39; or not to `C\u0026#39;, that is The Question!\u0026quot;\u003c/pre\u003e"}},{"title":"Sample Output","value":{"format":"HTML","content":"\u003cpre\u003e\n``To be or not to be,\u0026#39;\u0026#39; quoth the Bard, ``that\nis the question\u0026#39;\u0026#39;.\nThe programming contestant replied: ``I must disagree.\nTo `C\u0026#39; or not to `C\u0026#39;, that is The Question!\u0026#39;\u0026#39;\u003c/pre\u003e"}}]}