Problem:


Score : 300 points

Problem Statement

You are given strings S and T consisting of lowercase English letters.

You can perform the following operation on S any number of times:

Operation: Choose two distinct lowercase English letters c_1 and c_2, then replace every occurrence of c_1 with c_2, and every occurrence of c_2 with c_1.

Determine if S and T can be made equal by performing the operation zero or more times.

Constraints

1 \leq |S| \leq 2 \times 10^5

|S| = |T|

S and T consists of lowercase English letters.

Input

Input is given from Standard Input in the following format:

S
T

Output

If S and T can be made equal, print Yes; otherwise, print No.

Sample Input 1

azzel
apple

Sample Output 1

Yes

azzel can be changed to apple, as follows:

Choose e as c_1 and l as c_2. azzel becomes azzle.

Choose z as c_1 and p as c_2. azzle becomes apple.

Sample Input 2

chokudai
redcoder

Sample Output 2

No

No sequences of operation can change chokudai to redcoder.

Sample Input 3

abcdefghijklmnopqrstuvwxyz
ibyhqfrekavclxjstdwgpzmonu

Sample Output 3

Yes



Sample input:
azzel
apple


Sample output:
Yes

Submission status: Accepted

Solution code:
s=input()
t=input()
n=len(s)
A='abcdefghijklmnopqrstuvwxyz'
i=0
while A:
	if s==t:
		print('Yes')
		exit()
	if i==n:
		print('No')
		exit()
	if s[i]!=t[i]:
		if s[i] in A and t[i] in A:
			s=s.replace(s[i],'X').replace(t[i],s[i]).replace('X',t[i])
			A=A.replace(s[i],'').replace(t[i],'')
	i+=1
print('No')

Submission status: Accepted

Solution code:
import collections
s=input()
t=input()
cnt1=1
cnt2=1
lst1=[]
lst2=[]
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    cnt1+=1
  else:
    lst1.append(cnt1)
for j in range(len(t)-1):
  if t[j]==t[j+1]:
    cnt2+=1
  else:
    lst2.append(cnt2)
S=collections.Counter(s)
T=collections.Counter(t)
S_=list(S.values())
T_=list(T.values())
S_.sort()
T_.sort()
if S_==T_ and lst1==lst2:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
def solve():
    s = input()
    t = input()
    d = dict()
    for sc, tc in zip(s, t):
        if d.get(sc, None) is None:
            d[sc] = tc
        else:
            if d[sc] != tc:
                return False

    d = {value: key for key, value in d.items()}
    for sc, tc in zip(s, t):
        if d.get(tc, None) is None:
            d[tc] = sc
        else:
            if d[tc] != sc:
                return False
    return True


if __name__ == '__main__':
    print('Yes' if solve() else 'No')

Submission status: Accepted

Solution code:
# 2019-11-10 15:45:20(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    S, T = sys.stdin.read().split()

    convert = dict()
    
    flag = True
    for s, t in zip(S, T):
        if s in convert and convert[s] != t:
            flag = False
            break
        convert[s] = t

    # ここまでで対応表が完成
    # あとは異なる文字が同じ文字に変換されていないか確認
    after = convert.values()
    if len(after) != len(set(after)):
        flag = False
    

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

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
sdic = {}
tdic = {}
S = [0] * len(s)
T = [0] * len(t)
for i, char in enumerate(s):
  if char not in sdic.keys():
    sdic[char] = len(sdic.keys())
  S[i] = sdic[char]
for i, char in enumerate(t):
  if char not in tdic.keys():
    tdic[char] = len(tdic.keys())
  T[i] = tdic[char]
if S == T:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
from sys import stdin
import fractions

s = stdin.readline().rstrip()
t = stdin.readline().rstrip()

li = []
for i in range(len(s)):
    li.append((s[i],t[i]))
li.sort()

for i in range(len(li)-1):
    if li[i][0] == li[i+1][0]:
        if li[i][1] != li[i+1][1]:
            print("No")
            exit()

li.sort(key=lambda x:(x[1]))

for i in range(len(li)-1):
    if li[i][0] != li[i+1][0]:
        if li[i][1] == li[i+1][1]:
            print("No")
            exit()

print("Yes")

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
ma = dict()
yes = True
for i in range(len(S)):
    if S[i] not in ma:
        ma[S[i]] = T[i]
    else:
        if ma[S[i]] != T[i]:
            yes = False
            break
ma.clear()
for i in range(len(S)):
    if T[i] not in ma:
        ma[T[i]] = S[i]
    else:
        if ma[T[i]] != S[i]:
            yes = False
            break
            
if yes:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict

S=input()
T=input()
L=len(S)

dds=defaultdict(int)
ddt=defaultdict(int)

for i in range(L):
    s=S[i]
    t=T[i]
    if dds[s]==0:
        dds[s]=t
    else:
        if dds[s]!=t:
            print("No")
            exit()
    if ddt[t]==0:
        ddt[t]=s
    else:
        if ddt[t]!=s:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
S = input()
T = input()
alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
j = 0

for i in range(len(S)):
    if S[i].islower() and T[i].islower():
        S = S.replace(S[i], alphabet[j])
        T = T.replace(T[i], alphabet[j])
        j += 1
    elif S[i].isupper() and T[i].isupper():
        pass
    else:
        break

if S == T:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
abc = "abcdefghijklmnopqrstuvwxyz"

for i in range(len(abc)):
	a = 0
	for j in range(len(s)):
		if abc[i] == s[j]:
			if a == 0:
				st = t[j]
				a = 1
			else:
				if t[j] != st:
					print("No")
					exit(0)
	a = 0
	for j in range(len(t)):
		if abc[i] == t[j]:
			if a == 0:
				st = s[j]
				a = 1
			else:
				if s[j] != st:
					print("No")
					exit(0)
print("Yes")

Submission status: Accepted

Solution code:
import string

S = str(input())
T = str(input())

S_l = [[] for _ in range(26)]
T_l = [[] for _ in range(26)]
alpha = string.ascii_lowercase

for n in range(len(S)):
    for m in range(26):
        if S[n] == alpha[m]:
            S_l[m].append(n)

for n in range(len(T)):
    for m in range(26):
        if T[n] == alpha[m]:
            T_l[m].append(n)

for i in range(25, -1, -1):
    if S_l[i] == T_l[i] and S_l[i] !=0:
        del S_l[i]
        del T_l[i]

S_l = sorted(S_l)
T_l = sorted(T_l)

if S_l == T_l:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter as C
s,t = input(),input()
print('No') if C(C(s).values()) != C(C(t).values()) else print('Yes')

Submission status: Accepted

Solution code:
S = input()
T = input()

x = {}
for s in S:
    if s in x:
        x[s] += 1
    else:
        x[s] = 1

y = {}
for t in T:
    if t in y:
        y[t] += 1
    else:
        y[t] = 1

x2 = list(x.values())
x2.sort()
y2 = list(y.values())
y2.sort()


if len(x2) != len(y2):
    print("No")
else:
    for i in range(len(x2)):
        if x2[i] != y2[i]:
            print("No")
            break
    else:
        print("Yes")

Submission status: Accepted

Solution code:
s, t = input(), input()
ls, lt = [ [s[0], {0}] ], [ [t[0], {0}] ]

for i in range(len(s)-1):
  if s[i] != s[i+1]:
    b = True
    for j in range(len(ls)):
      if s[i+1] in ls[j][0]:
        ls[j][1].add(i+1)
        b = False
    if b:
      ls.append( [s[i+1], {i+1}] )
      
for i in range(len(t)-1):
  if t[i] != t[i+1]:
    b = True
    for j in range(len(lt)):
      if t[i+1] in lt[j][0]:
        lt[j][1].add(i+1)
        b = False
    if b:
      lt.append( [t[i+1], {i+1}] )

if len(ls) != len(lt):
  print("No")
else:
  for i in range(len(ls)):
    if ls[i][1] != lt[i][1]:
      print("No")
      exit()
  print("Yes")

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
T = input()

dic_S = defaultdict(int)
dic_T = defaultdict(int)

for s, t in zip(S, T):
    dic_S[s] += 1
    dic_T[t] += 1

S_count = list(dic_S.values())
T_count = list(dic_T.values())

S_count.sort()
T_count.sort()

if S_count == T_count:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S, T = input(), input()
cnt1, cnt2 = [0] * 30, [0] * 30
for s in S:
    cnt1[ord(s)-97] += 1
for t in T:
    cnt2[ord(t)-97] += 1
if all(c1==c2 for c1, c2 in zip(sorted(cnt1), sorted(cnt2))):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

r="ABCDEFGHIJKLMNOPQRSTUVWXYZ"

j=0
for i in range(len(s)):
  if s[i].islower():
    s = s.replace(s[i],r[j])
    j += 1

j=0
for i in range(len(t)):
  if t[i].islower():
    t = t.replace(t[i],r[j])
    j += 1

print('Yes' if s==t else 'No')

Submission status: Accepted

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

s_dict = {}
t_dict = {}

for i in range(len(s)):
    if s[i] not in s_dict:
        s_dict[s[i]] = t[i]
        
    elif s_dict[s[i]] != t[i]:
        print('No')
        exit()

    if t[i] not in t_dict:
        t_dict[t[i]] = s[i]
    elif t_dict[t[i]] != s[i]:
        print('No')
        exit()


print('Yes')

Submission status: Accepted

Solution code:
S = input()
T = input()
 
convert = dict()
 
answer = 'Yes'

for s, t in zip(S, T):
    #同じsに違うt
    if s in convert and convert[s] != t:
        answer = 'No'
        break
    #同じsに同じt
    else:
        convert[s] = t
 
after = convert.values()
#tの要素の総数とtの要素の種類を比べて、相違がある
#=sが全て相違するのに対しtの値が等しいペアがある=同じtに対して違うsが存在する
if len(after) != len(set(after)):
    answer = 'No'
 
print(answer)

Submission status: Accepted

Solution code:
S = input()
T = input()

ans = "Yes"
 
for i in range(0,len(S)):
  for j in range(0,i):
    if S[j] == S[i]:
      if T[i] != T[j]:
        ans = "No"
        break
      break
    if T[j] == T[i]:
      if S[j] != S[i]:
        ans = "No"
        break
      break
print(ans)

Submission status: Accepted

Solution code:
import collections
s = input()
t = input()

print("Yes" if sorted(collections.Counter(s).values()) == sorted(collections.Counter(t).values()) else "No")

Submission status: Accepted

Solution code:
S = input().strip()
T = input().strip()

s_dict = {}
for i in range(len(S)):
    if not S[i] in s_dict:
        s_dict[S[i]] = T[i]

    elif s_dict[S[i]] != T[i]:
        print('No')
        exit()

t_dict = {}
for i in range(len(T)):
    if not T[i] in t_dict:
        t_dict[T[i]] = S[i]

    elif t_dict[T[i]] != S[i]:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter
s=input()
t=input()
c1=Counter(s)
c2=Counter(t)
if sorted(c1.values())==sorted(c2.values()):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
def main():
    s=input()
    t=input()
    n=len(s)
    zumi=[]
    for i in range(n):
        ss= s[i]
        st= t[i]
        if ss != st:
            if st in zumi or ss in zumi:
                return "No"
            zumi.append(st)
            s=s.translate(str.maketrans({ss:st,st:ss}))
    return "Yes"

print(main())

Submission status: Accepted

Solution code:
S=input()
T=input()

r1=[set() for _ in range(26)]
r2=[set() for _ in range(26)]
for s,t in zip(S,T):
  r1[ord(t)-ord('a')].add(s)
  r2[ord(s)-ord('a')].add(t)
  
flag=True
for ind,outd in zip(r1,r2):
  n_in=len(ind)
  n_out=len(outd)
  if n_in>=2 or n_out>=2:
    flag=False
    break
print('Yes') if flag else print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
T = input()

first_appear_s = dict()
first_appear_t = dict()

for i in range(len(S)) :
    s = S[i]
    t = T[i]
    if not s in first_appear_s :
        first_appear_s[s] = i
    if not t in first_appear_t :
        first_appear_t[t] = i
        
    if first_appear_s[s] != first_appear_t[t] :
        print('No')
        break
else :
    print('Yes')

Submission status: Accepted

Solution code:
# ABC120 C - String Transformation
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

S = si()
T = si()
 
dict_S = {}
dict_T = {}
 
for i in range(len(S)):
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict_S[S[i]] = T[i]
        
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    else:
        dict_T[T[i]] = S[i]
        
print("Yes")

Submission status: Accepted

Solution code:
def main():
  S = str(input())
  s = list(S)
  T = str(input())
  t = list(T)
  alpha2num = lambda c: ord(c) - ord('a')
  r = [-1]*26
  r_ = [-1]*26
  ans = "Yes"
  for i in range(len(s)):
    if r[alpha2num(s[i])] >= 0:
      if r[alpha2num(s[i])] == alpha2num(t[i]):
        continue
      else:
        ans = "No"
        break
    else:
      r[alpha2num(s[i])] = alpha2num(t[i])
    if r_[alpha2num(t[i])] >= 0:
      if r_[alpha2num(t[i])] == alpha2num(s[i]):
        continue
      else:
        ans = "No"
        break
    else:
      r_[alpha2num(t[i])] = alpha2num(s[i])
  print(ans)

if __name__ == "__main__":
  main()

Submission status: Accepted

Solution code:
S = input()
T = input()

dict_S = {}
dict_T = {}

for i in range(len(S)):
    if S[i] in dict_S:
        if dict_S[S[i]] != T[i]:
            print("No")
            exit()
    else:
        dict_S[S[i]] = T[i]
        
    if T[i] in dict_T:
        if dict_T[T[i]] != S[i]:
            print("No")
            exit()
    else:
        dict_T[T[i]] = S[i]
        
print("Yes")

Submission status: Accepted

Solution code:
w1 = input()
w2 = input()

s1 = list(w1)
s2 = list(w2)
s1.sort()
s2.sort()

c1 = 0
t1 = ""
a1 = []
for i1 in range(len(s1)):
    if s1[i1] != t1:
        a1.append(c1)
        t1 = s1[i1]
        c1 = 1
        if i1 == len(s1) - 1:
            a1.append(c1)
    else:
        c1 += 1
        if i1 == len(s1) - 1:
            a1.append(c1)

c1 = 0
t1 = ""
a2 = []
for i2 in range(len(s2)):
    if s2[i2] != t1:
        a2.append(c1)
        t1 = s2[i2]
        c1 = 1
        if i2 == len(s2) - 1:
            a2.append(c1)
    else:
        c1 += 1
        if i2 == len(s2) - 1:
            a2.append(c1)

a1.sort()
a2.sort()

if a1 == a2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter
s=sorted(Counter(input()).values())
t=sorted(Counter(input()).values())
print('Yes' if s==t else 'No')

Submission status: Accepted

Solution code:
S = input()
T = input()
SD = dict()
TD = dict()

valid = True
for s, t in zip(S, T):
    if s not in SD.keys():
        SD[s] = t
    else:
        if SD[s] != t:
            valid = False
            break
    if t not in TD.keys():
        TD[t] = s
    else:
        if TD[t] != s:
            valid = False
            break

print('Yes' if valid else 'No')

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
t = input()
n = len(s)
sd = defaultdict(lambda: -1)
td = defaultdict(lambda: -1)
u, v = [0] * len(s), [0] * len(t)

for i in range(n):
    sc = s[i]
    if sd[sc] != -1:
        u[i] = sd[sc]
    else: 
        u[i] = i
        sd[sc] = i
    
    tc = t[i]
    if td[tc] != -1:
        v[i] = td[tc]
    else: 
        v[i] = i
        td[tc] = i
    
    if u[i] != v[i]:
        print("No")
        break
else: print("Yes")

Submission status: Accepted

Solution code:
S = input()
T = input()
d = dict()
d2 = dict()
check1 = dict()
check2 = dict()
for i in "abcdefghijklmnopqrstuvwxyz":
    check1[i] = False
    check2[i] = False
for i in range(len(S)):
    if check2[T[i]]:
        if d2[T[i]] != S[i]:print("No");exit()
    if not check1[S[i]]:
        check1[S[i]] = True
        d[S[i]] = T[i]
        check2[T[i]] = True
        d2[T[i]] = S[i]
    else:
        if d[S[i]] != T[i]:print("No");exit()
print("Yes")

Submission status: Accepted

Solution code:
S=input()
T=input()

dicS={};dicT={}

f=True

for i in range(len(S)):
    c=S[i];d=T[i]
    
    if c in dicS and d!=dicS[c]:
        f=False
        break
    elif c not in dicS:
        dicS[c]=d
    
    if d in dicT and c!=dicT[d]:
        f=False
        break
    elif d not in dicT:
        dicT[d]=c 

print('Yes' if f else 'No')

Submission status: Accepted

Solution code:
S, T = input(), input()

convert = dict()

answer = 'Yes'
for s, t in zip(S, T):
    if s in convert and convert[s] != t:
        answer = 'No'
        break
    else:
        convert[s] = t

after = convert.values()
if len(after) != len(set(after)):
    answer = 'No'

print(answer)

Submission status: Accepted

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

answer = 'Yes'
for s in sorted(map(chr,range(97,123))):
    if S.count(s) >= 2:
        l1 = [i for i, x in enumerate(S) if x == s]
        for x in l1:
            if T[x] != T[l1[0]]:
                answer = 'No'
    if T.count(s) >= 2:
        l2 = [i for i, x in enumerate(T) if x == s]
        for x in l2:
            if S[x] != S[l2[0]]:
                answer = 'No'
print(answer)

Submission status: Accepted

Solution code:
from collections import Counter
def main():
    s = sorted(Counter(input()).values())
    t = sorted(Counter(input()).values())
    print('Yes' if t == s else 'No')
if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:

flag1=True
flag2=True

for i in range(2):
    if i==0:
        a=input()
    else:
        b=input()

n=len(a)
uselist=[0]*n
for i in range(n):
        uselist[i]=(a[i],b[i])

  
sets=set(uselist)
dicti={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}
dicti2={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}

for i in sets:
        dicti[i[0]]+=1
        dicti2[i[1]]+=1
for i in dicti.values():
    if i>=2:
        flag1=False
        
        
for i in dicti2.values():
    if i>=2:
        flag2=False
        

if flag1 and flag2:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
from bisect import bisect_left, bisect_right
import random
from itertools import permutations, accumulate, combinations
import sys
import string



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7



s = S()
t = S()
s_dict = defaultdict(int)
t_dict = defaultdict(int)
for i in range(len(s)):
    if s_dict[s[i]] and s_dict[s[i]] != t[i]:
        print('No')
        break
    else:
        s_dict[s[i]] = t[i]
    if t_dict[t[i]] and t_dict[t[i]] != s[i]:
        print('No')
        break
    else:
        t_dict[t[i]] = s[i]
else:
    print('Yes')

Submission status: Accepted

Solution code:
s=input()
t=input()
n=len(s)
word="abcdefghijklmnopqrstuvwxyz"
data_s=[[] for i in range(26)]
data_t=[[] for i in range(26)]
for i in range(26):
    a=word[i]
    for j in range(n):
        if s[j]==a:
            data_s[i].append(j)
        if t[j]==a:
            data_t[i].append(j)
data_s.sort()
data_t.sort()
if data_s==data_t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
t = input()
S = defaultdict(list)
T = defaultdict(list)
trans = defaultdict(int)
for i in range(len(t)):
  c = t[i]
  m = s[i]
  if T[c]==[]:
    T[c] = i
  if S[m]==[]:
    S[m] = i
  if T[c]!= S[m]:
    print('No')
    break
else:
  print('Yes')

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()

    r = [[-1] * 26 for _ in range(2)]

    bl = True
    for se, te in zip(s, t):
        si = ord(se) - ord("a")
        ti = ord(te) - ord("a")

        if r[0][si] < 0:
            r[0][si] = ti
        else:
            if r[0][si] != ti:
                bl = False
                break

        if r[1][ti] < 0:
            r[1][ti] = si
        else:
            if r[1][ti] != si:
                bl = False
                break

    print("Yes" if bl else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()

    ind = [set() for _ in range(26)]
    outd = [set() for _ in range(26)]

    for se, te in zip(s, t):
        si = ord(se) - ord("a")
        ti = ord(te) - ord("a")
        outd[si].add(te)
        ind[ti].add(se)

    bl = True
    for e_ind, e_outd in zip(ind, outd):
        l_ind = len(e_ind)
        l_outd = len(e_outd)
        if l_ind >= 2 or l_outd >= 2:
            bl = False
            break

    print("Yes" if bl else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
# coding: utf-8
# Your code here!
S=list(input())
T=list(input())

dict1={}
dict2={}

for i in range(len(S)):
    if S[i] in dict1:
        if dict1[S[i]]==T[i]:
            pass
        else:
            print("No")
            exit()
    else:
        dict1[S[i]]=T[i]
    
    if T[i] in dict2:
        if dict2[T[i]]==S[i]:
            pass
        else:
            print("No")
            exit()
    else:
        dict2[T[i]]=S[i]
        
print("Yes")
#てきとー

Submission status: Accepted

Solution code:
import collections

S=input()
T=input()

def SameGroup(word):
    CW=collections.Counter(word)
    CWval,CWcou=zip(*CW.most_common())
    Count=[]
    for i in range(len(CWval)):
        if CWcou[i]==1:
            break
        else:
            Count.append([])
            for j in range(len(word)):
                if word[j]==CWval[i]:
                    Count[-1].append(j)
    return(Count)

print('YNeos'[SameGroup(S)!=SameGroup(T)::2])

Submission status: Accepted

Solution code:
S = input()
T = input()
from collections import defaultdict
ds = defaultdict(int)
dt = defaultdict(int)
for i in range(len(S)):
    ds[S[i]] += 1
    dt[T[i]] += 1
ds = list(ds.values())
dt = list(dt.values())
ds.sort()
dt.sort()
for e1,e2 in zip(ds,dt):
    if e1 != e2:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    s = collections.Counter(str(input().rstrip('\n'))).most_common()
    t = collections.Counter(str(input().rstrip('\n'))).most_common()
    if len(s) != len(t):
        print("No")
    else:
        for i in range(len(s)):
            if s[i][1] != t[i][1]:
                print("No")
                exit()
        print("Yes")


if __name__ == '__main__':
    slove()

Submission status: Accepted

Solution code:
s = input()
t = input()
import collections
import sys
c_s = collections.Counter(s)
c_t = collections.Counter(t)
l_s = c_s.most_common()
l_t = c_t.most_common()
for i in range(len(l_s)):
    if l_t[i][1] != l_s[i][1]:
        print("No")
        sys.exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
s=sorted(Counter(input()).values())
t=sorted(Counter(input()).values())
print("Yes" if t==s else "No")

Submission status: Accepted

Solution code:
def count1(s):
    L = len(s)
    abc=[]
    s0 = s[0]
    abc.append(s[0])
    ans1 = ""
    ans2=""
    cnt = 1
    cnt2=0
    a0=0
    for i in range(1, L):
        if s0 == s[i]:
            cnt += 1
        else:
            ans1 = ans1 + str(cnt)
            ans2=ans2+str(a0)
            cnt = 1
            s0=s[i]
            if s[i] in abc:
                a0=abc.index(s[i])
            else:
                abc.append(s[i])
                cnt2+=1
                a0=cnt2

    ans1 = ans1 + str(cnt)
    ans2 = ans2 + str(a0)

    return ans1,ans2


S = input()
T = input()

if len(S)==1:
    print("Yes")
    exit()

Sx,Sy = count1(S)
Tx,Ty = count1(T)

if Sx == Tx and Sy==Ty:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

S_list=list(set(list(S)))
T_list=list(set(list(T )))
print("Yes" if sorted([S.count(i) for i in S_list])==sorted([T.count(i) for i in T_list]) else "No")

Submission status: Accepted

Solution code:

s=input()
t=input()
n=len(s)
dic={}
se=set()
ans='Yes'
for i in range(n):
    if s[i] not in dic:
        dic[s[i]]=t[i]
        if t[i] in se:
            ans='No'
        se.add(t[i])
    else:
        if dic[s[i]]!=t[i]:
            ans='No'
print(ans)

Submission status: Accepted

Solution code:
S = input()
T = input()

N = len(S)
Slist = {}
Tlist = {}
for i in range(N):
    if S[i] in Slist:
        Slist[S[i]] += 1
    else:
        Slist[S[i]] = 1
    if T[i] in Tlist:
        Tlist[T[i]] += 1
    else:
        Tlist[T[i]] = 1

M = len(Slist)
L = len(Tlist)
if M == L:
    skey = []
    tkey = []
    svalue = []
    tvalue = []
    for k, v in Slist.items():
        skey.append(k)
        svalue.append(v)
    skey.sort()
    svalue.sort()
    
    for k, v in Tlist.items():
        tkey.append(k)
        tvalue.append(v)
    tkey.sort()
    tvalue.sort()
    
    if svalue == tvalue:
        print('Yes')
    else:
        print('No')
        
else:
    print('No')

Submission status: Accepted

Solution code:

from collections import Counter as cs

S = input()
T = input()

cS = cs(S)
cT = cs(T)

lS = [0] * 26
lT = [0] * 26

az = "abcdefghijklmnopqrstuvwxyz"

for i in range(26):
    lS[i] = cS[az[i]]
    lT[i] = cT[az[i]]

lS.sort()
lT.sort()

if lS==lT:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = input()
T = input()
cnt = 0
for i in range(len(S)):
  if cnt > 30:
    break
  if S[i] != T[i]:
    X = S[i]
    S = S.replace(S[i],"X")
    if T[i] in S:
      S = S.replace(T[i],X)
    S = S.replace("X",T[i])
    cnt += 1
print("Yes" if S == T else "No")

Submission status: Accepted

Solution code:
from collections import defaultdict
class CountUp:
    def __init__(self, start=0):
        self.index = start-1

    def __call__(self):
        self.index += 1
        return self.index

S = input()
T = input()
N = len(S)
Sdic = defaultdict(CountUp())
Tdic = defaultdict(CountUp())
for i in range(N):
    s = Sdic[S[i]]
    t = Tdic[T[i]]
    if s != t:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
u=list(int(-1) for i in range(26))
ans=[]

for i in range(len(s)):
    if u[ord(s[i])-97]==-1:
        u[ord(s[i])-97]=ord(t[i])-97
        
    else:
        if u[ord(s[i])-97]!=ord(t[i])-97:
            print('No')
            exit()
  
for i in range(len(u)):
    if u[i]!=-1:
        ans.append(u[i])

if len(set(ans))<len(ans):      
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter as ct

s = input()
t = input()

c_s = ct(s)
c_t = ct(t)

n_s = []
n_t = []

for w in set(s):
    n_s.append(c_s[w])

for w in set(t):
    n_t.append(c_t[w])

b = sorted(n_s) == sorted(n_t)

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

Submission status: Accepted

Solution code:
s = input()
t = input()
s_list = [-1]*26  # index = string of s, number = string of t
t_list = [-1]*26  # index = string of t, number = string of s
# a = 0, z = 25
ans = "Yes"
for i in range(len(s)):
    s_num = ord(s[i]) - 97
    t_num = ord(t[i]) - 97
    if s_list[s_num] < 0:
        s_list[s_num] = t_num
    else:
        if s_list[s_num] != t_num:
            ans = "No"
            break
    if t_list[t_num] < 0:
        t_list[t_num] = s_num
    else:
        if t_list[t_num] != s_num:
            ans = "No"
            break
print(ans)

Submission status: Accepted

Solution code:
s, t = input(), input()
ans = "Yes"
dct = {i:set() for i in t}
for i in range(len(s)): dct[t[i]].add(s[i])
for i in dct.items():
    if len(i[1])>1:ans="No"
dct = {i:set() for i in s}
for i in range(len(s)): dct[s[i]].add(t[i])
for i in dct.items():
    if len(i[1])>1:ans="No"
print(ans)

Submission status: Accepted

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

a={}
b={}

for i in range(len(S)):
  if S[i] in a:
    a[S[i]].append(i)
  else:
    a[S[i]]=[i]
  if T[i] in b:
    b[T[i]].append(i)
  else:
    b[T[i]]=[i]

if sorted(a.values())==sorted(b.values()):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

s_set = list(set(s))
t_set = list(set(t))

s_count = [0] * len(s_set)
t_count = [0] * len(t_set)

for i in range(0,len(s_set)) :
    s_count[i] = s.count(s_set[i])

for j in range(0,len(t_set)) :
    t_count[j] = t.count(t_set[j])

s_count.sort()
t_count.sort()

if s_count == t_count :
    print('Yes')
else :
    print('No')

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
sal=[]
ska=[]
tal=[]
tka=[]
n=len(s)
for i in range(n):
    if s[i] in sal:
        ska[sal.index(s[i])].append(i)
    else:
        sal.append(s[i])
        ska.append([i])
    if t[i] in tal:
        tka[tal.index(t[i])].append(i)
    else:
        tal.append(t[i])
        tka.append([i])
ska.sort()
tka.sort()
if ska==tka:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections, re, itertools, copy

S = input()
T = input()

# 文字リストとcollections.Counterを渡すと、同じ文字が存在するインデックスの集合を返す関数
def same_letter_index_set(A, cA):
    output = []
    for s in cA.keys():
        match_index_list = [m.span() for m in re.finditer(s, A)]
        output.append(list(itertools.chain.from_iterable([m.span() for m in re.finditer(s, A)])))
    return output

# 2重リストを2つ与えると、それらの要素が一致しているかどうかを返す関数
def same_multi_list(A_input,B_input):
    A = copy.deepcopy(A_input)
    B = copy.deepcopy(B_input)
    for i in A:
        try:
            B.remove(i)
        except:
            return False
    if len(B) == 0:
        return True
    else:
        return False

# それぞれの文字列において、同じ文字が存在するインデックスの集合を考える。それらが完全一致すれば置き換え可能
cS = collections.Counter(S)
cT = collections.Counter(T)
print("Yes" if same_multi_list(same_letter_index_set(S, cS), same_letter_index_set(T, cT)) else "No")

Submission status: Accepted

Solution code:
import collections, re, itertools, copy

S = input()
T = input()

# 文字リストとcollections.Counterを渡すと、同じ文字が存在するインデックスの集合を返す関数
def same_letter_index_set(A, cA):
    output = []
    for s in cA.keys():
        match_index_list = [m.span() for m in re.finditer(s, A)]
        output.append(list(itertools.chain.from_iterable([m.span() for m in re.finditer(s, A)])))
    return output

# 2重リストを2つ与えると、それらの要素が一致しているかどうかを関数
def same_multi_list(A_input,B_input):
    A = copy.deepcopy(A_input)
    B = copy.deepcopy(B_input)
    for i in A:
        try:
            B.remove(i)
        except:
            return False
    if len(B) == 0:
        return True
    else:
        return False

# それぞれの文字列において、同じ文字が存在するインデックスの集合を考える。それらが完全一致すれば置き換え可能
cS = collections.Counter(S)
cT = collections.Counter(T)
print("Yes" if same_multi_list(same_letter_index_set(S, cS), same_letter_index_set(T, cT)) else "No")

Submission status: Accepted

Solution code:
from collections import Counter
print("Yes" if sorted(Counter(input()).values())==sorted(Counter(input()).values()) else "No")