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

def main():
    S = input()

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

input = lambda: stdin.readline().rstrip()
main()

Solution (Python):
a = input()
arr = []

for i in range(len(a)):
    arr.append(a[i])

for i in range(len(arr)):
    if arr.count(arr[i]) == 2:
        continue
    else:
        print('No')
        exit()

print('Yes')

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

Solution (Python):
S = input()
s = set(S)
flg = True
for a in s:
    n = S.count(a)
    if n!=2:
        flg = False
        break
if flg:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
s = input()

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

print("Yes")

Solution (Python):



def f(S):
    X = {}
    for c in S:
        X[c] = X.get(c, 0) + 1

    if len(X) != 2:
        return False

    for key, value in X.items():
        if value != 2:
            return False

    return True


def main():
    S = input()
    
    print('Yes' if f(S) else 'No')




if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()

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

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

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

Solution (Python):
s = input()

l = list(s)
sets = list(set(l))

if l.count(sets[0]) == 2 and l.count(sets[1]) == 2 and len(sets) == 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
if len(d.keys()) == 2 and list(d.values()) == [2, 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()
d = {}

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

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


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

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

else:
  print("No")

Solution (Python):
str = input()

ans = False
if str[0] == str[1] and str[2] == str[3]:
    ans = True
elif str[0] == str[2] and str[1] == str[3]:
    ans = True
elif str[0] == str[3] and str[1] == str[2]:
    ans = True

if str[0] == str[1] and str[0] == str[2]:
    ans = False
    
if ans:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
A,B,C,D=input()
i=0
if A==B and C==D and A!=C:
    i=1
if A==C and B==D and B!=C:
    i=1
if A==D and B==C and A!=C:
    i=1
if i==0:
    print("No")
if i==1:
    print("Yes")

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

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

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

L = []
S = input()
for i in range(4):
    L.append(S[i])

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

Solution (Python):
S = input()

if len(set([x for x in S])) == 2:
  print('Yes')
else:
  print('No')

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

uniq = list(set(S))

if len(uniq) != 2 :
    print('No')
else :
    count = {}
    for s in S :
        if s in count :
            count[s] += 1
        else :
            count[s] = 1

    if count[uniq[0]] == 2 :
        print('Yes')
    else :
        print('No')

Solution (Python):
S = raw_input()
print "Yes" if [2]*4==[S.count(s) for s in S] else "No"

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

a.sort()

ans="No"
if a[0]==a[1]:
  if a[1]!=a[2]:
    if a[2]==a[3]:
      ans="Yes"

print(ans)

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

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

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

Solution (Python):
s = input()

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

Solution (Python):
S = str(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):
from collections import defaultdict
s = input().strip()
d = defaultdict(int)
for v in s:
    d[v] += 1

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

Solution (Python):
S = input()
let_1 = ""
let_2 = ""
count_1 = 0
count_2 = 0
for s in S:
    if s == let_1:
        count_1 += 1
    elif s == let_2:
        count_2 += 1
    elif let_1 == "":
        let_1 = s
        count_1 += 1
    elif let_2 == "":
        let_2 = s
        count_2 += 1
    else:
        print("No")
        exit()

if count_1 == 2 and count_2 == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = list(input())
c = False
a = s[0]
n = s.count(a)
for i in range(n):
    s.remove(a)
if len(s) == 2:
    if s[0] == s[1]:
        c = True

print("Yes" if c else "No")

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


rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

S = input()
ans = 0
if S.count(S[0]) == 2:
    for i in range(1,4):
        if S[0] != S[i] and S.count(S[i]) == 2:
            ans = 1

yn(ans)

Solution (Python):
s=input()
s_s=set()
for i in s:
    s_s.add(i)
s_s=list(s_s)
if len(s_s)==2:
    a=s_s[0]
    b=s_s[1]
    a_c=0
    b_c=0
    for i in s:
        if i==a:
            a_c+=1
        else:
            b_c+=1
    if a_c==2 and b_c==2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
s = input()
l = list(s)
c1 = s.count(l[0])
c2 = s.count(l[1])
c3 = s.count(l[2])
c4 = s.count(l[3])
if c1 == 2 and c2 == 2 and c3 == 2 and c4 == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
s = input()
l = {s[0] : 1,s[1] : 1,s[2] : 1,s[3] : 1}
print('Yes' if len(l)==2 else 'No')

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

Solution (Python):
import collections

S = list(input())
c = collections.Counter(S)
if c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2:
  print("Yes")
else:
  print("No")

Solution (Python):

S=str(input())

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

Solution (Python):



S = input()

list_str = []
for s in S:
    if not s in list_str:
        list_str.append(s)
if len(list_str) == 2:
    print('Yes')
else:
    print('No')

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

a_ = len(set(s))

if s_ == a_*2:
  print('Yes')
else:
  print('No')

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

Solution (Python):
s = list(input())
s0 = list(set(s))
p = s0[0]
ans = 0
for a in s:
    if a == p:
        ans += 1
if len(s0) == 2 and ans == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

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

Solution (Python):
from sys import stdin

input=list(stdin.readline().rstrip())

counter=0
word=[]
for i in input:
    if counter==0:
        word.append(i)
        counter+=1
    else:
        if i not in word:
            counter+=1
            word.append(i)

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

Solution (Python):
s = input()

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

    else:
        print("No")

Solution (Python):
words = lambda t : list(map(t, input().split()))
s = input()

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

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

SS = sorted(S)

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

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

flag=True

for s in S_:
    if S.count(s)!=2:
        flag=False

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

Solution (Python):
from collections import Counter

s = input()
counter = Counter(s)
if len(counter.keys()) == 2 and list(counter.values())[0] == 2:
	print("Yes")
else:
	print("No")

Solution (Python):
s=input()
d={}
for i in range(4):
    d.setdefault(s[i],0)
    d[s[i]]+=1
check=True
for k in d.values():
    if k!=2:
        check=False
if check:
    print('Yes')
else:
    print('No')

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

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

print('Yes')

Solution (Python):
yn = lambda b: print('Yes') if b else print('No')

s = input()		

b = True
b = b and (s.count(s[0]) == 2)
b = b and (s.count(s[1]) == 2)
b = b and (s.count(s[2]) == 2)
b = b and (s.count(s[3]) == 2)

yn(b)

Solution (Python):
S = input()
if all([S.count(x) == 2 for x in set(S)]):
  print("Yes")
else:
  print("No")

Solution (Python):

import sys
import re
import random
import numpy as np
from math import sqrt,log
from fractions import gcd  
from collections import Counter, defaultdict




ct = list(Counter(raw_input().rstrip()).values())
if ct == [2,2]:
    print 'Yes'
else:
    print 'No'

Solution (Python):
a=input()
a=[i for i in a]
c=a.count(a[0])
x=0
for i in a:
    if i!=a[0]:
        x=i
c2=a.count(x)
if c==2 and c2==2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = list(input())
s_set = set(s)
if len(s_set) != 2:
  print("No")
else:
  for str in s_set:
    s.remove(str)
  if len(set(s)) != 2:
    print("No")
  else:
    print("Yes")

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

S = input()
d = defaultdict(int)
for s in S:
    d[s] += 1

ret = 'No'

if len(d) == 2:
    for dd in d.values():
        
        if dd == 2:
            ret = 'Yes'
            break

print(ret)

Solution (Python):
S = str(input())
slist = [S[i] for i in range(4)]
if len(set(slist))!=2:
  print('No')
elif slist.count(slist[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]) 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()
inn = []
for i in range(4):
  inn += [ord(s[i])]
  
inn.sort()
flag = 1
if inn[0] != inn[1]:
  flag= 0
if inn[1] == inn[2]:
  flag=0
if inn[2] != inn[3]:
  flag=0
if flag:
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()

for elm in s:
    if s.count(elm) != 2:
        print("No")
        break
else:
    print("Yes")

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==2 and b==2 and c==2 and d==2:
  print("Yes")
else:
  print("No")

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

Solution (Python):
from collections import defaultdict

S = input()

d = defaultdict(int)
for s in S:
    d[s] += 1
    
if (len(d)==2) & ([d[s] for s in S] == [2,2,2,2]):
    print("Yes")
else:
    print("No")

Solution (Python):

import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)

dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())


s = input()

sset = set(s)

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

print('Yes')

Solution (Python):
s = input()

cnt = 0

flag = True
for s1 in s:
    for s2 in s:
        if s1 is s2:
            cnt += 1


    if cnt != 2:
        flag = False

    cnt = 0

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

Solution (Python):
N = input()

if len(N) != 4:
    print("No")

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

Solution (Python):
S = input()

dec = {}

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

ok = True
for i in dec:
    if dec[i] != 2:
        ok = False

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

Solution (Python):
S = input()
W = {S[0]: 1}
cnt = 1
for i in range(1, 4):
    if S[i] in W:
        W[S[i]] += 1
        if W[S[i]] == 3:
            print("No")
            break
    else:
        W[S[i]] = 1
        cnt += 1
        if cnt == 3:
            print("No")
            break
else:
    print("Yes")

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[2]:
    print('Yes')
else:
    print('No')

Solution (Python):
a,b,c,d=list(input())


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

Solution (Python):
from collections import Counter

S = input()

counter = dict(Counter(list(S)))

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

Solution (Python):
S=input()
slist=[S[0]]
numlist=[1]
for i in range(1,4):
    if not S[i] in slist:
        slist.append(S[i])

if len(slist)!=2:
    ans='No'
else:
    numlist=[0,0]
    for i in range(4):
        for j in range(2):
            if S[i]==slist[j]:
                numlist[j]+=1
    if numlist[0]==2 and numlist[1]==2:
        ans='Yes'
    else:
        ans='No'

print(ans)

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

Solution (Python):




def solve():
    S = input()
    s1 = (S[0] == S[1] and S[1] != S[2] and S[2] == S[3])
    s2 = (S[0] == S[2] and S[2] != S[1] and S[1] == S[3])
    s3 = (S[0] == S[3] and S[3] != S[1] and S[1] == S[2])
    return 'Yes' if (s1 or s2 or s3) else 'No'


def main():
    print(solve())


if __name__ == "__main__":
    main()

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

Solution (Python):
import sys

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

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

Solution (Python):
S=input()

s=0

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

if s==1:
    print('Yes')
else:
    print('No')

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

Solution (Python):
s = input()
s_dict = dict()
for i in s:
    if i not in s_dict:
        s_dict[i] = 1
    else:
        s_dict[i] += 1
for i in s_dict:
    if s_dict[i] != 2:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
def resolve():
    ss = input()

    tmp1 = ss[0]
    tmp2 = ""

    cnt1 = 1
    cnt2 = 0
    for s in ss[1:]:
        if s == tmp1:
            cnt1 += 1
        else:
            if tmp2 == "":
                tmp2 = s
                cnt2 = 1
            else:
                if tmp2 == s:
                    cnt2 += 1

    if cnt1 == 2 and cnt2 == 2:
        print('Yes')
    else:
        print('No')
        
resolve()

Solution (Python):
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    s = SI()
    from  collections import Counter
    co = Counter(s)
    if len(co) == 2:
        for i in co:
            if co[i] != 2:
                print('No')
                return
            print('Yes')
            return
    else:
        print('No')
        return
main()

Solution (Python):
s = input()

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

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

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

print('No')

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

Solution (Python):
from collections import Counter


s = list(input())
v = s[0]
c = Counter(s)
if len(c) == 2 and c[v] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


s = IS()
s = sorted(s)
if len(s) != 4:
    print('No')
else:
    print('Yes' if s[0] == s[1] and s[2] == s[3] and s[0] != s[2] else 'No')

Solution (Python):
s = input()

p = []
l = []
for i in s:
    if i in p:
        l.append(i)
    else:
        p.append(i)
if len(l) == 2 & len(p) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

slist = [i for i in s]

sset = set(slist)

def a():
    if len(sset) == 2:
        for i in sset:
            cnt = 0
            for j in slist:
                if i == j:
                    cnt += 1
            if cnt == 2:
                print("Yes")
                return
            else:
                print("No")
                return
    else:
        print("No")
        return

a()

Solution (Python):
S = input()

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

Solution (Python):
w = input()
if w.count(w[0])==2:
  w = w.replace(w[0],"",2)
  if w.count(w[0])==2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

Solution (Python):
from collections import Counter

S = Counter(list(input()))


def solve(S):
    if len(S) == 2:
        f = True
        for k, v in S.items():
            if v != 2:
                f = False
        if f:
            print("Yes")
            return 0
    print("No")
    return 0


solve(S)

Solution (Python):
s = input()
let = []
one = ''
two = ''
for i in s:
    if i not in let:
        let.append(i)
    elif one == '':
        one = i
    elif one != '' and i != one:
        two = i

if one != '' and two != '':
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
S = list(input())
ss = set(S)
if len(ss) == 2:
    co = 0
    for c in S[1:]:
        if  c == S[0]:
            co += 1
    if co == 1:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
input_line = input()
dic = {}
cnt = 0
for s in input_line:
    if s not in dic:
        dic[s] = 0
        cnt+=1

print('Yes' if len(dic.keys()) == 2 else 'No')

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

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):
from collections import Counter
S= input()
t = Counter(S)
for v in t.values():
  if v != 2:
    print('No')
    break
else:
  print('Yes')

Solution (Python):
s = input()
l = len(s)
set_s = set(s)

if l == 4 and len(set_s) == 2:
    print('Yes')
else:
    print('No')

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

s_uniq = set(s)

if len(s_uniq) != 2:
  print("No")
else:
  for ch in s_uniq:
    if s.count(ch) != 2:
      print("No")
      break
  else:
    print("Yes")

Solution (Python):
S = input()

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

Solution (Python):

from collections import defaultdict
import math
import re

def main():
    
    S = list(input().strip())
    d = defaultdict(int)
    for s in S:
        d[s] += 1

    if len(d) == 2 and all([s == 2 for s in d.values()]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Solution (Python):
S = list(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 = 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[2]:
    result = "Yes"
else:
    result = "No"
print(result)

Solution (Python):
S = input()
A =[]
for i in range(4):
    A.append(S[i])
B = set(A)
if len(B) == 2:
    print("Yes")
else:
    print("No")

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

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

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

print("Yes")

Solution (Python):
s = input()
s = list(s)
li =[]
for i in range(len(s)):
  li.append(s.count(s[i]))
if sum(li) == 8:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
a = []
b = [0,0,0,0]
for i in range(4):
    if not(S[i] in S[:i]):
        a.append(S[i])
    else:
        b[a.index(S[i])] += 1
if b == [1,1,0,0]:
    print("Yes")
else:
    print("No")

Solution (Python):
s= input()
done =set()
count = []
for c in s:
    if c not in done:
        count.append(s.count(c))
        done.add(c)
if len(count)==2:
    print('Yes' if count[0]==2 and count[1]==2 else 'No')
else:
    print('No')

Solution (Python):
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    S = input()
    num_dicts = {}
    for i in range(len(S)):
        if S[i] not in num_dicts:
            num_dicts[S[i]] = 1
        else:
            num_dicts[S[i]] += 1
    for key_, value_ in num_dicts.items():
        if value_ == 2:
            pass
        else:
            print("No")
            sys.exit()
    else:
        if len(num_dicts) == 2:
            print("Yes")
            sys.exit()
        else:
            print("No")
            sys.exit()


if __name__ == '__main__':
    main()

Solution (Python):
s = input()
str_list = []
sec_list = []
flag = 0
for i in s:
    if (i in str_list) and (i not in sec_list):
        flag += 1
        sec_list.append(i)
    else:
        str_list.append(i)
        
if flag == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = list(input())
T = set(S)
ans = "No"
for t in T:
    if S.count(t) == 2:
        continue
    break
else:
    ans = "Yes"
print(ans)

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

cnt = {}

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

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

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

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

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

Solution (Python):
c = 0
s = input()
for w in s:
    n = s.count(w)
    if n==2:
        c += 1
if c == 4:
    print('Yes')
else:
    print('No')

Solution (Python):
s = list(input())
d = dict()
ans = "No"
for t in s:
  if t not in d:
    d[t] = 0
  d[t] += 1
if list(d.values()) == [2,2]:
  ans = "Yes"
print(ans)

Solution (Python):
S =  str(input())
m = list(set(S))
cnt_first = 0
cnt_second = 0
if len(m) == 2:
    first = m[0]
    sec = m[1]
    for i in range(len(S)):
        if S[i] == first:
            cnt_first += 1
        elif S[i] == sec:
            cnt_second += 1
else:
    print("No")
    exit()
if cnt_first == 2 and cnt_second == 2:
    print("Yes")

Solution (Python):
S = input()

a = S[0]
a0 = 1

b = ''

if a != S[1]:
    b = S[1]
    b0 = 1
elif S[0] == S[1]:
    a0 += 1

if a == S[2]:
    a0 += 1
elif b == '':
    b = S[2]
    b0 = 1
elif b == S[2]:
    b0 += 1

if a == S[3]:
    a0 += 1
elif b == S[3]:
    b0 += 1

if a0 == 2 and b0 == 2:
    print("Yes")
else:
    print("No")

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

k = list(d.keys())
if len(k) == 2 and (d[k[0]] == 2 and d[k[1]] == 2):
  print('Yes')
else:
  print('No')