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:
str = input() 

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())

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

Submission status: Accepted

Solution code:
s=input()
d={}
for ss in s:
  d[ss]=0
for ss in s:
  d[ss]+=1
if len(d.keys())==2:
  f=True
  for k in d:
    if d[k]!=2:
      f=False
  if f :
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
    s = list(raw_input())
    flag = False
    if s[0] == s[1] and s[2] == s[3]:
        if s[0] != s[2]:
            flag = True
    elif s[0] == s[3] and s[1] == s[2]:
        if s[0] != s[1]:
            flag = True
    elif s[0] == s[2] and s[1] == s[3]:
        if s[0] != s[1]:
            flag = True
    if flag == True:
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(100000)

def intinput(): return map(int,sys.stdin.readline().split())

x=input()
for i in range(len(x)):
    if x.count(x[i])!=2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()

li = [0,0,0,0]
for i in range(len(s)):
  for j in s:
    if s[i] == j:
      li[i] += 1
      
if li == [2,2,2,2]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
 
s = list(input())
 
for i in range(2):
    letter = s[0]
    del s[0]
    if s.count(letter) == 1:
        del s[s.index(letter)]
    else:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input()

l = list(S)

s = set(l)

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

Submission status: Accepted

Solution code:
s = input()
from collections import defaultdict
dic = defaultdict(lambda : 0)
for i in s:
    dic[i] += 1
if len(dic.keys()) == 2:
    flag = 0
    for key in dic.keys():
        if dic[key] != 2:
            flag = 1
else:
    flag = 1
if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()

from collections import Counter
if len(s) != 4: print('No'); exit()
a = Counter(s)
if len(a) != 2: print('No'); exit()
for key in a:
    if a[key] != 2: print('No'); exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
sti = input()
x = set()
for i in sti:
    x.add(i)
if len(x) == 2 and sti.count(sti[0]) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#A

s = input()

x = {}
for i in s:
    if i in x:
        x[i] += 1
    else:
        x[i] = 1
        
if len(x) == 2:
    a, b = x
    if x[a] == 2 and x[b] == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections
S = list(input())
print('Yes' if len(collections.Counter(S).keys())==2 and list(collections.Counter(S).values())[0]==2 else 'No')

Submission status: Accepted

Solution code:
S = input()

a = S[0]
b = None
acount = 0

for i in range(4):
    if a == S[i]:
        acount += 1
    else:
        b = S[i]
        
bcount = 0
for i in range(4):
    if b == S[i]:
        bcount += 1
if acount == 2 and bcount ==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=input()
d={}
for c in s:
  if c not in d: d[c]=1
  else: d[c]+=1
print('Yes') if len(d.keys())==2 and [_ for _ in d.values()][0]==2 else print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:

A=input()

A=sorted(A)

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:
s = input()
d = {}

for i in s:
    if not d.get(i):
        d[i] = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def func():
    input_line = list(str(input('')))
    flag = 0
    for i in range(len(input_line)):
        for j in range(i+1,len(input_line)):
            if input_line[i] == input_line[j]:
                flag += 1
    if flag == 2:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    func()

Submission status: Accepted

Solution code:
def check(s):
    try:
        if s.count(s[0]) == 4:
            return False

        s1 = s[0]
        s.remove(s1)
        s.remove(s1)

        s1 = s[0]
        s.remove(s1)
        s.remove(s1)
    except ValueError:
        return False
    else:
        return True

s = list(input())
if check(s):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def mozi(S):
    s = list(S)
    s2 = list(set(s))
    if len(s2) != 2:
        ans = 'No'
        return ans
    else:
        p = 0
        q = 0
        for item in s:
            if item == s2[0]:
                p+=1
            if item == s2[1]:
                q+=1
        if p == 2 and q == 2:
            ans = 'Yes'
            return ans
        else:
            ans = 'No'
            return ans

#args = sys.argv
#S = args[0]
S = input()
print(mozi(S))

Submission status: Accepted

Solution code:
from collections import Counter
SC = Counter(input().strip())
if len(SC) == 2 and max(SC.values()) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def solve(string):
    for _s in string:
        if string.count(_s) != 2:
            return "No"
    return "Yes"


if __name__ == '__main__':
    print(solve(input()))

Submission status: Accepted

Solution code:
S = input()
Slist=[]
for i in range(4):
    Slist.append(S[i])
Slist.sort()

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

Submission status: Accepted

Solution code:
S = input()


list_S=list(S)

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
line = input()
charKind = [line[0]]
for c in line:
  if charKind[len(charKind)-1] != c and not c in charKind:
    charKind.append(c)
#print(charKind)
if len(charKind) > 2:
    print("No")
    quit()
charNum = [0 for i in range(len(charKind))]
for idx,c in enumerate(charKind):
    for cc in line:
        if cc == c:
            charNum[idx] += 1
if charNum[0] == 2 and charNum[1] == 2:
    print("Yes")
else:
    print("No")
quit()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
s = input()

for k in s:
  d[k] += 1
#print(d)
#print(len(d))
f = False
for v in d.values():
  if v == 2:
    f = True
    break
print('Yes' if len(d)==2 and f==True else 'No')

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input().rstrip()

char_dict = defaultdict(int)
for char in S:
    char_dict[char] += 1

kind = len(char_dict.keys())
val_set = set(char_dict.values())

if kind == 2 and val_set == {2}:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections

letters=input()
letter=[]
for i in range(len(letters)):
  letter.append(letters[i])
counter=collections.Counter(letter)

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

Submission status: Accepted

Solution code:
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[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:
stc = input()

chars = {}

for char in stc:
    if char in chars:
        chars[char] += 1
    else:
        chars[char] = 1

if len(chars) == 2:
    for num in chars.values():
        if num != 2:
            print('No')
            exit()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
a = Counter(input())
print('Yes' if len(a) == 2 else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

s = list(ns())
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())
Ss = set(S)
count2 = 0
for alp in Ss:
    if S.count(alp) == 2:
        count2 += 1
if count2 == len(Ss):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
a = list(str(input()))
b = set(a)

for i in b:
    c = a.count(i)
    if c != 2:
        print('No')
        sys.exit()

print('Yes')

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()
k = set(s)
r = []
for i in k:
  r.append(s.count(i))

if len(k) == 2 and max(r) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
A=list(input())
if A.count(A[0])==2:
  if A[1]==A[2] or A[2]==A[3] or A[3]==A[1]:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
S = input()
cnt = {}
for c in S:
    if c in cnt:
        cnt[c] += 1
    else:
        cnt[c] = 1

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

Submission status: Accepted

Solution code:
import collections
S = input()
c = collections.Counter(list(S))
kind_flag = len(c) == 2
if kind_flag:
    ll = list(c.values())
    flag = ll[0] == ll[1] == 2
    if flag:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
from sys import exit
s=input()
for l in s:
    if s.count(l)!=2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
x = input()
v ={ val for val in x }
if len(v) == 2:
    print("Yes")
else :
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input() # sを取得し、strに値を入れる
index = -1
cnt=0
for char in s:
    target = char
    
    while True:
        index = s.find(target, index + 1)
        if index == -1:
            break
        #print('start=%d' % index)
        cnt=cnt+1

if(cnt==8):
    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:
# -*- coding: utf-8 -*-

a = list(input())
dic = {}
for x in a:
    dic.setdefault(x, 0)
    dic[x] += 1
if (len(dic) == 2):
    if(dic[a[0]]==2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input()
 
import collections
c = collections.Counter(S).most_common()
if len(c) == 2 and c[0][1] == c[1][1]:
  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 not (s[1] == s[2]):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = list(input())
count = int(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:
import collections

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
data = list(input())

dic = {}

for i in data:
    if i in dic.keys():
        dic[i] += 1
    else:
        dic[i] = 1

if len(dic.keys()) == 2:
    if dic[data[0]] == 2:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
ans = []
count_ = []
for i in range(4):
	if S[i] not in ans:
		ans.append(S[i])
		count_.append(1)
	else:
		count_[ans.index(S[i])] += 1

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

Submission status: Accepted

Solution code:
import collections

s = input()

c = collections.Counter(list(s))

res = "Yes" if all([v==2  for v in c.values()]) and len(c)==2 else "No"

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l=sorted(list(input()))
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:
print("YNeos"[len(set(input())) != 2::2])

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 = 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 = sorted(input(),key=str)
print(["No", "Yes"][s.count(s[0]) == 2 and s[2] == s[3]])

Submission status: Accepted

Solution code:
def solve():
  s = input()
  istwo = True
  array = [s[0],s[1],s[2],s[3]]
  array.sort()
  if array[0] != array[1]:
    istwo = False
  if array[1] == array[2]:
    istwo = False
  if array[2] != array[3]:
    istwo = False
  if istwo:
    print("Yes")
  else:
    print("No")
  
  
solve()

Submission status: Accepted

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

Submission status: Accepted

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

s = input()

print("No" if False in [2 == s.count(i) for i in s] else "Yes")

Submission status: Accepted

Solution code:
s = sorted(input(),key=str)
print(["No", "Yes"][s.count(s[0]) == 2 and s[2] == s[3]])

Submission status: Accepted

Solution code:
s=input()
kind=[]
kind.append([s[0],1]) #１つ目は確実に新種類
for i in range(1,4): #残りの３つを既存の種類と比べる。
    l=len(kind)
    a=0
    for j in range(l):
        if s[i] == kind[j][0]:
            a=1
            match=j
            break
    if a==0: #新種類
        kind.append([s[i],1])
    else:
        kind[match][1]+=1
        
    
if kind[0][1]==2 and kind[1][1]==2:
    print("Yes")
else:
    print("No")
#print(kind)

Submission status: Accepted

Solution code:
def resolve():
    s=input()
    l=list(set(list(s)))
    if len(l)==2 and s.count(l[0])==2 and s.count(l[1])==2:
        print('Yes')
    else:
        print('No')
resolve()

Submission status: Accepted

Solution code:
S = input()
ans = True
for s in S:
  ans = ans * (S.count(s) == 2)
if ans:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()
print(['No', 'Yes'][all([S.count(s) == 2 for s in S])])

Submission status: Accepted

Solution code:
s = input()

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

for k, v in d.items():
    if v != 2:
        print('No')
        exit()

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

Submission status: Accepted

Solution code:
S = input()
l = [ c for c in 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()
l={x for x in s}
if s.count(l.pop())==2 and s.count(l.pop())==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s=input()
a=s[0]
if s.count(a)==2:
    s2=s.strip(a)
    b=s2[0]
    if s2.count(b)==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
n = 4
i = 0
d = {}
while(i<n):
    if s[i] in d.keys():
        d[s[i]] +=1
    else:
        d.setdefault(s[i], 1)
    i += 1
print("Yes" if len(d)==2 and max(d.values())==2 else "No")

Submission status: Accepted

Solution code:
S=input()
print("Yes" if all(S.count(S[i])==2 for i in range (4)) 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=list(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())
S.sort()
if len(set(S)) == 2 and S[0] == S[1] and S[2] == S[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
  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')
    
if __name__ == "__main__":
  main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

word_count = {}
for i in range(len(S)):
    if S[i] in word_count:
        word_count[S[i]] += 1
    else:
        word_count[S[i]] = 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
hoge=input()
ans=0
for i in range(4):
  ans+=hoge.count(hoge[i])
if(ans==8):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s=list(input())
s.sort()
print("YNeos"[not s[0]==s[1]!=s[2]==s[3]::2])

Submission status: Accepted

Solution code:
#abc132a

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
appear = list(S)

d = defaultdict(int)

for i in appear:
    d[i] += 1

a = list(d.values())

if len(d.items()) == 2:
    for i in a:
        if i != 2:
            print("No")
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
S = sorted(S,key=str)
if S.count(S[0]) == 2 and S[2] == S[3]:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

Solution code:
from collections import Counter
word = input()

counter = Counter(word)
status = "Yes"
if len(counter) !=  2:
  status = "No"
for c in counter.values():
  if c != 2:
    status = "No"
print(status)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
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")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
d=dict()

for s in S:
    d[s]=d.get(s,0)+1

boolean=True
if len(d.values())==2:
    for i in d.values():
        if i!=2:
            boolean=False
            break
        else:
            continue
else:
    boolean=False

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

Submission status: Accepted

Solution code:
s=input()
s=s.replace(s[0],'')
print('Yes' if len(s)==2 and s[0]==s[1] else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
char=list(input())
d={}
for c in char:
	if c not in d:
		d[c] = 0
	d[c] += 1
if 2 in d.values() and len(d)==2:
	print('Yes')
else:
	print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
for i in s:
  if s.count(i)!=2:
    print("No")
    break
else:
  print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

for c in set(S):
	if 2 != S.count(c):
		print("No")
		exit()
print("Yes")

Submission status: Accepted

Solution code:
S = input()

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

for c in set(S):
	if 2 != S.count(c):
		print("No")
		exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

arr = list(input())
c = Counter(arr)
print("Yes" if c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2 else "No")

Submission status: Accepted

Solution code:
S = list(input())

L = sorted(S)
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:
import collections
s=input()
slist=[c for c in s]
col = collections.Counter(slist)

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

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
c = Counter()
for s_i in S:
  c[s_i] += 1
for k,v in c.items():
  if v!=2:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
def f_f(str):
    for s in str:
        if str.count(s) != 2:
            return False
    return True
 
S = input()
if f_f(S):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x = input()
 
def Combination(x):
  if x[0] == x[1] and x[2] == x[3] and x[0] != x[2]:
      return "Yes"
  elif x[0] == x[2] and x[1] == x[3] and x[0] != x[1]:
      return "Yes"
  elif x[0] == x[3] and x[1] == x[2] and x[0] != x[2]:
      return "Yes"
  else:
    return "No"
print(Combination(x))

Submission status: Accepted

Solution code:
S = list(input())
S_unique = list(set(S))
ans = True
if len(S_unique) != 2:
    ans = False
elif S.count(S_unique[0]) != 2:
    ans = False
if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def fifty_fifty(str):
    for s in S:
        if S.count(s) != 2:
            return False
    return True


S = input()
if fifty_fifty(S):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
# S = "JSKK"
r = "No"
S_unique = list(set(S))
if len(S_unique) == 2:
    T = S[1] + S[2] + S[3]
    T_unique = list(set(T))
    if len(T_unique) == 2:
        T = S[0] + S[2] + S[3]
        T_unique = list(set(T))
        if len(T_unique) == 2:
            T = S[0] + S[1] + S[3]
            T_unique = list(set(T))
            if len(T_unique) == 2:
                T = S[0] + S[1] + S[2]
                T_unique = list(set(T))
                if len(T_unique) == 2:
                    r = "Yes"
print(r)

Submission status: Accepted

Solution code:
inp = list(input())
#print(inp)
inin = list(set(inp))

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

Submission status: Accepted

Solution code:
w = input()
a,b,c,d = w[0],w[1],w[2],w[3]
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 b == c and a != b:
    print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

tmp = []
kind = 0
flag = True
for i in range(len(S)):
    if (S[i] in tmp) == False:
        tmp.append(S[i])
        kind += 1
        if S.count(S[i]) != 2:
            flag = False

if (kind == 2) and (flag == True):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
n = input()
s = sorted(list(n))
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:
n = input()
s = sorted(list(n))
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()

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

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

Submission status: Accepted

Solution code:
def consunt():
    if input_.count(input_str_arr[0]) and input_.count(input_str_arr[1]):
      print("Yes")
    else:
      print("No")

input_ = input()

input_str = set(input_)

input_str_arr = [s for s in input_str]

if len(set(input_str_arr))==2:
    consunt()
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())

if len(set(S)) != 2:
    print('No')
elif S.count(S[0]) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = list(input())
if len(set(a)) == 2:
  count = 0
  for r in set(a):
    if a.count(r) == 2:
      count += 1
  if count == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
import sys
S=raw_input()
F=defaultdict(int)
for c in S: F[c]+=1
for k,v in F.iteritems():
    if v!=2:
        print("No")
        sys.exit(0)
print("Yes")