Problem:


Score : 100 points

Problem Statement

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.

Sample Input 1

ASSA

Sample Output 1

Yes

S consists of A and S which both appear twice in S.

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No



Sample input:
ASSA


Sample output:
Yes

Submission status: Accepted

Solution code:
import sys
from collections import Counter

indata = sys.stdin.read().strip()
c = Counter(indata)
if len(c) == 2 and all(v == 2 for v in c.values()):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
S = list(S)
S.sort()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3]:
  print("Yes")
elif s[0]==s[2] and s[0]!=s[1] and s[1]==s[3]:
  print("Yes")
elif s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S=input()
a=set(S)
if len(a)==2 and S.count(S[0])==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
if (s[0] == s[1] and s[2] == s[3] and s[0] != s[2]) or (s[0] == s[2] and s[1] == s[3] and s[0] != s[1]) or (s[0] == s[3] and s[2] == s[1] and s[0] != s[2]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())
S.sort()
print('Yes' if S[0] == S[1] and S[2] == S[3] and S[1] != S[2] else 'No')

Submission status: Accepted

Solution code:
S = list(input())
S.sort()
if S[0]==S[1] and S[2]==S[3] and S[1]!=S[2]:
    print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
S = input()

num_dict = {}

for i in range(len(S)):
    if S[i] in num_dict:
        num_dict[S[i]] += 1
    else:
        num_dict[S[i]] = 1

if len(num_dict) == 2 and \
    len([i for i, x in enumerate(num_dict.values()) if x == 2]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = sorted(list(input()))
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
lst = list(s)
for c in s:
    k = s.count(c)
    if k != 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
s = input()
lst = list(s)
for c in s:
    k = s.count(c)
    if k != 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import collections
s = input()
c = collections.Counter(s)
if list(c.values())[0] == 2 and len(c.keys()) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()
if len(set(s)) == 2:
	a = "Yes"  
else:
	a = "No"
print(a)

Submission status: Accepted

Solution code:
S = input()
if len(set(S)) == 2:
	ans = 'Yes'  
else:
	ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
S=input()
count = 0
for i in S:
    for j in S:
        if i==j:
            count+=1
if count==8:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
ans = "Yes" if len(set(S)) == 2 else "No"
print(ans)

Submission status: Accepted

Solution code:

T=sorted(input())
print("Yes" if T[0] == T[1] and T[2] == T[3] and T[0] != T[2] else "No")

Submission status: Accepted

Solution code:
s = input()
s = sorted(s)
if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input().strip()
chars = list(set(S))
if not len(chars) == 2:
  print('No')
else:
  if S.count(chars[0]) == 2 and S.count(chars[1]) == 2:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

Solution code:
n=input()
if (n[0]==n[1] and n[2]==n[3] or n[0]==n[2] and n[1]==n[3] or n[0]==n[3] and n[1]==n[2]) and len(set(n))==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import Counter
s = list(input())
s = sorted(Counter(s).values())
if s[0] ==2:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
S = [c for c in input()]
if len(set(S)) == 2 and S.count(S[0]) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())
S_set = set(S)
if len(S_set)==2 and (S.count(S[0])==2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

s = list(input().strip())
s = sorted(s)
if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
try:
    ans = ""
    N = input()
    N = N.replace(N[0], "")
    N = N.replace(N[0], "")
    print("Yes") if ans == N else print("No")
except IndexError:
    print("No")

Submission status: Accepted

Solution code:
s=input()
st=set()
for c in s:
  st.add(c)
if len(st)==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import collections

S = input()
Slist = collections.Counter(S)

if Slist.most_common()[0][1] == 2 and Slist.most_common()[1][1] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = str(input()).upper()
if 4 == len(s):
    if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
        print('Yes')
    elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
        print('Yes')
    elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
        print('Yes')
    else:
        print('No')
else:
    print('Please input type length 4')

Submission status: Accepted

Solution code:
S = input()
print("Yes" if len(set(list(S))) == 2 and S.count(S[0]) == 2 else "No")

Submission status: Accepted

Solution code:
S = input()
sorted_S = sorted(S)
if sorted_S[0] != sorted_S[2] and sorted_S[0] == sorted_S[1] and sorted_S[2] == sorted_S[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=input()
output='Yes'
for i in range(4):
  counter=0
  for j in range(4):
    if s[i]==s[j]:
      counter+=1
      
  if counter!=2:
    output='No'
    
print(output)

Submission status: Accepted

Solution code:
#coding:utf-8
 
s = str(input())
string  = list(s)
string_unique = list(set(string))
 
#print(string_unique)
 
if len(string_unique) == 2:
    if string.count(string_unique[0]) == 1 or string.count(string_unique[0]) == 3:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())

S = sorted(S)
if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
import collections

def main():
    S = input()
    d = dict()
    for c in S:
        d[c] = d.get(c, 0) + 1
    if len(d) == 2 and d[S[0]] == 2:
        return "Yes"
    return "No"


if __name__ == '__main__':
    print(main())

Submission status: Accepted

Solution code:
a = input()
print("Yes") if len(set(a)) ==2 and a.count(a[0]) == 2 else print("No")

Submission status: Accepted

Solution code:
s = list(input())
s = list(set(s))
if len(s) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:

s = input()

# パターン AABB ABAB ABBA
if s[0]==s[1] :
    if s[2]==s[3] and s[0]!=s[2]:
        print('Yes')
    else :
        print('No')
elif s[0]==s[2] and s[0]!=s[1]:
    if s[1]==s[3]:
        print('Yes')
    else :
        print('No')
elif s[2]==s[1] and s[0]!=s[2]:
    if s[0]==s[3]:
        print('Yes')
    else :
        print('No')
else :
    print('No')

Submission status: Accepted

Solution code:
#AtCoder Beginner Contest 132 A問題
S=input()
A=[S[0]]
for i in range(4):
    if S[0]!=S[i]:
        A+=S[i]
A=list(set(A))

if len(A)==2:
    cou=S.count(S[0])
    if cou==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s = sorted(input())
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())

if len(set(S))==2 and S.count(S[0])==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input().split()
s = list(s[0])
s.sort()
if s[0] == s[1] and s[1]!=s[2] and s[2] == s[3]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = sorted(input())

if S[0] == S[1] and S[0] != S[2] and S[2] == S[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
S = ''.join(sorted(S))

f = (S[0] == S[1] and S[2] == S[3] and S[1] != S[2])
print ("YNeos"[(not f)::2])

Submission status: Accepted

Solution code:
S = input()

dict_S = {}

for s in S:
  if s not in dict_S:
    dict_S[s] = 1
  else:
    dict_S[s] += 1

    
if len(dict_S) == 2:
  for v in dict_S.values():
    if v == 2:
      continue
    else:
      print('No')
      break
    
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys
S = str(sys.stdin.readline()).strip()

S1 = S.replace(S[0],'')
if len(S1) != 2:
  print('No')
  exit()
  
S2 = S1.replace(S1[0],'')
if len(S2) == 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
for s in set(S):
  if S.count(s) != 2:
    res = 'No'
    break
else:
  res = 'Yes'
print(res)

Submission status: Accepted

Solution code:
s=input()
s=sorted(s)
print("Yes"if s[0]==s[1] and s[2]==s[3] and s[1]!=s[2] else "No")

Submission status: Accepted

Solution code:
s=input()
if s[0]==s[1]==s[2]==s[3]:
    print("No")
elif (s[0]==s[1] and s[2]==s[3]) or (s[0]==s[2] and s[1]==s[3])or (s[0]==s[3] and s[1]==s[2]):
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())
for c in S:
  if S.count(c) != 2:
    print("No")
    exit(0)
print("Yes")

Submission status: Accepted

Solution code:
S = input()
if len(set(S)) == 2:
    if S.count(S[0]) == 2:
        print('Yes')
    else:
        print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
S=input()

S=sorted(S)
print("Yes" if S[0]==S[1] and S[2]==S[3] and S[0]!=S[3] else "No")

Submission status: Accepted

Solution code:
A=list(input())
print("Yes" if len(set(A))==2 and A.count(A[0])==2 else "No")

Submission status: Accepted

Solution code:
S = list(input())
S.sort()
if S[0] == S[1] and S[1]  != S[2] and S[2] == S[3]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
word = input()
if len(word) != 4:
  print('No')
else:
  letters = {word[0]: 1}
  for l in word[1:]:
    if l in letters:
      letters[l] += 1
    else:
      letters[l] = 1
  if list(letters.values()) == [2, 2]:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
s.sort()
ans = 'No'
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
  ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
import collections

s = input()
t = collections.Counter(s)
for i in t:
    if t[i] == 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
s = input()
t = set(s)
if len(t) == 2 and s.count(s[0]) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()
if len(set(s))==2 and s.count(s[0])==2:
  print("Yes" )
else:
  print("No")
  
#set関数とはリストやタプルから重複した要素を取り除くことができるる。
#count関数とは

Submission status: Accepted

Solution code:
s = input()
s = sorted(s)
if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
s = input()
s = sorted(s)
if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

s0_splited = S.split(sep=S[0])

vals = []
if len(s0_splited) == 3:
    for s_i in s0_splited:
        if len(s_i) == 2:
            if s_i[0] != s_i[1]:
                print("No")
                break
        elif len(s_i) == 1:
            vals.append(s_i)
        if len(vals) == 2:
            if vals[0] != vals[1]:
                print("No")
                break
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
if len(set(s))==2 and s.count(s[0])==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
arr = list(input())
arr.sort()
if arr[0] == arr[1] and arr[1] != arr[2] and arr[2] == arr[3] :
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc132/tasks/abc132_a
# A - Fifty-Fifty

s = input().split()[0]
count_dict = {}

for char in list(s):
    if char in count_dict.keys():
        count_dict[char] += 1
    else:
        count_dict[char] = 1

ans = True

if len(count_dict.keys()) == 2:
    is_match = True
    for k, v in count_dict.items():
        if v != 2:
            is_match = False
else:
    is_match = False

ans = 'Yes' if is_match else 'No'

print(ans)

Submission status: Accepted

Solution code:
S = input()
mach_list = [S[0], S[1], S[2], S[3]]
Flag = True
for i in range(3):
    if mach_list.count(mach_list[i]) != 2:
        Flag =False
if Flag == True:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    for ch1 in S:
        count = 0
        for ch2 in S:
            if ch1 == ch2:
                count += 1
        if count != 2:
            print(NO)
            return
    print(YES)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = list(input())
S_ = list(set(S))
if len(S_)==2 and S.count(S_[0])==2:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
S = str(input())
ans = 'No'
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2] \
    or S[0]==S[2] and S[1] == S[3] and S[0]!=S[1] \
    or S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
    ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
S=input()
A=list(S)

for i in range ( len(S) ) :
   if ( A.count( A[i] ) != 2 ) :
       print ( 'No' )
       quit()

print ('Yes')

Submission status: Accepted

Solution code:
s1, s2, s3, s4 = input()
s = [s1, s2, s3, s4]

s.sort()

if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
X=str(input())
XX=sorted(X)
if len(set(X))==2:
    if XX[1]!=XX[2]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s = str(input())
letter_list = []
for letter in s:
    letter_list.append(letter)
letter_list.sort()
l1 = letter_list[0]
l2 = letter_list[2]
if letter_list.count(l1) == 2 and letter_list.count(l2) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or \
(S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or \
(S[0]==S[3] and S[1]==S[2] and S[0]!=S[2]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from sys import stdin
a = stdin.readline().rstrip()
b = sorted(a)
if b[0] == b[1] and b[2] == b[3] and b[1] != b[2] :
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
if len(set(input())) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import collections
ls = collections.Counter(input())
for i in ls.values():
    if i != 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

S = input()

ss = sorted(S)

# print(ss)

if ss[0] != ss[1]:
    print('No')
elif ss[1] == ss[2]:
    print('No')
elif ss[2] != ss[3]:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import collections
S = list(input() )
A = collections.Counter(S)
A = A.most_common()
if len(A) == 2 and A[0][1]== 2 and A[1][1] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S1=input()
S2={}
for i in range(4):
    if S1[i] in S2:
        S2[S1[i]]+=1
    else:
        S2[S1[i]]=1
if len(S2)==2 and S2[S1[0]]==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=list(input())  

if len(set(s)) ==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
l=[i for i in input()]

ans='No'

con=len(set(l))
if (con==2) and (l.count(l[0])==2):
  ans='Yes'

print(ans)

Submission status: Accepted

Solution code:
word=input()
listword=list(word)
listword.sort()

if listword[0]==listword[1] and listword[2]==listword[3] and listword[0]!=listword[3]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=list(input())
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]:
	print("Yes")
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]:
	print("Yes")
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
# input string S
S = input()

# judge if 2S[0], 2S[1] and 2S[2] exist in S
if S.count(S[0])==2 and S.count(S[1])==2 and S.count(S[2])==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=list(set(input()));print("Yes") if len(s)==2 else print("No")

Submission status: Accepted

Solution code:
S = list(input())
if (S[0] == S[1] and S[2] == S[3] and S[0] != S[2])or (S[0] == S[2] and S[1] == S[3] and S[0] != S[1])or (S[0] == S[3] and S[1] == S[2] and S[0] != S[1]):
    print('Yes')
else:
    print("No")

Submission status: Accepted

Solution code:
x=list(input())

if (x[0]==x[1])and(x[2]==x[3])and(x[0]!=x[2]):
    print('Yes')
elif (x[0]==x[2])and(x[1]==x[3])and(x[0]!=x[1]):
    print('Yes')
elif (x[0]==x[3])and(x[1]==x[2])and(x[0]!=x[1]):
    print('Yes')
else :
    print('No')

Submission status: Accepted

Solution code:
word = input()
dict_word = {}
for i in range(len(word)):
  try:
    count = dict_word[word[i]]
    dict_word[word[i]] += 1
  except:
    dict_word[word[i]] = 1


if len(dict_word) == 2 and list(dict_word.values()) == [2, 2]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = list(input())
if len(set(s))==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
s.sort()
if s.count(s[0])==s.count(s[-1])==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
d={}
A = input()
for i in range(len(A)):
    if d.get(A[i],None)==None:
        d[A[i]]=1
    else:
        d[A[i]]+=1

if(max(d.values())==2 & min(d.values())==2):
    print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
S = input()
S = S.replace(S[0],'')
if len(S) != 2:
    print('No')
else:
    S = S.replace(S[0],'')
    if len(S) != 0:
        print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
s=sorted(input())
print('Yes' if s[0]==s[1] and s[2]==s[3] and s[0] != s[2] else 'No')

Submission status: Accepted

Solution code:

l = input()
L = []

for i in range(4):
    L.append(l[i])
    
n = 0
N = []

for w in range(4):
    n += L.count(L[w])

if n == 8:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
if len(set(s)) == 2 and s.count(s[0]) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())
judge = 'Yes'
for s in set(S):
	if S.count(s) != 2:
		judge = 'No'
print(judge)

Submission status: Accepted

Solution code:
s=input()
mydic={}
for i in s:
  if(i in mydic):
    mydic[i]+=1
  else:
    mydic[i]=1
if(len(mydic)==2 and mydic[s[0]]==2):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()

#文字列を1文字ずつリストにする！
moji = list(s)
#リストをそーとする！
moji.sort()

if moji[0] == moji[1]:
    if moji[2] == moji[3]:
        if moji[0] != moji[2]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
# Fifty-Fifty
S = str(input())

count = 1
ans = 0
for i in range(4):
    for j in range(i+1, 4):
        if S[i] == S[j]:
            count = count + 1
            if count == 2:
                count = 1
                ans = ans + 1
            else:
                pass
        else:
            pass
if ans == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

input = input().split()
inputList = list(input[0])
# a = int(input[0])
# b = int(input[1])
# c = int(input[2])

inputList.sort()

flg = 1
for i in range(0, len(inputList)-1, 2):
    if inputList[i] != inputList[i + 1]:
        flg = 0
        break
    if inputList[1] == inputList[2]:
        flg = 0
        break

if flg == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
sc = Counter(s)

a = 'Yes'
for i in sc.keys():
    if sc[i] != 2:
        a = 'No'
        break

print(a)

Submission status: Accepted

Solution code:
import re

def test():
    s = input()
    m = list(set(re.findall(r"[A-Z]",s)))

    if len(m) == 2:
        if s.count(m[0]) == 2 and s.count(m[1]) == 2:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


if __name__ == "__main__":
    test()

Submission status: Accepted

Solution code:
s = input()
s1 = s[:1]
for i in range(1, 4):
  if(s[i:i+1] != s1):
    s2 = s[i:i+1]
if(s.count(s1) == 2 and s.count(s2) == 2):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str):
    isGood = False
    if S[0] == S[1]:
        if S[2] == S[3] and S[0] != S[2]:
            isGood = True
    elif S[0] == S[2]:
        if S[1] == S[3] and S[0] != S[1]:
            isGood = True
    elif S[0] == S[3] and S[0] != S[1]:
        if S[1] == S[2]:
            isGood = True
    else:
        isGood = False
    if isGood:
        print(YES)
    else:
        print(NO)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
A = list(set(S))
if len(A) == 2 and S.count(A[0]) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())

dict = {}

for c in s:
    if(c in dict.keys()):
        dict[c] += 1
    else:
        dict[c] = 1

# print(dict)

result = 'Yes'

if(len(dict) != 2):
    result = 'No'

for v in dict.values():
    if(v != 2):
        result = 'No'

print(result)

Submission status: Accepted

Solution code:
s = str(input())
ans = set(s)
if len(ans) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections
S = input()

c = collections.Counter(S)
values, counts = zip(*c.most_common())

if counts == (2, 2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
str = list(input())  # 1文字区切りでリスト格納

flg = 1
for i in range(4):
    if str.count(str[i]) != 2:
        flg = 0
    
if flg == 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
D = defaultdict(lambda: 0)
 
f=0
for i in range(4):
  D[S[i]] += 1
  if D[S[i]] == 2:
    f +=1
    
if f ==2:
  print ("Yes")
else:
  print ("No")

Submission status: Accepted

Solution code:
S = input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = str(input())
if ((s[0] == s[1] and s[2] == s[3]) or (s[0] == s[2] and s[1] == s[3]) or (s[0] == s[3] and s[1] == s[2])):
    if(s[0] == s[1] == s[2]):
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

ans="No"
if S[0] == S[1] and S[0] != S[2] and S[0] != S[3] and S[2] == S[3]:
  ans = "Yes"
elif S[1] == S[2] and S[1] != S[0] and S[1] != S[3] and S[0] == S[3]:
  ans = "Yes"
elif S[2] == S[3] and S[2] != S[0] and S[2] != S[1] and S[0] == S[1]:
  ans = "Yes"
elif S[3] == S[0] and S[3] != S[1] and S[3] != S[2] and S[1] == S[2]:
  ans = "Yes"
elif S[1] == S[3] and S[1] != S[0] and S[1] != S[2] and S[2] == S[0]:
  ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
s=input()
cnt=set(s)
cnts=len(cnt)
if cnts==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=input()
if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or (S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
chars = []
for i in range(len(S)):
    chars.append(S[i])
if chars.count(chars[0]) == 2:
    for i in range(len(S)):
        if chars.count(chars[i]) != 2:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n=input()
N=sorted(n)
if N[1]==N[2]:
    print('No')
elif N[0]==N[1] and N[2]==N[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
    print('Yes')
elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
chars = sorted(list(S))
if chars[0] == chars[1] and chars[1] != chars[2] and chars[2] == chars[3]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

matched = False
for s in S:
    if S.count(s) != 2:
        matched = True

if matched:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter
fr=Counter(list(input()))
flag=True
if len(fr.keys())==2:
    k=list(fr.values())
    if k[0]==2 and k[1]==2:
        print("Yes")
        flag=False
if flag:print("No")

Submission status: Accepted

Solution code:
S = input()
if S.count(S[0])==2 and S.count(S[1])==2 and S.count(S[2])==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()

h = {}
for c in s:
        if c in h:
                h[c] += 1
        else:
                h[c] = 1

if len(h) == 2 and h[s[0]] == 2:
        print("Yes")
else:
        print("No")

Submission status: Accepted

Solution code:
s = input()
letter = {}
for i in s:
  letter.setdefault(i, 0)
  letter[i] += 1
if list(letter.values()) == [2, 2]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def solve():
    s = input()
    chars = set(s)
    if len(chars) == 2:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(solve())

Submission status: Accepted

Solution code:
S = input()
for i in S:
    if not S.count(i) ==2:
        print ('No')
        break
else:
    print ('Yes')

Submission status: Accepted

Solution code:
S = input()
if len(set(S)) == 2 and S.count(list(set(S))[0]) == 2 and S.count(list(set(S))[1]) == 2:
    print ('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
s1 = S[0]
out = 'No'
s1_list = list(filter(lambda x: x == s1, S))
if len(s1_list) == 2:
    s2_list = list(filter(lambda x: x != s1, S))
    if s2_list[0] == s2_list[1]:
        out = 'Yes'
print(out)

Submission status: Accepted

Solution code:
a,b,c,d=input()
if a==b and c==d and a!=c:
  print("Yes")
elif a==c and b==d and a!=b:
  print("Yes")
elif a==d and b==c and a!=b:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = str(input())
l = list(S)
s = int(len(S))

num = 0
for i in range(s):
    for j in range(i+1, s):
        if l[i] == l[j]:
            num += 1
        else:
            num += 0

if num == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    s = sorted(input())
    if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
S = set(s)
ss = sorted(s)
if len(S) !=2:
  print("No")
else:
  if  ss.count(ss[0]) ==2 and ss.count(ss[2]) ==2:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

Solution code:
#06 ABC132A
from collections import Counter
s=list(input())
c=Counter(s)
x=list(c.values())
print("Yes" if len(c)==2 and x[0]==2 and x[1]==2 else "No")

Submission status: Accepted

Solution code:
S=input()

one=S[0]

for n in S:
    if n!=one:
        two=n

if S.count(one)==2 and S.count(two)==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
S = input()
M = []
for i in range(4):
  M.append(S[i])
M = sorted(M)
if M[0] == M[1]:
  if M[2] == M[3]:
    if M[0] != M[2]:
      print("Yes")
      sys.exit()
print("No")

Submission status: Accepted

Solution code:
S=list(input())

if len(set(S))==2 and len([x for x in S if x==list(set(S))[0]])==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = set(input())

if len(s) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
for v in d.values():
    if v != 2:
        print("No")
        exit()
print("Yes" if len(d) == 2 else "No")

Submission status: Accepted

Solution code:
s = input()
for i in s:
    if s.count(i) != 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
S = input()
D = {chr(i):0 for i in range(65, 65+26)}

f=0
for i in range(4):
  D[S[i]] += 1
  if D[S[i]] == 2:
    f +=1

if f ==2:
  print ("Yes")
else:
  print ("No")

Submission status: Accepted

Solution code:
from collections import Counter

c = Counter(input())
if (len(c) == 2) & (list(c.values()) == [2, 2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
c = Counter(s)
if (len(c) == 2) & (list(c.values()) == [2, 2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
if s[0] == s[1] and s[2] ==s[3] and s[1] !=s[2]:
  print("Yes")
elif s[0] == s[2] and s[1] ==s[3] and s[1] !=s[2]:
  print("Yes")
elif s[0] == s[3] and s[1] ==s[2] and s[1] !=s[0]:
  print("Yes")
else:
  print("No")