qyliang/CodeNanoFix huggingface dataset:
Buggy code:

n = int(input())
w = []

for i in range(n):
    s = input()
    if s in w:
        flag = 0
        break
    else:
        w.append(s)

for i in range(1, n-1):
    if w[i][-1] != w[i+1][0]:
        flag = 0
        break

if flag == 0:
    print('No')
else:
    print('Yes')

Fixed code:
n = int(input())
w = []
flag = 1

for i in range(n):
    s = input()
    if s in w:
        flag = 0
        break
    else:
        w.append(s)

if flag != 0:
    if w[0][-1] != w[1][0]:
        flag = 0
    for i in range(1, n-1):
        if w[i][-1] != w[i+1][0]:
            flag = 0
            break

if flag == 0:
    print('No')
else:
    print('Yes')
Buggy code:
import sys

n = int(input())
word = [input() for _ in range(n)]

t = len(list(set(word)))

if n == t:
    for i in range(n-1):
        if word[i][-1] == word[i+1][0]:
            continue
        else:
            print("No")
    else:
        print("Yes")
else:
        print("No")

Fixed code:
import sys

n = int(input())
word = [input() for _ in range(n)]

t = len(list(set(word)))

if n != t:
    print("No")
else:
    for i in range(n-1):
        if word[i][-1] == word[i+1][0]:
            continue
        else:
            print("No")
            sys.exit()
    else:
        print("Yes")
Buggy code:
n = int(input())
l = []
x = []
a = []
for i in range(n):
    w = str(input())
    a.append(w)
    l.append(w[0])
    x.append(w[-1])
if len(set(a)) == n:
    if l[1:] == x[:len(x)-1]:
        print("Yes")
else:
    print("No")

Fixed code:
n = int(input())
l = []
x = []
a = []
for i in range(n):
    w = str(input())
    a.append(w)
    l.append(w[0])
    x.append(w[-1])
if len(set(a)) == n:
    if l[1:] == x[:len(x)-1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")
Buggy code:
N = int(input())
s = [str(input())]
for i in range(1, N):
    x = str(input())
    if x[0] != s[i-1][-1]:
        print('No')
        break
    s.append(x)
if len(set(s)) == len(s):
    print('Yes')
else:
    print('No')

Fixed code:
N = int(input())
s = [str(input())]
for i in range(1, N):
    x = str(input())
    if x[0] != s[i-1][-1]:
        break
    s.append(x)
if len(set(s)) == N:
    print('Yes')
else:
    print('No')
Buggy code:
n=int(input())
x=[input() for _ in range(n)]
ans='Yes'
if len(x)==len(set(x)):
  for i in lenge(n-1):
    if x[i][-1]!=x[i+1][0]:
      ans='No'
      break
else:
  ans='No'
print(ans)

Fixed code:
n=int(input())
x=[input() for _ in range(n)]
ans='Yes'
if len(x)==len(set(x)):
  for i in range(n-1):
    if x[i][-1]!=x[i+1][0]:
      ans='No'
      break
else:
  ans='No'
print(ans)
Buggy code:
import sys
n = int(input())
lis = []
lis.append(input())
ans = 0
for i in range(n-1):
    word = input()
    if word in lis:
        ans += 1
    if word[0] != lis[-1][-1]:
        ans += 1
        
if ans == 0:
    print("Yes")
else:
    print("No")

Fixed code:
import sys
n = int(input())
lis = []
lis.append(input())
ans = 0
for i in range(n-1):
    word = input()
    if word in lis:
        ans += 1
    if word[0] != lis[-1][-1]:
        ans += 2
    lis.append(word)    
if ans == 0:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
W = [input() for _ in range(N)]

Ws = set([W[0]])
for i in range(1, N):
    if not W[i - 1][-1] == W[i][0] or W[i] in Ws:
        print("No", W[i])
        exit()
    else:
        Ws.add(W[i])

print("Yes")


Fixed code:
N = int(input())
W = [input() for _ in range(N)]

Ws = set([W[0]])
for i in range(1, N):
    if not W[i - 1][-1] == W[i][0] or W[i] in Ws:
        print("No")
        exit()
    else:
        Ws.add(W[i])

print("Yes")
Buggy code:
import sys
if __name__ == '__main__':
    N = int(input())
    W = [int(input()) for _ in N]
    for i in range(1,N):
        if W[i-1][-1] != W[i][0]:
            print('No')
            sys.exit()
    print('Yes')

Fixed code:
import sys
if __name__ == '__main__':
    N = int(input())
    W = [str(input()) for _ in range(N)]
    if len(W) != len(set(W)):
        print('No')
        sys.exit(0)
    for i in range(1,N):
        if W[i-1][-1] != W[i][0]:
            print('No')
            sys.exit(0)
    print('Yes')
Buggy code:
N = int(input())
L = []

Ans = True

for i in range(N):
    a =input()
    L.append(a)

for j in range(N-1):
    if list(L[j])[-1] != list(L[j+1])[0]:
        Ans = False

for k in range(N):
    if L[i] in L:
        Ans = False
        
if Ans == True:
    print('Yes')
else:
    print('No')

Fixed code:
N = int(input())
L = []

Ans = True

for i in range(N):
    a =input()
    L.append(a)

for j in range(N-1):
    if list(L[j])[-1] != list(L[j+1])[0]:
        Ans = False

for k in range(N):
    if L[k] in L[:k]:
        Ans = False
        
if Ans == True:
    print('Yes')
else:
    print('No')
Buggy code:
N = int(input())
counter = 0
qq = 0
L = []
for i in range(N) :
    if i == 0 :
        w = input()
        L.append(w)
        q = w[-1]
    if i != 0 :
        w = input()
        if w in L :
            qq += 1
        p = w[0]
        if p == q :
            q = w[-1]
            counter += 1

            
            
if counter == N-1 and qq != 0 :
    print("Yes")
else :
    print("No")



Fixed code:
N = int(input())
counter = 0
qq = 0
L = []
for i in range(N) :
    if i == 0 :
        w = input()
        L.append(w)
        q = w[-1]
    if i != 0 :
        w = input()
        if w in L :
            qq += 1
        L.append(w)
        p = w[0]
        if p == q :
            q = w[-1]
            counter += 1

            
            
if counter == N-1 and qq == 0 :
    print("Yes")
else :
    print("No")
Buggy code:
N = int(input())
W = [input() for _ in range(N)]

from collections import Counter

dic = Counter(W)
flg = 0
for i in range(N):
    if dic[W[i]]!=1:
        flg=1
        break

for j in range(N-1):
    if W[j][-1]!=W[j+1][1]:
        flg = 1
        break

if flg!=1:
    print('Yes')
else:
    print('No')

Fixed code:
N = int(input())
W = [input() for _ in range(N)]

from collections import Counter

dic = Counter(W)
flg = 0
for i in range(N):
    if dic[W[i]]!=1:
        flg=1
        

for j in range(N-1):
    if W[j][-1]!=W[j+1][0]:
        flg = 1

if flg!=1:
    print('Yes')
else:
    print('No')
Buggy code:
n = int(input())
w = [input().rsprit() for i in range(n)]
use = [w[0]]
for i in range(1,n):
  if w[i][0] == w[i-1][-1] and w[i] not in use:
    use.append(w[i])
  else:
    print('No')
    exit()
print('Yes')

Fixed code:
n = int(input())
w = [input().rstrip() for i in range(n)]
use = [w[0]]
for i in range(1,n):
  if w[i][0] == w[i-1][-1] and w[i] not in use:
    use.append(w[i])
  else:
    print('No')
    exit()
print('Yes')
Buggy code:
import collections

N = int(input())
W = []
for i in range(N):
    W.append(input())

#if W.most_common()[0][1] == 1:
def is_unique2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)
c=0

if is_unique2(W)==True:
    for i in range(N-1):
        a = W[i]
        b = W[i+1]
#        print(a[len(a)-1])
#        print(b[0])
        if a[len(a)-1] == b[0]:
            c+=1
    if c == N-1:
        print('Yes')
else:
    print('No')

Fixed code:
import collections

N = int(input())
W = []
for i in range(N):
    W.append(input())

#if W.most_common()[0][1] == 1:
def is_unique2(seq):
    seen = []
    unique_list = [x for x in seq if x not in seen and not seen.append(x)]
    return len(seq) == len(unique_list)
c=0

if is_unique2(W)==True:
    for i in range(N-1):
        a = W[i]
        b = W[i+1]
#        print(a[len(a)-1])
#        print(b[0])
        if a[len(a)-1] == b[0]:
            c+=1
    if c == N-1:
        print('Yes')
    else:
        print('No')
else:
    print('No')
Buggy code:
N = int(input())
ans = "Yes"
arr = []
for i in range(N)
    arr.append(input())
    if not i == 1:
        if arr[i] in arr and arr[i-1][-1] == arr[i][0]
            pass
        else:
            ans = "No"
            break

print(ans)


Fixed code:
N = int(input())
ans = "Yes"
arr = []
for i in range(N):
    arr.append(input())
    if not i == 0:
        if arr[i-1][-1] == arr[i][0] and not arr[i] in arr[:-2]:
            pass
        else:
            ans = "No"
            break

print(ans)
Buggy code:
n = int(input())

w = [0]*n
used = []

for i in range(n):
  w[i] = input()
  
for i in range(n-1):
  if(w[i][-1] != w[i+1][0] or w[i] in used):
    print("No")
    exit()
  used.append(w[i])

if(w[n] not in used):
  print("Yes")
else:
  print("No")

Fixed code:
n = int(input())

w = [0]*n
used = []

for i in range(n):
  w[i] = input()
  
for i in range(n-1):
  if(w[i][-1] != w[i+1][0] or w[i] in used):
    print("No")
    exit()
  used.append(w[i])
#print(w)

if(w[n-1] not in used):
  print("Yes")
else:
  print("No")
Buggy code:
import sys

n = int(input())
w = [input() for i in range(n)]
if len(w) != len(set(w)):
    print("No")
    sys.exit()
for i in range(n - 1):
    if w[i][-1] != w[i + 1][0]:
        print("No")
else:
    print("Yes")


Fixed code:
import sys

n = int(input())
w = [input() for i in range(n)]
if len(w) != len(set(w)):
    print("No")
    sys.exit()
for i in range(n - 1):
    if w[i][-1] != w[i + 1][0]:
        print("No")
        break
else:
    print("Yes")
Buggy code:
N = int(input())
L = [input() for _ in range(N)]

flg = False
if len(L) != len(set(L)): flg = True
for i in range(N):
  if flg: break
  if i != 0:
    if L[i][1] != L[i-1][-1]:
      flg = True
print ("No" if flg else "Yes")

Fixed code:
N = int(input())
L = [input() for _ in range(N)]

flg = False
if len(L) != len(set(L)): flg = True
for i in range(1, N):
  if flg: break
  if i != 0:
    if L[i][0] != L[i-1][-1]:
      flg = True
print ("No" if flg else "Yes")
Buggy code:
N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

if len(set(l)) != len(l):
    print("No")
    exit(1)

for h in range(0,len(words),2):
    print(h)
    if words[h] == words[h+1]:
        words[h] = True
        words[h+1] = True
    else:
        print("No")
        exit(1)
    
if all(l):
    print("Yes")


Fixed code:
N = int(input())
words = []
l = []
for i in range(N):
    a = input()
    if i == 0:
        l.append(a)
        b = list(a)
        words.append(b[len(b)-1])
    elif i > 0:
        b = list(a)
        if i == N-1:
            words.append(b[0])
        else:
            words.append(b[0])
            words.append(b[len(b)-1])
        l.append(a)

if len(set(l)) != len(l):
    print("No")
    exit()

for h in range(0,len(words),2):
    if words[h] != words[h+1]:
        print("No")
        exit()
print("Yes")
Buggy code:
N=int(input())
a=[input() for i in range(N)]
if len(set(a))!=N:
	print("No")
	exit()
for i in range(1,N):
	if a[i-1][-1]!=a[i][0]:
		print("No")
		exit()
print("yes")		

Fixed code:
N=int(input())
a=[input() for i in range(N)]
if len(set(a))!=N:
	print("No")
	exit()
for i in range(1,N):
	if a[i-1][-1]!=a[i][0]:
		print("No")
		exit()
print("Yes")
Buggy code:
input_lines = int(input())
lastchar = ''
for i in range(input_lines):
    s = input().rstrip()
    if len(lastchar) > 0 and not s[0] in lastchar:
        print('No')
        break
    lastchar = s[-1]
else:
    print('Yes')
    

Fixed code:
input_lines = int(input())
tango=[]
lastchar = ''
for i in range(input_lines):
    s = input().rstrip()
    if len(lastchar) > 0 and not s[0] in lastchar or s in tango:
        print('No')
        break
    tango.append(s)
    lastchar = s[-1]
else:
    print('Yes')
Buggy code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
W=[0]*N
ans = 1
for i in range(N):
    W[i] = input()
    if ans == 1 and i != 0 and W[i-1][-1] != W[i][0]:
        ans = 0

if ans == 1 and set(W) != N:
    ans = 0

yn(ans)


Fixed code:
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18

N=ri()
W=[0]*N
ans = 1
for i in range(N):
    W[i] = input()
    if ans == 1 and i != 0 and W[i-1][-1] != W[i][0]:
        ans = 0

if ans == 1 and len(set(W)) != N:
    ans = 0

yn(ans)
Buggy code:
N = int(input())
W = []
W.append(input())
for _ in range(N-1):
    W.append(input())
    if W[-1] in W[:-2]
        print("No")
        break
    if W[-1][0] != W[-2][-1]:
        print("No")
        break
else:
    print("Yes")

Fixed code:
N = int(input())
W = []
W.append(input())
for _ in range(N-1):
    new_W = input()
    if new_W in W:
        print("No")
        break
    if new_W[0] != W[-1][-1]:
        print("No")
        break
    W.append(new_W)
else:
    print("Yes")
Buggy code:
n=int(input())
w=list(list(input()) for i in range(n))
f=True
c=-1
for i in range(n-1):
    for j in range(n):
        if w[i]!=w[j]:
            c+=1
    if w[i+1][0]!=w[i][-1] or c>0:
        f=False

if f:
    print("Yes")
else:
    print("No")


Fixed code:
n=int(input())
w=list(list(input()) for i in range(n))
f=True
c=0
for i in range(n):
    for j in range(n):
        if w[i]==w[j]:
            c+=1
    if (i!=n-1 and w[i+1][0]!=w[i][-1]) or c>n:
        f=False
if f:
    print("Yes")
else:
    print("No")
Buggy code:
def shiritori():
    n = int(input())
    words = [input() for _ in range(n)]
    print(words)
    for word in words:
        count = 0
        for w in words:
            if w == word:
                count += 1
        if count > 1:
            print('No')
            exit()
    
    for i in range(n):
        if i + 1 <= n - 1:
            x = words[i+1][0]
            y = words[i][-1]
            if x == y:
                continue
            else:
                print('No')
                exit()
    
    print('Yes')


if __name__ == '__main__':
    shiritori()


Fixed code:
def shiritori():
    n = int(input())
    words = [input() for _ in range(n)]

    for word in words:
        count = 0
        for w in words:
            if w == word:
                count += 1
        if count > 1:
            print('No')
            exit()
    
    for i in range(n):
        if i + 1 <= n - 1:
            x = words[i+1][0]
            y = words[i][-1]
            if x == y:
                continue
            else:
                print('No')
                exit()
    
    print('Yes')


if __name__ == '__main__':
    shiritori()
Buggy code:
n = int(input())
w = []
hantei = []
ans = ''
for i in range(n):
    w.append(input())
hantei.append(w[0])
for i in range(1,n):
    if w[i - 1][-1] == w[i][0] and w[i] not in hantei:
        ans = 'Yes'
    else:
        ans = 'No'
        break
print(ans)

Fixed code:
n = int(input())
w = []
hantei = []
ans = ''
for i in range(n):
    w.append(input())
hantei.append(w[0])
for i in range(1,n):
    if w[i - 1][-1] == w[i][0] and w[i] not in hantei:
        ans = 'Yes'
        hantei.append(w[i])
    else:
        ans = 'No'
        break
print(ans)
Buggy code:
l=[(i,input()) for i in range(int(input()))]
for i,w in l:
  if i:
    if l[i][0]!=l[i-1][-1] or w in l[:i]:
      exit(print('No'))
print('Yes')

Fixed code:
l=[input() for _ in range(int(input()))]
for i,w in enumerate(l):
  if i:
    if l[i][0]!=l[i-1][-1] or w in l[:i]:
      exit(print('No'))
print('Yes')
Buggy code:
N=int(input())
B=list()
B.append(input())
for i in range(N-1):
	tmp=input()
	if tmp in B:
		print('No')
		exit()
	if tmp[0]!=B[i-1][-1]:
		print('No')
		exit()
print('Yes')

Fixed code:
N=int(input())
B=list()
B.append(input())
ans='Yes'
for i in range(N-1):
    tmp=input()
    if tmp in B:
        ans='No'
    if tmp[0]!=B[i][-1]:
        ans='No'
    B.append(tmp)
print(ans)
Buggy code:
N = int(input())
W = [input() for _ in range(N)]


def has_duplicates(x):
    return len(x) == len(set(x))


if (has_duplicates(W)):
    s = ''
    for i, v in enumerate(W):
        if (i == 0):
            s = v[-1]
            continue
        elif(i > 0 and i < len(W) - 1):
            if (s == v[0]):
                s = v[-1]
                print(s)
            else:
                print('No')
                exit()
        else:
            if (s == v[0]):
                print('Yes')
            else:
                print('No')
                exit()
else:
    print('No')


Fixed code:
N = int(input())
W = [input() for _ in range(N)]


def has_duplicates(x):
    return len(x) == len(set(x))


if (has_duplicates(W)):
    s = ''
    for i, v in enumerate(W):
        if (i == 0):
            s = v[-1]
            continue
        elif(i > 0 and i < len(W) - 1):
            if (s == v[0]):
                s = v[-1]
            else:
                print('No')
                exit()
        else:
            if (s == v[0]):
                print('Yes')
            else:
                print('No')
else:
    print('No')
Buggy code:
n = int(input())
l = []
e = ["_"]
ans = "Yes"
for i in range(n):
  w = input()
  if w[-1] in e or w in l : ans = "No" 
  l.append(i)
  e[0] = w[-1]
print(ans)

Fixed code:
n = int(input())
l = []
e = "abcdefghijklmnopqrstuvwxyz"
ans = "Yes"
for i in range(n):
  w = input()
  if w[0] not in e or w in l : ans = "No" 
  l.append(w)
  e = w[-1]
print(ans)
Buggy code:
N = int(input())
W = [input() for i in range(N)]
flag = True

if len(set(W)) == N:
    for i in range(N - 1):
        if W[i][-1] != W[i + 1][0]:
            flag = False
            break
    if flag:
        print('Yes')
else:
    print('No')


Fixed code:
N = int(input())
W = [input() for i in range(N)]
flag = True

if len(set(W)) == N:
    for i in range(N - 1):
        if W[i][-1] != W[i + 1][0]:
            flag = False
            break
    if flag:
        print('Yes')
    else:
        print('No')
        
else:
    print('No')
Buggy code:
N = int(input())
W = []
W.append(input())
for n in range(N):
  w = input()
  if w[0] != W[-1][-1]:
    print("No")
    break
  elif W.count(w) != 0:
    print("No")
    break
else:
  print("Yes")
  

Fixed code:
N = int(input())
W = []
W.append(input())
for n in range(N-1):
  w = input()
  if w[0] != W[-1][-1]:
    print("No")
    break
  elif W.count(w) != 0:
    print("No")
    break
  W.append(w)
else:
  print("Yes")
Buggy code:
# input
N = int(input())
W = [input() for n in range(N)]

# check
before = W[0]
for i in range(1, N):
    if W[i][0] != before[-1] or W[i] in W[:i]:
        print("No")
        exit(0)
print("Yes")

Fixed code:
# input
N = int(input())
W = [input() for n in range(N)]

# check
before = W[0]
for i in range(1, N):
    if W[i][0] != before[-1] or W[i] in W[:i]:
        print("No")
        exit(0)
    before = W[i]
print("Yes")
Buggy code:
n = int(input())
L = [input() for i in range(n)]
ans = "Yes"
for i in range(n):
    if L[i] in L:
        ans = "No"
for i in range(n-1):
    if L[i][-1] !=L[i+1][0]:
        ans ="No"
print(ans)

Fixed code:
n = int(input())
L = [input() for i in range(n)]
ans = "Yes"
if len(L) != len(set(L)):
    ans = "No"
for i in range(n-1):
    if L[i][-1] !=L[i+1][0]:
        ans ="No"
print(ans)
Buggy code:
n=int(input())
s=input()
a=[]
last=s[-1]
a.append(s)

for i in range(n-1):
  s=input()
  a.append(s)
  if s[0]!=last:
    print(s[0])
    print(last)
    print('No')
    break
  last=s[-1]
  if i==n-2 and len(a)==len(set(a)):
    print(a)
    print(set(a))
    print('Yes')
  elif i==n-2:
    print('No')
    

Fixed code:
n=int(input())
s=input()
a=[]
last=s[-1]
a.append(s)

for i in range(n-1):
  s=input()
  a.append(s)
  if s[0]!=last:
    print('No')
    break
  last=s[-1]
  if i==n-2 and len(a)==len(set(a)):
    print('Yes')
  elif i==n-2:
    print('No')
Buggy code:
N = int(input())
A = []
for i in range(N):
   A.append(input())

for i in range(N-1):
     S = 0
     if A[i][-1] == A[i+1][0]:
        S += 1
for i in range(N):
  for j in range(N):
    if i != j:
      if A[i] == A[j]:
        A == 1
      else:
        A == 0

if S == 1 and A == 0:
  print('Yes')
else:

Fixed code:
N = int(input())
A = []
for i in range(N):
   A.append(input())
S = 0
for i in range(N-1):
    if A[i][-1] == A[i+1][0]:
        S += 1
B = 0
for i in range(N):
    for j in range(N):
        if A[i] == A[j]:
            B += 1
        else:
            B += 0

if S == N-1 and B == N:
    print('Yes')
else:
    print('No')
Buggy code:
n=int(input())
w=[]
flag=True
for i in range(n):
    w.append(input())
    
for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        flag=False

for i in range(n-1):
    for j in range(i+1,n):
        if(w[i]!=w[j]):
            flag=False

if flag==True:
    print("Yes")
else:
    print("No")




Fixed code:
n=int(input())
w=[]
flag=True
for i in range(n):
    w.append(input())
    
for i in range(n-1):
    if w[i][-1]!=w[i+1][0]:
        #print(i,"out1")
        flag=False

for i in range(n-1):
    for j in range(i+1,n):
        if(w[i]==w[j]):
            #print(i,j,"out2")
            flag=False

if flag==True:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
W = {}
last=""
flg = True

w =[]

for i in range(N):
    w.append(str(input()))
    
    
for i in w:
    temp = i
    
    if temp in W:
        flg = False
        break
    else:
        W[temp] = 1
        
    if i !=0:
        if temp[0] == last:
            last  = temp[-1]
        else:
            flg = False
            break
    else:
        last = temp[-1]
            
            
            
if(flg == True):
    print("Yes")
else:
    print("No")
        

Fixed code:
N = int(input())
W = {}
last=""
flg = True

w =[]

for i in range(N):
    w.append(str(input()))
    
cnt=0
for i in w:
    
    if i in W:
        flg = False
        break
    else:
        W[i] = 1
        
    if cnt !=0:
        if i[0] == last:
            last = i[-1]
        else:
            flg = False
            break
    else:
        last = i[-1]
            
    cnt+=1
        
if(flg == True):
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
A = list()
cnt = 0
A.append(input())
for i in range(N-1):
  x = input()
  if x in A:
    cnt = 1
  elif A[i][-1:] != x[0]:
    cnt = 1
  else:
    A.append(x)
print('Yes' if cnt == 0 else 'No')

Fixed code:
N = int(input())
A = list()
cnt = 0
A.append(input())
for i in range(N-1):
  x = input()
  if x in A:
    cnt = 1
  elif A[i][-1:] != x[0]:
    cnt = 1
  A.append(x)
print('Yes' if cnt == 0 else 'No')
Buggy code:
N=int(input())
F=input()
A=1
B=[]
B.append(F)
for i in range(N-1):
    L=input()
    B.append(L)
    if L in B:
        A=0
    if F[-1]!=L[0]:
        A=0
    F=L
if A==0:
    print("No")
else:
    print("Yes")


Fixed code:
N=int(input())
F=input()
A=1
B=[]
B.append(F)
for i in range(N-1):
    L=input()
    if L in B:
        A=0
    B.append(L)
    if F[-1]!=L[0]:
        A=0
    F=L
if A==0:
    print("No")
else:
    print("Yes")
Buggy code:
n = int(input())
l = []
for i in range(n):
    w = input()
    l.append(w)
for k in range(n):
    if  l[k-1][-1] == l[k][0]:
        for j in range(i):
            if l[k] == l[j]:
                flag = 0
                break
            else:
                flag = 1
    else:
        flag = 0
if(flag == 1):
    print('Yes')
else:
    print('No')

Fixed code:
n = int(input())
l = []
flag = 0
for i in range(n):
    w = input()
    l.append(w)
for k in range(1,n):
    if  l[k-1][-1] != l[k][0]:
        flag =1
        break

    for j in range(k):
        if l[k] == l[j]:
            flag = 1
            break
        
if(flag == 1):
    print('No')
else:
    print('Yes')