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()
ans = "No"
if len(set(S)) == 2:
    if S[0] == S[1] and S[2] == S[3]:
        ans = "Yes"
    if S[0] == S[2] and S[1] == S[3]:
        ans = "Yes"
    if S[0] == S[3] and S[1] == S[2]:
        ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter


a = input()

wlist = []

for i in a:
    wlist.append(i)

S=Counter(wlist)
if len(S.keys()) == 2:
    if S.most_common()[0][1] == 2:
        print("Yes")
    else:
        print("No")
        exit()
else:
    print("No")
    exit()

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s=list(input())
d = {}
for hoge in s:
  d[hoge] = d.get(hoge, 0) + 1

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

Submission status: Accepted

Solution code:
S = list(input())
c = []
for i in S:
    count = 0
    for j in S:
        if i == j:
            count+=1
    c.append(count)

if c == [2, 2, 2, 2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
sl=list(input())
cl=[]

cl.append(sl[0])

for i in range(1,4):
  if cl.count(sl[i]) == 0:
    cl.append(sl[i])


if len(cl)!=2 :
  answer='No'
elif sl.count(cl[0])==2 and sl.count(cl[1])==2:
  answer='Yes'
else:
  answer='No'
  
print(answer)

Submission status: Accepted

Solution code:
S = input()

S_list = []

for s in S:
    S_list.append(s)

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

Submission status: Accepted

Solution code:
S = list(input())

A = B = S[0]
for char in S:
    if char != S[0]:
        B = char

count1 = S.count(A)
count2 = S.count(B)

if count1 == 2 and count2 == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
if s.count(s[0]) == 2:
  t = [i for i in s if i != s[0]]
  if t[0] == t[1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
a = input()

w = a.count(a[0])
x = a.count(a[1])
y = a.count(a[2])
z = a.count(a[3])

if w == 2 and x == 2 and y == 2 and z == 2:
    print('Yes')

else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

a = S[0]
b = 'b'
a_count = 0
b_count = 0

for i in S:
    if i==a:
        a_count += 1
    else:
        b = i
for i in S:
    if i==b:
        b_count +=1

if a_count == 2 and b_count == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
L = []
for i in range(4):
  if S[i] not in L:
    L.append(S[i])
flag = False
if len(L) == 2:
  t = 0
  for i in range(2):
    if S.count(L[i]) == 2:
      t += 1
  if t == 2:
    flag = True
if flag:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S=input()
s=list(S)
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 = []
tmp = input()

for i in tmp:
    S.append(i)

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

Submission status: Accepted

Solution code:
# cook your dish here
s = input()
a=[0,0,0,0]
b=[1,1,1,1]
for i in range(4):
    for j in range(4):
        if(s[i]==s[j] and i != j):
            a[i]+=1 
if(a==b):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
mojis = []
count = []
for i in input():
    if i in mojis:
        count[mojis.index(i)] += 1
    else:
        count.append(1)
        mojis.append(i)
        
if count == [2,2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
count = 0
k = 0
index = [1,2,3]

for i in [1,2,3]:
    if s[0] == s[i]:
        count = count + 1
        k = i
        index.remove(k)
        
if count == 1:
    if s[index[0]] == s[index[1]]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
S = input()
S_ = list(set(S))
S = np.array(list(S))
S_ = np.array(S_)
ans = 'Yes'
if len(S_)!=2:
    ans = 'No'
elif sum(S==S_[0])!=2:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
lst=list(input())
unique=list(set(lst))
dct={}
is_yes=None
if len(unique)==2:
    len0=len([i for i, c in enumerate(lst) if c == unique[0]])
    len1=len([i for i, c in enumerate(lst) if c == unique[1]])
    if len0==2 & len1==2:
        is_yes=True
    else:
        is_yes=False
else:
    is_yes=False
if is_yes:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:

def solve():
    S = [_ for _ in raw_input()]
    dict = {}
    for ele in S:
        if ele in dict.keys():
            dict[ele] += 1
        else:
            dict[ele] = 1
    if len(dict) == 2 and dict.values() == [2, 2]:
        print 'Yes'
    else:
        print 'No'

if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
# N = list(map(int, input().split()))

S = input()
a = list(S)

a.sort()

# print(a)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

alphaList = []

for alpha in s:

    isExist = False

    for a in alphaList:
        if a == alpha :
            isExist = True
    
    if isExist == False:
        alphaList.append(alpha)

print( 'Yes' if(len(alphaList)==2) else 'No'  )

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
S = input()

arr = {}

for i in S:
    if i in arr:
        arr[i] += 1
    else:
        arr[i] = 1


if len(arr) > 2:
    print("No")
    sys.exit()

if arr[S[0]] is 2:
    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[1]==S[2]):
    if not (S[0]==S[1] and S[1]==S[2]):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
s = str(input()) 


set_s = set(s)

ans = 'Yes'
for i in set_s:
    if s.count(i) != 2:
        ans = 'No'
    
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
temp = ''
for i in s:
    temp += i

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

Submission status: Accepted

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

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

flag = False

if len(d.keys()) == 2:
    for v in d.values():
        if v != 2:
            flag = False
            break
        else:
            flag = True
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
M=input()


if M.count(M[0])+ M.count(M[1])+ M.count(M[2])+ M.count(M[3])==8:
  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]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(str(input()))
import collections
c = collections.Counter(S)
t = c.most_common()
if (len(t) > 1 and t[0][1] == t[1][1] == 2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

else:
    print("No")

Submission status: Accepted

Solution code:
def acinput():
    return list(map(int, input().split(" ")))


def anumber(x):
    return ord(x)-ord("A")


S = input()

cnts = [0]*27

for s in S:
    cnts[anumber(s)] += 1

n2 = 0
for sc in cnts:
    if sc == 2:
        n2 = n2+1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
if not S[0]==S[1]==S[2]==S[3]:
    a = S[0]
    S.pop(0)
    if a in S:
        S.remove(a)
        if S[0]==S[1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')
    
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

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

if min(d.values())==2 and max(d.values())==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections
S = [i for i in input()]
c = collections.Counter(S)
if len(c) != 2:
  print ("No")
else:
  flag = True
  for count in c.values():
    if count != 2:
      print ("No")
      flag = False
      break
  if flag:
    print ("Yes")

Submission status: Accepted

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

for c in S:
    dic[c] = dic.get(c,0)+1

if len(dic) != 2:
    print("No")
else:
    for key in dic:
        if dic[key] != 2:
            print("No")
            break
    else:
        print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

myword = input()

mycounter = Counter(myword)

r = 'Yes'

for v in mycounter.values():
    if v != 2:
        r = 'No'

print(r)

Submission status: Accepted

Solution code:
S = input()

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

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

Submission status: Accepted

Solution code:
import collections

S = list(input())
mymode = collections.Counter(S).most_common()

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

Submission status: Accepted

Solution code:
S=input()
A=[0]*10
flag=0

for i in range(4):
    A[i]=S.count(S[i])

for i in range(4):
    if A[i]!=2:
        flag=1
if flag==0:
    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:
from collections import Counter

def ans():
    S = input()
    c = Counter(S)
    if len(c) != 2:
        print('No')
        return
    for key in c:
        if c[key] != 2:
            print('No')
            return
    print('Yes')

ans()

Submission status: Accepted

Solution code:
S = str(input())

if S.count(S[0]) == 2:
    new_S = S.strip(S[0])
    if new_S.count(new_S[0]) == 2:
        print("Yes")
    else:
        print("No")    
else:
    print("No")

Submission status: Accepted

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

if s[0]==s[1] and s[0]==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()
same = 0
for i in range(3):
    if s[0] == s[i+1]:
        same += 1
if same == 1:
    if s[1] == s[2] or s[2] == s[3] or s[3] == s[1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections

s=input()
c=collections.Counter(s)

ret='Yes'

for v in c.values():
    if v!=2:
        ret='No'

print(ret)

Submission status: Accepted

Solution code:
s = input()

if (( s[0]==s[1] and s[2]==s[3] ) or ( s[1]==s[2] and s[0]==s[3] ) 
   or ( s[0]==s[2] and s[1]==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:
S = input()
if S[0]==S[1]:
	if S[2]==S[3] and S[1]!=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:
lista = input()

a=lista.count(lista[0])
b=lista.count(lista[1])
c=lista.count(lista[2])
d=lista.count(lista[3])
if(a==2 and b==2 and c==2 and d==2):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
s_set = set(s)
count=0
if len(s_set) == 2:
    count = 1
    for i,j in enumerate(s):
        if i>0 and j == s[0]:
             count += 1
if count == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#coding:utf-8

s = str(input())
string  = list(s)
string_unique = list(set(string))

#print(string_unique)

if len(string_unique) == 2:
    if string.count(string_unique[0]) == 1 or string.count(string_unique[0]) == 3:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections

string = str(input())

c = collections.Counter(list(string))
if list(c.values()) == [2, 2]:

    print('Yes')

else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

u = {}
sSet = set(S)
for s in S:
	if s not in u.keys():
		u[s] = 1
	else:
		u[s] += 1
			
if len(sSet) == 2:
	if u[list(sSet)[0]] == 2 and u[list(sSet)[1]] == 2:
		print("Yes")
		exit()
print("No")

Submission status: Accepted

Solution code:
S=list(input())
num=0
for c in S[1:]:
    if c == S[0]:
        num+=1

if S[1]==S[2]:
    num+=1
if S[1]==S[3]:
    num+=1
if S[2]==S[3]:
    num+=1
    
if num==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
N = str(input())
v = [N[i: i+1] for i in range(0, len(N), 1)]
v.sort()
if(v[0]==v[1] and v[2]==v[3]):
    if(v[1]!=v[2]):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
S = sorted(S)

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

Submission status: Accepted

Solution code:
import collections
S = input()
c = collections.Counter(S)
values, counts = zip(*c.most_common())
a = 0
for i in counts:
    if i==2:
        a += 1
    else:
        a *= 0
if a:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S=str(input())
moji=[]
result=[]

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

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

Submission status: Accepted

Solution code:
S = input()
lst = []
for i in S:
    lst.append(i)
s = sorted(lst)
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:
# coding: utf-8
# Your code here!
s=list(input())
ss=set(s)
flg=0
if len(ss)!=2:
    flg=1
ss=list(ss)
for i in ss:
    cnt=s.count(i)
    if cnt!=2:
        flg=1

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

Submission status: Accepted

Solution code:
import sys
import collections


def main():
    S = sys.stdin.readline().strip()
    d = collections.defaultdict(int)
    for c in S:
        d[c] += 1
    for key in d:
        if d[key] != 2:
            print('No')
            return
    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S=input()
S.split()
if S[0]==S[1]:
    if S[2]==S[3]:
        if not S[1]==S[3]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")
elif S[0]==S[2]:
    if S[1]==S[3]:
        if not S[1]==S[2]:
            print("Yes")
        else:
            print("No")
    else:
        print("No")

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

Submission status: Accepted

Solution code:
s = str(input())
s1 = set(s)
s2 = list(s)
cnt = 0
if len(s1) != 2:
    print("No")
else:
    for i in range(1,len(s2)):
        if s[0] == s[i]:
            cnt += 1
    if cnt == 1:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
ans = len(set(s))
if ans == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

def main():
    S=list(map(str,input()))
    l_duplicate = [x for x in set(S) if S.count(x) ==2]

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

if __name__=="__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
count_dict = {}
for i in S:
  if i not in count_dict:
    count_dict[i] = 1
  else:
    count_dict[i] += 1

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

Submission status: Accepted

Solution code:
s = input()

d = {}
for x in list(s):
    if x in d:
        d[x] += 1
    else:
        d[x] = 1

if len(d.keys()) == 2:
    t = True
    for e in d:
        if d[e] != 2:
            t = False
    if t:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())

res_dict = {}

for ch in S:
    if( ch not in res_dict ):
        res_dict[ch] = 1
    else:
        res_dict[ch] += 1

res_flag = False
if( len(res_dict) == 2 ):
    for v in res_dict.values():
        if( v == 2 ):
            res_flag = True
        else:
            res_flag = False
            break

print('YNeos'[not(res_flag)::2])

Submission status: Accepted

Solution code:

S = input()

one = S[0]
two = S[1]
three = S[2]
four = S[3]

count = 0
index = 0

judge = False


for i in range(len(S)):
    if i == 0:
        continue
    if one == S[i]:
        index = i
        count += 1

# print(count)
# print(index)

if index == 1:
    if S[2] == S[3]:
        judge = True

elif index == 2:
    if S[1] == S[3]:
        judge = True

elif index == 3:
    if S[1] == S[2]:
        judge = True

else:
    judge = False


if not(count == 1):
    judge = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
q = set(s)
if len(q) == 2:
    a = s[0]
    c = 0
    for i in range(1,4):
        if s[i] == a:
            c += 1
    if c == 1:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
import collections
S = input()
check = collections.Counter(S)
t = check.values()
ls = list(t)
ls2 = [2, 2]
if ls == ls2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
st=[]
d=[]
for i in s:
    if i in d:
        st[d.index(i)]+=1
    else:
        d.append(i)
        st.append(1)

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

Submission status: Accepted

Solution code:
import sys
s = input()
s1= s[:1]
s2 = s[1:2]
s3 = s[2:3]
s4 = s[3:4]
if s1 == s2:
	if s3 == s4:
		if s1 != s3:
			print("Yes")
			sys.exit(0)
if s1 == s3:
	if s2 == s4:
		if s1 != s2:
			print("Yes")
			sys.exit(0)
if s1 == s4:
	if s2 == s3:
		if s1 != s3:
			print("Yes")
			sys.exit(0)
print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(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:
import fractions
from collections import deque
import numbers as np


def main():
    S = input()
    s1 = S[0]
    S = S[1:]
    s2 = ''
    s1_cnt = 1
    s2_cnt = 0
    for i in range(len(S)):
        if s1 != S[i]:
            if s2 == S[i]:
                s2_cnt += 1
            else:
                s2 = S[i]
                s2_cnt = 1

        else:
            s1_cnt += 1
    print('Yes' if s1_cnt == 2 and s2_cnt == 2 else 'No')


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import collections

s = input()
c = collections.Counter(s)

flag = 0
for i in range(4):
	word = s[i]
	if c[word] != 2:
		flag = 1
		break
	
if flag == 1:
	print("No")
else :
	print("Yes")

Submission status: Accepted

Solution code:
S = input()
sList = list(S)
sList.sort()
c1 = sList.count(sList[0])
c2 = sList.count(sList[2])
print(["No", "Yes"][c1 == 2 and c2 == 2])

Submission status: Accepted

Solution code:
import sys

S = list(input())

set_s = list(set(S))
if len(set_s) != 2:
    print("No")
    sys.exit()

if S.count(set_s[0]) != 2:
    print("No")
    sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
S = raw_input()

count_map = {}

for s in S:
    if s in count_map :
        v = count_map[s]
        count_map[s] = v + 1
    else:
        count_map[s] = 1

answer = True

if len(count_map) == 2:
    for key in count_map.keys():
        if count_map[key] != 2:
            answer = False
            break
else:
    answer = False

if answer :
    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

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

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())
#print(s)

l = []

for i in range(4):
  if not s[i] in l:
    l.append(s[i])
#print(l)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
if len(S) == 4:
    if S.isupper():
        if S[0] == S[1]:
            if S[0] != S[2] and S[2] == S[3]:
                print("Yes")
            else:
                print("No")
        elif S[0] == S[2]:
            if S[0] != S[1] and S[1] == S[3]:
                print("Yes")
            else:
                print("No")
        elif S[0] == S[3]:
            if S[0] != S[2] and S[1] == S[2]:
                print("Yes")
            else:
                print("No")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(map(str, input()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
X=S[0]
i=1
while i<=3:
    if S[i]!=X:
        Y=S[i]
        break
    i+=1
if S.count(X)!=2 or S.count(Y)!=2:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

for i,j in ll:
    if j!=2:
        print("No")
        import sys
        sys.exit()
print("Yes")

Submission status: Accepted

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

if len(S_set) == 2:
  count_1 = S.count(list(S_set)[0])
  count_2 = S.count(list(S_set)[1])
  if count_1 == 2 and count_2 == 2:
  	flag = True

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

Submission status: Accepted

Solution code:
C = list(input())

cnt = 0

for i in range(3):
    if C[3] == C[i]:
        cnt += 1

if cnt == 1 and len(set(C)) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()

s1_sum = 0
s1 = None
s2_sum = 0
s2 = None

for i in s:
    if s1==i:
        s1_sum+=1
    elif s2==i:
        s2_sum += 1
    elif s1 == None:
        s1 = i
        s1_sum=1
    elif s2 == None:
        s2 = i
        s2_sum=1
    else:
        pass
if (s1_sum==2)&(s2_sum==2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import collections
S = input()

cnt = collections.Counter(S)

ans = 'Yes'
if len(cnt) == 2:
    for value in cnt.values():
        if value != 2:
            ans = 'No'
else:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
S = input()
x = set()
f = 0
for s in S:
  if s in x:
    f += 1
  else:
    x.add(s)
if f == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import collections

S = input().strip()

counter = collections.Counter()
for s in S:
    counter[s] += 1

ans = "Yes"
if(len(counter) != 2):
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
S = list(input())
T = S + []

T.sort()
if len(set(S))==2 and T[1]!=T[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
c = Counter(s)
print('Yes' if tuple(c.values()) == (2, 2) else 'No')

Submission status: Accepted

Solution code:
import sys
s = input()
s_map = []

for a in s:
    s_map.append(a)
s_map = list(set(s_map))

for a in s_map:
    if s.count(a) != 2:
        print("No")
        sys.exit()
print("Yes")