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:
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed=True):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    #N, M = iip(False)
    S = input()
    T = input()

    d1 = {}
    d2 = {}
    for s, t in zip(S, T):
        if t not in d1:
            d1[t] = s
            d2[s] = t

        if s not in d2:
            d1[t] = s
            d2[s] = t

            #print(t, t, d[s])
        if d1[t] != s or d2[s] != t:
            print("No")
            return
    print("Yes")



#####################################################ライブラリ集ここから

def fprint(s):
    for i in s:
        print(i)

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed=True):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    #N, M = iip(False)
    S = input()
    T = input()

    d1 = {}
    d2 = {}
    for s, t in zip(S, T):
        if t not in d1:
            d1[t] = s
            d2[s] = t
        if s not in d2:
            d2[s] = t
            d1[t] = s

            #print(t, t, d[s])
        if d1[t] != s or d2[s] != t:
            print("No")
            return
    print("Yes")



#####################################################ライブラリ集ここから

def fprint(s):
    for i in s:
        print(i)

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed=True):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    #N, M = iip(False)
    S = input()
    T = input()

    d1 = {}
    d2 = {}
    for s, t in zip(S, T):
        if t not in d1:
            d1[t] = s
            d2[s] = t
        else:
            #print(t, t, d[s])
            if d1[t] != s or d2[s] != t:
                print("No")
                return
    print("Yes")



#####################################################ライブラリ集ここから

def fprint(s):
    for i in s:
        print(i)

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed=True):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    #N, M = iip(False)
    S = input()
    T = input()

    d = {}
    for s, t in zip(S, T):
        if t not in d:
            d[t] = s
        else:
            #print(t, t, d[s])
            if d[t] != s:
                print("No")
                return
    print("Yes")



#####################################################ライブラリ集ここから

def fprint(s):
    for i in s:
        print(i)

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
mod = 10 ** 9 + 7
mod2 = 2**61+1
from collections import deque
import heapq
from bisect import bisect_left, insort_left, bisect_right

def iip(listed=True):
    ret = [int(i) for i in input().split()]
    if len(ret) == 1 and not listed:
        return ret[0]
    return ret

def iip_ord():
    return [ord(i) - ord("a") for i in input()]


def main():
    ans = solve()
    if ans is not None:
        print(ans)

def solve():
    #N, M = iip(False)
    S = input()
    T = input()

    d = {}
    for t, s in zip(S, T):
        if s not in d:
            d[s] = t
        else:
            #print(s, t, d[s])
            if d[s] != t:
                print("No")
                return
    print("Yes")



#####################################################ライブラリ集ここから

def fprint(s):
    for i in s:
        print(i)

def split_print_space(s):
    print(" ".join([str(i) for i in s]))


def split_print_enter(s):
    print("\n".join([str(i) for i in s]))


def koenai_saidai_x_index(sorted_list, n):
    l = 0
    r = len(sorted_list)
    if len(sorted_list) == 0:
        return False
    if sorted_list[0] > n:
        return False

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] == n:
            return x
        elif sorted_list[x] > n:
            r = x
        else:
            l = x
    return l


def searchsorted(sorted_list, n, side):
    if side not in ["right", "left"]:
        raise Exception("sideはrightかleftで指定してください")

    l = 0
    r = len(sorted_list)

    if n > sorted_list[-1]:
        # print(sorted_list)
        return len(sorted_list)
    if n < sorted_list[0]:
        return 0

    while r - l > 1:
        x = (l + r) // 2
        if sorted_list[x] > n:
            r = x
        elif sorted_list[x] < n:
            l = x
        else:
            if side == "left":
                r = x
            elif side == "right":
                l = x

    if side == "left":
        if sorted_list[l] == n:
            return r - 1
        else:
            return r

    if side == "right":
        if sorted_list[l] == n:
            return l + 1
        else:
            return l


def soinsuu_bunkai(n):
    ret = []
    for i in range(2, int(n ** 0.5) + 1):
        while n % i == 0:
            n //= i
            ret.append(i)
        if i > n:
            break
    if n != 1:
        ret.append(n)
    return ret


def conbination(n, r, mod, test=False):
    if n <= 0:
        return 0
    if r == 0:
        return 1
    if r < 0:
        return 0
    if r == 1:
        return n
    ret = 1
    for i in range(n - r + 1, n + 1):
        ret *= i
        ret = ret % mod

    bunbo = 1
    for i in range(1, r + 1):
        bunbo *= i
        bunbo = bunbo % mod

    ret = (ret * inv(bunbo, mod)) % mod
    if test:
        # print(f"{n}C{r} = {ret}")
        pass
    return ret


def inv(n, mod):
    return power(n, mod - 2)


def power(n, p, mod_= mod):
    if p == 0:
        return 1
    if p % 2 == 0:
        return (power(n, p // 2, mod_) ** 2) % mod_
    if p % 2 == 1:
        return (n * power(n, p - 1, mod_)) % mod_


if __name__ == "__main__":
    main()

Submission status: Wrong Answer

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

def f(l):
    dic = {}
    for i in l:
        if i in dic.keys():
            dic[i] += 1
        else:
            dic[i] = 1
    return list(dic.values())
    # return sorted(list(dic.values()))

dics = f(s)
dict = f(t)
# print(dics)
# print(dict)
print("Yes" if dics==dict else "No")

Submission status: Wrong Answer

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

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

s = input()
t = input()
n = len(s)
S = [-1]*26
for i in range(n):
    sidx = ord(s[i]) - ord("a")
    tidx = ord(t[i]) - ord("a")
    if S[tidx] < 0:
        S[tidx] = sidx
    else:
        if S[tidx] != sidx:
            print('No')
            quit()
print('Yes')

Submission status: Wrong Answer

Solution code:
s=input()
t=input()
if len(s)!=len(t):
    print("No")
    exit()
ans=0
for i in range(len(s)):
    if s[i]!=t[i]:
        ans+=1
if ans%2==0:
    print("Yes")
else :
    print("No")

Submission status: Wrong Answer

Solution code:
from collections import Counter
s = input()
t = input()
s_cnt = sorted(Counter(s).values(), reverse=True)
t_cnt = sorted(Counter(t).values(), reverse=True)
print(s_cnt)
print(t_cnt)
if s_cnt == t_cnt:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

l='abcdefghijklmnopqrstuvwxyz'
if len(set(t)) == len(set(s)):
    print('No')
    exit()

for item in l:
    can = [i for i, x in enumerate(t) if x == item]
    if len(can) > 1:
        d = [s[i] for i in can]
        if len(set(d)) != 1:
            print('No')
            exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

l='abcdefghijklmnopqrstuvwxyz'
if len(set(t)) == 26:
    if len(set(s)) != 26:
        print('No')
        exit()

for item in l:
    can = [i for i, x in enumerate(t) if x == item]
    if len(can) > 1:
        d = [s[i] for i in can]
        if len(set(d)) != 1:
            print('No')
            exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
from collections import defaultdict as dd
s=input()
t=input()
ds=dd(int)
dt=dd(int)
for ss,tt in zip(s,t):
    ds[ss]+=1
    ds[tt]+=1
cs,ct=[],[]

for v in ds.values():
    cs.append(v)
for v in dt.values():
    ct.append(v)
cs.sort()
ct.sort()

for sss,ttt in zip(cs,ct):
    if sss!=ttt:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline

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

cnt = [[0] * 26 for i in range(26)]

for i in range(len(S)):
    cnt[ord(S[i]) - ord('a')][ord(T[i]) - ord('a')] += 1

for j in range(26):
    n = 0
    for i in range(26):
        if cnt[i][j] != 0:
            n += 1
    if n > 1:
        print("No")
        exit(0)
print("Yes")
exit(0)

Submission status: Wrong Answer

Solution code:
def ii():return int(input())
def iim():return map(int,input().split())
def iil():return list(map(int,input().split()))
def ism():return map(str,input().split())
def isl():return list(map(str,input().split()))

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

l='abcdefghijklmnopqrstuvwxyz'

for item in l:
    can = [i for i, x in enumerate(t) if x == item]
    if len(can) > 1:
        d = []
        for i in can:
            d.append(s[i])
        if len(set(d)) != 1:
            print('No')
            exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
import string

S = input()
T = input()
sLst = [0] * 26
tLst = [0] * 26

for i in range(26):
    sLst[i] = S.count(string.ascii_lowercase[i])
    tLst[i] = T.count(string.ascii_lowercase[i])
sLst.sort(reverse=True)
tLst.sort(reverse=True)

for i in range(26):
    if sLst[i] != tLst[i]:
        print('No')

print('Yes')

Submission status: Wrong Answer

Solution code:

S = set(input())
T = set(input())

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

Submission status: Wrong Answer

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

tToS = {}
for s, t in zip(S, T):
    if not t in tToS:
        tToS[t] = s

    if tToS[t] != s:
        print('No')
        exit()

print('Yes')

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
dic = {}
for i in range(len(S)):
    if T[i] not in dic:
        dic[T[i]] = S[i]
    elif dic[T[i]] != S[i]:
        print('No')
        exit()
print('Yes')

Submission status: Wrong Answer

Solution code:
S = input()
T = input()
C = [0]*26
for k in range(len(S)):
    if S[k] != T[k]:
        if C[ord(T[k])-97] == 0:
            C[ord(T[k])-97] = ord(S[k])-97
        else:
            if C[ord(T[k])-97] != ord(S[k])-97:
                print("No")
                exit(0)

print("Yes")

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
n = len(s)
r=[-1]*26
r2=[-1]*26
abcd = 'abcdefghijklmnopqrstuvwxyz'

def f(l,l2,R):
  for i in range(n):
    if R[abcd.index(l[i])]==-1:
       R[abcd.index(l[i])]=l2[i]
    else:
       print("No")
       exit()

f(s,t,r)
f(t,s,r2)
print("Yes")

Submission status: Wrong Answer

Solution code:
s = input()
t = input()
n = len(s)
r=[-1]*26
r2=[-1]*26
abcd = 'abcdefghijklmnopqrstuvwxyz'

def f(l,l2,R):
  for i in range(n):
    if R[abcd.index(l[i])]!=-1:
       R[abcd.index(l[i])]=l2[i]
    else:
       print("No")
       exit()

f(s,t,r)
f(t,s,r2)
print("Yes")

Submission status: Wrong Answer

Solution code:
import sys
input = sys.stdin.readline
from collections import Counter

S = input().rstrip("\r\n")
T = input().rstrip("\r\n")
sc = Counter(S)
tc = Counter(T)
ans = "Yes" if len(sc.items()) == len(tc.items()) else "No"
print(ans)

Submission status: Wrong Answer

Solution code:
import collections 

s=input()
t=input()
s= collections.Counter(s)
t= collections.Counter(t)
#print(s)
sans=[]
tans=[]

for v in s.values():
    sans.append(v)
for v in t.values():
    tans.append(v)
#print(sans,tans)
if sans==tans:
    print('Yes')
else:
    print('No')

Submission status: Wrong Answer

Solution code:
from collections import Counter, defaultdict

s = Counter(input())
t = Counter(input())
ok = True
unused_nums_s = defaultdict(int)
unused_nums_t = defaultdict(int)
for k in s:
  if k in t and t[k] != s[k]:
    ok = False
  if k not in t:
    unused_nums_s[s[k]] += 1
for k in t:
  if k not in s:
    unused_nums_t[t[k]] += 1
ok = ok and all(unused_nums_s[k] == unused_nums_t[k] for k in unused_nums_s)
print('Yes' if ok else 'No')

Submission status: Wrong Answer

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

st = list(zip(s, t))
st.sort(key=lambda x:x[1])
dic_ST = set()
ans = "Yes"

for i in range(len(s)-1):
    if st[i][1] == st[i+1][1]:
        if st[i][0] != st[i+1][0]:
            ans = "No"
        if st[i][0] in dic_ST:
            ans = " No"
    else:
        dic_ST.add(st[i][0])

if len(st) != 1:
    if st[-2][1] == st[-1][1]:
        if st[-2][0] != st[-1][0]:
            ans = "No"
        if st[-1][0] in dic_ST:
            ans = " No"
    else:
        dic_ST.add(st[-1][0])

print(ans)

Submission status: Wrong Answer

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

st = list(zip(s, t))
st.sort(key=lambda x:x[1])
st.append(["!", "1"])
dic_ST = set()
ans = "Yes"

for i in range(len(s)):
    if st[i][1] == st[i+1][1]:
        if st[i][0] != st[i+1][0]:
            ans = "No"
        if st[i][0] in dic_ST:
            ans = " No"
    else:
        dic_ST.add(st[i][0])

print(ans)

Submission status: Wrong Answer

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


def main():
    for i, s1 in enumerate(S):
        list_index = []
        for j, s2 in enumerate(S[i + 1:]):
            if s1 == s2:
                list_index.append(j + 1)

        if len(list_index):
            t1 = T[i]
            for idx in list_index:
                # print(i, ',', s1, ',', j, ',', s2, ',', idx)
                t2 = T[idx]
                if t1 != t2:
                    print('No')
                    return
        else:
            for k, t3 in enumerate(T):
                list_index = []
                for l, t4 in enumerate(T[k + 1:]):
                    if t3 == t4:
                        list_index.append(l + 1)
                if len(list_index):
                    u1 = S[k]
                    for idx in list_index:
                        u2 = S[idx]
                        if u1 != u2:
                            print('No')
                            return

    print('Yes')


main()

Submission status: Wrong Answer

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


def main():
    for i, s1 in enumerate(S):
        list_index = []
        for j, s2 in enumerate(S[i + 1:]):
            if s1 == s2:
                list_index.append(j + 1)

        if len(list_index):
            t1 = T[i]
            for idx in list_index:
                # print(i, ',', s1, ',', j, ',', s2, ',', idx)
                t2 = T[idx]
                if t1 != t2:
                    print('No')
                    return
        else:
            for k, t3 in enumerate(T):
                list_index = []
                for l, t4 in enumerate(T[k + 1:]):
                    if t3 == t4:
                        list_index.append(l + 1)
                if len(list_index):
                    u1 = T[k]
                    for idx in list_index:
                        u2 = T[idx]
                        if u1 != u2:
                            print('No')
                            return

    print('Yes')


main()

Submission status: Wrong Answer

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


def main():
    for i, s1 in enumerate(S):
        list_index = []
        for j, s2 in enumerate(S[i + 1:]):
            if s1 == s2:
                list_index.append(j + 1)

        if len(list_index):
            t1 = T[i]
            for idx in list_index:
                # print(i, ',', s1, ',', j, ',', s2, ',', idx)
                t2 = T[idx]
                if t1 != t2:
                    print('No')
                    return
        else:
            if i:
                for k, t3 in enumerate(T[i - 1:]):
                    list_index = []
                    for l, t4 in enumerate(T[i:]):
                        if t3 == t4:
                            list_index.append(l + 1)
                    if len(list_index):
                        u1 = T[i - 1:][k]
                        for idx in list_index:
                            u2 = T[i - 1:][idx]
                            if u1 != u2:
                                print('No')
                                return

    print('Yes')


main()

Submission status: Wrong Answer

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


def main():
    for i, s1 in enumerate(S):
        list_index = []
        for j, s2 in enumerate(S[i + 1:]):
            if s1 == s2:
                list_index.append(j + 1)

        if len(list_index):
            t1 = T[i]
            for idx in list_index:
                # print(i, ',', s1, ',', j, ',', s2, ',', idx)
                t2 = T[idx]
                if t1 != t2:
                    print('No')
                    return
        else:
            if i > 0:
                for t3 in T[i - 1:]:
                    for t4 in T[i:]:
                        if t3 == t4:
                            print('No')
                            return

    print('Yes')


main()

Submission status: Wrong Answer

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


def main():
    for i, s1 in enumerate(S):
        list_index = []
        for j, s2 in enumerate(S[1:]):
            if s1 == s2:
                list_index.append(j + 1)

        if list_index:
            t1 = T[i]
            for idx in list_index:
                # print(i, ',', s1, ',', j, ',', s2, ',', idx)
                t2 = T[idx]
                if t1 != t2:
                    print('No')
                    return
        else:
            if i:
                for t3 in T[i - 1:]:
                    for t4 in T[i:]:
                        if t3 == t4:
                            print('No')
                            return

    print('Yes')


main()

Submission status: Wrong Answer

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


def main():
    for i, s1 in enumerate(S):
        list_index = []
        for j, s2 in enumerate(S[1:]):
            if s1 == s2:
                list_index.append(j + 1)

        if list_index:
            t1 = T[i]
            for idx in list_index:
                # print(i, ',', s1, ',', j, ',', s2, ',', idx)
                t2 = T[idx]
                if t1 != t2:
                    print('No')
                    return
        else:
            for t3 in T[i:]:
                for t4 in T[i + 1:]:
                    if t3 == t4:
                        print('No')
                        return

    print('Yes')


main()

Submission status: Wrong Answer

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


def main():
    for i, s1 in enumerate(S):
        list_index = []
        for j, s2 in enumerate(S[1:]):
            if s1 == s2:
                list_index.append(j + 1)

        if list_index:
            t1 = T[i]
            for idx in list_index:
                # print(i, ',', s1, ',', j, ',', s2, ',', idx)
                t2 = T[idx]
                if t1 != t2:
                    print('No')
                    return

    print('Yes')


main()