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

Solution (Python):
word = input()
list1 = list(word)
list1.sort()
if list1[0]!=list1[1]:
    print("No")
elif list1[2]!=list1[3]:
    print("No")
elif list1[0]==list1[2]:
    print("No")
else:
    print("Yes")

Solution (Python):
s = input()
s = sorted(s)
if s.count(s[0]) == 2 and s.count(s[3]) == 2:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
S = input()
ans = "Yes"
for s in S:
    if S.count(s) != 2:
        ans = "No"
print(ans)

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

Solution (Python):
s = input()

for x in s:
    if s.count(x) != 2:
        print("No")
        exit()

print("Yes")

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

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

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

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

Solution (Python):
s = str(input())
judge = 'No'
for i in range(len(s)):
    if s.count(s[i]) == 2:
        judge = 'Yes'
    else:
        judge = 'No'
        break
print(judge)

Solution (Python):
S = input()
L = sorted(list(S))

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

Solution (Python):
s = sorted(input())

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

Solution (Python):
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')

Solution (Python):
from collections import Counter
S = Counter(input())
for s, n in S.most_common():
    if n != 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
s=input()
if s.count(s[0])==s.count(s[1])==s.count(s[2])==s.count(s[3])==2:
  print("Yes")
else:
  print("No")

Solution (Python):
S = sorted(input())

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

Solution (Python):
from collections import Counter


s = input()
c = Counter(s)
if len(c) == 2 and c.most_common(1)[0][1] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
a=''
b=''
countA,countB = 0,0
aDefined = False
bDefined = False

for char in list(s):
    if char == a :
        countA += 1
    elif char == b:
        countB += 1
    elif not aDefined:
        aDefined = True
        countA += 1
        a = char
    elif not bDefined:
        bDefined = True
        countB += 1
        b = char
    else:
        break
if countA == 2 and countB == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter

s = input()
c = Counter(s)

if all(x == 2 for x in c.values()):
  print("Yes")
else:
  print("No")

Solution (Python):
s = set(input())

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

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

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

Solution (Python):
a,b,c,d = map(str, input())
s = [a,b,c,d]
s = sorted(s)
if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
  print('Yes')
else:
  print('No')

Solution (Python):
s=input()
from collections import Counter
l=[]
for a in Counter(s):
  l.append(a)
if len(l)==2:
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
if S.count(S[0]) == 2 and \
   S.count(S[1]) == 2 and \
   S.count(S[2]) == 2 and \
   S.count(S[3]) == 2 :
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
print("Yes" if s.count(s[0])==2 and s.count(s[1])==2 and s.count(s[2])==2 and s.count(s[3])==2 else "No"   )

Solution (Python):
S = input()
S_list = list(S[i] for i in range(len(S)))

S_list.sort()

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

else:
    print("No")

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

Solution (Python):
S = list(input())
ans = 0
for i in range(3):
    for j in range(i+1,4):
        if S[i] == S[j]:
            ans += 1
if ans == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
sarched = []
flag = True
for i in range(len(S)):
    if S[i] not in sarched:
        sarched.append(S[i])
        if(S.count(S[i])!=2):flag=False
if flag:print("Yes")
else:print("No")

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

Solution (Python):


s = input()

lis = list(s)
if len(set(lis)) == 2:
    if lis.count(lis[0]) == 2:
        print("Yes")
else:
    print("No")

Solution (Python):
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')

Solution (Python):
S = list(input())
print("Yes" if len(set(S)) == 2 and len(list(filter(lambda x: x == S[0], S))) == 2 else "No")

Solution (Python):
S = list(input())
print("Yes" if len(set(S)) == 2 and len(list(filter(lambda x: x == S[0], S))) == 2 else "No")

Solution (Python):
S = str(input())
count=0
for i in range(len(S)-1):
  for j in range(i+1,len(S)):
    if S[i] == S[j]:
      count+=1
if count==2:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()

LS = list(S)
SLS = sorted(LS)
SS = set(LS)

if len(SS) == 2 and SLS[0] == SLS[1] and SLS[2] == SLS[3]:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()

s = sorted(list(S))

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

Solution (Python):
S=sorted(input())
print("Yes" if S.count(S[0])==2 and S.count(S[2])==2 else "No")

Solution (Python):
from collections import Counter as cc
x = cc(input())
if len(x) != 2:
  print("No")
else:
  found = True
  for i in x.keys():
    if x[i] != 2:
      found = False
  if found:
    print("Yes")
  else:
    print("No")

Solution (Python):
S = sorted(input())

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

Solution (Python):
s = input()
s = sorted(s)
cnt = 0
for i in range(4 - 1) :
  if s[i] != s[i + 1] :
    cnt += 1
if cnt == 1 :
  print("Yes")
else :
  print("No")

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

Solution (Python):
import collections

S = str(input())
c = collections.Counter(S)

if all([x==2 for x in c.values()]):
    print("Yes")
else:
    print("No")

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

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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")

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

Solution (Python):
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')

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

Solution (Python):
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")

Solution (Python):
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')

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

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

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

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

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

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

Solution (Python):
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')

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

Solution (Python):

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

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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")

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

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

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

Solution (Python):
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")

Solution (Python):
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")

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

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
print('YNeos'[len(set(input()))!=2::2])

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

Solution (Python):
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')

Solution (Python):
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)

Solution (Python):

 
s = str(input())
string  = list(s)
string_unique = list(set(string))
 

 
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")

Solution (Python):
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")

Solution (Python):
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())

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

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

Solution (Python):

s = input()


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')

Solution (Python):

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")

Solution (Python):

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")

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

Solution (Python):
S = list(input())

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

Solution (Python):
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")

Solution (Python):
S = sorted(input())

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

Solution (Python):
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])

Solution (Python):
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')

Solution (Python):
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")

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

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

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

Solution (Python):
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")

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

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

Solution (Python):
S=input()

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

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

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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)

Solution (Python):
import collections

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

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

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

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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")

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

Solution (Python):
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")

Solution (Python):



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)

Solution (Python):
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")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

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



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

if __name__ == '__main__':
    main()

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

Solution (Python):
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)

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

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

print ('Yes')

Solution (Python):
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')

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

Solution (Python):
print("Yes" if len(set(input())) == 2 else "No")

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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")

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

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

Solution (Python):



S = input()

ss = sorted(S)



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

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
s=list(input())  

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

Solution (Python):
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)

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):

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')

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

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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")

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

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

Solution (Python):
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")

Solution (Python):
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')

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

Solution (Python):

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')

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

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

Solution (Python):
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")

Solution (Python):
s = input()


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')

Solution (Python):

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")

Solution (Python):

input = input().split()
inputList = list(input[0])




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")

Solution (Python):
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)

Solution (Python):
print("Yes" if len(set(input()))==2 else "No")

Solution (Python):
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()

Solution (Python):
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")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

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)  
    solve(S)

if __name__ == '__main__':
    main()

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

Solution (Python):
s = list(input())

dict = {}

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



result = 'Yes'

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

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

print(result)

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

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

Solution (Python):
import collections
S = input()

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

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

Solution (Python):
str = list(input())  

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

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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)

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

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
S = input()

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

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

Solution (Python):
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")

Solution (Python):
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')