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):
import sys

s = sys.stdin.readline().rstrip()
s = sorted(s)

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

if __name__ ==  '__main__':
    main()

Solution (Python):
S = list(input())
for x in S:
  if S.count(x) != 2:
    print('No')
    exit()
print('Yes')

Solution (Python):
import itertools
import fractions
def main():
  s = input()
  l = set(s)
  for a in l:
    if s.count(a) !=2:
      print('No')
      exit()
  print('Yes')
  
if __name__ == '__main__':
  main()

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

l = []

for i in range(4):
  l.append(ord(s[0][i]))
  
cl = sorted(l)

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

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

Solution (Python):
import collections

s = list(input())
c = collections.Counter(s)

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

Solution (Python):
from collections import Counter as co
s=co(input())
if all([i==2 for i in s.values()]) and len(s.keys())==2:
  print("Yes")
else:
  print("No")

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

Solution (Python):
import collections 
d=collections.defaultdict(int)
s=input()
for i in range(4):
    d[s[i]]+=1
ans="Yes"
for x in d:
    if d[x]!=2: ans="No"
print(ans)

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

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

Solution (Python):
s = input()

origin = list(set(list(s)))

if len(origin) > 2:
    print("No")
    exit()
a=0
b=0
for i in s:
    if i == origin[0]: a+=1
    elif i == origin[1]: b+=1

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

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

print("Yes" if len(d) == 2 and list(d.items())[0][1] == 2 else "No")

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

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

Solution (Python):
S=input()

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

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

Solution (Python):
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
for j in dic.values():
  if j != 2:
    print('No')
    exit()
print('Yes')

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

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

counter = {}
for c in s:
  if c in counter:
    counter[c] += 1
  else:
    counter[c] = 1

result = True
for k, v in counter.items():
  if v != 2:
    result = False
print("Yes" if result else "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):
S=str(input())
if (S[0]==S[1] and S[2]==S[3] and S[0]!=S[2]) or (S[0]==S[2] and S[1]==S[3] and S[0]!=S[1]) or (S[0]==S[3] and S[1]==S[2] and S[0]!=S[1]):
  print("Yes")
else:
  print("No")

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

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

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

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

Solution (Python):

import sys
from collections import defaultdict
YES = "Yes"  
NO = "No"  


def solve(S: str):
    a = defaultdict(int)
    for c in S:
        a[c]+=1
    for c in a:
        if a[c] != 2:
            print(NO)
            exit()
    print(YES)
    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 = list(input())
s.sort()
r = 'No'
if s[0] == s[1] and s[2] == s[3]:
    if s[1] != s[2]:
        r = 'Yes'

print(r)

Solution (Python):
S = input()

i = 0
j = 0
count = 0
while i < 4:
    while j<4:
        if S[i] == S[j]:
            count +=1
        j +=1
    i +=1
    j = 0

print('Yes' if count == 8 else 'No')

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

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

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

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

Solution (Python):
from collections import Counter

S = Counter([s for s in input()])

if len(S)!=2:
  print('No')
elif sum([1 for v in S.values() if v==2])!=2:
  print('No')
else:
  print('Yes')

Solution (Python):
S = input()
SS = {}
for i in range(4):
    if(S[i] not in SS.keys()):
        SS[S[i]] = 0
    SS[S[i]] += 1
if(list(SS.values()) == [2,2]):
    print("Yes")
else:
    print("No")

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

Solution (Python):
from collections import Counter

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

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

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):
St = input()
n = len(St)



Se = set(St)

answer = 1
for i in range(n):
    if St.count(St[i]) != 2 :
        answer = 0




if len(Se) == 2 and answer == 1:
    print("Yes")
else:
	print("No")

Solution (Python):
St = input()

Se = set(St)

answer = 0

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

Solution (Python):
S = input()

answer = 1

if S[0] != S[1]:
	answer = answer + 1

if S[0] != S[2] and S[1] != S[2]:
	answer = answer + 1

if S[0] != S[3] and S[1] != S[3] and S[2] != S[3]:
	answer = answer + 1

count0 = 0
count1 = 0
count2 = 0
count3 = 0

for i in range(4):
    if S[0] == S[i]:
    	count0 = count0 + 1
    if S[1] == S[i]:
    	count1 = count1 + 1
    if S[1] == S[i]:
    	count2 = count2 + 1
    if S[2] == S[i]:
    	count3 = count3 + 1

if answer == 2 and count0 ==2 and count1 == 2 and count2 == 2 and count3 == 2 :
	print("Yes")
else:
	print("No")

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

res = list(set(S))
if(len(res) == 2):
    print('Yes')
else:
    print('No')

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

d = defaultdict(int)

for i in range(len(S)):
    d[S[i]] += 1
f = 0
for i in range(len(S)):
    if d[S[i]] != 2:
        f = 1

if f == 0:
    print("Yes")
else:
    print("No")

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

d = defaultdict(int)

for i in range(len(S)):
    d[S[i]] += 1
f = 0
if len(d) != 2:
    f = 1
for d_key in d:
    if d[d_key] != 2:
        f = 1
        break

if f == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    s = input()
    c_list = list(s)
    result = True
    
    for c in c_list:
        if c_list.count(c) != 2:
            result = False
            break
    
    if result:
        print("Yes")
    else:
        print("No")

main()

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

Solution (Python):
s=input()
print('Yes' if all([s.count(i)==2 for i in set(s)]) else 'No')

Solution (Python):
a=input()
ret = True
for s in a:
	sum = 0
	for t in a:
		if s==t:
			sum += 1
	if sum != 2:
		ret = False
if ret:
	print("Yes")
else:
	print ("No")

Solution (Python):

import collections

S = input()

c = collections.Counter(S)


if len(S) == 4 and (c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2):
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
s_list = list(s)
s_set = set(s)
ans = "Yes"
if len(s_set) == 2:
    for i in range(len(s_list)):
        if s_list.count(s_list[i]) != 2:
            ans = "No"
            break
else:
    ans = "No"
print(ans)

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

Solution (Python):



from collections import deque,Counter








s = input()
counter = Counter(s)

ans = "Yes"
if len(counter) !=2:
    ans = "No"
for i,v in counter.items():
    if v != 2:
        ans = "No"

print(ans)

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

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

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

fact = set(s)
is_two = (len(fact) == 2)

num = []
for i in fact:
    num.append(s.count(i))

if is_two and num == [2, 2]:
    print('Yes')
else:
    print('No')

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

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

tmp = Counter(s)

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

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

import sys
s = input()
dic = {}
for c in s:
    if c in dic:
        dic[c] += 1
    else:
        dic[c] = 1
for v in dic.values():
    if v != 2:
        print('No')
        sys.exit()
print('Yes')

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

Solution (Python):
s=input();print('YNeos'[any(s.count(c)!=2 for c in set(s))::2])

Solution (Python):
d={}
for c in input():
  d[c]=d.get(c,0)+1
print('YNeos'[len(d)!=2 or max(d.values())>2::2])

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

lis = sorted(lis)

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

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):
s = input()
s1 =(s[0])
s2 =(s[1])
s3 =(s[2])
s4 =(s[3])

c1 = s.count(s1)
c2 = s.count(s2)
c3 = s.count(s3)
c4 = s.count(s4)

if c1 == c2 == c3 == c4 == 2:
    print("Yes")
else:
    print("No")

Solution (Python):

from collections import Counter

S = input().strip()


cnt_S=Counter(S)

if len(cnt_S)==2 and all(1 for i,v in cnt_S.items() if v==2):
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

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

Solution (Python):
s = list(input())
d = {}
keys = set()
for i,name in enumerate(s):
    if name not in d:
        d[name] = 0
        keys.add(name)
    else:
        d[name] += 1
ans = "No"
if len(keys) == 2:
    a = keys.pop()
    b = keys.pop()
    if d[a] == 1 and d[b] == 1:
        ans = "Yes"

print(ans)

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

Solution (Python):
c = 0 ; a = []

s = input()

for i in range(4):
    if s[i] not in  a:
        a.append(s[i])
    else:
        c += 1
    
if len(a) == 2 and c == 2:
    print('Yes')
else:
    print('No')

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

Solution (Python):
s = input()

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

Solution (Python):
def solve():
    S = list(input())
    S.sort()
    ans = 'No'
    if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
        ans = 'Yes'
    return ans

print(solve())

Solution (Python):
from collections import defaultdict

def solve():
    S = list(input())
    d = defaultdict(int)
    for key in S:
        d[key] = d[key] + 1
    ans = 'Yes'
    for v in d.values():
        if v != 2:
            ans = 'No'
    return ans

print(solve())

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

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

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

Solution (Python):
s=input()
S=set([i for i in s])
if len(S)==2 and s.count(list(S)[0])==s.count(list(S)[1]):
    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()
s=sorted(s)
print('Yes' if s[0]==s[1] and s[1]!=s[2] and s[2]==s[3] else 'No')

Solution (Python):


def main():
    s = input()

    result = 'Yes'

    for char in set(s):
        if s.count(char) != 2:
            result = "No"
    
    print(result)

if __name__ == '__main__':
    main()

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

Solution (Python):
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = list(sr())
counter = Counter(S)
bool = True
for v in counter.values():
    if v != 2:
        bool = False

print('Yes' if bool else '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):
a = str(input())
s = sorted(a)
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 = sorted(s)

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

Solution (Python):
S = input()
from collections import Counter
c = Counter(S)
Sa = set(list(S))
if len(Sa) != 2:
    print("No")
    exit()
for i in Sa:
    if c[i] != 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
s = input()

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

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

Solution (Python):
S=input()
for i in range(4):
    if S.count(S[i])==2:
        continue
    else:
        break
if i==3:
    print('Yes')
else:
    print('No')

Solution (Python):
S = list(input())
char_cnt = dict()
cnt = 2
ans = 'Yes'

for s in S:
    if s in char_cnt:
        char_cnt[s] += 1
    else:
        char_cnt[s] = 1

for n in char_cnt.values():
    if n != cnt:
        ans = 'No'

print(ans)

Solution (Python):
s = input()
flag = 0
if s[0]==s[1]:
  if s[2]==s[3] and s[0]!=s[2]:
    flag=1
elif s[0]==s[2]:
  if s[1]==s[3] and s[0]!=s[1]:
    flag=1
elif s[0]==s[3]:
  if s[1]==s[2] and s[0]!=s[1]:
    flag=1

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

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

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

Solution (Python):
from collections import Counter

def main():
    S = input()
    count = [val for val in Counter(S).values() if val == 2]
    print("Yes" if len(count) == 2 else "No")

if __name__ == "__main__":
    main()

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

Solution (Python):
import sys


def main():
    s = list(input())
    set_s = set(s)
    if len(set_s) != 2:
        print("No")
        sys.exit(0)
    for x in set_s:
        if s.count(x) != 2:
            print("No")
            sys.exit(0)
    print("Yes")


if __name__ == "__main__":
    main()

Solution (Python):
S = input()
 
Dict = {}
 
for i in range(4):
  s = S[i]
  if s in Dict:
    Dict[s] += 1
  else:
    Dict[s]=1
    
if len(Dict)!=2:
  print("No")
else:
    List = list(Dict.values())
    if List[0]!=2 or List[1]!=2:
        print("No")
    else:
        print("Yes")

Solution (Python):
S = input()

Sset = list(set(list(S)))

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

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

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

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

Solution (Python):
a=input()
print('YNeos'[sum(map(a.count,a))!=8::2])

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

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

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

else:
  print("No")

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

Solution (Python):
a=list(input())
print('YNeos'[sum(map(a.count,a))!=8::2])

Solution (Python):
a=list(input())
print('YNeos'[sum([a.count(i) for i in a])!=8::2])

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

Solution (Python):
a,b,c,d=sorted(input())
print('YNeos'[1-(a==b!=c==d)::2])

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

s = sorted(S)
S = set(S)

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

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

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

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

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

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

Solution (Python):
s = input()

dic = {}

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

for k, v in dic.items():
    if v != 2:
        print('No')
        exit()

print('Yes')

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

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

Solution (Python):
S = input()

if len(set(S)) !=2:
  print('No')
  exit()
  
s = list(S)
s.sort()
if s[1] != s[2]:
  print('Yes')
else:
  print('No')

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

Solution (Python):

s=input()
s1=set(s)
s2=list(s1)
s3=list(s)

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

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

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

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

S.sort()

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

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

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

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

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

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

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

Solution (Python):


s = sorted(input())

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

Solution (Python):
from collections import Counter
S = Counter([s for s in input()])

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

Solution (Python):
from sys import stdin

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

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

Solution (Python):

s=input()
print('Yes' if len(set(s))==2 and all(s.count(s[i])==2 for i in range(4)) else 'No')

Solution (Python):

s=input()
print('Yes' if len(set(s))==2 and all(s.count(s[i]) for i in range(4)) else 'No')

Solution (Python):
s=input()
a=s[0]
b=0
ac=1
bc=1
for i in range(1,4):
    if s[i]!=a:
        if s[i]!=b:
            if b==0:
                b=s[i]
            else:
                break
        else:
            bc-=1
    else:
        ac-=1
if ac==0 and bc==0:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

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

Solution (Python):
import sys
word = input()
 
word_cnt = {}
 
for s in word:
  if s in word_cnt:
  	word_cnt[s]+=1
  else:
    word_cnt[s]=1
  
if len(word_cnt) != 2:
  print('No')
  sys.exit()
  
for cnt in word_cnt.values():
  if cnt != 2:
    print('No')
    sys.exit()

print('Yes')

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

Solution (Python):
S = input()
dic = {}
for x in S:
    if x not in dic:
        dic[x] = 1
    else:
        dic[x] += 1
ans = dic.values()
if list(ans) == list([2,2]):
    print("Yes")
else:
    print("No")

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

Solution (Python):
import os, sys, re, math

S = sorted(list(input()))

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

Solution (Python):
S = input()

print('Yes' if all(S.count(s) == 2 for s in S) else 'No')

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

Solution (Python):
n = str(input())
flag = 1
for i in n:
  if n.count(i) == 2:
    pass
  else:
    flag = 0

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

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

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

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

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

Solution (Python):






import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    ss = list(set(s))
    flag = False

    if len(ss) == 2:
        a = s.count(ss[0])
        b = s.count(ss[1])
        if a == b == 2:
            flag = True

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

if __name__ == '__main__':
    main()

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

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

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

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

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

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

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

Solution (Python):
s = input()
dic = {}
for si in s:
    dic[si] = 0
for si in s:
    dic[si] += 1

cnt = 0
cnt_len = 0
for i, j in dic.items():
    
    cnt_len += 1
    if j == 2:
        cnt += 1
if cnt == 2 and cnt_len == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
from collections import Counter
D = Counter(list(S))
if list(D.values()).count(2)==2:
    print('Yes')
else:
    print('No')

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

s_set = list(set(s))
if len(s_set) != 2:
    print('No')
else:
    count1 = 0
    for i in range(len(s)):
        if s[i] == s_set[0]:
            count1 += 1
    count2 = 0
    for i in range(len(s)):
        if s[i] == s_set[1]:
            count2 += 1
    if count1 == 2 and count2 == 2:
        print('Yes')
    else:
        print('No')

Solution (Python):
import collections

S = input()
length=len(set(S))

CTR = collections.Counter(S).most_common()

if (length == 2 and CTR[0][1] == 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 len(set(s)) != 1:
  print("Yes")
else:
  print("No")

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

Solution (Python):
from collections import Counter

S = input()

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

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

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

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

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

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

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

Solution (Python):
s=input()

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

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

dup = [x for x in set(s) if s.count(x) == 2]

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

Solution (Python):
S = input()
S = S.replace(S[0],"")
if len(S) > 0:
    S = S.replace(S[0],"")
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
S = input()

m = {}

for c in S:
  if c in m:
    m[c] += 1
  else:
    m[c] = 1

if len(m) != 2:
  print("No")
  exit()

for k, v in m.items():
  if v != 2:
    print("No")
    exit()

print("Yes")

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

Solution (Python):



from collections import Counter

def main():
  counts = Counter(list(input().strip()))
  if len(counts) == 2 and all([v==2 for k, v in counts.items()]):
    print('Yes')
  else:
    print('No')

if __name__=='__main__':
  main()

Solution (Python):
N = input()
S = sorted(N)
flag = True
if S[0] != S[1]:
  flag = False
if S[2] != S[3]:
  flag = False
if S[1] == S[2]:
  flag = False
if flag == True:
  print("Yes")
else:
  print("No")

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

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

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

print(ans)

Solution (Python):
s = input()
use = set()
for i in range(4):
    use.add(s[i])
if len(use) != 2:
    print("No")
    exit()
if (s[0] == s[1] and s[1]==s[2]) or (s[0] == s[1] and s[1] == s[3]) or (s[0] == s[2] and s[2] == s[3]) or (s[1]== s[2] and s[2]== s[3]):
    print("No")
    exit()

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