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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding=utf-8

###
### for atcorder program
###

import sys
import math
import array

# math class
class mymath:
    ### pi
    pi = 3.14159265358979323846264338

    ### Prime Number
    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

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

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

    ### Mat Multiplication
    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()

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

output = output()

### input sample
#i = input()
#N = int(input())
#A, B, C = [x for x in input().split()]
#N, K = [int(x) for x in input().split()]
#inlist = [int(w) for w in input().split()]

#R = float(input())
#A.append(list(map(int,input().split())))

#for line in sys.stdin.readlines():
#    x, y = [int(temp) for temp in line.split()]

### output sample
#print("{0} {1} {2:.5f}".format(A//B, A%B, A/B))
#print("{0:.6f} {1:.6f}".format(R*R*math.pi,R*2*math.pi))
#print(" {}".format(i), end="")

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A問題
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())

Submission status: Accepted

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

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 and s.count(s[3]) == 2:
    print("Yes")
else: print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A - Fifty-Fifty

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC132
from collections import Counter


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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = sorted(raw_input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:

#Sの入力
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')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
a = min(s)
b = max(s)
print((a != b and s.count(a) + s.count(b) == len(s)) and 'Yes' or 'No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
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"  # type: str
NO = "No"  # type: str

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)  # type: str
    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()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
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()
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")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_data = input()

if input_data.count(input_data[0]) == 2 and len("".join(set(input_data))) == 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[1]==S[2]):
    if S[0]==S[1]==S[2]==S[3]:
        print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s=list(input())

a=s[0]
f=0
for x in range(1,4):
  if a!=s[x]:
    b=s[x]
    f=1
    break

if f==0:
    print("No")
    sys.exit()

for y in range(1,4):
    if y!=x:
        if a!=s[y] and b!=s[y]:
            print("No")
            sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
S = input()

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

print("Yes")

Submission status: Accepted

Solution code:
import collections

if __name__ == '__main__':
    l = list(input())
    c = collections.Counter(l)
    for char, count in c.most_common(2):
        if count != 2:
            print("No")
            exit()
    print("Yes")

Submission status: Accepted

Solution code:
s = input()
m = []
for i in s:
        m.append(i)
count_list = []
for i in m:
        count = 0
        for j in m:
                if i == j:
                        count += 1
        count_list.append(count)
for i in count_list:
        if i != 2:
                print("No")
                exit()
print("Yes")

Submission status: Accepted

Solution code:
a = str(input())
b=list(set(a))

if len(b) == 2:
  count = 0
  for i in range(1,4):
    if a[i] == a[0]:
      count +=1
  if count ==1:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
s=input()
for i in range(1):
    if s.count(s[0])==2:
        if s.count(s[1])==2:
            if s.count(s[2])==2:
                if s.count(s[3])==2:
                    print('Yes')
                    break
    print('No')

Submission status: Accepted

Solution code:
s = input()

n = len(s)

flg = True

if n != 4:
    flg = False  

else:  
    l = []
    for i in range(n):
        l.append(s[i])
    l.sort()
    if l[0] != l[1] or l[1] == l[2] or l[2] != l[3]:
        flg = False

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

Submission status: Accepted

Solution code:
S = input()
S = list(S)
#print(S)
counts0 = 0
counts1 = 0
counts2 = 0
if S[0] == S[1]:
    counts0 = counts0 + 1
if S[0] == S[2]:
    counts0 = counts0 + 1
if S[0] == S[3]:
    counts0 = counts0 + 1
if S[1] == S[2]:
    counts1 = counts1 + 1
if S[1] == S[3]:
    counts1 = counts1 + 1
if S[2] == S[3]:
    counts2 = counts2 + 1

if counts0 == 1 and ((counts1 == 1 and counts2 ==0) or (counts1 == 0 and counts2 == 1)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input()
sum=[0,0,0,0]
for t in range(4):
    for i in range(4):
        if S[int(t)]==S[int(i)]:
            sum[int(i)]+=1
if sum[0] == 2 and sum[1] == 2 and sum[2] == 2 and sum[3] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()

a = {}

for i in s:
    if i in a:
        a[i] += 1
    else:
        a[i] = 1

if len(a) == 2:
    values = list(a.values())
    if values == [2,2]:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

Solution code:
import numpy as np

S = input()

moji = [i for i in S]

a = moji[0]
for i in range(len(moji)):
    if a != moji[i]:
        b = moji[i]
count = 0
count2 = 0
for i in range(0,len(moji)):
    if moji[i] == a:
        count += 1
    elif moji[i] == b:
        count2 += 1
if count == 2 and count2 == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

m = {}

for c in s:
    if c not in m:
        m[c] = 1
    else:
        m[c] += 1

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

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
from collections import Counter

S = input()
S = list(S)


if(Counter(S).most_common(2)[0][1]!=4):
    c1 = Counter(S).most_common(2)[0][1]
    c2 = Counter(S).most_common(2)[1][1]
    if(c1==c2):
        if(c1==2):
            print("Yes")
        else:
            print("No")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
a = list([str(i) for i in input()])
s1={a[0]}
s2={a[1]}
s3={a[2]}
s4={a[3]}

s_union=s1|s2|s3|s4
if len(s_union)==2 and a.count(a[0])==2 and a.count(a[1])==2 and a.count(a[2])==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input();
check = [0]*26;
base = ord("A");
count2 = 0;
for i in range(4) :
	check[ord(s[i])-base] += 1;
for i in range(26) :
	if check[i] == 2 :
		count2 += 1;
if count2 == 2 :
	print('Yes');
else :
	print('No')

Submission status: Accepted

Solution code:
s = input()

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

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

Submission status: Accepted

Solution code:
S=input()
for i in range(4):
  if S.count(S[i])!=2:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
S=list(input())
dic = {}

for s in S:
    dic[s] = 0

for s in S:
    dic[s] += 1

if len(dic) == 2:
    flag = True
    for v in dic.values():
        if v != 2:
            flag = False
    
    if flag == True:
        print("Yes")
    else:
        print("No")

else:
    print("No")

Submission status: Accepted

Solution code:
import sys 

word =input()
flag = 0

for i in range(4):
    if word.count(word[i]) == 2:
        flag += 1
    
if flag == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
a = s.count(s[0])
if a == 4:
    print("No")
    exit()
for i in range(2):
    if s[0] != s[i+1]:
        b = s.count(s[i+1])
        if a + b == 4:
            print("Yes")
        else:
            print("No")
        exit()

Submission status: Accepted

Solution code:
S = input()

S_dict = {}

for s in S:
    if not s in S_dict:
        S_dict[s] = 1
    else:
        S_dict[s] += 1

x = 1
for k,v in S_dict.items():
    x *= v

print('Yes') if len(S_dict) == 2 and x == 4 else print('No')

Submission status: Accepted

Solution code:
s = input()
ans = []
for i in range(4):
	for j in range(4):
		if i >= j:
			continue
		ans.append(s[i] == s[j])
if sum(ans) == 2:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
C = 0
if S[0] == S[1]:
	if S[2] == S[3]:
		C = 1
elif S[0] == S[2]:
	if S[1] == S[3]:
		C = 1
elif S[0] == S[3]:
	if S[1] == S[2]:
		C = 1
if (S[0] == S[1]) & (S[1] == S[2]) & (S[2] == S[3]):
	print('No')
elif C == 1:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
import collections as C
def calc(arg):
    count = C.Counter(arg)
    if len(count) is not 2:
        return "No"
    if count.most_common()[0][1] is not count.most_common()[1][1]:
        return "No"
    return "Yes"
print(calc(input()))

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
A=list(input())
B=[]
a=A[0]
cnt1=0
cnt2=0
for i in range(4):
    if(a==A[i]):
        cnt1+=1
    else:
        B.append(A[i])

if(cnt1==2):
    b=B[0]
    for i in range(2):
        if(b==B[i]):
            cnt2+=1
    if(cnt2==2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())

cnt = [1,0,0,0]

if(S[1] == S[0]):
    cnt[0] += 1
else:
    cnt[1] += 1

if(S[2] == S[0]):
    cnt[0] += 1
elif(S[2] == S[1]):
    cnt[1] += 1
else:
    cnt[2] += 1

if(S[3] == S[0]):
    cnt[0] += 1
elif(S[3] == S[1]):
    cnt[1] += 1
elif(S[3] == S[2]):
    cnt[2] += 1
else:
    cnt[3] += 1

if(cnt == [2,2,0,0] or cnt == [2,0,2,0]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
d = defaultdict(int)
for c in S:
    d[c] += 1

if len(d) == 2:
    for v in d.values():
        if v != 2:
            print('No')
            quit()
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
a = input()

d = {}
for c in a:
  if c in d:
    d[c] += 1
  else:
    d[c] = 1

sum = 0
if len(d) == 2:
  for s in d.values():
    sum += s
  if sum == 4:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()

x=True
for c in S:
    x = x and S.count(c) == 2

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

Submission status: Accepted

Solution code:
s = input()
l = []
for i in s:
  l.append(i)
a = set(l)
if len(a) == 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[0] != s[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin
S = stdin.readline().rstrip()
s1 = S[0]
if S[0] == S[1]:
    s2 = S[2]
else:
    s2 = S[1]
if S.count(s1) == 2 and S.count(s2) == 2:
    print('Yes')
else:
    print('No')