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()
d = {}
for i in s:
	if i not in d:
		d[i] = 1
	else:
		d[i] += 1
if len(d.keys()) == 2:
	k = list(d.keys())
	if d[k[0]] == 2 and d[k[1]] == 2:
		print('Yes')
	else:
		print('No')
else:
	print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
S = input()
c = collections.Counter(S)
key = [k for k,v in c.items() if v == 2]
if len(key) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

for i in s:
    
    score  = 0
    for j in s:
        if i == j:
            score += 1

    if score != 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
a=[]
b=0
c=0
for i in n:
    if not i in a:
        a.append(i)
        b+=1
    elif i in a:
        c+=1
if b==2 and c==2 :
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A - Fifty-Fifty
A = str(input())
Acount =[]
ans = 'No'

for i in range(len(A)):
    if A.count(A[i]) == 2:
        Acount.append(2)
    else:
        Acount.append(0)

if Acount == [2,2,2,2]:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
S = list(input())
S.sort()

A = S[0] != S[1]
B = S[2] != S[3]
C = S[1] == S[2]

if A or B or C:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
i = input()
j = [_ for _ in i]
j = set(j)
if len(j) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s  = list(input())
s.sort()

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

Submission status: Accepted

Solution code:
import sys
s = input()

s = [val for val in s]
s.sort()

a = set(s)
if len(a) != 2:
    print("No")
    sys.exit()
if s[1] != s[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
dd = defaultdict(int)
s=input()
for key in s:
    dd[key] += 1

keys=list(set(s))
if len(keys)!=2:
  print("No")
elif dd[keys[0]]==2 and dd[keys[1]]==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import copy
import sys
from _operator import itemgetter
from collections import Counter
from math import log2, pi, ceil

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip()

s = input()
c = Counter(s)
print('Yes' if len(c.keys()) == 2 and max(c.values()) == 2 else 'No')

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = list(input())
s.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
A=list(S)
A.sort()
# S=list(S).sort()
# print(list(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=list(input())
so = set(s)
    
if len(so) == 2 and  [ s.count(c) for c in so ] == [2,2] :
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
import collections
c = collections.Counter(s)
if len(c) == 2:
    if min(c.values()) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
s = [ t for t in s ]
so = set(s)
 
if len(so) == 2 and  [ s.count(c) for c in so ] == [2,2] :
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s1,s2,s3,s4=input()
if s1==s2 and s3==s4 and s1!=s3:
    print("Yes")
elif s1==s3 and s2==s4 and s1!=s2:
    print("Yes")
elif s1==s4 and s2==s3 and s1!=s2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import exit, stdin
from collections import Counter
S = Counter(stdin.readline().rstrip())
if len(S.keys()) == 2 and set(S.values()) == {2}:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
s.sort()

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

Submission status: Accepted

Solution code:
# -*- coding:utf8 -*-

s = input()
ans = 'No'
if s[0] in s[1:] and len(set(s)) == 2:
    ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
s = input()

t = sorted(s)

#print(t)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
s=input()
def judge(s):
  d=Counter(s)
  if len(d) != 2:
    return print("No")
  else:
    for k in d:
      if d[k] != 2:
        return print("No")
  return print("Yes")
judge(s)

Submission status: Accepted

Solution code:
S = input()
if len(set(S)) != 2:
    print('No')
else:
    if [S.count(x) for x in set(S)] == [2,2]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
def main(): 

    S = input()

    List = [] 

    for s in S:
        if s not in List:
            List.append(s)

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()

count=0

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
S = list(S)
S_sorted = sorted(S)
if S_sorted[0] == S_sorted[1] and S_sorted[2] == S_sorted[3] and S_sorted[1] != S_sorted[2]:
    ans = ("Yes")
else:
    ans = ("No")

print(ans)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
dic = {}
for i in range(len(s)):
    c = s[i]
    count = dic.setdefault(c, 0) + 1
    dic[c] = count

result = "Yes"
for k in dic:
    if dic[k] != 2:
        result = "No"

print(result)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s_list = [0] * 4
s_list = sorted([c for c in s])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
from collections import Counter
S = input().strip()
dic = Counter(S)
if len(dic)==2 and dic[S[0]]==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = str(input())

cnt = 0
for x in S:
    if S.count(x) == 2:
        cnt += 1

print ( 'Yes' if cnt == 4 else 'No' )

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
b = len(a)
d = 0

for x in range(b):
    c = a.count(a[x])
    if c == 2:
         d += 1

if d == b:
    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 = input()
a = []
for n in s:
    a.append(n)
if a.count(a[0]) == 2 and a.count(a[1]) == 2 and a.count(a[2]) == 2 and a.count(a[3]) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
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:
inpt = input()
a = []
for i in inpt:
  a.append(i)
a.sort()
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()
res_1 = 0
res_2 = 0
s_1 = s[0]
s_2 = None

for i in range(1, 4):
    if s[i] == s_1:
        res_1 += 1
    elif s[i] == s_2:
        res_2 += 1
    elif not s_2:
        s_2 = s[i]


if res_1 == 1 and res_2 == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
while True:
    try:
        S = list(input())
        dic = {c:S.count(c) for c in set(S)}
        
        if len(dic.keys()) != 2:
            print("No")
        else:
            for cnt in dic.values():
                if cnt != 2:
                    print("No")
                    break
            else:
                print("Yes")
    except:
        break

Submission status: Accepted

Solution code:
from collections import Counter
n = input()
length = len(set(n))
c = Counter(n)

if length == 2 and max(c.values()) ==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    s = sorted(list(input()))

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from sys import stdin

S = stdin.readline().rstrip()
s = set(S)
if len(s)==2 and len(S.replace(S[0], ''))==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = sorted(input())

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:
num = 0
a = input()
s = [str(c) for c in a]
for i in range(4):
    for j in range(i + 1, 4):
        if(s[i] == s[j]):
            num += 1
if num == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

s = input()

def solve(s):
	counter = Counter(s)
	for c in counter:
		if counter[c] != 2:
			return False
	return True

print("Yes" if solve(s) else "No")

Submission status: Accepted

Solution code:
l = list(input())
l2 = list(set(l))
if len(l2) == 2:
  n = 0
  if l[0] == l[1] and l[0] != l[2] and l[0] != l[3]:
    n += 1
  elif l[0] != l[1] and l[0] == l[2] and l[0] != l[3]:
    n += 1
  elif l[0] != l[1] and l[0] != l[2] and l[0] == l[3]:
    n += 1
  else:
    n += 0
  if n == 1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
a,b,c,d = sorted(input())
if a == b and c == d and a != c:
  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:
s = str(input())

strs = set(s)
if len(strs) != 2:
  print("No")
  exit()

for i in strs:
  if len(list(filter(lambda x: i == x, s))) != 2:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
b_list = list(str(input()))
b_list = sorted(b_list)

if b_list[0] == b_list[1] and b_list[1] == b_list[2]:
    print("No")
elif b_list[0] == b_list[1] and  b_list[2] == b_list[3]:
    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:
s = input()
a = set()
for i in s: a.add(i)
if len(a) == 2 and s.count(s[0]) == 2:
    print("Yes")
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
if len(dic) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
from copy import deepcopy
from collections import deque
sys.setrecursionlimit(20000000)


def main():
    from collections import defaultdict
    S = input()
    ans = defaultdict(str)
    for s in S:
        if s in ans:
            ans[s] += 1
        else:
            ans[s] = 1

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

S = sorted(S)

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

Submission status: Accepted

Solution code:
n = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

ch1 = ''
ch2 = ''
ct1 = 0
ct2 = 0
for c in s:
	if ch1 == '':
		ch1 = c
		ct1 += 1
	elif ch1 == c:
		ct1 += 1
	elif ch2 == '':
		ch2 = c
		ct2 += 1
	elif ch2 == c:
		ct2 += 1

if ct1 == 2 and ct2 == 2:
	print('Yes')
else:
	print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# 初項s, 交差dのn個の数列の和
def sum_of_arithmetic_progression(s, d, n):
    return n * (2 * s + (n - 1) * d) // 2


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    S = input()
    c = Counter(S)
    if len(c) == 2 and list(c.items())[0][1] == 2 and list(c.items())[1][1] == 2:
        print(Yes)
    else:
        print(No)


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
word = input()
list1 = list(word)
list1.sort()
if list1[0]!=list1[1]:
    print("No")
elif list1[2]!=list1[3]:
    print("No")
elif list1[0]==list1[2]:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
judge = 'No'
for i in range(len(s)):
    if s.count(s[i]) == 2:
        judge = 'Yes'
    else:
        judge = 'No'
        break
print(judge)

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = sorted(input())

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

Submission status: Accepted

Solution code:
S = list(input())
S.sort()

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

Submission status: Accepted

Solution code:
from collections import Counter
S = Counter(input())
for s, n in S.most_common():
    if n != 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter


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

Submission status: Accepted

Solution code:
s=input()
a=''
b=''
countA,countB = 0,0
aDefined = False
bDefined = False

for char in list(s):
    if char == a :
        countA += 1
    elif char == b:
        countB += 1
    elif not aDefined:
        aDefined = True
        countA += 1
        a = char
    elif not bDefined:
        bDefined = True
        countB += 1
        b = char
    else:
        break
if countA == 2 and countB == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
c = Counter(s)

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

Submission status: Accepted

Solution code:
s = set(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
from collections import Counter
l=[]
for a in Counter(s):
  l.append(a)
if len(l)==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:
s=input()
print("Yes" if s.count(s[0])==2 and s.count(s[1])==2 and s.count(s[2])==2 and s.count(s[3])==2 else "No"   )

Submission status: Accepted

Solution code:
S = input()
S_list = list(S[i] for i in range(len(S)))

S_list.sort()

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

else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
sarched = []
flag = True
for i in range(len(S)):
    if S[i] not in sarched:
        sarched.append(S[i])
        if(S.count(S[i])!=2):flag=False
if flag:print("Yes")
else:print("No")

Submission status: Accepted

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

Submission status: Accepted

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

s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
print("Yes" if len(set(S)) == 2 and len(list(filter(lambda x: x == S[0], S))) == 2 else "No")

Submission status: Accepted

Solution code:
S = list(input())
print("Yes" if len(set(S)) == 2 and len(list(filter(lambda x: x == S[0], S))) == 2 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

LS = list(S)
SLS = sorted(LS)
SS = set(LS)

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

Submission status: Accepted

Solution code:
S = input()

s = sorted(list(S))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter as cc
x = cc(input())
if len(x) != 2:
  print("No")
else:
  found = True
  for i in x.keys():
    if x[i] != 2:
      found = False
  if found:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
s = sorted(s)
cnt = 0
for i in range(4 - 1) :
  if s[i] != s[i + 1] :
    cnt += 1
if cnt == 1 :
  print("Yes")
else :
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

S = str(input())
c = collections.Counter(S)

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

Submission status: Accepted

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