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

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

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

Solution (Python):
s = input()
letter = {}
for i in s:
  letter.setdefault(i, 0)
  letter[i] += 1
if list(letter.values()) == [2, 2]:
  print("Yes")
else:
  print("No")

Solution (Python):
def solve():
    s = input()
    chars = set(s)
    if len(chars) == 2:
        return "Yes"
    else:
        return "No"


if __name__ == "__main__":
    print(solve())

Solution (Python):
S = input()
for i in S:
    if not S.count(i) ==2:
        print ('No')
        break
else:
    print ('Yes')

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

Solution (Python):
S = input()
s1 = S[0]
out = 'No'
s1_list = list(filter(lambda x: x == s1, S))
if len(s1_list) == 2:
    s2_list = list(filter(lambda x: x != s1, S))
    if s2_list[0] == s2_list[1]:
        out = 'Yes'
print(out)

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

Solution (Python):
S = str(input())
l = list(S)
s = int(len(S))

num = 0
for i in range(s):
    for j in range(i+1, s):
        if l[i] == l[j]:
            num += 1
        else:
            num += 0

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

Solution (Python):
def main():
    s = sorted(input())
    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()
S = set(s)
ss = sorted(s)
if len(S) !=2:
  print("No")
else:
  if  ss.count(ss[0]) ==2 and ss.count(ss[2]) ==2:
    print("Yes")
  else:
    print("No")

Solution (Python):

from collections import Counter
s=list(input())
c=Counter(s)
x=list(c.values())
print("Yes" if len(c)==2 and x[0]==2 and x[1]==2 else "No")

Solution (Python):
S=input()

one=S[0]

for n in S:
    if n!=one:
        two=n

if S.count(one)==2 and S.count(two)==2:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
S = input()
M = []
for i in range(4):
  M.append(S[i])
M = sorted(M)
if M[0] == M[1]:
  if M[2] == M[3]:
    if M[0] != M[2]:
      print("Yes")
      sys.exit()
print("No")

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

if len(set(S))==2 and len([x for x in S if x==list(set(S))[0]])==2:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
s = input()
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
for v in d.values():
    if v != 2:
        print("No")
        exit()
print("Yes" if len(d) == 2 else "No")

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

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

Solution (Python):
S = input()
D = {chr(i):0 for i in range(65, 65+26)}

f=0
for i in range(4):
  D[S[i]] += 1
  if D[S[i]] == 2:
    f +=1

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

Solution (Python):
from collections import Counter

c = Counter(input())
if (len(c) == 2) & (list(c.values()) == [2, 2]):
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

s = input()
c = Counter(s)
if (len(c) == 2) & (list(c.values()) == [2, 2]):
    print("Yes")
else:
    print("No")

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

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

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

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

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

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

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

Solution (Python):
S = input()
S = [str(c) for c in S]

cnt = 0

for i in range(4):
	cnt += S.count(S[i])
	
if cnt == 8:
	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):
from collections import Counter

S = Counter(input())

v = list(S.values())
if len(S) == 2 and v[0] == 2:
    ans = 'Yes'
else:
    ans = 'No'
    
print(ans)

Solution (Python):
S = input()
l = []
for s in S:
    l.append(s)

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

Solution (Python):

S = input()
for x in S:
    if S.count(x) != 2:
        print('No')
        exit()

print('Yes')

Solution (Python):

S = (list(input()))
S.sort()
if S[0] == S[1] and S[2] == S[3]:
    if len(set(S)) == 2:
        print('Yes')
        exit()

print('No')

Solution (Python):
S = input()

count_1 = 0
count_2 = 0

if len(set(S))==2:
    list = list(set(S))

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

Solution (Python):
N = input()

for i in N:
  if N.count(i) != 2:
    print("No")
    exit()

print("Yes")

Solution (Python):
four = input()
four_set = set(four)

if len(four_set) != 2:
    print("No")
else:
    if four.count(list(four_set)[0]) != 2:
        print("No")
    else:
        print("Yes")

Solution (Python):
S = input()

P = len(S)
L = set()
for i in range(P):
    L.add(S[i])

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

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

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

Solution (Python):
i = reversed(input())
s = "".join(list(i))
if s[0] == s[1] == s[2] == s[3]:
    print("No")
else:
    s = s.replace(s[0], '', 2)
    s = s.replace(s[0], '', 2)
    print("Yes" if len(s) == 0 else "No")

Solution (Python):


def main(S):
    ans = 'No'
    letters = set(S)
    tmp = []
    for letter in letters:
        tmp.append(S.count(letter))
    if tmp == [2, 2]:
        ans = 'Yes'
    return ans
    
if __name__ == '__main__':
    S = input()
    print(main(S))

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

Solution (Python):
s=list(input())
a=s[0]
b=s[1]
c=s[2]
d=s[3]


if a==b and c==d and a!=c:
  print('Yes')
elif a==c and b==d and a!=b:
  print('Yes')
elif a==d and c==b and a!=c:
  print('Yes')
else:
  print('No')

Solution (Python):
A = input()
B = [i for i in A]
B.sort()
if B.count(B[0]) == 2:
  if B.count(B[-1]) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
S = input()
A = {}
flag = 0
for i in S:
    if i in A:
        A[i] += 1
    else:
        A[i] = 1
for i in A:
    if A[i] == 2:
        continue
    else:
        flag=1
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
a,b,c,d = sorted(input())

if a==b and b!=c and c==d:
  print("Yes")
else:
  print("No")

Solution (Python):
A = input()
B = [_ for _ in A]
B.sort()
if B[0] == B[1] and B[2] == B[3] and B[1] != B[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
l = input()

l2 = set(l)

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

Solution (Python):
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()


if __name__ == '__main__':
    s = sread()
    s = set(s)
    if len(s) == 2:
        print("Yes")
    else:
        print("No")

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

Solution (Python):
S = [x for x in input().rstrip()]

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 = [x for x in input().rstrip()]

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

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

Solution (Python):
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]
def mi(n): return [wi() for _ in range(n)]
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

s = s()
for moji in range(4):
    cnt = 0
    for i in range(4):
        if s[moji] == s[i]:
            cnt += 1
    if cnt != 2:
        print("No")
        exit()
print("Yes")

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

Solution (Python):
moji = raw_input()
a,b,c,d = list(moji)
moji = list(moji)
if moji.count(a) == moji.count(b):
    if moji.count(b) == moji.count(c):
        if moji.count(c) == 2:
            print "Yes"
            exit()

print "No"

Solution (Python):
from collections import Counter

s = list(input())
s_cnt = Counter(s)
if s_cnt[s[0]] == 2 and len(set(s)) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
a = input()

str_list = list(a)

str_list.sort()



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

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

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

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

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

Solution (Python):
S=input()

judge=True
for i in range(4):
  counter=int(0)
  for j in range(4):
    if S[i]==S[j]:
      counter+=1
      
  if counter!=2:
    judge=False
    
if judge:
  print('Yes')
else:
  print('No')

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

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

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

Solution (Python):

s = input()

c1 = set(s)
c2 = sorted(s)

if len(c1) == 2 and c2[0] == c2[1] and c2[2] == c2[3]:
    print("Yes")
else:
    print("No")

Solution (Python):
t = input()
a = [i for i in t]
b = list(set(a))
if len(b) == 2:
    if a.count(a[0]) ==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
A = list(input())
A_duplicate = [x for x in set(A) if A.count(x) > 1]
if len(A_duplicate) == 2:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
S = input()
A = "".join(list(set(S)))
if len(A)!=2:
    print("No")
else:
    B = S.replace(A[0],'')
    if len(B)!=2:
        print("No")
    else:
        print("Yes")

Solution (Python):
s = list(input())
f = set(s)
if len(f) == 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")
else:
  if S[0] == S[1]:
    if S[2] == S[3]:
      print("Yes")
    else:
      print("No")
  elif S[0] == S[2]:
    if S[1] == S[3]:
      print("Yes")
    else:
      print("No")
  elif S[0] == S[3]:
    if S[1] == S[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 = input()
ans = 'No'
a = list({x for x in s})
if len(a) == 2:

  if s.count(a[0]) == 2 and s.count(a[1]) == 2:
    ans = 'Yes'
    
print(ans)

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

uniq = set(chars)
if(len(uniq) != 2):
  print("No")
elif(chars[1] != chars[2]):
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
flag = 0
for i in range(1,4):
    for j in range(i):
        if S[i] == S[j]:
            flag +=1

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

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

result = True
for i in range(4):
  dummy = chars.copy()
  a = dummy.pop(i)
  if not (a in dummy):
    result = False

if len(set(chars)) == 1:
  result = False
    
print("Yes" if result else "No")

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

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()
dic = {}
for c in s:
    if c not in dic:
        dic[c] = 1
    else:
        dic[c] += 1
if len(dic.keys()) == 2:
    if dic[c] == 2:
        print("Yes")
        exit()
print("No")

Solution (Python):
S = input().strip()
D = {}

for s in S:
    if s in D.keys():
        D[s] += 1
    else:
        D[s] = 1

if len(D) != 2:
    print("No")
else:
    for k, v in D.items():
        if v != 2:
            print("No")
            break
    else:
        print("Yes")

Solution (Python):
S = input()
a=1
b=0
x = ''
for i in range(len(S)-1):
    if S[i+1]==S[0]:
        a+=1
    elif b==0 or S[i+1]==x :
        x = S[i+1]
        b+=1
    else:
        print('No')
        exit()
if a==b==2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()

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

i = 0

if a == b:
  i += 1
if a == c:
  i += 1
if a == d:
  i += 1
  
if b == c:
  i += 1
if b == d:
  i += 1
if c == d:
  i += 1

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

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

Solution (Python):
a = input()
msg1 = "@"
msg2 = "
countmsg1 = 0
countmsg2 = 0
flag = 0
for strliteral in a:
    if strliteral == msg1:
        countmsg1 += 1
    elif strliteral == msg2:
        countmsg2 += 1
    else:
        if msg1 == "@":
            msg1 = strliteral
            countmsg1 += 1
        else:
            if msg2 == "
                msg2 = strliteral
                countmsg2 += 1
if countmsg2 == 2 and countmsg2 == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = list(input())
cnt = 0
for i in S:
	if S.count(i) == 2:
  		cnt += 1
if cnt == 4:
  print("Yes")
else:
  print("No")

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

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

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

Solution (Python):
s = input()
t = list(s.encode('us-ascii'))
t.sort()
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[1] != S[2]) & (S[2] == S[3]):
  print("Yes")
elif (S[0] == S[2]) & (S[1] != S[2]) & (S[1] == S[3]):
  print("Yes")
elif (S[0] == S[3]) & (S[0] != S[2]) & (S[1] == S[2]):
  print("Yes")
else:
  print("No")

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

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

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

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

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

Solution (Python):
S   =   input()

for i in range(int(len(S))):
    if(S.count(S[i]) !=2 ):
        print("No")
        exit()
print("Yes")

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

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

Solution (Python):
def main():
    S = input()
    if(len(set(S)) != 2):
        print("No")
        return
    S_sort = sorted(list(S))
    if (S_sort[1] == S_sort[2]): 
        print("No")
    else:
        print("Yes")

main()

Solution (Python):

S = input()

t = {}

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

if len(t) != 2:
	print("No")
elif len(list(filter(lambda c: t[c] != 2, t))) > 0:
	print("No")
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()
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):
import sys
input = sys.stdin.readline
from collections import defaultdict

def main():
	s = input().strip()
	m = defaultdict(lambda : 0)
	for c in s:
		m[c] += 1
	
	v = list(m.values())
	if len(m) == 2 and v[0] == 2 and v[1] == 2:
		print('Yes')
	else:
		print('No')


if __name__ == '__main__':
	main()

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):
w=input();s=list(set(list(w)))
print("YNeos"[len(s)!=2 or w.count(s[0])!=2::2])

Solution (Python):
import sys
input = sys.stdin.readline

def main():
	s = input().strip()
	u = set(s)
	if len(u) == 2:
		t = [1, 0]
		c = s[0]
		for i in range(1, 4):
			if c == s[i]:
				t[0] += 1
			else:
				t[1] += 1
		if t == [2, 2]:
			print('Yes')
			return
	print('No')


if __name__ == '__main__':
	main()

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


if __name__ == '__main__':
  main()

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

Solution (Python):
import collections
S =  input()
c=collections.Counter(S)

A = dict(c)
B = list(A.keys())

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

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

print(ans)

Solution (Python):
a=list(input())
b = []
for i in range(len(a)):
	if a.count(a[i])==2:
		b.append(a.count(a[i]))
if len(b)==4:
	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 and d[s[0]] == 2:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
S = list(input())
h = {}
for s in S:
    h[s] = 1
if len(h.keys()) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
l = list(input())
a = list(set(l))

if len(a) != 2:
  print('No')
elif l.count(a[0]) == 2 and l.count(a[1]) == 2:
  print('Yes')

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

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

Solution (Python):
s=[i for i in input()]
c=0
h={}
for i in s:
    if i not in h:
        h[i]=1
        c+=1
if c==2:
    print("Yes")
else:
    print("No")

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


def solve(S):
    ssort = sorted(S)
    if ssort[0] == ssort[1] and ssort[2] == ssort[3] and ssort[1] != ssort[2]:
        return "Yes"
    return "No"


print(solve(S))

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

Solution (Python):
l = list(input())
unique_l = list(set(l))
err = False

if len(unique_l) == 2:
    for s in unique_l:
        if l.count(s) != 2:
            err = True
            break
else:
    err = True

if not err:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
dic = {}
mes = "Yes"
for l in s:
  if l in dic:
    dic[l] +=1
  else:
    dic[l] = 1
for v in dic.values():
  if v !=2 :
    mes = "No"
print(mes)

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

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

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

Solution (Python):
s = input()                                                                                                                                                                  

list_sorted = sorted([s[i] for i in range(4)])
if list_sorted[0] == list_sorted[1] and  list_sorted[2] == list_sorted[3] and list_sorted[1] != list_sorted[2]:
    print("Yes")
else:
    print("No")

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

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

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

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

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

Solution (Python):
s = input()
a = set()
for i in range(len(s)):
  a.add(s[i])
if len(a) == 2:
  print('Yes')
else:
  print('No')

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

Solution (Python):
s=input()
h=set()
for i in range(0,len(s)):
	h.add(s[i])
if(len(h)==2):
	print("Yes")
else:
	print("No")

Solution (Python):
from collections import Counter as c
s=list(input())
a=c(s).most_common(2)
if len(a)==1:
    print("No")
    exit()

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

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

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

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

Solution (Python):
s=input()
h=set()
for i in range(0,len(s)):
	h.add(s[i])
if(len(h)==2):
	print("Yes")
else:
	print("No")

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

Solution (Python):
moji = list(input())
hako = []
for m in moji:
  if m not in hako:
    hako.append(m)
if len(hako) == 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):
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)


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

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Solution (Python):
S = list(input())
cnt = {}
for s in S:
    if s not in cnt:
        cnt[s] = 1
    else:
        cnt[s] += 1
for c in cnt:
    if cnt[c] != 2:
        print('No')
        exit()
print('Yes')

Solution (Python):
def main():
    s = list(input())
    dic = {}
    cnt = 0
    for i in s:
        if i not in dic:
            dic[i]  = 1
        else:
            dic[i] += 1
    for key,i in dic.items():
        cnt += 1
        if i != 2 or cnt > 2:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

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()
count = 0
for i in range(len(s)-1):
    for j in range(i+1, len(s)):
        if s[i] == s[j]:
            count += 1
if count == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
N = input() 
a=0
b=0
c=[[2,3],[1,3],[1,2]]

for i in range(1,4):
		if N[i] == N[0]:
			a+=1
			b=i			
if a==1:
	if N[c[b-1][0]] == N[c[b-1][1]]:
		print("Yes")
	else:
		print("No")

else:
	print("No")

Solution (Python):
N = input() 
a=0
b=0

d=[1,2,3]
for i in range(1,4):
		if N[i] == N[0]:
			a+=1
			b=i			
if a==1:
	d.pop(b-1)
	if N[d[0]] == N[d[1]]:
		print("Yes")
	else:
		print("No")

else:
	print("No")

Solution (Python):
S = input()
mozi = dict()
for i in range(4):
	mozi[S[i]] = 0

for i in range(4):
    mozi[S[i]] += 1

num = 0
for i in mozi:
  num += 1
  if mozi[i] != 2:
    print("No")
    exit()
 
if num == 2:
  print("Yes")
else:
  print("No")

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

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

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

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

Solution (Python):
import collections

s= input()
slist = list(s)

flag =0

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

if len(values)==2:
    for i in range(len(counts)):
        counts[i] ==2
        flag =1

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

Solution (Python):
S = input()

count = 0
if S[0] == S[1] and S[2] == S[3]:
    count += 1

if S[0] == S[2] and S[1] == S[3]:
    count += 1

if S[0] == S[3] and S[1] == S[2]:
    count += 1

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

Solution (Python):
S = input()


S = list(set(S))

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

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

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