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:
S = input()
T = input()
for i in range(len(S)):    
    if S[i] != T[i]:
        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:
# -*- coding: utf-8 -*-
# !/usr/bin/env python
# vim: set fileencoding=utf-8 :

"""
#
# Author:   Noname
# URL:      https://github.com/pettan0818
# License:  MIT License
# Created: 日  9/23 21:36:03 2018

# Usage
#
"""
CHAR_LIST = [chr(i) for i in range(97, 97+26)]
def get_input():
    first = input()
    second = input()

    return first, second

def okikae(target_str):
    """
    >>> a = okikae("apple")
    >>> b = okikae("azzel")
    >>> a==b
    """
    res = [-1] * len(target_str)
    for n, char in enumerate(list(set(target_str))):
        res = [n if i == char else d for i, d in zip(target_str, res)]

    las = [-1] * len(target_str)
    for n, good in enumerate(res):
        las = [n if i == good else d for i,d in zip(res, las)]
    return las

if __name__ == '__main__':
    A, B = get_input()
    if okikae(A) == okikae(B):
        print("Yes")
    else:
        print("No")

Submission status: Time Limit Exceeded

Solution code:

s = input()
t = input()

[globals().update({'s': s.translate(str.maketrans({s[i]: t[i], t[i]: s[i]}))}) for i in range(len(s))]

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import copy

def main():
    data0 = np.array(list(input()))
    data1 = np.array(list(input()))

    flag = True
    data_tmp = data0
    for c0, c1 in zip(data0, data1):
        if list(data0 == c0) == list(data1 == c1):
            data0 = data0[data0 != c0]
            data1 = data1[data1 != c1]
        else:
            flag = False

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



def swap(data, c0, c1):
    data_tmp = copy.copy(data)
    data_tmp[data == c0] = c1
    data_tmp[data == c1] = c0
    return data_tmp

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

s = input()
t = input()

for i in range(len(s)):
    if s[i] != t[i]:
        tmp = s[i]
        d = str.maketrans(t[i], "*")
        s = s.translate(d)
        d = str.maketrans(s[i], t[i])
        s = s.translate(d)
        d = str.maketrans("*", tmp)
        s = s.translate(d)

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

Submission status: Time Limit Exceeded

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

def c(a,b,s):
    li=""
    for i in s:
        if i==a:
            li+=b
        elif i==b:
            li+=a
        else:
            li+=i
    return li
    
l=[]

for i in range(len(t)):
    if s[i]!=t[i]:
        for j in l:
            if s[i]==j:
                print("No")
                sys.exit()
        l.append(t[i])
        s=c(s[i],t[i],s)
    
        

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

Submission status: Time Limit Exceeded

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



for i in range(len(S)+1):
	s = str(S[i:i+1])
	t = str(T[i:i+1])
	S = S.replace(s,'A').replace(t,s).replace('A',t)

answer = 'No'

if S == T:
	answer = 'Yes'
	
print(answer)

Submission status: Time Limit Exceeded

Solution code:
m = input()
n = input()
 
def decs():
   if len(set(list(m))) != len(set(list(n))):
       return False

   j = 0
   for i in range(0,len(m)-2):
       j = i+1
       while j < len(m):
           
           if (m[i] == m[j] and n[i] != n[j]) or (n[i] == n[j] and m[i] != m[j]):
                   return False
               
           j += 1
 
   return True
           
   
if decs():
   print("Yes")
else:
   print("No")

Submission status: Time Limit Exceeded

Solution code:

s = input()
t = input()

for i in range(len(s)):

    # そうでない場合、s[i]をt[i]にtranslate
    s = s.translate(str.maketrans({s[i]: t[i], t[i]: s[i]}))

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

Submission status: Time Limit Exceeded

Solution code:
s = list(str(input()))
t = list(str(input()))
for i in range(len(s)):
    if s[i] != t[i]:
        c1 = s[i]
        c2 = t[i]
        for j in range(len(s)):
            if s[j] == c1:
                s[j] = c2
            else:
                if s[j] == c2:
                    s[j] = c1
if s == t:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
import sys
import socket

hostname = socket.gethostname()

if hostname == 'F551C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    S = read_str()
    T = read_str()
    n = len(S)
    res = 'Yes'
    for i in range(n):
        for j in range(n):
            if S[i] != S[j] and T[i] == T[j]:
                res = 'No'
            if S[i] == S[j] and T[i] != T[j]:
                res = 'No'
    print(res)


main()

Submission status: Time Limit Exceeded

Solution code:
S=list(input())
T=list(input())
N=len(S)
l=[]
i=0

for i in range(N):
  indexes = [f for f, x in enumerate(S) if x == S[i]]
  l.append(indexes)

  


l2=[]  
for i in range(N):
  indexes2 = [f for f, x in enumerate(T) if x == T[i]]
  l2.append(indexes2)

  
if l==l2:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

Solution code:
import sys

s = input()
t = input()

debug = False


def d(*s):
    print(*s) if debug else None


# 一致すればOK
if s == t:
    print("Yes")
    sys.exit()

for i in range(len(s)):

    # # 同じ文字ならスキップ
    d(s[i], t[i])
    if s[i] == t[i]:
        continue

    # そうでない場合、s[i]をt[i]にtranslate
    d("before", s)
    d("translate", {s[i]: t[i], t[i]: s[i]})
    s = s.translate(str.maketrans({s[i]: t[i], t[i]: s[i]}))
    d("after", s)

    if s == t:
        break

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

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
import copy

def main():
    data0 = np.array(list(input()))
    data1 = np.array(list(input()))

    flag = True
    data_tmp = data0
    for c0, c1 in zip(data0, data1):
        if list(data0 == c0) == list(data1 == c1):
            pass
        else:
            flag = False

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



def swap(data, c0, c1):
    data_tmp = copy.copy(data)
    data_tmp[data == c0] = c1
    data_tmp[data == c1] = c0
    return data_tmp

if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
# s = "azzel"
# t = "apple"

debug = False


def d(*s):
    print(*s) if debug else None


for i in range(len(s)):
    # # 同じ文字ならスキップ
    # d(s[i], t[i])
    # if s[i] == t[i]:
    #     continue

    # そうでない場合、s[i]をt[i]にtranslate
    d("before", s)
    d("translate", {s[i]: t[i], t[i]: s[i]})
    s = s.translate(str.maketrans({s[i]: t[i], t[i]: s[i]}))
    d("after", s)
    # 一致すればOK
    if s == t:
        break

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

Submission status: Time Limit Exceeded

Solution code:
m = input()
n = input()
 
def decs():
   j = 0
   for i in range(0,len(m)-2):
       j = i+1
       while j < len(m):
           
           if (m[i] == m[j] and n[i] != n[j]) or (n[i] == n[j] and m[i] != m[j]):
                   return False
               
           j += 1
 
   return True
           
   
if decs():
   print("Yes")
else:
   print("No")

Submission status: Time Limit Exceeded

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

a = True
if len(S) == len(T):
    for s,t in zip(S,T):
        if [i for i, x in enumerate(S) if x == s] != [i for i, x in enumerate(T) if x == t]:
            print("No")
            a = False
            break
    if a:
        print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
# s = "azzel"
# t = "apple"

debug = False


def d(*s):
    print(*s) if debug else None


for i in range(len(s)):
    # 同じ文字ならスキップ
    d(s[i], t[i])
    if s[i] == t[i]:
        continue

    # そうでない場合、s[i]をt[i]にtranslate
    d("before", s)
    d("translate", {s[i]: t[i], t[i]: s[i]})
    s = s.translate(str.maketrans({s[i]: t[i], t[i]: s[i]}))
    d("after", s)
    # 一致すればOK
    if s == t:
        break

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

Submission status: Time Limit Exceeded

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


    
l=[]

for i in range(len(t)):
    if s[i]!=t[i]:
        for j in l:
            if s[i]==j:
                print("No")
                sys.exit()
        l.append(t[i])
        u=s.replace(s[i],"A")
        v=u.replace(t[i],s[i])
        s=v.replace("A",t[i])
    
        

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

Submission status: Time Limit Exceeded

Solution code:
s=input()
t=input()
n=len(s)
sl=list(s)
tl=list(t)
l=[sl,tl]
l2=[list(x) for x in zip(*l)]
l2=sorted(l2,key=lambda x:x[0])
l2=[list(x) for x in zip(*l2)]
s=''.join(l2[0])
t=''.join(l2[1])
a=''
for i in range(n):
    if(s[i]==a):continue
    a=s[i]
    b=t[i]
    s=s.translate(str.maketrans({a:b,b:a}))
    
    
if(s==t):print("Yes")
else:print("No")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
s=input()
t=input()
n=len(s)
sl=list(s)
tl=list(t)
l=[sl,tl]


l=np.array(l).T
l=sorted(l,key=lambda x:x[0])
l=np.array(l).T
s=''.join(l[0])
t=''.join(l[1])
a=''
for i in range(n):
    if(s[i]==a):continue
    a=s[i]
    b=t[i]
    s=s.translate(str.maketrans({a:b,b:a}))
    
    
if(s==t):print("Yes")
else:print("No")

Submission status: Time Limit Exceeded

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

a = len(s)

d = []

for i in range(a):
	if s[i] != t[i] and s[i] not in d:
		d.append(t[i])
		b = str(s[i])
		c = str(t[i])
		s = s.replace(b,'.')
		s = s.replace(c,b)
		s = s.replace('.',c)


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

Submission status: Time Limit Exceeded

Solution code:
from operator import itemgetter
s=list(input())
t=list(input())
n=len(s)
l=[s,t]
l=[list(x) for x in zip(*l)]
l.sort(key=itemgetter(1,0))
l=[list(x) for x in zip(*l)]
s=''.join(l[0])
t=''.join(l[1])
a=''
for i in range(n):
    if(s[i]==a):continue
    a=s[i]
    b=t[i]
    s=s.translate(str.maketrans({a:b,b:a}))
    
    
if(s==t):print("Yes")
else:print("No")

Submission status: Time Limit Exceeded

Solution code:
m = input()
n = input()

def decs():
   j = 0
   for i in range(0,len(m)-2):
       j = i+1
       while j < len(m):
           
           if m[i] == m[j]:
               if n[i] != n[j]:
                   return False
           if n[i] == n[j]:
               if m[i] != m[j]:
                   return False
               
           j += 1

   return True
           
   
if decs():
   print("Yes")
else:
   print("No")

Submission status: Time Limit Exceeded

Solution code:
def transform(a, b):
    f = ""
    for i in range(len(a)):
        if a[i] in f:
            break
        else:
            check = [b[i]]
            for j in range(i+1,len(a)):
                if a[i] == a[j]:
                    check += b[j]

            if len(set(check)) > 1:
                return False
    return True

S = input()
T = input()
ans = transform(S, T) and transform(T, S)

print(("No", "Yes")[ans])

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
def check(a,b):
  for c in a:
    if a.count(c) > 1:
      m = [i for i, x in enumerate(a) if x == c]
      w = b[m[0]]
      for i in range(1,len(m)):
        if b[m[i]] != w:
          return "No" 
  return "Yes"
ans = check(s,t)
if ans == "Yes" : ans = check(t,s)
print(ans)

Submission status: Time Limit Exceeded

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

    for i in range(len(s)):
        _s, _t = s[i], t[i]
        if not _s == _t:
            s = s.translate(str.maketrans({_s: _t, _t: _s}))

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


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
def main(S, T):
    S = list(S)
    T = list(T)
    if S == T:
        return "Yes"
    l = len(S)
    for i in range(l):
        s = S[i]
        t = T[i]
        if s != t:
            for j in range(l):
                if S[j] == s:
                    S[j] = t
                elif S[j] == t:
                    S[j] = s
            #print("%s -> %s"%(s, t), "".join(S))
    return "Yes" if S == T else "No"

assert main("chokudai", "redcoder") == "No"
assert main("azzel", "apple") == "Yes"
assert main("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu") == "Yes"
S = input()
T = input()
print(main(S, T))

Submission status: Time Limit Exceeded

Solution code:
S=list(input())
T=list(input())
N=len(S)
l=[]
for i in range(N):
  k=[]
  for j in range(N):
    if S[i]==S[j] and i<j:
      break
    elif S[i]==S[j] and i>=j:  
      k.append(j)
    else:
      continue
    l.append(k)
    
l2=[]  
for i in range(N):
  k=[]
  for j in range(N):
    if T[i]==T[j] and i<j:
      break
    elif T[i]==T[j] and i>=j:  
      k.append(j)
    else:
      continue
    l2.append(k)

if l==l2:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

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

s = input()
t = input()

for i in range(len(s)):
    if s[i] != t[i]:
        tmp = s[i]
        s = s.replace(t[i], "*")
        s = s.replace(s[i], t[i])
        s = s.replace("*", tmp)

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

Submission status: Time Limit Exceeded

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

def get_yes(s, t):
    s_dup_lists = []
    t_dup_lists = []

    for i, (s1, t1) in enumerate(zip(s, t)):
        for j, (s2, t2) in enumerate(zip(s, t)):
            if (i != j) and (s1 == s2):
                s_dup_lists.append([i, j])
            if (i != j) and (t1 == t2):
                t_dup_lists.append([i, j])
            if s_dup_lists != t_dup_lists:
                return 'No'

    if s_dup_lists == t_dup_lists:
        return 'Yes'
    else:
        return 'No'
print(get_yes(s, t))

Submission status: Time Limit Exceeded

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

a = len(s)



for i in range(a):
	if s[i] != t[i]:
		b = str(s[i])
		c = str(t[i])
		s = s.replace(b,'.')
		s = s.replace(c,b)
		s = s.replace('.',c)

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

Submission status: Time Limit Exceeded

Solution code:
def transform(a, b):
    for i in range(len(a)):
        check = [b[i]]
        for j in range(i+1,len(a)):
            if a[i] == a[j]:
                check += b[j]

        if len(set(check)) > 1:
            return False
    return True

S = input()
T = input()
ans = transform(S, T) and transform(T, S)

print(("No", "Yes")[ans])

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

s = input()
t = input()

repeat_list = []

for i1, c1 in enumerate(t):
	for i2 in range(i1+1, len(t)):
		c2 = t[i2]
		if c1 == c2:
			flg = 1
			repeat_list.append((i1, i2))

answer_flg = 0
for element in repeat_list:
	if s[element[0]] != s[element[1]]:
		answer_flg = 1
		break

for i1, c1 in enumerate(s):
	for i2 in range(i1+1, len(s)):
		c2 = s[i2]
		if c1 == c2:
			flg = 1
			repeat_list.append((i1, i2))

for element in repeat_list:
	if t[element[0]] != t[element[1]]:
		answer_flg = 1
		break

if answer_flg == 0:
	print("Yes")
else:
	print("No")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
n = len(S)
result = False
if len(T) != n:
    result = True
SA = []
for i in range(n):
    SA.append(int(S.count(S[i])))
TA = []
for i in range(n):
    TA.append(int(T.count(T[i])))
SA.sort()
TA.sort()
for i in range(n):
    if SA[i] != TA[i]:
        result = True
if result:
    print("No")
else:
    print("Yes")

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    S = list(input())
    T = list(input())

    letter = []
    for i in range(len(S)):
        letter.append(T[i])                                                                                                                                                     
        if S[i] == T[i]:
            continue
        else:
            if S[i] in letter:
                break
            else:
                s = S[i]
                for j in range(len(S)):
                    if S[j] == s:
                        S[j] = T[i]
                    elif S[j] == T[i]:
                        S[j] = s

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

Submission status: Time Limit Exceeded

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

count = 0
for i in range(len(list)):
    if s1[i] != s2[i]:
      s1 = s1.translate(str.maketrans( s1[i]+s2[i], s2[i]+s1[i]) )
      count = count+1
    if s1[0:i] != s2[0:i]:
      break
    if count > 27:
      break

if s1==s2:
  print ("Yes")
else:
  print ("No")

Submission status: Time Limit Exceeded

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

for i in range(len(S)+1):
	s = str(S[i:i+1])
	t = str(T[i:i+1])
	S = S.replace(s,'A')
	S = S.replace(t,s)
	S = S.replace('A',t)

answer = 'No'


if S == T:
	answer = 'Yes'
	
print(answer)

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
s_dup_lists = []
t_dup_lists = []

for i, (s1, t1) in enumerate(zip(s, t)):
    for j, (s2, t2) in enumerate(zip(s, t)):
        if (i != j) and (s1 == s2):
            s_dup_lists.append([i, j])
        if (i != j) and (t1 == t2):
            t_dup_lists.append([i, j])

if s_dup_lists == t_dup_lists:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
# coding: utf-8

s = input()
t = input()

repeat_list = []

for i1, c1 in enumerate(t):
	for i2, c2 in enumerate(t):
		if i1 >= i2:
			continue
		if c1 == c2:
			flg = 1
			repeat_list.append((i1, i2))

answer_flg = 0
for element in repeat_list:
	if s[element[0]] != s[element[1]]:
		answer_flg = 1
		break

for i1, c1 in enumerate(s):
	for i2, c2 in enumerate(s):
		if i1 >= i2:
			continue
		if c1 == c2:
			flg = 1
			repeat_list.append((i1, i2))

for element in repeat_list:
	if t[element[0]] != t[element[1]]:
		answer_flg = 1
		break

if answer_flg == 0:
	print("Yes")
else:
	print("No")

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
for i in range(len(s)):
  if s[i] != t[i]:
    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:
s1 = input()
s2 = input()
list = s1

for i in range(len(list)):
    if s1[i] != s2[i]:
      s1 = s1.translate(str.maketrans( s1[i]+s2[i], s2[i]+s1[i]) )
    if s1[0:i] != s2[0:i]:
      break

if s1==s2:
  print ("Yes")
else:
  print ("No")

Submission status: Time Limit Exceeded

Solution code:
A=input("")
B=input("")
for i,ch in enumerate(A):
    if A[i]!=B[i]:
        val=A[i]
        A=A.replace(A[i],'0')


        A=A.replace(B[i],val)

        A=A.replace('0',B[i])

        #reduce(lambda a, b: a.replace(*b), [(A[i],B[i]), (B[i],A[i])]) #iterable of pairs: (oldval, newval), 'tomato' #The string from which to replace values

    

if A==B:
    print("Yes")
else :
    print("No")

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
N = len(S)
for i in range(N):
    for j in range(i, N):
        if S[i] == S[j]:
            if T[i] != T[j]:
                print("No")
                exit()
        if T[i] == T[j]:
            if S[i] != S[j]:
                print("No")
                exit()
else:
    print("Yes")

Submission status: Time Limit Exceeded

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

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

    if S == T:
        print("Yes")
        exit()

    # ある文字cがsとtで場所が半端に一致していたらNO
    ans = S
    len_s = len(S)
    for i in range(len_s):
        if ans[i] != T[i]:
            c1 = ans[i]
            c2 = T[i]
            ans = ans.replace(c1, "?")
            ans = ans.replace(c2, c1)
            ans = ans.replace("?", c2)

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


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

    if S == T:
        print("Yes")
        exit()

    # ある文字cがsとtで場所が半端に一致していたらNO
    len_s = len(S)
    for i in range(len_s):
        if not S[i] in T:
            continue
        flag1 = False
        flag2 = False
        for j in range(len_s):
            if flag1 and flag2:
                print("No")
                exit()
            if S[i] == T[j]:
                if i == j:
                    flag1 = True
                    continue
                flag2 = True
                continue
    print("Yes")



if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
S = input()
T = input()
N = len(S)
for i in range(N):
    for j in range(N):
        if S[i] == S[j]:
            if T[i] != T[j]:
                print("No")
                exit()
        if T[i] == T[j]:
            if S[i] != S[j]:
                print("No")
                exit()
else:
    print("Yes")

Submission status: Time Limit Exceeded

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

for i in range(len(S)+1):
	s = str(S[i:i+1])
	t = str(T[i:i+1])
	if s != t:
		S = S.replace(s,'A')
		S = S.replace(t,s)
		S = S.replace('A',t)

answer = 'No'


if S == T:
	answer = 'Yes'
	
print(answer)

Submission status: Time Limit Exceeded

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

for i in range(len(S)):
    s=S[i]
    t=T[i]
    Stemp=S
    if s!=t:
        if t in Stemp:
            S=S.replace(s,"1")
            S=S.replace(t,s)
            S=S.replace("1",t)
        else:
            S=S.replace(s,t)
    if S[i:len(S)]==T[i:len(T)]:
        break
    
if S==T:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

L = len(s)

equal = (s==t)
stop = False
mem = {}
cnt = 0
while (not equal) and (not stop):
  cnt += 1
  if cnt%2==1:
    gen = range(L)
  else:
    gen = range(L)[::-1]
  for i in gen:
    if s[i]==t[i]:
      continue
    else:
      #print(s)
      si = (s[i])
      s = s.replace(s[i], '#')#; print(1, s)
      s = s.replace(t[i], si)#; print(2, s)
      s = s.replace('#', t[i])#; print(3, s)
      equal = s==t
      if s not in mem:
      	mem[s] = 1
      elif (s in mem) or equal:
        stop = True
if equal:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

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

s_list = list(S)
t_list = list(T)

def my_replace(s_list, s, t):
    s_ind = [i for i in range(len(s_list)) if s_list[i] == s]
    t_ind = [i for i in range(len(s_list)) if s_list[i] == t]
    for i in range(len(s_list)):
        if i in s_ind:
            s_list[i] = t
        elif i in t_ind:
            s_list[i] = s
    return s_list

for i in range(len(s_list)):
    if s_list[i] != t_list[i]:
        s_list = my_replace(s_list, s_list[i], t_list[i])
        
if s_list == t_list:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

def c(a,b,s):
    t=s.replace(a,"A")
    u=t.replace(b,a)
    v=u.replace("A",b)
    
    return v
    
l=[]

for i in range(len(t)):
    if s[i]!=t[i]:
        for j in l:
            if s[i]==j:
                print("No")
                sys.exit()
        l.append(t[i])
        s=c(s[i],t[i],s)
    
        

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

Submission status: Time Limit Exceeded

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

for i in range(len(list)):
    if s1[i] != s2[i]:
      s1 = s1.translate(str.maketrans( s1[i]+s2[i], s2[i]+s1[i]) )

if s1==s2:
  print ("Yes")
else:
  print ("No")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
slen = []
tlen = []
ans = "Yes"

while len(S) > 0:
    tempS = S[0]
    slen.append(S.count(tempS))
    while tempS in S:
        S.remove(tempS)
    
    
while len(T) > 0:
    tempT = T[0]
    tlen.append(T.count(tempT))
    while tempT in T:
        T.remove(tempT)
    
slen.sort()
tlen.sort()

print(["No", "Yes"][slen == tlen])

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
import string
for i in range(len(s)):
    if s[i:i+1] != t[i:i+1]:
        s = s.translate(str.maketrans(s[i:i+1]+t[i:i+1],t[i:i+1]+s[i:i+1]))
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
s, t = map(str, [input() for _ in range(2)])

_s, _t = set(s), set(t)

if len(_s) != len(_t):
    print("No")
    exit(0)

for i in range(len(s)):
    if s.count(s[i]) != t.count(t[i]):
        print("No")
        exit(0)
    
    s.replace(s[i], "")
    t.replace(t[i], "")

print("Yes")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
r = "Yes"
for i in range(len(S)):
    s1 = S[i]
    t1 = T[i]
    s_bit = list(map(lambda x:1 if x==s1 else 0, S))
    t_bit = list(map(lambda x:1 if x==t1 else 0, T))
    if s_bit != t_bit:
        r = "No"
        break
print(r)

Submission status: Time Limit Exceeded

Solution code:

xa = list(input())

ya = list(input())

an=[]

f=1

for i in range(len(xa)):
    if not xa[i]==ya[i]:
        tmp=[xa[i], ya[i]]
        for j in range(len(an)):
            if an[j][0]!=tmp[0] and an[j][1]==tmp[1]:
                f=-1
            if an[j][0]==tmp[0] and an[j][1]!=tmp[1]:
                f=-1
        if f>0:
            an.append(tmp)
        else:
            break
        
if f>0:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

L = len(s)

equal = (s==t)
stop = False
mem = {}
while (not equal) and (not stop):
  for i in range(L):
    if s[i]==t[i]:
      continue
    else:
      #print(s)
      si = (s[i])
      s = s.replace(s[i], '#')#; print(1, s)
      s = s.replace(t[i], si)#; print(2, s)
      s = s.replace('#', t[i])#; print(3, s)
      equal = s==t
      if s not in mem:
      	mem[s] = 1
      elif (s in mem) or equal:
        stop = True
if equal:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

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

for i in range(len(list)):
    if s1[i] != s2[i]:
      a=s1[i]
      b=s2[i]
      s1 = s1.replace(s1[i], 'X') 
      s1 = s1.replace(s2[i], a)
      s1 = s1.replace('X', b)

if s1==s2:
  print ("Yes")
else:
  print ("No")

Submission status: Time Limit Exceeded

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

for i in range(len(S)):
    s=S[i]
    t=T[i]
    Stemp=S
    if s!=t:
        if t in Stemp:
            S=S.replace(s,"1")
            S=S.replace(t,s)
            S=S.replace("1",t)
        else:
            S=S.replace(s,t)

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

Submission status: Time Limit Exceeded

Solution code:
s, t = map(str, [input() for _ in range(2)])

_s, _t = set(s), set(t)

if len(_s) != len(_t):
    print("No")
    exit(0)

for i in range(len(s)):
    if s[i] == t[i]:
        continue
    
    if s.count(s[i]) != t.count(t[i]):
        print("No")
        exit(0)

print("Yes")

Submission status: Time Limit Exceeded

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

if False not in [s==t for s,t in zip(S,T)]:
  print("Yes")
  exit()

for i in range(len(S)):
  if S[i] == T[i]:
    continue
  c1 = S[i]
  c2 = T[i]
  for j in range(len(S)):
    if S[j] == c1:
      S[j] = c2
    elif S[j] == c2:
      S[j] = c1
  if False not in [s==t for s,t in zip(S,T)]:
    print("Yes")
    exit()

print("No")

Submission status: Time Limit Exceeded

Solution code:
s=list(input())
t=list(input())
sl = [s.count(e) for e in s]
tl = [t.count(e) for e in t]
if sl==tl:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:

S = input()
T = input()

naga = len(S)

for i in range(naga):
    ss = S[i]
    tt = T[i]
    S = S.replace(ss,"!")
    S = S.replace(tt,ss)
    S = S.replace("!",tt)

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

Submission status: Time Limit Exceeded

Solution code:
def make_reverse_index(s):
    idx = dict()

    for pos, c in enumerate(s):
        if c not in idx:
            idx[c] = set()
        idx[c].add(pos)

    return idx

def solve(s, t):
    idx1 = make_reverse_index(s)
    idx2 = make_reverse_index(t)

    for c1, c2 in zip(s, t):
        if idx1[c1] != idx2[c2]:
            return False

    return True

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

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

main()

Submission status: Time Limit Exceeded

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

def c(a,b,s):
    t=s.replace(a,"A")
    u=t.replace(b,a)
    v=u.replace("A",b)
    
    return v
    
l=[]

for i in range(len(t)):
    if s[i]!=t[i]:
        for j in l:
            if s[i]==j:
                break
        l.append(t[i])
        s=c(s[i],t[i],s)
    
        

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

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
S2, T2 = [], []
for i in S:
    S2.append(S.count(i))
for i in T:
    T2.append(T.count(i))
if S2 != T2:
    print('No')
else:
    print('Yes')

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

def count_string(strInput):
    tmp = {}
    for s in strInput:
        cnt = strInput.count(s)
        tmp[s] = cnt
    
    re = [tmp[a] for a in tmp]
    re.sort()
    return re

S_count = count_string(S)
T_count = count_string(T)

if S_count == T_count:
    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]:
        continue
    c1 = s[i]; c2 = t[i]
    
    c1List = []; c2List = []
    for j in range(len(s)):
        if s[j] == c1:
            c1List.append(j)
        if s[j] == c2:
            c2List.append(j)

    for j in c1List:
        s[j] = c2
    for j in c2List:
        s[j] = c1

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

Submission status: Time Limit Exceeded

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

def c(a,b,s):
    t=s.replace(a,".")
    u=t.replace(b,a)
    v=u.replace(".",b)
    
    return v
    

for i in range(len(t)):
    if s[i]!=t[i]:
        s=c(s[i],t[i],s)

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