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

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

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

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

Solution (Python):
S=input()
from collections import Counter
c = Counter(list(S))
cnt = 0
for char in list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
    if c[char] == 2:
        cnt += 1
if cnt == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
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")

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

Solution (Python):


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

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

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

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

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

print('Yes')

Solution (Python):
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')

Solution (Python):
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')

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

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

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

Solution (Python):
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")

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

Solution (Python):
s = input()

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

Solution (Python):
from collections import Counter
import sys

S = input()
c = Counter(S)
for k, v in c.items():
    if v != 2:
        print('No')
        sys.exit(0)
print('Yes')

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

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

Solution (Python):
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')
    exit()

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

Solution (Python):
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")
        exit(0)

print("Yes")

Solution (Python):
from collections import defaultdict
dic = defaultdict(int)
s = list(input())
for i in s:
    dic[i]+=1
b = True
for j in s:
    if dic[j]!=2:
        b=False
if b:
    print("Yes")
else:
    print("No")

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

Solution (Python):
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")

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


if __name__ == "__main__":
    main()

Solution (Python):
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')

Solution (Python):
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")

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

S.sort()


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

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

a=set(s)

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

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

Solution (Python):
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')

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


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

Solution (Python):
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")

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

Solution (Python):
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")

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

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

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

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

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


import sys
import math
import time

import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools











S = str(input())
ans = "Yes"

for i in range(4):
  if(S.count(S[i])!=2):
    ans = "No"

print(ans)

Solution (Python):

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

Solution (Python):
S = input()
 




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

Solution (Python):
S = input()
 





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

Solution (Python):
from collections import Counter
s = input()
x = Counter(s)
y = sorted(list(x.values()))
if y[0]*y[-1] == 4:
    print("Yes")
else:
    print("No")

Solution (Python):
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')

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

Solution (Python):
S = list(input())
if len([x for x in set(S) if S.count(x) > 1]) == 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):
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')
    exit()
print('Yes')

Solution (Python):
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')

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

Solution (Python):
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')

Solution (Python):
from collections import defaultdict

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

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

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

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

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

Solution (Python):
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")
    exit()
print("Yes")

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

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

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

Solution (Python):
S = input()
from collections import defaultdict
dic = defaultdict(int)

for s in S:
    dic[s] += 1
print('Yes' if len(dic)==2 and dic[s[0]]==2 else 'No')

Solution (Python):
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')

Solution (Python):
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")

Solution (Python):
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")

Solution (Python):
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")

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

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

Solution (Python):
s = input()

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

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

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


S = LS2()
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()

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

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

Solution (Python):
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")

Solution (Python):
S = input()

L = {}

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

print(ans)

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

Solution (Python):
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")

Solution (Python):
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  
def LS2(): return list(sys.stdin.readline().rstrip())  


S = LS2()
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 = list(input())
memo = {}
for i in s:
    if i in memo:
        memo[i] += 1
    else:
        memo[i] = 1
flag = True
for key,val in memo.items():
    if val != 2:
        flag=False
        break
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input().strip()
C = {}
for i in range(len(S)):
    if S[i] not in C:
        C[S[i]] = 0
    C[S[i]] += 1
if len(C)==2:
    flag = 0
    for a in C:
        if C[a]!=2:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

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

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

Solution (Python):
moji = str(input())
dictionary = {}
for i in moji:
    if i not in dictionary:
        dictionary[i] = 1
    else:
        dictionary[i] += 1
if len(dictionary) == 2 & dictionary[i] == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = sorted(list(input()))
bl = (S[0]==S[1] and S[1]!=S[2] and S[2]==S[3])

print('Yes' if bl == 1 else 'No')

Solution (Python):
from collections import Counter

S = list(input())
counter = dict(Counter(S))
cnt_v = list(counter.values())

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

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

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

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

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

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

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

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

for e in s_set:
    if s.count(e) != 2:
        print('No')
        break
else:
    print('Yes')

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

Solution (Python):
s=list(input())
a=len(set(s))
ans='No'
if a==2:
  b=len([t for t in s if t==s[0]])
  if b==2:
    ans='Yes'
print(ans)

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

Solution (Python):
import re
S = input()
s = set(S)
m = re.findall(S[0],S)
m

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

Solution (Python):
s=str(input())
l=[s[0],s[1],s[2],s[3]]
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=len(set(s))
if(l==2):
    print("Yes")
else:
    print("No")

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

main()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def main():
    s = input().strip()
    a = s[0] ; b = None
    c = 1 ; d = 0

    for i in range(1, 4):
        if s[i] == a:
            c += 1

        elif b == None:
            b = s[i]
            d += 1

        elif s[i] == b:
            d += 1

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

main()

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

Solution (Python):
from collections import Counter


def main():
    S = input()

    c = Counter(S)

    if len(c) == 2 and list(c.values())[0] == 2 and list(c.values())[1] == 2:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter
s = input()
c = Counter(s)
uni = set(s)
if len(uni) == 2 and c[s[0]] == 2:
  print("Yes")
else:
  print("No")

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

check = True
for i in range(4):
  if S.count(S[i]) != 2:
    check = False
    
print("Yes" if check else "No")

Solution (Python):
from collections import Counter
S = input()
a = Counter(S)


if len(a) == 2 and len(set(list(a.values()))) == 1:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
S = list(input())
d = dict()
for i in S:
  if not i in d:
    d[i] = 1
  else:
    d[i] += 1

res = "Yes"
for i in d.values():
  if i != 2:
    res = "No"
    break
print(res)

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

Solution (Python):
from collections import Counter
S = list(input())
S = Counter(S)

if len(S)==2:
    for i, j in S.items():
        if j != 2:
            print('No')
            exit()

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

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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

Solution (Python):
s=input()
s1=sorted(s)
if s.count(s[0])==2 and s.count(s[2])==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):
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy


import heapq
sys.setrecursionlimit(10**6)

INF = 10**18
import bisect
import statistics
mod = 10**9+7


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

Solution (Python):
S = input()
is_true = True
for i in range(len(S)):
    if S.count(S[i]) != 2:
        is_true =  False
        break
if is_true:
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = input()

S = sorted(S)

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

Solution (Python):
s = input().split()
b = list(s[0][0] + s[0][1] + s[0][2] + s[0][3])
sset = set(b)
if len(sset) == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
count = 0
same = []
for letter in S:
    if S.count(letter) == 2 and letter not in same:
        same.append(letter)
        count += 1

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

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

Solution (Python):




word = input()
dic_char = {}
for s in word:
    if s in list(dic_char.keys()):
        dic_char[s] += 1
    else:
        dic_char[s] = 1

check = True
for s, count in dic_char.items():
    if count != 2:
        check = False

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

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

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

a=S[0]
b=S[1]
c=S[2]
d=S[3]
l=[a,b,c,d]
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.count(s[0]) == 2 and s.count(s[2]) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=list(input())
from collections import Counter
s=Counter(s)

if len(s)==2:
  if min(s.values())==2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):


s = input()
s = s.replace(s[0], "")

if(len(s) == 2):
    s = s.replace(s[0], "")
    if(len(s) == 0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

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

Solution (Python):
string=input()
list=[]
for i in range(0,len(string)):
         if string[i] not in list:
            list.append(string[i])

         if string[i] not in list:
            list.append(string[i])

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

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

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

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

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

Solution (Python):

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

if __name__ == "__main__":
    main()

Solution (Python):
s=str(input())
s2=[]
a=0
for i in range(4):
    if s[i] in s2:
        a+=1
    else:
        s2.append(s[i])
if a==2 and len(s2)==2:
    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):
from collections import Counter
s = input()
S = Counter(s).most_common()
print('Yes' if S[0][1] == 2 and S[1][1] == 2 else 'No')

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

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

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

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

Solution (Python):
s=input()

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

Solution (Python):
s1,s2,s3,s4 = list(input())
p=0
if s1==s2 and s2== s3 and s3==s4:
    p=1
elif s1==s2:
    if s3!=s4:
        p=1
elif s1==s3:
    if s2!=s4:
        p=1
elif s1==s4:
    if s3!=s2:
        p=1
else:
    p=1
if p==0:
    print("Yes")
elif p==1:
    print("No")

Solution (Python):
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    cnt = collections.Counter(S)
    if list(cnt.values()) == [2, 2]:
        print(('Yes'))
    else:
        print(('No'))

if __name__ == '__main__':
    resolve()

Solution (Python):
S = list(input())
w = {}
for s in S:
    if w.get(s) == None:
        w[s] = 1
    else:
        w[s] += 1

if len(w) == 2 and sum(w.values()) == 4:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
S = input().rstrip()
dic = Counter(S)
print("Yes" if list(dic.values())==[2,2] else "No")

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

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

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

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

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

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

print(ans)

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

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