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

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

Submission status: Accepted

Solution code:
s = sorted(list(input()))

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

Submission status: Accepted

Solution code:
S = raw_input()
arr = []

for i in range(4):
     if S[i] not in arr:
         arr.append(S[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if S[i] == arr[0]:
            a = a + 1
        elif S[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print"Yes"
    else:
        print "No"

Submission status: Accepted

Solution code:
s= raw_input()
arr=[]
for i in range(4):
    if s[i] not in arr:
        arr.append(s[i])
if len(arr)!=2:
    print "No"
else:
    a=0
    b=0
    for i in range(4):
        if s[i]== arr[0]:
            a = a+1
        elif s[i]==arr[1]:
            b=b+1
    if a == 2 and b==2:
        print "Yes"
    else:
        print "No"

Submission status: Accepted

Solution code:
# coding : utf-8
# Author:Code
S = raw_input()
arr = []
for i in range(4):
    if S[i] not in arr:
        arr.append(S[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if S[i] == arr[0]:
            a = a + 1
        elif S[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print "Yes"
    else:
        print "No"

Submission status: Accepted

Solution code:
# coding: utf-8 
#Author:Code
s = raw_input()
arr = []
for i in range(4):
    if s[i] not in arr:
        arr.append(s[i])

if len(arr) != 2:
    print "No"
else:
    a = 0
    b = 0
    for i in range(4):
        if s[i] == arr[0]:
            a = a + 1
        elif s[i] == arr[1]:
            b = b + 1
    if a == 2 and b == 2:
        print "Yes"
    else:
        print "No"

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#import math.sqrt as sqrt

#S = list(map(int, input().split()))
#B = list(map(int, input().split()))

S = list(input())
count = [0, 0, 0]

for i in range(len(S)-1):
    for j in range(i+1, len(S)):
        if S[i] == S[j]:
            count[i] += 1

       # print(S[j]+" "+S[i])

#print(count)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import math
import datetime

# 入力
#N = int(input())
#S = str(input())
#H, W = map(int, input().split())
S = str(input())

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

Submission status: Accepted

Solution code:
set = {i for i in input()}

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

Submission status: Accepted

Solution code:
s = sorted(list(input()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

dic = {}

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

flag = [dic[i] == 2 for i in dic.keys()]

print("Yes" if all(flag) else "No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
flag = 0

if s[0] == s[1] and s[2] == s[3] and s[0] != s[2] :
    flag = 1

elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1] :
    flag = 1


elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1] :
    flag = 1


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

Submission status: Accepted

Solution code:

S = raw_input()

if len(S) != 4:
    print "No"
else:
    Dict = {}
    for s in S:
        if s in Dict.keys():
            Dict[s] += 1
        else:
            Dict[s] = 1
    if all([i==2 for i in Dict.values()]):
        print "Yes"
    else:
        print "No"

Submission status: Accepted

Solution code:
S=input()
ss=set(S)
if len(ss)!=2:
  print('No')
else:
  cnt=0
  for i in S:
    if i == S[0]:
      cnt+=1
  if len(S)==cnt*2:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = dict()
b = list(input())
s1 = "random"
s2 = "random"
x = 0
y = 0
for i in b:
    if i == s1:
        x += 1
    elif i == s2:
        y += 1
    else:
        if s1 == "random":
            s1 = i
            x += 1
        elif s2 == "random":
            s2 = i
            y += 1
if x == 2 and y == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
sums=0
for i in range(4):
  if s[i]==s[0]:sums+=1
print('Yes' if sums==2 and len(set(s))==2 else 'No')

Submission status: Accepted

Solution code:
s = list(input())
c = 0

if s[0]==s[1]:
    c+=1
if s[0]==s[2]:
    c+=1
if s[0]==s[3]:
    c+=1
if s[1]==s[2]:
    c+=1
if s[1]==s[3]:
    c+=1
if s[2]==s[3]:
    c+=1

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

Submission status: Accepted

Solution code:
letter = input()
word = []
for i in range(len(letter)):
  word.append(letter[i])
word.sort()
if (word[0] == word[1]) and (word[2] == word[3]) and (word[0] != word[2]):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()
f = 1 
if s[0] == s[1] == s[2] == s[3]:
        f = 1 
elif (s[0] == s[1] and s[2] == s[3]) or (s[:2] == s[2:] or s[1::-1] == s[2:]):
        f = 0 
print('YNeos'[f::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import heapq
import sys
from collections import Counter
import numpy as np

#N,K=map(int, input[0].split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
#x=list(map(int, input[1].split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
#s = [input() for i in range(3)]

s=input()

S=sorted(s)

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

Submission status: Accepted

Solution code:
s = input()
hash = {}
for char in s:
  # print(char)
  if char in hash.keys():
    hash[char] += 1
  else:
    hash[char] = 1

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = list(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[1] == S[2] and S[0] != S[1]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = str(input())
S = sorted(S)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

def main():
    S = input()
    num = {}
    for i in S:
        if i not in num:
            num[i] = 1
        else:
            num[i] += 1

    if(len(num) == 2):
        for i in num.keys():
            if num[i] != 2:
                print("No")
                return 0
            print("Yes")
            return
    else:
        print("No")

main()

Submission status: Accepted

Solution code:
import collections
S = input()
c = collections.Counter(list(S))
print("Yes" if len(c) == 2 else "No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
ss = set(S)
ss_list = list(ss)

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

Submission status: Accepted

Solution code:
S = list(input())
S.sort()
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
dic={}
for i in range(len(a)):
  if a[i] in dic:
    dic[a[i]]+=1
  else:
    dic[a[i]]=1
if len(dic)==2:
  my=True
  for i in dic.values():
    if i!=2:
      my=False
  if my:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
S2 = list(set(S))

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

Submission status: Accepted

Solution code:
s = input()
s_sort = ''.join(sorted(s))
s1 = s[0]
s1cnt = s_sort.count(s1)
if s1cnt == 2:
    s2 = s[2]
    s2cnt = s_sort.count(s2)
    if s2cnt == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
ans = 'Yes'
for i in S:
    if S.count(i) != 2:
        ans = 'No'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = sorted(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
def print_ans(S):
    """Test Case
    >>> print_ans("ASSA")
    Yes
    >>> print_ans("STOP")
    No
    >>> print_ans("FFEE")
    Yes
    """
    ans_arr = []
    ans_arr.append(S[0])


    for s_ch in S[1:]:
        for a_ch in ans_arr:
            if s_ch != a_ch:
                ans_arr.append(s_ch)
    if len(set(ans_arr)) == 2:
        print("Yes")
    else:
        print("No")



if __name__ == '__main__':
    S = input().rstrip()
    print_ans(S)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

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

Submission status: Accepted

Solution code:
# 2019-11-15 00:35:39(JST)
import sys
import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    s = sys.stdin.readline().rstrip()
    for v in collections.Counter(s).values():
        if v == 2:
            continue
        else:
            ans = 'No'
            break
    else:
        ans = 'Yes'

    print(ans)

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()

count1 = s.count(s[0])
count2 = s.count(s[1])
count3 = s.count(s[2])
count4 = s.count(s[3])

if count1 == 2 and count2 == 2 and count3 == 2 and count4 == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
u = set()
for let in s:
  u.add(let)
count=0
for let in s:
  if s[0] == let:
    count += 1
if count ==2 and len(u)==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()

cnt_dict = Counter(S)

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

Submission status: Accepted

Solution code:
S = input()

sum_1 = 0
sum_2 = 0
sum_3 = 0
sum_4 = 0

for i in range(4):
    if S[0] == S[i]:
        sum_1 += 1
    if S[1] == S[i]:
        sum_2 += 1
    if S[2] == S[i]:
        sum_3 += 1
    if S[3] == S[i]:
        sum_4 += 1
    
if sum_1 == sum_2 == sum_3 == sum_4 == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input().strip()

a = ""
a_cnt = 0
b = ""
b_cnt = 0
flg = True

for e in s:
    if (a == ""):
        a = e
        a_cnt += 1
    elif (a == e):
        a_cnt += 1
    elif (b == ""):
        b = e
        b_cnt += 1
    elif (b == e):
        b_cnt += 1

if (a_cnt == 2 and b_cnt == 2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
ans = "No"
if len(list(set(s))) == 2:
  ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
#%%
import sys
def input():
    return sys.stdin.readline().rstrip()

def main():
    S = input()

    d = {}
    for c in S:
        if c not in d:
            if len(d) >= 2:
                print('No')
                return
            else:
                d[c] = 1
        else:
            if d[c] > 2:
                print('No')
                return
            else:
                d[c] = d[c] + 1
    print('Yes')




# %%
if __name__ == '__main__':
    main()

# %%
# from atcoder_test import doTest
# doTest("abc132","a",main)

Submission status: Accepted

Solution code:
def solve():
    s = input()
    s_set = set(s)
    s_set_l = list(s_set)
    if len(s_set) == 2:
        if s.count(s_set_l[0]) == 2 and s.count(s_set_l[1]) == 2:
            print('Yes')
            exit()
    print('No')


if __name__ == '__main__':
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
import collections
s=dict(collections.Counter(s))
if len(s)==2:
  flag=True
  for k in s.values():
    if k!=2:
      flag=False
  if flag:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
import re

s = sorted(input())
s = "".join(s)

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

Submission status: Accepted

Solution code:
s = input()

s_list = list(set(s))
if len(s_list) != 2:
    print("No")
else:
    flag = True
    for origin  in s_list:
        if s.count(origin) != 2:
            flag = False
    if flag:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
import collections
S = input()
c =  collections.Counter(S)

if len(c.keys())==2 and list(c.values())==[2,2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
count = 0
for i in s:
  for j in s:
    if i==j:
      count+=1
if count==8:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = str(input())

d = {}
for i in s:
    if i not in d:
        d[i] = 1
    else:
        d[i]+=1
    
if len(d) == 2 and d[s[0]] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
w=input()
l=[]
for i in range(4):
  if w[i] in l:
    pass
  else:
    l.append(w[i])
if len(l)!=2:
  print("No")
else:
  count=0
  for i in range(4):
    if w[i]==l[0]:
      count+=1
  if count==2:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

clear = True
l = list()
for n in range(4):
    if S[n] not in S[n+1:]:
        l.append(S[n])
    if len(l) > 2:
        clear = False
for x in l:
    if [y for y in S].count(x) > 2:
        clear = False
if clear:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=str(input())
a = S[0:1]
b = S[1:2]
c = S[2:3]
d = S[3:4]
if a==b and b==c and c==d and a==d:
    print('No')
elif a==b:
    if c==d:
        print('Yes')
    else:
        print('No')
elif a==c:
    if b==d:
        print('Yes')
    else:
        print('No')    
elif a==d:
    if b==c:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
S=str(input())
a = S[0:1]
b = S[1:2]
c = S[2:3]
d = S[3:4]
if a==b and b==c and c==d and a==d:
    print('No')
elif a==b:
    if c==d:
        print('Yes')
    else:
        print('No')
elif a==c:
    if b==d:
        print('Yes')
    else:
        print('No')    
elif a==d:
    if b==c:
        print('Yes')
    else:
        print('No')
elif a==b and b==c and c==d and a==d:
    print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
ls_s = [i for i in input()]
ls_s1 = sorted(ls_s)

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    from collections import Counter
    C=Counter(input())
    if(len(C)!=2):
        print("No")
        return
    for k,v in C.items():
        if(v!=2):
            print("No")
            return
    print("Yes")
resolve()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

import sys
s = list(input())

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

Submission status: Accepted

Solution code:
import unittest


class TestA(unittest.TestCase):
    def test_1(self):
        self.assertEqual(think('ASSA'), 'Yes')

    def test_2(self):
        self.assertEqual(think('STOP'), 'No')

    def test_3(self):
        self.assertEqual(think('FFEE'), 'Yes')

    def test_4(self):
        self.assertEqual(think('FREE'), 'No')


def solve():
    s = read()
    result = think(s)
    write(result)


def read():
    length_of_string = 4
    return read_line(n=length_of_string)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(s):
    for i in range(len(s)):
        if s.count(s[i]) == 2:
            continue
        else:
            return 'No'
    return 'Yes'


def write(result):
    print(result)


if __name__ == '__main__':
    # unittest.main()
    solve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
a = list( input() ) 
dic = collections.Counter(a)
k = 0

for i in dic.values():
    if not i == 2:
        k = 1
if k == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# ABC 132: A – Fifty-Fifty
s = input()
c = []

for letter in s:
    if letter not in c:
        c.append(letter)

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
S = input()
dic = {}
for i in range(4):
    if S[i] not in dic.keys():
        dic[S[i]] = 1
    else:
        dic[S[i]] += 1

ok = 0


for k in dic.keys():
    if(dic[k] != 2):
        ok = 1

if(len(dic.keys()) == 2 and ok==0):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
tmp_s = list(set(s))
s = sorted(s)
if len(tmp_s) == 2 and s[1] != s[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
ltr = []
cnt = []
for a in s:
    if not a in ltr:
        ltr.append(a)
        cnt.append(0)
    else:
        cnt[ltr.index(a)] += 1
print("Yes" if cnt == [1, 1] else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections


S = input()
c = collections.Counter(S)
cm = c.most_common()

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

Submission status: Accepted

Solution code:
line = input()
li = []
for s in line:
  if s not in li:
    li.append(s)
if len(li) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import itertools
import sys
input = sys.stdin.readline

s = list(input().rstrip('\n'))
s.sort()
gr = itertools.groupby(s)
ks = []
gs = []

for k, g in gr:
    ks.append(k)
    gs.append(len(list(g)))

if len(ks) == 2 and gs.count(2) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = map(str , input())
list_S = list(S)

list_S.sort()

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

Submission status: Accepted

Solution code:
S = map(str , input())
list_S = list(S)

list_S.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
sls = list(input())
sdic = {}
for i in range(len(sls)):
  if sls[i] in sdic:
  	sdic[sls[i]] += 1
  else:
    sdic[sls[i]] = 1

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

Submission status: Accepted

Solution code:
a = input()

b = [0]*4

for i in range(4):
	b[i] = a.count(a[i])

c = 'No'

if b[0]==2 and b[1]==2 and b[2]==2 and b[3]==2:
	c = 'Yes'
	
print(c)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())
ans='Yes'
if len(set(S))!=2:
    ans='No'
if S.count(S[0])!=2:
    ans='No'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
flag = 0

if s[0] == s[1] and s[2] == s[3]:
    if s[1] != s[2]:
        flag = 1
elif s[0] == s[2] and s[1] == s[3]:
    if s[1] != s[2]:
        flag = 1
elif s[0] == s[3] and s[1] == s[2]:
    if s[0] != s[1]:
        flag = 1

if flag == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = 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")

Submission status: Accepted

Solution code:
s=input()
li=[]
for i in range(0,len(s)):
  li.append(s[i])
  
if len(set(li))==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys
S = input()

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

Submission status: Accepted

Solution code:
s = input()
a = s[0]
b = s[1]
c = s[2]
d = s[3]

cnt = 0

if a==b:
    cnt +=1
if a==c:
    cnt+=1
if a==d:
    cnt+=1

if b==c:
    cnt += 1
if b==d:
    cnt+=1
if c==d:
    cnt+=1

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

Submission status: Accepted

Solution code:
s = list(input());
ans = 0;

if s[0] == s[1] or s[0] == s[2] or s[0] == s[3]: ans += 1;
if s[1] == s[2] or s[1] == s[3]: ans += 1;
if s[2] == s[3]: ans += 1;
if ans == 2: print("Yes");
else: print("No");

Submission status: Accepted

Solution code:
#!/usr/bin/env python3

def main():
    S = input()
    for i in range(4):
        if S.count(S[i])!=2:
            print('No')
            return
    print('Yes')

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=str(input())
sort_S=sorted(S)

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
S2 = sorted(S)

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

Submission status: Accepted

Solution code:
s = input()
flg = True
for i in s:
  cnt = 0
  for j in s:
    if i == j:
      cnt += 1
  if cnt != 2:
    flg = False
if flg:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import collections

s = list(input())
c = collections.Counter(s)
ans = 'No'

if len(c) == 2:
	n = list(c.values())
	if n[0] == n[1]:
		ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
S = input()

if len(set(S)) == 2:
    if S[0] == S[1] or S[0] == S[2] or S[0] == S[3]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
s = sorted(S)

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
ans = sorted(s)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
A - Fifty-Fifty
https://atcoder.jp/contests/abc132/tasks/abc132_a

"""
import sys


def solve(s):
    return 'Yes' if all([s.count(ch) == 2 for ch in s]) else 'No'


def main(args):
    s = input()
    ans = solve(s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])