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()
ss = sorted(s)

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

Submission status: Accepted

Solution code:
s = input()
ss = sorted(s)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

cnt = 0

for i in range(4):
	cnt += S.count(S[i])
	
if cnt == 8:
	print('Yes')
else:
	print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter

S = Counter(input())

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

Submission status: Accepted

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

if len(set(l)) == 2:
    if l.count(s[0]) == 2:
        print('Yes')
    else:
        print('No')
else:
    print('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 = (list(input()))
S.sort()
if S[0] == S[1] and S[2] == S[3]:
    if len(set(S)) == 2:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
S = input()

count_1 = 0
count_2 = 0

if len(set(S))==2:
    list = list(set(S))

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

Submission status: Accepted

Solution code:
N = input()

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

print("Yes")

Submission status: Accepted

Solution code:
four = input()
four_set = set(four)

if len(four_set) != 2:
    print("No")
else:
    if four.count(list(four_set)[0]) != 2:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
S = input()

P = len(S)
L = set()
for i in range(P):
    L.add(S[i])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
i = reversed(input())
s = "".join(list(i))
if s[0] == s[1] == s[2] == s[3]:
    print("No")
else:
    s = s.replace(s[0], '', 2)
    s = s.replace(s[0], '', 2)
    print("Yes" if len(s) == 0 else "No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python

def main(S):
    ans = 'No'
    letters = set(S)
    tmp = []
    for letter in letters:
        tmp.append(S.count(letter))
    if tmp == [2, 2]:
        ans = 'Yes'
    return ans
    
if __name__ == '__main__':
    S = input()
    print(main(S))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A = input()
B = [i for i in A]
B.sort()
if B.count(B[0]) == 2:
  if B.count(B[-1]) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
A = {}
flag = 0
for i in S:
    if i in A:
        A[i] += 1
    else:
        A[i] = 1
for i in A:
    if A[i] == 2:
        continue
    else:
        flag=1
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = input()

l2 = set(l)

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

Submission status: Accepted

Solution code:
def iread():
    return int(input())


def sread():
    return input()


def aread_int():
    tmp = input().split()
    ret = [int(i) for i in tmp]
    return ret


def aread_str():
    return input().split()


if __name__ == '__main__':
    s = sread()
    s = set(s)
    if len(s) == 2:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = [x for x in input().rstrip()]

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 = [x for x in input().rstrip()]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
import sys
from collections import deque, defaultdict, Counter; from heapq import heappush, heappop
from itertools import permutations, combinations, product, accumulate, groupby
from bisect import bisect_left, bisect_right, insort_left, insort_right
from operator import itemgetter as ig
sys.setrecursionlimit(10 ** 7)
inf = 10 ** 20; INF = float("INF"); ans = 0; tmp = 0; ansli = []; tmpli = []; candili = []
eps = 1.0 / 10 ** 10; mod = 10 ** 9 + 7
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]; ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]; ddn9 = ddn + [(0, 0)]
"""for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:"""
def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]#WideIntPoint
def ws(): return sys.stdin.readline().split()
def i(): return int(sys.stdin.readline())
def s(): return input()
def s_list(): return list(input())
def hi(n): return [i() for _ in range(n)]
def hs(n): return [s() for _ in range(n)]#HeightString
def mi(n): return [wi() for _ in range(n)]#MatrixInt
def num__grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]#NumberGrid
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def grid(n): return [s_list() for _ in range(n)]

s = s()
for moji in range(4):
    cnt = 0
    for i in range(4):
        if s[moji] == s[i]:
            cnt += 1
    if cnt != 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
moji = raw_input()
a,b,c,d = list(moji)
moji = list(moji)
if moji.count(a) == moji.count(b):
    if moji.count(b) == moji.count(c):
        if moji.count(c) == 2:
            print "Yes"
            exit()

print "No"

Submission status: Accepted

Solution code:
from collections import Counter

s = list(input())
s_cnt = Counter(s)
if s_cnt[s[0]] == 2 and len(set(s)) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = input()

str_list = list(a)

str_list.sort()

#print(str_list)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
y = sorted(list(input()))

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

Submission status: Accepted

Solution code:
S=input()

judge=True
for i in range(4):
  counter=int(0)
  for j in range(4):
    if S[i]==S[j]:
      counter+=1
      
  if counter!=2:
    judge=False
    
if judge:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

s = input()

c1 = set(s)
c2 = sorted(s)

if len(c1) == 2 and c2[0] == c2[1] and c2[2] == c2[3]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
t = input()
a = [i for i in t]
b = list(set(a))
if len(b) == 2:
    if a.count(a[0]) ==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
A = list(input())
A_duplicate = [x for x in set(A) if A.count(x) > 1]
if len(A_duplicate) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

if len(s_element) == 2:
    if s.count(list(s_element)[0]) == 2:
        print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
A = "".join(list(set(S)))
if len(A)!=2:
    print("No")
else:
    B = S.replace(A[0],'')
    if len(B)!=2:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
ans = 'No'
a = list({x for x in s})
if len(a) == 2:

  if s.count(a[0]) == 2 and s.count(a[1]) == 2:
    ans = 'Yes'
    
print(ans)

Submission status: Accepted

Solution code:
chars = sorted(list(input()))
#print(chars)
uniq = set(chars)
if(len(uniq) != 2):
  print("No")
elif(chars[1] != chars[2]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
flag = 0
for i in range(1,4):
    for j in range(i):
        if S[i] == S[j]:
            flag +=1

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

Submission status: Accepted

Solution code:
chars = list(input())

result = True
for i in range(4):
  dummy = chars.copy()
  a = dummy.pop(i)
  if not (a in dummy):
    result = False

if len(set(chars)) == 1:
  result = False
    
print("Yes" if result else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = input()
dic = {}
for c in s:
    if c not in dic:
        dic[c] = 1
    else:
        dic[c] += 1
if len(dic.keys()) == 2:
    if dic[c] == 2:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
S = input().strip()
D = {}

for s in S:
    if s in D.keys():
        D[s] += 1
    else:
        D[s] = 1

if len(D) != 2:
    print("No")
else:
    for k, v in D.items():
        if v != 2:
            print("No")
            break
    else:
        print("Yes")

Submission status: Accepted

Solution code:
S = input()
a=1
b=0
x = ''
for i in range(len(S)-1):
    if S[i+1]==S[0]:
        a+=1
    elif b==0 or S[i+1]==x :
        x = S[i+1]
        b+=1
    else:
        print('No')
        exit()
if a==b==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

a = S[0]
b = S[1]
c = S[2]
d = S[3]

i = 0

if a == b:
  i += 1
if a == c:
  i += 1
if a == d:
  i += 1
  
if b == c:
  i += 1
if b == d:
  i += 1
if c == d:
  i += 1

if i == 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:
a = input()
msg1 = "@"
msg2 = "#"
countmsg1 = 0
countmsg2 = 0
flag = 0
for strliteral in a:
    if strliteral == msg1:
        countmsg1 += 1
    elif strliteral == msg2:
        countmsg2 += 1
    else:
        if msg1 == "@":
            msg1 = strliteral
            countmsg1 += 1
        else:
            if msg2 == "#":
                msg2 = strliteral
                countmsg2 += 1
if countmsg2 == 2 and countmsg2 == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
t = list(s.encode('us-ascii'))
t.sort()
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:
S = input()
if (S[0] == S[1]) & (S[1] != S[2]) & (S[2] == S[3]):
  print("Yes")
elif (S[0] == S[2]) & (S[1] != S[2]) & (S[1] == S[3]):
  print("Yes")
elif (S[0] == S[3]) & (S[0] != S[2]) & (S[1] == S[2]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s_list = list(s)

yes_count = 0
for i in range(0, len(s_list)):
    count = s_list.count(s_list[i])
    if count == 2:
        yes_count += 1
    
if yes_count == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
x = input()
if 2 >= x.count(x[0]) > 1 and x.count(x[1]) > 1 and x.count(x[2]) > 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S   =   input()

for i in range(int(len(S))):
    if(S.count(S[i]) !=2 ):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    if(len(set(S)) != 2):
        print("No")
        return
    S_sort = sorted(list(S))
    if (S_sort[1] == S_sort[2]): # ex ['A','B','B','B']
        print("No")
    else:
        print("Yes")

main()

Submission status: Accepted

Solution code:

S = input()

t = {}

for c in S:
	if c in t:
		t[c] += 1
	else:
		t[c] = 1

if len(t) != 2:
	print("No")
elif len(list(filter(lambda c: t[c] != 2, t))) > 0:
	print("No")
else:
	print("Yes")

Submission status: Accepted

Solution code:
#ABC132 A
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()
s = sorted(s)
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:
import sys
input = sys.stdin.readline
from collections import defaultdict

def main():
	s = input().strip()
	m = defaultdict(lambda : 0)
	for c in s:
		m[c] += 1
	# print(len(m))
	v = list(m.values())
	if len(m) == 2 and v[0] == 2 and v[1] == 2:
		print('Yes')
	else:
		print('No')


if __name__ == '__main__':
	main()

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:
w=input();s=list(set(list(w)))
print("YNeos"[len(s)!=2 or w.count(s[0])!=2::2])

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

def main():
	s = input().strip()
	u = set(s)
	if len(u) == 2:
		t = [1, 0]
		c = s[0]
		for i in range(1, 4):
			if c == s[i]:
				t[0] += 1
			else:
				t[1] += 1
		if t == [2, 2]:
			print('Yes')
			return
	print('No')


if __name__ == '__main__':
	main()

Submission status: Accepted

Solution code:
def main():
  s = input()
  if len(set(s)) == 2:
    a = 0
    for i in range(1, 4):
      a += 1 if s[0] == s[i] else 0
    print('Yes' if a == 1 else 'No')
  else:
    print('No')


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
str_list = input()
cnt=0
for i in range(4):
  if str_list[i] == str_list[0]:
    cnt+=1
if (len(set(str_list))==2) and (cnt==2):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

A = dict(c)
B = list(A.keys())

if (len(B) != 2):
    print('No')
    
else:
    if ((A[B[0]] == 2)and(A[B[1]] == 2)):
        print('Yes')
    else:
        print("No")

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
a=list(input())
b = []
for i in range(len(a)):
	if a.count(a[i])==2:
		b.append(a.count(a[i]))
if len(b)==4:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
d = defaultdict(int)
for c in s:
    d[c] += 1
if len(d) == 2 and d[s[0]] == 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[3])==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
h = {}
for s in S:
    h[s] = 1
if len(h.keys()) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
l = list(input())
a = list(set(l))

if len(a) != 2:
  print('No')
elif l.count(a[0]) == 2 and l.count(a[1]) == 2:
  print('Yes')

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:
a = sorted(list(input()))
if a[0] == a[1] and a[1] != a[2] and a[2] == a[3]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=[i for i in input()]
c=0
h={}
for i in s:
    if i not in h:
        h[i]=1
        c+=1
if c==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = str(input())


def solve(S):
    ssort = sorted(S)
    if ssort[0] == ssort[1] and ssort[2] == ssort[3] and ssort[1] != ssort[2]:
        return "Yes"
    return "No"


print(solve(S))

Submission status: Accepted

Solution code:
s = str(input())
tmpset = set()
for char in s:
  tmpset.add(char)
if len(tmpset) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
l = list(input())
unique_l = list(set(l))
err = False

if len(unique_l) == 2:
    for s in unique_l:
        if l.count(s) != 2:
            err = True
            break
else:
    err = True

if not err:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
dic = {}
mes = "Yes"
for l in s:
  if l in dic:
    dic[l] +=1
  else:
    dic[l] = 1
for v in dic.values():
  if v !=2 :
    mes = "No"
print(mes)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

list_sorted = sorted([s[i] for i in range(4)])
if list_sorted[0] == list_sorted[1] and  list_sorted[2] == list_sorted[3] and list_sorted[1] != list_sorted[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())

flag = True
for i in s:
    if s.count(i) != 2:
        flag = False
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
h=set()
for i in range(0,len(s)):
	h.add(s[i])
if(len(h)==2):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
from collections import Counter as c
s=list(input())
a=c(s).most_common(2)
if len(a)==1:
    print("No")
    exit()

if a[0][1]==a[1][1]==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:
a = input()
a = a.replace(a[0], "")
if len(a) != 0:
    a = a.replace(a[0], "")
    if len(a) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
h=set()
for i in range(0,len(s)):
	h.add(s[i])
if(len(h)==2):
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
s = input()
a = [i for i in s]
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:
moji = list(input())
hako = []
for m in moji:
  if m not in hako:
    hako.append(m)
if len(hako) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = list(input())
s.sort()
#print(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:
from copy import *
from sys import *
import math
import queue
from collections import defaultdict,Counter,deque
from fractions import Fraction as frac

setrecursionlimit(1000000)

#dp[i][j]: iまでからj枚えらんで和がkになるのは何通り
def main():
	s =  input()
	if(len(set(s))==2):
		print('Yes')
	else:
		print('No')

def zip(a):
	mae = a[0]
	ziparray = [mae]
	for i in range(1,len(a)):
		if(mae != a[i]):
			ziparray.append(a[i])
			mae = a[i]
	return ziparray

def is_prime(n):
	if n < 2: return False

	for k in range(2, int(math.sqrt(n)) + 1):
		if n % k == 0:
			return False

	return True

def list_replace(n,f,t):
	return [t if i==f else i for i in n]

def base_10_to_n(X, n):
	X_dumy = X
	out = ''
	while X_dumy>0:
		out = str(X_dumy%n)+out
		X_dumy = int(X_dumy/n)
	if(out == ''): return '0'
	return out

def gcd(m,n):
	x = max(m,n)
	y = min(m,n)
	while(x%y!=0):
		z = x%y
		x = y
		y = z
	return y

class queue():
	def __init__(self):
		self.q = deque([])
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.popleft()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class stack():
	def __init__(self):
		self.q = []
	def push(self,i):
		self.q.append(i)
	def pop(self):
		return self.q.pop()
	def size(self):
		return len(self.q)
	def debug(self):
		return self.q

class graph():
	def __init__(self):
		self.graph = defaultdict(list)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
		self.graph[t].append(f)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
		self.graph[t].remove(f)
	def linked(self,f):
		return self.graph[f]

class dgraph():
	def __init__(self):
		self.graph = defaultdict(set)
	def addnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].append(t)
	def rmnode(self,l):
		f,t = l[0],l[1]
		self.graph[f].remove(t)
	def linked(self,f):
		return self.graph[f]

main()

Submission status: Accepted

Solution code:
S = list(input())
cnt = {}
for s in S:
    if s not in cnt:
        cnt[s] = 1
    else:
        cnt[s] += 1
for c in cnt:
    if cnt[c] != 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    dic = {}
    cnt = 0
    for i in s:
        if i not in dic:
            dic[i]  = 1
        else:
            dic[i] += 1
    for key,i in dic.items():
        cnt += 1
        if i != 2 or cnt > 2:
            print('No')
            exit()
    print('Yes')

if __name__ == '__main__':
    main()

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()
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:
N = input() 
a=0
b=0
c=[[2,3],[1,3],[1,2]]

for i in range(1,4):
		if N[i] == N[0]:
			a+=1
			b=i			
if a==1:
	if N[c[b-1][0]] == N[c[b-1][1]]:
		print("Yes")
	else:
		print("No")

else:
	print("No")

Submission status: Accepted

Solution code:
N = input() 
a=0
b=0

d=[1,2,3]
for i in range(1,4):
		if N[i] == N[0]:
			a+=1
			b=i			
if a==1:
	d.pop(b-1)
	if N[d[0]] == N[d[1]]:
		print("Yes")
	else:
		print("No")

else:
	print("No")

Submission status: Accepted

Solution code:
S = input()
mozi = dict()
for i in range(4):
	mozi[S[i]] = 0

for i in range(4):
    mozi[S[i]] += 1

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

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:
s=sorted(list(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()

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

Submission status: Accepted

Solution code:
s = input()
for i in range(3):
  if s.count(s[i])!=2:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
import collections

s= input()
slist = list(s)

flag =0

c = collections.Counter(slist)
values,counts = zip(*c.most_common())

if len(values)==2:
    for i in range(len(counts)):
        counts[i] ==2
        flag =1

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

Submission status: Accepted

Solution code:
S = input()

count = 0
if S[0] == S[1] and S[2] == S[3]:
    count += 1

if S[0] == S[2] and S[1] == S[3]:
    count += 1

if S[0] == S[3] and S[1] == S[2]:
    count += 1

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

Submission status: Accepted

Solution code:
S = input()


S = list(set(S))

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

Submission status: Accepted

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

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

else:
    for i in range(1, len(s)):
        if s[0] == s[i]:
            buf = i
            break
        else:
            buf = 0
    if buf == 0:
        print('No')
    else:
        nokori = []
        for i in range(1, len(s)):
            if i == buf:
                continue
            else:
                nokori.append(s[i]) 
        if nokori[0] == nokori[1]:
            print('Yes')
        else:
            print('No')

Submission status: Accepted

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

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