Problem:


Score : 100 points

Problem Statement

You are given a 4-character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S.

Constraints

The length of S is 4.

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.

Sample Input 1

ASSA

Sample Output 1

Yes

S consists of A and S which both appear twice in S.

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No



Sample input:
ASSA


Sample output:
Yes

Submission status: Accepted

Solution code:
S = input()

lstStr = sorted(S)

res = "Yes" if len(set(lstStr)) == 2 and lstStr[1]!=lstStr[2] else "No"

print(res)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
count={}
for i in s:
    count.setdefault(i,0)
    count[i]+=1
l=[count.values()]
if len(count.keys())==2:
    k,l=count.values()
    if k==l==2:
        print('Yes')
    else:
        print('No')        
else:
    print('No')

Submission status: Accepted

Solution code:
s=list(input())
a=[]
for x in s:
    if s.count(x) == 2 and x not in a: a.append(x)
print('Yes' if len(a) == 2 else 'No')

Submission status: Accepted

Solution code:
l = list(map(str, input())) 
if l.count(l[0]) == l.count(l[1]) == l.count(l[2]) == l.count(l[3]) == 2: 
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
d = defaultdict(int)
for s in S:
  d[s] += 1
  
if len(d) != 2:
  print('No')
else:
  for v in d.values():
    if v != 2:
      print('No')
  else:
    print('Yes')

Submission status: Accepted

Solution code:
def main():
    from collections import Counter
    S = list(input())
    if len(Counter(S))==2:
        print("Yes")
    else:
        print("No")

if __name__=="__main__":
    main()

Submission status: Accepted

Solution code:
S=input()
T=list()
for i in range(len(S)):
    T.append(S[i])
T.sort()
if len(set(T))==2 and T[0]==T[1] and T[2]==T[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
l = []
for i in range( len( s )):
  if not ( s[i] in l ):
    l.append( s[i] )

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

Submission status: Accepted

Solution code:
word = input()
chr =[s for s in word]

x=[0,0,0,0]

for i in range(4):
  for j in range(4):
    if chr[i]==chr[j]:
      x[i]=x[i]+1

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

Submission status: Accepted

Solution code:
S = input()
l = [c for c in S]
ls = sorted(l)
if ls.count(ls[0]) == 2 and ls.count(ls[2]) == 2:
  r = 'Yes'
else:
  r = 'No'
                                     
print(r)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#python3
s=input()
d={k:s.count(k) for k in set(s)}

def solve():
  if len(d) != 2:
    return False
  for i in d.values():
    if i != 2:
      return False
  return True

print('Yes') if solve() else print('No')

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
S = input()
sorted_S = sorted(S)

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

Submission status: Accepted

Solution code:
s = input()
se = set()

for i in s:
    se.add(i)
li = list(se)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
"""
author : halo2halo
date : 12, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

S = set(readline().decode('utf8').rstrip())
print('Yes' if len(S) == 2 else 'No')

Submission status: Accepted

Solution code:
S = list(input())

count = 0

for i in range(len(S)):
    for j in range(i+1, len(S)):
        if S[i] == S[j]:
            count += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
import collections
import sys

input = sys.stdin.readline


class AtCoder:
    def main(self):
        S = input().rstrip()
        counter = collections.Counter(S)
        if len(counter) != 2:
            print("No")
            exit()

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


# Run main
if __name__ == '__main__':
    AtCoder().main()

Submission status: Accepted

Solution code:
s = input()
a = s[0]
s = s.replace(a,"")
if len(s) != 2:
  print("No")
  exit()
if s[0] == s[1]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict
dd = defaultdict(int)

S=input()
N=len(S)
for i in range(N):
    dd[S[i]]+=1
    
if len(dd.keys())==2 and list(dd.values())==[2,2]:
    ans="Yes"
else:
    ans="No"
    
print(ans)

Submission status: Accepted

Solution code:
s = list(input())

for i in s:
  if s.count(i) != 2:
    print("No")
    exit(0)

print("Yes")

Submission status: Accepted

Solution code:
S = list(input())
d = {}
for s in S:
    if s in d:
        d[s] += 1
    else:
        d[s] = 1
print("Yes" if list(d.values()) == [2, 2] else "No")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
count = 0
for i in range(len(S)):
    for j in range(i+1,len(S)):
        if S[i]==S[j]:
            count += 1
if count==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

Solution code:
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    S=sorted(input())
    if S[0]==S[1] and S[1]!=S[2] and S[2]==S[3]:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    do()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
li=[0]*4
for i in range(4) :
  li[i]=S[i]
li.sort()
a = 'No'
if li[0] != li[2] and li[0] == li[1] and li[2] == li[3] :
  a = 'Yes'
print(a)

Submission status: Accepted

Solution code:
S = list(input())
result = len(set(S))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

s.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
a = str(input())
for i in range(len(a)-1):
    if(a[i+1] == a[0]):
        t = i+1
        break
    t = 8

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

Submission status: Accepted

Solution code:
def main():
	n = list(str(input()))
	n_s = sorted(n)
	if n_s[0] == n_s[1] and n_s[2] == n_s[3] and n_s[1] != n_s[2]:
		print("Yes")
	else:
		print("No")

 
if __name__ == '__main__':
	main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = sorted(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

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

print("Yes" if (len(d.keys()) == 2 and all([d[k] == 2 for k in d])) else "No")

Submission status: Accepted

Solution code:
def main():
    S = input()
    dict = {}
    for i in range(4):
        if S[i] in dict:
            dict[S[i]] += 1
        else:
            dict[S[i]] = 1
    if len(dict.values()) == 2:
        if list(dict.values())[0] == 2:
            return "Yes"
    else:
        return "No"

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

Submission status: Accepted

Solution code:
ss = input()
set_ss = set(ss)
if len(set_ss) != 2 :
  print("No")
else:
  for s in set(ss):
    if ss.count(s) != 2:
      print("No")
      break
  else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().rstrip()

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

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()

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

if list(d.values()) == [2, 2]:
  ans = 'Yes'
else:
  ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
import sys

li=list(input())
a=[0,0,0,0]
for i in range(4):
    a[i]=li.count(li[i]);
    if a[i]==2:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
from sys import stdin

str = stdin.readline().rstrip()

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = sorted(input())


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

Submission status: Accepted

Solution code:
S = sorted(input())
print('Yes') if S.count(S[0]) == 2 and S.count(S[2]) == 2 else print('No')

Submission status: Accepted

Solution code:
S=input()
sort_list= sorted(S)

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

Submission status: Accepted

Solution code:
S = str(input())

if (S[0:2] == S[2:4] and S[1] != S[2]) or (S[0:2] == ''.join(list(reversed(S[2:4]))) and S[0] != S[2]):
    print('Yes')
elif S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()

if len(set(s)) != 2:
    print("No")
else:
    for i in set(s):
        if s.count(i) != 2:
            print("No")
            break
        else:
            print("Yes")
            break

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
dic = {}
flg = True

for i in range(4):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
        
for k, v in dic.items():
    if v == 2:
        pass
    else:
        flg = False

if flg == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
S = list(s[i] for i in range(4))
set_S = list(set(S))

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
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')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

if S.count(S[0]) != 2:
    print("No")
    exit()

else:
    S = S.strip(S[0])

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

else:
    print("No")

Submission status: Accepted

Solution code:
s = list( str( input() ) )
check = [ x == s[0] for x in s ]
if len( set(s) ) == 2 and sum( check ) == 2 :
   print( "Yes" )
else : 
   print( "No" )

Submission status: Accepted

Solution code:
list_S = list(str(input()))
cnt = 0
for i in range(4):
    if list_S[i] == list_S[1]:
        cnt += 1
if cnt == 2 and len(set(list_S)) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input()
a=set(S)
if len(a)==2:
  if S[0]==S[1] and S[2]==S[3]:
    print('Yes')
    exit()
  if S[0]==S[2] and S[1]==S[3]:
    print('Yes')
    exit()
  if S[0]==S[3] and S[2]==S[1]:
    print('Yes')
    exit()

print('No')

Submission status: Accepted

Solution code:
s=[i for i in input()]
a=s[0]
for i in range(3):
    if s[i]!=a:
        b=s[i]
        break
             
print("Yes" if s.count(a)==2 and s.count(b)==2 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=[i for i in input()]
dic={}
for i in range(4):
    if s[i] in dic:
        dic[s[i]] += 1
    else:
        dic[s[i]] = 1
flg=True        
for k,v in dic.items():
    if v != 2:
	    flg=False
print("Yes" if flg else "No")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
counter = Counter(S)

if len(counter) != 2:
    print('No')
else :    
    flag = True
    for k, v in counter.items():
        if v != 2:
            flag = False

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

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
counter = Counter(S)

v = list(counter.values())
if v[0] == 2 and v[1] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = list(input())
a.sort()

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

else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())
s.sort()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())

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

Submission status: Accepted

Solution code:
#coding:utf-8
import bisect
from collections import deque
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = True

def index(a,b):
    return str(min(a,b)) + "," +  str(max(a, b))

def main(given = sys.stdin.readline):
    input = lambda : given().rstrip()
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())
    XLMIIS = lambda x : [LMIIS() for _ in range(x)]

    s = input()
    if s[0] == s[1] == s[2]:
        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")




if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
slist = list(s)

slist.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
A=list(map(str,input()))

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

Submission status: Accepted

Solution code:
import sys
string = input()

ch_1 = ""
ch_2 = ""
ct_1 = 0
ct_2 = 0
for ch in string:
  
  if ch_1 != ch and ch_2 != ch and ch_1 is not "" and ch_2 is not "":
    print("No")
    sys.exit(0)
  if ch_1 != ch:
    if ch_1 == "":
      ch_1 = ch
    else:
      ch_2 = ch

  if ch_1 == ch:
    ct_1 += 1
  elif ch_2 == ch:
    ct_2 += 1


if ct_1 == 2 and ct_2 == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = sorted(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
st = list(map(str, S))
o = st[0]
st.remove(o)
if o not in st:
    print("No")
else:
    st.remove(o)
    t = st[0]
    st.remove(t)
    if o in st or o == t:
        print("No")
    elif t in st:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
s = input()

ss = sorted(s)
if ss[0] == ss[1] and ss[2] == ss[3] and ss[0] != ss[2]:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

Solution code:
s=input()
print(["No","Yes"][all(s.count(s[i])==2 for i in range(4))])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = sorted(list(str(input())))

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = list(str(input()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
s=collections.Counter(input())
if len(s)==2 and s[0]==s[1]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
ans = "Yes"
for char in S:
    if S.count(char) != 2:
        ans = "No"
        break

print(ans)

Submission status: Accepted

Solution code:
S = input()
d = {}

for c in S:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1

v = list(d.values())

ans = "Yes" if len(d) == 2 and v[0] == v[1] else "No" 
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
S = input()
S2 = collections.Counter(S)
c = True
for i,v in S2.items():
  if v == 2:
    continue
  else:
    c = False
if c:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
a=[]
b=[]
for i in s:
    a.append(i)

for j in a:
    if j not in b:
        b.append(j)

c=[]
for k in b:
    c.append(a.count(k))

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

Submission status: Accepted

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

else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=list(map(str,input()))
count=0
for i in range(len(a)-1):
    for j in range(i+1,len(a)):
        if a[i]==a[j]:
            count+=1
if count==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import math

MOD = 10 ** 9 + 7


def main():
    S = input()
    dic = {}

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

    if len(dic.keys()) == 2 and len([i for i in dic.values() if i == 2]):
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections
s = list(i for i in str(input()))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC132a
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**6)

s = list(input()[:-1])
s.sort()
print('YNeos'[s.count(s[0]) != 2 or s.count(s[2]) != 2::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
for i in range(len(s)):
    cnt=0
    for j in range(len(s)):
        if s[i] == s[j]:
            cnt+= 1
    if cnt != 2:
        print("No")
        exit(0)
print("Yes")

Submission status: Accepted

Solution code:
S = input()

appearence = {}

for char in S:
    if char not in appearence:
        appearence[char] = 1
    else:
        appearence[char] += 1

if len(appearence) == 2 and all(2 == value for value in appearence.values()):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import collections
S = str(input())

s = collections.Counter(S)

ans = 4
for key in s.keys():
   ans = ans //2

if ans == 1 and len(s) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
import sys

S = input()
S = list(S)

first_S = S.pop()
for i in range(len(S)):
    if S[i] == first_S:
        S.remove(first_S)
        break
else:
    print('No')
    sys.exit()

second_S = S.pop()
for i in range(len(S)):
    if S[i] == second_S:
        break
else:
    print('No')
    sys.exit()

if first_S == second_S:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
# Fifty-Fifty
d = {}
for s in input():
    if s not in d.keys():
        d[s] = 1
    else:
        d[s] += 1

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