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:
d=dict()
for s in input():
    if not s in d:
        d[s]=1
    else:
        d[s]+=1
if len(d)==2:
    for v in d.values():
        if not v==2:
            print('No')
            exit()
else:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter

c = Counter(input())
if len(c) == 2 and tuple(c.values())[0] == 2:
    print('Yes')
else:
    print('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:
    for i in d.values():
        if i != 2:
            break
    print('Yes')
    exit()
print('No')

Submission status: Accepted

Solution code:
s = input()
if len([s.count(i) for i in set(s) if s.count(i) == 2])==2:
  print('Yes')
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:
#!/usr/bin/env python3
import bisect
import collections
import sys

sys.setrecursionlimit(1000000)
ACMOD = 1000000007
INF = 1 << 62


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


def solve(S: str):
    c= collections.Counter(S)
    if c.most_common()[0][1] == 2 and c.most_common()[1][1] == 2:
        print("Yes")
    else:
        print("No")

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

Submission status: Accepted

Solution code:
import collections


S = input()

C = collections.Counter(S)
ans = "No"
if C.most_common()[0][1] == 2 and C.most_common()[1][1] == 2:
    ans = "Yes"
print(ans)

Submission status: Accepted

Solution code:
palabra = str(input()).upper()
x=0
if len(palabra)==4:
    for letras in palabra:
        if letras == palabra[0]:
            x+=1
        if letras == palabra[1]:
            x+=1
        if letras == palabra[2]:
            x+=1
        if letras == palabra[3]:
            x+=1
if x==8:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def ABC_132_A():
    S = input()
    if S.count(S[0]) != 2 or S.count(S[1]) != 2 or S.count(S[2]) != 2 or S.count(S[3]) != 2:
        print('No')
    else:
        print('Yes')

if __name__ == '__main__':

    ABC_132_A()

Submission status: Accepted

Solution code:
s=list(input())

from collections import Counter

c = dict(Counter(s))

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

Submission status: Accepted

Solution code:
from collections import Counter
S = list(input().rstrip())
ans = Counter(S)
print("Yes") if len(ans)==2 & list(ans.values())[0]==2 & list(ans.values())[1]==2 else print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


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

Submission status: Accepted

Solution code:
s = list(input())
flg = 'Yes'

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

print(flg)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
def solve():
    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')


solve()

Submission status: Accepted

Solution code:
def ABC132A(s):
    ans = True
    for i in s:
        ans = ans and (s.count(i) == 2)
    if ans:
        print("Yes")
    else:
        print("No")

ABC132A(input())

Submission status: Accepted

Solution code:
def ABC132A(s):
    s = list(s)
    ans = True
    for i in range(len(s)):
        ans = ans and (s.count(s[i]) == 2)
    if ans:
        print("Yes")
    else:
        print("No")

ABC132A(input())

Submission status: Accepted

Solution code:
import sys, heapq, bisect, math, fractions
from collections import deque
from collections import Counter

S = list(input())
L = Counter(S)

for l in L.values():
    if l != 2:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
# A - Fifty-Fifty

S = [s for s in str(input())]
ls = list(set(S))
if len(ls) == 2:
    if S.count(ls[0]) == 2 and S.count(ls[1]):
        print('Yes')
    else:
        print('No')
else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())
c1 = S.count(S[0])
c2 = S.count(S[1])
c3 = S.count(S[2])
c4 = S.count(S[3])
if c1 == c2 == c3 == c4 == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a=input()
b={}
for i in a:
    if i in b:
        b[i]+=1
    else:
        b[i]=1

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

Submission status: Accepted

Solution code:
# region header
import sys
from bisect import bisect_left, bisect_right, insort_left, insort_right
from collections import defaultdict, deque, Counter
from copy import deepcopy
from fractions import gcd
from functools import lru_cache, reduce
from heapq import heappop, heappush
from itertools import accumulate, groupby, product, permutations, combinations, combinations_with_replacement
from math import ceil, floor, factorial, log, sqrt, sin, cos, pi, e
from operator import itemgetter
sys.setrecursionlimit(10**6)
rs = lambda: sys.stdin.readline().rstrip()
ri = lambda: int(rs())
rf = lambda: float(rs())
rs_ = lambda: [_ for _ in rs().split()]
ri_ = lambda: [int(_) for _ in rs().split()]
rf_ = lambda: [float(_) for _ in rs().split()]
INF = float('inf')
MOD = 10 ** 9 + 7
# endregion
S = Counter(rs())
if list(S.values()) == [2, 2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
#%% for atcoder uniittest use
import sys
input= lambda: sys.stdin.readline().rstrip()
sys.setrecursionlimit(10**9)
def pin(type=int):return map(type,input().split())
def tupin(t=int):return tuple(pin(t))
def lispin(t=int):return list(pin(t))
#%%code

def resolve():
    S=input()
    cond=1
    for i in range(4):
        temp=S[i]
        a=[0,0]
        for s in S:
            a[s==temp]+=1
        if a[0]!=a[1]:cond=0
    print(["No","Yes"][cond])
#%%submit!
resolve()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
res = {u for u in s}
if len(res) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
palavra = input()
contador = 0

for i in palavra:
    if palavra.count(i) != 2:
        contador=5
if contador!=5:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    s = input()
    letras = []
    for char in s:
        if char not in letras:
            letras.append(char)
    if len(letras) == 2:
        print('Yes')
    else:
        print('No')

main()

Submission status: Accepted

Solution code:
s = input()
aux = []
for i in s:
  if i not in aux:
    aux.append(i)

if len(aux) == 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:
let = set(input())
print({True: 'Yes', False: 'No'}[len(let) == 2])

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
S = list(input())
n = {}
for s in S:
    n[s] = 0
for s in S:
    n[s] += 1
ans = 'Yes'
if len(n.keys()) == 2:
    for i in n.values():
        if i != 2:
            ans = 'No'
else:
    ans = 'No'
print(ans)

Submission status: Accepted

Solution code:
import collections


def resolve():
    S = list(input())

    counter_S = collections.Counter(S)

    if len(counter_S) != 2:
        print("No")
        return

    for value in counter_S.values():
        if value != 2:
            print("No")
            return

    print("Yes")


resolve()

Submission status: Accepted

Solution code:
# Python3 (3.4.3)
import sys
input = sys.stdin.readline

# -------------------------------------------------------------
# function
# -------------------------------------------------------------


# -------------------------------------------------------------
# main
# -------------------------------------------------------------
S = list(input().rstrip())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
# N = int(input())
S = input()
# N, A, B = map(int, input().split())
# A = list(map(int, input().split()))
cnt = [0 for i in range(200)]
syurui = []
for s in S:
    syurui.append(s)
    cnt[ord(s)] += 1
for s in syurui:
    if cnt[ord(s)] != 2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
lst=list(str(input()))
temp=[]
for i in range(4):
  if lst[i] not in temp:
    temp.append(lst[i])
if len(temp)!=2:
  print("No")
else:
  if lst.count(temp[0])==2 and lst.count(lst[1])==2:
    print("Yes")
  else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
for c in S[1:]:
    if S.count(c) != 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
import os
import math
import bisect
import collections
import itertools

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

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


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

    S = list(iss())
    S = collections.Counter(S)
    print('Yes' if all([v == 2 for v in S.values()]) else 'No')

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()

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

Submission status: Accepted

Solution code:
n = str(input())
valor =1;index=0;banderita=0;array=[];m=0;igual=[];posicion=0;vacio=0
for i in range(3):
    while(valor!=4):
        if(n[index]==n[valor]):
            banderita=banderita+1
            igual.append(n[valor])
            posicion = valor
        valor=valor+1   
    if(banderita==1):
        array.append(banderita)
    elif(banderita>1):
        print('No')
        break
    else:
        if(n[posicion] in igual):
            vacio=0
        else:
            print('No')
            break
    banderita=0
    index=index+1
    valor=index+1
    posicion=0
if(len(array)==2):
    print('Yes')
elif(len(array)==1):
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

import collections

S = input()
_set = set(S)

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

S = str(input())

c = collections.Counter(S)

j = True

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

print('Yes')

Submission status: Accepted

Solution code:
S = list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# ABC 132
S=str(input())
if len(set(S))==2:
    ans ="Yes"
else:
    ans ="No"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

def main():
    S = list(input())

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


main()

Submission status: Accepted

Solution code:
s = input()
if s[0] == s[1] and s[0] != s[2] and s[0] != s[3]:
    if s[2] == s[3]:
        print("Yes")
    else:
        print("No")
elif s[1] == s[2] and s[1] != s[3]:
    if s[0] == s[3]:
        print("Yes")
    else:
        print("No")
elif s[0] == s[2] and s[0] != s[3]:
    if s[1] == s[3]:
        print("Yes")
    else:
        print("No")
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:
from collections import Counter
s=input()
t=Counter(s)
if len(t)==2 and max(t.values())==2:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
s = input()
t = [s[0], s[1], s[2], s[3]]
u = list(set(t))
v = len(u)
if v != 2:
    print("No")
else:
    w = s.count(u[0])
    x = s.count(u[1])
    if w == 2 and x ==2:
      print("Yes")
    else:
      print("No")

Submission status: Accepted

Solution code:
from collections import Counter

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

Submission status: Accepted

Solution code:

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

Submission status: Accepted

Solution code:
s = input()
count = 0
for i in range(3):
    for j in range(i+1, 4):
        if s[i] == s[j]:
            count += 1
if count == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = input()
if len(set(list(i for i in S))) == 2:
    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=input()

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

Submission status: Accepted

Solution code:
Ss = list(input().rstrip())

Ss.sort()

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()
a=s[0]
b=s[1]
c=s[2]
d=s[3]
if a==b==c==d:
  print('No')
elif (a==b and c==d) or (a==c and b==d) or (a==d and b==c):
  print('Yes')
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()

l = []
count_a=0
count_b=0
for i in s:
  if i not in l:
    l.append(i)
    count_a+=1
  else: 
    count_b+=1
if count_a == 2 and count_b == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

slist = list(set(s))

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

Submission status: Accepted

Solution code:
import math
import sys
s = input()
li=['']*len(s)
for i in range(len(s)):
    li[i] = s[i]
li.sort()
if (li[0] == li[1] and li[2] == li[3] and li[1] != li[2]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s=list(input())

k=set(s)
if len(k)==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))
# map(int, input().split())
# int(input())
# input().split()
# mojiretu = ','.join(str_list)
# sorted(input())

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:
from collections import Counter
s = list(input())
c = Counter(s)
if len(c) != 2:
  print('No')
  exit()
for v in c.values():
  if v != 2:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
l = [x for x in set(list(s)) if list(s).count(x) > 1]
if len(l) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# A - Fifty-Fifty

s = str(input())
ans = 'Yes'

for i in range(len(s)):
    if s.count(s[i])!=2:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
s = input()

tmp = [c for c in s[1:] if c != s[0]]

if len(tmp) == 2 and tmp[0] == tmp[1]:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections
S = input()

a = dict(collections.Counter(S))

if len(a) != 2:
    print("No")
else:
    for item in a:
        if a[item]!= 2:
            print("No")
            exit()
    print("Yes")

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 = list(input())
# print(s)
s_s = set(s)
# print(s_s)
if len(s_s) == 2 and s.count(s[0])==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = list(input())
# print(s)
s_s = set(s)
# print(s_s)
if len(s_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:
s = list(input())
s_ = set(s)
if len(s_)==2 and s.count(s[0]) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()
a = ''
b = ''
ac = 0
bc = 0
for i in range(4):
  if a == '':
    a = S[i]
    ac = 1
  else:
    if S[i] == a:
      ac = ac + 1
    else:
      if b == '':
        b = S[i]
        bc = 1
      else:
        if S[i] == b:
          bc = bc + 1
if ac == 2 and bc == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

def main():
#  A,B = map(int, input().split())
  S = input().rstrip()
  SS = sorted(S)

  result = 'No'
  if SS[0] == SS[1]:
    if SS[2] == SS[3]:
      if SS[0] != SS[2]:
        result = 'Yes'
  print(result)
  
if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
#copy

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

Submission status: Accepted

Solution code:
def main():
    S = input()
    alphabet = list(set(S))
    flag = False
    if len(alphabet) == 2:
        if S.count(alphabet[0]) == 2 and S.count(alphabet[1]) == 2:
            flag = True
    if flag :
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
a, b, c, d = input()

if (a == b and c == d and a != c) or (a == c and b == d and a != b) or (a == d and b == c and a != b):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:

s = list(input())

cnt = 0
for i in range(len(s)):
    if s.count(s[i]) != 2:
        cnt += 1

if cnt != 0:
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
temp = "?"
ans = "Yes"
for c in s:
    if c != temp:
        if s.count(c) != 2:
            ans = "No"
            break
        temp = c
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

if len(c.keys()) == 2:
    for v in c.values():
        if v == 2:
            print('Yes')
            exit()
        else:
            print('No')
            exit()
print('No')

Submission status: Accepted

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

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

if a==b and b==c and 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 = sorted(input())

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

Submission status: Accepted

Solution code:
s = str(input())
if len(set(s)) == 1:
    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:
#A
import collections
s = input()

l = collections.Counter(s)
if len(l)==2 and list(l.values())==[2,2]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

letter = []
for i in range(4):
    if not S[i] in letter:
        letter.append(S[i])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
s_set = set(s)
if len(s_set) == 2:
    if s.count(list(s_set)[0]) == 2 and s.count(list(s_set)[1]) == 2:
        print('Yes')
        exit()
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 = input("")
uniques = []
for n in s:
    if uniques.count(n) == 0:
        uniques.append(n)

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

Submission status: Accepted

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