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


def check():
    
    char_set = set(S)
    
    if len(char_set) != 2:
        return "No"
    
    for c in char_set:
        if S.count(c) != 2:
            return "No"
    
    return "Yes"


print(check())

Solution (Python):
A=input()
B=set(A)
a=[]
for i in B:
    a.append(A.count(i))
if a[0]==2 and a[1]==2:
    print('Yes')
else:
    print('No')

Solution (Python):

import collections

s = list(input())

collct = collections.Counter(s)
flag = False

for i in collct:
    if collct[i] == 2:
        flag = True
    else:
        flag = False
        break

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

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

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

Solution (Python):
import sys

input = sys.stdin.readline


def main():
    print("Yes" if len(set(input().strip())) == 2 else "No")


if __name__ == "__main__":
    main()

Solution (Python):
from collections import defaultdict
s = input()
dic = defaultdict(int)
for x in s:
    dic[x] += 1
f = 1
for x in s:
    if dic[x] != 2:
        f = 0
if f:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections
S = list(input())
c = collections.Counter(S)
c = c.most_common()
if len(c) == 2:
    for i in c:
        if i[1] == 2:
            None
        else:
            break
    else:
        print("Yes")
        exit()
print('No')

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

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

Solution (Python):
S = input()
s = [S[i] for i in range(len(S))]

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

Solution (Python):
S = input()

flg = 0

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

Solution (Python):
def resolve():

    s = input()
    flag = 1


    for st in s:
        if s.count(st) != 2:
            print('No')
            flag = 0
            break

    if flag:
        print('Yes')
        
resolve()

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

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

Solution (Python):
from collections import Counter
if __name__ == "__main__":
    S = Counter(input())
    if len(S) == 2 and all(v == 2 for v in S.values()):
        print("Yes")
    else:
        print("No")

Solution (Python):
s = input()
d = {}
for c in s:
    if c in d:
        d[c] +=1
    else:
        d[c] = 1

ans = 'Yes'
if len(list(d.keys())) != 2:
    ans ='No'
else:
    for c in d.keys():
        if d[c] != 2:
            ans = 'No'
print(ans)

Solution (Python):
s = list(input())
flag = True
for i in range(3):
    if s.count(s[i]) != 2:
        flag= False
    
if flag == False:
    print("No")
else:
    print("Yes")

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

Solution (Python):
S = input()

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

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

x=list(input())

temp={}
for e in x:
    if e not in  temp:
        temp[e]=0
    temp[e]+=1

if len(temp.keys())==2:
    for e in temp.values():
        if e!=2:
            print("No")
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
ls = []
ols = []
for i in S:
    if i not in ls:
        ls.append(i)
    else:
        ols.append(i)
ls.sort()
ols.sort()
if ls == ols:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
dic = {}
for i in s:
  if i not in dic:
    dic[i] = 1
  else:
    dic[i] += 1
    if dic[i] >= 3:
      print("No")
      exit()
  
if len(dic) >= 3 or len(dic) <= 1:
  print("No")
  exit()
for i in s:
  if dic[i] != 2:
    print("No")
    exit()
print("Yes")

Solution (Python):
s = list(input())
temp = s[3]
cnt = 1
for i in range(3):
    if temp == s[i]:
        cnt +=1
if cnt == 2 and len(set(s)) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
mojidic = {}
for i in range(4):
    if S[i] in mojidic.keys():
        mojidic[S[i]] += 1
    else:
        mojidic[S[i]] = 1
mvalue = list(mojidic.values())
if mvalue == [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[2]!=S[1]:
    print('Yes')
else:
    print('No')

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

print(ans)

Solution (Python):
string = input()

s_list = []
for i in range(4):
  s_list.append(string[i])
  
sn_list = sorted(s_list)

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

Solution (Python):
S = input()
strtype = []
cnt = 0
for i in S:
    if not (i in strtype):
        strtype.append(i)
    else:
        cnt += 1


print('Yes') if len(strtype) == 2 and cnt == 2 else print('No')

Solution (Python):
S = input()
ss = {}
for i in S:
    if i in ss:
        ss[i] += 1
    else:
        ss[i] = 1
print('Yes' if list(ss.values()) == [2, 2] else 'No')

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

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

if len(s) == 2:
    a = S[0]
    count = 0
    for i in S:
        if i == a:
            count += 1

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

else:
    print('No')

Solution (Python):
s = input()
l = [s[0],s[1],s[2],s[3]]
setlist = list(set(l))

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

Solution (Python):

import copy
import random
import bisect 
import fractions 
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) 

def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
count = {}
for i in range(len(S)):
    if S[i] in count.keys():
        count[S[i]] += 1
    else:
        count[S[i]] = 1

flag = True
for key in count.keys():
    if count[key] == 2:
        pass
    else:
        flag = False
        break

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

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


if __name__ == '__main__':
    s = input()
    print(A(s))

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

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

Solution (Python):



import sys
from collections import defaultdict

S = input()

d = defaultdict(int)

for i in range(4):
    d[S[i]] += 1
    
for key in d.keys():
    if d[key] != 2:
        print('No')
        sys.exit()
        
print('Yes')

Solution (Python):
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]


def get_nums_l():
    return [ int(s) for s in input().split(" ")]


def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

s = input()

a,b = "",""

a = s[0]

if a != s[1]:
    b = s[1]

    if a in s[2:] and b in s[2:]:
        print("Yes")
    else:
        print("No")
else:
    if a != s[2] and s[2] == s[3]:
        print("Yes")
    else:
        print("No")

Solution (Python):
S = input()

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

else:
    print("No")

Solution (Python):
S = input()

set_s = set(S)
if len(set_s) == 2:
    for val in set_s:
        if S.count(val) != 2:
            print('No')
            exit()
else:
    print('No')
    exit()

print('Yes')

Solution (Python):
s = input()

a = ''
b = ''
count_a = 0
count_b = 0
count_c = 0

for i in range(4):
    if s[i] == a:
        count_a += 1
    elif s[i] == b:
        count_b += 1
    elif a == '':
        a = s[i]
        count_a += 1
    elif b == '':
        b = s[i]
        count_b += 1
    else:
        count_c += 1

if count_c > 0 or count_a != 2 or count_b != 2:
    print('No')
else:
    print('Yes')

Solution (Python):

S = list(map(str, input()))

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

Solution (Python):
s = input()
s = [s[0], s[1], s[2], s[3]]
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 fractions


inp = list(input())

for i in inp:
    n = inp.count(i)
    if n  != 2:
        print('No')
        exit()
print('Yes')

Solution (Python):
s = input()
flg = True
for i in range(4):
    if s.count(list(s)[i]) != 2:
        flg = False
        break
if flg:
    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):



def main():
    
    
    
    S = list(input())
    d = {}
    flag = True
    for si in S:
        if si in d:
            d[si] += 1
        else:
            d[si] = 1
    for k in d:
        if d[k] != 2:
            flag = False

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


if __name__ == "__main__":
    main()

Solution (Python):
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy




def main():
    S = input()
    hoge = defaultdict(int)
    for s in S:
        hoge[s] += 1
    keys = hoge.keys()
    if len(keys) == 2:
        a = list(set(hoge.values()))
        if len(a) == 1 and a[0] == 2:
            return True
    return False

if __name__ == '__main__':
    if main():
        print("Yes")
    else:
        print("No")

Solution (Python):
from collections import Counter

S = Counter(input())
i = 0
count2 = 0
for k, v in S.items():
    i += 1
    if v == 2:
        count2 += 1
        
if i == 2 and count2 == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter

s = input().rstrip()

c = Counter(s)

if len(c) == 2 and all([val == 2 for val in c.values()]):
    print('Yes')
else:
    print('No')

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

Solution (Python):
print(["No","Yes"][len(set(input())) == 2])

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

for i in range(3):
	for j in range(i + 1, 4):
		if S[i] == S[j]:
			count += 1
			
if count == 2:
	print('Yes')
else:
	print('No')

Solution (Python):
s = str(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 = list(input())
f = True

S.sort()

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

Solution (Python):
S = input()

alfa = [chr(i) for i in range(97,97+26)]

A = []


counter = []
for i in range(4):
    counter.append(S.count(S[i]))

flag = 0
for i in range(4):
    if counter[i] == 2:
        flag += 1

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

Solution (Python):


S = input().rstrip()

Su = list(set(S))

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

Solution (Python):
import collections
S = list(str(input()))
C = collections.Counter(S)
LEN = len(C)
count = 0
if LEN == 2:
    for i in range(3):
        if S[0] == S[i+1]:
            count += 1

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

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

Solution (Python):
S=list(input())
cut=0
for i in range(len(S)):
    a=S.count(S[i])
    cut+=a
if cut==8:
    print("Yes")
else:
    print("No")

Solution (Python):
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

S = stdin.readline().rstrip()
s = [x for x in S]

a = Counter(s)

try:
    aa = a.most_common()
    if aa[0][1] == 2 and aa[1][1] == 2:
        print("Yes")
    else:
        print("No") 
except:
    print("No")

Solution (Python):
import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    d = defaultdict(lambda: 0)
    S = str(input().strip())
    for s in S:
        d[s] += 1

    if len(d.keys()) != 2:
        return 'No'

    for k, v in d.items():
        if v != 2:
            return 'No'

    return 'Yes'


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

Solution (Python):
from collections import Counter
s = input()
c = Counter(s).values()
if list(c) == [2, 2]:
    print('Yes')
else:
    print('No')

Solution (Python):



def solv(s):
    s = sorted(s)
    if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':

    s = input()

    ans = solv(s)

    print(ans)

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

c = 0

for i in s:
    if s.count(i) != 2:
        c += 1

if c == 0:
    print('Yes')

else:
    print('No')

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

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

Solution (Python):
s = input()
d = {}
for c in s:
    d[c] = d.get(c, 0) + 1
if len(d) == 2 and all(i==2 for i in d.values()):
    print("Yes")
else:
    print("No")

Solution (Python):
S=input()
a=0
if S[0]==S[1]!=S[2]==S[3] or S[1]==S[2]!=S[3]==S[0] or S[0]==S[2]!=S[1]==S[3]:
    a=1
print(['No','Yes'][a])

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

Solution (Python):
from sys import stdin
S = (stdin.readline().rstrip())
flag = True
if len(set(S)) == 2:
    flag = True
else:
    flag = False

for i in list(set(S)):
    if S.count(i) != 2:
        flag = False

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

Solution (Python):

s = input()

a = s.count(s[0])
b = s.count(s[1])
c = s.count(s[2])
d = s.count(s[3])

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

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

Solution (Python):

from collections import defaultdict 

S = input()

cnt = defaultdict(int)

for s in S:
    cnt[s] += 1

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

Solution (Python):
def main():
    S = input()
    str_dict = {}
    for s in S:
        if s not in str_dict:
            str_dict[s] = 0
        str_dict[s] += 1

    if len(str_dict) == 2:
        for value in str_dict.values():
            if value != 2:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

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

if len(S2) == 2:
    if S[0] == S[1] and S[2] == S[3] or S[0] == S[2] and S[1] == S[3] or S[0] == S[3] and S[1] == S[2]:
        print("Yes")
        exit()

print("No")

Solution (Python):
import sys
sys.setrecursionlimit(10 ** 7)

debug = True


def dprint(*objects):
    if debug == True:
        print(*objects)







def solve():
    l = input()
    li = [l[i] for i in range(len(l))]

    u = len(set(li))
    c = li.count(li[0])

    if u == 2 and c == 2:
        print("Yes")
    else:
        print("No")

solve()

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

cond1 = len(set(s)) == 2
c0 = s[0]
cond2 = sum([1 for c in s if c == c0]) == 2

if cond1 and cond2:
    out = "Yes"
else:
    out = "No"

print(out)

Solution (Python):
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()]

ss = list(set(s))

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

Solution (Python):
S = input()

d = {}
for s in S:
    if s not in d:
        d[s] = 1 
    else:
        d[s] += 1 

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

Solution (Python):


from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

import collections
def solve(S: str):
    count_dict = collections.defaultdict(int)
    for s in S:
        count_dict[s] += 1
    if len(count_dict)==2:
        for s in S:
            if count_dict[s]!=2:
                print('No')
                exit()
        else:
            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):
s = input()

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

Solution (Python):
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)










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

cnt = {}
for c in s:
    cnt[c] = cnt.get(c, 0) + 1

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

for c in cnt:
    if cnt[c] != 2:
        print('No')
        exit(0)

print('Yes')

Solution (Python):
S = input().strip()

d={}
for c in list(S):
    d[c] = d.get(c, 0) + 1

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

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

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

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

Solution (Python):

"""
Created on Sat Jun 29 20:44:35 2019

@author: Yamazaki Kenichi
"""

S = input()

a = S.count(S[0])
b = S.count(S[1])
c = S.count(S[2])
d = S.count(S[3])

if a*b*c*d == 16:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()

s1 = S[0]
s2 = S[1]
s3 = S[2]
s4 = S[3]

if s1 == s2 and s1 == s3 and s1 == s4:
    print('No')
elif s1 == s2 and s3 == s4:
    print('Yes')
elif s1 == s3 and s2 == s4:
    print('Yes')
elif s1 == s4 and s2 == s3:
    print('Yes')
else:
    print('No')

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

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

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

Solution (Python):

import sys

import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

t = list(input())
d = defaultdict(int)

k = 0
for i in t:
    d[i] += 1
for i in d:
    if d[i] == 2:
        k += 1
if k == 2:
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
s = input()
ans=0
for a in [[0,1,2,3],[0,2,1,3],[0,3,2,1],[1,2,0,3],[1,3,0,2],[2,3,1,0]]:
    if s[a[0]] == s[a[1]] and s[a[2]]==s[a[3]] and s[a[0]]!=s[a[2]]:
        ans = 1

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

Solution (Python):


import sys
sys.setrecursionlimit(1000000)
from collections import deque

S = list(input())
T = list(set(S))
for i in T:
    if S.count(i) != 2:
        print('No')
        quit()
if len(T) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
N = [_ for _ in input()]
for i in range(4):
    if N.count(N[i]) != 2:
        print("No")
        exit()

print("Yes")

Solution (Python):
S = list(input())
first_char = S[0]


cnt = 0
for i in range(1, 4):
    if S[i] == first_char:
        cnt += 1
        
if cnt == 1 and len(set(list(S))) == 2:
    print('Yes')
else:
    print('No')

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

Solution (Python):
S = input()
L = []

for s in S :
    L.append(s)

L = sorted(L)

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

Solution (Python):
s = input()

if s.count(s[0]) == 4:
    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())

import collections

c = collections.Counter(s)

flag = True
if len(c.keys()) != 2:
    flag = False
else:
    for k in c.keys():
        if c[k] != 2:
            flag = False

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

Solution (Python):
import collections

S = input()

charactorVocabrarys = len(collections.Counter(S))
if charactorVocabrarys == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
cnt = 0
ans = False
for i in S:
    cnt = S.count(i)
    if cnt != 2:
        ans = True

if ans:
    print("No")
else:
    print("Yes")

Solution (Python):
import sys

x = str(input()) 

cnt = 0

for i in range(3):
    for j in range(i+1,4):
        if x[i] == x[j]:
            cnt += 1

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

Solution (Python):
s=input()
cnt=0
if s.count("A")==2:
    cnt+=1
if s.count("B") == 2:
    cnt += 1
if s.count("C")==2:
    cnt+=1
if s.count("D") == 2:
    cnt += 1
if s.count("E")==2:
    cnt+=1
if s.count("F") == 2:
    cnt += 1
if s.count("G")==2:
    cnt+=1
if s.count("H") == 2:
    cnt += 1
if s.count("I")==2:
    cnt+=1
if s.count("J") == 2:
    cnt += 1
if s.count("K")==2:
    cnt+=1
if s.count("L") == 2:
    cnt += 1
if s.count("M")==2:
    cnt+=1
if s.count("N") == 2:
    cnt += 1
if s.count("O")==2:
    cnt+=1
if s.count("P") == 2:
    cnt += 1
if s.count("Q")==2:
    cnt+=1
if s.count("R") == 2:
    cnt += 1
if s.count("S") == 2:
    cnt += 1
if s.count("T") == 2:
    cnt += 1
if s.count("U")==2:
    cnt+=1
if s.count("V") == 2:
    cnt += 1
if s.count("W") == 2:
    cnt += 1
if s.count("X") == 2:
    cnt += 1
if s.count("Y") == 2:
    cnt += 1
if s.count("Z") == 2:
    cnt += 1

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

Solution (Python):
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


a = input()                                  






s = []
for i in range(4):
    s.append(a[i])
s.sort()
if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:j(1)
j(0)

Solution (Python):
S = input()
c = []
cnt = []
for i in range(4):
  x = S[i]
  if not x in c:
    c.append(x)
    cnt.append(1)
  else:
    idx = c.index(x)
    cnt[idx] += 1
if len(c) == 2 and cnt[0] == 2 and cnt[1] == 2:
  print("Yes")
else:
  print("No")

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

d = {}
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

def check(d):
    for k,v in d.items():
        if v != 2:
            return False
        
    return True
    

if check(d):
    print("Yes")
else:
    print("No")

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

Solution (Python):
s = input()

if s[0] == s[1] and s[0] == s[2]:
    print('No')
elif s[0] == s[1] and s[0] == s[3]:
    print('No')
elif 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 = input()
from collections import Counter
c = Counter(S)

if len(set(S)) == 2:
    a =  c.most_common(2)[0][1]
    b = c.most_common(2)[1][1]
    if a  == b:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

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

A = input().strip()
counter = 0
B = collections.Counter(A)
if len(B.keys()) == 2:
    for value in B.values():
        if value == 2:
            counter += 1
    if counter ==2:
        print('Yes')
        exit()

print('No')

Solution (Python):
from collections import Counter
s = input()
cnt = Counter(s)
for key in cnt.keys():
    if cnt[key] != 2:
        print("No")
        exit()

print("Yes")

Solution (Python):
from collections import Counter
S=raw_input()

C=Counter(S)

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

Solution (Python):
S = input()

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

print("Yes")

Solution (Python):
from collections import Counter


def m():
    S = input()
    values = list(Counter(S).values())
    if len(values) != 2:
        print("No")
        return
    if values[0] == 2 and values[1] == 2:
        print("Yes")
    else:
        print("No")


m()

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

Solution (Python):
from collections import Counter

counter = Counter()
for c in input().strip():
  counter[c] += 1


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

Solution (Python):
s = input()

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

Solution (Python):
S = input()

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

print('Yes')

Solution (Python):
s = input()
a = set([i for i in s])
if len(a) != 2:
    print('No')
else:
    i,j = a
    ni = s.count(i)
    nj = s.count(j)
    if ni == 2 and nj == 2:
        print('Yes')
    else:
        print('No')

Solution (Python):
S = input()

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

Solution (Python):
S = input()
d = {}
for c in S:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1

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

Solution (Python):
from collections import defaultdict
S=input()
d=defaultdict(lambda: 0)
for c in S:
    d[c]+=1
print('Yes' if len(d.keys())==2 and all([v==2 for v in d.values()]) else "No")

Solution (Python):
from collections import defaultdict
S = input()
d = defaultdict(int)
for i in range(4):
    d[S[i]] += 1
print('Yes' if set(d.values()) == set([2, 2]) else 'No')

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