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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inputs_array = list(input())
check_dict = {}

is_words = False
is_two = True

for later in inputs_array:
  if later in check_dict:
    check_dict[later] += 1
  else:
    check_dict[later] = 1
    
for v in check_dict:
  if check_dict[v] == 2:
    continue
  else:
    is_two = False
    break

if len(check_dict) == 2:
  is_words = True
  
if is_words and is_two:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
d = {}

#それぞれの文字の数を数える
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

#dの長さが2出ないとき(文字の種類が2種類じゃないとき)
if len(d) != 2:
    print("No")
    exit()

#それぞれの文字の数が2かどうか
for s in S :
    if d[s] != 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

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

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

print("Yes")

Submission status: Accepted

Solution code:
S = input()

s = []
count = 0

for i in range(0, len(S)):
    s.append(S[i])

s = sorted(s)

a = s[0]
b = s[2]

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

if s[0] == s[2]:
    print('No')
elif count == 4:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = [w for w in input()]

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

Submission status: Accepted

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

Submission status: Accepted

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

if __name__ == "__main__":
    A_FiftyFifty()

Submission status: Accepted

Solution code:
from collections import Counter
c = True
for (k, v) in Counter(input()).items():
  if v != 2:
    c = False
if c:
  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 = input()

s1 = s[0]
if s.count(s1) == 2:
    s = s.replace(s1, "")
    s2 = s[0]
    if s.count(s2) == 2:
        print('Yes')
    else:
        print('No')

else:
    print('No')

Submission status: Accepted

Solution code:
s=input()
cnt=0;a=0
res = []
for i in s:
    if i not in res:
        res.append(i)
if len(res)!=2:
    print("No")
    exit()
else:
    for i in s:
        if res[0] == i:
            cnt += 1
        if res[1] == i:
            a += 1
    if a == 2 and cnt == 2:
        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 = list(input())
count = {}
for i in S:
  if i in count:
    count[i] += 1
  else:
    count[i] = 1
ans = 'Yes'
for i in count:
  if count[i] != 2:
    ans = 'No'
    break
print(ans)

Submission status: Accepted

Solution code:
S = [str(a) for a in input()]

S_0 = S.count(S[0])
S_2 = S.count(S[2])

if S_0 == 2 and S_2 == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
first = s[0]
count = 0
s_count = 0
num = 0
second = ""
for i in range(1,len(s)):
    if s[i] == first:
        count += 1
    else:
        second = s[i]  
        num = i
for i in range(1,len(s)):
    if num == i:
        m = 0
    elif second == s[i]:
        s_count += 1

if count == 1 and s_count == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

if s.count(s[0]) != 2:
    print('No')
    exit(0)
s = s.replace(s[0], '')
if s.count(s[0]) != 2:
    print('No')
    exit(0)
    
print('Yes')

Submission status: Accepted

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

j = [t[1] for t in c]
if j==[2,2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

l = set(list(S))

c = list(l)

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

Submission status: Accepted

Solution code:
def main():
    S = input()

    answer = {}
    for s in S:
        if s in answer:
            answer[s] += 1
        else:
            answer[s] = 1


    count = 0
    for s, c in answer.items():
        count += 1
        if answer[s] != 2:
            print('No')
            return
    if count == 2:
        print('Yes')
    

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import math

def main():
    S = input()
    char_dict = {}
    for s in S:
        if not s in char_dict:
            char_dict[s] = 1
        else:
            char_dict[s] = char_dict[s] + 1
    flag = 1
    if len(char_dict) == 2:
        for char in char_dict.keys():
            if char_dict[char] != 2:
                flag = 0
    else:
        flag = 0

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
moji = list(input())
hako = []
yes = 0
for m in moji:
  if m not in hako:
    hako.append(m)
if len(hako) == 2:
  for h in hako:
    if moji.count(h) == 2:
      yes += 1
if yes == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
s=list(input())
a=Counter(s).most_common(2)
if len(a)==1:
    print("No")
    exit()
print("Yes" if a[0][1]==a[1][1]==2 else "No")

Submission status: Accepted

Solution code:
from enum import Enum
from queue import Queue
import collections

import sys
import math

BIG_NUM = 2000000000
MOD = 1000000007
EPS = 0.000000001

S = list(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()
L=[str(c) for c in S]
if L[0]==L[1]==L[2]==L[3]:
  print("No")
elif L[0] ==L[1]:
  if L[2]==L[3]:
    print("Yes")
  else:
    print("No")
elif L[0]==L[2]:
  if L[1]==L[3]:
    print("Yes")
  else:
    print("No")
elif L[0]==L[3]:
  if L[1]==L[2]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()


s1 = s[0]
if s.count(s1) == 2:
    s = s.replace(s1,"")
    s2 = s[0]
    if s.count(s2) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
def main() :

    S = input()

    S = S.replace(S[0],"")

    if (S == "") :
        print("No")
        return 

    S = S.replace(S[0],"")
    if (S == "") :
        print("Yes")
    else :
        print("No")

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
c = Counter(input())
print('Yes' if all(map(lambda x: c[x] == 2, c)) else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

l = [i for i in S]
l = list(set(l))

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

Submission status: Accepted

Solution code:
S = input()

l = [i for i in S]
l = list(set(l))

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

Submission status: Accepted

Solution code:
s = list(input())

flag = False
for i in range(len(s)):
    if s.count(s[i]) == 2 :
        flag = True
    else :
        flag = False
        break
if flag :
    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 len(set(S)) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()


t = S[0]
S = [s for s in S if s != t]


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

Submission status: Accepted

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

c = Counter(S)

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

Submission status: Accepted

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

success = True
words = []
for i in range(n):
    if s.count(s[i]) != 2:
        success = False
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import io
import sys


def IN_S():
  return input()


def IN_I():
  return int(input())


def IN_L_I():
  return list(map(int, input().split()))


def IN_L_S():
  return list(map(str, input().split()))


def STR_SPLIT(s, n):
  for l in range(0, len(s), n):
    yield s[0 + l:n + l]


def T_IN():
  global test_str
  sys.stdin = io.StringIO(test_str[1:-1])


test_str = '''
ABBA
'''

def MAIN():
  # T_IN()
  if A():
    print("Yes")
  else:
    print("No")
  quit()

def A():
  s = IN_S()
  l = list(STR_SPLIT(s, 1))
  l.sort()
  if len(l) == 4 and l[0] == l[1] and l[2] == l[3] and l[1] != l[2]:
    return True
  return False


MAIN()

Submission status: Accepted

Solution code:
from collections import defaultdict

s = input()
d = defaultdict(int)
for si in s:
    d[si] += 1
if len(d.keys()) == 2 and list(d.values()) == [2, 2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
st=input()
isfail=False
for i in range(len(st)):
    count=0
    for k in range(len(st)):
        if st[i]==st[k]:
            count=count+1
    if count!=2:
        isfail=True
        break
if isfail:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
string = input()
if string[0] == string[1] and string[2] == string[3]\
and string[0] != string[2]:
  print("Yes")
elif string[0] == string[2] and string[1] == string[3]\
and string[0] != string[1]:
  print("Yes")
elif string[0] == string[3] and string[1] == string[2]\
and string[0] != string[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:
A = input()
S = sorted(A)

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

Submission status: Accepted

Solution code:
import sys
s = input()
a = s[0]
if s.count(a) != 2:
  print("No")
  sys.exit()
t = s.replace(a,"")

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s = len(set(s[i] for i in range(len(s))))
if s==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections

s = collections.Counter(input()).most_common()
if len(s) == 2:
    if s[0][1] == 2 and s[1][1] == 2:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
s_set=list(set(s))
#print(len(s_set))
if 2<=len(set(s_set)):
    if s.count(s_set[0])==2 and s.count(s_set[1])==2:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(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[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:
S = input()
cnt = {}
for s in S:
    if s not in cnt.keys():
        cnt[s] = 1
    else:
        cnt[s] += 1
for s in cnt.values():
    if s != 2:
        print("No")
        exit()
if len(cnt) != 2:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
S = list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(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] )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:
x =  list(input())
charList = []
for s in x:
    if s not in charList:
        charList.append(s)
    
if(len(charList) == 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 = list(input())

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

Submission status: Accepted

Solution code:
S=input()
flag_count=len(S)
Counter=0
for i in range(len(S)):
    for j in range(len(S)):
        if S[i]==S[j]:
            Counter+=1
    if Counter==2:
        flag_count=flag_count-1
    Counter=0
if flag_count == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#文字入力
str = input() 

#文字列の長さ取得
str_leg = len(str)

#判定

count = 0
#(0,1)(0,2)(0,3)(1,2)(1,3)(2,3)
for i in range(0, str_leg - 1):
    for j in range(i+1, str_leg):
        if (str[i] == str[j]):
             count = count + 1 

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict as dedict
counter = dedict(int)

a = input()
for i in list(a):
  counter[i] += 1
  
if ( len(counter) == 2) and (  counter [a[0]] == 2):
  print ("Yes")
  
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()

letters = []
for i in range(4):
  if not s[i] in letters:
    letters.append(s[i])
  
if len(letters)==2 and s.count(s[0])==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = list(input())

sample = []

for moji in S:
  if moji not in sample:
    sample.append(moji)

total = 0
if len(sample) == 2:
  for letter in S:
    if sample[0] == letter:
      total += 1
  if total == 2:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()

temp = s[0]
temp2 = ""
count1 = 0
count2 = 0
for i in range(3):
    if temp == s[i+1]:
        count1 += 1
    elif temp2 == "":
        temp2 = s[i+1]
    elif temp2 == s[i+1]:
        count2 += 1
    else:
        break

if count1 == 1 and count2 == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
s = input()
x = [s[i:i+1] for i in range(len(s))]

new_str_list = sorted(s)
li_uniq = list(set(new_str_list))
if len(li_uniq) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
check = 0

for i in range(len(S)):
  if S.count(S[i]) == 2:
    check += 1

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

Submission status: Accepted

Solution code:
a = input()
a = a.replace(a[0], "")
if len(a) == 0:
    print("No")
else:
    a = a.replace(a[0], "")
    if len(a) == 0:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
S = input()

c = 0

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

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

Submission status: Accepted

Solution code:
s = list(input())
c = 0
for i in range(4):
    for j in range(i+1,4):
        c = c + (1 if s[i] == s[j] else 0) 
print("Yes" if c==2 else "No")

Submission status: Accepted

Solution code:
n= input()

n_list=list(n)

a=(n_list.count(n_list[0]))
b=(n_list.count(n_list[1]))
c=(n_list.count(n_list[2]))
d=(n_list.count(n_list[3]))

if a==2:
    if b==2:
        if c==2:
            if d==2:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")
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[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[0] != s[2]):
    print('Yes')
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:
S = list(input())
if len(S) == 4 and (S.count(S[1])) == 2  and len(set(S))==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())
S = set(S)
if len(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]) 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:
a = list(str(input()))

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

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())
sset = set(s)
leng = len(sset)
c = s.count(s[0])
if leng == 2:
    if c == 2:  
        print("Yes")
    else:
        print("No")        
else:
    print("No")

Submission status: Accepted

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


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:
#coding: utf-8
s = input()
set_s = set(s)
if len(set_s) == 2:
    first = s[0]
    if s.find(first,1) > 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
from itertools import groupby

s = input()
result = True

for k, g in groupby(s):
        if s.count(k) is not 2:
                result = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from collections import Counter


def is_valid(S):
    if len(S) != 4:
        return False

    counter = Counter(S)
    if len(counter) == 2:
        for key in counter:
            if counter[key] != 2:
                return False
        return True
    else:
        return False


def main():
    S = input()
    valid = is_valid(S)
    if valid:
        print('Yes')
    else:
        print('No')


main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
for c in S:
    if S.count(c) != 2:
        print('No')
        quit()

print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/bin/env python
#長さが4の文字列で、２種の文字が２回ずつ現れる文字列かどうか判定

def main():
  s = input() # len(s) == 4
  if s[0] != s[1]:
    if s.count(s[0]) == 2 and s.count(s[1]) == 2:
      print("Yes")
    else:
      print("No")
  elif s.count(s[0]) == 2 and s.count(s[3]) == 2:
    print("Yes")
  else:
    print("No")

main()

Submission status: Accepted

Solution code:
S = list(input())
answer = "Yes"
for i in range(len(S)):
    check = S[i]
    if(S.count(check) != 2):
        answer = "No"
print(answer)

Submission status: Accepted

Solution code:
S = list(input())

if S.count(S[0]) == 2:
    S = [s for s in S if s != S[0]]
    if S.count(S[0]) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
count=0
for i in range(3):
    if s[0]==s[i+1]:
        count+=1
if count==1:
    a=s[0]
    s.remove(a)
    s.remove(a)
    
    if s[0]==s[1]:
        print("Yes")
        
    else:
        print("No")
    
else:
    print("No")

Submission status: Accepted

Solution code:
S=str(input())
a=0
for i in S:
  if S.count(i)==2:
    a+=1
    
print('Yes' if a==4 else 'No')

Submission status: Accepted

Solution code:
s = input()
cnt = 0
for l in s:
    if s.count(l) == 2:
        cnt += 1
print("Yes") if cnt == 4 else print("No")

Submission status: Accepted

Solution code:
s=list(input())
l=[]
for item in s:
  if item not in l:
    l.append(item)
l_c=[s.count(item) for item in l]
if len(l_c)==2 and l_c[0]==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[3]):
  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 = list(input())
print('Yes' if len(set(S)) == 2 and S.count(S[0]) == 2 else 'No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    
    s = input()
    if(s.count(s[0]) == 2):
        s2 = s[1:]
        idx = s2.index(s[0])
        if idx == 0:
            if(s2[1] == s2[2]):
                print('Yes')
            else:
                print('No')
        elif idx == 1:
            if (s2[0] == s2[2]):
                print('Yes')
            else:
                print('No')
        elif idx == 2:
            if (s2[0] == s2[1]):
                print('Yes')
            else:
                print('No')
        else:
            print('No')
    else:
        print('No')

Submission status: Accepted

Solution code:
S = input()

if not sum(list(map(lambda x: x == S[0], S))) == 2:
  print('No')
else:
  s = S[1:]
  idx = s.index(S[0])

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

Submission status: Accepted

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

bool_var = True
if len(s_unique) == 2:
  for w in s_unique:
    cnt = 0
    for s in S: 
      if w==s:
        cnt+=1
    if cnt != 2:
      bool_var = False
      break;
else:
  bool_var = False
        
if bool_var:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
###template###
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
import heapq
INF = float("inf")
sys.setrecursionlimit(10**7)
# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W
def mi(): return map(int, input().split())
def ii(): return int(input())
###template###

s = input()

sset = set(s)

for c in sset:
  if s.count(c) != 2:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter
A=input()
ele=Counter(A)
print("Yes" if len(ele)==2 else "No")

Submission status: Accepted

Solution code:
s = input()

s = list(s)

v = list(set(s))

if len(v) == 2:
    j1 = True

    if s.count(v[0]) == 2 and s.count(v[1]) == 2:
        j2 = True
else:
    j1 = False

if j1 and j2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = raw_input()
f = True

for i in S:
  if S.count(i) != 2:
    f = False
if f:
  print "Yes"
else:
  print "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:
s = input()

def func(s):
  dict = {}
  for i in s:
    dict[i] = 0
  for i in s:
    dict[i] += 1
  for k in dict:
    if not dict[k] == 2:
      print("No")
      return False
  print("Yes")
  return True

func(s)