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

from collections import Counter
keys = Counter(S).keys()
values = Counter(S).values()

if len(keys) == 2 and max(values) == 2 and min(values) == 2 :
    print("Yes")
else :
    print("No")

Solution (Python):
s = input()

li = {}

for i in s:
  try:
    li[i] += 1
  except:
    li[i] = 1

if len(li) == 2 and max(li.values()) == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
from collections import Counter
s = input().strip()
c = Counter(s)
fl = True
for v in c.values():
  if v != 2:
    print("No")
    fl = False
    break
if fl:
  print("Yes")

Solution (Python):


S = input()
word = []
for i in S:
	word.append(i)
ans = list(set(word))
a = 0
for i in word:
    if i == word[0]:
        a += 1
    else:
        pass

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

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

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

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

s_arr = [str(s) for s in S]
s_arr = sorted(s_arr)

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

Solution (Python):
S = input()

temp2 = 0
for i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
    temp1 = S.count(i)
    if temp1 == 2:
        temp2 += 1

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

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

for  i in range(4):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
        
if len(dic) == 2 :
    for i in dic :
        if dic[i] != 2:
            print("No")
            break
    else:
        print("Yes")
        
else:
    print('No')

Solution (Python):



S = input()

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

cnt = 0        
for s in S : 
    if s == list[0] : 
        cnt += 1
        
if len(list) == 2 and cnt == 2 : 
    print("Yes")
else : 
    print("No")

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

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

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

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

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

Solution (Python):
S= input()
count = 0

for i in range(0,3):
    for j in range(i+1,4):
        if(S[i] == S[j]):
            count += 1
if(count == 2):
    print("Yes")
else:
    print("No")

Solution (Python):
S=list(input())
ans='Yes'
for i in range(len(S)):
	if S.count(S[i])!=2:ans='No'
print(ans)

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

if 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 = input()
l = [s[0], s[1], s[2], s[3]]
l.sort()
if l[0] == l[1] != l[2] == l[3]:
    print('Yes')
else: print('No')

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

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = set(list(input()))

print("Yes" if len(S) == 2 else "No")

Solution (Python):
S = list(input())
d = {}

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

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

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

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

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

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

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

Solution (Python):
from collections import Counter
S=Counter(input())
print("Yes" if len(S)==2 and len(set(list(S.values())))==1 else "No")

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

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

Solution (Python):
s = input()
n = s.count(s[0])
print("YNeos"[n!=2 or len(set(s))!=2::2])

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

Solution (Python):
import sys

s = sys.stdin.readline().rstrip()

def main():
    for char in set(s):
        if s.count(char) != 2:
            return 'No'
    return 'Yes'

if __name__ == '__main__':
    ans = main()
    print(ans)

Solution (Python):



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

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

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

Solution (Python):
s = input()

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

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

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

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

if len(c) == 2:
    a, b = c.values()
    if a == 2 and b == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

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

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

Solution (Python):
import collections
s = input()
s = list(s)
s = collections.Counter(s)
s = list(s.values())
flag = False
for i in s:
    if i!=2:
        flag = True
if flag==True:
    print('No')
else:
    print('Yes')

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

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

Solution (Python):


from collections import defaultdict

s = input()
m = defaultdict(int) 

for c in s:
    m[c] += 1

if len(m.keys()) != 2:
    print("No")
    exit()

if all([v == 2 for v in m.values()]):
    print("Yes")
    exit()

print("No")

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

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

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

Solution (Python):
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp



def main():
    d = defaultdict(int)
    for s in input():
        d[s] += 1
    print('Yes' if all(v==2 for v in d.values()) else 'No')


main()

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

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

Solution (Python):
s=list(input())
f=len(set(s))==2
g=s.count(s[0])==2
h=f and g
print("Yes" if h==True else "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=list(input())
print("Yes" if len(set(s))==2 else "No")

Solution (Python):
s=input()

print("{}".format("Yes" if len(set(s))==2 else "No"))

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

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

a = list(set(s))

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

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

Solution (Python):

N = list(input())
import collections
counter = collections.Counter(N)

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

Solution (Python):




def main():
    S = list(input())
    print('Yes' if all(
        [S.count(S[i]) == 2 for i in range(len(S))]) else 'No')


if __name__ == "__main__":
    main()

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

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

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

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

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

b = True
for value in d.values():
    if value != 2:
        b = False

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

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

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

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

Solution (Python):
S=input()
d={}
for i in S:
    if i not in d:
        d[i]=1
    else:
        d[i]+=1
v=list(d.values())
if len(d)==2:
    if (v[0]==2)and(v[1]==2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

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

Solution (Python):
S = input()

a = set()

for i in range(len(S)):
  a.add(S[i])

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

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

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

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

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

Solution (Python):
S = input()
result = False
for v in list(S):
    if S.count(v) != 2:
        break
    new = S.replace(v, '')
    if new[0] == new[1]:
        result = True
    break
print("Yes" if result else "No")

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

s_sorted = sorted(s)

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

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

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

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

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

Solution (Python):

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

Solution (Python):
S=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):
s = input()
set_s = set(s)
flag = 1
for si in set_s:
    if s.count(si) != 2:
        flag = 0

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

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

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

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

Solution (Python):
from collections import Counter

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

Solution (Python):
s = input()

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

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

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

Solution (Python):
S=str(input())
s=set(S)
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")
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()
moji=dict()
ans="No"
for c in s:
    if c not in moji:
        moji[c]=1
    else:
        moji[c]+=1
if len(moji)==2:
    ans="Yes"
print(ans)

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

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

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

Solution (Python):
s=input()
l=[s[i] for i in range(4)]
se = set(l)
if len(se)==2 and l.count(s[0])==2:
  print("Yes")
else:
  print("No")

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

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

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

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

Solution (Python):
S =list(input())
print( "Yes" if S.count(S[0]) ==2 and len(list(set(S)))==2 else "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])
e=a+b+c+d
if e==8:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

S_array = [""] * 4

for i in range(len(S)):
    S_array[i] = S[i]

S_array.sort()

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

Solution (Python):

import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

YES = "Yes"  
NO = "No"  

def solve(S: str):
    if all([S.count(S[i]) == 2 for i in range(len(S))]):
        print(YES)
    else:
        print(NO)
    return



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

if __name__ == '__main__':
    main()

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

Solution (Python):
count = {}

S = input()

for s in S:
  count[s] = count[s] + 1 if s in count else 1
  
key_counts = len(count)

if key_counts == 2:
  for v in count.values():
    if v != 2:
      print('No')
      exit()
  print('Yes')
else:
  print('No')

Solution (Python):
S=input()
lis=[]
for i in range(4):
    lis.append(ord(S[i]))

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

Solution (Python):
from collections import Counter
s = tuple(input())
d = Counter(s)
if len(set(s)) == 2 and d[s[0]] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
s_list = list(s)
s_list.sort()

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

Solution (Python):
s=input()
d={}
n="No"
for i in s:
  if i in d:
    d[i]=d[i]+1
  else:
    d[i]=1
    
if len(d) ==2:
  for k,v in d.items():
    n="Yes"
    
print(n)

Solution (Python):
s = input()

cnt = 0
for c in set(s):
  if s.count(c) == 2:
    cnt += 1

print('Yes' if cnt == 2 else 'No')

Solution (Python):
def main():
    s = input()

    sl = list(s)

    ss = set(sl)

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

    if sl.count(list(ss)[0]) != 2:
        print('No')
        exit()

    print('Yes')

 
if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()

lstStr = sorted(S)

res = "Yes" if len(set(lstStr)) == 2 and lstStr[1]!=lstStr[2] else "No"

print(res)

Solution (Python):
S = list(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()
count={}
for i in s:
    count.setdefault(i,0)
    count[i]+=1
l=[count.values()]
if len(count.keys())==2:
    k,l=count.values()
    if k==l==2:
        print('Yes')
    else:
        print('No')        
else:
    print('No')

Solution (Python):
s=list(input())
a=[]
for x in s:
    if s.count(x) == 2 and x not in a: a.append(x)
print('Yes' if len(a) == 2 else 'No')

Solution (Python):
l = list(map(str, input())) 
if l.count(l[0]) == l.count(l[1]) == l.count(l[2]) == l.count(l[3]) == 2: 
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict

S = input()
d = defaultdict(int)
for s in S:
  d[s] += 1
  
if len(d) != 2:
  print('No')
else:
  for v in d.values():
    if v != 2:
      print('No')
  else:
    print('Yes')

Solution (Python):
def main():
    from collections import Counter
    S = list(input())
    if len(Counter(S))==2:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Solution (Python):
S=input()
T=list()
for i in range(len(S)):
    T.append(S[i])
T.sort()
if len(set(T))==2 and T[0]==T[1] and T[2]==T[3]:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
l = []
for i in range( len( s )):
  if not ( s[i] in l ):
    l.append( s[i] )

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

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

x=[0,0,0,0]

for i in range(4):
  for j in range(4):
    if chr[i]==chr[j]:
      x[i]=x[i]+1

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

Solution (Python):
S = input()
l = [c for c in S]
ls = sorted(l)
if ls.count(ls[0]) == 2 and ls.count(ls[2]) == 2:
  r = 'Yes'
else:
  r = 'No'
                                     
print(r)

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={k:s.count(k) for k in set(s)}

def solve():
  if len(d) != 2:
    return False
  for i in d.values():
    if i != 2:
      return False
  return True

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

Solution (Python):
s = input()

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

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

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

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

for i in s:
    se.add(i)
li = list(se)

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

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

Solution (Python):
"""
author : halo2halo
date : 12, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = set(readline().decode('utf8').rstrip())
print('Yes' if len(S) == 2 else 'No')

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

Solution (Python):
s = input()

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

Solution (Python):
import collections
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()
        counter = collections.Counter(S)
        if len(counter) != 2:
            print("No")
            exit()

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



if __name__ == '__main__':
    AtCoder().main()

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

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

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):
from collections import defaultdict
dd = defaultdict(int)

S=input()
N=len(S)
for i in range(N):
    dd[S[i]]+=1
    
if len(dd.keys())==2 and list(dd.values())==[2,2]:
    ans="Yes"
else:
    ans="No"
    
print(ans)

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

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

print("Yes")

Solution (Python):
S = list(input())
d = {}
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
print("Yes" if list(d.values()) == [2, 2] else "No")

Solution (Python):
s = input()
s_sorted = ''.join(sorted(s))
if (s_sorted[0]==s_sorted[1]) and (s_sorted[2]==s_sorted[3]) and (s_sorted[1]!=s_sorted[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[2] == s[1]:
   if not s[0] == s[1] == s[2] == s[3]:
       print('Yes')
else:
    print('No')

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

Solution (Python):
S = [s for s in 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):
def main():
    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")


if __name__ == '__main__':
    main()

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

Solution (Python):
s=input()
set_s=set(list(s))
list_s=list(s)
list_s.sort()
if len(set_s)==2 and list_s[0]==list_s[1] and list_s[2]==list_s[3]:
    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):
s = list(input())

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

Solution (Python):
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    S=sorted(input())
    if S[0]==S[1] and S[1]!=S[2] and S[2]==S[3]:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

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

Solution (Python):
S=input()
li=[0]*4
for i in range(4) :
  li[i]=S[i]
li.sort()
a = 'No'
if li[0] != li[2] and li[0] == li[1] and li[2] == li[3] :
  a = 'Yes'
print(a)

Solution (Python):
S = list(input())
result = len(set(S))

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

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

Solution (Python):
a=str(input())
a=sorted(a)
if a[0]==a[1] and a[2]==a[3] and a[0]!=a[3]:
	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):
LIST = list(input())
SET = set(LIST)
SET = list(SET)
if len(SET)==2 and LIST.count(SET[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[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]:
  if s[0] != s[2] and s[1] != s[2]:
    print("Yes")
    exit()
print("No")

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

Solution (Python):
import sys
a = str(input())
for i in range(len(a)-1):
    if(a[i+1] == a[0]):
        t = i+1
        break
    t = 8

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

Solution (Python):
def main():
	n = list(str(input()))
	n_s = sorted(n)
	if n_s[0] == n_s[1] and n_s[2] == n_s[3] and n_s[1] != n_s[2]:
		print("Yes")
	else:
		print("No")

 
if __name__ == '__main__':
	main()

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

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

Solution (Python):
s = input()

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

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

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

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

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

Solution (Python):
s = input()
dic = {}
for i in s:
    if not i in dic:
        dic[i] = 0
    dic[i] += 1
if list(dic.values()) == [2,2]:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
s=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()
t=set(s)
u=list(t)
if len(t)!=2:
    print("No")
else:
    if s.count(u[0])==s.count(u[1])==2:
        print("Yes")
    else:
        print(("No"))

Solution (Python):
from collections import defaultdict

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

print("Yes" if (len(d.keys()) == 2 and all([d[k] == 2 for k in d])) else "No")

Solution (Python):
def main():
    S = input()
    dict = {}
    for i in range(4):
        if S[i] in dict:
            dict[S[i]] += 1
        else:
            dict[S[i]] = 1
    if len(dict.values()) == 2:
        if list(dict.values())[0] == 2:
            return "Yes"
    else:
        return "No"

if __name__ == '__main__':
    print(main())