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

Solution in C# (Mono 4.6.2.0) (judge verdict: Wrong Answer)

using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ProgrammingContest
{
    class Writer : IDisposable
    {
        private System.IO.TextWriter Out { get; }
        private StringBuilder Sb { get; }
        private bool IsReactive { get; }
        public Writer(string path)
            : this(new System.IO.StreamWriter(path))
        {
        }
        public Writer(bool isReactive)
            : this(null, isReactive)
        {
        }
        public Writer(System.IO.TextWriter writer = null, bool isReactive = false)
        {
            this.Out = (writer ?? Console.Out);
            this.IsReactive = isReactive;
            if (!this.IsReactive)
            {
                this.Sb = new StringBuilder();
            }
        }
        public void Dispose()
        {
            if (!this.IsReactive)
            {
                this.Out.Write(Sb.ToString());
            }
            if (!this.Out.Equals(Console.Out))
            {
                this.Out.Dispose();
            }
        }
        public void Write(object val)
        {
            if (this.IsReactive)
            {
                this.Out.Write(val.ToString());
                this.Out.Flush();
            }
            else
            {
                this.Sb.Append(val.ToString());
            }
        }
        public void WriteFormat(string format, params object[] vals)
        {
            if (this.IsReactive)
            {
                this.Out.Write(format, vals);
                this.Out.Flush();
            }
            else
            {
                this.Sb.AppendFormat(format, vals);
            }
        }
        public void WriteLine(object val = null)
        {
            this.WriteFormat((val ?? string.Empty).ToString() + Environment.NewLine);
        }
        public void WriteLine(int val)
        {
            this.WriteLine(val.ToString());
        }
        public void WriteLine(long val)
        {
            this.WriteLine(val.ToString());
        }
        public void WriteLine(string val)
        {
            this.WriteLine((object)val);
        }
        public void WriteLine(string format, params object[] vals)
        {
            this.WriteFormat(format + Environment.NewLine, vals);
        }
    }

    class Scanner : IDisposable
    {
        private Queue<string> Buffer { get; }
        private char[] Sep { get; }
        private System.IO.TextReader Reader { get; }
        public Scanner(string path, char[] sep = null)
            : this(new System.IO.StreamReader(path), sep)
        {
        }
        public Scanner(System.IO.TextReader reader = null,
                        char[] sep = null)
        {
            this.Buffer = new Queue<string>();
            this.Sep = (sep ?? new char[] { ' ' });
            this.Reader = (reader ?? Console.In);
        }
        private void CheckBuffer()
        {
            if (this.Buffer.Count == 0 && this.Reader.Peek() != -1)
            {
                string str = string.Empty;
                for (; string.IsNullOrEmpty(str) || string.IsNullOrWhiteSpace(str);
                    str = this.Reader.ReadLine()) ;

                var strs = str.Split(this.Sep).Where(el => !(string.IsNullOrEmpty(el) || string.IsNullOrWhiteSpace(el)));
                foreach (var el in strs)
                {
                    this.Buffer.Enqueue(el);
                }
            }
        }

        public void Dispose()
        {
            if (!this.Reader.Equals(Console.In))
            {
                this.Reader.Dispose();
            }
        }

        public string Next()
        {
            this.CheckBuffer();
            return this.Buffer.Dequeue();
        }
        public string[] GetStringArray(int N)
        {
            return Enumerable.Range(0, N)
                             .Select(e => this.Next())
                             .ToArray();
        }

        public int NextInt()
        {
            return int.Parse(this.Next());
        }
        public int[] GetIntArray(int N)
        {
            return Enumerable.Range(0, N)
                             .Select(e => this.NextInt())
                             .ToArray();
        }

        public double NextDouble()
        {
            return double.Parse(this.Next());
    }
        public double[] GetdoubleArray(int N)
        {
            return Enumerable.Range(0, N)
                             .Select(e => this.NextDouble())
                             .ToArray();
        }

        public long NextLong()
        {
            return long.Parse(this.Next());
        }
        public long[] GetLongArray(int N)
        {
            return Enumerable.Range(0, N)
                             .Select(e => this.NextLong())
                             .ToArray();
        }

        public bool IsEnd
        {
            get
            {
                this.CheckBuffer();
                return this.Buffer.Count == 0;
            }
        }
    }

    class MainClass : IDisposable
    {
        private Scanner Sc { get; }
        private Writer Wr { get; }
        static string BackPath { get; } = "..";
        private char DirSep { get; } = System.IO.Path.DirectorySeparatorChar;
        private string InFilePath { get; } = string.Empty;
        private string OutFilePath { get; } = string.Empty;
        public MainClass()
        {
            this.InFilePath = MainClass.BackPath
                            + this.DirSep
                            + MainClass.BackPath
                            + this.DirSep
                            + "in.txt";
            this.OutFilePath = MainClass.BackPath
                             + this.DirSep
                             + MainClass.BackPath
                             + this.DirSep
                             + "out.txt";

            this.Wr = new Writer(this.IsReactive);
            //this.Wr = new Writer(this.OutFilePath);
#if DEBUG
            if (!this.IsReactive)
            {
                this.Sc = new Scanner(this.InFilePath);
            }
            else
            {
                this.Sc = new Scanner();
            }
#else
            this.Sc = new Scanner();
#endif
        }
        static void Main(string[] args)
        {
            using (var mainClass = new MainClass())
            {
                mainClass.Solve();
            }
        }

        public void Dispose()
        {
            this.Sc?.Dispose();
            this.Wr?.Dispose();
#if DEBUG
            Console.WriteLine("press any key to continue...");
            Console.ReadKey();
#endif
        }

        void Solve()
        {
            var S = Sc.Next();
            var T = Sc.Next();
            Dictionary<char, HashSet<char>> dic = new Dictionary<char, HashSet<char>>();
            for (char c = 'a'; c <= 'z'; c++)
            {
                dic.Add(c, new HashSet<char>());
            }
            for (int i = 0; i < T.Length; i++)
            {
                dic[T[i]].Add(S[i]);
            }
            foreach (var e in dic)
            {
                if (e.Value.Count > 1)
                {
                    Wr.WriteLine("No");
                    return;
                }
            }
            Wr.WriteLine("Yes");
        }

        private bool IsReactive { get; } = false; // TODO: reactive check !!
    }
}