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()
ls = set(list(s))
flag = True
for i in ls:
    if(s.count(i) != 2):
        flag = False
if(flag):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

for mj in moji:
    list.append(mj)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
s.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 sys,collections as cl,bisect as bs
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
    return list(map(int,input().split()))
def m(): #複数文字
    return map(int,input().split())
def onem(): #Nとかの取得
    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): #listをスペースごとに分ける
    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")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env 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

# This mergesort can be like 7 times faster than build in sort
# (for stupid reasons)
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


# region fastio

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()]

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
# coding: utf-8
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")

Submission status: Accepted

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

Submission status: Accepted

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

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:
from collections import Counter
S = input()
c = Counter(S)
if len(c)==2:
    if c[S[0]]==2:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
S = input()

flag = True

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
s_set = set(s)

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

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


# Generated by 1.1.4 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 = input()
if len(set(S)) == 2:
        if S.count(S[0]) == 2:
                print("Yes")
                exit()
print("No")

Submission status: Accepted

Solution code:


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

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

S = input()
c = Counter(S)

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
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()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#!/usr/bin/env pypy3

from math import *

def main():
    import sys
    sys.dont_write_bytecode = True
    sys.setrecursionlimit(10000000)

    input = sys.stdin.readline

    #import numpy as np
    #import scipy as sp

    # Python 3 modules: https://docs.python.org/3/library/

    import os
    import math, itertools, operator
    from math import factorial as fact
    from operator import itemgetter, attrgetter
    from itertools import permutations, combinations
    from functools import reduce, lru_cache
    # Use scipy for stats: https://docs.scipy.org/doc/scipy/reference/stats.html
    # Before Python 3.5.  Import from math after it.
    from fractions import gcd
    from fractions import Fraction as Frac

    inf = float('inf')

    def lcm(a, b):
        return a * b // gcd(a,b)

    def perm(a, b):
        import scipy.special
        return scipy.special.perm(a, b, exact = True)

    def comb(a, b):
        import scipy.special
        return scipy.special.comb(a, b, exact = True)

    def dfact(n):
        import scipy.special
        return scipy.special.factorial2(n, exact = True)

    def prod(l):
        return reduce(operator.mul, l)

    def input_ints(func = input, sep = None, conv = int):
        return list(map(conv, func().split(sep = sep)))

    if os.environ.get('GOROOT') is None:
        def dprint(*args, **kwargs):
            kwargs['file'] = sys.stderr
            import inspect
            frame = inspect.currentframe().f_back
            print('[' + os.path.basename(frame.f_code.co_filename)
                    + ':' + str(frame.f_lineno) + ']', *args, **kwargs)
    else:
        def dprint(*args, **kwargs):
            pass


    ############################################################################


    #= list(map(int, input().split()))
    S = list(input()[:4])
    S.sort()
    dprint(S)
    if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque
# 直積 A={a, b, c}, B={d, e}:のとき，A×B={(a,d),(a,e),(b,d),(b,e),(c,d),(c,e)}: product(A, B)
from itertools import product
# 階乗 P!: permutations(seq), 順列 {}_len(seq) P_n: permutations(seq, n)
from itertools import permutations
# 組み合わせ {}_len(seq) C_n: combinations(seq, n)
from itertools import combinations
# 一次元累積和
from itertools import accumulate
from bisect import bisect_left, bisect_right

# import numpy as np
# from scipy.special import perm
# from scipy.special import comb

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

# 四方向: 右, 下, 左, 上
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]
 
def i_inpl(): return int(input())
def l_inpl(): return list(map(int, input().split()))
INF = float("inf")

########

S = input()

c = Counter(S)

flag = True
for i in c.values():
    if i != 2:
        flag = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

S_ = [ord(s) for s in S]
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:
ss = sorted(list(input()))
if ss[0] == ss[1] and ss[1] != ss[2] and ss[2] == ss[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
dic={}
for i in range(4):
  if s[i] not in dic:
    dic[s[i]]=1
  else:
    dic[s[i]]+=1
val=list(dic.values())
if len(dic)==2 and val[0]==2 and val[1]==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()
s = list(sorted(S))
ans = s[0] == s[1] and s[1] != s[2] and s[2] == s[3]

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    s = S()
    d = defaultdict(int)
    for i in s:
        d[i] += 1
    for i in d.keys():
        if d[i] != 2:
            print("No")
            quit()
    print("Yes")
    return

#B
def B():
    n = I()
    p = LI()

    return

#C
def C():
    n = I()

    return

#D
def D():
    n = I()

    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return


#Solve
if __name__ == "__main__":
    A()

Submission status: Accepted

Solution code:
S = list(input())
for i in range(4):
    if not S.count(S[i]) == 2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
s=input()

s1=set(s)

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

Submission status: Accepted

Solution code:
import sys

stdin = sys.stdin

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

s = ns()
f = [0] * 26
for c in s:
    f[ord(c)-ord('A')] += 1
f.sort()
if f[-1] == 2 and f[-2] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    S = input()
    C = Counter(S)
    for c in C:
        if C[c] != 2:
            print("No")
            return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

counts = defaultdict(int)
S = s()

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

if len(counts) == 2 and all([v == 2 for v in counts.values()]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

res = 'Yes'
dic = {}
for s in S:
    if s in dic:
        dic[s] += 1
        
    else:
        dic[s] = 1
        
for d in dic:
    if dic[d] == 2:
        pass
    else:
        res = 'No'
        
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
INF = float("inf")


def yes():
    print("Yes")  # type: str


def no():
    print("No")  # type: str


def solve(S: str):
    if len(set(S)) != 2:
        no()
        return

    if S.count(S[0]) != 2:
        no()
        return
    yes()
    return


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

Submission status: Accepted

Solution code:
n=input()
#n,k=map(int,input().split())
#a=list(map(int,input().split()))
a=[i for i in n]
a.sort()
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:
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(input())
def inpl(): return list(map(int, input().split()))
def inpl_str(): return list(input().split())

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: Runtime Error

Solution code:
#ABC132 B

n = int(input())
K = 0
for i in range(n-2):
    if (P[i]<P[i+1] and P[i+1] < P[i+2]) or (P[i+2]<P[i+1] and P[i+1]<P[i]):
        K += 1
        
print(K)

Submission status: Runtime Error

Solution code:
#ABC132 A

S = str(input())
T = [S[0],S[1],S[2],S[3]]
T.sort()
if T[0] == T[1] and T[2] == T[3] and T[1] != T[2]
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#ABC132 A

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import Counter
a = Counter(input()).most_common()

print("Yes" if a[1][1]==2 else "No")

Submission status: Runtime Error

Solution code:
from collections import defaultdict
S = input()
dct = defaultdict(int)
for s in S:
  dct[s] += 1
for key, val in dct.items():
  if not val == 2:
    print('No')
    exit(1)
print('Yes')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict

S = defaultdict(int)
for i in input():
    S[i] += 1

a, b, *_ = S.values()
if a == b == 2:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

Submission status: Runtime Error

Solution code:
S = 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: Runtime Error

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

Submission status: Runtime Error

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

from operator import mul
from functools import reduce



def main():
    n, k = list(map(int, input().split()))
    modulo = 1000_000_000 + 7

    def cmb(n, r):
        if n < r:
            return 0
        r = min(n - r, r)
        if r == 0:
            return 1
        numer = reduce(mul, range(n, n - r, -1))
        denom = reduce(mul, range(1, r + 1))
        return numer // denom % modulo

    for i in range(1, k+1):
        # i分割する方法
        a = cmb(k-1, i-1)
        # 赤のボールを分割する方法
        b = cmb(n-k+1, i)
        print(a * b % modulo)

main()

Submission status: Runtime Error

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

Submission status: Runtime Error

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

if len(a)==2:
    for i in a:
        if a[i]==2:
            pass
        else:
            count+=1
    if count == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No"