qyliang/CodeNanoFix huggingface dataset:
Buggy code:
N = int(input())
W = [input() for _ in range(N)]

prev = ''
if len(set(W)) != len(W):
    exit(0)

prev = W[0]
for w in W[1:]:
    if prev[-1] != w[0]:
        print(prev[-1], w[0])
        print('No')
        exit(0)
    prev = w
print('Yes')

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

if len(set(W)) != len(W):
    print('No')
    exit(0)

prev = W[0]
for w in W[1:]:
    if prev[-1] != w[0]:
        print('No')
        exit(0)
    prev = w
print('Yes')
Buggy code:
n=int(input())
klist=[input() for i in range(n)]
kset=set(klist)
if len(kset)!=len(klist):
  print("No")
else:
  for i in range(n-1):
    if klist[i][-1]!=klist[i+1][0]:
      print("No")
      break
  print("Yes")

Fixed code:
n=int(input())
klist=[input() for i in range(n)]
ans=1
kset=set(klist)
if len(kset)!=len(klist):
  print("No")
  ans=2
else:
  for i in range(n-1):
    if klist[i][-1]!=klist[i+1][0]:
      print("No")
      ans=2
      break
      
if ans==1:
  print("Yes")
Buggy code:
n = int(input())
words = []
for i in range(n):
    words.append(input())
if len(words) != len(list(set(words))):
    print("No")
    exit()
for i in range(len(words)-1):
    if words[i][-1] != words[i+1][-1]:
        print("No")
        exit()
print("Yes")

Fixed code:
n = int(input())
words = []
for i in range(n):
    words.append(input())
if len(words) != len(list(set(words))):
    print("No")
    exit()
for i in range(len(words)-1):
    if words[i][-1] != words[i+1][0]:
        print("No")
        exit()
print("Yes")
Buggy code:
import sys
n = int(input())
words = input().split()
for i in range(n-1)
    for j in range(1, i):
        if words[i] == words[j]:
                print('No')
                sys.exit()
    if words[i][-1] != words[i+1][1]:
        print('No')
        sys.exit()
print('Yes')

Fixed code:
import sys
n = int(input())
words=[]
for i in range(n):
    words += [input()]
for i in range(n-1):
    for j in range(i+1, n):
        if words[i] == words[j]:
                print('No')
                sys.exit()
    if words[i][-1] != words[i+1][0]:
        print('No')
        sys.exit()
print('Yes')
Buggy code:
import numpy as np
import sys

input = sys.stdin.readline

N = int(input())

x = []

res = True
for i in range(N):
    w = input()
    w = w[:(len(w)-1)]
    if w in x:
        res = False
    x.append(w)
    print(w,w[0],x[i-1][-1],res)
    if i > 0: 
        if w[0] != x[i-1][-1]:
            res = False
        

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


Fixed code:
import numpy as np
import sys

input = sys.stdin.readline

N = int(input())

x = []

res = True
for i in range(N):
    w = input()
    w = w[:(len(w)-1)]
    if w in x:
        res = False
    x.append(w)
    if i > 0: 
        if w[0] != x[i-1][-1]:
            res = False
        

if res:print("Yes")
else:print("No")
Buggy code:
import sys
input = sys.stdin.readline
N = int(input())
W = [input() for _ in range(N)]
for i in range(1,N):
    if W[i-1][-1] == W[i][0] or W[i] in W[:i]:
        print("No")
        sys.exit()
print("Yes")

Fixed code:
import sys
input = sys.stdin.readline
N = int(input())
W = [input().rstrip() for _ in range(N)]
for i in range(1,N):
    if W[i-1][-1] != W[i][0] or W[i] in W[:i]:
        print("No")
        sys.exit()
print("Yes")
Buggy code:
n=int(input())
w=list()
for i in range(n):
    w.append(input())
ws=set(w)
if len(ws)!=n:
    print("No")
    exit()
for i in range(n):
    x=i+1
    if w[i][-1]!=w[x][0]:
        print("No")
        exit()
print("Yes")

Fixed code:
n=int(input())
w=list()
for i in range(n):
    w.append(input())
ws=set(w)
if len(ws)!=n:
    print("No")
    exit()
x=0
for i in range(n-1):
    x=i+1
    if w[i][-1]!=w[x][0]:
        print("No")
        exit()
print("Yes")
Buggy code:
n=int(input())
w=[input() for i range(n)]
d={}
for i in range(n):
  if w[i] not in d:
    d[w[i]]=1
  else:
    print('No')
    exit()
for i in range(n-1):
  if w[i][len(w[i])-1]!=w[i+1][0]:
    print('No')
    exit()
print('Yes')

Fixed code:
n=int(input())
w=[input() for i in range(n)]
d={}
for i in range(n):
  if w[i] not in d:
    d[w[i]]=1
  else:
    print('No')
    exit()
for i in range(n-1):
  if w[i][len(w[i])-1]!=w[i+1][0]:
    print('No')
    exit()
print('Yes')
Buggy code:
N = int(input())
words = []
s = input()
words.append(s)
ans = True
for i in range(N-1):
    t = input()
    print(t in words)
    if(t[0] == s[-1] and (t in words) == False):
        words.append(t)
        s = t
    else:
        ans = False
        break
if(ans):
    print("Yes")
else:
    print("No")

Fixed code:
N = int(input())
words = []
s = input()
words.append(s)
ans = True
for i in range(N-1):
    t = input()
    if(t[0] == s[-1] and (t in words) == False):
        words.append(t)
        s = t
    else:
        ans = False
if(ans):
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
W = input()
L = []
L.append(W)
last = W[-1]
ans = 'Yes'
for _ in range(N-1):
    w = input()
    if w in L:
        ans = 'No'
    if last == w[0]:
        last = w[-1]
    else:
        ans = 'No'
print(ans)

Fixed code:
N = int(input())
W = input()
L = []
L.append(W)
last = W[-1]
ans = 'Yes'
for _ in range(N-1):
    w = input()
    if w in L:
        ans = 'No'
    if last == w[0]:
        last = w[-1]
        L.append(w)
    else:
        ans = 'No'
print(ans)
Buggy code:
n=int(input())
w = [(input()) for _ in range(n)]
l = set(w)
if len(w) != len(l):
        print('No')
        exit()
for i in range(n-1):
        if w[i][len(w[i]-1)] != w[i+1][0]:
                print('No')
                exit()
print('Yes')

Fixed code:
n=int(input())
w = [(input()) for _ in range(n)]
l = set(w)
if len(w) != len(l):
        print('No')
        exit()
for i in range(n-1):
        if w[i][len(w[i])-1] != w[i+1][0]:
                print('No')
                exit()
print('Yes')
Buggy code:
import sys

N = int(input())

W = []
for i in range(N):
    w = str(input())
    if w in W:
        print("No")
        sys.exit()
    if i != 0 and w[-1] != W[-1][-1]:
        print("No")
        sys.exit()
    W.append(w)

print("Yes")

Fixed code:
import sys

N = int(input())

W = []
for i in range(N):
    w = str(input())
    if w in W:
        print("No")
        sys.exit()
    if i != 0 and w[0] != W[i-1][-1]:
        print("No")
        sys.exit()
    W.append(w)

print("Yes")
Buggy code:
n = int(input())
prev = input()
s = set([prev])
for i in range(n-1):
    w = input()
    if w in s:
        print('No')
        exit()
    if w[0] != prev[-1]:
        print('No')
        exit()
    prev = w
print('Yes')

Fixed code:
n = int(input())
prev = input()
s = set([prev])
for i in range(n-1):
    w = input()
    if w in s:
        print('No')
        exit()
    if w[0] != prev[-1]:
        print('No')
        exit()
    s.add(w)
    prev = w
print('Yes')
Buggy code:
n = int(input())
w_list = [input() for nesya in range(n)]
a = len(set(w_list))
t = 1
c = 0
while t < n:
  if (w_list[t-1])[-1] != (w_list[t])[0]:
    print('No')
    break
    c += 1
  t +=1
if c == 0:
  if a == n:
    print('Yes')
  else:
    print('No')

Fixed code:
n = int(input())
w_list = [input() for nesya in range(n)]
a = len(set(w_list))
t = 1
c = 0
while t < n:
  if (w_list[t-1])[-1] != (w_list[t])[0]:
    print('No')
    c += 1
    break
  t +=1
if c == 0:
  if a == n:
    print('Yes')
  else:
    print('No')
Buggy code:
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
if li[-2][-1] == li[-1][0]:
    print('No')
    exit()
for j in range(n-1):
    if li[j][-1] == li[j+1][0]:
        for k in range(j):
            if li[j] == li[k]:
                print('No')
                exit()
    else:
        print('No')
        exit()
print('Yes')


Fixed code:
# Shiritori
n = int(input())
li = []
for i in range(n):
    li.append(list(input()))
for j in range(n-1):
    if li[j][-1] == li[j+1][0]:
        for k in range(j):
            if li[j] == li[k] or li[-1] == li[k]:
                print('No')
                exit()
    else:
        print('No')
        exit()
print('Yes')
Buggy code:
n = int(input())

last = None
seen = set()
for _ in range(n):
  w = input()
  if w in seen or (last and last[-1] != w):
    print("No")
    break
  seen.add(w)
else:
  print("Yes")

Fixed code:
n = int(input())

last = None
seen = set()
for _ in range(n):
  w = input()
  if w in seen or (last and last[-1] != w[0]):
    print("No")
    break
  seen.add(w)
  last = w
else:
  print("Yes")
Buggy code:
n = int(input())
w = [str(input()) for _ in range(n)]
tmp = 0

for i in range(n-1):

    if w.count(w[i])==1 and str(w[i])[-1]==str(w[i+1])[0]:
        tmp += 1

if tmp==n:
    print('Yes')
else:
    print('No')

Fixed code:
n = int(input())
w = [str(input()) for _ in range(n)]
tmp = 0

for i in range(n-1):

    if w.count(w[i])==1 and str(w[i])[-1]==str(w[i+1])[0]:
        tmp += 1

if tmp==n-1:
    print('Yes')
else:
    print('No')
Buggy code:
n = int(input())
w = []
w.append(input())
for i in range(1, n):
	W = input()
	if W in w or w[0] != w[i-1][len(w[i-1])-1]:
		print("No")
		exit(0)
	w.append(W)
print("Yes")

Fixed code:
n = int(input())
w = []
w.append(input())
for i in range(1, n):
	W = input()
	if W in w or W[0] != w[i-1][len(w[i-1])-1]:
		print("No")
		exit(0)
	w.append(W)
print("Yes")
Buggy code:
N=int(input())
words=[]
flg=True

before=input()
N=N-1

for i in range(N):
    s=input()
    if before[-1] != s[0]:
        flg=False
    words.append(s)
    if len(words) != len(set(words)):
        flg=False
    before=s
print("Yes" if flg else "No")

Fixed code:
N=int(input())
words=[]
flg=True

before=input()
words.append(before)
N=N-1

for i in range(N):
    s=input()
    if before[-1] != s[0]:
        flg=False
    words.append(s)
    before=s
if len(words) != len(set(words)):
    flg=False
print("Yes" if flg else "No")
Buggy code:
N = int(input())
W = [input() for _ in range(N)]
flag = True 
b = W[0][-1] 
for i in range(1,N): 
  if b == W[i][0]:　
    b = W[i][-1]　
  else: 
    flag = False
    exit()
    
if int(len(W))!=len(set(W)):
  flag = False

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

Fixed code:
N = int(input())
W = [input() for _ in range(N)]
flag = True
b = W[0][-1]
for i in range(1,N): 
  if b == W[i][0]:
    b = W[i][-1]
  else:
    flag = False
    break
    
if int(len(W))!=len(set(W)):
  flag = False

if flag == True:
  print("Yes")
else:
  print("No")
Buggy code:
N = int(input())
list = []
bool = True

for i in range(N):
    list.append(input())
if len(set(list)) != len(list):
    bool = False
else:
    for i in range(N - 1):
        if list[i][-1] != li[i+1][0]:
            bool = False

if bool:
    print('Yes')
else:
    print('No')
        

Fixed code:
N = int(input())
list = []
bool = True

for i in range(N):
    list.append(input())
if len(set(list)) != len(list):
    bool = False
else:
    for i in range(N - 1):
        if list[i][-1] != list[i+1][0]:
            bool = False

if bool:
    print('Yes')
else:
    print('No')
Buggy code:
def solve():
    n = int(input())
    already = set()
    prev = '-'
    for _ in range(n):
        word = input()
        if word in already:
            return False
        if prev[-1] != word[0]:
            return False
        already.add(word)
        prev = word
    return True


print('Yes' if solve() else 'No')


Fixed code:
def solve():
    n = int(input())
    prev = input()
    already = {prev}
    for _ in range(n - 1):
        word = input()
        if word in already:
            return False
        if prev[-1] != word[0]:
            return False
        already.add(word)
        prev = word
    return True


print('Yes' if solve() else 'No')
Buggy code:
N = int(input())
S = [input() for _ in range(N)]

if len(S) != len(set(S)):
    print("No")

next_s = ""
for s in S:
    if next_s == "":
        next_s = s[-1]
        continue
    
    if next_s != s[0]:
        print("No")
        break
    
    next_s = s[-1]
else:
    print("Yes")



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

if len(S) != len(set(S)):
    print("No")
    
else:
    next_s = S[0][0]
    for s in S:
        if next_s != s[0]:
            print("No")
            break
        
        next_s = s[-1]
    else:
        print("Yes")
Buggy code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys


N = int(input())
prev = None
ok = True
for n in range(N):
    w = input()
    if prev is None:
        prev = w
    else:
        if prev[-1] != w[0]:
            ok = False
    prev = w
if ok:
    print('Yes')
else:
    print('No')
    
 


Fixed code:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq 
from itertools import *
import math
import random
import re
import string
import sys

N = int(input())
prev = None
ok = True
seen = set()
for n in range(N):
    w = input()
    if prev is None:
        prev = w
    else:
        if prev[-1] != w[0]:
            ok = False
    if w in seen:
        ok = False
    seen.add(w)
    prev = w
if ok:
    print('Yes')
else:
    print('No')
Buggy code:
# ABC109B

n = int(input())
w = [int(input()) for i in range(n)]
ok = "Yes"
e = w[0][-1]
double = [w[0]]
for i in range(1, n):
    if double.count(w[i]) != 0:
        ok = "No"
        break
    double.append(w[i])
    s = w[i][0]
    if s != e:
        ok = "No"
        break
    e = w[i][-1]
print(ok)


Fixed code:
n = int(input())
w = [input() for i in range(n)]
ok = "Yes"
e = w[0][-1]
double = [w[0]]
for i in range(1, n):
    if double.count(w[i]) != 0:
        ok = "No"
        break
    double.append(w[i])
    s = w[i][0]
    if s != e:
        ok = "No"
        break
    e = w[i][-1]
print(ok)
Buggy code:
N = int(input())
W = [input() for _ in range(N)]
bl = True
if len(W) != len(set(W)):
    bl = False
for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        bl = False
print('Yes' if bl else 'NO')


Fixed code:
N = int(input())
W = [input() for _ in range(N)]
bl = True
if len(W) != len(set(W)):
    bl = False
for i in range(N-1):
    if W[i][-1] != W[i+1][0]:
        bl = False
print('Yes' if bl else 'No')
Buggy code:
n=int(input())
s=set()
wp=input()
s.add(wp)

f=True
for i in range(n-1):
  wn=input()
  if wp[-1]!=wn[0]:
    f=False
  elif s.issubset(set(wp))==True:
    f=False
  wp=wn
  s.add(wn)

print('Yes' if f==True else 'No')


Fixed code:
n=int(input())
s=set()
wp=input()
s.add(wp)

f=True
for i in range(n-1):
  wn=input()
  if wp[-1]!=wn[0]:
    f=False
  elif wn in s:
    f=False
  wp=wn
  s.add(wn)

print('Yes' if f==True else 'No')
Buggy code:
N = int(input())
used = [input()]
flag = 1
for i in range(N-1):
  now = input()
  if now not in used and used[-1][-1] == now[0]:
    used.append(now)
  else:
    flag = 0
   	break
if flag == 1:
  print("Yes")
else:
  print("No")

Fixed code:
N = int(input())
used = [input()]
flag = 1
for i in range(N-1):
  now = input()
  if now not in used and used[-1][-1] == now[0]:
    used.append(now)
  else:
      flag = 0

if flag == 1:
  print("Yes")
else:
  print("No")
Buggy code:
loop=int(input())
word=input()
word_list=list()
word_list.append(word)

for i in range(loop-1):
  word=input()
  for j in range(len(word_list)):
    print(word_list[j],word)
    if word_list[j]==word:
      print("No")
      break
  if word_list[i][-1]!=word[0]:
    print("No")
    break
  if j!=len(word_list)-1:
    break
  word_list.append(word)
  if i==loop-2:
    print("Yes")


Fixed code:
loop=int(input())
word=input()
word_list=list()
word_list.append(word)
 
for i in range(loop-1):
  word=input()
  for j in range(len(word_list)):
    if word_list[j]==word:
      print("No")
      break
  if word_list[i][-1]!=word[0]:
    print("No")
    break
  if j!=len(word_list)-1:
    break
  word_list.append(word)
  if i==loop-2:
    print("Yes")
Buggy code:
n=int(input())
a=[input() for i in range(n)]
s=0
for i in raneg(n-1):
    if a[i][-1]!=a[i+1][0]:
        s+=1
a.sort()
for i in raneg(n-1):
    if a[i]==a[i+1]:
        s+=1
if s==0:
    print("Yes")
else:
    print("No")

Fixed code:
n=int(input())
a=[input() for i in range(n)]
s=0
for i in range(n-1):
    if a[i][-1]!=a[i+1][0]:
        s+=1
a.sort()
for i in range(n-1):
    if a[i]==a[i+1]:
        s+=1
if s==0:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
ws = [input()]

flg = True
for i in range(N-1):
    Wi = input()
    if Wi in ws:
        flg = False
    elif ws[-1] != Wi[0]:
        flg = False
    ws.append(Wi)

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

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

flg = True
for i in range(N-1):
    Wi = input()
    if Wi in ws:
        flg = False
    elif ws[-1][-1] != Wi[0]:
        flg = False
    ws.append(Wi)

if flg:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
ls = []
flag = True
bChar = ""
for n in range(0, N):
  char = input()
  if n == 0:
    ls.append(char)
  else:
    if (char in ls) or (bChar[-1:1] == char[0:1]):
      flag == False
    ls.append(char)
  bChar = char
if flag == True:
  print('Yes')
else:
  print('No')


Fixed code:
N = int(input())
ls = []
flag = True
bChar = ""
for n in range(0, N):
  ch = input()
  if n == 0:
    ls.append(ch)
  else:
    if (ch in ls) or (bChar[-1:] != ch[0:1]):
      flag = False
  ls.append(ch)
  bChar = ch
if flag == True:
  print('Yes')
else:
  print('No')
Buggy code:
n = int(input())
aa = []
for i in range(n):
    a = input()
    aa.append(a)
print(aa)

bb = []
if len(set(aa)) != len(aa):
    print('No')
else:
    for i in range(n-1):
        if aa[i][-1] == aa[i+1][0]:
            bb.append(True)
        else:
            bb.append(False)
    if all(bb):
        print('Yes')
    else:
        print('No')

Fixed code:
n = int(input())
aa = []
for i in range(n):
    a = input()
    aa.append(a)

bb = []
if len(set(aa)) != len(aa):
    print('No')
else:
    for i in range(n-1):
        if aa[i][-1] == aa[i+1][0]:
            bb.append(True)
        else:
            bb.append(False)
    if all(bb):
        print('Yes')
    else:
        print('No')
Buggy code:
n = int(input())
rec = []
flag = True
t = input()
pre = t[-1]
for i in range(1, n):
    s = input()
    if s in rec:
        flag = False
    elif s[0] != pre:
        flag = False
    else:
        rec.append(s)
        pre = s[-1]

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


Fixed code:
n = int(input())
rec = []
flag = True
t = input()
pre = t[-1]
rec.append(t)
for i in range(1, n):
    s = input()
    if s in rec:
        flag = False
    elif s[0] != pre:
        flag = False
    else:
        rec.append(s)
        pre = s[-1]

if flag:
    print("Yes")
else:
    print("No")
Buggy code:
n=int(input())
a=[]
x=str(input())
a[0]=x
d=bool(True)
for i in range(1, n):
  y=str(input)
  if x[len(x)]!=y[0]:
    d=False
  for i in range(a.size()):
    if y==a[i]:
      d=False
  a.append(y)

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

Fixed code:
n=int(input())
a=[]
x=str(input())
a.append(x)
d=bool(True)

for i in range(1, n):
  y=str(input())
  if x[len(x)-1]!=y[0]:
    d=False
    
  for j in range(len(a)):
    if y==a[j]:
      d=False
  a.append(y)
  x=y

if  d==True:
  print("Yes")
else:
  print("No")
Buggy code:
N = int(input())

appeared = []
prev = input()
for i in range(N-1):
    S = input()
    if prev[-1] != S[0] or S in appeared:
        print('No')
        exit()
    prev = S
    appeared += [S]
print('Yes')


Fixed code:
N = int(input())

appeared = []
prev = input()
for i in range(N-1):
    appeared += [prev]
    S = input()
    if prev[-1] != S[0] or S in appeared:
        print('No')
        exit()
    prev = S
print('Yes')
Buggy code:
import sys

n=int(input())
l=[]
for x in range(n):
	l.append(str(input()))
	if x>0:
		if not(l[x-1][-1] == l[x][0]) or (l[:x] in l):
			print("No")
			sys.exit()
print("Yes")


Fixed code:
import sys

n=int(input())
l=[]
for x in range(n):
	l.append(str(input()))
	if x>0:
		if not(l[x-1][-1] == l[x][0]) or (l[x] in l[:x]):
			print("No")
			sys.exit()
print("Yes")
Buggy code:
N = int(input())
words = [input() for i in range(N)]
count=0
if len(words)==len(set(words)):
  for j in range(0,N-1):
    if words[j][-1]==words[j+1][0]:
      count+=1
  if count==N-1:
    print("Yes")
else:
  print("No")
    

Fixed code:
N = int(input())
words = [input() for i in range(N)]
count=0
if len(words)==len(set(words)):
  for j in range(0,N-1):
    if words[j][-1]==words[j+1][0]:
      count+=1
  if count==N-1:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Buggy code:
N = int(input())
word_set = set()
prev_word = ""
cur_word = ""
valid = True
words = ["" for i in range(N)]
for i in range(N):
    words[i] = input()
    
for i in range(1, N):
    if words[i-1] != words[i][0] or words[i] in word_set:
        valid = False
        break
    word_set.add(words[i])
    
if valid:
    print("Yes")
else:
    print("No")

Fixed code:
N = int(input())
word_set = set()
valid = True
words = ["" for i in range(N)]
for i in range(N):
    words[i] = input()

word_set.add(words[0])
for i in range(1, N):
    if words[i-1][-1] != words[i][0] or words[i] in word_set:
        valid = False
        break
    word_set.add(words[i])
    
if valid:
    print("Yes")
else:
    print("No")
Buggy code:
import sys
n = int(input())
w = []
for i in range(n):
  word = input()
  if word in w:
    print('No')
    sys.exit()
cur = w[0][-1]
for x in w[1:]:
  if cur != x[0]:
    print('No')
    sys.exit()
  cur = x[-1]
print('Yes')

Fixed code:
import sys
n = int(input())
w = []
for i in range(n):
  word = input()
  if word in w:
    print('No')
    sys.exit()
  w.append(word)
cur = w[0][-1]
for x in w[1:]:
  if cur != x[0]:
    print('No')
    sys.exit()
  cur = x[-1]
print('Yes')
Buggy code:
n = int(input())
a = [input() for i in range(n)]
ans = 'Yes'
for i in range(n):
    if a.count(a[i])!=1:
        ans = 'No'
        break
for i in range(n-1):
    if a[i][-1] != a[i][0]:
        ans = 'No'
print(ans)


Fixed code:
n = int(input())
a = [input() for i in range(n)]
ans = 'Yes'
for i in range(n):
    if a.count(a[i])!=1:
        ans = 'No'
        break
for i in range(n-1):
    if a[i][-1] != a[i+1][0]:
        ans = 'No'
        break
print(ans)
Buggy code:
N = int(input())
word_list = []
for i in range(N):
    w = str(input())
    if w not in word_list:
        word_list.append(w)
    elif w in word_list:
        print('No')
        break
        
    if i == 0:
        continue
    else:
        if w[0] == word_list[i-1][-1]:
            print('Yes')
        else:
            print('No')
            break

Fixed code:
N = int(input())
word_list = []
yes_or_no = []
for i in range(N):
    w = str(input())
    if w not in word_list:
        word_list.append(w)
    elif w in word_list:
        yes_or_no.append('No')
        
    if i == 0:
        continue
    else:
        if w[0] == word_list[i-1][-1]:
            yes_or_no.append('Yes')
        else:
            yes_or_no.append('No')
if 'No' in yes_or_no:
    print('No')
else:
    print('Yes')
Buggy code:
N = int(input())
dic = dict()
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1
    Start  = S[0]
    if i != 0:
        if Start != End or dic[S] > 1:
            print("No")
            exit
    End = S[len(S)-1]
print("Yes")

Fixed code:
N = int(input())
dic = dict()
for i in range(N):
    S = input()
    if S in dic:
        dic[S] += 1
    else:
        dic[S] = 1
    Start  = S[0]
    if i != 0:
        if Start != End or dic[S] > 1:
            print("No")
            exit()
    End = S[len(S)-1]
print("Yes")