问题

### Instructions: You are an expert Python programmer. You will be given a question (problem specification) and will generate a correct Python program that matches the specification and passes all tests. You will NOT return anything except for the program.
### Question:
We define Extended A strings, Extended B strings, Extended C strings, and Extended ABC strings as follows:

- A string S is an Extended A string if all characters in S are A.
- A string S is an Extended B string if all characters in S are B.
- A string S is an Extended C string if all characters in S are C.
- A string S is an Extended ABC string if there is an Extended A string S_A, an Extended B string S_B, and an Extended C string S_C such that the string obtained by concatenating S_A, S_B, S_C in this order equals S.

For example, ABC, A, and AAABBBCCCCCCC are Extended ABC strings, but ABBAAAC and BBBCCCCCCCAAA are not.
Note that the empty string is an Extended A string, an Extended B string, and an Extended C string.
You are given a string S consisting of A, B, and C.
If S is an Extended ABC string, print Yes; otherwise, print No.

Input

The input is given from Standard Input in the following format:
S

Output

If S is an Extended ABC string, print Yes; otherwise, print No.

Constraints


- S is a string consisting of A, B, and C.
- 1\leq|S|\leq 100 (|S| is the length of the string S.)

Sample Input 1

AAABBBCCCCCCC

Sample Output 1

Yes

AAABBBCCCCCCC is an Extended ABC string because it is a concatenation of an Extended A string of length 3, AAA, an Extended B string of length 3, BBB, and an Extended C string of length 7, CCCCCCC, in this order.
Thus, print Yes.

Sample Input 2

ACABABCBC

Sample Output 2

No

There is no triple of Extended A string S_A, Extended B string S_B, and Extended C string S_C such that the string obtained by concatenating S_A, S_B, and S_C in this order equals ACABABCBC.
Therefore, print No.

Sample Input 3

A

Sample Output 3

Yes

Sample Input 4

ABBBBBBBBBBBBBCCCCCC

Sample Output 4

Yes

### Format: Read the inputs from stdin solve the problem and write the answer to stdout (do not directly test on the sample inputs). Enclose your code within delimiters as follows.
```python
# YOUR CODE HERE
```

### Answer: (use the provided format with backticks)

答案

模型 模型答案 正确答案
金声玉亮2.0 ```python
import sys

def is_extended_abc_string(s):
if not s:
return True

a_count = 0
b_count = 0
c_count = 0

for char in s:
if char == 'A':
if b_count > 0 or c_count > 0:
return False
a_count += 1
elif char == 'B':
if c_count > 0:
return False
b_count += 1
elif char == 'C':
c_count += 1

return True

s = input().strip()

if is_extended_abc_string(s):
print("Yes")
else:
print("No")
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
deepseek-r1

```python
# Read the input string
S = input().strip()

index = 0

# Process A's
while index < len(S) and S[index] == 'A':
index += 1

# Process B's
while index < len(S) and S[index] == 'B':
index += 1

# Process C's
while index < len(S) and S[index] == 'C':
index += 1

# Check if all characters were processed
if index == len(S):
print("Yes")
else:
print("No")
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
gpto1 ```python
# YOUR CODE HERE
S = input()
n = len(S)
i = 0

# Process 'A's
while i < n and S[i] == 'A':
i += 1

# Process 'B's
while i < n and S[i] == 'B':
i += 1

# Process 'C's
while i < n and S[i] == 'C':
i += 1

# Check if reached the end
if i == n:
print('Yes')
else:
print('No')
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
gpt-4o-2024-08-06 ```python
# YOUR CODE HERE
def is_extended_abc_string(s):
# We need to find a point where the string can be split into A's, B's, and C's
n = len(s)
i = 0

# Count the A's
while i < n and s[i] == 'A':
i += 1

# Count the B's
while i < n and s[i] == 'B':
i += 1

# Count the C's
while i < n and s[i] == 'C':
i += 1

# If we have reached the end of the string, it means the string is an Extended ABC string
return i == n

# Read input
import sys
input = sys.stdin.read
s = input().strip()

# Check if the string is an Extended ABC string
if is_extended_abc_string(s):
print("Yes")
else:
print("No")
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
DeepSeek-Coder-V2-Lite-Instruct ```python
# YOUR CODE HERE
def is_extended_abc_string(S):
# Initialize indices to track the positions of A, B, and C in the string
index_a = 0
index_b = 0
index_c = 0

# Iterate through the string S
for char in S:
if char == 'A':
index_a += 1
elif char == 'B':
index_b += 1
elif char == 'C':
index_c += 1
else:
# If the character is not A, B, or C, it's an invalid character
return "No"

# Check if the counts of A, B, and C are consistent with an Extended ABC string
if index_a % 3 == 0 and index_b % 3 == 0 and index_c % 3 == 0:
return "Yes"
else:
return "No"

# Read input from stdin
S = input().strip()

# Print the result
print(is_extended_abc_string(S))
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
Meta-Llama-3.1-405B-Instruct-Turbo ```python
import sys

def is_extended_abc_string(s):
if not s:
return True

a_count = 0
b_count = 0
c_count = 0

for char in s:
if char == 'A':
if b_count > 0 or c_count > 0:
return False
a_count += 1
elif char == 'B':
if c_count > 0:
return False
b_count += 1
elif char == 'C':
c_count += 1

return True

s = input().strip()

if is_extended_abc_string(s):
print("Yes")
else:
print("No")
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
Meta-Llama-3.1-70B-Instruct-Turbo ```python
import sys

def solve():
s = input()
a = 0
b = 0
c = 0
for char in s:
if char == 'A':
a += 1
elif char == 'B':
if a == 0:
print("No")
return
b += 1
elif char == 'C':
if a == 0 or b == 0:
print("No")
return
c += 1
print("Yes")

if __name__ == "__main__":
solve()
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
Qwen2-72B-Instruct ```python
s = input()
a = s.find('B')
b = s.rfind('B')
if a == -1 or b == -1 or a != s.find('C') or b != s.rfind('C'):
print('No')
else:
print('Yes' if set(s[:a]) == {'A'} and set(s[a:b+1]) == {'B'} and set(s[b+1:]) == {'C'} else 'No')
```
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
baichuan4 ```python
# YOUR CODE HERE
def is_extended_abc_string(s):
# Initialize pointers for A, B, and C segments
a_start = b_start = c_start = 0

# Iterate through the string
for i in range(len(s)):
if s[i] == 'A':
# If we encounter an 'A' after a 'B' or 'C', return False
if b_start > 0 or c_start > 0:
return "No"
a_start = i
elif s[i] == 'B':
# If we encounter a 'B' after an 'A', start the B segment
if a_start > 0:
b_start = i
elif s[i] == 'C':
# If we encounter a 'C' after a 'B', start the C segment
if b_start > 0:
c_start = i

# Check if all segments are valid
return "Yes" if a_start >= 0 and b_start >= 0 and c_start >= 0 else "No"

# Read input from stdin
input_string = input()

# Output the result
print(is_extended_abc_string(input_string))
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
doubao ```python
S = input()

a_count = 0
b_count = 0
c_count = 0
current_char = None

for char in S:
if char == 'A':
if current_char == 'B' or current_char == 'C':
break
a_count += 1
elif char == 'B':
if current_char == 'C':
break
b_count += 1
current_char = 'B'
elif char == 'C':
c_count += 1
current_char = 'C'

if a_count > 0 and b_count > 0 and c_count > 0 and current_char == 'C':
print('Yes')
else:
print('No')
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
gpto1 ```python
# YOUR CODE HERE
S = input()
n = len(S)
i = 0

# Process 'A's
while i < n and S[i] == 'A':
i += 1

# Process 'B's
while i < n and S[i] == 'B':
i += 1

# Process 'C's
while i < n and S[i] == 'C':
i += 1

# Check if reached the end
if i == n:
print('Yes')
else:
print('No')
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
kimi ```python
def is_extended_abc(s):
if len(s) == 0:
return True
for i in range(1, len(s)):
if s[:i] == ''.join(['A'] * i) and s[i:-1] == ''.join(['B'] * (len(s) - i - 1)) and s[-1:] == ''.join(['C'] * 1):
return True
return False

s = input()
if is_extended_abc(s):
print('Yes')
else:
print('No')
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
minimax ```python
# YOUR CODE HERE
input_string = input()
extended_a = extended_b = extended_c = ""
for char in input_string:
if char == 'A':
extended_a += char
extended_b = extended_c = ""
elif char == 'B':
extended_b += char
extended_c = ""
elif char == 'C':
extended_c += char
else:
# If any character other than A, B, or C is encountered, it's not an Extended ABC string
print("No")
break
else:
# If the entire string is traversed without breaking, check if all three parts are non-empty
if extended_a and extended_b and extended_c:
print("Yes")
else:
print("No")
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
wenxinyiyan ```python
# Read the input string
s = input()

# Initialize flags to track the occurrence of characters
found_a = False
found_b = False
found_c = False

# Flag to track if characters are in correct order
is_extended_abc = True

# Iterate over each character in the string
for char in s:
if char == 'A':
# If we have already found B or C, then the string is not an Extended ABC string
if found_b or found_c:
is_extended_abc = False
break
found_a = True
elif char == 'B':
# If we have already found C or we haven't found A yet, then the string is not an Extended ABC string
if found_c or not found_a:
is_extended_abc = False
break
found_b = True
elif char == 'C':
# If we haven't found A or B yet, then the string is not an Extended ABC string
if not found_a or not found_b:
is_extended_abc = False
break
found_c = True

# Print the result
if is_extended_abc:
print('Yes')
else:
print('No')
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
zhipu ```python
def is_extended_abc_string(s):
# Check if the string can be split into three parts: A's, B's, and C's
# First, find the transition points from A to B and B to C
try:
first_b = s.index('B')
first_c = s.index('C', first_b)
except ValueError:
# If B or C is not found, it cannot be an Extended ABC string
return "No"

# Check if all characters before first_b are 'A'
if any(c != 'A' for c in s[:first_b]):
return "No"

# Check if all characters between first_b and first_c are 'B'
if any(c != 'B' for c in s[first_b:first_c]):
return "No"

# Check if all characters after first_c are 'C'
if any(c != 'C' for c in s[first_c:]):
return "No"

return "Yes"

def main():
import sys
input = sys.stdin.read
s = input().strip()
result = is_extended_abc_string(s)
print(result)

if __name__ == "__main__":
main()
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]
deepseek-v3 ```python
# YOUR CODE HERE
def is_extended_abc_string(s):
# Split the string into three parts based on the order A, B, C
# Find the first occurrence of B
first_b = s.find('B')
if first_b == -1:
# No B, check if all are A or all are C
if all(c == 'A' for c in s) or all(c == 'C' for c in s):
return True
else:
return False
# Find the first occurrence of C
first_c = s.find('C')
if first_c == -1:
# No C, check if all are A or all are B
if all(c == 'A' for c in s) or all(c == 'B' for c in s):
return True
else:
return False
# Now, we have at least one B and one C
# The A part should be before the first B
a_part = s[:first_b]
# The B part should be between the first B and the first C
b_part = s[first_b:first_c]
# The C part should be after the first C
c_part = s[first_c:]
# Check if each part is valid
if all(c == 'A' for c in a_part) and all(c == 'B' for c in b_part) and all(c == 'C' for c in c_part):
return True
else:
return False

# Read input
S = input().strip()
# Check if it is an Extended ABC string
if is_extended_abc_string(S):
print("Yes")
else:
print("No")
```
[{"input": "AAABBBCCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ACABABCBC\n", "output": "No\n", "testtype": "stdin"}, {"input": "A\n", "output": "Yes\n", "testtype": "stdin"}, {"input": "ABBBBBBBBBBBBBCCCCCC\n", "output": "Yes\n", "testtype": "stdin"}]