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 len(set(S)) == 2 and S.count(S[0]) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S=input()

from collections import Counter

c=Counter([S[0],S[1],S[2],S[3]])

if len(list(c.keys()))==2:
    flag=True
    for key in c.keys():
        if c[key]!=2:
            flag=False
            break

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

Submission status: Accepted

Solution code:
from collections import defaultdict
s=input()
x=set()
d=defaultdict(int)
for v in s:
  d[v]+=1
  x.add(v)
if len(d)==2:
  for k in d:
    if d[k]!=2:
      print("No")
      exit(0)
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()
ans = 'No'
if s.isupper() and len(s)==4:
  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[1]):
    ans ='Yes'
print(ans)

Submission status: Accepted

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

L = list(input().strip())
m = {}

for v in L:
    if m.get(v) == None:
        m[v] = 0
    m[v] += 1
    
for v in m.values():
    if v != 2:
        print("No")
        exit()
        
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
t=1
for i in s:
	if not s.count(i)==2:
		print('No')
		t=0
		break;
if t==1: print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
S = sorted(S)
yes = [a == b for a, b in zip(S, S[1:])] == [True, False, True]
print('Yes' if yes else 'No')

Submission status: Accepted

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

if len(d) == 2 and set(d.values()) == {2}:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def ok(s: str) -> str:
    char_count = {}
    for c in s:
      if c not in char_count:
        char_count[c] = 0
      if c in char_count.keys():
        char_count[c] += 1
    
    return all([count == 2 for count in char_count.values()])

numbers_str = input()
result = ok([c for c in numbers_str])
if result:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
S = input()
c = 1
for i in range(4):
    if S.count(S[i]) != 2:
        c = 0
if c==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = str(input())

if S[0] == S[1]:
	if S[0] != S[2] and S[2] == S[3] :
		print('Yes')
	else:
		print('No')
else:
	if (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:
from collections import Counter

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

Submission status: Accepted

Solution code:
S = input()
s = set(S)
flag = True

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

if len(s) == 2 and flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from sys import stdin
from collections import Counter

S = stdin.readline().rstrip()
c = Counter(S)

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

Submission status: Accepted

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools

sys.setrecursionlimit(10**7)
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 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 pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    c = collections.Counter(S())
    if len(c) == 2 and list(c.values())[0] == 2:
        return 'Yes'

    return 'No'


print(main())

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#Coding-Utf8

S=input()
A=B=0

for i in range(4):
    for l in range(i+1,4):
        if S[i]==S[l]:
            A+=1

if A==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("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[2] == S[1]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
code = input()

wc = {}
for i in code:
    if i in wc:
        wc[i] = wc[i] + 1
    else:
        wc[i] = 1

for key in wc.keys():
    if int(wc[key]) != 2:
        print("No")
        exit(0)
print("Yes")

Submission status: Accepted

Solution code:
s=input()

ans=True

for i in s:
  if s.count(i)!= 2:
    ans=False
    
print('Yes' if ans==True else 'No')

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
S = input()

A = S[0]
ans = 'No'

if A == S[1]:
    B = S[2]
    if B == S[3]:
        ans = 'Yes'
else:
    B = S[1]
    if A == S[2] and B == S[3]:
        ans = 'Yes'
    if B == S[2] and A == S[3]:
        ans = 'Yes'

if A == B:
    ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
# using main() makes code faster from the point of view of "access to variables in global name-space"
# def main():

""" convenient functions
# for i, a in enumerate(iterable)
# q, mod = divmod(a, b)
# divmod(x, y) returns the tuple (x//y, x%y)
# manage median(s) using two heapq https://atcoder.jp/contests/abc127/tasks/abc127_f
"""

import sys
sys.setrecursionlimit(10**7)
from itertools import accumulate, combinations, permutations, product # https://docs.python.org/ja/3/library/itertools.html
# accumulate() returns iterator! to get list: list(accumulate())
from math import factorial, ceil, floor
def factorize(n):
    """return the factors of the Arg and count of each factor
    
    Args:
        n (long): number to be resolved into factors
    
    Returns:
        list of tuples: factorize(220) returns [(2, 2), (5, 1), (11, 1)]
    """
    fct = []  # prime factor
    b, e = 2, 0  # base, exponent
    while b * b <= n:
        while n % b == 0:
            n = n // b
            e = e + 1
        if e > 0:
            fct.append((b, e))
        b, e = b + 1, 0
    if n > 1:
        fct.append((n, 1))
    return fct
def combinations_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    # TODO: How should I do when n - r is negative?
    if n < 0 or r < 0:
        raise Exception('combinations_count(n, r) not defined when n or r is negative')
    if n - r < r: r = n - r
    if r < 0: return 0
    if r == 0: return 1
    if r == 1: return n
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
    return result
def combinations_with_replacement_count(n, r):
    """Return the number of selecting r pieces of items from n kinds of items allowing individual elements to be repeated more than once.
    
    Args:
        n (long): number
        r (long): number
    
    Raises:
        Exception: not defined when n or r is negative
    
    Returns:
        long: number
    """
    if n < 0 or r < 0:
        raise Exception('combinations_with_replacement_count(n, r) not defined when n or r is negative')
    elif n == 0:
        return 1
    else:
        return combinations_count(n + r - 1, r)
from bisect import bisect_left, bisect_right
from collections import deque, Counter, defaultdict # https://docs.python.org/ja/3/library/collections.html#collections.deque
from heapq import heapify, heappop, heappush, heappushpop, heapreplace,nlargest,nsmallest # https://docs.python.org/ja/3/library/heapq.html
from copy import deepcopy, copy # https://docs.python.org/ja/3/library/copy.html
from operator import itemgetter
# ex1: List.sort(key=itemgetter(1))
# ex2: sorted(tuples, key=itemgetter(1,2))
from functools import reduce
def chmin(x, y):
    """change minimum
    if x > y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current minimum value
        y (long): potential minimum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x > y:
        x = y
        return (x, True)
    else:
        return (x, False)
def chmax(x, y):
    """change maximum
    if x < y, x = y and return (x, True).
    convenient when solving problems of dp[i]
    
    Args:
        x (long): current maximum value
        y (long): potential maximum value
    
    Returns:
        (x, bool): (x, True) when updated, else (x, False)
    """
    if x < y:
        x = y
        return (x, True)
    else:
        return (x, False)

from fractions import gcd # Deprecated since version 3.5: Use math.gcd() instead.
def gcds(numbers):
    return reduce(gcd, numbers)
def lcm(x, y):
    return (x * y) // gcd(x, y)
def lcms(numbers):
    return reduce(lcm, numbers, 1)

# first create factorial_list
# fac_list = mod_factorial_list(n)
INF = 10 ** 18
MOD = 10 ** 9 + 7
modpow = lambda a, n, p = MOD: pow(a, n, p) # Recursive function in python is slow!
def modinv(a, p = MOD):
    # evaluate reciprocal using Fermat's little theorem:
    # a**(p-1) is identical to 1 (mod p) when a and p is coprime
    return modpow(a, p-2, p)
def modinv_list(n, p = MOD):
    if n <= 1:
        return [0,1][:n+1]
    else:
        inv_t = [0,1]
        for i in range(2, n+1):
            inv_t += [inv_t[p % i] * (p - int(p / i)) % p]
        return inv_t
def modfactorial_list(n, p = MOD):
    if n == 0:
        return [1]
    else:
        l = [0] * (n+1)
        tmp = 1
        for i in range(1, n+1):
            tmp = tmp * i % p
            l[i] = tmp
        return l
def modcomb(n, k, fac_list = [], p = MOD):
    # fac_list = modfactorial_list(100)
    # print(modcomb(100, 5, modfactorial_list(100)))
    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    if len(fac_list) <= n:
        a = factorial(n) % p
        b = factorial(k) % p
        c = factorial(n-k) % p
    else:
        a = fac_list[n]
        b = fac_list[k]
        c = fac_list[n-k]
    return (a * modpow(b, p-2, p) * modpow(c, p-2, p)) % p
def modadd(a, b, p = MOD):
    return (a + b) % MOD
def modsub(a, b, p = MOD):
    return (a - b) % p
def modmul(a, b, p = MOD):
    return ((a % p) * (b % p)) % p
def moddiv(a, b, p = MOD):
    return modmul(a, modpow(b, p-2, p))

""" initialize variables and set inputs
# initialize variables
    # to initialize list, use [0] * n
    # to initialize two dimentional array, use [[0] * N for _ in range(N)]
# set inputs
    # open(0).read() is a convenient method:
    # ex) n, m, *x = map(int, open(0).read().split())
    #     min(x[::2]) - max(x[1::2])
    # ex2) *x, = map(int, open(0).read().split())
    #     don't forget to add comma after *x if only one variable is used
# preprocessing
    # transpose = [x for x in zip(*data)]
    # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [(1, 4, 7), (2, 5, 8), (3, 6, 9)]
    # flat = [flatten for inner in data for flatten in inner]
    # ex) [[1, 2, 3], [4, 5, 6], [7, 8, 9]] => [1, 2, 3, 4, 5, 6, 7, 8, 9]
# calculate and output
    # output pattern
    # ex1) print(*l) => when l = [2, 5, 6], printed 2 5 6
"""

# functions used
r = lambda: sys.stdin.readline().strip()
r_int = lambda: int(r())
R = lambda: list(map(int, r().split()))
Rfloat = lambda: list(map(float, r().split()))
Rtuple = lambda: tuple(map(int, r().split()))
Rmap = lambda: map(int, r().split())

""" how to treat input
# single int: int(r())
# single string: r()
# single float: float(r())
# line int: R()
# line string: r().split()
# line (str, int, int): [j if i == 0 else int(j) for i, j in enumerate(r().split())]
# lines int: [R() for _ in range(n)]
"""


# ----------------------------------
# main
S = r()
for i in Counter(S).values():
    if i != 2:
        print('No')
        exit()
print('Yes')

# end of main
# ----------------------------------

"""memo: how to use defaultdict of list
# initialize
Dic = defaultdict(list)
# append / extend
Dic[x].append(y)
# for
for k, v in Dic.items():
"""

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

Submission status: Accepted

Solution code:
s = input()

s = sorted(list(s))

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

Submission status: Accepted

Solution code:
ssss = list(input())
ans = {}

for s in ssss:
    if s in ans:
        ans[s] += 1
    else:
        ans[s] = 1
for s in ans:
    if ans[s] == 2:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:

a = input()
dic = {}
if len(set(a)) == 2:
    for i in range(len(a)):
        if a[i] not in dic:
            dic.setdefault(a[i], 1)
        else:
            dic[a[i]] += 1
            if dic[a[i]] > 2:
                print('No')
                break
    print('Yes')

else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
table = {}
for s in S:
    if s not in table:
        table[s] = 1
    else:
        table[s] += 1

if len(table) != 2:
    print('No')
    exit()
for t in table:
    if table[t] != 2:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc132

s = list(str(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:
import collections
S = input()
C = collections.Counter(S)
count = 0
for c in C.items():
  if c[1] == 2:
    count += 1
print("Yes" if count == 2 else "No")

Submission status: Accepted

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

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

def solve(S: str):
    print(YES if len(set(list(S))) == 2 else 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:
import sys

def input(): return sys.stdin.readline()[:-1]
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 MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
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

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

Submission status: Accepted

Solution code:
S = input()

from collections import defaultdict

dic = defaultdict(int)

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

if len(dic) == 2:
    for k, v in dic.items():
        if v == 2:
            continue
        else:
            print("No")
            exit()
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
flag = 'Yes'
for i in S:
    if S.count(i) != 2:
        flag = 'No'

print(flag)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input1 =list(input())

check = 0
for i in input1:
    for j in range(len(input1)):
        if i == input1[j]:
            check = check +1

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

Submission status: Accepted

Solution code:
#import numpy as np
#from numpy import*
#from scipy.sparse.csgraph import shortest_path #shortest_path(csgraph=graph) # dijkstra# floyd_warshall
#from scipy.sparse import csr_matrix
 
from collections import* #defaultdict Counter deque appendleft
from fractions import gcd
from functools import* #reduce
from itertools import* #permutations("AB",repeat=2) combinations("AB",2) product("AB",2) groupby accumulate
from operator import mul,itemgetter
from bisect import* #bisect_left bisect_right
from heapq import* #heapify heappop heappushpop
from math import factorial,pi
from copy import deepcopy
import sys
sys.setrecursionlimit(10**8)
#input=sys.stdin.readline  #危険！基本オフにしろ！
 
def main():
    s=input()
    if s[0]==s[1] and s[2]==s[3] and len(set(s))==2:
        print("Yes")
    elif s[0]==s[2] and s[1]==s[3] and len(set(s))==2:
        print("Yes")
    elif s[0]==s[3] and s[1]==s[2] and len(set(s))==2:
        print("Yes")
    
    else:
        print("No")
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
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 len(set(S)) != 2:
    print('No')
    exit()

c1, c2 = list(set(list(S)))

if (S.count(c1) == 2) and (S.count(c2) == 2):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()

alph = set(S)
if len(alph) != 2:
    print("No")
    exit(0)

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

print("Yes")

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()
m = {}
for c in s:
  if c in m.keys():
    m[c] += 1
  else:
    m[c] = 1
if len(m.keys()) == 2 and set(m.values()) == set([2]):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# -*- encoding: UTF-8 -*-
s = input()
 
dic = {}
 
for i in range(4) :
    a = s[i]
    if not (a in dic) :
        dic[a]=0
    dic[a] = dic[a] +1

result = "No"

count =0
for val in dic.values():
    if val == 2 :
        count = count +1

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

Submission status: Accepted

Solution code:
def solve(s):
    s = sorted(s)
    return "Yes" if s[0] == s[1] and s[1] != s[2] and s[2] == s[3] else "No"

print(solve(input()))

Submission status: Accepted

Solution code:
from collections import Counter

S = Counter(input())

ans = 'Yes'
for s in S.values():
	if s != 2:
		ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
s = list(input())
s.sort()
cnt = 1
ans = 1
# print(s)
for i in range(1, 4):
  # print(cnt)
  if s[i - 1] != s[i]:
    if cnt < 2:
      ans = 0
      break
    cnt = -1
  if not ans:
    break
  cnt += 1
if cnt > 3:
  ans = 0
if not ans:
  print("No")
else:
  print("Yes")

Submission status: Accepted

Solution code:
letters = list(input())
x = 1
for letter in letters:
        if letters.count(letter) == 2:
            x *= 1
        else:
            x *= 0
print(["No","Yes"][x])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
def main():
    S = list(input())
    S.sort()
    SS = set(S)
    if len(SS)==2 and S[0]==S[1] and S[2]==S[3]:
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
str=list(input())
if str.count(str[0])==2 and str.count(str[1])==2 and str.count(str[3])==2 and str.count(str[2])==2:
    print("Yes")
elif str.count(str[0])==4 or str.count(str[2])==4 or str.count(str[1])==4 or str.count(str[3])==4:
    print("No")
else:
    print("No")

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

Submission status: Accepted

Solution code:
S  = input()
import collections
c = collections.Counter(S)
for i,c in enumerate(c.values()):
    if c != 2:
        print('No')
        exit(0)
    if i == 2:
        print('No')
        exit(0)
print('Yes')

Submission status: Accepted

Solution code:
INPUT = input()

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

Submission status: Accepted

Solution code:
import collections

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

c = collections.Counter(input())

if len(c.keys()) == 2 and all(i == 2 for i in c.values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())

num = [0]*26

num_A = ord("A")

for s in S:
    num[ord(s)-num_A] += 1

if num[ord(S[0])-num_A] == 1 or num[ord(S[1])-num_A] == 1 or num[ord(S[2])-num_A] == 1 or num[ord(S[3])-num_A] == 1:
    print("No")
elif num[ord(S[0])-num_A] == 4 or num[ord(S[1])-num_A] == 4 or num[ord(S[2])-num_A] == 4 or num[ord(S[3])-num_A] == 4:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

s = input()
cnt = 0

for i in range(4):
    for j in [a+i+1 for a in range(3-i)]:
        if s[i] == s[j]:
            cnt += 1

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

Submission status: Accepted

Solution code:
s = input()
g = {}
for i in s:
    if i not in g:
        g[i] = 0
    g[i] += 1
a = []
for i in g:
    a.append(g[i])
if a == [2, 2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
input_str = input()
items = set(list(input_str))
print('Yes' if len(items) == 2 and len(list(input_str.replace(list(items)[0], ''))) == 2 else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
S_list = list(S)
df = "Yes"
for i in range(0, 3):
    if S_list.count(S_list[i]) != 2:
        df = "No"
print(df)

Submission status: Accepted

Solution code:

S = input()
ls ={}
s =True
for i in S:
    if S.count(i)!=2:
        s =False
if s:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import string

S = input()

ans = 0
for char in list(string.ascii_uppercase):
    if S.count(char) == 2:
        ans += 1
if ans == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
inputString = input()
counts = set(map(lambda i: inputString.count(inputString[i]), range(4)))
if counts == {2}:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import itertools
import sys

def hantei(s):
  hantei = s.isupper()
  
  if hantei:
    i = 0
    for s1, s2 in itertools.combinations(s, 2):
      if s1 == s2:
        i += 1
    hantei = 'Yes' if i == 2 else 'No'
  else:
    hantei = 'No'
    
  return hantei


if __name__ == '__main__':
  args = sys.stdin
  
  for arg in args:
    print(hantei(str(arg)))

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

from collections import Counter

cs = Counter(S)

result = list(cs.values()) == [2, 2]

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