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

import collections
Sc = collections.Counter(S).most_common()
Tc = collections.Counter(T).most_common()
if len(Sc) != len(Tc):
    print('No')
    exit()
for s,t in zip(Sc,Tc):
    if s[1] != t[1]:
        print('No')
        exit()
di=dict()
for i,c in enumerate(S):
    if not c in di:
        di[c] = T[i]
        continue
    if di[c] != T[i]:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

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

ds = {}
dt = {}

for i in range(len(s)):
    if s[i] not in ds:
        ds[s[i]] = 1
    else:
        ds[s[i]] += 1

for i in range(len(t)):
    if t[i] not in dt:
        dt[t[i]] = 1
    else:
        dt[t[i]] += 1

vs = list(ds.values())
vt = list(dt.values())

vs.sort()
vt.sort()
#print(vs)
#print(vt)

if vs == vt:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import Counter
s=sorted(Counter(input()).values())
t=sorted(Counter(input()).values())
for i,j in zip(s,t):
    if i!=j:
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc110/tasks/abc110_c
# 文字のカウント数についてその種類が同じならばYes

S = input()
T = input()

from collections import Counter
s_cnt = Counter(S)
t_cnt = Counter(T)


# if set(s_cnt.values()) == set(t_cnt.values()) and len(s_cnt) == len(t_cnt):
#     # 実は嘘解法 #文字のカウントの種類について、長さが等しく且つセットも等しいけど、内容が異なる場合は存在する。
#     print('Yes')
# else:
#     print('No')

for (k, v), (kk, vv) in zip(s_cnt.most_common(), t_cnt.most_common()):
    if v != vv:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
# https://atcoder.jp/contests/abc110/tasks/abc110_c
# 文字のカウント数についてその種類が同じならばYes

S = input()
T = input()

from collections import Counter
s_cnt = Counter(S)
t_cnt = Counter(T)

if set(s_cnt.values()) == set(t_cnt.values()) and len(s_cnt) == len(t_cnt):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections
s1=input()
s2=input()
s1 = list(s1)
s2 = list(s2)

s11 = collections.Counter(s1)
s22 = collections.Counter(s2)

if len(s11) != len(s22):
    print('No')
    exit()

for i in range(len(s11)):
    if s11.most_common()[i][1] != s22.most_common()[i][1] :
        print('No')
        exit()
print('Yes')

Submission status: Accepted

Solution code:
#両者に、同じ位置，同じ文字があれば変換可能
s = input()
t = input()

s_inf = [[] for _ in range(97+26+1)]
t_inf = [[] for _ in range(97+26+1)]

for i in range(len(s)):
    s_inf[ord(s[i])].append(i)
    t_inf[ord(t[i])].append(i)
s_inf.sort()
t_inf.sort()
if s_inf==t_inf:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

s_inf = [[] for _ in range(97+26+1)]
t_inf = [[] for _ in range(97+26+1)]

for i in range(len(s)):
    s_inf[ord(s[i])].append(i)
    t_inf[ord(t[i])].append(i)
s_inf.sort()
t_inf.sort()
if s_inf==t_inf:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

s = sorted([s.count(i) for i in set(s)])
t = sorted([t.count(i) for i in set(t)])

if s==t:
    print("Yes")
else:
    print("No")
#aab
#bba
#が通ってしまうので　嘘回答

#そもそも、chokudai から redcoder も、
#k to x , d to x , x to d を行えれば、"Yes"になるため、
#説明不足感がある

#再び変換出来ないという条件を追加で成り立つような気がした

Submission status: Accepted

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

s = sorted([s.count(i) for i in set(s)])
t = sorted([t.count(i) for i in set(t)])

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

Submission status: Accepted

Solution code:
ds, dt = dict(), dict()
for s, t in zip(input(), input()):
    if t in ds and ds[t] != s or s in dt and dt[s] != t:
        print("No")
        break
    ds[t] = s
    dt[s] = t
else:
    print("Yes")

Submission status: Accepted

Solution code:
import collections
s = input()
t = input()
s_cnt = collections.Counter(s)
t_cnt = collections.Counter(t)
a = s_cnt.most_common()
b = t_cnt.most_common()
ans = True
for i in range(len(a)):
    if a[i][1] != b[i][1]:
        ans = False
        break

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

Submission status: Accepted

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

converter = dict()

for s, t in zip(S, T):
    if converter.get(s) is not None:
        if converter[s] != t:
            print("No")
            break
    else:
        converter[s] = t
else:
    if len(converter.values()) != len(set(converter.values())):
        print("No")
    else:
        print("Yes")

Submission status: Accepted

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

# 文字の変換を行う（0回以上文字の入れ替えを行う）
converter = dict()

for s, t in zip(S, T):
    # 出力とTの文字が一致しているか確認
    if converter.get(s) is not None:
        if converter[s] != t:
            print('No')
            break
    else:
        converter[s] = t

# 入力と出力の整合性を確認
# 入力が同じなら出力も同じなのと同様に、出力が同じなら入力も同じになる
# すなわち、出力が重複していることはありえない
else:  
    if len(converter.values()) != len(set(converter.values())):
        print('No')
    else:
        print('Yes')

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
s = []
t = []
s_num = []
t_num = []
for Si, Ti in zip(S, T):
    if not Si in s:
        s.append(Si)
    if not Ti in t:
        t.append(Ti)
for Si, Ti in zip(S, T):
    s_num.append(str(s.index(Si)))
    t_num.append(str(t.index(Ti)))
# print(S, T, s, t)
# print(s_num)
# print(t_num)
# print(''.join(s_num))
# print(''.join(t_num))

if ''.join(s_num) == ''.join(t_num):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

def calculate(s, t):
    dictS = {}
    dictT = {}

    for ss in s:
        if dictS.get(ss) == None:
            dictS.__setitem__(ss, 1)
        else:
            dictS.__setitem__(ss, dictS.get(ss) + 1)

    for tt in t:
        if dictT.get(tt) == None:
            dictT.__setitem__(tt, 1)
        else:
            dictT.__setitem__(tt, dictT.get(tt) + 1)

    sValues = dictS.values()
    tValues = dictT.values()

    sNums = {}
    tNums = {}


    for value in sValues:
        if sNums.get(value) == None:
            sNums.__setitem__(value,1)
        else:
            sNums.__setitem__(value,sNums.get(value) + 1)

    for value in tValues:
        if tNums.get(value) == None:
            tNums.__setitem__(value,1)
        else:
            tNums.__setitem__(value,tNums.get(value) + 1)

    if (sNums == tNums):
        print("Yes")
    else:
        print("No")

calculate(S, T)

Submission status: Accepted

Solution code:
from collections import defaultdict
d = defaultdict(str)
k = defaultdict(str)

S = input()
T = input()

ans = "Yes"

for i in range(len(S)):
  if d[S[i]] and d[S[i]] != T[i]:
    ans = 'No'
    break

  if k[T[i]] and k[T[i]] != S[i]:
    ans = 'No'
    break

  d[S[i]] = T[i]
  k[T[i]] = S[i]

print(ans)

Submission status: Accepted

Solution code:
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']

S=input()
T=input()
Sdata=[[] for i in range(0,26)]
Tdata=[[] for i in range(0,26)]

for i in range(0,len(S)):
    Sdata[alphabetlist.index(S[i])].append(i)
for i in range(0,len(T)):
    Tdata[alphabetlist.index(T[i])].append(i)
Sdata.sort()
Tdata.sort()
if Sdata==Tdata:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
from collections import defaultdict
s = input()
t = input()
d = defaultdict(str)
e = defaultdict(str)
for i in range(len(s)):
    c1,c2 = s[i],t[i]
    if d[c1] == "":
        d[c1] = c2
    elif d[c1] != c2:
        print("No")
        exit(0)
    if e[c2] == "":
        e[c2] = c1
    elif e[c2] != c1:
        print("No")
        exit(0)
print("Yes")

Submission status: Accepted

Solution code:

if __name__ == '__main__':
    S=input()
    T=input()
    MA={}
    IMA={}
    ok=True
    for i in range(len(S)):
        s=S[i]
        t=T[i]
        if list(MA.keys()).count(s)>0:
            if MA[s]!=t:
                ok=False
        if list(IMA.keys()).count(t) > 0:
            if IMA[t] != s:
                ok = False
        MA[s]=t
        IMA[t]=s
    if ok:
        print("Yes")
    else:
        print("No")

Submission status: Accepted

Solution code:
smap, tmap = [-1] * 26, [-1] * 26

S = input()
T = input()

ans = 'Yes'
for s, t in zip(S, T):
    s = ord(s) - ord('a')
    t = ord(t) - ord('a')
    if smap[s] >= 0:
        if smap[s] != t:
            ans = 'No'
            break
    else:
        smap[s] = t
    if tmap[t] >= 0:
        if tmap[t] != s:
            ans = 'No'
            break
    else:
        tmap[t] = s
    
print(ans)

Submission status: Accepted

Solution code:
S, T = [0] * 26, [0] * 26

for s in input():
    S[ord(s) - ord('a')] += 1
for t in input():
    T[ord(t) - ord('a')] += 1
S.sort()
T.sort()
ans = 'Yes' if S == T else 'No'
print(ans)

Submission status: Accepted

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

Submission status: Accepted

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

    dic={}
    for i in range(n):
        if s[i] not in dic:
            dic[s[i]]=t[i]
        else:
            if dic[s[i]]!=t[i]:
                print('No')
                exit()
    if len(set(dic.values()))!=len(dic.values()):
        print('No')
    else:
        print('Yes')
if __name__=='__main__':
    main()

Submission status: Accepted

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

st = {s: set() for s in set(S)}
ts = {t: set() for t in set(T)}
for i in range(len(S)):
    st[S[i]].add(T[i])
    ts[T[i]].add(S[i])

for vs, vt in zip(st.values(), ts.values()):
    if len(vs) > 1 or len(vt) > 1:
        print('No')
        break
else:
    print('Yes')

Submission status: Accepted

Solution code:
import collections

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

sc = collections.Counter(S)
tc = collections.Counter(T)

scv = sorted(sc.values())
tcv = sorted(tc.values())

if scv == tcv:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
class Solution:
    def solve(self, S: str, T: str) -> str:

        def str2pattern(S: str) -> str:
            swap = {}
            a = ord('a')
            pattern = ""
            for s in S:

                if not s in swap:
                    swap[s] = chr(a)
                    a += 1

                pattern += swap[s]

            return pattern

        if str2pattern(S) == str2pattern(T):
            return "Yes"
        else:
            return "No"


if __name__ == '__main__':

    # standard input
    S = input()
    T = input()

    # solve
    solution = Solution()
    print(solution.solve(S, T))

Submission status: Accepted

Solution code:
from operator import itemgetter
s=input()
t=input()
u=[]
v=[]
s_len=len(s)
for i in range(s_len):
    s_i=s[i]
    t_i=t[i]
    ts=t_i+s_i
    if s_i!=t_i:
        if ts not in u:
            u.append(ts)
    elif s_i not in v:
        v.append(s_i)
u_len=len(u)
ans="Yes"
if u_len!=0:
    u1=sorted(u)
    u1.append("XX")
    for i in range(u_len):
        if u1[i][0] in v or u1[i][1] in v:
            ans="No"
            break
        elif u1[i][0]==u1[i+1][0] and u1[i][1]!=u1[i+1][1]:
            ans="No"
            break
    if ans=="Yes":
        u2=sorted(u,key=itemgetter(1))
        u2.append("XX")
        for i in range(u_len):
            if u2[i][0]!=u2[i+1][0] and u2[i][1]==u2[i+1][1]:
                ans="No"
                break
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
inf = float('inf')
ninf = -float('inf')
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip().split()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

s=list(ss())
t=list(ss())

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

ck=list(cs.values())
tk=list(ct.values())

ck.sort()
tk.sort()
if ck==tk:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
#110_C
S=input()
T=input()
R={}
L={}
flg=True
for i in range(len(S)):
    if S[i] in R:
        if R[S[i]]!=T[i]: flg=False
    else:
        R[S[i]]=T[i]
    if T[i] in L:
        if L[T[i]]!=S[i]: flg=False
    else:
        L[T[i]]=S[i]
print('Yes' if flg else 'No')

Submission status: Accepted

Solution code:
#https://atcoder.jp/contests/abc110/submissions/10200775
s = input()
t = input()


alp = 'abcdefghijklmnopqrstuvwxyz'

scnt = [[] for i in range(28)]
tcnt = [[] for i in range(28)]

for i in range(len(s)):
    for j,v in enumerate(alp):
        if s[i] == v:
            scnt[j].append(i)

for i in range(len(t)):
    for j,v in enumerate(alp):
        if t[i] == v:
            tcnt[j].append(i)

scnt.sort()
tcnt.sort()


if scnt == tcnt:print("Yes")
else :print("No")

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    ds = {}
    dt = {}
    for i, v in enumerate(S):
        if v in ds:
            ds[v].append(i)
        else:
            ds[v] = [i]
    for i, v in enumerate(T):
        if v in dt:
            dt[v].append(i)
        else:
            dt[v] = [i]
    for i in ds:
        l = ds[i]
        for j in dt:
            if l == dt[j]:
                break
        else:
            return 'No'
    return 'Yes'
print(main())

Submission status: Accepted

Solution code:
s = input()
t = input()
p = {}
q = {}
for i in range(len(s)):
    if s[i] in p and p[s[i]] != t[i]:
        print('No')
        exit(0)
    if t[i] in q and q[t[i]] != s[i]:
        print('No')
        exit(0)
    p[s[i]] = t[i]
    q[t[i]] = s[i]
print('Yes')

Submission status: Accepted

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

sc = Counter(s)
tc = Counter(t)

sc_l = sorted(sc.values())
tc_l = sorted(tc.values())

if sc_l == tc_l:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections

s=list(input())
t=list(input())

ss=collections.Counter(s)
tt=collections.Counter(t)

s_v = sorted(ss.values())
t_v = sorted(tt.values())

if s_v == t_v:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

st=[]
ts=[]
for i in range(len(s)):
    st.append([s[i],t[i]])
    ts.append([t[i],s[i]])
#print(st)
st.sort()
ts.sort()
#print(st)
    
yesno="Yes"
for i in range(len(st)-1):
    sj,tj=st[len(st)-i-1]
    sk,tk=st[len(st)-i-2]
    if sj==sk and tj!=tk:
        yesno="No"
        break
    tj,sj=ts[len(ts)-i-1]
    tk,sk=ts[len(ts)-i-2]
    if tj==tk and sj!=sk:
        yesno="No"
        break
    
print(yesno)

Submission status: Accepted

Solution code:
def f():w=input();return sorted(w.count(c) for c in set(w))
print('YNeos'[f()!=f()::2])

Submission status: Accepted

Solution code:
def f(): w=input(); return sorted(w.count(c) for c in set(w))
s,t=f(),f()
print('YNeos'[s!=t::2])

Submission status: Accepted

Solution code:
def f():
  w = input()
  return sorted([w.count(c) for c in set(w)])
s,t = f(),f()
print('YNeos'[s!=t::2])

Submission status: Accepted

Solution code:
S, T = input(), input()
ma, ima = {}, {}
ok = True
for i in range(len(S)):
    s, t = S[i], T[i]
    if s in ma and ma[s] != t:
        ok = False
    if t in ima and ima[t] != s:
        ok = False
    ma[s] = t
    ima[t] = s
if ok:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

def chr_count(S):
    count = [0]*1000
    for i in S:
        count[ord(i)] += 1
    return count

Sc = chr_count(S)
Tc = chr_count(T)
Sc.sort()
Tc.sort()

if Sc == Tc:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import collections


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

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

Submission status: Accepted

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

if len(set(S)) != len(set(T)):
    print("No")
    sys.exit()

record = {}
for i, s in enumerate(S):
    if s in record.keys():
        record[s].append(i)
    else:
        record[s] = [i]


def eq(x, t):
    if len(x) == 1:
        return 1
    for w in x[1:]:
        if t[w] == t[x[0]]:
            pass
        else:
            return 0
    return 1


ans = "Yes"
for i in record.values():
    if eq(i, T):
        pass
    else:
        ans = "No"
        break
print(ans)

Submission status: Accepted

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
import fractions
import bisect

MOD = int(1e9+7)
PI = 3.14159265358979323846264338327950288

'''
1行のint
N, K = map(int, input().split())

1行のstring
S, T = input().split()

1行の整数配列
P = list(map(int,input().split()))

改行ありl
x = []
y = []
for i in range(5):
    x1,y1=[int(i) for i in input().split()]
    x.append(x1)
    y.append(y1)

'''


S = input()
T = input()

s_hash = [0]*28
t_hash = [0]*28

s_next = 0
t_next = 0


for i in range(len(S)):

    if s_hash[ord(S[i])-ord("a")] !=  t_hash[ord(T[i])-ord("a")]:
        print("No")
        sys.exit()

    else:
        
        if s_hash[ord(S[i])-ord("a")] == 0:
            s_next+=1
        s_hash[ord(S[i])-ord("a")] += 1

        if t_hash[ord(T[i])-ord("a")] == 0:
            t_next+=1
        t_hash[ord(T[i])-ord("a")] += 1



print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

# これは嘘解法です
def lie():
    S = input()
    T = input()

    s = Counter(S)
    t = Counter(T)

    a = sorted(list(s.values()))
    b = sorted(list(t.values()))

    print("Yes" if a == b else "No")


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

    # one-to-one correspondence
    s_to_t = {}
    t_to_s = {}

    for s, t in zip(S, T):
        if s not in s_to_t:
            s_to_t[s] = t
        else:
            if s_to_t[s] != t:
                print("No")
                exit()

        if t not in t_to_s:
            t_to_s[t] = s
        else:
            if t_to_s[t] != s:
                print("No")
                exit()

    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
S = str(input())
T = str(input())
S_d = {}
T_d = {}
trans_d = {}
for i,j in zip(S,T):
    if i in S_d and j in T_d:
        if S_d[i] == T_d[j]:
            if trans_d[i] == j:
                pass
            else:
                print("No")
                break            
        else:
            print("No")
            break
    else:
        if i in S_d or j in T_d:
            print("No")
            break
        else:
            if S.count(S) == T.count(T):
                S_d[i] = S.count(S)
                T_d[j] = T.count(T)
                trans_d[i] = j
            else:
                print("No")
                break
        
else:
    print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

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

    s = Counter(S)
    t = Counter(T)

    a = sorted(list(s.values()))
    b = sorted(list(t.values()))

    print("Yes" if a == b else "No")


if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def convert(st):
    d = {}
    lst = []
    for ch in st:
        if ch not in d:
            d[ch] = len(d)
        lst.append(d[ch])
    return lst


S = input()
T = input()
Sl = convert(S)
Tl = convert(T)
print('Yes' if Sl == Tl else 'No')

Submission status: Accepted

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

Sd = {}
Sl = []
for c in S:
    if c not in Sd:
        Sd[c] = len(Sd)
    Sl.append(Sd[c])

Td = {}
Tl = []
for c in T:
    if c not in Td:
        Td[c] = len(Td)
    Tl.append(Td[c])

print('Yes' if Sl == Tl else 'No')

Submission status: Accepted

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

s_arr = [0] * 26
t_arr = [0] * 26
for i in range(len(s)):
    temp = ord(s[i])- ord('a')
    s_arr[temp] += 1
    temp = ord(t[i])- ord('a')
    t_arr[temp] += 1

s_arr.sort()
t_arr.sort()

ans = 'Yes'
for i in range(26):
    if s_arr[i] != t_arr[i]:
        ans = 'No'

print(ans)

Submission status: Accepted

Solution code:
from collections import Counter
 
S=input()
T=input()
 
S=list(Counter(S).values())
T=list(Counter(T).values())
 
S.sort()
T.sort()
 
if S==T:
  print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
S = input()
T = input()
R_s = [-1] * 26
R_t = [-1] * 26
ans = 'Yes'

for i in range(len(S)):
  tmpS = ord(S[i]) - 97
  tmpT = ord(T[i]) - 97
  if R_s[tmpS] < 0:
    R_s[tmpS] = tmpT
  elif R_s[tmpS] != tmpT:
    ans = 'No'
  
  if R_t[tmpT] < 0:
    R_t[tmpT] = tmpS
  elif R_t[tmpT] != tmpS:
    ans = 'No'

print(ans)

Submission status: Accepted

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


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YN = {False: 'No', True: 'Yes'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
# sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


show_flg = True
show_flg = False


def main():
    s = S()
    t = S()
    s_pos = {k: set() for k in l_alp}
    t_pos = {k: set() for k in l_alp}

    for i in range(len(s)):
        s_pos[s[i]].add(i)
        t_pos[t[i]].add(i)

    for c in l_alp:
        loc = s_pos[c]
        candidates = set()
        for i in loc:
            candidates.add(t[i])

        if len(candidates) > 1:
            print('No')
            return

    for c in l_alp:
        loc = t_pos[c]
        candidates = set()
        for i in loc:
            candidates.add(s[i])

        if len(candidates) > 1:
            # print(c, candidates)
            print('No')
            return

    print('Yes')


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s=input()
t=input()
st={}
ts={}
for i in range(len(s)):
    if s[i] in st:
        if st[s[i]]!=t[i]:
            print("No")
            break
    else:
        st[s[i]]=t[i]
    if t[i] in ts:
        if ts[t[i]]!=s[i]:
            print("No")
            break
    else:
        ts[t[i]]=s[i]
    if i==len(s)-1:
        print("Yes")

Submission status: Accepted

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

Submission status: Accepted

Solution code:
S = input()
T = input()
def f(x):
  d = {chr(97+i):[] for i in range(26)}
  for i in range(len(x)):
    d[x[i]].append(i)
  D = list(d.values())
  D.sort()
  return D
if f(S) == f(T):
  print("Yes")
else:
  print("No")

Submission status: Accepted

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

before = [-1] * 26
after = [-1] * 26

for i, j in zip(s, t):
    si = ord(i) - ord('a')
    ti = ord(j) - ord('a')

    if before[si] != -1 or after[ti] != -1:
        if before[si] != ti or after[ti] != si:
            print("No")
            exit()

    before[si] = ti
    after[ti] = si
print("Yes")

Submission status: Accepted

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

cnt_s = sorted(Counter(s).values())
cnt_t = sorted(Counter(t).values())
print('Yes' if cnt_s == cnt_t else 'No')

Submission status: Accepted

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

Ls=[0]*26
Lt=[0]*26

for i in range(len(S)):
    Ls[ord(S[i])-ord("a")]+=1
    Lt[ord(T[i])-ord("a")]+=1
    
Ls.sort()
Lt.sort()

flag=True
for i in range(len(Ls)):
    if Ls[i]!=Lt[i]:
        flag=False
        break
        
if flag:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
def checkTrans(s, t):
    ms = {}
    mt = {}
    for sc, tc in zip(s, t):
        if sc in ms:
            if ms[sc] != tc:
                return False
        else:
            ms[sc] = tc

        if tc in mt:
            if mt[tc] != sc:
                return False
        else:
            mt[tc] = sc

    return True

s = input()
t = input()

if checkTrans(s, t):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

s_cnt=[]
t_cnt=[]

for i in range(97,97+26):
    s_cnt.append(S.count((chr(i))))
    t_cnt.append(T.count((chr(i))))

s_cnt.sort()
t_cnt.sort()

ok_flag=True
for i in range(len(s_cnt)):
    if s_cnt[i] != t_cnt[i]:
        ok_flag=False

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

Submission status: Accepted

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

Submission status: Accepted

Solution code:
import collections

S = input()
T = input()

reg = [None]*26
reg_flag = [0]*26

for i in range(len(S)):
    index = ord(S[i])-97
    if reg_flag[index] == 0:
        reg[index] = T[i]
        reg_flag[index] = 1

    if reg[index] != T[i]:
        print('No')
        exit()

reg = filter(lambda x: x != None, reg)
if collections.Counter(reg).most_common()[0][1] > 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
import collections

S = input()
T = input()

reg = [None]*26
reg_flag = [0]*26

for i in range(len(S)):
    index = ord(S[i])-97
    if reg_flag[index] == 0:
        reg[index] = T[i]
        reg_flag[index] = 1

    if reg[index] == T[i]:
        pass
    else:
        print('No')
        exit()

reg = filter(lambda x: x != None, reg)
if collections.Counter(reg).most_common()[0][1] > 1:
    print('No')
else:
    print('Yes')

Submission status: Accepted

Solution code:
def main():
    S = input()
    T = input()
    st = {}
    ts = {}
    for i in range(97, 97 + 26):
        st[chr(i)] = ""
        ts[chr(i)] = ""
    for s, t in zip(S, T):
        if st[s] == "":
            st[s] = t
        if ts[t] == "":
            ts[t] = s
        if not st[s] == t or not ts[t] == s:
            print("No")
            break
    else:
        print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

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

S1 = {}
for i, s in enumerate(S):
  if s in S1:
    S1[s].append(i)
  else:
    S1[s] = [i]
    
for str_key, keys in S1.items():
  t_str = []
  for k in keys:
    t_str.append(T[k])
  if len(set(t_str)) > 1:
    print('No')
    exit()
    
T1 = {}
for i, t in enumerate(T):
  if t in T1:
    T1[t].append(i)
  else:
    T1[t] = [i]
    
for str_key, keys in T1.items():
  s_str = []
  for k in keys:
    s_str.append(S[k])
  if len(set(s_str)) > 1:
    print('No')
    exit()
    
print('Yes')

Submission status: Accepted

Solution code:
def assert_(s, t):
    if s != t:
        print("No")
        exit()

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

    mapping = {}
    mapping_ = {}
    for i in range(len(S)):
        if S[i] in mapping:
            assert_(mapping[S[i]], T[i])
        if T[i] in mapping_:
            assert_(mapping_[T[i]], S[i])
        mapping[S[i]] = T[i]
        mapping_[T[i]] = S[i]
    print("Yes")

main()

Submission status: Accepted

Solution code:
from collections import Counter

S=input()
T=input()

S=list(Counter(S).values())
T=list(Counter(T).values())

S.sort()
T.sort()

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

Submission status: Accepted

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

d = {x: 0 for x in "abcdefghijklmnopqrstuvwxyz"}
e = {x: 0 for x in "abcdefghijklmnopqrstuvwxyz"}

for i in range(len(s)):
    if d[s[i]] == 0 and e[t[i]] == 0:
        d[s[i]] = t[i]
        e[t[i]] = s[i]
    else:
        if d[s[i]] != t[i] or e[t[i]] != s[i]:
            print("No")
            exit()
print("Yes")

Submission status: Accepted

Solution code:
S = input()
T = input()
 
alphabet = 'abcdefghijklmnopqrstuvwxyz'
 
S_list = []
T_list = []
 
for i in alphabet:
    Scnt = S.count(i)
    Tcnt = T.count(i)
    if Scnt > 0:
        S_list.append(Scnt)
    if Tcnt > 0:
        T_list.append(Tcnt)
 
if sorted(T_list) == sorted(S_list):
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

S = input()
T = input()

dict = {}
re_dict = {}
flg = 1
for i in range(len(S)):
    if S[i] in dict:
        if T[i] != dict[S[i]]:
            flg = 0
            break
    else:
        dict[S[i]] = T[i]
        if T[i] in re_dict:
            if re_dict[T[i]] != S[i]:
                flg = 0
                break
        else:
            re_dict[T[i]] = S[i]

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

Submission status: Accepted

Solution code:
def normalized(s):
  indexes = {}
  def translated(ch):
    if ch not in indexes:
      indexes[ch] = len(indexes)
    return indexes[ch]

  return list(map(translated, s))


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

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


if __name__ == '__main__':
  main()