{"problem":{"name":"ABC String","description":{"content":"Given is a string $S$ consisting of `A`,`B`, and `C`. Consider the (not necessarily contiguous) subsequences $x$ of $S$ that satisfy all of the following conditions: *   `A`, `B`, and `C` all occur t","description_type":"Markdown"},"platform":"AtCoder","limit":{"time_limit":2000,"memory_limit":262144},"difficulty":"None","is_remote":true,"is_sync":true,"sync_url":null,"sign":"agc036_e"},"statements":[{"statement_type":"Markdown","content":"Given is a string $S$ consisting of `A`,`B`, and `C`.\nConsider the (not necessarily contiguous) subsequences $x$ of $S$ that satisfy all of the following conditions:\n\n*   `A`, `B`, and `C` all occur the same number of times in $x$.\n*   No two adjacent characters in $x$ are the same.\n\nAmong these subsequences, find one of the longest. Here a subsequence of $S$ is a string obtained by deleting zero or more characters from $S$.\n\n## Constraints\n\n*   $1 \\leq |S| \\leq 10^6$\n*   $S$ consists of `A`,`B`, and `C`.\n\n## Input\n\nInput is given from Standard Input in the following format:\n\n$S$\n\n[samples]","is_translate":false,"language":"English"}],"meta":{"iden":"agc036_e","tags":[],"sample_group":[["ABBCBCAB","ACBCAB\n\nConsider the subsequence `ACBCAB` of $S$. It satisfies the conditions and is one of the longest with these properties, along with `ABCBCA`. On the other hand, the subsequences `ABCBCAB` and `ABBCCA` do not satisfy the conditions."],["ABABABABACACACAC","BABCAC"],["ABCABACBCBABABACBCBCBCBCBCAB","ACABACABABACBCBCBCBCA"],["AAA","It is possible that only the empty string satisfies the condition."]],"created_at":"2026-03-03 11:01:14"}}