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):
str = input()
ma = {}
cnt = 0
for i in str :
    if i not in ma.keys() :
        ma[i] = 1
    else :
        ma[i] += 1
for i in ma :
    if ma[i] == 2 :
        cnt += 1
if cnt == 2 :
    print("Yes")
else :
    print("No")

Solution (Python):
mojiretsu = input()
lst = [c for c in mojiretsu]
lst.sort()

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

Solution (Python):
s = list(map(str, input()))

k = 0
l = list()
for i in range(0, 3):
    for j in range(i, 3):
        if s[i] == s[j+1]:
            k += 1
    if k == 1:
        l.append(1)
    k = 0

if sum(l) == 2:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()

S_list = list(S)

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



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

Solution (Python):
from collections import Counter

S = input()
word = Counter(S)
if len(word) == 2:
  if list(word.values())[0] == 2 and list(word.values())[1] == 2:
    print('Yes')
    exit()
print('No')

Solution (Python):
b=0
mojiretu = input()
char_list=list(mojiretu)


for c in char_list:
    if mojiretu.count(c) == 2:
        b +=1
        
if b==4:
    print("Yes")
else:
    print("No")

Solution (Python):
def fifty_fifty(S: str)->bool:
    m = {}
    for c in S:
        m.setdefault(c, 0)
        m[c] += 1

    return len(m.keys()) == 2 and all(v == 2 for v in m.values())


if __name__ == "__main__":
    S = input()

    ans = fifty_fifty(S)
    print('Yes' if ans else 'No')

Solution (Python):
s = input()

c = 0
if s.count(s[0]) == 2:
    for i in range(4):
        if s.count(s[i]) == 2:
            c += 1
        else:
            pass
    if c == 4:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Solution (Python):
import collections as coll
 
s = list(input().rstrip())
c = coll.Counter(s)
 
if len(c.keys()) != 2:
  print("No")
 
else:
  if c.most_common()[0][1] != 2:
    print("No")
  else:
    print("Yes")

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

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

Solution (Python):
S = input()
SS = list(S)
boo = False
boo2 = False
s1 = S[0]
s2 = S[1]
s3 = S[2]
s4 = S[3]
buf = ""
if s1 == s2:
    buf =SS.pop(1)
    buf =SS.pop(0)
elif s1 == s3:
    buf=SS.pop(2)
    buf=SS.pop(0)
elif  s1 == s4:
    buf=SS.pop(3)
    buf=SS.pop(0)
elif s2 == s3:
    buf=SS.pop(2)
    buf=SS.pop(1)
elif s2 == s4:
    buf=SS.pop(3)
    buf=SS.pop(1)
elif s3 == s4:
    buf=SS.pop(3)
    buf=SS.pop(2)
    
if len(SS) == 4:
    print("No")
elif SS[0] == SS[1] and buf != SS[0]:
    print("Yes")
else:
    print("No")

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

if len(set(S)) == 2:
    
    m = list(set(S))[0]
    n = list(set(S))[1]

    m_c, n_c = 0, 0
    c = False
    
    for i in range(len(S)):
        if S[i] == m:
            m_c += 1
        else:
            n_c += 1
            
    if m_c == n_c:
        c = True

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

else:
    print('No')

Solution (Python):











S=input()
ans="Yes"
l=[0,0,0,0]
for i in range(4):
    for j in range(4):
        if S[j]==S[i]:
            l[i]+=1
for i in range(4):
    if l[i]!=2:
        ans="No"
print(ans)

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

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

Solution (Python):
import collections

str=input()
c=collections.Counter(str)

isFF=True

if len(c)!=2:
    isFF=False

for v in c.values():
    if v!=2:
        isFF=False

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

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

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

Solution (Python):
x=list(input())
a=x[0]
b=x[1]
c=x[2]
d=x[3]
if a==b and a!=c:
  if c==d:
    print("Yes")
  else:
    print("No")
elif a==c and a!=b:
  if b==d:
    print("Yes")
  else:
    print("No")
elif a==d and a!=b:
  if b==c:
    print("Yes")
  else:
    print("No")
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:
  print("Yes")
else:
  print("No")

Solution (Python):
s = input()
emar = []
deta = [0] * 3
for a in s:
    flag = True
    for de in range(len(emar)):
        if a == emar[de]:
            flag = False
            deta[de] += 1
    if flag:
        emar.append(a)
if deta[0] == deta[1] and deta[0] == 1:
    print("Yes")
else:
    print("No")

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

out = dict()
for s in S:
	if s in list(out.keys()):
		out[s] += 1
	else:
		out[s] = 1

if (len(list(out.keys())) == 2) and ([out[key] for key in out.keys()] == [2,2]):
	print("Yes")
else:
	print("No")

Solution (Python):
l = input()
a = l[0]
b = l[1]
c = l[2]
d = l[3]


while(True):
    if(a==b and b==c and c==d):
        print("No")
        break
    if(a==b and c==d):
        print("Yes")
        break
    if(a==c and b==d):
        print("Yes")
        break
    if(a==d and c==b):
        print("Yes")
        break
    else:
      print("No")
      break

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

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

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

count = 0
if len(S_set) == 2:
    s0 = S[0]
    for s in S:
        if s == s0:
            count += 1
        
if count == 2:
    print("Yes")
else:
    print("No")

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

out = dict()
for s in S:
	if s in list(out.keys()):
		out[s] += 1
	else:
		out[s] = 1

if (len(list(out.keys())) == 2) and ([out[key] for key in out.keys()] == [2,2]):
	print("Yes")
else:
	print("No")

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

Solution (Python):
from collections import Counter
import sys



def fifty(S):
    out = 'No'

    c = Counter(S)

    if len(c) == 2:

        for value in c.values():
            if value == 2:
                out = 'Yes'
                pass
            else:
                out = 'No'
                break
    return out
  
if __name__ == "__main__":
    S = input()
    print(fifty(S))

Solution (Python):
S = input()

strs = {}

for i in range(len(S)):
    if S[i] in strs:
        strs[S[i]] += 1
    else:
        strs[S[i]] = 1

if len(strs) != 2:
    print('No')
    exit()

values = strs.values()
for val in strs.values():
    if val != 2:
        print('No')
        exit()

print('Yes')

Solution (Python):
x = input()
ans = "No"
a = x[0]

for i in range(1, 4):
    if a != x[i]:
        b = x[i]
        ans = "Yes"
        break

for i in range(4):
    if (x[i] != a) and (x[i] != b):
        ans = "No"

print(ans)

Solution (Python):
s=input()
count1=0
count2=0

char1=s[0]
char2='1'
count1+=1
if s[1]==char1:
    count1+=1
else :
    char2=s[1]
    count2+=1

if s[2]==char1:
    count1+=1
elif '1'==char2:
    char2=s[2]
    count2+=1
elif s[2]==char2:
    count2+=1

if s[3]==char1:
    count1+=1
elif '1'==char2:
    char2=s[3]
    count2+=1
elif s[3]==char2:
    count2+=1

if count1==2 and count2==2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()
if len(s) != 4:
    print('No')
elif s[1:].count(s[0]) == 1:
    s2 = s.replace(s[0], '')
    if s2[0] == s2[1]:
        print('Yes')
    else: print('No')
else:
    print("No")

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

if len(dict_S) > 2:
    print("No")
else:
    cnt = 0
    for s in dict_S.values():
        if s == 2:
            cnt += 1
    if cnt == 2:
        print("Yes")
    else:
        print("No")

Solution (Python):
import re
import numpy as np


S = str(input())

s0=len(re.findall(S[0],S))
s1=len(re.findall(S[1],S))
s2=len(re.findall(S[2],S))
s3=len(re.findall(S[3],S))

flag=np.array([s0,s1,s2,s3])
if np.sum(flag==2)==4:
  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 = input()
list = []
for l in s:
	if l not in list:
		list.append(l)
if len(list) == 2:
	if s.count(list[0]) == 2:
		print('Yes')
	else:
		print('No')
else:
	print('No')

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

Solution (Python):
s = str(input())
for c in s:
    if s.count(c)!=2:
        print("No")
        exit()
print("Yes")

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

s0 = s[0]
s1 = s[1]
s2 = s[2]
s3 = s[3]

c0 = S.count(s0)
c1 = S.count(s1)
c2 = S.count(s2)
c3 = S.count(s3)
ct = c0 + c1 + c2 + c3
ct

if ct == 8:
    print('Yes')
else:
    print('No')

Solution (Python):
def main():
    s = input()
    count = s.count(s[0])
    if count == 2:
        strip = s.strip(s[0])
        if strip.count(strip[0]) == 2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()

Solution (Python):
S=input()

s1=S[0]
nc=0
for i,st in enumerate(S[1:]):
    if s1==st:
        nc+=1
        it=i
        
if nc==1:
    if it==0:
        if S[2]==S[3]:
            print('Yes')
        else:
            print('No')
    elif it==1:
        if S[1]==S[3]:
            print('Yes')
        else:
            print('No')

    elif it==2:
        if 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):


S = list(input())

S.sort()

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

Solution (Python):
import collections

s = input()
c = collections.Counter(s)
if len(c) == 2 and c[s[0]] == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
import sys
import re
from collections import Counter

S = input()
c = Counter(S)
if (len(c)== 2):
    values, counts = zip(*c.most_common())
    if counts[0] == 2 and counts[1]==2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Solution (Python):
S = input()
flag = True
for i in range(4):
    if S.count(S[i]) != 2:
        flag = False
if flag == True:
    print("Yes")
else:
    print("No")

Solution (Python):
S = input()
w_list = []
flag = True
for cha in S:
    w_list.append(cha)
c = 1
for i in w_list:
    w_c = i
    c += 1
    w_time = w_list.count(w_c)
    if w_time != 2:
        flag = False
if flag == True:
    print("Yes")
else:
    print("No")

Solution (Python):
str = input()

a = 0
b = 0
c = 0
d = 0
for i in range(4):
	if (str[i] == str[0]):
		a+=1
	if (str[i] == str[1]):
		b+=1
	if (str[i] == str[2]):
		c+=1
	if (str[i] == str[3]):
		d+=1
		
if (a == 2 and b == 2 and c == 2 and d == 2) :
	print('Yes')
else :
	print('No')

Solution (Python):
s = input()

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

Solution (Python):
s=[]
s = input()
cnt=0
 
if(s[0] == s[1]):
    cnt+=1

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

Solution (Python):
from collections import defaultdict

sent = input()
w_count = defaultdict(int)

for i in range(len(sent)):
    w_count[sent[i]] += 1

result = set(list(w_count.values()))

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

Solution (Python):
s = input()
result = 0
count = 0
for i in s:
  if s.count(i) == 2:
    result = 0
    count+=1
  else:
    count = 5
    break
if result == 1 or count > 4:
  print("No")
else:
  print("Yes")

Solution (Python):
def main():
    s = list(input())
    s_unq = list(set(s))

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

main()

Solution (Python):
x = input()
chars = list(x)
a = ord(chars[0])
b = ord(chars[1])
c = ord(chars[2])
d = ord(chars[3])
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=input()
dic={}
for i in range(4):
    if s[i] in dic.keys():
        dic[s[i]]+=1
    else:
        dic[s[i]]=1
ans=0
for i in range(4):
    if dic[s[i]]!=2:
        ans=1
if ans==0:
    print("Yes")
else:
    print("No")

Solution (Python):
s = input()
if s[0] == s[1] == s[2] == s[3]:
  print('No')
else:
  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()

if (len(S)==4):
    w=[]
    for x in S:
        w.append(x)
    c=dict(zip(w,[0]*len(w)))
    b=[0]*len(c)
    a=dict(zip(w,b))
    if (len(c)==2):
        flag=True
        for t in w:
            c[t]=c[t]+1
        for t in w:
            if c[t]!=2:
                flag=False
        if(flag):
            print("Yes")
        else:
            print("No")
    else:
        print("No")

Solution (Python):
S=list(input())
A=S.count(S[0])
B=S.count(S[1])
C=S.count(S[2])
D=S.count(S[3])
if (A==B==2 or A==C==2 or A==D==2) and (B==C==2 or B==D==2):
  print('Yes')
else:
  print('No')

Solution (Python):

S = str(input())

output = "No"

unique = list(set(S))
if len(unique) == 2:
    if S.count(unique[0]) == 2 and S.count(unique[1]) == 2:
        output = "Yes"

print(output)

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

Solution (Python):
b = input()
S = 0
for i in range(len(b)):
  count = 0
  for _a in b:
    if _a==b[i]:
      count = count + 1
  S = S + abs(count-2)

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

Solution (Python):
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    a = s[0]
    b = ""
    found_a = False
    found_b = False
    for si in s[1:]:
        if si != a:
            if si != b:
                b = si
            else:
                found_b = True
        else:
            found_a = True

    if found_a and found_b:
        print("Yes")
    else:
        print("No")

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

for s in S:
  if s in S_cnt.keys():
    S_cnt[s] += 1
  else:
    S_cnt[s] = 1
    
res = 'Yes'
for s in S_cnt.keys():
  if S_cnt[s] != 2:
    res = 'No'
print(res)

Solution (Python):
s = input()

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

Solution (Python):
listed_str = list(input())
set_str = set(listed_str)
number_str = len(set_str)
count = 0
if(number_str == 2):
  for i in range(3):
    if(listed_str[0] == listed_str[i + 1]):
      count += 1
  if(count == 1):
    print("Yes")
  else:
    print("No")
else:
  print("No")

Solution (Python):
import sys


S = [str(s) for s in input()]

s_dic = {}
for s in S:
    if s in s_dic.keys():
        s_dic[s] += 1
    else:
        s_dic[s] = 1


for i in s_dic.values():
    if int(i) != 2:
        print("No")
        sys.exit()

print("Yes")

Solution (Python):






import sys
import math
import array


class mymath:
    
    pi = 3.14159265358979323846264338

    
    def pnum_eratosthenes(self, n):
        ptable = [0 for i in range(n+1)]
        plist = []

        for i in range(2, n+1):
            if ptable[i]==0:
                plist.append(i)
                for j in range(i+i, n+1, i):
                    ptable[j] = 1
        return plist

    
    def gcd(self, a, b):
        if b == 0:
            return a
        return self.gcd(b, a%b)

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

    
    def mul(self, A, B):
        ans = []
        for a in A:
            c = 0
            for j, row in enumerate(a):
                c += row*B[j]
            ans.append(c)
        return ans

mymath = mymath()


class output:
    
    def list(self, l):
        l = list(l)
        
        for i, num in enumerate(l):
            print(num, end="")
            if i != len(l)-1:
                print(" ", end="")
        print()

output = output()



















def main():
    
    ans = 'No'

    S = input()

    S = [x for x in S]

    S.sort()

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

    print(ans)

if __name__ == '__main__':
    main()

Solution (Python):
S = input()
chars = []
res = True
for i in range(len(S)):
  if len(chars) == 0:
    chars += [S[i]]
  elif len(chars) == 1:
    if S[i] == chars[0]:
      continue
    else:
      chars += [S[i]]
  elif len(chars) == 2:
    if S[i] == chars[0] or S[i] == chars[1]:
      continue
    else:
      res = False
print('Yes' if res and len(chars) == 2 else 'No')

Solution (Python):
s=input()
list=[]
for i in s:
  list.append(i)

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

Solution (Python):
s = input()
n = list(s)
b = list(set(n))
m = []
a=0
d=0
if(len(b)!=2):
	print("No")
else:
	for i in range(0,4):
	    if n[i]==b[0]:
	        a+=1
	    elif n[i]==b[1]:
	        d+=1
if d==2 and a==2:
	print('Yes')

Solution (Python):

import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()

  for i in range(4):
    if s.count(s[i])!=2:
      return 'No'

  return 'Yes'

print(main())

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

S=list(s)
a=0

if S[0]==S[1] and S[2]!=S[0]:
    if S[2]==S[3]:
        a=1

elif S[0]==S[2] and S[2]!=S[1]:
    if S[1]==S[3]:
        a=1

elif S[0]==S[3] and S[2]!=S[0]:
    if S[1]==S[2]:
        a=1

else:
    a=0

if a==1:
    print('Yes')
else:
    print('No')

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

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

S =input()
T = ['']*4
for i in range(4):
    T[i] = S[i]

t = c(T).most_common()
if len(t) == 2 and t[0][1] ==2:
    print('Yes')
else:
    print('No')

Solution (Python):
s = input()

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

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

S = input()

c = collections.Counter(S)
if len(c) == 2:
  for d in c.values():
    if d != 2:
      print("No")
      break
  else:
    print("Yes")
else:
  print("No")

Solution (Python):
str1 = list(input())
X = []

cnt=0
for i in range(4):
    if str1[i] not in X:
        X.append(str1[i])
        cnt += 1
    else:
        pass
if cnt == 2:
    print("Yes")
else:
    print("No")

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

x = [s[0]]
cnt1 = 0
cnt2 = 0

for i in s:
    if x[0] != i:
        if i not in x:
            x.append(i)

if len(x) == 2:
    cnt1 = s.count(x[0])
    cnt2 = s.count(x[1])

if cnt1 == 2 and cnt2 == 2:
    print('Yes')
else:
    print('No')

Solution (Python):


def main():
	S = input()
	isFF = checkFF(S)
	if isFF:
		print('Yes')
	else:
		print('No')

def checkFF(s):
	if len(s) != 4:
		return False
	if (s[0] == s[1]) and (s[2] == s[3]) and (s[0] != s[2]): 
		return True
	elif (s[0] == s[2]) and (s[1] == s[3]) and (s[0] != s[1]):
		return True
	elif (s[0] == s[3]) and (s[1] == s[2]) and (s[0] != s[1]):
		return True
	else:
		return False

main()

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] or S[0] == S[2] and S[1] == S[3] or S[0] == S[3] and S[1] == S[2]:
    print("Yes")
else:
    print("No")

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

Solution (Python):

if __name__=='__main__':
    S = input()
    ans = False
    if S[0]==S[1] and S[0]!=S[2] and S[2]==S[3]: ans = True
    if S[0]==S[2] and S[0]!=S[3] and S[3]==S[1]: ans = True
    if S[0]==S[3] and S[0]!=S[1] and S[1]==S[2]: ans = True
    print('Yes' if ans else 'No')

Solution (Python):
S = input()

V = {}
V[S[0]] = 1
for i in range(1,4):
  if S[i] not in V:
    V[S[i]] = 1
  else:
    V[S[i]] += 1
ret = 'No'
if len(V) == 2:
  check = True
  for k,v in V.items():
    if v != 2:
      check = False
      break
    
  if check == True:
    ret = 'Yes'
    
print(ret)

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

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

Solution (Python):
s = input()
count = 0
for i in s:
	if s.count(i) == 2:
		count += 1

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

Solution (Python):
import collections as c
s=input()
a=c.Counter(s)
if str(a.values())=='dict_values([2, 2])':
  print('Yes')
else:
  print('No')

Solution (Python):
S = input()
C = [0] * 26
for s in S:
    C[ord(s)-ord('A')] += 1
v = 0
for  c in C:
    if c == 2:
        v += 1
    elif c != 0:
        print('No')
        break
if v == 2:
    print('Yes')

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

Solution (Python):

from collections import Counter


def main():
    s = input()
    print("Yes" if Counter(s).most_common()[-1][1] == 2 else "No")


if __name__ == "__main__":
    main()

Solution (Python):
s = str(input())
char_list = list(s)
hoge = {}
flg = False
for i in char_list:
    if i in hoge:
        hoge[i] = hoge[i] + 1
    else:
        hoge[i] = 1
if len(hoge.keys()) == 2:
    if hoge[char_list[0]] == 2:
        print('Yes')
        flg = True
if not flg:
    print('No')

Solution (Python):
s = str(input())
d = {}
for c in list(s):
    count = d.get(c, 0)
    d[c] = count + 1

if len(d) == 2 and all(filter(lambda x: x == 2, d.values())):
    print("Yes")
else:
    print("No")

Solution (Python):
import sys
S = sys.stdin.readline().rstrip()
a1 = S[0]
a2 = S[1]
a3 = S[2]
a4 = S[3]
count1=0
count2=0
count3=0
count4=0

for i in range(4):
  if a1==S[i]:
    count1+=1
  if a2==S[i]:
    count2+=1
  if a3==S[i]:
    count3+=1
  if a4==S[i]:
    count4+=1
    
if count1==2 & count2==2 & count3==2 & count4==2:
  print('Yes')
else: print('No')

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

if chars.count(chars[0]) == 2:
  temp = chars[0]
  chars = [i for i in chars if i != temp]
  if chars.count(chars[0]) == 2:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Solution (Python):
S = input()

count = 0
fircnt = 0
before = ''
first = ''

cl = set()

for s in S:
    if s not in cl:
        count += 1
        cl.add(s)
        if first == '':
            first = s
    if first == s:
        fircnt += 1
if count != 2:
    print('No')
elif fircnt == 2:
    print('Yes')
else:
    print('No')

Solution (Python):
S_list=list(str(input()))
S_set=list(set(S_list))
n1=0
n2=0

if len(S_set) == 2:
    for ii in range(0,len(S_list)):
        if S_list[ii] == S_set[0]:
            n1 += 1
        elif S_list[ii] == S_set[1]:
            n2 += 1
    ans = "Yes" if n1 == 2 and n2 == 2 else "No"
else:
    ans = "No"

print(ans)

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

print 'Yes' if s[0] == s[1] != s[2] == s[3] else 'No'

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

Solution (Python):


s=input()

if s[0] == s[1]:
    if s[1] == s[2]:
        if s[2] == s[3]:
            print('No')
            exit()

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

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

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

else:
    print('No')

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

Solution (Python):
S = input()
count = {}
for s in S:
    if not s in count.keys():
        count[s] = 0
    count[s] += 1
count_sorted = sorted(count.items(),key=lambda x:-x[1])
if count_sorted[0][1] == 2 and count_sorted[1][1] == 2:
    print("Yes")
else:
    print("No")

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

Solution (Python):
S = list(input())
S.sort()
a = ""
cnt_syurui = 0



for i in range(4):
    if a != S[i]:
        cnt_syurui += 1
    a = S[i]

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

Solution (Python):
text = [chr]
text = input()
ch = True
count = 0
for i in range(len(text)):
    for j in range(len(text)):
        if not(text[i] != text[j]):
            count += 1
if count == 8:
    print("Yes")
else:
    print("No")

Solution (Python):

s = input()
a = min(s)
b = max(s)
print((a != b and s.count(a) + s.count(b) == len(s)) and 'Yes' or 'No')

Solution (Python):

import sys
from collections.abc import Iterable
from math import *
from itertools import *
from collections import *
from functools import *
from operator import *
try:
    from math import gcd
except Exception:
    from fractions import gcd

YES = "Yes"  
NO = "No"  

def solve(S: str):
    c = Counter(S)
    return YES if len(c) == 2 and len(set(c.values())) == 1 else NO


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  
    result = solve(S)
    if isinstance(result, Iterable) and not isinstance(result, str):
        result = '\n'.join([str(v) for v in result])
    print(result)

if __name__ == '__main__':
    main()

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 = input()
a = S[0]
b = S[1]
c = S[2]
d = S[3]

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

Solution (Python):
import collections
s = input()
sli = list(s)
c = collections.Counter(sli)
d = c.most_common()
if len(d) == 2:
    if d[0][1] == d[1][1]:
        ans = "Yes"
    else:
        ans = "No"
else:
    ans = "No"

print(ans)

Solution (Python):
s=input()

slist=[]
for i in range(4):
    slist.append(s[i])

slistx=sorted(slist)

if slistx[0]==slistx[1]:
    if slistx[2]==slistx[3]:
        if slistx[1]!=slistx[2]:
            print("Yes")
            quit()
            
print("No")

Solution (Python):
word = input()

while True:
    if(word[0]==word[1]):
        if((word[2]==word[3])and(word[0]!=word[2])):
            print("Yes")
            break
    if(word[0]==word[2]):
        if(word[1]==word[3])and(word[0]!=word[1]):
            print("Yes")
            break    
    if(word[0]==word[3]):
        if((word[1]==word[2])and(word[0]!=word[1])):
            print("Yes")
            break
    if((word[1]==word[2])and(word[0]==word[1])):
        print("No")
        break
    if((word[1]==word[3])and(word[0]==word[1])):
        print("No")
        break
    if((word[1]==word[3])and(word[2]==word[1])):
        print("No")
        break
    else:      
        print("No")
        break

Solution (Python):
s = input()
chars = []
a = None
a_count = 0
b = None
b_count = 0
fifty_fifty = True
for i in range(4):  
  if len(chars) == 0:
    chars.append(s[i])
    a = s[i]
    a_count += 1
  else:
    if s[i] not in chars:
      chars.append(s[i])
      b = s[i]
    if len(chars) > 2:
      fifty_fifty = False
    if s[i] == a:
      a_count += 1
    elif s[i] == b:
      b_count += 1
  
if fifty_fifty and a_count == b_count == 2:
  print('Yes')
else:
  print('No')

Solution (Python):
input_data = input()

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

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

Solution (Python):
s=str(input())
lst=list(s)
lst.sort()
result = False

if lst[0] == lst[1]:
    if lst[1] != lst[2]:
        if lst[2] == lst[3]:
            result = True

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