Problem:
 Score : 100 points    Problem Statement You are given a 4 -character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S .      Constraints  The length of S is 4 .  S consists of uppercase English letters.         Input Input is given from Standard Input in the following format:  S       Output If S consists of exactly two kinds of characters which both appear twice in S , print Yes ; otherwise, print No .        Sample Input 1 ASSA      Sample Output 1 Yes  S consists of A and S which both appear twice in S .       Sample Input 2 STOP      Sample Output 2 No       Sample Input 3 FFEE      Sample Output 3 Yes       Sample Input 4 FREE      Sample Output 4 No

Solution (Python):




S = input().strip()
first_char = ['', 0]
second_char = ['', 0]
counter = 0
ans = True
for c in S:
    if counter == 0:
        first_char[0] = c
        first_char[1] += 1
    
    if counter == 1:
        if c != first_char[0]:
            second_char[0] = c
            second_char[1] += 1
        else:
            first_char[1] += 1
            
    if counter >1:
        if second_char[0] == '':
            second_char[0] = c
            
        if(first_char[0] != c and second_char[0] != c):
            ans = False
            break
        if c == first_char[0]:
            first_char[1] += 1
            if first_char[1] > 2:
                ans = False
                break
                
        if c == second_char[0]:
            second_char[1] += 1
            if second_char[1] > 2:
                ans = False
                break
    counter += 1

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

Solution (Python):
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    s = inputs[0]
    counts = {}
    for c in s:
        if c in counts:
            counts[c] += 1
        else:
            counts[c] = 1

    if len(counts) != 2:
        return "No"

    for k, v in counts.items():
        if v != 2:
            return "No"
    return "Yes"


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Solution (Python):
from collections import Counter; print("YNeos"[list(Counter(list(input())).values()) != [2,2]::2])

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

con = True
for i in ss:
  if ss.count(i) != 2:
    con = False
if con:
  print("Yes")
else:
  print("No")

Solution (Python):
def calc(text):
  unique = list(set(text))
  if len(unique) != 2:
    return "No"

  if text.count(unique[0]) == 2:
    return "Yes"
  else:
    return "No"

text = input()
print(calc(text))

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

Solution (Python):
cnt = {}

A = input()

for i in A:
    if i in cnt:
        cnt[i] += 1

    else:
        cnt[i] = 1


diclenth = len(cnt)


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

Solution (Python):
a,b,c,d = input()
flag = 0
if(a==b and c==d):
    flag = 1
elif(a==c and b==d):
    flag = 1
elif(a==d and b==c):
    flag = 1
else:
    flag = 0
if(a==b and a==c and a==d):
    flag = 0
if(flag==1):
    print("Yes")
else:
    print("No")

Solution (Python):
a,b,c,d=input()
kotae="No"
kai=0
if (a==b and c==d):
        kotae="Yes"
        kai+=1
if (a==c and b==d):
        kotae="Yes"
        kai+=1
if (a==d and b==c):
        kotae="Yes"
        kai+=1
if(kai!=1):
    kotae="No"
print(kotae)

Solution (Python):
S = input()
A = set (S)
B = len (A)
if B == 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()
S_list = set(list(S))





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

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

Solution (Python):
list1 = [0,0]
S=input()

a1 = S[0]
a2 = "NUM"

if S[1] == a1:
    list1[0]=2
else:
    a2 = S[1]

if S[2]==a1:
    list1[0]=2
else:
    if S[1]==a1:
        a2 =S[2]
    else:
        if S[2]==a2:
            list1[1]=2
        else:
            pass

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

Solution (Python):
S = input()
if S.isupper() == True:
    if  (S[0]==S[1] and S[2]==S[3] and S[1]!=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')
else:
    print('No')

Solution (Python):
S = input()
isFifty = True
for i in S:
    if S.count(i) != 2:
        isFifty = False
if isFifty:
    print('Yes')
else:
    print('No')

Solution (Python):
text = list(input())
first = text[0]
firstCount = 1
second = ""
secondCount = 0
error = False
for i in range(1, 4):
    moji = text[i]
    if moji == first:
        firstCount += 1
        if firstCount > 2:
            error = True
            break
    else:
        if second == "" or second == moji:
            second = moji
            secondCount += 1
            if secondCount > 2:
                error = True
                break
        else:
            error = True
            break
if error == True:
    print("No")
else:
    print("Yes")

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

if len(b) != 2:
    print("No")
elif a.count(b[0]) != 2 or a.count(b[1]) != 2:
    print("No")
else:
    print("Yes")

Solution (Python):


import sys
import copy

sys.setrecursionlimit(1000000)






S = input().rstrip()
S = sorted(S)

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

Solution (Python):
s = str(input())
c1 = "Init"
c2 = "Init"
ans = "Yes"
for i in s:
    if c1 == "Init":
        c1 = i
    elif c1 == i:
        continue
    elif c2 == "Init":
        c2 = i
    elif c2 == i:
        continue
    else:
        ans = "No"
        break
if c2 == "Init":
    ans = "No"
print(ans)

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

Solution (Python):
s = input()

s_d = dict()

for c in s:
  if s_d.get(c) is None:
    s_d[c] = 1
  else:
    s_d[c] += 1
  
flag = True
for v in s_d.values():
  if not v == 2:
    flag = False

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

Solution (Python):
S = input()

T = sorted(S)
ans = (
    'Yes' if T[0] == T[1] and T[1] != T[2] and T[2] == T[3] else
    'No'
)

print(ans)

Solution (Python):
from collections import defaultdict

s_dic = defaultdict(int)
for s in list(input()):
    s_dic[s] += 1

values_set = list(set(s_dic.values()))
if len(s_dic.keys()) == 2 and len(values_set) == 1 and values_set[0] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
c = 0
for i in range(len(s)):
  for j in range(i + 1, len(s)):
    if s[i] == s[j]:
      c += 1

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

Solution (Python):
S=input()

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

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

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

s = set(S)
if len(s) == 2:
    count = 0
    for _ in s:
        if len([a for a in S if a == _]) == 2:
            print('Yes')
            quit()

print('No')

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

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

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

Solution (Python):
from collections import Counter

word = input()
seen_letters = Counter(word)

flag = 'Yes'
for letter in seen_letters:
    if seen_letters[letter] != 2:
        flag = "No"

print(flag)

Solution (Python):
word = input()

seen_letters = {}

for letter in word:
    seen_letters[letter] = seen_letters[letter] + 1 if letter in seen_letters else 1

flag = 'Yes'
for letter in seen_letters:
    if seen_letters[letter] != 2:
        flag = "No"

print(flag)

Solution (Python):


from collections import defaultdict

S = input()
d = defaultdict(int)

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

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

Solution (Python):
S = list(input())
str = "Yes"
for char in S:
    if S.count(char) != 2:
        str = "No"
print(str)

Solution (Python):
N = input()

A = []
for i in range(1,4):
	if N[i] != N[0]:
		A.append(N[i])

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

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

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

if __name__=="__main__":
    main()

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

Solution (Python):
S = input()

sorted_S = sorted(S)

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

Solution (Python):
import collections
s = list(input())
t = collections.Counter(s)
temp = True
for i in t:
    if t[i] != 2:
        temp = False
if temp:
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
s = input()

sr = list(set(s))

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()

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

Solution (Python):
s = input()

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

Solution (Python):
s=input()

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

Solution (Python):
s = input()
d = dict()

for c in s:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1
        
result = 'Yes'
for k in d:
    if d[k] != 2:
        result ='No'
        
print(result)

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()
d = dict()

for c in s:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1
        
result = 'Yes'
for k in d:
    if d[k] != 2:
        result = 'No'
        
print(result)

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

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

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

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

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

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

Solution (Python):
L=input()
L_l=[]
for i in L:
     L_l.append(i)
L_l.sort()

if L_l[0]==L[1] and L_l[1]==L_l[2]:
     print("No")
elif L_l[0]==L_l[1] and L_l[2]==L_l[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()
t = list(s)[0]
s = s.replace(t, '', 2)
if(list(s)[0] != t):
    s = s.replace(list(s)[0], '', 2)
if(len(s) == 0):
    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):
inputS = set(input())
if len(inputS) == 2:
    print('Yes')
else:
    print('No')

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

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

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

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

for i in range(4):
  if 2 != s.count(s[i]):
    print("No")
    sys.exit()
    
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[1]:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
C = Counter(S)
if all([v == 2 for key, v in C.items()]):
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

Count = 0
for i in range(len(S)):
    count = 0
    for j in range(len(S)-i-1):
        
        
        if (S[i] == S[i+j+1]):
            count += 1
            
            
        if (count == 1):
            Count += 1
            
            
            break

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

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

Solution (Python):
a = list(input())
a.sort()
s = 1
if (len(set(a))==2 and a[0]==a[1] and a[2]==a[3]):s = 0

def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
y(s,0)

Solution (Python):
s = input()
t = list(set(s))
if len(t)==2:
    flag = True
    for i in range(2):
        if s.count(t[i]) != 2:
            flag = False
else:
    flag = False

print("Yes" if flag==True else "No")

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

Solution (Python):



def main():
    from collections import Counter

    s = Counter(input())

    if len(s.keys()) == 2:
        count = 0

        for v in s.values():
            if v == 2:
                count += 1

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


if __name__ == '__main__':
    main()

Solution (Python):



def main():
    from collections import Counter

    s = Counter(input())

    if len(s.keys()) == 2:
        count = 0

        for v in s.values():
            if v == 2:
                count += 1

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
from collections import Counter

str = input().strip()

count = Counter(str)

if len(count) == 2:
    for v in count.values():
        if v == 2:
            print("Yes")
        else:
            print("No")
        
        break

else:
    print("No")

Solution (Python):
a = input()

if a[0] == a[1] == a[2]:
    print("No")

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

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

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

else:
    print("No")

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

S_set=list(set(S))

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

for s in S_set:
    if S.count(s) == 2:
        ans += 1

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

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

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

Solution (Python):


import sys
tmp = input()

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

Solution (Python):
l =[str(i) for i in input()]
l_set = list(set(l))
if len(l_set) ==2:
  print('Yes')
else:
  print('No')

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

Solution (Python):
s = input()

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

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

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

Solution (Python):
s=input()
ans=0
for i in range(4):
    ans+=s.count(s[i])
if ans==8: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):
import collections

S=input()
c=collections.Counter(S)
c=dict(c)
for key in c:
    if c[key]!=2:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
s = input().strip()
v = {}

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

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

Solution (Python):


S = input()

flg = True

for i in S:
    if S.count(i) != 2:
        flg = False

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

Solution (Python):
import collections
s=input()
x=list(s)
c = collections.Counter(x)
if len(set(s))==2:
    if list(c.values())[0]==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
str = input()

list = []
num = []

for i in str:

    if len(list) is 0:
        list.append(i)
    else:
        if list.count(i) == 0:
                list.append(i)



for i in list:
    num.append(str.count(i))

if len(num) is 2 and num[0]==2 and num[1]==2:
    print("Yes")
else:
    print("No")

Solution (Python):
str = input().split()[0]
first = str[0]
strlist = str.split(first)
if len(strlist) != 3:
	print("No")
else:
	if len(strlist[1]) == 2:
		if strlist[1][0] == strlist[1][1]:
			print("Yes")
		else:
			print("No")
	elif len(strlist[1]) == 1 and len(strlist[2]) == 1:
		if strlist[1][0] == strlist[2][0]:
			print("Yes")
		else:
			print("No")
	elif len(strlist[2]) == 2:
		if strlist[2][0] == strlist[2][1]:
			print("Yes")
		else:
			print("No")
	else:
		print("No")

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

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

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

Solution (Python):
import sys

s = input()
if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")

Solution (Python):
import sys

s = input()
if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")

Solution (Python):
import sys

s = input()
if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")

Solution (Python):
import sys



s = input()
if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")
exit()

Solution (Python):
S = input()
def solve():
  for s in S:
    if not(S.count(s) == 2):
      return False
  return True

print('Yes' if solve() else 'No')

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

i = 0
while i < 3:
  if s_list.count(s_list[i]) == 2:
    i = i + 1
    continue
  else:
    break

if i == 3:
  print("Yes")
else:
  print("No")

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

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

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

Solution (Python):
S=input()
hantei=False
SS=sorted(S)
if(len(set(S))==2):
    if(SS[0]==SS[1] and SS[0]!=SS[2]):
        hantei=True
    else:
        hantei=False
else:
    hantei=False


if(hantei==True):
    print("Yes")
else:
    print("No")

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

Solution (Python):
print('YNeos'[not (lambda s: s[0]==s[1]!=s[2]==s[3])(sorted(input()))::2])

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

Solution (Python):
s = input()
word_list = []
for i in range(len(s)):
    word_list.append(s[i])
list = []

for i in range(len(word_list)):
    flag = 0
    w = word_list[i]
    if len(list) == 0:
        list.append([w,1])
    else:
        for j in range(len(list)+1):
            if j == len(list) and flag == 0:
                list.append([w,1])
            elif j == len(list):
                continue
            elif list[j][0] == w:
                flag = 1
                list[j][1] = list[j][1] + 1

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

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

Solution (Python):
S = input()

if len(set(S)) == 2:
  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()

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

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

dic = {}
for i, v in enumerate(l):
    if v in dic:
        dic[v] += 1
    else:
        dic[v] = 1

li = list(dic.values())
if li[0] == 2 and li[1] == 2:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
li = list(input())
li1 = li[:]

flag = 'No'
for i in range(1,4):
    if li[0]==li[i]:
        del li1[i],li1[0]
        if li1[0] == li1[1]:
            flag = 'Yes'
            break
        break
if li[0]==li1[0]:
    flag = 'No'

print(flag)

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

Solution (Python):
s = [n for n in input()];r = len(set(s)) == 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" if r else "No")

Solution (Python):


def fifty_fifty(word):
    r = {}
    for s in list(word):
        if s in r:
            r[s] += 1
        else:
            r[s] = 1
    if len(r) == 2 and max(r.values()) == 2:
        return 'Yes'
    else:
        return 'No'

s = input()
print(fifty_fifty(s))

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

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

line = list(set(s))

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

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

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

Solution (Python):
S = input()
a_dict = dict()
count = 0
for word in S:
  a_dict.setdefault(word, count)
  if word in a_dict.keys():
    a_dict[word] += 1
if len(a_dict) != 2:
  print("No")
else:
  for value in a_dict.values():
    if value != 2:
      print("No")
      break
    else:
      print("Yes")
      break

Solution (Python):
S=input()

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

Solution (Python):
str = input() 

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

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

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

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

Solution (Python):
s=input()
d={}
for ss in s:
  d[ss]=0
for ss in s:
  d[ss]+=1
if len(d.keys())==2:
  f=True
  for k in d:
    if d[k]!=2:
      f=False
  if f :
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
def main():
    s = list(raw_input())
    flag = False
    if s[0] == s[1] and s[2] == s[3]:
        if s[0] != s[2]:
            flag = True
    elif s[0] == s[3] and s[1] == s[2]:
        if s[0] != s[1]:
            flag = True
    elif s[0] == s[2] and s[1] == s[3]:
        if s[0] != s[1]:
            flag = True
    if flag == True:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Solution (Python):
import sys
sys.setrecursionlimit(100000)

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

x=input()
for i in range(len(x)):
    if x.count(x[i])!=2:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
s = input()

li = [0,0,0,0]
for i in range(len(s)):
  for j in s:
    if s[i] == j:
      li[i] += 1
      
if li == [2,2,2,2]:
  print("Yes")
else:
  print("No")

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

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

Solution (Python):
import sys
 
s = list(input())
 
for i in range(2):
    letter = s[0]
    del s[0]
    if s.count(letter) == 1:
        del s[s.index(letter)]
    else:
        print('No')
        sys.exit()
print('Yes')

Solution (Python):

S = input()

l = list(S)

s = set(l)

if len(s) != 2:
    print('No')
else:
    if l[0] == l[1] or l[0] == l[2] or l[0] == l[3]:
        print('Yes')
    else:
        print('No')

Solution (Python):
s = input()
from collections import defaultdict
dic = defaultdict(lambda : 0)
for i in s:
    dic[i] += 1
if len(dic.keys()) == 2:
    flag = 0
    for key in dic.keys():
        if dic[key] != 2:
            flag = 1
else:
    flag = 1
if flag == 0:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()

from collections import Counter
if len(s) != 4: print('No'); exit()
a = Counter(s)
if len(a) != 2: print('No'); exit()
for key in a:
    if a[key] != 2: print('No'); exit()

print('Yes')