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()
S=list(S)
S.sort()
S0=S[:2]
S1=S[2:]
if S0[0]==S0[1] and S1[0]==S1[1] and S0[1]!=S1[0]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = sorted(input())

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

Submission status: Accepted

Solution code:
s = input()
ans=0
for a in [[0,1,2,3],[0,2,1,3],[0,3,2,1],[1,2,0,3],[1,3,0,2],[2,3,1,0]]:
    if s[a[0]] == s[a[1]] and s[a[2]]==s[a[3]] and s[a[0]]!=s[a[2]]:
        ans = 1

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#ABC132 A
import sys
sys.setrecursionlimit(1000000)
from collections import deque

S = list(input())
T = list(set(S))
for i in T:
    if S.count(i) != 2:
        print('No')
        quit()
if len(T) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

print("Yes")

Submission status: Accepted

Solution code:
S = list(input())
first_char = S[0]


cnt = 0
for i in range(1, 4):
    if S[i] == first_char:
        cnt += 1
        
if cnt == 1 and len(set(list(S))) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
for s in S:
    if S.count(s) != 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
S = input()
L = []

for s in S :
    L.append(s)

L = sorted(L)

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

Submission status: Accepted

Solution code:
s = input()

if s.count(s[0]) == 4:
    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 = list(input())

import collections

c = collections.Counter(s)

flag = True
if len(c.keys()) != 2:
    flag = False
else:
    for k in c.keys():
        if c[k] != 2:
            flag = False

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

Submission status: Accepted

Solution code:
import collections

S = input()

charactorVocabrarys = len(collections.Counter(S))
if charactorVocabrarys == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
cnt = 0
ans = False
for i in S:
    cnt = S.count(i)
    if cnt != 2:
        ans = True

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

Submission status: Accepted

Solution code:
import sys

x = str(input()) 

cnt = 0

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

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

Submission status: Accepted

Solution code:
s=input()
cnt=0
if s.count("A")==2:
    cnt+=1
if s.count("B") == 2:
    cnt += 1
if s.count("C")==2:
    cnt+=1
if s.count("D") == 2:
    cnt += 1
if s.count("E")==2:
    cnt+=1
if s.count("F") == 2:
    cnt += 1
if s.count("G")==2:
    cnt+=1
if s.count("H") == 2:
    cnt += 1
if s.count("I")==2:
    cnt+=1
if s.count("J") == 2:
    cnt += 1
if s.count("K")==2:
    cnt+=1
if s.count("L") == 2:
    cnt += 1
if s.count("M")==2:
    cnt+=1
if s.count("N") == 2:
    cnt += 1
if s.count("O")==2:
    cnt+=1
if s.count("P") == 2:
    cnt += 1
if s.count("Q")==2:
    cnt+=1
if s.count("R") == 2:
    cnt += 1
if s.count("S") == 2:
    cnt += 1
if s.count("T") == 2:
    cnt += 1
if s.count("U")==2:
    cnt+=1
if s.count("V") == 2:
    cnt += 1
if s.count("W") == 2:
    cnt += 1
if s.count("X") == 2:
    cnt += 1
if s.count("Y") == 2:
    cnt += 1
if s.count("Z") == 2:
    cnt += 1

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

Submission status: Accepted

Solution code:
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

#n,m = ips()
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
s = []
for i in range(4):
    s.append(a[i])
s.sort()
if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:j(1)
j(0)

Submission status: Accepted

Solution code:
S = input()
c = []
cnt = []
for i in range(4):
  x = S[i]
  if not x in c:
    c.append(x)
    cnt.append(1)
  else:
    idx = c.index(x)
    cnt[idx] += 1
if len(c) == 2 and cnt[0] == 2 and cnt[1] == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = list(input())

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

def check(d):
    for k,v in d.items():
        if v != 2:
            return False
        
    return True
    

if check(d):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

if len(set(S)) == 2:
    a =  c.most_common(2)[0][1]
    b = c.most_common(2)[1][1]
    if a  == b:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
s = set(input())
print(["No","Yes"][len(s) == 2])

Submission status: Accepted

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

A = input().strip()
counter = 0
B = collections.Counter(A)
if len(B.keys()) == 2:
    for value in B.values():
        if value == 2:
            counter += 1
    if counter ==2:
        print('Yes')
        exit()

print('No')

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
cnt = Counter(s)
for key in cnt.keys():
    if cnt[key] != 2:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
S=raw_input()

C=Counter(S)

if len(C)==2 and C.values()==[2,2]:
	print "Yes"
else:
	print "No"

Submission status: Accepted

Solution code:
S = input()

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

print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter


def m():
    S = input()
    values = list(Counter(S).values())
    if len(values) != 2:
        print("No")
        return
    if values[0] == 2 and values[1] == 2:
        print("Yes")
    else:
        print("No")


m()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

counter = Counter()
for c in input().strip():
  counter[c] += 1


for k, v in counter.items():
  if v != 2:
    print('No')
    break
else:
  print("Yes")

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:
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:
S = input()

for i in S:
    if S.count(i) != 2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
s = input()
a = set([i for i in s])
if len(a) != 2:
    print('No')
else:
    i,j = a
    ni = s.count(i)
    nj = s.count(j)
    if ni == 2 and nj == 2:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
S = input()
d = {}
for c in S:
    if c in d:
        d[c] += 1
    else:
        d[c] = 1

c = S[0]
if len(d) == 2 and d[c] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict
S=input()
d=defaultdict(lambda: 0)
for c in S:
    d[c]+=1
print('Yes' if len(d.keys())==2 and all([v==2 for v in d.values()]) else "No")

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
d = defaultdict(int)
for i in range(4):
    d[S[i]] += 1
print('Yes' if set(d.values()) == set([2, 2]) else 'No')

Submission status: Accepted

Solution code:
s=[i for i in 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 = input()

s_list = list(S)
s_list = sorted(s_list)
#print(s_list)

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

Submission status: Accepted

Solution code:
def main():
  s = input().strip()
  ss = set(s)
  if len(ss) == 2:
    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')
  else:
    print('No')


if __name__ == '__main__':
  main()

Submission status: Accepted

Solution code:
S = input()
a = S[0]
b = S[1]
c = S[2]
d = S[3]
not_a = []
for st in S[1:]:
    if st != a:
        not_a.append(st)
if len(not_a) != 2:
    print("No")
    exit()
if not_a[0] == not_a[1]:
    print("Yes")
    exit()
print("No")

Submission status: Accepted

Solution code:
from collections import Counter
S = input()

count = Counter(S)

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

Submission status: Accepted

Solution code:
def resolve():
    S = input()
    kinds = set(S)
    for i in kinds:
        if S.count(i) != 2:
            print("No")
            return
    print("Yes")


if '__main__' == __name__:
    resolve()

Submission status: Accepted

Solution code:
S = input()
s = list(S[i] for i in range(4))
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:
# 2019/06/29
# AtCoder Beginner Contest 132 - A

# Input
s = input()
s1 = s[0]
s2 = ""
c1 = 1
c2 = 1

# Calc
for i in range(1, 4):
    if s[i] == s1:
        c1 += 1
    elif s[i] == s2:
        c2 += 1
    elif s2 == "":
        s2 = s[i]

if c1 == 2 and c2 == 2:
    ans = "Yes"
else:
    ans = "No"

# Output
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

if len(list(set(list(S)))) == 2 and len([i for i in list(list(S)) if i == S[0]]) == 2:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:
s = list(input())
c = 0
if len(set(s))==2:
    for i in set(s):
        if s.count(i) == 2:
            c = 1
            break
if c == 0:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

print(ans)

Submission status: Accepted

Solution code:
s = input()
d = dict()
for c in s:
  if d.__contains__(c):
    d[c] += 1
  else:
    d[c] = 1
l = list(d.items())
if len(l)!=2:
  print("No")
  exit(0)
if l[0][1] == 2 and l[1][1] == 2:
  print("Yes")
  exit(0)
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()

from collections import Counter

s = Counter(S)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

count = {}
for i in range(4):
    if S[i] in count:
        count[S[i]] += 1
    else:
        count[S[i]] = 1

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

from collections import defaultdict

s = input()
d = defaultdict(int)

for c in s:
    d[c] += 1
    if d[c] == 3:
        print("No")
        exit()
if len(d) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()

l=set()
for i in range(4):
    l.add(s[i])

ans='No'
if len(l)==2:
    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]):
        ans='Yes'

print(ans)

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n=input()
a=[0]*4
for i in range(4):
    for p in range(4):
        if n[i]==n[p]:
            a[i]+=1
if a==[2,2,2,2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

adic = {}
for c in s:
  if c in adic.keys():
    adic[c] += 1
  else:
    adic[c] = 1
if list(adic.values()) == [2, 2]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()
a = [0 for _ in range(26)]
for x in s:
    a[ord(x)-ord('A')] += 1
print('Yes' if a.count(2) == 2 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
i=0
ans=1
while i!=4:
    a=s.count(s[i])
    if a!=2:
        ans=0
    i+=1
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input())

s = Counter(S).most_common()

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

Submission status: Accepted

Solution code:
s = input()

syu = set(s)
tmp = list(syu)

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

Submission status: Accepted

Solution code:
s=input()
dict={}
for i in range(4):
    if not s[i] in dict:
        dict[s[i]]=0
    dict[s[i]]+=1

a=list(dict.keys())
for i in range(len(a)):
    if dict[a[i]]!=2:
        print("No")
        quit()
print("Yes")

Submission status: Accepted

Solution code:
s = input()
dictionary = {}
pattern = 0
for c in s:
    if(c in dictionary):
        dictionary[c] += 1
    else:
        dictionary[c] = 1
        pattern += 1
    if(dictionary[c] > 2):
        print("No")
        exit()
    if(pattern > 2):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
from collections import deque
from collections import Counter

readline = sys.stdin.readline

S = readline().rstrip()

c = Counter(S)
a = list(c.items())

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

Submission status: Accepted

Solution code:
S=input()
d={}
for c in S:
    if c not in d.keys():
        d[c]=1
    else:
        d[c] += 1
j=True
for i in d.values():
    if i!=2:
        j=False
        break

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

Submission status: Accepted

Solution code:
import math

def main():
  s = input()
  
  s = s.replace(s[0], "")
  if len(s) != 2:
    print("No")
    return
  
  s = s.replace(s[0], "")
  
  if len(s ) != 0 :
    print("No")
    return
  
  print("Yes")
  
main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    for s in S:
        if S.count(s) != 2:
            print('No')
            return
    print('Yes')


main()

Submission status: Accepted

Solution code:
s = input()
l = []
l.append(s[0])
l.append(s[1])
l.append(s[2])
l.append(s[3])
p = set(l)
if len(p)==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
b = set(S)
if len(b)==2:
  for s in S:
    if S.count(s)==2:
      print('Yes')
      break
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
S=list(input())
a={}
for i in range(4):
    a[S[i]]=a.get(S[i],0)+1
print('Yes' if len(list(a.keys()))==2 and len(list(a.values()))==2 else 'No')

Submission status: Accepted

Solution code:
import sys

fin = sys.stdin.readline

s = fin()[:4]
for ss in s:
    if s.count(ss) != 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = set(s)
if len(t) == 2:
    f = True
    for c in t:
        if list(s).count(c) != 2:
            f = False
    print("Yes" if f else "No")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

tmp = []
for s in S:
    if s not in tmp:
        tmp.append(s)

if len(tmp) == 2:
    if S.count(tmp[0]) == 2:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

Solution code:
s = str(input())
k = 0
for i in s:
  if s.count(i) == 2:
    k += 1
if k == 4:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
import math


def main():
    a = list(input())
    b = defaultdict(int)

    for ele in a:
        b[ele] += 1

    if len(b) == 2:
        aaa = list(b.values())
        if aaa[0] == aaa[1]:
            print('Yes')
        else:
            print('No')
    else:
        print('No')






if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = sorted(input())

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

Submission status: Accepted

Solution code:
from collections import defaultdict

if __name__ == '__main__':
    s = input()
    count = defaultdict(int)
    for c in s:
        count[c] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
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:
import numpy as np
import copy


def main():
    S = input()
    if len(set(S)) == 2 and S.count(S[0]) == 2:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = list(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:
s = input()
m = dict()
for c in s:
    m.setdefault(c, 0)
    m[c] += 1
print('Yes' if len(m) == 2 and all(v == 2 for v in m.values()) else 'No')

Submission status: Accepted

Solution code:
S = list(input())

dic = {}

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

ok = True
for k in dic:
    if dic[k] == 2:
        pass
    else:
        ok = False

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = sorted(raw_input())

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

Submission status: Accepted

Solution code:
s=list(input())

f=0
for i in range(4):
    if s.count(s[i]) != 2:
        f =1

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

Submission status: Accepted

Solution code:
S = input()

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


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

Submission status: Accepted

Solution code:
s = input()

hoge = {}
for i in range(len(s)):
    if s[i] in hoge:
        hoge[s[i]] += 1
    else:
        hoge[s[i]] = 1

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

Submission status: Accepted

Solution code:
from collections import Counter

S = Counter(input())

ans = 1
for s in S:
    if S[s]!=2:
        ans = 0
        break
        
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#A問題
S = list(str(input()))
word = ["",""]
count = [0,0]
flag = 0
for i in range(4):
    if i == 0:
        word[0] = S[0]
        count[0]+=1
    else:
        if S[i] in word:
            count[word.index(S[i])]+=1
        else:
            if word[1] == "":
                word[1] = S[i]
                count[1]+=1
            else:
                flag = 1
                break
                
if count[0] == 2 and count[1] == 2:
    pass
else:
    flag = 1
    
if flag == 0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

d = dict()
for s in S:
    if s not in d:
        d[s] = 0
    d[s] += 1

print(["No", "Yes"][tuple(d.values()) == (2, 2)])

Submission status: Accepted

Solution code:
import collections
S = 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:
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 = list(input())

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

Submission status: Accepted

Solution code:
s = input()


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

    else:
        print('No')

else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())
ans = {}
for i in range(4):
    if S[i] not in ans.keys():
        ans[S[i]] = 1
    else :
        ans[S[i]] += 1
for i in ans.keys():
    if ans[i] == 2 :
        pass
    else :
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def main():
     a=list(input())
     if a.count(a[0])==2 and a.count(a[1])==2 and a.count(a[3])==2:
          print("Yes")
     else:
          print("No")
     
if __name__=='__main__':
     main()

Submission status: Accepted

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

for i in s:
    k.add(i)

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

Submission status: Accepted

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

def main(D):
    if len(D.keys()) != 2:
        return 0
    else:
        for v in D.values():
            if v != 2:
                return 0
    return 1

if main(D):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

fin = sys.stdin.readline
num = str(fin()).split()[0]

char_list = defaultdict(int)
for each_char in num:
    char_list[each_char] += 1

if len(char_list) == 2 and list(char_list.values())[0] == 2:
    print("Yes")
else:
    print('No')

Submission status: Accepted

Solution code:
n = input()
for i in range(4):
    if n.count(n[i]) == 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10 ** 7)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x) - 1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

from collections import defaultdict

s = ns()
dic = defaultdict(int)
for si in s:
    dic[si] += 1

ok = True
for _, v in dic.items():
    if v != 2:
        ok = False
        break

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

Submission status: Accepted

Solution code:
s = input()
set_s = set(s)
ans = 'Yes' if len(set_s) == 2 and s.count(s[0]) == 2 else 'No'
print(ans)

Submission status: Accepted

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

def readInts():
  return [int(s) for s in input().split(" ")]

def main():
  S = input()
  d = {}
  for c in S:
    if not c in d:
      d[c] = 0
    d[c] += 1
  if len(d.keys()) == 2 and d[list(d.keys())[0]] == 2:
    print("Yes")
  else:
    print("No")

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
alp = "abcdefghijklmnopqrstuvwxyz"
S = list(input())
s = set(S)
ans = "Yes"
if len(s)!=2:
    ans = "No"
else:
    for i in s:
        if S.count(i)!=2:
            ans = "No"
print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

def main():
    s = input()

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

def solve(s):
    cnt = Counter(s)
    for k, v in cnt.items():
        if v != 2:
            return False
    return True

main()

Submission status: Accepted

Solution code:
a = list(input())
l_unique = list(set(a))

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
def main():
    s = input()
    if len(set(s))==2:
        for i in set(s):
            if s.count(i)!=2:
                print("No")
                exit()
        print("Yes")
    else: print("No")

if __name__=="__main__": main()

Submission status: Accepted

Solution code:
import sys,collections,math,random;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = S()
d = collections.defaultdict(int)
for e in s:
    d[e] += 1
items = d.items()
if len(d) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
D = {}
s = set()
for i in S:
    s.add(i)
    if i not in D:
        D[i] = 1
    else:
        D[i] += 1

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

Submission status: Accepted

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

Submission status: Accepted

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

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