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: Runtime Error

Solution code:
S = list(input())
T = list(input())
S.sort()
T.sort()
SKind = []
TKind = []
cnt = 1
for i in range(1,len(S)):
    if i == 0:
        cnt+=1
    elif i == N-1:
        if S[i]==S[i-1]:
            cnt += 1
            SKind.append(cnt)
        else:
            SKind.append(cnt)
            SKind.append(1)
    elif S[i]==S[i-1]:
        cnt+=1
    elif S[i]!=S[i-1]:
        SKind.append(cnt)
        cnt = 1
cnt = 1        
for i in range(1,len(T)):
    if i == 0:
        cnt+=1
    elif i == N-1:
        if T[i]==T[i-1]:
            cnt += 1
            TKind.append(cnt)
        else:
            TKind.append(cnt)
            TKind.append(1)
    elif T[i]==T[i-1]:
        cnt+=1
    elif T[i]!=T[i-1]:
        TKind.append(cnt)
        cnt = 1
SKind.sort()
TKind.sort()
if SKind == TKind:
    print("Yes")
else: print("No")

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
S.sort()
T.sort()
SKind = []
TKind = []
cnt = 1
for i in range(1,len(S)):
    if i == 0:
        cnt+=1
    elif i == N-1:
        if S[i]==S[i-1]:
            cnt += 1
            SKind.append(cnt)
        else:
            SKind.append(cnt)
            SKind.append(1)
    elif S[i]==S[i-1]:
        cnt+=1
    elif S[i]!=S[i-1]:
        SKind.append(cnt)
        cnt = 1
#    print(SKind)
cnt = 1        
for i in range(1,len(T)):
    if i == 0:
        cnt+=1
    elif i == N-1:
        if T[i]==T[i-1]:
            cnt += 1
            TKind.append(cnt)
        else:
            TKind.append(cnt)
            TKind.append(1)
    elif T[i]==T[i-1]:
        cnt+=1
    elif T[i]!=T[i-1]:
        TKind.append(cnt)
        cnt = 1
#    print(TKind)
#print(SKind,TKind)
SKind.sort()
TKind.sort()
if SKind == TKind:
    print("Yes")
else: print("No")

Submission status: Runtime Error

Solution code:
def chain(k,y):
    if y in D or y==S[cur]:
        return 0
    for i in G[y]:
        if T[i]==y:
            return 1
        hist[i] = 1
        z = T[i]
        return chain(i,z)
S = input().strip()
T = input().strip()
D = [chr(i) for i in range(97,123)]
G = {}
for i in range(len(S)):
    x = S[i]
    if x in D:
        D.remove(x)
    if x not in G:
        G[x] = []
    G[x].append(i)
hist = [0 for _ in range(len(S))]
ind = 0
for i in range(len(S)):
    if hist[i]==1:continue
    x = S[i]
    y = T[i]
    if x!=y:
        for j in G[x]:
            cur = j
            hist[j]=1
            ind = chain(j,y)
            if ind==1:break
        if ind==1:break
if ind==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
def chain(x,y):
    if y in D or y==cur:
        return 0
    for i in G[y]:
        if T[i]==y:
            return 1
        hist[i] = 1
        z = T[i]
        return chain(y,z)
S = input().strip()
T = input().strip()
D = [chr(i) for i in range(97,123)]
G = {}
for i in range(len(S)):
    x = S[i]
    if x in D:
        D.remove(x)
    if x not in G:
        G[x] = []
    G[x].append(i)
hist = [0 for _ in range(len(S))]
ind = 0
for i in range(len(S)):
    if hist[i]==1:continue
    x = S[i]
    y = T[i]
    hist[i]=1
    if x!=y:
        cur = x
        ind = chain(cur,y)
        if ind==1:break
if ind==0:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from collections import defaultdict
if __name__ == '__main__':
    S = str(input())
    T = str(input())
    
    count = defaultdict(str)
    
    flag = True
    for i in range(len(S)):
        s = S[i]
        t = T[i]
        if count[t] != '':
            if count[t] != s:
                flag = False
        else:
            count[t] = s
    if flag:
        print(1/0)
        print('Yes')
    else:
        print('No')

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
dics ={}
dic ={}
for i in range(len(S)):
  if S[i] in dics:
  	dics[S[i]]=[dics[S[i]],i]
  else :
    dics[S[i]]=[i]
  if T[i] in dic:
    dic[T[i]]=[dic[T[i]],i]
  else:
    dic[T[i]]=[i]

for i in range(len(S)):
  if dics[S[i]]!=dic[T[i]] and (T[i] in dics and S[i] in dic and dics[T[i]]!=dic[S[i]]):
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
dics ={}
dic ={}
for i in range(len(S)):
  if S[i] in dics:
  	dics[S[i]]=[dics[S[i]],i]
  else :
    dics[S[i]]=[i]
  if T[i] in dic:
    dic[T[i]]=[dic[T[i]],i]
  else:
    dic[T[i]]=[i]
for i in range(len(S)):
  if dics[S[i]]!=dic[T[i]] and (T[i] in dics and dics[T[i]]!=dic[S[i]]):
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
dics ={}
dic ={}
for i in range(len(S)):
  if S[i] in dics:
  	dics[S[i]]=[dics[S[i]],i]
  else :
    dics[S[i]]=[i]
  if T[i] in dic:
    dic[T[i]]=[dic[T[i]],i]
  else:
    dic[T[i]]=[i]
print(dic)
for i in range(len(S)):
  if dics[S[i]]!=dic[T[i]] and (T[i] in dics and dics[T[i]]!=dic[S[i]]):
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
dics ={}
dic ={}
for i in range(len(S)):
  if S[i] in dics:
  	dics[S[i]]=[dics[S[i]],i]
  else :
    dics[S[i]]=i
  if T[i] in dic:
    dic[T[i]]=[dic[T[i]],i]
  else:
    dic[T[i]]=i
for i in range(len(S)):
  if dics[S[i]]!=dic[T[i]] and (T[i] in dics and dics[T[i]]!=dic[S[i]]):
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
dics ={}
dic ={}
for i in range(len(S)):
  if S[i] in dics:
  	dics[S[i]].append(i)
  else :
    dics[S[i]]=i
  if T[i] in dic:
  	dic[T[i]].append(i)
  else:
    dic[T[i]]=i
for i in range(len(S)):
  if dics[S[i]]!=dic[T[i]] and (T[i] in dics and dics[T[i]]!=dic[S[i]]):
    print("No")
    exit()
print("Yes")

Submission status: Runtime Error

Solution code:
from sys import exit
S = input()
T = input()
for i in range(26):
  c = chr(i + ord('a'))
  d[c] = '\0'
for i in range(len(S)):
  if d[S[i]] != '\0' or d[T[i]] != '\0':
    if d[S[i]] != T[i] or d[T[i]] != S[i]:
      print('No')
      exit()
  d[S[i]] = T[i]
  d[T[i]] = S[i]
print('Yes')

Submission status: Runtime Error

Solution code:
from sys import exit
S = input()
T = input()
d = {}
for i in range(len(S)):
  if S[i] in d or T[i] in d:
    if d[S[i]] != T[i] or d[T[i]] != S[i]:
      print('No')
      exit()
  d[S[i]] = T[i]
  d[T[i]] = S[i]
print('Yes')

Submission status: Runtime Error

Solution code:
S = input()
T = input()
al = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'

setS = []
for i in range(len(S)):
  if S[i] not in setS:
    S = S.replace(S[i],al[i])
    setS.append(S[i])

setT = []
for i in range(len(T)):
  if T[i] not in setT:
    T = T.replace(T[i],al[i])
    setT.append(T[i])

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

Submission status: Runtime Error

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

dict_st = {}
dict_st = {}

for x, y in zip(s, t):
    if x not in dict_st:
        dict_st[x] = y 
    else:
        if dict_st[x] != y:
            print("No")
            break

    if y not in dict_ts:
        dict_ts[y]=x
    else:
        if dict_ts[y]!=x:
            print("No")
            break
else:
    print("Yes")

Submission status: Runtime Error

Solution code:
S = list(input())
T = list(input())
dic = {}
for i in range(len(S)):
    if i == 0:
        dic[S[i]] = T[i]
        dic[T[i]] = S[i]
        S[i] = T[i]
    else:
        if T[i] in S[:i]:
            if dic[S[i]] != T[i]:
                print('No')
                exit()
        else:
            dic[S[i]] = T[i]
            dic[T[i]] = S[i]
            S[i] = T[i]
print('Yes')

Submission status: Runtime Error

Solution code:
import sys
s=input()
t=input()
def hanten(*S,c1,c2):
  for i range(len(S)):
    if S[i]==c1:
      S[i]=c2
    if S[i]==c2:
      S[i]=c1
for j,k in s:
  if hanten(s,j,k)==t:
    print('Yes')
    sys.exit()
print('No')

Submission status: Runtime Error

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

Submission status: Runtime Error

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

S1 = sorted(S)
T1 = sorted(T)

count1 = 0
count2 = 0

for j in range(26):
    for i in range(len(S1)):
        if string.ascii_lowercase[j] == S1[i]:
            count1 += 1
            break
    for i in range(len(T1)):
        if string.ascii_lowercase[j] == T1[i]:
            count2 += 1
            break

if count1 == count2:
    print("Yes")
else:
    print("N0")

Submission status: Runtime Error

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

    ds = dict()
    dt = dict()
    tr = dict()
    tr2 = dict()
    res = True
    for i in range(len(s)):
        ds[s[i]] = True
        dt[s[i]] = True
        if s[i] not in tr:
            tr[s[i]] = t[i]
        else:
            if tr[s[i]] != t[i]:
                res = False

        if t[i] not in tr2:
            tr2[t[i]] = s[i]
        else:
            if tr2[t[i]] != s[i]:
                res = False

    #if (len(ds) == 26 or len(dt) == 26) and ds != dt:
    #    res = False

    print("Yes" if res else "No")

Submission status: Runtime Error

Solution code:
s,t=input(),input()
rs=rt=[""for _ in range(26)]
def a(n):return [chr(ord('a')+i)for i in range(26)].index(n)
for i in range(len(s)):
  if rs[a(s[i])]=="":rs[a(s[i])]=t[i]
  elif rs[a(s[i])]!=t[i]:print("No");exit()
  if rt[a(t[i])]=="":rt[a(t[i])]=s[i]
  elif rt[a(t[i])]!=s[i]:print("No");exit()
rint("Yes")

Submission status: Runtime Error

Solution code:
def resolve():
    S = input()
    T = input()
    chmap = {}
    # 2つのアルファベットを選んで入れ替えるという操作を何回繰り返しても、
    # 必ずalphabet26文字は自分以外のalphabetと一対一に対応し重複しない
    for i in range(len(S)):
        if S[i] != T[i]:
            if S[i] in chmap: 
                if chmap[S[i]] != T[i]:
                    print("No")
                    return
            else:
                chmap[S[i]] = T[i]

    import collections
    chmapMosts = collections.Counter(chmap.values()).most_common()
    if chmapMosts[0][1] > 1:
        print("No")
        return
    
    print("Yes")
    return


if '__main__' == __name__:
    resolve()

Submission status: Runtime Error

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

U = set()
for s, t in sorted(zip(S, T)):
  U.add((s, t))

for x, y in zip(U[0:-1], U[1:]):
  if x == y:
    print("No")
    break
else:
  print("Yes")

Submission status: Runtime Error

Solution code:
s,t=input(),input()
d={"a":0,"b":0,"c":0,"d":0,"e":0,"f":0,"g":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}
for i,j in s,t:
  if d[i]==0:d[i]=j
  elif d[i]!=j:print("No");exit()
  if d[j]==0:d[j]=i
  elif d[j]!=i:print("No");exit()
print("Yes")

Submission status: Runtime Error

Solution code:
s,t=input(),input()
d={"a":0,"b":0,c"":0,"d":0,"e":0,"f":0,g"":0,"h":0,"i":0,"j":0,"k":0,"l":0,"m":0,"n":0,"o":0,"p":0,"q":0,"r":0,"s":0,"t":0,"u":0,"v":0,"w":0,"x":0,"y":0,"z":0}
for i,j in s,t:
  if d[i]==0:d[i]=j
  elif d[i]!=j:print("No");exit()
  if d[j]==0:d[j]=i
  elif d[j]!=i:print("No");exit()
print("Yes")

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import sys

input = sys.stdin.readline

def main():
    T2 = T[:]
    for i in range(len(S)):
        if S[i] == T2[i]:
            continue
        from_c = T2[i]
        to_c = S[i]
        T2 = T2.translate(str.maketrans({from_c: to_c, to_c: from_c}))

    if S != T2:
        print("No")
    else:
        print("Yes")

main()

Submission status: Runtime Error

Solution code:
s = input()
t = input()
# snum = []
# tnum = []
# for c in range(ord('a'), ord('z') + 1):
#     snum.append([i for i, x in enumerate(s) if x == chr(c)])
# for c in range(ord('a'), ord('z') + 1):
#     tnum.append([i for i, x in enumerate(t) if x == chr(c)])
# snum.sort()
# tnum.sort()
# print('Yes' if snum == tnum else 'No')


sn=[0 for i in range(26)]
tn=[0 for i in range(26)]
for i in range(len(s)):
    sn[ord(s[i])]+=1
    tn[ord(t[i])]+=1
print('Yes' if sorted(sn) == sorted(tn) else 'No')

Submission status: Runtime Error

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

s_list=list(s)
t_list=list(t)
js=''
jt=''
if len(set(s_list)) != len(set(t_list)):
  print('No')
else:
  for i in range(len(s_list)-1):
    t_list.replace(t_list[i],s_list[i])
    s+=s_list[i]
    t+=t_list[i]
  if s_list == t_list:
    print('Yes')
  else:
    print('No')

Submission status: Runtime Error

Solution code:
s=input()
t=inpur()
arr1=[0]*26
arr2=[0]*26
check='abcdefghijklmnopqrstuvwxyz'
for i in range(26):
  arr1[i]=s.count(check[i])
  arr2[i]=s.count(check[i])
arr1=sorted(arr1)
arr2=sorted(arr2)
for i in range(26):
  if arr1[i]!=arr2[i]:
    print('No')
    break
else:
  print('Yes')

Submission status: Runtime Error

Solution code:
from collections import defaultdict
import sys
input = sys.stdin.readline

s = input()
t = input()
ds = defaultdict(int)
ss = ""
dt = defaultdict(int)
st = ""
a = "abcdefghijklmnopqrstuvwxyz"
s_res = ""
t_res = ""

for i in range(len(s)):
    ds[s[i]] += 1
    dt[t[i]] += 1
    if ds[s[i]] == 1:
        ss += s[i]
    if dt[t[i]] == 1:
        st += t[i]
    s_res += a[ss.find(s[i])]
    t_res += a[st.find(t[i])]
    

if s_res == t_res:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
from collections import defaultdict
import sys
input = sys.stdin.readline

s = input()
t = input()
ds = defaultdict(int)
dt = defaultdict(int)
a = "abcdefghijklmnopqrstuvwxyz"
s_res = ""
t_res = ""

for i in range(len(s)):
    ds[s[i]] += 1
    dt[t[i]] += 1
    s_res += a[len(ds)-1]
    t_res += a[len(dt)-1]

if s_res == t_res:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = list(input())
T = list(input())

for i in range(len(S)):
    s = S[i]
    for j in S:
        if j == s:
            j == T[i]

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

Submission status: Runtime Error

Solution code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
S = list(input())
T = list(input())

for i in range(len(S)):
    s = S[i]
    for j in S:
        if j == s:
            j == T[i]

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

Submission status: Runtime Error

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

dic = {}
sets = set()
flag = True
for s,t in S,T:
  if s in sets:
    if dic[s] != t:
      flag = False
      break
  else:
    sets.add(s)
    dic[s] = t
    
if flag:
  print('Yes')
else:
  print('No')

Submission status: Runtime Error

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

#print(s)
#print(t)

sset = list(set(s))
tset = list(set(t))

#print(sset)
#print(tset)

s_getindex = []
t_getindex = []

for j in range(len(sset)):
    s_getindex.append([i for i, x in enumerate(s) if x == sset[j]])

for jj in range(len(tset)):
    t_getindex.append([ii for ii, y in enumerate(t) if y == tset[jj]])

#print(s_getindex)
#print(t_getindex)

check_s = []
check_t = []
ans = 0

for k in range(len(sset)):
    if len(s_getindex[k]) != 1:
        for m in s_getindex[k]:
            check_s.append(t[m])
        if len(set(check_s)) != 1:
            ans = ans + 1

for kk in range(len(tset)):
    if len(t_getindex[kk]) != 1:
        for mm in s_getindex[kk]:
            check_t.append(s[mm])
        if len(set(check_t)) != 1:
            ans = ans + 1

#print(ans)

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

Submission status: Runtime Error

Solution code:
from collections import defaultdict

S = input()
T = input()
L=len(S)
dds = defaultdict(int)
ddt = defaultdict(int)
for i in range(L):
  s = S[i]
  t = T[i]
  if dds[s] == 0:
    dds[s] = t
  else:
    if dds[s] != t:
      print("No")
      sys.exit()
      
  if ddt[t] == 0:
    ddt[t] = s
  else:
    if ddt[t] != s:
      print("No")
      sys.exit()
      
print("Yes")

Submission status: Runtime Error

Solution code:
s=input()
n=input()
d=dict()
ans="Yes"
for i in range(len(s)):
  if s[i] not in d:
    d[s[i]]=n[i]
  elif d[s[i]]!=n[i]:
    ans="No"
if s!=n and len(s)=26:
  ans="No"
print(ans)

Submission status: Runtime Error

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

def calc(S, T):
    # 差を計算する
    ans = 0
    for i in range(len(S)):
        if S[i] != T[i]:
            ans += 1
    return ans


def solve():
    s = input()
    S = [moji for moji in s]
    T = input()

    # 文字の置き換えをして、差が減ってなかったら無理？
    pre_diff = calc(S, T)
    while True:
        for i in range(len(S)):
            if S[i] != T[i]:
                c1 = S[i]
                c2 = T[i]
                break
        
        for i in range(len(S)):
            if S[i] == c1:
                S[i] = c2
            elif S[i] == c2:
                S[i] = c1
        
        # 差を計算する
        diff = calc(S, T)
        if diff == 0:
            break
        elif diff < pre_diff:
            pre_diff = diff
            continue
        else:
            print("No")
            return
    print("Yes")





if __name__ == "__main__":
    solve()

Submission status: Runtime Error

Solution code:
S = input()
T = input()
alll = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
alfa = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
count_s = set()
count_t = set()
for s in range(len(S)):
    if count_s == alfa:
        break
    if S[s] in count_s:
        continue
    count_s.add(S[s])
    S = S.replace(S[s],str(alll[s]))
for t in range(len(T)):
    if count_t == alfa:
        break
    if t in count_t:
        continue
    count_t.add(T[t])
    T = T.replace(T[t],str(alll[t]))
if S == T:
    print('Yes')
else:print('No')

Submission status: Runtime Error

Solution code:
import collections

s = input()
t = input()
c1 = collections.Counter(s)
c2 = collections.Counter(t)
s_values = sorted(list(c1.values()))
t_values = sorted(list(c2.values()))

if len(s) == len(t):
  if len(list(set(s))) == len(list(set(t))):
    if s_values == v_values():
      print("Yes")
    else:
      print("No")
  else:
    print("No")
else:
  print("No")

Submission status: Runtime Error

Solution code:
S=input()
T=input()
Skey=sorted(S,key=S.index)
Tkey=sorted(t,ket=T.index)

for index,i in enumerate(Skey):
  S=S.replace(i,str(index))
for index,i in enumerate(Tkey):
  T=T.replace(i,str(index))

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

Submission status: Runtime Error

Solution code:
s = np.array(list(input()))
t = np.array(list(input()))
num = 0
for i in set(t):
  if np.sum(s==i) == np.sum(t==i):
    num += 1
    continue
  if len(set(s[t==i])) == 1:
    num += 1
    continue
if num == len(set(t)):
  print("Yes")
else:
  print("No")

Submission status: Runtime Error

Solution code:
from collections import*;C=Counter;print('YNeos'[eval('!=C(C(input()).values())'*2[2:])::2])

Submission status: Runtime Error

Solution code:
from itertools import*;i=lambda:sorted([len(list(v))for k,v in groupby(input()]);print('YNeos'[i()!=i()::2])

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    n = II()
    print("ABC"+str(n))
    return

#B
def B():
    ni = [2 ** i for i in range(1, 10)]
    n = II()
    ans = 1
    for i in range(1, n + 1):
        if i in ni:
            ans = i
    print(ans)        
    return

#C
def C():
    alp = [chr(ord('a') + i) for i in range(26)]
    s = S()
    t = S()
    ss = [[] for i in range(26)]
    for i in range(len(s)):
        ss[alp.index(s[i])].append(t[i])
        ss[alp.index(s[i])] = set(ss[alp.index(s[i])])
    for st in ss:
        if len(st) >= 2:
            print("Yes")
            return
    print("No")
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    C()

Submission status: Runtime Error

Solution code:
S=input()
T=input()
N=[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: Runtime Error

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(S)
print('No') if S!=T else print('Yes')

Submission status: Runtime Error

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



def judge(S,T):
    start = [-1 for i in range(26) ] 
    goal = [-1 for i in range(26)]
    for i in range(len(S)):
        a = ord(S[i]) - ord('a')
        b = ord(T[i]) - ord('a')
        if start[a] != -1 or goal[b] != -1:
            if start[a]!= b or goal[b] !=a:
                print("No")
                break
        else:
            start[a] = b
            goal[b] =a
        if i==len(S)-1:
            print("Yes")
            
            
 judge(s,t)

Submission status: Runtime Error

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

count = 0
while True:
    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 count == len(S)-1:
        break

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

Submission status: Runtime Error

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

count = 0
while True:
    if S[count] == T[count]:
        count = count + 1
        #print(count)
    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
    if count == len(S)-1:
        break

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

Submission status: Runtime Error

Solution code:
from collections import Counter
S=input()
T=input()
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(len(s)):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2 and flag:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
                break
    if c[i][1]>=2 and flag:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
                break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S=input()
T=input()
from collections import Counter
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(len(s)):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2 and flag:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
                break
    if c[i][1]>=2 and flag:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        print(f)
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
                break
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
S=input()
T=input()
from collections import Counter
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(len(s)):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2:
        e=[]
        for j in range(len(s)):
            if t[j]==d[i][0]:
                e.append(s[j])
        for j in range(len(e)-1):
            if e[j]!=e[j+1]:
                flag=False
    if c[i][1]>=2:
        f=[]
        for j in range(len(s)):
            if s[j]==c[i][0]:
                f.append(t[j])
        for j in range(len(f)-1):
            if f[j]!=f[j+1]:
                flag=False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
from collections import Counter
S=input()
T=input()
s=list(S)
t=list(T)
a=Counter(s)
b=Counter(t)
c=a.most_common()
d=b.most_common()
flag=True
for i in range(len(s)):
    if d[i][1]==1 and c[i][1]==1:
        break
    if d[i][1]>=2:
        e=[]
        for i in range(len(s)):
            if t[i]==d[0][0]:
                e.append(s[i])
        for i in range(len(e)-1):
            if e[i]!=e[i+1]:
                flag=False
    if c[i][1]>=2:
        f=[]
        for i in range(len(s)):
            if s[i]==c[0][0]:
                f.append(t[i])
        for i in range(len(f)-1):
            if f[i]!=f[i+1]:
                flag=False
if flag:
    print('Yes')
else:
    print('No')

Submission status: Runtime Error

Solution code:
s = input()
t = input()
dic = defaultdict(set)
for x, y in zip(s, t):
  if x != y:
    dic[x].add(y)
    dic[y].add(x)
f = True
for key in dic:
  if len(dic[key]) > 1:
    print("No")
  	f = False
if f:
  print("Yes")

Submission status: Runtime Error

Solution code:
import collections as c
s=input()
t=input()
d=c.defaultdict(list)
d2=c.defaultdict(list)
for k,v in enumerate(s):
    d[v].append(k)
for k,v in enumerate(t):
    d2[v].append(k)
if set(tuple(d.values()))==set(tuple(d2.values())):
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
s = input()
t = input()
if s == t:
	pritn('Yes')
	exit()
if len(s) == 1:
	if s != t:
		print('No')
		exit()
for i in range(len(t)):
	for j in range(len(t)):
		if t[i] == t[j] and s[i] != s[j]:
			print('No')
			exit()
print('Yes')

Submission status: Runtime Error

Solution code:
s = input()
t = input()
if s == t:
	pritn('Yes')
	exit()
if len(s) == 1:
	if s != t:
		print('No')
        exit(
for i in range(len(t)):
	for j in range(len(t)):
		if t[i] == t[j] and s[i] != s[j]:
			print('No')
			exit()
print('Yes')

Submission status: Runtime Error

Solution code:
s = list(input())
t = list(input())
if s == t:
	pritn('Yes')
	exit()
for i in range(len(t)):
	for j in range(len(t)):
		if t[i] == t[j] and s[i] != s[j]:
			print('No')
			exit()
print('Yes')

Submission status: Runtime Error

Solution code:
def solve(string):
    s, t = map(int, string.split())

    c_s = sorted([s.count(_c) for _c in set(s)])
    c_t = sorted([t.count(_c) for _c in set(t)])

    if c_s == c_t:
        return "Yes"
    else:
        return "No"


if __name__ == '__main__':
    print(solve('\n'.join([input(), input()])))

Submission status: Runtime Error

Solution code:
s=input()
t=input()
i=0
while i<=min(len(s),len(t))-2:
    while s[i]==s[i+1]:
        s=s.replace(s[i],"",1)
    while t[i]==t[i+1]:
        t=t.replace(t[i],"",1)
    if len(s)==len(t):
        i+=1
    else:
        print("No")
        break
    
    if i==len(s)-2:
        while s!="":
            s=s.replace(s[0],"")
            t=t.replace(t[0],"")
            if len(s)==len(t):
                pass
            else:
                print("No")
                break
            
            if s=="":
                print("Yes")
            else:
                pass

Submission status: Runtime Error

Solution code:
s=input()
t=input()
i=0
while i<=min(len(s),len(t))-2:
    while s[i]==s[i+1]:
        s=s.replace(s[i],"",1)
        print(s)
    while t[i]==t[i+1]:
        t=t.replace(t[i],"",1)
    if len(s)==len(t):
        i+=1
    else:
        print("No")
        break
    
    if i==len(s)-2:
        while s!="":
            s=s.replace(s[0],"")
            t=t.replace(t[0],"")
            if len(s)==len(t):
                pass
            else:
                print("No")
                break
            
            if s=="":
                print("Yes")
            else:
                pass

Submission status: Runtime Error

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

i = 0
his = []
length = len(s)
flag = True
for i in range(0, length-1):
	ss = s[i:i+1]
	tt = t[i:i+1]
	if ss != tt:
		if tt in his:
			flag = False
			break
		else:
			his.append(tt)
			it1 = re.finditer(ss, s)
			it2 = re.finditer(tt, s)
			for match in it1:
				s = s[:match.start()] + tt + s[match.end():]
			for match in it2:
				s = s[:match.start()] + ss + s[match.end():]

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

Submission status: Runtime Error

Solution code:
import re
import sys

s = input()
t = input()

i = 0
dic = {}
length = len(s)
for i in range(0, length-1):
	ss = s[i:i+1]
	tt = t[i:i+1]
	if ss != tt:
		if ss in dic or tt in dic:
			if dic[ss] != tt or dic[tt] != ss:
				print("No")
				sys.exit()
			else:
				it1 = re.finditer(ss, s)
				it2 = re.finditer(tt, s)
				for match in it1:
					s = s[:match.start()] + tt + s[:match.end()]
				for match in it2:
					s = s[:match.start()] + ss + s[:match.end()]
		else:
			dic[ss] = tt
			dic[tt] = ss
			it1 = re.finditer(ss, s)
			it2 = re.finditer(tt, s)
			for match in it1:
				s = s[:match.start()] + tt + s[:match.end()]
			for match in it2:
				s = s[:match.start()] + ss + s[:match.end()]

print("Yes")