stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.356242792696644x):
#include <stdio.h>

#include <string.h>

int main(){

char a[101],b[101],c[101],m,n;

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

m=strlen(a);

n=strlen(b);

if(a[m-1]==b[0]&&b[n-1]==c[0]){

	printf("YES");

}

else{

	printf("NO");

}

return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.352078078913963x):
#include <stdio.h>

#include <string.h>

int main(){

char a[101],b[101],c[101],m,n;

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

m=strlen(a);

n=strlen(b);

if(a[m-1]==b[0]&&b[n-1]==c[0]){

	printf("YES");

}

else{

	printf("NO");

}

return 0;

}
// Slower C++ solution:
#include<iostream>

#include <cstring>

#include<stdio.h>

#include <cctype>



using namespace std;



char s1[11],s2[11],s3[11];

int a,b,c,j,k,loop,i,temp = 0;



int main()

{

    cin>>s1;

    cin>>s2;

    cin>>s3;



    a = strlen(s1);

    b = strlen(s2);

    c = strlen(s3);



    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)

    {

            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])

            {

                printf("YES\n");

            }

            else

            {

                printf("NO\n");

            }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.300162555295813x):
#include <stdio.h>

#include <string.h>

 

int main(){

	char a[11], b[11], c[11];

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

	int lena=strlen(a);

	int lenb=strlen(b);

	

	if(a[lena-1]==b[0] && b[lenb-1] == c[0]){

		printf("YES");

	}

	else {

		printf("NO");

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

    char a[11],b[11],c[11];

    char n,m,p,q;

    cin>>a>>b>>c;





    n=a[strlen(a)-1];

    m=b[0];

    p=b[strlen(b)-1];

    q=c[0];



    if(n==m && p==q)

    {

        cout<<"YES"<<endl;

    }

    else

    {



        cout<<"NO"<<endl;



    }







    return 0;





}

// Faster C++ solution for the same problem (measured speedup: 5.32326030515776x):
#include <stdio.h>

#include <string.h>

 

int main(){

	char a[11], b[11], c[11];

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

	int lena=strlen(a);

	int lenb=strlen(b);

	

	if(a[lena-1]==b[0] && b[lenb-1] == c[0]){

		printf("YES");

	}

	else {

		printf("NO");

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    string a,b,c;

    cin>>a>>b>>c;



    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])

        cout<<"YES";

    else

        cout<<"NO";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.349798854051079x):
#include <stdio.h>

#include <string.h>

 

int main(){

	char a[11], b[11], c[11];

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

	int lena=strlen(a);

	int lenb=strlen(b);

	

	if(a[lena-1]==b[0] && b[lenb-1] == c[0]){

		printf("YES");

	}

	else {

		printf("NO");

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.3531729568751x):
#include <stdio.h>

#include <string.h>

 

int main(){

	char a[11], b[11], c[11];

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

	int lena=strlen(a);

	int lenb=strlen(b);

	

	if(a[lena-1]==b[0] && b[lenb-1] == c[0]){

		printf("YES");

	}

	else {

		printf("NO");

	}

	

	return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.349010630024463x):
#include <stdio.h>

#include <string.h>

 

int main(){

	char a[11], b[11], c[11];

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

	int lena=strlen(a);

	int lenb=strlen(b);

	

	if(a[lena-1]==b[0] && b[lenb-1] == c[0]){

		printf("YES");

	}

	else {

		printf("NO");

	}

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include <cstring>

#include<stdio.h>

#include <cctype>



using namespace std;



char s1[11],s2[11],s3[11];

int a,b,c,j,k,loop,i,temp = 0;



int main()

{

    cin>>s1;

    cin>>s2;

    cin>>s3;



    a = strlen(s1);

    b = strlen(s2);

    c = strlen(s3);



    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)

    {

            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])

            {

                printf("YES\n");

            }

            else

            {

                printf("NO\n");

            }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.338101734614963x):
#include<stdio.h>

 

int main(){

  char a[100];

  scanf("%[^\n]", a);

	int ctr = 0;

	

  for(int i= 0; a[i] != '\0'; i++){

    if(a[i] == ' '){

		if(a[i - 1] == a[i + 1]){

			ctr++;

		}

    }

  }

  if(ctr == 2){

  	printf("YES\n");

  }

  else{

  	printf("NO\n");

  }

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

    char a[11],b[11],c[11];

    char n,m,p,q;

    cin>>a>>b>>c;





    n=a[strlen(a)-1];

    m=b[0];

    p=b[strlen(b)-1];

    q=c[0];



    if(n==m && p==q)

    {

        cout<<"YES"<<endl;

    }

    else

    {



        cout<<"NO"<<endl;



    }







    return 0;





}

// Faster C++ solution for the same problem (measured speedup: 5.361364820853811x):
#include<stdio.h>

 

int main(){

  char a[100];

  scanf("%[^\n]", a);

	int ctr = 0;

	

  for(int i= 0; a[i] != '\0'; i++){

    if(a[i] == ' '){

		if(a[i - 1] == a[i + 1]){

			ctr++;

		}

    }

  }

  if(ctr == 2){

  	printf("YES\n");

  }

  else{

  	printf("NO\n");

  }

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    string a,b,c;

    cin>>a>>b>>c;



    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])

        cout<<"YES";

    else

        cout<<"NO";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.388093335763233x):
#include<stdio.h>

 

int main(){

  char a[100];

  scanf("%[^\n]", a);

	int ctr = 0;

	

  for(int i= 0; a[i] != '\0'; i++){

    if(a[i] == ' '){

		if(a[i - 1] == a[i + 1]){

			ctr++;

		}

    }

  }

  if(ctr == 2){

  	printf("YES\n");

  }

  else{

  	printf("NO\n");

  }

  return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.391491590807257x):
#include<stdio.h>

 

int main(){

  char a[100];

  scanf("%[^\n]", a);

	int ctr = 0;

	

  for(int i= 0; a[i] != '\0'; i++){

    if(a[i] == ' '){

		if(a[i - 1] == a[i + 1]){

			ctr++;

		}

    }

  }

  if(ctr == 2){

  	printf("YES\n");

  }

  else{

  	printf("NO\n");

  }

  return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.387299469537462x):
#include<stdio.h>

 

int main(){

  char a[100];

  scanf("%[^\n]", a);

	int ctr = 0;

	

  for(int i= 0; a[i] != '\0'; i++){

    if(a[i] == ' '){

		if(a[i - 1] == a[i + 1]){

			ctr++;

		}

    }

  }

  if(ctr == 2){

  	printf("YES\n");

  }

  else{

  	printf("NO\n");

  }

  return 0;

}
// Slower C++ solution:
#include<iostream>

#include <cstring>

#include<stdio.h>

#include <cctype>



using namespace std;



char s1[11],s2[11],s3[11];

int a,b,c,j,k,loop,i,temp = 0;



int main()

{

    cin>>s1;

    cin>>s2;

    cin>>s3;



    a = strlen(s1);

    b = strlen(s2);

    c = strlen(s3);



    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)

    {

            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])

            {

                printf("YES\n");

            }

            else

            {

                printf("NO\n");

            }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.316382400715368x):
#include<stdio.h>

#include<string.h>



int main()

{

 char a[255];

 char b[255];

 char c[255];

 scanf("%s %s %s", a, b, c);

 int len = strlen(a);

 int n = strlen(b);

 int s = strlen(c);

 if (a[len - 1] == b[0] && b[n - 1] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

  }

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

    char a[11],b[11],c[11];

    char n,m,p,q;

    cin>>a>>b>>c;





    n=a[strlen(a)-1];

    m=b[0];

    p=b[strlen(b)-1];

    q=c[0];



    if(n==m && p==q)

    {

        cout<<"YES"<<endl;

    }

    else

    {



        cout<<"NO"<<endl;



    }







    return 0;





}

// Faster C++ solution for the same problem (measured speedup: 5.339550835566387x):
#include<stdio.h>

#include<string.h>



int main()

{

 char a[255];

 char b[255];

 char c[255];

 scanf("%s %s %s", a, b, c);

 int len = strlen(a);

 int n = strlen(b);

 int s = strlen(c);

 if (a[len - 1] == b[0] && b[n - 1] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

  }

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    string a,b,c;

    cin>>a>>b>>c;



    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])

        cout<<"YES";

    else

        cout<<"NO";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.366170599168918x):
#include<stdio.h>

#include<string.h>



int main()

{

 char a[255];

 char b[255];

 char c[255];

 scanf("%s %s %s", a, b, c);

 int len = strlen(a);

 int n = strlen(b);

 int s = strlen(c);

 if (a[len - 1] == b[0] && b[n - 1] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

  }

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.369555027605723x):
#include<stdio.h>

#include<string.h>



int main()

{

 char a[255];

 char b[255];

 char c[255];

 scanf("%s %s %s", a, b, c);

 int len = strlen(a);

 int n = strlen(b);

 int s = strlen(c);

 if (a[len - 1] == b[0] && b[n - 1] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

  }

	

	return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.36537996297631x):
#include<stdio.h>

#include<string.h>



int main()

{

 char a[255];

 char b[255];

 char c[255];

 scanf("%s %s %s", a, b, c);

 int len = strlen(a);

 int n = strlen(b);

 int s = strlen(c);

 if (a[len - 1] == b[0] && b[n - 1] == c[0]){

  puts("YES");

 }

 else{

  puts("NO");

  }

	

	return 0;

}
// Slower C++ solution:
#include<iostream>

#include <cstring>

#include<stdio.h>

#include <cctype>



using namespace std;



char s1[11],s2[11],s3[11];

int a,b,c,j,k,loop,i,temp = 0;



int main()

{

    cin>>s1;

    cin>>s2;

    cin>>s3;



    a = strlen(s1);

    b = strlen(s2);

    c = strlen(s3);



    if(a>0 && a<=10 && b>0 && b<=10 && c>0 &&c <=10)

    {

            if(s1[a-1]==s2[0] && s2[b-1]==s3[0])

            {

                printf("YES\n");

            }

            else

            {

                printf("NO\n");

            }

    }

}


// Faster C++ solution for the same problem (measured speedup: 5.312973969596665x):
#include <stdio.h>

#include <string.h>



int main (){

	char a[100];

	char b[100];

	char c[100];

	scanf("%s %s %s", a, b, c);

	

	int A = strlen(a);

	int B = strlen (b);

	

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

		if ( a[A - 1] == b[0] && b[B - 1]== c[0]){

			puts ("YES");

			break;

		}

		else{

			puts ("NO");

			break;

		}

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>



using namespace std;



int main()

{

    char a[11],b[11],c[11];

    char n,m,p,q;

    cin>>a>>b>>c;





    n=a[strlen(a)-1];

    m=b[0];

    p=b[strlen(b)-1];

    q=c[0];



    if(n==m && p==q)

    {

        cout<<"YES"<<endl;

    }

    else

    {



        cout<<"NO"<<endl;



    }







    return 0;





}

// Faster C++ solution for the same problem (measured speedup: 5.336127550735448x):
#include <stdio.h>

#include <string.h>



int main (){

	char a[100];

	char b[100];

	char c[100];

	scanf("%s %s %s", a, b, c);

	

	int A = strlen(a);

	int B = strlen (b);

	

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

		if ( a[A - 1] == b[0] && b[B - 1]== c[0]){

			puts ("YES");

			break;

		}

		else{

			puts ("NO");

			break;

		}

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

using namespace std;

int main()

{

    string a,b,c;

    cin>>a>>b>>c;



    if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0])

        cout<<"YES";

    else

        cout<<"NO";

    return 0;

}


// Faster C++ solution for the same problem (measured speedup: 5.3627302479150245x):
#include <stdio.h>

#include <string.h>



int main (){

	char a[100];

	char b[100];

	char c[100];

	scanf("%s %s %s", a, b, c);

	

	int A = strlen(a);

	int B = strlen (b);

	

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

		if ( a[A - 1] == b[0] && b[B - 1]== c[0]){

			puts ("YES");

			break;

		}

		else{

			puts ("NO");

			break;

		}

	}

	

	return 0;

}
// Slower C++ solution:
#include<bits/stdc++.h>

#include <iostream>

using namespace std;

int main()

{ 

      string c,d,e;

       

      cin>>c>>d>>e;

 

      

      

        int n = c.length(); 

    char g[n + 1]; 

    strcpy(g, c.c_str()); 

    

     int m = d.length(); 

    char h[m + 1]; 

    strcpy(h, d.c_str()); 

    

    

     int o = e.length(); 

    char k[o + 1]; 

    strcpy(k, e.c_str()); 



     if((g[n-1]==h[0])&&(h[m-1]==k[0]))

        cout<<"YES";



     else  cout<<"NO";

     

   return 0;



}

// Faster C++ solution for the same problem (measured speedup: 5.366112506532142x):
#include <stdio.h>

#include <string.h>



int main (){

	char a[100];

	char b[100];

	char c[100];

	scanf("%s %s %s", a, b, c);

	

	int A = strlen(a);

	int B = strlen (b);

	

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

		if ( a[A - 1] == b[0] && b[B - 1]== c[0]){

			puts ("YES");

			break;

		}

		else{

			puts ("NO");

			break;

		}

	}

	

	return 0;

}
// Slower C++ solution:


#include<bits/stdc++.h>

#define lln long long int

#define llu unsigned lln

#define sc(n) scanf("%d",&n);

#define scl(n) scanf("%lld",&n);

#define scd(n) scanf("%lf",&n);

#define pf(res) printf("%d\n",res);

#define pfl(res) printf("%lld\n",res);

#define pfd(res) printf("%lf\n",res);

#define maxii 100005

using namespace std;

typedef pair<int,int> pii;

typedef pair<lln,lln> pll;

typedef vector<int> vi;

typedef vector<lln> vl;

typedef vector<pii> vii;

typedef vector<pll> vll;





int arr[maxii];

int arr2[maxii];

int gcd(int a,int b)

{

    if(b==0){

      return a;

     }

    return gcd(b,a%b);

}

int lcm(int a,int b)

{

    int res=(a*b)/gcd(a,b);

    return res;

}

int po(int a,int b)

{

    int res=1;

    while(b)

    {

        if(b%2!=0)

        {

            res*=a;

            b--;

        }

        else

        {

            a*=a;

            b/=2;

        }

    }

    return res;

}



lln modMul(lln  a, lln b,lln mod){

    lln ans = 0;

    a = a % mod;

    while (b > 0){

        if ( b % 2 )ans = (ans%mod+ a%mod) % mod;

        a = (a%mod * 2%mod) % mod;

        b /= 2;

    }

    return ans % mod;

}

lln powerMod(lln a,lln b,lln mod){

	if(b==0)return 1LL%mod;

	lln x=powerMod( a,b/2,mod );

	x = ( x%mod * x%mod ) % mod;

	if( b%2==1 )x = ( x%mod * a%mod ) % mod;

	return x%mod;

}



int main()

{

   string a,b,c;

   cin>>a>>b>>c;

   int len=a.size();

   int len2=b.size();

   int len3=c.size();

   if(a[len-1]==b[0] && b[len2-1]==c[0] )cout<<"YES\n";

   else cout<<"NO";



}










// Faster C++ solution for the same problem (measured speedup: 5.361940118613908x):
#include <stdio.h>

#include <string.h>



int main (){

	char a[100];

	char b[100];

	char c[100];

	scanf("%s %s %s", a, b, c);

	

	int A = strlen(a);

	int B = strlen (b);

	

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

		if ( a[A - 1] == b[0] && b[B - 1]== c[0]){

			puts ("YES");

			break;

		}

		else{

			puts ("NO");

			break;

		}

	}

	

	return 0;

}