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):
S=input()

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

Solution (Python):
S = input()

A = S[0]
ans = 'No'

if A == S[1]:
    B = S[2]
    if B == S[3]:
        ans = 'Yes'
else:
    B = S[1]
    if A == S[2] and B == S[3]:
        ans = 'Yes'
    if B == S[2] and A == S[3]:
        ans = 'Yes'

if A == B:
    ans = 'No'

print(ans)

Solution (Python):



""" convenient functions




"""

import sys
sys.setrecursionlimit(10**7)
from itertools import accumulate, combinations, permutations, product 

from math import factorial, ceil, floor
def factorize(n):
    """return the factors of the Arg and count of each factor
    
    Args:
        n (long): number to be resolved into factors
    
    Returns:
        list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
    """
    fct = []  
    b, e = 2, 0  
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def combinations_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    
    if n < 0 or r < 0:
        raise Exception('combinations_count(n, r) not defined when n or r is negative')
    if n - r < r: r = n - r
    if r < 0: return 0
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combinations_with_replacement_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    if n < 0 or r < 0:
        raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
    elif n == 0:
        return 1
    else:
        return combinations_count(n + r - 1, r)
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict 
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest 
from copy import deepcopy, copy 
from operator import itemgetter


from functools import reduce
def chmin(x, y):
    """change minimum
    if x > y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current minimum value
        y (long): potential minimum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x > y:
        x = y
        return (x, True)
    else:
        return (x, False)
def chmax(x, y):
    """change maximum
    if x < y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current maximum value
        y (long): potential maximum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x < y:
        x = y
        return (x, True)
    else:
        return (x, False)

from fractions import gcd 
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)



INF = 10 ** 18
MOD = 10 ** 9 + 7
modpow = lambda a, n, p = MOD: pow(a, n, p) 
def modinv(a, p = MOD):
    
    
    return modpow(a, p-2, p)
def modinv_list(n, p = MOD):
    if n <= 1:
        return [0,1][:n+1]
    else:
        inv_t = [0,1]
        for i in range(2, n+1):
            inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
        return inv_t
def modfactorial_list(n, p = MOD):
    if n == 0:
        return [1]
    else:
        l = [0] * (n+1)
        tmp = 1
        for i in range(1, n+1):
            tmp = tmp * i % p
            l[i] = tmp
        return l
def modcomb(n, k, fac_list = [], p = MOD):
    
    
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if len(fac_list) <= n:
        a = factorial(n) % p
        b = factorial(k) % p
        c = factorial(n-k) % p
    else:
        a = fac_list[n]
        b = fac_list[k]
        c = fac_list[n-k]
    return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
def modadd(a, b, p = MOD):
    return (a + b) % MOD
def modsub(a, b, p = MOD):
    return (a - b) % p
def modmul(a, b, p = MOD):
    return ((a % p) * (b % p)) % p
def moddiv(a, b, p = MOD):
    return modmul(a, modpow(b, p-2, p))

""" initialize variables and set inputs

    
    

    
    
    
    
    

    
    
    
    

    
    
"""


r = lambda: sys.stdin.readline().strip()
r_int = lambda: int(r())
R = lambda: list(map(int, r().split()))
Rfloat = lambda: list(map(float, r().split()))
Rtuple = lambda: tuple(map(int, r().split()))
Rmap = lambda: map(int, r().split())

""" how to treat input







"""




S = r()
for i in Counter(S).values():
    if i != 2:
        print('No')
        exit()
print('Yes')




"""memo: how to use defaultdict of list

Dic = defaultdict(list)

Dic[x].append(y)

for k, v in Dic.items():
"""

Solution (Python):
s = input()

s = sorted(list(s))

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

Solution (Python):
ssss = list(input())
ans = {}

for s in ssss:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1
for s in ans:
    if ans[s] == 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

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

Solution (Python):

a = input()
dic = {}
if len(set(a)) == 2:
    for i in range(len(a)):
        if a[i] not in dic:
            dic.setdefault(a[i], 1)
        else:
            dic[a[i]] += 1
            if dic[a[i]] > 2:
                print('No')
                break
    print('Yes')

else:
    print('No')

Solution (Python):
S = input()
table = {}
for s in S:
    if s not in table:
        table[s] = 1
    else:
        table[s] += 1

if len(table) != 2:
    print('No')
    exit()
for t in table:
    if table[t] != 2:
        print('No')
        exit()

print('Yes')

Solution (Python):


s = list(str(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):
import collections
S = input()
C = collections.Counter(S)
count = 0
for c in C.items():
  if c[1] == 2:
    count += 1
print("Yes" if count == 2 else "No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

def solve(S: str):
    print(YES if len(set(list(S))) == 2 else 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):
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input()
    if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
        Yes()
    elif S[0] == S[2] and S[1] == S[3] and S[0] != S[1]:
        Yes()
    elif S[0] == S[3] and S[1] == S[2] and S[0] != S[1]:
        Yes()
    else:
        No()
    
if __name__ == '__main__':
    main()

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

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

Solution (Python):
S = input()

from collections import defaultdict

dic = defaultdict(int)

for s in S:
    dic[s] += 1

if len(dic) == 2:
    for k, v in dic.items():
        if v == 2:
            continue
        else:
            print("No")
            exit()
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
flag = 'Yes'
for i in S:
    if S.count(i) != 2:
        flag = 'No'

print(flag)

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

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

check = 0
for i in input1:
    for j in range(len(input1)):
        if i == input1[j]:
            check = check +1

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

Solution (Python):




 
from collections import* 
from fractions import gcd
from functools import* 
from itertools import* 
from operator import mul,itemgetter
from bisect import* 
from heapq import* 
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)

 
def main():
    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")
if __name__ == '__main__':
    main()

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()
s=input()
ss=sorted(s)
if ss[0] == ss[1] and ss[1] != ss[2] and ss[2] == ss[3]:
    print('Yes')
else:
    print('No')

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

c1, c2 = list(set(list(S)))

if (S.count(c1) == 2) and (S.count(c2) == 2):
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
s1 = s
s = sorted(s)

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

Solution (Python):
S = input()

alph = set(S)
if len(alph) != 2:
    print("No")
    exit(0)

for c in alph:
    if S.count(c) != 2:
        print("No")
        exit(0)

print("Yes")

Solution (Python):
s = sorted(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()
m = {}
for c in s:
  if c in m.keys():
    m[c] += 1
  else:
    m[c] = 1
if len(m.keys()) == 2 and set(m.values()) == set([2]):
  print('Yes')
else:
  print('No')

Solution (Python):

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

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

Solution (Python):

s = input()
 
dic = {}
 
for i in range(4) :
    a = s[i]
    if not (a in dic) :
        dic[a]=0
    dic[a] = dic[a] +1

result = "No"

count =0
for val in dic.values():
    if val == 2 :
        count = count +1

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

Solution (Python):
def solve(s):
    s = sorted(s)
    return "Yes" if s[0] == s[1] and s[1] != s[2] and s[2] == s[3] else "No"

print(solve(input()))

Solution (Python):
from collections import Counter

S = Counter(input())

ans = 'Yes'
for s in S.values():
	if s != 2:
		ans = 'No'
print(ans)

Solution (Python):
s = list(input())
s.sort()
cnt = 1
ans = 1

for i in range(1, 4):
  
  if s[i - 1] != s[i]:
    if cnt < 2:
      ans = 0
      break
    cnt = -1
  if not ans:
    break
  cnt += 1
if cnt > 3:
  ans = 0
if not ans:
  print("No")
else:
  print("Yes")

Solution (Python):
letters = list(input())
x = 1
for letter in letters:
        if letters.count(letter) == 2:
            x *= 1
        else:
            x *= 0
print(["No","Yes"][x])

Solution (Python):
import collections
S = list(input())
c = collections.Counter(S)
values, counts = zip(*c.most_common())
if counts[0] == 2:
    if counts[1] == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

Solution (Python):
s = input()

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

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

Solution (Python):

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

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

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

Solution (Python):
str=list(input())
if str.count(str[0])==2 and str.count(str[1])==2 and str.count(str[3])==2 and str.count(str[2])==2:
    print("Yes")
elif str.count(str[0])==4 or str.count(str[2])==4 or str.count(str[1])==4 or str.count(str[3])==4:
    print("No")
else:
    print("No")

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

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

Solution (Python):
S  = input()
import collections
c = collections.Counter(S)
for i,c in enumerate(c.values()):
    if c != 2:
        print('No')
        exit(0)
    if i == 2:
        print('No')
        exit(0)
print('Yes')

Solution (Python):
INPUT = input()

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

Solution (Python):
import collections

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

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

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

Solution (Python):
import collections

c = collections.Counter(input())

if len(c.keys()) == 2 and all(i == 2 for i in c.values()):
    print("Yes")
else:
    print("No")

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

num = [0]*26

num_A = ord("A")

for s in S:
    num[ord(s)-num_A] += 1

if num[ord(S[0])-num_A] == 1 or num[ord(S[1])-num_A] == 1 or num[ord(S[2])-num_A] == 1 or num[ord(S[3])-num_A] == 1:
    print("No")
elif num[ord(S[0])-num_A] == 4 or num[ord(S[1])-num_A] == 4 or num[ord(S[2])-num_A] == 4 or num[ord(S[3])-num_A] == 4:
    print("No")
else:
    print("Yes")

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

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

Solution (Python):
S = input()

d = {}
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1

if len(d) == 2 and d[s] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = str(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[1] != S[2] and S[1] == S[3]:
    print('Yes')
elif S[0] == S[3] and S[3] != S[2] and S[1] == S[2]:
    print('Yes')
else:
    print('No')

Solution (Python):



s = input()
cnt = 0

for i in range(4):
    for j in [a+i+1 for a in range(3-i)]:
        if s[i] == s[j]:
            cnt += 1

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

Solution (Python):
s = input()
g = {}
for i in s:
    if i not in g:
        g[i] = 0
    g[i] += 1
a = []
for i in g:
    a.append(g[i])
if a == [2, 2]:
    print('Yes')
else:
    print('No')

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

Solution (Python):
s=input()
ls=[s[i] for i in range(4)]
if len(set(ls))==2 and ls.count(s[0])==2:
	print('Yes')
else:
	print('No')

Solution (Python):
input_str = input()
items = set(list(input_str))
print('Yes' if len(items) == 2 and len(list(input_str.replace(list(items)[0], ''))) == 2 else 'No')

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

Solution (Python):
S = input()
S_list = list(S)
df = "Yes"
for i in range(0, 3):
    if S_list.count(S_list[i]) != 2:
        df = "No"
print(df)

Solution (Python):

S = input()
ls ={}
s =True
for i in S:
    if S.count(i)!=2:
        s =False
if s:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
import string

S = input()

ans = 0
for char in list(string.ascii_uppercase):
    if S.count(char) == 2:
        ans += 1
if ans == 2:
    print("Yes")
else:
    print("No")

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

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

Solution (Python):
inputString = input()
counts = set(map(lambda i: inputString.count(inputString[i]), range(4)))
if counts == {2}:
    print("Yes")
else:
    print("No")

Solution (Python):
import itertools
import sys

def hantei(s):
  hantei = s.isupper()
  
  if hantei:
    i = 0
    for s1, s2 in itertools.combinations(s, 2):
      if s1 == s2:
        i += 1
    hantei = 'Yes' if i == 2 else 'No'
  else:
    hantei = 'No'
    
  return hantei


if __name__ == '__main__':
  args = sys.stdin
  
  for arg in args:
    print(hantei(str(arg)))

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

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

Solution (Python):
S = input()

from collections import Counter

cs = Counter(S)

result = list(cs.values()) == [2, 2]

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

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
from operator import itemgetter, mul
from copy import deepcopy,copy
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

def main():
    s=list(input())
    t=set(s)
    if len(t)==2:
        print('Yes')
    else:
        print('No')


if  __name__=='__main__':
    main()

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

Solution (Python):
s=list(input())
s1=s[0]
sf=s.count(s1)
if sf==2:
  for i in range(2):
    s.remove(s1)
  if s[0]==s[1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
import sys
def input(): return sys.stdin.readline().strip()

import collections
s = list(input())
c = collections.Counter(s)
if len(c.keys()) == 2 and c.most_common()[0][1] == 2:
        print("Yes")
else:
        print("No")

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

if len(S2) == 2:
    print("Yes")
    exit()

print("No")

Solution (Python):

import sys

YES = "Yes"  
NO = "No"  

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

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

Solution (Python):
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

S = input()
C  =Counter(S)
a = 0
for k,v in C.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[1] != s[2]:
        print("Yes")
else:
        print("No")

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

Solution (Python):

import time
import re
import math
import fractions

def main():
    s=input()
    if 2==len(set(s)):
        print("Yes")
    else:
        print("No")

start=time.time()
main()

Solution (Python):
from collections import Counter
S = input()
input_counter = Counter(S)

if len(input_counter) == 2:
    for v in input_counter.values():
        if v != 2:
            print('No')
            exit()
    else:
        print('Yes')
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 = str(input())
s = list(S)

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

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

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

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

Solution (Python):
def main():
    S = input()

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

    return


if __name__ == "__main__":
    main()

Solution (Python):
S = input()

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

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

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

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

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

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

Solution (Python):
s = input()
x = {}
for i in s:
    x[i] = 0
for i in s:
    x[i] += 1

ans = 0
for i in x:
    if x[i] == 2:
        ans += 1

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

Solution (Python):
s=input();print('YNeos'[any(s.count(t)!=2for t in s)::2])

Solution (Python):
s=input();print('YNeos'[any(s.count(t)!=2for t in s)::2])

Solution (Python):



while True :
	S = input()
	if len(S) == 4 and S.isupper() :
		break
	else :
		continue


char_list = list(S)

judge = 0


for i in range(3) :
	for j in range(3-i) : 
		if char_list[i] == char_list[i+j+1] :
			judge = judge + 1

if judge == 2 :
	print('Yes')
else :
	print('No')

Solution (Python):
S = input()

S2 = set(S)

ans = ''
if len(S2) == 2:
    ans = 'Yes'
else:
    ans = 'No'

print('{}'.format(ans))

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

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

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

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

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

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

Solution (Python):
import sys

if sys.platform =='ios':
	sys.stdin=open('inputFile.txt')
		


def main():
	s = input()
	ss=set()
	for c in s:
		ss.add(c)
		
	if len(ss) != 2:
		return 'No'
		
	cc=list(s)[0]
	aa=len([c for c in list(s) if c==cc])
	
	if aa == 2:
		return 'Yes'
	return 'No'
	

if __name__ == "__main__":
	print(main())

Solution (Python):

S = input()
s = set(S)

c = 0
for i in s:
    if S.count(i) == 2:
        c += 1
if c == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
import collections
l = list(input())
c = collections.Counter(l)
A = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
count = 0
for i in A:
    if c[i] == 2:
        count += 1
    else:
        count += 0
if count == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
string = input()
string = string.lower()
strDict = {}
for i in range(len(string)):
    if string[i] in strDict:
        strDict[string[i]] = strDict[string[i]] - 1
    else:
        strDict[string[i]] = 1
not_fount = True
for key, value in strDict.items():
    if value != 0:
        print("No")
        not_fount = False
        break
        
if not_fount:
    print("Yes")

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

count=0
for i in range(len(x)):
    if x[i] in x:
        count += 1
x = set(x)

if len(x) == 2 and count == 4:
    print("Yes")
else:
    print("No")

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

def judge(S):
    if S[0]==S[1] and S[2]==S[3] and S[0]==S[3]:
        return 'No'        
    elif S[0]==S[1] and S[2]==S[3]:
        return 'Yes'
    elif S[0]==S[2] and S[1]==S[3]:
        return 'Yes'
    elif S[0]==S[3] and S[1]==S[2]:
        return 'Yes'
    else:
        return 'No'

print(judge(S))

Solution (Python):
s = input()
b1 = ''
b2 = ''
n = 0
for i, c in enumerate(s):
  if i == 0:
    b1 = c
    n += 1
    continue
  if c != b1 and b2 == '':
    b2 = c
    continue
  if c == b1:
    n += 1
    continue
  if c == b2:
    continue
  if c != b1 and c != b2:
    print('No')
    break
else:
    print('Yes' if n == 2 else '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()
if s[0]==s[1]==s[2]==s[3]:
  print('No')
elif s[0]==s[1]:
  if s[2]==s[3]:
    print('Yes')
  else:
    print('No')
elif s[0]==s[2]:
  if s[1]==s[3]:
    print('Yes')
  else:
    print('No')
elif s[0]==s[3]:
  if s[1]==s[2]:
    print('Yes')
  else:
    print('No')
elif s[1]==s[2]:
  if s[0]==s[3]:
    print('Yes')
  else:
    print('No')
elif s[2]==s[3]:
  if s[0]==s[1]:
    print('Yes')
  else:
    print('No')
elif s[1]==s[3]:
  if s[0]==s[2]:
    print('Yes')
  else:
    print('No')
if s[0] != s[1] and s[1]!=s[3] and s[0]!=s[2] and s[0]!=s[3] and s[1]!=s[2] and s[2] != s[3]:
  print('No')

Solution (Python):
string = input()

if all([string.count(c)==2 for c in set(string)]) :
    print('Yes')
else:
    print('No')

Solution (Python):
import collections

s = input()

if list(collections.Counter(list(s)).values()) == [2, 2]:
    print("Yes")
else:
    print("No")

Solution (Python):
n = input()
m = list({(i, n.count(i)) for i in n})

if len(m) != 2 or m[0][1] != 2:
    print("No")
else:
    print("Yes")

Solution (Python):
import sys

def check():
    S = raw_input()
    for a in S:
        if S.count(a)!=2:
            return 0
    return 1

if check()==0:
    print('No')
else:
    print('Yes')

Solution (Python):
S = input()

s = {i for i in S}
c1=0
c2=0
if len(s) !=2:
    print("No")
else:
    a = S[0]
    b = S[1]
    for i in S[2:]:
        if i==a:
            c1 += 1
        elif i == b:
            c2 += 1
    if c1 == 2 or c2 == 2:
        print("No")
    else:
        print("Yes")

Solution (Python):
s = input()

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

cnt1 = 0
cnt2 = 0
memo =24
for i in range(1,4):
    if a[0] == a[i]:
        memo = i
        break;
    

ans = "No"
if(memo != 24):
    for i in range(1,4):
        for j in range(i+1,4):
            if (i != memo and j != memo):
                if a[i] == a[j]:
                    if a[0] != a[i]:
                        ans = "Yes"
                        break;


print(ans)

Solution (Python):
import collections
S=list(map(str,input()))

S=collections.Counter(S)
a=S.most_common()



if int(len(a)) is 2:
    print("Yes")

else:
    print("No")

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

S_unique = list(set(S))

if all(map(lambda x:S.count(x)==2,S_unique)):
  print("Yes")
else:
  print("No")

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

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

Solution (Python):
S = input()
judge = "No"
count=[]
for i in range(4):
    count.append(S.count(S[i]) )
if count == [2,2,2,2]:
    judge = "Yes"
    
print(judge)