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



Sample input:
ASSA


Sample output:
Yes

Submission status: Runtime Error

Solution code:
n = int(input())
l = list(map(int,input().split()))

ans = 0

for i in range(n-2):
    tmp = list([l[i],l[i+1],l[i+2]])
    if max(tmp) != tmp[1] and min(tmp) != tmp[1]:
        ans += 1
print(ans)

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
str=list(input())
if str.count(str[0])==2 and str.count(str[1])==2:
    print("Yes")
elif str.count(str[0])==2 and str.count(str[2])==2:
else:
    print("No")

Submission status: Runtime Error

Solution code:
# coding: utf-8
# A - Fifty-Fifty

s = input()
c = []
dict = {}
for i in s:
    if i in dict:
        dict[i] +=1
    else:
        dict[i] = 1
        c.append(i)
if dict[c[0]] == dict[c[1]]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
text = input()

if len(text) == 4:
	text = text.strip(text[0])
	if len(text) == 2:  
		text = text.strip(text[0])
		if len(text) == 0:
  			print("Yes")
		else:
  			print("No")
	else:
      print("No")
else:
 	print("No")

Submission status: Runtime Error

Solution code:
S = list(input())

if len(S) == 0:
    print('No')
else:
    c1 = (len(set(S)) == 2)

    m = list(set(S))[0]
    n = list(set(S))[1]

    m_c, n_c = 0, 0

    c2 = False

    if c1:
        for i in range(len(S)):
            if S[i] == m:
                m_c += 1
            else:
                n_c += 1
        if m_c == n_c:
            c2 = True

    if c1 and c2:
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
import pandas
import math
import numpy
import collections

x = input()
TF =  x.isupper() and x.isalpha()
if(TF):
    li = [i for i in x]
    count_dict = collections.Counter(li)
    list = [v for k, v in count_dict.items()]
    
    if(list == [2,2]):
        print("Yes")
    else:
        print("No")
print("No")

Submission status: Runtime Error

Solution code:
S = input()
C = [0] * 26
for s in S:
    C[ord(s)-ord('A')] += 1
v = 0
for  c in C:
    if c != 0 and c!= 2:
        print('No')
        import sys
        sys.exit(1)

print('Yes')

Submission status: Runtime Error

Solution code:
S = list(input())

c1 = (len(set(S)) == 2)

m = list(set(S))[0]
n = list(set(S))[1]

m_c, n_c = 0, 0

c2 = False

if c1:
    for i in range(len(S)):
        if S[i] == m:
            m_c += 1
        else:
            n_c += 1
    if m_c == n_c:
        c2 = True
else:
    print('No')

if c1 and c2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
import pandas
import math
import numpy
import collections

x = input()
TF =  x.isupper() and x.isalpha()
if(TF):
    li = [i for i in x]
    count_dict = collections.Counter(li)
    list = [v for k, v in count_dict.items()]
    
    if(list == [2,2]):
        print(True)
    else:
        print(False)
print(False)

Submission status: Runtime Error

Solution code:
text = input()

text = text.strip(text[0])
text = text.strip(text[0])

if len(text) == 0:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
n=int(input())
p=list(map(int,input().split()))
uuum = 0
for i in range(n-2):
  aaa = [p[i],p[i+1],p[i+2]]
  aaa.sort()
  if aaa[1]==p[i+1]:
    uuum+=1
print(uuum)

Submission status: Runtime Error

Solution code:
S=input()
list1=list(S)
if list1[0]==list1[2]==list1[3]==list1[4]:
  print("No")
else:
  if list1[0]==list1[1] and list1[2]==list1[3]:
    print("Yes")
  elif list1[0]==list1[2] and list1[1]==list1[3]:
    print("Yes")
  elif list1[0]==list1[3] and list1[1]==list1[2]:
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

Solution code:
check = True

if len(set(list(s))) == len(s):
    pass
else:
    for c in list(set(list(s))):
        if list(s).count(c) != 2:
            if check:
                print('No')
                check = False
    if check:
        print('Yes')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = list(input())

A = S[0]
for char in S:
    if char != S[0]:
        B = char

count1 = S.count(A)
count2 = S.count(B)

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

Submission status: Runtime Error

Solution code:
# coding: utf-8
# Your code here!
from collections import Counter

S = input()
S = list(S)


c1 = Counter(S).most_common(2)[0][1]
c2 = Counter(S).most_common(2)[1][1]

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

Submission status: Runtime Error

Solution code:
A=list(input())
B=[]
a=A[0]
cnt1=0
cnt2=0
for i in range(4):
    if(a==A[i]):
        cnt1+=1
    else:
        B.append(A[i])
b=B[0]
if(cnt1==2):
    for i in range(2):
        if(b==B[i]):
            cnt2+=1
    if(cnt2==2):
        print("Yes")
    else:
        print("No")        
else:
    print("No")

Submission status: Runtime Error

Solution code:
s=input()
count1=0
count2=0

char1=s[0]
count1+=1
if s[1]==char1:
    count1+=1
else :
    char2=s[1]
    count2+=1

if s[2]==char1:
    count1+=1
elif s[2]==char2:
    char2=s[2]
    count2+=1
else:
    print('No')
    exit()

if s[3]==char1:
    count1+=1
elif s[3]==char2:
    char2=s[3]
    count2+=1
else:
    print('No')
    exit

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = [_ for _ in input()]
s_s = list(set(s))

if len(s_s) >= 3:
  print("No")
else:
  if s.count(s_s[0]) == s.count(s_s[1]):
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
S = input()

a = S[0]
a_count = 0
b_count = 0

for i in S:
    if i==a:
        a_count += 1
    else:
        b = i
for i in S:
    if i==b:
        b_count +=1

if a_count == 2 and b_count == 2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S=input()
s=list(S)
if s[1]==s[2] and s[3]==s[4] and s[2]!=s[3]:
	print("Yes")
elif s[1]==s[3] and s[2]==s[4] and s[1]!=s[3]:
	print("Yes")
elif s[1]==s[4] and s[2]==s[3] and s[1]!=s[2]:
	print("Yes")
else:
	print("No")

Submission status: Runtime Error

Solution code:
S = input()
c = collections.Counter(S)
values, counts = zip(*c.most_common())
a = 0
for i in counts:
    if i==2:
        a += 1
    else:
        a *= 0
if a:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
s_s = list(set(s))

if len(s_s) >= 3:
  print("No")
else:
  if s.count(s_s[0]) == s.count(s_s[1]):
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
S = input()

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

Submission status: Runtime Error

Solution code:
M=input()


if M.count(M[0])+ M.count(M[1])+ M.count(M[2])+ M.count(M[3])=8:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
S = list(input())
c1 = (len(set(S)) == 2)
m = list(set(S))[0]
n = list(set(S))[1]
m_c, n_c = 0, 0
c2 = False
if c1:
    for i in range(len(S)):
        if S[i] == m:
            m_c += 1
        else:
            n_c += 1
    if m_c == n_c:
        c2 = True

if c1 and c2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
s=input()

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

l=list(dict.keys())

if dict[l[0]]==dict[l[1]] and len(l)==2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
s_s = listed(set(s))

if len(s_s) >= 3:
  print("No")
else:
  if s.count(s_s[0]) == s.count(s_s[1]):
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
S = list(str(input()))
import collections
c = collections.Counter(S)
t = c.most_common()
if (t[0][1] == t[1][1] == 2):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
text = list(input())

list = {}

for t in text:
  if text.count(t) != 2:
    continue
  if t in list:
    list[t] += 1
  else:
    list[t] == 1
    
if len(list) == 2:
  return Yes
else:
  return No

Submission status: Runtime Error

Solution code:
s = input()

if len(list(set(s))) >= 3:
  print("No")
else:
  s_s = list(set(s))
  if s.count(s_s[0]) == s.count(s_s[1]):
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
s=input()

dict={}
for i in s:
    dict[i]=0
for i in s:
    dict[i]+=1

l=list(dict.keys())

if dict[l[0]]==dict[l[1]] and len(l)==2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s=input()

dict={}
for i in s:
    dict[i]=0
for i in s:
    dict[i]+=1

l=list(dict.keys())

if dict[l[0]]==dict[l[1]] and len(l)==2:
    print("yes")
else:
    print("no")

Submission status: Runtime Error

Solution code:
def main():
    s = list(input())
    s_uniq = list(set(s))

    a = s.count(s_uniq[0])
    b = s.count(s_uniq[1])

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

main()

Submission status: Runtime Error

Solution code:
s = input()

if len(list(set(s))) >= 3:
  print("No")
else:
  s = list(set(s))
  if s.count(s[0]) == s.count(s[1]):
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
S = input()

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

Submission status: Runtime Error

Solution code:
# cook your dish here
s = input()
c = 0 
if(s[0]==s[1] and s[2]==s[3]):
    c=1 
elif(s[0]==s[2] and s[1]==a[3]):
    c=1 
elif(s[0]==s[3] and s[1]==s[2]):
    c=1 
if(c==1):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
n = int(input())
ns = map(input().split(), int)

c = 0
for i in range(1, n):
  if sorted([ns[i-1], ns[i], ns[i+1]])[2] == ns[i]:
    c += 1
    
print(c)

Submission status: Runtime Error

Solution code:
S = sorted(input())
return S[0] == S[1] and S[2] == S[3] and S[1] != S[2]

Submission status: Runtime Error

Solution code:
def code_for_A(S, test=None):

    if not test:
        S = input()

    condition = 0
    for s in S:
        condition += S.count(s) != 2

    if condition:
        answer = 'No'
    else:
        answer = 'Yes'

    print(answer)

code_for_A(,1)

Submission status: Runtime Error

Solution code:
S = input()

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

Submission status: Runtime Error

Solution code:
s = input()

if len(list(set(s))) >= 3:
  print("No")
else:
  s = list(set(s))
  if count(s[0]) == count(s[1]):
    print("Yes")
  else:
    print("No")

Submission status: Runtime Error

Solution code:
# -*- coding: utf-8 -*-
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[4] 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")

Submission status: Runtime Error

Solution code:
S = input()
count1=1
count2=0
for i in range(4):
  if S[i] == S[0] :
    count1++
  else:
    count2++
    
if count2==2 and count1 ==2:
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
s = input()

for i in range(len(S)):
  if len(list(set(s))) >= 3:
    print("No")
  else:
    s = list(set(s))
    if count(s[0]) == count(s[1]):
      print("Yes")
   	else:
      print("No")

Submission status: Runtime Error

Solution code:
S = list(map(int, input()))

t = 0
for i in range(len(S)-1):
  if S[i] == S[i+1]:
    t = 1
    break  
  else:
    pass

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

Submission status: Runtime Error

Solution code:
text = input()
list = [e for e in set(text)]

if set(text) == 2:
  for e in list:
    if text.count(e) != 2:
      print('No')
      sys.exit()
else:
  print('No')
  sys.exit()
  
print('Yes')

Submission status: Runtime Error

Solution code:
s = str(input())

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s = input()

for i in range(len(S)):
  if len(set(s)) > 3:
    print("No")
  else:
    s = list(set(s))
    if count(s[0]) == count(s[1]):
      print("Yes")
   	else:
      print("No")

Submission status: Runtime Error

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


if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
from collections import Counter
S = input()
c = Counter(S)
for v in c.values():
  if v != 2: return False
return True

Submission status: Runtime Error

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

if s.count("S")==2:
    s_rm = s.remove("S")
    if s_rm[0] == s_rm[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Runtime Error

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

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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[1]==S[2]):
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from collections import Counter
S = input()
    c = Counter(S)
    for v in c.values():
        if v != 2: return False
    return True

Submission status: Runtime Error

Solution code:
word = input()
char_list = []

count1 = 0
count2 = 0
for c in word:
    if c not in char_list:
        char_list.append(c)

char1 = char_list[0]
char2 = char_list[1]


for c in word:
    if c == char1:
        count1 += 1
    elif c == char2:
        count2 += 1
        
if len(char_list) == 2 and count1 == 2 and count2 == 2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
l = list(s)
c1 = s.count(l[0])
c2 = s.count(l[1])
c3 = s.count(l[2])
c4 = s.count(l[3])
if c1 == 2 and c2 == 2 and c3 == 2 and c4 == 2:
  print('Yes')
  else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
s=input()
sl=list(s)
p=s[0]
ans=0
ans2=0
for i in range(4):
    if s[i]==p:
        ans+=1
    else:
        q=s[i]

for i in range(4):
    if s[i]==q:
        ans2+=1

if ans==2 and ans2==2:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
word = input()
char_list = []

count1 = 0
count2 = 0
for c in word:
    if c not in char_list:
        char_list.append(c)

char1 = char_list[0]
char2 = char_list[1]


for c in word:
    if c == char1:
        count1 += 1
    elif c == char2:
        count2 += 1
        
if len(char_list) != 2 or count1 != 2 or count2 != 2:
    print("No")
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
s = input()
l = len(s)
set_s = set(s)

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
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():
    P=list(input())
    ct_a=0
    ct_s=0
    for x in P:
        if x=='A' :
            ct_a+=1
        elif x=='S':
            ct_s+=1
    if ct_a==2 an ct_s==2:
        print('Yes')
    else:
        print('No')




if  __name__=='__main__':
    main()

Submission status: Runtime Error

Solution code:
import collections as c
s=input()
a=c.Counter(s)
if a.value()==[2,2]:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
S = input()

print('Yes' if all(S.count(s) == 2 for s in input()) else 'No')

Submission status: Runtime Error

Solution code:
a,b,c,d = input().split()

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()]

ss = list(set(s))

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

Submission status: Runtime Error

Solution code:
s = list(input())
s_ = len(s_)

a_ = len(set(s_))

if s_ > s_:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
if __name__ == "__main__":
    S = Counter(input())
    if len(S) == 2 and all(v == 2 for v in S.values()):
        print("Yes")
    else:
        print("No")

Submission status: Runtime Error

Solution code:
from collections import Counter
ct = Counter(input())
a1, a2 = ct.most_common(2)
if a1[1] == 2 and a2[1] == 2:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)
#define all(x) x.begin(),x.end()
struct revran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { --i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr revran(const i64 e) noexcept: b(0), e(e) {}
  constexpr revran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(e - 1); }
  constexpr iter end() const noexcept { return iter(b - 1); }
};

struct ran {
  const i64 b, e;
  struct iter {
    i64 i;
    constexpr iter(const i64 i) noexcept: i(i) {}
    void operator++() noexcept { ++i; }
    constexpr i64 operator*() const noexcept { return i; }
    constexpr bool operator!=(const iter x) const noexcept { return i != x.i; }
  };
  constexpr ran(const i64 e) noexcept: b(0), e(e) {}
  constexpr ran(const i64 b, const i64 e) noexcept: b(b), e(e) {}
  constexpr iter begin() const noexcept { return iter(b); }
  constexpr iter end() const noexcept { return iter(e); }
  constexpr revran rev() const noexcept { return revran(b, e); }
};

constexpr ran rin(const i64 e) noexcept { return ran(1, e + 1); }
constexpr ran rin(const i64 b, const i64 e) noexcept { return ran(b, e + 1); }

int main() {
  string s;
  cin >> s;
  sort(all(s));
  if(s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}