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

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

S.sort()

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

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

Solution (Python):
print ("YNeos"[len(''.join(set(sorted(input()))))!=2::2])

Solution (Python):
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

    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[0] != S[1]
        or S[0] == S[3]
        and S[1] == S[2]
        and S[0] != S[1]
    ):
        print('Yes')
    else:
        print('No')

    return


if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import Counter

s = input()
c = Counter(s)
print('Yes' if len(c) == 2 and c[s[0]] == 2 else 'No')

Solution (Python):


inp = input()
ans = True

for i in inp:
    y = inp.count(i)
    if y != 2:
        ans = False
        break

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

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

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

Solution (Python):
S=input()
l=[]
n=[]
l.extend(S)
a=set(l)
if len(a)==2:
    print('Yes')
else:
    print('No')

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

for s in S:
    if s == S[0]:
        s1 += 1

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

Solution (Python):
a1=input()
a2=list(a1)
b=[ord(x) for x in a2]
b.sort()
if len(a2)==4 and b[0]==b[1] and b[2]==b[3] and b[1]!=b[2]:
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
a1=input()
a2=list(a1)
b=[ord(x) for x in a2]
b.sort()
if len(a2)==4 and b[0]==b[1] and b[2]==b[3] and b[1]!=b[2]:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
def solve():
    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
    print('YNeos'[count!=2::2])





if __name__ == '__main__':
    solve()

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

c = collections.Counter(S)

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

Solution (Python):
s=input()
s1=[]
for i in s:
    if i not in s1:
        s1.append(i)
if len(s1)==2:
    print('Yes')
else:

    print('No')

Solution (Python):
import sys
sys.setrecursionlimit(10**6)

s = input()

d = {}

for ch in s:
    d[ch] = d.get(ch, 0) + 1
    
if len(d) == 2:
    for k in d:
        if d[k] == 2:
            pass
        else:
            print('No')
            break
    else:
        print('Yes')
else:
    print('No')

Solution (Python):
S = input()
S1 = []
for i in S:
  if i not in S1:
    S1.append(i)
if len(S1) == 2:
  print('Yes')
else:
  print('No')

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

Solution (Python):
import sys
S=list(input())
for i in range(4):
  t=S.count(S[i])
  if t!=2:
    print("No")
    sys.exit()
print("Yes")

Solution (Python):
import collections

S = input()

c = collections.Counter(S)


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

Solution (Python):
s = input()
chk = {}
for i in s:
    if i not in chk:
        chk[i] = 1
    else:
        chk[i] += 1

if len(chk) == 2 and chk[i] == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
chk = {}
for i in s:
    if i not in chk:
        chk[i] = 1
    else:
        chk[i] += 1

if len(chk) == 2 and chk[i] == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import Counter

S = str(input())

if all(v == 2 for v in Counter(S).values()):
    print("Yes")
else:
    print("No")

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

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

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

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

Solution (Python):

from collections import Counter

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


main()

Solution (Python):
a = input()
b = True
for i in set(a):
  if a.count(i) == 2:
    b = "Yes"
  else:
    b = "No"
print(b)

Solution (Python):
from collections import Counter

s = input()
C = Counter(s)
D = C.most_common()
print("Yes" if len(D) == 2 and D[0][1] == D[1][1] == 2 else "No")

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

Solution (Python):
s = input()

cnt = [0]*26
for c in s:
    cnt[ord(c) - ord('A')] += 1

if cnt.count(2) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
dic = {}
for x in s:
    if(dic.get(x) is None):
        dic[x] = 1
    else:
        dic[x] += 1

for i in dic.values():
    if(i!=2):
        print('No')
        exit()

print('Yes')

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

Solution (Python):
s=input()
t=list(set(s))
if len(t)==2:
  cnt1=0
  cnt2=0
  for i in s:
    if i==t[0]:
      cnt1+=1
      
    elif i==t[1]:
      cnt2+=1
      
  if cnt1==2 and cnt2==2:
    print('Yes')
    exit()
    
print('No')

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

Solution (Python):
S=input();s=set(S);print('NYoe s'[len(s)==2 and S.count(list(s)[0])==2::2])

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

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

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

Solution (Python):
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    S = input()
    d = dict()
    for s in S:
        if s in d:
            d[s] += 1
        else:
            d[s] = 1

    ans = 'Yes'
    if len(d) == 2:
        for k, v in d.items():
            if v != 2:
                ans = 'No'
    else:
        ans = 'No'

    print(ans)


if __name__ == '__main__':
    solve()

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())
import collections
c = collections.Counter(s)
ans = 1
for i in range(4):
    if c[s[i]] != 2:
        ans = 0
print(["No","Yes"][ans])

Solution (Python):
S = input()

import collections

S_list = list(S)
c = collections.Counter(S_list)

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

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

Solution (Python):
s = input()

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

print('No')

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


if __name__ == '__main__':
    main()

Solution (Python):
import collections

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

Solution (Python):
import collections
cc = collections.Counter(raw_input())
print 'Yes' if len(cc) == 2 and cc.values() ==[2,2] else 'No'

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

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

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

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

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

if len(set(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 = input()
t = sorted(s)

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

Solution (Python):
s = input()

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

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

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

Solution (Python):
s = input()

lis = []
for i in s:
    lis.append(i)
    
tmp = list(set(lis))

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

Solution (Python):
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    s.sort()
    if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

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

Solution (Python):
from collections import defaultdict
d = defaultdict(int)
s = input()
for i in range(len(s)):
  d[s[i]] += 1
d = dict(d)
values = set(list(d.values()))
if len(d) == 2 and len(values) == 1 and list(values)[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]:
    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):

from collections import Counter
import sys
input = sys.stdin.readline
s =list(input().strip())
co =Counter(s)
ans =list(co.values())
if ans[0] ==2 and ans[1] ==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):
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):
s = input()
if len(set(s)) == 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()

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

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

Solution (Python):
import collections

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

print('Yes' if len(c) == 2 else 'No')

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

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


if __name__ == '__main__':
    main()

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

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

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

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

Solution (Python):
s=input()
t=set(s)
t=list(t)
if len(t)!=2:
  print("No")
  exit(0)
c1,c2=0,0
for ss in s:
  if t[0]==ss:c1+=1
  if t[1]==ss:c2+=1

if c1==2 and c2==2:
  print("Yes")
else:
  print("No")

Solution (Python):
def main():
  s=input()
  flg=0
  if s.count(s[0])!=2:
    flg=1
  s=s.replace(s[0],'')
  if len(s)>0 and s.count(s[0])!=2:
    flg=1
  if flg==1:
    print('No')
  else:
    print('Yes')  
main()

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

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

Solution (Python):
from collections import Counter
S = input()
C = Counter(S)
if list(C.values()) == [2, 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[2]:
    print("Yes")
else:
    print("No")

Solution (Python):
from collections import Counter
s = Counter(input())
ans = "Yes"
if len(s)==2:
  for x in s.values():
    if x == 2: continue
    else: 
      ans = "No"
      break
else: ans = "No"
print(ans)

Solution (Python):
s=input()
kit=[]
for i in range(4):
  if not s[i] in kit:
    kit.append(s[i])
if len(kit)!=2:
  print('No')
else:
  counter=0
  for i in range(4):
    if kit[0]==s[i]:
      counter+=1
  if counter==2:
    print('Yes')
  else:
    print('No')

Solution (Python):
S = input().strip()
C = {}
for i in range(4):
    a = S[i]
    if a not in C:
        C[a] = 0
    C[a] += 1
C = list(C.items())
if len(C)==2 and C[0][1]==2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    s = input()
    print("Yes" if len(set(s)) == 2 else "No")


if __name__ == '__main__':
    resolve()

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()
a = s[0]
b = s[1]
c = s[2]
d = s[3]

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

Solution (Python):
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 Counter

SC = Counter(input())

for key, value in SC.items():
    if value != 2:
        print('No')
        exit()
print('Yes')

Solution (Python):
s = list(input())
ans = 'Yes'

if len(set(s)) != 2:
    ans = 'No'

if s.count(s[0]) != 2 or s.count(s[1]) != 2 or s.count(s[2]) != 2:
    ans = 'No'

print(ans)

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

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

Solution (Python):

s = input()
count_dict = dict()

for word in s:
    count_dict.setdefault(word,0)
    count_dict[word] += 1
    
if len(count_dict) == 2:
    for row in count_dict:
        if count_dict[row] != 2:
            print("No")
            break
    print("Yes")
else:
    print("No")

Solution (Python):

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

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

Solution (Python):
S=input()
s1=S[0]
s2=0

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

if S.count(s1)==2 and S.count(s2)==2:
  print("Yes")
else:
  print("No")

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

Solution (Python):
from collections import Counter
c = Counter(input())
for k, v in c.items():
    if v != 2:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
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):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)


from collections import Counter,deque,defaultdict





s=s0()
s="".join(sorted(s))
p0(s[0]==s[1] and s[1]!=s[2] and s[2]==s[3])

Solution (Python):

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)


from collections import Counter,deque,defaultdict





s=s0()
d=Counter(s)
p0(list(d.values())==[2,2])

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

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

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

Solution (Python):



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


if __name__ == '__main__':
    main()

Solution (Python):
from collections import Counter
s = input()
c = Counter(s)
if len(c)==2 and all(vi==2 for vi in c.values()):
    print("Yes")
else:
    print("No")

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

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

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

Solution (Python):
s=input()
t=set()
for i in range(len(s)):
    t.add(s[i])
cnt=0
u=t.pop()
t.add(u)
for i in range(len(s)):
    if(u==s[i]):
        cnt+=1

if(cnt==2 and len(t)==2):
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
char1 = S[0]
char2 = 'none'
count1 = 0
count2 = 0
for i in range(1, 4):
  if S[i] == char1:
    count1 += 1
  elif char2 == 'none':
    char2 = S[i]
  elif S[i] == char2:
    count2 += 1
if count1 == 1 and count2 == 1:
  print('Yes')
else:
  print('No')

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

t= sorted([s[1], s[0], s[2], s[3]])

if t[1] != t[2] and t[0]==t[1] and t[2]==t[3]:
    print('Yes')
else:
    print('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()

a = []
for i in range(0,len(s)):
  c = 0 
  for j in range(0,len(s)):
    if(s[i] == s[j]):
      c += 1
  a.append(c)

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

Solution (Python):
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    flag = True
    s = input()
    c = Counter(s)
    values, counts = zip(*c.most_common())
    for i in counts:
        if (i != 2):
            flag = False
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):
x = list(input())
count = 0
for i in x:
    if x.count(i) == 2:
        count += 1
if count == len(x):
    print("Yes")
else:
    print("No")

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

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

print("No")

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

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

Solution (Python):
s = 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]!=s[2]==s[3] or s[0]==s[2]!=s[1]==s[3] or s[0]==s[3]!=s[1]==s[2]:
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = input()
for i in S:
  if S.count(i) != 2:
    print('No')
    break
else:
  print('Yes')

Solution (Python):


s = list(str(input()))

if len(set(s)) != 2:
    print("No")
    exit()

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

print("Yes")

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

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

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

Solution (Python):
s = input()
a = []

for i in s:
    if a.count(i)==0:
        a.append(i)

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

Solution (Python):
import collections
import sys

s = input()
n = collections.Counter(s)
t = list(set(s))

if(len(t) == 1):
  print('No')
  sys.exit()

print('Yes' if n[t[0]] == 2 and n[t[1]] == 2 else 'No')

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

else:
    print("No")

Solution (Python):
print('YNeos'[len(set(input()))!=2::2])

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 = sorted(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('Yse')
elif (s[0] == s[3]) and (s[1] == s[2]) and (s[0] != s[1]):
        print('Yes')
else:
    print('No')

Solution (Python):
s = input()
s_l = set(s)
s_l = list(s_l)
if len(s_l) != 2:
  print("No")
elif s.count(s_l[0]) == 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):
S = input()
print('Yes' if len(set(S))==2 else 'No')

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

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

Solution (Python):
print("YNeos"[len(set(input()))!=2::2])

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

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

Solution (Python):
import itertools
num = 0
a= input()
for v in itertools.combinations(a, 2):
    (f, g) = v
    if f == g:
        num += 1
if num == 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=input()
a=[]
for i in s:
    a.append(i)
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):
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()

set_s = set(S)

if len(set_s) == 2 and S.count(set_s.pop()) == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
from collections import Counter


S = input()

Counter_S = Counter(S)

if len(Counter_S.keys()) == 2 and list(set(Counter_S.values())) == [2]:
    print("Yes")
else:
    print("No")

Solution (Python):
import collections

S = list(input())

c = collections.Counter(S)

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

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

Solution (Python):
import sys

def main():
    S = input()
    S_list = [S[i] for i in range(0, 4)]

    S_set = set(S_list)
    if len(S_set) != 2:
        print('No')
        return
    
    for i_set in S_set:
        num = 0
        for i_list in S_list:
            if i_set == i_list:
                num += 1
        
        if num != 2:
            print('No')
            break
    
    else:
        print('Yes')
        
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

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

Solution (Python):
import sys
s = list(input())
if s.count(s[0]) != 2:
	print("No")
	sys.exit()
print("Yes" if len(set(s)) == 2 else "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()
s = list(s)
sset = set(s)
if len(sset) == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = 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 and sorted(s)[2] != sorted(s)[1]:
    print('Yes')
else:
    print('No')

Solution (Python):
n=4
s=list(input())
s.sort()
if s.count(s[0])==2 and s.count(s[n-1])==2:
  print("Yes")
else:
  print("No")

Solution (Python):
import itertools
import math
import fractions
import functools
import copy

s = input()

dic = {}
for i in range(len(s)):
    current = dic.get(s[i],0)
    dic[s[i]] = current + 1

for key in dic:
    if dic[key] != 2:
        print("No")
        quit()

print("Yes")

Solution (Python):

s=list(input())

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

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

Solution (Python):

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

Solution (Python):
def fifty_fifty(s):

    count = set(s)
    return "Yes" if len(count) == 2 and s.count(list(count)[0]) == 2 and s.count(list(count)[1]) == 2 else "No"
def main():
    s = list(str(input()))
    print(fifty_fifty(s))

if __name__ == '__main__':
    main()

Solution (Python):

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