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: Time Limit Exceeded

Solution code:
""" AtCoder """

S = input()
T = input()

for i in range(len(S)):
    index = i
    tmp = T[i]
    while True:
        index = S.find(S[i], index + 1)
        if index == -1:
            break

        if tmp != T[index]:
            print("No")
            exit()

for i in range(len(T)):
    index = i
    tmp = S[i]
    while True:
        index = T.find(T[i], index + 1)
        if index == -1:
            break
        if tmp != S[index]:
            print("No")
            exit()

print("Yes")

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
N=[i for i in range(len(S))]
visited=[]

for i in N:
    if (S[i] not in visited) and S[i]!=T[i]:
        visited.append(T[i])
        x=S[i]
        S=S.replace(T[i],'_')
        S=S.replace(S[i],T[i])
        S=S.replace('_',x)
    elif S[i] in visited and S[i]!=T[i]:
        break
    else:
        visited.append(T[i])
print('No') if S!=T else print('Yes')

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
visited=[]

for i in range(len(S)):
    if (S[i] not in visited) and S[i]!=T[i]:
        visited.append(T[i])
        x=S[i]
        S=S.replace(T[i],'_')
        S=S.replace(S[i],T[i])
        S=S.replace('_',x)
    elif S[i] in visited and S[i]!=T[i]:
        break
    else:
        visited.append(T[i])
print('No') if S!=T else print('Yes')

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
visited=[]

for i in range(len(S)):
    if (S[i] not in visited) and S[i]!=T[i]:
        visited.append(T[i])
        x=S[i]
        S=S.replace(T[i],'_')
        S=S.replace(S[i],T[i])
        S=S.replace('_',x)
    elif (S[i] in visited) and S[i]!=T[i]:
        break
    else:
        visited.append(T[i])
print('No') if S!=T else print('Yes')

Submission status: Time Limit Exceeded

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

def judge(S,T):
    count = 0
    while True:
        if count == len(S):
            break
        if S[count] == T[count]:
            count = count + 1
        else:
            c1 = S[count]
            c2 = T[count]
            for i in range(len(S)):
                if S[i] == c1:
                    S[i] = c2
                elif S[i] == c2:
                    S[i] = c1
            count = count + 1
    if S == T:
        print("Yes")
    else:
        print("No")
    #print(S)
    #print(T)
    
judge(s,t)

Submission status: Time Limit Exceeded

Solution code:
S,T=input(),input()
if len(S)==1:
    print('Yes')
else:
    for i in range(len(S)-1):
        for j in range(i+1,len(S)):
            ans='Yes'
            if (S[i]==S[j] and T[i]!=T[j]) or (S[i]!=S[j] and T[i]==T[j]):
                ans='No'
            if ans=='No':
                break
        if ans=='No':
            break
    print(ans)

Submission status: Time Limit Exceeded

Solution code:
S = list(str(input()))
T = list(str(input()))
check = 1
SC = [e for e in set(S) if S.count(e) > 1]
TC = [e for e in set(T) if T.count(e) > 1]
while len(S) > 0:
  if S[0] not in SC and T[0] not in TC:
    S.pop(0)
    T.pop(0)
  elif S[0]in SC and T[0] in TC:
    idxS = [j for j, x in enumerate(S) if x == S[0]]
    idxT = [j for j, x in enumerate(T) if x == T[0]]
    if idxS == idxT:
      for i in idxS[::-1]:
        S.pop(i)
        T.pop(i)
    else:
      check = 0
      break
  else:
    check = 0
    break
if check:
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

Solution code:
S = list(str(input()))
T = list(str(input()))
check = 1
while len(S) > 0:
  idxS = [j for j, x in enumerate(S) if x == S[0]]
  idxT = [j for j, x in enumerate(T) if x == T[0]]
  if idxS == idxT:
    for i in idxS[::-1]:
      S.pop(i)
      T.pop(i)
  else:
    check = 0
    break
if check:
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

Solution code:
S = str(input())
T = str(input())
def check(S):
  done = []
  for i in range(len(S)):
    if i not in done:
      indexes = [j for j, x in enumerate(S) if x == S[i]]
      done.append(indexes)
  return done
if check(S) == check(T):
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
sl = {}
tl = {}
for i in range(len(S)):
    if S[i] in sl:
        sl[S[i]] = sl[S[i]] + str(i)
    else:
        sl[S[i]] = str(i)
    if T[i] in tl:
        tl[T[i]] = tl[T[i]] + str(i)
    else:
        tl[T[i]] = str(i)
sv = [i for i in list(sl.values()) if len(i)>=2]
tv = [i for i in list(tl.values()) if len(i)>=2]
flag = True
if len(sv) != len(tv):
    flag = False
elif len(sv) == 0 and len(tv) == 0:
    pass
else:
    for v in sv:
        if not v in tv:
            flag = False
            break
    if flag:
        for v in tv:
            if not v in sv:
                flag = False
                break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
S_list = [i for i in S]
T_list = [i for i in T]
S_set = set(S_list)
T_set = set(T_list)
def judge():
  if len(S_set)==len(T_set)==len(S_list):
    return "Yes"
  for car in S_set:
    if [j for j, x in enumerate(T_list) if x == T_list[S_list.index(car)]]!=[j for j, x in enumerate(S_list) if x == car]:
      return "No"
  return "Yes"

print(judge())

Submission status: Time Limit Exceeded

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

def trans(c1, c2):
  tmp = ","
  return S.replace(c1, tmp).replace(c2, c1).replace(tmp, c2)

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

Submission status: Time Limit Exceeded

Solution code:
str1 = input()
str2 = input()

n = len(str1)
res = "Yes"
for i in range(n):
    for j in range(i+1,n):
        if str1[i] == str1[j]:
            if str2[i] != str2[j]:
                res = "No"
                break
        if str2[i] == str2[j]:
            if str1[i] != str1[j]:
                res = "No"
                break
    if res == "No":
        print(res)
        exit(0)

print(res)

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
n = len(S)
for i in range(n):
    s = S[i]
    t = T[i]
    S = S.translate(str.maketrans({s: t, t: s}))
if S == T:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
import sys

def main():
  input = sys.stdin.readline
  S = str(input().strip())
  T = str(input().strip())
  for i in range(len(S)):
    if S[i] == T[i]:
      continue
    else:
      c1, c2 = S[i], T[i]
      S = S.replace(c1, ' ')
      S = S.replace(c2, c1)
      S = S.replace(' ', c2)
  
  if S == T:
    print('Yes')
  else:
    print('No')


if __name__ == '__main__':
  main()

Submission status: Time Limit Exceeded

Solution code:
s=input()
t=input()
S=[0 for i in range(26)]
T=[0 for i in range(26)]
for i in range(len(s)):
    S[ord(s[i])-97]=int(str(S[ord(s[i])-97])+str(i))  
for i in range(len(t)):
    T[ord(t[i])-97]=int(str(T[ord(t[i])-97])+str(i))  
ss=sorted(S)
tt=sorted(T)
if ss==tt:
    print('Yes')
else:print('No')

Submission status: Time Limit Exceeded

Solution code:
s=input()
t=input()
S=[0 for i in range(26)]
T=[0 for i in range(26)]
for i in range(26):
    for j in range(len(s)):
        if s[j]==chr(i+97):
            S[i]=int(str(S[i])+str(j))
for i in range(26):
    for j in range(len(t)):
        if t[j]==chr(i+97):
            T[i]=int(str(T[i])+str(j))  
ss=sorted(S)
tt=sorted(T)
if ss==tt:
    print('Yes')
else:print('No')

Submission status: Time Limit Exceeded

Solution code:
s=input()
t=input()
S=[[] for i in range(len(s))]
T=[[] for i in range(len(t))]
c=0
d=0
for i in range(len(s)):
    if S[i]==[]:
        S[i]=[s.count(s[i])]
        c=s.count(s[i])
        for j in range(i,len(s)):
            if s[j]==s[i]:
                S[j]=[c]
for i in range(len(t)):
    if T[i]==[]:
        T[i]=[t.count(t[i])]
        d=t.count(t[i])
        for j in range(j,len(t)):
            if t[j]==t[i]:
                T[j]=[d]            
if S==T:
    print('Yes')
else:print('No')

Submission status: Time Limit Exceeded

Solution code:
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 = s.translate(s.maketrans({s[i]:t[i], t[i]:s[i]}))

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

Submission status: Time Limit Exceeded

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

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

for i in range(len(s)):
    for j in range(26):
        if s[i] == atoz[j]:
            s_list[j].append(1)
        else:
            s_list[j].append(0)

t_list = [[] for i in range(26)]

for i in range(len(t)):
    for j in range(26):
        if t[i] == atoz[j]:
            t_list[j].append(1)
        else:
            t_list[j].append(0)

s_sort = sorted(s_list)
t_sort = sorted(t_list)

if s_sort == t_sort:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

for i in range(len(s)):
    if s[i] != t[i]:
        be = s[i]
        af = t[i]
        for i in range(len(s)):
            if s[i] == be:
                s[i] = af
            elif s[i] == af:
                s[i] = be

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

Submission status: Time Limit Exceeded

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

def func(s, t):
    for i, (a, b) in enumerate(zip(s, t)):
        while True:
            ss, tt = s[i + 1:], t[i + 1:]
            si = ss.find(a)
            ti = tt.find(b)
            if si != ti:
                return 'No'
            if si == -1:
                break
            i += si + 1
    return 'Yes'

ans = func(s, t)

print(ans)

Submission status: Time Limit Exceeded

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

U = [[S[i],T[i]] for i in range(len(S))]
U.sort()

tmp=''
g_tmp=[]
for a in U:
  if tmp!=a[0]:
    tmp=a[0]
    tmp_s=[]
    if a[1] in g_tmp:
      print('No')
      break
    g_tmp.append(a[1])
    
  tmp_s.append(a[1])
  if len(set(tmp_s))!=1:
    print('No')
    break
else:
  print('Yes')

Submission status: Time Limit Exceeded

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

for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        s = s.translate(str.maketrans({s[i]: t[i], t[i]: s[i]}))
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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 s == t:
        print("Yes")
    else:
        print("No")
s=input()
t=input()
main(s,t)

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
def alpha(s_list,N):
    ss =""
    S = [0 for i in range(N)]
    for i in range(len(s_list)):
        for j in s_list[i]:
            S[j] = chr(i+97)
    for i in range(len(S)):
        ss = ss + str(S[i])
    
    return ss
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)

for i in range(len(S)):
    if S[i] != T[i]:
        #S[i]がT[i]になるように入れ替える
        temp = s_list[ord(S[i])-97] #T[i]
        s_list[ord(S[i])-97] = s_list[ord(T[i])-97]
        s_list[ord(T[i])-97] = temp
    S = alpha(s_list,len(S))
if s_list == t_list:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
a = input()
b = input()
ar = list(a)
br = list(b)
ca = 0
cb = 0
for i in range(len(a)):
    if a[i] in br:
        br.remove(a[i])
for i in range(len(b)):
    if b[i] in ar:
        ar.remove(b[i])
if len(set(ar)) == len(set(br)):
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
buf=[]
for i in range(len(S)):
    if S[i]==T[i]:
        continue
    else:
        if not(S[i] in buf):
            buf.append(T[i])
            table = str.maketrans({S[i]:T[i],
                                    T[i]: S[i],
                                  })
            S = S.translate(table)
            if S==T:
                break
    if S==T:
        break
if S==T:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:

S=input()
T=input()
buf=[]
for i in range(len(S)):
    if S[i]==T[i]:
        continue
    else:
        if not(S[i] in buf):
            buf.append(T[i])
            table = str.maketrans({S[i]:T[i],
                                    T[i]: S[i],
                                  })
            S = S.translate(table)
            if S==T:
                break
if S==T:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

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


def answer(S, T, N):
    i = 0
    while i < N:
        c1 = S[i]
        c2 = T[i]
        # print("c1:", str(c1))
        # print("c2:", str(c2))
        if c1 != c2:
            for j in range(N):
                # print([S[j], c1])
                # print([T[j], c2])
                if S[j] == c1 and T[j] != c2:
                    return False
        i += 1

    return True


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

N = len(S)

ST = [None] * N

for i in range(N):
    ST[i] = [S[i], T[i]]

ST.sort(key=lambda a_i: a_i[0])

for i in range(N):
    S[i] = ST[i][0]
    T[i] = ST[i][1]

ans1 = answer(S, T, N)

ST.sort(key=lambda a_i: a_i[1])

for i in range(N):
    S[i] = ST[i][0]
    T[i] = ST[i][1]

# print(S)
# print(T)

ans2 = answer(T, S, N)

if ans1 and ans2:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

dicS = {}
dicT = {}

for i,_s_ in enumerate(S):
   if not _s_ in dicS:
       dicS[_s_] = []
   dicS[_s_] = dicS[_s_] + [i]
   
for i,_t_ in enumerate(T):
    if not _t_ in dicT:
        dicT[_t_] = []
    dicT[_t_] = dicT[_t_] + [i]
    
listS = []
listT = []

for _s_ in dicS.values():
    listS.append(_s_)
    
for _t_ in dicT.values():
    listT.append(_t_)

for i,_s_ in enumerate(listS):
    listS[i] = tuple(_s_)
    
for i,_t_ in enumerate(listT):
    listT[i] = tuple(_t_)


setS = set(listS)
setT = set(listT)

if setS == setT:
   print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import string

S = input()
T = input()

S_ = []
T_ = []
for c in string.ascii_lowercase:
    S_.append(np.array(list(map(lambda x: 0 if c != x else 1, S))))
    T_.append(np.array(list(map(lambda x: 0 if c != x else 1, T))))

for s_ in S_:
    flag = False
    for i,t_ in enumerate(T_):
        if np.all(t_- s_ == 0):
            flag = True
            T_.pop(i)
            break
    if not flag:
        print("No")
        exit(0)

print("Yes")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import string

S = input()
T = input()

S_ = []
T_ = []
for c in string.ascii_lowercase:
    S_.append(np.array(list(map(lambda x: 0 if c != x else 1, S))))
    T_.append(np.array(list(map(lambda x: 0 if c != x else 1, T))))

for s_ in S_:
    flag = False
    for t_ in T_:
        if np.all(t_- s_ == 0):
            flag = True
            break
    if not flag:
        print("No")
        exit(0)

print("Yes")

Submission status: Time Limit Exceeded

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

i=0
L=len(S)
while i<L:
    if S[i]!=T[i]:
        S=S.translate(str.maketrans({S[i]: T[i], T[i]: S[i]}))
    i+=1

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

Submission status: Time Limit Exceeded

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

out_str = "Yes"
well_known_indexes = []
for i in range(len(S)) :
	if(i in well_known_indexes) :
		continue

	indexes_s = [n for n, x in enumerate(list(S)) if x == S[i]]
	indexes_t = [n for n, x in enumerate(list(T)) if x == T[i]]
	if (indexes_s == indexes_t) :
		well_known_indexes.extend(indexes_s)
		continue
	out_str = "No"
	break

print(out_str)

Submission status: Time Limit Exceeded

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

out_str = "Yes"
for i in range(len(S)) :
	indexes_s = [n for n, x in enumerate(list(S)) if x == S[i]]
	indexes_t = [n for n, x in enumerate(list(T)) if x == T[i]]
	if (indexes_s == indexes_t) :
		continue
	out_str = "No"
	break

print(out_str)

Submission status: Time Limit Exceeded

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

out_str = "Yes"
for i in range(len(S)) :
	indexes_s = [n for n, x in enumerate(list(S)) if x == S[i]]
	indexes_t = [n for n, x in enumerate(list(T)) if x == T[i]]
	if (indexes_s == indexes_t) :
		continue
	out_str = "No"

print(out_str)

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
def string_transformation(s, t):
    for i in range(len(s)):
        text = s[i]
        textt = t[i]
        for j in range(i, len(s)):
            if text == s[j]:
                if textt != t[j]:
                    return 'No'
            if textt == t[j]:
                if text != s[j]:
                    return 'No'
    return 'Yes'


s = input()
t = input()
print(string_transformation(s, t))

Submission status: Time Limit Exceeded

Solution code:
def string_transformation(s, t):
    for i in range(len(s)):
        text = s[i]
        textt = t[i]
        for j in range(len(s)):
            if text == s[j]:
                if textt != t[j]:
                    return 'No'
            if textt == t[j]:
                if text != s[j]:
                    return 'No'
    return 'Yes'


s = input()
t = input()
print(string_transformation(s, t))

Submission status: Time Limit Exceeded

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

s=list(input().rstrip())
t=input().rstrip()
l=[]
for i in zip(s,t):
    l.append(i)
for j in l:
    for k in l:
        if j[0]==k[0]:
            if j[1]!=k[1]:
                print('No')
                exit()
        elif j[1]==k[1]:
            if j[0]!=k[0]:
                print('No')
                exit()
print('Yes')

Submission status: Time Limit Exceeded

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

ans = 'Yes'

for j in range(len(s)):
    if s.count(s[j]) != t.count(t[j]):
        ans = 'No'

print(ans)

Submission status: Time Limit Exceeded

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

arr = [[s[i],t[i]] for i in range(len(s))]

ans = 'Yes'

for j in range(len(s)):
    if s.count(s[j]) != t.count(t[j]) or s.count(s[j]) != arr.count(arr[j]):
        ans = 'No'

print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = list(input())
t = list(input())
#s = ['a','b','a']
#t = ['d','e','f']

arr = [[s[i],t[i]] for i in range(len(s))]

ans = 'Yes'

for y in arr:
	for j in range(len(s)):
		if y[0] == arr[j][0] and y[1] != arr[j][1]:
			ans = 'No'
		elif y[1] == arr[j][1] and y[0] != arr[j][0]:
			ans = 'No'


print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = input()
j = [str(x) for x in list(str(s))]
t = input()
k = [str(x) for x in list(str(t))]

ar = []

for i in range(len(j)):
    if j[i] != k[i]:
        if j[i] in ar:
            break
        """if j[i] not in ar:
            ar.append(j[i])"""
        com = j[i]
        j[i] = k[i]
        if j[i] not in ar:
            ar.append(j[i])
        for h in range(len(j)):
            if j[h] == com:
                j[h] = k[i]
            elif j[h] == k[i] and h != i:
                j[h] = com

if j == k:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
s = input()
j = [str(x) for x in list(str(s))]
t = input()
k = [str(x) for x in list(str(t))]

for i in range(len(j)):
    if j[i] != k[i]:
        com = j[i]
        j[i] = k[i]
        for h in range(len(j)):
            if j[h] == com:
                j[h] = k[i]
            elif j[h] == k[i] and h != i:
                j[h] = com

if j == k:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
s = list(S)
t = list(T)
a = len(s)
i = 0
while i < a:
    for j in range(a-1):
        if (s[i] == s[j]) and (t[i] != t[j]):
            print("No")
            exit()
        if (t[i] == t[j]) and (s[i] != s[j]):
            print("No")
            exit()
    i = i+1
    if i == a:
        print("Yes")
        break

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
l = len(S)
right = True
for c in range(26):
    st = set()
    for i in range(l):
        if ord(T[i]) == ord('a') + c:
            st.add(S[i])
    if len(st) > 1:
        right = False
for c in range(26):
    st = set()
    for i in range(l):
        if ord(S[i]) == ord('a') + c:
            st.add(T[i])
    if len(st) > 1:
        right = False
print("Yes" if right else "No")

Submission status: Time Limit Exceeded

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

def swap(s,c1,c2):
    a = "0"
    s = s.replace(c1,a)
    s = s.replace(c2,c1)
    s = s.replace(a,c2)
    return s

for i in range(len(S)):
    if S[i] == T[i]:
        continue
    else:
        S = swap(S,S[i],T[i])

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

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
s_list,t_list = list(),list()
for i in range(len(s)):
    s_list.append(s[i])
    t_list.append(t[i])
if len(set(s_list)) == len(set(t_list)):
    for ii in range(len(s)):
        if s_list[ii] != t_list[ii]:
            c_1 = s_list[ii]
            c_2 = t_list[ii]
            for iii in range(len(s)):
                if c_1 == s_list[iii]:
                    s_list[iii] = c_2
                elif c_2 == s_list[iii]:
                    s_list[iii] = c_1
    if s_list == t_list:
        print("Yes")
    else:
        print("No")
else:
    print("No")

Submission status: Time Limit Exceeded

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


for i in range(len(S)):
    str1, str2 = S[i], T[i]
    S = S.replace(str1, "0")
    S = S.replace(str2, "1")
    S = S.replace("0", str2)
    S = S.replace("1", str1)

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

Submission status: Time Limit Exceeded

Solution code:
import sys

s = list(input())
t = list(input())
n = len(s)

u = []
v = []

for i in range(n):
    if s[i] != t[i]:
        u.append(s[i])
        v.append(t[i])

m = len(u)

if m == 0:
    print('Yes')
    sys.exit()
else:
    for j in range(m):
        for k in range(j, m):
            if u[j]==u[k] and v[j]!=v[k]:
                print('No')
                sys.exit()
            
            if v[j]==v[k] and u[j]!=u[k]:
                print('No')
                sys.exit()

print('Yes')

Submission status: Time Limit Exceeded

Solution code:
LN1 = list(input())
LN2 = list(input())

LL1 = len(LN1)
LL2 = len(LN2)

LV1 = [0]
LV2 = [0]

CO = 1

for i in range(1,LL1):
    CH = 0
    for x in range(0,i): 
        if LN1[i] == LN1[x]:
            LV1.append(LV1[x])
            CH = 1
    if CH == 0:
        LV1.append(CO)
        CO += 1

CO = 1

for i in range(1,LL1):
    CH = 0
    for x in range(0,i): 
        if LN2[i] == LN2[x]:
            LV2.append(LV2[x])
            CH = 1
    if CH == 0:
        LV2.append(CO)
        CO += 1

if LV1 == LV2:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
s=input()
t=input()
l=len(s)
sl=[]
tl=[]
slist=[]
tlist=[]
flag=0
for i in range(l):
    if not i in slist:
        si=s[i]
        for j in range(l):
            if s[j]==si:
                slist.append(j)
    if not i in tlist:
        ti=t[i]
        for j in range(l):
            if t[j]==ti:
                tlist.append(j)
    if slist!=tlist:
        flag=1
        break
if flag==1:
    print('No')
else:
    print('Yes')

Submission status: Time Limit Exceeded

Solution code:
s = list(input())
t = list(input())
pair = []
ans = "Yes"

def check(pair,i,s,t):
    for j in range(len(pair)):
        if s!=pair[j][0] and s!=pair[j][1] and t!=pair[j][0] and t!=pair[j][1]:
            pass
        elif s==pair[j][0] and t==pair[j][1]:
            pass
        elif s==pair[j][1] or t==pair[j][0]:
            pass
        else:
            return False
    return True

def check2(pair,i,s,t):
    for j in range(len(pair)):
        if (s==pair[j][0] and t!=pair[j][1])or(s!=pair[j][0] and t==pair[j][1]):
            return False
    return True

for i in range(len(s)):
    if check2(pair,i,s[i],t[i]):
        pair.append([s[i],t[i]])
    else:
        ans = "No"
        break

print(ans)

Submission status: Time Limit Exceeded

Solution code:
s = list(input())
t = list(input())
pair = []
ans = "Yes"

def check(pair,i,s,t):
    for j in range(len(pair)):
        if s!=pair[j][0] and s!=pair[j][1] and t!=pair[j][0] and t!=pair[j][1]:
            pass
        elif s==pair[j][0] and t==pair[j][1]:
            pass
        elif s==pair[j][1] or t==pair[j][0]:
            pass
        else:
            return False
    return True

for i in range(len(s)):
    if check(pair,i,s[i],t[i]):
        pair.append([s[i],t[i]])
    else:
        ans = "No"
        break

print(ans)

Submission status: Time Limit Exceeded

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

def restr2(s, t):
    if len(set(s)) != len(set(t)):
        return False
    for i in range(len(s)):
        for j in range(i+1, len(s)):
            if s[i] == s[j]:
                if t[i] != t[j]:
                    return False
    return True

print('Yes' if restr2(s, t) else 'No')

Submission status: Time Limit Exceeded

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

def restr(string):
    result = []
    for i in range(len(string)):
        tmp = [i]
        for j in range(i+1, len(string)):
            if string[i] == string[j]:
                tmp.append(j)
        if len(tmp) > 1:
            result.append(tmp)
    return result

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

Submission status: Time Limit Exceeded

Solution code:
from collections import deque

s = input()
t = input()

def restr(string):
    result = []
    for i in range(len(string)):
        tmp = [i]
        for j in range(i+1, len(string)):
            if string[i] == string[j]:
                tmp.append(j)
        if len(tmp) > 1:
            result.append(tmp)
    return result

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

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
l = len(S)
flag = "Yes"
for i in range(l):
    for j in range(l):
        if (S[i] == S[j] and T[i] != T[j]):
            flag = "No"
        if (S[i] != S[j] and T[i] == T[j]):
            flag= "No"

print(flag)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


SS = stdin.readline().rstrip()
TT = stdin.readline().rstrip()

S = list(SS)
T = list(TT)

N = len(S)

ret = "Yes"

for i in range(0, N):
    if ret == "No":
        break

    for j in range(i+1, N):
        if S[i] == S[j]:
            if T[i] != T[j]:
                ret = "No"
        if T[i] == T[j]:
            if S[i] != S[j]:
                ret = "No"

print(ret)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


S = stdin.readline().rstrip()
T = stdin.readline().rstrip()

N = len(S)

ret = "Yes"

for i in range(0, N):
    if ret == "No":
        break

    for j in range(i+1, N):
        if S[i] == S[j]:
            if T[i] != T[j]:
                ret = "No"
        if T[i] == T[j]:
            if S[i] != S[j]:
                # print("type2:",i,j, S[j],T[j])
                ret = "No"

print(ret)

Submission status: Time Limit Exceeded

Solution code:
from sys import stdin


S = stdin.readline().rstrip()
T = stdin.readline().rstrip()

N = len(S)

ret = "Yes"

for i in range(0, N):
    for j in range(i+1, N):
        if S[i] == S[j]:
            if T[i] != T[j]:
                # print("type1:",i,j, S[j],T[j])
                ret = "No"
        if T[i] == T[j]:
            if S[i] != S[j]:
                # print("type2:",i,j, S[j],T[j])
                ret = "No"

print(ret)

Submission status: Time Limit Exceeded

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

for w in S:
    if w in T:
        idxs = [i for i, x in enumerate(S) if x == w]
        idxt = [i for i, x in enumerate(T) if x == w]
        for num in idxs[::-1]:
            del S[num]
        for num in idxt[::-1]:
            del T[num]

s_count = Counter(S)
del_s = ''
t_count = Counter(T)
del_t = ''

for ks, vs in list(s_count.items()):
    for kt, vt in list(t_count.items()):
        if vs == vt:
            del_s += ks
            del_t += kt
            del s_count[ks]
            del t_count[kt]
            break

if len(set(S)) == len(del_s) and len(set(T)) == len(del_t):
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

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

for w in S:
    if w in T:
        idxs = [i for i, x in enumerate(S) if x == w]
        idxt = [i for i, x in enumerate(T) if x == w]
        for num in idxs[::-1]:
            del S[num]
        for num in idxt[::-1]:
            del T[num]

s_count = Counter(S)
del_s = []
t_count = Counter(T)
del_t = []

for ks, vs in list(s_count.items()):
    for kt, vt in list(t_count.items()):
        if vs == vt:
            del_s.append(ks)
            del_t.append(kt)
            del s_count[ks]
            del t_count[kt]
            break

if len(set(S)) == len(del_s) and len(set(T)) == len(del_t):
    print('Yes')
else:
    print('No')