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:
import sys
from collections import Counter


def main():
    s = input()
    t = input()
    s_count = [0]*26
    t_count = [0]*26
    for i in range(ord("a"), ord("z")+1):
        s_count[i-97] = s.count(chr(i))
        t_count[i-97] = t.count(chr(i))
        print(s_count[i-97], t_count[i-97])
    s_count.sort()
    t_count.sort()
    if s_count == t_count:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
def main3():
    s = input()
    t = input()
    mapping = {}
    for i in range(len(s)):
        if mapping.get(s[i], s[i]) != mapping.get(t[i], t[i]):
            mapping[s[i]] = t[i]
            mapping[t[i]] = s[i]
        s = s[0:i] + mapping.get(s[i], s[i]) + s[i + 1::]
    if s == t:
        print('Yes')
    else:
        print('No')




if __name__ == '__main__':
    main3()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C_fix
# CreatedDate:  2020-09-19 19:01:39 +0900
# LastModified: 2020-09-19 19:15:49 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd


def main():
    S = input()
    T = input()
    box = []
    for i in range(len(S)):
        if S[i] != T[i] and (T[i] in box):
            print('No')
            return
        elif S[i] != T[i] and T[i] not in box:
            box.append(T[i])
#            print(S.replace(s, '0')).replace(t, '1')
            S = S.replace(S[i], '0').replace(T[i], '1').replace('0', T[i]).replace('1', S[i])
        else:
            pass
    print('Yes')




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():


    s = S()
    t = S()
    
    dic = collections.defaultdict(str)
    
    for i in range(len(s)):
        if dic[t[i]] == "":
            dic[t[i]] = s[i]
        else:
            if dic[t[i]] != s[i]:
                print("No")
                exit(0)
    
    print("Yes")

main()

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

S = input()
S = S.replace('\n','')
s_list = list(S)

T = input()
T = T.replace('\n','')
t_list = list(T)

alpha_dict = {}
t_diff_count = [0 for i in range(27)]
s_diff_count = [0 for i in range(27)]

for i,c in enumerate(range(ord('a'),ord('z')+1)):
    alpha_dict[chr(c)] = i 

for i,s in enumerate(s_list):
    if not s == t_list[i]:
        number = alpha_dict[s_list[i]]
        s_diff_count[number] += 1
        number = alpha_dict[t_list[i]]
        t_diff_count[number] += 1

for i,s in enumerate(s_list):
    number = alpha_dict[s_list[i]]
    s_count = s_diff_count[number] 
    number = alpha_dict[t_list[i]]
    t_count = t_diff_count[number]
    if not s_count == t_count:
        if t_count >= 2:
            print("No")
            exit(0)
        if s_count >= 2:
            print("No")
            exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys

input = sys.stdin.readline

S = input()
S = S.replace('\n','')
s_list = list(S)

T = input()
T = T.replace('\n','')
t_list = list(T)

alpha_dict = {}
t_diff_count = [0 for i in range(27)]
s_diff_count = [0 for i in range(27)]

for i,c in enumerate(range(ord('a'),ord('z')+1)):
    alpha_dict[chr(c)] = i 

for i,s in enumerate(s_list):
    if not s == t_list[i]:
        number = alpha_dict[s_list[i]]
        s_diff_count[number] += 1
        number = alpha_dict[t_list[i]]
        t_diff_count[number] += 1

for i,s in enumerate(s_list):
    number = alpha_dict[s_list[i]]
    s_count = s_diff_count[number] 
    number = alpha_dict[t_list[i]]
    t_count = t_diff_count[number]
    if not s_count == t_count:
        if t_count >= 2:
            print("No")
            exit(0)
print("Yes")

Submission status: Wrong Answer

Solution code:
def main():
	alphabet = "abcdefghijklmnopqrstuvwxyz"
	a_dic = {}
	for i in range(len(alphabet)):
		a_dic[alphabet[i]] = i

	a_s = [0] * 26
	a_t = [0] * 26

	S = input()
	T = input()
	for i in range(len(S)):
		a_s[a_dic[S[i]]] += 1
		a_t[a_dic[T[i]]] += 1
	for j in range(len(a_s)):
		if a_t[j] > a_s[j] > 0 or a_s[j] > a_t[j] > 0:
			print("No")
			return 0

	print("Yes")

main()

Submission status: Wrong Answer

Solution code:
def main():
	alphabet = "abcdefghijklmnopqrstuvwxyz"
	a_dic = {}
	for i in range(len(alphabet)):
		a_dic[alphabet[i]] = i

	a_s = [0] * 26
	a_t = [0] * 26

	S = input()
	T = input()
	for i in range(len(S)):
		a_s[a_dic[S[i]]] += 1
		a_t[a_dic[T[i]]] += 1
	for j in range(len(a_s)):
		if a_t[j] > a_s[j] > 0:
			print("No")
			return 0

	print("Yes")

main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-15 23:04:33 +0900
# LastModified: 2020-09-15 23:49:14 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter


def main():
    S = input()
    T = input()
    S_cnt = Counter(S)
    T_cnt = Counter(T)
    ST_dict = {}
    for key, value in S_cnt.items():
        if key in T_cnt.keys() and T_cnt[key] != value:
            ST_dict[key] = [value, T_cnt[key]]

    tmp = []
    cnt = 0
    while ST_dict:
        flag = 0
        for key, value in ST_dict.items():
            for k, v in ST_dict.items():
                if value[0] == v[1] and value[1] == v[0]:
                    flag = 1
                    ST_dict.pop(key)
                    ST_dict.pop(k)
                    break
            if flag == 1:
                break
        cnt += 1
        if cnt == 1000:
            print('No')
            return
    print('Yes')




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-15 23:04:33 +0900
# LastModified: 2020-09-15 23:47:26 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter


def main():
    S = input()
    T = input()
    S_cnt = Counter(S)
    T_cnt = Counter(T)
    ST_dict = {}
    for key, value in S_cnt.items():
        if key in T_cnt.keys() and T_cnt[key] != value:
            ST_dict[key] = [value, T_cnt[key]]

    tmp = []
    cnt = 0
    while ST_dict:
        flag = 0
        for key, value in ST_dict.items():
            for k, v in ST_dict.items():
                if value[0] == v[1] and value[1] == v[0]:
                    flag = 1
                    ST_dict.pop(key)
                    ST_dict.pop(k)
                    break
            if flag == 1:
                break
        cnt += 1
        if cnt == 100:
            print('No')
            return
    print('Yes')




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-15 23:04:33 +0900
# LastModified: 2020-09-15 23:40:49 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter


def main():
    S = input()
    T = input()
    S_cnt = Counter(S)
    T_cnt = Counter(T)
    ST_dict = {}
    for key, value in S_cnt.items():
        if key in T_cnt.keys() and T_cnt[key] != value:
            ST_dict[key] = [value, T_cnt[key]]

    tmp = []
    while ST_dict:
        arg1, arg2 = ST_dict.popitem()
        if arg1 in tmp:
            print('No')
            return
        tmp.append(arg1)
        flag = 0
        for key, value in ST_dict.items():
            if arg2[0] == value[1] and arg2[1] == value[0]:
                ST_dict.pop(key)
                flag = 1
                break
        if flag == 0:
            ST_dict[arg1] = arg2
    print('Yes')




if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	C
# CreatedDate:  2020-09-15 23:04:33 +0900
# LastModified: 2020-09-15 23:13:21 +0900
#


import os
import sys
# import numpy as np
# import pandas as pd
from collections import Counter


def main():
    S = input()
    T = input()
    S_cnt = Counter(S)
    T_cnt = Counter(T)
    for key, value in S_cnt.items():
        if key in T_cnt.keys() and T_cnt[key] != value:
            print('No')
            return
    print('Yes')


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
S=input()
T=input()
alp=[chr(i) for i in range(97, 97+26)]
words=[[] for _ in range(len(alp))]
num=0
for al in alp:
    for n in range(len(T)):
        if T[n]==al:
            words[num].append(n)
    num+=1
flag=0
for word in words:
    if len(word)<=1:
        continue
    wo=S[word[0]]
    for w in word:
        if wo==S[w]:
            continue
        else:
            flag=1
            break
if flag==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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()
C=[-1]*26
D=set(list(range(26)))
ans=True
for i in range(len(S)):
    s,t=ston(S[i]),ston(T[i])
    if C[s]!=t:
        if t not in D:
            ans=False
            break
        D.remove(t)
        C[s]=t
judge(ans)

Submission status: Wrong Answer

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()
C=[-1]*26
s=set(list(range(26)))
ans=True
for i in range(len(S)):
    if C[ston(S[i])]!=ston(T[i]):
        if ston(T[i]) not in s:
            ans=False
            break
        s.remove(ston(T[i]))
        C[ston(S[i])]=ston(T[i])
judge(ans)

Submission status: Wrong Answer

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

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

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    s = S()
    t = S()
    dic = {}
    for i in range(len(t)):
        if str(t[i]) not in dic:
            dic[str(t[i])] = s[i]
            dic[str(s[i])] = t[i]
        else:
            if dic[str(t[i])] == s[i] and dic[str(s[i])] == t[i]:
                continue
            else:
                print("No")
                return

    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
# coding=utf-8
from math import floor, ceil, sqrt, factorial, log, gcd
from itertools import accumulate, permutations, combinations, product, combinations_with_replacement
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict
from heapq import heappop, heappush, heappushpop, heapify
import copy
import numpy as np
import sys
INF = float('inf')
mod = 10**9+7
sys.setrecursionlimit(10 ** 6)


def lcm(a, b): return a * b / gcd(a, b)

# 1 2 3
# a, b, c = LI()


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))

# a = I()


def I(): return int(sys.stdin.buffer.readline())

# abc def
# a, b = LS()


def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()

# a = S()


def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')

# 2
# 1
# 2
# [1, 2]


def IR(n): return [I() for i in range(n)]

# 2
# 1 2 3
# 4 5 6
# [[1,2,3], [4,5,6]]


def LIR(n): return [LI() for i in range(n)]

# 2
# abc
# def
# [abc, def]


def SR(n): return [S() for i in range(n)]

# 2
# abc def
# ghi jkl
# [[abc,def], [ghi,jkl]]


def LSR(n): return [LS() for i in range(n)]

# 2
# abcd
# efgh
# [[a,b,c,d], [e,f,g,h]]


def SRL(n): return [list(S()) for i in range(n)]


def main():
    s = S()
    t = S()
    dic = {}
    for i in range(len(t)):
        if str(t[i]) not in dic:
            dic[str(t[i])] = s[i]
        else:
            if dic[str(t[i])] == s[i]:
                continue
            else:
                print("No")
                return
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

Solution code:
S = input()
T = input()
ans = 'Yes'
for i in T:
    if i in S:
        continue
    else:
        ans = 'No'
        break

print(ans)

Submission status: Wrong Answer

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

D={}

ans=1
for s,t in zip(S,T):
    x=D.get(t, '')
    # print(s,t,x)
    if x=='':
        D[t]=s
    else:
        # print(s,t,x)
        if x!=s:
            ans=0
            break
            

print('Yes' if ans else 'No')

Submission status: Wrong Answer

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

D={}

ans=1
for s,t in zip(S,T):
    x=D.get(t, '')
    print(s,t,x)
    if x=='':
        D[t]=s
    else:
        print(s,t,x)
        if x!=s:
            ans=0
            break
            

print('Yes' if ans else 'No')

Submission status: Wrong Answer

Solution code:
from collections import Counter

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

sc = Counter(s)
tc = Counter(t)

scc = sorted(sc.values())
tcc = sorted(tc.values())

if len(scc) == len(tcc):
    for i in range(len(scc)):
        if scc[i] == tcc[i]:
            continue
        else:
            print('No')
            break
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
import sys
import math
from collections import defaultdict
from collections import deque

sys.setrecursionlimit(1000000)
MOD = 10 ** 9 + 7
input = lambda: sys.stdin.readline().strip()
NI = lambda: int(input())
NMI = lambda: map(int, input().split())
NLI = lambda: list(NMI())
SI = lambda: input()


def main():
    S = SI()
    T = SI()
    D = defaultdict(str)
    for s, t in zip(S, T):
        if D[s] == "":
            D[s] = t

        if D[s] != t:
            print("No")
            exit()
    print("Yes")


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:

from collections import defaultdict

S = input()
T = input()

ctr_s = defaultdict(list)
ctr_t = defaultdict(list)
for i in range(len(S)):
    ctr_s[S[i]].append(i)
    ctr_t[T[i]].append(i)

ok = True
for key in ctr_s:
    char = T[ctr_s[key][0]]
    ok &= all(u == v for u, v in zip(ctr_s[key], ctr_t[char]))

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

Submission status: Wrong Answer

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

import sys
dic_s={}
dic_t={}

for i in range(len(s)):
  a=dic_s.get(s[i],t[i])
  b=dic_t.get(t[i],s[i])
  if a!=t[i] or b!=s[i]:
    print(i,a,b)
    print("No")
    sys.exit()
  dic_s[s[i]]=t[i]
  dic_t[t[i]]=s[i]
print("Yes")

Submission status: Wrong Answer

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

n=len(s)
ch=0
ch1=0
ans=0

if n>1:
  for i in range(1,n):
    if s[i]==s[i-1]:
      ch+=1
    else:
      ch=0
    if t[i]==t[i-1]:
      ch1+=1
    else:
      ch1=0
    
    if ch==ch1:
      ans+=1
  if ans==n-1 and len(set(t))==len(set(s)):
    print('Yes')
  else:
    print('No')
      
else:
  print('Yes')

Submission status: Wrong Answer

Solution code:
s = str(input())
t = str(input())
A=[]
B=[]
for i in range(len(s)):
    if s[i] ==t[i]:
        A.append(s[i])
    else:
        B.append(t[i])
for j in range(len(A)):
    if A[j] in B:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

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

dict_S={}
dict_T={}

for x, y in zip(S, T):
    if x not in dict_S:
        dict_S[x]=y
    else:
        if dict_S[x]!=y:
            print("No")
            break

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

print("Yes")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
import collections

S=input()
T=input()

S_list=collections.Counter(S)
S_list1=list(S_list.values())
S_list1=set(S_list1)

T_list=collections.Counter(T)
T_list1=list(T_list.values())
T_list1=set(T_list1)

if S_list1==T_list1:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
s = input()
t = input()
n = len(s)

d = defaultdict(str)

for i in range(n):
    if d[t[i]] == "":
        d[t[i]] = s[i]
    elif d[t[i]] != s[i]:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
N = len(S)
L = set(S) & set(T)
ans = 'Yes'
for l in L:
    if S.count(l) != T.count(l):
        ans = 'No'
        break
print(ans)

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
d = dict()
s = list(input().rstrip())
t = list(input().rstrip())

for i in range(len(s)):
    if s[i] not in d.keys():
        if t[i] in d.keys():
            d[s[i]] = t[i]
        else:
            d[s[i]] = t[i]
            d[t[i]] = s[i]
    s[i] = d[s[i]]
    # print(d)
# print(s)
# print(t)
if s==t:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def main():
    from string import ascii_lowercase
    S = input()
    T = input()

    dic = {a: set() for a in ascii_lowercase}
    for s, t in zip(S, T):
        dic[t].add(s)
    if all(len(s) <= 1 for s in dic.values()):
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from string import ascii_lowercase
    S = input()
    T = input()

    dic = {a: [] for a in ascii_lowercase}
    changed = set()
    ok = True
    for s, t in zip(S, T):
        if dic[s]:
            s = dic[s][-1]
        if s != t:
            if t in changed:
                ok = False
                break
            dic[s].append(t)
            dic[t].append(s)
            changed.add(t)
    if ok:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
def main():
    from string import ascii_lowercase
    S = input()
    T = input()
    dic = {a: [] for a in ascii_lowercase}
    ok = True
    for s, t in zip(S, T):
        if dic[s]:
            s = dic[s][-1]
        if s != t:
            if s in dic[t]:
                ok = False
                break
            dic[s].append(t)
            dic[t].append(s)

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def main():
    from string import ascii_lowercase
    S = input()
    T = input()
    dic = {a: [] for a in ascii_lowercase}
    for s, t in zip(S, T):
        if dic[s]:
            s = dic[s][-1]
        if s != t:
            dic[s].append(t)
            dic[t].append(s)
    ok = True

    for a in ascii_lowercase:
        b = len(dic[a])
        c = len(set(dic[a]))
        if b != c:
            ok = False
            break

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


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
n=len(s)
f=0
a=[[] for i in range(26)]
for i in range(n):
    if s[i]!=t[i]:
        if len(a[ord(s[i])-97])==0:
            a[ord(s[i])-97].append(t[i])
        else:
            if a[ord(s[i])-97][0]!=t[i]:
                f=1
x=[a[i][0] for i in range(26) if len(a[i])==1]
if len(x)!=len(set(x)):
    f=1
print("Yes" if f==0 else "No")

Submission status: Wrong Answer

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

visited = [0] * (len(S)+1)

def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]

for i in range(len(S)):
    if visited[i] == 1:
        continue
    if S[i] == T[i]:
        visited[i] == 1
        continue
    else:
        for j in my_index_multi(T, T[i]):
            if visited[j] == 1 :
                continue
            elif S[i] == S[j]:
                visited[j] == 1
                continue
            else:
                print('No')
                exit()

print('Yes')

Submission status: Wrong Answer

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

cntS = collections.Counter(S)
cntT = collections.Counter(T)

if len(cntS) != len(cntT):
    print('No')
    exit()
else:
    valS = cntS.most_common()[::-1]
    valT = cntT.most_common()[::-1]

    for i in range(len(valS)):
        if valS[i][1] != valS[i][1]:
            print('No')
            exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
s=[ord(c)-ord('a') for c in input()]
t=[ord(c)-ord('a') for c in input()]
n=len(s)

st=[(s[i],t[i]) for i in range(n)]
st=sorted(st,key=lambda x:x[1])
s=[c for c,_ in st]
t=[c for _,c in st]

for i in range(n-1):
    if (s[i+1]==s[i]) ^ (t[i+1]==t[i]):
        print('No')
        break
else:
    print('Yes')

Submission status: Wrong Answer

Solution code:
s=[c for c in input()]
t=[c for c in input()]
n=len(s)

st=[(s[i],t[i]) for i in range(n)]
st=sorted(st,key=lambda x:x[1])
s=[c for c,_ in st]
t=[c for _,c in st]

for i in range(n):
    j=i+1
    cnt=0
    while j<n and t[i]==t[j]:
        j+=1
        cnt+=1
    
    while cnt>0 and s[i+cnt]==s[i]:
        cnt-=1
    
    if cnt>0:
        print('No')
        exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

s = input()
t = input()
n = len(s)
sset = set()
tset = set()
smemo = [0] * (n)
tmemo = [0] * (n)
jisho1 = defaultdict(int)
jisho2 = defaultdict(int)
idx1 = 0
idx2 = 0
for i in range(n):
    if jisho1[s[i]] == 0:
        jisho1[s[i]] = idx1
        idx1 += 1
        sset.add(s[i])
    smemo[i] = jisho1[s[i]]
    if jisho2[t[i]] == 0:
        jisho2[t[i]] = idx2
        idx2 += 1
        tset.add(t[i])
    tmemo[i] = jisho2[t[i]]
    if idx1 != idx2:
        print("No")
        exit()
# for word in sset:
#     if word not in tset:
#         print("No")
#         exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
s=Counter(list(input()))
t=Counter(list(input()))
s_1=s&t
s1=s-s_1
t1=t-s_1
s2=sorted(list(s1.values()))
t2=sorted(list(t1.values()))
if len(s1)==len(t1) and s2==t2:
    print('Yes')
else:print('No')

Submission status: Wrong Answer

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

# In[16]:


S = input()
T = input()


# In[17]:


myset = set(T)
for x in myset:
    mylist = [i for i in range(len(T)) if T[i] == x]
    if len(mylist) > 0:
        tmp = S[mylist[0]]
        for j in mylist[1:]:
            if S[j] != tmp:
                print("No")
                break
        else:
            continue
        break
else:
    print("Yes")


# In[ ]:

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
memo = {}
ans = 'Yes'
for i in range(len(s)):
    if s[i] in memo:
        if t[i] != memo[s[i]]:
            ans = 'No'
            break
    else:
        memo[s[i]] = t[i]
a = memo.values()
if set(a) != len(a):
    ans = 'No'
print(ans)

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
memo = {}
ans = 'Yes'
for i in range(len(s)):
    if s[i] in memo:
        if t[i] != memo[s[i]]:
            ans = 'No'
            break

    else:
        memo[s[i]] = t[i]
print(ans)