stablegradients/pie-gem5-bysrc huggingface dataset:
// Original C++ solution (slower):
#include <bits/stdc++.h>

using namespace std;

const int64_t INF = (1LL << 60);

int64_t N, K;

vector<int64_t> scores[5005];

vector<int64_t> P(5005), C(5005);

int64_t tot[5005];

vector<int64_t> maxs(5005, -INF);



bool visited[5005];

void dfs(int64_t v, int64_t score, int64_t start)

{

  if (visited[v])

  {

    scores[start].push_back(score);

    tot[start] = score;

    return;

  }

  visited[v] = true;

  scores[start].push_back(score);

  dfs(P.at(v), score + C.at(P.at(v)), start);

}



int main()

{

  cin >> N >> K;

  for (int64_t i = 0; i < N; i++)

  {

    cin >> P.at(i);

    P.at(i)--;

  }

  for (int64_t i = 0; i < N; i++)

  {

    cin >> C.at(i);

  }

  for (int i = 0; i < N; i++)

  {

    for (int j = 0; j < 5005; j++)

    {

      visited[j] = false;

    }

    dfs(i, 0, i);

  }

  for (int i = 0; i < N; i++)

  {

    int64_t cyc = scores[i].size() - 1;

    int64_t cycles = K / cyc, r = K % cyc;

    if (tot[i] < 0 || cycles == 0)

    {

      int64_t ma = -INF;

      for (int j = 1; j <= min(K, cyc); j++)

      {

        ma = max(ma, scores[i].at(j));

      }

      maxs[i] = ma;

    }

    else

    {

      if (r == 0)

      {

        int64_t ma = -INF;

        for (int j = 1; j <= cyc; j++)

        {

          ma = max(ma, scores[i].at(j));

        }

        ma += (cycles - 1) * tot[i];

        maxs[i] = ma;

      }

      else

      {

        int64_t ma = 0;

        for (int j = 1; j <= r; j++)

        {

          ma = max(ma, scores[i].at(j));

        }

        ma += cycles * tot[i];

        maxs[i] = ma;

      }

    }

  }

  int64_t ans = -INF;

  for (int64_t i = 0; i < N; i++)

  {

    ans = max(ans, maxs[i]);

  }

  cout << ans << endl;

}

// Optimized solution to the same problem (faster):
#include <bits/stdc++.h>

using namespace std;

int64_t N, K, p, c;

vector<int64_t> to(5005), C(5005);



int64_t solve(int start)

{

  vector<bool> visited(N, false);

  int64_t k = K, score = 0, moves = 0, ret = -(1LL << 62), next = to[start];

  while (!visited[next])

  {

    visited[next] = true;

    moves++;

    score += C.at(next);

    ret = max(ret, score);

    if (moves == K)

    {

      return ret;

    }

    next = to[next];

  }

  if (score <= 0)

  {

    return ret;

  }

  if (k % moves == 0)

  {

    return score * (k / moves - 1) + ret;

  }

  ret = score = score * (k / moves), k %= moves;



  while (k > 0)

  {

    k--;

    score += C.at(next);

    ret = max(ret, score);

    next = to[next];

  }

  return ret;

}



int main()

{

  cin >> N >> K;

  for (int i = 0; i < N; i++)

  {

    cin >> to[i];

    to[i]--;

  }

  for (int i = 0; i < N; i++)

  {

    cin >> C.at(i);

  }

  int64_t ans = -(1LL << 62);

  for (int i = 0; i < N; i++)

  {

    ans = max(ans, solve(i));

  }

  cout << ans << endl;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<set>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;



const int Maxn=2*1e5;



char s[Maxn+5],t[Maxn+5];

int c[256+5];



int main() {

	#ifdef LOACL

	freopen("in.txt","r",stdin);

	freopen("out.txt","w",stdout);

	#endif

	scanf("%s %s",s,t);

	int len=strlen(s);

	memset(c,-1,sizeof c);

	set<char> cnt;

	for(int i=0;i<len;i++)

		cnt.insert(s[i]);

	for(int i=0;i<len;i++) {

		if(c[t[i]]!=-1&&c[t[i]]!=s[i]) {

			if(t[i]==s[i]&&cnt.size()<26)

				continue;

			puts("No");

			return 0;

		}

		c[t[i]]=s[i];

	}

	memset(c,-1,sizeof c);

	for(int i=0;i<len;i++) {

		if(c[s[i]]!=-1&&c[s[i]]!=t[i]) {

			if(t[i]==s[i]&&cnt.size()<26)

				continue;

			puts("No");

			return 0;

		}

		c[s[i]]=t[i];

	}

	puts("Yes");

	return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

using namespace std;

#define L 200005



char s[L],t[L];

int len,last[30];

int lasts[L],lastt[L];

bool flag=true;



int main() {

	scanf("%s %s",s,t);

	len=strlen(s);

	for(int i=0;i<len;i++) {

		int j=s[i]-'a';

		lasts[i]=last[j];

		last[j]=i;

	}

	memset(last,0,sizeof(last));

	for(int i=0;i<len;i++) {

		int j=t[i]-'a';

		lastt[i]=last[j];

		last[j]=i;

	}

	for(int i=0;i<len;i++)

		if(lasts[i]!=lastt[i]) {

			printf("No\n");

			return 0;

		}

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<set>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

const int MAXN=2e5+5;

char s[MAXN],t[MAXN];

int c[256+5],d[256+5];

 

int main() 

{

	scanf("%s%s",s,t);

	int len=strlen(s);

	memset(c,-1,sizeof c);

	memset(d,-1,sizeof d);

	set<char> cnt;

	for(int i=0;i<len;i++)

		cnt.insert(s[i]);

	for(int i=0;i<len;i++) {

		if(c[t[i]]!=-1&&c[t[i]]!=s[i]) {

			if(t[i]==s[i]&&cnt.size()<=26)

				continue;

			puts("No");

			return 0;

		}

		c[t[i]]=s[i];

	}

	for(int i=0;i<len;i++) {

		if(d[s[i]]!=-1&&d[s[i]]!=t[i]) {

			if(t[i]==s[i]&&cnt.size()<=26)

				continue;

			puts("No");

			return 0;

		}

		d[s[i]]=t[i];

	}

	puts("Yes");

	return 0;

}

 

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

using namespace std;

#define L 200005



char s[L],t[L];

int len,last[30];

int lasts[L],lastt[L];

bool flag=true;



int main() {

	scanf("%s %s",s,t);

	len=strlen(s);

	for(int i=0;i<len;i++) {

		int j=s[i]-'a';

		lasts[i]=last[j];

		last[j]=i;

	}

	memset(last,0,sizeof(last));

	for(int i=0;i<len;i++) {

		int j=t[i]-'a';

		lastt[i]=last[j];

		last[j]=i;

	}

	for(int i=0;i<len;i++)

		if(lasts[i]!=lastt[i]) {

			printf("No\n");

			return 0;

		}

	printf("Yes\n");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

#include <stdio.h>



using namespace std;



int main() {

    string s, t;

    while (cin >> s >> t) {

        int len = s.size(), i;

        for (i = 0; i < len; ++i) {

            if (s.find(s[i]) != t.find(t[i])) break;

        }

        if(i < len) puts("No");

        else puts("Yes");

    }

    return 0;

}


// Optimized solution to the same problem (faster):
#include <stdio.h>

#include <string.h>

#include <algorithm>



using namespace std;



#define N 210000



int a[30], b[30];

char s1[N], s2[N];



int main() {

    while (scanf("%s", s1) != EOF) {

        scanf("%s", s2);

        memset(a, 0, sizeof(a));

        memset(b, 0, sizeof(b));

        int i, n = strlen(s1);

        for (i = 0; i < n; ++i) {

            a[s1[i] - 'a']++;

            b[s2[i] - 'a']++;

        }

        sort(a, a + 26); sort(b, b + 26);

        for (i = 0; i < 26; ++i) {

            if (a[i] != b[i]) break;

        }

        if (i < 26) puts("No");

        else puts("Yes");

    }

    return 0;

}


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<vector>



using namespace std;



bool solve(string s, string t) {

    vector<int> v[26];

    for (int i = 0; i < (int)s.size(); ++i) {

        v[s[i] - 'a'].push_back(i);

    }

    int table[200001] = {0};

    for (int i = 0; i < (int)t.size(); ++i) {

        table[i] = t[i] - 'a';

    }

    for (int i = 0; i < 26; ++i) {

        if ((int)v[i].size() == 0) continue;

        int c = table[v[i][0]];

        for (int j = 1; j < (int)v[i].size(); ++j) {

            if (table[v[i][j]] != c) {

                return 0;

            }

        }

    }

    return 1;

}

int main() {

    ios::sync_with_stdio(false);

    cin.tie(0);

    string s, t;

    cin >> s >> t;

    if (solve(s, t) + solve(t, s) == 2) cout << "Yes" << endl;

    else cout << "No" << endl;

}

/*

 sの同じ文字のindex列とtのそれが一致すればいい

 

 */


// Optimized solution to the same problem (faster):
#include<iostream>

#include<string>

#include<algorithm>



using namespace std;



int main() {

    string S, T;

    cin >> S >> T;

    int s[26] = {0}, t[26] = {0};

    for (int i = 0; i < (int)S.size(); ++i) {

        s[S[i] - 'a']++;

        t[T[i] - 'a']++;

    }

    sort(s, s + 26);

    sort(t, t + 26);

    for (int i = 0; i < 26; ++i) {

        if (s[i] != t[i]) {

            cout << "No" << endl;

            return 0;

        }

    }

    cout << "Yes" << endl;

}

/*

 aaabb

 abaab

 */


// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<string>

#include<map>

#include<set>

using namespace std;

int n,q,t,k,d,ans;

map <char,char> mp,mp2;

const int maxn=1e5+7;

int num[maxn];

bool vis[1000];

int main(){

    string a;

    string b;

    memset(num,-1,sizeof(num));

    cin>>a>>b;

    int len=a.size();

    for(int i=0;i<len;i++)

    {

        if(num[a[i]]==-1)

        {

            num[a[i]]=b[i];

        }

        else

        {

            if(num[a[i]]!=b[i])

            {

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    memset(num,-1,sizeof(num));

    for(int i=0;i<len;i++)

    {

        if(num[b[i]]==-1)

        {

            num[b[i]]=a[i];

        }

        else

        {

            if(num[b[i]]!=a[i])

            {

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    cout<<"Yes"<<endl;

    return 0;

	}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

const int N=200005;

struct node

{

	char a;

	char b;

}stringss[N];

int inc1(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.a-n.a;

}

int inc2(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.b-n.b;

}

int main()

{

	char str1[N],str2[N];

	scanf("%s",str1);

	scanf("%s",str2);

	int len=strlen(str1);

	for(int i=0;i<len;i++)

	{

		stringss[i].a=str1[i];

		stringss[i].b=str2[i];

	}

	qsort(stringss,len,sizeof(struct node),inc1);

	for(int i=0;i<len;i++)

	{

		if(stringss[i].a==stringss[i+1].a&&stringss[i].b!=stringss[i+1].b)

		{

			printf("No\n");

			return 0;

		}

	}

	qsort(stringss,len,sizeof(struct node),inc2);

	for(int i=0;i<len;i++)

	{

		if(stringss[i].b==stringss[i+1].b&&stringss[i].a!=stringss[i+1].a)

		{

			printf("No\n");

			return 0;

		}

	}

	printf("Yes\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<cstring>

#include<string>

#include<map>

#include<iostream>



using namespace std;



string S,T;



map <char,char> mu;

map <char,char> pu;



int main()

{

	cin >> S;

	cin >> T;

	for(int i = 0; i < S.size(); i++){

		if(mu.count(S[i])){

			if(mu[S[i]] != T[i]) {

				printf("No\n");

				return 0;

			}

		}

		if(pu.count(T[i])) {

			if(pu[T[i]] != S[i]) {

				printf("No\n");

				return 0;

			}

		}

		mu[S[i]] = T[i];

		pu[T[i]] = S[i];

	}

	printf("Yes\n");

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

const int N=200005;

struct node

{

	char a;

	char b;

}stringss[N];

int inc1(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.a-n.a;

}

int inc2(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.b-n.b;

}

int main()

{

	char str1[N],str2[N];

	scanf("%s",str1);

	scanf("%s",str2);

	int len=strlen(str1);

	for(int i=0;i<len;i++)

	{

		stringss[i].a=str1[i];

		stringss[i].b=str2[i];

	}

	qsort(stringss,len,sizeof(struct node),inc1);

	for(int i=0;i<len;i++)

	{

		if(stringss[i].a==stringss[i+1].a&&stringss[i].b!=stringss[i+1].b)

		{

			printf("No\n");

			return 0;

		}

	}

	qsort(stringss,len,sizeof(struct node),inc2);

	for(int i=0;i<len;i++)

	{

		if(stringss[i].b==stringss[i+1].b&&stringss[i].a!=stringss[i+1].a)

		{

			printf("No\n");

			return 0;

		}

	}

	printf("Yes\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include <iostream>

#include <string>

#include <vector>

#include <map>

#include <algorithm>

using namespace std;



int change[26][26];



int main()

{

    string s, t;



    map<char, int> rep1, rep2;

    cin >> s >> t;

    for (auto &c : s)

    {

        rep1[c]++;

    }

    vector<int> mapOfS;

    for (auto &a : rep1)

    {

        mapOfS.push_back(a.second);

    }

    sort(mapOfS.begin(), mapOfS.end());



    for (auto &c : t)

    {

        rep2[c]++;

    }

    vector<int> mapOfT;

    for (auto &a : rep2)

    {

        mapOfT.push_back(a.second);

    }

    sort(mapOfT.begin(), mapOfT.end());



    if (mapOfS == mapOfT)

    {

        cout << "Yes";

    }

    else

    {

        cout << "No";

    }

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

const int N=200005;

struct node

{

	char a;

	char b;

}stringss[N];

int inc1(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.a-n.a;

}

int inc2(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.b-n.b;

}

int main()

{

	char str1[N],str2[N];

	scanf("%s",str1);

	scanf("%s",str2);

	int len=strlen(str1);

	for(int i=0;i<len;i++)

	{

		stringss[i].a=str1[i];

		stringss[i].b=str2[i];

	}

	qsort(stringss,len,sizeof(struct node),inc1);

	for(int i=0;i<len;i++)

	{

		if(stringss[i].a==stringss[i+1].a&&stringss[i].b!=stringss[i+1].b)

		{

			printf("No\n");

			return 0;

		}

	}

	qsort(stringss,len,sizeof(struct node),inc2);

	for(int i=0;i<len;i++)

	{

		if(stringss[i].b==stringss[i+1].b&&stringss[i].a!=stringss[i+1].a)

		{

			printf("No\n");

			return 0;

		}

	}

	printf("Yes\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<iostream>

#include<algorithm>

#include<cmath>

#include<cstring>

#include<string>

#include<map>

#include<set>

using namespace std;

int n,q,t,k,d,ans;

map <char,char> mp,mp2;

int num[1000];

bool vis[1000];

int main(){

    string a;

    string b;

    memset(num,-1,sizeof(num));

    cin>>a>>b;

    for(int i=0;i<a.size();i++)

    {

        if(num[a[i]]==-1)

        {

            num[a[i]]=b[i];

        }

        else

        {

            if(num[a[i]]!=b[i])

            {

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    memset(num,-1,sizeof(num));

    for(int i=0;i<a.size();i++)

    {

        if(num[b[i]]==-1)

        {

            num[b[i]]=a[i];

        }

        else

        {

            if(num[b[i]]!=a[i])

            {

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    cout<<"Yes"<<endl;

    return 0;

	}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<stdlib.h>

#include<string.h>

const int N=200005;

struct node

{

	char a;

	char b;

}stringss[N];

int inc1(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.a-n.a;

}

int inc2(const void *a, const void *b)

{

    struct node m = *(struct node *)a;

    struct node n = *(struct node *)b;

    return m.b-n.b;

}

int main()

{

	char str1[N],str2[N];

	scanf("%s",str1);

	scanf("%s",str2);

	int len=strlen(str1);

	for(int i=0;i<len;i++)

	{

		stringss[i].a=str1[i];

		stringss[i].b=str2[i];

	}

	qsort(stringss,len,sizeof(struct node),inc1);

	for(int i=0;i<len;i++)

	{

		if(stringss[i].a==stringss[i+1].a&&stringss[i].b!=stringss[i+1].b)

		{

			printf("No\n");

			return 0;

		}

	}

	qsort(stringss,len,sizeof(struct node),inc2);

	for(int i=0;i<len;i++)

	{

		if(stringss[i].b==stringss[i+1].b&&stringss[i].a!=stringss[i+1].a)

		{

			printf("No\n");

			return 0;

		}

	}

	printf("Yes\n");

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<bits/stdc++.h>

using namespace std;

const int maxn=1e5+7;

int num[maxn];

int main()

{

    string stra;

    string strb;

    cin>>stra>>strb;

    int len=stra.size();

    memset(num,-1,sizeof(num));

    for(int i=0;i<len;i++)

    {

        if(num[stra[i]]==-1)

        {

            num[stra[i]]=strb[i];

        }

        else

        {

            if(num[stra[i]]!=strb[i])

            {

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    memset(num,-1,sizeof(num));

    for(int i=0;i<len;i++)

    {

        if(num[strb[i]]==-1)

        {

            num[strb[i]]=stra[i];

        }

        else

        {

            if(num[strb[i]]!=stra[i])

            {

                cout<<"No"<<endl;

                return 0;

            }

        }

    }

    cout<<"Yes"<<endl;

    return 0;

}

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;



const int N=200000;



int len;

char s[N+5],t[N+5];

char s1[255],t1[255];



int main()

{

	scanf("%s %s",s+1,t+1);

	len=strlen(s+1);

	for(int i=1;i<=len;i++)

	{

		if( (!s1[s[i]] || s1[s[i]] == t[i]) && (!t1[t[i]] || t1[t[i]] == s[i]))

		{

			s1[s[i]] = t[i];

			t1[t[i]] = s[i];

		}

		else

		{

			puts("No");

			return 0;

		}

	}

	puts("Yes");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<map>

#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;

const int MAXN=200005;

int n;map<char,char>M1,M2;

char c1[MAXN],c2[MAXN];

int main(){

	scanf("%s%s",c1+1,c2+1);

	n=strlen(c1+1);

	for(int i=1;i<=n;i++){

		if(M1[c1[i]]&&M1[c1[i]]!=c2[i]){

			printf("No\n");return 0;

		}

		if(M2[c2[i]]&&M2[c2[i]]!=c1[i]){

			printf("No\n");return 0;

		}

		if(!M1[c1[i]]&&!M2[c2[i]]){

			M1[c1[i]]=c2[i];

			M2[c2[i]]=c1[i];

		}

	}

	printf("Yes\n");

}

/*

abcdefg

bcdefga

*/

// Optimized solution to the same problem (faster):
#include<cstdio>

#include<cstring>

#include<algorithm>

using namespace std;



const int N=200000;



int len;

char s[N+5],t[N+5];

char s1[255],t1[255];



int main()

{

	scanf("%s %s",s+1,t+1);

	len=strlen(s+1);

	for(int i=1;i<=len;i++)

	{

		if( (!s1[s[i]] || s1[s[i]] == t[i]) && (!t1[t[i]] || t1[t[i]] == s[i]))

		{

			s1[s[i]] = t[i];

			t1[t[i]] = s[i];

		}

		else

		{

			puts("No");

			return 0;

		}

	}

	puts("Yes");

	return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<cstdio>

#include<algorithm>

#include<cstring>

#include<map>

using namespace std;

char s[200002],t[200002];

map<char,char>ms,mt;

int main()

{

	scanf("%s%s",s,t);

	int len=strlen(s);

	for(int i=0;i<len;i++)

		if(ms[s[i]]&&ms[s[i]]!=t[i])

		{

			printf("No");

			return 0;

		}

		else	if(mt[t[i]]&&mt[t[i]]!=s[i])

				{

					printf("No");

					return 0;

				}

				else	if(!ms[s[i]]&&!mt[t[i]])

				{

					ms[s[i]]=t[i];

					mt[t[i]]=s[i];

				}

	printf("Yes");

}

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define N 200010

char s1[N],s2[N];

int a[30],b[30];

int main()

{

    int i,j,k;

    scanf("%s%s",s1,s2);

    k=strlen(s1);

    for(i=0;i<k;i++)

    {

        j=s1[i]-'a';

        a[j]++;

    }

    k=strlen(s2);

    for(i=0;i<k;i++)

    {

        j=s2[i]-'a';

        b[j]++;

    }

    sort(a,a+30);

    sort(b,b+30);

    for(i=0;i<30;i++)

    if(a[i]!=b[i])

    {

        printf("No\n");

        return 0;

    }

    printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
#include<iostream>

#include<cstdio>

#include<algorithm>

#include<cstring>

using namespace std;

#define MAXN 200000

char s[MAXN+5],t[MAXN+5];

int n;

int Ts[27],Ts2[27];

int main()

{

    scanf("%s%s",s+1,t+1);

    n=strlen(s+1);

    for(int i=1;i<=n;i++)

    {

        int A=s[i]-'a'+1,B=t[i]-'a'+1;

        if(Ts[B]==0)Ts[B]=A;

        else if(Ts[B]!=A){printf("No\n");return 0;}

        if(Ts2[A]==0)Ts2[A]=B;

        else if(Ts2[A]!=B){printf("No\n");return 0;}

    }

    printf("Yes");

}


// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define N 200010

char s1[N],s2[N];

int a[30],b[30];

int main()

{

    int i,j,k;

    scanf("%s%s",s1,s2);

    k=strlen(s1);

    for(i=0;i<k;i++)

    {

        j=s1[i]-'a';

        a[j]++;

    }

    k=strlen(s2);

    for(i=0;i<k;i++)

    {

        j=s2[i]-'a';

        b[j]++;

    }

    sort(a,a+30);

    sort(b,b+30);

    for(i=0;i<30;i++)

    if(a[i]!=b[i])

    {

        printf("No\n");

        return 0;

    }

    printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem:
// Original C++ solution (slower):
/*Lucky_Glass*/

#include<bits/stdc++.h>

using namespace std;

string A,B;

int totA[26],totB[26];

int main(){

	cin>>A>>B;

	for(int i=0;i<A.length();i++)

		totA[A[i]-'a']++;

	for(int i=0;i<B.length();i++)

		totB[B[i]-'a']++;

	sort(totA,totA+26);

	sort(totB,totB+26);

	for(int i=0;i<26;i++)

		if(totA[i]!=totB[i]){

			printf("No\n");

			return 0;

		}

	printf("Yes");

	return 0;

}//

// Optimized solution to the same problem (faster):
#include<stdio.h>

#include<string.h>

#include<algorithm>

using namespace std;

#define N 200010

char s1[N],s2[N];

int a[30],b[30];

int main()

{

    int i,j,k;

    scanf("%s%s",s1,s2);

    k=strlen(s1);

    for(i=0;i<k;i++)

    {

        j=s1[i]-'a';

        a[j]++;

    }

    k=strlen(s2);

    for(i=0;i<k;i++)

    {

        j=s2[i]-'a';

        b[j]++;

    }

    sort(a,a+30);

    sort(b,b+30);

    for(i=0;i<30;i++)

    if(a[i]!=b[i])

    {

        printf("No\n");

        return 0;

    }

    printf("Yes\n");

    return 0;

}

// Fastest known solution for this problem: