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: Wrong Answer

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

roma = list('abcdefghijklmnopqrstuvwxyz')
di = {}
for i in roma:
    di.update({i:0})

for i in range(len(s)):
    if s[i] == t[i]:
        continue
    else:
        di[s[i]] += 1
        di[t[i]] += 1

        if di[s[i]] == 2:
            di[s[i]] = 0
        if di[t[i]] == 2:
            di[t[i]] = 0
flag = 1
for key,value in di.items():
    if value > 0:
        flag = 0

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
L = len(S)
dic = {}
ans = "Yes"
for i in range(L):
    if T[i] not in dic:
        dic[T[i]] = S[i]
    else:
        if S[i] != dic[T[i]]:
            ans = "No"
print(ans)

Submission status: Wrong Answer

Solution code:
s=list(input())
t=list(input())
ns=[0 for i in range(len(s))]
nt=[0 for i in range(len(s))]
a=0
us=[s[0]]
ut=[t[0]]
for i in range(1,len(s)):
    if s[i] in us:
        ns[i]=ns[us.index(s[i])]
    else:
        ns[i]=ns[i-1]+1
    us.append(s[i])
for i in range(1,len(t)):
    if t[i] in ut:
        nt[i]=nt[ut.index(t[i])]
    else:
        nt[i]=nt[i-1]+1
    ut.append(t[i])
if ns==nt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    T = input()
    cs = dict()
    to = set()
    for i, s in enumerate(S):
        t = T[i]
        if s != t:
            if s not in cs:
                if t in to:
                    print("NO")
                    return
                to.add(t)
                cs[s] = t
            elif cs[s] == t:
                continue
            else:
                print("NO")
                return
    print("YES")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

works = True
trans = {}

for c1, c2 in zip(s1, s2):
  print("s",c1,c2,trans)
  if c1 in trans:
    if trans[c1] != c2:
      works = False
      break
  else:
    trans[c1] = c2
    trans[c2] = c1
    
if works:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
c = 0
for i,j in zip(s,t):
    if i != j:
        c = c + 1
if c % 2 == 0:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
d = {}
for i in range(len(s)):
    if t[i] in d:
        if d[t[i]] != s[i]:
            print("No")
            exit()
    else:
        d[t[i]] = s[i]
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
s=input()
t=input()
s1=Counter(s)
t1=Counter(t)
if s1[max(s1)]==t1[max(t1)] and s1[min(s1)]==t1[min(t1)] and len(s1)==len(t1):print('Yes')
else:print('No')

Submission status: Wrong Answer

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

for s, t in zip(S, T):
    if s != t:
        D[t].add(s)

for x in D.values():
    if len(x) > 1:
        print("No")
        break
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
# coding:utf-8

INF = float('inf')


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


S = input()
T = input()

tmp = []
word = []
prev = ''
hoge = 0
for s in S:
    if s == prev:
        hoge += 1
        continue
    else:
        if s not in word:
            tmp.append(hoge)
            word.append(s)
        hoge = 0
        prev = s


tmp2 = []
word = []
prev = ''
hoge = 0
for t in T:
    if t == prev:
        hoge += 1
        continue
    else:
        if t not in word:
            tmp2.append(hoge)
            word.append(t)
        hoge = 0
        prev = t

if tmp == tmp2:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
il = lambda: list(map(int, input().split()))
ils = lambda n, s="int(input())": [eval(s) for _ in range(n)]

s = input()
t = input()
S = ""
T = ""

se = set()
cnt = 0
for j in s:
    if not(j in se): cnt += 1
    se.add(j)
    S += str(cnt)

se = set()
cnt = 0
for j in t:
    if not(j in se): cnt += 1
    se.add(j)
    T += str(cnt)

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
S=list(input())
T=list(input())
Tcnt=list(Counter(T).items())
Tcnt2=[]
for i in range(len(Tcnt)):
    if Tcnt[i][1]>1:
        Tcnt2.append(Tcnt[i][0])
U=[]
for i in range(len(Tcnt2)):
    tmp=set([])
    for j in range(len(S)):
        if T[j]==Tcnt2[i]:
            tmp.add(S[j])
    if len(tmp)>1:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
check = [[] for i in range(26)]
for i in range(len(T)):
    check[ord(T[i]) - 97].append(i)
ans = 1
for i in check:
    for j in range(1, len(i)):
        if S[i[j]] != S[i[j - 1]]:
            ans = -1
            break
if ans == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
# coding: utf-8
s,t=input(),input()
memo={}
for i in range(len(s)):
    if s[i] in memo:
        if memo[s[i]]!=t[i]:
            print('No')
            break
    else:
        memo[s[i]]=t[i]
        memo[t[i]]=s[i]
else:
    print('Yes')

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
import sys
s=input()
t=input()
if s==t:
    print('No')
s=set(s)
t=set(t)
if len(s)==len(t):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


def comb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2, r + 1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p - 1, r, p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def bisearch(L, target):
    low = 0
    high = len(L) - 1
    
    while low <= high:
        mid = (low + high) // 2
        guess = L[mid]
        if guess == target:
            return True
        elif guess < target:
            low = mid + 1
        elif guess > target:
            high = mid - 1
    if guess != target:
        return False

# --------------------------------------------

dp = None


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

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

        for j in range(i - 1, -1, -1):
            if T[i] == T[j] and S[i] != S[j]:
                print("No")
                return

    print("Yes")




main()

Submission status: Wrong Answer

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

d = {}

f=True

for s,t in zip(S,T):
    if t not in d:
        d[t] = s
    else:
        if d[t] != s:
            f = False
            break
if f:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

S = input()
T = input()

ds = defaultdict(set)
for k, c in enumerate(S):
    ds[c] |= {k}
dt = defaultdict(set)
for k, c in enumerate(T):
    dt[c] |= {k}

print('Yes' if sorted(ds.values()) == sorted(dt.values()) else 'No')

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
s=set(s)
t=set(t)
if len(s)==len(t):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=raw_input()
t=raw_input()
m={}
ret = "Yes"
for i,c in enumerate(s):
  if c in m and m[c]!=t[i]:ret = "No"
  m[c] = t[i]
print ret

Submission status: Wrong Answer

Solution code:
print('Yes' if len(set(input())) % 2 == len(set(input())) % 2 else 'No')

Submission status: Time Limit Exceeded

Solution code:
import sys


def main():
    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")


if __name__ == "__main__":
    main()

Submission status: Time Limit Exceeded

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

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

Submission status: Time Limit Exceeded

Solution code:
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import gcd, sin, cos, tan, asin, acos, atan, degrees, radians

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def powmod(n,i,mod):
    return pow(n,mod-1+i,mod) if i<0 else pow(n,i,mod)
def div2(x):
    return x.bit_length()
def div10(x):
    return len(str(x))-(x==0)
def perm(n,mod=None):
    ans = 1
    for i in range(1,n+1):
        ans *= i
        if mod!=None:
            ans %= mod
    return ans
def intput():
    return int(input())
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x,d=1):
        self.setdefault(x,0)
        self[x] += d
    def list(self):
        l = []
        for k in self:
            l.extend([k]*self[k])
        return l
class comb():
    def __init__(self, n, mod=None):
        self.l = [1]
        self.n = n
        self.mod = mod
    def get(self,k):
        l,n,mod = self.l, self.n, self.mod
        k = n-k if k>n//2 else k
        while len(l)<=k:
            i = len(l)
            l.append(l[i-1]*(n+1-i)//i if mod==None else (l[i-1]*(n+1-i)*powmod(i,-1,mod))%mod)
        return l[k]
def pf(x):
    C = counter()
    p = 2
    while x>1:
        k = 0
        while x%p==0:
            x //= p
            k += 1
        if k>0:
            C.add(p,k)
        p = p+2-(p==2) if p*p<x else x
    return C

S,T=input(),input()
for i in range(len(S)):
    if S[i]!=T[i]:
        c=S[i]
        S=S.replace(c,'-').replace(T[i],c).replace('-',T[i])
judge(S==T)

Submission status: Time Limit Exceeded

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

s_par = [i for i in range(n + 1)]
t_par = [i for i in range(n + 1)]

def operation(x, par):
    for i in range(n):
        for j in range(i):
            if x[i] == x[j]:
                par[i] = par[j]
    return par

if operation(s, s_par) == operation(t, t_par):
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

Solution code:
def main():
    s = input()
    t = input()
    rep_map = {}
    for i in range(len(s)):
        if s[i] != t[i]:
            s = s.translate(str.maketrans({s[i]: t[i], t[i]: s[i]}))
    print('Yes') if s == t else print('No')


if __name__ == '__main__':
    main()

Submission status: Time Limit Exceeded

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

for i in range(n):
    if s.count(s[i]) == 1:
        continue
    else:
        memo1 = [t[i]]
        for j in range(i+1,n):
            if s[j] == s[i]:
                memo1.append(t[j])
        if len(set(memo1)) != 1:
            print('No')
            exit()


for i in range(n):
    if t.count(t[i]) == 1:
        continue
    else:
        memo2 = [s[i]]
        for j in range(i+1,n):
            if t[j] == t[i]:
                memo2.append(s[j])
        if len(set(memo2)) != 1:
            print('No')
            exit()
print('Yes')

Submission status: Time Limit Exceeded

Solution code:
s=list(input())
t=list(input())
n=len(s)
def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for i in range(n):
        ans[s[i]].append(i)
    return ans


def get_index2alpha(s):
    ans={}
    for i in range(n):
        ans[i]=s[i]
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0
for i in range(len(s)):
    if not s_count[s_index[i]]==t_count[t_index[i]]:
        ans+=1

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

Submission status: Time Limit Exceeded

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

def get_count_list(s):
    alphabets="abcdefghijklmnopqrstuvwxyz"
    ans={}
    for alphabet in alphabets:
        ans[alphabet]=[]
    for j,i in enumerate(s):
        ans[i].append(j)
    return ans


def get_index2alpha(s):
    ans={}
    for i,c in enumerate(s):
        ans[i]=c
    return ans

s_count=get_count_list(s)
t_count=get_count_list(t)
s_index=get_index2alpha(s)
t_index=get_index2alpha(t)

ans=0
for i in range(len(s)):
    if not s_count[s_index[i]]==t_count[t_index[i]]:
        ans+=1

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

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
n = len(S)
s = []
t = []
for i in range(n):
  s.append(S[i])
  t.append(T[i])
#print(s, t)

for i in range(n):
  if s[i] != t[i]:
    c1 = s[i]
    c2 = t[i]
    for j in range(n):
      if s[j] == c1:
        s[j] = c2
      elif s[j] == c2:
        s[j] = c1      
if s == t:
  print('Yes')
else:
  print('No')

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
N = len(S)
pos_S = {c: set() for c in "abcdefghijklmnopqrstuvwxyz"}
[pos_S[S[i]].add(i) for i in range(N)]
pos_T = {c: set() for c in "abcdefghijklmnopqrstuvwxyz"}
[pos_T[T[i]].add(i) for i in range(N)]
if all(pos_S[S[i]] == pos_T[T[i]] for i in range(N)):
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
N = len(S)
pos_S = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
[pos_S[S[i]].append(i) for i in range(N)]
pos_T = {c: [] for c in "abcdefghijklmnopqrstuvwxyz"}
[pos_T[T[i]].append(i) for i in range(N)]
if all(pos_S[S[i]] == pos_T[T[i]] for i in range(N)):
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
alp =list("abcdefghijklmnopqrstuvwxyz")
sl = [0] * 26
tl = [0] * 26
for i in s:
    for j in range(26):
        sl[j] = s.count(alp[j])
for i in t:
    for j in range(26):
        tl[j] = t.count(alp[j])
sl.sort()
tl.sort()
if(sl == tl):
    print("Yes")
else:
    print("No")

Submission status: Time Limit Exceeded

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

for i in range(len(s)):
    a, b = s[i], t[i]
    if a != b:
        s = s.replace(a, '-').replace(b, a).replace('-', b)
        
if s == t:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

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

for i in range(len(s)):
    if s[i] != t[i]:
        if not i in num:
            a, b = s[i], t[i]
            s = s.replace(a, '-')
            s = s.replace(b, a)
            s = s.replace('-', b)
            num.add(a)
            num.add(b)
    num.add(s[i])
    num.add(t[i])
            
if s == t:
    print('Yes')
else:
    print('No')

Submission status: Time Limit Exceeded

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

for i in range(len(s)):
    if s[i] != t[i]:
        if not i in num:
            a, b = s[i], t[i]
            s = s.replace(a, '-')
            s = s.replace(b, a)
            s = s.replace('-', b)
            num.add(s[i])

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

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
d=[[] for i in range(26)]
for i,c in enumerate(S):
    d[ord(c)-ord('a')].append(i)
d2=[[] for i in range(26)]
for i,c in enumerate(T):
    d2[ord(c)-ord('a')].append(i)
d=sorted([x for x in d if x],key=lambda x:x[0])
d2=sorted([x for x in d2 if x],key=lambda x:x[0])
f=0
if len(d)==len(d2):
    f=1
    for i in range(len(d)):
        if len(d[i])!=len(d2[i]):
            f=0
        else:
            for j in range(len(d[i])):
                if d[i]!=d2[i]:
                    f=0
print(['No','Yes'][f])

Submission status: Time Limit Exceeded

Solution code:
S=input()
T=input()
d=[[] for i in range(26)]
for i,c in enumerate(S):
    d[ord(c)-ord('a')].append(i)
d2=[[] for i in range(26)]
for i,c in enumerate(T):
    d2[ord(c)-ord('a')].append(i)
d.sort()
d2.sort()
f=1
for i in range(26):
    if len(d[i])!=len(d2[i]):
        f=0
    else:
        for j in range(len(d[i])):
            if d[i]!=d2[i]:
                f=0
print(['No','Yes'][f])

Submission status: Time Limit Exceeded

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

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

    S = S.replace(S[i], '-').replace(T[i], S[i]).replace('-', T[i])

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

Submission status: Time Limit Exceeded

Solution code:
S = input()
T = input()
a_idx = ord('a')
S_Lis = {}
T_Lis = {}
leng = len(S)
for i in range(leng):
    s_idx = ord(S[i])-a_idx
    t_idx = ord(T[i])-a_idx
    if s_idx in S_Lis:
        S_Lis[s_idx].append(i)
    else:
        S_Lis[s_idx] = [i]
    if t_idx in T_Lis:
        T_Lis[t_idx].append(i)
    else:
        T_Lis[t_idx] = [i]
    if S_Lis[s_idx] != T_Lis[t_idx]:
        print("No")
        exit()
print("Yes")

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
import sys
S = input()
T = input()
tmp = {}
for i in range(len(S)):
    if S.count(S[i]) > 1:
        if S[i] not in tmp:
            tmp[S[i]] = T[i]
        elif tmp[S[i]] == T[i]:
            pass
        else:
            print("No")
            sys.exit()
tmp = {}
for i in range(len(T)):
    if T.count(T[i]) > 1:
        if T[i] not in tmp:
            tmp[T[i]] = S[i]
        elif tmp[T[i]] == S[i]:
            pass
        else:
            print("No")
            sys.exit()
print("Yes")

Submission status: Time Limit Exceeded

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

for i in range(N):
    if S.count(S[i]) != T.count(T[i]):
        print('No')
        break
else:
    print('Yes')

Submission status: Time Limit Exceeded

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

X = []
Y = []
for i in range(N):
    X.append(S.count(S[i]))
    Y.append(T.count(T[i]))

print('Yes' if X == Y else 'No')

Submission status: Time Limit Exceeded

Solution code:
s = input()
t = input()
cnts = 0
cntt = 0
for i in range(len(s)):
    for j in range(i,len(s)):
        if s[i] == s[j]:
            cnts = cnts+1
        if t[i] == t[j]:
            cntt = cntt+1
if(cnts != cntt):
    print('No')
else:
    print('Yes')

Submission status: Time Limit Exceeded

Solution code:
def solve():
    s = input()
    t = input()
    for i in range(len(s)):
        if s[i] != t[i]:
            tmp = s[i]
            s = s.replace(s[i], '*')
            s = s.replace(t[i], tmp)
            s = s.replace('*', t[i])
    if s == t:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    solve()

Submission status: Time Limit Exceeded

Solution code:
s=input()
t=input()
ds=dict()
dt=dict()
ss=''
st=''
for i in s:
    if i not in ds:
        ds[i]=str(len(ds))+' '
    ss+=ds[i]
for i in t:
    if i not in dt:
        dt[i]=str(len(dt))+' '
    st+=dt[i]
#print(ss,st)
print('Yes' if ss==st else 'No')
#print(ds,dt)

Submission status: Time Limit Exceeded

Solution code:
import sys
s=list(input())
t=list(input())
n=len(s)
for i in range(n):
  if s.count(s[0])>1:
    if t[0]!=t[s[1:].index(s[0])+1]:
      print('No')
      sys.exit()
  if t.count(t[0])>=2:
    if s[0]!=s[t[1:].index(t[0])+1]:
      print('No')
      sys.exit()
  s.pop(0)
  t.pop(0)
print('Yes')

Submission status: Time Limit Exceeded

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

# 例abcdefg...のように文字列が1対1の矢印関係の場合は、
# どのような場合でも置き換えできる。問題は同じ文字が複数現れる場合

# S上に同じ文字sのある場所には
# T上にも同じ文字tがなくてはならない
# つまり、同じ値になっているインデックスの集合を取れば
# 全部同じになっているはず

# 文字種ごとにインデックスの集合を求める
ns = len(S)
indexS = {}
for i in range(ns):
    s = S[i]
    if s in indexS:
        indexS[s].append(i)
    else:
        indexS[s] = [i]
indexT = {}
for i in range(ns):
    t = T[i]
    if t in indexT:
        indexT[t].append(i)
    else:
        indexT[t] = [i]
# 先頭の文字から、インデックスの集合が等しいかチェック
for s, t in zip(S, T):
    i_s = indexS[s]
    i_t = indexT[t]
    if i_s != i_t:
        print("No")
        break
else:
    print("Yes")

Submission status: Time Limit Exceeded

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

# 例abcdefg...のように文字列が1対1の矢印関係の場合は、
# どのような場合でも置き換えできる。問題は同じ文字が複数現れる場合

# S上に同じ文字sのある場所には
# T上にも同じ文字tがなくてはならない
# つまり、同じ値になっているインデックスの集合を取れば
# 全部同じになっているはず

# 文字種ごとにインデックスの集合を求める
indexS = {}
for i, s in enumerate(S):
    if s in indexS:
        indexS[s].append(i)
    else:
        indexS[s] = [i]
indexT = {}
for i, t in enumerate(T):
    if t in indexT:
        indexT[t].append(i)
    else:
        indexT[t] = [i]
# 先頭の文字から、インデックスの集合が等しいかチェック
for s, t in zip(S, T):
    i_s = indexS[s]
    i_t = indexT[t]
    if i_s != i_t:
        print("No")
        break
else:
    print("Yes")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
alp = ["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"]
sets = set(S)
sett = set(T)
variedad = len(sets)
sa = set()
sb = set()
flag = 0

if(variedad != len(sets)):
  print("No")
else:
  for j in range(variedad):
    indexis = []
    char = sets.pop()
    for k in range(S.count(char)):
      index = S.index(char)
      S[index] = ""
      indexis.append(index)
    t = tuple(indexis)
    sa.add(t)
  
  for j in range(variedad):
    indexis = []
    char = sett.pop()
    for k in range(T.count(char)):
      index = T.index(char)
      T[index] = ""
      indexis.append(index)
    t = tuple(indexis)
    sb.add(t)
    if(t not in sa):
      print("No")
      flag = 1
      break

  if(flag == 0):
    if(sa == sb):
      print("Yes")
    else:
      print("No")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
alp = ["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"]
numa = []
numb = []
sa = set()
sb = set()
flag = 0

for i in range(26):
  numa.append(S.count(alp[i]))
  numb.append(T.count(alp[i]))
  
Numa = sorted(numa)
Numb = sorted(numb)

if(Numa != Numb):
  print("No")
else:
  for j in range(26):
    indexi = []
    for k in range(numa[j]):
      index = S.index(alp[j])
      S[index] = ""
      indexi.append(index)
    t = tuple(indexi)
    sa.add(t)
  
  for j in range(26):
    indexi = []
    for k in range(numb[j]):
      index = T.index(alp[j])
      T[index] = ""
      indexi.append(index)
    t = tuple(indexi)
    sb.add(t)
    if(t not in sa):
      print("No")
      flag = 1
      break

  if(flag == 0):
    if(sa == sb):
      print("Yes")
    else:
      print("No")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
alp = ["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"]
numa = []
numb = []
sa = set()
sb = set()
flag = 0

for i in range(26):
  numa.append(S.count(alp[i]))
  numb.append(T.count(alp[i]))
  
Numa = set(numa)
Numb = set(numb)

if(Numa != Numb):
  print("No")
else:
  for j in range(26):
    indexi = []
    for k in range(numa[j]):
      index = S.index(alp[j])
      S[index] = ""
      indexi.append(index)
    t = tuple(indexi)
    sa.add(t)
  
  for j in range(26):
    indexi = []
    for k in range(numb[j]):
      index = T.index(alp[j])
      T[index] = ""
      indexi.append(index)
    t = tuple(indexi)
    sb.add(t)
    if(t not in sa):
      print("No")
      flag = 1
      break

  if(flag == 0):
    if(sa == sb):
      print("Yes")
    else:
      print("No")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
alp = ["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"]
numa = []
numb = []
sa = set()
sb = set()
flag = 0

for i in range(26):
  numa.append(S.count(alp[i]))
  numb.append(T.count(alp[i]))
  
for j in range(26):
  indexi = []
  for k in range(numa[j]):
    index = S.index(alp[j])
    S[index] = ""
    indexi.append(index)
  t = tuple(indexi)
  sa.add(t)
  
for j in range(26):
  indexi = []
  for k in range(numb[j]):
    index = T.index(alp[j])
    T[index] = ""
    indexi.append(index)
  t = tuple(indexi)
  sb.add(t)
  if(t not in sa):
    print("No")
    flag = 1
    break

if(flag == 0):
  if(sa == sb):
    print("Yes")
  else:
    print("No")

Submission status: Time Limit Exceeded

Solution code:
S = list(input())
T = list(input())
alp = ["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"]
numa = []
numb = []
sa = set()
sb = set()

for i in range(26):
  numa.append(S.count(alp[i]))
  numb.append(T.count(alp[i]))
  
for j in range(26):
  indexi = []
  for k in range(numa[j]):
    index = S.index(alp[j])
    S[index] = ""
    indexi.append(index)
  t = tuple(indexi)
  sa.add(t)
  
for j in range(26):
  indexi = []
  for k in range(numb[j]):
    index = T.index(alp[j])
    T[index] = ""
    indexi.append(index)
  t = tuple(indexi)
  sb.add(t)
  
if(sa == sb):
  print("Yes")
else:
  print("No")

Submission status: Time Limit Exceeded

Solution code:
s,t=map(lambda x:sorted(x.count(i)for i in x),open(0))
print('YNeos'[s!=t::2])

Submission status: Time Limit Exceeded

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

Submission status: Time Limit Exceeded

Solution code:
a=input()
b=input()

def swap(word,x,y):
	word=word.replace(x,'+')
	word=word.replace(y,'-')
	word=word.replace('+',y)
	word=word.replace('-',x)
	return word
	
for i in range(len(a)):
	if a[i] != b[i]:
		a=swap(a,a[i],b[i])

if a == b:
	print('Yes')
else:
	print('No')

Submission status: Time Limit Exceeded

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

length=len(S)
Smarker=[0]*length
Tmarker=[0]*length

for num1 in range(length):
    for num2 in range(length-num1-1):
        if S[num1]==S[num1+1+num2]:
            Smarker[num1]+=1
        if T[num1]==T[num1+1+num2]:
            Tmarker[num1]+=1

Sresult=0
Tresult=0

for num in range(length):
    if Smarker[num]==0:
        Sresult+=1
    if Tmarker[num]==0:
        Tresult+=1
    if Smarker[num]==1:
        Sresult+=10
    if Tmarker[num]==1:
        Tresult+=10

if Sresult==Tresult:
    print("Yes")
else:
    print("No")