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

Solution (Python):
S = list(input())
i=0
if(S[i]==S[i+1]==S[i+2]==S[i+3]):
    print('No')
elif S[i]==S[i+1] and S[i+2]==S[i+3]:
    print('Yes')
elif S[i]==S[i+2] and S[i+1]==S[i+3]:
    print('Yes')
elif S[i]==S[i+3] and S[i+1]==S[i+2]:
    print('Yes')

else:
    print('No')

Solution (Python):
s = str(input())
s_unique = ''.join(set(s))
is_st = True
for i in s_unique:
    if s.count(i) != 2:
        is_st = False
        break
        
print('Yes' if is_st else 'No')

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

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

if(a==b):
    count+=1
    if(c==d and a!=c):
        count+=1
elif(a==c):
    count+=1
    if(b==d and a!=b):
        count+=1
elif(a==d):
    count+=1
    if(b==c and a!=b):
        count+=1

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

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

Solution (Python):
import collections


line = input().strip()

counter = collections.Counter(line)

if len(counter) == 2:
    former, latter = counter.most_common(2)
    if former[1] == latter[1] == 2:
        print("Yes")
        exit(0)

print("No")
exit(0)

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

count = {}
result = "Yes"
for s in word:
  if count.get(s) != None:
    count[s] += 1
  else:
    count[s] = 1
if (len(count) != 2):
  result = "No"
else:
  for t in count.values():
    if t != 2:
      result = "No"

print(result)

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

Solution (Python):
str = input()
chars = list(str)
lng = []

for i in range(len(chars)):
    lng.append(ord(chars[i]))

lng.sort()

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

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

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

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

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

Solution (Python):


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

Solution (Python):
s = input()

a = []

for i in range(4):
    a.append(s[i])

a.sort()

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

Solution (Python):

from collections import Counter

S = input()
cnt = Counter(list(S))
ls = list(cnt.values())
if (ls[0]==2 and ls[1]==2):
    print ("Yes")
else:
    print ("No")

Solution (Python):
S = str(input())
ans = set([S[i] for i in range(0, 4)])
if (S.count(ans.pop()) == 2) and (S.count(ans.pop()) == 2):
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

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

Solution (Python):
s=input()

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

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

else:
  print("No")

Solution (Python):
import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
word = input()
w1=None
w2=None
isNG=False
for w in word:
    if w1 == None or w1 == w:
        w1=w
        
    else:
        if w2 == None or w2 == w:
            w2=w
        else:
            isNG = True
if isNG or w1 == None or w2 == None:
    print("No")
else:
    print("Yes")

Solution (Python):

word = list(input())

word_set = set(word)

if len(word_set) == 2:
    if word.count(word[0]) == 2:
        print("Yes")
else:
    print("No")

Solution (Python):
import sys

s = input()
l = list(s)
for i in range(2):
    c = s.count(l[0])
    s = s.replace(l[0], "")
    h = l[0]
    while h in l:
        l.remove(h)
    if c!=2: 
        print("No")
        sys.exit()
if s != "":
    print("No")
else:
    print("Yes")

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

Solution (Python):
S = input()

Sl = list(S)

a= Sl.count(Sl[0])
b= Sl.count(Sl[1])
c= Sl.count(Sl[2])

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

Solution (Python):
s = input()
sum = 0
count = [0] * 4
for i in range(4):
    for j in range(i + 1,4):
        if s[i] == s[j]:
            count[i] += 1

for num in range(4):
    sum += count[num]

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

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

Solution (Python):
s = str(input())
cnt = 0
for moji in s:
    
    num = s.count(moji)
    
    if num == 2:
        cnt+=1
    else:
        break
        
if cnt == 4:
    print("Yes")
else:
    print("No")

Solution (Python):
s = list(input())
flag = True
for ch in set(s):
    if s.count(ch)!=2:
        flag =False
if len(set(s))==len(s)//2 and flag:
    print("Yes")
else:
    print("No")

Solution (Python):
str = input()

d = {}
for c in str:
    if c in d: d[c] += 1
    else: d[c] = 1

l = []
for v in d.items():
    l.append(v)

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

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

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

Solution (Python):
s = list(input())
count = 0
s_1 = s[0]
for i in range(3):
    if s_1 == s[i+1]:
        del(s[i+1])
        break

tmp = s_1
del(s[0])
if len(s) == 3:
    print('No')

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

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

for i in range(len(s)):     
    for j in range(len(s)):
        if i ==j:
            continue
        elif s[i] == s[j]:
            cnt+=1
            
if cnt == 4:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()


if len(S) == 4:
    li = list(S)
    if len(set(li)) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

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

Solution (Python):
S = input()
s0, s1 = 1, 0
second = ""
for i in range(1, 4):
  if S[i] == S[0]: s0 += 1
for i in range(1, 4):
  if S[i] != S[0]: 
    second = S[i]
    break
for i in range(1, 4):
  if S[i] == second: s1 += 1
if s0 == 2 and s1 == 2: print("Yes")
else: print("No")

Solution (Python):
S = list(input())
A = S[0]
while A in S :
    S.remove(A)
if len(S) == 2 :
    if S[0] == S[1] :
        print("Yes")
    else :
        print("No")
else :
    print("No")

Solution (Python):
S = input()
a = S[0]
b = S[1]
c = S[2]
d = S[3]
l = []
l.append(a)
l.append(b)
l.append(c)
l.append(d)
k = list(set(l))
if len(k) == 2:
  if l.count(a) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
n = input()

cnt = 0

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

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

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

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

s=list(set(s))

ans1=0
if (a==3) or (b==3) or (c==3) or (d==3):
    
    ans1=-1
if len(s)==2:
    
    ans1=+1
else:
    ans1=-1
    

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

Solution (Python):
S = list(input())
hantei = 1
kaisu = 0

for i in range(0,4):
    for j in range(0,4):
        if S[i] == S[j]:
            kaisu += 1
    if kaisu != 2:
        hantei = 0
        
    kaisu = 0

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

Solution (Python):
import collections

inputstr = input()
input = sorted(inputstr)
a = collections.Counter(input)
if len(a) == 2 and a.most_common()[0][1] == 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] == s[2] == s[3]:
		print("No")
	else:
		print("Yes")
else:
	print("No")

Solution (Python):
s = input()
if len(set(s)) == 2:
  a,b = set(s)
  if s.count(a) == 2 and s.count(b) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
from collections import Counter
from functools import reduce

S = input()
SC = Counter(S)

if len(SC.items()) == 2 and reduce(lambda x, y: x and y, [v == 2 for v in SC.values()], True):
    print('Yes')
else:
    print('No')

Solution (Python):

S = input()
A = {}
A[S[0]] = True
A[S[1]] = True
A[S[2]] = True
A[S[3]] = True
if len(A) == 2 and S.count(S[0]) == 2:
	print("Yes")
else:
	print("No")

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

if len(sd) != 2:
    print('No')
elif sd[s[0]] == sd[s[1]] == sd[s[2]] == sd[s[3]] == 2:
    print('Yes')

Solution (Python):



s = input()
c = []
dict = {}
for i in s:
    if i in dict:
        dict[i] +=1
    else:
        dict[i] = 1
        c.append(i)

if dict[c[0]] == 4:
    print("No")
elif dict[c[0]] == dict[c[1]] == 2 and len(dict) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
l =[S[0]]
for i in S:
  if i not in l:
    l.append(i)
if len(l)==2:
  count1=0
  for i in range(4):
    for j in range (4):
      if S[i]==S[j]:
        count1+=1
  if count1 ==8:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

Solution (Python):
import collections
x=input()
y=[x[0],x[1],x[2],x[3]]
c = collections.Counter(y)
ans="Yes"
if(len(c))>2:
    ans="No"
if(ans=="Yes"):

    a=x.count(x[0])
    if(a>2):
        ans="No"



print(ans)

Solution (Python):
t = list(input())
T = set(t)
flg = 0

for i in T:
    if not t.count(i) == 2:
        flg = 1

if len(list(T)) == 2 and flg == 0:
    print('Yes')
else:
    print('No')

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

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

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

Solution (Python):
S = input()

c=[0,0,0,0]
h=[]
h.append(S[0])
c[0]+=1

for i in range(1,len(S)):
	cnt=0
	for k in range(len(h)):
		if h[k] ==S[i]:
			c[k]+=1
		elif h[k]!=S[i]:
			cnt+=1
	if cnt == len(h):
		h.append(S[i])
		c[len(h)-1]+=1
if 2==c[0] and 2==c[1]:
	print("Yes")
else:
	print("No")

Solution (Python):
A,B,C,D = input()
S = (A+B+C+D)
S1 = []
if A == B == C== D:
    print('No')
    exit()
for i in S:
    if i.strip(A) !='':
        S1.append(i.strip(A))
if len(S1) == 2:
        if S1[0] == S1[1]:
            print("Yes")
        else:
            print("No")
else :
    print("No")

Solution (Python):
ns = input()

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

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

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

Solution (Python):
a = input()
c = 0
tmp = a[0]
for i in range(len(a)):
  if tmp == a[i]:
    c += 1
    
if a[0] == a[1] or a[0] == a[2] or a[0] == a[3]:
  if a[1] == a[2] or a[1] == a[3] or a[2] == a[3]:
    if c == 2:
      print("Yes")
    else:print("No")
  else:print("No")
else:print("No")

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

Solution (Python):
s = input()
c1 = s[0]
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()
output = 'No'

if S[0] == S[1]:
  if S[2] == S[3] and S[2] != S[0]:
    output = 'Yes'

if S[0] == S[2]:
  if S[1] == S[3] and S[1] != S[0]:
    output = 'Yes'

if S[0] == S[3]:
  if S[1] == S[2] and S[1] != S[0]:
    output = 'Yes'

print(output)

Solution (Python):
char=input()

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

Solution (Python):
import sys

str = str(input())
list = []
for c in str:
  list.append(c)
list.sort()

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

Solution (Python):



from sys import stdin

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

flg = 0

type_str = ""

for i in range(4):
    for j in range(i+1,4):
        if N[i] == N[j]:
            type_str = N[i]
            del N[j]
            del N[i]
            flg = 1
            break

    if flg == 1:
        break

if flg == 1 and N[0] == N[1] and type_str != N[0]:
    print("Yes")
else:
    print("No")

Solution (Python):
str = input()

chars = {}
for char in str:
    if char in chars:
        chars[char] += 1
    else:
        chars[char] = 1
        
if len(chars) == 2 and chars[str[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()
for i in S:
    cnt=0
    for j in S:
        if j==i:
            cnt += 1
    if cnt!=2:
        print("No")
        break
if cnt==2:
    print("Yes")

Solution (Python):
S = input()
ls = []
for i in S:
    ls.append(i)
a = set(ls)
if len(a) != 2:
    print("No")
elif ls[0] == ls[1] == ls[2] or ls[1] == ls[2] == ls[3]:
    print("No")
else:
    print("Yes")

Solution (Python):
a = input()
b = list(a)
b.sort()
Judge = True
if b[0] != b[1]:
    Judge = False
if b[1] == b[2]:
    Judge = False
if b[2] != b[3]:
    Judge = False
if Judge == True:
    print('Yes')
else:
    print('No')

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

Solution (Python):
S = input()
Slen = len(S)
cnt=[0,0,0]
flg = True
for i in range(Slen-1):
  
  for j in range(Slen):
    if S[i]==S[j]:
      cnt[i] += 1
  
  if cnt[i] < 2 or cnt[i] > 2:
    flg = False
    break

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

Solution (Python):
S=input()

if len(S)!=4:
  print('No')
else:  
  Sorted_S = sorted(S)
  
  L1=Sorted_S[0]
  L2=Sorted_S[1]
  L3=Sorted_S[2]
  L4=Sorted_S[3]

  if (L1==L2) and (L3==L4) and (L2!=L3):
    print("Yes")
  else:
    print("No")

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

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

Solution (Python):
input_data= input()
dic={}
yes_flag= 0

for moji in input_data:
  try:
    dic[moji] = dic[moji] + 1
  except KeyError:
    dic[moji] = 1


for keys in dic:
  if dic[keys] == 2:
    yes_flag = yes_flag +1

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

Solution (Python):
a=map(str, input())
char=list(a)
b=set(char)
c=len(b)
if c==2:
	print("Yes")
else:
  print("No")

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

if len(s)==2:
    print("Yes")

else:
    print("No")

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

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

Solution (Python):
s = input()

check = True
 
if len(set(list(s))) == len(s):
  print('No')
else:
    for c in list(set(list(s))):
        if list(s).count(c) != 2:
            if check:
                print('No')
                check = False
    if check:
        print('Yes')

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

Solution (Python):

S = str(input())
s_list = []
s_set = set()
for s in S:
    s_set.add(s)
    if s in s_list:
        s_list.remove(s)
    else:
        s_list.append(s)
        
if len(s_list) == 0 and len(s_set) == 2:
    print("Yes")
else:
    print("No")

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

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

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

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

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

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):
import os, sys, re, math

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):
def main():
    a= input()

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


if __name__ == "__main__":
    main()

Solution (Python):
S=input()
count=0
first=False
OK=False
memo=S[0]
for i in range(4):    
    if S[i]==S[0]:
        count+=1
    elif (S[i]!=S[0] and first==False):
        memo=S[i]
        first=True
    elif (S[i]!=S[0] and first==True):
        if S[i]==memo:
            OK=True


if (count==2 and OK==True):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
s = input()
s = s.replace(s[0],'')
if len(s) == 0:
    print('No')
    sys.exit()
else:
    s = s.replace(s[0],'')
if len(s) == 0:
    print('Yes')
else:
    print('No')

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

Solution (Python):
S = input()  

count=0

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

if count == 8:
    print('Yes')

else:
    print('No')

Solution (Python):
S = input()
S = str(S)
for i in range(len(S)):
  s = S[i]
  count = S.count(s)
  if count != 2:
    print("No")
    break
  if count == 2:
    if i == (len(S) - 1):
      print("Yes")

Solution (Python):
import collections

def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

S=input()
c = collections.Counter(list(S))
pred = len(c.keys())==2 and all([x==2 for x in list(c.values())])
print('Yes' if pred else '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):
l=[0 for i in range(300)]
s=input()
for c in s:
    l[ord(c)]+=1
l.sort(reverse=True)
if l[0]==2 and l[1]==2:
    print("Yes")
else:
    print("No")

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

if a==b and c==d and a==d:
  print('No')

elif a==b and c==d:
  print('Yes')
  
elif a==c and b==d:
  print('Yes')
  
elif a==d and b==c:
  print('Yes')

else:
  print('No')

Solution (Python):

st =input()
chars = []
for sss in st:
    chars.append(sss)
chars.sort()
if chars[0] == chars[1] and chars[2] == chars[3] and chars[2] != chars[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):
s = input()
flg = 0
for c in s:
  if s.count(c) != 2:
    flg = 1
if flg == 0:
  print("Yes")
else:
  print("No")

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

Solution (Python):
S = input()

d = {}
for s in S:
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1

flag = 1
for v in d.values():
    if v != 2:
        flag = 0

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

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

if s.count(s[0]) == 4:
    print("No")
else:
    for i in s[1:]:
        if s[0] == i:
            s.remove(i)
            s.remove(i)
            break

    if len(s) == 4:
        print("No")

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

Solution (Python):
s = str(input())
adic = {}

for i in range(4):
  if not s[i] in adic:
    adic[s[i]] = 1
  else:
    adic[s[i]] += 1
    
abool = True
if len(adic) == 2:
  for item in adic:
    if adic.get(item) != 2:
      abool = False
else:
  abool = False
  
if abool:
  print('Yes')
else:
  print('No')

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

if s[0] == s[1]:
    if s[2] == s[3]:
        count = 1
elif s[0] == s[2]:
    if s[1] == s[3]:
        count = 1
elif s[0] == s[3]:
    if s[1] == s[2]:
        count = 1

if s[0] == s[1] == s[2] == s[3]:
    count = 0

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

Solution (Python):
import collections
s = input()
s = list(s)
s.sort()
count = 0
ans = collections.Counter(s)
ans = len(ans)
if ans == 2:
    print("Yes")
else:
    print("No")

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

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):
in_str = input()
ok = 0
if in_str[0] == in_str[1]:
  if in_str[2] == in_str[3]:
    ok += 1
if in_str[0] == in_str[2]:
  if in_str[1] == in_str[3]:
    ok += 1
if in_str[0] == in_str[3]:
  if in_str[1] == in_str[2]:
    ok+= 1
if(ok == 1):
  print("Yes")
else :
  print("No")

Solution (Python):
import collections

x = input()
TF =  x.isupper() and x.isalpha()
flg  = 0
if(TF):
    li = [i for i in x]
    count_dict = collections.Counter(li)
    list = [v for k, v in count_dict.items()]
    if(list == [2,2]):
        print("Yes")
        flg = 1
if(flg == 0):
    print("No")

Solution (Python):
str = input().strip()
alp = [chr(i) for i in range(65, 65+26)]
ans = {}
for S in str:
    for A in range(26):
        if S == alp[A]:
            if alp[A] in ans.keys():
                ans[alp[A]] += 1
            else:
                ans[alp[A]] = 1
if len(ans) == 2 and max(ans.values()) == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
from sys import stdin
from collections import Counter

S = stdin.readline().rstrip()
cnt = Counter(S)

if len(cnt.keys()) == 2 and set(cnt.values()) == {2}:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()
if S[0]==S[1]==S[2]==S[3]:
	print("No")
else:
	if 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):
text = input()

text1 = text.replace(text[0], "")
try:
	text2 = text1.replace(text1[0], "")
except:
	text2 = "e"

if len(text) == 4 and len(text1) == 2 and len(text2) == 0:
  print("Yes")
else:
  print("No")

Solution (Python):
S=input()

if S[1]==S[0]:
    if S[2] == S[3]:
        ans = 1
    else:
        ans = 0

elif S[0] == S[2]:
    if S[1] == S[3]:
        ans = 1
    else:
        ans = 0

elif S[0] == S[3]:
    if S[1] == S[2]:
        ans = 1
    else:
        ans = 0

else:
    ans = 0

if S[0]==S[1] == S[2]:
    ans = 0

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

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

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

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

else:
    print("No")

Solution (Python):
s=input()

x=len(set(s))

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

Solution (Python):
a = list(input())
before = -1
count =0
for char in a:
    current = char
    if before == current:
        count = count+1
    else:
        before = current

if count<=2:
    s = set()
    for item in a:
        s.add(item)
    if len(s) == 2:
        print("Yes")
        exit()

print("No")

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

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

Solution (Python):
S = input()

D = 0
temp = 0
for i in S:
    if S.count(i) != 2:
      print("No")
      D = 1
      break
      
if D == 0:
  print("Yes")

Solution (Python):
def count_cap(S):
    renso={"A":0,"B":0,"C":0,"D":0,"E":0,"F":0,"G":0,"H":0,"I":0,"J":0,"K":0,"L":0,"M":0,"N":0,
          "O":0,"P":0,"Q":0,"R":0,"S":0,"T":0,"U":0,"V":0,"W":0,"X":0,"Y":0,"Z":0}
    count = 0
    for a in S:
        if renso[a] == 1:
            count = count + 1
        renso[a] = renso[a]+1
    
    if count == 2:
        return "Yes"
    else:
        return "No"

print(count_cap(input()))

Solution (Python):
import collections

S = input()
split_str = list(S)
coll = collections.Counter(split_str)





if len(coll) == 2 & coll.most_common()[0][1] == 2 & coll.most_common()[1][1] == 2:
    print('Yes')
else:
    print('No')

Solution (Python):



n = input()
a1 = n[0]
a2 = n[0]
count1 = 1
count2 = 0
for nc in range(1,4):
    if(n[nc] == a1):
        count1 += 1
    elif(a1 == a2):
        a2 = n[nc]
        count2 += 1
    elif(n[nc] == a2):
        count2 += 1
    else:
        count1 = 5
if(count1 == count2):
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
s = input()

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

print(result)

Solution (Python):

def logic():
    text = input()
    i = 0
    check = False
    while i < 3:
        count = text.count(text[i])
        if count != 2:
            print("No")
            return True
        elif count == 2:
            check = True
            text.replace(text[i],"")
        else:
            print("No")
            return True
        i += 1
    if check:
        print("Yes")

if __name__ == '__main__':
    logic()