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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

a = S[0]
b = S[1]
c = S[2]
d = S[3]

if a==b and c==d and b!=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:
import sys

s = input()
s_list = set(list(s))

if (len(s_list) != 2):
    print('No')
    sys.exit()

is_ok = True
for char in set(list(s)):
    if (s.count(char) != 2):
        is_ok = False

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()

freq = {}

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


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

cond = True
for c in freq:
    if freq[c] != 2:
        cond = False
        break

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

Submission status: Accepted

Solution code:
S = input()

ans = "Yes"
for s in S:
  if S.count(s) != 2:
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
S = input()
c = Counter(S)
print('Yes' if all(v == 2 for v in c.values()) else 'No')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
d=[0]*len(s)
for i in range(0,4):
  d[i]=s[i]
if len(set(d))==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 = str(input())
l = []
for i in range(4):
    l.append(s[i])
if len(set(l)) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = str(input())
l = []
for i in range(4):
    l.append(s[i])
if len(set(l)) == 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 = input()

for i in range(4):
    cnt = s.count(s[i])
    if cnt == 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
    array = list(input())
    for i in range(len(array)):
        count = 0
        for j in range(len(array)):
            if array[i] == array[j]:
                count += 1
            continue
        if count != 2:
            print('No')
            return
    print('Yes')
    return


if __name__ == '__main__':
    main()

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()
count={}
for c in S:
	count[c] = count.get(c, 0) + 1
counts=list(count.values())
if(counts[0] == 2 and counts[1] == 2):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
S=input()
L=[]
for i in range(3):
    L.append(S.count(S[i]))
if sum(L)==6:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

if s[0] == s[1] and s[1] == s[2] and s[2] == s[3]:
    print("No")
else:
    if 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 = str(input())
X=[]

for s in S:
    X.append(s)

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

S = read().rstrip().decode('utf-8')

a,b,c,d = sorted(S)

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

Submission status: Accepted

Solution code:
S = input()

first = S[0]
fnum = 1
snum = 0
for i in range(1, 4):
	if S[i] == first:
		fnum += 1
	elif snum == 0:
		sec = S[i]
		snum += 1
	elif S[i] == sec:
		snum += 1

if fnum == 2 and snum == 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[0]!=s[2]:
	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[1]!=s[0]:
    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[3]:
  ans = "Yes"
else:
  ans = "No"
  
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d=input()
if a==b==c==d:
  print('No')
elif a==b and c==d:
  print('Yes')
elif a==c and b==d:
  print('Yes')
elif a==d and b==c:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()

ans = "Yes"
L = []
cnt = 0
for i in range(4):
    if S[i] not in L:
        cnt += 1
    L.append(S[i])
        
if cnt != 2:
    ans ="No"
else:
    for i in range(4):
        if L.count(L[i]) != 2:
            ans = "No"
            break
print(ans)

Submission status: Accepted

Solution code:
S = input()

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

else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s = ''.join(sorted(s))
if s.count(s[0]) != 2:
  print('No')
elif s.count(s[2]) != 2:
  print('No')
else:
  print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
count1 = 0
count2 = 0
for i in range(3):
    for j in range(i+1, 4):
        if S[i] == S[j]:
            count1 += 1
for i in range(3):
    if S[i] == S[i+1]:
        count2 += 1

if count1 == 2 and count2 != 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d=input()
if a==b and c==d and a!=c or a==c and b==d and a!=b or a==d and b==c and a!=b:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

one, one_n = None, 0
two, two_n = None, 0

for s in S:
  if not one or s == one:
    one = s
    one_n += 1
    continue

  if not two or s == two:
    two = s
    two_n += 1
    continue

if one_n == 2 and two_n == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
a = list()
b = list()
c = list()
a.append(s[0])
for i in range(1,4):
    if s[i] == a[0]:
        a.append(s[i])
    elif len(b) == 0:
        b.append(s[i])
    elif s[i] == b[0]:
        b.append(s[i])
    else:
        c.append(s[i])
if (len(a) == 2) and (len(b) == 2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

def judge(L):
	setS = list(set(L))
	if len(setS) != 2:
		print("No")
		return
	
	if S.count(setS[0]) and S.count(setS[1]) == 2:
		print("Yes")
	else:print("No")

judge(S)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x = sorted(list(map(str,input())))
print('Yes'if x.count(x[0])==2 and x.count(x[2])==2 else 'No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
words = list(input())
if len(set(words)) == 2 and words.count(words[0]) == 2:
  print("Yes")
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 = input()
if S[0] in S[1:4]:
    if S[1] in S[2:4] :
        if S[0] != S[1]:
            print("Yes")
            exit()
    elif S[2] in S[3]:
        if S[0] != S[2]:
            print("Yes")
            exit()
print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
count = 0

if S.count(S[0]) == 2:
    count = count + 1
if S.count(S[1]) == 2:
    count = count + 1
if S.count(S[2]) == 2:
    count = count + 1
if S.count(S[3]) == 2:
    count = count + 1

if count==4:
    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("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
'''A - Fifty-Fifty
https://atcoder.jp/contests/abc132/tasks/abc132_a

>>> main('ASSA')
Yes
>>> main('STOP')
No
>>> main('FFEE')
Yes

06.txt
>>> main('YSKY')
No

07.txt
>>> main('JJKP')
No

'''


def main(s):
    for _s in s:
        if s.count(_s) != 2:
            print('No')
            return

    print('Yes')


if __name__ == "__main__":
    main(input())

Submission status: Accepted

Solution code:
s=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()
a = {}
for i in s:
    if i in a:
        a[i] += 1
    else:
        a[i] = 1
if len(a) == 2 and a[s[0]] == 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[0] != s[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
dict = {}

for i in range(4):
  dict[s[i]] = dict.get(s[i], 0) + 1
    
print("Yes" if all([v == 2 for v in dict.values()]) else "No")

Submission status: Accepted

Solution code:
S = input()
s = list(v for v in S)

first = s.count(s[0])
second = s.count(s[1])
third = s.count(s[2])
fourth = s.count(s[3])

if first == 2 and second == 2 and third == 2 and fourth == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(str(input().rstrip('\n'))).most_common()
    if len(s) == 2:
        for k, v in s:
            if v != 2:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    slove()

Submission status: Accepted

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

#文字ごとの出現頻度を取得
import collections
c = collections.Counter(s_list)

#上位２つの文字を抽出
top2 = c.most_common(2)

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

Submission status: Accepted

Solution code:
import collections
str = input()
counter = collections.Counter(str)

for val in counter.values():
    if val != 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
s = input()
first = s[0]
second = ""
cnt_f = 0
cnt_s = 0
for i in range(len(s)):
    if s[i] != first:
        second = s[i]
        break
for i in range(len(s)):
    if s[i] == first:
        cnt_f+=1
    if s[i] == second:
        cnt_s+=1
if cnt_f == 2 and cnt_s == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a = input()
s = [i for i in a]
for i in s:
  if s.count(i) != 2:
    print("No")
    quit()
print("Yes")

Submission status: Accepted

Solution code:
# AtCoder
st = input()
if len(set(st)) == 2:
    print("Yes")
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()

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

Submission status: Accepted

Solution code:
S = input()

count = [0] * 4
flag = 0

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

    if count[j] != 2:
        flag = 1
        break

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

Submission status: Accepted

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

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 "No")

Submission status: Accepted

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

Submission status: Accepted

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


def main():
    s_list = list(input())
    dic = {}
    for s in s_list:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1

    if len(dic) != 2:
        print('No')
        return
    else:
        for v in dic.values():
            if v != 2:
                print('No')
                return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#input:長さ４の英大文字列
#output:文字列が２文字で構成されていてそれぞれ二回出てきているかを判定 Yes,No

S = list(input())
S_K = []
n = 0

for i in range(4):
    if i == 0:
        S_K.append(S[i])
        n += 1
    else:
        if S[i] not in S_K:
            S_K.append(S[i])
            n += 1

if n == 2:
    if S.count(S_K[0]) == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
S=list(input())
S_count = list(S.count(s) for s in S)
if S_count == [2,2,2,2]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import Counter
import numpy as np

input_ = np.array(Counter(input()).most_common())

if input_.shape[0] == 2 and np.all(input_[:, 1] == "2"):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
s_setted = list(set(s))
if len(s_setted) == 2:
    s_one = 0
    s_two = 0
    for s_elem in s:
        if s_elem == s_setted[0]:
            s_one += 1
        if s_elem == s_setted[1]:
            s_two += 1
    if s_two == 2 and s_one == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
S=sorted(input())
if len(set(S)) ==2 and 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 sys,collections
S = list(input())
S_Collection = collections.Counter(S) #Sの各文字の出現回数

#S_Collectionの内容が[2,2]であれば各文字は2回ずつ出現することになる
if list(S_Collection.values()) == [2,2]:
    print("Yes")
    sys.exit()
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:
from collections import Counter


def p_a():
    s = Counter(input())
    if len(s.keys()) == 2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    p_a()

Submission status: Accepted

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

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    s_list = list(S)
    dic = {}
    for st in s_list:
        if st in dic:
            dic[st] += 1
        else:
            dic[st] = 1
    is_ok = True
    for key, val in dic.items():
        if val != 2:
            is_ok = False
    if len(dic) != 2:
        is_ok = False
    if is_ok:
        print(YES)
    else:
        print(NO)
    return


# Generated by 1.1.5 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#132  Fifty-Fifty
A = list(input())
print('Yes' if len(set(A)) == 2 & A.count(A[0]) == 2 else 'No')

Submission status: Accepted

Solution code:
#132  Fifty-Fifty
A = input()
if len(set(A)) == 2 & A.count(A[0]) == 2:
       print('Yes')
else:
       print('No')

Submission status: Accepted

Solution code:
S = input()

cnt = [0,0,0,0]

for i in range(4):
  
  for j in range(4):
    if S[i] == S[j]:
      cnt[i] += 1
      
    else:
      pass

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

Submission status: Accepted

Solution code:
S=input()
cnt=0
if S[0]==S[1]:
  cnt=cnt+1
if S[0]==S[2]:
  cnt=cnt+1
if S[0]==S[3]:
  cnt=cnt+1
if S[1]==S[2]:
  cnt=cnt+1
if S[1]==S[3]:
  cnt=cnt+1
if S[2]==S[3]:
  cnt=cnt+1
if cnt==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:
import collections

s = input()

count_char = collections.Counter(s)

if len(count_char) == 2 and all(map(lambda x: x == 2, count_char.values())):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

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

Submission status: Accepted

Solution code:
S = input()
ans = "No"

if len(set(list(S))) == 2 and list(S).count(list(S)[0]) == 2:
    ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
s=list(input())

if(all(s.count(x)==2 for x in s )):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(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")

Submission status: Accepted

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

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:
import collections
def counter_list(A):
  counter = collections.Counter(A)
  counter =  [list(e) for e in counter.items()]
  #counter.sort() #sortしたい場合はつける
  return counter

S = list(input())
A = counter_list(S)
judge = 0

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

Submission status: Accepted

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

for target in S_set:
    if S.count(target) != 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
S = input()
ss = list(set(S))
if len(ss) == 2 and S.count(ss[0]) == S.count(ss[1]):
    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[1] != 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:
#!/usr/bin/env python3
import sys


def solve(S: str):
    if len(set(S)) == 2:
        if list(S).count(list(set(S))[0]) == 2 and list(S).count(list(set(S))[1]) == 2:
            print("Yes")
        else:
            print("No")
    else:
        print("No")


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
count = 0
s1 = 0
s2 = 0
A = dict()
N = len(S)
judge = True
for i in range(N):
    if S[i] in A:
        A[S[i]] += 1
        if A[S[i]] > 2:
            judge = False

    else:
        A[S[i]] = 1
        count += 1
if count > 2:
    judge = False
    
if judge:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()

kotae = 'No'

if a[0] == a[1] and a[2] == a[3] and a[0] != a[2]:
  kotae= 'Yes'

if a[0] == a[2] and a[1] == a[3] and a[0] != a[1]:
  kotae= 'Yes'

if a[0] == a[3] and a[1] == a[2] and a[0] != a[1]:
  kotae= 'Yes'

print(kotae)

Submission status: Accepted

Solution code:
import collections

s = input()

list_s = [s[i] for i in range(len(s))]
count = collections.Counter(list_s)
count = [v for v in count.values()]

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

Submission status: Accepted

Solution code:
S = input()
S_list = list(S)
S_set = set(S_list)
for s in S_list:
    if S_list.count(s) == 2 and len(S_set) == 2:
        print('Yes')
        break
    else:
        print('No')
        break

Submission status: Accepted

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

s=input()
l=[]
count=0
for i in range(4):
    for j in range(4):
        if s[i]==s[j]:
            count+=1
    l.append(count)
    count=0

l=set(l)
if len(l)==1 and l=={2}:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().rstrip()

li = list(set(s))

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

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input().strip())

C = Counter(S)

for k,v in C.items():
  if v == 2:
    continue
  else:
    break
else:
  print("Yes")
  quit()
print("No")

Submission status: Accepted

Solution code:
s = input()
ans = []
for i in range(4):
    ans.append(s[i])

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

Submission status: Accepted

Solution code:
S = input()

ans = 0
for i in range(4):
    if S.count(S[i]) == 2:
        ans += 1

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

Submission status: Accepted

Solution code:
import collections
s = input()

d = dict(collections.Counter(s))

if len(d) == 2 and len(set(d.values())) == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

stringSet = set([S[0],S[1],S[2],S[3]])

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

Submission status: Accepted

Solution code:
from collections import Counter

s = input()

c = Counter(s)

if len(c) == 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:
S = list(input())
s = set(S)

ans = 'Yes'

if len(s) != 2 :
    ans = 'No'
else :
    a, b = s
    if not S.count(a) == S.count(b) == 2 :
        ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
S = input()

res = "Yes"
s = set(list(S))
if len(s) != 2:
    res = "No"
else:
    a, b = s
    if not S.count(a) == S.count(b) == 2:
        res = "No"
print(res)

Submission status: Accepted

Solution code:
S=str(input())
if S[0]==S[1]:
    if S[2]==S[3] and S[1]!=S[2]:
        print("Yes")
    else:
        print("No")
else:
    if 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:
#132a
S = str(input())

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

Submission status: Accepted

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