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

#include<string.h>

using namespace std;



main() {

    char A[100],B[100],C[100];

    int a,b,c;

    cin>>A;

    cin>>B;

    cin>>C;



    a=strlen(A);

    b=strlen(B);

    c=strlen(C);



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

        cout<<"YES";

    else

        cout<<"NO";

}

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

#include <string.h>

int main(){

    char str1[11], str2[11], str3[11];

    scanf("%s %s %s", str1, str2, str3);



    if(str1[strlen(str1)-1] == str2[0] && str2[strlen(str2)-1] == str3[0]){

        puts("YES");

    } else{

        puts("NO");

    }





    return 0;

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

#include<string.h>

using namespace std;



main() {

    char A[100],B[100],C[100];

    int a,b,c;

    cin>>A;

    cin>>B;

    cin>>C;



    a=strlen(A);

    b=strlen(B);

    c=strlen(C);



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

        cout<<"YES";

    else

        cout<<"NO";

}

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

#include <string.h>



int main(){

	char x[105];

	char y[105];

	char z[105];

	int a,b;

	scanf("%s %s %s", &x,&y,&z);

	a = strlen(x)-1;

	b = strlen(y)-1;

	if ( x[a]== y[0] && y[b]==z[0]){

		printf("YES\n");

	}	

	else{

		printf("NO\n");

	}

	return 0;

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

#include<string.h>

using namespace std;



main() {

    char A[100],B[100],C[100];

    int a,b,c;

    cin>>A;

    cin>>B;

    cin>>C;



    a=strlen(A);

    b=strlen(B);

    c=strlen(C);



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

        cout<<"YES";

    else

        cout<<"NO";

}

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

#include <string.h>



int main() {

    char A[20], B[20], C[20];

    A[20] = 'a' - 'z';

    B[20] = 'a' - 'z';

    C[20] = 'a' - 'z';

    scanf ("%s %s %s", &A, &B, &C);

    

    if (A [strlen(A) - 1] == B[0] && B [strlen(B) - 1] == C[0]) {

        printf ("YES");

    }

    else {

        printf ("NO");

    }

    return 0;

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

#include<string.h>

using namespace std;



main() {

    char A[100],B[100],C[100];

    int a,b,c;

    cin>>A;

    cin>>B;

    cin>>C;



    a=strlen(A);

    b=strlen(B);

    c=strlen(C);



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

        cout<<"YES";

    else

        cout<<"NO";

}

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

#include <string.h>



int main(){



    char tulisanA[11];

    char tulisanB[11];

    char tulisanC[11];



    scanf("%s %s %s", &tulisanA, &tulisanB, &tulisanC);



    int panjangA = strlen (tulisanA);

    int panjangB = strlen(tulisanB);



    if(tulisanA[panjangA-1] == tulisanB[0] && tulisanB[panjangB-1] == tulisanC[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.292605790900163x):
#include<stdio.h>

#include<string.h>

int main()

{

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

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

    int al, bl;

    al = strlen(a)-1;

    bl = strlen(b)-1;

    if(a[al]==b[0] && b[bl]==c[0])

    printf("YES");

    else printf("NO");

}
// 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.315670608894086x):
#include<stdio.h>

#include<string.h>

int main()

{

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

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

    int al, bl;

    al = strlen(a)-1;

    bl = strlen(b)-1;

    if(a[al]==b[0] && b[bl]==c[0])

    printf("YES");

    else printf("NO");

}
// 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.342171320162747x):
#include<stdio.h>

#include<string.h>

int main()

{

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

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

    int al, bl;

    al = strlen(a)-1;

    bl = strlen(b)-1;

    if(a[al]==b[0] && b[bl]==c[0])

    printf("YES");

    else printf("NO");

}
// 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.299450674804578x):
#include<stdio.h>



int main(){

	char a[150];

	int x=1;

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

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

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

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

				continue;

			} else{

				x=0;

				break;

			}

		}

	}

	printf("%s\n", x==1 ? "YES" : "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.322545322339502x):
#include<stdio.h>



int main(){

	char a[150];

	int x=1;

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

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

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

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

				continue;

			} else{

				x=0;

				break;

			}

		}

	}

	printf("%s\n", x==1 ? "YES" : "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.349080306761915x):
#include<stdio.h>



int main(){

	char a[150];

	int x=1;

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

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

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

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

				continue;

			} else{

				x=0;

				break;

			}

		}

	}

	printf("%s\n", x==1 ? "YES" : "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.352453956400217x):
#include<stdio.h>



int main(){

	char a[150];

	int x=1;

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

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

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

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

				continue;

			} else{

				x=0;

				break;

			}

		}

	}

	printf("%s\n", x==1 ? "YES" : "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.348292188603996x):
#include<stdio.h>



int main(){

	char a[150];

	int x=1;

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

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

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

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

				continue;

			} else{

				x=0;

				break;

			}

		}

	}

	printf("%s\n", x==1 ? "YES" : "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.313312616285336x):
#include<stdio.h>

#include<string.h>

int main(){

	char input[3][30];

	int panjang[3];

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

	scanf("%s", input[i]);

	panjang[i]=strlen(input[i]);

	}

	

	if(input[0][panjang[0]-1]==input[1][0] &&input[1][panjang[1]-1]==input[2][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.336467673223479x):
#include<stdio.h>

#include<string.h>

int main(){

	char input[3][30];

	int panjang[3];

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

	scanf("%s", input[i]);

	panjang[i]=strlen(input[i]);

	}

	

	if(input[0][panjang[0]-1]==input[1][0] &&input[1][panjang[1]-1]==input[2][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.3630720660475975x):
#include<stdio.h>

#include<string.h>

int main(){

	char input[3][30];

	int panjang[3];

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

	scanf("%s", input[i]);

	panjang[i]=strlen(input[i]);

	}

	

	if(input[0][panjang[0]-1]==input[1][0] &&input[1][panjang[1]-1]==input[2][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.366454540248432x):
#include<stdio.h>

#include<string.h>

int main(){

	char input[3][30];

	int panjang[3];

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

	scanf("%s", input[i]);

	panjang[i]=strlen(input[i]);

	}

	

	if(input[0][panjang[0]-1]==input[1][0] &&input[1][panjang[1]-1]==input[2][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.362281886383977x):
#include<stdio.h>

#include<string.h>

int main(){

	char input[3][30];

	int panjang[3];

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

	scanf("%s", input[i]);

	panjang[i]=strlen(input[i]);

	}

	

	if(input[0][panjang[0]-1]==input[1][0] &&input[1][panjang[1]-1]==input[2][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], b[100], c[100];

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

	int pnjgA = strlen(a);

	int pnjgB = strlen(b);

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

		if (a[pnjgA-1] == b[0] && b[pnjgB-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], b[100], c[100];

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

	int pnjgA = strlen(a);

	int pnjgB = strlen(b);

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

		if (a[pnjgA-1] == b[0] && b[pnjgB-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], b[100], c[100];

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

	int pnjgA = strlen(a);

	int pnjgB = strlen(b);

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

		if (a[pnjgA-1] == b[0] && b[pnjgB-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], b[100], c[100];

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

	int pnjgA = strlen(a);

	int pnjgB = strlen(b);

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

		if (a[pnjgA-1] == b[0] && b[pnjgB-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], b[100], c[100];

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

	int pnjgA = strlen(a);

	int pnjgB = strlen(b);

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

		if (a[pnjgA-1] == b[0] && b[pnjgB-1] == c[0]) {

			puts ("YES");

			break;

		} 

		else

			puts ("NO");

			break;

	}

	

	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.303201991720402x):
#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>



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.326312987240671x):
#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>

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.352866754956303x):
#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;

}