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):
ss = input()
set_ss = set(ss)
if len(set_ss) != 2 :
  print("No")
else:
  for s in set(ss):
    if ss.count(s) != 2:
      print("No")
      break
  else:
    print("Yes")

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Solution (Python):
S = input()

d = {}
for s in S:
  if s in d:
    d[s] += 1
  else:
    d[s] = 1

if list(d.values()) == [2, 2]:
  ans = 'Yes'
else:
  ans = 'No'

print(ans)

Solution (Python):
import sys

li=list(input())
a=[0,0,0,0]
for i in range(4):
    a[i]=li.count(li[i]);
    if a[i]==2:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):
from sys import stdin

str = stdin.readline().rstrip()

if len(set(list(str))) == 2:
  print('Yes')
else:
  print('No')

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

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

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

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


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

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

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

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

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

if (S[0:2] == S[2:4] and S[1] != S[2]) or (S[0:2] == ''.join(list(reversed(S[2:4]))) and S[0] != S[2]):
    print('Yes')
elif S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()

if len(set(s)) != 2:
    print("No")
else:
    for i in set(s):
        if s.count(i) != 2:
            print("No")
            break
        else:
            print("Yes")
            break

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()
dic = {}
flg = True

for i in range(4):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
        
for k, v in dic.items():
    if v == 2:
        pass
    else:
        flg = False

if flg == True:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
S = list(s[i] for i in range(4))
set_S = list(set(S))

if len(set_S) == 2:
  if S.count(set_S[0]) == 2 and S.count(set_S[1]) == 2:
    print('Yes')
  else:
    print('No')
else:
  print('No')

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

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

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

data = {}
for s in S:
    if s in data:
        data[s] = data.get(s)+1
    else:
        data[s] = 1

if (len(data) == 2) and (data.get(S[0]) == 2):
    print('Yes')
else:
    print('No')

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

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

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

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

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

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

Solution (Python):
S = input()

if S.count(S[0]) != 2:
    print("No")
    exit()

else:
    S = S.strip(S[0])

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

else:
    print("No")

Solution (Python):
s = list( str( input() ) )
check = [ x == s[0] for x in s ]
if len( set(s) ) == 2 and sum( check ) == 2 :
   print( "Yes" )
else : 
   print( "No" )

Solution (Python):
list_S = list(str(input()))
cnt = 0
for i in range(4):
    if list_S[i] == list_S[1]:
        cnt += 1
if cnt == 2 and len(set(list_S)) == 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=set(S)
if len(a)==2:
  if S[0]==S[1] and S[2]==S[3]:
    print('Yes')
    exit()
  if S[0]==S[2] and S[1]==S[3]:
    print('Yes')
    exit()
  if S[0]==S[3] and S[2]==S[1]:
    print('Yes')
    exit()

print('No')

Solution (Python):
s=[i for i in input()]
a=s[0]
for i in range(3):
    if s[i]!=a:
        b=s[i]
        break
             
print("Yes" if s.count(a)==2 and s.count(b)==2 else "No")

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

Solution (Python):
s=[i for i in input()]
dic={}
for i in range(4):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
flg=True        
for k,v in dic.items():
    if v != 2:
	    flg=False
print("Yes" if flg else "No")

Solution (Python):
from collections import Counter

S = input()
counter = Counter(S)

if len(counter) != 2:
    print('No')
else :    
    flag = True
    for k, v in counter.items():
        if v != 2:
            flag = False

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

Solution (Python):
from collections import Counter

S = input()
counter = Counter(S)

v = list(counter.values())
if v[0] == 2 and v[1] == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = str(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()
t = sorted(s)
if t[0] == t[1] and t[2] == t[3] and t[0] != t[2]:
    print("Yes")
else:
    print("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]:
  print('Yes')
elif S[0] == S[2] and S[1] == S[3]:
  print('Yes')
elif S[0] == S[3] and S[1] == S[2]:
  print('Yes')
else:
  print('No')

Solution (Python):
a = list(input())
a.sort()

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

else:
    print("No")

Solution (Python):
n=list(input())
n.sort()
if n[0]==n[1] and n[2]==n[3] and n[0]!=n[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 = set(input())
if len(s) == 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]:
    ans = "Yes"
else:
    ans = "No"

print(ans)

Solution (Python):
S = input()
S = sorted(S)
print("Yes" if S[0] == S[1] != S[2] == S[3] else "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()
S = sorted(S)
print("Yes" if S[0] == S[1] != S[2] == S[3] else "No")

Solution (Python):
a = input()
if len(set(a))==2 and list(a).count(list(set(a))[0])==2:
  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()
wk1 = (S[0]==S[1]) and (S[2]==S[3]) and (S[0]!=S[2])
wk2 = (S[0]==S[3]) and (S[1]==S[2]) and (S[0]!=S[1])
wk3 = (S[0]==S[2]) and (S[1]==S[3]) and (S[0]!=S[1])
if wk1 or wk2 or wk3:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):

import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

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




if __name__ == '__main__':
    main()

Solution (Python):

import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

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




if __name__ == '__main__':
    main()

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

slist.sort()

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

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

Solution (Python):
A=list(map(str,input()))

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

Solution (Python):
import sys
string = input()

ch_1 = ""
ch_2 = ""
ct_1 = 0
ct_2 = 0
for ch in string:
  
  if ch_1 != ch and ch_2 != ch and ch_1 is not "" and ch_2 is not "":
    print("No")
    sys.exit(0)
  if ch_1 != ch:
    if ch_1 == "":
      ch_1 = ch
    else:
      ch_2 = ch

  if ch_1 == ch:
    ct_1 += 1
  elif ch_2 == ch:
    ct_2 += 1


if ct_1 == 2 and ct_2 == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
T = sorted(S)
if (T[0] == T[1]) and (T[2] == T[3]) and (T[1] != T[2]):
    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):
l=sorted(list(input()))
if l[0] == l[1] and l[2]==l[3] and not l[0] ==l[3]:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

if len(set(S)) != 2:
    print("No")
else:
    if S.count(list(set(S))[0]) == 2:
        print("Yes")
    else:
        print("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):
S = input()
st = list(map(str, S))
o = st[0]
st.remove(o)
if o not in st:
    print("No")
else:
    st.remove(o)
    t = st[0]
    st.remove(t)
    if o in st or o == t:
        print("No")
    elif t in st:
        print("Yes")
    else:
        print("No")

Solution (Python):
s = input()

ss = sorted(s)
if ss[0] == ss[1] and ss[2] == ss[3] and ss[0] != ss[2]:
    print("Yes")
    exit()

print("No")

Solution (Python):
s=input()
print(["No","Yes"][all(s.count(s[i])==2 for i in range(4))])

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

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

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

Solution (Python):

s = list(str(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 = ''.join(sorted(input()))
if(s[0]==s[1] and s[2] == s[3] and s[1] != s[3]):
  print("Yes")
else:
  print("No")

Solution (Python):
import collections
s=collections.Counter(input())
if len(s)==2 and s[0]==s[1]:
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = list(input())
ans = "Yes"
for char in S:
    if S.count(char) != 2:
        ans = "No"
        break

print(ans)

Solution (Python):
S = input()
d = {}

for c in S:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1

v = list(d.values())

ans = "Yes" if len(d) == 2 and v[0] == v[1] else "No" 
print(ans)

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

Solution (Python):
import collections
S = input()
S2 = collections.Counter(S)
c = True
for i,v in S2.items():
  if v == 2:
    continue
  else:
    c = False
if c:
  print('Yes')
else:
  print('No')

Solution (Python):
S = list(str(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()
if len(set(S)) == 2 and S.count(S[0]) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
a=[]
b=[]
for i in s:
    a.append(i)

for j in a:
    if j not in b:
        b.append(j)

c=[]
for k in b:
    c.append(a.count(k))

if c.count(2)>=2:
    print("Yes")
else:
    print("No")

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

else:
  print('No')

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

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

Solution (Python):
import sys
import math

MOD = 10 ** 9 + 7


def main():
    S = input()
    dic = {}

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

    if len(dic.keys()) == 2 and len([i for i in dic.values() if i == 2]):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
import collections
s = list(i for i in str(input()))

c_list = collections.Counter(s).most_common()
if len(c_list) == 2 and c_list[0][1] == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
a, b, c, d = input()
if (a == b and c ==d and a != c) or (a == c and b == d and a != b) or (a == d and b == c and a != b):
  print('Yes')
else:
  print('No')

Solution (Python):

import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = list(input()[:-1])
s.sort()
print('YNeos'[s.count(s[0]) != 2 or s.count(s[2]) != 2::2])

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

Solution (Python):
s = input()
for i in range(len(s)):
    cnt=0
    for j in range(len(s)):
        if s[i] == s[j]:
            cnt+= 1
    if cnt != 2:
        print("No")
        exit(0)
print("Yes")

Solution (Python):
S = input()

appearence = {}

for char in S:
    if char not in appearence:
        appearence[char] = 1
    else:
        appearence[char] += 1

if len(appearence) == 2 and all(2 == value for value in appearence.values()):
    print('Yes')
else:
    print('No')

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

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

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

s = collections.Counter(S)

ans = 4
for key in s.keys():
   ans = ans //2

if ans == 1 and len(s) == 2:
  print("Yes")
else:
  print("No")

Solution (Python):

import sys

S = input()
S = list(S)

first_S = S.pop()
for i in range(len(S)):
    if S[i] == first_S:
        S.remove(first_S)
        break
else:
    print('No')
    sys.exit()

second_S = S.pop()
for i in range(len(S)):
    if S[i] == second_S:
        break
else:
    print('No')
    sys.exit()

if first_S == second_S:
    print('No')
else:
    print('Yes')

Solution (Python):

d = {}
for s in input():
    if s not in d.keys():
        d[s] = 1
    else:
        d[s] += 1

if list(d.values()) == [2,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()
for i in range(4):
  if s.count(s[i])!=2:
    print('No')
    exit()
print('Yes')

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 = raw_input()
arr = []

for i in range(4):
     if S[i] not in arr:
         arr.append(S[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if S[i] == arr[0]:
            a = a + 1
        elif S[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print"Yes"
    else:
        print "No"

Solution (Python):
s= raw_input()
arr=[]
for i in range(4):
    if s[i] not in arr:
        arr.append(s[i])
if len(arr)!=2:
    print "No"
else:
    a=0
    b=0
    for i in range(4):
        if s[i]== arr[0]:
            a = a+1
        elif s[i]==arr[1]:
            b=b+1
    if a == 2 and b==2:
        print "Yes"
    else:
        print "No"

Solution (Python):


S = raw_input()
arr = []
for i in range(4):
    if S[i] not in arr:
        arr.append(S[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if S[i] == arr[0]:
            a = a + 1
        elif S[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print "Yes"
    else:
        print "No"

Solution (Python):


s = raw_input()
arr = []
for i in range(4):
    if s[i] not in arr:
        arr.append(s[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if s[i] == arr[0]:
            a = a + 1
        elif s[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print "Yes"
    else:
        print "No"

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

Solution (Python):





S = list(input())
count = [0, 0, 0]

for i in range(len(S)-1):
    for j in range(i+1, len(S)):
        if S[i] == S[j]:
            count[i] += 1

       



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

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

import math
import datetime





S = str(input())

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

Solution (Python):
set = {i for i in input()}

if len(set) == 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=str(input())
l=list(s)
l.sort()
if(l[0]==l[1] and l[2]==l[3] and l[0]!=l[2]):
  print ("Yes")
else:
  print("No")

Solution (Python):
s = input()

dic = {}

for i in s:
    if i not in dic:
        dic[i] = 1
    else:
        dic[i] += 1

flag = [dic[i] == 2 for i in dic.keys()]

print("Yes" if all(flag) else "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())
print("Yes" if len(set(s))==2 and s.count(s[0])==2 else "No")

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

Solution (Python):
s = input()
flag = 0

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2] :
    flag = 1

elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1] :
    flag = 1


elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1] :
    flag = 1


if(flag == 1):
    print('Yes')
else:
    print('No')

Solution (Python):

S = raw_input()

if len(S) != 4:
    print "No"
else:
    Dict = {}
    for s in S:
        if s in Dict.keys():
            Dict[s] += 1
        else:
            Dict[s] = 1
    if all([i==2 for i in Dict.values()]):
        print "Yes"
    else:
        print "No"

Solution (Python):
S=input()
ss=set(S)
if len(ss)!=2:
  print('No')
else:
  cnt=0
  for i in S:
    if i == S[0]:
      cnt+=1
  if len(S)==cnt*2:
    print('Yes')
  else:
    print('No')

Solution (Python):

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

Solution (Python):
a = dict()
b = list(input())
s1 = "random"
s2 = "random"
x = 0
y = 0
for i in b:
    if i == s1:
        x += 1
    elif i == s2:
        y += 1
    else:
        if s1 == "random":
            s1 = i
            x += 1
        elif s2 == "random":
            s2 = i
            y += 1
if x == 2 and y == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
for i in range(4):
  if s.count(s[i])!=2:
    print('No')
    exit()
print('Yes')

Solution (Python):
s=input()
sums=0
for i in range(4):
  if s[i]==s[0]:sums+=1
print('Yes' if sums==2 and len(set(s))==2 else 'No')

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

if s[0]==s[1]:
    c+=1
if s[0]==s[2]:
    c+=1
if s[0]==s[3]:
    c+=1
if s[1]==s[2]:
    c+=1
if s[1]==s[3]:
    c+=1
if s[2]==s[3]:
    c+=1

if c == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
letter = input()
word = []
for i in range(len(letter)):
  word.append(letter[i])
word.sort()
if (word[0] == word[1]) and (word[2] == word[3]) and (word[0] != word[2]):
  print('Yes')
else:
  print('No')

Solution (Python):
s = input()
f = 1 
if s[0] == s[1] == s[2] == s[3]:
        f = 1 
elif (s[0] == s[1] and s[2] == s[3]) or (s[:2] == s[2:] or s[1::-1] == s[2:]):
        f = 0 
print('YNeos'[f::2])

Solution (Python):
S = str(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):
import math
import heapq
import sys
from collections import Counter
import numpy as np





s=input()

S=sorted(s)

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

Solution (Python):
s = input()
hash = {}
for char in s:
  
  if char in hash.keys():
    hash[char] += 1
  else:
    hash[char] = 1

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

Solution (Python):
S = input()

if len(set(S)) == 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 = 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):
S = input()
buf = 0
for i in range(len(S)) :
    for j in range(i+1,len(S)) :
        if S[i] == S[j] :
            buf += 1
 
if buf == 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):

def main():
    S = input()
    num = {}
    for i in S:
        if i not in num:
            num[i] = 1
        else:
            num[i] += 1

    if(len(num) == 2):
        for i in num.keys():
            if num[i] != 2:
                print("No")
                return 0
            print("Yes")
            return
    else:
        print("No")

main()

Solution (Python):
import collections
S = input()
c = collections.Counter(list(S))
print("Yes" if len(c) == 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 = input()
out = "No"
if S[0] == S[1]:
    if S[2] == S[3] and S[1] != S[2]:
        out = "Yes"
elif S[0] == S[2]:
    if S[1] == S[3] and S[1] != S[2]:
        out = "Yes"
elif S[0] == S[3]:
    if S[1] == S[2] and S[1] != S[0]:
        out = "Yes"
print(out)

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()
ss = set(S)
ss_list = list(ss)

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

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

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

Solution (Python):
a=input()
dic={}
for i in range(len(a)):
  if a[i] in dic:
    dic[a[i]]+=1
  else:
    dic[a[i]]=1
if len(dic)==2:
  my=True
  for i in dic.values():
    if i!=2:
      my=False
  if my:
    print("Yes")
    exit()
print("No")

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

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

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

Solution (Python):
s = input()
s_sort = ''.join(sorted(s))
s1 = s[0]
s1cnt = s_sort.count(s1)
if s1cnt == 2:
    s2 = s[2]
    s2cnt = s_sort.count(s2)
    if s2cnt == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

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

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

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

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

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

Solution (Python):
import sys
input = sys.stdin.readline
def print_ans(S):
    """Test Case
    >>> print_ans("ASSA")
    Yes
    >>> print_ans("STOP")
    No
    >>> print_ans("FFEE")
    Yes
    """
    ans_arr = []
    ans_arr.append(S[0])


    for s_ch in S[1:]:
        for a_ch in ans_arr:
            if s_ch != a_ch:
                ans_arr.append(s_ch)
    if len(set(ans_arr)) == 2:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)

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):
a = list(input())
a.sort()
if a[0]==a[1] and a[2]==a[3] and a[1]!=a[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

S = input()
ct = Counter(S)
if len(ct) == 2 and ct[S[0]] == 2:
    print('Yes')
else: print('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):

import sys
import collections









def main():
    s = sys.stdin.readline().rstrip()
    for v in collections.Counter(s).values():
        if v == 2:
            continue
        else:
            ans = 'No'
            break
    else:
        ans = 'Yes'

    print(ans)

if __name__ == "__main__":
    main()

Solution (Python):
s = input()

count1 = s.count(s[0])
count2 = s.count(s[1])
count3 = s.count(s[2])
count4 = s.count(s[3])

if count1 == 2 and count2 == 2 and count3 == 2 and count4 == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
import collections
S=list(input())
c=collections.Counter(S)
if len(c)==2:
  if c[S[0]]==2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
s=input()
u = set()
for let in s:
  u.add(let)
count=0
for let in s:
  if s[0] == let:
    count += 1
if count ==2 and len(u)==2:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import Counter

S = input()

cnt_dict = Counter(S)

if len(cnt_dict) == 2 and cnt_dict[S[0]] == 2:print('Yes')
else: print('No')

Solution (Python):
S = input()

sum_1 = 0
sum_2 = 0
sum_3 = 0
sum_4 = 0

for i in range(4):
    if S[0] == S[i]:
        sum_1 += 1
    if S[1] == S[i]:
        sum_2 += 1
    if S[2] == S[i]:
        sum_3 += 1
    if S[3] == S[i]:
        sum_4 += 1
    
if sum_1 == sum_2 == sum_3 == sum_4 == 2:
    print('Yes')
else:
    print('No')