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

cnt = []
for i in range(4):
  cnt.append(s.count(s[i]))
  
if all(n == 2 for n in cnt):
  print('Yes')
else:
  print('No')

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

Solution (Python):
s = str(input())
s1 = [s[i] for i in range(4)]
from collections import Counter
s2 = Counter(s1).most_common(2)
if s2[0][1] == 2 and s2[1][1] == 2:
    print('Yes')
else:
    print('No')

Solution (Python):








s = input()

temp = sorted(s)

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

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

Solution (Python):
S = input()

letter = []
for i in range(65, 91):
    letter.append(S.count(chr(i)))
letter = sorted(letter, reverse=True)
if letter[0] == 2 and letter[1] == 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):
a=list(input())
b=set(a)
count=0
for i in range(4):
  if a[0]==a[i]:
    count+=1
if len(b)==2 and (count==2):
  print('Yes')
else:
  print('No')

Solution (Python):
from collections import defaultdict
S = input()
t = defaultdict(int)
for i in S:
  t[i] += 1
if len(t.keys()) == 2:
  for i in t.values():
    if i != 2:
      print("No")
      break
  else:
    print("Yes")
else:
  print("No")

Solution (Python):
str = input()
a1 = str[0]
a2 = str[1]
a3 = str[2]
a4 = str[3]

if str.count(a1) == 2 and str.count(a2) == 2 and str.count(a3) == 2 and str.count(a4) == 2:
  print("Yes")
else:
  print("No")

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

for v in d.values():
    if v == 2:
        continue
    print('No')
    exit()
else:
    print('Yes')

Solution (Python):
s = input()
ans = 'No'
index = s.find(s[0], 1)
if index >= 1:
    s = s.replace(s[0], '')
    if (len(s) == 2):
        if (s[0] == s[1]):
            ans ='Yes'
    
print(ans)

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 Counter

s = input()
counter = Counter(s)
if len(counter.keys()) == 2:
    for key, val in counter.items():
        if val != 2:
            print("No")
            exit()
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

counter_map = dict()
for i in range(4):
    if s[i] not in counter_map:
        counter_map[s[i]] = 1
    else:
        counter_map[s[i]] += 1

for i in counter_map.values():
    if i == 2:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
S=input().strip()
h={}
for s in S:
  h[s]=0

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

Solution (Python):
S=input()
l=[]
for s in S:
  if not s in l:
    l.append(s)
if len(l) == 2:
  p = 2
  for s in S:
    if l[0] == s:
      p-=1
  if not p:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
S1 = input()
S2 = list(S1)
S2.sort()

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

Solution (Python):
s=input();print('NYoe s'[[s.count(i)==2 for i in s] and len(set(s))==2::2])

Solution (Python):


def main():

    S = input()

    listS = list(S)
    listS.sort()

    ans = 'No'
    
    if listS[0] == listS[1] and listS[2] == listS [3] and listS[1] != listS[2]:
        ans = 'Yes'

    print(ans)


if __name__ == "__main__":
    main()

Solution (Python):
s = input()
v = [0] * 26
for i in range(4):
    v[ord(s[i])-65] += 1
for i in range(26):
    if v[i] == 1 or v[i] == 3 or v[i] == 4:
        print('No')
        exit()
print('Yes')

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

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

Solution (Python):

















































global FLAG_LOG
FLAG_LOG = False


def log(value):
    
    
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[0]
    
    
    
    
    
    
    
    
    
    

    values = list()
    for i in range(4):
        values.append(S[i])

    values.sort()

    result = 'Yes'
    if values[0] != values[1]:
        result = 'No'
    if values[1] == values[2]:
        result = 'No'
    if values[2] != values[3]:
        result = 'No'

    return [result]



def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines



def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['ASSA']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['STOP']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['FFEE']
        lines_export = ['Yes']
    if pattern == 4:
        lines_input = ['FREE']
        lines_export = ['No']
    return lines_input, lines_export



def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode



def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    
    
    
    
    
    
    
    
    
    
    



if __name__ == '__main__':
    main()

Solution (Python):
s = input()
sd = s[::-1]
ans = 'No'
if len(set(s)) == 2:
    c = 0
    for i in range(4):
        if s[i] == sd[i]:
            c += 1
    if c%2 == 0:
        ans = 'Yes'
print(ans)

Solution (Python):
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

s = input()
co = collections.Counter(list(s))
f =True
if len(co) ==2:
    for it,cnt in co.items():
        if cnt!=2:
            f=False
else:f=False
yn(f)

Solution (Python):
S=input()
T=list(S)
U=list(set(T))
b=[0]*2
if len(U)==2:
  for x in range(4):
    if U[0]==S[x]:
      b[0]+=1
    elif U[1]==S[x]:
      b[1]+=1
  if b[0]==2 and b[1]==2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):

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

Solution (Python):
from collections import Counter
S = input()
ans = []
for i in range(4):
    ans.append(S[i])
ans = Counter(ans)
if len(ans) == 2 and ans[S[0]] == 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[2]):
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

s=input()

c = Counter(list(s))

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

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

Solution (Python):
S = input()
group = set(S)
count = 0
if len(group) == 2:
    for _ in S:
        if _ == list(group)[0]:
            count += 1

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

Solution (Python):


s = input()
cnt = {l:0 for l in set(s)}
if len(cnt) != 2:
    print('No')
    exit(0)

for l in s:
    cnt[l] += 1
    if cnt[l] > 2:
        print('No')
        exit(0)

print('Yes')

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

def pj(cond):
  print({True: "Yes", False:"No"}[cond])

d = {}
for c in S:
  if c in d:
    d[c] += 1
  else:
    d[c] = 1
if len(d.keys()) != 2:
  pj(False)
  exit(0)
if not all(i == 2 for i in d.values()):
  pj(False)
  exit(0)
pj(True)

Solution (Python):
from collections import Counter
S = input()
cnt = Counter(list(S))
print('Yes' if list(cnt.values()) == [2, 2] else '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):
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

s =s()
a = Counter(s)
if len(a)==2:
    for i in a.values():
        if i==2:
            pass
        else:
            print("No")
            sys.exit()
else:
    print("No")
    sys.exit()

print("Yes")

Solution (Python):
import collections
S=input()
s=collections.Counter(S)
S=list(set(S))
if len(S)!=2:
    print("No")
else:
    for i in S:
        if s[i]==2:
            pass
        else:
            print("No")
            break
    else:
        print("Yes")

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

import collections
s = collections.Counter(S)

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

Solution (Python):
S = input()
x = 0
for i in range(len(S)):
    if S.count(S[i]) == 2:
        x += 1

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

Solution (Python):
from collections import Counter

S = list(input())
c = Counter(S)

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

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

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

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

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

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

for v in dic.values():
    if v != 2:
        flag += 1

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

Solution (Python):
s = input()
a1 = s[0]
a2 = s[1]
a3 = s[2]
a4 = s[3]
alis = set()
alis.add(a1)
alis.add(a2)
alis.add(a3)
alis.add(a4)
if len(alis) == 2 and ((a1 == a2 and a3 == a4) or (a1 == a3 and a2 == a4) or (a1 == a4 and a2 == a3)):
  print('Yes')
else:
  print('No')

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

Solution (Python):
s = input()

lists = [i for i in s]
sets = set(lists)

if len(sets) != 2:
  print('No')
else:
  if lists.count(lists[0]) == 2:
    print('Yes')
  else:
    print('No')

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

if not ( len(S) == 4 and pre_S.isupper() ): sys.exit()

uniq = set(S)
count = 0
if len(uniq) == 2:
    for I in uniq:
        if S.count(I) == 2: count += 1
print('Yes') if count == 2 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):
s = list(input())
ss = set(s)
if len(ss) != 2:
    print('No')
    exit()

for s1 in ss:
    if s.count(s1) != 2:
        print('No')
        exit()

print('Yes')

Solution (Python):
a=input()
s = {a[0],a[1],a[2],a[3]}
if len(s) == 2:
  b = s.pop()
  flag1 = a.count(b)
  c = s.pop()
  flag2 = a.count(c)
  if flag1 ==2 and flag2 == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
s = input()
a = [i for i in s]
a1 = list(set(a))

print("Yes" if len(a1) == a.count(a1[0]) == 2 else "No")

Solution (Python):
s = input()
if len(set(s)) == 2 and sum(s[i] == s[-i] for i in range(4))%2 == 0:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

S = rs()

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

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

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

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

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

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

Solution (Python):


import sys
stdin = sys.stdin
from collections import Counter

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    lc = list(Counter(s).values())
    if len(lc) == 2 and lc[0] ==lc[1]:
        print("Yes")
    else:
        print("No")
    

if __name__ == "__main__":
    main()

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

Solution (Python):
from collections import Counter as C
 
S = input()
 
c = C(S)
if len(c.keys())==2:
  if list(c.values())[0]==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):
line = list(input())
line.sort()
if line[0] == line[1] and line[2] == line[3] and line[1] != line[2]:
    print("Yes")
else:
    print("No")

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

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

flg=False
for s in ss:
  if d[s]!=2:
    flg=True
print("No" if flg else "Yes")

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

Solution (Python):
s=list(str(input()))
ans=[]
for i in s:
	if i not in ans:
		ans.append(i)

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

Solution (Python):
S = input()
temp = S[0]
temp1 = '0'
a = 1
b = 0
c = 0
for i in range(1,4):
  if temp == S[i]:
    a = a+1
  elif temp1 == S[i]:
    c = c+1
  else:
    temp1 = S[i]
    b = b+1
if b == 1 and a == 2 and c == 1:
  print('Yes')
else:
  print('No')

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

Solution (Python):
s = input()
s1 = s[:1]
for i in range(1, 4):
  if(s[i:i+1] != s1):
    s2 = s[i:i+1]
if(s.count(s1) == 2 and s.count(s2) == 2):
  print("Yes")
else:
  print("No")

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 b == c and a != c:
  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[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):
a=set(input())
if len(a)==2:
    print("Yes")
else:
    print("No")

Solution (Python):

import datetime
from decimal import Decimal, ROUND_DOWN
import heapq
from fractions import gcd
from functools import reduce
from collections import deque

import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)


















s = input()
count = collections.Counter(s)
for i in count.values():
    if i != 2:
        print("No")
        exit()
print("Yes")

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

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

Solution (Python):
x,y,z,w = input()

l = []
l.append(x)
l.append(y)
l.append(z)
l.append(w)
new_l = sorted(l)

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

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

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

Solution (Python):
s = input()
counter = {}
flag = True

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

for x, y in counter.items():
    if y != 2:
        flag = False
        break

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

Solution (Python):



S = list(input())

if len(set(S)) == 2:
    if S.count(S[0]) == 2:
        print("Yes")
        quit()
print("No")

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

ans = "No"

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

print(ans)

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

Solution (Python):



s = input()
from collections import Counter
d = Counter(s)
if len(d.keys()) == 2 and all(i == 2 for i in d.values()):
	print("Yes")
else:
	print("No")

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

Solution (Python):
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

Solution (Python):
def main():
    a=input()
    b=set(a)
    if(len(b)==2):
        if(a.count(b.pop())==2):
            if(a.count(b.pop())==2):
                print("Yes")
                return;
    print("No")

main()

Solution (Python):
s = input()
ans = 0
for i in range(len(s)):
  if s.count(s[i]) == 2:
    ans += 1
    
if ans == 4:
  print('Yes')
else:
  print('No')

Solution (Python):
s=input()
ans=0
for i in range(4):
    for j in range(4):
        if s[i]==s[j]:
            ans+=1
        else:
            pass
if ans==8:
    print("Yes")
else:
    print("No")

Solution (Python):
def ans(S):
	Sset=set(S)
	if len(Sset)==2:
		for i in Sset:	
			if S.count(i)==2:
				print("Yes")
				return
	print("No")

S=input()
ans(S)

Solution (Python):
import collections
dict_values = []


S = input()

c = collections.Counter(S)

d = len(c)


f = list(c.values())



if (d==2) and f[0]==f[1]:
    print("Yes")
    
else:
    print("No")

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

def main():
    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')
    
if __name__ == '__main__':
    main()

Solution (Python):


import io
import sys
import math

def solve(s):
    
    pass

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

_DEB = 0   

_INPUT = """\
AACD
"""
_EXPECTED = """\
Yes
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")


if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Solution (Python):


import io
import sys
import math

def solve(s):
    
    a,b = "",""
    cnt = 0
    
    for c in s:
        if a == "":
            a = c
            cnt += 1
        elif a == c:
            cnt += 1
        elif b == "":
            b = c
        elif b != c:
            return False
    return cnt == 2

def main():
    
    s = input()

    ans = "Yes" if solve(s) else "No"
    
    
    print(ans)
    return ans
        

_DEB = 0   

_INPUT = """\
FFEE
"""
_EXPECTED = """\
Yes
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")


if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Solution (Python):
def ABC_132_A():
    S = input()
    if S.count(S[0]) != 2 or S.count(S[1]) != 2 or S.count(S[2]) != 2 or S.count(S[3]) != 2:
        print('No')
    else:
        print('Yes')
 
if __name__ == '__main__':
 
    ABC_132_A()

Solution (Python):
s = input()
ss = set(s)
flg = True

if len(ss) != 2:
    flg = False

for i in ss:
    if s.count(i) != 2:
        flg = False
    
print('Yes') if flg else print('No')

Solution (Python):
S = str(input())
cnt = 0
cha = []
for s in S:
  if s not in cha:
    cha.append(s)
  elif s == cha[0]:
    cnt += 1
  
if len(cha)==2 and cnt==1:
  print('Yes')
else:
  print('No')

Solution (Python):
a = list(map(str, input()))
b = []
for i in a:
    if i not in b:
        b.append(i)
if len(b) == 2:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
import sys
sys.setrecursionlimit(10**7) 
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right

from collections import deque


from collections import Counter

from itertools import accumulate,combinations,permutations

from heapq import heapify,heappop,heappush


from functools import lru_cache

from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    

    
    
    
    
    
    s=input()
    si=Counter(list(s))
    if len(si.keys())!=2 or si[s[0]]!=2:
        print("No")
    else:
        print('Yes')





if __name__ == "__main__":
    main()

Solution (Python):


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

Solution (Python):
from collections import defaultdict
s = str(input())
d = defaultdict(int)
for x in s:
  d[x]+=1
if len(d)==2:
  for key in d:
    if d[key]!=2:
      print("No")
      exit()
  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 = input()
SetS = list(set(S))
if len(SetS)==2 and S.count(SetS[0])==S.count(SetS[1]):
    print('Yes')
else:
    print('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):
A=input()
ans=[]
count=0

for i in range(4):
    if A[i] not in ans:
        ans.append(A[i])
    else:
        count+=1

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

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

Solution (Python):

s = input()
f = s[0]
print("YNeos"[sum(f == i for i in s) != 2 or len({i for i in s}) != 2::2])

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

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

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

Solution (Python):
print('YNeos'[len({*input()})!=2::2])

Solution (Python):
print('YNeos'[len({*input()})!=2::2])

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

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

Solution (Python):


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

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

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

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

Solution (Python):
s = input()
t = set(s)
if len(t) == 2 and s.count(list(t)[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 = str(input())
apple = []
for i in s:
    apple.append(i)
apple = set(apple)
print("Yes" if len(apple) == 2 else "No")

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

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

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

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

Solution (Python):
liste =[x for x in input()]
def pp():
    for loop in range(3):
        if liste.count(liste[loop]) != 2:
            return "No"
    return "Yes"
print(pp())

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

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

Solution (Python):
inp = list(input())
inpset = set(inp)
inplist = list(inpset)

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

Solution (Python):
def main():
    s = list(input())
    if s[0] == s[1] == s[2] == s[3]:
        print('No')
        return
    for i in range(3):
        if s[3] == s[i]:
            s.pop(3)
            s.pop(i)
            if s[0] == s[1]:
                print('Yes')
                return
            print('No')
            return
    print('No')
            
main()

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

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

Solution (Python):
s=[i for i in 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):
string = input()
a,b,c,d = string[0],string[1],string[2],string[3]

def truth(x):
  count = 0
  if a ==b or a==c or a==d:
    count += 1
  if b ==c or b==d:
    count += 1
  if c ==d:
    count += 1
  if a == b == c or a ==b ==d or a==c==d:
    return False
  return count>1

if truth(a): print("Yes")
else: print("No")