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()
a=s[0]
b=0
ac=1
bc=1
for i in range(1,4):
    if s[i]!=a:
        if s[i]!=b:
            if b==0:
                b=s[i]
            else:
                break
        else:
            bc-=1
    else:
        ac-=1
if ac==0 and bc==0:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
import sys
word = input()
 
word_cnt = {}
 
for s in word:
  if s in word_cnt:
  	word_cnt[s]+=1
  else:
    word_cnt[s]=1
  
if len(word_cnt) != 2:
  print('No')
  sys.exit()
  
for cnt in word_cnt.values():
  if cnt != 2:
    print('No')
    sys.exit()

print('Yes')

Submission status: Accepted

Solution code:
s = sorted(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:
S = input()
dic = {}
for x in S:
    if x not in dic:
        dic[x] = 1
    else:
        dic[x] += 1
ans = dic.values()
if list(ans) == list([2,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 os, sys, re, math

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

print('Yes' if all(S.count(s) == 2 for s in S) else 'No')

Submission status: Accepted

Solution code:
s = input()
result = 'Yes'
for c in s:
    if s.count(c) != 2:
        result = 'No'
print(result)

Submission status: Accepted

Solution code:
n = str(input())
flag = 1
for i in n:
  if n.count(i) == 2:
    pass
  else:
    flag = 0

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

Submission status: Accepted

Solution code:
S = list(input())

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

Submission status: Accepted

Solution code:
S = input()
if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
    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()
for i in range(4):
  if s.count(s[i]) != 2:
    print("No")
    quit()
print("Yes")

Submission status: Accepted

Solution code:
#import math
#import bisect
#import numpy as np
#import itertools
#import copy
#import collections
import sys

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    s = input()
    ss = list(set(s))
    flag = False

    if len(ss) == 2:
        a = s.count(ss[0])
        b = s.count(ss[1])
        if a == b == 2:
            flag = True

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

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

S.sort()

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

Submission status: Accepted

Solution code:
s = sorted(input())

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()
s=sorted(s)

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

Submission status: Accepted

Solution code:
s = input()
dic = {}
for si in s:
    dic[si] = 0
for si in s:
    dic[si] += 1
#dic
cnt = 0
cnt_len = 0
for i, j in dic.items():
    #print(i, j)
    cnt_len += 1
    if j == 2:
        cnt += 1
if cnt == 2 and cnt_len == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
from collections import Counter
D = Counter(list(S))
if list(D.values()).count(2)==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

s_set = list(set(s))
if len(s_set) != 2:
    print('No')
else:
    count1 = 0
    for i in range(len(s)):
        if s[i] == s_set[0]:
            count1 += 1
    count2 = 0
    for i in range(len(s)):
        if s[i] == s_set[1]:
            count2 += 1
    if count1 == 2 and count2 == 2:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
import collections

S = input()
length=len(set(S))

CTR = collections.Counter(S).most_common()

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

Submission status: Accepted

Solution code:
s = input()
sl = sorted(list(s))
if len(set(sl)) == 2:
  if sl[1] != sl[2]:
    print('Yes')
  else:
    print('No')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import Counter

S = input()

if list(Counter(S).values()) == [2, 2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
s = list(input())

dup = [x for x in set(s) if s.count(x) == 2]

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

Submission status: Accepted

Solution code:
S = input()
S = S.replace(S[0],"")
if len(S) > 0:
    S = S.replace(S[0],"")
    if len(S) == 0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

m = {}

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

if len(m) != 2:
  print("No")
  exit()

for k, v in m.items():
  if v != 2:
    print("No")
    exit()

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

from collections import Counter

def main():
  counts = Counter(list(input().strip()))
  if len(counts) == 2 and all([v==2 for k, v in counts.items()]):
    print('Yes')
  else:
    print('No')

if __name__=='__main__':
  main()

Submission status: Accepted

Solution code:
N = input()
S = sorted(N)
flag = True
if S[0] != S[1]:
  flag = False
if S[2] != S[3]:
  flag = False
if S[1] == S[2]:
  flag = False
if flag == True:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

if ss[0] == ss[1] and ss[1] != ss[2] and ss[2] == ss[3]:
    ans = 'Yes'
else:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
s = input()
use = set()
for i in range(4):
    use.add(s[i])
if len(use) != 2:
    print("No")
    exit()
if (s[0] == s[1] and s[1]==s[2]) or (s[0] == s[1] and s[1] == s[3]) or (s[0] == s[2] and s[2] == s[3]) or (s[1]== s[2] and s[2]== s[3]):
    print("No")
    exit()

print("Yes")

Submission status: Accepted

Solution code:
S = input()

from collections import Counter
keys = Counter(S).keys()
values = Counter(S).values()

if len(keys) == 2 and max(values) == 2 and min(values) == 2 :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
s = input()

li = {}

for i in s:
  try:
    li[i] += 1
  except:
    li[i] = 1

if len(li) == 2 and max(li.values()) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import Counter
s = input().strip()
c = Counter(s)
fl = True
for v in c.values():
  if v != 2:
    print("No")
    fl = False
    break
if fl:
  print("Yes")

Submission status: Accepted

Solution code:
# coding: utf-8

S = input()
word = []
for i in S:
	word.append(i)
ans = list(set(word))
a = 0
for i in word:
    if i == word[0]:
        a += 1
    else:
        pass

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

s_arr = [str(s) for s in S]
s_arr = sorted(s_arr)

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

Submission status: Accepted

Solution code:
S = input()

temp2 = 0
for i in "ABCDEFGHIJKLMNOPQRSTUVWXYZ":
    temp1 = S.count(i)
    if temp1 == 2:
        temp2 += 1

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

Submission status: Accepted

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

for  i in range(4):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1
        
if len(dic) == 2 :
    for i in dic :
        if dic[i] != 2:
            print("No")
            break
    else:
        print("Yes")
        
else:
    print('No')

Submission status: Accepted

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

S = input()

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

cnt = 0        
for s in S : 
    if s == list[0] : 
        cnt += 1
        
if len(list) == 2 and cnt == 2 : 
    print("Yes")
else : 
    print("No")

Submission status: Accepted

Solution code:
s = list(input())

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

Submission status: Accepted

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

for i in range(0,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=list(input())
ans='Yes'
for i in range(len(S)):
	if S.count(S[i])!=2:ans='No'
print(ans)

Submission status: Accepted

Solution code:
s = set(input())

if 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 = input()
l = [s[0], s[1], s[2], s[3]]
l.sort()
if l[0] == l[1] != l[2] == l[3]:
    print('Yes')
else: print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = set(list(input()))

print("Yes" if len(S) == 2 else "No")

Submission status: Accepted

Solution code:
S = list(input())
d = {}

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

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

Submission status: Accepted

Solution code:
S=input()
s_list=sorted(list(S))

if s_list[0]==s_list[1] and s_list[2]==s_list[3]:
    if len(set(s_list))==2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
l = set(input())

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

Submission status: Accepted

Solution code:
from collections import Counter
S=Counter(input())
print("Yes" if len(S)==2 and len(set(list(S.values())))==1 else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
n = s.count(s[0])
print("YNeos"[n!=2 or len(set(s))!=2::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

s = sys.stdin.readline().rstrip()

def main():
    for char in set(s):
        if s.count(char) != 2:
            return 'No'
    return 'Yes'

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# https://atcoder.jp/contests/abc132/tasks/abc132_a

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

for c in s:
    if s.count(c)!=2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
c = Counter(S)
print("Yes" if tuple(c.values()) == (2,2) else "No")

Submission status: Accepted

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

Submission status: Accepted

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

if len(c) == 2:
    a, b = c.values()
    if a == 2 and b == 2:
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
lst = list(s)
st = set(s)
if len(st) == 2 and (lst[0]==lst[1] and lst[2] == lst[3]):
    print("Yes")
elif len(st) == 2 and (lst[0]==lst[2] and lst[1] == lst[3]):
    print("Yes")
elif len(st) == 2 and (lst[0]==lst[3] and lst[1] == lst[2]):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = sorted(str(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:
import collections
s = input()
s = list(s)
s = collections.Counter(s)
s = list(s.values())
flag = False
for i in s:
    if i!=2:
        flag = True
if flag==True:
    print('No')
else:
    print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# Code for A - Fifty-Fifty
# Use input() to fetch data from STDIN
from collections import defaultdict

s = input()
m = defaultdict(int) 

for c in s:
    m[c] += 1

if len(m.keys()) != 2:
    print("No")
    exit()

if all([v == 2 for v in m.values()]):
    print("Yes")
    exit()

print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    d = defaultdict(int)
    for s in input():
        d[s] += 1
    print('Yes' if all(v==2 for v in d.values()) else 'No')


main()

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()

print("{}".format("Yes" if len(set(s))==2 else "No"))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

a = list(set(s))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#PythonのCounterでリストの各要素の出現個数をカウント
N = list(input())
import collections
counter = collections.Counter(N)
#print(counter)
ans = "Yes"
for i in counter.values():
    if i != 2:
        ans = "No"
print(ans)

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-


def main():
    S = list(input())
    print('Yes' if all(
        [S.count(S[i]) == 2 for i in range(len(S))]) else 'No')


if __name__ == "__main__":
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
A = sorted(S)
if A[0] == A[1] != A[2] == A[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

b = True
for value in d.values():
    if value != 2:
        b = False

if b:
    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')
    #aabb
elif s[0]==s[2] and s[1]==s[3] and s[0]!=s[1]:
    print('Yes')
    #abab
elif s[0]==s[3] and s[1]==s[2] and s[0]!=s[1]:
    print('Yes')
    #abba
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()
list = [s[0],s[1],s[2],s[3]]
list.sort()
if list[0] == list[1] and list[1] != list[2] and list[2] == list[3]: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
S=input()
d={}
for i in S:
    if i not in d:
        d[i]=1
    else:
        d[i]+=1
v=list(d.values())
if len(d)==2:
    if (v[0]==2)and(v[1]==2):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
flag = True
for c in S:
    if S.count(c) != 2:
        flag = False
print('Yes') if flag else print('No')

Submission status: Accepted

Solution code:
S = input()

a = set()

for i in range(len(S)):
  a.add(S[i])

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(set(s))
if len(t)==2:
    if s.count(t[0])==2 and s.count(t[1])==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[1]==S[2] and S[0]!=S[1]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
result = False
for v in list(S):
    if S.count(v) != 2:
        break
    new = S.replace(v, '')
    if new[0] == new[1]:
        result = True
    break
print("Yes" if result else "No")

Submission status: Accepted

Solution code:
s = sorted(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 = input()

s_sorted = sorted(s)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
F=input()
if F[0]==F[1] and F[2]==F[3] and F[0]!=F[2]:
  print('Yes')
elif F[0]==F[2] and F[1]==F[3] and F[0]!=F[1]:
  print('Yes')
elif F[0]==F[3] and F[1]==F[2] and F[0]!=F[1]:
  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")
    
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 = input()
set_s = set(s)
flag = 1
for si in set_s:
    if s.count(si) != 2:
        flag = 0

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

S=input()
c=Counter(S)
if len(c)==2 and c[S[0]]==2:
  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] = 0

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

Submission status: Accepted

Solution code:
C = set(s_i for s_i in input())
print('Yes' if len(C)==2 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

if S[0] == S[1] and S[2] == S[3] and S[0] != S[2]:
  print("Yes")
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:
#132 a
s=input()
moji=dict()
ans="No"
for c in s:
    if c not in moji:
        moji[c]=1
    else:
        moji[c]+=1
if len(moji)==2:
    ans="Yes"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
l=[s[i] for i in range(4)]
se = set(l)
if len(se)==2 and l.count(s[0])==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

if ((S[0] == S[1] and S[2] == S[3] and S[1] != S[2]) or
    (S[0] == S[2] and S[1] == S[3] and S[1] != S[2]) 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:
a=input()
a=sorted(a)
cont=0
if a[0]==a[1] and a[2]==a[3] and a[0]!=a[2]: print("Yes")
else: print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(input())
a=s.count(s[0])
b=s.count(s[1])
c=s.count(s[2])
d=s.count(s[3])
e=a+b+c+d
if e==8:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

S_array = [""] * 4

for i in range(len(S)):
    S_array[i] = S[i]

S_array.sort()

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10000000)
INF = 1<<32

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

def solve(S: str):
    if all([S.count(S[i]) == 2 for i in range(len(S))]):
        print(YES)
    else:
        print(NO)
    return



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

Submission status: Accepted

Solution code:
count = {}

S = input()

for s in S:
  count[s] = count[s] + 1 if s in count else 1
  
key_counts = len(count)

if key_counts == 2:
  for v in count.values():
    if v != 2:
      print('No')
      exit()
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S=input()
lis=[]
for i in range(4):
    lis.append(ord(S[i]))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s_list = list(s)
s_list.sort()

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

Submission status: Accepted

Solution code:
s=input()
d={}
n="No"
for i in s:
  if i in d:
    d[i]=d[i]+1
  else:
    d[i]=1
    
if len(d) ==2:
  for k,v in d.items():
    n="Yes"
    
print(n)

Submission status: Accepted

Solution code:
s = input()

cnt = 0
for c in set(s):
  if s.count(c) == 2:
    cnt += 1

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

Submission status: Accepted

Solution code:
def main():
    s = input()

    sl = list(s)

    ss = set(sl)

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

    if sl.count(list(ss)[0]) != 2:
        print('No')
        exit()

    print('Yes')

 
if __name__ == '__main__':
    main()

Submission status: Accepted

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