Skip to content
TheChatArchiveThe Chat Archive
DeepSeekDeepseek v3.2· deepseekHugging Face Frontier Reasoning Traces

You are given a 4-character string S consisting of uppercase English letters. Determine…

  1. User

    You are given a 4-character string S consisting of uppercase English letters. Determine if S consists of exactly two kinds of characters which both appear twice in S.

    Constraints

    • The length of S is 4.
    • S consists of uppercase English letters. Input

    Input is given from Standard Input in the following format:

    S

    Output

    If S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.

    Examples

    Input

    ASSA

    Output

    Yes

    Input

    STOP

    Output

    No

    Input

    FFEE

    Output

    Yes

    Input

    FREE

    Output

    No

  2. DeepSeek Assistant

    We need to solve a simple problem: Given a 4-character uppercase string S, determine if it consists of exactly two distinct characters, each appearing exactly twice.

    We can approach by counting frequencies: Use a dictionary or set. Since length is fixed to 4, we can also sort and check conditions. For example, get unique letters; if there are exactly 2, and for each, count is 2 (since total 4, if exactly 2 distinct, each must appear exactly 2? Actually not necessarily: Could be one appears three times and other one time. So need to check each appears exactly twice. But with exactly 2 distinct, total 4, the possibilities are (1,3) or (2,2) or (0,4) but 0,4 can't because distinct count is 1, not 2. So if exactly 2 distinct, the multiset of counts could be (1,3) or (2,2). So we need to ensure both counts are 2. So check that the sorted list of counts equals [2,2]. Or check that the set of counts is {2}. But if there are exactly 2 distinct, checking if both counts are 2 can be done.

    Alternatively, we can just count frequency and then ensure that the set of frequencies equals {2}. That would cover exactly two characters each appearing twice. But if there were 3 distinct characters (counts like 2,1,1) set of frequencies contains 2,1 not {2}. So {2} would be false. If there is one character (counts {4}), set of frequencies {4} not {2}. So condition: len(set(S)) == 2 and all(S.count(c) == 2 for c in set(S)). That works.

    Simpler: sorted(S) and check S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]. But careful: The letters may not be sorted, but we can sort. So after sorting, if first two equal, last two equal, and first and third differ, then condition holds. Because after sorting, if there are exactly two distinct characters each appearing twice, the sorted string will be like A A B B. So check: sortedS = sorted(S); if sortedS[0]==sortedS[1] and sortedS[2]==sortedS[3] and sortedS[0]!=sortedS[2]: Yes else No. This works.

    Edge cases: exactly two characters but counts 3 and 1: sorted would be A A A B; then condition fails because sortedS[2]!=sortedS[3] or sortedS[0]!=sortedS[1]? Actually sortedS[0]==sortedS[1] true, sortedS[2]==sortedS[3] false (since A vs B). So No. If all same: sortedS[0]==sortedS[1] true, sortedS[2]==sortedS[3] true, but sortedS[0]==sortedS[2] true, so fails last condition. So No. If 4 distinct: sortedS[0]==sortedS[1] false, so No. Good.

    Thus implement.

    Let's produce Python solution.

    We'll read input string (strip). S is 4 characters. Then compute sorted_s = sorted(S). Then check condition.

    If condition true print Yes else No.

    Make sure to follow exact output: Yes/No with capital Y and N.

    That's it.

    Now produce final answer. ```python

    def main(): S = input().strip() sorted_s = sorted(S) if sorted_s[0] == sorted_s[1] and sorted_s[2] == sorted_s[3] and sorted_s[0] != sorted_s[2]: print("Yes") else: print("No")

    if name == "main": main()