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:
from bisect import bisect_left, bisect_right; from collections import Counter, defaultdict, deque, OrderedDict; from copy import deepcopy; from fractions import gcd; from functools import lru_cache, reduce; from math import ceil, floor; from sys import stdin, setrecursionlimit
import heapq as hq; import itertools as its; import operator as op


# globals
inf = float('inf')
input = stdin.readline


def main():
    s = get_str()
    c = Counter(s)
    if len(c.keys()) == 2 and list(c.values())[0] == 2:
        print("Yes")
    else:
        print("No")
    return


def get_int():
    return int(input())


def get_float():
    return float(input())


def get_str():
    return input().strip()


def get_li():
    return [int(i) for i in input().split()]


def get_lf():
    return [float(f) for f in input().split()]


def get_lc():
    return list(input().strip())


def gets(n, types, sep=None):
    if len(types) == 1:
        return [types[0](input().strip()) for _ in range(n)]
    return list(zip(*(
        [t(x) for t, x in zip(types, input().strip().split(sep=sep))]
        for _ in range(n)
    )))


if __name__ == '__main__':
    setrecursionlimit(4100000)
    main()

Submission status: Accepted

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

print(solve())

Submission status: Accepted

Solution code:
s = input()
if len(set(s)) == 2 and all(sum(1 for c in s if c == k) == 2 for k in s):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for i in range(4):
    if S[i] in a.keys():
        a[S[i]] += 1
    else:
        a[S[i]] = 1
    

check = 0
for i in a.values():
    if i==2:
        check += 1

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

Submission status: Accepted

Solution code:
S = list(input())
flg = True
for c in S:
    if S.count(c) != 2:
        flg = False

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

Submission status: Accepted

Solution code:
import sys
from collections import deque  # 双方向キュー
from collections import defaultdict  # 初期化済み辞書
from heapq import heapify, heappush, heappop, heappushpop  # プライオリティキュー
from bisect import bisect_left, bisect_right  # 二分探索
#import numpy as np  # 1.8.2
#import scipy  # 0.13.3
#sys.setrecursionlimit(int(1e+6))
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))
MOD = int(1e+9) + 7

def main():
    S = i2s()
    d = defaultdict(lambda: 0)
    for s in S:
        d[s] += 1
    for k, v in d.items():
        if v != 2:
            print('No')
            return
    print('Yes')

main()

Submission status: Accepted

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

Submission status: Accepted

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

s = input()

a = dict()

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

for i,v in a.items():
    if v != 2:
        print("No")
        exit()
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:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# coding: utf-8

import sys
def input(): return sys.stdin.readline().strip()
def gcd(x, y): return y if x % y == 0 else gcd(y, x % y)
def lcm(x, y): return (x * y) // gcd(x, y)
import collections
# N = int(input())
# L = [int(x) for x in input().split()]
# L = [[int(x) for x in input().split()] for _ in range(N)]
# N, M = map(int, input().split())
S = input()

c = collections.Counter(S)

print("Yes" if len(c.values()) == 2 else "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 = list(str(input()))
if len(set(s)) == 2 and len(s) == 4:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()

sdict = {}
for s in S:
    sdict.setdefault(s,0)
    sdict[s] += 1

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

print("Yes")

Submission status: Accepted

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

Submission status: Accepted

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

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

def solve(S: str):
    s = sorted(S)
    if s[0] == s[1] and s[2] == s[3] and s[0] != s[2]:
        return YES
    else:
        return NO


# 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
    print(solve(S))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
N = input()
flag = True
for i in range(4):
    if not N.count(N[i])==2:
        flag = False
        break
if flag:
    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:
def find(s):
    dic={}
    for i in range(len(s)):
        if s[i] in dic:
            dic[s[i]]+=1
        else:
            dic[s[i]]=1
    if len(dic)==2:
        for x in dic:
            if dic[x]!=2:
                return False
        return True
    else:
        return False
s=input()
if find(s):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

S=list(input().strip())

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

Submission status: Accepted

Solution code:
s = input()
c_set = set([c for c in s])

counts = [s.count(c) for c in c_set]
if max(counts) == 2 and min(counts) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
from collections import Counter
s = Counter(list(input()))
print(['No','Yes'][all(x == 2 for x in s.values())])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
setS = set(S)
flag = True
if len(setS) != 2: flag = False
for s in setS:
  if S.count(s) != 2: flag = False

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

Submission status: Accepted

Solution code:
S = sorted(list(map(str, 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()

dic = {}


for i in S:

    if i in dic:
        dic[i] += 1
    else:
        dic[i] = 1

bul = True

for i in dic:

    if len(dic)!=2 or dic[i] != 2:
        bul = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
c = Counter(S).items()

if len(c) == 2 and all(i[1] == 2 for i in c):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
if all(s.count(s[i])==2 for i in range(4)): print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
#
import itertools
from collections import Counter
from collections import defaultdict
import bisect
from heapq import heappush, heappop

def main():
    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')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

################################################################################
s = list(input().strip())
s.sort()
print("Yes" if s[0] == s[1] and s[2] == s[3] and s[1] != s[2] else "No")

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
from collections import defaultdict
n = str(input())
seen = defaultdict(int)
for letter in n:
    seen[letter] += 1
res = 0
for key in seen.keys():
    if seen[key] != 2:
        res += 1
if res != 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
s = input()

t = set(s)

ok = True

for c in t:
	if s.count(c) != 2:
		ok = False

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:


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


if __name__ == '__main__':
    solve()

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

S=input()

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

Submission status: Accepted

Solution code:
def main():
    import sys
    input = sys.stdin.readline
    
    a = sorted(input()[:-1])
    # print(a)
    if a[0] == a[1] and a[2] == a[3] and a[1] != a[2]:
        print("Yes")
    else:
        print("No")
    
    return 0

main()

Submission status: Accepted

Solution code:
s = input()
a = {}
b = []
for i in range(len(s)):
    if s[i] in a.keys():
        a[s[i]] += 1
    else:
        a[s[i]] = 1
for i in a.keys():
    b.append(a[i])
if len(a) == 2 and b == [2,2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from heapq import heappush, heappop
import re
from collections import deque
import sys
input = sys.stdin.readline


def int_raw():
    return int(input())


def ss_raw():
    return input().split()


def ints_raw():
    return tuple(map(int, ss_raw()))


DIV = 10**9+7


def mod_invs(n, mod=DIV):
    inv = [0]*(n+1)
    inv[0] = 1
    inv[1] = 1
    for i in range(2, n+1):
        inv[i] = (-(mod//i)*inv[mod % i]) % mod
    return inv


def main():
    S = input().strip("\n")
    if len(set(S))==2 and S.count(S[0])==2:
        return "Yes"
    return "No"


print(main())

Submission status: Accepted

Solution code:
s=input().rstrip()
x=list(s)
l=[]
for i in range(0,len(x)):
    if x.count(x[i])>=2 and x[i] not in l:
        l.append(x[i])
if len(l)==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=list(input())
f=True
for i in s:
    if s.count(i)!=2:
        f=False
if f:
    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 = list(input())
S.sort()
if S[0]==S[1] and S[2]==S[3] and len(set(S))==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

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



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

Submission status: Accepted

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

lst.sort()
if lst[0] == lst[1] and lst[2] == lst[3] and lst[1] != lst[2]:
    print("Yes")

else:
    print("No")

Submission status: Accepted

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

import sys

a= dict()
for x in sys.stdin.readline().strip(): a[x]= a.get(x,0) + 1
#
ans= "Yes"
for v in a.values():
    if v!=2: ans="No"
print( ans )

Submission status: Accepted

Solution code:
S = input()

set_S = set(S)

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

print('Yes')

Submission status: Accepted

Solution code:
s = list(input())

from collections import Counter

c = Counter(s)

for i in c.values():
    if i !=2:
        print("No")
        exit()
    else:
        pass

print("Yes")

Submission status: Accepted

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

ans = 'Yes'
for i in range(len(S)):
    if S[i] in d:
        d[S[i]] += 1
    else:
        d[S[i]] = 1

    if d[S[i]] > 2:
        ans = 'No'
        break

if len(d) != 2:
    ans = 'No'

print(ans)

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()
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 -*-
import sys
from operator import itemgetter
# gcd
from fractions import gcd
# 切り上げ，切り捨て
from math import ceil, floor
# リストの真のコピー（変更が伝播しない）
from copy import deepcopy
# 累積和。list(accumulate(A))としてAの累積和
from itertools import accumulate
# l = ['a', 'b', 'b', 'c', 'b', 'a', 'c', 'c', 'b', 'c', 'b', 'a']
# S = Counter(l)  # カウンタークラスが作られる。S=Counter({'b': 5, 'c': 4, 'a': 3})
# print(S.most_common(2))  # [('b', 5), ('c', 4)]
# print(S.keys())  # dict_keys(['a', 'b', 'c'])
# print(S.values())  # dict_values([3, 5, 4])
# print(S.items())  # dict_items([('a', 3), ('b', 5), ('c', 4)])
from collections import Counter
import math
from functools import reduce
# input関係の定義
# fin = open('in_4.txt', 'r')
# sys.stdin = fin
#
input = sys.stdin.readline
def ii(): return int(input())
def mi(): return map(int, input().rstrip().split())
def lmi(): return list(map(int, input().rstrip().split()))
def li(): return list(input().rstrip())
# template


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


def solve(S: str):
    lisS = sorted(S)
    if lisS[0] == lisS[1] and lisS[2] == lisS[3] and lisS[1] != lisS[2]:
        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 = input()

a = []
for si in s:
    a.append(si)

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

Submission status: Accepted

Solution code:
S = sorted(list(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()
St = list(set(S))
arr = []
for i in range(len(St)):
    arr.append(S.count(St[i]) == 2)

print("Yes" if all(arr) else "No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
s = input()
k = collections.Counter(s)
ans = "Yes"
if (len(k) == 2):
    for i in k.values():
        if  i != 2:
            ans = "No"
            break
else:
    ans = "No"
print(ans)

Submission status: Accepted

Solution code:
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    # a, b = map(int, input().split())

    s = input()

    for i in s:
        if s.count(i) != 2:
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
from collections import Counter

c = Counter(input())
print(['No','Yes'][len(c) == 2 and list(c.values())[0] == 2 and list(c.values())[1] == 2])

Submission status: Accepted

Solution code:

S = input()
slist = []

for i in range(4):
    slist.append(S[i])
    
slist.sort()
    
if slist[0] == slist[1] and slist[2] == slist[3] and slist[1] != slist[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/usr/bin/env pypy
from __future__ import division, print_function

import os
import sys
from __builtin__ import xrange as range
from cStringIO import StringIO
from collections import Counter
from future_builtins import ascii, filter, hex, map, oct, zip
from io import IOBase

import __pypy__


def main():
    s = input()
    c = Counter(s)
    if len(c) == 2 and set(c.values()) == {2}:
        print('Yes')
    else:
        print('No')



# region fastio

BUFSIZE = 8192


class FastI(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = StringIO()
        self.newlines = 0

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count("\n") + (not b)
            ptr = self._buffer.tell()
            self._buffer.seek(0, 2), self._buffer.write(b), self._buffer.seek(ptr)
        self.newlines -= 1
        return self._buffer.readline()


class FastO(IOBase):
    def __init__(self, file):
        self._fd = file.fileno()
        self._buffer = __pypy__.builders.StringBuilder()
        self.write = lambda s: self._buffer.append(s)

    def flush(self):
        os.write(self._fd, self._buffer.build())
        self._buffer = __pypy__.builders.StringBuilder()


def print(*args, **kwargs):
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


sys.stdin, sys.stdout = FastI(sys.stdin), FastO(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

a = list(set(S))
b,c = 0,0

for i in range(4):
    if S[i] == a[0]:
        b += 1
    elif S[i] == a[1]:
        c += 1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
D = set(S)
def f():
    if len(D) != 2:
        return False

    for d in D:
        if S.count(d) != 2:
            return False
    return True

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
import collections

s = input()
sc = collections.Counter(s).most_common()
if len(sc) == 2:
    if sc[0][1] == 2 and sc[1][1] == 2:
        print("Yes")
        exit()
print("No")

Submission status: Accepted

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

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())
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:
s=sorted(input())
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 = input()
for s in S:
  if S.count(s) != 2:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

S = input()

a = S[0]
S_a = S.replace(a,'')

ans = 'No'
if len(S_a) == 2:
    if S_a[0]==S_a[1]:
        ans = 'Yes'



print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())
s = list(set(S))
ans = 'No'
if len(s) == 2:
    if S.count(s[0]) == 2:
        ans = 'Yes'

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter

s = input()
ctr = Counter(s)
if all(v == 2 for _, v in ctr.most_common()):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007
dire4 = [(1,0), (0,1), (-1,0), (0,-1)]
dire8 = [(1, 0), (1, 1), (0, 1), (-1, 1), (-1, 0), (-1, -1), (0, -1), (1, -1)]

S = input()
T = list(set(S))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
S = input()
S = collections.Counter(S)
check = True
if len(S)==2:
    for key,value in S.items():
        if value!=2:
            check=False
else:
    check=False

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

Submission status: Accepted

Solution code:
import collections


def main():
    ctr = collections.Counter(input())
    if tuple(ctr.values()) == (2, 2):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
"""
AtCoder A
"""

import sys, math, random
import numpy as np

# N = int(input())
# A = list(map(int,input().split())) # N row 1 column
# A = [int(input()) for _ in range(N)] # 1 row N column
# S = str(input()) # str(input()) == input() -> 'abc'
# S = list(input()) # abc -> ['a','b','c']
# S.replace('ABC','X') # "testABCABC" -> "testXX"
# S=numpp.assaray(S)=="#"
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LLS(): return [list(sys.stdin.readline().rstrip()) for _ in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



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

    
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter

Ss = input()

num = len(set(Ss))
cnt = Counter(Ss)

if num == 2 and min(cnt.values()) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections

S = input()
d = collections.defaultdict(lambda :0)

for c in S:
    d[c] += 1

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

Submission status: Accepted

Solution code:
from collections import Counter
S = Counter(input())
if all([v == 2 for v in S.values()]):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()
se=list(set([i for i in s]))
print("Yes" if s.count(s[0])==2 and len(se)==2 else "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:
import collections


s = input()
c = collections.Counter(list(s))

if len(c) != 2:
    print('No')
    exit()
else:
    for k in c.keys():
        if c[k] != 2:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
S = input()
print("Yes" if sum([2==S.count(ch) for ch in S])==4 else "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())
S.sort()
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()
for i in range(len(S)):
    if S.count(S[i]) != 2:
        print('No')
        exit(0)

print('Yes')

Submission status: Accepted

Solution code:
S = input()

A = set(S)
ans = (
    'Yes' if len(A) == 2 and all(S.count(a) == 2 for a in A) else
    'No'
)

print(ans)

Submission status: Accepted

Solution code:
S = input()
L = set([str(s) for s in S])
if len(L) == 2 and S.count(S[0]) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import os
import sys

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(2147483647)
INF = float("inf")
IINF = 10 ** 18

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

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 = input()
dic = {}
for s in S:
    if s in dic:
        dic[s] += 1
    else:
        dic[s] = 1
a = list(dic.values())
if a.count(2) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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



S = str(input())
ret = set()
for c in S:
  ret.add(S.count(c))
if 2 in ret and len(ret)==1:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def inpl(): return map(int, input().split())
from collections import Counter
S = input()
C = Counter(S)
K = list(C.keys())
if len(K) == 2 and C[K[0]] == C[K[1]] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()

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

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 defaultdict
N = input()
di = defaultdict(int)
for i in N:
    di[i]+=1
for j in di:
    if(not di[j]==2):
        print('No')
        break
else:
    print('Yes')