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

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

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

Solution (Python):


s = input()

x = {}
for i in s:
    if i in x:
        x[i] += 1
    else:
        x[i] = 1
        
if len(x) == 2:
    a, b = x
    if x[a] == 2 and x[b] == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

Solution (Python):
S = input()

a = S[0]
b = None
acount = 0

for i in range(4):
    if a == S[i]:
        acount += 1
    else:
        b = S[i]
        
bcount = 0
for i in range(4):
    if b == S[i]:
        bcount += 1
if acount == 2 and bcount ==2:
    print('Yes')
else:
    print('No')

Solution (Python):
s=input()
d={}
for c in s:
  if c not in d: d[c]=1
  else: d[c]+=1
print('Yes') if len(d.keys())==2 and [_ for _ in d.values()][0]==2 else print('No')

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

Solution (Python):

A=input()

A=sorted(A)

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

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

for i in s:
    if not d.get(i):
        d[i] = True

print("Yes" if len(d)==2 else "No")

Solution (Python):
S = 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):
def func():
    input_line = list(str(input('')))
    flag = 0
    for i in range(len(input_line)):
        for j in range(i+1,len(input_line)):
            if input_line[i] == input_line[j]:
                flag += 1
    if flag == 2:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    func()

Solution (Python):
def check(s):
    try:
        if s.count(s[0]) == 4:
            return False

        s1 = s[0]
        s.remove(s1)
        s.remove(s1)

        s1 = s[0]
        s.remove(s1)
        s.remove(s1)
    except ValueError:
        return False
    else:
        return True

s = list(input())
if check(s):
    print("Yes")
else:
    print("No")

Solution (Python):
def mozi(S):
    s = list(S)
    s2 = list(set(s))
    if len(s2) != 2:
        ans = 'No'
        return ans
    else:
        p = 0
        q = 0
        for item in s:
            if item == s2[0]:
                p+=1
            if item == s2[1]:
                q+=1
        if p == 2 and q == 2:
            ans = 'Yes'
            return ans
        else:
            ans = 'No'
            return ans



S = input()
print(mozi(S))

Solution (Python):
from collections import Counter
SC = Counter(input().strip())
if len(SC) == 2 and max(SC.values()) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
def solve(string):
    for _s in string:
        if string.count(_s) != 2:
            return "No"
    return "Yes"


if __name__ == '__main__':
    print(solve(input()))

Solution (Python):
S = input()
Slist=[]
for i in range(4):
    Slist.append(S[i])
Slist.sort()

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

Solution (Python):
S = input()


list_S=list(S)

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

Solution (Python):
S = input()

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

Solution (Python):
line = input()
charKind = [line[0]]
for c in line:
  if charKind[len(charKind)-1] != c and not c in charKind:
    charKind.append(c)

if len(charKind) > 2:
    print("No")
    quit()
charNum = [0 for i in range(len(charKind))]
for idx,c in enumerate(charKind):
    for cc in line:
        if cc == c:
            charNum[idx] += 1
if charNum[0] == 2 and charNum[1] == 2:
    print("Yes")
else:
    print("No")
quit()

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

Solution (Python):
s = input()

if s.count(s[0]) != 2:
    p = "No"
elif s.count(s[1]) != 2:
    p = "No"
elif s.count(s[2]) != 2:
    p = "No"
elif s.count(s[3]) != 2:
    p = "No"
else:
    p = "Yes"
print(p)

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

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
s = input()

for k in s:
  d[k] += 1


f = False
for v in d.values():
  if v == 2:
    f = True
    break
print('Yes' if len(d)==2 and f==True else 'No')

Solution (Python):
from collections import defaultdict

S = input().rstrip()

char_dict = defaultdict(int)
for char in S:
    char_dict[char] += 1

kind = len(char_dict.keys())
val_set = set(char_dict.values())

if kind == 2 and val_set == {2}:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections

letters=input()
letter=[]
for i in range(len(letters)):
  letter.append(letters[i])
counter=collections.Counter(letter)

if len(counter.keys())==2 and len(counter.values())==2:
  print ("Yes")
else: print ("No")

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

chars = {}

for char in stc:
    if char in chars:
        chars[char] += 1
    else:
        chars[char] = 1

if len(chars) == 2:
    for num in chars.values():
        if num != 2:
            print('No')
            exit()

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

Solution (Python):
S = input()
s = []
for i in range(len(S)):
    if S[0] != S[i]:
        s.append(S[i])
if len(s) == 2:
    if s[0] == s[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
from collections import Counter
a = Counter(input())
print('Yes' if len(a) == 2 else 'No')

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

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

Solution (Python):
import sys
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

s = list(ns())
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 = list(input())
Ss = set(S)
count2 = 0
for alp in Ss:
    if S.count(alp) == 2:
        count2 += 1
if count2 == len(Ss):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
a = list(str(input()))
b = set(a)

for i in b:
    c = a.count(i)
    if c != 2:
        print('No')
        sys.exit()

print('Yes')

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()
k = set(s)
r = []
for i in k:
  r.append(s.count(i))

if len(k) == 2 and max(r) == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
A=list(input())
if A.count(A[0])==2:
  if A[1]==A[2] or A[2]==A[3] or A[3]==A[1]:
    print("Yes")
    exit()
print("No")

Solution (Python):
S = input()
cnt = {}
for c in S:
    if c in cnt:
        cnt[c] += 1
    else:
        cnt[c] = 1

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

Solution (Python):
import collections
S = input()
c = collections.Counter(list(S))
kind_flag = len(c) == 2
if kind_flag:
    ll = list(c.values())
    flag = ll[0] == ll[1] == 2
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
from sys import exit
s=input()
for l in s:
    if s.count(l)!=2:
        print("No")
        exit()
print("Yes")

Solution (Python):
x = input()
v ={ val for val in x }
if len(v) == 2:
    print("Yes")
else :
    print("No")

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

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

Solution (Python):
s = input() 
index = -1
cnt=0
for char in s:
    target = char
    
    while True:
        index = s.find(target, index + 1)
        if index == -1:
            break
        
        cnt=cnt+1

if(cnt==8):
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

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

Solution (Python):


a = list(input())
dic = {}
for x in a:
    dic.setdefault(x, 0)
    dic[x] += 1
if (len(dic) == 2):
    if(dic[a[0]]==2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
S=input()
 
import collections
c = collections.Counter(S).most_common()
if len(c) == 2 and c[0][1] == c[1][1]:
  print('Yes')
else:
  print('No')

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

Solution (Python):
s = list(input())
count = int(0)
for i in s:
    for j in s:
        if(i==j):
            count += 1
if(count == 8):
    print("Yes")
else:
    print("No")

Solution (Python):
import collections

S = list(input())
c = collections.Counter(S)
if len(c.most_common()) == 2 and c.most_common()[0][1] == 2:
  print('Yes')
else:
  print('No')

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

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

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

dic = {}

for i in data:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1

if len(dic.keys()) == 2:
    if dic[data[0]] == 2:
        print("Yes")
        exit()

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 = list(input())
ans = []
count_ = []
for i in range(4):
	if S[i] not in ans:
		ans.append(S[i])
		count_.append(1)
	else:
		count_[ans.index(S[i])] += 1

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

Solution (Python):
import collections

s = input()

c = collections.Counter(list(s))

res = "Yes" if all([v==2  for v in c.values()]) and len(c)==2 else "No"

print(res)

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

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

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

Solution (Python):
s=input()
if len(set(s))==2 and s.count(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):
s = sorted(input(),key=str)
print(["No", "Yes"][s.count(s[0]) == 2 and s[2] == s[3]])

Solution (Python):
def solve():
  s = input()
  istwo = True
  array = [s[0],s[1],s[2],s[3]]
  array.sort()
  if array[0] != array[1]:
    istwo = False
  if array[1] == array[2]:
    istwo = False
  if array[2] != array[3]:
    istwo = False
  if istwo:
    print("Yes")
  else:
    print("No")
  
  
solve()

Solution (Python):
input_data=input()
 
a=input_data[0]
b=input_data[1]
c=input_data[2]
d=input_data[3]
 
if a==b :
    if c==d and a!=c :
            output="Yes"
    else :
        output="No"
    
else :
        if a==c and b==d :
            output="Yes"
    
        elif a==d and b==c :
            output="Yes"
        
        else :
            output="No"
           
print(output)

Solution (Python):



s = input()

print("No" if False in [2 == s.count(i) for i in s] else "Yes")

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

Solution (Python):
s=input()
kind=[]
kind.append([s[0],1]) 
for i in range(1,4): 
    l=len(kind)
    a=0
    for j in range(l):
        if s[i] == kind[j][0]:
            a=1
            match=j
            break
    if a==0: 
        kind.append([s[i],1])
    else:
        kind[match][1]+=1
        
    
if kind[0][1]==2 and kind[1][1]==2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = input()
ans = True
for s in S:
  ans = ans * (S.count(s) == 2)
if ans:
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
print(['No', 'Yes'][all([S.count(s) == 2 for s in S])])

Solution (Python):
s = input()

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

for k, v in d.items():
    if v != 2:
        print('No')
        exit()

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

Solution (Python):
S = input()
l = [ c for c in 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()
l={x for x in s}
if s.count(l.pop())==2 and s.count(l.pop())==2:
  print('Yes')
else:
  print('No')

Solution (Python):
s=input()
a=s[0]
if s.count(a)==2:
    s2=s.strip(a)
    b=s2[0]
    if s2.count(b)==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
s = input()
n = 4
i = 0
d = {}
while(i<n):
    if s[i] in d.keys():
        d[s[i]] +=1
    else:
        d.setdefault(s[i], 1)
    i += 1
print("Yes" if len(d)==2 and max(d.values())==2 else "No")

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

Solution (Python):
S = input()

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

Solution (Python):
def main():
  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')
    
if __name__ == "__main__":
  main()

Solution (Python):
s=input()
l=[s[0],s[1],s[2],s[3]]
l.sort()
if l[0]==l[1] and l[2]==l[3] and l[1]!=l[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):
S = input()

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

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

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

Solution (Python):
hoge=input()
ans=0
for i in range(4):
  ans+=hoge.count(hoge[i])
if(ans==8):
  print("Yes")
else:
  print("No")

Solution (Python):
s=list(input())
s.sort()
print("YNeos"[not s[0]==s[1]!=s[2]==s[3]::2])

Solution (Python):


s=list(raw_input())
s.sort()
if s[0]==s[1] and s[2]==s[3] and not s[0]==s[2]:
 print 'Yes'
else:
 print 'No'

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

Solution (Python):
from collections import defaultdict

S = input()
appear = list(S)

d = defaultdict(int)

for i in appear:
    d[i] += 1

a = list(d.values())

if len(d.items()) == 2:
    for i in a:
        if i != 2:
            print("No")
    print("Yes")

else:
    print("No")

Solution (Python):
S = input()
S = sorted(S,key=str)
if S.count(S[0]) == 2 and S[2] == S[3]:
    print("Yes")
    exit()
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):
from collections import Counter
word = input()

counter = Counter(word)
status = "Yes"
if len(counter) !=  2:
  status = "No"
for c in counter.values():
  if c != 2:
    status = "No"
print(status)

Solution (Python):
import collections as c;s=input();a=c.Counter(s);print('Yes' if str(a.values())=='dict_values([2, 2])' 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())
s.sort()
print('Yes') if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2] else print('No')

Solution (Python):
S=input()
d=dict()

for s in S:
    d[s]=d.get(s,0)+1

boolean=True
if len(d.values())==2:
    for i in d.values():
        if i!=2:
            boolean=False
            break
        else:
            continue
else:
    boolean=False

if boolean:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
s=s.replace(s[0],'')
print('Yes' if len(s)==2 and s[0]==s[1] else '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[1]!=S[2] and S[1]==S[3]:
    print('Yes')
elif S[0]==S[3] and S[1]!=S[3] and S[1]==S[2]:
    print('Yes')
else:
    print('No')

Solution (Python):
char=list(input())
d={}
for c in char:
	if c not in d:
		d[c] = 0
	d[c] += 1
if 2 in d.values() and len(d)==2:
	print('Yes')
else:
	print('No')

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

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

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

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

for c in set(S):
	if 2 != S.count(c):
		print("No")
		exit()
print("Yes")

Solution (Python):
S = input()

if 2 != len(set(S)):
	print("No")
	exit()

for c in set(S):
	if 2 != S.count(c):
		print("No")
		exit()
print("Yes")

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

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

Solution (Python):
from collections import Counter

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

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

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

Solution (Python):
import collections
s=input()
slist=[c for c in s]
col = collections.Counter(slist)

for key,v in col.items():
    if v!=2:
        print('No')
        exit()
print('Yes')

Solution (Python):
from collections import Counter

S = input()
c = Counter()
for s_i in S:
  c[s_i] += 1
for k,v in c.items():
  if v!=2:
    print("No")
    exit()
print("Yes")

Solution (Python):
def f_f(str):
    for s in str:
        if str.count(s) != 2:
            return False
    return True
 
S = input()
if f_f(S):
    print("Yes")
else:
    print("No")

Solution (Python):
x = input()
 
def Combination(x):
  if x[0] == x[1] and x[2] == x[3] and x[0] != x[2]:
      return "Yes"
  elif x[0] == x[2] and x[1] == x[3] and x[0] != x[1]:
      return "Yes"
  elif x[0] == x[3] and x[1] == x[2] and x[0] != x[2]:
      return "Yes"
  else:
    return "No"
print(Combination(x))

Solution (Python):
S = list(input())
S_unique = list(set(S))
ans = True
if len(S_unique) != 2:
    ans = False
elif S.count(S_unique[0]) != 2:
    ans = False
if ans:
    print("Yes")
else:
    print("No")

Solution (Python):
def fifty_fifty(str):
    for s in S:
        if S.count(s) != 2:
            return False
    return True


S = input()
if fifty_fifty(S):
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()

r = "No"
S_unique = list(set(S))
if len(S_unique) == 2:
    T = S[1] + S[2] + S[3]
    T_unique = list(set(T))
    if len(T_unique) == 2:
        T = S[0] + S[2] + S[3]
        T_unique = list(set(T))
        if len(T_unique) == 2:
            T = S[0] + S[1] + S[3]
            T_unique = list(set(T))
            if len(T_unique) == 2:
                T = S[0] + S[1] + S[2]
                T_unique = list(set(T))
                if len(T_unique) == 2:
                    r = "Yes"
print(r)

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

inin = list(set(inp))

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

Solution (Python):
w = input()
a,b,c,d = w[0],w[1],w[2],w[3]
if a == b and b != c and c == d:
    print('Yes')
elif a == c and b != c and b == d:
    print('Yes')
elif a == d and b == c and a != b:
    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()
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()
s_set = set(s)
if len(s_set) == 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]:
    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 = list(input())

tmp = []
kind = 0
flag = True
for i in range(len(S)):
    if (S[i] in tmp) == False:
        tmp.append(S[i])
        kind += 1
        if S.count(S[i]) != 2:
            flag = False

if (kind == 2) and (flag == True):
    print("Yes")
else:
    print("No")

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

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

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

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

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

Solution (Python):
def consunt():
    if input_.count(input_str_arr[0]) and input_.count(input_str_arr[1]):
      print("Yes")
    else:
      print("No")

input_ = input()

input_str = set(input_)

input_str_arr = [s for s in input_str]

if len(set(input_str_arr))==2:
    consunt()
else:
    print("No")

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

if len(set(S)) != 2:
    print('No')
elif S.count(S[0]) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
a = list(input())
if len(set(a)) == 2:
  count = 0
  for r in set(a):
    if a.count(r) == 2:
      count += 1
  if count == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
from collections import defaultdict
import sys
S=raw_input()
F=defaultdict(int)
for c in S: F[c]+=1
for k,v in F.iteritems():
    if v!=2:
        print("No")
        sys.exit(0)
print("Yes")

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

Solution (Python):
S=input()

from collections import Counter

c=Counter([S[0],S[1],S[2],S[3]])

if len(list(c.keys()))==2:
    flag=True
    for key in c.keys():
        if c[key]!=2:
            flag=False
            break

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

Solution (Python):
from collections import defaultdict
s=input()
x=set()
d=defaultdict(int)
for v in s:
  d[v]+=1
  x.add(v)
if len(d)==2:
  for k in d:
    if d[k]!=2:
      print("No")
      exit(0)
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()
ans = 'No'
if s.isupper() and len(s)==4:
  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):
import sys
input = sys.stdin.readline

L = list(input().strip())
m = {}

for v in L:
    if m.get(v) == None:
        m[v] = 0
    m[v] += 1
    
for v in m.values():
    if v != 2:
        print("No")
        exit()
        
print("Yes")

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

Solution (Python):
s=input()
t=1
for i in s:
	if not s.count(i)==2:
		print('No')
		t=0
		break;
if t==1: print('Yes')

Solution (Python):
a = input()
a = a.replace(a[0], "")
if len(a) == 0:
    print("No")
    exit()
a = a.replace(a[0], "")
if len(a) == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
S = sorted(S)
yes = [a == b for a, b in zip(S, S[1:])] == [True, False, True]
print('Yes' if yes else 'No')

Solution (Python):
s = input()
d = {}
for e in s:
  if e in d:
    d[e] += 1
  else:
    d[e] = 1

if len(d) == 2 and set(d.values()) == {2}:
  print("Yes")
else:
  print("No")

Solution (Python):
def ok(s: str) -> str:
    char_count = {}
    for c in s:
      if c not in char_count:
        char_count[c] = 0
      if c in char_count.keys():
        char_count[c] += 1
    
    return all([count == 2 for count in char_count.values()])

numbers_str = input()
result = ok([c for c in numbers_str])
if result:
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()

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

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

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

Solution (Python):
S = input()
c = 1
for i in range(4):
    if S.count(S[i]) != 2:
        c = 0
if c==1:
    print("Yes")
else:
    print("No")

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

if S[0] == S[1]:
	if S[0] != S[2] and S[2] == S[3] :
		print('Yes')
	else:
		print('No')
else:
	if (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):
from collections import Counter

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

Solution (Python):
S = input()
s = set(S)
flag = True

for i in s:
    if S.count(i) != 2:
        flag = False

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

Solution (Python):
from sys import stdin
from collections import Counter

S = stdin.readline().rstrip()
c = Counter(S)

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

Solution (Python):
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    c = collections.Counter(S())
    if len(c) == 2 and list(c.values())[0] == 2:
        return 'Yes'

    return 'No'


print(main())

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

Solution (Python):


S=input()
A=B=0

for i in range(4):
    for l in range(i+1,4):
        if S[i]==S[l]:
            A+=1

if A==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("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[2] == S[1]:
    print("Yes")
else:
    print("No")

Solution (Python):
code = input()

wc = {}
for i in code:
    if i in wc:
        wc[i] = wc[i] + 1
    else:
        wc[i] = 1

for key in wc.keys():
    if int(wc[key]) != 2:
        print("No")
        exit(0)
print("Yes")

Solution (Python):
code = input()

wc = {}
for i in code:
    if i in wc:
        wc[i] = wc[i] + 1
    else:
        wc[i] = 1

for key in wc.keys():
    if int(wc[key]) != 2:
        print("No")
        exit(0)
print("Yes")

Solution (Python):
s=input()

ans=True

for i in s:
  if s.count(i)!= 2:
    ans=False
    
print('Yes' if ans==True else 'No')