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

Solution (Python):
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]







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

Solution (Python):
S = input()
lst = list(S)

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

else:
    print("No")

Solution (Python):


import sys

a= dict()
for x in sys.stdin.readline().strip(): a[x]= a.get(x,0) + 1

ans= "Yes"
for v in a.values():
    if v!=2: ans="No"
print( ans )

Solution (Python):
S = input()

set_S = set(S)

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

print('Yes')

Solution (Python):
s = list(input())

from collections import Counter

c = Counter(s)

for i in c.values():
    if i !=2:
        print("No")
        exit()
    else:
        pass

print("Yes")

Solution (Python):
S = input()
d = {}

ans = 'Yes'
for i in range(len(S)):
    if S[i] in d:
        d[S[i]] += 1
    else:
        d[S[i]] = 1

    if d[S[i]] > 2:
        ans = 'No'
        break

if len(d) != 2:
    ans = 'No'

print(ans)

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):

import sys
from operator import itemgetter

from fractions import gcd

from math import ceil, floor

from copy import deepcopy

from itertools import accumulate






from collections import Counter
import math
from functools import reduce




input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())



YES = "Yes"  
NO = "No"  


def solve(S: str):
    lisS = sorted(S)
    if lisS[0] == lisS[1] and lisS[2] == lisS[3] and lisS[1] != lisS[2]:
        print(YES)
    else:
        print(NO)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)


if __name__ == '__main__':
    main()

Solution (Python):
s = input()

a = []
for si in s:
    a.append(si)

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

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

Solution (Python):
S = input()
St = list(set(S))
arr = []
for i in range(len(St)):
    arr.append(S.count(St[i]) == 2)

print("Yes" if all(arr) else "No")

Solution (Python):
s = input()
ans = "Yes"
for i in range(4):
    if s.count(s[i:i+1]) != 2:
        ans = "No"
print(ans)

Solution (Python):
import collections
s = input()
k = collections.Counter(s)
ans = "Yes"
if (len(k) == 2):
    for i in k.values():
        if  i != 2:
            ans = "No"
            break
else:
    ans = "No"
print(ans)

Solution (Python):
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    

    s = input()

    for i in s:
        if s.count(i) != 2:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()

Solution (Python):

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

Solution (Python):
from collections import Counter

c = Counter(input())
print(['No','Yes'][len(c) == 2 and list(c.values())[0] == 2 and list(c.values())[1] == 2])

Solution (Python):

S = input()
slist = []

for i in range(4):
    slist.append(S[i])
    
slist.sort()
    
if slist[0] == slist[1] and slist[2] == slist[3] and slist[1] != slist[2]:
    print("Yes")
else:
    print("No")

Solution (Python):

from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    s = input()
    c = Counter(s)
    if len(c) == 2 and set(c.values()) == {2}:
        print('Yes')
    else:
        print('No')





BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

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

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


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")



if __name__ == "__main__":
    main()

Solution (Python):
S = input()

a = list(set(S))
b,c = 0,0

for i in range(4):
    if S[i] == a[0]:
        b += 1
    elif S[i] == a[1]:
        c += 1

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

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

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

Solution (Python):
S = input()
D = set(S)
def f():
    if len(D) != 2:
        return False

    for d in D:
        if S.count(d) != 2:
            return False
    return True

print("Yes" if f() else "No")

Solution (Python):
s = input()

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

Solution (Python):
import collections

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

Solution (Python):
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")

Solution (Python):
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')

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

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

Solution (Python):
S=list(input())
s=list(set(S))
if len(s)!=2:
    print('No')

elif S.count(s[0])==2 and S.count(s[1])==2:
    print('Yes')
else:
    print('No')

Solution (Python):

S = input()

a = S[0]
S_a = S.replace(a,'')

ans = 'No'
if len(S_a) == 2:
    if S_a[0]==S_a[1]:
        ans = 'Yes'



print(ans)

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

Solution (Python):
s = input()
l = []
for a in s:
    l.append(a)
if len(set(l)) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = list(input())
s = list(set(S))
ans = 'No'
if len(s) == 2:
    if S.count(s[0]) == 2:
        ans = 'Yes'

print(ans)

Solution (Python):
from collections import Counter

s = input()
ctr = Counter(s)
if all(v == 2 for _, v in ctr.most_common()):
    print('Yes')
else:
    print('No')

Solution (Python):

from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

S = input()
T = list(set(S))

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

Solution (Python):
s = input()
s_ = set(s)
for i in s_:
    if s.count(i) != 2:
        print('No')
        break
else:
    print('Yes')

Solution (Python):
import collections
S = input()
S = collections.Counter(S)
check = True
if len(S)==2:
    for key,value in S.items():
        if value!=2:
            check=False
else:
    check=False

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

Solution (Python):
import collections


def main():
    ctr = collections.Counter(input())
    if tuple(ctr.values()) == (2, 2):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Solution (Python):

"""
AtCoder A
"""

import sys, math, random
import numpy as np








inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



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

    
    
if __name__ == "__main__":
    main()

Solution (Python):
from collections import Counter

Ss = input()

num = len(set(Ss))
cnt = Counter(Ss)

if num == 2 and min(cnt.values()) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections

S = input()
d = collections.defaultdict(lambda :0)

for c in S:
    d[c] += 1

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

Solution (Python):
from collections import Counter
S = Counter(input())
if all([v == 2 for v in S.values()]):print("Yes")
else:print("No")

Solution (Python):
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")

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

Solution (Python):
S = input()
ans = 'Yes'

for i in range(len(S)):
    if S.count(S[i])!=2:
        ans = 'No'

print(ans)

Solution (Python):
import collections


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

if len(c) != 2:
    print('No')
    exit()
else:
    for k in c.keys():
        if c[k] != 2:
            print('No')
            exit()

print('Yes')

Solution (Python):
S = input()
print("Yes" if sum([2==S.count(ch) for ch in S])==4 else "No")

Solution (Python):
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')

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

Solution (Python):
S = input()
for i in range(len(S)):
    if S.count(S[i]) != 2:
        print('No')
        exit(0)

print('Yes')

Solution (Python):
S = input()

A = set(S)
ans = (
    'Yes' if len(A) == 2 and all(S.count(a) == 2 for a in A) else
    'No'
)

print(ans)

Solution (Python):
S = input()
L = set([str(s) for s in S])
if len(L) == 2 and S.count(S[0]) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

S = sys.stdin.readline().rstrip()

S = list(S)
S.sort()

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

Solution (Python):
S = input()
dic = {}
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
a = list(dic.values())
if a.count(2) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):





S = str(input())
ret = set()
for c in S:
  ret.add(S.count(c))
if 2 in ret and len(ret)==1:
  print("Yes")
else:
  print("No")

Solution (Python):
def inpl(): return map(int, input().split())
from collections import Counter
S = input()
C = Counter(S)
K = list(C.keys())
if len(K) == 2 and C[K[0]] == C[K[1]] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

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

Solution (Python):
S = list(input())
S = sorted(S)

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

Solution (Python):
from collections import defaultdict
N = input()
di = defaultdict(int)
for i in N:
    di[i]+=1
for j in di:
    if(not di[j]==2):
        print('No')
        break
else:
    print('Yes')

Solution (Python):
s = input()
ls = set(list(s))
flag = True
for i in ls:
    if(s.count(i) != 2):
        flag = False
if(flag):
    print("Yes")
else:
    print("No")

Solution (Python):
moji=input()
list=[]

for mj in moji:
    list.append(mj)

list=sorted(list)

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

Solution (Python):
from collections import Counter

s = input()
counter = Counter(s)
if len(counter) != 2:
    print("No")
    exit()

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

print("Yes")

Solution (Python):
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")

Solution (Python):
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')

Solution (Python):
import sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): 
    return list(map(int,input().split()))
def m(): 
    return map(int,input().split())
def onem(): 
    return int(input())
def s(x): 
    a = []
    aa = x[0]
    su = 1
    for i in range(len(x)-1):
        if aa == x[i+1]:
            a.append([aa,su])
            aa = x[i+1]
            su = 1
        else:
            su += 1
    a.append([aa,su])
    return a
def jo(x): 
    return " ".join(map(str,x))
def max2(x): 
    return max(map(max,x))

l = list(input())

k = cl.Counter(l)

jj = k.most_common()

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

Solution (Python):
S=input()
from collections import Counter
if list(Counter(S).values())==[2,2]:
    print("Yes")
else:
    print("No")

Solution (Python):
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')

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

Solution (Python):

from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

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

import random
import collections
import math
import itertools
import bisect

def real_main():
    c = collections.Counter(read())
    for k, v in c.items():
        if v != 2:
            print("No")
            return
    print("Yes")


def solve():
    pass


def main():
    if False and 'PYCHARM_HOSTED' in os.environ:
        main_pycharm()
    else:
        real_main()


from copy import deepcopy
def main_pycharm():
    solution = solve

    test_inputs = None
    test_outputs = None
    judge = None
    slow_solution = None
    if solution is not None:
        if test_outputs is not None:
            test_with_answers(solution, test_inputs, test_outputs)
        if judge is not None:
            test_with_judge(solution, test_inputs, judge)
        if slow_solution is not None:
            test_with_slow_solution(solution, test_inputs, slow_solution)


def test_with_answers(solution, inputs, answers):
    total, wrong = 0, 0
    for args, test_ans in zip(inputs, answers):
        ans = solution(*deepcopy(args))
        if ans != test_ans:
            print('WRONG! ans=%s, test_ans=%s, args=%s' % (ans, test_ans, args))
            wrong += 1
        else:
            print('GOOD')
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))


def test_with_judge(solution, inputs_gen, judge):
    total, wrong = 0, 0
    for args in inputs_gen:
        ans = solution(*deepcopy(args))
        if not judge(deepcopy(ans), *deepcopy(args)):
            print('WRONG! ans=%s, args=%s' % (ans, args))
            wrong += 1
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))


def test_with_slow_solution(solution, inputs_gen, solution_slow):
    total, wrong = 0, 0
    for args in inputs_gen:
        ans = solution(*deepcopy(args))
        slow = solution_slow(*deepcopy(args))
        if ans != slow:
            print('WRONG! ans=%s, slow=%s, args=%s' % (ans, slow, args))
            wrong += 1
        total += 1
    print('ALL %d TESTS PASSED' % total if not wrong else '%d out of %d tests are WRONG' % (wrong, total))

def generate_nums(n, min, max, check_if_good=None):
    while True:
        nums = [random.randint(min, max) for _ in range(n)]
        if check_if_good is None or check_if_good(nums):
            return nums



def mergesort(A, key=lambda x: x, reverse=False):
    C = A
    A = list(range(len(A)))
    B = list(A)

    n = len(A)
    for i in range(0, n - 1, 2):
        if key(C[A[i]]) > key(C[A[i ^ 1]]):
            A[i], A[i ^ 1] = A[i ^ 1], A[i]

    width = 2
    while width < n:
        for i in range(0, n, 2 * width):
            R1, R2 = min(i + width, n), min(i + 2 * width, n)
            j, k = R1, i
            while i < R1 and j < R2:
                if key(C[A[i]]) > key(C[A[j]]):
                    B[k] = A[j]
                    j += 1
                else:
                    B[k] = A[i]
                    i += 1
                k += 1
            while i < R1:
                B[k] = A[i]
                k += 1
                i += 1
            while k < R2:
                B[k] = A[k]
                k += 1
        A, B = B, A
        width *= 2

    if reverse:
        A.reverse()
    return A

def mergesort_simple(A, reverse=False):
    C = A
    A = list(range(len(A)))
    B = list(A)

    n = len(A)
    for i in range(0, n - 1, 2):
        if C[A[i]] > C[A[i ^ 1]]:
            A[i], A[i ^ 1] = A[i ^ 1], A[i]

    width = 2
    while width < n:
        for i in range(0, n, 2 * width):
            R1, R2 = min(i + width, n), min(i + 2 * width, n)
            j, k = R1, i
            while i < R1 and j < R2:
                if C[A[i]] > C[A[j]]:
                    B[k] = A[j]
                    j += 1
                else:
                    B[k] = A[i]
                    i += 1
                k += 1
            while i < R1:
                B[k] = A[i]
                k += 1
                i += 1
            while k < R2:
                B[k] = A[k]
                k += 1
        A, B = B, A
        width *= 2

    if reverse:
        A.reverse()
    return A




BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

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

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

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

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


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


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


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

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

def read():
    return input()

def read_int():
    return int(input())

def read_array(sep=None, maxsplit=-1):
    return input().split(sep, maxsplit)

def read_int_array():
    return [int(a) for a in read_array()]



if __name__ == "__main__":
    main()

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

Solution (Python):
S = list(input())
flag = True
for s in S:
    if S.count(s) == 2:
        pass
    else:
        flag = False

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

Solution (Python):
s = input()
import collections
c = collections.Counter(s)

if len(c) == 2 and all([c[k]==2 for k in c]):
    print('Yes')
else:
    print('No')

Solution (Python):
from collections import defaultdict as dd, deque
C = dd(int)
for c in input():
    C[c] += 1
if len(C) == 2 and all(v == 2 for v in C.values()):
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
index=0
valL=[]
countL=[]
index=0
while index < len(s):
    if s[index] in valL:
        targetI = valL.index(s[index])
        countL[targetI]+=1
    else:
        valL.append(s[index])
        countL.append(1)
    index+=1
if len(valL) == 2:
    if countL[0]==2 and countL[1]==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
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')

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

Solution (Python):

S = list(input())
if len(set(S)) == 2:
    cnt = 0
    for s in set(S):
        if S.count(s) == 2:
            cnt += 1
    if cnt == 2:
        print("Yes")
        exit()
print("No")

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

Solution (Python):
S = input()
P = set(S)

if len(P) == 2:
    for i in P:
        if S.count(i) != 2:
            print('No')
            exit()
else:
    print('No')
    exit()
print('Yes')

Solution (Python):
s=input()
ans='No'
if len(set(s))==2:
    ans='Yes'
print(ans)

Solution (Python):
s = input()

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

Solution (Python):
from collections import Counter
S = input()
c = Counter(S)
if len(c)==2:
    if c[S[0]]==2:
        print('Yes')
        exit()
print('No')

Solution (Python):
S = input()

flag = True

for ch in S:
    if S.count(ch) != 2:
        flag = False
    
if flag:
    print('Yes')
else:
    print('No')

Solution (Python):
import numpy as np
from collections import defaultdict
from functools import reduce

S = input()

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

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

Solution (Python):
s = input()

s_set = {c for c in s}
if len(s_set) == 2 and s.count(s_set.pop()) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input().strip()
s = sorted(s)
x = s[0]
y = s[3]
if s.count(x) == 2 and s.count(y) == 2 and x != y:
    print('Yes')
else:
    print('No')

Solution (Python):
S = list(input().strip())
S.sort()

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

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

Solution (Python):
S = list(input())
chars = list(set(S))

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

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

Solution (Python):

s = input()
s_set = set(s)

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

Solution (Python):

import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline


def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(S):
    c = Counter(S)
    if len(c) == 2 and len(S) == 4:
        return 'Yes'
    return 'No'


def main():
    S = read_str()
    print(slv(S))


if __name__ == '__main__':
    main()

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(S: str):
    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)
    return



def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    solve(S)

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
if len(set(S)) == 2:
        if S.count(S[0]) == 2:
                print("Yes")
                exit()
print("No")

Solution (Python):


def main():
    s = raw_input()
    d = {}
    for c in s:
        d[c] = d.get(c, 0) + 1
    if len(d) == 2 and list(d.values()) == [2, 2]:
        print 'Yes'
    else:
        print 'No'


if __name__ == '__main__':
    main()

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

Solution (Python):
from collections import Counter

S = input()
c = Counter(S)

ans = 'Yes'
for n in c.values():
    if n != 2:
        ans = 'No'

print(ans)

Solution (Python):
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

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

Solution (Python):











import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log 
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S = ST()
    a = defaultdict(int)
    for s in S:
        a[s] += 1
        if a[s] == 3:
            print("No")
            exit()
    if len(a) == 2:
        print("Yes")
    else:
        print("No")
if __name__ == '__main__':
    main()