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()
a1 = s[0]
a2 = s[1]
a3 = s[2]
a4 = s[3]
alis = set()
alis.add(a1)
alis.add(a2)
alis.add(a3)
alis.add(a4)
if len(alis) == 2 and ((a1 == a2 and a3 == a4) or (a1 == a3 and a2 == a4) or (a1 == a4 and a2 == a3)):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

lists = [i for i in s]
sets = set(lists)

if len(sets) != 2:
  print('No')
else:
  if lists.count(lists[0]) == 2:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

Solution code:
import sys
pre_S = input()
S = list(pre_S)

if not ( len(S) == 4 and pre_S.isupper() ): sys.exit()

uniq = set(S)
count = 0
if len(uniq) == 2:
    for I in uniq:
        if S.count(I) == 2: count += 1
print('Yes') if count == 2 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())
ss = set(s)
if len(ss) != 2:
    print('No')
    exit()

for s1 in ss:
    if s.count(s1) != 2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
a=input()
s = {a[0],a[1],a[2],a[3]}
if len(s) == 2:
  b = s.pop()
  flag1 = a.count(b)
  c = s.pop()
  flag2 = a.count(c)
  if flag1 ==2 and flag2 == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()
a = [i for i in s]
a1 = list(set(a))

print("Yes" if len(a1) == a.count(a1[0]) == 2 else "No")

Submission status: Accepted

Solution code:
s = input()
if len(set(s)) == 2 and sum(s[i] == s[-i] for i in range(4))%2 == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 1000000007
sys.setrecursionlimit(1000000)

S = rs()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter
S = Counter(input())
if len(S) == 2:
    for i in S.values():
        print("No" if i != 2 else "Yes")
        break
else:
    print("No")

Submission status: Accepted

Solution code:
S=sorted(list(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:
#create date: 2020-07-12 13:28

import sys
stdin = sys.stdin
from collections import Counter

def ns(): return stdin.readline().rstrip()
def ni(): return int(ns())
def na(): return list(map(int, stdin.readline().split()))

def main():
    s = ns()
    lc = list(Counter(s).values())
    if len(lc) == 2 and lc[0] ==lc[1]:
        print("Yes")
    else:
        print("No")
    

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter as C
 
S = input()
 
c = C(S)
if len(c.keys())==2:
  if list(c.values())[0]==2:
    print("Yes")
  else:
    print("No")
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:
line = list(input())
line.sort()
if line[0] == line[1] and line[2] == line[3] and line[1] != line[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

flg=False
for s in ss:
  if d[s]!=2:
    flg=True
print("No" if flg else "Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(str(input()))
ans=[]
for i in s:
	if i not in ans:
		ans.append(i)

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

Submission status: Accepted

Solution code:
S = input()
temp = S[0]
temp1 = '0'
a = 1
b = 0
c = 0
for i in range(1,4):
  if temp == S[i]:
    a = a+1
  elif temp1 == S[i]:
    c = c+1
  else:
    temp1 = S[i]
    b = b+1
if b == 1 and a == 2 and c == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s1 = s[:1]
for i in range(1, 4):
  if(s[i:i+1] != s1):
    s2 = s[i:i+1]
if(s.count(s1) == 2 and s.count(s2) == 2):
  print("Yes")
else:
  print("No")

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 b == c and a != c:
  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[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:
a=set(input())
if len(a)==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

import datetime
from decimal import Decimal, ROUND_DOWN
import heapq
from fractions import gcd
from functools import reduce
from collections import deque
# from math import factorial
import itertools
import collections
import math
import sys
sys.setrecursionlimit(2000000)
# import statistics
# import numpy as np
# n = int(input())
# n, m, p = list(map(int, input().split()))
# a = list(map(int, input().split()))
#
#  abc = [int(input()) for i in range(5)]
# n = int(input())
#h, w, k = list(map(int, input().split()))
# A = list(map(int, input().split()))
# a = list(map(int, input().split()))
# data = [list(map(int, input().split())) for i in range(n)]
# q = int(input())
# s = list(map(int, input().split()))
# b = list(map(int, input().split()))
# ab_sorted = sorted(ab, key=lambda x: x[0])
# ab = [list(map(int, input().split())) for i in range(n)]
# print(min(15*n, 100*(n//10+1), 100*(n//10)+15*(n % 10)))
s = input()
count = collections.Counter(s)
for i in count.values():
    if i != 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
x,y,z,w = input()

l = []
l.append(x)
l.append(y)
l.append(z)
l.append(w)
new_l = sorted(l)

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

Submission status: Accepted

Solution code:
s = input()
s = list(s)
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:
s = input()
counter = {}
flag = True

for i in s:
    if i not in counter:
        counter[i] = 1
    else:
        counter[i] += 1

for x, y in counter.items():
    if y != 2:
        flag = False
        break

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

Submission status: Accepted

Solution code:
# Vicfred
# https://atcoder.jp/contests/abc132/tasks/abc132_a
# implementation
S = list(input())

if len(set(S)) == 2:
    if S.count(S[0]) == 2:
        print("Yes")
        quit()
print("No")

Submission status: Accepted

Solution code:
S = list(input())

ans = "No"

if len(set(S)) == 2:
    if S.count(S[0]) == 2:
        ans = "Yes"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# n, k = map(int, input().split())
# n = int(input())
# li = list(map(int, input().split()))
s = input()
from collections import Counter
d = Counter(s)
if len(d.keys()) == 2 and all(i == 2 for i in d.values()):
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import math
import itertools
import collections
import heapq
import re
import numpy as np

rr = lambda: sys.stdin.readline().rstrip()
rs = lambda: sys.stdin.buffer.readline().split()
ri = lambda: int(sys.stdin.readline())
rm = lambda: map(int, sys.stdin.buffer.readline().split())
rl = lambda: list(map(int, sys.stdin.readline().split()))
inf = float('inf')
mod = 10**9 + 7

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

Submission status: Accepted

Solution code:
def main():
    a=input()
    b=set(a)
    if(len(b)==2):
        if(a.count(b.pop())==2):
            if(a.count(b.pop())==2):
                print("Yes")
                return;
    print("No")

main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ans(S):
	Sset=set(S)
	if len(Sset)==2:
		for i in Sset:	
			if S.count(i)==2:
				print("Yes")
				return
	print("No")

S=input()
ans(S)

Submission status: Accepted

Solution code:
import collections
dict_values = []


S = input()

c = collections.Counter(S)

d = len(c)


f = list(c.values())



if (d==2) and f[0]==f[1]:
    print("Yes")
    
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    s = input()
    if len(set(s)) == 2 and s.count(list(set(s))[0]) == 2 and s.count(list(set(s))[1]) == 2:
        print('Yes')
    else:
        print('No')
    
if __name__ == '__main__':
    main()

Submission status: Accepted

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

import io
import sys
import math

def solve(s):
    # implement process
    pass

def main():
    # input
    s = input()
    flag = len(set(s)) == 2 and s.count(s[0]) == 2
    ans = "Yes" if flag else "No"
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
AACD
"""
_EXPECTED = """\
Yes
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Submission status: Accepted

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

import io
import sys
import math

def solve(s):
    # implement process
    a,b = "",""
    cnt = 0
    # process
    for c in s:
        if a == "":
            a = c
            cnt += 1
        elif a == c:
            cnt += 1
        elif b == "":
            b = c
        elif b != c:
            return False
    return cnt == 2

def main():
    # input
    s = input()

    ans = "Yes" if solve(s) else "No"
    
    # output
    print(ans)
    return ans
        
### DEBUG I/O ###
_DEB = 0   # 1:ON / 0:OFF

_INPUT = """\
FFEE
"""
_EXPECTED = """\
Yes
"""

def logd(str):
    """usage:
    if _DEB: logd(f"{str}")
    """
    if _DEB: print(f"[deb] {str}")

### MAIN ###
if __name__ == "__main__":
    if _DEB:
        sys.stdin = io.StringIO(_INPUT)
        print("!! Debug Mode !!")

    ans = main()

    if _DEB:
        print()
        if _EXPECTED.strip() == ans.strip(): print("!! Success !!")
        else: print(f"!! Failed... !!\nANSWER:   {ans}\nExpected: {_EXPECTED}")

Submission status: Accepted

Solution code:
def ABC_132_A():
    S = input()
    if S.count(S[0]) != 2 or S.count(S[1]) != 2 or S.count(S[2]) != 2 or S.count(S[3]) != 2:
        print('No')
    else:
        print('Yes')
 
if __name__ == '__main__':
 
    ABC_132_A()

Submission status: Accepted

Solution code:
s = input()
ss = set(s)
flg = True

if len(ss) != 2:
    flg = False

for i in ss:
    if s.count(i) != 2:
        flg = False
    
print('Yes') if flg else print('No')

Submission status: Accepted

Solution code:
S = str(input())
cnt = 0
cha = []
for s in S:
  if s not in cha:
    cha.append(s)
  elif s == cha[0]:
    cnt += 1
  
if len(cha)==2 and cnt==1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
a = list(map(str, input()))
b = []
for i in a:
    if i not in b:
        b.append(i)
if len(b) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = "".join(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:
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
#import fractions#古いatcoderコンテストの場合GCDなどはここからimportする
from functools import lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reversed=True)  #二個目の要素で降順並び替え

    #N = int(input())
    #N, K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    s=input()
    si=Counter(list(s))
    if len(si.keys())!=2 or si[s[0]]!=2:
        print("No")
    else:
        print('Yes')





if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
s = input()
a = list(set(s))
if len(a)==2 and s.count(a[0]):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict
s = str(input())
d = defaultdict(int)
for x in s:
  d[x]+=1
if len(d)==2:
  for key in d:
    if d[key]!=2:
      print("No")
      exit()
  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()
SetS = list(set(S))
if len(SetS)==2 and S.count(SetS[0])==S.count(SetS[1]):
    print('Yes')
else:
    print('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:
A=input()
ans=[]
count=0

for i in range(4):
    if A[i] not in ans:
        ans.append(A[i])
    else:
        count+=1

if count==2 and len(ans)==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:
#!/usr/bin/env python3
s = input()
f = s[0]
print("YNeos"[sum(f == i for i in s) != 2 or len({i for i in s}) != 2::2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print('YNeos'[len({*input()})!=2::2])

Submission status: Accepted

Solution code:
print('YNeos'[len(set(input()))!=2::2])

Submission status: Accepted

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

Submission status: Accepted

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

s = sorted(list(str(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 = 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()
ans = "No"
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]: 
    ans = "Yes"
elif s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    ans = "Yes"
elif s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
s=list(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
apple = []
for i in s:
    apple.append(i)
apple = set(apple)
print("Yes" if len(apple) == 2 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
liste =[x for x in input()]
def pp():
    for loop in range(3):
        if liste.count(liste[loop]) != 2:
            return "No"
    return "Yes"
print(pp())

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inp = list(input())
inpset = set(inp)
inplist = list(inpset)

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

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    if s[0] == s[1] == s[2] == s[3]:
        print('No')
        return
    for i in range(3):
        if s[3] == s[i]:
            s.pop(3)
            s.pop(i)
            if s[0] == s[1]:
                print('Yes')
                return
            print('No')
            return
    print('No')
            
main()

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=[i for i in 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:
string = input()
a,b,c,d = string[0],string[1],string[2],string[3]

def truth(x):
  count = 0
  if a ==b or a==c or a==d:
    count += 1
  if b ==c or b==d:
    count += 1
  if c ==d:
    count += 1
  if a == b == c or a ==b ==d or a==c==d:
    return False
  return count>1

if truth(a): print("Yes")
else: print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
print ("YNeos"[len(''.join(set(sorted(input()))))!=2::2])

Submission status: Accepted

Solution code:
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    S = readline().strip()

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

    return


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
c = Counter(s)
print('Yes' if len(c) == 2 and c[s[0]] == 2 else 'No')

Submission status: Accepted

Solution code:
# 132 A

inp = input()
ans = True

for i in inp:
    y = inp.count(i)
    if y != 2:
        ans = False
        break

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
l=[]
n=[]
l.extend(S)
a=set(l)
if len(a)==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
s1 = 0

for s in S:
    if s == S[0]:
        s1 += 1

print("Yes" if len(set(S)) == 2 and s1 == 2 else "No")

Submission status: Accepted

Solution code:
a1=input()
a2=list(a1)
b=[ord(x) for x in a2]
b.sort()
if len(a2)==4 and b[0]==b[1] and b[2]==b[3] and b[1]!=b[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    s = input()
    count = 0
    for i in range(len(s)):
        for j in range(i+1, len(s)):
            if s[i] == s[j]:
                count += 1
    print('YNeos'[count!=2::2])





if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
import collections
S = input()

c = collections.Counter(S)

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

Submission status: Accepted

Solution code:
s=input()
s1=[]
for i in s:
    if i not in s1:
        s1.append(i)
if len(s1)==2:
    print('Yes')
else:

    print('No')

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)

s = input()

d = {}

for ch in s:
    d[ch] = d.get(ch, 0) + 1
    
if len(d) == 2:
    for k in d:
        if d[k] == 2:
            pass
        else:
            print('No')
            break
    else:
        print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
S1 = []
for i in S:
  if i not in S1:
    S1.append(i)
if len(S1) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

S = input()

c = collections.Counter(S)


if len(c.values()) == 2:
  a, b = c.values()
  if a == b:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

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

if len(chk) == 2 and chk[i] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter

S = str(input())

if all(v == 2 for v in Counter(S).values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = sorted(input())

if S[0]==S[1]==S[2]==S[3]:
  print("No")
elif S[0]==S[1] and S[2]==S[3]:
  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 = 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():
    c = Counter(input())
    if len(c) == 2 and all(v == 2 for v in c.values()):
        print("Yes")
    else:
        print("No")


main()

Submission status: Accepted

Solution code:
a = input()
b = True
for i in set(a):
  if a.count(i) == 2:
    b = "Yes"
  else:
    b = "No"
print(b)

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
C = Counter(s)
D = C.most_common()
print("Yes" if len(D) == 2 and D[0][1] == D[1][1] == 2 else "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()

cnt = [0]*26
for c in s:
    cnt[ord(c) - ord('A')] += 1

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

Submission status: Accepted

Solution code:
s = input()
dic = {}
for x in s:
    if(dic.get(x) is None):
        dic[x] = 1
    else:
        dic[x] += 1

for i in dic.values():
    if(i!=2):
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
def main():
    
    s = list(input())
    if len(set(s)) == 2:
        print('Yes')
    else:
        print('No')
        
if __name__ == '__main__':
    main()