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

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

Submission status: Accepted

Solution code:
S = input()
A =[]
for i in range(4):
    A.append(S[i])
B = set(A)
if len(B) == 2:
    print("Yes")
else:
    print("No")

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:
s = input()
if len(set(s)) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = list(input())
setS = set(S)

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

print("Yes")

Submission status: Accepted

Solution code:
s = input()
s = list(s)
li =[]
for i in range(len(s)):
  li.append(s.count(s[i]))
if sum(li) == 8:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()
a = []
b = [0,0,0,0]
for i in range(4):
    if not(S[i] in S[:i]):
        a.append(S[i])
    else:
        b[a.index(S[i])] += 1
if b == [1,1,0,0]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s= input()
done =set()
count = []
for c in s:
    if c not in done:
        count.append(s.count(c))
        done.add(c)
if len(count)==2:
    print('Yes' if count[0]==2 and count[1]==2 else 'No')
else:
    print('No')

Submission status: Accepted

Solution code:
import numpy as np
import math
import sys
sys.setrecursionlimit(10000000)

def main():
    S = input()
    num_dicts = {}
    for i in range(len(S)):
        if S[i] not in num_dicts:
            num_dicts[S[i]] = 1
        else:
            num_dicts[S[i]] += 1
    for key_, value_ in num_dicts.items():
        if value_ == 2:
            pass
        else:
            print("No")
            sys.exit()
    else:
        if len(num_dicts) == 2:
            print("Yes")
            sys.exit()
        else:
            print("No")
            sys.exit()


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
str_list = []
sec_list = []
flag = 0
for i in s:
    if (i in str_list) and (i not in sec_list):
        flag += 1
        sec_list.append(i)
    else:
        str_list.append(i)
        
if flag == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())
T = set(S)
ans = "No"
for t in T:
    if S.count(t) == 2:
        continue
    break
else:
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
s = list(input())

cnt = {}

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
chr={s[0]:1}
for si in s[1:]:
    if si in chr:
        chr[si]+=1
    else:
        chr[si]=1
# print(chr)
if len(chr)==2 and 2 in chr.values():
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
c = 0
s = input()
for w in s:
    n = s.count(w)
    if n==2:
        c += 1
if c == 4:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
d = dict()
ans = "No"
for t in s:
  if t not in d:
    d[t] = 0
  d[t] += 1
if list(d.values()) == [2,2]:
  ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
S =  str(input())
m = list(set(S))
cnt_first = 0
cnt_second = 0
if len(m) == 2:
    first = m[0]
    sec = m[1]
    for i in range(len(S)):
        if S[i] == first:
            cnt_first += 1
        elif S[i] == sec:
            cnt_second += 1
else:
    print("No")
    exit()
if cnt_first == 2 and cnt_second == 2:
    print("Yes")

Submission status: Accepted

Solution code:
S = input()

a = S[0]
a0 = 1

b = ''

if a != S[1]:
    b = S[1]
    b0 = 1
elif S[0] == S[1]:
    a0 += 1

if a == S[2]:
    a0 += 1
elif b == '':
    b = S[2]
    b0 = 1
elif b == S[2]:
    b0 += 1

if a == S[3]:
    a0 += 1
elif b == S[3]:
    b0 += 1

if a0 == 2 and b0 == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

k = list(d.keys())
if len(k) == 2 and (d[k[0]] == 2 and d[k[1]] == 2):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = list(input())


def check():
    # 使われている文字種のセットを得る
    char_set = set(S)
    # 2種類でなければNo
    if len(char_set) != 2:
        return "No"
    # それぞれの文字種が2個ずつでなければNo
    for c in char_set:
        if S.count(c) != 2:
            return "No"
    # ここまで来たらYes
    return "Yes"


print(check())

Submission status: Accepted

Solution code:
A=input()
B=set(A)
a=[]
for i in B:
    a.append(A.count(i))
if a[0]==2 and a[1]==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

import collections

s = list(input())

collct = collections.Counter(s)
flag = False

for i in collct:
    if collct[i] == 2:
        flag = True
    else:
        flag = False
        break

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

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

Solution code:
import sys

input = sys.stdin.readline


def main():
    print("Yes" if len(set(input().strip())) == 2 else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
dic = defaultdict(int)
for x in s:
    dic[x] += 1
f = 1
for x in s:
    if dic[x] != 2:
        f = 0
if f:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections
S = list(input())
c = collections.Counter(S)
c = c.most_common()
if len(c) == 2:
    for i in c:
        if i[1] == 2:
            None
        else:
            break
    else:
        print("Yes")
        exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
flag = True
l = list(s)
if len(set(l)) != 2:
    flag = False
if l.count(l[1]) != 2:
    flag = False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
s = [S[i] for i in range(len(S))]

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

Submission status: Accepted

Solution code:
S = input()

flg = 0

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

Submission status: Accepted

Solution code:
def resolve():

    s = input()
    flag = 1


    for st in s:
        if s.count(st) != 2:
            print('No')
            flag = 0
            break

    if flag:
        print('Yes')
        
resolve()

Submission status: Accepted

Solution code:
a, b, c, d = input()
if ((a == b and c==d) or (a==c and b==d) or (a == d and b==c)):
    if (a == b == c == d):
        print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
if __name__ == "__main__":
    S = Counter(input())
    if len(S) == 2 and all(v == 2 for v in S.values()):
        print("Yes")
    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

ans = 'Yes'
if len(list(d.keys())) != 2:
    ans ='No'
else:
    for c in d.keys():
        if d[c] != 2:
            ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
flag = True
for i in range(3):
    if s.count(s[i]) != 2:
        flag= False
    #l[i] == l[i+1]
if flag == False:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

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

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:

x=list(input())

temp={}
for e in x:
    if e not in  temp:
        temp[e]=0
    temp[e]+=1

if len(temp.keys())==2:
    for e in temp.values():
        if e!=2:
            print("No")
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
ls = []
ols = []
for i in S:
    if i not in ls:
        ls.append(i)
    else:
        ols.append(i)
ls.sort()
ols.sort()
if ls == ols:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
dic = {}
for i in s:
  if i not in dic:
    dic[i] = 1
  else:
    dic[i] += 1
    if dic[i] >= 3:
      print("No")
      exit()
  
if len(dic) >= 3 or len(dic) <= 1:
  print("No")
  exit()
for i in s:
  if dic[i] != 2:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

Solution code:
s = list(input())
temp = s[3]
cnt = 1
for i in range(3):
    if temp == s[i]:
        cnt +=1
if cnt == 2 and len(set(s)) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
mojidic = {}
for i in range(4):
    if S[i] in mojidic.keys():
        mojidic[S[i]] += 1
    else:
        mojidic[S[i]] = 1
mvalue = list(mojidic.values())
if mvalue == [2,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[2]!=S[1]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=input()
ans="Yes"
for i in range(len(s)):
    if s.count(s[i])!=2:
            ans="No"

print(ans)

Submission status: Accepted

Solution code:
string = input()

s_list = []
for i in range(4):
  s_list.append(string[i])
  
sn_list = sorted(s_list)

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

Submission status: Accepted

Solution code:
S = input()
strtype = []
cnt = 0
for i in S:
    if not (i in strtype):
        strtype.append(i)
    else:
        cnt += 1


print('Yes') if len(strtype) == 2 and cnt == 2 else print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
s = set(S)

if len(s) == 2:
    a = S[0]
    count = 0
    for i in S:
        if i == a:
            count += 1

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

else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
l = [s[0],s[1],s[2],s[3]]
setlist = list(set(l))

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

Submission status: Accepted

Solution code:
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

S = str(input())
count = {}
for i in range(len(S)):
    if S[i] in count.keys():
        count[S[i]] += 1
    else:
        count[S[i]] = 1

flag = True
for key in count.keys():
    if count[key] == 2:
        pass
    else:
        flag = False
        break

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

Submission status: Accepted

Solution code:
def A(s):
    for i in s:
        if s.count(i)!=2:
            break
    else :
        return 'Yes'
    return 'No'


if __name__ == '__main__':
    s = input()
    print(A(s))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys
from collections import defaultdict

S = input()

d = defaultdict(int)

for i in range(4):
    d[S[i]] += 1
    
for key in d.keys():
    if d[key] != 2:
        print('No')
        sys.exit()
        
print('Yes')

Submission status: Accepted

Solution code:
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

s = input()

a,b = "",""

a = s[0]

if a != s[1]:
    b = s[1]

    if a in s[2:] and b in s[2:]:
        print("Yes")
    else:
        print("No")
else:
    if a != s[2] and s[2] == s[3]:
        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:
S = input()

set_s = set(S)
if len(set_s) == 2:
    for val in set_s:
        if S.count(val) != 2:
            print('No')
            exit()
else:
    print('No')
    exit()

print('Yes')

Submission status: Accepted

Solution code:
s = input()

a = ''
b = ''
count_a = 0
count_b = 0
count_c = 0

for i in range(4):
    if s[i] == a:
        count_a += 1
    elif s[i] == b:
        count_b += 1
    elif a == '':
        a = s[i]
        count_a += 1
    elif b == '':
        b = s[i]
        count_b += 1
    else:
        count_c += 1

if count_c > 0 or count_a != 2 or count_b != 2:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:

S = list(map(str, input()))

if S[0] == S[1] and S[2] == S[3] and S[1] != S[2]:
	print('Yes')
elif S[0] == S[2] and S[1] == S[3] and S[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()
s = [s[0], s[1], s[2], s[3]]
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:
import fractions


inp = list(input())

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

Submission status: Accepted

Solution code:
s = input()
flg = True
for i in range(4):
    if s.count(list(s)[i]) != 2:
        flg = False
        break
if flg:
    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:
# coding:utf-8


def main():
    # N = int(input())
    # N, M = map(int, input().split())
    # A = list(map(int, input().split()))
    S = list(input())
    d = {}
    flag = True
    for si in S:
        if si in d:
            d[si] += 1
        else:
            d[si] = 1
    for k in d:
        if d[k] != 2:
            flag = False

    if flag:
        print("Yes")
    else:
        print("No")
    # print(ans)
    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict, Counter, deque
from itertools import accumulate, permutations, combinations
from operator import itemgetter
from bisect import bisect_left, bisect_right, bisect
from heapq import heappop, heappush
from fractions import gcd
from math import ceil, floor, sqrt, cos, sin, pi
from copy import deepcopy

# If you use recursive call, uncomment this code
#sys.setrecursionlimit(10**6)

def main():
    S = input()
    hoge = defaultdict(int)
    for s in S:
        hoge[s] += 1
    keys = hoge.keys()
    if len(keys) == 2:
        a = list(set(hoge.values()))
        if len(a) == 1 and a[0] == 2:
            return True
    return False

if __name__ == '__main__':
    if main():
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = Counter(input())
i = 0
count2 = 0
for k, v in S.items():
    i += 1
    if v == 2:
        count2 += 1
        
if i == 2 and count2 == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter

s = input().rstrip()

c = Counter(s)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
count = 0

for i in range(3):
	for j in range(i + 1, 4):
		if S[i] == S[j]:
			count += 1
			
if count == 2:
	print('Yes')
else:
	print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
f = True

S.sort()

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

Submission status: Accepted

Solution code:
S = input()

alfa = [chr(i) for i in range(97,97+26)]

A = []


counter = []
for i in range(4):
    counter.append(S.count(S[i]))

flag = 0
for i in range(4):
    if counter[i] == 2:
        flag += 1

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

Submission status: Accepted

Solution code:
# Fifty-Fifty

S = input().rstrip()

Su = list(set(S))

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

Submission status: Accepted

Solution code:
import collections
S = list(str(input()))
C = collections.Counter(S)
LEN = len(C)
count = 0
if LEN == 2:
    for i in range(3):
        if S[0] == S[i+1]:
            count += 1
#print(LEN,count)
if LEN == 2 and count == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
w = input()
a = w[0]
b = w[1]
c = w[2]
d = w[3]
 
if a == b and b != c and c == d:
  print('Yes')
elif a == c and b != c and b == d:
  print('Yes')
elif a == d and a != b and b == c:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S=list(input())
cut=0
for i in range(len(S)):
    a=S.count(S[i])
    cut+=a
if cut==8:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

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

a = Counter(s)

try:
    aa = a.most_common()
    if aa[0][1] == 2 and aa[1][1] == 2:
        print("Yes")
    else:
        print("No") 
except:
    print("No")

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

def main():
    input = sys.stdin.readline
    d = defaultdict(lambda: 0)
    S = str(input().strip())
    for s in S:
        d[s] += 1

    if len(d.keys()) != 2:
        return 'No'

    for k, v in d.items():
        if v != 2:
            return 'No'

    return 'Yes'


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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3


def solv(s):
    s = sorted(s)
    if s[0] == s[1] and s[2] == s[3] and s[1] != s[2]:
        return 'Yes'
    else:
        return 'No'


if __name__ == '__main__':

    s = input()

    ans = solv(s)

    print(ans)

Submission status: Accepted

Solution code:
s = list(input())

c = 0

for i in s:
    if s.count(i) != 2:
        c += 1

if c == 0:
    print('Yes')

else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
d = {}
for c in s:
    d[c] = d.get(c, 0) + 1
if len(d) == 2 and all(i==2 for i in d.values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input()
a=0
if S[0]==S[1]!=S[2]==S[3] or S[1]==S[2]!=S[3]==S[0] or S[0]==S[2]!=S[1]==S[3]:
    a=1
print(['No','Yes'][a])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from sys import stdin
S = (stdin.readline().rstrip())
flag = True
if len(set(S)) == 2:
    flag = True
else:
    flag = False

for i in list(set(S)):
    if S.count(i) != 2:
        flag = False

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

Submission status: Accepted

Solution code:

s = input()

a = s.count(s[0])
b = s.count(s[1])
c = s.count(s[2])
d = s.count(s[3])

if(a==b==c==d==2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
ans=dict()
for i in input():
	ans[i]=i
print("Yes" if len(ans)==2  else "No")

Submission status: Accepted

Solution code:
#!venv/bin/python
from collections import defaultdict 

S = input()

cnt = defaultdict(int)

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

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    str_dict = {}
    for s in S:
        if s not in str_dict:
            str_dict[s] = 0
        str_dict[s] += 1

    if len(str_dict) == 2:
        for value in str_dict.values():
            if value != 2:
                print("No")
                exit()
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = input()
S2 = set(S)

if len(S2) == 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]:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10 ** 7)

debug = True
#debug = False

def dprint(*objects):
    if debug == True:
        print(*objects)


# n = int(input())
# a, b = map(int, input().split())
# int_list = list(map(int, input().split()))
# l = list(input().split())

def solve():
    l = input()
    li = [l[i] for i in range(len(l))]

    u = len(set(li))
    c = li.count(li[0])

    if u == 2 and c == 2:
        print("Yes")
    else:
        print("No")

solve()

Submission status: Accepted

Solution code:
s = list(input())

cond1 = len(set(s)) == 2
c0 = s[0]
cond2 = sum([1 for c in s if c == c0]) == 2

if cond1 and cond2:
    out = "Yes"
else:
    out = "No"

print(out)

Submission status: Accepted

Solution code:
import bisect
from operator import itemgetter
import math
import copy
import collections
import functools
import itertools
import numpy as np
import sys
MAX_INT = int(10e10)
MIN_INT = -MAX_INT
mod = 1000000007
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

s = [i for i in S()]

ss = list(set(s))

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

Submission status: Accepted

Solution code:
S = input()

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

flag = False
if len(d) == 2:
    flag = True
    for s in d:
        if d[s] != 2:
            flag = False 
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as ite
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

import collections
def solve(S: str):
    count_dict = collections.defaultdict(int)
    for s in S:
        count_dict[s] += 1
    if len(count_dict)==2:
        for s in S:
            if count_dict[s]!=2:
                print('No')
                exit()
        else:
            print('Yes')
    else:
        print('No')
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# INF = float('inf')
# N = int(input())
# A = [int(x) for x in input().split()]
# A = [int(input()) for _ in range(N)]
# dp = [[0] * 100 for _ in range(100)]
# dp = defaultdict(lambda: float('inf'))
# print('hoge', file=sys.stderr)


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

cnt = {}
for c in s:
    cnt[c] = cnt.get(c, 0) + 1

if len(cnt) != 2:
    print('No')
    exit(0)

for c in cnt:
    if cnt[c] != 2:
        print('No')
        exit(0)

print('Yes')

Submission status: Accepted

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

d={}
for c in list(S):
    d[c] = d.get(c, 0) + 1

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

Submission status: Accepted

Solution code:
s=input()
flag=True
for i in s:
  if s.count(i)!=2:
    flag=False
    break
if flag:
  print("Yes")
else:
  print("No")

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:
# -*- coding: utf-8 -*-
"""
Created on Sat Jun 29 20:44:35 2019

@author: Yamazaki Kenichi
"""

S = input()

a = S.count(S[0])
b = S.count(S[1])
c = S.count(S[2])
d = S.count(S[3])

if a*b*c*d == 16:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()

s1 = S[0]
s2 = S[1]
s3 = S[2]
s4 = S[3]

if s1 == s2 and s1 == s3 and s1 == s4:
    print('No')
elif s1 == s2 and s3 == s4:
    print('Yes')
elif s1 == s3 and s2 == s4:
    print('Yes')
elif s1 == s4 and s2 == s3:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

readl= lambda: list(map(int, sys.stdin.readline().split()))
readt= lambda: tuple(map(int, sys.stdin.readline().split()))
read = lambda: sys.stdin.readline().rstrip()
readi = lambda: int(read())
readmi = lambda: map(int, sys.stdin.readline().split())
readms = lambda: map(str, sys.stdin.readline().split())

t = list(input())
d = defaultdict(int)

k = 0
for i in t:
    d[i] += 1
for i in d:
    if d[i] == 2:
        k += 1
if k == 2:
    print("Yes")
else:
    print("No")