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:
from collections import Counter
S = input()
T = input()

for w in list(S):
    if w in list(T):
        S = list(S)
        T = list(T)
        #print(S, 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 = ''.join(S)
        T = ''.join(T)

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

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
cnt = []
ans = 1
fis1 = [index for index, word in enumerate(S) if word == S[0]]
fis2 = [index for index, word in enumerate(T) if word == T[0]]
 
if fis1 != fis2:
    ans = 0
else:
    for i in range(len(S)):
        if i not in fis1:
            kensa1 = [index for index, word in enumerate(S) if S[i] == word]
            kensa2 = [index for index, word in enumerate(T) if T[i] == word]
            if kensa1 != kensa2:
                ans = 0
                break
            else:
                fis1.append(kensa1)
          
    
print('Yes' if ans == 1 else 'No')

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
for i in range(len(S)):
    kensa1 = [index for index, word in enumerate(S) if S[i] == word]
    kensa2 = [index for index, word in enumerate(T) if T[i] == word]

    if kensa1 != kensa2:
        print('No')
        break
else:
    print('Yes')

Submission status: Time Limit Exceeded

Solution code:
def solve():
    alpha = "abcdefghijklmnopqrstuvwxyz"
    inp1, inp2 = input(), input()
    sz = dict(zip(list(alpha), [0] * 26))
    tz = dict(zip(list(alpha), [0] * 26))
    siz = dict(
        zip(list(alpha), [[0 for i in range(2 * (10 ** 5))] for _ in range(26)]))
    tiz = dict(
        zip(list(alpha), [[0 for i in range(2 * (10 ** 5))] for _ in range(26)]))
    for i in range(len(inp1)):
        sz[inp1[i]] += 1
        tz[inp2[i]] += 1
        siz[inp1[i]][i] = i
        tiz[inp2[i]][i] = i
        if (sz[inp1[i]] != tz[inp2[i]]
                or set(siz[inp1[i]]) ^ set(tiz[inp2[i]])):
            print("No")
            return
    print("Yes")


solve()

Submission status: Time Limit Exceeded

Solution code:
def solve():
    alpha = "abcdefghijklmnopqrstuvwxyz"
    inp1, inp2 = input(), input()
    sz = dict(zip(list(alpha), [0] * 26))
    tz = dict(zip(list(alpha), [0] * 26))
    siz = dict(zip(list(alpha), [set([]) for _ in range(26)]))
    tiz = dict(zip(list(alpha), [set([]) for _ in range(26)]))
    for i in range(len(inp1)):
        sz[inp1[i]] += 1
        tz[inp2[i]] += 1
        siz[inp1[i]].add(i)
        tiz[inp2[i]].add(i)
        if (sz[inp1[i]] != tz[inp2[i]]
                or siz[inp1[i]] ^ tiz[inp2[i]]):
            print("No")
            return
    print("Yes")


solve()

Submission status: Time Limit Exceeded

Solution code:
def solve():
    alpha = "abcdefghijklmnopqrstuvwxyz"
    inp1, inp2 = input(), input()
    sz = dict(zip(list(alpha), [0] * 26))
    tz = dict(zip(list(alpha), [0] * 26))
    siz = dict(zip(list(alpha), [[] for _ in range(26)]))
    tiz = dict(zip(list(alpha), [[] for _ in range(26)]))
    for i in range(len(inp1)):
        sz[inp1[i]] += 1
        tz[inp2[i]] += 1
        siz[inp1[i]].append(i)
        tiz[inp2[i]].append(i)
        if (sz[inp1[i]] != tz[inp2[i]]
                or siz[inp1[i]] != tiz[inp2[i]]):
            print("No")
            return
    print("Yes")


solve()

Submission status: Time Limit Exceeded

Solution code:
def Swap2(l, c1, c2):
    for index in range(len(l)):
        if l[index] == c1:
            l[index] = c2
        elif l[index] == c2:
            l[index] = c1
        # print('l=', l)

if __name__ == '__main__':
    s = list(input())
    t = list(input())

    for i in range(len(s)):
        if s[i] != t[i]:
            Swap2(s, s[i], t[i])
    if s == t:
        print('Yes')
    else:
        print('No')

Submission status: Time Limit Exceeded

Solution code:

s= input()
t = input()

def swap(S, a,b):
    ss = ""
    for s in S:
        if s == a:
            ss += b
        elif s == b:
            ss += a
        else:
            ss += s
    return ss
        
def solve(S,T):
    s_copy = S
    t_copy = T
    char_map = set()
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if s != t:
            char_map.add((s,t))
            S = swap(S, s,t)
    return S == T


    

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

Submission status: Time Limit Exceeded

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

for i in range(len(s)):
    if s[i] == t[i]:
        pass
    else:
        s_diff = s[i]
        t_diff = t[i]
        s = s.translate(str.maketrans({s_diff: t_diff, t_diff: s_diff}))

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

Submission status: Time Limit Exceeded

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


for i in range(len(S)):
    S_ch = [j for j, x in enumerate(S) if x == S[i]]
    T_ch = [j for j, x in enumerate(T) if x == T[i]]
    if S_ch != T_ch:
        print('No')
        exit()

print('Yes')

Submission status: Time Limit Exceeded

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

S = [s[i] for i in range(len(s))]
T = [t[i] for i in range(len(t))]

for i in range(len(S)):
    S_ch = [j for j, x in enumerate(S) if x == S[i]]
    T_ch = [j for j, x in enumerate(T) if x == T[i]]
    if S_ch != T_ch:
        print('No')
        exit()

print('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.replace(S[i], '0').replace(T[i], S[i]).replace('0', T[i])
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):
    for j in range(i+1,len(S)):
        if S[i] ==S[j] and T[i] != T[j]:
            print("No")
            break
        elif S[i] != S[j] and T[i] == T[j]:
            print("No")
            flag = True
            break
    else:
        continue
    break
else:
    print("Yes")

Submission status: Time Limit Exceeded

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

flag = False
for i in range(len(S)-1):
    for j in range(i+1,len(S)):
        if S[i] ==S[j] and T[i] != T[j]:
            print("No")
            flag = True
            break
        elif S[i] != S[j] and T[i] == T[j]:
            print("No")
            flag = True
            break
    if flag:
        break
else:
    print("Yes")

Submission status: Time Limit Exceeded

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

len_S = len(S)
S_Converted = S
for i in range (len(S)):
    tmp_S = S_Converted[i]
    tmp_T = T[i]
    if tmp_S == tmp_T:
        continue
    S_Converted = list(S_Converted) 
    list_indexT = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_T]
    
    S_Converted = ''.join(S_Converted)
    #print(tmp_S)
    S_Converted = S_Converted.replace(tmp_S, tmp_T)
    #print(S_Converted)
    S_Converted = list(S_Converted) 
    
    for li in list_indexT:
        if li == i:
            continue
        else:
            S_Converted[li] = tmp_S
    #print(''.join(S_Converted))
    
S_Converted = ''.join(S_Converted)

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

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
for i in range(len(s)):
	if not s[i] == t[i]:
		si = s[i]
		ti = t[i]
		s = s.replace(ti,"3")
		s = s.replace(si, ti)
		s = s.replace("3", si)
if s == t:
	print("Yes")
else:
	print("No")

Submission status: Time Limit Exceeded

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

len_S = len(S)
S_Converted = list(S) 
for i in range (len(S)):
    tmp_S = S_Converted[i]
    tmp_T = T[i]
    if tmp_S == tmp_T:
        continue
    list_indexS = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_S]
    list_indexT = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_T]
    for li in list_indexS:
        S_Converted[li] = tmp_T
    #S_Converted[list_indexS] = tmp_T
    for li in list_indexT:
        if li == i:
            continue
        else:
            S_Converted[li] = tmp_S
    #print(''.join(S_Converted))
S_Converted = ''.join(S_Converted)

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

Submission status: Time Limit Exceeded

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

len_S = len(S)
S_Converted = list(S) 
for i in range (len(S)):
    tmp_S = S_Converted[i]
    tmp_T = T[i]
    if tmp_S == tmp_T:
        continue
    list_index = []     
    index = S_Converted.index(tmp_S)
    list_indexS = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_S]
    list_indexT = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_T]
    for li in list_indexS:
        S_Converted[li] = tmp_T
    for li in list_indexT:
        if li == i:
            continue
        else:
            S_Converted[li] = tmp_S
    #print(''.join(S_Converted))
S_Converted = ''.join(S_Converted)

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

Submission status: Time Limit Exceeded

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

len_S = len(S)
S_Converted = list(S) 
for i in range (len(S)):
    tmp_S = S_Converted[i]
    tmp_T = T[i]
    list_index = []     
    index = S_Converted.index(tmp_S)
    list_indexS = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_S]
    list_indexT = [j for j, tmp_SC in enumerate(S_Converted) if tmp_SC == tmp_T]
    for li in list_indexS:
        S_Converted[li] = tmp_T
    for li in list_indexT:
        if li == i:
            continue
        else:
            S_Converted[li] = tmp_S
    #print(''.join(S_Converted))
S_Converted = ''.join(S_Converted)

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

Submission status: Time Limit Exceeded

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

def swap(s,c1,c2):
    if c2 in s:
        # slist = list(s)
        def rep(chr):
            if chr == c1:
                return c2
            elif chr == c2:
                return c1
            return chr
        slist = [rep(i) for i in list(s)]
        s = "".join(slist)
    #s = "".join(list(map(rep,slist)))
    else:
       s = s.replace(c1,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()

def swap(s,c1,c2):
    if c2 in s:
        slist = list(s)
        def rep(chr):
            if chr == c1:
                return c2
            elif chr == c2:
                return c1
            return chr
        s = "".join(list(map(rep,slist)))
    else:
       s = s.replace(c1,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()

for i in range(len(s)):
    if not s[i] == t[i]:
        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 = input()
T = input()

for i in range(len(S)):
    s = S[i]
    t = T[i]
    
    # 文字列の入れ替
    S = S.replace(s, '0')
    S = S.replace(t, s)
    S = S.replace('0', t)

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

Submission status: Time Limit Exceeded

Solution code:
# coding:utf-8

s = str(input())
t = str(input())

def is_check(index, s, t):
    si = s[index]
    ti = t[index]
    check_arr = s[index+1:]
    for k, sk in enumerate(check_arr):
        if(si == sk):
            if(ti == t[index+1+k]):
                pass
            else:
                return False
        else:
            pass
    return True

for index, si in enumerate(s):
    if(is_check(index, s, t)):
        pass
    else:
        print("No")
        quit()

for index, ti in enumerate(t):
    if(is_check(index, t, s)):
        pass
    else:
        print("No")
        quit()

print("Yes")

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
X=0
for s in S:
    if ord(s)>96:X+=1;S=S.replace(s,chr(X+47))
Y=0
for t in T:
    if ord(t)>96:Y+=1;T=T.replace(t,chr(Y+47))
print('Yes'if S==T else'No')

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
for i in range(len(S)):
    if S[i] != T[i]:
        
        motoT = [j for j in range(len(S)) if S[j] == T[i]]
        
        migawari = S[i]
        
        
        S = S.replace(S[i], T[i])
        
        
        for k in motoT:
            S = list(S)
            S[k] = migawari
            S = ''.join(S)

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

Submission status: Time Limit Exceeded

Solution code:
def swap_letters(string, swap1, swap2):
    return_string = ''
    for i in range(len(string)):
        ith_letter = string[i:i+1]
        if ith_letter == swap1:
            return_string += swap2
        elif ith_letter == swap2:
            return_string += swap1
        else:
            return_string += ith_letter
    return return_string

S_str = input()
T_str = input()

S_last_index = len(S_str)
for i in range(S_last_index):
    # TODO: スライスで値を参照でなくコピーする必要があるか要検討
    S_ith_letter = S_str[i:i+1]
    T_ith_letter = T_str[i:i+1]
    if S_ith_letter == T_ith_letter:
        continue
    else:
        S_str = swap_letters(S_str, S_ith_letter, T_ith_letter)
    # print(S_str, T_str)

if S_str == T_str:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

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

for i in range(N):
  if i==N-1:
    break
  elif S[i] in S[i+1::]:
    m=int(i+1)
    l.append([i,S[i::].index(S[i])])
  else:
    continue
  


l2=[]  
for i in range(N):
  if i==N-1:
    break
  elif T[i] in T[i+1::]:    
    l2.append([i,T[i+1::].index(T[i])])
  else:
    continue

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

Submission status: Time Limit Exceeded

Solution code:
def run(s, t):
    key_s = tuple(s)
    key_t = tuple(t)
    dic_s = {}
    dic_t = {}
    for key in key_s:
        dic_s[key] = s.count(key)
    for key in key_t:
        dic_t[key] = t.count(key)
    if sorted(dic_s.values()) == sorted(dic_t.values()):
        return 'Yes'
    else:
        return 'No'


def main():
    s = input()
    t = input()
    print(run(s, t))


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

S_indices_dict = defaultdict(set)
T_indices_dict = defaultdict(set)

for i, char in enumerate(S):
    S_indices_dict[char].add(i)
for i, char in enumerate(T):
    T_indices_dict[char].add(i)

indices_set = set(range(len(S)))
for char in S:
    indices = S_indices_dict[char]
    char_set = set()
    for i in indices:
        char_set.add(T[i])
        if len(char_set) != 1:
            print("No")
            exit(0)
for char in T:
    indices = T_indices_dict[char]
    char_set = set()
    for i in indices:
        char_set.add(S[i])
    if len(char_set) != 1:
        print("No")
        exit(0)
print("Yes")

Submission status: Time Limit Exceeded

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

sarr = []
tarr = []
flg = 0
for i in list(range(len(s))):
    if s[i] != t[i]:
        sarr.append(s[i])
        tarr.append(t[i])
        
for i in list(range(len(sarr))):
    if sarr.count(sarr[i]) != tarr.count(tarr[i]):
        flg = 1
    
if len(set(sarr)) == len(set(tarr)) and flg == 0:
    print('Yes')
else:
    print('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
    count = 0
    len_data = len(data0)
    while(count <= len_data):
        if not list(data0):
            break
        count += 1
        c0 = data0[0]
        c1 = data1[0]
        if np.allclose(data0 == c0, 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:
S = list(input())
T = list(input())

for i in range(len(S)):
    if S[i] != T[i]:
        migawari = S[i]
        index1 = [index for index, x in enumerate(S) if x == S[i]]
        index2 = [index for index, x in enumerate(S) if x == T[i]]
        for k in index1:
            S[k] = T[i]
        for j in index2:
            S[j] = migawari

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

Submission status: Time Limit Exceeded

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

def swap(s,c1,c2):
    if c2 in s:
        slist = list(s)
        def rep(chr):
            if chr == c1:
                return c2
            elif chr == c2:
                return c1
            return chr

        # for i in range(len(slist)):
        #     if slist[i] == c1:
        #         slist[i]=c2
        #     elif slist[i] == c2:
        #         slist[i] = c1
        # s = "".join(slist)
        s = "".join(list(map(rep,slist)))
    else:
       s = s.replace(c1,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()

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

Submission status: Time Limit Exceeded

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

a = list(A)
b = list(B)

for i in range(len(a)):
  if a[i] != b[i]:
    tmp = a[i]
    for j in range(len(a)):
      if tmp == a[j]:
        a[j] = b[i]
      elif b[i] == a[j]:
        a[j] = tmp
if a == b :
  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]
    if s!=t:
        S=S.replace(s,"1")
        S=S.replace(t,s)
        S=S.replace("1",t)
    
if S==T:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
def translate(x,y):
    if x == y[0]:
      return y[1]
    if x == y[1]:
      return y[0]
    return x

s1 = list(input())
s2 = list(input())
list = s1

count = 0
for i in range(len(list)):
    if s1[i] != s2[i]:
      x = s1[i]
      y = s2[i]
      for j in range(len(s1)):
        if s1[j] == x:
          s1[j]=y
        elif s1[j] == y:
          s1[j]=x
      #s1 = s1.translate(str.maketrans( s1[i]+s2[i], s2[i]+s1[i]) )
      #s1.replace( s1[i], "X").replace( s2[i], x).replace( 'X' , y)
      #s1 = list(map(translate, s1))
      
      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=input()
T=input()

for i in range(len(S)):
    s=S[i]
    t=T[i]
    Stemp=S
    if s!=t:
        S=S.replace(s,"1")
        S=S.replace(t,s)
        S=S.replace("1",t)
    
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)):
    if S[i] == T[i]:
        continue
    else:
        s_before = S[i]
        S = S.replace(T[i], ',')
        S = S.replace(S[i], T[i])
        S = S.replace(',', s_before)
    if (S == T):
        print("Yes")
        exit()

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

Submission status: Time Limit Exceeded

Solution code:
s1 = input()
t1 = input()

s = list(s1)
t = list(t1)

flag = 0
for i in range(len(s)):
    for j in range(len(s)):
        if s[i] == s[j]:
            if t[i] != t[j]:
                print("No")
                flag = 1
                break
        if flag == 1:
            break

        if t[i] == t[j]:
            if s[i] != s[j]:
                print("No")
                flag = 1
                break
        if flag == 1:
            break
    if flag == 1:
        break
if flag == 0:
    print("Yes")

Submission status: Time Limit Exceeded

Solution code:
import numpy as np
S = input()
T = input()

nS = np.array([s for s in S])
nT = np.array([s for s in T])
False_position = np.where(nS!=nT)[0]

for i in False_position:
    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:
S = raw_input()
T = raw_input()

CS = [S.count(s) for s in S]
TS = [T.count(t) for t in T]

if False in [CS[i] == TS[i] for i in range(len(CS))]:
	print 'No'
else:
	print 'Yes'

Submission status: Time Limit Exceeded

Solution code:
from collections import Counter
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:
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 = s[i]
		c = 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:
S = [i for i in input()]
T = [i for i in input()]
flag = 1
count1 = 0
count2 = 0
if(len(set(S))!=len(set(T))):
  flag = 0
for i in range(len(S)-1):
  if(S[i]==S[i+1]):
    count1 += S.count(S[i])
  if(T[i]==T[i+1]):
    count2 += T.count(T[i])
if(count1!=count2):
  flag = 0
if(flag==1):
  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]
        d = str.maketrans(t[i]+s[i], "*"+t[i])
        s = s.translate(d)
        d = str.maketrans("*", tmp)
        s = s.translate(d)
    if s[:i+1] != t[:i+1]:
        break

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)):
    if S[i] == T[i]:
        continue
    else:
        s_before = S[i]
        S = S.replace(T[i], ',')
        S = S.replace(S[i], T[i])
        S = S.replace(',', s_before)


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,t):
    li=""
    j=0
    for i in s:
        if i==a:
            li+=b
            if t[j]!=b:
                print("No")
                sys.exit()
        elif i==b:
            li+=a
        else:
            li+=i
        j+=1
    return li
    

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

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

Submission status: Time Limit Exceeded

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

def swap(s,c1,c2):
    if c2 in s:
        slist = list(s)

        for i in range(len(slist)):
            if slist[i] == c1:
                slist[i]=c2
            elif slist[i] == c2:
                slist[i] = c1
        s = "".join(slist)
    else:
       s = s.replace(c1,c2)
    return s

for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        # x = s.find(t[i])
        # if x > i and s.count(t[i])==1:
        #     s = s[0:i]+s[x]+s[i+1:x]+s[i]+s[x+1:]
        #     continue
        s = swap(s,s[i],t[i])
if s == t:
    print("Yes")
else:
    print("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
    count = 0
    len_data = len(data0)
    while(count <= len_data):
        if not list(data0):
            break
        count += 1
        c0 = data0[0]
        c1 = data1[0]
        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:
s1 = input()
t1 = input()

s = list(s1)
t = list(t1)

flag = 0
for i in range(len(s)):
    for j in range(len(s)):
        if s[i] == s[j]:
            if t[i] == t[j]:
                a = 1
            else:
                print("No")
                flag = 1
                break
        if flag == 1:
            break

        if t[i] == t[j]:
            if s[i] == s[j]:
                a = 1
            else:
                print("No")
                flag = 1
                break
        if flag == 1:
            break
    if flag == 1:
        break
if flag == 0:
    print("Yes")

Submission status: Time Limit Exceeded

Solution code:
st1 = input()
st2 = input()
key1 = list(st1)
key2 = list(st2)

def list_difference(list1, list2):
    result = list1.copy()
    for value in list2:
        if value in result:
            result.remove(value)

    return result

result1 = str(list_difference(key1,key2))
result2 = str(list_difference(key2,key1))



def az_count(s):
	ss = []
	ss.append(s.count('a'))
	ss.append(s.count('b'))
	ss.append(s.count('c'))
	ss.append(s.count('d'))
	ss.append(s.count('e'))
	ss.append(s.count('f'))
	ss.append(s.count('h'))
	ss.append(s.count('i'))
	ss.append(s.count('j'))
	ss.append(s.count('k'))
	ss.append(s.count('l'))
	ss.append(s.count('n'))
	ss.append(s.count('m'))
	ss.append(s.count('o'))
	ss.append(s.count('p'))
	ss.append(s.count('q'))
	ss.append(s.count('r'))
	ss.append(s.count('s'))
	ss.append(s.count('t'))
	ss.append(s.count('u'))
	ss.append(s.count('v'))
	ss.append(s.count('w'))
	ss.append(s.count('x'))
	ss.append(s.count('y'))
	ss.append(s.count('z'))
	return ss

t = az_count(result1)
t1 = az_count(result2)

t.sort()
t1.sort()
if t == t1:
	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]
        d = str.maketrans(t[i]+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,t):
    li=""
    j=0
    for i in s:
        if i==a:
            li+=b
            if t[j]!=b:
                print("No")
                sys.exit()
        elif i==b:
            li+=a
        else:
            li+=i
        j+=1
    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,t)
    
        

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

Submission status: Time Limit Exceeded

Solution code:
if __name__ == '__main__':
    s = input()
    t = input()

    n = len(s)

    for i in range(n):
        _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')

Submission status: Time Limit Exceeded

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

def swap(s,c1,c2):
    if c2 in s:
        slist = list(s)
        for i in range(len(slist)):
            if slist[i] == c1:
                slist[i]=c2
            elif slist[i] == c2:
                slist[i] = c1
        s = "".join(slist)
    else:
       s = s.replace(c1,c2)
    return s

for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        x = s.find(t[i])
        if x > i and s.count(t[i])==1:
            s = s[0:i]+s[x]+s[i+1:x]+s[i]+s[x+1:]
            continue
        s = swap(s,s[i],t[i])
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
import itertools
import copy
import math
import collections


s = input()
t = input()

def swap(s,t,c1,c2):
    if c2 in s:
        slist = list(s)
        for i in range(len(slist)):
            if slist[i] == c1:
                slist[i]=c2
            elif slist[i] == c2:
                slist[i] = c1
        s = "".join(slist)
    else:
       s = s.replace(c1,c2)
    return s

for i in range(len(s)):
    # print(s)
    if s[i] == t[i]:
        continue
    else:
        x = s.find(t[i])
        if x > i and s.count(t[i])==1:
            s = s[0:i]+s[x]+s[i+1:x]+s[i]+s[x+1:]
            continue
        s = swap(s,t,s[i],t[i])
        # s = s.replace(s[i],t[i])
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
import sys
import numpy as np
from collections import Counter
s=input()
t=input()
s1=set(s)
t1=set(t)
if s==t:
    print('Yes')
    sys.exit()
qu2=[]
if len(s1)==len(t1):
    for i in s:
        if s.count(i)>1:
            qu=[j for j,e in enumerate(s) if e==i]
            for j in qu:
                j=int(j)
                qu2.append(t[j])
            qu3=set(qu2)
            if len(qu3)!=1:
                print('No')
                sys.exit()
            else:
                qu3.clear()
        qu2=[]
        qu=[]
    print('Yes')
elif len(s1)!=len(t1):
    print('No')

Submission status: Time Limit Exceeded

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

    n = len(s)

    for i in range(n):
        _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()