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:
# -*- coding: utf-8 -*-
"""
Created on Fri May 17 12:54:56 2019

@author: avina
"""

S = input()
T = input()
S_map = {}
T_map = {}
l = len(S)
S_cnt = 0
T_cnt = 0
for i in range(l):
	s,t = S[i], T[i]
	if s in S_map:
		s_id = S_map[s]
	else:
		s_id = S_cnt
		S_map[s] = S_cnt
		S_cnt += 1
	if t in T_map:
		t_id = T_map[t]
	else:
		t_id = T_cnt
		T_map[t] = T_cnt
		T_cnt += 1
	if s_id != t_id:
		print("No")
		break
print("Yes")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
"""
Created on Fri May 17 00:23:37 2019

@author: avina
"""

s1 = input().strip()
s2 = input().strip()
F = True
if len(set(s1)) == len(set(s2)):
  
  s = {}
  for i in range(len(s1)):
    if s2[i] not in s:
        s[s2[i]] = s1[i]
    elif s[s2[i]] != s1[i]:
        F = False
        break
  if F:
    print('Yes')
  else:
    print('No')
else:
   print('NO')

Submission status: Wrong Answer

Solution code:

s1 = input().strip()
s2 = input().strip()
F = True
s = {}
for i in range(len(s1)):
    if s2[i] not in s:
        s[s2[i]] = s1[i]
    elif s[s2[i]] != s1[i]:
        F = False
        break
if F:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

if len(set(s1)) == len(set(s2)):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
import collections

S = input()
T = input()

s = collections.Counter(S)
t = collections.Counter(T)

s_set = set(s.values())
t_set = set(t.values())


def judge():
    if s_set != t_set:
        return 'No'

    for i in range(97, 97+26):
        ch = chr(i)
        if s[ch] and t[ch] and s[ch] != t[ch]:
            return 'No'

    return 'Yes'


print(judge())

Submission status: Wrong Answer

Solution code:
import collections

S = input()
T = input()

s = collections.Counter(S)
t = collections.Counter(T)

s_set = set(s.values())
t_set = set(t.values())

ans = 'Yes' if s_set == t_set else 'No'
print(ans)

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:
S, T = input(), input()

s, t = sorted(S), sorted(T)

rm = {}
for n in range(len(S)):
	if s[n] in rm:
		if rm[s[n]] != t[n]:
			print("No")
			exit()
	else:
		rm[s[n]] = t[n]
	if not t[n] in rm:
		rm[t[n]] = s[n]

#print(s)
#print(t)
#print(rm)

print("Yes")

Submission status: Wrong Answer

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

s, t = sorted(S), sorted(T)

rm = {}
for n in range(len(S)):
	if (s[n] in rm) and (t[n] in rm):
		if not ((rm[s[n]] == t[n]) and (rm[t[n]] == s[n])):
			print("No")
			exit()
	else:
		rm[s[n]] = t[n]
		rm[t[n]] = s[n]
#print(s)
#print(t)
#print(rm)

print("Yes")

Submission status: Wrong Answer

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

s, t = sorted(S), sorted(T)

rm = {}
for n in range(len(S)):
	if s[n] in rm:
		if t[n] != rm[s[n]]:
			print("No")
			exit()
	else:
		rm[s[n]] = t[n]
		rm[t[n]] = s[n]
#print(s)
#print(t)
#print(rm)

print("Yes")

Submission status: Wrong Answer

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

s, t = sorted(S), sorted(T)

rm = {}
for n in range(len(S)):
	if s[n] == t[n]:
		continue
	if s[n] in rm:
		if t[n] != rm[s[n]]:
			print("No")
			exit()
	else:
		rm[s[n]] = t[n]
		rm[t[n]] = s[n]
#print(s)
#print(t)
#print(rm)

print("Yes")

Submission status: Wrong Answer

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

s, t = sorted(S), sorted(T)

rm = {}
for n in range(len(S)):
	if s[n] == t[n]:
		continue
	if s[n] in rm:
		if t[n] != rm[s[n]]:
			print("No")
			exit()
	else:
		if s[n] in rm.values():
			print("No")
			exit()
		rm[s[n]] = t[n]
#print(s)
#print(t)
#print(rm)

print("Yes")

Submission status: Wrong Answer

Solution code:
# ガバガバ説あり、同じ文字がS内に出てくるときの考察が甘い予感
def run_length(s):
	cnt = 1
	result = ""
	for i in range(len(s)):
		try:
			if s[i] == s[i + 1]:
				cnt += 1
			else:
				result += str(s[i]) + str(cnt)
				cnt = 1
		except:
			# 最後の文字がOutOfRangeになるので出力
			result += str(s[i]) + str(cnt)
	return result

S, T = input(), input()

s = run_length(S)
t = run_length(T)

if s[1:: 2] == t[1:: 2]:
	print("Yes")
else:
	print("No")

Submission status: Wrong Answer

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

X = {}
for i in range(N):
  if S[i] not in X.keys():
    X[S[i]] = []
  X[S[i]].append(T[i])

for i,j in X.items():
  if len(set(j)) >= 2:
    print('No')
    exit()
print('Yes')

Submission status: Wrong Answer

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

s_list=list(s)
t_list=list(t)

if len(set(s_list)) != len(set(t_list)):
  print('No')
else:
  out='Yes'
  for i in range(len(s_list)-1):
    if s_list[i] == s_list[i+1] and t_list[i] == t_list[i+1]:
      continue
    elif s_list[i] != s_list[i+1] and t_list[i] != t_list[i+1]:
      continue
    else:
      out='No'
      break
  print(out)

Submission status: Wrong Answer

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

s_list=set(list(s))
t_list=set(list(t))

if len(s_list) != len(t_list):
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

s_list=list(s)
t_list=list(t)

if len(s_list) != len(t_list):
  print('No')
else:
  print('Yes')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

flag = True
if len(A) != len(B):
  flag = False 

pair_dict = dict()
reverse_dict = dict()
for i in range(len(A)):
  if A[i] not in pair_dict:
    pair_dict[A[i]] = B[i]
  elif pair_dict[A[i]] != B[i]:
    flag = False
    break
  if B[i] not in reverse_dict:
    reverse_dict[B[i]] = A[i]
  elif reverse_dict[B[i]] != A[i]:
    flag = False
    break
if flag:
  print("YES")
else:
  print("NO")

Submission status: Wrong Answer

Solution code:
import sys

s = input()
t = input()
seen = {}

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

Submission status: Wrong Answer

Solution code:
import sys

s = input().strip()
t = input().strip()

d = dict()
for i, sc in enumerate(s):
    tc = t[i]
    if sc == tc:
        continue

    if sc in d:
        if d[sc] == tc:
            continue
        else:
            print('No')
            sys.exit(0)

    d[sc] = tc

vs = list(d.values())
for v in vs:
    if vs.count(v) > 1:
        print('No')
        sys.exit(0)

print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
epsilon = set()
sigma = set()
for x, y in zip(s, t):
    if x == y:
        epsilon.add(x)
    else:
        x, y = sorted([x, y])
        sigma.add((x,y))
flag = False
for n, k in sigma:
    for e in epsilon:
        if n == e or k == e:
            flag = True
            print('No')
            break
    if flag:
        break
if not flag:
    print('Yes')

Submission status: Wrong Answer

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

table = [[0 for i in range(26)] for j in range(26)]
for i in range(len(s)):
  table[ord(t[i])-ord('a')][ord(s[i])-ord('a')] += 1
for t_row in table:
  counter = 0
  for v in t_row:
    if v != 0:
      counter += 1
  if counter >= 2:
    break
#else:
#  print('Yes')
#  exit(0)
print('No')

Submission status: Wrong Answer

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

table = [[0 for i in range(26)] for j in range(26)]
for i in range(len(s)):
  table[ord(t[i])-ord('a')][ord(s[i])-ord('a')] += 1
for t_row in table:
  counter = 0
  for v in t_row:
    if v != 0:
      counter += 1
  if counter >= 2:
    break
else:
  print('Yes')
  exit(0)
print('No')

Submission status: Wrong Answer

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

table = [[0 for i in range(26)] for j in range(2)]
for i in range(len(s)):
  wrong = 0
  if s[i] != t[i]:
    wrong = 1
  table[wrong][ord(t[i])-ord('a')] += 1
for i in range(26):
  if table[0][i]*table[1][i] != 0:
    break
else:
  print('Yes')
  exit(0)
print('No')

Submission status: Wrong Answer

Solution code:
#3
s = str(input())
t = str(input())
memo = {}
ifadd = False
ifsamedest = False
destlist = set()
for i in range(len(s)):
    sor = s[i]
    des = t[i]
    if sor not in memo:
        memo[sor] = des
        if des in destlist:
            ifsamedest = True
        destlist.add(des)
    else:
        if memo[sor]!=des:
            ifadd = True

#同じ文字から複数の行き先はアウト
#交換関係になっていなければアウト
#異なる文字から同じ行き先もアウト

ans = "Yes"
visited = set()
if ifadd == True:
    ans = "No"
if ifsamedest == True:
    ans = "No"
else:
    for sta in memo:
        if sta not in visited:
            visited.add(sta)
            gol = memo[sta]
            fsta = sta
            while(gol!=sta):
                if gol not in memo:
                    if sta != fsta:
                        ans = "No"
                    gol = sta
                else:
                    sta,gol = gol,memo[gol]
                    visited.add(sta)
                    if gol == fsta:
                        gol = sta
                        
print(ans)

Submission status: Wrong Answer

Solution code:
#3
s = str(input())
t = str(input())
memo = {}
ifadd = False
for i in range(len(s)):
    sor = s[i]
    des = t[i]
    if sor not in memo:
        memo[sor] = des
    else:
        if memo[sor]!=des:
            ifadd = True

#同じ文字から複数の行き先はアウト
#交換関係になっていなければアウト
ans = "Yes"
visited = set()
if ifadd == True:
    ans = "No"
else:
    for sta in memo:
        if sta not in visited:
            visited.add(sta)
            gol = memo[sta]
            fsta = sta
            while(gol!=sta):
                if gol not in memo:
                    if sta != fsta:
                        ans = "No"
                    gol = sta
                else:
                    sta,gol = gol,memo[gol]
                    visited.add(sta)
                    if gol == fsta:
                        gol = sta
                        
print(ans)

Submission status: Wrong Answer

Solution code:
s = str(input())
t = str(input())
memo = {}
ifadd = False
for i in range(len(s)):
    sor = s[i]
    des = t[i]
    if sor not in memo:
        memo[sor] = des
    else:
        if memo[sor]!=des:
            ifadd = True

#同じ文字から複数の行き先はアウト
#交換関係になっていなければアウト
ans = "Yes"
visited = set()
if ifadd == True:
    ans = "No"
else:
    for sta in memo:
        if sta not in visited:
            visited.add(sta)
            gol = memo[sta]
            fsta = sta
            while(gol!=sta):
                if gol not in memo:
                    if sta != fsta:
                        ans = "No"
                    gol = sta
                else:
                    sta,gol = gol,memo[gol]
                    visited.add(sta)
                    if gol in visited:
                        gol = sta
                        
print(ans)

Submission status: Wrong Answer

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

ans="Yes"
nc=set()
c=set()
for i in range(len(s)):
    #print(nc,c)
    if s[i]==t[i]:
        nc.add(s[i])
    else:
        c.add(s[i])
        c.add(t[i])
        
for ch in c:
    if ch in nc:
        ans="No"
        break
print(ans)

Submission status: Wrong Answer

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

ans="Yes"
nc=[]
c=[]
for i in range(len(s)):
    #print(nc,c)
    if s[i]==t[i]:
        nc.append(s[i])
    else:
        c+=[s[i],t[i]]
        
for ch in c:
    if ch in nc:
        ans="No"
        break
print(ans)

Submission status: Wrong Answer

Solution code:
from collections import Counter

S = input()
T = input()

S_cnt = Counter(S).most_common()
T_cnt = Counter(T).most_common()

if len(S_cnt) != len(T_cnt):
    print('No')
else:
    for i in range(len(S_cnt)):
        if S_cnt[i][1] != S_cnt[i][1]:
            print('No')
            exit()
    print('Yes')

Submission status: Wrong Answer

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


dict_S = {}

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

Submission status: Wrong Answer

Solution code:
s  = input()
t = [ord(i) - 97 for i in input()]
flag = [None for i in range(26)]

for rep, content in enumerate(t):
    if flag[content] == None:
        flag[content] = s[rep]

    elif flag[content] != s[rep]:
        print("No")
        exit()

print("Yes")

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

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

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

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python
S = input()
T = input()

flag = True
dic_s = {}
for i,s in enumerate(S):
    if dic_s.get(s, -1) == -1:
        dic_s[s] = T[i]
    elif dic_s.get(s) != T[i]:
        flag = False
        break 

if flag:
    dic_t = {}
    for j,t in enumerate(T):
        if dic_t.get(t, -1) == -1:
            dic_t[t] = S[j]
        elif dic_t.get(t) != S[j]:
            print('No')
            break
    else:
        print('Yes')
else:
    print('Yes')

Submission status: Wrong Answer

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

for i in range(L):
  s = S[i]
  t = T[i]
  S = S.replace(s, s.upper())
  T = T.replace(t, s.upper())

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

Submission status: Wrong Answer

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


def count_up(string):
    results = []
    prev = None
    cnt = 0
    for v in string:
        if v == prev:
            cnt += 1
        else:
            results.append(cnt)
            cnt = 1
            prev = v
    results.append(cnt)
    return results[1:]

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

Submission status: Wrong Answer

Solution code:
from collections import*
e=defaultdict(list)
d=defaultdict(list)
for k,v in enumerate(input()):
    e[v].append(k)
for k,v in enumerate(input()):
    d[v].append(k)
if list(e.values())==list(d.values()):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

#print(s)
#print(t)

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

#print(sset)
#print(tset)

s_getindex = []
t_getindex = []

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

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

#print(s_getindex)
#print(t_getindex)

check_s = []
check_t = []
ans = 0

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

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

#print(ans)

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

Submission status: Wrong Answer

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

print(s)
print(t)

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

print(sset)
print(tset)

s_getindex = []
t_getindex = []

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

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

print(s_getindex)
print(t_getindex)

check_s = []
check_t = []
ans = 0

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

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

print(ans)

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

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(S: str, T: str):
    n = len(S)
    m_in = {}
    m_out = {}
    for i in range(n):
        if S[i] != T[i]:
            if (S[i] in m_in and m_in[S[i]] != T[i]) or (T[i] in m_out and m_out[T[i]] != S[i]):
                ret = NO
                print(ret)
                return
            else:
                m_in[S[i]] = T[i]
                m_out[T[i]] = S[i]
    print(YES)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    T = next(tokens)  # type: str
    solve(S, T)

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

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

Submission status: Wrong Answer

Solution code:
from collections import Counter
S = input()
T = input()
S = Counter(S)
T = Counter(T)
S = list(S.values())
T = list(T.values())

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

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:
s=input()
n=input()
d=dict()
ans="Yes"
for i in range(len(s)):
  if s[i] not in d:
    d[s[i]]=n[i]
  elif d[s[i]]!=n[i]:
    ans="No"
print(ans)

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s=input()
n=input()
d=dict()
ans="Yes"
for i in range(len(s)):
  if s[i] not in d:
    d[s[i]]=n[i]
  elif d[s[i]]!=n[i]:
    ans="No"
a=set()
for i in s:
  a.add(i)
b=set()
for i in n:
  b.add(i)
if a!=b:
  ans="No"
print(ans)

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	S = list(input())
	T = list(input())
	
	S_dict = {}
	for i, val in enumerate(S):
		if val in S_dict:
			S_dict[val].append(i)
		else:
			tmp = [i]
			S_dict[val] = tmp
			
	S_val = []
	for i in S_dict.values():
		S_val.append(i)
			
	T_dict = {}
	for i, val in enumerate(T):
		if val in T_dict:
			T_dict[val].append(i)
		else:
			tmp = [i]
			T_dict[val] = tmp
	
	T_val = []
	for i in T_dict.values():
		T_val.append(i)
	
	if S_val == T_val:
		print("Yes")
		sys.exit()
	
	#print(S_val)
	#print(T_val)
		
	isOK = True
	for i, val in enumerate(T_val):
		if val == S_val[i]:
			continue
		if len(val) < len(S_val[i]) or len(val) == 1:
			print("No")
			sys.exit()
			
		if len(val) > len(S_val[i]):
			tmp = S_val[i]
			mark = []
			for j, vol in enumerate(val):
				if len(tmp) <= j:
					mark.append(vol)
					continue
				if vol != tmp[j]:
					print("No")
					sys.exit()
			for k in mark:
				aaa = [k]
				#print([7] in S_val)
				#print(S_val)
				if not aaa in S_val:
					print("No")
					sys.exit()
				bbb = S_val.index(aaa)
				S_val.pop(bbb)
			continue
			
		print("No")
		sys.exit()
	
	print("Yes")
		
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
print("No")

Submission status: Wrong Answer

Solution code:
# -*- coding: utf-8 -*-
import sys
import copy
import collections
from bisect import bisect_left

def main():
	S = list(input())
	T = list(input())
	
	S_dict = {}
	for i, val in enumerate(S):
		if val in S_dict:
			S_dict[val].append(i)
		else:
			tmp = [i]
			S_dict[val] = tmp
			
	S_val = []
	for i in S_dict.values():
		S_val.append(i)
			
	T_dict = {}
	for i, val in enumerate(T):
		if val in T_dict:
			T_dict[val].append(i)
		else:
			tmp = [i]
			T_dict[val] = tmp
	
	T_val = []
	for i in T_dict.values():
		T_val.append(i)
	
	if S_val == T_val:
		print("Yes")
	else:
		print("No")
		
	
if __name__ == "__main__":
	main()

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
slist,tlist = [],[]
S2,T2 = [],[]
scount,tcount = 0,0

for i in range(len(S)):
  if S[i] not in slist:
    slist.append(S[i])
    scount += 1
  S2.append(scount)
  
  if T[i] not in tlist:
    tlist.append(T[i])
    tcount += 1
  T2.append(tcount)
if S2 == T2:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
s = list(input())
t = list(input())
s_len = len(s)
same_list = []
for i in range(s_len):
    if s[i] == t[i]:
        same_list.append(s[i])
f = 0
for i in same_list:
    indexes_s = [j for j, x in enumerate(s) if x == i]
    for l in indexes_s:
        if s[l] != t[l]:
            f = 1
    indexes_t = [j for j, x in enumerate(t) if x == i]
    for l in indexes_t:
        if s[l] != t[l]:
            f = 1
    if f == 1:
        break
if f == 1:
    print("No")
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
alfa = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'}
count_s = set()
count_t = set()
for s in range(len(S)):
    if S[s] in count_s:
        continue
    count_s.add(S[s])
    S = S.replace(S[s],str(s))
for t in range(len(T)):
    if t in count_t:
        continue
    count_t.add(T[t])
    T = T.replace(T[t],str(t))
if S == T:
    print('Yes')
else:print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
a = "abcdefghijklmnopqrstuvwxyz"

flag = 0
i = 0 
while i < len(s):
	if s[i] != t[i]:
		if t[i] in a:
			c = s[i]
			s = s.replace(c, "1")
			s = s.replace(t[i], c)
			s = s.replace("1", t[i])
			a = a.replace(t[i], "1")
		else:
			break
	i += 1
if s == t:
	print("True")
else:
	print("False")

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
def C(a, b):
    d={}
    for i in range(len(a)):
        if a[i] in d:
            print(a[i])
            if d[a[i]]!=b[i]:
                return False
        else:
            d[a[i]]=b[i]
    return True
if C(s, t)and C(t, s):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
d={}
def C(a, b):
    for i in range(len(a)):
        if a[i] in d:
            if d[a[i]]!=b[i]:
                return False
        else:
            d[a[i]]=b[i]
    return True
if C(s, t)and C(t, s):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

src_set = set(s)
tag_set = set(t)
matched_list = list(src_set ^ tag_set)

ss="".join(s)
tt="".join(t)

for jogai in matched_list:
    ss=ss.replace(jogai,"A")
    tt=tt.replace(jogai,"A")
    #ttt=t.remove(jogai)

ss=list(ss)
tt=list(tt)
ss.sort()
tt.sort()

sss="".join(ss)
ttt="".join(tt)

if sss==ttt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

set_A = set(A)
set_B = set(B)
match_list=set_A^set_B

a = "".join(A)
b = "".join(B)

for matches in match_list:
    a = a.replace(matches,'A')
    b = b.replace(matches,'A')
    
modify_a = list(a)
modify_b = list(b)
modify_a.sort()
modify_b.sort()

if "".join(modify_a)=="".join(modify_b):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
A = list(input())
B = list(input())
flag = 0
duplicate_list = []
for i in range (len(A)):
    if A[i] == B[i]:
        duplicate_list.append(A[i])

for j in duplicate_list:
    a_count = A.count(j)
    b_count = B.count(j)
    if a_count!=b_count:
        flag +=1
        
if flag ==0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

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

s.sort()
t.sort()

ss="".join(s)
tt="".join(t)

if ss==tt:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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))
print(S,T)

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

Submission status: Wrong Answer

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

s_counter = []
t_counter = []
for c in 'abcdefghijklmnopqlstuvwxyz':
    s_counter.append(s.count(c))
    t_counter.append(t.count(c))

s_counter.sort()
t_counter.sort()

ans = 'Yes' if s_counter == t_counter else 'No'
print(ans)

Submission status: Wrong Answer

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

ans = 'Yes' if len(set(s)) == len(set(t)) else 'No'
print(ans)

Submission status: Wrong Answer

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

d={}

for s,t in zip(S,T):
    if t in d:
        if d[t]!=s:
            print("No")
            exit()
    else:
        d[t]=s
print("Yes")

Submission status: Wrong Answer

Solution code:
S = [c for c in input()]
T = [c for c in input()]

def main():
    z = zip(S, T)
    f = filter(lambda e: e[0] != e[1], z)
    s = set(f)
    unpacked = list(zip(*s))
    
    ans = [len(set(t)) == len(t) for t in unpacked]
    print('Yes' if all(ans) else 'No')

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
l = [[] for _ in range(26)]
for k, c in enumerate([chr(ord("a") + i) for i in range(26)]):
    for i,t in enumerate(T):
        if t == c:
            l[k].append(i)

for a in l:
    if len(a) <= 1:
        continue
    prop = S[a[0]]
    for i in a:
        if prop != S[i]:
            print("No")
            exit()
print("Yes")

Submission status: Wrong Answer

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

ps = S[0]
pt = T[0]
for s,t in zip(S[1:],T[1:]):
	if ((ps == s) and (pt != t)) or ((ps != s) and (pt == t)):
		print("No")
		exit()

print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
while len(S) > 0:
    s = [i for i, x in enumerate(S) if x == S[0]]
    t = [i for i, x in enumerate(T) if x == S[0]]
    #print(s,t)
    if s == t:
        #print(S, T)
        T = T.replace(S[0], "")
        S = S.replace(S[0], "")
        #print(S, T)
    elif S.count(S[0]) == T.count(T[0]):
        S = S.replace(S[0], "A")
        S = S.replace(T[0], S[0])
        S = S.replace("A", T[0])
        #print(S)
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
while len(S) > 0:
    if S.count(S[0]) == T.count(S[0]):
        #print(S, T)
        T = T.replace(S[0], "")
        S = S.replace(S[0], "")
        #print(S, T)
    elif S.count(S[0]) == T.count(T[0]):
        S = S.replace(S[0], "A")
        S = S.replace(T[0], S[0])
        S = S.replace("A", T[0])
    else:
        print("No")
        exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter
s = Counter(input())
t = Counter(input())
print('Yes') if len(s) == len(t) else print('No')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import sys

S = input()
T = input()
dic = defaultdict(str)

for x, y in zip(S, T):
    if not x in dic:
        dic[x] = y
    else:
        if dic[x] != y:
            print('No')
            sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
import sys

S = input()
T = input()
dic = defaultdict(str)

for x, y in zip(S, T):
    if not y in dic:
        dic[y] = x
    else:
        if dic[y] != x:
            print('No')
            sys.exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
#coding: utf-8
S = list(input())
T = list(input())
Sl, Tl = [], []
for i in range(len(S)):
    if S[i] != T[i]:
        Sl.append(S[i])
        Tl.append(T[i])
if len(set(Sl)) == len(set(Tl)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
#coding: utf-8
S = list(input())
T = list(input())
if len(set(S)) == len(set(T)):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

Submission status: Wrong Answer

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

Submission status: Wrong Answer

Solution code:
from collections import*
s=enumerate(input())
t=enumerate(input())
d1=defaultdict(list)
d2=defaultdict(list)
for k,v in s:
    d1[v].append(k)
for k,v in t:
    d2[v].append(k)
print(["No","Yes"][list(d1.values())==list(d2.values())])

Submission status: Wrong Answer

Solution code:
from itertools import*
from collections import*
s=input()
t=input()
if [len(list(v)) for k,v in groupby(s)]==[len(list(v)) for k,v in groupby(t)] and list(Counter(s).values())==list(Counter(t).values()):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S, T = [input() for _ in range(2)]
smemo, tmemo = {}, {}
for si, ti in zip(S, T):
    if si in smemo and smemo[si] != ti or ti in tmemo and tmemo[ti] != si:
        print("NO")
        quit()
    smemo[si], tmemo[ti] = ti, si
print("YES")

Submission status: Wrong Answer

Solution code:
a=len(set(input()))
b=len(set(input()))
print("Yes") if a==b else print("No")