Problem:


Score : 100 points

Problem Statement

You are given a 4-character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S.

Constraints

The length of S is 4.

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.

Sample Input 1

ASSA

Sample Output 1

Yes

S consists of A and S which both appear twice in S.

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No



Sample input:
ASSA


Sample output:
Yes

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import numpy as np

S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
memo = {}
for i in s:
    if i in memo:
        memo[i] += 1
    else:
        memo[i] = 1
if list(memo.values()) == [2, 2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
S = [s for s in input()]
S_sort = sorted(S)
if S_sort[0] == S_sort[1] and S_sort[2] == S_sort[3] and S_sort[1] != S_sort[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

for c in s:
    ss[c] += 1

if sum(ss.values()) == 4 and len(ss) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
string = input()

dict = {}
for s in string:
    if s in dict:
        dict[s] += 1
    else:
        dict[s] = 1

for k in dict.values():
    if k != 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin

def main():
    S = input()

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

input = lambda: stdin.readline().rstrip()
main()

Submission status: Accepted

Solution code:
a = input()
arr = []

for i in range(len(a)):
    arr.append(a[i])

for i in range(len(arr)):
    if arr.count(arr[i]) == 2:
        continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
s = set(S)
flg = True
for a in s:
    n = S.count(a)
    if n!=2:
        flg = False
        break
if flg:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
if len(set(S)) == 2:
	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")
else:
	print("No")

Submission status: Accepted

Solution code:
s = input()

for each in s:
    if s.count(each) != 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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


def f(S):
    X = {}
    for c in S:
        X[c] = X.get(c, 0) + 1

    if len(X) != 2:
        return False

    for key, value in X.items():
        if value != 2:
            return False

    return True


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




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
ans=1
for x in s:
  if s.count(x)!=2:
    ans=0
print("Yes" if ans==1 else "No")

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

if c.most_common()[-1][1] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

l = list(s)
sets = list(set(l))

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

Submission status: Accepted

Solution code:
S=input()
d = {}
for s in S:
    if s not in d:
        d[s] = 1
    else:
        d[s] += 1
if len(d.keys()) == 2 and list(d.values()) == [2, 2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
a, b, c, d = input()
#print(a)

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

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

flag = True
if len(d) == 2:
    for key in d.keys():
        if d[key] != 2:
            flag = False
else:
    flag =  False


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

Submission status: Accepted

Solution code:
s=input()

a=s.count(s[0])
b=s.count(s[1])
c=s.count(s[2])
d=s.count(s[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:
str = input()

ans = False
if str[0] == str[1] and str[2] == str[3]:
    ans = True
elif str[0] == str[2] and str[1] == str[3]:
    ans = True
elif str[0] == str[3] and str[1] == str[2]:
    ans = True

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A,B,C,D=input()
i=0
if A==B and C==D and A!=C:
    i=1
if A==C and B==D and B!=C:
    i=1
if A==D and B==C and A!=C:
    i=1
if i==0:
    print("No")
if i==1:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

L = []
S = input()
for i in range(4):
    L.append(S[i])

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

if len(set([x for x in S])) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = list(input())

uniq = list(set(S))

if len(uniq) != 2 :
    print('No')
else :
    count = {}
    for s in S :
        if s in count :
            count[s] += 1
        else :
            count[s] = 1

    if count[uniq[0]] == 2 :
        print('Yes')
    else :
        print('No')

Submission status: Accepted

Solution code:
S = raw_input()
print "Yes" if [2]*4==[S.count(s) for s in S] else "No"

Submission status: Accepted

Solution code:
S=input()
a=[]
for i in range(0,4):
  a.append(S[i])

a.sort()

ans="No"
if a[0]==a[1]:
  if a[1]!=a[2]:
    if a[2]==a[3]:
      ans="Yes"

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input().strip()
d = defaultdict(int)
for v in s:
    d[v] += 1

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

Submission status: Accepted

Solution code:
S = input()
let_1 = ""
let_2 = ""
count_1 = 0
count_2 = 0
for s in S:
    if s == let_1:
        count_1 += 1
    elif s == let_2:
        count_2 += 1
    elif let_1 == "":
        let_1 = s
        count_1 += 1
    elif let_2 == "":
        let_2 = s
        count_2 += 1
    else:
        print("No")
        exit()

if count_1 == 2 and count_2 == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
c = False
a = s[0]
n = s.count(a)
for i in range(n):
    s.remove(a)
if len(s) == 2:
    if s[0] == s[1]:
        c = True

print("Yes" if c else "No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

S = input()
ans = 0
if S.count(S[0]) == 2:
    for i in range(1,4):
        if S[0] != S[i] and S.count(S[i]) == 2:
            ans = 1

yn(ans)

Submission status: Accepted

Solution code:
s=input()
s_s=set()
for i in s:
    s_s.add(i)
s_s=list(s_s)
if len(s_s)==2:
    a=s_s[0]
    b=s_s[1]
    a_c=0
    b_c=0
    for i in s:
        if i==a:
            a_c+=1
        else:
            b_c+=1
    if a_c==2 and b_c==2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = {s[0] : 1,s[1] : 1,s[2] : 1,s[3] : 1}
print('Yes' if len(l)==2 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

Submission status: Accepted

Solution code:

S=str(input())

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

Submission status: Accepted

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

S = input()

list_str = []
for s in S:
    if not s in list_str:
        list_str.append(s)
if len(list_str) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

a_ = len(set(s))

if s_ == a_*2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import Counter
ct = Counter(input())
a = ct.most_common(2)
if len(a) == 2 and a[0][1] == 2 and a[1][1] == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = list(input())
s0 = list(set(s))
p = s0[0]
ans = 0
for a in s:
    if a == p:
        ans += 1
if len(s0) == 2 and ans == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
from sys import stdin

input=list(stdin.readline().rstrip())

counter=0
word=[]
for i in input:
    if counter==0:
        word.append(i)
        counter+=1
    else:
        if i not in word:
            counter+=1
            word.append(i)

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

Submission status: Accepted

Solution code:
s = input()

tmp_0 = s[0]
if tmp_0 == s[1]:
    if tmp_0 == s[2] or tmp_0 == s[3]:
        print("No")
    else:
        if s[2] == s[3]:
            print("Yes")
        else:
            print("No")
else:
    tmp_1 = s[1]
    if s[2] == tmp_0:
        if s[3] == tmp_1:
            print("Yes")
        else:
            print("No")
    elif s[2] == tmp_1:
        if s[3] == tmp_0:
            print("Yes")
        else:
            print("No")

    else:
        print("No")

Submission status: Accepted

Solution code:
words = lambda t : list(map(t, input().split()))
s = input()

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

Submission status: Accepted

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

SS = sorted(S)

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

Submission status: Accepted

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

flag=True

for s in S_:
    if S.count(s)!=2:
        flag=False

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

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
counter = Counter(s)
if len(counter.keys()) == 2 and list(counter.values())[0] == 2:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
s=input()
d={}
for i in range(4):
    d.setdefault(s[i],0)
    d[s[i]]+=1
check=True
for k in d.values():
    if k!=2:
        check=False
if check:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = str(input())

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

print('Yes')

Submission status: Accepted

Solution code:
yn = lambda b: print('Yes') if b else print('No')

s = input()		# 文字列の入力  abcdefg...

b = True
b = b and (s.count(s[0]) == 2)
b = b and (s.count(s[1]) == 2)
b = b and (s.count(s[2]) == 2)
b = b and (s.count(s[3]) == 2)

yn(b)

Submission status: Accepted

Solution code:
S = input()
if all([S.count(x) == 2 for x in set(S)]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
# -*- encoding: utf-8 -*-
import sys
import re
import random
import numpy as np
from math import sqrt,log
from fractions import gcd  # python<=3.4
from collections import Counter, defaultdict

# st = Counter(raw_input())


ct = list(Counter(raw_input().rstrip()).values())
if ct == [2,2]:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
a=input()
a=[i for i in a]
c=a.count(a[0])
x=0
for i in a:
    if i!=a[0]:
        x=i
c2=a.count(x)
if c==2 and c2==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
s_set = set(s)
if len(s_set) != 2:
  print("No")
else:
  for str in s_set:
    s.remove(str)
  if len(set(s)) != 2:
    print("No")
  else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()
if s[0] == s[1] and s[0] == s[2]:
	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:
from collections import defaultdict

S = input()
d = defaultdict(int)
for s in S:
    d[s] += 1

ret = 'No'
#print(d)
if len(d) == 2:
    for dd in d.values():
        #print(dd)
        if dd == 2:
            ret = 'Yes'
            break

print(ret)

Submission status: Accepted

Solution code:
S = str(input())
slist = [S[i] for i in range(4)]
if len(set(slist))!=2:
  print('No')
elif slist.count(slist[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]) 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 = input()
inn = []
for i in range(4):
  inn += [ord(s[i])]
  
inn.sort()
flag = 1
if inn[0] != inn[1]:
  flag= 0
if inn[1] == inn[2]:
  flag=0
if inn[2] != inn[3]:
  flag=0
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()

for elm in s:
    if s.count(elm) != 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
s=input()

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

if a==2 and b==2 and c==2 and d==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()

d = defaultdict(int)
for s in S:
    d[s] += 1
    
if (len(d)==2) & ([d[s] for s in S] == [2,2,2,2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

cnt = 0

flag = True
for s1 in s:
    for s2 in s:
        if s1 is s2:
            cnt += 1


    if cnt != 2:
        flag = False

    cnt = 0

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

Submission status: Accepted

Solution code:
N = input()

if len(N) != 4:
    print("No")

for n in N:
    if N.count(n) != 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
S = input()

dec = {}

for i in range(4):
    if S[i] not in dec:
        dec[S[i]] = 1
    else:
        dec[S[i]] += 1

ok = True
for i in dec:
    if dec[i] != 2:
        ok = False

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

Submission status: Accepted

Solution code:
S = input()
W = {S[0]: 1}
cnt = 1
for i in range(1, 4):
    if S[i] in W:
        W[S[i]] += 1
        if W[S[i]] == 3:
            print("No")
            break
    else:
        W[S[i]] = 1
        cnt += 1
        if cnt == 3:
            print("No")
            break
else:
    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[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a,b,c,d=list(input())
#print(a,b,c,d)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

S = input()

counter = dict(Counter(list(S)))

if len(counter) == 2 and all([c == 2 for c in counter.values()]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input()
slist=[S[0]]
numlist=[1]
for i in range(1,4):
    if not S[i] in slist:
        slist.append(S[i])

if len(slist)!=2:
    ans='No'
else:
    numlist=[0,0]
    for i in range(4):
        for j in range(2):
            if S[i]==slist[j]:
                numlist[j]+=1
    if numlist[0]==2 and numlist[1]==2:
        ans='Yes'
    else:
        ans='No'

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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


def solve():
    S = input()
    s1 = (S[0] == S[1] and S[1] != S[2] and S[2] == S[3])
    s2 = (S[0] == S[2] and S[2] != S[1] and S[1] == S[3])
    s3 = (S[0] == S[3] and S[3] != S[1] and S[1] == S[2])
    return 'Yes' if (s1 or s2 or s3) else 'No'


def main():
    print(solve())


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

st = input()
for i in range(4):
    if st.count(st[i]) != 2:
        print('No')
        sys.exit()
    if i == 3:
        print('Yes')

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

s=0

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s_dict = dict()
for i in s:
    if i not in s_dict:
        s_dict[i] = 1
    else:
        s_dict[i] += 1
for i in s_dict:
    if s_dict[i] != 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
def resolve():
    ss = input()

    tmp1 = ss[0]
    tmp2 = ""

    cnt1 = 1
    cnt2 = 0
    for s in ss[1:]:
        if s == tmp1:
            cnt1 += 1
        else:
            if tmp2 == "":
                tmp2 = s
                cnt2 = 1
            else:
                if tmp2 == s:
                    cnt2 += 1

    if cnt1 == 2 and cnt2 == 2:
        print('Yes')
    else:
        print('No')
        
resolve()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return sys.stdin.readline().strip()
INF = 10 ** 18
MOD = 10 ** 9 + 7

def main(): 
    s = SI()
    from  collections import Counter
    co = Counter(s)
    if len(co) == 2:
        for i in co:
            if co[i] != 2:
                print('No')
                return
            print('Yes')
            return
    else:
        print('No')
        return
main()

Submission status: Accepted

Solution code:
s = input()

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

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

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

print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

# list(map(int, input().split()))
s = list(input())
v = s[0]
c = Counter(s)
if len(c) == 2 and c[v] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))
class UnionFind():

    def __init__(self, n):
        self.n = n
        self.node = [i for i in range(n)]
        self.size = [1 for _ in range(n)]

    def same(self, x, y):
        return bool(self.root(x) == self.root(y))

    def root(self, x):
        if self.node[x] == x:
            return x
        else:
            self.node[x] = self.root(self.node[x])  # 経路圧縮
            return self.node[x]

    def unite(self, x, y):
        x, y = self.root(x), self.root(y)
        if x == y:
            return  # 結合不要
        if self.size[x] < self.size[y]:
            x, y = y, x
        self.node[y] = x
        self.size[x] += self.size[y]

    def return_size(self, x):
        return self.size[self.root(x)]


s = IS()
s = sorted(s)
if len(s) != 4:
    print('No')
else:
    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()

p = []
l = []
for i in s:
    if i in p:
        l.append(i)
    else:
        p.append(i)
if len(l) == 2 & len(p) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

slist = [i for i in s]

sset = set(slist)

def a():
    if len(sset) == 2:
        for i in sset:
            cnt = 0
            for j in slist:
                if i == j:
                    cnt += 1
            if cnt == 2:
                print("Yes")
                return
            else:
                print("No")
                return
    else:
        print("No")
        return

a()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
w = input()
if w.count(w[0])==2:
  w = w.replace(w[0],"",2)
  if w.count(w[0])==2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

S = Counter(list(input()))


def solve(S):
    if len(S) == 2:
        f = True
        for k, v in S.items():
            if v != 2:
                f = False
        if f:
            print("Yes")
            return 0
    print("No")
    return 0


solve(S)

Submission status: Accepted

Solution code:
s = input()
let = []
one = ''
two = ''
for i in s:
    if i not in let:
        let.append(i)
    elif one == '':
        one = i
    elif one != '' and i != one:
        two = i

if one != '' and two != '':
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
ss = set(S)
if len(ss) == 2:
    co = 0
    for c in S[1:]:
        if  c == S[0]:
            co += 1
    if co == 1:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
input_line = input()
dic = {}
cnt = 0
for s in input_line:
    if s not in dic:
        dic[s] = 0
        cnt+=1

print('Yes' if len(dic.keys()) == 2 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
a=s.count(s[0])
b=s.count(s[1])
c=s.count(s[2])
d=s.count(s[3])
if a==b==c==d==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = len(s)
set_s = set(s)

if l == 4 and len(set_s) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())

s_uniq = set(s)

if len(s_uniq) != 2:
  print("No")
else:
  for ch in s_uniq:
    if s.count(ch) != 2:
      print("No")
      break
  else:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()

for i in range(4):
    if S.count(S[i]) != 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
#!/usr/bin/env python
from collections import defaultdict
import math
import re

def main():
    #H, W = map(int, input().split())
    S = list(input().strip())
    d = defaultdict(int)
    for s in S:
        d[s] += 1

    if len(d) == 2 and all([s == 2 for s in d.values()]):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = list(input())

s = sorted(S)

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