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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
#ABC132 = 2*2*3*11
S = input()
if 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: Wrong Answer

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

import os
import sys
from collections import Counter
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    s = set(Counter(input()).values())
    print('YES' if s == {2} else 'NO')


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

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

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

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Solution code:
string = input()

s_list = []
for i in range(4):
  s_list.append(string[i])
  
sn_list = sorted(s_list)

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

Submission status: Wrong Answer

Solution code:
text = input()
textlist = [g for g in set(text)]

if set(text) == 2:
  for e in textlist:
    if text.count(e) != 2:
      print('No')
      sys.exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
stdin = sys.stdin
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()

s = ns()

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

print('No')

Submission status: Wrong Answer

Solution code:
S = sorted(input())

print(S)

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

Submission status: Wrong Answer

Solution code:
S = input()
c1 = S.count(S[0])
c2 = S.count(S[1])
print(["No", "Yes"][c1 == 2 and c2 == 2 and S[0] != S[1]])

Submission status: Wrong Answer

Solution code:
a = list(input())


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

Submission status: Wrong Answer

Solution code:
s=list(input())
l=[]
for i in range(4):
    if not s[i] in l:
        l.append(s[i])

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:

S = input()
if (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: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S  = list(input())
dic = {}
f = False
for s in S:
  if s in dic:
    f = True
  else:
    dic[s] = 1
if f:
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
# @author 

import sys

class AFiftyFifty:
    def solve(self):
        s = list(input())
        s.sort()
        print("Yes" if (s[0] == s[1] and s[2] == s[3]) else "No")


solver = AFiftyFifty()
input = sys.stdin.readline

solver.solve()

Submission status: Wrong Answer

Solution code:
S = input()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import sys
from collections import Counter, deque, defaultdict
from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
from functools import reduce
from math import ceil, floor, log10, log2, factorial

sys.setrecursionlimit(1000000)
# MOD = 10 ** 9 + 7
# INF = float('inf')
# N = int(input())
# A = [int(x) for x in input().split()]
# A = [int(input()) for _ in range(N)]
# dp = [[0] * 100 for _ in range(100)]
# dp = defaultdict(lambda: float('inf'))
# print('hoge', file=sys.stderr)


S = list(input())
S.sort()

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

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s = input().strip()
d = defaultdict(int)
for v in s:
    d[v] += 1

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
a = list(input())
a.sort()
ret = "No"
if a[0]==a[1] and a[2]==a[3]:
    ret = "Yes"
print(ret)

Submission status: Wrong Answer

Solution code:
S = [s for s in input()]
S.sort()

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
if(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: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
ri = lambda: int(input())
#rl = lambda: [int(x) if x.isdecimal() else x for x in input().split()]
#rl = lambda: list(input().split()))
rl = lambda: map(int,input().split())
rr = lambda N: [list(l) for l in zip(*[rl() for _ in range(N)])]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD = 10**9+7

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
print("Yes" if sum([2==S.count(ch) for ch in S]) else "No")

Submission status: Wrong Answer

Solution code:
a = input()
b = sorted(a)

if b[0]==b[1] and b[2]==b[3]:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("Yes")
    elif q == 0:print("No")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def ips():
    return (int(i) for i in input().split())
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

#n,m = ips()
a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!
s = []
for i in range(4):
    s.append(a[i])
s.sort()
if s[0] == s[1] and s[2] == s[3]:j(1)
j(0)

Submission status: Time Limit Exceeded

Solution code:
l = input()
a = l[0]
b = l[1]
c = l[2]
d = l[3]


while(True):
    if(a==b and b==c and c==d):
        print("No")
        break
    if(a==b and c==d):
        print("Yes")
        break
    if(a==c and b==d):
        print("Yes")
        break
    if(a==d and c==b):
        print("Yes")
        break
    print("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 = list(input())
if len(set(s)) == 2 and s.count(s[0]) == 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:
s=input()
ans="Yes"
for i in range(4):
    if s.count(s[i])!=2:
        ans="No"
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
from collections import Counter
c = Counter(list(S))
cnt = 0
for char in list("ABCDEFGHIJKLMNOPQRSTUVWXYZ"):
    if c[char] == 2:
        cnt += 1
if cnt == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#ABC132 A

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
setslen = len(set(s))
if setslen == 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 = input()
S = set(s)
if len(S) != 2:
    print('No')
    exit()
else:
    for i in range(4):
        if s.count(s[i]) != 2:
            print('No')
            exit()

print('Yes')

Submission status: Accepted

Solution code:
s = input()

S = []
for i in range(len(s)):
    S.append(s[i])

B = list(set(S))

cnt1 = 0
cnt2 = 0

if len(B) != 2:
    print('No')
else:
    for i in range(len(s)):
        if B[0] == s[i]:
            cnt1 += 1
        elif B[1] == s[i]:
            cnt2 += 1
    if cnt1 == 2 and cnt2 == 2:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
s=input()
a=0
b=0
c=0
for i in range(1,4):
  if ord(s[0])==ord(s[i]):
    a=i
    b+=1
if b==1:
  if a==1:
    if ord(s[2])==ord(s[3]):
      print('Yes')
    else:
      print('No')
  elif a==2:
    if ord(s[1])==ord(s[3]):
      print('Yes')
    else:
      print('No')
  elif a==3:
    if ord(s[1])==ord(s[2]):
      print('Yes')
    else:
      print('No')
else:
    print('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[1] and s[1] == s[2] and s[0]==s[3]:
  print("Yes")
elif s[0]!=s[1] and s[0] == s[2] and s[1]==s[3]:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = list(input())
sorted_s = sorted(s)

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

Submission status: Accepted

Solution code:
x = list(input())

a1 = (x[0] == x[2]) and (x[1] == x[3])
a2 = (x[0] == x[1]) and (x[2] == x[3])
a3 = (x[0] == x[3]) and (x[1] == x[2])
b = len(set(x)) == 2

if b and ( a1 or a2 or a3 ):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
a = Counter(input()).most_common()
if len(a)==2:
  if a[1][1]==2:
    print("Yes")
else:
  print("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:
from collections import Counter
import sys

S = input()
c = Counter(S)
for k, v in c.items():
    if v != 2:
        print('No')
        sys.exit(0)
print('Yes')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
s = input()

cou = []
enc = 0
enc1 = 0
for i in s:
    if i not in cou:
        cou.append(i)

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

for i in s:
    if i in cou[0]:
        enc += 1
    if i in cou[1]:
        enc1 += 1

if enc == 2 and enc1 == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from _collections import defaultdict
S = input()

cnt = defaultdict(int)
for i in range(len(S)):
    cnt[S[i]] += 1
    if cnt[S[i]] > 2 or len(cnt) > 2:
        print("No")
        exit(0)

print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict
dic = defaultdict(int)
s = list(input())
for i in s:
    dic[i]+=1
b = True
for j in s:
    if dic[j]!=2:
        b=False
if b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = str(input())

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

Submission status: Accepted

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


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
sl = []
for i in s:
    if i not in sl:
        sl.append(i)
if len(sl) == 2:
    n = 0
    for i in s:
        if i == sl[0]:
            n += 1
    if n == 2:
        print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

S.sort()
#print(S)

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

        else:
            print("No")

    else:
        print("No")

else:
        print("No")

Submission status: Accepted

Solution code:
s=list(input())

a=set(s)

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

Submission status: Accepted

Solution code:
S = input()
c = 1
if S[0] == S[1]:
    if S[2] == S[3] and S[0] != S[2]:
        c = 0

elif S[0] == S[2]:
    if S[1] == S[3] and S[0] != S[1]:
        c = 0

elif S[0] == S[3]:
    if S[1] == S[2] and S[0] != S[1]:
        c = 0
        

if c:
    print('No')

else:
    print('Yes')

Submission status: Accepted

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


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

Submission status: Accepted

Solution code:
S = list(input())
s = set(S)
lis = {}
for x in S:
  if x in lis:
    lis[x] += 1
  else:
    lis[x] = 1
ans = True
if len(lis) == 2:
  for x in s:
    if lis[x] != 2:
      ans = False
else:
  ans = False
if ans:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()
for i in range(len(s)):
    if s.count(s[i]) != 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
s=set(S)
for c in s:
    if S.count(c)!=2:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
S = sorted(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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:
# coding:utf-8

import sys
import math
import time
#import numpy as np
import collections
from collections import deque
from collections import Counter
import queue
import copy
import bisect
import heapq
import itertools


#sys.setrecursionlimit(10**7)
#N, Q = map(int, input().split())
#G = [list(input()) for i in range(H)]
#INF = V * 10001
#A = [int(i) for i in input().split()]
#AB = [list(map(int, input().split())) for _ in range(K)]
#CW = [list(map(int, list(input()))) for _ in range(H)]


S = str(input())
ans = "Yes"

for i in range(4):
  if(S.count(S[i])!=2):
    ans = "No"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
 
# S_0 = S_1 かつ S_2 = S_3
# S_0 = S_2 かつ S_1 = S_3
# S_0 = S_3 かつ S_1 = S_2
# S_0 = S_1 = S_2 = S_3 を除外
 
if (S[0] == S[1] and S[2] == S[3] and S[1] != S[2]) or (S[0] == S[2] and S[1] == S[3] and S[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 = input()
 
# S_0 = S_1 かつ S_2 = S_3
# S_0 = S_2 かつ S_1 = S_3
# S_0 = S_3 かつ S_1 = S_2
# S_0 = S_1 = S_2 = S_3 を除外

if S[0] == S[1] == S[2] == S[3]: print('No')
else:
  if (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:
from collections import Counter
s = input()
x = Counter(s)
y = sorted(list(x.values()))
if y[0]*y[-1] == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
word = input()

list_word = list(word)

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

Submission status: Accepted

Solution code:
import collections
s = input()
c = collections.Counter(list(s))
print('Yes' if len(c.keys()) == 2 and len(set(c.values())) == 1 else 'No')

Submission status: Accepted

Solution code:
S = list(input())
if len([x for x in set(S) if S.count(x) > 1]) == 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:
from collections import defaultdict
S = input()
dct = defaultdict(int)
for s in S:
  dct[s] += 1
for key, val in dct.items():
  if not val == 2:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
S = input()
flag = False
if S[0] == S[1] and S[1] != S[2] and S[2] == S[3]:
    flag = True
if S[0] == S[2] and S[2] != S[3] and S[1] == S[3]:
    flag = True
if S[0] == S[3] and S[1] != S[3] and S[1] == S[2]:
    flag = True

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
tmp = {}
for i in range(4):
    tmp.setdefault(s[i],0)
    tmp[s[i]]+=1
if len(tmp)==2 and max(tmp.values())==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict

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

if len(S.values()) == 2:
    a, b = S.values()
    if a == b == 2:
        print('Yes')
        exit()
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:
input = input();
uni_arr = set(input)
if(len(input) == 4 and len(uni_arr) == 2):
  print("Yes")
else: 
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
n = input()
dic = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
for i in range(26):
  if n.count(str(dic[i]))==1 or n.count(str(dic[i]))==3 or n.count(str(dic[i]))==4:
    print("No")
    exit()
print("Yes")

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = input()
if len(set(a)) == 2:
  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
print('Yes' if len(dic)==2 and dic[s[0]]==2 else 'No')

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if len(set(S)) == 2:
    print("Yes")
else:
	print("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=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 = list(input())
ans = 'No'
if (S[0] == S[1] and S[0] != S[2] and S[2] == S[3]) or (S[0] == S[2] and S[0] != S[1] and S[1] == S[3]) or (S[0] == S[3] and S[0] != S[1] and S[1] == S[2]):
    ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
import sys
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S = LS2()
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 = input()

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

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

Submission status: Accepted

Solution code:
import sys

S = list(sys.stdin.readline().strip())
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()

L = {}

ans = "Yes"
for s in S:
    if s in L.keys():
        L[s] += 1
        if L[s] > 2:
            ans = "No"
    else:
        L[s] = 1
if len(L.keys()) != 2:
    ans = "No"

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし


S = LS2()
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())
memo = {}
for i in s:
    if i in memo:
        memo[i] += 1
    else:
        memo[i] = 1
flag = True
for key,val in memo.items():
    if val != 2:
        flag=False
        break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input().strip()
C = {}
for i in range(len(S)):
    if S[i] not in C:
        C[S[i]] = 0
    C[S[i]] += 1
if len(C)==2:
    flag = 0
    for a in C:
        if C[a]!=2:
            flag = 1
            break
    if flag==0:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
S = list(input())
S = Counter(S)
for i in S.values():
    if i == 2 and len(S) == 2:
        ans = "Yes"
    else:
        ans = "No"
    break
print(ans)

Submission status: Accepted

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