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



from math import *

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

    input = sys.stdin.readline

    
    

    

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


    


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

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

Solution (Python):
import math
import copy
from operator import mul
from functools import reduce
from collections import defaultdict
from collections import Counter
from collections import deque

from itertools import product

from itertools import permutations

from itertools import combinations

from itertools import accumulate
from bisect import bisect_left, bisect_right





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

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

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

Solution (Python):
ss = sorted(list(input()))
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:
  if S.count(S[0]) == 2 and S.count(S[1]) == 2:
    print("Yes")
    exit()
print("No")

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):
n=input()
n=list(n)
n=set(n)
if(len(n)==2):
  print('Yes')
else:
  print('No')

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

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

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

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 and S.count(S[0]) == 2:
    print('Yes')
else:
    print('No')

Solution (Python):

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


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


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

    return


def C():
    n = I()

    return


def D():
    n = I()

    return


def E():
    n = I()

    return


def F():
    n = I()

    return



if __name__ == "__main__":
    A()

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

print('Yes')

Solution (Python):
s=input()

s1=set(s)

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

Solution (Python):
import sys

stdin = sys.stdin

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

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

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

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

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

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

resolve()

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

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

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

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

Solution (Python):

import sys
INF = float("inf")


def yes():
    print("Yes")  


def no():
    print("No")  


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


if __name__ == '__main__':
    main()

Solution (Python):
s = input()

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

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

Solution (Python):
n=input()


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

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