stablegradients/pie-gem5-pairs huggingface dataset:
// Slower C++ solution:
#include <iostream>

#include <string.h>



using namespace std;



int main()

{

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

    int x,y;

    cin>>a>>b>>c;

    x=strlen(a);

    y=strlen(b);

    if(a[x-1]==b[0])

    {

        if(b[y-1]==c[0])

        {

            cout<<"YES";

        }

        else

        {

            cout<<"NO";

        }

    }

    else

    {

        cout<<"NO";

    }

    return 0;

}


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

#include <string.h>



int main() {

	char A[101];

	char B[101];

	char C[101];

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

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

		printf("YES\n");

	}

	else {

		printf("NO\n");

	}

	return 0;

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

#include<string.h>



using namespace std;



int main()

{

    char line[50];

    cin.getline(line,50);

    char a,b,c,d;

    int count=0;

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

    {

        if(line[i]==' ')

        {

            if(count==0)

            {

            a=line[i-1];

            b=line[i+1];

            count=1;

            }

            else

            {

              c=line[i-1];

              d=line[i+1];

            }

        }

    }

    if(a==b && c==d)

    {

        cout<<"YES";

    }

    else{

        cout<<"NO";

    }

    return 0;

}




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

#include <string.h>



int main()

{

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



    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 <iostream>

#include <string.h>



using namespace std;



int main()

{

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

    int x,y;

    cin>>a>>b>>c;

    x=strlen(a);

    y=strlen(b);

    if(a[x-1]==b[0])

    {

        if(b[y-1]==c[0])

        {

            cout<<"YES";

        }

        else

        {

            cout<<"NO";

        }

    }

    else

    {

        cout<<"NO";

    }

    return 0;

}


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

#include <string.h>



int main()

{

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



    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;



int main()

{

    char line[50];

    cin.getline(line,50);

    char a,b,c,d;

    int count=0;

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

    {

        if(line[i]==' ')

        {

            if(count==0)

            {

            a=line[i-1];

            b=line[i+1];

            count=1;

            }

            else

            {

              c=line[i-1];

              d=line[i+1];

            }

        }

    }

    if(a==b && c==d)

    {

        cout<<"YES";

    }

    else{

        cout<<"NO";

    }

    return 0;

}




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

#include <string.h>



int main() {

	

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

	

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

	

	int p = strlen(a), q = strlen(b);

	

	

	if(a[p-1] == b[0] && b[q-1] == c[0]){

		puts("YES");

	}else{

		puts("NO");

	}

	







	return 0;

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

#include <string.h>



using namespace std;



int main()

{

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

    int x,y;

    cin>>a>>b>>c;

    x=strlen(a);

    y=strlen(b);

    if(a[x-1]==b[0])

    {

        if(b[y-1]==c[0])

        {

            cout<<"YES";

        }

        else

        {

            cout<<"NO";

        }

    }

    else

    {

        cout<<"NO";

    }

    return 0;

}


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

#include <string.h>



int main() {

	

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

	

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

	

	int p = strlen(a), q = strlen(b);

	

	

	if(a[p-1] == b[0] && b[q-1] == c[0]){

		puts("YES");

	}else{

		puts("NO");

	}

	







	return 0;

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

#include<string.h>



using namespace std;



int main()

{

    char line[50];

    cin.getline(line,50);

    char a,b,c,d;

    int count=0;

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

    {

        if(line[i]==' ')

        {

            if(count==0)

            {

            a=line[i-1];

            b=line[i+1];

            count=1;

            }

            else

            {

              c=line[i-1];

              d=line[i+1];

            }

        }

    }

    if(a==b && c==d)

    {

        cout<<"YES";

    }

    else{

        cout<<"NO";

    }

    return 0;

}




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

#include<string.h>

int main(){

    

    char a[11];

    char b[11];

    char c[11];

    

    scanf("%s",a);

    scanf("%s",b);

    scanf("%s",c);

    

    int len1 = strlen(a);

    int len2 = strlen(b);

    int len3 = strlen(c);

    

    if(a[len1-1] == b[0]  &&  b[len2-1] == c[0]){

        printf("YES");

    }

    else{

        printf("NO");

    }

    

    return 0;

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

#include <string.h>



using namespace std;



int main()

{

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

    int x,y;

    cin>>a>>b>>c;

    x=strlen(a);

    y=strlen(b);

    if(a[x-1]==b[0])

    {

        if(b[y-1]==c[0])

        {

            cout<<"YES";

        }

        else

        {

            cout<<"NO";

        }

    }

    else

    {

        cout<<"NO";

    }

    return 0;

}


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

#include<string.h>

int main(){

    

    char a[11];

    char b[11];

    char c[11];

    

    scanf("%s",a);

    scanf("%s",b);

    scanf("%s",c);

    

    int len1 = strlen(a);

    int len2 = strlen(b);

    int len3 = strlen(c);

    

    if(a[len1-1] == b[0]  &&  b[len2-1] == c[0]){

        printf("YES");

    }

    else{

        printf("NO");

    }

    

    return 0;

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

#include<string.h>



using namespace std;



int main()

{

    char line[50];

    cin.getline(line,50);

    char a,b,c,d;

    int count=0;

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

    {

        if(line[i]==' ')

        {

            if(count==0)

            {

            a=line[i-1];

            b=line[i+1];

            count=1;

            }

            else

            {

              c=line[i-1];

              d=line[i+1];

            }

        }

    }

    if(a==b && c==d)

    {

        cout<<"YES";

    }

    else{

        cout<<"NO";

    }

    return 0;

}




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

#include <string.h>



int main()

{

	char str1[15];

	char str2[15];

	char str3[15];

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

	int len1;

	len1= strlen(str1);

	int len2;

	len2= strlen(str2);

	int len3;

	len3= strlen(str3);

	

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

			printf("YES\n");

		}

		else{

			printf("NO\n");

	}

		

	return 0;

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

#include <string.h>



using namespace std;



int main()

{

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

    int x,y;

    cin>>a>>b>>c;

    x=strlen(a);

    y=strlen(b);

    if(a[x-1]==b[0])

    {

        if(b[y-1]==c[0])

        {

            cout<<"YES";

        }

        else

        {

            cout<<"NO";

        }

    }

    else

    {

        cout<<"NO";

    }

    return 0;

}


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

#include <string.h>



int main()

{

	char str1[15];

	char str2[15];

	char str3[15];

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

	int len1;

	len1= strlen(str1);

	int len2;

	len2= strlen(str2);

	int len3;

	len3= strlen(str3);

	

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

			printf("YES\n");

		}

		else{

			printf("NO\n");

	}

		

	return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include<string.h>





int main()

{

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

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

    int len_a = strlen(a);

    int len_b = strlen(b);

    if((a[len_a-1] == b[0]) && b[len_b-1] == c[0])

        printf("YES\n");

    else

        printf("NO\n");

    return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>

int main() {

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

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

	int lastA = strlen(A) - 1, lastB = strlen(B) - 1;

	if (A[lastA] == B[0] && B[lastB] == C[0]) {

		printf("YES\n");

	}

	else {

		printf("NO\n");

	}

	return 0;

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

using namespace std;

int main(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>

int main() {

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

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

	int lastA = strlen(A) - 1, lastB = strlen(B) - 1;

	if (A[lastA] == B[0] && B[lastB] == C[0]) {

		printf("YES\n");

	}

	else {

		printf("NO\n");

	}

	return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>



int main(){

    char str1[25];

    char str2[25];

    char str3[25];



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



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

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

            printf("YES\n");

        }

        else

        {

        printf("NO\n");

        }

    }

    else

    {

        printf("NO\n");

    }

    

    return 0;

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

using namespace std;

int main(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>



int main(){

    char str1[25];

    char str2[25];

    char str3[25];



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



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

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

            printf("YES\n");

        }

        else

        {

        printf("NO\n");

        }

    }

    else

    {

        printf("NO\n");

    }

    

    return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>



int main (){



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

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

    

    

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

        printf("YES\n");

    }else {

        printf("NO\n");

    }





    return 0;

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

using namespace std;

int main(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>



int main (){



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

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

    

    

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

        printf("YES\n");

    }else {

        printf("NO\n");

    }





    return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>

int main(){

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

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(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>

int main(){

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

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 s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>



int main(){

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

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

	

	int lenA=0, lenB=0, lenC=0;

	lenA = strlen(A);

	lenB = strlen(B);

	lenC = strlen(C);

	

	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(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>



int main(){

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

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

	

	int lenA=0, lenB=0, lenC=0;

	lenA = strlen(A);

	lenB = strlen(B);

	lenC = strlen(C);

	

	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 s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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



int main (){

	char kalimat1[255];	// rng

	char kalimat2 [255]; // gorila

	char kalimat3 [255]; // apple

	scanf("%s", &kalimat1);

	scanf("%s", &kalimat2);

	scanf("%s", &kalimat3);	

	int lenght1=0;

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

		lenght1++;

	}

	int lenght2=0;

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

		lenght2++;

	}

	if (kalimat1[lenght1-1]==kalimat2[0]){

		if (kalimat2[lenght2-1]== kalimat3[0]){

			printf("YES");

		}

		else {

			printf("NO");

		}

	}

	else {

		printf("NO");

	}

	return 0;

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

using namespace std;

int main(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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



int main (){

	char kalimat1[255];	// rng

	char kalimat2 [255]; // gorila

	char kalimat3 [255]; // apple

	scanf("%s", &kalimat1);

	scanf("%s", &kalimat2);

	scanf("%s", &kalimat3);	

	int lenght1=0;

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

		lenght1++;

	}

	int lenght2=0;

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

		lenght2++;

	}

	if (kalimat1[lenght1-1]==kalimat2[0]){

		if (kalimat2[lenght2-1]== kalimat3[0]){

			printf("YES");

		}

		else {

			printf("NO");

		}

	}

	else {

		printf("NO");

	}

	return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>



int main(){

 	

	char strA[100], strB[100], strC[100];

 	scanf("%s %s %s",&strA, &strB, &strC);

 	

	int lenA=strlen(strA);

 	int lenB=strlen(strB);

 	

 	if (strA[lenA-1] == strB[0] && strB[lenB-1] == strC[0]){

 		printf("YES");

	 }

	 

	 else{

	 	printf("NO");

	 }

 	

	return 0;	

	

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

using namespace std;

int main(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>



int main(){

 	

	char strA[100], strB[100], strC[100];

 	scanf("%s %s %s",&strA, &strB, &strC);

 	

	int lenA=strlen(strA);

 	int lenB=strlen(strB);

 	

 	if (strA[lenA-1] == strB[0] && strB[lenB-1] == strC[0]){

 		printf("YES");

	 }

	 

	 else{

	 	printf("NO");

	 }

 	

	return 0;	

	

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>

 

int main(){

	int i, j;

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

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

	 

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

	 	printf("YES\n");

	 } 

	 else {

	 	printf("NO\n");

	 }

	

	return 0;

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

using namespace std;

int main(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>

 

int main(){

	int i, j;

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

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

	 

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

	 	printf("YES\n");

	 } 

	 else {

	 	printf("NO\n");

	 }

	

	return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>



int main (){

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

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

	strlen (A),(B);

	

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

		printf("YES\n");

	}

	else{

		printf("NO\n");

	}

	

	return 0;

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

using namespace std;

int main(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>



int main (){

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

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

	strlen (A),(B);

	

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

		printf("YES\n");

	}

	else{

		printf("NO\n");

	}

	

	return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include <string.h>

 

int main(){

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

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

 

	int x = strlen(a), y = strlen(b);

	if(a[x-1] == b[0] && b[y-1] == c[0]){

		printf("YES \n");

	}else {

		printf("NO \n");

	}

	return 0;

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

using namespace std;

int main(void)

{

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

    cin>>A>>B>>C;

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

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;



}


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

#include <string.h>

 

int main(){

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

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

 

	int x = strlen(a), y = strlen(b);

	if(a[x-1] == b[0] && b[y-1] == c[0]){

		printf("YES \n");

	}else {

		printf("NO \n");

	}

	return 0;

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

using namespace std;



int main()

{

    string s,a,e;

    int c,d,j;

    cin>>s>>a>>e;

    c = s.size();

    d = a.size();

    j = e.size();

    if(s[c-1]==a[0]&&a[d-1]==e[0])

        cout<<"YES"<<endl;

    else

        cout<<"NO"<<endl;

    return 0;



}


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

#include<string.h>

int main(){

	

	char a[11];

	char b[11];

	char c[11];

	

	scanf("%s",a);

	scanf("%s",b);

	scanf("%s",c);

	

	int len1 = strlen(a);

	int len2 = strlen(b);

	int len3 = strlen(c);

	

	if(a[len1-1] == b[0]  &&  b[len2-1] == c[0]){

		printf("YES");

	}

	else{

		printf("NO");

	}

	

	return 0;

}