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()
t=list(set(s))
if len(t)==2:
  cnt1=0
  cnt2=0
  for i in s:
    if i==t[0]:
      cnt1+=1
      
    elif i==t[1]:
      cnt2+=1
      
  if cnt1==2 and cnt2==2:
    print('Yes')
    exit()
    
print('No')

Submission status: Accepted

Solution code:
S=input();s=set(S);print('NYoe s'[len(s)==2 and S.count(list(s)[0])==2::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = list(input())

S.sort()
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()
print("Yes" if len(set(s)) == 2 else "No")

Submission status: Accepted

Solution code:
s=input()
print("Yes" if len(set(s))==2 else "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[2] else "No")
    
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

input = lambda: sys.stdin.readline().rstrip()


def solve():
    S = input()
    d = dict()
    for s in S:
        if s in d:
            d[s] += 1
        else:
            d[s] = 1

    ans = 'Yes'
    if len(d) == 2:
        for k, v in d.items():
            if v != 2:
                ans = 'No'
    else:
        ans = 'No'

    print(ans)


if __name__ == '__main__':
    solve()

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 = list(input())
import collections
c = collections.Counter(s)
ans = 1
for i in range(4):
    if c[s[i]] != 2:
        ans = 0
print(["No","Yes"][ans])

Submission status: Accepted

Solution code:
S = input()

import collections

S_list = list(S)
c = collections.Counter(S_list)

if min(c.values()) == 2 and len(c.keys()) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
judge = True
if S[0] == S[1]:#AA00
  if S[1] == S[2]:#AAA0
    judge = False
  else:#AAB0
    if S[2] != S[3]:#AABC
      judge = False
    elif S[0] == S[3]:#AABA
      judge = False
else:#AB00
  if S[1] != S[2]:#ABC0 or ABA0
    if S[0] != S[2]:#ABC0
      judge = False
    else:
      if S[1] != S[3]:#ABAC
        judge = False
  else:#ABB0
    if S[0] != S[3]:#ABBC
      judge = False
if judge:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = input()

if s[0] == s[1] and s[1] == s[2]:
    print('No')
    exit()
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:
def main():
    S = list(input())
    if len(set(S)) == 2:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import collections

s = input()
c = collections.Counter(s)
v = list(c.values())
if len(c.keys())==2 and v[0]==2 and v[1]==2:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections
cc = collections.Counter(raw_input())
print 'Yes' if len(cc) == 2 and cc.values() ==[2,2] else 'No'

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

if len(set(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]:
  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()
t = sorted(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()

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

lis = []
for i in s:
    lis.append(i)
    
tmp = list(set(lis))

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

Submission status: Accepted

Solution code:
from sys import stdin, setrecursionlimit


def main():
    input = stdin.buffer.readline
    s = list(input()[:-1].decode())
    s.sort()
    if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
        print('Yes')
    else:
        print('No')


if __name__ == "__main__":
    setrecursionlimit(10000)
    main()

Submission status: Accepted

Solution code:
def main():
    S = input()
    for i in S:
        if S.count(i) != 2:
            return False
    return True
if main():
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(int)
s = input()
for i in range(len(s)):
  d[s[i]] += 1
d = dict(d)
values = set(list(d.values()))
if len(d) == 2 and len(values) == 1 and list(values)[0] == 2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
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 collections import Counter
import sys
input = sys.stdin.readline
s =list(input().strip())
co =Counter(s)
ans =list(co.values())
if ans[0] ==2 and ans[1] ==2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

s = input()
c = collections.Counter(s)

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

Submission status: Accepted

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

Submission status: Accepted

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


if __name__ == '__main__':
    main()

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    s=list(input())
    s.sort()
    if len(set(s))==2 and s[0]==s[1] and s[2]==s[3]:
        print('Yes')
    else:
        print('No')
resolve()

Submission status: Accepted

Solution code:
s=input()
t=set(s)
t=list(t)
if len(t)!=2:
  print("No")
  exit(0)
c1,c2=0,0
for ss in s:
  if t[0]==ss:c1+=1
  if t[1]==ss:c2+=1

if c1==2 and c2==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
def main():
  s=input()
  flg=0
  if s.count(s[0])!=2:
    flg=1
  s=s.replace(s[0],'')
  if len(s)>0 and s.count(s[0])!=2:
    flg=1
  if flg==1:
    print('No')
  else:
    print('Yes')  
main()

Submission status: Accepted

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

if len(t) != 2:
    print("No")
else:
    if s.count(t[0]) == s.count(t[1]):
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
from collections import Counter
S = input()
C = Counter(S)
if list(C.values()) == [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[2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
s = Counter(input())
ans = "Yes"
if len(s)==2:
  for x in s.values():
    if x == 2: continue
    else: 
      ans = "No"
      break
else: ans = "No"
print(ans)

Submission status: Accepted

Solution code:
s=input()
kit=[]
for i in range(4):
  if not s[i] in kit:
    kit.append(s[i])
if len(kit)!=2:
  print('No')
else:
  counter=0
  for i in range(4):
    if kit[0]==s[i]:
      counter+=1
  if counter==2:
    print('Yes')
  else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


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


if __name__ == '__main__':
    resolve()

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()
a = s[0]
b = s[1]
c = s[2]
d = s[3]

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

Submission status: Accepted

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

SC = Counter(input())

for key, value in SC.items():
    if value != 2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

if len(set(s)) != 2:
    ans = 'No'

if s.count(s[0]) != 2 or s.count(s[1]) != 2 or s.count(s[2]) != 2:
    ans = 'No'

print(ans)

Submission status: Accepted

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

if len(tmp) == 2:
    for c in tmp:
        if s.count(c) != 2:
            print('No')
            exit()
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#A
s = input()
count_dict = dict()

for word in s:
    count_dict.setdefault(word,0)
    count_dict[word] += 1
    
if len(count_dict) == 2:
    for row in count_dict:
        if count_dict[row] != 2:
            print("No")
            break
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S=sorted(list(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=input()
s1=S[0]
s2=0

if S[0]!=S[1]:
  s2=S[1]
elif S[0]!=S[2]:
  s2=S[2]
else:
  s2=S[3]

if S.count(s1)==2 and S.count(s2)==2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter
c = Counter(input())
for k, v in c.items():
    if v != 2:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
s = sorted(S())
if s[0] == s[1] and s[1] != s[2] and s[2] == s[3]:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
s="".join(sorted(s))
p0(s[0]==s[1] and s[1]!=s[2] and s[2]==s[3])

Submission status: Accepted

Solution code:

def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
s=s0()
d=Counter(s)
p0(list(d.values())==[2,2])

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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


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


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
from collections import Counter
s = input()
c = Counter(s)
if len(c)==2 and all(vi==2 for vi in c.values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s=input()
t=set()
for i in range(len(s)):
    t.add(s[i])
cnt=0
u=t.pop()
t.add(u)
for i in range(len(s)):
    if(u==s[i]):
        cnt+=1
#print(cnt)
if(cnt==2 and len(t)==2):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
char1 = S[0]
char2 = 'none'
count1 = 0
count2 = 0
for i in range(1, 4):
  if S[i] == char1:
    count1 += 1
  elif char2 == 'none':
    char2 = S[i]
  elif S[i] == char2:
    count2 += 1
if count1 == 1 and count2 == 1:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
s = str(input())

t= sorted([s[1], s[0], s[2], s[3]])

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()

a = []
for i in range(0,len(s)):
  c = 0 
  for j in range(0,len(s)):
    if(s[i] == s[j]):
      c += 1
  a.append(c)
#print(a)
if(a[0] == 2 and a[1] == 2 and a[2] == 2 and a[3] == 2):
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
import os
import sys
from collections import defaultdict, Counter
from itertools import product, permutations,combinations, accumulate
from operator import itemgetter
from bisect import bisect_left,bisect
from heapq import heappop,heappush
from fractions import gcd
from math import ceil, floor, sqrt
from copy import deepcopy

def main():
    flag = True
    s = input()
    c = Counter(s)
    values, counts = zip(*c.most_common())
    for i in counts:
        if (i != 2):
            flag = False
    if flag:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
x = list(input())
count = 0
for i in x:
    if x.count(i) == 2:
        count += 1
if count == len(x):
    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]:
    if s[0]!=s[2]:
        print("Yes")
        exit()

print("No")

Submission status: Accepted

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

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a = [i for i in s]
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:
S = input()
for i in S:
  if S.count(i) != 2:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

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

s = list(str(input()))

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

for i in list(set(s)):
    if s.count(i) != 2:
        print("No")
        exit()

print("Yes")

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
s = input()
a = []

for i in s:
    if a.count(i)==0:
        a.append(i)

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

Submission status: Accepted

Solution code:
import collections
import sys

s = input()
n = collections.Counter(s)
t = list(set(s))

if(len(t) == 1):
  print('No')
  sys.exit()

print('Yes' if n[t[0]] == 2 and n[t[1]] == 2 else 'No')

Submission status: Accepted

Solution code:
s = input()
if(s[0]==s[1])and(s[1]==s[2])and(s[2]==s[3]):
    print("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:
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 = sorted(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('Yse')
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()
s_l = set(s)
s_l = list(s_l)
if len(s_l) != 2:
  print("No")
elif s.count(s_l[0]) == 2:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s = sorted(input())

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

Submission status: Accepted

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

Submission status: Accepted

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

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

Submission status: Accepted

Solution code:
print("YNeos"[len(set(input()))!=2::2])

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
num = 0
a= input()
for v in itertools.combinations(a, 2):
    (f, g) = v
    if f == g:
        num += 1
if num == 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()
a=[]
for i in s:
    a.append(i)
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 = 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 = input()

set_s = set(S)

if len(set_s) == 2 and S.count(set_s.pop()) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter

# input
S = input()

Counter_S = Counter(S)

if len(Counter_S.keys()) == 2 and list(set(Counter_S.values())) == [2]:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections

S = list(input())

c = collections.Counter(S)

if all([cs == 2 for cs in c.values()]):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys

def main():
    S = input()
    S_list = [S[i] for i in range(0, 4)]

    S_set = set(S_list)
    if len(S_set) != 2:
        print('No')
        return
    
    for i_set in S_set:
        num = 0
        for i_list in S_list:
            if i_set == i_list:
                num += 1
        
        if num != 2:
            print('No')
            break
    
    else:
        print('Yes')
        
    return


if __name__ == "__main__":
    main()
    sys.exit(0)

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import sys
s = list(input())
if s.count(s[0]) != 2:
	print("No")
	sys.exit()
print("Yes" if len(set(s)) == 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()
s = list(s)
sset = set(s)
if len(sset) == 2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import itertools
import math
import fractions
import functools
import copy

s = input()

dic = {}
for i in range(len(s)):
    current = dic.get(s[i],0)
    dic[s[i]] = current + 1

for key in dic:
    if dic[key] != 2:
        print("No")
        quit()

print("Yes")

Submission status: Accepted

Solution code:

s=list(input())

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
#!/usr/bin/env python3
s = input()
if s[0] == s[1] == s[2] == s[3]:
    print('No')
elif (s[0] == s[1] and s[2] == s[3]) or (s[0] == s[2] and s[1] == s[3]) or (s[0] == s[3] and s[1] == s[2]):
    print("Yes")
else:
    print('No')

Submission status: Accepted

Solution code:
def fifty_fifty(s):

    count = set(s)
    return "Yes" if len(count) == 2 and s.count(list(count)[0]) == 2 and s.count(list(count)[1]) == 2 else "No"
def main():
    s = list(str(input()))
    print(fifty_fifty(s))

if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
import sys
import math
import bisect

def main():
    d = dict()
    s = input()
    for c in list(s):
        if c not in d:
            d[c] = 0
        d[c] += 1
    ans = True
    if len(s) != 4:
        ans = False
    if len(d) != 2:
        ans = False
    for k in d:
        if d[k] != 2:
            ans = False
    if ans:
        print('Yes')
    else:
        print('No')
    
if __name__ == "__main__":
    main()

Submission status: Accepted

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

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

Submission status: Accepted

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

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

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

S = inputS()
s = set(S)

if len(s) == 2:
  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[2]==S[1]):
    print("Yes")
    exit()
    
print("No")

Submission status: Accepted

Solution code:
S=input()
cnt=[0 for _ in range(26)]
for c in S:
  cnt[ord(c)-ord('A')]+=1

  ans="Yes"
for x in cnt:
  if(x==0 or x==2):
    continue;
  else:
    ans="No"

print(ans)