Problem:


Score : 100 points

Problem Statement

You are given a 4-character string S consisting of uppercase English letters.
Determine if S consists of exactly two kinds of characters which both appear twice in S.

Constraints

The length of S is 4.

S consists of uppercase English letters.

Input

Input is given from Standard Input in the following format:

S

Output

If S consists of exactly two kinds of characters which both appear twice in S, print Yes; otherwise, print No.

Sample Input 1

ASSA

Sample Output 1

Yes

S consists of A and S which both appear twice in S.

Sample Input 2

STOP

Sample Output 2

No

Sample Input 3

FFEE

Sample Output 3

Yes

Sample Input 4

FREE

Sample Output 4

No



Sample input:
ASSA


Sample output:
Yes

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
moji = str(input())
dictionary = {}
for i in moji:
    if i not in dictionary:
        dictionary[i] = 1
    else:
        dictionary[i] += 1
if len(dictionary) == 2 & dictionary[i] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = sorted(list(input()))
bl = (S[0]==S[1] and S[1]!=S[2] and S[2]==S[3])

print('Yes' if bl == 1 else 'No')

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input())
counter = dict(Counter(S))
cnt_v = list(counter.values())

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

Submission status: Accepted

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

if s.count(S[0]) == 2 and s.count(S[1]) == 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 print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

for e in s_set:
    if s.count(e) != 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = list(input())
if len(set(s)) == 2:
  for i in set(s):
    if s.count(i) != 2:
      break
    else:
      print("Yes")
      exit()
print("No")

Submission status: Accepted

Solution code:
s=list(input())
a=len(set(s))
ans='No'
if a==2:
  b=len([t for t in s if t==s[0]])
  if b==2:
    ans='Yes'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
S = input()
s = set(S)
m = re.findall(S[0],S)
m

if len(s) == 2:
    if len(m) == 2:
        print('Yes')
        exit()
print('No')

Submission status: Accepted

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

Submission status: Accepted

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

main()

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline

def main():
    s = input().strip()
    a = s[0] ; b = None
    c = 1 ; d = 0

    for i in range(1, 4):
        if s[i] == a:
            c += 1

        elif b == None:
            b = s[i]
            d += 1

        elif s[i] == b:
            d += 1

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

main()

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:
from collections import Counter


def main():
    S = input()

    c = Counter(S)

    if len(c) == 2 and list(c.values())[0] == 2 and list(c.values())[1] == 2:
        ans = "Yes"
    else:
        ans = "No"

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
c = Counter(s)
uni = set(s)
if len(uni) == 2 and c[s[0]] == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()

check = True
for i in range(4):
  if S.count(S[i]) != 2:
    check = False
    
print("Yes" if check else "No")

Submission status: Accepted

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


if len(a) == 2 and len(set(list(a.values()))) == 1:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
S = list(input())
d = dict()
for i in S:
  if not i in d:
    d[i] = 1
  else:
    d[i] += 1

res = "Yes"
for i in d.values():
  if i != 2:
    res = "No"
    break
print(res)

Submission status: Accepted

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

Submission status: Accepted

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

if len(S)==2:
    for i, j in S.items():
        if j != 2:
            print('No')
            exit()

    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[2]==s[1]:
  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:
import sys
def input(): return sys.stdin.readline().strip()
def mapint(): return map(int, input().split())
sys.setrecursionlimit(10**9)

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()
s1=sorted(s)
if s.count(s[0])==2 and s.count(s[2])==2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = input()
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:
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353

S = input()

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

Submission status: Accepted

Solution code:
S = input()
is_true = True
for i in range(len(S)):
    if S.count(S[i]) != 2:
        is_true =  False
        break
if is_true:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

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().split()
b = list(s[0][0] + s[0][1] + s[0][2] + s[0][3])
sset = set(b)
if len(sset) == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()
count = 0
same = []
for letter in S:
    if S.count(letter) == 2 and letter not in same:
        same.append(letter)
        count += 1

if count == 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:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# 問題：https://atcoder.jp/contests/abc126/tasks/abc132_a

word = input()
dic_char = {}
for s in word:
    if s in list(dic_char.keys()):
        dic_char[s] += 1
    else:
        dic_char[s] = 1

check = True
for s, count in dic_char.items():
    if count != 2:
        check = False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
# AtCoder Beginner Contest 132
# A - Fifty-Fifty

S=input()

a=S[0]
b=S[1]
c=S[2]
d=S[3]
l=[a,b,c,d]
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 = list(input())
s.sort()
if s.count(s[0]) == 2 and s.count(s[2]) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=list(input())
from collections import Counter
s=Counter(s)

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

Submission status: Accepted

Solution code:
# Written by Shagoto

s = input()
s = s.replace(s[0], "")

if(len(s) == 2):
    s = s.replace(s[0], "")
    if(len(s) == 0):
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
string=input()
list=[]
for i in range(0,len(string)):
         if string[i] not in list:
            list.append(string[i])

         if string[i] not in list:
            list.append(string[i])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=input()
S1=''.join(sorted(S))
S=str(S1)
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:
l = list(input())
l.sort()
a,b,c,d = l
if a == b and b != c and c == d:
  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 and max(d.values()) == 2:
	print('Yes')
else:
	print('No')

Submission status: Accepted

Solution code:

def main():
    s = input()
    s_ = list(set(s))
    if s.count(s_[0]) == 2 and len(s_) == 2:
        print('Yes')
    else:
        print('No')
   

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s=str(input())
s2=[]
a=0
for i in range(4):
    if s[i] in s2:
        a+=1
    else:
        s2.append(s[i])
if a==2 and len(s2)==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
a = input()
l = sorted(list(a))

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

Submission status: Accepted

Solution code:
s=input()

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

Submission status: Accepted

Solution code:
s1,s2,s3,s4 = list(input())
p=0
if s1==s2 and s2== s3 and s3==s4:
    p=1
elif s1==s2:
    if s3!=s4:
        p=1
elif s1==s3:
    if s2!=s4:
        p=1
elif s1==s4:
    if s3!=s2:
        p=1
else:
    p=1
if p==0:
    print("Yes")
elif p==1:
    print("No")

Submission status: Accepted

Solution code:
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    S = SS()

    cnt = collections.Counter(S)
    if list(cnt.values()) == [2, 2]:
        print(('Yes'))
    else:
        print(('No'))

if __name__ == '__main__':
    resolve()

Submission status: Accepted

Solution code:
S = list(input())
w = {}
for s in S:
    if w.get(s) == None:
        w[s] = 1
    else:
        w[s] += 1

if len(w) == 2 and sum(w.values()) == 4:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
u = list(set(list(s)))
if len(u) == 2 and s.count(u[0]) == 2 and s.count(u[1]) == 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")

Submission status: Accepted

Solution code:
S = list(input())
S.sort()

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

Submission status: Accepted

Solution code:
S = input()

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = list(input())

if len(set(s)) != 2:
    ans = 'No'
else:
    if s.count(s[0]) == 2:
        ans = 'Yes'
    else:
        ans = 'No'

print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

cnt = []
for i in range(4):
  cnt.append(s.count(s[i]))
  
if all(n == 2 for n in cnt):
  print('Yes')
else:
  print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = str(input())
s1 = [s[i] for i in range(4)]
from collections import Counter
s2 = Counter(s1).most_common(2)
if s2[0][1] == 2 and s2[1][1] == 2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]


s = input()

temp = sorted(s)

if (temp[0] == temp[1] and temp[2] == temp[3] and temp[1] != temp[2]):
    print("Yes")
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[1]==s[2] and s[2]!=s[3] and s[3]==s[0]:
  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:
S = input()
result = 'Yes'
for i in range(len(S)):
    if S.count(S[i]) != 2:
        result = 'No'
print(result)

Submission status: Accepted

Solution code:
S = input()

letter = []
for i in range(65, 91):
    letter.append(S.count(chr(i)))
letter = sorted(letter, reverse=True)
if letter[0] == 2 and letter[1] == 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:
a=list(input())
b=set(a)
count=0
for i in range(4):
  if a[0]==a[i]:
    count+=1
if len(b)==2 and (count==2):
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
t = defaultdict(int)
for i in S:
  t[i] += 1
if len(t.keys()) == 2:
  for i in t.values():
    if i != 2:
      print("No")
      break
  else:
    print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
str = input()
a1 = str[0]
a2 = str[1]
a3 = str[2]
a4 = str[3]

if str.count(a1) == 2 and str.count(a2) == 2 and str.count(a3) == 2 and str.count(a4) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

for v in d.values():
    if v == 2:
        continue
    print('No')
    exit()
else:
    print('Yes')

Submission status: Accepted

Solution code:
s = input()
ans = 'No'
index = s.find(s[0], 1)
if index >= 1:
    s = s.replace(s[0], '')
    if (len(s) == 2):
        if (s[0] == s[1]):
            ans ='Yes'
    
print(ans)

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 Counter

s = input()
counter = Counter(s)
if len(counter.keys()) == 2:
    for key, val in counter.items():
        if val != 2:
            print("No")
            exit()
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()

counter_map = dict()
for i in range(4):
    if s[i] not in counter_map:
        counter_map[s[i]] = 1
    else:
        counter_map[s[i]] += 1

for i in counter_map.values():
    if i == 2:
        pass
    else:
        print("No")
        break
else:
    print("Yes")

Submission status: Accepted

Solution code:
S=input().strip()
h={}
for s in S:
  h[s]=0

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

Submission status: Accepted

Solution code:
S=input()
l=[]
for s in S:
  if not s in l:
    l.append(s)
if len(l) == 2:
  p = 2
  for s in S:
    if l[0] == s:
      p-=1
  if not p:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:
S1 = input()
S2 = list(S1)
S2.sort()

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

Submission status: Accepted

Solution code:
s=input();print('NYoe s'[[s.count(i)==2 for i in s] and len(set(s))==2::2])

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

def main():

    S = input()

    listS = list(S)
    listS.sort()

    ans = 'No'
    
    if listS[0] == listS[1] and listS[2] == listS [3] and listS[1] != listS[2]:
        ans = 'Yes'

    print(ans)


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
v = [0] * 26
for i in range(4):
    v[ord(s[i])-65] += 1
for i in range(26):
    if v[i] == 1 or v[i] == 3 or v[i] == 4:
        print('No')
        exit()
print('Yes')

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 = Counter(input()).values()
print("Yes" if min(s)==max(s) and len(s)==2 else "No")

Submission status: Accepted

Solution code:
# abc132_a.py
# https://atcoder.jp/contests/abc132/tasks/abc132_a

# A - Fifty-Fifty /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# 長さ 4の英大文字からなる文字列 S が与えられます。 
# S がちょうど 2 種類の文字からなり、かつ現れる各文字はちょうど 2回ずつ現れているかどうかを判定してください。

# 制約
#     Sの長さは 4である
#     Sは英大文字からなる

# 入力
# 入力は以下の形式で標準入力から与えられる。
# S

# 出力
# Sがちょうど 2 種類の文字からなり、かつ現れる各文字はちょうど 2回ずつ現れているなら Yes を、そうでないなら No を出力せよ。

# 入力例 1
# ASSA

# 出力例 1
# Yes

# Sは A と S からなり、A と S はそれぞれ 2回ずつ現れます。

# 入力例 2
# STOP

# 出力例 2
# No

# 入力例 3
# FFEE

# 出力例 3
# Yes

# 入力例 4
# FREE

# 出力例 4
# No


global FLAG_LOG
FLAG_LOG = False


def log(value):
    # FLAG_LOG = True
    # FLAG_LOG = False
    if FLAG_LOG:
        print(str(value))


def calculation(lines):
    S = lines[0]
    # N = int(lines[0])
    # X, A = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[2].split()))
    # values = list()
    # for i in range(6):
    #     values.append(int(lines[i]))
    # valueses = list()
    # for i in range(M):
    #     valueses.append(list(map(int, lines[i+1].split())))

    values = list()
    for i in range(4):
        values.append(S[i])

    values.sort()

    result = 'Yes'
    if values[0] != values[1]:
        result = 'No'
    if values[1] == values[2]:
        result = 'No'
    if values[2] != values[3]:
        result = 'No'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['ASSA']
        lines_export = ['Yes']
    if pattern == 2:
        lines_input = ['STOP']
        lines_export = ['No']
    if pattern == 3:
        lines_input = ['FFEE']
        lines_export = ['Yes']
    if pattern == 4:
        lines_input = ['FREE']
        lines_export = ['No']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    global FLAG_LOG
    if len(args) == 1:
        mode = 0
        FLAG_LOG = False
    else:
        mode = int(args[1])
        FLAG_LOG = True
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
sd = s[::-1]
ans = 'No'
if len(set(s)) == 2:
    c = 0
    for i in range(4):
        if s[i] == sd[i]:
            c += 1
    if c%2 == 0:
        ans = 'Yes'
print(ans)

Submission status: Accepted

Solution code:
ma = lambda :map(int,input().split())
ni = lambda:int(input())
yn = lambda fl:print("Yes") if fl else print("No")
import collections
import math
import itertools
import heapq as hq

s = input()
co = collections.Counter(list(s))
f =True
if len(co) ==2:
    for it,cnt in co.items():
        if cnt!=2:
            f=False
else:f=False
yn(f)

Submission status: Accepted

Solution code:
S=input()
T=list(S)
U=list(set(T))
b=[0]*2
if len(U)==2:
  for x in range(4):
    if U[0]==S[x]:
      b[0]+=1
    elif U[1]==S[x]:
      b[1]+=1
  if b[0]==2 and b[1]==2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

Solution code:

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:
from collections import Counter
S = input()
ans = []
for i in range(4):
    ans.append(S[i])
ans = Counter(ans)
if len(ans) == 2 and ans[S[0]] == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

s=input()

c = Counter(list(s))

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
group = set(S)
count = 0
if len(group) == 2:
    for _ in S:
        if _ == list(group)[0]:
            count += 1

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-

s = input()
cnt = {l:0 for l in set(s)}
if len(cnt) != 2:
    print('No')
    exit(0)

for l in s:
    cnt[l] += 1
    if cnt[l] > 2:
        print('No')
        exit(0)

print('Yes')

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

def pj(cond):
  print({True: "Yes", False:"No"}[cond])

d = {}
for c in S:
  if c in d:
    d[c] += 1
  else:
    d[c] = 1
if len(d.keys()) != 2:
  pj(False)
  exit(0)
if not all(i == 2 for i in d.values()):
  pj(False)
  exit(0)
pj(True)

Submission status: Accepted

Solution code:
from collections import Counter
S = input()
cnt = Counter(list(S))
print('Yes' if list(cnt.values()) == [2, 2] else 'No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import re
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
import functools
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
cnt = 0
ans = 0
inf = float("inf")

s =s()
a = Counter(s)
if len(a)==2:
    for i in a.values():
        if i==2:
            pass
        else:
            print("No")
            sys.exit()
else:
    print("No")
    sys.exit()

print("Yes")

Submission status: Accepted

Solution code:
import collections
S=input()
s=collections.Counter(S)
S=list(set(S))
if len(S)!=2:
    print("No")
else:
    for i in S:
        if s[i]==2:
            pass
        else:
            print("No")
            break
    else:
        print("Yes")

Submission status: Accepted

Solution code:
I = input()
S = []
for i in range(4):
  S.append(I[i])

import collections
s = collections.Counter(S)

if s.most_common()[0][1] == 2 and s.most_common()[1][1] == 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')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
x = 0
for i in range(len(S)):
    if S.count(S[i]) == 2:
        x += 1

if x == 4:
    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")
else:
    for k, v in c.items():
        if v != 2:
            print("No")
            break
    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()
x = list(set(s))
if len(x) == 2:
  if s.count(x[0])==2 and s.count(x[1])==2:
    print("Yes")
  else:
    print("No")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
dic = {}
flag = 0

for i in range(4):
    if S[i] in dic:
        dic[S[i]] += 1
    else:
        dic[S[i]] = 1

for v in dic.values():
    if v != 2:
        flag += 1

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