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

Solution (Python):
import fractions
from collections import deque
import numbers as np


def main():
    S = input()
    s1 = S[0]
    S = S[1:]
    s2 = ''
    s1_cnt = 1
    s2_cnt = 0
    for i in range(len(S)):
        if s1 != S[i]:
            if s2 == S[i]:
                s2_cnt += 1
            else:
                s2 = S[i]
                s2_cnt = 1

        else:
            s1_cnt += 1
    print('Yes' if s1_cnt == 2 and s2_cnt == 2 else 'No')


if __name__ == "__main__":
    main()

Solution (Python):
import collections

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

flag = 0
for i in range(4):
	word = s[i]
	if c[word] != 2:
		flag = 1
		break
	
if flag == 1:
	print("No")
else :
	print("Yes")

Solution (Python):
S = input()
sList = list(S)
sList.sort()
c1 = sList.count(sList[0])
c2 = sList.count(sList[2])
print(["No", "Yes"][c1 == 2 and c2 == 2])

Solution (Python):
import sys

S = list(input())

set_s = list(set(S))
if len(set_s) != 2:
    print("No")
    sys.exit()

if S.count(set_s[0]) != 2:
    print("No")
    sys.exit()

print("Yes")

Solution (Python):
S = raw_input()

count_map = {}

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

answer = True

if len(count_map) == 2:
    for key in count_map.keys():
        if count_map[key] != 2:
            answer = False
            break
else:
    answer = False

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

Solution (Python):
from collections import defaultdict

S = input()

d = defaultdict(int)

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

for r in d.values():
    if r != 2:
        print("No")
        exit()
print("Yes")

Solution (Python):
S = input()


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

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


l = []

for i in range(4):
  if not s[i] in l:
    l.append(s[i])


if len(l) != 2:
  print("No")
else:
  if s.count(l[0]) == 2:
    print("Yes")
  else:
    print("No")

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

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

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

if s.count(s[0])==2:
    s_rm = [i for i in s if i != s[0]]
    if s_rm[0] == s_rm[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
s = input()
a = s[0]
s = s.replace(a, "")
if not len(s) == 2:
    print("No")
else:
    if s[0] == s[1]:
        print("Yes")
    else:
        print("No")

Solution (Python):
S = input()
X=S[0]
i=1
while i<=3:
    if S[i]!=X:
        Y=S[i]
        break
    i+=1
if S.count(X)!=2 or S.count(Y)!=2:
    print("No")
else:
    print("Yes")

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

for i,j in ll:
    if j!=2:
        print("No")
        import sys
        sys.exit()
print("Yes")

Solution (Python):
S = input()
flag =False
S_set = set(list(S))

if len(S_set) == 2:
  count_1 = S.count(list(S_set)[0])
  count_2 = S.count(list(S_set)[1])
  if count_1 == 2 and count_2 == 2:
  	flag = True

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

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

cnt = 0

for i in range(3):
    if C[3] == C[i]:
        cnt += 1

if cnt == 1 and len(set(C)) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()

s1_sum = 0
s1 = None
s2_sum = 0
s2 = None

for i in s:
    if s1==i:
        s1_sum+=1
    elif s2==i:
        s2_sum += 1
    elif s1 == None:
        s1 = i
        s1_sum=1
    elif s2 == None:
        s2 = i
        s2_sum=1
    else:
        pass
if (s1_sum==2)&(s2_sum==2):
    print("Yes")
else:
    print("No")

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

a = sorted(s)

if a[0] == a[1] and a[2] == a[3] and a[0] != a[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):
import collections
S = input()

cnt = collections.Counter(S)

ans = 'Yes'
if len(cnt) == 2:
    for value in cnt.values():
        if value != 2:
            ans = 'No'
else:
    ans = 'No'

print(ans)

Solution (Python):
S = input()
x = set()
f = 0
for s in S:
  if s in x:
    f += 1
  else:
    x.add(s)
if f == 2:
  print("Yes")
else:
  print("No")

Solution (Python):
import collections

S = input().strip()

counter = collections.Counter()
for s in S:
    counter[s] += 1

ans = "Yes"
if(len(counter) != 2):
    ans = "No"
print(ans)

Solution (Python):
S = list(input())
T = S + []

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

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

Solution (Python):
from collections import Counter

s = input()
c = Counter(s)
print('Yes' if tuple(c.values()) == (2, 2) else 'No')

Solution (Python):
import sys
s = input()
s_map = []

for a in s:
    s_map.append(a)
s_map = list(set(s_map))

for a in s_map:
    if s.count(a) != 2:
        print("No")
        sys.exit()
print("Yes")

Solution (Python):


''' 
------------------------
author : iiou16
------------------------
'''

def main():
    S = input()

    count = {}

    for s in S:
        if s not in count.keys():
            count[s] = 1
        else:
            count[s] += 1
    flag = 0
    if len(count) == 2:
        for v in count.values():
            if v != 2:
                flag = -1
                break
    else:
        flag = -1
    
    if flag == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

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().split()
 
s = str(S)
s = s[2:-2]

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

Solution (Python):
S  = input()
import collections
c = collections.Counter(S)
for i,c in enumerate(c.values()):
    if c != 2:
        print('No')
        exit(0)
    if i == 2:
        print('No')
        exit(0)
print('Yes')

Solution (Python):
s = input()

if s[0] == s[1]:
    if s[1] == s[2]:
        print('No')
    elif s[2] == s[3]:
        print('Yes')
    else:
        print('No')
else:
    if 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()
import collections
li = [i for i in S]
d = collections.Counter(li)
li_uniq = list(set(li))
ans = "No"
if len(li_uniq) == 2:
    if d[li_uniq[0]] == 2:
        if d[li_uniq[1]] == 2:
            ans = "Yes"
print(ans)

Solution (Python):
s = input()
ss = list(set([s[0], s[1], s[2], s[3]]))
flag = True
if len(ss) != 2:
    flag = False
else:
    for i in range(len(ss)):
        if s.count(ss[i]) == 2:
            continue
        else:
            flag = False
            break

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

Solution (Python):
S = raw_input()

p = []
for s in S:
      p.append(s)
p.sort()

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

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

Solution (Python):


tmp = input()

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

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

Solution (Python):
import collections
S=list(input())
c = collections.Counter(S)
cnt=0
if len(c)==2:
    for cc in c:
        if c[cc]==2:
            cnt+=1
    if cnt==2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

Solution (Python):
li = input()
li_a = []
count = 0

for i in li:
    if i in li_a:
        count += 1
    li_a.append(i)
li_a = list(set(li_a))
if len(li_a) == 2 and count == 2:
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
import sys


input_str = input()

list_str = [i for i in input_str]
set_str = set(list_str)

if len(set_str) == 2:
  for i in set_str:
    try:
      for j in range(2):
        list_str.remove(i)
    except ValueError:
      print('No')
      sys.exit()
else:
  print('No')
  sys.exit()
  
print('Yes')

Solution (Python):
S = input()
s0=S.count(S[0])
s1=S.count(S[1])
s2=S.count(S[2])
s3=S.count(S[3])
if s0 == 2 and s1 == 2 and s2 == 2 and s3 == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
s = input()

words = {}

for i in s:
  if words.get(i):
    words[i] += 1
  else:
    words[i] = 1
  
if len(words.keys()) == 2 and list(words.values())[0] == list(words.values())[1] == 2:
   print('Yes')
else:
   print('No')

Solution (Python):
S = input()
s = {S[0], S[1], S[2], S[3]}

if len(s) != 2:
    print('No')
else:
    num = 1
    for i in range(3):
        if S[i+1] == S[0]:
            num += 1
    
    if num == 2:
        print('Yes')
    else:
        print('No')

Solution (Python):
s = input()
l = list(s)
for i in range(len(l)):
    if s.count(l[i]) != 2:
        print("No")
        exit()

print("Yes")

Solution (Python):
import sys
from fractions import gcd
from collections import defaultdict
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())

def main():
    s = S()
    d = defaultdict(int)
    for i in range(4):
        d[s[i]] += 1
    if len(d) == 2:
        for v in d.values():
            if v != 2:
                break
        else:
            print("Yes")
            return
    print("No")



if __name__ == "__main__":
    main()

Solution (Python):
import sys,collections
S = input()
S_ = list(S)
S__ = collections.Counter(S_)
if len(S_) == 4:
    values,counts = zip(*S__.most_common())
    if len(values) == 2:
        print("Yes")
        sys.exit()
print("No")

Solution (Python):
S = input()
flag = False
count0 = 0
count1 = 0
count2 = 0
count3 = 0
for i in S:
    if i == S[0]:
        count0 += 1
    if i == S[1]:
        count1 += 1
    if i == S[2]:
        count2 += 1
    if i == S[3]:
        count3 += 1

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

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

a = list1[0]
b = list1[1]
c = list1[2]
d = list1[3]

if a == b:
    if c == d and a != c:
        print("Yes")
    else:
        print("No")
elif a == c:
    if b ==d and a != b:
        print("Yes")
    else:
        print("No")
elif a == d:
    if b == c and a != b:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

Solution (Python):

lis = []
s = input()
flag = 0
two = 0
for x in s:
    if x in lis:
        flag += 1
    else:
        two += 1
    lis.append(x)
if two == 2 and  flag <= 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()

ans = "No"
s = []

for _ in S:
    s.append(_)

s.sort()
if s[0] == s[1]:
    if s[2] == s[3]:
        if s[1] != s[2]:
            ans = "Yes"

print(ans)

Solution (Python):
S = input()
count = {}
for k in S:
  count[k] = 0
for y in S:
  count[y] += 1
if len(count) == 2 and count[S[0]] == 2:
  print("Yes")
else:
  print("No")

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

for k,v in c.items():
    if v == 2:
        count = count +1

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

Solution (Python):
S = list(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):
word = list(input())

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

Solution (Python):


def main():
    
    
    
    
    
    
    
    
    S = input()
    dic = {}
    for s in S:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    if len(dic)==2 and list(dic.values())==[2,2]:
        print('Yes')
    else:
        print('No')


if __name__=='__main__':
    main()

Solution (Python):
str = input()

a=str[-4]
b=str[-3]
c=str[-2]
d=str[-1]
count = 0
if(a is b):
    
    count += 1
elif(a is c):
    
    count += 1
elif(a is d):
    
    count += 1
else:
    pass
if(b is c):
  count += 1
elif(b is d):
  count += 1
else:
  pass

if(c is d):
  count += 1
else:
  pass

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

Solution (Python):

S = list(input().split()[0])

flg = False

if S[0] == S[1] and S[1] == S[2] and S[2] == S[3]:
    flg = True

S_0 = S[0]
del S[0]
for i in range(0,3):
    if S[i] == S_0:
        del S[i]
        break
S_1 = S[0]
del S[0]
if S[0] == S_1:
    del S[0]
if not flg:
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

for k,v in c.items():
    if v == 2:
        count = count +1

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

Solution (Python):

s = input()

ans = True
if len(set(s)) != 2:
    ans = False
else:
    a, b = list(set(s))
    if s.count(a) == s.count(b) == 2:
        pass
    else:
        ans = False

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

Solution (Python):

S=str(input())

cnt1=1
cnt2=0
a1=S[0]
t=0
for i in range(1,len(S)):
    if S[i]==a1:
        cnt1+=1
    elif t ==0:
        a2=S[i]
        t=1
        cnt2+=1
    elif a2==S[i]:
        cnt2+=1
    else:
        t=0
        break

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

Solution (Python):
import collections

S = input()
ans=0
for i in S:
    if(S.count(i)!=2):
        print('No')
        break
    ans+=1

if(ans==4):
    print('Yes')

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

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

Solution (Python):
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function



import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


s = input()
xs = set(s)
if (len(xs) == 2 and all(s.count(i) == 2 for i in xs)):
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
S=list(s)
a=set(S)
ans=0
if len(a)==2:
	for n in S:
		if S[0]==n:ans+=1


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

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

ans = True
if len(m) != 2:
    ans = False
else:
    for v in m.values():
        if v != 2:
            ans = False

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

Solution (Python):
S = [s for s in input()]
cnt = {}
for s in S:
    if s not in cnt:
       cnt[s] = 0
    cnt[s] += 1
if len(cnt) == 2 and cnt[s] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
dic = {}
for i in s:
    if i not in dic.keys():
        dic[i]=1
    else:
        dic[i]+=1
ans = "Yes"
if len(dic) !=2:
    ans = "No"
else:
    for i in dic:
        if dic[i] != 2:
            ans = "No"
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]) or (S[0]==S[2] and S[1]==S[3]) or (S[0]==S[3] and S[1]==S[2]):
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
s = input()
print("Yes" if all(map(lambda c: s.count(c) == 2, s)) else "No")

Solution (Python):


"""
Created on Sat Jun 29 20:53:13 2019

@author: YudNK
"""

l = [i for i in input()]

k = len(set(l))

a = l[0]
c = 0
for i in l:
    if i == a:
        c = c + 1

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

Solution (Python):
s = input()
dic = {}

for i in s:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
if len(dic.keys()) == 2:
  for i in dic.values():
    if i != 2:
      print('No')
      exit()
  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")
    exit()

print("No")

Solution (Python):
import re

inputData = input()

uniq_str_list = list(set(inputData))
if len(uniq_str_list) != 2:
    print("No")
    exit()
if len(re.findall(uniq_str_list[0], inputData)) != 2:
    print("No")
    exit()

if len(re.findall(uniq_str_list[1], inputData)) != 2:
    print("No")
    exit()

print("Yes ")

Solution (Python):
inp=input()
ans=0
for s in inp:
  if inp.count(s)==2:
    ans=ans;
  else:
    ans+=1
if ans==0:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys

cin = sys.stdin
s = cin.readline().strip()

from collections import Counter
c = Counter(s)

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

Solution (Python):
from collections import Counter
S = list(input())
kind = list(set(S))
result = "Yes"
for i in range(len(kind)):
    if S.count(kind[i]) != 2:
        result = "No"
print(result)

Solution (Python):
def main():
    S = list(input())
    chars = list(set(S))

    if len(chars) != 2:
        print('No')
        return

    def count_a_char(c):
        return len([s for s in S if s == c])

    if count_a_char(chars[0]) != 2 or count_a_char(chars[1]) != 2:
        print('No')
        return 
    
    print('Yes')
    

main()

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

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

Solution (Python):

S = input()
S_unique = list(set(S))
flg = len(S_unique)==2
if flg:
    ans1 =(S.count(S_unique[0])==2)
    ans2 =(S.count(S_unique[1])==2)
    ans3 = ans1 and ans2
    if ans3:
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

Solution (Python):


str_in = input()
str_set = set(str_in)

if len(str_in) != 4:
    print('No')
    quit()

if len(str_set) != 2:
    print('No')
    quit()

for s in str_set:
    if str_in.count(s) != 2:
        print('No')
        quit()

print('Yes')

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

s = list(set(S))
if len(s)!= 2:
    print('No')
    exit()

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

Solution (Python):
S = input()

abet = {}
for c in S:
    if c not in abet:
        abet[c] = 1
    else:
        abet[c] += 1


if len(abet.values()) == 2:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
import collections

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

Solution (Python):
s = input()

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

for num in d.values():
    if not num == 2:
        print('No')
        break
else:
    print('Yes')

Solution (Python):

S = input()
A = []
for i in range(len(S)):
    A.append(S[i])
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 A.count(S[0]) == 4:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Solution (Python):

import collections
a = list(input())
c = collections.Counter(a)

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

Solution (Python):
s = input()

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

Solution (Python):
flg = False
s = input()
s1, s2, s3, s4 = s[:1], s[1:2], s[2:3], s[3:4]
if s1 == s2 and s3 == s4:
	flg = True
elif s1 == s3 and s2 == s4:
	flg = True
elif s1 == s4 and s2 == s3:
	flg = True

if s1==s2 and s1==s3:
	flg = False

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

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

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

print('Yes')

Solution (Python):
n = list(input())
flag = 0
dict = {}
for i in n:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1
 
for key,val in dict.items():
    if val != 2:
        flag = 1
 
if flag:
    print("No")
else:
    print("Yes")

Solution (Python):
S = input()

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

Solution (Python):


import sys
import collections

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    c = collections.Counter(S)
    if tuple(c.values()) == (2, 2):
        print('Yes')
    else:
        print('No')
    return

main()

Solution (Python):
S = input()
a = S[0]
b = 0
acount = 1
bcount  = 1
for i in range(1,4):
    if a == S[i]:
        acount += 1
    elif b == S[i]:
        bcount += 1
    else:
        if b == 0:
            b = S[i]

if acount == 2 and bcount == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):

from collections import Counter

S = input()
s = list(S)

count = Counter(S)

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

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

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

if len(C)==2:
    counter = {c:0 for c in C}
    for s in S:
        counter[s]+=1
    if counter[C[0]]==2 and counter[C[1]]==2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

Solution (Python):
import sys

def input():
    return sys.stdin.readline().rstrip()

if __name__ == "__main__":
    s = input()

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

    if len(dict.keys()) == 2:
        is_ok = True
        for v in dict.values():
            if v != 2:
                is_ok = False
                break
        print("Yes" if is_ok else "No")
    else:
        print("No")

Solution (Python):
x = input()

a = 1
b = 1
other = '0'

for i in range(1,4):
  if x[0] == x[i]:
    a += 1
  else:
    if other == x[i]:
      b += 1
    else:
      other = x[i]
      
if a == b == 2:
  print("Yes")
else:
  print("No")

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

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

Solution (Python):
S  = list(input())
dic = {}
for s in S:
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
for v in dic.values():
  if v != 2:
    print('No')
    quit()
print('Yes')

Solution (Python):
import collections
s= str(input())
l=list(s)
c=collections.Counter(l)
l_c=c.most_common()
if len(l_c)==1:
  print("No")
  exit()
if l_c[0][1]==l_c[1][1]==2:print("Yes")
else:print("No")

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

A = S[0] == S[1]
B = S[2] == S[3]
C = S[0]!=S[2]

if A*B*C == True:
  print('Yes')
else:
  print('No')

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

Solution (Python):
S = input()

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

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):
import sys
S = input()
S1 = S[0]
S2 = S[1]
S3 = S[2]
S4 = S[3]
S = [S1, S2, S3, S4]
kind = set([S1, S2, S3, S4])

if len(kind) == 2:
    for k in kind:
        if S.count(k) != 2:
            print("No")
            sys.exit()
    else:
        print("Yes")
        sys.exit()
else:
    print("No")

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

A = [0] * 4

s = input()
for i in range(4):
    A[i] = s[i]

A_uni = list(set(A))

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