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:
#!/usr/bin/env python
# -*- coding: utf-8 -*-

from sys import stdin

N = [ x for x in stdin.readline().rstrip()]

flg = 0

type_str = ""

for i in range(4):
    for j in range(i+1,4):
        if N[i] == N[j]:
            type_str = N[i]
            del N[j]
            del N[i]
            flg = 1
            break

    if flg == 1:
        break

if flg == 1 and N[0] == N[1] and type_str != N[0]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
str = input()

chars = {}
for char in str:
    if char in chars:
        chars[char] += 1
    else:
        chars[char] = 1
        
if len(chars) == 2 and chars[str[0]] == 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]) 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()
for i in S:
    cnt=0
    for j in S:
        if j==i:
            cnt += 1
    if cnt!=2:
        print("No")
        break
if cnt==2:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()
ls = []
for i in S:
    ls.append(i)
a = set(ls)
if len(a) != 2:
    print("No")
elif ls[0] == ls[1] == ls[2] or ls[1] == ls[2] == ls[3]:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
a = input()
b = list(a)
b.sort()
Judge = True
if b[0] != b[1]:
    Judge = False
if b[1] == b[2]:
    Judge = False
if b[2] != b[3]:
    Judge = False
if Judge == True:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
A="Yes"
for i in range(4):
    if s.count(s[i]) != 2:
        A="No"
        break
print(A)

Submission status: Accepted

Solution code:
S = input()
Slen = len(S)
cnt=[0,0,0]
flg = True
for i in range(Slen-1):
  
  for j in range(Slen):
    if S[i]==S[j]:
      cnt[i] += 1
  
  if cnt[i] < 2 or cnt[i] > 2:
    flg = False
    break

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

Submission status: Accepted

Solution code:
S=input()

if len(S)!=4:
  print('No')
else:  
  Sorted_S = sorted(S)
  
  L1=Sorted_S[0]
  L2=Sorted_S[1]
  L3=Sorted_S[2]
  L4=Sorted_S[3]

  if (L1==L2) and (L3==L4) and (L2!=L3):
    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[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[2] == s[1]):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
input_data= input()
dic={}
yes_flag= 0

for moji in input_data:
  try:
    dic[moji] = dic[moji] + 1
  except KeyError:
    dic[moji] = 1


for keys in dic:
  if dic[keys] == 2:
    yes_flag = yes_flag +1

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

Submission status: Accepted

Solution code:
a=map(str, input())
char=list(a)
b=set(char)
c=len(b)
if c==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())
if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
    print('Yes')
    exit()
if s[0] == s[2] and s[1] == s[3] and s[0] != s[1]:
    print('Yes')
    exit()
if s[0] == s[3] and s[1] == s[2] and s[0] != s[1]:
    print('Yes')
    exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

check = True
 
if len(set(list(s))) == len(s):
  print('No')
else:
    for c in list(set(list(s))):
        if list(s).count(c) != 2:
            if check:
                print('No')
                check = False
    if check:
        print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = str(input())
s_list = []
s_set = set()
for s in S:
    s_set.add(s)
    if s in s_list:
        s_list.remove(s)
    else:
        s_list.append(s)
        
if len(s_list) == 0 and len(s_set) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
c = Counter(s)

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

Submission status: Accepted

Solution code:
S = input()
x = [str(i) for i in str(S)]
a = x[0]
b = x[1]
c = x[2]
d = x[3]
if a == b == c == d:
    print('No')
elif a == b and c == d: 
    print('Yes')
elif b == c and a == d:
    print('Yes')
elif a == c and b == d:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import os, sys, re, math

s = input()
s = list(s)
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():
    a= input()

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S=input()
count=0
first=False
OK=False
memo=S[0]
for i in range(4):    
    if S[i]==S[0]:
        count+=1
    elif (S[i]!=S[0] and first==False):
        memo=S[i]
        first=True
    elif (S[i]!=S[0] and first==True):
        if S[i]==memo:
            OK=True


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

Submission status: Accepted

Solution code:
import sys
s = input()
s = s.replace(s[0],'')
if len(s) == 0:
    print('No')
    sys.exit()
else:
    s = s.replace(s[0],'')
if len(s) == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()  

count=0

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

if count == 8:
    print('Yes')

else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
S = str(S)
for i in range(len(S)):
  s = S[i]
  count = S.count(s)
  if count != 2:
    print("No")
    break
  if count == 2:
    if i == (len(S) - 1):
      print("Yes")

Submission status: Accepted

Solution code:
import collections

def all(iterable):
    for element in iterable:
        if not element:
            return False
    return True

S=input()
c = collections.Counter(list(S))
pred = len(c.keys())==2 and all([x==2 for x in list(c.values())])
print('Yes' if pred else '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:
l=[0 for i in range(300)]
s=input()
for c in s:
    l[ord(c)]+=1
l.sort(reverse=True)
if l[0]==2 and l[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==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')

Submission status: Accepted

Solution code:

st =input()
chars = []
for sss in st:
    chars.append(sss)
chars.sort()
if chars[0] == chars[1] and chars[2] == chars[3] and chars[2] != chars[1]:
    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[1] !=  a[2]:
       print('Yes')
else:
     print('No')

Submission status: Accepted

Solution code:
s = input()
flg = 0
for c in s:
  if s.count(c) != 2:
    flg = 1
if flg == 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

flag = 1
for v in d.values():
    if v != 2:
        flag = 0

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

Submission status: Accepted

Solution code:
s = list(input())

if s.count(s[0]) == 4:
    print("No")
else:
    for i in s[1:]:
        if s[0] == i:
            s.remove(i)
            s.remove(i)
            break

    if len(s) == 4:
        print("No")

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

Submission status: Accepted

Solution code:
s = str(input())
adic = {}

for i in range(4):
  if not s[i] in adic:
    adic[s[i]] = 1
  else:
    adic[s[i]] += 1
    
abool = True
if len(adic) == 2:
  for item in adic:
    if adic.get(item) != 2:
      abool = False
else:
  abool = False
  
if abool:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
count = 0
s = list(str(input()))

if s[0] == s[1]:
    if s[2] == s[3]:
        count = 1
elif s[0] == s[2]:
    if s[1] == s[3]:
        count = 1
elif s[0] == s[3]:
    if s[1] == s[2]:
        count = 1

if s[0] == s[1] == s[2] == s[3]:
    count = 0

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

Submission status: Accepted

Solution code:
import collections
s = input()
s = list(s)
s.sort()
count = 0
ans = collections.Counter(s)
ans = len(ans)
if ans == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input().upper()

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:
in_str = input()
ok = 0
if in_str[0] == in_str[1]:
  if in_str[2] == in_str[3]:
    ok += 1
if in_str[0] == in_str[2]:
  if in_str[1] == in_str[3]:
    ok += 1
if in_str[0] == in_str[3]:
  if in_str[1] == in_str[2]:
    ok+= 1
if(ok == 1):
  print("Yes")
else :
  print("No")

Submission status: Accepted

Solution code:
import collections

x = input()
TF =  x.isupper() and x.isalpha()
flg  = 0
if(TF):
    li = [i for i in x]
    count_dict = collections.Counter(li)
    list = [v for k, v in count_dict.items()]
    if(list == [2,2]):
        print("Yes")
        flg = 1
if(flg == 0):
    print("No")

Submission status: Accepted

Solution code:
str = input().strip()
alp = [chr(i) for i in range(65, 65+26)]
ans = {}
for S in str:
    for A in range(26):
        if S == alp[A]:
            if alp[A] in ans.keys():
                ans[alp[A]] += 1
            else:
                ans[alp[A]] = 1
if len(ans) == 2 and max(ans.values()) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
from collections import Counter

S = stdin.readline().rstrip()
cnt = Counter(S)

if len(cnt.keys()) == 2 and set(cnt.values()) == {2}:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
text = input()

text1 = text.replace(text[0], "")
try:
	text2 = text1.replace(text1[0], "")
except:
	text2 = "e"

if len(text) == 4 and len(text1) == 2 and len(text2) == 0:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S=input()

if S[1]==S[0]:
    if S[2] == S[3]:
        ans = 1
    else:
        ans = 0

elif S[0] == S[2]:
    if S[1] == S[3]:
        ans = 1
    else:
        ans = 0

elif S[0] == S[3]:
    if S[1] == S[2]:
        ans = 1
    else:
        ans = 0

else:
    ans = 0

if S[0]==S[1] == S[2]:
    ans = 0

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

Submission status: Accepted

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

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

elif S.count(Slist[0]) == 2 and S.count(Slist[1]) == 2:
        print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
s=input()

x=len(set(s))

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

Submission status: Accepted

Solution code:
a = list(input())
before = -1
count =0
for char in a:
    current = char
    if before == current:
        count = count+1
    else:
        before = current

if count<=2:
    s = set()
    for item in a:
        s.add(item)
    if len(s) == 2:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()

D = 0
temp = 0
for i in S:
    if S.count(i) != 2:
      print("No")
      D = 1
      break
      
if D == 0:
  print("Yes")

Submission status: Accepted

Solution code:
def count_cap(S):
    renso={"A":0,"B":0,"C":0,"D":0,"E":0,"F":0,"G":0,"H":0,"I":0,"J":0,"K":0,"L":0,"M":0,"N":0,
          "O":0,"P":0,"Q":0,"R":0,"S":0,"T":0,"U":0,"V":0,"W":0,"X":0,"Y":0,"Z":0}
    count = 0
    for a in S:
        if renso[a] == 1:
            count = count + 1
        renso[a] = renso[a]+1
    
    if count == 2:
        return "Yes"
    else:
        return "No"

print(count_cap(input()))

Submission status: Accepted

Solution code:
import collections

S = input()
split_str = list(S)
coll = collections.Counter(split_str)
# print(coll.values())
# print(coll.most_common()[0][1])
# print(coll.most_common()[1][1])


if len(coll) == 2 & coll.most_common()[0][1] == 2 & coll.most_common()[1][1] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!

n = input()
a1 = n[0]
a2 = n[0]
count1 = 1
count2 = 0
for nc in range(1,4):
    if(n[nc] == a1):
        count1 += 1
    elif(a1 == a2):
        a2 = n[nc]
        count2 += 1
    elif(n[nc] == a2):
        count2 += 1
    else:
        count1 = 5
if(count1 == count2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()

result = 'Yes' if len(set(s)) == 2 and s.count(s[0]) == 2 else 'No'

print(result)

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def logic():
    text = input()
    i = 0
    check = False
    while i < 3:
        count = text.count(text[i])
        if count != 2:
            print("No")
            return True
        elif count == 2:
            check = True
            text.replace(text[i],"")
        else:
            print("No")
            return True
        i += 1
    if check:
        print("Yes")

if __name__ == '__main__':
    logic()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#長さ 4 の英大文字からなる文字列 S が与えられます。
#S がちょうど 2 種類の文字からなり、かつ現れる各文字はちょうど 2 回ずつ現れているかどうかを判定してください。

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#d=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
#import numpy as np
#n=int(input())
#import fractions
#import itertools
#import math
#lis=list(input().split())
#lis=list(map(float,input().split()))
#lis=list(map(int,input().split()))
#n=int(input())

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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#coding:utf-8

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

Submission status: Accepted

Solution code:
import collections

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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