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-----
ASSA

-----Sample Output-----
Yes

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

Difficulty: introductory

Starter code:

Solutions:
s = input()

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

s = str(input())
tmp = {}
for i in range(4):
    tmp.setdefault(s[i],0)
    tmp[s[i]]+=1
if len(tmp)==2 and max(tmp.values())==2:
    print('Yes')
else:
    print('No')

S = input()
 
# S_0 = S_1 かつ S_2 = S_3
# S_0 = S_2 かつ S_1 = S_3
# S_0 = S_3 かつ S_1 = S_2
# S_0 = S_1 = S_2 = S_3 を除外

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

S = input()

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

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

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

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

S = list(input())
s = set(S)
lis = {}
for x in S:
  if x in lis:
    lis[x] += 1
  else:
    lis[x] = 1
ans = True
if len(lis) == 2:
  for x in s:
    if lis[x] != 2:
      ans = False
else:
  ans = False
if ans:
  print("Yes")
else:
  print("No")

import collections
S = input()
s = collections.Counter(S)


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


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

s = input()

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

x = list(input())

a1 = (x[0] == x[2]) and (x[1] == x[3])
a2 = (x[0] == x[1]) and (x[2] == x[3])
a3 = (x[0] == x[3]) and (x[1] == x[2])
b = len(set(x)) == 2

if b and ( a1 or a2 or a3 ):
    print("Yes")
else:
    print("No")



S = input()

L = {}

ans = "Yes"
for s in S:
    if s in list(L.keys()):
        L[s] += 1
        if L[s] > 2:
            ans = "No"
    else:
        L[s] = 1
if len(list(L.keys())) != 2:
    ans = "No"

print(ans)


from collections import Counter

S = input()
c = Counter(S)
ans = 'No'
if len(c)==2:
  if all([x for x in c.values() if x==2]):
    ans = 'Yes'
print(ans)

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

n = input()
dic = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(26):
  if n.count(str(dic[i]))==1 or n.count(str(dic[i]))==3 or n.count(str(dic[i]))==4:
    print("No")
    return
print("Yes")

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


s = input()

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

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


s = input()
lst = []
for i in range(4):
  lst.append(s[i])
ans = 0
for i in range(4):
  if(lst.count(lst[i]) != 2):
    ans = 1
if (ans == 0):
  print("Yes")
else:
  print("No")


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

s=input()
a=0
b=0
c=0
for i in range(1,4):
  if ord(s[0])==ord(s[i]):
    a=i
    b+=1
if b==1:
  if a==1:
    if ord(s[2])==ord(s[3]):
      print('Yes')
    else:
      print('No')
  elif a==2:
    if ord(s[1])==ord(s[3]):
      print('Yes')
    else:
      print('No')
  elif a==3:
    if ord(s[1])==ord(s[2]):
      print('Yes')
    else:
      print('No')
else:
    print('No')


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

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

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

from collections import Counter
S = list(input())
S = Counter(S)
for i in list(S.values()):
    if i == 2 and len(S) == 2:
        ans = "Yes"
    else:
        ans = "No"
    break
print(ans)


from collections import defaultdict

S = defaultdict(int)
for i in input():
    S[i] += 1

if len(list(S.values())) == 2:
    a, b = list(S.values())
    if a == b == 2:
        print('Yes')
        return
print('No')


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


s=input()
st=set(s)

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

s=input()
l={}
for i in s:
    l[i]=1
if len(l)==2:
    print("Yes")
else:
    print("No")

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

S = input()

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


S = list(input())

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

S=list(input())
S_=list(set(S))

if len(S_)==2:
	cnt=0
	for s_ in S_:
		for i in range(4):
			if S[i]==s_:
				cnt+=1
		if cnt==2:
			cnt=0
			continue
		else:
			print("No")
			return

	print("Yes")

else:
	print("No")

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

S=input()
s=set(S)
for c in s:
    if S.count(c)!=2:
        print("No")
        break
else:
    print("Yes")


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


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


import sys

S = list(sys.stdin.readline().strip())
S.sort()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print("Yes")
else:
    print("No")

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


S = input()
ary = list(set(S))
print('Yes' if len(ary) == 2 else 'No')

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

s = input()

cou = []
enc = 0
enc1 = 0
for i in s:
    if i not in cou:
        cou.append(i)

if len(cou) != 2:
    print('No')
    return

for i in s:
    if i in cou[0]:
        enc += 1
    if i in cou[1]:
        enc1 += 1

if enc == 2 and enc1 == 2:
    print('Yes')
else:
    print('No')

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

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

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


from collections import Counter
a = Counter(input()).most_common()
if len(a)==2:
  if a[1][1]==2:
    print("Yes")
else:
  print("No")

import collections
s = input()
c = collections.Counter(list(s))
print('Yes' if len(c.keys()) == 2 and len(set(c.values())) == 1 else 'No')

ans = "No"
S = input()
initial = S[0]
SS = S.replace(initial, "")
if len(SS) == 2:
  if SS[0] == SS[1]:
    ans = "Yes"
print(ans)

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



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


def __starting_point():
    main()

__starting_point()

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


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

a = list(input())
if(len(a) > 4):
	stop()
a.sort()
if(a[0] == a[1] and a[2] == a[3] and a[0] != a[2]):
	print("Yes")
else:
	print("No")

S = input()
flag = False
if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
    flag = True
if S[0] == S[2] and S[2] != S[3] and S[1] == S[3]:
    flag = True
if S[0] == S[3] and S[1] != S[3] and S[1] == S[2]:
    flag = True

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


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


from collections import defaultdict
S = input()
dct = defaultdict(int)
for s in S:
  dct[s] += 1
for key, val in dct.items():
  if not val == 2:
    print('No')
    return
print('Yes')

s=input()
S=sorted(s)
S.sort()
flag=False
if S[0]==S[1]:
    if S[2]==S[3]:
        if S[1]!=S[2]:
            flag=True
if flag:
    print("Yes")
else:
    print("No")

import collections

S=list(str(input()))
num=collections.Counter(S)

for i,j in num.items():
   if j!=2:
       print("No")
       return
       
print("Yes")

s=input()
ans="Yes"
for i in range(4):
    if s.count(s[i])!=2:
        ans="No"
print(ans)

S = list(input())
S.sort()
print(['No', 'Yes'][S[0] == S[1] and S[2] == S[3] and S[1] != S[2]])

s=input()
d={}
for i in range(4):
    if s[i] not in d:
        d[s[i]]=1
    else:
        d[s[i]]+=1
ans="Yes"
for i in d:
    if d[i]!=2:
        ans="No"
print(ans)

S = input()
c = 1
if S[0] == S[1]:
    if S[2] == S[3] and S[0] != S[2]:
        c = 0

elif S[0] == S[2]:
    if S[1] == S[3] and S[0] != S[1]:
        c = 0

elif S[0] == S[3]:
    if S[1] == S[2] and S[0] != S[1]:
        c = 0
        

if c:
    print('No')

else:
    print('Yes')

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

#ABC132 A

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


S = input()
 
# S_0 = S_1 かつ S_2 = S_3
# S_0 = S_2 かつ S_1 = S_3
# S_0 = S_3 かつ S_1 = S_2
# S_0 = S_1 = S_2 = S_3 を除外
 
if (S[0] == S[1] and S[2] == S[3] and S[1] != 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')

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


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


s=input()
l={}
ans="Yes"
for i in s:
  if i not in l.keys():
    l[i] = 1
  else:
    l[i] += 1
for i in l.values():
  if i != 2:
    ans="No"
print(ans)

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

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

from _collections import defaultdict
S = input()

cnt = defaultdict(int)
for i in range(len(S)):
    cnt[S[i]] += 1
    if cnt[S[i]] > 2 or len(cnt) > 2:
        print("No")
        return

print("Yes")


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

S = input()
S2 = list(set(S))

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

s = input()
S = set(s)
if len(S) != 2:
    print('No')
    return
else:
    for i in range(4):
        if s.count(s[i]) != 2:
            print('No')
            return

print('Yes')



S = str(input())
hantei = 0

for i in range(len(S)):
    if S.count(S[i]) == 2:
        hantei +=1

if hantei == 4:
    print('Yes')
else:
    print('No')

S = input()
s = []
for i in range(4):
  s.append(S[i])
s = set(s)
print("Yes" if len(s)==2 else 'No')

S = input()

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

cnt = 0
tmp = list(set_S)[0]
for s in S:
    if tmp == s:
        cnt += 1
if cnt != 2:
    print("No")
else:
    print("Yes")

S = sorted(input())

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

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

S = list(input())

S.sort()
#print(S)

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

        else:
            print("No")

    else:
        print("No")

else:
        print("No")


s = input()

S = []
for i in range(len(s)):
    S.append(s[i])

B = list(set(S))

cnt1 = 0
cnt2 = 0

if len(B) != 2:
    print('No')
else:
    for i in range(len(s)):
        if B[0] == s[i]:
            cnt1 += 1
        elif B[1] == s[i]:
            cnt2 += 1
    if cnt1 == 2 and cnt2 == 2:
        print('Yes')
    else:
        print('No')

import collections
s = input()
c = collections.Counter(s)
if list(c.values()) == [2,2]:
    print('Yes')
else:
    print('No')

s = input()
sl = []
for i in s:
    if i not in sl:
        sl.append(i)
if len(sl) == 2:
    n = 0
    for i in s:
        if i == sl[0]:
            n += 1
    if n == 2:
        print('Yes')
else:
    print('No')

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

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


s=input()
ans="Yes"
for i in range(4):
    if s.count(s[i])!=2:
        ans="No"
print(ans)

S = list(input())
print("Yes") if len(set(S))==2 else print("No")

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


S = input()
T = []
for i in S:
    if(i not in T):
        T.append(i)

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


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

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

s = input()
d = dict()
for si in s:
    if si not in list(d.keys()):
        d[si] = 1
    else:
        d[si] += 1

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


S = str(input())

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

word = input()

list_word = list(word)

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


def resolve():
    S = set(input())
    print("Yes" if len(S) == 2 else "No")
 
resolve()

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

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

S = list(input())
if len([x for x in set(S) if S.count(x) > 1]) == 2:
    print('Yes')
else:
    print('No')


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