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

def main():
    d = dict()
    s = input()
    for c in list(s):
        if c not in d:
            d[c] = 0
        d[c] += 1
    ans = True
    if len(s) != 4:
        ans = False
    if len(d) != 2:
        ans = False
    for k in d:
        if d[k] != 2:
            ans = False
    if ans:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

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

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

Solution (Python):






import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache






MOD = 10**9+7
INF = float('inf')






def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]


def inv(n): return pow(n, MOD-2, MOD)


kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr


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





S = inputS()
s = set(S)

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

Solution (Python):
S=input()
cnt=[0 for _ in range(26)]
for c in S:
  cnt[ord(c)-ord('A')]+=1

  ans="Yes"
for x in cnt:
  if(x==0 or x==2):
    continue;
  else:
    ans="No"

print(ans)

Solution (Python):
d=dict()
for s in input():
    if not s in d:
        d[s]=1
    else:
        d[s]+=1
if len(d)==2:
    for v in d.values():
        if not v==2:
            print('No')
            exit()
else:
    print('No')
    exit()
print('Yes')

Solution (Python):
from collections import Counter

c = Counter(input())
if len(c) == 2 and tuple(c.values())[0] == 2:
    print('Yes')
else:
    print('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:
    for i in d.values():
        if i != 2:
            break
    print('Yes')
    exit()
print('No')

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

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

Solution (Python):

import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


YES = "Yes"  
NO = "No"  


def solve(S: str):
    c= collections.Counter(S)
    if c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2:
        print("Yes")
    else:
        print("No")

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()
l = sorted(s)
if l[0] == l[1] and l[1] != l[2] and l[2] == l[3]:
    print('Yes')
else:
    print('No')

Solution (Python):
import collections


S = input()

C = collections.Counter(S)
ans = "No"
if C.most_common()[0][1] == 2 and C.most_common()[1][1] == 2:
    ans = "Yes"
print(ans)

Solution (Python):
palabra = str(input()).upper()
x=0
if len(palabra)==4:
    for letras in palabra:
        if letras == palabra[0]:
            x+=1
        if letras == palabra[1]:
            x+=1
        if letras == palabra[2]:
            x+=1
        if letras == palabra[3]:
            x+=1
if x==8:
    print("Yes")
else:
    print("No")

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

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

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

if __name__ == '__main__':

    ABC_132_A()

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

from collections import Counter

c = dict(Counter(s))

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

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

Solution (Python):
from collections import Counter
S = list(input().rstrip())
ans = Counter(S)
print("Yes") if len(ans)==2 & list(ans.values())[0]==2 & list(ans.values())[1]==2 else print("No")

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

Solution (Python):
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce


import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


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

Solution (Python):
s = list(input())
flg = 'Yes'

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

print(flg)

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

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


solve()

Solution (Python):
def ABC132A(s):
    ans = True
    for i in s:
        ans = ans and (s.count(i) == 2)
    if ans:
        print("Yes")
    else:
        print("No")

ABC132A(input())

Solution (Python):
def ABC132A(s):
    s = list(s)
    ans = True
    for i in range(len(s)):
        ans = ans and (s.count(s[i]) == 2)
    if ans:
        print("Yes")
    else:
        print("No")

ABC132A(input())

Solution (Python):
import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter

S = list(input())
L = Counter(S)

for l in L.values():
    if l != 2:
        print("No")
        exit()
print("Yes")

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


if __name__ == "__main__":
    main()

Solution (Python):
s = input()
cnt = 0
for i in range(4):
    for j in range(i+1,4,1):
        if s[i] == s[j]:
            cnt +=1

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

Solution (Python):


S = [s for s in str(input())]
ls = list(set(S))
if len(ls) == 2:
    if S.count(ls[0]) == 2 and S.count(ls[1]):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
S = list(input())
c1 = S.count(S[0])
c2 = S.count(S[1])
c3 = S.count(S[2])
c4 = S.count(S[3])
if c1 == c2 == c3 == c4 == 2:
    print('Yes')
else:
    print('No')

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

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

Solution (Python):
a=input()
b={}
for i in a:
    if i in b:
        b[i]+=1
    else:
        b[i]=1

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

Solution (Python):
a=input()
b={}
for i in a:
    if i in b:
        b[i]+=1
    else:
        b[i]=1

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

Solution (Python):

import sys
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos, pi, e
from operator import itemgetter
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7

S = Counter(rs())
if list(S.values()) == [2, 2]:
    print('Yes')
else:
    print('No')

Solution (Python):


import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))


def resolve():
    S=input()
    cond=1
    for i in range(4):
        temp=S[i]
        a=[0,0]
        for s in S:
            a[s==temp]+=1
        if a[0]!=a[1]:cond=0
    print(["No","Yes"][cond])

resolve()

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

Solution (Python):
s = input()
res = {u for u in s}
if len(res) == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
palavra = input()
contador = 0

for i in palavra:
    if palavra.count(i) != 2:
        contador=5
if contador!=5:
    print("Yes")
else:
    print("No")

Solution (Python):
def main():
    s = input()
    letras = []
    for char in s:
        if char not in letras:
            letras.append(char)
    if len(letras) == 2:
        print('Yes')
    else:
        print('No')

main()

Solution (Python):
s = input()
aux = []
for i in s:
  if i not in aux:
    aux.append(i)

if len(aux) == 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):
let = set(input())
print({True: 'Yes', False: 'No'}[len(let) == 2])

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

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

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

Solution (Python):

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

Solution (Python):
S = list(input())
n = {}
for s in S:
    n[s] = 0
for s in S:
    n[s] += 1
ans = 'Yes'
if len(n.keys()) == 2:
    for i in n.values():
        if i != 2:
            ans = 'No'
else:
    ans = 'No'
print(ans)

Solution (Python):
import collections


def resolve():
    S = list(input())

    counter_S = collections.Counter(S)

    if len(counter_S) != 2:
        print("No")
        return

    for value in counter_S.values():
        if value != 2:
            print("No")
            return

    print("Yes")


resolve()

Solution (Python):

import sys
input = sys.stdin.readline









S = list(input().rstrip())

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

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

Solution (Python):


S = input()


cnt = [0 for i in range(200)]
syurui = []
for s in S:
    syurui.append(s)
    cnt[ord(s)] += 1
for s in syurui:
    if cnt[ord(s)] != 2:
        print("No")
        break
else:
    print("Yes")

Solution (Python):
lst=list(str(input()))
temp=[]
for i in range(4):
  if lst[i] not in temp:
    temp.append(lst[i])
if len(temp)!=2:
  print("No")
else:
  if lst.count(temp[0])==2 and lst.count(lst[1])==2:
    print("Yes")
  else:
    print("No")

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

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

Solution (Python):
from collections import Counter
c = Counter(input().rstrip())
if len(c) == 2 and list(set(c.values()))[0] == 2:
    print('Yes')
else:
    print('No')

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

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

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

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

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

Solution (Python):
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    S = list(iss())
    S = collections.Counter(S)
    print('Yes' if all([v == 2 for v in S.values()]) else 'No')

if __name__ == '__main__':
    main()

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

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

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

Solution (Python):
S=input()

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

Solution (Python):
n = str(input())
valor =1;index=0;banderita=0;array=[];m=0;igual=[];posicion=0;vacio=0
for i in range(3):
    while(valor!=4):
        if(n[index]==n[valor]):
            banderita=banderita+1
            igual.append(n[valor])
            posicion = valor
        valor=valor+1   
    if(banderita==1):
        array.append(banderita)
    elif(banderita>1):
        print('No')
        break
    else:
        if(n[posicion] in igual):
            vacio=0
        else:
            print('No')
            break
    banderita=0
    index=index+1
    valor=index+1
    posicion=0
if(len(array)==2):
    print('Yes')
elif(len(array)==1):
    print('No')

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

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

Solution (Python):
S=input().strip('\n')
if len(set(S[:]))==2 and (len(set(S[:2]))==len(set(S[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):


import collections

S = input()
_set = set(S)

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

Solution (Python):
S = input()

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

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

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

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

Solution (Python):
import collections

S = str(input())

c = collections.Counter(S)

j = True

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

print('Yes')

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

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

Solution (Python):
S = input()
s = set(S)
if len(s) == 2 and all(c in s for c in S):
    print('Yes')
else:
    print('No')

Solution (Python):

S=str(input())
if len(set(S))==2:
    ans ="Yes"
else:
    ans ="No"
print(ans)

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

Solution (Python):

import collections

def main():
    S = list(input())

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


main()

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

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

Solution (Python):
from collections import Counter
s=input()
t=Counter(s)
if len(t)==2 and max(t.values())==2:
	print("Yes")
else:
	print("No")

Solution (Python):
s = input()
t = [s[0], s[1], s[2], s[3]]
u = list(set(t))
v = len(u)
if v != 2:
    print("No")
else:
    w = s.count(u[0])
    x = s.count(u[1])
    if w == 2 and x ==2:
      print("Yes")
    else:
      print("No")

Solution (Python):
from collections import Counter

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

Solution (Python):

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

Solution (Python):
s = input()
count = 0
for i in range(3):
    for j in range(i+1, 4):
        if s[i] == s[j]:
            count += 1
if count == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()

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

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

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

Solution (Python):
S = 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):
S = input()
if len(set(list(i for i in 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):
s=input()


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

Solution (Python):
Ss = list(input().rstrip())

Ss.sort()

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

Solution (Python):
s=input()
a=s[0]
b=s[1]
c=s[2]
d=s[3]
if a==b==c==d:
  print('No')
elif (a==b and c==d) or (a==c and b==d) or (a==d and b==c):
  print('Yes')
else:
  print("No")

Solution (Python):
s = input()

l = []
count_a=0
count_b=0
for i in s:
  if i not in l:
    l.append(i)
    count_a+=1
  else: 
    count_b+=1
if count_a == 2 and count_b == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
s = 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())
T=set(S)
if len(T)==2:
  print('Yes')
else:
  print('No')

Solution (Python):
s = input()

slist = list(set(s))

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

Solution (Python):
import math
import sys
s = input()
li=['']*len(s)
for i in range(len(s)):
    li[i] = s[i]
li.sort()
if (li[0] == li[1] and li[2] == li[3] and li[1] != li[2]):
    print('Yes')
else:
    print('No')

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

k=set(s)
if len(k)==2:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd 
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) 







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):
from collections import Counter
s = list(input())
c = Counter(s)
if len(c) != 2:
  print('No')
  exit()
for v in c.values():
  if v != 2:
    print('No')
    exit()
print('Yes')

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

Solution (Python):
s = input()
l = [x for x in set(list(s)) if list(s).count(x) > 1]
if len(l) == 2:
  print('Yes')
else:
  print('No')

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

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

Solution (Python):


s = str(input())
ans = 'Yes'

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

print(ans)

Solution (Python):
s = input()

tmp = [c for c in s[1:] if c != s[0]]

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

Solution (Python):
import collections
S = input()

a = dict(collections.Counter(S))

if len(a) != 2:
    print("No")
else:
    for item in a:
        if a[item]!= 2:
            print("No")
            exit()
    print("Yes")

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

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

s_s = set(s)

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

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

s_s = set(s)

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

Solution (Python):
S = input()
a = ''
b = ''
ac = 0
bc = 0
for i in range(4):
  if a == '':
    a = S[i]
    ac = 1
  else:
    if S[i] == a:
      ac = ac + 1
    else:
      if b == '':
        b = S[i]
        bc = 1
      else:
        if S[i] == b:
          bc = bc + 1
if ac == 2 and bc == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
import sys
input = sys.stdin.readline

def main():

  S = input().rstrip()
  SS = sorted(S)

  result = 'No'
  if SS[0] == SS[1]:
    if SS[2] == SS[3]:
      if SS[0] != SS[2]:
        result = 'Yes'
  print(result)
  
if __name__ == "__main__":
  main()

Solution (Python):


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

Solution (Python):
def main():
    S = input()
    alphabet = list(set(S))
    flag = False
    if len(alphabet) == 2:
        if S.count(alphabet[0]) == 2 and S.count(alphabet[1]) == 2:
            flag = True
    if flag :
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Solution (Python):
a, b, c, d = input()

if (a == b and c == d and a != c) or (a == c and b == d and a != b) or (a == d and b == c and a != b):
    print("Yes")
else:
    print("No")

Solution (Python):

s = list(input())

cnt = 0
for i in range(len(s)):
    if s.count(s[i]) != 2:
        cnt += 1

if cnt != 0:
    print("No")
else:
    print("Yes")

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

Solution (Python):
s = input()
temp = "?"
ans = "Yes"
for c in s:
    if c != temp:
        if s.count(c) != 2:
            ans = "No"
            break
        temp = c
print(ans)

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

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

if len(c.keys()) == 2:
    for v in c.values():
        if v == 2:
            print('Yes')
            exit()
        else:
            print('No')
            exit()
print('No')

Solution (Python):
s = str(input())
if len(set(s)) == 1:
    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())

a=s[0]
b=s[1]
c=s[2]
d=s[3]

if a==b and b==c and c==d:
  print("No")
elif a==b and c==d:
  print("Yes")
elif a==c and b==d:
  print("Yes")
elif a==d and b==c:
  print("Yes")
else:
  print("No")

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

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

Solution (Python):
s = str(input())
if len(set(s)) == 1:
    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):

import collections
s = input()

l = collections.Counter(s)
if len(l)==2 and list(l.values())==[2,2]:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
d = {}
for i in range(4):
    if s[i] in d:
        d[s[i]] += 1
    else:
        d[s[i]] = 1
if d[s[0]] == d[s[1]] == d[s[2]] == d[s[3]] == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = list(input())
if S.count(S[0]) == 2:
    if 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')
else:
    print('No')

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

Solution (Python):
S = input()

letter = []
for i in range(4):
    if not S[i] in letter:
        letter.append(S[i])

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

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

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

Solution (Python):
s = input()
s_set = set(s)
if len(s_set) == 2:
    if s.count(list(s_set)[0]) == 2 and s.count(list(s_set)[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 = input("")
uniques = []
for n in s:
    if uniques.count(n) == 0:
        uniques.append(n)

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

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