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:
# encoding: utf-8
import sys
# input = sys.stdin.readline

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

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

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

Submission status: Accepted

Solution code:
import sys

s = input()
dic = dict()

for a in s:
	if a in dic:
		dic[a] += 1
	else:
		dic[a] = 1
		
for a in dic:
	if dic[a] != 2:
		print("No")
		sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
def test(d, str):
    d[str] = d.get(str, 0) + 1

S = input()

dic = {}

# dic["s"] = 2
# dic["a"] = 2
s1 = S[0:1]
s2 = S[1:2]
s3 = S[2:3]
s4 = S[3:4]


test(dic, s1)
test(dic, s2)
test(dic, s3)
test(dic, s4)

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

Submission status: Accepted

Solution code:
## AABB
## ABBA
## ABAB

S = input().strip()
first_char = ['', 0]
second_char = ['', 0]
counter = 0
ans = True
for c in S:
    if counter == 0:
        first_char[0] = c
        first_char[1] += 1
    
    if counter == 1:
        if c != first_char[0]:
            second_char[0] = c
            second_char[1] += 1
        else:
            first_char[1] += 1
            
    if counter >1:
        if second_char[0] == '':
            second_char[0] = c
            
        if(first_char[0] != c and second_char[0] != c):
            ans = False
            break
        if c == first_char[0]:
            first_char[1] += 1
            if first_char[1] > 2:
                ans = False
                break
                
        if c == second_char[0]:
            second_char[1] += 1
            if second_char[1] > 2:
                ans = False
                break
    counter += 1

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    s = inputs[0]
    counts = {}
    for c in s:
        if c in counts:
            counts[c] += 1
        else:
            counts[c] = 1

    if len(counts) != 2:
        return "No"

    for k, v in counts.items():
        if v != 2:
            return "No"
    return "Yes"


def string_to_int(string):
    return list(map(lambda x: int(x), string.split()))


if __name__ == "__main__":
    ret = solve(inputs(1))
    print(ret)

Submission status: Accepted

Solution code:
from collections import Counter; print("YNeos"[list(Counter(list(input())).values()) != [2,2]::2])

Submission status: Accepted

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

con = True
for i in ss:
  if ss.count(i) != 2:
    con = False
if con:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def calc(text):
  unique = list(set(text))
  if len(unique) != 2:
    return "No"

  if text.count(unique[0]) == 2:
    return "Yes"
  else:
    return "No"

text = input()
print(calc(text))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
cnt = {}

A = input()

for i in A:
    if i in cnt:
        cnt[i] += 1

    else:
        cnt[i] = 1


diclenth = len(cnt)


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

Submission status: Accepted

Solution code:
a,b,c,d = input()
flag = 0
if(a==b and c==d):
    flag = 1
elif(a==c and b==d):
    flag = 1
elif(a==d and b==c):
    flag = 1
else:
    flag = 0
if(a==b and a==c and a==d):
    flag = 0
if(flag==1):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a,b,c,d=input()
kotae="No"
kai=0
if (a==b and c==d):
        kotae="Yes"
        kai+=1
if (a==c and b==d):
        kotae="Yes"
        kai+=1
if (a==d and b==c):
        kotae="Yes"
        kai+=1
if(kai!=1):
    kotae="No"
print(kotae)

Submission status: Accepted

Solution code:
S = input()
A = set (S)
B = len (A)
if B == 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:
#４文字の文字列Sが二種類で2回ずつ現れる判定
S = input()
S_list = set(list(S))
#print(S_list)




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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
list1 = [0,0]
S=input()

a1 = S[0]
a2 = "NUM"

if S[1] == a1:
    list1[0]=2
else:
    a2 = S[1]

if S[2]==a1:
    list1[0]=2
else:
    if S[1]==a1:
        a2 =S[2]
    else:
        if S[2]==a2:
            list1[1]=2
        else:
            pass

if S[3]==a1:
    list1[0]=2
else:
    if S[2]==a1 and S[1] == a1:
        a2 = S[3]
    else:
        if S[3]==a2:
            list1[1]=2
        else:
            pass
        
if list1[1]==2 and list1[0]==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
if S.isupper() == True:
    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')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
text = list(input())
first = text[0]
firstCount = 1
second = ""
secondCount = 0
error = False
for i in range(1, 4):
    moji = text[i]
    if moji == first:
        firstCount += 1
        if firstCount > 2:
            error = True
            break
    else:
        if second == "" or second == moji:
            second = moji
            secondCount += 1
            if secondCount > 2:
                error = True
                break
        else:
            error = True
            break
if error == True:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
a = [i for i in input()]
b = list(set(a))

if len(b) != 2:
    print("No")
elif a.count(b[0]) != 2 or a.count(b[1]) != 2:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
import copy

sys.setrecursionlimit(1000000)


# input = sys.stdin.readline

# ~~~~~~~~~~~~~~~~~~~~~_(＾～＾ ｣ ∠)_~~~~~~~~~~~~~~~~~~~~~

S = input().rstrip()
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 = str(input())
c1 = "Init"
c2 = "Init"
ans = "Yes"
for i in s:
    if c1 == "Init":
        c1 = i
    elif c1 == i:
        continue
    elif c2 == "Init":
        c2 = i
    elif c2 == i:
        continue
    else:
        ans = "No"
        break
if c2 == "Init":
    ans = "No"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

s_d = dict()

for c in s:
  if s_d.get(c) is None:
    s_d[c] = 1
  else:
    s_d[c] += 1
  
flag = True
for v in s_d.values():
  if not v == 2:
    flag = False

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

Submission status: Accepted

Solution code:
S = input()

T = sorted(S)
ans = (
    'Yes' if T[0] == T[1] and T[1] != T[2] and T[2] == T[3] else
    'No'
)

print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict

s_dic = defaultdict(int)
for s in list(input()):
    s_dic[s] += 1

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

Submission status: Accepted

Solution code:
s = input()
c = 0
for i in range(len(s)):
  for j in range(i + 1, len(s)):
    if s[i] == s[j]:
      c += 1

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

Submission status: Accepted

Solution code:
S=input()

ans='No'
SS=list(set(S))
if len(SS)==2:
    if S.count(SS[0])==2:
        ans='Yes'
print(ans)

Submission status: Accepted

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

s = set(S)
if len(s) == 2:
    count = 0
    for _ in s:
        if len([a for a in S if a == _]) == 2:
            print('Yes')
            quit()

print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

word = input()
seen_letters = Counter(word)

flag = 'Yes'
for letter in seen_letters:
    if seen_letters[letter] != 2:
        flag = "No"

print(flag)

Submission status: Accepted

Solution code:
word = input()

seen_letters = {}

for letter in word:
    seen_letters[letter] = seen_letters[letter] + 1 if letter in seen_letters else 1

flag = 'Yes'
for letter in seen_letters:
    if seen_letters[letter] != 2:
        flag = "No"

print(flag)

Submission status: Accepted

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

from collections import defaultdict

S = input()
d = defaultdict(int)

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

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

Submission status: Accepted

Solution code:
S = list(input())
str = "Yes"
for char in S:
    if S.count(char) != 2:
        str = "No"
print(str)

Submission status: Accepted

Solution code:
N = input()

A = []
for i in range(1,4):
	if N[i] != N[0]:
		A.append(N[i])

if len(A) == 2 and A[0] == A[1]:
	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:
def main():
    s=input()
    if s[0]==s[1] and s[2]==s[3] and s[0]!=s[2]:
        print("Yes")
        return
    if s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]:
        print("Yes")
        return
    if s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]:
        print("Yes")
        return
    print("No")
    return

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

sorted_S = sorted(S)

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

Submission status: Accepted

Solution code:
import collections
s = list(input())
t = collections.Counter(s)
temp = True
for i in t:
    if t[i] != 2:
        temp = False
if temp:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = 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:
s = input()
if s[0] == s[2] and s[1] == s[3] or s[0] == s[1] and s[2] == s[3] or s[0] == s[3] and s[1] == s[2]:
    if not (s[0] == s[1] and s[1] == s[2] and s[2] == s[3]):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

sr = list(set(s))

if len(sr) == 2:
  print("Yes")
else:
  print("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 = 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 len(set(s)) == 2 and s.count(s[0]) ==2:
    print('Yes')
else:
    print('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 = input()
d = dict()

for c in s:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1
        
result = 'Yes'
for k in d:
    if d[k] != 2:
        result ='No'
        
print(result)

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()
d = dict()

for c in s:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1
        
result = 'Yes'
for k in d:
    if d[k] != 2:
        result = 'No'
        
print(result)

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:
s = input()
s = sorted(s) # list of sorted data

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 = sorted(s) # list of sorted data

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:
L=input()
L_l=[]
for i in L:
     L_l.append(i)
L_l.sort()

if L_l[0]==L[1] and L_l[1]==L_l[2]:
     print("No")
elif L_l[0]==L_l[1] and L_l[2]==L_l[3]:
     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()
t = list(s)[0]
s = s.replace(t, '', 2)
if(list(s)[0] != t):
    s = s.replace(list(s)[0], '', 2)
if(len(s) == 0):
    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:
inputS = set(input())
if len(inputS) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s = input()

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

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:
from collections import Counter
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

S = input()[:-1]
C = Counter(S)
if all([v == 2 for key, v in C.items()]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

Count = 0
for i in range(len(S)):
    count = 0
    for j in range(len(S)-i-1):
        # print('i,j:',i,j)
        # print('S[i]:',S[i],'S[i+j+1]:',S[i+j+1])
        if (S[i] == S[i+j+1]):
            count += 1
            # print('aaaaaaaa')
            # print('count:',count)
        if (count == 1):
            Count += 1
            # print('bbbbbbb')
            # print('Count:',Count)
            break

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(input())
a.sort()
s = 1
if (len(set(a))==2 and a[0]==a[1] and a[2]==a[3]):s = 0

def Y(a,t = 0):
    if a==t : print('YES')
    else : print('NO')
def y(a, t =0):
    if a==t : print('Yes')
    else : print('No')
y(s,0)

Submission status: Accepted

Solution code:
s = input()
t = list(set(s))
if len(t)==2:
    flag = True
    for i in range(2):
        if s.count(t[i]) != 2:
            flag = False
else:
    flag = False

print("Yes" if flag==True else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

    s = Counter(input())

    if len(s.keys()) == 2:
        count = 0

        for v in s.values():
            if v == 2:
                count += 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(lambda: 0)
S = input()
for i in range(4):
  d[S[i]] += 1
keys = list(d.keys())
values = list(d.values())
if len(keys) == 2 and values[0] == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

str = input().strip()

count = Counter(str)

if len(count) == 2:
    for v in count.values():
        if v == 2:
            print("Yes")
        else:
            print("No")
        
        break

else:
    print("No")

Submission status: Accepted

Solution code:
a = input()

if a[0] == a[1] == a[2]:
    print("No")

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

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

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

else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())
ans = 0

S_set=list(set(S))

if len(S_set) != 2:
    print('No')
    exit()

for s in S_set:
    if S.count(s) == 2:
        ans += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

import sys
tmp = input()

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

Submission status: Accepted

Solution code:
l =[str(i) for i in input()]
l_set = list(set(l))
if len(l_set) ==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
ans=0
for i in range(4):
    ans+=s.count(s[i])
if ans==8: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:
import collections

S=input()
c=collections.Counter(S)
c=dict(c)
for key in c:
    if c[key]!=2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input().strip()
v = {}

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

if len(v) == 2 and list(v.values())[0] == 2 and list(v.values())[1] == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# ABC132 A Fifty-Fifty

S = input()

flg = True

for i in S:
    if S.count(i) != 2:
        flg = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
str = input()

list = []
num = []

for i in str:

    if len(list) is 0:
        list.append(i)
    else:
        if list.count(i) == 0:
                list.append(i)



for i in list:
    num.append(str.count(i))

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

Submission status: Accepted

Solution code:
str = input().split()[0]
first = str[0]
strlist = str.split(first)
if len(strlist) != 3:
	print("No")
else:
	if len(strlist[1]) == 2:
		if strlist[1][0] == strlist[1][1]:
			print("Yes")
		else:
			print("No")
	elif len(strlist[1]) == 1 and len(strlist[2]) == 1:
		if strlist[1][0] == strlist[2][0]:
			print("Yes")
		else:
			print("No")
	elif len(strlist[2]) == 2:
		if strlist[2][0] == strlist[2][1]:
			print("Yes")
		else:
			print("No")
	else:
		print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input().strip()
if len(set(S[:])) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys

s = input()
if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")

Submission status: Accepted

Solution code:
import sys


#s = sys.argv[1]
s = input()
if len(s) == 4:
    if s.count(s[0]) == 2:
        if s.count(s[1]) == 2:
            if s.count(s[2]) == 2:
                if s.count(s[3]) == 2:
                    print("Yes")
                    exit()
print("No")
exit()

Submission status: Accepted

Solution code:
S = input()
def solve():
  for s in S:
    if not(S.count(s) == 2):
      return False
  return True

print('Yes' if solve() else 'No')

Submission status: Accepted

Solution code:
s_list = list(str(input()))

i = 0
while i < 3:
  if s_list.count(s_list[i]) == 2:
    i = i + 1
    continue
  else:
    break

if i == 3:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S=input()
if len(set(S))==2:
  s=list(set(S))
  a=s[0]
  b=s[1]
  if S.count(a)==2 and S.count(b)==2:
    print('Yes')
  else:
    print('No')
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 = input()
ans = False
if s[0] == s[1] :
  if s[0] != s[2] and s[2] == s[3] :
    ans = True
elif s[0] == s[2] :
  if s[0] != s[1] and s[1] == s[3] :
    ans = True
elif s[0] == s[3] :
  if s[0] != s[1] and s[1] == s[2] :
    ans = True
if ans :
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
hantei=False
SS=sorted(S)
if(len(set(S))==2):
    if(SS[0]==SS[1] and SS[0]!=SS[2]):
        hantei=True
    else:
        hantei=False
else:
    hantei=False


if(hantei==True):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
print('YNeos'[not (lambda s: s[0]==s[1]!=s[2]==s[3])(sorted(input()))::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
word_list = []
for i in range(len(s)):
    word_list.append(s[i])
list = []

for i in range(len(word_list)):
    flag = 0
    w = word_list[i]
    if len(list) == 0:
        list.append([w,1])
    else:
        for j in range(len(list)+1):
            if j == len(list) and flag == 0:
                list.append([w,1])
            elif j == len(list):
                continue
            elif list[j][0] == w:
                flag = 1
                list[j][1] = list[j][1] + 1

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

Submission status: Accepted

Solution code:
if len(set(input()))==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=sorted(input())
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()

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

Submission status: Accepted

Solution code:
l = list(input())

dic = {}
for i, v in enumerate(l):
    if v in dic:
        dic[v] += 1
    else:
        dic[v] = 1

li = list(dic.values())
if li[0] == 2 and li[1] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
sorted_s = sorted(s)
if sorted_s[0] == sorted_s[1] and sorted_s[1] != sorted_s[2] and sorted_s[2] == sorted_s[3]:
    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:
li = list(input())
li1 = li[:]

flag = 'No'
for i in range(1,4):
    if li[0]==li[i]:
        del li1[i],li1[0]
        if li1[0] == li1[1]:
            flag = 'Yes'
            break
        break
if li[0]==li1[0]:
    flag = 'No'

print(flag)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = [n for n in input()];r = len(set(s)) == 2 and ((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" if r else "No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def fifty_fifty(word):
    r = {}
    for s in list(word):
        if s in r:
            r[s] += 1
        else:
            r[s] = 1
    if len(r) == 2 and max(r.values()) == 2:
        return 'Yes'
    else:
        return 'No'

s = input()
print(fifty_fifty(s))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

line = list(set(s))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
a_dict = dict()
count = 0
for word in S:
  a_dict.setdefault(word, count)
  if word in a_dict.keys():
    a_dict[word] += 1
if len(a_dict) != 2:
  print("No")
else:
  for value in a_dict.values():
    if value != 2:
      print("No")
      break
    else:
      print("Yes")
      break

Submission status: Accepted

Solution code:
S=input()

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