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

a = ""
a_cnt = 0
b = ""
b_cnt = 0
flg = True

for e in s:
    if (a == ""):
        a = e
        a_cnt += 1
    elif (a == e):
        a_cnt += 1
    elif (b == ""):
        b = e
        b_cnt += 1
    elif (b == e):
        b_cnt += 1

if (a_cnt == 2 and b_cnt == 2):
    print("Yes")
else:
    print("No")

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

print(ans)

Solution (Python):

import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    S = input()

    d = {}
    for c in S:
        if c not in d:
            if len(d) >= 2:
                print('No')
                return
            else:
                d[c] = 1
        else:
            if d[c] > 2:
                print('No')
                return
            else:
                d[c] = d[c] + 1
    print('Yes')





if __name__ == '__main__':
    main()

Solution (Python):
def solve():
    s = input()
    s_set = set(s)
    s_set_l = list(s_set)
    if len(s_set) == 2:
        if s.count(s_set_l[0]) == 2 and s.count(s_set_l[1]) == 2:
            print('Yes')
            exit()
    print('No')


if __name__ == '__main__':
    solve()

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

Solution (Python):
s=input()
import collections
s=dict(collections.Counter(s))
if len(s)==2:
  flag=True
  for k in s.values():
    if k!=2:
      flag=False
  if flag:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
import re

s = sorted(input())
s = "".join(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()

s_list = list(set(s))
if len(s_list) != 2:
    print("No")
else:
    flag = True
    for origin  in s_list:
        if s.count(origin) != 2:
            flag = False
    if flag:
        print("Yes")
    else:
        print("No")

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

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

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

Solution (Python):
s=input()
count = 0
for i in s:
  for j in s:
    if i==j:
      count+=1
if count==8:
  print('Yes')
else:
  print('No')

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

d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i]+=1
    
if len(d) == 2 and d[s[0]] == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
w=input()
l=[]
for i in range(4):
  if w[i] in l:
    pass
  else:
    l.append(w[i])
if len(l)!=2:
  print("No")
else:
  count=0
  for i in range(4):
    if w[i]==l[0]:
      count+=1
  if count==2:
    print("Yes")
  else:
    print("No")

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

Solution (Python):
S = input()

clear = True
l = list()
for n in range(4):
    if S[n] not in S[n+1:]:
        l.append(S[n])
    if len(l) > 2:
        clear = False
for x in l:
    if [y for y in S].count(x) > 2:
        clear = False
if clear:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
ls_s = [i for i in input()]
ls_s1 = sorted(ls_s)

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

Solution (Python):
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    C=Counter(input())
    if(len(C)!=2):
        print("No")
        return
    for k,v in C.items():
        if(v!=2):
            print("No")
            return
    print("Yes")
resolve()

Solution (Python):



import sys
s = list(input())

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

Solution (Python):
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think('ASSA'), 'Yes')

    def test_2(self):
        self.assertEqual(think('STOP'), 'No')

    def test_3(self):
        self.assertEqual(think('FFEE'), 'Yes')

    def test_4(self):
        self.assertEqual(think('FREE'), 'No')


def solve():
    s = read()
    result = think(s)
    write(result)


def read():
    length_of_string = 4
    return read_line(n=length_of_string)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s):
    for i in range(len(s)):
        if s.count(s[i]) == 2:
            continue
        else:
            return 'No'
    return 'Yes'


def write(result):
    print(result)


if __name__ == '__main__':
    
    solve()

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):
import collections
a = list( input() ) 
dic = collections.Counter(a)
k = 0

for i in dic.values():
    if not i == 2:
        k = 1
if k == 0:
    print("Yes")
else:
    print("No")

Solution (Python):

s = input()
c = []

for letter in s:
    if letter not in c:
        c.append(letter)

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

Solution (Python):
S = input()
dic = {}
for i in range(4):
    if S[i] not in dic.keys():
        dic[S[i]] = 1
    else:
        dic[S[i]] += 1

ok = 0


for k in dic.keys():
    if(dic[k] != 2):
        ok = 1

if(len(dic.keys()) == 2 and ok==0):
    print("Yes")
else:
    print("No")

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

Solution (Python):
s = input()
ltr = []
cnt = []
for a in s:
    if not a in ltr:
        ltr.append(a)
        cnt.append(0)
    else:
        cnt[ltr.index(a)] += 1
print("Yes" if cnt == [1, 1] else "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):
import collections


S = input()
c = collections.Counter(S)
cm = c.most_common()

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

Solution (Python):
line = input()
li = []
for s in line:
  if s not in li:
    li.append(s)
if len(li) == 2:
  print("Yes")
else:
  print("No")

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

s = list(input().rstrip('\n'))
s.sort()
gr = itertools.groupby(s)
ks = []
gs = []

for k, g in gr:
    ks.append(k)
    gs.append(len(list(g)))

if len(ks) == 2 and gs.count(2) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = map(str , input())
list_S = list(S)

list_S.sort()

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

Solution (Python):
S = map(str , input())
list_S = list(S)

list_S.sort()

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

Solution (Python):
S = sorted([C for C in 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()
s = sorted(s)

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

Solution (Python):
sls = list(input())
sdic = {}
for i in range(len(sls)):
  if sls[i] in sdic:
  	sdic[sls[i]] += 1
  else:
    sdic[sls[i]] = 1

if len(sdic) == 2 and list(sdic.values()) == [2,2]:
  print("Yes")
else:
  print("No")

Solution (Python):
a = input()

b = [0]*4

for i in range(4):
	b[i] = a.count(a[i])

c = 'No'

if b[0]==2 and b[1]==2 and b[2]==2 and b[3]==2:
	c = 'Yes'
	
print(c)

Solution (Python):
S = list(map(str ,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 = str(input())
ans='Yes'
if len(set(S))!=2:
    ans='No'
if S.count(S[0])!=2:
    ans='No'
print(ans)

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

Solution (Python):
s = input()
flag = 0

if s[0] == s[1] and s[2] == s[3]:
    if s[1] != s[2]:
        flag = 1
elif s[0] == s[2] and s[1] == s[3]:
    if s[1] != s[2]:
        flag = 1
elif s[0] == s[3] and s[1] == s[2]:
    if s[0] != s[1]:
        flag = 1

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

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

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

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

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

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

cnt = 0

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

if b==c:
    cnt += 1
if b==d:
    cnt+=1
if c==d:
    cnt+=1

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

Solution (Python):
s = list(input());
ans = 0;

if s[0] == s[1] or s[0] == s[2] or s[0] == s[3]: ans += 1;
if s[1] == s[2] or s[1] == s[3]: ans += 1;
if s[2] == s[3]: ans += 1;
if ans == 2: print("Yes");
else: print("No");

Solution (Python):


def main():
    S = input()
    for i in range(4):
        if S.count(S[i])!=2:
            print('No')
            return
    print('Yes')

if __name__ == "__main__":
    main()

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

if sort_S[0]==sort_S[1] and sort_S[1]!=sort_S[2] and sort_S[2]==sort_S[3]:
    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=list(input())
new_s=set(s)

if len(new_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 not S[1] == S[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 = list(input())
S2 = sorted(S)

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

Solution (Python):
s = input()
flg = True
for i in s:
  cnt = 0
  for j in s:
    if i == j:
      cnt += 1
  if cnt != 2:
    flg = False
if flg:
  print('Yes')
else:
  print('No')

Solution (Python):
import collections

s = list(input())
c = collections.Counter(s)
ans = 'No'

if len(c) == 2:
	n = list(c.values())
	if n[0] == n[1]:
		ans = 'Yes'

print(ans)

Solution (Python):
S = 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')
else:
    print('No')

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

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

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

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

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

Solution (Python):

"""
A - Fifty-Fifty
https://atcoder.jp/contests/abc132/tasks/abc132_a

"""
import sys


def solve(s):
    return 'Yes' if all([s.count(ch) == 2 for ch in s]) else 'No'


def main(args):
    s = input()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

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

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

Solution (Python):
S = input()

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

if a==b and c==d and b!=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):
import sys

s = input()
s_list = set(list(s))

if (len(s_list) != 2):
    print('No')
    sys.exit()

is_ok = True
for char in set(list(s)):
    if (s.count(char) != 2):
        is_ok = False

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

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

if 2 in c.values() and len(c.keys()) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()

freq = {}

for c in s:
    if c in freq:
        freq[c] += 1
    else:
        freq[c] = 1


if (len(freq)) != 2:
    print('No')
    exit(0)

cond = True
for c in freq:
    if freq[c] != 2:
        cond = False
        break

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

Solution (Python):
S = input()

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

Solution (Python):
from collections import Counter
S = input()
c = Counter(S)
print('Yes' if all(v == 2 for v in c.values()) else 'No')

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

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

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

Solution (Python):
s=input()
d=[0]*len(s)
for i in range(0,4):
  d[i]=s[i]
if len(set(d))==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 = str(input())
l = []
for i in range(4):
    l.append(s[i])
if len(set(l)) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = str(input())
l = []
for i in range(4):
    l.append(s[i])
if len(set(l)) == 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()

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

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

Solution (Python):
def main():
    array = list(input())
    for i in range(len(array)):
        count = 0
        for j in range(len(array)):
            if array[i] == array[j]:
                count += 1
            continue
        if count != 2:
            print('No')
            return
    print('Yes')
    return


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):
S=input()
count={}
for c in S:
	count[c] = count.get(c, 0) + 1
counts=list(count.values())
if(counts[0] == 2 and counts[1] == 2):
	print("Yes")
else:
	print("No")

Solution (Python):
S=input()
L=[]
for i in range(3):
    L.append(S.count(S[i]))
if sum(L)==6:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
s = input()

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

Solution (Python):
S = str(input())
X=[]

for s in S:
    X.append(s)

X = sorted(X)
if (X[0] == X[1]) & (X[2]==X[3]) & (X[0] != X[3]):
    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 len(set(S)) != 2:
       print("No")
       exit(0)
       
if len(S) != 4:
       print("No")
       exit(0)
       
print("Yes")

Solution (Python):
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode('utf-8')

a,b,c,d = sorted(S)

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

Solution (Python):
S = input()

first = S[0]
fnum = 1
snum = 0
for i in range(1, 4):
	if S[i] == first:
		fnum += 1
	elif snum == 0:
		sec = S[i]
		snum += 1
	elif S[i] == sec:
		snum += 1

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

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

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

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

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

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

Solution (Python):
S = input()

ans = "Yes"
L = []
cnt = 0
for i in range(4):
    if S[i] not in L:
        cnt += 1
    L.append(S[i])
        
if cnt != 2:
    ans ="No"
else:
    for i in range(4):
        if L.count(L[i]) != 2:
            ans = "No"
            break
print(ans)

Solution (Python):
S = input()

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

else:
  print("No")

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

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

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

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

if count1 == 2 and count2 != 4:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
S=list(s)
S.sort()
if S[1]==S[0] and S[3]==S[2] and S[2]!=S[1]:
    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[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):
a,b,c,d=input()
if a==b and c==d and a!=c or a==c and b==d and a!=b or a==d and b==c and a!=b:
    print('Yes')
else:
    print('No')

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

Solution (Python):
S = input()

one, one_n = None, 0
two, two_n = None, 0

for s in S:
  if not one or s == one:
    one = s
    one_n += 1
    continue

  if not two or s == two:
    two = s
    two_n += 1
    continue

if one_n == 2 and two_n == 2:
  print("Yes")
else:
  print("No")

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

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

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

Solution (Python):
s = list(input())
a = list()
b = list()
c = list()
a.append(s[0])
for i in range(1,4):
    if s[i] == a[0]:
        a.append(s[i])
    elif len(b) == 0:
        b.append(s[i])
    elif s[i] == b[0]:
        b.append(s[i])
    else:
        c.append(s[i])
if (len(a) == 2) and (len(b) == 2):
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

def judge(L):
	setS = list(set(L))
	if len(setS) != 2:
		print("No")
		return
	
	if S.count(setS[0]) and S.count(setS[1]) == 2:
		print("Yes")
	else:print("No")

judge(S)

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

Solution (Python):
x = sorted(list(map(str,input())))
print('Yes'if x.count(x[0])==2 and x.count(x[2])==2 else 'No')

Solution (Python):
S = input()
cnt = {}
for i in range(len(S)):
  if S[i] in cnt:
    cnt[S[i]] += 1
  else:
    cnt[S[i]] = 1

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

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

Solution (Python):
s = input()
ans = "Yes"

for i in s:
    if s.count(i) != 2:
        ans ="No"
print(ans)

Solution (Python):
S = input()
if S[0] in S[1:4]:
    if S[1] in S[2:4] :
        if S[0] != S[1]:
            print("Yes")
            exit()
    elif S[2] in S[3]:
        if S[0] != S[2]:
            print("Yes")
            exit()
print("No")

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

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

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

Solution (Python):
S = input()
count = 0

if S.count(S[0]) == 2:
    count = count + 1
if S.count(S[1]) == 2:
    count = count + 1
if S.count(S[2]) == 2:
    count = count + 1
if S.count(S[3]) == 2:
    count = count + 1

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

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

Solution (Python):
S = input()

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

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

Solution (Python):
'''A - Fifty-Fifty
https://atcoder.jp/contests/abc132/tasks/abc132_a

>>> main('ASSA')
Yes
>>> main('STOP')
No
>>> main('FFEE')
Yes

06.txt
>>> main('YSKY')
No

07.txt
>>> main('JJKP')
No

'''


def main(s):
    for _s in s:
        if s.count(_s) != 2:
            print('No')
            return

    print('Yes')


if __name__ == "__main__":
    main(input())

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

Solution (Python):
s = input()
a = {}
for i in s:
    if i in a:
        a[i] += 1
    else:
        a[i] = 1
if len(a) == 2 and a[s[0]] == 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 = list(input())
dict = {}

for i in range(4):
  dict[s[i]] = dict.get(s[i], 0) + 1
    
print("Yes" if all([v == 2 for v in dict.values()]) else "No")

Solution (Python):
S = input()
s = list(v for v in S)

first = s.count(s[0])
second = s.count(s[1])
third = s.count(s[2])
fourth = s.count(s[3])

if first == 2 and second == 2 and third == 2 and fourth == 2:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(str(input().rstrip('\n'))).most_common()
    if len(s) == 2:
        for k, v in s:
            if v != 2:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()

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


import collections
c = collections.Counter(s_list)


top2 = c.most_common(2)

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

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

for val in counter.values():
    if val != 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
s = input()
first = s[0]
second = ""
cnt_f = 0
cnt_s = 0
for i in range(len(s)):
    if s[i] != first:
        second = s[i]
        break
for i in range(len(s)):
    if s[i] == first:
        cnt_f+=1
    if s[i] == second:
        cnt_s+=1
if cnt_f == 2 and cnt_s == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):

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

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

count = [0] * 4
flag = 0

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

    if count[j] != 2:
        flag = 1
        break

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

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

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

Solution (Python):
s = input()
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])):
  print('Yes')
else:
  print('No')

Solution (Python):



def main():
    s_list = list(input())
    dic = {}
    for s in s_list:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1

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


if __name__ == '__main__':
    main()

Solution (Python):



S = list(input())
S_K = []
n = 0

for i in range(4):
    if i == 0:
        S_K.append(S[i])
        n += 1
    else:
        if S[i] not in S_K:
            S_K.append(S[i])
            n += 1

if n == 2:
    if S.count(S_K[0]) == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
S=list(input())
S_count = list(S.count(s) for s in S)
if S_count == [2,2,2,2]:
  print("Yes")
else:
  print("No")

Solution (Python):
from collections import Counter
import numpy as np

input_ = np.array(Counter(input()).most_common())

if input_.shape[0] == 2 and np.all(input_[:, 1] == "2"):
    print("Yes")
else:
    print("No")