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

kind_num = 0

for i in range(4):
    for j in range(i+1, 4):
        if S[i] == S[j]:
            kind_num += 1

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

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

Solution (Python):
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

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

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


from fractions import gcd
from math import ceil,floor
import collections







S = input()
SC = collections.Counter(S)

ans = 'No'

if len(SC.most_common()) == 2:
    ans = 'Yes'


print(ans)

Solution (Python):
ss = input()
cou = 0
for s in ss:
    if ss.count(s) == 2:
        cou += 1
print('Yes' if cou == 4 else  'No')

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

Solution (Python):
import collections

s=input()

c = collections.Counter(s)


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

Solution (Python):
from collections import Counter

s = input()

t = Counter(s)

a = []
for i,j in t.items():
    a.append(j)

if len(a) == 2:
    if a[0] == a[1]:
        print("Yes")
        exit()

print("No")

Solution (Python):

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

Solution (Python):
S = str(input())
num = [0]*4
for i in range(len(S)):
    for j in range(len(S)):
        if S[i] == S[j]:
            num[i] += 1
if num == [2,2,2,2]:
    print("Yes")
else:
    print("No")

Solution (Python):
s = str(input())
j = list(set(list(s)))
c1 = j[0]
try:
    c2 = j[1]
except:
    print("No")
    exit()
if len(j) == 2 and s.count(c1) == 2 and s.count(c2) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter

S = input()

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

Solution (Python):
from collections import Counter

S = input()
C = Counter(S)
if len(C) == 2 and C.most_common()[0][1]== 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s=input()
ans = []
while len(s)>1:
    count = 1
    a = s[0]
    s=s[1:]
    for i in range(len(s)-1,-1,-1):
        if s[i] == a:
            s=s[:i] + s[i+1:] 
            count += 1
    ans += [count]
if ans==[2,2]:
    print("Yes")
else:
    print("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 permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


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

def main():
    s=list(input())
    t=set(s)
    if len(t)==2:
        print('Yes')
    else:
        print('No')


if  __name__=='__main__':
    main()

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()
if len("".join(set(s)))==2 :
  if s[0]==s[1]:
    if s[2]==s[3]:
      print("Yes")
    else:
      print("No")
  elif s[0]==s[2]:
    if s[1]==s[3]:
      print("Yes")
    else:
      print("No")
  elif s[0]==s[3]:
    if s[1]==s[2]:
      print("Yes")
    else:
      print("No")
else:
  print("No")

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

Solution (Python):
S = input()

dic = {}

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

if len(dic) == 2 :
    for i in dic:
        if dic[i] != 2:
            break

    print("Yes")
    quit()

print("No")

Solution (Python):
s = input()

l = []

for i in range(len(s)):
    l.append(s[i])
    
if  2 *len(set(l)) == len(l):
    print("Yes")
else:
    print('No')

Solution (Python):
S = {x for x in input()}
print('Yes' if len(S)==2 else 'No')

Solution (Python):
ls = list(input())
cnt = ls.count(ls[0])
for i in ls[1::]:
    if i != ls[0]:
        if cnt == 2 and ls.count(i) == 2:
            print("Yes")
            quit()
print("No")

Solution (Python):


def main():
    S = input()
    ans = "Yes"
    T = [0]*30
    for s in S:
        T[ord(s)-ord("A")] += 1
    for i in range(30):
        if T[i] == 0 or T[i] == 2:
            pass
        else:
            ans = "No"
            break
    print(ans)
    
if __name__ == '__main__':
    main()

Solution (Python):
l = list(input())
s_l = list(set(l))
if len(s_l) != 2:
    ret = "No"
elif sum([1 if x==s_l[0] else 0 for x in l])==2:
    ret = "Yes"
print(ret)

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

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


main()

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

Solution (Python):
s = input()
letter_dict = {'A':1,'B':2,'C':3,'D':4,'E':5,'F':6,'G':7,'H':8,
    'I':9,'J':10,'K':11,'L':12,'M':13,'N':14,'O':15,'P':16,'Q':17,
    'R':18,'S':19,'T':20,'U':21,'V':22,'W':23,'X':24,'Y':25,'Z':26
    }
a = [0] * 27
b = [0] * 5
for i in s:
	a[letter_dict[i]] += 1
count = 0
for i in a:
	if i != 0:
		b[i] += 1

if b[2] == 2:
	print('Yes')
else:
	print('No')

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

ans = "No"

if s.count(S[0]) == 2:
  if s.count(S[1]) == 2:
    if s.count(S[2]) == 2:
      if s.count(S[3]) == 2:
        ans ="Yes"
print(ans)

Solution (Python):
s=input()
p=s[0]
c1=1
c2=0
q=""
t=1


for i in range(1,4):
    if s[i]==p:
        c1+=1
    else:
        if c2==0:
            c2=1
            q=s[i]
        elif s[i]==q:
            c2+=1
        
if c1==2 and c2==2:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
s = input()
c = Counter(s)
r = True
for v in c.values():
  if not v == 2:
    r = False
    break
print('Yes' if r else 'No')

Solution (Python):
s = input()

s = sorted(s)

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

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

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

wdict = {}
for w in S:
    if w in wdict:
        wdict[w] += 1
    else:
        wdict[w] = 1

cnt = 0
for i in wdict.values():
    if i == 2:
        cnt +=1

if len(wdict.keys()) == 2 and cnt == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s=input()
s_d={}
for c in s:
    if c not in s_d.keys():
        s_d[c] = 0
    s_d[c] += 1

r = 'No'
key = list(s_d.keys())
if len(key) == 2:
    if s_d[key[0]] == 2 and s_d[key[1]] == 2:
        r = "Yes"

print(r)

Solution (Python):
s = input()

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

Solution (Python):
from collections import defaultdict

S = input()

kind = defaultdict(int)

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

if len(kind) == 2:
    f = True
    for k in kind.values():
        if k != 2:
            f = False
    
    if f:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

cs = Counter(S)
if all([v == 2 for v in cs.values()]):
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
s = list(input())
if s[0] == s[1] == 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):
a, b, c, d = sorted(input())
print(('No', 'Yes')[a == b != c == d])

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

x = {}
for s in S:
    if s not in x:
        x[s] = 1
    else:
        x[s] = x[s] + 1

if len(x) == 2 and 2 in x.values():
    print('Yes')
else:
    print('No')

Solution (Python):
s = list(input())
d = {}
for x in s:
    d[x] = d.get(x, 0) + 1
for v in d.values():
    if v != 2:
        print('No')
        exit()
print('Yes')

Solution (Python):
from collections import Counter
import sys
a = Counter(input())

ok = False
if len(a) == 2:
    for x in a:
        if a[x] != 2:
            break
    else:
        ok = True
if ok:
    print("Yes")
else:
    print("No")

Solution (Python):
s_list = list(input())
s_set = set(s_list)

if len(s_set) == 2:
    if ''.join(s_list).count(s_list[0]) == 2 and ''.join(s_list).count(s_list[1]) == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
S = input()
s1 = S[0]
s2 = S[1]
s3 = S[2]
s4 = S[3]
SL = [s1, s2, s3, s4]
SL.sort()
if SL[0] == SL[1] and SL[2] == SL[3] and SL[0] != SL[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
list_res = [i for i in S]
list_res_2 = list(set(list_res))

if len(list_res_2) != 2:
    print("No")
elif list_res.count(list_res_2[0]) ==2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

cnt1 = S.count(S[0])
cnt2 = S.count(S[1])
cnt3 = S.count(S[2])
cnt4 = S.count(S[3])

if cnt1 == 2 and cnt2 == 2 and cnt3 == 2 and cnt4 == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
text = input()

text_list = []

for i in range(4):
    if not text[i] in text_list:
        text_list.append(text[i])


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

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

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

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

Solution (Python):
import string
s = input()
d = {i:0 for i in string.ascii_uppercase}
for i in s:
  d[i] += 1

def solve():
  for i in d.values():
    if i not in [0, 2]:
      print("No")
      return
  print("Yes")

solve()

Solution (Python):


import sys

class AFiftyFifty:
    def solve(self):
        s = list(input().strip())
        s.sort()
        print("Yes" if (s[0] == s[1] and s[2] == s[3] and s[0] != s[2]) else "No")


solver = AFiftyFifty()
input = sys.stdin.readline

solver.solve()

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[0] != S[1]:
    print("Yes")
    exit()
if S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
    print("Yes")
    exit()

print("No")

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

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

if (len(cnt) == 2 and cnt[max(cnt)] == 2 and cnt[min(cnt)] == 2):
    print('Yes')
else:
    print('No')

Solution (Python):
import sys

a = input()

if a.count(a[0]) != 2:
  print("No")
  sys.exit()
if a[0] == a[1]:
  if a.count(a[2]) != 2:
    print("No")
    sys.exit()
else:
  if a.count(a[1]) != 2:
    print("No")
    sys.exit()
print("Yes")

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

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

d = {}

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

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

Solution (Python):
from collections import defaultdict

def read_input():
    s = input()
    chars = [c for c in s]
    return chars


def submit():
    chars = read_input()

    c_dic = defaultdict(int)
    for c in chars:
        c_dic[c] += 1

    c_list = list(c_dic.items())

    if len(c_list) == 2:
        if c_list[0][1] == c_list[1][1] == 2:
            print("Yes")
            return

    print("No")
    return


if __name__ == '__main__':
    submit()

Solution (Python):
import collections
s=input()
c=dict(collections.Counter(s))
for i in c.values():
    if(i!=2):
        print("No")
        break
else:
    print("Yes")

Solution (Python):


S = input()

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

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

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')


def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return


def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return


def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(d[-1]):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def D():
    return


def E():
    return


def F():
    return


def G():
    return


def H():
    return


if __name__ == '__main__':
    A()

Solution (Python):
s=input()

a=s[0]
b=''
for i in range(1,4):
  if s[i]!=a:
    b=s[i]
    break
ca=0
cb=0
for i in range(4):
  if s[i]!=a and s[i]!=b:
    print('No')
    exit()
  if s[i]==a:
    ca+=1
  elif s[i]==b:
    cb+=1
if ca==2 and cb==2:
  print('Yes')
else:
  print('No')

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

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

Solution (Python):
import collections

s = input()
s = [i for i in s]
c = list(collections.Counter(s).values())
if len(c)==2 and c[0]==2:
    print('Yes')
else:
    print('No')

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

Solution (Python):
S = list(input())
output = "Yes"
a = []
b = []
for i in range(4):
    if S[i] in b:
        output = "No"
    if S[i] in a:
        b.append(S[i])
    a.append(S[i])

if len(b)>2:
    output = "No"
if len(b)<2:
    output = "No"

print(output)

Solution (Python):
s=list(input())
from collections import defaultdict
d=defaultdict(int)
for i in s:
    d[i]+=1

if len(d)!=2:
    print("No")
else:
    for i in d.items():
        if i[1]!=2:
            print("No")
            import sys
            sys.exit()
    print("Yes")

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

Solution (Python):

import time
import re
import math
import fractions

def main():
    global N,A,B,C,D,memo,mx,mn,temp
    s=input()
    f=False
    if len(set(list(s)))==2:
        num1=0
        num2=0
        for a in range(4):
            if list(set(list(s)))[0]==s[a]:
                num1+=1
            else:
                num2+=1
        if num1==num2:
            f=True
    if f:
       print("Yes")
    else:
        print("No")

start=time.time()
main()

Solution (Python):
from collections import Counter
S = input()
c = Counter(S)
flag = True
if len(c.keys()) == 2:
    for v in c.values():
        if v != 2: flag = False
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

Solution (Python):
from collections import defaultdict
def main():
	S = input()
	ans = defaultdict(int)
	for c in S:
		ans[c] += 1
	if len(ans) == 2 and ans[S[0]] == 2:
		print("Yes")
	else:
		print("No")



if __name__ == '__main__':
	main()

Solution (Python):


s = input()

a = s.count(s[0])
b = 0
for i in s:
    if i!= s[0]:
        b = s.count(i)

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

Solution (Python):
S = input()

T = list(set(S))

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

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

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

s1.sort()

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

Solution (Python):
S = input()
judge = "No"
for i in range(len(S)):
    if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
        judge = "Yes"
    elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
        judge = "Yes"
    elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
        judge = "Yes"

print(judge)

Solution (Python):

S = input()
ans=0
if S[0] == S[1]:
    if S[2] == S[3]and S[0]!=S[2]:
        print("Yes")
        ans=1
elif S[0] == S[2]:
    if S[1] == S[3]and S[0] != S[1]:
        print("Yes")
        ans=1
elif S[0] == S[3]:
    if S[1] == S[2]and S[0] != S[2]:
        print("Yes")
        ans=1

if ans==0:
    print("No")

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

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

Solution (Python):
def input_from_console():
    s = list(input().strip())
    return s


def solve(s):
    result = 'No'
    if len(set(s)) == 2 and s.count(set(s).pop()) == 2:
        result = 'Yes'
    return result


def main():
    s = input_from_console()
    print(solve(s))


if __name__ == "__main__":
    import sys

    if sys.gettrace():  
        check_cases()
    else:
        main()

Solution (Python):
s = list(input())
a = set(s)
if len(a) == 2:
    s1 = s[0]
    s.remove(s1)
    if s1 in s:
        s.remove(s1)
        if s1 in s:
            print("No")
        else:
            print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
"""


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


 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  


a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654


char_list = list("abcd") 
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    S= list(sys.stdin.readline().rstrip())
    c1=S.count(S[0])
    c2=S.count(S[1])
    c3=S.count(S[2])
    c4=S.count(S[3])
    if c1==c2==c3==c4==2:
        print("Yes")
    else:
        print("No")

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

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

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

S = input()

d = {}

for c in S:
    if c in d:
        if d[c] > 1:
            
            print("No")
            exit()
        d[c] += 1
    else:
        d[c] = 1


if 3 < len(d):
    print("No")
else:
    print("Yes")

Solution (Python):
import sys
st=input()
for i in range(len(st)):
  if not st.count(st[i])==2:
    print("No")
    sys.exit()
print("Yes")

Solution (Python):
def main():
    S = input()
    frag = [0] * 4
    for i in range(len(S)):
        for j in range(len(S)):
            if S[i] == S[j]:
                frag[i] += 1
    fragp = 0
    for i in range(len(frag)):
        if frag[i] != 2:
            fragp = 1
    if fragp == 0:
        print('Yes')
    else:
        print('No')

if __name__ == "__main__":
    main()

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(S: str):
    set_s = set(c for c in S)
    for e_s in set_s:
        if S.count(e_s) != 2:
            print(NO)
            return
    print(YES)
    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 = input()
set_S = set(S)
print("Yes" if len(set_S) == 2 and len(S) == 4 and S.count(S[0]) == 2 else "No")

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

Solution (Python):


s = input()

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

print(a)

Solution (Python):
s = input()

if len(set(s))!=2:
  print('No')
else:
  if len([i for i in s if i==s[0]])==2:
    print('Yes')
  else:
    print('No')

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

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

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

ans = 'Yes'
for i in range(0,3):
    if (s[i] == s[i+1]) ^ (i%2 == 0):
        ans = 'No'

print(ans)

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

Solution (Python):
S = input()
s = list(S)
ans = "No"
if s[0] != s[1]:
    if S.count(s[0]) == 2 and S.count(s[1]) == 2:
        ans = "Yes"
elif s[0] != s[2]:
    if S.count(s[0]) == 2 and S.count(s[2]) == 2:
        ans = "Yes"
print(ans)

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

s = input()

a = 0
num_a = 0
b = 0
num_b = 0
for i in range(len(s)):
    if a == 0 and b == 0:
        a = s[i]
        num_a += 1
    elif s[i] == a:
        num_a += 1
    elif s[i] != a and b == 0:
        b = s[i]
        num_b += 1
    elif s[i] == b:
        num_b += 1
    else:
        print('No')
        sys.exit()

if num_a == num_b:
    print('Yes')
else:
    print('No')

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

Solution (Python):
import sys
from collections import defaultdict

input = sys.stdin.readline

S = list(input().strip())
count = defaultdict(int)
for c in S:
    count[c] += 1

kind = len(count.keys()) == 2
nums = all(freq == 2 for freq in count.values())
if kind and nums:
    print('Yes')
else:
    print('No')

Solution (Python):


def main():
    S = input()
    counter = dict()

    for c in S:
        if c in  counter:
            counter[c] += 1
        else:
            counter[c] = 1

    if len(counter) == 2:
        for c in counter.keys():
            if counter[c] != 2:
                print("No")
                break
        else:
            print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

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

Solution (Python):
S = input()
S = S.replace(S[0], "")

if S == "":
    print("No")
    exit()

S = S.replace(S[0], "")

if S == "":
    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 = input()
is_no = False
for s in S:
  if S.count(s) != 2:
    is_no = True
    break
if is_no:
  print("No")
else:
  print("Yes")

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

Solution (Python):
S = input()
dic = {}
ok = 0
for i in S:
    if not i in dic:
        dic[i] = 1
    else:
        dic[i]+= 1

if len(dic)==2:
    for i in dic:
        if dic[i]!=2:
            ok = 0
            break
        else:
            ok = 1
if ok:
    print("Yes")
else:
    print("No")

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

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

if (2 == len(SS)):
  for s in SS:
    if (2 != S.count(s)):
      print('No')
      exit()
else:
  print('No')
  exit()
  
print('Yes')

Solution (Python):
s = input()
d = {}
for i in range(4):
    if s[i] in d.keys():
        d[s[i]] += 1
    else:
        d[s[i]] = 1
if len(d.items()) != 2:
    print('No')
    quit()
for i in d.items():
    if i[1] != 2:
        print('No')
        quit()
print('Yes')

Solution (Python):
s = input()
l = []
for i in range(4):
    l.append(s[i])
lset = list(set(l))
if len(lset) == 2:
    if l.count(lset[0]) == 2 and l.count(lset[1]) == 2:
        print('Yes')
        exit()
print('No')

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

print(main())

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

Solution (Python):
import sys,heapq
from collections import deque,defaultdict
printn = lambda x: sys.stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
DBG = True  and False
def ddprint(x):
  if DBG:
    print(x)

s = input()
h = defaultdict(int)
for i in range(4):
    h[s[i]] += 1
k = list(h.keys())
ddprint(k)
if len(k)==2 and h[k[0]]==2 and h[k[1]]==2:
    print('Yes')
else:
    print('No')

Solution (Python):
S = input()

n = S.count(S[0])
if not n == 2:
  print("No")
else:
  S = S.replace(S[0], "")
  if S.count(S[0]) == 2:
    print("Yes")
  else:
    print("No")

Solution (Python):

def main():
    S = list(input())
    
    SS = set(S)
    
    
    if len(SS)==2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import numpy as np

S = input()

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

Solution (Python):
s = input()
if s.count(s[0]) != 2:
    print('No')
    exit()
s = s.replace(s[0], '')
if s.count(s[0]) != 2:
    print('No')
    exit()
print('Yes')

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

Solution (Python):

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

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

Solution (Python):
from collections import defaultdict
ss = defaultdict(int)
s = input()

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

if sum(ss.values()) == 4 and len(ss) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
string = input()

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

for k in dict.values():
    if k != 2:
        print("No")
        exit()

print("Yes")

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