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 = list(input())
s_setted = list(set(s))
if len(s_setted) == 2:
    s_one = 0
    s_two = 0
    for s_elem in s:
        if s_elem == s_setted[0]:
            s_one += 1
        if s_elem == s_setted[1]:
            s_two += 1
    if s_two == 2 and s_one == 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):
import sys,collections
S = list(input())
S_Collection = collections.Counter(S) 


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

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

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 p_a():
    s = Counter(input())
    if len(s.keys()) == 2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    p_a()

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  


def solve(S: str):
    s_list = list(S)
    dic = {}
    for st in s_list:
        if st in dic:
            dic[st] += 1
        else:
            dic[st] = 1
    is_ok = True
    for key, val in dic.items():
        if val != 2:
            is_ok = False
    if len(dic) != 2:
        is_ok = False
    if is_ok:
        print(YES)
    else:
        print(NO)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)

if __name__ == '__main__':
    main()

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

Solution (Python):

A = list(input())
print('Yes' if len(set(A)) == 2 & A.count(A[0]) == 2 else 'No')

Solution (Python):

A = input()
if len(set(A)) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')

Solution (Python):
S = input()

cnt = [0,0,0,0]

for i in range(4):
  
  for j in range(4):
    if S[i] == S[j]:
      cnt[i] += 1
      
    else:
      pass

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

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

Solution (Python):
s = sorted(list(input()))
if s[0] == s[1] and s[2] == s[3] and s[0] != 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]:
    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 collections

s = input()

count_char = collections.Counter(s)

if len(count_char) == 2 and all(map(lambda x: x == 2, count_char.values())):
    print("Yes")
else:
    print("No")

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

if [2,2] == [x for x in c.values()]:
  print('Yes')
else:
  print('No')

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

Solution (Python):
s = input()

count = [0,0,0,0]
for i in range(len(s)):
  for j in range(len(s)):
    if s[i] == s[j]:
      count[i] += 1

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

Solution (Python):
S = input()
ans = "No"

if len(set(list(S))) == 2 and list(S).count(list(S)[0]) == 2:
    ans = "Yes"

print(ans)

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

if(all(s.count(x)==2 for x in s )):
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
s = list(input().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=list(input())
s.sort()
if s.count(s[0])==2 and s.count(s[2])==2:
    print('Yes')
else:
    print('No')

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

Solution (Python):
s = input()

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

Solution (Python):
import collections
def counter_list(A):
  counter = collections.Counter(A)
  counter =  [list(e) for e in counter.items()]
  
  return counter

S = list(input())
A = counter_list(S)
judge = 0

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

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

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

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

print("Yes")

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

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

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

Solution (Python):

import sys


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


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)


if __name__ == "__main__":
    main()

Solution (Python):
S = input()
count = 0
s1 = 0
s2 = 0
A = dict()
N = len(S)
judge = True
for i in range(N):
    if S[i] in A:
        A[S[i]] += 1
        if A[S[i]] > 2:
            judge = False

    else:
        A[S[i]] = 1
        count += 1
if count > 2:
    judge = False
    
if judge:
    print('Yes')
else:
    print('No')

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

Solution (Python):
S = list(input())
S.sort()
if S[0] == S[1] and S[2] == 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):
a = input()

kotae = 'No'

if a[0] == a[1] and a[2] == a[3] and a[0] != a[2]:
  kotae= 'Yes'

if a[0] == a[2] and a[1] == a[3] and a[0] != a[1]:
  kotae= 'Yes'

if a[0] == a[3] and a[1] == a[2] and a[0] != a[1]:
  kotae= 'Yes'

print(kotae)

Solution (Python):
import collections

s = input()

list_s = [s[i] for i in range(len(s))]
count = collections.Counter(list_s)
count = [v for v in count.values()]

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

Solution (Python):
S = input()
S_list = list(S)
S_set = set(S_list)
for s in S_list:
    if S_list.count(s) == 2 and len(S_set) == 2:
        print('Yes')
        break
    else:
        print('No')
        break

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

s=input()
l=[]
count=0
for i in range(4):
    for j in range(4):
        if s[i]==s[j]:
            count+=1
    l.append(count)
    count=0

l=set(l)
if len(l)==1 and l=={2}:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import stdin

s = stdin.readline().rstrip()

li = list(set(s))

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

Solution (Python):
from collections import Counter

S = list(input().strip())

C = Counter(S)

for k,v in C.items():
  if v == 2:
    continue
  else:
    break
else:
  print("Yes")
  quit()
print("No")

Solution (Python):
s = input()
ans = []
for i in range(4):
    ans.append(s[i])

ans.sort()
print('Yes' if ans[0] == ans[1] and ans[2] == ans[3] and ans[0] != ans[2] else 'No')

Solution (Python):
S = input()

ans = 0
for i in range(4):
    if S.count(S[i]) == 2:
        ans += 1

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

Solution (Python):
import collections
s = input()

d = dict(collections.Counter(s))

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

Solution (Python):
S = input()

stringSet = set([S[0],S[1],S[2],S[3]])

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

Solution (Python):
from collections import Counter

s = input()

c = Counter(s)

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

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

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

ans = 'Yes'

if len(s) != 2 :
    ans = 'No'
else :
    a, b = s
    if not S.count(a) == S.count(b) == 2 :
        ans = 'No'

print(ans)

Solution (Python):
S = input()

res = "Yes"
s = set(list(S))
if len(s) != 2:
    res = "No"
else:
    a, b = s
    if not S.count(a) == S.count(b) == 2:
        res = "No"
print(res)

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

Solution (Python):
s = list(input())
c = list((set(s)))
ans = []
for i in range(len(c)):
    ans.append(s.count(s[i]))
if ans == [2,2]:
    print("Yes")
else:
    print("No")

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

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

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

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

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

Solution (Python):
import collections
S = input()
c = collections.Counter(S)
key = [k for k,v in c.items() if v == 2]
if len(key) == 2:
    print('Yes')
else:
    print('No')

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

Solution (Python):
s = input()

for i in s:
    
    score  = 0
    for j in s:
        if i == j:
            score += 1

    if score != 2:
        print("No")
        exit()

print("Yes")

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

Solution (Python):
n=input()
a=[]
b=0
c=0
for i in n:
    if not i in a:
        a.append(i)
        b+=1
    elif i in a:
        c+=1
if b==2 and c==2 :
    print("Yes")
else:
    print("No")

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):
print("YNeos"[len(set(input()))!=2::2])

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())
s=list(set(S))
if len(s) ==2 :
  c_num=S.count(s[0])
  if c_num == 2 :
    print("Yes")
else:
  print("No")

Solution (Python):

A = str(input())
Acount =[]
ans = 'No'

for i in range(len(A)):
    if A.count(A[i]) == 2:
        Acount.append(2)
    else:
        Acount.append(0)

if Acount == [2,2,2,2]:
	print('Yes')
else:
	print('No')

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

A = S[0] != S[1]
B = S[2] != S[3]
C = S[1] == S[2]

if A or B or C:
    print("No")
else:
    print("Yes")

Solution (Python):
i = input()
j = [_ for _ in i]
j = set(j)
if len(j) == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
s  = sorted(list(input()))
if(s.count(s[0]) == 2) and (s.count(s[2]) == 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):
import sys
s = input()

s = [val for val in s]
s.sort()

a = set(s)
if len(a) != 2:
    print("No")
    sys.exit()
if s[1] != s[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import defaultdict
dd = defaultdict(int)
s=input()
for key in s:
    dd[key] += 1

keys=list(set(s))
if len(keys)!=2:
  print("No")
elif dd[keys[0]]==2 and dd[keys[1]]==2:
  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[3] else 'No')

Solution (Python):
import copy
import sys
from _operator import itemgetter
from collections import Counter
from math import log2, pi, ceil

stdin = sys.stdin

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

s = input()
c = Counter(s)
print('Yes' if len(c.keys()) == 2 and max(c.values()) == 2 else '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=input()
if s.count(s[0])==2 and len(set(s))==2:
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
A=list(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):
s=list(input())
so = set(s)
    
if len(so) == 2 and  [ s.count(c) for c in so ] == [2,2] :
  print("Yes")
else:
  print("No")

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

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

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

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

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

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

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

Solution (Python):
s=input()
import collections
c = collections.Counter(s)
if len(c) == 2:
    if min(c.values()) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
s = input()
s = [ t for t in s ]
so = set(s)
 
if len(so) == 2 and  [ s.count(c) for c in so ] == [2,2] :
  print("Yes")
else:
  print("No")

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

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

Solution (Python):
from sys import exit, stdin
from collections import Counter
S = Counter(stdin.readline().rstrip())
if len(S.keys()) == 2 and set(S.values()) == {2}:
    print("Yes")
else:
    print("No")

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

Solution (Python):
s = input()

t = sorted(s)



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

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

Solution (Python):
from collections import Counter
s=input()
def judge(s):
  d=Counter(s)
  if len(d) != 2:
    return print("No")
  else:
    for k in d:
      if d[k] != 2:
        return print("No")
  return print("Yes")
judge(s)

Solution (Python):
S = input()
if len(set(S)) != 2:
    print('No')
else:
    if [S.count(x) for x in set(S)] == [2,2]:
        print('Yes')
    else:
        print('No')

Solution (Python):
def main(): 

    S = input()

    List = [] 

    for s in S:
        if s not in List:
            List.append(s)

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

if __name__ == "__main__":
    main()

Solution (Python):
S=input()

count=0

for i in S:
    if S.count(i) == 2:
        count +=1
        

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

Solution (Python):
S = list(input())
S.sort()
if (S[0] == S[1] and S[0]!= S[2] and S[2] == S[3]):
    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):
S = input()
li = sorted(list(S))
bl = (li[0] == li[1] != li[2] and li[2] == li[3])
answer = 'Yes' if bl else 'No'
print(answer)

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

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

print(ans)

Solution (Python):

s = input()
dic = {}
for i in range(len(s)):
    c = s[i]
    count = dic.setdefault(c, 0) + 1
    dic[c] = count

result = "Yes"
for k in dic:
    if dic[k] != 2:
        result = "No"

print(result)

Solution (Python):
List=list(input())
a=List[0]
b=List[1]
c=List[2]
d=List[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 = 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(list(set(s))) == 2 and s.count(s[0]) == s.count(s[1]) and s.count(s[1]) == s.count(s[2]):
    print('Yes')
else:
    print('No')
print()

Solution (Python):
s = list(input())
t = list(set(s))
if len(t) == 2 and s.count(t[0]) == s.count(t[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 = input()
s_list = [0] * 4
s_list = sorted([c for c in s])

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

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

Solution (Python):
S=input()

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

Solution (Python):
from collections import Counter
S = input().strip()
dic = Counter(S)
if len(dic)==2 and dic[S[0]]==2:
    print("Yes")
else:
    print("No")

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

cnt = 0
for x in S:
    if S.count(x) == 2:
        cnt += 1

print ( 'Yes' if cnt == 4 else 'No' )

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

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

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

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

Solution (Python):
a = input()
b = len(a)
d = 0

for x in range(b):
    c = a.count(a[x])
    if c == 2:
         d += 1

if d == b:
    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 = input()
a = []
for n in s:
    a.append(n)
if a.count(a[0]) == 2 and a.count(a[1]) == 2 and a.count(a[2]) == 2 and a.count(a[3]) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
c = 0
for i in S:
  if S.count(i) == 2:
    c = c + 1
if (c == 4):
  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[1] == s[2] and s[0] != s[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[0] != s[2]:
  print("Yes")
else:
  print("No")

Solution (Python):
inpt = input()
a = []
for i in inpt:
  a.append(i)
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()
res_1 = 0
res_2 = 0
s_1 = s[0]
s_2 = None

for i in range(1, 4):
    if s[i] == s_1:
        res_1 += 1
    elif s[i] == s_2:
        res_2 += 1
    elif not s_2:
        s_2 = s[i]


if res_1 == 1 and res_2 == 1:
    print("Yes")
else:
    print("No")

Solution (Python):
while True:
    try:
        S = list(input())
        dic = {c:S.count(c) for c in set(S)}
        
        if len(dic.keys()) != 2:
            print("No")
        else:
            for cnt in dic.values():
                if cnt != 2:
                    print("No")
                    break
            else:
                print("Yes")
    except:
        break

Solution (Python):
from collections import Counter
n = input()
length = len(set(n))
c = Counter(n)

if length == 2 and max(c.values()) ==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):
S = input()

if S[0] == S[1] and S[0] == S[2] and S[0] == 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):
def main():
    s = sorted(list(input()))

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

if __name__ == '__main__':
    main()

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

Solution (Python):
from sys import stdin

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

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

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

Solution (Python):
num = 0
a = input()
s = [str(c) for c in a]
for i in range(4):
    for j in range(i + 1, 4):
        if(s[i] == s[j]):
            num += 1
if num == 2:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
from collections import Counter

s = input()

def solve(s):
	counter = Counter(s)
	for c in counter:
		if counter[c] != 2:
			return False
	return True

print("Yes" if solve(s) else "No")

Solution (Python):
l = list(input())
l2 = list(set(l))
if len(l2) == 2:
  n = 0
  if l[0] == l[1] and l[0] != l[2] and l[0] != l[3]:
    n += 1
  elif l[0] != l[1] and l[0] == l[2] and l[0] != l[3]:
    n += 1
  elif l[0] != l[1] and l[0] != l[2] and l[0] == l[3]:
    n += 1
  else:
    n += 0
  if n == 1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
a,b,c,d = sorted(input())
if a == b and c == d and a != c:
  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 = str(input())

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

for i in strs:
  if len(list(filter(lambda x: i == x, s))) != 2:
    print("No")
    exit()

print("Yes")

Solution (Python):
b_list = list(str(input()))
b_list = sorted(b_list)

if b_list[0] == b_list[1] and b_list[1] == b_list[2]:
    print("No")
elif b_list[0] == b_list[1] and  b_list[2] == b_list[3]:
    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()
a = set()
for i in s: a.add(i)
if len(a) == 2 and s.count(s[0]) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
if len(dic) == 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 = input()
srt = sorted(s)
if srt[0] == srt[1] and srt[1] != srt[2] and srt[2] == srt[3]:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    from collections import defaultdict
    S = input()
    ans = defaultdict(str)
    for s in S:
        if s in ans:
            ans[s] += 1
        else:
            ans[s] = 1

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


if __name__ == '__main__':
    main()

Solution (Python):
S = input()

S = sorted(S)

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

Solution (Python):
n = input()

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

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

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

Solution (Python):
s = input()

ch1 = ''
ch2 = ''
ct1 = 0
ct2 = 0
for c in s:
	if ch1 == '':
		ch1 = c
		ct1 += 1
	elif ch1 == c:
		ct1 += 1
	elif ch2 == '':
		ch2 = c
		ct2 += 1
	elif ch2 == c:
		ct2 += 1

if ct1 == 2 and ct2 == 2:
	print('Yes')
else:
	print('No')

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

Solution (Python):
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b



def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2



def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)



def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()
    c = Counter(S)
    if len(c) == 2 and list(c.items())[0][1] == 2 and list(c.items())[1][1] == 2:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
s = input()

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

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