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 = str(input())
t = str(input())

a = len(s)

d = []

for i in range(a):
	if s[i] != t[i] and s[i] not in d:
		d.append(s[i])
		d.append(t[i])
		b = str(s[i])
		c = str(t[i])
		s = s.replace(b,'.')
		s = s.replace(c,b)
		s = s.replace('.',c)

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

Submission status: Wrong Answer

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

l = []

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


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

flag = 1

for sets in l:
    if di[sets[0]] != di[sets[1]]:
        flag = 0

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

Submission status: Wrong Answer

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

ta = []
a = True
for t in T:
    if len([i for i, x in enumerate(T) if x == t]) != len([i for i, x in enumerate(S) if x == t]):
        print("No")
        a = False
        break
if a:
    print("Yes")

Submission status: Wrong Answer

Solution code:
ss = input()
tt = input()
s = set(ss)
t = set(tt)

print("Yes" if (len(ss+tt) - len(s - t ^ t - s)) % 2 == 0 else "No")

Submission status: Wrong Answer

Solution code:
s_str = [ord(i) for i in input()]
t_str = [ord(i) for i in input()]

s = sorted(s_str)
t = sorted(t_str)

cnt_s = 1
cnt_t = 1
s_num = []
t_num = []

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt_s += 1
        if i == len(s)-2:
            s_num.append(cnt_s)
    else:
        s_num.append(cnt_s)
        cnt_s = 1
    if t[i] == t[i+1]:
        cnt_t += 1
        if i == len(s)-2:
            t_num.append(cnt_t)
    else:
        t_num.append(cnt_t)
        cnt_t = 1

s_num = sorted(s_num)
t_num = sorted(t_num)
print(s_num)
print(t_num)

if s_num == t_num:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
def main():
    S, T = [str(input()) for i in range(2)]
    if len(set(S)) == len(set(T)):
        correspondence = {}
        converted = ''
        for index, charactor in enumerate(S):
            if charactor != T[index]:
                if not charactor in correspondence:
                    correspondence[charactor] = T[index]
                converted += correspondence[charactor]
            else:
                converted += T[index]

            if converted != T[:index+1]:
                print('No')

        print('Yes')

    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
m = input()
n = input()
 
def decs():
   for i in range(0,len(m)-1):
       for j in range(1,len(m)-1):
           if m[i] == m[j]:
               if n[i] != n[j]:
                   return False
           if n[i] == n[j]:
               if m[i] != m[j]:
                   return False
               
               
   return True
           
   
if decs():
   print("Yes")
else:
   print("No")

Submission status: Wrong Answer

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


def main():
    convert_table = {}
    for i in range(len(S)):
        if S[i] == T[i]:
            continue

        if S[i] in convert_table:
            if convert_table[S[i]] != T[i]:
                print("No")
                return
        else:
            convert_table[S[i]] = T[i]

    deletes = []
    for src in convert_table:
        dst = convert_table[src]
        if dst not in S:
            deletes.append(src)

    for src in deletes:
        del convert_table[src]

    while len(convert_table) > 0:
        start = list(convert_table)[0]
        visited = [start]
        s = start
        while True:
            t = convert_table[s]
            if t == start:
                break

            visited.append(t)
            if t in convert_table:
                s = t
            else:
                print("No")
                return

        for src in visited:
            del convert_table[src]

    print("Yes")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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


def main():
    convert_table = {}
    for i in range(len(S)):
        if S[i] == T[i]:
            continue

        if S[i] in convert_table:
            if convert_table[S[i]] != T[i]:
                print("NO")
                return
        else:
            convert_table[S[i]] = T[i]

    deletes = []
    for src in convert_table:
        dst = convert_table[src]
        if dst not in S:
            deletes.append(src)

    for src in deletes:
        del convert_table[src]

    while len(convert_table) > 0:
        start = list(convert_table)[0]
        visited = [start]
        s = start
        while True:
            t = convert_table[s]
            if t == start:
                break

            visited.append(t)
            if t in convert_table:
                s = t
            else:
                print("NO")
                return

        for src in visited:
            del convert_table[src]

    print("YES")


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

if len(set(s)) != len(set(t)):
    print("No")
    exit()
print("Yes")

Submission status: Wrong Answer

Solution code:
s = str(input())
t = str(input())
sl = list(s)
tl = list(t)
list1 = []
list2 = []
count = 0
if len(sl) != len(tl):
  count = 1
else:
  for i in range(len(sl)):
    if i not in list1:
      for j in range(len(sl) - i - 1):
        if sl[i] == sl[i+j]:
          list1.append(j)
        if tl[i] == tl[i+j]:
          list2.append(j)        
      if list1 != list2:
        count = 1
        break
if count == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

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

a = set(list(s))
b = set(list(t))
if len(a) == len(b):
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:

import math


def main():
    a = list(input())
    b = list(input())
    dica = {}
    dicb = {}
    dif = 0
    alpha = list("abcdefghijklmnopqrstuvwxyz")
    for aa,bb in zip(a,b):
        if aa != bb:
            if bb in dica and aa in dicb:
                if dica[bb] != aa or dicb[aa] != bb:            
                    print("No")
                    return 0
            if bb not in dica:  
                dica[bb] = aa
            if aa not in dicb:
                dicb[aa] =bb
            if bb in dica and aa in dicb:
                if dica[bb] != aa or dicb[aa] != bb:            
                    print("No")
                    return 0
        
            # if aa not in dica:
            #     dica[aa] = bb
            # if bb not in dicb:
            #     dicb[bb] = aa
            
   
    
    print("Yes")
    
    # for c in alpha:
    #     dica[c] = 0
    #     dicb[c] = 0
    # for temp in a:
    #     dica[temp] +=1
    # for temp in b:
    #     dicb[temp] +=1
    # for c in alpha:
    #     dif += (dica[c]-dicb[c])
    
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])


indexes = []
indexes2 = []

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes.append((i for i, x in enumerate(S) if x == k1[0]))
                indexes2.append(i for i, x in enumerate(T) if x == k2[0])
        if set(indexes) == indexes2:
            print('Yes')
        else:
            print('No')
else:
    print('No')

# for k1,k2 in zip(count1, count2, ):
#     if count1[k1] > 1:
#         [100 if i > 0 else i for i in l]

Submission status: Wrong Answer

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

double_lst = []

def my_index_multi(l, x):
    return [i for i, _x in enumerate(l) if _x == x]
  
for i in range(len(T)):
  try:
    T[i+1:].index(T[i])
    double_lst.append(my_index_multi(T,T[i]))
  except:
    continue
#print(double_lst)

flag = False
for i  in range(len(double_lst)):
  for j in range(1,len(double_lst[i])):
    if S[double_lst[i][0]] == S[double_lst[i][j]]:
      continue
    else:
      flag = True
      break
  if flag:
    print("No")
    break
else:
  print("Yes")

Submission status: Wrong Answer

Solution code:
s_str = [ord(i) for i in input()]
t_str = [ord(i) for i in input()]

s = sorted(s_str)
t = sorted(t_str)

cnt_s = 1
cnt_t = 1
s_num = []
t_num = []

for i in range(len(s)-1):
    if s[i] == s[i+1]:
        cnt_s += 1
    else:
        s_num.append(cnt_s)
        cnt_s = 1
    if t[i] == t[i+1]:
        cnt_t += 1
    else:
        t_num.append(cnt_t)
        cnt_t = 1

s_num = sorted(s_num)
t_num = sorted(t_num)

if s_num == t_num:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

Solution code:
S = list(raw_input())
T = list(raw_input())
# print(S, len(S), len(set(S)))
# print(T, len(T), len(set(T)))

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

Submission status: Wrong Answer

Solution code:
def c_string_transformation(S, T):
    from collections import defaultdict
    c = defaultdict(str)
    for k, (c1, c2) in enumerate(zip(S, T)):
        if c1 not in c[c2]:
            c[c2] += c1
    ans = 'Yes'
    for _, v in c.items():
        if len(v) >= 2:
            ans = 'No'
            break
    return ans

S = input()
T = input()
print(c_string_transformation(S, T))

Submission status: Wrong Answer

Solution code:

import math


def main():
    a = list(input())
    b = list(input())
    dica = {}
    dicb = {}
    dif = 0
    alpha = list("abcdefghijklmnopqrstuvwxyz")
    for aa,bb in zip(a,b):
        if aa != bb:
            if bb in dica and aa in dicb:
                if dica[bb] != aa or dicb[aa] != bb:            
                    print("No")
                    return 0
            if bb not in dica:  
                dica[bb] = aa
            if aa not in dicb:
                dicb[aa] =bb
        
            if dica[bb] != aa or dicb[aa] != bb:            
                print("No")
                return 0
        
            # if aa not in dica:
            #     dica[aa] = bb
            # if bb not in dicb:
            #     dicb[bb] = aa
            
   
    
    print("Yes")
    
    # for c in alpha:
    #     dica[c] = 0
    #     dicb[c] = 0
    # for temp in a:
    #     dica[temp] +=1
    # for temp in b:
    #     dicb[temp] +=1
    # for c in alpha:
    #     dif += (dica[c]-dicb[c])
    
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
def remove_duplicates(x):
    y=[]
    for i in x:
        if i not in y:
            y.append(i)
    return y
  
S=input()
T=input()
A=remove_duplicates(S)  
B=remove_duplicates(T)  
if len(A)==len(B):
  print('Yes')
else:
  print('No')

Submission status: Wrong Answer

Solution code:
a = list(input())
b = list(input())
c = len(a)
p = 0
d = [0 for i in range(27)]
l = [[]for i in range(27)]
ll = [0 for i in range(27)]
if a == b:
	print("Yes")
else:
	for i in range(c):
		if a[i] == b[i]:
			k = ord(a[i])-97
			if d[k] != 2:
				d[k] = 1
				if b[i] in l[k]:
					p = 0
				elif ll[k] == 0:
					ll[k] += 1
					l[k].append(b[i])
				else:
					p = 1
					break
			else:
				p = 1
				break
		else:
			k = ord(b[i])-97
			if d[k] != 1:
				d[k] = 2
				k = ord(a[i])-97
				if b[i] in l[k]:
					p = 0
				elif ll[k] == 0:
					ll[k] += 1
					l[k].append(b[i])
				else:
					p = 1
					break

			else:
				p = 1
				break
	if p == 1:
		print("No")
	else:
		print("Yes")

Submission status: Wrong Answer

Solution code:
from collections import Counter

S = Counter(list(input()))
T = Counter(list(input()))
s,t = [],[]
for x in S.values():
    s.append(x)
for x in T.values():
    t.append(x)

print(["No", "Yes"][s.sort() == t.sort()])

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ls = []
lt = []

for i in s:
  ls.append(i)
  
for j in t:
  lt.append(j)

ls2 = set(ls)
lt2 = set(lt)

res1 = [e for e in ls2 if ls.count(e)>1] 
res2 = [e for e in lt2 if lt.count(e)>1]

if len(set(ls2)) != len(set(lt2)):
  print('No')
else:
  for j in res1:
    a = [i for i, x in enumerate(ls) if x == j]
    ind = ls.index(j)
    b = [i for i, x in enumerate(lt) if x == lt[ind]]
    if a != b:
      print('No')
      exit()
    else:
      print('Yes')
      exit()
  print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np
from collections import Counter
s=input()
t=input()
s1=set(s)
t1=set(t)
qu2=[]
if len(s1)==len(t1):
    for i in s:
        if s.count(i)!=1:
            qu=[j for j,e in enumerate(s) if e==i]
            for j in qu:
                j=int(j)
                qu2.append(t[j])
            if len(set(qu2))!=1:
                print('No')
                sys.exit()

    print('Yes')



else:
    print('No')

Submission status: Wrong Answer

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

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes = [i for i, x in enumerate(S) if x == k1[0]]
                indexes2 = [i for i, x in enumerate(T) if x == k2[0]]
                if indexes != indexes2:
                    print('No')
            else:
                print('Yes')
else:
    print('No')

# for k1,k2 in zip(count1, count2, ):
#     if count1[k1] > 1:
#         [100 if i > 0 else i for i in l]

Submission status: Wrong Answer

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

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes = [i for i, x in enumerate(S) if x == k1[0]]
                indexes2 = [i for i, x in enumerate(S) if x == k2[0]]
                if indexes != indexes2:
                    print('No')
            else:
                print('Yes')
else:
    print('No')

# for k1,k2 in zip(count1, count2, ):
#     if count1[k1] > 1:
#         [100 if i > 0 else i for i in l]

Submission status: Wrong Answer

Solution code:
s = str(input())
t = str(input())
sl = list(s)
tl = list(t)
list1 = []
list2 = []
count = 0
if len(sl) != len(tl):
  count = 1
else:
  for i in range(len(sl)):
    for j in range(len(sl) - i - 1):
      if sl[i] == sl[i+j]:
        list1.append(j)
      if tl[i] == tl[i+j]:
        list2.append(j)
    if list1 != list2:
      count = 1
      break
if count == 0:
  print("Yes")
else:
  print("No")

Submission status: Wrong Answer

Solution code:
def c_string_transformation(S, T):
    from collections import defaultdict
    c = defaultdict(str)
    for k, (c1, c2) in enumerate(zip(S, T)):
        if c1 not in c[c2]:
            c[c2] += c1
    ans = 'Yes'
    for k, v in c.items():
        if k != v and k in v:
            ans = 'No'
            break
    return ans

S = input()
T = input()
print(c_string_transformation(S, T))

Submission status: Wrong Answer

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

count1 = collections.Counter(S)
count2 = collections.Counter(T)

count1=sorted(count1.items(), key=lambda x: x[1])
count2=sorted(count2.items(), key=lambda x: x[1])

if len(S) == len(T):
    if len(count1) != len(count2):
        print('No')
    else:
        for k1, k2 in zip(count1, count2):
            if k1[1] > 1:
                indexes = [i for i, x in enumerate(S) if x == k1[0]]
                indexes2 = [i for i, x in enumerate(S) if x == k1[0]]
                if indexes != indexes2:
                    print('No')
            else:
                print('Yes')
else:
    print('No')

# for k1,k2 in zip(count1, count2, ):
#     if count1[k1] > 1:
#         [100 if i > 0 else i for i in l]

Submission status: Wrong Answer

Solution code:
import itertools

s = input()
t = input()

g1 = len(list(itertools.groupby(sorted(s))))
g2 = len(list(itertools.groupby(sorted(t))))
if g1<g2:
    print('No')
    exit()

ls = [0]*26
for c,d in zip(s,t):
    p = ord(c)-ord('a')
    if ls[p]==0:
        ls[p] = d
    else:
        if d!=ls[p]:
            print('No')
            exit()
for i in range(26):
    if ls[i]!=0:
        p = ord(ls[i])-ord('a')
        if ls.count(ls[i])>1:
            tmp = []
            for j in range(26):
                if ls[j]!=0 and ord(ls[j])-ord('a')==i:
                    tmp.append(j)
            for j in tmp:
                if ls.count(chr(ord('a')+j))!=0:
                    print('No')
                    exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
ls = []
lt = []

for i in s:
  ls.append(i)
  
for j in t:
  lt.append(j)

ls2 = set(ls)
lt2 = set(lt)

res1 = [e for e in ls2 if ls.count(e)>1] 
res2 = [e for e in lt2 if lt.count(e)>1]

if len(set(ls2)) != len(set(lt2)):
  print('No')
else:
  for j in res1:
    a = [i for i, x in enumerate(ls) if x == j]
    ind = ls.index(j)
    b = [i for i, x in enumerate(lt) if x == lt[ind]]
    if a != b:
      print('No')
    else:
      print('Yes')

Submission status: Wrong Answer

Solution code:
import numpy as np
from string import ascii_lowercase
s = list(input())
t = list(input())

s_c = []
t_c = []

for a in ascii_lowercase:
  if s.count(a) != 0:
    s_c.append(s.count(a))
  if t.count(a) != 0:
    t_c.append(t.count(a))
    
if np.array_equal(s_c.sort(), t_c.sort()):
	print('Yes')
else:
	print('No')

Submission status: Wrong Answer

Solution code:
def main():
    S = input()
    T = input()
    items = {}
    can = True
    for s, t in zip(S, T):
        if t in items:
            if items[t] == s:
                continue
            can = False
            break
        items[t] = s
    if can:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Submission status: Wrong Answer

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

n = len(s)
x = [0]*n
for i in range(n-1):
    if s[i] == s[i+1]: 
        x[i] += 1
    else:
        break

y = [0]*n
for i in range(n-1):
    if s[i] == s[i+1]: 
        x[i] += 1
    else:
        break

if x == y:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s_str = [ord(i) for i in input()]
t_str = [ord(i) for i in input()]

s = sorted(s_str)
t = sorted(t_str)

bool_ans = 1
for i in range(len(s)-1):
   if s[i] == s[i+1]:
       if t[i] != t[i+1]:
           bool_ans = 0
           break

   if s[i] != s[i+1]:
       if t[i] == t[i+1]:
           bool_ans = 0
           break

if s_str == t_str:
    bool_ans = 1

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

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))]
us=[s[0]]
ut=[t[0]]
cs=0
ct=0
for i in range(1,len(s)):
    if s[i] in us:
        ns[i]=ns[us.index(s[i])]
    else:
        cs+=1
        ns[i]=cs
        us.append(s[i])
for i in range(1,len(t)):
    if t[i] in ut:
        nt[i]=nt[ut.index(t[i])]
    else:
        ct+=1
        nt[i]=ct
        ut.append(t[i])
if ns==nt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s, t = input(), input()
alp_dict = {}
for i, j in zip(s, t):
    if not j in alp_dict:
        alp_dict[j] = i
    elif alp_dict[j] == i:
        pass
    else:
        print("No")
        exit()  

print("Yes")

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])
# 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')


# A=set([])
# for i in range(len(S)):
#     if S[i]!=T[i]:
#         A.add((min(S[i],T[i]),max(S[i],T[i])))
# # print(A,len(A))
# C=list(A)
# B=[]
# for i in range(len(C)):
#     for j in range(2):
#         B.append(C[i][j])
# # print(B)
# BX=list(set(list(Counter(B).values())))
# # print(BX)
# print('Yes' if len(BX)==1 else 'No')

E=set([])
for i in range(len(S)):
    if S[i]==T[i]:
        E.add(S[i])
Elist=list(E)
for i in range(len(Elist)):
    for j in range(len(S)):
        if S[j]==Elist[i]:
            if T[j]!=Elist[i]:
                print('No')
                exit()
        if T[j]==Elist[i]:
            if S[j]!=Elist[i]:
                print('No')
                exit()
for i in range(len(S)):
    for j in range(len(S)):
        if S[i]==T[j] and T[i]==S[j]:
            print('No')
            exit
print('Yes')

Submission status: Wrong Answer

Solution code:
import itertools

s = input()
t = input()

"""
g1 = len(list(itertools.groupby(sorted(s))))
g2 = len(list(itertools.groupby(sorted(t))))
if g1<g2:
    print('No')
    exit()
"""

ls = [0]*26
for c,d in zip(s,t):
    p = ord(c)-ord('a')
    if ls[p]==0:
        ls[p] = d
    else:
        if d!=ls[p]:
            print('No')
            exit()
for i in range(26):
    if ls[i]!=0:
        p = ord(ls[i])-ord('a')
        if ls.count(ls[i])>1:
            tmp = []
            for j in range(26):
                if ls[j]!=0 and ord(ls[j])-ord('a')==i:
                    tmp.append(j)
            for j in tmp:
                if ls.count(chr(ord('a')+j))!=0:
                    print('No')
                    exit()
print('Yes')
#print(ls)

Submission status: Wrong Answer

Solution code:
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

S = raw_input()
T = raw_input()
ms = {}
mt = {}
for i in range(len(S)):
    if S[i] != T[i]:
        if S[i] in ms and ms[S[i]] != T[i]:
            print "No"
            exit()
        else:
            ms[S[i]] = T[i]
        if T[i] in mt and mt[T[i]] != S[i]:
            print "No"
            exit()
        else:
            mt[T[i]] = S[i]

print "Yes"

Submission status: Wrong Answer

Solution code:
# coding: utf-8

s = input()
t = input()

repeat_list = []

for i1, c1 in enumerate(t):
	for i2, c2 in enumerate(t):
		if i1 >= i2:
			continue
		if c1 == c2:
			flg = 1
			repeat_list.append((i1, i2))

answer_flg = 0
for element in repeat_list:
	if s[element[0]] != s[element[1]]:
		print("No")
		answer_flg = 1
		break
if answer_flg == 0:
	print("Yes")

Submission status: Wrong Answer

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

T_indices_dict = defaultdict(set)
for i, char in enumerate(T):
    T_indices_dict[char].add(i)

indices_set = set(range(len(S)))
for char in T:
    indices = T_indices_dict[char]
    char_set = set()
    for i in indices:
        char_set.add(S[i])
    if len(char_set) != 1:
        print("No")
        exit(0)
else:
    print("Yes")

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
slen = []
tlen = []
ans = "Yes"

while len(S) > 0:
    tempS = S[0]
    slen.append(S.count(tempS))
    while tempS in S:
        S.remove(tempS)
    
    
while len(T) > 0:
    tempT = T[0]
    tlen.append(T.count(tempT))
    while tempT in T:
        T.remove(tempT)
    
slen.sort()
tlen.sort()
print(slen,tlen)
print(["No", "Yes"][slen == tlen])

Submission status: Wrong Answer

Solution code:
s = [ord(i) for i in input()]
t = [ord(i) for i in input()]

s = sorted(s)
t = sorted(t)

bool_ans = 1
for i in range(len(s)-1):
   if s[i] == s[i+1]:
       if t[i] != t[i+1]:
           bool_ans = 0
           break

   if s[i] != s[i+1]:
       if t[i] == t[i+1]:
           bool_ans = 0
           break

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

Submission status: Wrong Answer

Solution code:
from sys import stdin

S = stdin.readline().rstrip()
T = stdin.readline().rstrip()

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

ans = ''
lst_ind = 0
for i in range(len(S)):
    S1 = S

    if S[i] == T[i]:
        ans += S[i]
    else:
        S1 = S1.replace(lst[lst_ind][0], lst[lst_ind][1])
        ans += S1[i]
        lst_ind += 1

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

Submission status: Wrong Answer

Solution code:
S = list(input())
T = list(input())
S_uniq = list(set(S))
T_uniq = list(set(T))
if len(S_uniq) == len(T_uniq):
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
p = input()
q=input()
for i in range(len(p)-1):
    p.replace(p[i],q[i])
if p == 1:
    print("Yes")
else:
    print("No")

Submission status: Wrong Answer

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

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

Submission status: Wrong Answer

Solution code:
A=input()
B=input()
d={}
nglist=[]
flag=0

for i,j in zip(A,B):
    if i == j:
        nglist.append(j)

for i,j in zip(A,B):
    if i not in d:
        d[i] = j
    else:
        if d[i] != j:
            flag=1
            break

    #if i == j:
    #    nglist.append(j)

    if (i != j) and (j in nglist):
        flag=1
        break
    #print(d)
    #print(nglist)



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

Submission status: Wrong Answer

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


if False not in [s==t for s,t in zip(S,T)]:
  print("Yes")
  exit()

for i in range(len(S)):
  #print(S)
  if S[i] == T[i]:
    continue
  c1 = S[i]
  c2 = T[i]
  #print("c1: {}, c2: {}".format(c1,c2))
  for j in range(len(S)):
    if S[j] == c1:
      #print("i:{}, j: {}, S[j]: {}, c1: {}, c2: {}".format(i, j, S[j], c1, c2))
      S[j] = c2
    elif S[j] == c2:
      #print("i:{}, j: {}, S[j]: {}, c1: {}, c2: {}".format(i, j, S[j], c1, c2))
      S[j] = c1
  if False not in [s==t for s,t in zip(S,T)]:
    print("Yes")
    exit()

print("No")

Submission status: Wrong Answer

Solution code:

import math


def main():
    a = list(input())
    b = list(input())
    dica = {}
    dicb = {}
    dif = 0
    alpha = list("abcdefghijklmnopqrstuvwxyz")
    for aa,bb in zip(a,b):
        if aa != bb:
            if bb not in dica:  
                dica[bb] = aa
            if aa not in dicb:
                dicb[aa] =bb
        
            if dica[bb] != aa or dicb[aa] != bb:            
                print("No")
                return 0
        
            # if aa not in dica:
            #     dica[aa] = bb
            # if bb not in dicb:
            #     dicb[bb] = aa
            
            
    print("Yes")
    
    # for c in alpha:
    #     dica[c] = 0
    #     dicb[c] = 0
    # for temp in a:
    #     dica[temp] +=1
    # for temp in b:
    #     dicb[temp] +=1
    # for c in alpha:
    #     dif += (dica[c]-dicb[c])
    
    

if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:
import collections
s = list(input())
t = list(input())
alps = collections.defaultdict(int)
alpt = collections.defaultdict(int)
flag = 0
for i in s:
    alps[i] += 1
for i in t:
    alpt[i] += 1
alps = dict(alps)
alpt = dict(alpt)
alps = list(alps.values())
alpt = list(alpt.values())
if alps != alpt:
    flag = 1
s = sorted(s)
t = sorted(t)
i = 0
pres = s[0]
cnts = 0
pret = t[0]
cntt = 0

while i < len(s):
    if s[i] == pres:
        cnts += 1
    else:
        cnts = 1
        pres = s[i]
    if t[i] == pret:
        cntt += 1
    else:
        cntt = 1
        pret = t[i]
    i += 1
    if cnts != cntt:
        flag = 1
print("Yes" if flag == 0 else "No")

Submission status: Wrong Answer

Solution code:
def main(S, T):
    cs = dict()

    for i, s in enumerate(S):
        t = T[i]
        if t not in cs:
            cs[t] = s
        elif cs[t] == s:
            continue
        else:
            return "No"
    return "Yes"

if __name__ == "__main__":
    assert main("azzel", "apple") == "Yes"
    assert main("abcdefghijklmnopqrstuvwxyz", "ibyhqfrekavclxjstdwgpzmonu") == "Yes"
    assert main("chokudai", "redcoder") == "No"
    S = input()
    T = input()
    print(main(S, T))

Submission status: Wrong Answer

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

N=len(S)

a=''
b=''
countA=0
countB=0
for i in range(N):
	if S[i] in S[:i+1]:
		countA+=1
		a+=str(countA)
	else:
		a+=str(countA)
		
	if T[i] in T[:i+1]:
		countB+=1
		b+=str(countB)
	else:
		b+=str(countB)
				

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

Submission status: Wrong Answer

Solution code:
def transform(a, b):
    for i in range(len(a)):
        check = [b[i]]
        for j in range(i-1):
            if a[i] == a[j]:
                check += b[j]

        if len(set(check)) > 1:
            return False
    return True

S = input()
T = input()
ans = transform(S, T) and transform(T, S)

print(("No", "Yes")[ans])

Submission status: Wrong Answer

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

s = input()
t = input()

sd = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0,
      'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0,
      'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0,
      'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
td = {'a': 0, 'b': 0, 'c': 0, 'd': 0, 'e': 0, 'f': 0, 'g': 0,
      'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0,
      'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0,
      'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}

for si, ti in zip(s, t):
    sd[si] += 1
    td[ti] += 1

x = 0
for sdv, tdv in zip(sd.values(), td.values()):
    x ^= sdv ^ tdv

if x == 0:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
def check(a,b):
  for c in a:
    if a.count(c) > 1:
      m = [i for i, x in enumerate(a) if x == c]
      w = b[m[0]]
      for i in range(1,len(m)):
        if b[i] != w:
          return "No" 
  return "Yes"
ans = check(s,t)
if ans == "Yes" : ans = check(t,s)
print(ans)