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

using namespace std;

int main(){

    int n, k;

    cin >> n >> k;

    int a;

    int last = 0;

    int ans = 0;

    int kol = 1;

    char s;

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

        cin >> s;

        if(s=='R')a=1;

        else a=0;

        if(i==0){

            last = a;

        }else{

            if(a!=last)kol++;

            else ans++;

            last = a;

        }

    }

    if(n>1 && k<n-1){

        if(kol>=2){

            if(k>=kol/2)cout<<n-1;

            else{

                ans+= 2*k;

                cout << ans ;

            }

        }else{

            cout << n-1;

        }

    }else{

        if(n == 1)cout << 0;

        else cout << n-1;

    }

}

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

#include <cstring>

using namespace std;

int min(int a, int b);

int main()

{

    char queue[100000];

    int happy_num = 0;

    int len, time;

    scanf("%d%d",&len, &time);

    scanf("%s", queue);

    for(int i = 0; i < strlen(queue);i++)

    {

        if((i != strlen(queue)-1)&&(queue[i+1] == 'R')&&(queue[i] == 'R'))

            happy_num++;

        else if((i!=0)&&(queue[i-1] == 'L')&&(queue[i] == 'L'))

            happy_num ++;

    }

    printf("%d", min((happy_num + 2*time), len -1));

    return 0;

}

int min(int a, int b)

{

    return (a>=b)?b:a;

}

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

#include<vector>

#include<algorithm>

#include<string>



using namespace std;



int main() {

	int n, k, ans = 0;

	cin >> n >> k;

	string s;

	cin >> s;

	vector<int> a(1, 1);

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

		if (s[i] == s[i - 1]) {

			a.back() += 1;

			ans += 1;

		}

		else {

			a.push_back(1);

		}

	}

	ans += min((int)a.size() - 1, 2 * k);

	cout << ans;

}

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

#include <cstring>

using namespace std;

int min(int a, int b);

int main()

{

    char queue[100000];

    int happy_num = 0;

    int len, time;

    scanf("%d%d",&len, &time);

    scanf("%s", queue);

    for(int i = 0; i < strlen(queue);i++)

    {

        if((i != strlen(queue)-1)&&(queue[i+1] == 'R')&&(queue[i] == 'R'))

            happy_num++;

        else if((i!=0)&&(queue[i-1] == 'L')&&(queue[i] == 'L'))

            happy_num ++;

    }

    printf("%d", min((happy_num + 2*time), len -1));

    return 0;

}

int min(int a, int b)

{

    return (a>=b)?b:a;

}

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

#include <string>

int main() {

    size_t      n, k;

    std::string s;

    std::cin >> n >> k >> s;

    size_t result = 0;

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

        if (s[i] == s[i - 1]) ++result;

    result += k << 1;

    std::cout << (result >= n ? n - 1 : result) << '\n';

    return 0;

}


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

#include <cstring>

using namespace std;

int min(int a, int b);

int main()

{

    char queue[100000];

    int happy_num = 0;

    int len, time;

    scanf("%d%d",&len, &time);

    scanf("%s", queue);

    for(int i = 0; i < strlen(queue);i++)

    {

        if((i != strlen(queue)-1)&&(queue[i+1] == 'R')&&(queue[i] == 'R'))

            happy_num++;

        else if((i!=0)&&(queue[i-1] == 'L')&&(queue[i] == 'L'))

            happy_num ++;

    }

    printf("%d", min((happy_num + 2*time), len -1));

    return 0;

}

int min(int a, int b)

{

    return (a>=b)?b:a;

}

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

#include <iostream>

#include <algorithm>





using namespace std;



int main(){

	int n, k, c = 0, an, i;

	char s[100005] = { '\0' };

	

	cin >> n >> k;

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

		cin >> s[i];

	}

	int count = 0;

	i = 0;

	if (s[i] == 'R'&&s[i + 1] == 'R') count++;

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

		if (s[i] == 'L'&&s[i - 1] == 'L') count++;

		if (s[i] == 'R'&&s[i + 1] == 'R') count++;

	}

	if (s[i] == 'L'&&s[i - 1] == 'L') count++;

//	for(i = 0; i < n-1; i++){

//		if (s[i] != s[i + 1]) c++;

//	}

//	cout << count << endl;

	an = min((count + 2 * k), (n - 1));

	cout << an;

	system("pause");

	return 0;

}

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

#include <cstring>

using namespace std;

int min(int a, int b);

int main()

{

    char queue[100000];

    int happy_num = 0;

    int len, time;

    scanf("%d%d",&len, &time);

    scanf("%s", queue);

    for(int i = 0; i < strlen(queue);i++)

    {

        if((i != strlen(queue)-1)&&(queue[i+1] == 'R')&&(queue[i] == 'R'))

            happy_num++;

        else if((i!=0)&&(queue[i-1] == 'L')&&(queue[i] == 'L'))

            happy_num ++;

    }

    printf("%d", min((happy_num + 2*time), len -1));

    return 0;

}

int min(int a, int b)

{

    return (a>=b)?b:a;

}

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

using namespace std;

int n,k,t;

char c[100010];

int main(){

	scanf("%d%d%s",&n,&k,c+1);

	for(int i=2;i<=n;++i)t+=c[i]!=c[i-1];

	printf("%d",n-1-max(0,t-(k<<1)));

	return 0;

}

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

#include <cstring>

using namespace std;

int min(int a, int b);

int main()

{

    char queue[100000];

    int happy_num = 0;

    int len, time;

    scanf("%d%d",&len, &time);

    scanf("%s", queue);

    for(int i = 0; i < strlen(queue);i++)

    {

        if((i != strlen(queue)-1)&&(queue[i+1] == 'R')&&(queue[i] == 'R'))

            happy_num++;

        else if((i!=0)&&(queue[i-1] == 'L')&&(queue[i] == 'L'))

            happy_num ++;

    }

    printf("%d", min((happy_num + 2*time), len -1));

    return 0;

}

int min(int a, int b)

{

    return (a>=b)?b:a;

}

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

#include <cstring>

#include <cstdio>

#include <cmath>

#include <algorithm>

#include <vector>

using namespace std;

#define fir first

#define sec second

#define pb push_back

#define lowbit(x) ((x)&(-(x))) 



int n, k; 

string s; 



int main() {

	cin>>n>>k>>s; ;

	int num = 1;  

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

		if (s[i] != s[i-1]) num++; 

	cout<<n-max(1,(num-2*k))<<endl;  

}


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

#include <cstring>

using namespace std;

int min(int a, int b);

int main()

{

    char queue[100000];

    int happy_num = 0;

    int len, time;

    scanf("%d%d",&len, &time);

    scanf("%s", queue);

    for(int i = 0; i < strlen(queue);i++)

    {

        if((i != strlen(queue)-1)&&(queue[i+1] == 'R')&&(queue[i] == 'R'))

            happy_num++;

        else if((i!=0)&&(queue[i-1] == 'L')&&(queue[i] == 'L'))

            happy_num ++;

    }

    printf("%d", min((happy_num + 2*time), len -1));

    return 0;

}

int min(int a, int b)

{

    return (a>=b)?b:a;

}

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

#include<string>

#include<malloc.h>



using namespace std;



int ishappy(string s,int k){

	int len=s.size();

	char direction=s[k];

	if(direction=='L'){

		if(k==0) return 0;

		char front=s[k-1];

		if(front=='L') return 1;

	}

	if(direction=='R'){

		if(k==len-1) return 0;

		char front=s[k+1];

		if(front=='R') return 1;

	}

	return 0;

}



int Cal(string s){

	int sum=0;

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

	    sum+=ishappy(s,i);

	return sum;

}



int main(){

	

    int N,K,MAX;

    string S; 

    cin>>N>>K>>S;

    MAX=Cal(S); 

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

	 if(MAX==N-1)  break;

	 if(MAX==N-2)  {

	     MAX+=1;

	     break;

	 }

     MAX+=2;

	}

	

    cout<<MAX<<endl;

    return 0;

}

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

#include<cstring>

char ren[1000000];

int main()

{

	int n,k;

	scanf("%d %d",&n,&k);

	int xf=0;

	int j2=0;

	scanf("%s",&ren); 

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

	{

		if(ren[i]==ren[i-1])

		xf++;

	}

//	printf("xf%d\n",xf);

	if(xf+2*k>n-1)

	xf=n-1;

	else

	xf=xf+2*k;

	

	printf("%d",xf);

}

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

#include<string>

#include<algorithm>

#define INF 500050

#define Max 1e9

using namespace std;

int r,l,c;

int n,k,ans=0;

string s;

char ch;

bool flag = false;

int main()

{

	cin>>n>>k;

	cin>>s;

	int t = 0;

	for(int i=0; i<s.length()&&k; i++) {

		if(s[i]=='L'&&s[i+1] == 'R') {

			int pi = i+1;

			while(s[pi]=='R'&&pi<s.length()) 

			{

				s[pi]='L';

				pi++;

			}

				k--;

		}

		if(s[i]=='R'&&s[i+1] == 'L') {

			int pi = i+1;

			while(s[pi]=='L'&&pi<s.length()) 

			{

				s[pi]='R';

				pi++;

			}

			k--;

		}

	}

	

	

	for(int i=1; i<s.length(); i++) {

		if(s[i] == s[i-1])	ans++;

	}



	ans=min(ans,n-1);

	cout << ans <<endl; 

	

	

	return 0;

}

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

#include<cstring>

char ren[1000000];

int main()

{

	int n,k;

	scanf("%d %d",&n,&k);

	int xf=0;

	int j2=0;

	scanf("%s",&ren); 

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

	{

		if(ren[i]==ren[i-1])

		xf++;

	}

//	printf("xf%d\n",xf);

	if(xf+2*k>n-1)

	xf=n-1;

	else

	xf=xf+2*k;

	

	printf("%d",xf);

}

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

#include<algorithm>

#include<math.h>

#include<string>

#include<iostream>

#include<vector>

#include<cstdlib>

using namespace std;

 

template <class T> using V = vector<T>;

 

template<class T> inline bool chmin(T& a, T b) {

    if (a > b) {

        a = b;

        return true;

    }

    return false;

}

template<class T> inline bool chmax(T& a, T b) {

    if (a < b) {

        a = b;

        return true;

    }

    return false;

}

 

const long long INF = 1LL << 60;

 

using ll = long long;

using db = double;

using st = string;

using ch = char;

using bl = bool;

using vll = V<ll>;

using vpll =V<pair<ll,ll>>;

using vst = V<st>;

using vdb = V<db>;

using vch = V<ch>;

using vbl = V<bl>;

 

 

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)

#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)

#define bgn begin()

#define en end()

#define SORT(a) sort((a).bgn,(a).en)

#define REV(a) reverse((a).bgn,(a).en)

#define M(a,b) max(a,b)

#define rM(a,b) min(a,b)

#define fi first

#define se second

#define sz size()

#define gcd(a,b) __gcd(a,b)

#define co(a) cout<<a<<endl;

#define ci(a) cin>>a;

 



vll dp(100100);



ll sum(ll n) {

ll m=0;

  FOR(i,0,20){

    m+=n%10;

    n/=10;

    if(n==0){

      break;

    }

  }

  return m;

}

 

 

const int MAX = 510000;

const int MOD = 1000000007;

 

long long fac[MAX], finv[MAX], inv[MAX];

 

void Comuse() {

    fac[0] = fac[1] = 1;

    finv[0] = finv[1] = 1;

    inv[1] = 1;

    for (int i = 2; i < MAX; i++){

        fac[i] = fac[i - 1] * i % MOD;

        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;

        finv[i] = finv[i - 1] * inv[i] % MOD;

    }

}

 

 

#define comuse Comuse()

 

ll combi(int n, int k){

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;

}

 

 

 

 

ll lcm(ll a,ll b){

  ll n;

  n=a/gcd(a,b)*b;

  return n;

}





 

/****************************************\

| Thank you for viewing my code:)        |

| Written by RedSpica a.k.a. RanseMirage |

| Twitter:@asakaakasaka                  | 

\****************************************/

 

 

signed main() {

  ll n,k;

    ci(n>>k);

  st s;

    ci(s);

  vll A;

  ll count=1;

  FOR(i,1,n-1){

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

      A.push_back(count);

      count=1;

    }

    else{

      count++;

    }

  }



  if(s[n-1]!=s[n-2]){

    A.push_back(count);

    A.push_back(1);

  }

  else{

    A.push_back(count+1);

  }



  ll a=A.sz;

  ll ans=0;

  FOR(i,0,a){

    ans+=A[i]-1;

  }

  ans+=2*k; 

  co(min(n-1,ans))

  }


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

using namespace std;

 

int main() {

  int N,K;

  string S;

  cin >> N >> K >> S;

  int count=1;

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

    if(S[i] != S[i-1]) count ++;

  }

  cout <<N+min(-1,-count+2*K)<<endl;

}


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

#include<algorithm>

#include<math.h>

#include<string>

#include<iostream>

#include<vector>

#include<cstdlib>

using namespace std;

 

template <class T> using V = vector<T>;

 

template<class T> inline bool chmin(T& a, T b) {

    if (a > b) {

        a = b;

        return true;

    }

    return false;

}

template<class T> inline bool chmax(T& a, T b) {

    if (a < b) {

        a = b;

        return true;

    }

    return false;

}

 

const long long INF = 1LL << 60;

 

using ll = long long;

using db = double;

using st = string;

using ch = char;

using bl = bool;

using vll = V<ll>;

using vpll =V<pair<ll,ll>>;

using vst = V<st>;

using vdb = V<db>;

using vch = V<ch>;

using vbl = V<bl>;

 

 

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)

#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)

#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)

#define bgn begin()

#define en end()

#define SORT(a) sort((a).bgn,(a).en)

#define REV(a) reverse((a).bgn,(a).en)

#define M(a,b) max(a,b)

#define rM(a,b) min(a,b)

#define fi first

#define se second

#define sz size()

#define gcd(a,b) __gcd(a,b)

#define co(a) cout<<a<<endl;

#define ci(a) cin>>a;

 



vll dp(100100);



ll sum(ll n) {

ll m=0;

  FOR(i,0,20){

    m+=n%10;

    n/=10;

    if(n==0){

      break;

    }

  }

  return m;

}

 

 

const int MAX = 510000;

const int MOD = 1000000007;

 

long long fac[MAX], finv[MAX], inv[MAX];

 

void Comuse() {

    fac[0] = fac[1] = 1;

    finv[0] = finv[1] = 1;

    inv[1] = 1;

    for (int i = 2; i < MAX; i++){

        fac[i] = fac[i - 1] * i % MOD;

        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;

        finv[i] = finv[i - 1] * inv[i] % MOD;

    }

}

 

 

#define comuse Comuse()

 

ll combi(int n, int k){

    if (n < k) return 0;

    if (n < 0 || k < 0) return 0;

    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;

}

 

 

 

 

ll lcm(ll a,ll b){

  ll n;

  n=a/gcd(a,b)*b;

  return n;

}





 

/****************************************\

| Thank you for viewing my code:)        |

| Written by RedSpica a.k.a. RanseMirage |

| Twitter:@asakaakasaka                  | 

\****************************************/

 

 

signed main() {

  ll n,k;

    ci(n>>k);

  st s;

    ci(s);



  ll count=1;

  FOR(i,1,n-1){

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

      count++;

    }

  }



  if(s[n-1]!=s[n-2]){

    count++;

  }



  ll ans=n-count+2*k;



  co(min(n-1,ans))

  }

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

using namespace std;

 

int main() {

  int N,K;

  string S;

  cin >> N >> K >> S;

  int count=1;

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

    if(S[i] != S[i-1]) count ++;

  }

  cout <<N+min(-1,-count+2*K)<<endl;

}


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



using namespace std;



#define ll long long



const int INF = 1e9+9999;



int main()

{

    ios::sync_with_stdio(0);

    cin.tie(0);

    int n, k, arr=0;

    string s;

    cin >> n >> k >> s;

    s.push_back('W');

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

        if (s[i] != s[i+1])

            ++arr;

    int ans = n - arr;

    while (k && arr) {

        if (arr == 2)

            ++ans, ++arr;

        else

            ans+=2;

        --k;

        arr-=2;

    }

    cout << min(ans, n-1);

}


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

#include <algorithm>



using std::min;



const int MAXN=100005;



int main()

{

    int N,K,diffs=0;

    char str[MAXN];



    scanf("%d%d%s",&N,&K,str);



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

        if (str[i]!=str[i-1]) diffs++;

    printf("%d",min(N-1-diffs+2*K,N-1));



    return 0;

}


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

using namespace std;

int a[100100];

int main()

{

	int n,k;

	int i,j;

	cin>>n>>k;

	int t=1;

	getchar();

	while(t<=n){

		char x;

		x=getchar();

		if(x=='L') a[t]=1;

		else if(x=='R')a[t]=2;

		t++;

	}

	int pre=a[1];

	int cnt=1;

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

		if(a[i]==pre) continue;

		else if(a[i]!=pre&&i!=n){

			pre=a[i];

			cnt++;

		}

		else cnt+=1;

	}

	cnt-=k*2;

	if(cnt<=0)cout<<n-1<<endl;

	else cout<<n-cnt<<endl;

} 

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

#include <algorithm>



using std::min;



const int MAXN=100005;



int main()

{

    int N,K,diffs=0;

    char str[MAXN];



    scanf("%d%d%s",&N,&K,str);



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

        if (str[i]!=str[i-1]) diffs++;

    printf("%d",min(N-1-diffs+2*K,N-1));



    return 0;

}


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

using namespace std;

int main(){

	ios::sync_with_stdio(0);

	string str;

	string tmp;

	while(cin>>str){

		cin>>tmp;

		reverse(str.begin(),str.end());

		if(str==tmp) cout<<"YES"<<endl;

		else cout<<"NO"<<endl;

	}

}

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



int main(){

	

	char board[5][5];

	

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

		for(int j=0;j<3;j++){

			scanf("%c",&board[i][j]);

		}

		getchar();

	}

	

	if(board[0][0] == board[1][2] && board[1][0] == board[0][2] && board[0][1] == board[1][1]){

		printf("YES\n");

	}else{

		printf("NO\n");

	}

	

}

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

#include <cstdio>

#include <cstring>

#include <algorithm>

#include <string>

#include <cmath>

#include <map>

#include <set>

#include <vector>

#include <iterator>

#include <list>

#include <stack>

#include <queue>

#include <cstdlib>

using namespace std;



int main()

{

    string a,b,c;

    cin >> a >> b;

    int flag = 0;

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

    {

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

        {

            flag = 1;

            break;

        }

    }

    if(flag == 0) cout << "YES" << endl;

    else cout << "NO" << endl;

    return 0;

}


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



int main(){

	

	char board[5][5];

	

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

		for(int j=0;j<3;j++){

			scanf("%c",&board[i][j]);

		}

		getchar();

	}

	

	if(board[0][0] == board[1][2] && board[1][0] == board[0][2] && board[0][1] == board[1][1]){

		printf("YES\n");

	}else{

		printf("NO\n");

	}

	

}

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

#include <queue>

#include <cstdio>

#include <cstdlib>

#include <algorithm>

#include <cstring>

using namespace std;

char a[10][10];

int main()

{

    int f=0;

    scanf("%s",a[1]);

    scanf("%s",a[2]);

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

    {

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

        {

            f=1;

        }

        else

        {

            f=0;

            break;

        }

    }

    if(f==1)

        printf("YES\n");

    else

    {

        printf("NO\n");

    }

    return 0;

}




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



int main(){

	

	char board[5][5];

	

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

		for(int j=0;j<3;j++){

			scanf("%c",&board[i][j]);

		}

		getchar();

	}

	

	if(board[0][0] == board[1][2] && board[1][0] == board[0][2] && board[0][1] == board[1][1]){

		printf("YES\n");

	}else{

		printf("NO\n");

	}

	

}

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

using namespace std;



bool same(char *top, char *bottom) {

	int length = ((string) top).length();

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

		if (top[i] != bottom[length - i - 1]) return false;

	}

	

	return true;

}



int main() {

	char top[5], bottom[5];

	scanf("%s\n%s", top, bottom);

	printf("%s", same(top, bottom) ? "YES" : "NO");

	return 0;

}

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



int main(){

	

	char board[5][5];

	

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

		for(int j=0;j<3;j++){

			scanf("%c",&board[i][j]);

		}

		getchar();

	}

	

	if(board[0][0] == board[1][2] && board[1][0] == board[0][2] && board[0][1] == board[1][1]){

		printf("YES\n");

	}else{

		printf("NO\n");

	}

	

}

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

#include <cstring>

#include <stack>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <cstdio>

#include <algorithm>

#include <string>

#include <iomanip>

using namespace std;

int main()

{

    char c[10][10];

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

    {

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

        {

            scanf("%c",&c[i][j]);

        }

    }

    if(c[1][1]==c[2][3]&&c[1][2]==c[2][2]&&c[1][3]==c[2][1])

    {

        printf("YES\n");

    }

    else printf("NO\n");

    return 0;

}


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

#include <cstdlib>

#include <cstring>

using namespace std;

int main()

{

    char a[10]={'\0'},b[10]={'\0'},c[10]={'\0'};

        int i,j;

        scanf("%s",&a);

        scanf("%s",&b);;

        if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])

            printf("YES\n");

        else

            printf("NO\n");

  return 0;

}


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

#include <cstring>

#include <stack>

#include <cstdlib>

#include <queue>

#include <cmath>

#include <cstdio>

#include <algorithm>

#include <string>

#include <vector>

#include <list>

#include <iterator>

#include <set>

#include <map>

#include <utility>

#include <iomanip>

#include <ctime>

#include <sstream>

#include <bitset>

#include <deque>

#include <limits>

#include <numeric>

#include <functional>

#define gc getchar()

#define mem(a) memset(a,0,sizeof(a))

#define mod 1000000007

#define sort(a,n,int) sort(a,a+n,less<int>())

using namespace std;

typedef long long ll;

typedef char ch;

typedef double db;

using namespace std;

ch a[5][10];

int main()

{

    while(~scanf("%s",a[0]))

    {

        scanf("%s",a[1]);

        if(a[0][0] == a[1][2] && a[0][1] == a[1][1] && a[0][2] == a[1][0])

        {

            cout<<"YES"<<endl;

        }

        else

        {

            cout<<"NO"<<endl;

        }

    }

    return 0;

}

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

#include <cstdlib>

#include <cstring>

using namespace std;

int main()

{

    char a[10]={'\0'},b[10]={'\0'},c[10]={'\0'};

        int i,j;

        scanf("%s",&a);

        scanf("%s",&b);;

        if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])

            printf("YES\n");

        else

            printf("NO\n");

  return 0;

}


// Fastest known solution for this problem: