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

s_list = list(S)
s_list = sorted(s_list)


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

Solution (Python):
def main():
  s = input().strip()
  ss = set(s)
  if len(ss) == 2:
    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')
  else:
    print('No')


if __name__ == '__main__':
  main()

Solution (Python):
S = input()
a = S[0]
b = S[1]
c = S[2]
d = S[3]
not_a = []
for st in S[1:]:
    if st != a:
        not_a.append(st)
if len(not_a) != 2:
    print("No")
    exit()
if not_a[0] == not_a[1]:
    print("Yes")
    exit()
print("No")

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

count = Counter(S)

if list(count.values()) == [2, 2]:
    print('Yes')
else:
    print('No')

Solution (Python):
def resolve():
    S = input()
    kinds = set(S)
    for i in kinds:
        if S.count(i) != 2:
            print("No")
            return
    print("Yes")


if '__main__' == __name__:
    resolve()

Solution (Python):
S = input()
s = list(S[i] for i in range(4))
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()
s1 = s[0]
s2 = ""
c1 = 1
c2 = 1


for i in range(1, 4):
    if s[i] == s1:
        c1 += 1
    elif s[i] == s2:
        c2 += 1
    elif s2 == "":
        s2 = s[i]

if c1 == 2 and c2 == 2:
    ans = "Yes"
else:
    ans = "No"


print(ans)

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

Solution (Python):
S = input()

if len(list(set(list(S)))) == 2 and len([i for i in list(list(S)) if i == S[0]]) == 2:
	print('Yes')
else:
	print('No')

Solution (Python):
s = list(input())
c = 0
if len(set(s))==2:
    for i in set(s):
        if s.count(i) == 2:
            c = 1
            break
if c == 0:
    print('No')
else:
    print('Yes')

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):
ans  = "Yes"
s = input()
for c in s:
    if s.count(c)!=2:
        ans = "No"

print(ans)

Solution (Python):
s = input()
d = dict()
for c in s:
  if d.__contains__(c):
    d[c] += 1
  else:
    d[c] = 1
l = list(d.items())
if len(l)!=2:
  print("No")
  exit(0)
if l[0][1] == 2 and l[1][1] == 2:
  print("Yes")
  exit(0)
else:
  print("No")

Solution (Python):
S = input()

from collections import Counter

s = Counter(S)

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

Solution (Python):
import collections
data=collections.Counter(input())
data=[[i,data[i]] for i in data]
if len(data)==2 and data[0][1]==data[1][1]==2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

count = {}
for i in range(4):
    if S[i] in count:
        count[S[i]] += 1
    else:
        count[S[i]] = 1

if len(count) == 2 and count[S[0]] == 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 = 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):

from collections import defaultdict

s = input()
d = defaultdict(int)

for c in s:
    d[c] += 1
    if d[c] == 3:
        print("No")
        exit()
if len(d) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()

l=set()
for i in range(4):
    l.add(s[i])

ans='No'
if len(l)==2:
    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]):
        ans='Yes'

print(ans)

Solution (Python):
s = input()

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

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

Solution (Python):
n=input()
a=[0]*4
for i in range(4):
    for p in range(4):
        if n[i]==n[p]:
            a[i]+=1
if a==[2,2,2,2]:
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
s = input()

adic = {}
for c in s:
  if c in adic.keys():
    adic[c] += 1
  else:
    adic[c] = 1
if list(adic.values()) == [2, 2]:
  print('Yes')
else:
  print('No')

Solution (Python):
s = input()
a = [0 for _ in range(26)]
for x in s:
    a[ord(x)-ord('A')] += 1
print('Yes' if a.count(2) == 2 else 'No')

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

Solution (Python):
s=list(input())
i=0
ans=1
while i!=4:
    a=s.count(s[i])
    if a!=2:
        ans=0
    i+=1
if ans==1:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

S = list(input())

s = Counter(S).most_common()

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

Solution (Python):
s = input()

syu = set(s)
tmp = list(syu)

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

Solution (Python):
s=input()
dict={}
for i in range(4):
    if not s[i] in dict:
        dict[s[i]]=0
    dict[s[i]]+=1

a=list(dict.keys())
for i in range(len(a)):
    if dict[a[i]]!=2:
        print("No")
        quit()
print("Yes")

Solution (Python):
s = input()
dictionary = {}
pattern = 0
for c in s:
    if(c in dictionary):
        dictionary[c] += 1
    else:
        dictionary[c] = 1
        pattern += 1
    if(dictionary[c] > 2):
        print("No")
        exit()
    if(pattern > 2):
        print("No")
        exit()
print("Yes")

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

readline = sys.stdin.readline

S = readline().rstrip()

c = Counter(S)
a = list(c.items())

if len(a) == 2 and a[0][1] == 2 and a[1][1] == 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()
d={}
for c in S:
    if c not in d.keys():
        d[c]=1
    else:
        d[c] += 1
j=True
for i in d.values():
    if i!=2:
        j=False
        break

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

Solution (Python):
import math

def main():
  s = input()
  
  s = s.replace(s[0], "")
  if len(s) != 2:
    print("No")
    return
  
  s = s.replace(s[0], "")
  
  if len(s ) != 0 :
    print("No")
    return
  
  print("Yes")
  
main()

Solution (Python):
def main():
    S = input()
    for s in S:
        if S.count(s) != 2:
            print('No')
            return
    print('Yes')


main()

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

Solution (Python):
s = input()
l = []
l.append(s[0])
l.append(s[1])
l.append(s[2])
l.append(s[3])
p = set(l)
if len(p)==2:
  print("Yes")
else:
  print("No")

Solution (Python):
S = input()
b = set(S)
if len(b)==2:
  for s in S:
    if S.count(s)==2:
      print('Yes')
      break
  else:
    print('No')
else:
  print('No')

Solution (Python):
S=list(input())
a={}
for i in range(4):
    a[S[i]]=a.get(S[i],0)+1
print('Yes' if len(list(a.keys()))==2 and len(list(a.values()))==2 else 'No')

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

Solution (Python):
import sys

fin = sys.stdin.readline

s = fin()[:4]
for ss in s:
    if s.count(ss) != 2:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
s = input()
t = set(s)
if len(t) == 2:
    f = True
    for c in t:
        if list(s).count(c) != 2:
            f = False
    print("Yes" if f else "No")
else:
    print("No")

Solution (Python):
S = input()

tmp = []
for s in S:
    if s not in tmp:
        tmp.append(s)

if len(tmp) == 2:
    if S.count(tmp[0]) == 2:
        print('Yes')
        exit()
print('No')

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

Solution (Python):
from collections import defaultdict
import math


def main():
    a = list(input())
    b = defaultdict(int)

    for ele in a:
        b[ele] += 1

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






if __name__ == '__main__':
    main()

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

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

Solution (Python):
from collections import defaultdict

if __name__ == '__main__':
    s = input()
    count = defaultdict(int)
    for c in s:
        count[c] += 1

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

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

Solution (Python):
S = str(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()
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 numpy as np
import copy


def main():
    S = input()
    if len(set(S)) == 2 and S.count(S[0]) == 2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
s = list(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()
m = dict()
for c in s:
    m.setdefault(c, 0)
    m[c] += 1
print('Yes' if len(m) == 2 and all(v == 2 for v in m.values()) else 'No')

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

dic = {}

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

ok = True
for k in dic:
    if dic[k] == 2:
        pass
    else:
        ok = False

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

Solution (Python):
s = input()
a = s[0]
for i in s:
    if i != a:
        b = i
if s.count(a) == len(s)/2 and s.count(b) == len(s)/2 :
    print("Yes")
else :
    print("No")

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

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

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

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

f=0
for i in range(4):
    if s.count(s[i]) != 2:
        f =1

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

Solution (Python):
S = input()

s_hash = {}
for i in range(len(S)):
    if S[i] in s_hash:
        s_hash[S[i]] += 1
    else:
        s_hash[S[i]] = 1


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

Solution (Python):
s = input()

hoge = {}
for i in range(len(s)):
    if s[i] in hoge:
        hoge[s[i]] += 1
    else:
        hoge[s[i]] = 1

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

Solution (Python):
from collections import Counter

S = Counter(input())

ans = 1
for s in S:
    if S[s]!=2:
        ans = 0
        break
        
if ans==1:
    print("Yes")
else:
    print("No")

Solution (Python):

S = list(str(input()))
word = ["",""]
count = [0,0]
flag = 0
for i in range(4):
    if i == 0:
        word[0] = S[0]
        count[0]+=1
    else:
        if S[i] in word:
            count[word.index(S[i])]+=1
        else:
            if word[1] == "":
                word[1] = S[i]
                count[1]+=1
            else:
                flag = 1
                break
                
if count[0] == 2 and count[1] == 2:
    pass
else:
    flag = 1
    
if flag == 0:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

d = dict()
for s in S:
    if s not in d:
        d[s] = 0
    d[s] += 1

print(["No", "Yes"][tuple(d.values()) == (2, 2)])

Solution (Python):
import collections
S = input()
c = collections.Counter(S)
if len(c) == 2 and c.most_common()[0][1] == 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 :
    print('Yes')
else :
    print("No")

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

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

Solution (Python):
s = input()


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

    else:
        print('No')

else:
    print('No')

Solution (Python):
S = list(input())
ans = {}
for i in range(4):
    if S[i] not in ans.keys():
        ans[S[i]] = 1
    else :
        ans[S[i]] += 1
for i in ans.keys():
    if ans[i] == 2 :
        pass
    else :
        print("No")
        exit()

print("Yes")

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

Solution (Python):
def main():
     a=list(input())
     if a.count(a[0])==2 and a.count(a[1])==2 and a.count(a[3])==2:
          print("Yes")
     else:
          print("No")
     
if __name__=='__main__':
     main()

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

for i in s:
    k.add(i)

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

Solution (Python):
from collections import defaultdict
S = input()
D = defaultdict(int)
for s in S:
    D[s] += 1

def main(D):
    if len(D.keys()) != 2:
        return 0
    else:
        for v in D.values():
            if v != 2:
                return 0
    return 1

if main(D):
    print("Yes")
else:
    print("No")

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

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

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

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

Solution (Python):
import sys
from collections import defaultdict

fin = sys.stdin.readline
num = str(fin()).split()[0]

char_list = defaultdict(int)
for each_char in num:
    char_list[each_char] += 1

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

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

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

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict

s = ns()
dic = defaultdict(int)
for si in s:
    dic[si] += 1

ok = True
for _, v in dic.items():
    if v != 2:
        ok = False
        break

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

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

Solution (Python):


def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  S = input()
  d = {}
  for c in S:
    if not c in d:
      d[c] = 0
    d[c] += 1
  if len(d.keys()) == 2 and d[list(d.keys())[0]] == 2:
    print("Yes")
  else:
    print("No")

if __name__ == "__main__":
  main()

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

Solution (Python):
from collections import Counter

def main():
    s = input()

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

def solve(s):
    cnt = Counter(s)
    for k, v in cnt.items():
        if v != 2:
            return False
    return True

main()

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):
a = list(input())
l_unique = list(set(a))

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

Solution (Python):
S = input()

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

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

if __name__=="__main__": main()

Solution (Python):
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
d = collections.defaultdict(int)
for e in s:
    d[e] += 1
items = d.items()
if len(d) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
D = {}
s = set()
for i in S:
    s.add(i)
    if i not in D:
        D[i] = 1
    else:
        D[i] += 1

s = list(s)
if len(D) == 2 and D[s[0]] == 2 and D[s[1]] == 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[1]!=S[2]:
    print('Yes')
else:
    print('No')

Solution (Python):
a = input()
b = sorted(a)

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

Solution (Python):
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op



inf = float('inf')
input = stdin.readline


def main():
    s = get_str()
    c = Counter(s)
    if len(c.keys()) == 2 and list(c.values())[0] == 2:
        print("Yes")
    else:
        print("No")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Solution (Python):
def solve():
  S = input()
  s = list(set(S))
  if len(s) != 2: return 'No'
  return 'Yes' if S.count(s[0]) == 2 and S.count(s[1]) == 2 else 'No'

print(solve())

Solution (Python):
s = input()
if len(set(s)) == 2 and all(sum(1 for c in s if c == k) == 2 for k in s):
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
S = input()
a = {}

for i in range(4):
    if S[i] in a.keys():
        a[S[i]] += 1
    else:
        a[S[i]] = 1
    

check = 0
for i in a.values():
    if i==2:
        check += 1

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

Solution (Python):
S = list(input())
flg = True
for c in S:
    if S.count(c) != 2:
        flg = False

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

Solution (Python):
import sys
from collections import deque  
from collections import defaultdict  
from heapq import heapify, heappush, heappop, heappushpop  
from bisect import bisect_left, bisect_right  



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

def main():
    S = i2s()
    d = defaultdict(lambda: 0)
    for s in S:
        d[s] += 1
    for k, v in d.items():
        if v != 2:
            print('No')
            return
    print('Yes')

main()

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

Solution (Python):



s = input()

a = dict()

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

for i,v in a.items():
    if v != 2:
        print("No")
        exit()
else:
    print("Yes")

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

Solution (Python):


import sys
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
import collections




S = input()

c = collections.Counter(S)

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

Solution (Python):
S = input()

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

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

Solution (Python):
S = input()

sdict = {}
for s in S:
    sdict.setdefault(s,0)
    sdict[s] += 1

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

print("Yes")

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

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(S: str):
    s = sorted(S)
    if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
        return YES
    else:
        return NO



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    print(solve(S))

if __name__ == '__main__':
    main()

Solution (Python):
N = input()
flag = True
for i in range(4):
    if not N.count(N[i])==2:
        flag = False
        break
if flag:
    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):
def find(s):
    dic={}
    for i in range(len(s)):
        if s[i] in dic:
            dic[s[i]]+=1
        else:
            dic[s[i]]=1
    if len(dic)==2:
        for x in dic:
            if dic[x]!=2:
                return False
        return True
    else:
        return False
s=input()
if find(s):
    print("Yes")
else:
    print("No")

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

S=list(input().strip())

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

Solution (Python):
s = input()
c_set = set([c for c in s])

counts = [s.count(c) for c in c_set]
if max(counts) == 2 and min(counts) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):

from collections import Counter
s = Counter(list(input()))
print(['No','Yes'][all(x == 2 for x in s.values())])

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

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

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

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

Solution (Python):
S = input()
setS = set(S)
flag = True
if len(setS) != 2: flag = False
for s in setS:
  if S.count(s) != 2: flag = False

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

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

Solution (Python):

S = input()

dic = {}


for i in S:

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

bul = True

for i in dic:

    if len(dic)!=2 or dic[i] != 2:
        bul = False

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

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

Solution (Python):
from collections import Counter

S = input()
c = Counter(S).items()

if len(c) == 2 and all(i[1] == 2 for i in c):
    print('Yes')
else:
    print('No')

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

Solution (Python):

import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    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')


if __name__ == '__main__':
    main()

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


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

Solution (Python):
import sys
sys.setrecursionlimit(4100000)
from collections import defaultdict
n = str(input())
seen = defaultdict(int)
for letter in n:
    seen[letter] += 1
res = 0
for key in seen.keys():
    if seen[key] != 2:
        res += 1
if res != 0:
    print("No")
else:
    print("Yes")

Solution (Python):
s = input()

t = set(s)

ok = True

for c in t:
	if s.count(c) != 2:
		ok = False

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

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

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

Solution (Python):
s = input()
memo = {}
for i in range(len(s)):
    if s[i] not in memo:
        memo[s[i]] = 1
    else:
        memo[s[i]] += 1
for i in memo:
    if memo[i] != 2:
        print("No")
        exit()
print("Yes")

Solution (Python):


def solve():
    S = input()
    for s in list(S):
        if S.count(s) != 2:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    solve()

Solution (Python):
s = input()

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

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

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()

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

Solution (Python):
def main():
    import sys
    input = sys.stdin.readline
    
    a = sorted(input()[:-1])
    
    if a[0] == a[1] and a[2] == a[3] and a[1] != a[2]:
        print("Yes")
    else:
        print("No")
    
    return 0

main()

Solution (Python):
s = input()
a = {}
b = []
for i in range(len(s)):
    if s[i] in a.keys():
        a[s[i]] += 1
    else:
        a[s[i]] = 1
for i in a.keys():
    b.append(a[i])
if len(a) == 2 and b == [2,2]:
    print("Yes")
else:
    print("No")

Solution (Python):
from heapq import heappush, heappop
import re
from collections import deque
import sys
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_invs(n, mod=DIV):
    inv = [0]*(n+1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, n+1):
        inv[i] = (-(mod//i)*inv[mod % i]) % mod
    return inv


def main():
    S = input().strip("\n")
    if len(set(S))==2 and S.count(S[0])==2:
        return "Yes"
    return "No"


print(main())

Solution (Python):
s=input().rstrip()
x=list(s)
l=[]
for i in range(0,len(x)):
    if x.count(x[i])>=2 and x[i] not in l:
        l.append(x[i])
if len(l)==2:
    print("Yes")
else:
    print("No")

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

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

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