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 = list(input())
T = list(input())

flag = 0
dic1 = {}
dic2 = {}

for i in range(len(S)):
    if dic1.get(S[i]) == None:
        dic1[S[i]] = T[i]
    elif dic1[S[i]] != T[i]:
        print("No")
        exit()
    
    if dic2.get(T[i]) == None:
        dic2[T[i]] = S[i]
    elif dic2[T[i]] != S[i]:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
d = {}
e = {}
flag = 1

for i in range(len(S)):
    if S[i] not in d:
        d[S[i]] = T[i]
    else:
        if d[S[i]] != T[i]:
            flag = 0
            break

for i in range(len(S)):
    if T[i] not in e:
        e[T[i]] = S[i]
    else:
        if e[T[i]] != S[i]:
            flag = 0
            break



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

Submission status: Accepted

Solution code:
S = input()
T = input()
 
dicS = {}
dicT = {}

alphabet = "abcdefghijklmnopqrstuvwxyz"

for _a in alphabet:
    dicS[_a] = []
    dicT[_a] = []

for i,_s_ in enumerate(S):
    dicS[_s_].append(i)
   
for i,_t_ in enumerate(T):
    dicT[_t_].append(i)

for _s in dicS:
    dicS[_s] = tuple(dicS[_s])

for _t in dicT:
    dicT[_t] = tuple(dicT[_t])

flg = True
for t in dicS.values():
    if not t in dicT.values():
        flg = False
        
if flg:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
s = input()
t = input()
d1 = {}
d2 = {}

for i in range(len(s)):
  if s[i] not in d1:
    d1[s[i]] = t[i]
  elif d1[s[i]] != t[i]:
    print("No")
    break
  if t[i] not in d2:
    d2[t[i]] = s[i]
  elif d2[t[i]] != s[i]:
    print("No")
    break
  
else:
  print("Yes")

Submission status: Accepted

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


def main():
    StoT = {}
    TtoS = {}

    for i in range(len(S)):

        if S[i] in StoT:
            if StoT[S[i]] != T[i]:
                print("No")
                return

        else:
            StoT[S[i]] = T[i]

            if T[i] in TtoS:
                if TtoS[T[i]] != S[i]:
                    print("No")
                    return
            else:
                TtoS[T[i]] = S[i]

    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
s = input()
t = input()
dic1 = {}
dic2 = {}
for i in range(len(s)):
    if dic1.get(s[i]) == None:
        dic1[s[i]] = t[i]
    elif dic1[s[i]] != t[i]:
        print("No")
        exit()
    if dic2.get(t[i]) == None:
        dic2[t[i]] = s[i]
    elif dic2[t[i]] != s[i]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

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

s_s = sorted(s.values())
t_s = sorted(t.values())

if s_s == t_s:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
import collections

S = input()
T = input()

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

scounts = list(s.values())
tcounts = list(t.values())

scounts.sort()
tcounts.sort()

if scounts == tcounts:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
S = list(input())
T = list(input())
dic = {}

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

if len(set(dic.values())) != len(dic):
    print("No")
else:
    print("Yes")

Submission status: Accepted

Solution code:
#このコード
# aabbccdd
# ababcdcd
# をYesと通すのだが....

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 = input()
T = input()

dic = {}
dic_rev = {}


def solve():
    for s, t in zip(S, T):
        if t in dic.keys():
            if s != dic[t]:
                print('No')
                return
        else:
            dic[t] = s
    for s, t in zip(S, T):
        if s in dic_rev.keys():
            if t != dic_rev[s]:
                print('No')
                return
        else:
            dic_rev[s] = t
    print('Yes')
    return


solve()

Submission status: Accepted

Solution code:
from collections import Counter

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

S = Counter(S).most_common()
T = Counter(T).most_common()

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

Submission status: Accepted

Solution code:
# -*- coding: utf-8 -*-
s = input()
t = input()
n = len(s)

ds = {}
dt = {}
for i in range(n):
    if s[i] not in ds:
        ds[s[i]] = t[i]
    elif ds[s[i]]!=t[i]:
        print("No")
        exit()
    if t[i] not in dt:
        dt[t[i]] = s[i]
    elif dt[t[i]]!=s[i]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

s=input()
t=input()
if len(Counter(t))==len(Counter(s)) and len(s)==len(t):
  ls1=sorted([Counter(t)[x] for i,x in enumerate(Counter(t))])
  ls2=sorted([Counter(s)[x] for i,x in enumerate(Counter(s))])
  for i in range(len(ls1)):
    if ls1[i]!= ls2[i]:
      print('No')
      exit()
  print('Yes')
else:
  print("No")

Submission status: Accepted

Solution code:
# coding: utf8

if __name__ == "__main__":
    s = input()
    t = input()
    map_s = {}
    map_t = {}
    for i in range(len(s)):
        if s[i] not in map_s:
            map_s[s[i]] = t[i]
        else:
            if map_s[s[i]] != t[i]:
                print("No")
                i = 0
                break
        if t[i] not in map_t:
            map_t[t[i]] = s[i]
        else:
            if map_t[t[i]] != s[i]:
                print("No")
                i = 0
                break
    if i == len(s) - 1:
        print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

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

for i, v in enumerate(S):
    if v == T[i]:
        continue
    else:
        print('No')
        break
else:
    print(('Yes'))

Submission status: Accepted

Solution code:
def ctonum(c):
	alp = "qwertyuiopasdfghjklzxcvbnm"
	for i in range(len(alp)):
		if c == alp[i]:
			return i

countS=[0 for i in range(100)]
countT=[0 for i in range(100)]

S=input()
T=input()

for i in range(len(S)):
	countS[ctonum(S[i])]+=1
	countT[ctonum(T[i])]+=1
	
countS.sort()
countT.sort()

if countS==countT:
	print("Yes")
else:
	print("No")

Submission status: Accepted

Solution code:
S = input()
T = input()
S_dic = {}
T_dic = {}

for i in range(len(S)):
    s = S[i]
    t = T[i]
    if s in S_dic:
        S_dic[s] += 1
    else:
        S_dic[s] = 1

    if t in T_dic:
        T_dic[t] +=1

    else:
        T_dic[t] = 1

S_dic = sorted(S_dic.items(), key= lambda x:x[1])
T_dic = sorted(T_dic.items(), key=lambda x:x[1])
f = True
if len(S_dic) >= len(T_dic):
    length = len(T_dic)
else:
    length = len(S_dic)
for i in range(length):
    s = S_dic[i][1]
    t = T_dic[i][1]
    if s != t:
        f = False

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

Submission status: Accepted

Solution code:
S = input()
T = input()
S_dic = [-1 for _ in range(26)]
T_dic = [-1 for _ in range(26)]

alphabet = ["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 range(len(S)):
    s = S[i]
    t = T[i]
    si = alphabet.index(s)
    ti = alphabet.index(t)

    if S_dic[si] == -1:
        S_dic[si] = ti
    elif S_dic[si] != ti:
        print("No")
        exit()

    if T_dic[ti] == -1:
        T_dic[ti] = si
    elif T_dic[ti] != si:
        print("No")
        exit()

print("Yes")

Submission status: Accepted

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

letters = 'abcdefghijklmnopqrstuvwxyz'
res = "Yes"
for st in letters:
    temp = ""
    for i in range(len(S)):
        if S[i] == st:
            if temp and T[i] != temp:
                res = "No"
                break
            else:
                temp = T[i]
    if res == "No":
        break

for st in letters:
    temp = ""
    for i in range(len(T)):
        if T[i] == st:
            if temp and S[i] != temp:
                res = "No"
                break
            else:
                temp = S[i]
    if res == "No":
        break

print(res)

Submission status: Accepted

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

sd = {}
td = {}

for k in range(ord('a'),ord('z')+1):   
    sd[chr(k)] = 0
    td[chr(k)] = 0

for i in range(len(s)) :
    if s[i] in sd :
        sd[s[i]] = sd[s[i]] + 1

    if t[i] in td :
        td[t[i]] = td[t[i]] + 1
""" 
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in sd :
        print(str(sd[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print()
for k in range(ord('a'),ord('z')+1):   
    print(str(chr(k)) + ":",end="")
    if chr(k) in td :
        print(str(td[chr(k)]) + " ",end="")
    else:
        print("0 ",end="")
print() """

ta = []
sa = []
for k in range(ord('a'),ord('z')+1):
    if td[chr(k)] != sd[chr(k)] : 
        if td[chr(k)] > 0 :
            ta.append(td[chr(k)])
        if sd[chr(k)] > 0 :    
            sa.append(sd[chr(k)])
#print(ta)
#print(sa)

ta.sort()
sa.sort()

if ta == sa :
    print("Yes")
else :
    print("No")

Submission status: Accepted

Solution code:
import collections
S = sorted(list(collections.Counter(input()).values()))
T = sorted(list(collections.Counter(input()).values()))
for i,s in enumerate(S):
    if s == T[i]:
        continue
    print('No')
    break
else:
    print('Yes')

Submission status: Accepted

Solution code:
from collections import defaultdict
import string


S = input()
T = input()

td = defaultdict(set)
for i, s in enumerate(T):
    td[s].add(i)

for c in td.keys():
    index = td[c]
    s = set()
    for i in index:
        s.add(S[i])
    if len(s) != 1:
        print("No")
        exit()

sd = defaultdict(set)
for i, s in enumerate(S):
    sd[s].add(i)

for c in sd.keys():
    index = sd[c]
    s = set()
    for i in index:
        s.add(T[i])
    if len(s) != 1:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    chk_dir = {}
    for i in range(len(s)):
        if not(s[i] in chk_dir.keys()):
            if (t[i] in chk_dir.values()):
                return print("No")
            else:
                chk_dir[s[i]] = t[i]
        elif chk_dir[s[i]] != t[i]:
            return print("No")

    print("Yes")

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
def main():
    s = input()
    t = input()
    chk_dir = {}
    for i in range(len(s)):
        if not(s[i] in chk_dir.keys()):
            if (t[i] in chk_dir.values()):
                print("No")
                return
            else:
                chk_dir[s[i]] = t[i]
        elif chk_dir[s[i]] != t[i]:
            print("No")
            return

    print("Yes")
    return

if __name__ == "__main__":
    main()

Submission status: Accepted

Solution code:
import sys

S=input()
T=input()

DICT=dict()
L=len(S)

for i in range(L):
    if DICT.get(S[i])!=None and DICT.get(S[i])!=T[i]:
        print("No")
        sys.exit()
    else:
        DICT[S[i]]=T[i]


INVDICT=dict()

for d in DICT:
    if INVDICT.get(DICT[d])!=None and INVDICT.get(DICT[d])!=d:
        print("No")
        sys.exit()
    else:
        INVDICT[DICT[d]]=d

else:
    print("Yes")

Submission status: Accepted

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

list1 = [-1 for i in range(26)]
list2 = [-1 for i in range(26)]

for i in range(len(s)):
    a = ord(s[i]) - ord("a")
    b = ord(t[i]) - ord("a")
    
    if list1[a] != -1 or list2[b] != -1:
        if list1[a] != b or list2[b] != a:
            print("No")
            exit()
    else:
        list1[a] = b
        list2[b] = a

print("Yes")

Submission status: Accepted

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

d = {}
for a,b in zip(S,T):
    if a in d:
        if d[a] == b:
            continue
        else:
            print('No')
            exit()
    else:
        d[a] = b
l = len(set(d.values()))

print('Yes' if len(d) == l else 'No')

Submission status: Accepted

Solution code:
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

stot = dict()
ttos = dict()

s = lc()
t = lc()

ans = True

for si,ti in zip(s,t):
    if not si in stot.keys():
        stot.update({si: ti})
    elif stot[si] != ti:
        ans = False
        break
        
    if not ti in ttos.keys():
        ttos.update({ti: si})
    elif ttos[ti] != si:
        ans = False
        break
    
print('Yes') if ans else print('No')

Submission status: Accepted

Solution code:
def check(S, T):
    tbl = {}
    inv = {}
    for i in range(len(S)):
        if S[i] in tbl and tbl[S[i]] != T[i]:
            return False
        if T[i] in inv and inv[T[i]] != S[i]:
            return False
        tbl[S[i]] = T[i]
        inv[T[i]] = S[i]
    return True


def main():
    S = input()
    T = input()
    if check(S, T):
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Accepted

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

arrayS = []
arrayT = []
for i in range(len(S)):
    if S[i] in arrayS:
        if arrayT[arrayS.index(S[i])] != T[i]:
            result = False
            break
    elif T[i] in arrayT:
        result = False
        break
    else:
        arrayS.append(S[i])
        arrayT.append(T[i])

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

Submission status: Accepted

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

ds = {}
dt = {}
for letter in s:
    ds.setdefault(letter,0)
    ds[letter]+=1

for letter in t:
    dt.setdefault(letter,0)
    dt[letter]+=1

if sorted(ds.values()) == sorted(dt.values()):
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
str1= list(raw_input())
str2 = list(raw_input())
from collections import Counter
# import operator
resstr2 = Counter(str2)
resstr1 = Counter(str1)

# a = sorted(res.values())
res1 = Counter(resstr1.values())
res2 =  Counter(resstr2.values())
result = "Yes"
for k , i in res1.iteritems():
    if res2[k] != i:
        result = "No"
        break
print result

Submission status: Accepted

Solution code:
#!/usr/bin/python
# -*- coding: utf-8 -*-
s = raw_input()
t = raw_input()
dd1 = {}
dd2 = {}
flag = True
for i in xrange(len(s)):
    c1, c2 = s[i], t[i]
    if dd1.get(c1, c2) != c2:
        flag = False
        break
    if dd2.get(c2, c1) != c1:
        flag = False
        break
    dd1[c1] = c2
    dd2[c2] = c1
print 'Yes' if flag else 'No'

Submission status: Accepted

Solution code:
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:
import numpy as np

s=input()
t=input()
s_cnt=np.zeros(26)
s_letterPlace=[[] for _ in range(26)]
for i,si in enumerate(s):
    num=ord(si)-ord('a')
    s_cnt[num]+=1
    s_letterPlace[num].append(i)

s_multiLetter=[]
for cnt,place in zip(s_cnt,s_letterPlace):
    if cnt>1:
        s_multiLetter.append(place)

t_cnt=np.zeros(26)
t_letterPlace=[[] for _ in range(26)]
for i,ti in enumerate(t):
    num=ord(ti)-ord('a')
    t_cnt[num]+=1
    t_letterPlace[num].append(i)

t_multiLetter=[]
for cnt,place in zip(t_cnt,t_letterPlace):
    if cnt>1:
        t_multiLetter.append(place)
# print(len(s_multiLetter))
# print(len(t_multiLetter))

flag=1
if len(s_multiLetter)!=len(t_multiLetter):
    flag=0
elif len(s_multiLetter)==0 & len(t_multiLetter)==0:
    flag=1
elif len(s_multiLetter)*len(t_multiLetter)==0:
    flag=0
else:
    for s_place in s_multiLetter:
        if(flag==1):
            for t_place in t_multiLetter:
                if(s_place==t_place):
                    flag=1
                    break
                else:
                    flag=0

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

Submission status: Accepted

Solution code:
S=input()
T=input()
s=list(S)
t=list(T)
ss=[]
tt=[]
for i in range(97,123):
    a=s.count(chr(i))
    ss.append(a)
    b=t.count(chr(i))
    tt.append(b)
ss.sort()
tt.sort()
if ss==tt:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
import sys
import collections
import itertools
import math
import re
from collections import Counter
from collections import deque
from collections import defaultdict

S = input()
T = input()


N = len(S)


def f(STR1, STR2):
    d = {}
    isOK = True
    for i in range(N):
        s = STR1[i]
        t = STR2[i]

        if d.get(s) == None:
            d[s] = t
        elif d.get(s) == t:
            pass
        else:
            return False
    return True


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

Submission status: Accepted

Solution code:
def m():
    s = input()
    t = input()
    a = {chr(i): "" for i in range(97, 97 + 26)}
    b = {chr(i): "" for i in range(97, 97 + 26)}
    n = len(s)
    for i in range(n):
        if a[s[i]] == "":
            a[s[i]] = t[i]
        else:
            if a[s[i]] != t[i]:
                return 'No'
        if b[t[i]] == "":
            b[t[i]] = s[i]
        else:
            if b[t[i]] != s[i]:
                return 'No'
    return 'Yes'
print(m())

Submission status: Accepted

Solution code:
from fractions import gcd
from collections import defaultdict as dd
from collections import Counter as C
a = input()
b = input()
a = sorted(a)
b = sorted(b)
a = C(a)
b = C(b)
p,q = [],[]
for k in dict(a):
    p.append(a[k])
for k in dict(b):
    q.append(b[k])
p = sorted(p)
q = sorted(q)
if p==q:
    print('Yes')
else:
    print('No')

Submission status: Accepted

Solution code:
#提出3250967より

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

Submission status: Accepted

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

    dt = dict()
    ds = dict()
    for i in range(len(s)):
        if t[i] not in dt:
            dt[t[i]] = s[i]
        else:
            if dt[t[i]] != s[i]:
                print("No")
                return

        if s[i] not in ds:
            ds[s[i]] = t[i]
        else:
            if ds[s[i]] != t[i]:
                print("No")
                return

    print("Yes")

if __name__ == "__main__":
    main()

Submission status: Accepted

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

out_str = "Yes"

indexes_s_all = []
indexes_t_all = []
for i in range(26) :
	c = chr(ord('a') + i)
	indexes_s = [n for n, x in enumerate(list(S)) if x == c]
	indexes_t = [n for n, x in enumerate(list(T)) if x == c]
	indexes_s_all.append(indexes_s)
	indexes_t_all.append(indexes_t)

indexes_s_all.sort()
indexes_t_all.sort()
if (indexes_s_all == indexes_t_all) :
	print("Yes")
else :
	print("No")

Submission status: Accepted

Solution code:
S = raw_input()
T = raw_input()
N = len(S)
ks = {}
kt = {}
xs = 0
xt = 0
ys = []
yt = []
for i in range(N):
  if S[i] not in ks:
    ks[S[i]] = xs
    xs += 1
  ys.append(ks[S[i]])
  if T[i] not in kt:
    kt[T[i]] = xt
    xt += 1
  yt.append(kt[T[i]])
print "Yes" if ys==yt else "No"

Submission status: Accepted

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

dict_s = {}
for i in range(len(s)):
    if s[i] not in dict_s:
        dict_s[s[i]] = t[i]
    else:
        if dict_s[s[i]] != t[i]:
            print('No')
            exit()
        else:
            continue

dict_t = {}
for i in range(len(t)):
    if t[i] not in dict_t:
        dict_t[t[i]] = s[i]
    else:
        if dict_t[t[i]] != s[i]:
            print('No')
            exit()
        else:
            continue

print('Yes')

Submission status: Accepted

Solution code:
def listToString(_list, split=""):
    maped_list = map(str, _list)  # mapで要素すべてを文字列に
    mojiretu = split.join(maped_list)
    return mojiretu


def stringToList(_string, split=" "):
    str_list = []
    temp = ''
    for x in _string:
        if x == split:  # 区切り文字
            str_list.append(temp)
            temp = ''
        else:
            temp += x
    if temp != '':  # 最後に残った文字列を末尾要素としてリストに追加
        str_list.append(temp)
    return str_list


def asciiToindex(alphabet):
    return ord(alphabet) - ord("a")


s = input()
t = input()
# 　初期状態から、各操後の変換後テーブル
alpha = [i for i in range(asciiToindex("z") + 1)]
visited = [0 for i in range(asciiToindex("z") + 1)]

for i in range(len(s)):
    if alpha[asciiToindex(s[i])] != asciiToindex(t[i]):
        if visited[alpha[asciiToindex(s[i])]] == 1 or\
                        visited[asciiToindex(t[i])] == 1:
            print("No")
            exit()
        else:
            # tmp = 現在のs[i]の値
            tmp = alpha[asciiToindex(s[i])]
            for j in range(len(alpha)):
                if alpha[j] == tmp:
                    alpha[j] = asciiToindex(t[i])
                elif alpha[j] == asciiToindex(t[i]):
                    alpha[j] = tmp
    visited[asciiToindex(t[i])] = 1
    # print(listToString([chr(i+ord("a")) for i in alpha], "_"))
    # print("visited:{}".format(visited))
    # print(alpha)
print("Yes")

Submission status: Accepted

Solution code:
from collections import Counter

S = input()
T = input()

s_count = Counter(S)
t_count = Counter(T)

flag = True
for i in range(len(S)):
    if t_count.get(T[i]) != s_count.get(S[i]):
        flag = False
        break
print('Yes' if flag else 'No')

Submission status: Accepted

Solution code:
import sys
Ga={}
Gb={}
A=list(input())
B=list(input())
for i in range(len(A)):
  if A[i] in Ga and Ga[A[i]] != B[i]:
    print("No")
    sys.exit()
  else:
    Ga[A[i]] = B[i]
for i in range(len(B)):
  if B[i] in Gb and Gb[B[i]] != A[i]:
    print("No")
    sys.exit()
  else:
    Gb[B[i]] = A[i]
print("Yes")

Submission status: Accepted

Solution code:
Ga={}
Gb={}
A=list(input())
B=list(input())
flag = True
for i in range(len(A)):
  if A[i] in Ga and Ga[A[i]] != B[i]:
    flag = False
    break
  else:
    Ga[A[i]] = B[i]
for i in range(len(B)):
  if B[i] in Gb and Gb[B[i]] != A[i]:
    flag = False
    break
  else:
    Gb[B[i]] = A[i]
if flag:
  print("Yes")
else:
  print("No")

Submission status: Accepted

Solution code:
s=input()
t=input()
a,b={},{}
cnt=1

for i in range(len(s)):
    if s[i] not in a and t[i] not in b:
        a[s[i]]=cnt
        b[t[i]]=cnt
        cnt+=1
    elif s[i] in a and t[i] in b and (a[s[i]]==b[t[i]]):
        pass
    else:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
s=input()
t=input()
a,b={},{}
cnt=1
for i in s:
    if i not in a:
        a[i]=cnt
        cnt+=1
cnt=1
for i in t:
    if i not in b:
        b[i]=cnt
        cnt+=1

for i in range(len(s)):
    if a[s[i]]!=b[t[i]]:
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import collections

s=input()
t=input()

ans=True
sa=collections.Counter(s)
ta=collections.Counter(t)
for i in range(len(s)):
    if(ta.get(t[i])!=sa.get(s[i])):
        ans=False
        break
if(ans):
    print('Yes')
else:
    print('No')

Submission status: Accepted

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

s_c=collections.Counter(s)
s_t=collections.Counter(t)
for i in range(len(s_c)):
    if s_c.get(s[i]) != s_t.get(t[i]):
        print("No")
        exit()
print("Yes")

Submission status: Accepted

Solution code:
import sys
from collections import defaultdict

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

dcts = defaultdict(int)
dctt = defaultdict(int)
for i in range(L):
    s = S[i]
    t = T[i]
    if dcts[s] == 0:
        dcts[s] = t
    else:
        if dcts[s] != t:
            print('No')
            sys.exit()
    if dctt[t] == 0:
        dctt[t] = s
    else:
        if dctt[t] != s:
            print('No')
            sys.exit()
print('Yes')

Submission status: Accepted

Solution code:
import numpy as np

S = input()
T = input()

F = -np.ones(26,dtype=np.int)
G = -np.ones(26,dtype=np.int)
for i in range(len(S)):
    s = ord(S[i])-ord('a')
    t = ord(T[i])-ord('a')
    if F[s] < 0:
        F[s] = t
    elif F[s] != t:
        print('No')
        exit()

    if G[t] < 0:
        G[t] = s
    elif G[t] != s:
        print('No')
        exit()

print('Yes')

Submission status: Accepted

Solution code:
import sys
fin = sys.stdin.readline


S = fin()[:-1]
T = fin()[:-1]

correspondence = dict()
for char_s, char_t in zip(S, T):
    if char_s not in correspondence:
        correspondence[char_s] = char_t
    else:
        if char_t != correspondence[char_s]:
            print("No")
            exit(0)
if len(set(correspondence.values())) < len(correspondence):
    print("No")
else:
    print("Yes")

Submission status: Accepted

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

dictS={}
dictT={}

passed = True
for i in range((len(S))):
  s = S[i]
  t = T[i]
  if( not s in dictS.keys() ):
    dictS[s]=len(dictS)
  if( not t in dictT.keys() ):
    dictT[t]=len(dictT)

  if(dictS[s] != dictT[t]):
    print("No")
    passed=False
    break
    
if(passed):
  print("Yes")

Submission status: Accepted

Solution code:
S=input();T=input()
for i in range(2):
    d={}
    S,T = T,S
    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()

print("Yes")

Submission status: Accepted

Solution code:
def solve(S, T):
    sm = {}
    tm = {}
    for s, t in zip(S, T):
        if s in sm and sm[s] != t:
            return "No"
        sm[s] = t

        if t in tm and tm[t] != s:
            return "No"
        tm[t] = s

    return "Yes"


if __name__ == "__main__":
    S = input()
    T = input()
    print(solve(S, T))

Submission status: Accepted

Solution code:
s = input()
t = input()
n = len(s)
a = ord("a")
s_al = list()
t_al = list()
for i in range(a, 123):
    s_al.append(s.count(chr(i)))
    t_al.append(t.count(chr(i)))
s_al.sort()
t_al.sort()
if s_al == t_al:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


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

    st = dict()
    ts = dict()
    for s, t in zip(S, T):
        if s in st and st[s] != t:
            print(No)
            return
        st[s] = t
        if t in ts and ts[t] != s:
            print(No)
            return
        ts[t] = s

    print(Yes)


if __name__ == '__main__':
    main()

Submission status: Accepted

Solution code:
A = input()
B = input()

dica = {}
dicb = {}
for i, a in enumerate(list(A)):
    b = B[i]
    ai = dica.get(a, -1)
    bi = dicb.get(b, -1)
    if ai != bi:
        print('No')
        exit()
    dica[a] = i
    dicb[b] = i
print('Yes')

Submission status: Accepted

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

S = input().rstrip()
T = input().rstrip()
sm = {}

for i in range(len(S)):
    if S[i] in sm:
        sm[S[i]] = sm[S[i]] + 1
    else:
        sm[S[i]] = 1

st = {}
for i in range(len(T)):
    if T[i] in st:
        st[T[i]] = st[T[i]] + 1
    else:
        st[T[i]] = 1

sl = list(sm.values())
tl = list(st.values())
sl.sort()
tl.sort()

print('Yes' if sl == tl else 'No')

Submission status: Accepted

Solution code:
from collections import defaultdict
S,T = input(),input()
ss,ts = defaultdict(int),defaultdict(int)
for i in range(len(S)):
    ss[S[i]] += 1
    ts[T[i]] += 1
s = sorted(ss.items(),key=lambda x:x[1])
t = sorted(ts.items(),key=lambda x:x[1])
OK = True
for i in range(min(len(s),len(t))):
    if s[i][1]!=t[i][1]:
        OK = False
print('Yes' if OK else 'No')

Submission status: Accepted

Solution code:
S=input()
T=input()
kaesk=[i for i in range(97,97+26)]
ans=1

for i in range(len(S)):
    tmp=kaesk[ord(S[i])-97]
    no=0
    for j in range(26):
        if kaesk[j]==ord(T[i]):
            no=j
    kaesk[ord(S[i])-97]=ord(T[i])
    kaesk[no]=tmp


for i in range(len(S)):
    if kaesk[ord(S[i])-97]!=ord(T[i]):
        ans=0
        break
if ans==1:
    print("Yes")
else:
    print("No")

Submission status: Accepted

Solution code:
A=input()
B=input()
a=[0 for s in range(len(A))]
b=[0 for t in range(len(A))]

count=1
count2=1
for i in range(len(A)):
    j=i
    if a[i] == 0:
        while A.find(A[i],j) != -1:
            a[A.find(A[i],j)]=count
            j=A.find(A[i],j)+1
        count+=1
    j=i
    if b[i] == 0:
        while B.find(B[i],j) != -1:
            b[B.find(B[i],j)]=count2
            j=B.find(B[i],j)+1
        count2+=1
        
if a == b:
    print("Yes")
else:
    print("No")

Submission status: Accepted

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

mydict={}
for i in range(len(S)):
    if( S[i] in mydict):
        if(mydict[S[i]] != T[i]):
            print("No")
            sys.exit(0)
    else:
        mydict[S[i]]=T[i]

mydict={}
for i in range(len(T)):
    if( T[i] in mydict):
        if(mydict[T[i]] != S[i]):
            print("No")
            sys.exit(0)
    else:
        mydict[T[i]]=S[i]
print("Yes")

Submission status: Accepted

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


def trans_to_num(arr):
    letter_used = []
    num_arr = []
    for i in range(len(arr)):
        if arr[i] not in letter_used:
            letter_used.append(arr[i])
        num_arr.append(letter_used.index(arr[i]))
    return num_arr

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