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().strip()
from collections import defaultdict
d = defaultdict(int)
for c in s:
    d[c] += 1
for k in d:
    if d[k] != 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  s = input()
  count = Counter(s)
  ans = 'Yes'
  for i in count.values():
    if i != 2:
      ans = 'No'
  print(ans)
  
  
  
  
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
S = sorted(str(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:
a=input()
if a[0] is not a[2] or a[0] is not a[3]:
    if a[0] == a[1] and a[2] == a[3]:
        print('Yes')
    elif a[0] == a[3] and a[2] == a[1]:
        print('Yes')    
    elif a[0] == a[2] and a[3] == a[1]:
        print('Yes')
    else:
        print('No')

else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
a = 0
for i in range(len(s)):
  if s.count(s[i]) != 2:
    a += 1
    print('No')
    break
    
if a == 0:
  print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))
from collections import Counter
def main():
    c = Counter(list(input()))
    if len(c) != 2:
        print('No')
        exit()
    if c.most_common()[0][1] != 2:
        print('No')
        exit()
    print('Yes')

if __name__ == '__main__':
    main()

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()
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:
import sys

s = sys.stdin.readline().rstrip()
s = sorted(s)

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

if __name__ ==  '__main__':
    main()

Submission status: Accepted

Solution code:
S = list(input())
for x in S:
  if S.count(x) != 2:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
import itertools
import fractions
def main():
  s = input()
  l = set(s)
  for a in l:
    if s.count(a) !=2:
      print('No')
      exit()
  print('Yes')
  
if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
s = [str(input())]

l = []

for i in range(4):
  l.append(ord(s[0][i]))
  
cl = sorted(l)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

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

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

Submission status: Accepted

Solution code:
from collections import Counter as co
s=co(input())
if all([i==2 for i in s.values()]) and len(s.keys())==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections 
d=collections.defaultdict(int)
s=input()
for i in range(4):
    d[s[i]]+=1
ans="Yes"
for x in d:
    if d[x]!=2: ans="No"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

origin = list(set(list(s)))

if len(origin) > 2:
    print("No")
    exit()
a=0
b=0
for i in s:
    if i == origin[0]: a+=1
    elif i == origin[1]: b+=1

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

Submission status: Accepted

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

print("Yes" if len(d) == 2 and list(d.items())[0][1] == 2 else "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()
if len(set(S)) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=input()

st=set(list(S))
if len(st)==2:
    if S.count(list(st)[0])==2:
        print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
dic = {}
for i in s:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
for j in dic.values():
  if j != 2:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

counter = {}
for c in s:
  if c in counter:
    counter[c] += 1
  else:
    counter[c] = 1

result = True
for k, v in counter.items():
  if v != 2:
    result = False
print("Yes" if result else "No")

Submission status: Accepted

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

if (len(c.keys()) == 2 )and(list(c.values()) == [2,2]):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
from collections import defaultdict
YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(S: str):
    a = defaultdict(int)
    for c in S:
        a[c]+=1
    for c in a:
        if a[c] != 2:
            print(NO)
            exit()
    print(YES)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

print(r)

Submission status: Accepted

Solution code:
S = input()

i = 0
j = 0
count = 0
while i < 4:
    while j<4:
        if S[i] == S[j]:
            count +=1
        j +=1
    i +=1
    j = 0

print('Yes' if count == 8 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=list(str(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:
from collections import Counter

S = Counter([s for s in input()])

if len(S)!=2:
  print('No')
elif sum([1 for v in S.values() if v==2])!=2:
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
S = input()
SS = {}
for i in range(4):
    if(S[i] not in SS.keys()):
        SS[S[i]] = 0
    SS[S[i]] += 1
if(list(SS.values()) == [2,2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input())
c = Counter(S)

if len(c) != 2:
  print("No")
  exit()
else:
  for n in c.values():
    if n != 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] and s[1] != s[2]:
   print('Yes')

else:
   print('No')

Submission status: Accepted

Solution code:
St = input()
n = len(St)
#Stを集合に変換
#集合は同じ要素のダブりはない
#だから要素が何種類あるかすぐにわかる
Se = set(St)

answer = 1
for i in range(n):
    if St.count(St[i]) != 2 :
        answer = 0

#len() は要素の個数がわかる
#だから要素の個数がわかる　つまり　それぞれの文字が文字列中に何個あるかがわかる
#リスト.count(文字)　でリスト中の文字の出現回数がわかる
if len(Se) == 2 and answer == 1:
    print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
St = input()

Se = set(St)

answer = 0

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

Submission status: Accepted

Solution code:
S = input()

answer = 1

if S[0] != S[1]:
	answer = answer + 1

if S[0] != S[2] and S[1] != S[2]:
	answer = answer + 1

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

count0 = 0
count1 = 0
count2 = 0
count3 = 0

for i in range(4):
    if S[0] == S[i]:
    	count0 = count0 + 1
    if S[1] == S[i]:
    	count1 = count1 + 1
    if S[1] == S[i]:
    	count2 = count2 + 1
    if S[2] == S[i]:
    	count3 = count3 + 1

if answer == 2 and count0 ==2 and count1 == 2 and count2 == 2 and count3 == 2 :
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
S = list(input())

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

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()

d = defaultdict(int)

for i in range(len(S)):
    d[S[i]] += 1
f = 0
for i in range(len(S)):
    if d[S[i]] != 2:
        f = 1

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

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()

d = defaultdict(int)

for i in range(len(S)):
    d[S[i]] += 1
f = 0
if len(d) != 2:
    f = 1
for d_key in d:
    if d[d_key] != 2:
        f = 1
        break

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    c_list = list(s)
    result = True
    
    for c in c_list:
        if c_list.count(c) != 2:
            result = False
            break
    
    if result:
        print("Yes")
    else:
        print("No")

main()

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()
print('Yes' if all([s.count(i)==2 for i in set(s)]) else 'No')

Submission status: Accepted

Solution code:
a=input()
ret = True
for s in a:
	sum = 0
	for t in a:
		if s==t:
			sum += 1
	if sum != 2:
		ret = False
if ret:
	print("Yes")
else:
	print ("No")

Submission status: Accepted

Solution code:
# coding: utf-8
import collections

S = input()
# print(S)
c = collections.Counter(S)
# print(c)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# from math import factorial,sqrt
# from itertools import permutations as permus
# from fractions import gcd
from collections import deque,Counter
# from decimal import Decimal, getcontext
# # getcontext().prec = 1000
# # eps = Decimal(10) ** (-100)

# import numpy as np
# import scipy as scp

# 入力の受け取り
s = input()
counter = Counter(s)

ans = "Yes"
if len(counter) !=2:
    ans = "No"
for i,v in counter.items():
    if v != 2:
        ans = "No"

print(ans)
# print("{:.10f}".format(ans))
# print(*ans)   # unpackして出力。間にスペースが入る
# for row in board:
#     print(*row,sep="")    #unpackして間にスペース入れずに出力する

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
d = {}
for i in range(len(s)):
    if s[i] not in d:
        d[s[i]] = 1
    else:
        d[s[i]] += 1
ans = 'Yes'
if len(d.keys()) != 2:
    ans = 'No'
for i in d.keys():
    if d[i] != 2:
        ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
s = str(input())

fact = set(s)
is_two = (len(fact) == 2)

num = []
for i in fact:
    num.append(s.count(i))

if is_two and num == [2, 2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
s = str(input())

tmp = Counter(s)

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

Submission status: Accepted

Solution code:
# A
import sys
s = input()
dic = {}
for c in s:
    if c in dic:
        dic[c] += 1
    else:
        dic[c] = 1
for v in dic.values():
    if v != 2:
        print('No')
        sys.exit()
print('Yes')

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();print('YNeos'[any(s.count(c)!=2 for c in set(s))::2])

Submission status: Accepted

Solution code:
d={}
for c in input():
  d[c]=d.get(c,0)+1
print('YNeos'[len(d)!=2 or max(d.values())>2::2])

Submission status: Accepted

Solution code:
lis = list(input())

lis = sorted(lis)

if (lis[0]!=lis[2]) & (lis[0]==lis[1]) & (lis[2]==lis[3]):
  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 = input()
s1 =(s[0])
s2 =(s[1])
s3 =(s[2])
s4 =(s[3])

c1 = s.count(s1)
c2 = s.count(s2)
c3 = s.count(s3)
c4 = s.count(s4)

if c1 == c2 == c3 == c4 == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter

S = input().strip()
#-----

cnt_S=Counter(S)

if len(cnt_S)==2 and all(1 for i,v in cnt_S.items() if v==2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
s = list(input())
d = {}
keys = set()
for i,name in enumerate(s):
    if name not in d:
        d[name] = 0
        keys.add(name)
    else:
        d[name] += 1
ans = "No"
if len(keys) == 2:
    a = keys.pop()
    b = keys.pop()
    if d[a] == 1 and d[b] == 1:
        ans = "Yes"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
c = 0 ; a = []

s = input()

for i in range(4):
    if s[i] not in  a:
        a.append(s[i])
    else:
        c += 1
    
if len(a) == 2 and c == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S=list(input())
A=len(set(S))
if A==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]) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
def solve():
    S = list(input())
    S.sort()
    ans = 'No'
    if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
        ans = 'Yes'
    return ans

print(solve())

Submission status: Accepted

Solution code:
from collections import defaultdict

def solve():
    S = list(input())
    d = defaultdict(int)
    for key in S:
        d[key] = d[key] + 1
    ans = 'Yes'
    for v in d.values():
        if v != 2:
            ans = 'No'
    return ans

print(solve())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC132 A

def main():
    s = input()

    result = 'Yes'

    for char in set(s):
        if s.count(char) != 2:
            result = "No"
    
    print(result)

if __name__ == '__main__':
    main()

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:
import sys
from collections import Counter

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

S = list(sr())
counter = Counter(S)
bool = True
for v in counter.values():
    if v != 2:
        bool = False

print('Yes' if bool else 'No')
# 20

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:
a = str(input())
s = sorted(a)
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[1] != s[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
from collections import Counter
c = Counter(S)
Sa = set(list(S))
if len(Sa) != 2:
    print("No")
    exit()
for i in Sa:
    if c[i] != 2:
        print("No")
        exit()
print("Yes")

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

Submission status: Accepted

Solution code:
S = input()
count = 0
for i in range(4):
  for j in range(4):
    if S[i] == S[j]:
      count = count + 1
if count == 8:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S=input()
for i in range(4):
    if S.count(S[i])==2:
        continue
    else:
        break
if i==3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())
char_cnt = dict()
cnt = 2
ans = 'Yes'

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

for n in char_cnt.values():
    if n != cnt:
        ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
s = input()
flag = 0
if s[0]==s[1]:
  if s[2]==s[3] and s[0]!=s[2]:
    flag=1
elif s[0]==s[2]:
  if s[1]==s[3] and s[0]!=s[1]:
    flag=1
elif s[0]==s[3]:
  if s[1]==s[2] and s[0]!=s[1]:
    flag=1

if flag:
  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:
s = input()
if len(set(s)) == 2 and s.count(s[0]) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

def main():
    S = input()
    count = [val for val in Counter(S).values() if val == 2]
    print("Yes" if len(count) == 2 else "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:
a = input()
if a.count(a[0])==2 and a.count(a[1])==2 and a.count(a[2])==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys


def main():
    s = list(input())
    set_s = set(s)
    if len(set_s) != 2:
        print("No")
        sys.exit(0)
    for x in set_s:
        if s.count(x) != 2:
            print("No")
            sys.exit(0)
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()
 
Dict = {}
 
for i in range(4):
  s = S[i]
  if s in Dict:
    Dict[s] += 1
  else:
    Dict[s]=1
    
if len(Dict)!=2:
  print("No")
else:
    List = list(Dict.values())
    if List[0]!=2 or List[1]!=2:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
S = input()

Sset = list(set(list(S)))

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

Submission status: Accepted

Solution code:
a,b,c,d = input()
if ((a==b and c==d) or (a==c and b==d) or 
    (a==d and c==b)) and not a==b==c==d:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
print('YNeos'[sum(map(a.count,a))!=8::2])

Submission status: Accepted

Solution code:
a=sorted(input())
if (len(set(a))==2)*(a[1]!=a[2]):print('Yes')
else:print('No')

Submission status: Accepted

Solution code:
a,b,c,d=sorted(input())
if a==b and c==d and b!=c:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(input())
print('YNeos'[sum(map(a.count,a))!=8::2])

Submission status: Accepted

Solution code:
a=list(input())
print('YNeos'[sum([a.count(i) for i in a])!=8::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a,b,c,d=sorted(input())
print('YNeos'[1-(a==b!=c==d)::2])

Submission status: Accepted

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

s = sorted(S)
S = set(S)

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

Submission status: Accepted

Solution code:
a,b,c,d=sorted(input())
print('Yes'if(a==b!=c==d)else'No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A - Fifty-Fifty
s=input()
s1=set(s)
s2=list(s1)
s3=list(s)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print(["No","Yes"][len(set(list(input())))==2])

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

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:
from collections import Counter
S = Counter([s for s in input()])

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

Submission status: Accepted

Solution code:
from sys import stdin

s = [x for x in stdin.readline().rstrip()]

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

Submission status: Accepted

Solution code:
#132_A
s=input()
print('Yes' if len(set(s))==2 and all(s.count(s[i])==2 for i in range(4)) else 'No')

Submission status: Accepted

Solution code:
#132_A
s=input()
print('Yes' if len(set(s))==2 and all(s.count(s[i]) for i in range(4)) else 'No')