{"raw_statement":[{"iden":"statement","content":"Great wizard gave Alice and Bob a cycle string of length $2 dot.op n$, which has no repeated substrings of length $n$. In a cycle string, character $s_{i + 1}$ comes after $s_i$. Also, $s_1$ comes after $s_{2 n}$. \n\nUnfortunately, evil gin shuffled all the symbols of the string. Help Alice and Bob restore the original string so that the above condition is satisfied.\n\nThe first line contains one string $s$ of length $2 dot.op n$ ($2 <= 2 dot.op n <= 1 thin 000 thin 000$) which consists only of the lowercase Latin letters.\n\nPrint \"_NO_\" (without quotes) to the first line if it is impossible to restore the string so that the condition is satisfied. Otherwise, in the first line print \"_YES_\" (without quotes).\n\nIn the second line print one string — the restored string.\n\nIf there are multiple answers, print any.\n\nIn the first example, substrings of the restored string are: \"_abbab_\", \"_bbabc_\", \"_babcb_\", \"_abcbc_\", \"_bcbcc_\", \"_cbccb_\", \"_bccba_\", \"_ccbab_\", \"_cbabb_\", \"_babba_\".\n\nNote that the first example does not contain repetitions, however it can be rewritten as another cycle with no repetitions. Thus, the solution is not unique — the given example is also a correct solution.\n\nIn the second example, it is impossible to restore the string so that no repetition exists.\n\nIn the third example, there is no need to change anything.\n\n"},{"iden":"input","content":"The first line contains one string $s$ of length $2 dot.op n$ ($2 <= 2 dot.op n <= 1 thin 000 thin 000$) which consists only of the lowercase Latin letters."},{"iden":"output","content":"Print \"_NO_\" (without quotes) to the first line if it is impossible to restore the string so that the condition is satisfied. Otherwise, in the first line print \"_YES_\" (without quotes).In the second line print one string — the restored string.If there are multiple answers, print any."},{"iden":"examples","content":"Inputcbbabcacbb\nOutputYES\nabbabcbccbInputaa\nOutputNOInputafedbc\nOutputYES\nafedbc\n"},{"iden":"note","content":"In the first example, substrings of the restored string are: \"_abbab_\", \"_bbabc_\", \"_babcb_\", \"_abcbc_\", \"_bcbcc_\", \"_cbccb_\", \"_bccba_\", \"_ccbab_\", \"_cbabb_\", \"_babba_\".Note that the first example does not contain repetitions, however it can be rewritten as another cycle with no repetitions. Thus, the solution is not unique — the given example is also a correct solution.In the second example, it is impossible to restore the string so that no repetition exists.In the third example, there is no need to change anything."}],"translated_statement":null,"sample_group":[],"show_order":[],"formal_statement":"**Definitions**  \nLet $ x \\in \\mathbb{Z}^+ $ be the required amount of gold.  \nLet $ n \\in \\mathbb{Z}^+ $ be the number of houses.  \nLet $ A = (a_1, a_2, \\dots, a_n) $ be a sequence of positive integers representing gold in each house, indexed from 1 to $ n $.  \n\n**Constraints**  \n1. $ 1 \\leq n \\leq 1000 $  \n2. $ 1 \\leq x \\leq 10^6 $  \n3. $ 1 \\leq a_i \\leq 1000 $ for all $ i \\in \\{1, \\dots, n\\} $  \n\n**Objective**  \nFind the minimum distance $ d $ Bashar must walk, defined as the number of steps between the first and last house visited (i.e., if he visits houses from index $ i $ to $ j $, then $ d = |j - i| $), such that the sum of gold from a contiguous subarray $ \\sum_{k=i}^{j} a_k \\geq x $.  \n\nIf no such contiguous subarray exists, output $ -1 $.  \n\nFormally, compute:  \n$$\n\\min_{1 \\leq i \\leq j \\leq n} \\{ j - i \\mid \\sum_{k=i}^{j} a_k \\geq x \\}\n$$  \nIf the minimum does not exist, return $ -1 $.","simple_statement":"Bashar needs x gold coins. There are n houses in a line, each with some gold. He can start and stop at any house. Find the minimum number of houses he must walk through (consecutively) to collect at least x coins. If impossible, print -1.","has_page_source":false}