Problem:


Score : 100 points

Problem Statement

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

Constraints

The length of S is 4.

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

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

Sample Input 1

ASSA

Sample Output 1

Yes

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

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No



Sample input:
ASSA


Sample output:
Yes

Submission status: Accepted

Solution code:
S = list(input())
import collections

c = collections.Counter(S)
val = list(c.values())
if len(c.keys()) == 2 and val[0] == val[1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def code_for_A(S, test=None):

    if not test:
        S = input()

    condition = 0
    for s in S:
        condition += S.count(s) != 2

    if condition:
        answer = 'No'
    else:
        answer = 'Yes'

    print(answer)

code_for_A(None, 0)

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:
S = list(str(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()
memo={}
for c in S:
    memo.setdefault(c,0)
    memo[c] += 1

if(len(memo)==2):
    for num in memo.values():
        if(num!=2):
            print("No")
            exit(1)
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin

s = stdin.readline().rstrip()


m = {}

for i in range(len(s)):
    if s[i] in m:
        m[s[i]] += 1
    else:
        m[s[i]] = 1

ans = "Yes"
if len(m) != 2:
    ans = "No"
else:
    l = list(m.values())
    if l[0] != l[1]:
        ans = "No"

print(ans)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter


if __name__ == '__main__':
    S = list(input())

    s = Counter(S)

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

Submission status: Accepted

Solution code:
string = input()
cnt = 0

if len(set([c for c in string])) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys

S = input()

Slist = list(S)

Sset = set(Slist)

if not len(Sset) == 2:
    print("No")
    sys.exit()
    

counters = {}

for c in Slist:
    if not c in counters.keys():
        counters[c] = 1
    else:
        counters[c] += 1

for k in counters.keys():
    if not counters[k] == 2:
        print("No")
        sys.exit()
        
print("Yes")

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:
# coding: utf-8
# Your code here!
import collections

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys

str = input()

for chr in str:
    if str.count(chr) != 2:
        print("No")
        sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
import sys

s = input()

count = Counter(s)

for k, v in count.items():
    if v!=2:
        print('No')
        sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
S = input()

str = ""

dic = {}

for s in S :
    str = s
    if s not in dic :
        dic[s] = 1
    else :
        dic[s] += 1

if len(dic) == 2 and dic[str] == 2 :
    print('Yes')
else :
    print('No')

Submission status: Accepted

Solution code:
s = [i for i in input()]
a = s[0]
b = ""
cnta = 0
cntb = 0
for i in range(1,4):
    if s[i] == a:
       cnta += 1
    elif b == "":
        b = s[i]
        continue
    if s[i] == b:
        cntb += 1

if cnta == 1 and cntb == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
if (s[0]==s[1] and s[2]==s[3] and s[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 = [i for i in input().split()][0]

S_unique = list(set(S))

flag=0
for s in S_unique:
  if S.count(s)!=2:
    print('No')
    flag=1
    break
if flag==0:
  print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter
s = list(input())
D = Counter(s)
for v in D.values():
    if v != 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
if len(set(S)) != 2:
    print("No")
    exit(0)
c = 0
c0 = S[0]
for ch in S:
    if ch == c0:
        c += 1
if c == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

count = 0
for i in dict:
  if 2 == dict[i]:
    count = count +1

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

Submission status: Accepted

Solution code:
import sys

def solve(code):
    counter = {}
    for i in range(len(code)):
        if code[i] not in counter:
            counter[code[i]] = 0
        counter[code[i]] += 1

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


if __name__ == '__main__':
    code = sys.stdin.readline().strip()
    print solve(code)

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]) 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:
S = input()
one = 0
two = 0
strs = ["", ""]

for s in S:
    if strs[0] == s:
        one += 1
    elif strs[1] == s:
        two += 1
    elif strs[0] == "":
        strs[0] = s
        one += 1
    elif strs[1] == "":
        strs[1] = s
        two += 1
    else:
        print("No")
        break
    if one > 2 or two > 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
def main():
    S = input()
    count = {}
    for s in S:
        if not s in count.keys():
            count[s] = 0
        count[s] += 1
    count_sorted = sorted(count.items(), key=lambda x:-x[1])
    if count_sorted[0][1] == 2 and count_sorted[1][1] == 2:
        print("Yes")
    else:
        print("No")
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
data = dict()
for c in s:
    if c not in data:
        data[c] = 1
    else:
        data[c] = data[c] + 1
ans = True
for d in data:
    if data[d] != 2:
        ans = False
print('Yes' if ans and len(data) == 2 else 'No')

Submission status: Accepted

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

s = [c for c in input()]

s_unique = list(set(s))

if len(s_unique) == 2 \
    and s.count(s_unique[0]) == s.count(s_unique[1]) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
if (s[0]==s[1])or(s[0]==s[2])or(s[0]==s[3]):
    if (s[0]==s[1])and(s[0]==s[2])and(s[0]==s[3]):
        print("No")
    else:        
        if s[0]==s[1]:
            if (s[2]==s[3])and(s[0]!=s[2]):
                print("Yes")
            else:
                print("No")
        if s[0]==s[2]:
            if (s[1]==s[3])and(s[0]!=s[1]):
                print("Yes")
            else:
                print("No")
        if 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:
# -*- coding: utf-8 -*-
import sys
import collections

def main():
	#A, B, Q = map(int, input().split(" "))
	S = input()
	
	tmp = S[0]
	tmp2 = S[1]
	tmp3 = S[2]
	tmp4 = S[3]
	
	if tmp == tmp2 and tmp2 == tmp3 and tmp3 == tmp4:
		print("No")
		sys.exit()
	
	if tmp == tmp2 and tmp3 == tmp4:
		print("Yes")
	elif tmp2 == tmp3 and tmp == tmp4:
		print("Yes")
	elif tmp == tmp3 and tmp2 == tmp4:
		print("Yes")
	else:
		print("No")
	
		
	
	
if __name__ == "__main__":
	main()

Submission status: Accepted

Solution code:
s = str(input())

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

Submission status: Accepted

Solution code:
s= input()
dic={}
for i in s:
    if i in dic:
        dic[i]+=1
    else:
        dic[i]=1
flag=True
for i in dic:
    if dic[i]!=2:
        flag=False
if flag:
    if len(dic)==2:
        print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def read():
    S = input().strip()
    return S, 


def solve(S):
    count = [0] * 26
    S = sorted(S)
    if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':
    inputs = read()
    print(solve(*inputs))

Submission status: Accepted

Solution code:
a=""
b=[]
a=input()
for x in a:
    b.append(x)

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

Submission status: Accepted

Solution code:
s = str(input())
dic = {}
for i in range(4):
    t = s[i]
    if t not in dic:
        dic[t] = 1
    else:
        dic[t] += 1
ans = "No"
if len(dic)==2:
    count = 0
    for t in dic:
        count+=1
        if dic[t]!=2:
            break
        if count == 2:
            ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
def ans(s):
    s = list(sorted(s))
    if (s[0] == s[1]) & (s[2] == s[3]) & (s[0] != s[2]):
        return True
    else:
        return False

s = input()
if(ans(s) == True):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
s=list(str(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:
x=input()
y=len(set(x))
print('Yes' if y==2 else 'No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()

num = len(set(list(s)))

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a = []
for i in s:
    a.append(i)

a.sort()

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
#A
s= input()
flg = False
for itm in s:
    if s.count(itm) != 2:
        flg = True
        break
if flg:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
#!/usr/bin/python3

import sys

def solve(input: str):
    count = {}
    for char in list(input):
        if char not in count:
            count[char] = 0
        count[char] += 1
    if len(count) != 2:
        return False
    for _, v in count.items():
        if v != 2:
            return False
    return True

def main():
    inputs = sys.stdin.read().rstrip()
    if solve(inputs):
        print("Yes")
    else:
        print("No")

main()

Submission status: Accepted

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

ll=sorted(l)

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

Submission status: Accepted

Solution code:
S = input()

d = {}

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

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

Submission status: Accepted

Solution code:
a,b,c,d = input()
answer = 'No'

if a ==b:
  if c ==d and a!=c:
    answer = 'Yes'
    
if b ==c:
  if d ==a and b!=d:
    answer = 'Yes'
    
if a == c:
  if b ==d and a!=b:
    answer = 'Yes'

print(answer)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

h = {}
for c in s:
  if c not in h:
    h[c] = 0
  h[c] += 1

count_eq_2 = True
for c in h:
  if h[c] != 2:
    count_eq_2 = False
    
if len(h) == 2 and count_eq_2:
  ans = 'Yes'
else:
  ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
a = list(input())
a.sort()
ret = "No"
if a[0]==a[1] and a[2]==a[3] and a[0] != a[2]:
    ret = "Yes"
print(ret)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
str = input()
h = {}
count = 0
for c in list(str):
    if c in h:
        h[c] += 1
    else:
        count += 1
        h[c] = 1
if len(h.keys()) != 2:
    print("No")
    exit(0)
for v in h.values():
    if v != 2:
        print("No")
        exit(0)
print("Yes")

Submission status: Accepted

Solution code:
S = input()
unique = set(S)

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

for u in unique:
    if S.count(u) != 2:
        print("No")
        exit()
    
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 not(S[0]==S[1]==S[2]==S[3]):
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
S = str(input())

a = b = c = d= 0

for i in S:
    if(i==S[0]):
        a=a+1
    if(i==S[1]):
        b=b+1
    if(i==S[2]):
        c=c+1
    if(i==S[3]):
        d=d+1
if(len(S)==4 and a==b==c==d==2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
from sys import stdin
import numpy as np

def main():
    #pass
    S = list(input())
    if len(set(S)) != 2:
        print("No")
        return
    else:
        count=0
        for i in range(1, 4):
            #print(S[0],S[i])
            if S[0]==S[i]:
                count+=1
        if count==1:
            print("Yes")
        else:
            print("No")
        return
    

if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()
a = 0
s_list = list(s)
s_set_list = list(set(s_list))
if len(s_set_list) == 2:
  a += 1
s_list.sort()
if (s_list[0] == s_list[1]) and (s_list[2] == s_list[3]):
  a += 1
if a == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import collections

arr = list(input())
arr2 = collections.Counter(arr)
count_list = list(arr2.values())
if count_list == [2,2]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = list(input())
count = {}

for i in S:
  if count.get(i) is None:
    count[i] = 1
  else:
    count[i] += 1

num = 0
for i in count:
  if count[i] != 2:
    print("No")
    break
  else:
    num += 1
  if num == 2:
    print("Yes")

Submission status: Accepted

Solution code:
import sys

def main():
    # [int(i) for i in sys.stdin.readline().strip().split()]
    s = sys.stdin.readline().strip()
    set(s)
    if len(set(s)) == 2:
        ret = 'Yes'
        for i in s:
            if s.count(i) != 2:
                ret = 'No'
    else:
        ret = 'No'
    return ret
print(main())

Submission status: Accepted

Solution code:
S = input()
s = set()
ans = "No"
for i in S:
    s.add(i)
if len(s) == 2:
    num = 0
    for i in S:
        if i == S[0]:
            num+=1
    if num == 2:
        ans = "Yes"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
a = 0
for i in range(0,4):
    a += S.count(S[i])
if(a == 8):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
S = list(input())
s = set(S)
if len(s) != 2:
    print("No")
    sys.exit(0)

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]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

Sl = list(S)
flag = True
for i in range(4):
    if Sl.count(Sl[i])==2:
        pass
    else:
        flag = False
        break
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
d = {}
for i in range(len(S)):
    d[S[i]] = 1
if len(d) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = [c for c in input()]
s.sort()

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

Submission status: Accepted

Solution code:
S = input()

a = 1
b = 1
first = S[0]
second = ""
for i in range(3):
    if S[i+1] == first:
        a += 1
    elif second == "":
        second = S[i+1]
    elif second == S[i+1]:
        b+= 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())

a = s.count(s[0])

if (s[0] == s[1]):
    ss = s[2]
else:
    ss = s[1]

b = s.count(ss)

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

Submission status: Accepted

Solution code:
import sys
import numpy as np
sys.setrecursionlimit(1000000)
 
s = input()

s0 = s[0]
s1 = s[1]
s2 = s[2]
s3 = s[3]

if s0 == s1 and s2 == s3 and not s0 == s2:
    print("Yes")
    exit()
if s0 == s2 and s1 == s3 and not s0 == s1:
    print("Yes")
    exit()
if s0 == s3 and s1 == s2 and not s0 == s1:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
s = input()
a = {}
for i in s:
  if not i in a.keys():
    a[i] = 0
  a[i] += 1
if len(a) == 2 and min(a.values()) == 2 and max(a.values()) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
data_list = [x for x in input()]
word_first = data_list[0]
word_second = data_list[1]
word_third = data_list[2]
if data_list.count(word_first) ==2 and data_list.count(word_second) == 2 and data_list.count(word_third) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

s = input()

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

Submission status: Accepted

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

# input
S = list(input())

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

# output
print(ans)

Submission status: Accepted

Solution code:
n = input()

if n.count(n[0]) == 2 and n.count(n[1]) == 2 and n.count(n[2]) == 2 and n.count(n[3]) == 2:
    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:
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from collections import Counter
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    s = Counter(input()).values()
    print('Yes' if s == [2, 2] else 'No')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = list(input())

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

for i in range(4):
    if C[i] != 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
"""
# 標準入力取得
## 文字列
 = sys.stdin.readline().rstrip()
 = list(sys.stdin.readline().rstrip())

## 数値
 = int(sys.stdin.readline())
 = map(int, sys.stdin.readline().split())
 = list(map(int, sys.stdin.readline().split()))
 = [list(map(int,list(sys.stdin.readline().split()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

# 0埋め, 小数点出力桁指定時のときの出力
a = 100
b = 0.987654321
print("{0:06d}-{1:6f}".format(a,b))
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)

mod = 1000000007

if __name__ == "__main__":
    S = list(sys.stdin.readline().rstrip())
    a = S[0]
    if S.count(a) > 2:
        print("No")
        exit()
    S = S[1::]
    if a in S:
        S.remove(a)
    else:
        print("No")
        exit()
    b = S[0]
    S = S[1::]
    if b in S:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
s=input()

s2=sorted(s)

res='No'

if s2[0]==s2[1] and s2[2]==s2[3] and s2[1]!=s2[2]:
	res='Yes'

print(res)

Submission status: Accepted

Solution code:
import sys
s= input()

a = s[0]
b = []
count = 0
for i in range(3):
    if s[i+1] == a:
        count += 1
    else:
        b.append(i+1)

if count == 1:
    if s[b[0]] == s[b[1]]:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

def solve():
    S = input()

    def func(s):
        moji_dic = {}
        for moji in s:
            if not moji in moji_dic:
                moji_dic[moji] = 0
            moji_dic[moji] += 1
        
        if len(moji_dic.keys()) != 2:
            return False
        
        for v in moji_dic.values():
            if v != 2:
                return False
        
        return True
    
    if func(S):
        print("Yes")
    else:
        print("No")

if __name__ == "__main__":
    solve()

Submission status: Accepted

Solution code:
s = input().rstrip()

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

s2 = ''
for c in s:
    if s1 != c:
        s2 = c
        break

if s.count(s2) != 2:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
x = str(input())
r = set([])
r.add(x[0])
r.add(x[1])
r.add(x[2])
r.add(x[3])
if len(r) == 2:
    t = list(r)
    a = x.count(t[0])
    b = x.count(t[1])
    if a == 2 and b == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

kind_num = 0

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

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

print('No')