{"problem":{"name":"A. Check the string","description":{"content":"A has a string consisting of some number of lowercase English letters '_a_'. He gives it to his friend B who appends some number of letters '_b_' to the end of this string. Since both A and B like the","description_type":"Markdown"},"platform":"Codeforces","limit":{"time_limit":1000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"CF960A"},"statements":[{"statement_type":"Markdown","content":"A has a string consisting of some number of lowercase English letters '_a_'. He gives it to his friend B who appends some number of letters '_b_' to the end of this string. Since both A and B like the characters '_a_' and '_b_', they have made sure that at this point, **at least one '_a_' and one '_b_'** exist in the string.\n\nB now gives this string to C and he appends some number of letters '_c_' to the end of the string. However, since C is a good friend of A and B, the number of letters '_c_' he appends is equal to the number of '_a_' or to the number of '_b_' in the string. It is also possible that the number of letters '_c_' equals both to the number of letters '_a_' and to the number of letters '_b_' at the same time.\n\nYou have a string in your hands, and you want to check if it is possible to obtain the string in this way or not. If it is possible to obtain the string, print \"_YES_\", otherwise print \"_NO_\" (without the quotes).\n\n## Input\n\nThe first and only line consists of a string $S$ ( $ 1 \\le |S| \\le 5\\,000 $ ). It is guaranteed that the string will only consist of the lowercase English letters '_a_', '_b_', '_c_'.\n\n## Output\n\nPrint \"_YES_\" or \"_NO_\", according to the condition.\n\n[samples]\n\n## Note\n\nConsider first example: the number of '_c_' is equal to the number of '_a_'.\n\nConsider second example: although the number of '_c_' is equal to the number of the '_b_', the order is not correct.\n\nConsider third example: the number of '_c_' is equal to the number of '_b_'.","is_translate":false,"language":"English"},{"statement_type":"Markdown","content":"A 有一个由若干个小写英文字母 '_a_' 组成的字符串。他将这个字符串交给他的朋友 B，B 在字符串末尾追加若干个 '_b_'。由于 A 和 B 都喜欢字符 '_a_' 和 '_b_'，他们确保此时字符串中 *至少存在一个 '_a_' 和一个 '_b_'*。\n\nB 现在将这个字符串交给 C，C 在字符串末尾追加若干个 '_c_'。然而，由于 C 是 A 和 B 的好朋友，他追加的 '_c_' 的数量等于当前字符串中 '_a_' 的数量，或等于 '_b_' 的数量。也有可能 '_c_' 的数量同时等于 '_a_' 和 '_b_' 的数量。\n\n你现在手中有一个字符串，你想判断这个字符串是否可以通过上述方式得到。如果可以，请输出 \"_YES_\"，否则输出 \"_NO_\"（不含引号）。\n\n第一行且仅有一行包含一个字符串 $S$（$1 lt.eq | S | lt.eq 5 thin 000$）。保证字符串仅由小写英文字母 '_a_'、'_b_'、'_c_' 组成。\n\n根据条件输出 \"_YES_\" 或 \"_NO_\"。\n\n考虑第一个例子：'_c_' 的数量等于 '_a_' 的数量。\n\n考虑第二个例子：虽然 '_c_' 的数量等于 '_b_' 的数量，但顺序不正确。\n\n考虑第三个例子：'_c_' 的数量等于 '_b_' 的数量。\n\n## Input\n\n第一行且仅有一行包含一个字符串 $S$（$1 lt.eq | S | lt.eq 5 thin 000$）。保证字符串仅由小写英文字母 '_a_'、'_b_'、'_c_' 组成。\n\n## Output\n\n根据条件输出 \"_YES_\" 或 \"_NO_\"。\n\n[samples]\n\n## Note\n\n考虑第一个例子：'_c_' 的数量等于 '_a_' 的数量。考虑第二个例子：虽然 '_c_' 的数量等于 '_b_' 的数量，但顺序不正确。考虑第三个例子：'_c_' 的数量等于 '_b_' 的数量。","is_translate":true,"language":"Chinese"},{"statement_type":"Markdown","content":"**Definitions**  \nLet $ S $ be a string over the alphabet $ \\{a, b, c\\} $.  \nLet $ n_a = |S|_a $, $ n_b = |S|_b $, $ n_c = |S|_c $ denote the counts of characters 'a', 'b', and 'c' in $ S $, respectively.\n\n**Constraints**  \n1. $ n_a \\geq 1 $, $ n_b \\geq 1 $, $ n_c \\geq 1 $  \n2. All occurrences of 'a' come before all occurrences of 'b', and all occurrences of 'b' come before all occurrences of 'c'. That is, $ S $ must be of the form $ a^* b^* c^* $.  \n3. $ n_c = n_a $ **or** $ n_c = n_b $ (or both).\n\n**Objective**  \nDetermine whether $ S $ satisfies all above constraints. If yes, output \"YES\"; otherwise, output \"NO\".","is_translate":false,"language":"Formal"}],"meta":{"iden":"CF960A","tags":["implementation"],"sample_group":[["aaabccc","YES"],["bbacc","NO"],["aabc","YES"]],"created_at":"2026-03-03 11:00:39"}}