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 python3
# -*- coding: utf-8 -*-
''' 
------------------------
author : iiou16
------------------------
'''

def main():
    S = input()

    count = {}

    for s in S:
        if s not in count.keys():
            count[s] = 1
        else:
            count[s] += 1
    flag = 0
    if len(count) == 2:
        for v in count.values():
            if v != 2:
                flag = -1
                break
    else:
        flag = -1
    
    if flag == 0:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()


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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
S = input().split()
 
s = str(S)
s = s[2:-2]

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

Submission status: Accepted

Solution code:
s = input()

if s[0] == s[1]:
    if s[1] == s[2]:
        print('No')
    elif s[2] == s[3]:
        print('Yes')
    else:
        print('No')
else:
    if 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()
import collections
li = [i for i in S]
d = collections.Counter(li)
li_uniq = list(set(li))
ans = "No"
if len(li_uniq) == 2:
    if d[li_uniq[0]] == 2:
        if d[li_uniq[1]] == 2:
            ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
s = input()
ss = list(set([s[0], s[1], s[2], s[3]]))
flag = True
if len(ss) != 2:
    flag = False
else:
    for i in range(len(ss)):
        if s.count(ss[i]) == 2:
            continue
        else:
            flag = False
            break

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

Submission status: Accepted

Solution code:
S = raw_input()

p = []
for s in S:
      p.append(s)
p.sort()

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

Submission status: Accepted

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

Submission status: Accepted

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

tmp = input()

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

if len(r.keys()) == 2 and r[list(r.keys())[0]] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections
S=list(input())
c = collections.Counter(S)
cnt=0
if len(c)==2:
    for cc in c:
        if c[cc]==2:
            cnt+=1
    if cnt==2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
a=input()
x = [a[i:i+1] for i in range(len(a))]
if (a[0]==a[1] and a[2]==a[3]) or (a[0]==a[2] and a[1]==a[3]) or (a[0]==a[3] and a[1]==a[2]):
    if a[0]==a[1] and a[0]==a[2] and a[0]==a[3]:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
li = input()
li_a = []
count = 0

for i in li:
    if i in li_a:
        count += 1
    li_a.append(i)
li_a = list(set(li_a))
if len(li_a) == 2 and count == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
import sys


input_str = input()

list_str = [i for i in input_str]
set_str = set(list_str)

if len(set_str) == 2:
  for i in set_str:
    try:
      for j in range(2):
        list_str.remove(i)
    except ValueError:
      print('No')
      sys.exit()
else:
  print('No')
  sys.exit()
  
print('Yes')

Submission status: Accepted

Solution code:
S = input()
s0=S.count(S[0])
s1=S.count(S[1])
s2=S.count(S[2])
s3=S.count(S[3])
if s0 == 2 and s1 == 2 and s2 == 2 and s3 == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
k = 0 
for i in range(4):
     k += s.count(s[i])
if k == 8:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()

words = {}

for i in s:
  if words.get(i):
    words[i] += 1
  else:
    words[i] = 1
  
if len(words.keys()) == 2 and list(words.values())[0] == list(words.values())[1] == 2:
   print('Yes')
else:
   print('No')

Submission status: Accepted

Solution code:
S = input()
s = {S[0], S[1], S[2], S[3]}

if len(s) != 2:
    print('No')
else:
    num = 1
    for i in range(3):
        if S[i+1] == S[0]:
            num += 1
    
    if num == 2:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
s = input()
l = list(s)
for i in range(len(l)):
    if s.count(l[i]) != 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
import sys
from fractions import gcd
from collections import defaultdict
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return list(map(int, sys.stdin.readline().split()))
def II(): return int(sys.stdin.readline())
def LS(): return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())

def main():
    s = S()
    d = defaultdict(int)
    for i in range(4):
        d[s[i]] += 1
    if len(d) == 2:
        for v in d.values():
            if v != 2:
                break
        else:
            print("Yes")
            return
    print("No")



if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys,collections
S = input()
S_ = list(S)
S__ = collections.Counter(S_)
if len(S_) == 4:
    values,counts = zip(*S__.most_common())
    if len(values) == 2:
        print("Yes")
        sys.exit()
print("No")

Submission status: Accepted

Solution code:
S = input()
flag = False
count0 = 0
count1 = 0
count2 = 0
count3 = 0
for i in S:
    if i == S[0]:
        count0 += 1
    if i == S[1]:
        count1 += 1
    if i == S[2]:
        count2 += 1
    if i == S[3]:
        count3 += 1

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

Submission status: Accepted

Solution code:
S = input()
list1 = list(S)
#例えば4つ
a = list1[0]
b = list1[1]
c = list1[2]
d = list1[3]

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

Submission status: Accepted

Solution code:
S = list(input())
s = set(S)
if len(s) == 2:
    num = 0
    for x in S:
        if x == S[0]:
            num += 1
    if num == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
#a.py
lis = []
s = input()
flag = 0
two = 0
for x in s:
    if x in lis:
        flag += 1
    else:
        two += 1
    lis.append(x)
if two == 2 and  flag <= 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

ans = "No"
s = []

for _ in S:
    s.append(_)

s.sort()
if s[0] == s[1]:
    if s[2] == s[3]:
        if s[1] != s[2]:
            ans = "Yes"

print(ans)

Submission status: Accepted

Solution code:
S = input()
count = {}
for k in S:
  count[k] = 0
for y in S:
  count[y] += 1
if len(count) == 2 and count[S[0]] == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import collections
list = list(input())
c = collections.Counter(list)
count = 0

for k,v in c.items():
    if v == 2:
        count = count +1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
word = list(input())

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

Submission status: Accepted

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

def main():
    # # 整数の入力
    # a = int(input())
    # # スペース区切りの整数の入力
    # b, c = map(int, input().split())
    # # 文字列の入力
    # s = input()
    # # 出力
    # print("{} {}".format(a+b+c, s))
    S = input()
    dic = {}
    for s in S:
        if s in dic:
            dic[s] += 1
        else:
            dic[s] = 1
    if len(dic)==2 and list(dic.values())==[2,2]:
        print('Yes')
    else:
        print('No')


if __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
str = input()
#print(int(a[-4]), int(a[-3]), int(a[-2]), int(a[-1]))
a=str[-4]
b=str[-3]
c=str[-2]
d=str[-1]
count = 0
if(a is b):
    #print("No")
    count += 1
elif(a is c):
    #print("No")
    count += 1
elif(a is d):
    #print("No")
    count += 1
else:
    pass
if(b is c):
  count += 1
elif(b is d):
  count += 1
else:
  pass

if(c is d):
  count += 1
else:
  pass

if(count is 2):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:

S = list(input().split()[0])

flg = False

if S[0] == S[1] and S[1] == S[2] and S[2] == S[3]:
    flg = True

S_0 = S[0]
del S[0]
for i in range(0,3):
    if S[i] == S_0:
        del S[i]
        break
S_1 = S[0]
del S[0]
if S[0] == S_1:
    del S[0]
if not flg:
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()

ans = True
if len(set(s)) != 2:
    ans = False
else:
    a, b = list(set(s))
    if s.count(a) == s.count(b) == 2:
        pass
    else:
        ans = False

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

Submission status: Accepted

Solution code:

S=str(input())

cnt1=1
cnt2=0
a1=S[0]
t=0
for i in range(1,len(S)):
    if S[i]==a1:
        cnt1+=1
    elif t ==0:
        a2=S[i]
        t=1
        cnt2+=1
    elif a2==S[i]:
        cnt2+=1
    else:
        t=0
        break

if t==0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import collections

S = input()
ans=0
for i in S:
    if(S.count(i)!=2):
        print('No')
        break
    ans+=1

if(ans==4):
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s_lst = list(s)
s = s.replace(s_lst[0], "")
s_lst_2 = list(s)
if len(s_lst_2) == 2 and s_lst_2[0] == s_lst_2[1]:
    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[3]) 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:
"""
AtCoder
    :author: vierbein
"""
from __future__ import absolute_import, division, print_function

# import itertools as it
# import collections
import sys


def pp(*args, **kwargs):
    print(*args, file=sys.stderr, **kwargs)


s = input()
xs = set(s)
if (len(xs) == 2 and all(s.count(i) == 2 for i in xs)):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
S=list(s)
a=set(S)
ans=0
if len(a)==2:
	for n in S:
		if S[0]==n:ans+=1


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

Submission status: Accepted

Solution code:
s = list(input())
m = {}
for c in s:
    if c in m:
        m[c] += 1
    else:
        m[c] = 1

ans = True
if len(m) != 2:
    ans = False
else:
    for v in m.values():
        if v != 2:
            ans = False

if ans:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = [s for s in input()]
cnt = {}
for s in S:
    if s not in cnt:
       cnt[s] = 0
    cnt[s] += 1
if len(cnt) == 2 and cnt[s] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
dic = {}
for i in s:
    if i not in dic.keys():
        dic[i]=1
    else:
        dic[i]+=1
ans = "Yes"
if len(dic) !=2:
    ans = "No"
else:
    for i in dic:
        if dic[i] != 2:
            ans = "No"
print(ans)

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:
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()
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:
import collections
s = input()
c = collections.Counter(s)
if list(c.values())[0] == 2 and list(c.values())[1] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
print("Yes" if all(map(lambda c: s.count(c) == 2, s)) else "No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 20:53:13 2019

@author: YudNK
"""

l = [i for i in input()]

k = len(set(l))

a = l[0]
c = 0
for i in l:
    if i == a:
        c = c + 1

if k == 2 and c == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
dic = {}

for i in s:
  if i in dic:
    dic[i] += 1
  else:
    dic[i] = 1
if len(dic.keys()) == 2:
  for i in dic.values():
    if i != 2:
      print('No')
      exit()
  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")
    exit()

print("No")

Submission status: Accepted

Solution code:
import re
# input process
inputData = input()

uniq_str_list = list(set(inputData))
if len(uniq_str_list) != 2:
    print("No")
    exit()
if len(re.findall(uniq_str_list[0], inputData)) != 2:
    print("No")
    exit()

if len(re.findall(uniq_str_list[1], inputData)) != 2:
    print("No")
    exit()

print("Yes ")

Submission status: Accepted

Solution code:
inp=input()
ans=0
for s in inp:
  if inp.count(s)==2:
    ans=ans;
  else:
    ans+=1
if ans==0:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
import sys

cin = sys.stdin
s = cin.readline().strip()

from collections import Counter
c = Counter(s)
# print(c.values())
if len(c)==2 and all(v == 2 for v in c.values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
S = list(input())
kind = list(set(S))
result = "Yes"
for i in range(len(kind)):
    if S.count(kind[i]) != 2:
        result = "No"
print(result)

Submission status: Accepted

Solution code:
def main():
    S = list(input())
    chars = list(set(S))

    if len(chars) != 2:
        print('No')
        return

    def count_a_char(c):
        return len([s for s in S if s == c])

    if count_a_char(chars[0]) != 2 or count_a_char(chars[1]) != 2:
        print('No')
        return 
    
    print('Yes')
    

main()

Submission status: Accepted

Solution code:
s = list(input())
print('Yes') if len(set(s)) == 2 & s.count(list(set(s))[0]) == 2 & s.count(list(set(s))[1]) == 2 else print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#A
S = input()
S_unique = list(set(S))
flg = len(S_unique)==2
if flg:
    ans1 =(S.count(S_unique[0])==2)
    ans2 =(S.count(S_unique[1])==2)
    ans3 = ans1 and ans2
    if ans3:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

str_in = input()
str_set = set(str_in)

if len(str_in) != 4:
    print('No')
    quit()

if len(str_set) != 2:
    print('No')
    quit()

for s in str_set:
    if str_in.count(s) != 2:
        print('No')
        quit()

print('Yes')

Submission status: Accepted

Solution code:
S = list(input())

s = list(set(S))
if len(s)!= 2:
    print('No')
    exit()

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

Submission status: Accepted

Solution code:
S = input()

abet = {}
for c in S:
    if c not in abet:
        abet[c] = 1
    else:
        abet[c] += 1

# ４文字の大文字で、２回ずつ存在するなら、辞書の長さは必ず２となるはず
if len(abet.values()) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

Solution code:
import collections

S = input()
c = collections.Counter(S)
list = c.most_common()
if len(list)==2:
    if list[0][1]==2 and list[1][1]==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

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

for num in d.values():
    if not num == 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
#ABC132 = 2*2*3*11
S = input()
A = []
for i in range(len(S)):
    A.append(S[i])
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 A.count(S[0]) == 4:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

import collections
a = list(input())
c = collections.Counter(a)

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

Submission status: Accepted

Solution code:
s = input()

s1 = s[0]
if s.count(s1) == 2:
  for i in range(1, 4):
    if s[i] != s1:
      print('Yes' if s.count(s[i]) == 2 else 'No')
      break
  
else:
  print('No')

Submission status: Accepted

Solution code:
flg = False
s = input()
s1, s2, s3, s4 = s[:1], s[1:2], s[2:3], s[3:4]
if s1 == s2 and s3 == s4:
	flg = True
elif s1 == s3 and s2 == s4:
	flg = True
elif s1 == s4 and s2 == s3:
	flg = True

if s1==s2 and s1==s3:
	flg = False

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

Submission status: Accepted

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

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

print('Yes')

Submission status: Accepted

Solution code:
n = list(input())
flag = 0
dict = {}
for i in n:
    if i in dict:
        dict[i] += 1
    else:
        dict[i] = 1
 
for key,val in dict.items():
    if val != 2:
        flag = 1
 
if flag:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
# abc132/abc132_a
import sys
import collections

s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in list(ss)]
ss2nnn = lambda ss: [s2nn(s) for s in list(ss)]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [i2s() for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

def main():
    S = i2s()
    c = collections.Counter(S)
    if tuple(c.values()) == (2, 2):
        print('Yes')
    else:
        print('No')
    return

main()

Submission status: Accepted

Solution code:
S = input()
a = S[0]
b = 0
acount = 1
bcount  = 1
for i in range(1,4):
    if a == S[i]:
        acount += 1
    elif b == S[i]:
        bcount += 1
    else:
        if b == 0:
            b = S[i]

if acount == 2 and bcount == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections 
S = list(input())
c = collections.Counter(S)
if len(c) == 2 and c.most_common()[0][1] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
from collections import Counter

S = input()
s = list(S)

count = Counter(S)

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

Submission status: Accepted

Solution code:

S = str(input())

if S[0]==S[1] and S[0]==S[2] and S[0]==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:
S = input()
C = list(set(S))

if len(C)==2:
    counter = {c:0 for c in C}
    for s in S:
        counter[s]+=1
    if counter[C[0]]==2 and counter[C[1]]==2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def input():
    return sys.stdin.readline().rstrip()

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

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

    if len(dict.keys()) == 2:
        is_ok = True
        for v in dict.values():
            if v != 2:
                is_ok = False
                break
        print("Yes" if is_ok else "No")
    else:
        print("No")

Submission status: Accepted

Solution code:
x = input()

a = 1
b = 1
other = '0'

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

Submission status: Accepted

Solution code:
S = input()
yes = 0;
if S[0] == S[1]:
  if S[2] == S[3]:
    if S[1] != S[2]:
      yes = 1
elif S[0] == S[2]:
  if S[1] == S[3]:
    if S[1] != S[2]:
      yes = 1
elif S[0] == S[3]:
  if S[1] == S[2]:
    if S[1] != S[0]:
      yes = 1
if yes == 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('No')
    exit()
elif S[0] == S[1] and S[2] == S[3]:
    print('Yes')
    exit()
elif S[0] == S[2] and S[1] == S[3]:
    print('Yes')
    exit()
elif S[0] == S[3] and S[1] == S[2]:
    print('Yes')
    exit()
else:
    print('No')

Submission status: Accepted

Solution code:
S  = list(input())
dic = {}
for s in S:
  if s in dic:
    dic[s] += 1
  else:
    dic[s] = 1
for v in dic.values():
  if v != 2:
    print('No')
    quit()
print('Yes')

Submission status: Accepted

Solution code:
import collections
s= str(input())
l=list(s)
c=collections.Counter(l)
l_c=c.most_common()
if len(l_c)==1:
  print("No")
  exit()
if l_c[0][1]==l_c[1][1]==2:print("Yes")
else:print("No")

Submission status: Accepted

Solution code:
S = input()
S = [str(i) for i in S]
S.sort()

A = S[0] == S[1]
B = S[2] == S[3]
C = S[0]!=S[2]

if A*B*C == True:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s=list(input())
d={}
for i in range(4):
    if not s[i] in d:
        d[s[i]]=1
    else:
        d[s[i]]=d[s[i]]+1
flag=0
if len(d)==2:
    for val in d.values():
        if not val==2:
            flag=1
    if flag:
        print("No")
    else:
        print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

if (S.count(S[0]) != 2 or S.count(S[1]) != 2 or S.count(S[2]) != 2):
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
S = input()
S1 = S[0]
S2 = S[1]
S3 = S[2]
S4 = S[3]
S = [S1, S2, S3, S4]
kind = set([S1, S2, S3, S4])

if len(kind) == 2:
    for k in kind:
        if S.count(k) != 2:
            print("No")
            sys.exit()
    else:
        print("Yes")
        sys.exit()
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline

A = [0] * 4

s = input()
for i in range(4):
    A[i] = s[i]

A_uni = list(set(A))

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

Submission status: Accepted

Solution code:

import sys
import collections
S = input()

C = collections.Counter(S)

for i in C.values():
    if i == 2:
        continue
    else:
        print("No")
        sys.exit()

print("Yes")

Submission status: Accepted

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

ans = []
#print(S_arr)
for i in S_arr:
    if i in ans:
        pass
    else:
        ans.append(i)

#print(ans)
if len(ans) != 2:
    print("No")
else:
    if S.count(ans[0]) == S.count(ans[1]):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
s = input()
ch_count = [1 for i in range(26)]

for ch in s:
  ch_count[ord(ch) - ord('A')] += 1

num = 1
for i in range(26):
  num *= ch_count[i]

print("Yes" if num == 9 else "No")

Submission status: Accepted

Solution code:
#入力取得
S = input()

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


if S.count(a) == 2 and  S.count(b) == 2 and S.count(c) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
A=input()
d={}
for i in A:
    if i not in d:
        d[i]=1
    else:
        d[i]+=1

flag=0

for num,i in enumerate(d.values()):
    #print(i)
    if i!=2:
        break
    if num==len(d)-1:
        flag=1
    
if flag==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/Library/Frameworks/Python.framework/Versions/3.5/bin/python3
from collections import defaultdict

s = input()

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

for i in d:
    if d[i] != 2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = [i for i in input()]
n = 0
for j in range(4):
    if S.count(S[j]) == 2:
        n += 1
if n == 4:
    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]:
    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:
import sys

S = input()
se = dict(enumerate(set(S)))
if len(se) == 2:
	if S.count(se[0])==2:
		print("Yes")
		sys.exit()
print("No")

Submission status: Accepted

Solution code:
s = list(input())

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

print("Yes")

Submission status: Accepted

Solution code:
s = str(input())
s0 = s[0]
if s0 == s[1]:
    if s[2] == s[3] and s[2] != s0:
        print('Yes')
    else:
        print('No')
else:
    s1 = s[1]
    if s1 in s[2:4] and s0 in s[2:4]:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

flag = 0
for k, v in d.items():
    if v != 2:
        flag = 1

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