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()
    
dt = {}
ds = {}
for s, t in zip(S,T):
    if not t in dt:
        dt[t] = s
    else:
        if dt[t] != s:
            print('No')
            quit()

    if not s in ds:
        ds[s] = t
    else:
        if ds[s] != t:
            print('No')
            quit()
print('Yes')

Submission status: Accepted

Solution code:
def char_range(c1, c2):
    """
    Generates the characters from `c1` to `c2`, inclusive.
    Taken from: https://stackoverflow.com/questions/7001144/range-over-character-in-python
    """
    for c in range(ord(c1), ord(c2)+1):
        yield chr(c)

class Solver(object):
    def __init__(self):
        self.s = input()
        self.t = input()

    def solve(self):
        self.s_to_t = {}
        self.t_to_s = {}
        for c in char_range('a', 'z'):
            self.s_to_t[c] = None
            self.t_to_s[c] = None
        
        for i in range(len(self.s)):
            cs = self.s[i]
            ct = self.t[i]
            if self.s_to_t[cs] is None:
                self.s_to_t[cs] = ct
            if self.t_to_s[ct] is None:
                self.t_to_s[ct] = cs
            if self.s_to_t[cs] != ct:
                print("No")
                return
            if self.t_to_s[ct] != cs:
                print("No")
                return
        print("Yes")


if __name__ == "__main__":
    s = Solver()
    s.solve()

Submission status: Accepted

Solution code:
a = input()
b = input()
k = []
l = []
np=0
nq=0
for i in range(0,len(a)):
    if a[i] not in k:
        k.append(a[i])
        np+=1
    if b[i] not in l:
        l.append(b[i])
        nq+=1
    if i != 0:
        if not (k.index(a[i])==l.index(b[i]) and ((a[i-1]==a[i] and b[i-1] == b[i]) or ( a[i-1] != a[i] and b[i-1]!= b[i]))):
            np*=0
if np == nq:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S=input()
T=input()
d={}
for i in range(len(S)):
    if S[i] not in d:
        d[S[i]]=T[i]
    else:
        if d[S[i]]!=T[i]:
            print('No')
            exit()
d={}
for i in range(len(T)):
    if T[i] not in d:
        d[T[i]]=S[i]
    else:
        if d[T[i]]!=S[i]:
            print('No')
            exit()
print('Yes')

Submission status: Accepted

Solution code:
def judge(S,T):
    d={}
    length=len(S)
    for i in range(length):
        if S[i] not in d:
            d[S[i]]=T[i]
        else:
            if d[S[i]]!=T[i]:
                return "No"
    d={}          
    for i in range(length):
        if T[i] not in d:
            d[T[i]]=S[i]
        else:
            if d[T[i]]!=S[i]:
                return "No"
    return "Yes"
  
print(judge(input(),input()))

Submission status: Accepted

Solution code:
s = input()
t = input()
sl = []
tl = []
for c in "abcdefghijklmnopqrstuvwxyz":
    sl.append(s.count(c))
    tl.append(t.count(c))
if sorted(sl)==sorted(tl):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

from collections import defaultdict

td = defaultdict(set)
sd = defaultdict(set)
for i in range(len(s)):
        td[t[i]].add(s[i])
        sd[s[i]].add(t[i])

for tv, sv in zip(td.values(), sd.values()):
    if (len(tv) > 1) or (len(sv) > 1):
        print("No")
        break
else:
    print('Yes')

Submission status: Accepted

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

cs = collections.Counter(s)
ct = collections.Counter(t)

sv = []
tv = []
for v in cs.values():
    sv.append(v)
for v in ct.values():
    tv.append(v)
    
sv.sort()
tv.sort()
if len(sv) == len(tv):
    for i in range(len(sv)):
        if sv[i] != tv[i]:
            print('No')
            exit()
    else:
        print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
tra = {}
f = True
for i in range(len(s)):
    if s[i] in tra.keys():
        if tra[s[i]] != t[i]:
            f = False
            break
    else:
        if t[i] in tra.values():
            f = False
            break
        else:
            tra[s[i]] = t[i]
print("Yes" if f == True else "No")

Submission status: Accepted

Solution code:
import sys

s = input()
t = input()

# atoz = [chr(i) for i in range(97,97+26)]


for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        s_tmp = s
        s = s.translate(s.maketrans({s[i]:t[i], t[i]:s[i]}))
        if s_tmp[:i] != s[:i]:
            print("No")
            sys.exit()
        else:
            pass


if s == t:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
S = input()
T = input()
n = len(T)
from collections import defaultdict

diff = {}
diff2 = {}
same = set()
for i in range(n):
    if S[i] != T[i]:
        diff[S[i]] = T[i]
        diff2[T[i]] = S[i]
    else:
        same.add(S[i])

for i in range(n):
    if S[i] in diff and diff[S[i]] != T[i]:
        print("No")
        exit(0)
    elif T[i] in diff2 and diff2[T[i]] != S[i]: 
        print("No")
        exit(0)


print("Yes")
exit(0)

Submission status: Accepted

Solution code:
#!/mnt/c/Users/moiki/bash/env/bin/python
S = input()
T = input()
n = len(T)
from collections import defaultdict

diff_s_to_t = {}
diff_t_to_s = {}
same = set()

for i in range(n):
    if S[i] == T[i]:
        same.add(S[i])

for i in range(n):
    if S[i] != T[i] and not S[i] in diff_s_to_t:
        diff_s_to_t[S[i]] = T[i]
        diff_t_to_s[T[i]] = S[i] 

for i in range(n):
    if S[i] != T[i] and  S[i] in diff_s_to_t:
        if diff_s_to_t[S[i]] != T[i]: # atesaki tigau
            print("No")
            exit(0)


for i in range(n):
    if S[i]==T[i] and S[i] in diff_t_to_s: # same and diff
        print("No")
        exit(0)

S,T = T,S
diff_s_to_t = {}
diff_t_to_s = {}
same = set()
for i in range(n):
    if S[i] == T[i]:
        same.add(S[i])

for i in range(n):
    if S[i] != T[i] and not S[i] in diff_s_to_t:
        diff_s_to_t[S[i]] = T[i]
        diff_t_to_s[T[i]] = S[i] 

for i in range(n):
    if S[i] != T[i] and  S[i] in diff_s_to_t:
        if diff_s_to_t[S[i]] != T[i]: # atesaki tigau
            print("No")
            exit(0)


for i in range(n):
    if S[i]==T[i] and S[i] in diff_t_to_s: # same and diff
        print("No")
        exit(0)


print("Yes")
exit(0)

Submission status: Accepted

Solution code:
#abc110c

s=raw_input()
t=raw_input()
if [s.find(i) for i in s] == [t.find(j) for j in t]:
 print 'Yes'
else:
 print 'No'

Submission status: Accepted

Solution code:
def func():
    pass


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

    s_s = set(s)
    t_s = set(t)

    s_c = list()
    t_c = list()

    for si in s_s:
        s_c.append(s.count(si))

    for ti in t_s:
        t_c.append(t.count(ti))

    # print(s_c)
    # print(t_c)
    if sorted(s_c) == sorted(t_c):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
counts = []
countt = []
alphabetlist = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"]
for i in alphabetlist:
    counts.append(s.count(i))
    countt.append(t.count(i))
if sorted(counts) == sorted(countt):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s=input()
t=input()
ss=[]
tt=[]
for i in "abcdefghijklmnopqrstuvwxyz":
    ss.append(s.count(i))
    tt.append(t.count(i))
if sorted(ss)==sorted(tt):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

S.sort()
T.sort()
Sdata = []
Tdata = []

counter = 0
p = S[0]
for i in S:
    if i == p:
        counter += 1
    else:
        Sdata.append(counter)
        counter = 1
        p = i
Sdata.append(counter)

counter = 0
p = T[0]
for i in T:
    if i == p:
        counter += 1
    else:
        Tdata.append(counter)
        counter = 1
        p = i
Tdata.append(counter)

Sdata.sort()
Tdata.sort()

if Sdata == Tdata:
    print 'Yes'
else:
    print 'No'

Submission status: Accepted

Solution code:
S = input()
T = input()
s = []
t = []
for alp in "abcdefghijklmnopqrstuvwxyz":
  s.append(S.count(alp))
  t.append(T.count(alp))
if(sorted(s) == sorted(t)):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

mapping = {}
for i in range(len(s)):
    if s[i] in mapping:
        if mapping[s[i]] == t[i]:
            continue
        else:
            print('No')
            break
    elif t[i] in mapping.values():
        print('No')
        break
    else:
        mapping[s[i]] = t[i]
else:
    print('Yes')

Submission status: Accepted

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

d = {}
flag = True
for i in range(len(s)):
    if s[i] in d.keys():
        if t[i] == d[s[i]]:
            continue
        else:
            flag=False
            break
    elif t[i] in d.values():
        if d.get(s[i]) == t[i]:
            continue
        else:
            flag=False
            break
    else:
        d[s[i]] = t[i]

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

Submission status: Accepted

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

s2t = {}
t2s = {}
ans = 'Yes'
for si, ti in zip(s, t):
    if si not in s2t:
        s2t[si] = ti
    elif s2t[si] != ti:
        ans = 'No'
        break
    if ti not in t2s:
        t2s[ti] = si
    elif t2s[ti] != si:
        ans = 'No'
        break

print(ans)

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
L = []
M = []
al = list('abcdefghijklmnopqrstuvwxyz')

for i in range(len(al)):
    l = []
    for j in range(len(S)):
        if al[i] == S[j]:
            l.append(j)
        else:
            pass
    L.append(l)
i = 0
for i in range(len(al)):
    l = []
    for j in range(len(T)):
        if al[i] == T[j]:
            l.append(j)
        else:
            pass
    M.append(l)
if sorted(L)==sorted(M):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections
S = input()
L = []
M = []
c = collections.Counter(S)
for x in c.items():
    L.append(x[1])
T = input()
c = collections.Counter(T)
for x in c.items():
    M.append(x[1])
if sorted(M) == sorted(L):
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

R={}
R_={}

for a in zip(S,T):
  if a[0] not in R:
    R[a[0]]=a[1]
  else:
    if R[a[0]]!=a[1]:
      print('No')
      break
      
  if a[1] not in R_:
    R_[a[1]]=a[0]
  else:
    if R_[a[1]]!=a[0]:
      print('No')
      break
      
else:
  print('Yes')

Submission status: Accepted

Solution code:
S=input()
T=input()
l=len(S)
Rs=[0]*26
Rt=[0]*26
for i in range(l):
    Rs[ord(S[i])-ord('a')]+=1
    Rt[ord(T[i])-ord('a')]+=1
Rs.sort()
Rt.sort()
if Rs==Rt:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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


def check(A, B):
    alphabets = "abcdefghijklmnopqrstuvwxyz"
    d = {c: None for c in alphabets}
    for i in range(len(A)):
        if d[A[i]] is None:
            d[A[i]] = B[i]
        elif d[A[i]] != B[i]:
            return False
    return True


print("Yes" if check(S, T) and check(T, S) else "No")

Submission status: Accepted

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


def check(A, B):
    alphabets = "abcdefghijklmnopqrstuvwxyz"
    d = {c: None for c in alphabets}
    for i in range(len(A)):
        if d[A[i]] is None:
            d[A[i]] = B[i]
        elif d[A[i]] != B[i]:
            return False
    return True


print("Yes" if check(S, T) and check(T, S) else "No")

Submission status: Accepted

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

command = [S, T]
spel = [[], []]
counter = [[], []]

for i in range(2):
    for j in range(len(S)):
        if command[i][j] in spel[i]:
            counter[i][spel[i].index(command[i][j])].append(j)

        else:
            spel[i].append(command[i][j])
            counter[i].append([j])

print('Yes' if counter[0] == counter[1] else 'No')

Submission status: Accepted

Solution code:
# ABC 110
def db(x): 
    global debug
    if debug: print(x)
debug = False
def swap(fromStr, toStr, nth):
    db((fromStr,toStr,nth))
    fromChar = fromStr[nth]
    toChar = toStr[nth]
    toStr = toStr.replace(fromChar,'#')
    db(toStr)
    toStr = toStr.replace(toChar,fromChar)
    db(toStr)
    toStr =  toStr.replace('#', toChar)
    db(toStr)
    return toStr
S = input()
T = input()
db((S,T))
used = []
for i in range(len(S)):
    if S[i] in used: 
        continue
    else:
        used.append(S[i])
        if S[i]==T[i]: continue
        T = swap(S, T, i)
if S==T: print('Yes')
else: print('No')
db((S,T,used))

Submission status: Accepted

Solution code:
S = sorted(input())
T = sorted(input())
S_list = []
T_list = []
for alp in "abcdefghijklmnopqrstuvwxyz":
  S_list.append(S.count(alp))
  T_list.append(T.count(alp))
if(sorted(S_list) != sorted(T_list)):
  print('No')
else:
  print('Yes')

Submission status: Accepted

Solution code:
a = int('a', 36)
S = list(input())
T = list(input())

s_index = [[] for i in range(28)]
t_index = [[] for i in range(28)]

for i in range(len(S)):
  s_index[int(S[i], 36) - a].append(i)
  t_index[int(T[i], 36) - a].append(i)

s_index = sorted(s_index)
t_index = sorted(t_index)

if s_index == t_index:
  print('Yes')
else:
  print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(S)
num_swap = 0
for i in range(N):
    if num_swap > 24:
        print('No')
        break
    if S[i] != T[i]:
        s, t = S[i], T[i]
        S = S.replace(s, '0').replace(t, s).replace('0', t)
        num_swap += 1
else:
    if S == T:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
N = len(S)
num_swap = 0
for i in range(N):
    if num_swap > 24:
        print('No')
        break
    if S[i] != T[i]:
        s, t = S[i], T[i]
        S = S.replace(s, '0')
        S = S.replace(t, s)
        S = S.replace('0', t)
        num_swap += 1
else:
    if S == T:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

Solution code:
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline
    s = input()
    t = input()
    l_s = list(s)
    l_t = list(t)
    str_key = {}
    str_key_t = {}
    for i,moji in enumerate(s):
        if not moji in str_key:
            str_key[moji] = t[i]
        l_s[i] = str_key[moji]
    for i,moji in enumerate(t):
        if not moji in str_key_t:
            str_key_t[moji] = s[i]
        l_t[i] = str_key_t[moji]
    if "".join(l_s) == t and "".join(l_t) == s:
        print('Yes')
    else:
        print('No')

Submission status: Accepted

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

def main():
    S = input()
    T = input()

    ct = [-1] * 26
    dt = [-1] * 26

    oa = ord('a')
    f = True
    for i in range(len(S)):
        c1 = S[i]
        c2 = T[i]
        j1 = ord(c1) - oa
        j2 = ord(c2) - oa
        if ct[j1] == -1:
            if dt[j2] == -1:
                ct[j1] = j2
                dt[j2] = j1
            else:
                f = False
                break
        elif ct[j1] != j2:
            f = False
            break


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


if __name__ == '__main__':
    main()

Submission status: Accepted

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


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

# ある1文字に対応する文字が1種であることを確認
d = dict()
for si, ti in zip(s, t):
    if si not in d:
        d[si] = ti
    else:
        if d[si] != ti:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
s = input()
t = input()
s_memo = {}
t_memo = {}

for i in range(len(s)):
    c1 = s[i]
    c2 = t[i]
    if (c1 in s_memo and s_memo[c1] != c2) or \
            (c2 in t_memo and t_memo[c2] != c1):
        print("No")
        exit()
    s_memo[c1] = c2
    t_memo[c2] = c1

print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter
S = Counter(input()).most_common()
T = Counter(input()).most_common()

ans = 'Yes'
if len(S) != len(T):
    ans = 'No'
else:
    for i in range(len(S)):
        if S[i][1] != T[i][1]:
            ans = 'No'
            break
            
print(ans)

Submission status: Accepted

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

def to_num_list(s):
    word_dic = {}
    word_number = []
    idx = 0
    for i in s:
        if i not in word_dic:
            word_dic[i] = idx
            idx += 1
        word_number.append(word_dic[i])
    return word_number

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

Submission status: Accepted

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

ABC = "abcdefghijklmnopqrstuvwxyz"
assert len(ABC) == 26

def main():
    s = input()
    t = input()
    ss = sets_of_indices(s)
    tt = sets_of_indices(t)
    print("Yes" if ss == tt else "No")

def sets_of_indices(s):
    di = {c: [] for c in ABC}
    for i, c in enumerate(s):
        di[c].append(i)
    res = {tuple(di[c]) for c in ABC}
    return res

main()

Submission status: Accepted

Solution code:
s=input()
t=input()
s_set={}
t_set={}
s_dash=[]
t_dash=[]
for i in range(len(s)):
    if s[i] not in s_set.keys():
        s_set.update({s[i]:i})
    s_dash.append(s_set[s[i]])
    if t[i] not in t_set.keys():
        t_set.update({t[i]:i})
    t_dash.append(t_set[t[i]])

if s_dash==t_dash:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    t = list(input())
    n = len(s)
    memo1 = {}
    memo2 = {}

    for i in range(n):
        c1 = s[i]
        c2 = t[i]
        if (c1 in memo1 and memo1[c1] != c2) or \
                (c2 in memo2 and memo2[c2] != c1):
            print('No')
            exit()
        memo1[c1] = c2
        memo2[c2] = c1

    print('Yes')


main()

Submission status: Accepted

Solution code:
def main():
    s = list(input())
    t = list(input())
    n = len(s)
    memo1 = {}
    memo2 = {}

    for i in range(n):
        c1 = s[i]
        c2 = t[i]
        if c1 in memo1:
            if memo1[c1] != c2:
                print('No')
                exit()
        else:
            memo1[c1] = c2
        if c2 in memo2:
            if memo2[c2] != c1:
                print('No')
                exit()
        else:
            memo2[c2] = c1

    print('Yes')


main()

Submission status: Accepted

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

s_memo = {}
t_memo = {}

for i in range(len(s)):
  if t[i] not in t_memo:
    t_memo[t[i]] = s[i]
  else:
    if t_memo[t[i]] != s[i]:
      print("No")
      exit()
      break
  
  if s[i] not in s_memo:
    s_memo[s[i]] = t[i]
  else:
    if s_memo[s[i]] != t[i]:
      print("No")
      exit()
      break

print("Yes")

Submission status: Accepted

Solution code:
S = input()
T = input()
A = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

k=0
for i in range(len(S)):
    if S[i].islower():
        S = S.replace(S[i],A[k])
        k=k+1


k=0
for i in range(len(T)):
    if T[i].islower():
        T = T.replace(T[i],A[k])
        k=k+1

print('Yes' if S==T else 'No')

Submission status: Accepted

Solution code:
def d(s,t):
    s1=list(set([i for i in s]))
    t1=list(set([i for i in t]))
    ans='No'
    st=set(zip(s,t))
    if len(st)-len(s1)==0 and len(st)-len(t1)==0:
        ans='Yes'
    return ans
print(d(input(),input()))

Submission status: Accepted

Solution code:
def main(s,t):
    n = len(s)
    for i in range(n):
        if t[i]!=s[i]:
            rep =s[i]
            s=s.replace(rep,"A")
            s=s.replace(t[i],rep)
            s=s.replace("A",t[i])
            if t[:i] !=s [:i]:
                return "No"
    if s == t:
        return "Yes"
    else:
        return "No"
s=input()
t=input()
print(main(s,t))

Submission status: Accepted

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

sd = {S[0]: 0}
td = {T[0]: 0}

def len_match():
    for i in range(1, len(S)):
        if (S[i-1] == S[i] and T[i-1] == T[i]) or (S[i] != S[i-1] and T[i] != T[i-1]):
            slast = sd.get(S[i], -1)
            tlast = td.get(T[i], -1)
            if slast != tlast:
                return False
            sd[S[i]] = i
            td[T[i]] = i
        else:
            return False
    return True

def ans():
    result = len_match()
    return 'Yes' if result else 'No'

print(ans())

Submission status: Accepted

Solution code:
def check(str1,str2):
    al = [[] for i in range(26)]
    # 同じアルファベットでインデックスをまとめる
    for i in range(len(str1)):
        index = ord(str1[i]) - 97
        al[index].append(i)
    # str1[i] == str1[j] => str2[i] == str2[j] のチェック
    for l in al:
        note = [str2[i] for i in l]
        if len(list(set(note))) > 1:
            global ans 
            ans = "No"
            break

S = input(); T = input()
ans = "Yes"
check(S,T); check(T,S)
print(ans)

Submission status: Accepted

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

d1 = {}
d2 = {}

flag = 1

for s,t in zip(S,T):
    if not s in d1:
        d1[s] = t
    elif d1[s] != t:
        print('No')
        flag = 0
        break
    if not t in d2:
        d2[t] = s
    elif d2[t] != s:
        print('No')
        flag = 0
        break

if flag:
    print('Yes')

Submission status: Accepted

Solution code:
abc=list("abcdefghijklmnopqrstuvwxyz")
S=input()
T=input()

c1=[[] for i in abc]
c2=[[] for i in abc]
for i in range(0,len(S)):
    c1[ord(S[i])-ord("a")].append(i)

for i in range(0,len(T)):
    c2[ord(T[i])-ord("a")].append(i)

ans="Yes"
for i in c1:
    if(i not in c2):
        ans="No"
        break
    
print(ans)

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
T = input()

flag = True
ds = defaultdict(chr)
dt = defaultdict(chr)
for i in range(len(S)):
    if S[i] in ds.keys():
        if ds[S[i]] != T[i]:
            flag = False
    else:
        ds[S[i]] = T[i]

    if T[i] in dt.keys():
        if dt[T[i]] != S[i]:
            flag = False
    else:
        dt[T[i]] = S[i]

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

Submission status: Accepted

Solution code:
s=list(input())
t=list(input())
S=sorted(map(s.count,set(s)))
T=sorted(map(t.count,set(t)))
print("Yes" if S==T else "No")

Submission status: Accepted

Solution code:
from collections import Counter

S = sorted(Counter(input()).values())
T = sorted(Counter(input()).values())
if S == T:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import Counter

S = sorted(Counter(input()).values())
T = sorted(Counter(input()).values())

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

Submission status: Accepted

Solution code:
S = input()
T = input()
for x in set(T):
    S = S.replace(S[T.index(x)],'A').replace(x,S[T.index(x)]).replace('A',x)
if S == T:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
# A,B,C = [int(n) for n in input().split()]
# N = int(input())
S = list(input())
T = list(input())
s = {}
for i in range(len(S)):
    if not(S[i] in s):
        s[S[i]] = i
        S[i] = i
    else:
        S[i] = s[S[i]]
s = {}
for i in range(len(T)):
    if not(T[i] in s):
        s[T[i]] = i
        T[i] = i
    else:
        T[i] = s[T[i]]
print("Yes" if T == S  else "No")

Submission status: Accepted

Solution code:
s = list(input())
t = list(input())
A = []
B = []
count=0
for i, j in zip(s, t):
    if(s.index(i) != t.index(j)):
        print("No")
        count+=1
        break
if(count==0):
    print("Yes")

Submission status: Accepted

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

f_S = {}
f_T = {}


for i in range(len(S)):
    if S[i] not in f_S:
        f_S[S[i]] = T[i]
    elif f_S[S[i]] != T[i]:
        print('No')
        exit()
      
for i in range(len(T)):
    if T[i] not in f_T:
        f_T[T[i]] = S[i]
    elif f_T[T[i]] != S[i]:
        print('No')
        exit()
      
print('Yes')

Submission status: Accepted

Solution code:
# coding: utf-8


def check(S, T, c):
    ids = tuple((i for i in range(len(T)) if T[i] == c))
    if len(ids) < 2:
        return True
    cs = set((S[i] for i in ids))
    if len(cs) != 1:
        return False
    return True


def main():
    S = input().strip()
    T = input().strip()

    for ci in range(ord("a"), ord("z") + 1):
        c = chr(ci)
        if check(S, T, c) and check(T, S, c):
            continue
        return False
    return True


if __name__ == "__main__":
    print(["No", "Yes"][main()])

Submission status: Accepted

Solution code:
from collections import defaultdict

S = input()
T = input()

s_dic = defaultdict(lambda: -1)
t_dic = defaultdict(lambda: -1)

can_replace = True
for i in range(len(S)):
    s_char = S[i]
    t_char = T[i]

    if s_dic[s_char] != -1 or t_dic[t_char] != -1:
        if s_dic[s_char] != t_char and t_dic[t_char] != s_char:
            can_replace = False
            break
    else:
        s_dic[s_char] = t_char
        t_dic[t_char] = s_char

if can_replace:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
s = input()
t = input()
s_l = {}
t_l = {}
for i in range(len(s)):
    if s[i] in s_l:
        s_l[s[i]]+=1
    else:
        s_l[s[i]]=1
    if t[i] in t_l:
        t_l[t[i]]+=1
    else:
        t_l[t[i]]=1

s_arr = []
t_arr = []
for i in s_l.values():
    s_arr.append(i)
for i in t_l.values():
    t_arr.append(i)
s_arr = sorted(s_arr)
t_arr = sorted(t_arr)
flag = False
for i in range(len(s_arr)):
    if s_arr[i] != t_arr[i]:
        flag = True
        break
if flag:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

lenS = len(Counter(S))
lenT = len(Counter(T))
flag = 0

if lenS == lenT:
    for i in range(lenS):
        if Counter(S).most_common()[i][1] == Counter(T).most_common()[i][1]:
            continue
        else:
            flag = 1
            break
else:
    flag = 1
    
if flag == 0:
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

dic_S = {}
dic_T = {}

for i in range(len(S)):
	if S[i] in dic_S.keys():
		if dic_S[S[i]] == T[i]: continue
		else:
			print('No')
			break
	if T[i] in dic_T.keys():
		if dic_T[T[i]] == S[i]: continue
		else:
			print('No')
			break
	else:
		dic_S[S[i]] = T[i]
		dic_T[T[i]] = S[i]
else:
	print('Yes')

Submission status: Accepted

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

dic = {}
flag=True

for i in range(len(S)):
    v = S[i]
    w = T[i]
    key=''

    if v not in dic.keys() and w not in dic.values():
        dic[v]=w
    elif w in dic.values():
        for k in dic.keys():
            if dic[k]==w:
                key=k
        if v!=key:
            flag=False
    else:
        flag=False


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

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input())
T = list(input())

Scount = Counter(S).values()
Tcount = Counter(T).values()



if sorted(Scount) == sorted(Tcount):
    ans = 'Yes' 
else:
    ans = 'No'

print(ans)

Submission status: Accepted

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

cntS = [0 for _ in range(26)]
cntT = [0 for _ in range(26)]
Alph = list("abcdefghijklmnopqrstuvwxyz")

for i in range(26):
    for j in S:
        if j == Alph[i]:
            cntS[i] += 1

for i in range(26):
    for j in T:
        if j == Alph[i]:
            cntT[i] += 1
cntS.sort()
cntT.sort()

# print(cntS)
# print(cntT)
if cntS == cntT:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import string
s = input()
t = input()
n = len(s)
trans = {c:['', ''] for c in string.ascii_lowercase}

for i in range(n):
    if trans[s[i]][1] == '':
        trans[s[i]][1] = t[i]
        if trans[t[i]][0] != '' and trans[t[i]][0] != s[i]:
            print('No')
            exit()
        trans[t[i]][0] = s[i]
    if trans[s[i]][1] != t[i] or trans[t[i]][0] != s[i]:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
from collections import defaultdict
S = input()
T = input()
def solve(S, T):
    fanin = defaultdict(set)
    fanout = defaultdict(set)
    for s, t in zip(S, T):
        fanin[t].add(s)
        fanout[s].add(t)
    for x in fanin.values():
        if len(x) > 1:
            return False
    for x in fanout.values():
        if len(x) > 1:
            return False
    return True
print(['No', 'Yes'][solve(S, T)])

Submission status: Accepted

Solution code:
from collections import Counter

S = list(input())
T = list(input())

cs = sorted(Counter(S).values())
ct = sorted(Counter(T).values())

if cs == ct:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
 
Sn = [ord(i)-ord("a") for i in S]
Tn = [ord(i)-ord("a") for i in T]
sub1 = [-1]*26
sub2 = [-1]*26
 
for i in range(len(S)):
    if sub1[Sn[i]] == -1 or sub2[Tn[i]] == -1:
        if sub1[Sn[i]] == -1:
            sub1[Sn[i]] = Tn[i]
        if sub2[Tn[i]] == -1:
            sub2[Tn[i]] = Sn[i]
    if sub1[Sn[i]] != Tn[i] or sub2[Tn[i]] != Sn[i]:
            print("No")
            break
else:
    print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
from collections import Counter


def main():
    s = input()
    t = input()
    vs_s = Counter(Counter(s).values())
    vs_t = Counter(Counter(t).values())
    if vs_s == vs_t:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
s_list = [[] for i in range(26)]
t_list = [[] for i in range(26)]
#各アルファベットがどこにあるか？
for i in range(len(S)):
    s_list[ord(S[i])-97].append(i)
for i in range(len(T)):
    t_list[ord(T[i])-97].append(i)
ok = True
for s in s_list:
    if s != []:
        if s in t_list:
            continue
        else:
            ok = False
            break

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