Problem:


Score : 100 points

Problem Statement

You are given three strings A, B and C. Check whether they form a word chain.

More formally, determine whether both of the following are true:

The last character in A and the initial character in B are the same.

The last character in B and the initial character in C are the same.

If both are true, print YES. Otherwise, print NO.

Constraints

A, B and C are all composed of lowercase English letters (a - z).

1 ≤ |A|, |B|, |C| ≤ 10, where |A|, |B| and |C| are the lengths of A, B and C, respectively.

Input

Input is given from Standard Input in the following format:

A B C

Output

Print YES or NO.

Sample Input 1

rng gorilla apple

Sample Output 1

YES

They form a word chain.

Sample Input 2

yakiniku unagi sushi

Sample Output 2

NO

A and B form a word chain, but B and C do not.

Sample Input 3

a a a

Sample Output 3

YES

Sample Input 4

aaaaaaaaab aaaaaaaaaa aaaaaaaaab

Sample Output 4

NO



Sample input:
rng gorilla apple


Sample output:
YES

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())

flag = False

for i in range(B + 1):
    if A * i % B == C:
        flag = True
        break

print('YES' if flag else 'NO')

Submission status: Runtime Error

Solution code:
import os
input = os.stdin.readline
A, B, C = map(int, input().split())

flag = False

for i in range(B + 1):
    if A * i % B == C:
        flag = True
        break

print('YES' if flag else 'NO')

Submission status: Runtime Error

Solution code:
a, b, c = map(input().split())
if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())
if A % B == 0:
    if C == 0:
        print('YES')
    else:
        print('NO')
elif A > B:
    if C % (A % B) == 0 or (B - C) % (A % B) == 0:
        print('YES')
    else:
        print('NO')
else:
    if C % (B - A) == 0 or (B - C) % A == 0 or (B - C) % (B % A):
        print('YES')
    else:
        print('NO')

Submission status: Runtime Error

Solution code:
A,B,C = map(int, input().split())

flag = False

for i in range(B):
    
    t = i*A%B
    
    if t == C: 
        flag = True
        

if flag == True:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
def main():
    a,b,c = list(map(int, input().split()))
    if a[-1] == b[0] and b[-1] == c[0]:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
A=input()
B=input()
C=input()
if A[-1]==B[0] and B[-1]==C[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a,b,c = input.split()

if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();

int main() {
  string A, B, C;
  cin >> A >> B >> C;
  if (A.at(A.size() - 1) == B.at(0) && B.at(B.size() - 1) == C.at(0)) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())
if A[-1] == B[0] and B[-1] == C[0]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c = input().split
if a[-1] == b[1] and b[-1] == c[1]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
a,b,c=[str(i) for i in input().split()]
if a[-1]==b[1] and b[-1]==c[1]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
a,b,c=map(str, input().split())
if a[len(a)]==b[0] and b[len(b)]==c[0]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
  break
else:
  print('NO')

Submission status: Runtime Error

Solution code:
import sys
a,b,c =  list(map(int, input().split()))

for i in range(b):
	if (i+1)*a%(b) == c:
		print('YES')
		sys.exit()

print('NO')

Submission status: Runtime Error

Solution code:
A, B, C = input().split()
print('YES'  if A[-1] == B[0] and B[-1] == C[0])

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print(["NO","YES"][a[-1]==b[0] and b[-1]==c[1]])

Submission status: Runtime Error

Solution code:
a,b,c = input().split()
print("YES" if a[-1] == b[0] && b[-1] == c[0] else "NO")

Submission status: Runtime Error

Solution code:
A, B, C = input().split()
# l = A[-1] 
# v = B[0]
# n = B[-1]
# s = C[0]
# if l == v and v == n and n == s:
if (A[-1]) == (B[0]) and (B[-1]) == (C[0])
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A,B,C=map(str,input().split())
x=len(A)
y=len(B)
if A[x-1]==B[1] and B[y-1]==C[1]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=list(map(str,input().split()))
if a[-1]==b[0] and b[-1]==c[0]:print('YES')
else print('NO')

Submission status: Runtime Error

Solution code:
|A|,|B|,|C| = list(map(int,input().split()))
a,b,c=list(map(str,input().split()))
if a[|A|-1]==b[0] and b[|B|-1]==c[0] :print('YES')
else:print('NO')

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())

flg = 0

for i in range(100000):
    if (i*a)%b = c:
        flg+=1
    break

if flg==0:
    print("NO")
else:
    print("YES")

Submission status: Runtime Error

Solution code:
A,B,C=input().split()
if A[-1]==B[0] and B[-1]=C[0]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
a, b,c = map(str, input().split())
if a[-1]==b[1] and b[-1]==c[1]:
  print('YES')
  exit()
print('NO')

Submission status: Runtime Error

Solution code:
a,b,c=map(int,raw_input().split())
if a[len(a)-1]== b[0] and b[len(b)-1]==c[0]:
  print "YES"
else:
  print "NO"

Submission status: Runtime Error

Solution code:
a,b,c=map(int,raw_input(),split())
if a[len(a)-1]== b[0] and b[len(b)-1]==c[0]:
  print "YES"
else:
  print "NO"

Submission status: Runtime Error

Solution code:
a,b,c=input().strip().split()

if a[-1]==b[0] and b[-1]==c[1]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c = input()
print('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())
if A[-1] == B[0] and B[-1] == C[0]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
A, B, C = list(map(int, input().split()))
if A[len(A)-1] == B[0] and B[len(B)-1] == C[0]:
    print("YES")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
 print(’YES’)
else:
 print(’NO’)

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
	print(’YES’)
else:
	print(’NO’)

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
print(’YES’)
else:
print(’NO’)

Submission status: Runtime Error

Solution code:
A,B,C=map(int, input().split())
res = "NO"
for i in range(10*8):
    if (A-B*i)%C==0:
        res = "YES"
        break
print(res)

Submission status: Runtime Error

Solution code:
A,B,C = list(map(int,input().split()))
if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
s = input().split()
print(s)
if s[0][-1]==s[1][0] and s[1][-1]==s[2][1]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
print('Yes' if a<=c<=b else 'No')

Submission status: Runtime Error

Solution code:
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

A, B, C = rl()
bool = A[-1] == B[0] and B[-1] == C[0]
print('YES' if bool else 'NO')

Submission status: Runtime Error

Solution code:
A,B,C = list(map(input()))
ans="NO"
if A[len(A)-1] == B[0] and B[len(B)-1] == C[0]:
  ans = "YES"
print(ans)

Submission status: Runtime Error

Solution code:
a, b, c = map(int,input().split())
if a[-1] == b[0] and b[-1] == c[0]:
	print("YES")
else:
	print("NO")

Submission status: Runtime Error

Solution code:
N, T = map(int, input().split())

t = list(map(int, input().split()))

discount = 0
for i in range(N - 1):
    if t[i + 1] - t[i] < T:
        discount += (T - (t[i + 1] - t[i]))

X = N * T - discount

print(X)

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
if a[-1:]==b[:1] and b[-1:]==c[:1]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=map(input().split())

if a[-1]==b[0] and b[-1]==c[0]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())

N=[]
x=0

while True:
    if x%b not in N:
        N.append(x%b)
    else:
        break
    x=x+a
    
if c in N:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
for i in range(b):
    if i*a % b==c:
        print("YES")
        quit()
print('NO')

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
for i in range(b):
    if i*a % b==c:
        print("YES")
        exit()
print('NO')

Submission status: Runtime Error

Solution code:
A, B, C = map(str, input().split())
a = list(A)
b = list(B)
c = list(C)

if a[-1] == b[0] and b[-1] == c[1]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
st="NO"
for i in range(a,b*a+1):
  if i%b==c:
    st="YES"
    break

print(st)

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
a=list(a)
b=list(b)
c=list(c)
if a[len(a)]==b[0] and b[len(b)]==c[0]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
A,B,C = map(int,input().split())
if A[-1] == B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a,b,c = input().split()
if('YES' if a[-1]==b[0] and b[-1]==c[0] else 'NO')

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
A, B , C = map(int, input().split())

if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
a,b,c=input()
print('YES' if a[-1]==b[0] and b[-1] == c[0] else 'NO')

Submission status: Runtime Error

Solution code:
import sys

if sys.platform =='ios':
    sys.stdin=open('input_file.txt')
    

s1,s2,s3=map(str,input().split())

if s1[-1]==s2[0] and s2[-1]=s3[0]:
	print("YES")
else:
	print("NO")

Submission status: Runtime Error

Solution code:
A,B,C = input().split()

if A[len(A)-1]==B[0] and B[len(B)-1]==C[0]:
  print("YES)
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = list(input().split(' '))
if a[-1] = b[0] and b[-1] = c[0]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
a, b, c = map(list, input().split(' '))
if a[-1] = b[-1] and b[-1] = c[-1]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
a, b, c = list(input().split(' '))
if a[-1] = b[-1] and b[-1] = c[-1]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
A = input()
B = input()
C = input()

if A[-1]==B[0] and B[-1] == C[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
A,B,C=input().split()

if A[2]==B[0] and B[2]==C[0]:
    print('YES')
else :
    print('NO')

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
print("YES" if a[-1] == b[0] and b[-1] == c[0] else "NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()

if a[len(a-1)] == b[0] and b[len(b-1)] == c[0]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print('YES' if a[-1]=b[0] and b[-1]=c[0] else "NO")

Submission status: Runtime Error

Solution code:
a,b,c=map(input())
print('YES' if a[-1]=b[0] and b[-1]=c[0] else "NO")

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())

if a[-1] == b[0] and b[-1] == c[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print("YES" a[-1]==b[0] and b[-1]==c[0] else "NO")

Submission status: Runtime Error

Solution code:
word1,word2,word3 = map(str,input().split())
if word1[-1] == word2[1] and word2[-1] == word3[1]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
word1,word2,word3 = map(str,input().split())
if word1[-1] == word2[1] and word1[-1] == word2[1]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
A B C =input()



print('YES' if A[count(A-1)]==B[0] and B[count(B-1)]==c[0] else 'No')

Submission status: Runtime Error

Solution code:
A, B, C = map(str, input().split())

if A[-1] == B[0] and B[-1] == c[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
if a[-1] == b[0] and b[-1] == c[0]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
s = list(input().split())
if s[0].offset(-1) == s[1].offset(0) and s[1].offset(-1) == s[2].offset(0):
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print('YES' if a[-1]==b[1] and b[-1]==c[1] else 'NO')

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print('YES' if a[::-1]==b[1] and b[::-1]==c[1] else 'NO')

Submission status: Runtime Error

Solution code:
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))

sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B, C = S_LIST()
if A[-1] == B[0] and B[-1] = C[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
A, B, C= input(), input(), input()
if A[-1] == B[0] and B[-1] == C[0]:
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    a, b, c = LI()
    if a[-1] == b[0] and b[-1] == c[0]:
        print("YES")
    else:
        print("NO")
    return

#B
def B():
    return

#C
def C():
    return

#D
def D():
    return

#E
def E():
    return

#F
def F():
    return

#G
def G():
    return

#H
def H():
    return

#Solve
if __name__ == '__main__':
    A()

Submission status: Runtime Error

Solution code:
row = list(map(int, input().split()))
Flag = False
for i in range(1000000):
    if row[0]*i % row[1] == row[2]:
        Flag = True
        break
if Flag:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().spit()
if a[-1] ==b[0] and b[-1] ==c[0]:print("YES")
else:print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[len(a)] == b[0] and b[len(b)] == b[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
siri = input().split()

one = siri[0][-1]
two = [siri[1][1],siri[1][-1]]
three = siri[2][0]

if one == two[0]:
  if two[1] == three:
    print("YES")
  else:
    print("NO")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
words = list(map(int,input().split()))
a = words[0][-1:]
b = words[1][0]
c = words[1][-1:]
d = words[2][0]
if a==b and c == d:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
# https://atcoder.jp/contests/abc060/tasks/abc060_a

import itertools
import collections
import bisect

def main():
    A, B, C = map(int, input().split())
    print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')

if __name__ == '__main__':
    main()

Submission status: Runtime Error

Solution code:
A,B,C = map(int, input().split())
print('YES' if A[-1] == B[0] and B[-1] == C[0] and C[-1] == A[0] else 'NO')

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[-1] == b[0] and b[-1] == c[0]:
  print('YES')
 else:
  print('NO')

Submission status: Runtime Error

Solution code:
from fractions import gcd
a,b,c=map(int,input().split())
print("NO"if c%gcd(a,b)!=0else"YES")

Submission status: Runtime Error

Solution code:
x,y,z=input(),split()
print("YES" if x[-1]==y[0] and y[-1]==z[0] else "NO")

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[len(a)-1] == b[0] and b[len(b)-1] == c[0]:
     print(’YES’)
else:
print(’NO’)

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print('NYOE S'[[a[-1]==b[0] and b[-1]==c[0]]::2])

Submission status: Runtime Error

Solution code:
a,b,c=input().split();print('NYOE S'[[a[-1]==b[0]and b[-1]==c[0]]::2])

Submission status: Runtime Error

Solution code:
a,b,c=input().split();print('NYOE S'[a[-1]==b[0]and b[-1]==c[0]]::2)

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
if a[-1]==b[0] and b[-1]==c[0]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
ans="NO"

for i in range (100000):
    if a*i%b==c:
        ans="YES"
        break

print(ans)

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())
print('YES' if A[-1] == B[0] and B[-1] == C[0] else 'NO')

Submission status: Runtime Error

Solution code:
import sys, os
import numpy as np

f = lambda:list(map(int,input().split()))
if 'local' in os.environ :
    sys.stdin = open('./input.txt', 'r')

def solve():
    a,b,c = input(), input(), input()
    if a[-1]== b[0] and b[-1] = c[0]:
        print('YES')
    else:
        print('NO')
    

solve()

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
ans='NO'
A=[]
for i in range(10001):
    A.append((a*i-c)%b)
    if(i>3)and(A[0]==A[-1]):
      break
    if (a*i-c)%b==0:
        ans='YES'
        break
print(ans)

Submission status: Runtime Error

Solution code:
a,b,c=map(str,input().split())
if("YES" if a[len(a)-1]==b[0] and b[len(b)-1]==c[0] else "NO")

Submission status: Runtime Error

Solution code:
a,b,c=map(input().split())
if("YES" if a[len(a)-1]==b[0] and b[len(b)-1]==c[0] else "NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
if("YES" if a[len(a)-1]==b[0] and b[len(b)-1]==c[0] else "NO")

Submission status: Runtime Error

Solution code:
a=input().split()
if("YES" if a[0][len(a[0])-1]==a[1][0] and a[1][len(a[1])-1]==a[2][0] else "NO")

Submission status: Runtime Error

Solution code:
a,b,c = map(str,input().split())
if a[-1]=b[0] and b[-1]=c[0]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
#!usr/bin/env python3
from collections import defaultdict
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
a,b,c = LI()
if a[-1] == b[0] and b[-1] == c[0]:
    print("YES")
else:
    print("NO")
#B

#C
""""
n,T = LI()
ans = 0
t = LI()
for i in range(n-1):
    ans += min(T,t[i+1]-t[i])
ans += T
print(ans)
"""

#D
"""
n,w = LI()
g = LIR(n)
l = [[] for i in range(4)]
for W,v in g:
    l[W-g[0][0]].append(v)
    l[W-g[0][0]].sort(reverse = True)
l0 = len(l[0])
l1 = len(l[1])
l2 = len(l[2])
l3 = len(l[3])
for i in range(l0-1):
    l[0][i+1] += l[0][i]
l[0].insert(0,0)
for i in range(l1-1):
    l[1][i+1] += l[1][i]
l[1].insert(0,0)
for i in range(l2-1):
    l[2][i+1] += l[2][i]
l[2].insert(0,0)
for i in range(l3-1):
    l[3][i+1] += l[3][i]
l[3].insert(0,0)
ans = 0
for i in range(l0+1):
    for j in range(l1+1):
        for k in range(l2+1):
            for m in range(l3+1):
                if i*g[0][0]+j*(g[0][0]+1)+k*(g[0][0]+2)+m*(g[0][0]+3) <= w:
                    ans = max(ans,l[0][i]+l[1][j]+l[2][k]+l[3][m])
print(ans)
"""

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T

Submission status: Runtime Error

Solution code:
A,B,C=map(list,input().split())
print(['NO','YES'][A[-1]==B[0] and B[-1]==

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print("YES") if a[len(a)] == b[0] and b[len(b)] == c[0] else print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = input().split()

if (a[-1] == B[0]) and (B[-1] == C[0]):
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split
print("YES") if a[-1]==b[0] and b[-1]==c[0] else print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = input().split()

if a[-1] == b[1] and b[-1] == c[1]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
import re;a,b=re.findall('. .',input());print('YNEOS'[a[0]+b[2]!=a[2]+b[0]::2])

Submission status: Runtime Error

Solution code:
s=input().find;i=s(' ');j=s(' ',i);print('YNEOS'[s[i-1]+s[j+1]!=s[i+1]+s[j-1]::2])

Submission status: Runtime Error

Solution code:
a,b,c=input().split();print('YNEOS'[a[-1]+c[0]!=b[::len(b)-1]::2])

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print "YES" if a[-1] == b[0] and b[-1] == c[0] else "NO"

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print "YES" if a[-1] == b[0] && b[-1] == c[0] else "NO"

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print "YES" if a.last() == b.first() && b.last() == c.first() else "NO"

Submission status: Runtime Error

Solution code:
a,b,c=map(int(),split())
print "YES" if a.last() == b.first() && b.last() == c.first() else "NO"

Submission status: Runtime Error

Solution code:
a,b,c=map(int,input().split())
for i in range(1,b+1):
    if (a*i)%b==c:
        print("YES")
        break
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = map(int, input().split())
print("YES" if any((a*i)%b==c for i in range(1, b+1)) else "NO")
#コピペです。

Submission status: Runtime Error

Solution code:
a,b,c=input().split()

if a[0]==b[-1] anb b[0] == c[-1]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
a,b,c=input().split()

if a[0]==b[-1] anb [0] == c[-1]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
a=input()
b=input()
c=input()
if a[-1]==b[0] and b[-1]==c[0]:
  print('YES')
else:
  print('NO')

Submission status: Runtime Error

Solution code:
,b,c = input().split()
print('YES') if a[-1] == b[0] and b[-1] == c[0] else print('NO')

Submission status: Runtime Error

Solution code:
A,B,C=input().split()
if A[-1]=B[0] and B[-1]=C[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
a,b,c = map(int,input().split())
print('YES' if a[-1] == b[0] and b[-1] == c[0] else 'NO')

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())
if A[-1] == B[0] and B[-1] == C[0]:
  print("YES")
else :
  print("NO")

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())
if A[-1] == B[0] && B[-1] == C[0]:
  print("YES")
else :
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=map(input().split())
if (a[len(a)-1]==b[0])&(b[len(b)-1]==c[0]):
    print('YES')
else:
    print('NO')

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
print("YES" if a[-1] == b[1] and b[-1] == c[1] else "NO")

Submission status: Runtime Error

Solution code:
a = list(input())
b = list(input())
c = list(input())

if a[len(a)] == b[0] and b[len(b)] == c[0]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a = list(input())
b = list(input())
c = list(input())

if a[len(a)] = b[0] and b[len(b)] = c[0]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
s = input().split()
a, b, c = s[0], s[1], s[2]
if b.startswith(a[-1:]) and c.stratswith(b[-1:]):
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split();print('YNEOS'[a[-1]^b[0]^b[-1]^c[0]>0::2])

Submission status: Runtime Error

Solution code:
a,b,c=input().split();print('YNEOS'[a[-1]^c[0]^b[0]^b[-1]::2])

Submission status: Runtime Error

Solution code:
#60b
a,b,c =map(int,input().split())
i=0
aa=a
while i<b:
    i+=1
    if aa%b == c:
        print('YES')
        exit()
    aa+=a
print('NO')

Submission status: Runtime Error

Solution code:
N,T=(int(i) for i in input().split())
t = [int(i) for i in input().split()]
a=0
for b in range(N-1):
    if (t[b+1] - t[b]) < T:
        a = a + t[b+1] - t[b]
    else:
        a = a + T
a = a+T
print(a)

Submission status: Runtime Error

Solution code:
A = list(input())
B = list(input())
C = list(input())
if A[-1]==B[0] and B[-1]==C[0]:
    print("Yes")
else:
    print("No")

Submission status: Runtime Error

Solution code:
A = list(input())
B = list(input())
C = list(input())
if condition:A[-1]=B[0]
    if condition:B[-1]=c[0]
        if condition:C[-1]=A[0]
            print("Yes")
        else:
            print("No")
    else:print("No")
        pass
else:
    print("No")

Submission status: Runtime Error

Solution code:
#coding:utf-8
n=input().split()
if(n[0][0]==n[0][1]==n[0][2]):
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
print("YES" if a[-1]==b[0]&&b[-1]==c[0] else "NO")

Submission status: Runtime Error

Solution code:
a,b,c=[int(i) for i in input().split()]
print("YES" if a[-1]==b[0] and b[-1]== c[0] else "NO")

Submission status: Runtime Error

Solution code:
s = list(map(str,input().split()))

a = list(s[0])
b = list(s[1])
c = list(s[2])

if a[-1] == b[0] and b ==[-1] == c[0]:
    print('YES')
else:
    primt('NO')

Submission status: Runtime Error

Solution code:
A, B, C = map(int, input().split())
if A[-1]==B[0] and B[-1]==C[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
s=list(input(a))
f=list(input(b))
g=list(input(c))
if s[-0]==f[0] and f[-0]==g[0]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
e=list(input(a))
f=list(input(b))
g=list(input(c))
if e[-0]==f[0] and f[-0]==g[0]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
a,b,c=input().split()
e=list(input(a))
f=list(input(b))
g=list(input(c))
if e[-0]==f[0] and f[-0]==g[0]
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
s = str(input()).split(" "):
if s[0][0] == s[1][-1] and s[1][0] == s[2][-1]:
  print("YES")
else:
  print("NO")

Submission status: Runtime Error

Solution code:
import heapq
N,W=map(int,raw_input().split())
wv=[]

w_sum=0
for i in range(N):
	w,v=map(int,raw_input().split())
	w_sum+=w
	wv.append((w,v))


a=[ float("-inf") for i in range(w_sum*2) ]

i=0
i=1
q=[]
for ind_i, i in enumerate(wv):
	w=i[0]
	v=i[1]
	#Initialize
	if ind_i==0:
		a[0]=0
		a[w]=v
		continue
	#Put queue
	for ind_j, j in enumerate(a):
		if j!=float("-inf"):
			heapq.heappush(q,(ind_j,j))
	
	while len(q)!=0:
		ind_j, j=heapq.heappop(q)
		a[ind_j+w]=max(a[ind_j+w], a[ind_j]+v)
		
print max(a[:W+1])

Submission status: Runtime Error

Solution code:
k = map(int, raw_input().split())
temp = [k[0]]
for i in xrange((k[0]*k[2])):
    if sum(temp) % k[1] == k[2]:
        print "YES"
        exit()
    temp.append(int(k[0]))

print "NO"

Submission status: Runtime Error

Solution code:
l = map(str, raw_input().split())

for i in range(len(l)-1):
    if l[i][len(l)-1] == l[i+1][0]:
        print "YES"
        exit()
print "NO"

Submission status: Runtime Error

Solution code:
def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    n, t = LI()
    T = LI()
    sentou = [0] * (T[-1] + t + 1)
    
    i = 0
    while i < len(T):
        sentou[T[i]] += 1
        sentou[T[i] + t] -= 1
        i += 1

    j = 1
    while j < len(sentou):
        sentou[j] += sentou[j - 1]
        j += 1

    print(n * t - (sum(sentou) - (sentou.count(1) + len(sentou) - sentou.count(1) - sentou.count(0))))

solve()

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[len(a-1)] == b[0] and b[len(b-1)] == c[0]:
    print("YES")
else:
    print("NO")

Submission status: Runtime Error

Solution code:
a, b, c = input().split()
if a[len(a)] == b[0] and b[len(b)] == c[0]:
    print("YES")
else:
    print("NO")