Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
T = list(input())

w = [0 for _ in range(200)]

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == tmp2:
                    return("No")
    return("Yes")

print(ans())



Fixed submission:
S = list(input())
T = list(input())

w = [0 for _ in range(200)]

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] !=0 and w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == tmp2:
                    return("No")
    return("Yes")

print(ans())

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
T = list(input())

w = [0 for _ in range(200)]
q = []
e = []

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == i:
                    return("No")
    return("Yes")

print(ans())



Fixed submission:
S = list(input())
T = list(input())

w = [0 for _ in range(200)]

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] !=0 and w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == tmp2:
                    return("No")
    return("Yes")

print(ans())

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
T = list(input())

w = [0 for _ in range(200)]
q = []
e = []

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = 0
            while(tmp!=i):
                tmp = w[i]
                if w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                if tmp == i:
                    return("No")
    return("Yes")

print(ans())



Fixed submission:
S = list(input())
T = list(input())

w = [0 for _ in range(200)]

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] !=0 and w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == tmp2:
                    return("No")
    return("Yes")

print(ans())

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
T = list(input())

w = [0 for _ in range(200)]
q = []
e = []

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = 0
            while(tmp!=i):
                if w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                if tmp == i:
                    return("No")
    return("Yes")

print(ans())



Fixed submission:
S = list(input())
T = list(input())

w = [0 for _ in range(200)]

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] !=0 and w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == tmp2:
                    return("No")
    return("Yes")

print(ans())

Buggy python submission (verdict: Time Limit Exceeded):
S = list(input())
T = list(input())

w = [0 for _ in range(200)]
q = []
e = []

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = 0
            while(tmp!=i):
                if w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                if tmp == i:
                    return("No")
    return("Yes")

print(ans())



Fixed submission:
S = list(input())
T = list(input())

w = [0 for _ in range(200)]

def ans():
    for s, t in zip(S, T):
        if w[ord(s)] > 0:
            # print("a", w[ord(s)], ord(t))
            if w[ord(s)] != ord(t):
                return("No")
        elif ord(t) in w:
            # print("b")
            return("No")

        w[ord(s)] = ord(t)
        

    for i in range(ord("a"), ord("z")):
        # print(i)
        if w[i] > 0:
            # print(chr(w[w[i]]), chr(i))
            tmp = w[i]
            tmp2 = w[i]
            while(True):
                if w[w[i]] !=0 and w[w[i]] != i:
                    r = w[w[i]]
                    w[w[i]] = w[i]
                    w[i] = r
                else:
                    break
                tmp = w[i]
                if tmp == tmp2:
                    return("No")
    return("Yes")

print(ans())