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):
import sys
s=list(input())

a=s[0]
f=0
for x in range(1,4):
  if a!=s[x]:
    b=s[x]
    f=1
    break

if f==0:
    print("No")
    sys.exit()

for y in range(1,4):
    if y!=x:
        if a!=s[y] and b!=s[y]:
            print("No")
            sys.exit()
print("Yes")

Solution (Python):
S = input()

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

print("Yes")

Solution (Python):
import collections

if __name__ == '__main__':
    l = list(input())
    c = collections.Counter(l)
    for char, count in c.most_common(2):
        if count != 2:
            print("No")
            exit()
    print("Yes")

Solution (Python):
s = input()
m = []
for i in s:
        m.append(i)
count_list = []
for i in m:
        count = 0
        for j in m:
                if i == j:
                        count += 1
        count_list.append(count)
for i in count_list:
        if i != 2:
                print("No")
                exit()
print("Yes")

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

if len(b) == 2:
  count = 0
  for i in range(1,4):
    if a[i] == a[0]:
      count +=1
  if count ==1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
s=input()
for i in range(1):
    if s.count(s[0])==2:
        if s.count(s[1])==2:
            if s.count(s[2])==2:
                if s.count(s[3])==2:
                    print('Yes')
                    break
    print('No')

Solution (Python):
s = input()

n = len(s)

flg = True

if n != 4:
    flg = False  

else:  
    l = []
    for i in range(n):
        l.append(s[i])
    l.sort()
    if l[0] != l[1] or l[1] == l[2] or l[2] != l[3]:
        flg = False

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

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

counts0 = 0
counts1 = 0
counts2 = 0
if S[0] == S[1]:
    counts0 = counts0 + 1
if S[0] == S[2]:
    counts0 = counts0 + 1
if S[0] == S[3]:
    counts0 = counts0 + 1
if S[1] == S[2]:
    counts1 = counts1 + 1
if S[1] == S[3]:
    counts1 = counts1 + 1
if S[2] == S[3]:
    counts2 = counts2 + 1

if counts0 == 1 and ((counts1 == 1 and counts2 ==0) or (counts1 == 0 and counts2 == 1)):
    print("Yes")
else:
    print("No")

Solution (Python):
S=input()
sum=[0,0,0,0]
for t in range(4):
    for i in range(4):
        if S[int(t)]==S[int(i)]:
            sum[int(i)]+=1
if sum[0] == 2 and sum[1] == 2 and sum[2] == 2 and sum[3] == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()

a = {}

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

if len(a) == 2:
    values = list(a.values())
    if values == [2,2]:
        print("Yes")
        exit()
print("No")

Solution (Python):
import numpy as np

S = input()

moji = [i for i in S]

a = moji[0]
for i in range(len(moji)):
    if a != moji[i]:
        b = moji[i]
count = 0
count2 = 0
for i in range(0,len(moji)):
    if moji[i] == a:
        count += 1
    elif moji[i] == b:
        count2 += 1
if count == 2 and count2 == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

m = {}

for c in s:
    if c not in m:
        m[c] = 1
    else:
        m[c] += 1

if len(m) == 2 and all([value == 2 for value in m.values()]):
    print("Yes")
else:
    print("No")

Solution (Python):


from collections import Counter

S = input()
S = list(S)


if(Counter(S).most_common(2)[0][1]!=4):
    c1 = Counter(S).most_common(2)[0][1]
    c2 = Counter(S).most_common(2)[1][1]
    if(c1==c2):
        if(c1==2):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Solution (Python):
a = list([str(i) for i in input()])
s1={a[0]}
s2={a[1]}
s3={a[2]}
s4={a[3]}

s_union=s1|s2|s3|s4
if len(s_union)==2 and a.count(a[0])==2 and a.count(a[1])==2 and a.count(a[2])==2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
s = input();
check = [0]*26;
base = ord("A");
count2 = 0;
for i in range(4) :
	check[ord(s[i])-base] += 1;
for i in range(26) :
	if check[i] == 2 :
		count2 += 1;
if count2 == 2 :
	print('Yes');
else :
	print('No')

Solution (Python):
s = input()

a = s[0]
b = s[1]
c = s[2]
d = s[3]

if(a == b and b == c and c == d): 
 print('No')
elif(a == b and c == d): 
 print('Yes')
elif(a == c and d == b): 
 print('Yes')
elif(a == d and c == b): 
 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=list(input())
dic = {}

for s in S:
    dic[s] = 0

for s in S:
    dic[s] += 1

if len(dic) == 2:
    flag = True
    for v in dic.values():
        if v != 2:
            flag = False
    
    if flag == True:
        print("Yes")
    else:
        print("No")

else:
    print("No")

Solution (Python):
import sys 

word =input()
flag = 0

for i in range(4):
    if word.count(word[i]) == 2:
        flag += 1
    
if flag == 4:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
a = s.count(s[0])
if a == 4:
    print("No")
    exit()
for i in range(2):
    if s[0] != s[i+1]:
        b = s.count(s[i+1])
        if a + b == 4:
            print("Yes")
        else:
            print("No")
        exit()

Solution (Python):
S = input()

S_dict = {}

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

x = 1
for k,v in S_dict.items():
    x *= v

print('Yes') if len(S_dict) == 2 and x == 4 else print('No')

Solution (Python):
s = input()
ans = []
for i in range(4):
	for j in range(4):
		if i >= j:
			continue
		ans.append(s[i] == s[j])
if sum(ans) == 2:
	print("Yes")
else:
	print("No")

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

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

Solution (Python):
import collections as C
def calc(arg):
    count = C.Counter(arg)
    if len(count) is not 2:
        return "No"
    if count.most_common()[0][1] is not count.most_common()[1][1]:
        return "No"
    return "Yes"
print(calc(input()))

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

if (s1[0] == s1[1] and s1[2] == s1[3] and s1[0] != s1[2]) or (s1[1] == s1[2] and s1[0] == s1[3] and s1[1] != s1[3]) or (s1[0] == s1[2] and s1[1] == s1[3] and s1[0] != s1[1]):
    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 = list(input())
s.sort()

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

Solution (Python):
A=list(input())
B=[]
a=A[0]
cnt1=0
cnt2=0
for i in range(4):
    if(a==A[i]):
        cnt1+=1
    else:
        B.append(A[i])

if(cnt1==2):
    b=B[0]
    for i in range(2):
        if(b==B[i]):
            cnt2+=1
    if(cnt2==2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

cnt = [1,0,0,0]

if(S[1] == S[0]):
    cnt[0] += 1
else:
    cnt[1] += 1

if(S[2] == S[0]):
    cnt[0] += 1
elif(S[2] == S[1]):
    cnt[1] += 1
else:
    cnt[2] += 1

if(S[3] == S[0]):
    cnt[0] += 1
elif(S[3] == S[1]):
    cnt[1] += 1
elif(S[3] == S[2]):
    cnt[2] += 1
else:
    cnt[3] += 1

if(cnt == [2,2,0,0] or cnt == [2,0,2,0]):
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
from collections import defaultdict
S = input()
d = defaultdict(int)
for c in S:
    d[c] += 1

if len(d) == 2:
    for v in d.values():
        if v != 2:
            print('No')
            quit()
    print('Yes')
else:
    print('No')

Solution (Python):
a = input()

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

sum = 0
if len(d) == 2:
  for s in d.values():
    sum += s
  if sum == 4:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Solution (Python):
S = input()

x=True
for c in S:
    x = x and S.count(c) == 2

print('Yes' if x else 'No')

Solution (Python):
s = input()
l = []
for i in s:
  l.append(i)
a = set(l)
if len(a) == 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[0] != s[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import stdin
S = stdin.readline().rstrip()
s1 = S[0]
if S[0] == S[1]:
    s2 = S[2]
else:
    s2 = S[1]
if S.count(s1) == 2 and S.count(s2) == 2:
    print('Yes')
else:
    print('No')

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

Solution (Python):
from collections import Counter


a = input()

wlist = []

for i in a:
    wlist.append(i)

S=Counter(wlist)
if len(S.keys()) == 2:
    if S.most_common()[0][1] == 2:
        print("Yes")
    else:
        print("No")
        exit()
else:
    print("No")
    exit()

Solution (Python):
s = input()

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

Solution (Python):
s=list(input())
d = {}
for hoge in s:
  d[hoge] = d.get(hoge, 0) + 1

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

Solution (Python):
S = list(input())
c = []
for i in S:
    count = 0
    for j in S:
        if i == j:
            count+=1
    c.append(count)

if c == [2, 2, 2, 2]:
    print("Yes")
else:
    print("No")

Solution (Python):
sl=list(input())
cl=[]

cl.append(sl[0])

for i in range(1,4):
  if cl.count(sl[i]) == 0:
    cl.append(sl[i])


if len(cl)!=2 :
  answer='No'
elif sl.count(cl[0])==2 and sl.count(cl[1])==2:
  answer='Yes'
else:
  answer='No'
  
print(answer)

Solution (Python):
S = input()

S_list = []

for s in S:
    S_list.append(s)

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

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

A = B = S[0]
for char in S:
    if char != S[0]:
        B = char

count1 = S.count(A)
count2 = S.count(B)

if count1 == 2 and count2 == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = list(input())
if s.count(s[0]) == 2:
  t = [i for i in s if i != s[0]]
  if t[0] == t[1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
a = input()

w = a.count(a[0])
x = a.count(a[1])
y = a.count(a[2])
z = a.count(a[3])

if w == 2 and x == 2 and y == 2 and z == 2:
    print('Yes')

else:
    print('No')

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

Solution (Python):
S = input()

a = S[0]
b = 'b'
a_count = 0
b_count = 0

for i in S:
    if i==a:
        a_count += 1
    else:
        b = i
for i in S:
    if i==b:
        b_count +=1

if a_count == 2 and b_count == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
L = []
for i in range(4):
  if S[i] not in L:
    L.append(S[i])
flag = False
if len(L) == 2:
  t = 0
  for i in range(2):
    if S.count(L[i]) == 2:
      t += 1
  if t == 2:
    flag = True
if flag:
  print('Yes')
else:
  print('No')

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

Solution (Python):
S = []
tmp = input()

for i in tmp:
    S.append(i)

isYes='Yes'
for i in S:
    if S.count(i) != 2:
        isYes = 'No'
print(isYes)

Solution (Python):

s = input()
a=[0,0,0,0]
b=[1,1,1,1]
for i in range(4):
    for j in range(4):
        if(s[i]==s[j] and i != j):
            a[i]+=1 
if(a==b):
    print("Yes")
else:
    print("No")

Solution (Python):
mojis = []
count = []
for i in input():
    if i in mojis:
        count[mojis.index(i)] += 1
    else:
        count.append(1)
        mojis.append(i)
        
if count == [2,2]:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
count = 0
k = 0
index = [1,2,3]

for i in [1,2,3]:
    if s[0] == s[i]:
        count = count + 1
        k = i
        index.remove(k)
        
if count == 1:
    if s[index[0]] == s[index[1]]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
import numpy as np
S = input()
S_ = list(set(S))
S = np.array(list(S))
S_ = np.array(S_)
ans = 'Yes'
if len(S_)!=2:
    ans = 'No'
elif sum(S==S_[0])!=2:
    ans = 'No'

print(ans)

Solution (Python):
lst=list(input())
unique=list(set(lst))
dct={}
is_yes=None
if len(unique)==2:
    len0=len([i for i, c in enumerate(lst) if c == unique[0]])
    len1=len([i for i, c in enumerate(lst) if c == unique[1]])
    if len0==2 & len1==2:
        is_yes=True
    else:
        is_yes=False
else:
    is_yes=False
if is_yes:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

str = []
for x in list(s):
    if not x in str:
        str.append(x)
if len(str) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):

def solve():
    S = [_ for _ in raw_input()]
    dict = {}
    for ele in S:
        if ele in dict.keys():
            dict[ele] += 1
        else:
            dict[ele] = 1
    if len(dict) == 2 and dict.values() == [2, 2]:
        print 'Yes'
    else:
        print 'No'

if __name__ == '__main__':
    solve()

Solution (Python):


S = input()
a = list(S)

a.sort()



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

Solution (Python):
S = input()
A = [S[0],S[1],S[2],S[3]]
A.sort()
B = set(A)
if len(B)==2 and A[0]==A[1] and A[2]==A[3]:
  print('Yes')
else:
  print('No')

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

Solution (Python):
from collections import Counter
S=input()
c=Counter(S)
if len(c.most_common())==2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

alphaList = []

for alpha in s:

    isExist = False

    for a in alphaList:
        if a == alpha :
            isExist = True
    
    if isExist == False:
        alphaList.append(alpha)

print( 'Yes' if(len(alphaList)==2) else 'No'  )

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

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

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

arr = {}

for i in S:
    if i in arr:
        arr[i] += 1
    else:
        arr[i] = 1


if len(arr) > 2:
    print("No")
    sys.exit()

if arr[S[0]] is 2:
    print("Yes")
else:
    print("No")

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

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


set_s = set(s)

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

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

Solution (Python):
s=input()
temp = ''
for i in s:
    temp += i

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

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

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

flag = False

if len(d.keys()) == 2:
    for v in d.values():
        if v != 2:
            flag = False
            break
        else:
            flag = True
if flag:
    print("Yes")
else:
    print("No")

Solution (Python):
M=input()


if M.count(M[0])+ M.count(M[1])+ M.count(M[2])+ M.count(M[3])==8:
  print("Yes")
else:
  print("No")

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

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

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

Solution (Python):
word = input()
flg = 0
for i in word:
  if word.count(i) != 2:
    flg = 1
    print("No")
    break
if flg==0: print("Yes")

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

else:
    print("No")

Solution (Python):
def acinput():
    return list(map(int, input().split(" ")))


def anumber(x):
    return ord(x)-ord("A")


S = input()

cnts = [0]*27

for s in S:
    cnts[anumber(s)] += 1

n2 = 0
for sc in cnts:
    if sc == 2:
        n2 = n2+1

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

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

Solution (Python):
S = list(input())
if not S[0]==S[1]==S[2]==S[3]:
    a = S[0]
    S.pop(0)
    if a in S:
        S.remove(a)
        if S[0]==S[1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    
else:
    print('No')

Solution (Python):
S = input()

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

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

Solution (Python):
import collections
S = [i for i in input()]
c = collections.Counter(S)
if len(c) != 2:
  print ("No")
else:
  flag = True
  for count in c.values():
    if count != 2:
      print ("No")
      flag = False
      break
  if flag:
    print ("Yes")

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

for c in S:
    dic[c] = dic.get(c,0)+1

if len(dic) != 2:
    print("No")
else:
    for key in dic:
        if dic[key] != 2:
            print("No")
            break
    else:
        print("Yes")

Solution (Python):
from collections import Counter

myword = input()

mycounter = Counter(myword)

r = 'Yes'

for v in mycounter.values():
    if v != 2:
        r = 'No'

print(r)

Solution (Python):
S = input()

cnt = 0
for i in range(3):
    n = 0
    for j in range(i + 1, 4):
        if S[i] == S[j]:
            n += 1
    if n == 1:
        cnt += 1

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

Solution (Python):
import collections

S = list(input())
mymode = collections.Counter(S).most_common()

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

Solution (Python):
S=input()
A=[0]*10
flag=0

for i in range(4):
    A[i]=S.count(S[i])

for i in range(4):
    if A[i]!=2:
        flag=1
if flag==0:
    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):
from collections import Counter

def ans():
    S = input()
    c = Counter(S)
    if len(c) != 2:
        print('No')
        return
    for key in c:
        if c[key] != 2:
            print('No')
            return
    print('Yes')

ans()

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

if S.count(S[0]) == 2:
    new_S = S.strip(S[0])
    if new_S.count(new_S[0]) == 2:
        print("Yes")
    else:
        print("No")    
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):
s = input()

if s[0]==s[1] 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[1]==s[2]:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
same = 0
for i in range(3):
    if s[0] == s[i+1]:
        same += 1
if same == 1:
    if s[1] == s[2] or s[2] == s[3] or s[3] == s[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
import collections

s=input()
c=collections.Counter(s)

ret='Yes'

for v in c.values():
    if v!=2:
        ret='No'

print(ret)

Solution (Python):
s = input()

if (( s[0]==s[1] and s[2]==s[3] ) or ( s[1]==s[2] and s[0]==s[3] ) 
   or ( s[0]==s[2] and s[1]==s[3] )) :

    if ( s[0]==s[1] and s[1]==s[2] and s[2]==s[3] ) :

        print('No')

    else :

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

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

Solution (Python):
lista = input()

a=lista.count(lista[0])
b=lista.count(lista[1])
c=lista.count(lista[2])
d=lista.count(lista[3])
if(a==2 and b==2 and c==2 and d==2):
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
s_set = set(s)
count=0
if len(s_set) == 2:
    count = 1
    for i,j in enumerate(s):
        if i>0 and j == s[0]:
             count += 1
if count == 2:
    print('Yes')
else:
    print('No')

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):
import collections

string = str(input())

c = collections.Counter(list(string))
if list(c.values()) == [2, 2]:

    print('Yes')

else:
    print('No')

Solution (Python):
S = input()

u = {}
sSet = set(S)
for s in S:
	if s not in u.keys():
		u[s] = 1
	else:
		u[s] += 1
			
if len(sSet) == 2:
	if u[list(sSet)[0]] == 2 and u[list(sSet)[1]] == 2:
		print("Yes")
		exit()
print("No")

Solution (Python):
S=list(input())
num=0
for c in S[1:]:
    if c == S[0]:
        num+=1

if S[1]==S[2]:
    num+=1
if S[1]==S[3]:
    num+=1
if S[2]==S[3]:
    num+=1
    
if num==2:
    print("Yes")
else:
    print("No")

Solution (Python):
N = str(input())
v = [N[i: i+1] for i in range(0, len(N), 1)]
v.sort()
if(v[0]==v[1] and v[2]==v[3]):
    if(v[1]!=v[2]):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
s = list(set(input()))
if len(s) != 2 or s[0] == s[1]:
    print('No')
else:
    print('Yes')

Solution (Python):
S = input()
l = list(set(S))
if len(l)==2:
    if S.count(l[0])==2 and S.count(l[1])==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):
import collections
S = input()
c = collections.Counter(S)
values, counts = zip(*c.most_common())
a = 0
for i in counts:
    if i==2:
        a += 1
    else:
        a *= 0
if a:
    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())
moji=[]
result=[]

for i in range(4):
    if S[i] not in moji:
        moji.append(S[i])
        result.append(0)
    else:
        result[moji.index(S[i])]+=1

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

Solution (Python):
S = input()
lst = []
for i in S:
    lst.append(i)
s = sorted(lst)
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())
ss=set(s)
flg=0
if len(ss)!=2:
    flg=1
ss=list(ss)
for i in ss:
    cnt=s.count(i)
    if cnt!=2:
        flg=1

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

Solution (Python):
import sys
import collections


def main():
    S = sys.stdin.readline().strip()
    d = collections.defaultdict(int)
    for c in S:
        d[c] += 1
    for key in d:
        if d[key] != 2:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

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

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

Solution (Python):
s = str(input())
s1 = set(s)
s2 = list(s)
cnt = 0
if len(s1) != 2:
    print("No")
else:
    for i in range(1,len(s2)):
        if s[0] == s[i]:
            cnt += 1
    if cnt == 1:
        print("Yes")
    else:
        print("No")

Solution (Python):

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

Solution (Python):

def main():
    S=list(map(str,input()))
    l_duplicate = [x for x in set(S) if S.count(x) ==2]

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

if __name__=="__main__":
    main()

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

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

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

Solution (Python):
S = input()
count_dict = {}
for i in S:
  if i not in count_dict:
    count_dict[i] = 1
  else:
    count_dict[i] += 1

value = list(count_dict.values())
if len(value) == 2 and value[0] == value[1]:
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()

d = {}
for x in list(s):
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

if len(d.keys()) == 2:
    t = True
    for e in d:
        if d[e] != 2:
            t = False
    if t:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

res_dict = {}

for ch in S:
    if( ch not in res_dict ):
        res_dict[ch] = 1
    else:
        res_dict[ch] += 1

res_flag = False
if( len(res_dict) == 2 ):
    for v in res_dict.values():
        if( v == 2 ):
            res_flag = True
        else:
            res_flag = False
            break

print('YNeos'[not(res_flag)::2])

Solution (Python):

S = input()

one = S[0]
two = S[1]
three = S[2]
four = S[3]

count = 0
index = 0

judge = False


for i in range(len(S)):
    if i == 0:
        continue
    if one == S[i]:
        index = i
        count += 1




if index == 1:
    if S[2] == S[3]:
        judge = True

elif index == 2:
    if S[1] == S[3]:
        judge = True

elif index == 3:
    if S[1] == S[2]:
        judge = True

else:
    judge = False


if not(count == 1):
    judge = False

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

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

Solution (Python):
s = input()
q = set(s)
if len(q) == 2:
    a = s[0]
    c = 0
    for i in range(1,4):
        if s[i] == a:
            c += 1
    if c == 1:
        print("Yes")
        exit()

print("No")

Solution (Python):
import collections
S = input()
check = collections.Counter(S)
t = check.values()
ls = list(t)
ls2 = [2, 2]
if ls == ls2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
st=[]
d=[]
for i in s:
    if i in d:
        st[d.index(i)]+=1
    else:
        d.append(i)
        st.append(1)

if len(st)==2 & st[0]==2 & st[1]==2:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
s = input()
s1= s[:1]
s2 = s[1:2]
s3 = s[2:3]
s4 = s[3:4]
if s1 == s2:
	if s3 == s4:
		if s1 != s3:
			print("Yes")
			sys.exit(0)
if s1 == s3:
	if s2 == s4:
		if s1 != s2:
			print("Yes")
			sys.exit(0)
if s1 == s4:
	if s2 == s3:
		if s1 != s3:
			print("Yes")
			sys.exit(0)
print("No")

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