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:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy,copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd


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()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def main():
    s=list(input())
    t=set(s)
    if len(t)==2:
        print('Yes')
    else:
        print('No')


if  __name__=='__main__':
    main()

Submission status: Accepted

Solution code:
s=list(input())
s1=s[0]
sf=s.count(s1)
if sf==2:
  for i in range(2):
    s.remove(s1)
  if s[0]==s[1]:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()
#-------------------------------------
import collections
s = list(input())
c = collections.Counter(s)
if len(c.keys()) == 2 and c.most_common()[0][1] == 2:
        print("Yes")
else:
        print("No")

Submission status: Accepted

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

if len(S2) == 2:
    print("Yes")
    exit()

print("No")

Submission status: Accepted

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

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

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


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

S = input()
C  =Counter(S)
a = 0
for k,v in C.items():
    if v!=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()
for s in S:
  if S.count(s) != 2:
    print('No')
    exit()
print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8
import time
import re
import math
import fractions

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

start=time.time()
main()
#print("処理速度 {}sec".format(time.time()-start))
#A=list(map(int,input().split()))
#A,B,C=map(int,input().split())
#n=int(input())
# global N,A,B,C,D,memo,mx,mn,temp

Submission status: Accepted

Solution code:
from collections import Counter
S = input()
input_counter = Counter(S)

if len(input_counter) == 2:
    for v in input_counter.values():
        if v != 2:
            print('No')
            exit()
    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 = str(input())
s = list(S)

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=str(input())
if(s[0]!=s[1]):
	if(s.count(s[0])==2 and s.count(s[1])==2):
		print("Yes")
	else:
		print("No")
else:
	if(s[2]!=s[0]):
		if(s.count(s[0])==2 and s.count(s[2])==2):
			print("Yes")
		else:
			print("No")
	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()
sep = set(s)
if len(sep) == 2:
  if s.count(list(sep)[0]) == s.count(list(sep)[1]):
    print ("Yes")
  else:
    print("No")
    
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
    S = input()

    if (
        S.count(S[0]) is 2
        and S.count(S[1]) is 2
        and S.count(S[2]) is 2
        and S.count(S[3]) is 2
    ):
        print("Yes")
    else:
        print("No")

    return


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

if len(s_set) == 1:
    print("No")
else:
    if 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()
x = {}
for i in s:
    x[i] = 0
for i in s:
    x[i] += 1

ans = 0
for i in x:
    if x[i] == 2:
        ans += 1

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

Submission status: Accepted

Solution code:
s=input();print('YNeos'[any(s.count(t)!=2for t in s)::2])

Submission status: Accepted

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


while True :
	S = input()
	if len(S) == 4 and S.isupper() :
		break
	else :
		continue


char_list = list(S)

judge = 0


for i in range(3) :
	for j in range(3-i) : 
		if char_list[i] == char_list[i+j+1] :
			judge = judge + 1

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

Submission status: Accepted

Solution code:
S = input()

S2 = set(S)

ans = ''
if len(S2) == 2:
    ans = 'Yes'
else:
    ans = 'No'

print('{}'.format(ans))

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=list(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())
if len(set(s)) == 2:
    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:
S = input()
s = "".join(set(S))
if len(s) == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

if sys.platform =='ios':
	sys.stdin=open('inputFile.txt')
		
#+++++

def main():
	s = input()
	ss=set()
	for c in s:
		ss.add(c)
		
	if len(ss) != 2:
		return 'No'
		
	cc=list(s)[0]
	aa=len([c for c in list(s) if c==cc])
	
	if aa == 2:
		return 'Yes'
	return 'No'
	

if __name__ == "__main__":
	print(main())

Submission status: Accepted

Solution code:

S = input()
s = set(S)

c = 0
for i in s:
    if S.count(i) == 2:
        c += 1
if c == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections
l = list(input())
c = collections.Counter(l)
A = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
count = 0
for i in A:
    if c[i] == 2:
        count += 1
    else:
        count += 0
if count == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
string = input()
string = string.lower()
strDict = {}
for i in range(len(string)):
    if string[i] in strDict:
        strDict[string[i]] = strDict[string[i]] - 1
    else:
        strDict[string[i]] = 1
not_fount = True
for key, value in strDict.items():
    if value != 0:
        print("No")
        not_fount = False
        break
        
if not_fount:
    print("Yes")

Submission status: Accepted

Solution code:
x = list(input())

count=0
for i in range(len(x)):
    if x[i] in x:
        count += 1
x = set(x)

if len(x) == 2 and count == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=list(input())

def judge(S):
    if S[0]==S[1] and S[2]==S[3] and S[0]==S[3]:
        return 'No'        
    elif S[0]==S[1] and S[2]==S[3]:
        return 'Yes'
    elif S[0]==S[2] and S[1]==S[3]:
        return 'Yes'
    elif S[0]==S[3] and S[1]==S[2]:
        return 'Yes'
    else:
        return 'No'

print(judge(S))

Submission status: Accepted

Solution code:
s = input()
b1 = ''
b2 = ''
n = 0
for i, c in enumerate(s):
  if i == 0:
    b1 = c
    n += 1
    continue
  if c != b1 and b2 == '':
    b2 = c
    continue
  if c == b1:
    n += 1
    continue
  if c == b2:
    continue
  if c != b1 and c != b2:
    print('No')
    break
else:
    print('Yes' if n == 2 else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
string = input()

if all([string.count(c)==2 for c in set(string)]) :
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections

s = input()

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

Submission status: Accepted

Solution code:
n = input()
m = list({(i, n.count(i)) for i in n})

if len(m) != 2 or m[0][1] != 2:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
import sys

def check():
    S = raw_input()
    for a in S:
        if S.count(a)!=2:
            return 0
    return 1

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

Submission status: Accepted

Solution code:
S = input()

s = {i for i in S}
c1=0
c2=0
if len(s) !=2:
    print("No")
else:
    a = S[0]
    b = S[1]
    for i in S[2:]:
        if i==a:
            c1 += 1
        elif i == b:
            c2 += 1
    if c1 == 2 or c2 == 2:
        print("No")
    else:
        print("Yes")

Submission status: Accepted

Solution code:
s = input()

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

cnt1 = 0
cnt2 = 0
memo =24
for i in range(1,4):
    if a[0] == a[i]:
        memo = i
        break;
    

ans = "No"
if(memo != 24):
    for i in range(1,4):
        for j in range(i+1,4):
            if (i != memo and j != memo):
                if a[i] == a[j]:
                    if a[0] != a[i]:
                        ans = "Yes"
                        break;


print(ans)

Submission status: Accepted

Solution code:
import collections
S=list(map(str,input()))

S=collections.Counter(S)
a=S.most_common()



if int(len(a)) is 2:
    print("Yes")

else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())

S_unique = list(set(S))

if all(map(lambda x:S.count(x)==2,S_unique)):
  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()
judge = "No"
count=[]
for i in range(4):
    count.append(S.count(S[i]) )
if count == [2,2,2,2]:
    judge = "Yes"
    
print(judge)

Submission status: Accepted

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

else:
    print('No')

Submission status: Accepted

Solution code:
s = str(input())
s_unique = ''.join(set(s))
is_st = True
for i in s_unique:
    if s.count(i) != 2:
        is_st = False
        break
        
print('Yes' if is_st else 'No')

Submission status: Accepted

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

Submission status: Accepted

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

if(a==b):
    count+=1
    if(c==d and a!=c):
        count+=1
elif(a==c):
    count+=1
    if(b==d and a!=b):
        count+=1
elif(a==d):
    count+=1
    if(b==c and a!=b):
        count+=1

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections


line = input().strip()

counter = collections.Counter(line)

if len(counter) == 2:
    former, latter = counter.most_common(2)
    if former[1] == latter[1] == 2:
        print("Yes")
        exit(0)

print("No")
exit(0)

Submission status: Accepted

Solution code:
word = list(input())

count = {}
result = "Yes"
for s in word:
  if count.get(s) != None:
    count[s] += 1
  else:
    count[s] = 1
if (len(count) != 2):
  result = "No"
else:
  for t in count.values():
    if t != 2:
      result = "No"

print(result)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
str = input()
chars = list(str)
lng = []

for i in range(len(chars)):
    lng.append(ord(chars[i]))

lng.sort()

if lng[0] == lng[1] < lng[2] == lng[3]:
    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 = input()
S=str(S)

if S[0]==S[1]:
  if S[2]==S[3]:
    if S[0] != S[2]:
      print('Yes')
    else:
      print('No')
  else:
  	print('No')
elif S[0]==S[2]:
  if S[1]==S[3]:
    if S[0] != S[1]:
      print('Yes')
    else:
      print('No')
  else:
  	print('No')
elif S[0]==S[3]:
  if S[1]==S[2]:
    if S[0] != S[1]:
      print('Yes')
    else:
      print('No')
  else:
  	print('No')
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]) 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:
# -*- coding: utf-8 -*-
# 整数の入力
p=str(input())
if p[0] ==p[1] ==p[2] ==p[3]:
    print("No") 
elif p[0] ==p[3] and p[1] == p[2]:
    print("Yes")
elif p[0] == p[1] and p[2] == p[3]:
    print("Yes")
elif p[0] ==p[2] and p[1] == p[3]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

a = []

for i in range(4):
    a.append(s[i])

a.sort()

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

Submission status: Accepted

Solution code:
#coding:utf-8
from collections import Counter

S = input()
cnt = Counter(list(S))
ls = list(cnt.values())
if (ls[0]==2 and ls[1]==2):
    print ("Yes")
else:
    print ("No")

Submission status: Accepted

Solution code:
S = str(input())
ans = set([S[i] for i in range(0, 4)])
if (S.count(ans.pop()) == 2) and (S.count(ans.pop()) == 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()

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

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

else:
  print("No")

Submission status: Accepted

Solution code:
import sys
from collections import Counter
from operator import itemgetter, attrgetter
n=0
 
word = input()
w1=None
w2=None
isNG=False
for w in word:
    if w1 == None or w1 == w:
        w1=w
        
    else:
        if w2 == None or w2 == w:
            w2=w
        else:
            isNG = True
if isNG or w1 == None or w2 == None:
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:

word = list(input())

word_set = set(word)

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

Submission status: Accepted

Solution code:
import sys

s = input()
l = list(s)
for i in range(2):
    c = s.count(l[0])
    s = s.replace(l[0], "")
    h = l[0]
    while h in l:
        l.remove(h)
    if c!=2: 
        print("No")
        sys.exit()
if s != "":
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

Sl = list(S)

a= Sl.count(Sl[0])
b= Sl.count(Sl[1])
c= Sl.count(Sl[2])

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

Submission status: Accepted

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

for num in range(4):
    sum += count[num]

if sum == 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 and a!=c and c==d:
  print("Yes")
elif a!=b and a==c and b==d:
  print("Yes")
elif a!=b and a==d and b==c:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = str(input())
cnt = 0
for moji in s:
    #print(moji)
    num = s.count(moji)
    #print(num)
    if num == 2:
        cnt+=1
    else:
        break
        
if cnt == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
flag = True
for ch in set(s):
    if s.count(ch)!=2:
        flag =False
if len(set(s))==len(s)//2 and flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
str = input()

d = {}
for c in str:
    if c in d: d[c] += 1
    else: d[c] = 1

l = []
for v in d.items():
    l.append(v)

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
count = 0
for i in range(len(S)-1):
    if S[i] in S[i+1:]:
        count += 1
if count ==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = list(input())
count = 0
s_1 = s[0]
for i in range(3):
    if s_1 == s[i+1]:
        del(s[i+1])
        break

tmp = s_1
del(s[0])
if len(s) == 3:
    print('No')

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

Submission status: Accepted

Solution code:
s = input()
cnt = 0

for i in range(len(s)):     
    for j in range(len(s)):
        if i ==j:
            continue
        elif s[i] == s[j]:
            cnt+=1
            
if cnt == 4:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()


if len(S) == 4:
    li = list(S)
    if len(set(li)) == 2:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
s0, s1 = 1, 0
second = ""
for i in range(1, 4):
  if S[i] == S[0]: s0 += 1
for i in range(1, 4):
  if S[i] != S[0]: 
    second = S[i]
    break
for i in range(1, 4):
  if S[i] == second: s1 += 1
if s0 == 2 and s1 == 2: print("Yes")
else: print("No")

Submission status: Accepted

Solution code:
S = list(input())
A = S[0]
while A in S :
    S.remove(A)
if len(S) == 2 :
    if S[0] == S[1] :
        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]
l = []
l.append(a)
l.append(b)
l.append(c)
l.append(d)
k = list(set(l))
if len(k) == 2:
  if l.count(a) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
n = input()

cnt = 0

if n.count(n[0]) == 2:
  cnt += 1
if n.count(n[1]) == 2:
  cnt += 1
if n.count(n[2]) == 2:
  cnt += 1
if n.count(n[3]) == 2:
  cnt += 1

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

Submission status: Accepted

Solution code:
s=list(input())

a=s.count(s[0])
b=s.count(s[1])
c=s.count(s[2])
d=s.count(s[3])

s=list(set(s))
#print(s)
ans1=0
if (a==3) or (b==3) or (c==3) or (d==3):
    #print("No")
    ans1=-1
if len(s)==2:
    #print("Yes")
    ans1=+1
else:
    ans1=-1
    #print("No")

if ans1==1:
    print("Yes")
else:
    print("No")

#print(a)
#print(b)
#print(c)
#print(d)

Submission status: Accepted

Solution code:
S = list(input())
hantei = 1
kaisu = 0

for i in range(0,4):
    for j in range(0,4):
        if S[i] == S[j]:
            kaisu += 1
    if kaisu != 2:
        hantei = 0
        
    kaisu = 0

if hantei == 1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections

inputstr = input()
input = sorted(inputstr)
a = collections.Counter(input)
if len(a) == 2 and a.most_common()[0][1] == 2:
    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 = input()
if len(set(s)) == 2:
  a,b = set(s)
  if s.count(a) == 2 and s.count(b) == 2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
from collections import Counter
from functools import reduce

S = input()
SC = Counter(S)

if len(SC.items()) == 2 and reduce(lambda x, y: x and y, [v == 2 for v in SC.values()], True):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

S = input()
A = {}
A[S[0]] = True
A[S[1]] = True
A[S[2]] = True
A[S[3]] = True
if len(A) == 2 and S.count(S[0]) == 2:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
s = input()
sd = {}
for i in range(4):
    if not s[i] in sd.keys():
        sd[s[i]] = 1
    else:
        sd[s[i]] += 1

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

Submission status: Accepted

Solution code:
# coding: utf-8
# A - Fifty-Fifty

s = input()
c = []
dict = {}
for i in s:
    if i in dict:
        dict[i] +=1
    else:
        dict[i] = 1
        c.append(i)

if dict[c[0]] == 4:
    print("No")
elif dict[c[0]] == dict[c[1]] == 2 and len(dict) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
l =[S[0]]
for i in S:
  if i not in l:
    l.append(i)
if len(l)==2:
  count1=0
  for i in range(4):
    for j in range (4):
      if S[i]==S[j]:
        count1+=1
  if count1 ==8:
    print("Yes")
  else:
    print("No")
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:
import collections
x=input()
y=[x[0],x[1],x[2],x[3]]
c = collections.Counter(y)
ans="Yes"
if(len(c))>2:
    ans="No"
if(ans=="Yes"):

    a=x.count(x[0])
    if(a>2):
        ans="No"



print(ans)

Submission status: Accepted

Solution code:
t = list(input())
T = set(t)
flg = 0

for i in T:
    if not t.count(i) == 2:
        flg = 1

if len(list(T)) == 2 and flg == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

c=[0,0,0,0]
h=[]
h.append(S[0])
c[0]+=1

for i in range(1,len(S)):
	cnt=0
	for k in range(len(h)):
		if h[k] ==S[i]:
			c[k]+=1
		elif h[k]!=S[i]:
			cnt+=1
	if cnt == len(h):
		h.append(S[i])
		c[len(h)-1]+=1
if 2==c[0] and 2==c[1]:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
A,B,C,D = input()
S = (A+B+C+D)
S1 = []
if A == B == C== D:
    print('No')
    exit()
for i in S:
    if i.strip(A) !='':
        S1.append(i.strip(A))
if len(S1) == 2:
        if S1[0] == S1[1]:
            print("Yes")
        else:
            print("No")
else :
    print("No")

Submission status: Accepted

Solution code:
ns = input()

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
a = input()
c = 0
tmp = a[0]
for i in range(len(a)):
  if tmp == a[i]:
    c += 1
    
if a[0] == a[1] or a[0] == a[2] or a[0] == a[3]:
  if a[1] == a[2] or a[1] == a[3] or a[2] == a[3]:
    if c == 2:
      print("Yes")
    else:print("No")
  else:print("No")
else:print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
c1 = s[0]
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()
output = 'No'

if S[0] == S[1]:
  if S[2] == S[3] and S[2] != S[0]:
    output = 'Yes'

if S[0] == S[2]:
  if S[1] == S[3] and S[1] != S[0]:
    output = 'Yes'

if S[0] == S[3]:
  if S[1] == S[2] and S[1] != S[0]:
    output = 'Yes'

print(output)

Submission status: Accepted

Solution code:
char=input()

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

Submission status: Accepted

Solution code:
import sys

str = str(input())
list = []
for c in str:
  list.append(c)
list.sort()

if list[0] == list[2]:
    print("No")
    sys.exit()
if list[0] == list[1]:
  if list[2] == list[3]:
    print("Yes")
    sys.exit()
print("No")