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:
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    a = list(set(s))
    if len(a) <2:
        print('No')
        exit()
    if s.count(a[0]) == s.count(a[1]) == 2:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
 
if len(set(s)) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=input()
x=s.count(s[0])
y=s.count(s[1])
z=s.count(s[2])
if x==2 and y==2 and z==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[0]!=S[1] and S[1]==S[3]:
     print("Yes")
elif S[0]==S[3] and S[0]!=S[1] and S[1]==S[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

c = Counter(input())

ok = True
for k in c:
    if c[k] != 2:
        ok = False
        break

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

Submission status: Accepted

Solution code:
S = input()
cnt = 0
for i in range(len(S)-1):
    for j in range(i+1, len(S)):
        if S[i] == S[j]:
            cnt += 1

if cnt == 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:
            pass
        else:
            print("No") 
            exit()
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
s = set(S)
cnt = 0

if len(s) != 2:
  print("No")
  exit()
for i in range(4):
  if S[0] == S[i]:
    cnt += 1
if cnt == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
S=input()
data=[S[i] for i in range(0,4)]
data.sort()
if data[0]==data[1]:
    if data[1]!=data[2] and data[2]==data[3]:
        print('Yes')
    else:
        print('No')
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:
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
N = int(input())
N, A, B = map(int, input().split())
A = list(map(int, input().split()))
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
AB = [[int(x) for x in input().split()] for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""

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





# def main():

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

Submission status: Accepted

Solution code:
#--Fifty-Fifty
import collections

S = list(input())

c = collections.Counter(S)

check_1 = int(c.most_common()[0][1])
if (check_1 == 2):
  pass
else:
  print("No")
  exit()

check_2 = int(c.most_common()[1][1])
if (check_2 == 2):
  print("Yes")
else:
  print("No")
  exit()

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
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    b = list(set(s))
    a = len(list(set(s)))
    if a == 2 and s.count(b[0]) == s.count(b[1]) == 2:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    p = LI()
    ans = 0
    for i in range(1,n-1):
        if (p[i - 1] < p[i] and p[i] < p[i + 1]) or (p[i + 1] < p[i] and p[i] < p[i - 1]):
            ans += 1
    print(ans)
    return

#C
def C():
    n = II()
    d = LI()
    d.sort()
    ans = 0
    for i in range(10**5+1):
        if n // 2 == bisect_left(d, i):
            ans += 1
    print(ans)
    return


def combination_mod(n, k, mod):
    # power_funcを用いて(nCk) mod p を求める 
    # nCk = n!/((n-k)!k!)を使用

    from math import factorial
    if n < 0 or k < 0 or n < k: return 0
    if n == 0 or k == 0: return 1
    a = factorial(n) % mod
    b = factorial(k) % mod
    c = factorial(n - k) % mod
    return (a * power_func(b, mod - 2, mod) * power_func(c, mod - 2, mod)) % mod
    
def power_func(a, b, mod):
    # a^b mod p を求める
    # bを2進数分解して高速累乗

    if b == 0: return 1
    if b % 2 == 0:
        d = power_func(a, b // 2, mod)
        return d * d % mod
    if b % 2 == 1:
        return (a * power_func(a, b - 1, mod)) % mod

#D
def D():
    n, k = LI()
    ans = 0
    for i in range(1,k+1):
        a = combination_mod(n - k + 1, i, mod)
        b = combination_mod(k - 1, i - 1, mod)
        print((a*b)%mod)
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Accepted

Solution code:
s = input()

if len(set(s)) == 2:
    print('Yes')
else:
    print('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, groupby
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()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

S = input()

if len(set(S)) == 2 and S.count(S[0])==2:
	print("Yes")
else:
	print("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 = input()
l = list()
for a in S:
    l.append(a)

if len(list(set(l))) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())

a = S[0]
b = S[1]
c = S[2]
d = S[3]

acount = 0
bcount = 0
ccount = 0
dcount = 0

if S.count(a) == 2 and S.count(c) == 2 and S.count(b) == 2 and S.count(d) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
A = 'Yes'
for i in range(4):
    C = S.count(S[i])
    if C != 2:
        A = 'No'
        
print(A)

Submission status: Accepted

Solution code:
S = input()

if S[0]==S[1]: # AA
    if S[1]!=S[2] and S[2]==S[3]: # AABB
        print("Yes")
    else:
        print("No")
elif S[0]==S[2]: # ABA
    if S[1]==S[3]: # ABAB
        print("Yes")
    else:
        print("No")
elif S[1]==S[2]: # ABB
    if S[0]==S[3]: # ABBA
        print("Yes")
    else:
        print("No")
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 = input()
S = sorted(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:
from collections import Counter
s = list(input())
c = Counter(s)
if len(c) == 2 and c.most_common()[0][1] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
S = sorted(S)
num = len(set(S))

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

Submission status: Accepted

Solution code:
import collections
N = list(input())
N = list(collections.Counter(N).values())
if N[0] == 2 and N[1] == 2:
    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[1] != S[2] and S[2] == S[3]:
	print("Yes")
else:
	print("No")

Submission status: Accepted

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

if s[0]==s[3]==s[1]==s[2]:
  print('No')
elif (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:
a = input()
y =0
a=sorted(a)
for i in range(4):
    x = a.count('{}'.format(a[i]))
    if x!=2:
        print("No")
        y=1
        break
if y==0:print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s = s.lower()
sset = set(s)
judge = False
for i in s:
    if s.count(i) == 2:
        judge = True
    else:
        judge = False
if len(sset) != 2:
    judge = False
print('Yes' if judge else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

if len(set(S)) == 2:
    for x in set(S):
        if S.count(x) == 2:
            continue
        else:
            print('No')
            break
    else:
        print('Yes')
else:
    print('No')

Submission status: Accepted

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

def MI():return map(int,input().split())
def LI():return list(MI())

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:
A=input()
if A[0]==A[1]==A[2]==A[3]:
  print("No")
elif (A[0]==A[1] and A[2]==A[3]) or (A[1]==A[2] and A[0]==A[3]) or (A[0]==A[2] and A[1]==A[3]):
  print("Yes")

else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]

if A == B and C ==D and A != C:
  print("Yes")
elif A == C and B ==D and A != B:
  print("Yes")
elif A == D and B == C and A != B:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
s = dict(Counter(s))
if len(s)==2 and (v==2 for v in list(s.values())):
  print('Yes')
  exit()
print('No')

Submission status: Accepted

Solution code:
s = list(input())
if len(set(s))==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:
str = input()
strlist = list(str)
strlist.sort()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
variety = set(s)
if len(variety) == 2:
    x = []
    for i in variety:
        x.append(i)
    count_1 = s.count(x[0])
    count_2 = s.count(x[1])
    if count_1 == count_2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()

if a[0] == a[1] == a[2] == a[3]:
    print("No")
elif a[0] == a[1] and a[2] == a[3]:
    print("Yes")
elif 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()

m=list(s)

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

Submission status: Accepted

Solution code:
S = input()
A = S[0]
B = S[1]
C = S[2]
D = S[3]
if A == B and C == D and A != C:
  print('Yes')
elif A == C and B == D and A != B:
  print('Yes')
elif A == D and B == C and A != B:
  print('Yes')
else:
  print('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)
s = ''.join(s)

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

Submission status: Accepted

Solution code:
s = input()
a = set(s)
if len(a) != 2:
  print('No')
  exit()
  
import collections
c = collections.Counter(s)
if c.most_common()[0][1] == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
S = list(input())[: -1]
for i in range(4):
  if S.count(S[i]) != 2:
    print("No")
    exit(0)
print("Yes")

Submission status: Accepted

Solution code:
import collections
s = str(input())
l = []
for i in range(0,4):
  l.append(s[i])
  i += 1
c = collections.Counter(l)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
T=sorted(S)
if S.count(S[0])==2 and S.count(S[2])==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
a=S[0]
flag=False
b=""
for i in range(4):
  if(S[i]!=a and b==""):
    flag=True
    b=S[i]
  if(S[i]!=a and S[i]!=b and flag==True):
    print("No")
    exit()
if(flag):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s = str(input())
a = {i for i in s}
ans = 0
if len(a) == 2:
     for i in range(1,4):
          if s[0] == s[i]:
               ans += 1
     if ans == 1:
          print('Yes')
          sys.exit()
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:
N=input()
A=len(set(N))
if A==2 and N.count(N[0]) == N.count(N[1]) == 2:
    print("Yes")
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()
print('Yes'if len(set(s))==2 and s.count(s[0])==2 else 'No')

Submission status: Accepted

Solution code:
import collections

s=input()
print('Yes'if len(set(s))==2 and collections.Counter(s).most_common()[0][1]==2 else 'No')

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

if(S[0]==S[1]==S[2]==S[3]):
    print("No")

elif(S[0]==S[1] and S[2]==S[3]):
    print("Yes")

elif(S[0]==S[2] and S[1]==S[3]):
    print("Yes")

elif(S[0]==S[3] and S[1]==S[2]):
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import os
import math

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

MOD = 10 ** 9 + 7


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

    S = iss()
    print('Yes' if len(set(S)) == 2 and all([S.count(s) == 2 for s in set(S)]) else 'No')


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def MI1(): return map(int1, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")


s=input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

dic = {}
for ch in s:
  if ch not in dic:
    dic[ch] = 1
  else:
    dic[ch] += 1
    
if len(dic)==2 and (dic[ch]==2 for ch in dic):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

for i in range(4):
  T = "n"
  for j in range(len(L)):
    if S[i] == L[j][0]:
      L[j][1] +=1
      T = "y"
  if T == "n":
    L.append([S[i],1])
    
if len(L) == 2:
  if L[0][1] == L[1][1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
s = list(input())
s = sorted(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 = input()
ans = 'No'
if len(set(S)) == 2:
    if S.count(list(set(S))[0]) == S.count(list(set(S))[1]):
        ans = 'Yes'
print(ans)

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()
ans = str()

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

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

Submission status: Accepted

Solution code:
import sys
input = sys.stdin.readline
import math
import collections
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

s=input()
letter=[]
for i in range(4):
    letter.append(s[i:i+1])
#print(letter)
i=collections.Counter(letter)
#print(i)
mul=1
for l in i:
    if i[l]==2:
        continue
    else:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

cnt = 0
for i in range(len(s) - 1):
    for j in range(i + 1, len(s)):
        if s[i] == s[j]:
            cnt += 1

if cnt == 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]:
    if S[0] == S[1] == S[2] == S[3]:
        print('No')
    else:
        print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())

s.sort()

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

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

Submission status: Accepted

Solution code:
S = input()

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

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
S =list(S)

dic = defaultdict(int)
for i in S:
    dic[i] += 1

dic = dict(dic)
bools = [i == 2 for i in dic.values()]
if all(bools):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

table = {}
for s in S:
    table[s] = 1 if table.get(s) is None else table.get(s) + 1

answer = 'Yes' if all([value is 2 for value in table.values()]) else 'No'

print(answer)

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

d = {}
for s in S:
  if s in d.keys():
    d[s] += 1
  else:
    d[s] = 1 

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
chk={}
for i in range(4):
  if s[i] in chk:
    chk[s[i]]+=1
  else:
    chk[s[i]]=1
print("Yes" if len(chk)==2 and chk[s[0]]==2 else "No")

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    q1()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s1 = ord(s[0])
s2 = ord(s[1])
s3 = ord(s[2])
s4 = ord(s[3])

if s1 == s2:
    if s3 == s4 and s1 != s3:
        print("Yes")
        exit()
elif s1 == s3:
    if s2 == s4 and s1 != s2:
        print("Yes")
        exit()
elif s1 == s4:
    if s2 == s3 and s1 != s2:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

Solution code:
s = str(input())
x = {}
for i in range(4):
  if s[i] not in x.keys():
    x[s[i]] = 1
  else:
    x[s[i]] += 1
for i in x.values():
  if i != 2:
    print("No")
    exit()
print("Yes")

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
if len(set([i for i in input()]))==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
a = S.count(S[0])
b = S.count(S[1])
c = S.count(S[2])
d = S.count(S[3])
if (a==b==c==d==2):
  print("Yes")
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 132: A – Fifty-Fifty
s = input()
print('Yes' if len(set(s)) == 2 and s.count(s[0]) == 2 else 'No')