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

for i in range(len(S)):
    s_idx = [j for j, c in enumerate(S) if c == S[i]]
    t_idx = [j for j, c in enumerate(T) if c == T[i]]

    if s_idx != t_idx:
        print('No')
        exit()

print('Yes')

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
ans = 1
for i in range(len(S)):
    if S.count(S[i]) != T.count(T[i]):
        ans = 0
        break
print("Yes" if ans == 1 else "No")

Submission status: Time Limit Exceeded

Solution code:
s = input()
target = input()
for index in range(len(s)):
    ss = s[index]
    tt = target[index]
	
    if s[:index] != target[:index] or s==target:
        break
    if ss == tt:
        continue
    else: #ssとttを相互変換する
        s = s.replace(ss,"0").replace(tt,ss).replace("0",tt)

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

Submission status: Time Limit Exceeded

Solution code:
s = input()
target = input()
for index in range(len(s)):
    ss = s[index]
    tt = target[index]
	
    if s[:index] != target[:index]:
        break
    if ss == tt:
        continue
    else: #ssとttを相互変換する
        s = s.replace(ss,"0").replace(tt,ss).replace("0",tt)

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

Submission status: Time Limit Exceeded

Solution code:
s = input()
target = input()
for index in range(len(s)):
    ss = s[index]
    tt = target[index]

    if ss == tt:
        continue
    else: #ssとttを相互変換する
        s = s.replace(ss,"0").replace(tt,ss).replace("0",tt)

if s == target:
    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[i]
    t = T[i]
    S = S.replace(str(s),"1").replace(str(t),str(s)).replace("1",str(t))
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 S[i]==T[i]:
        continue

    else:
        table=str.maketrans(S[i]+T[i],T[i]+S[i])
        S=S.translate(table)
        

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

else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
s = str(input())
t = str(input())
ans = "Yes"
for i in range(len(s)):
    if s.count(s[i])!=t.count(t[i]):
        ans = "No"
        break
    else:
        continue
print(ans)

Submission status: Time Limit Exceeded

Solution code:
import sys

s = input()
t = input()

def replacement(word, a, b):
    return word.replace(a, "0").replace(b, a).replace("0", b)

yet_list = []
for i in range(len(s)):
    if s[i] != t[i]:
        if s[i] in yet_list:
            print("No")
            sys.exit()
        if not s[i] in yet_list:
            s = replacement(s, s[i], t[i])
            yet_list.append(s[i])
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

def replacement(word, a, b):
    return word.replace(a, "0").replace(b, a).replace("0", b)

yet_list = []
for i in range(len(s)):
    if s[i] != t[i]:
        if not s[i] in yet_list:
            s = replacement(s, s[i], t[i])
            yet_list.append(s[i])
            yet_list.append(t[i])
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

def replacement(word, a, b):
    return word.replace(a, "0").replace(b, a).replace("0", b)

yet_list = []
for i in range(len(s)):
    if s[i] != t[i]:
        if not s[i] in yet_list:
            s = replacement(s, s[i], t[i])
            yet_list.append(s[i])
if s == t:
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

    for i in range(len(s)):
        if s[i]==t[i]:
            continue
        si=s[i]
        ti=t[i]
        t=t.replace(ti, "?")
        t=t.replace(si, ti)
        t=t.replace("?", si)
    
    if s==t:
        return "Yes"
    else:
        return "No"

print(check())

Submission status: Time Limit Exceeded

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

for i in range(len(s)):
  if s[i] != t[i]:
    x = s[i]
    #print(s[i],t[i])
    s = s.replace(t[i], "#").replace(s[i], t[i]).replace("#", x)
    #print(s)
  if s == t:
    print("Yes")
    quit()
    
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]:
    x = s[i]
    #print(s[i],t[i])
    s = s.replace(t[i], "#")
    s = s.replace(s[i], t[i])
    s = s.replace("#", x)
    #print(s)
  if s == t:
    print("Yes")
    quit()
    
if s == t:
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
# 2019/08/16

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

c1={}
c2={}
for ss,tt in zip(s,t):
    c1[ss]=c1.get(ss,'')+tt
    c2[tt]=c2.get(tt,'')+ss
    
    if len(c1[ss])<2 and len(c2[tt])<2:continue
    if c1[ss].count(tt)==len(c1[ss]) and c2[tt].count(ss)==len(c2[tt]):continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Time Limit Exceeded

Solution code:
# 2019/08/16

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

c1={}
c2={}
for ss,tt in zip(s,t):
    c1[ss]=c1.get(ss,'')+tt
    c2[tt]=c2.get(tt,'')+ss
    if len(c1[ss])<2 and len(c2[tt])<2:continue
    if set(c1[ss])=={tt} and set(c2[tt])=={ss}:continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Time Limit Exceeded

Solution code:
# 2019/08/16

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

c1={}
c2={}
for ss,tt in zip(s,t):
    c1[ss]=c1.get(ss,'')+tt
    c2[tt]=c2.get(tt,'')+ss
    if len(c1[ss])<2 and len(c2[tt])<2:continue
    if set(c1[ss])==set(tt) and set(c2[tt])==set(ss):continue
    else:
        print('No')
        exit()

print('Yes')

Submission status: Time Limit Exceeded

Solution code:
# 2019/08/16

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

c1={}
c2={}
for ss,tt in zip(s,t):
    c1[ss]=c1.get(ss,'')+tt
    c2[tt]=c2.get(tt,'')+ss

for ss,tt in zip(c1.values(),c2.values()):
    if len(set(ss))>1 or len(set(tt))>1:
        print('No')
        exit()
else:print('Yes')

Submission status: Time Limit Exceeded

Solution code:
# 2019/08/16

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

c1={}
c2={}
for ss,tt in zip(s,t):
    c1[ss]=c1.get(ss,'')+tt
    c2[tt]=c2.get(tt,'')+ss
    if len(set(c1[ss]))>1 or len(set(c2[tt]))>1:
        print('No')
        exit()

print('Yes')

Submission status: Time Limit Exceeded

Solution code:
# 2019/08/16

from collections import Counter

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

c1={}
c2={}
for ss,tt in zip(s,t):
    c1[ss]=c1.get(ss,'')+tt
    c2[tt]=c2.get(tt,'')+ss
    if len(set(c1[ss]))>1 or len(set(c2[tt]))>1:
        print('No')
        exit()

print('Yes')

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc110/tasks/abc110_c

s = list(str(input()))
t = list(str(input()))
flag = 'Yes'
jskip = []
l = len(s)
for i in range(l):
    f = True
    for j in range(len(jskip)):
        if jskip[j] == s[i]:
            f = False
            break
    if f == True:
        for j in range(l):
            if s[i] == s[j] and t[i] != t[j]:
                flag = 'No'
                break
            elif t[i] == t[j] and s[i] != s[j]:
                flag = 'No'
                break
            elif s[i] == s[j] and t[i] == t[j]:
                jskip.append(s[i])
            if flag == 'No':
                break
    if flag == 'No':
        break

print(flag)

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc110/tasks/abc110_c

s = list(str(input()))
t = list(str(input()))
flag = 'Yes'
jskip = []
for i in range(len(s)):
    f = True
    for j in range(len(jskip)):
        if jskip[j] == s[i]:
            f = False
            break
    if f == True:
        for j in range(i+1, len(s)):
            if s[i] == s[j] and t[i] != t[j]:
                flag = 'No'
                break
            elif t[i] == t[j] and s[i] != s[j]:
                flag = 'No'
                break
            elif s[i] == s[j] and t[i] == t[j]:
                jskip.append(s[i])
    if flag == 'No':
        break

print(flag)

Submission status: Time Limit Exceeded

Solution code:
s = list(str(input()))
t = list(str(input()))
flag = 'Yes'
for i in range(len(s)):
    for j in range(i):
        if s[i] == s[j] and t[i] != t[j]:
            flag = 'No'
            break
        elif t[i] == t[j] and s[i] != s[j]:
            flag = 'No'
            break
        if flag == 'No':
            break
    if flag == 'No':
        break

print(flag)

Submission status: Time Limit Exceeded

Solution code:


import collections
import itertools
import sys


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

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

cnt = 0
while s != t:
    for i in range(n):
        if s[i] != t[i]:
            c1, c2 = s[i], t[i]
            for j in range(n):
                if s[j] == c1:
                    s[j] = c2
                elif s[j] == c2:
                    s[j] = c1
    cnt += 1
    if cnt > 100:
        break

ok = s == t

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

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc110/tasks/abc110_c

s = list(str(input()))
t = list(str(input()))
u = []
v = []
flag = 'Yes'


for i in range(len(s)):
    for j in range(i+1, len(s)):
        if s[i] == s[j] and t[i] != t[j]:
            flag = 'No'
            break
        elif t[i] == t[j] and s[i] != s[j]:
            flag = 'No'
            break
    if flag == 'No':
        break

print(flag)

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc110/tasks/abc110_c

s = list(str(input()))
t = list(str(input()))
u = []
v = []
flag = 'Yes'


for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == s[j]:
            if t[i] != t[j]:
                flag = 'No'
                break
        if t[i] == t[j]:
            if s[i] != s[j]:
                flag = 'No'
                break
    if flag == 'No':
        break


print(flag)

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc110/tasks/abc110_c

s = list(str(input()))
t = list(str(input()))
u = []
v = []
flag = 'Yes'
cnt = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == s[j]:
            cnt += 1
    u.append(cnt)
    cnt = 0

cnt = 0
for i in range(len(t)):
    for j in range(i, len(t)):
        if t[i] == t[j]:
            cnt += 1
    v.append(cnt)
    cnt = 0
    if u[len(v) - 1] != v[len(v) - 1]:
        flag = 'No'
        break


print(flag)

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc110/tasks/abc110_c

s = list(str(input()))
t = list(str(input()))
u = []
v = []
cnt = 0
for i in range(len(s)):
    for j in range(i, len(s)):
        if s[i] == s[j]:
            cnt += 1
    u.append(cnt)
    cnt = 0

cnt = 0
for i in range(len(t)):
    for j in range(i, len(t)):
        if t[i] == t[j]:
            cnt += 1
    v.append(cnt)
    cnt = 0

flag = 'Yes'
for i in range(len(u)):
    if u[i] != v[i]:
        flag = 'No'
        break

print(flag)

Submission status: Time Limit Exceeded

Solution code:
#https://atcoder.jp/contests/abc110/tasks/abc110_c

s = list(str(input()))
t = list(str(input()))
u = []
v = []
cnt = 0
for i in range(len(s)):
    for j in range(len(s)):
        if s[i] == s[j]:
            cnt += 1
    u.append(cnt)
    cnt = 0

cnt = 0
for i in range(len(t)):
    for j in range(len(t)):
        if t[i] == t[j]:
            cnt += 1
    v.append(cnt)
    cnt = 0

flag = 'Yes'
for i in range(len(u)):
    if u[i] != v[i]:
        flag = 'No'
        break

print(flag)
'''
cnt = 1
for i in range(1, len(s)):
    if s[i] == s[i - 1]:
        cnt += 1
    else:
        u.append(cnt)
        cnt = 1
    if i == len(s) - 1:
        u.append(cnt)

cnt = 1
for i in range(1, len(t)):
    if t[i] == t[i - 1]:
        cnt += 1
    else:
        v.append(cnt)
        cnt = 1
    if i == len(t) - 1:
        v.append(cnt)

print(u)
print(v)

flag = 'Yes'
if len(u) == len(v):
    for i in range(len(u)):
        if u[i] != v[i]:
            flag = 'No'
else:
    flag = 'No'

print(flag)
'''
'''
if flag == 'Yes':
    for i in range(len(s)):
        f = False
        for j in range(len(t)):
            if s[i] == t[j]:
                f = True
                break
        if f == False:
            flag = 'No'
            print(i)
            break

print(flag)
'''

Submission status: Time Limit Exceeded

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

s_samelist=[]
t_samelist=[]

for i in range(len(T)):
    same=set()
    for j in range(i+1,len(T)):
        if T[i]==T[j]:
            same.add(i)
            same.add(j)
    if len(same)>=1:
        t_samelist.append(list(same))

for i in range(len(S)):
    same=set()
    for j in range(i+1,len(S)):
        if S[i]==S[j]:
            same.add(i)
            same.add(j)
    if len(same)>=1:
        s_samelist.append(list(same))

if s_samelist==t_samelist:
    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:
import sys
s0,t0=input(),input()
s,t=list(s0),list(t0)
n=len(s)
sn=set(s)
tn=set(t)
if len(sn)!=len(tn) or len(s)!=len(t):
  print('No')
  sys.exit()
for i in range(n):
  if s0[i]!=t0[i]:
    s_tmp=s0[i]
    t_tmp=t0[i]
    s0=s0.replace(s0[i],'0').replace(t0[i],'1').replace('0',t_tmp).replace('1',s_tmp)
if s0==t0:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

Solution code:
import sys
s0,t0=input(),input()
s,t=list(s0),list(t0)
n=len(s)
sn=set(s)
tn=set(t)
if len(sn)!=len(tn) or len(s)!=len(t):
  print('No')
  sys.exit()
for i in range(n):
  if s0[i]!=t0[i]:
    s_tmp=s0[i]
    t_tmp=t0[i]
    s0=s0.replace(s0[i],'0')
    s0=s0.replace(t0[i],'1')
    s0=s0.replace('0',t_tmp)
    s0=s0.replace('1',s_tmp)
if s0==t0:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

Solution code:
import sys
s,t=list(input()),list(input())
n=len(s)

for i in range(n):
  ss = [j for j, x in enumerate(s) if x == s[i]]
  tt = [j for j, x in enumerate(t) if x == t[i]]
  if ss!=tt:
    print('No')
    sys.exit()
print('Yes')

Submission status: Time Limit Exceeded

Solution code:
import sys
s,t=list(input()),list(input())
n=len(s)
for i in range(n):
  if s.count(s[i])!=t.count(t[i]):
    print('No')
    sys.exit()
print('Yes')

Submission status: Time Limit Exceeded

Solution code:
s,t=list(input()),list(input())
n=len(s)
m=len(t)
ss=[0]*n
tt=[0]*n
for i in range(n):
  ss[i]=s.count(s[i])
for i in range(m):
  tt[i]=t.count(t[i])
if ss==tt:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

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

cs={}
for i,c in enumerate(s):
    cs[c] = cs.get(c,[])+[i]

ct={}
for i,c in enumerate(t):
    ct[c] = ct.get(c,[])+[i]

print('Yes' if sorted(list(ct.values()),key=lambda x:x[0])==sorted(list(cs.values()),key=lambda x:x[0]) else 'No')

Submission status: Time Limit Exceeded

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

cs={}
for i,c in enumerate(s):
    cs[c] = cs.get(c,[])+[i]

ct={}
for i,c in enumerate(t):
    ct[c] = ct.get(c,[])+[i]

print('Yes' if sorted(list(ct.values()))==sorted(list(cs.values())) else '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:
# -*- coding: utf-8 -*-
#ABC109C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

for i in range(0,len(s)-1):
	for j in range(i+1,len(s)):
		if(s[i]==s[j]):
			if(t[i]!=t[j]):
				print("No")
				sys.exit()
		else:
			if(t[i]==t[j]):
				print("No")
				sys.exit()
print("Yes")

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
#ABC109C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

for i in range(0,len(s)):
	for j in range(i,len(s)):
		if(s[i]==s[j]):
			if(t[i]!=t[j]):
				print("No")
				sys.exit()
		else:
			if(t[i]==t[j]):
				print("No")
				sys.exit()
print("Yes")

Submission status: Time Limit Exceeded

Solution code:
# -*- coding: utf-8 -*-
#ABC109C
import sys

s = input()
t = input()

#tmp = input().split()
#hoge = list(map(lambda a: int(a), tmp))
#n=hoge[0]
#x=hoge[1]

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

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


if len(list(set(S))) != len(list(set(T))):
    print("No")
else:
    ans_s = [0] * len(S)
    ans_t = [0] * len(T)

    s = copy.deepcopy(S)
    t= copy.deepcopy(T)
    list(set(s))
    list(set(t))

    for i in range(len(s)):
        for j in range(len(S)):
            if S[j] == s[i]:
                ans_s[i] += 1
            if T[j] == t[i]:
                ans_t[i] += 1
    else:
        if ans_s == ans_t:
            print("Yes")
        else:
            print("No")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
s = []
t = []
ans_s = []
ans_t = []
for i in range(len(S)):
    s.append(S[i])
    t.append(T[i])
    ans_s.append(0)
    ans_t.append(0)
else:
    list(set(s))
    list(set(t))

if len(list(set(S))) != len(list(set(T))):
    print("No")
else:
    for i in range(len(s)):
        for j in range(len(S)):
            if S[j] == s[i]:
                ans_s[i] += 1
            if T[j] == t[i]:
                ans_t[i] += 1
    else:
        if ans_s == ans_t:
            print("Yes")
        else:
            print("No")

Submission status: Time Limit Exceeded

Solution code:
s,t=input(),input()
rs=[""for _ in range(26)]
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)):
  ss,tt=a(s[i]),a(t[i])
  if rs[ss]=="":rs[ss]=t[i]
  elif rs[ss]!=t[i]:print("No");exit()
  if rt[tt]=="":rt[tt]=s[i]
  elif rt[tt]!=s[i]:print("No");exit()
print("Yes")

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
n = len(s)
p = n*(n-1)/2
i = 0
j = 1
k = 0
for _ in range(int(p)):
  if s[i] == s[j] and t[i] == t[j]:
    k = k + 1
  elif s[i] != s[j] and t[i] != t[j]:
    k = k + 1
  else:
    print('No')
    break
  j = j + 1
  if j == n:
    i = i + 1
    j = i + 1
if k == p:
  print('Yes')

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
a=[None]*26
b=[None]*26
k=1
for i in range(26):
    for j in range(len(S)):
        if S[j]==chr(97+i):
            if a[i]==None:
                a[i]=T[j]
            else:
                if T[j]!=a[i]:
                    k=0
                    break
for i in range(26):
    for j in range(len(S)):
        if T[j]==chr(97+i):
            if b[i]==None:
                b[i]=S[j]
            else:
                if S[j]!=b[i]:
                    k=0
                    break
if k==1:print("Yes")
else:print("No")

Submission status: Time Limit Exceeded

Solution code:
S = input()
size = len(list(S))
T = input()
"""
S_iとS_jが同じ文字ならば，T_iとT_jが同じでないといけない
"""

for i in range(size-1):
    if S[i] not in S[i+1:]:
        if T[i] in T[i+1:] :
            print("No")
            exit()
        else : pass
    else :
        for j in range(size,i,-1):
            if S[i] == S[j-1] :
                if T[i] == T[j-1] :
                    pass
                else :
                    print("No")
                    exit()
print("Yes")

Submission status: Time Limit Exceeded

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

for i in range(size):
    
    a = S[i]
    b = T[i]
    S = S.replace(a,"1")
    S = S.replace(b,"2")
    S = S.replace("1",b)
    S = S.replace("2",a)
    
if S == T : print("Yes")
else : print("No")

Submission status: Time Limit Exceeded

Solution code:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7

def LI(): return list(map(int,input().split()))
def I(): return int(input())
def LS(): return input().split()
def S(): return input()

def main():

  # a〜z
  l=['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']

  l2=[list() for i in range(26)]
  l3=[list() for i in range(26)]

  s=S()
  t=S()

  for i in range(len(s)):
    l2[l.index(s[i])].append(t[i])
    l3[l.index(t[i])].append(s[i])

  for x in l2:
    for y in x:
      if x.count(y)!=len(x):
        return 'No'

  for x in l3:
    for y in x:
      if x.count(y)!=len(x):
        return 'No'

  return 'Yes'

print(main())

Submission status: Time Limit Exceeded

Solution code:
sent1 = input()
sent2 = input()

l = len(sent1)

for i in range(l-1):
    for j in range(i,l):
        if sent1[i] == sent1[j] and sent2[i] != sent2[j] or sent1[i] != sent1[j] and sent2[i] == sent2[j]:
            print("No")
            exit(0)
print("Yes")

Submission status: Time Limit Exceeded

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

import sys

input = sys.stdin.readline

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

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

Solution code:
S = input()
T = input()
for i in range(0, 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")
      break
  else:
    continue
  break
else:
  print("Yes")

Submission status: Time Limit Exceeded

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

ans = True 

while S != []:
    lis = []
    lit = []
    x = S[0]
    y = T[0]
    for i in range(len(S)):
        if x == S[i]:
            lis.append(i)
        if y == T[i]:
            lit.append(i)
    if lis == lit:
        S = [S[i] for i in range(len(S)) if i not in lis]
        T = [T[i] for i in range(len(T)) if i not in lis]
        continue
    else:
        ans = False
        break
if ans:
    print('Yes')
if not ans:
    print('No')

Submission status: Time Limit Exceeded

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

ans = True 

while S != []:
    lis = []
    lit = []
    x = S[0]
    y = T[0]
    for i in range(len(S)):
        if x == S[i]:
            lis.append(i)
        if y == T[i]:
            lit.append(i)
    if lis == lit:
        while x in S:
            S.remove(x)
        while y in T:
            T.remove(y)
        continue
    else:
        ans = False
        break
if ans:
    print('Yes')
if not ans:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
ans = True
for i in range(len(S)):
    li =  []
    for j in range(len(S)):
        if S[j] == S[i]:
            li.append(j)
    for j in li:
        if T[li[0]] != T[j]:
            ans = False

for i in range(len(T)):
    li =  []
    for j in range(len(T)):
        if T[j] == T[i]:
            li.append(j)
    for j in li:
        if S[li[0]] != S[j]:
            ans = False
if ans:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

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

    answer = "Yes"
    for i in range(len(S)):
        l_s = S[i]
        l_t = T[i]
        for j in range(i, len(S)):
            r_s = S[j]
            r_t = T[j]

            if (l_s == r_s and l_t != r_t) or (l_s != r_s and l_t == r_t):
                answer = "No"
                break
    print(answer)

Submission status: Time Limit Exceeded

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

new_S = ""
new_T = ""


def change_word(a,b,S):
    for i in range(len(S)):
        if S[i] == a:
            S[i] = b
        elif S[i] == b:
            S[i] = a
        else:
            S[i] == S[i]
    return S



tmp = []
for i in range(len(S)):
    if S[i] != T[i]:
        #tmp.append([S[i], T[i]])
        S = change_word(S[i], T[i], S)
        #T = change_word(S[i], T[i], T)


#for i in tmp:


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

Submission status: Time Limit Exceeded

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

new_S = ""
new_T = ""


def change_word(a,b,S):
    for i in range(len(S)):
        if S[i] == a:
            S[i] = b
        elif S[i] == b:
            S[i] = a
        else:
            S[i] == S[i]
    return S




for i in range(len(S)):
    if S[i] != T[i]:
        S = change_word(S[i], T[i], S)
        T = change_word(S[i], T[i], T)

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

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
for _ in range(26):
    sigma = set()
    for x, y in zip(s, t):
        if x != y:
            x, y = sorted([x, y])
            sigma.add((x,y))
    sigma = sorted(sigma)
    for c1, c2 in sigma:
        tem = ""
        for c in s:
            if c == c1:
                tem += c2
            elif c == c2:
                tem += c1
            else:
                tem += c
        s = tem
    if s == t:
        print('Yes')
        exit()
print('No')

Submission status: Time Limit Exceeded

Solution code:
S, T=input(), input()
dic = {}
for i in range(len(S)):
    s, t = S[i], T[i]
    if s!=t:
        S=S.replace(s, "*")
        S=S.replace(t, s)
        S=S.replace("*", t)
    if S[:i] != T[:i]:
        print("No")
        exit()
print("Yes")

Submission status: Time Limit Exceeded

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

x = 0

for i in range(len(s)):
    if x >30:
        print('No')
        exit()
    if s[i]!=t[i]:
        a = s[i]
        b = t[i]
        for j in range(len(s)):
            if s[j] == a:
                s = s[:j] + b + s[j+1:]
            elif s[j] == b:
                s = s[:j] + a + s[j+1:]
        x += 1

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

Submission status: Time Limit Exceeded

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

s_box = []
t_box = []

for i in range(len(S)):
    if i >= len(S):
        break
    s_box.append(S.count(S[i]))
    t_box.append(T.count(T[i]))
    if s_box[i] == t_box[i]:
        S.replace(S[i], "")
        T.replace(T[i], "")
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Time Limit Exceeded

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

s_box = []
t_box = []

for i in range(len(S)):
    s_box.append(S.count(S[i]))
    t_box.append(T.count(T[i]))
    if s_box[i] == t_box[i]:
        continue
    else:
        print('No')
        exit()
print('Yes')

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
Skey=sorted(S,key=S.index)
Tkey=sorted(T,key=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: Time Limit Exceeded

Solution code:
S=input()
T=input()
Skey,Tkey=[],[]
for i in range(len(S)):
  Skey.append(S[i])
  Tkey.append(T[i])

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

Solution code:
import re

S = input()
T = input()

def func(T,S,count=0):
    if count > len(T):
        return 'No'
    for i,j in zip(T,S):
        if i == j:
            pass
        else:
            new_str = ''
            for letter in T:
                if letter == i:
                    new_str += j
                elif letter == j:
                    new_str += i
                else:
                    new_str += letter
            return func(new_str,S,count+1)
    return 'Yes'

print(func(T,S))