qyliang/CodeNanoFix huggingface dataset:
Buggy code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    words=[]
    n = int(input())
    words=[input().rstrip() for _ in range(n)]
    print(words)

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

    endstring=""
    for word in words:
        if len(endstring)==0:
            endstring=word[-1]
        else:
            if endstring==word[0]:
                endstring=word[-1]
            else:
                print("No")
                exit()
    print("Yes")


if __name__=="__main__":
    main()

Fixed code:
#-*-coding:utf-8-*-
import sys
input=sys.stdin.readline

def main():
    words=[]
    n = int(input())
    words=[input().rstrip() for _ in range(n)]

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

    endstring=""
    for word in words:
        if len(endstring)==0:
            endstring=word[-1]
        else:
            if endstring==word[0]:
                endstring=word[-1]
            else:
                print("No")
                exit()
    print("Yes")


if __name__=="__main__":
    main()
Buggy code:
n=int(input())
w=[]
ws=[]
count=1
for i in range(n):
    w.append(input())
    ws.append(list(w[i]))
for i in range(n):
    if (w.count(w[i]))>1:
        count-=1
for j in range(n-1):
    if (ws[j][len(w[j])-1])==(ws[j+1][0]):
        count+=1
if count==(n):
    print('Yes')
else:
    print('N0')

Fixed code:
n=int(input())
w=[]
ws=[]
count=1
for i in range(n):
    w.append(input())
    ws.append(list(w[i]))
for i in range(n):
    if (w.count(w[i]))>1:
        count-=1
for j in range(n-1):
    if (ws[j][len(w[j])-1])==(ws[j+1][0]):
        count+=1
if count==int(n):
    print('Yes')
else:
    print('No')
Buggy code:
n=int(input())
a=[]
for i in range(n):
  aa=input()
  if aa in a or aa[0] != a[-1][0]:
    print("No")
    break
  if i == n-1:
    print("Yes")
  a.append(aa)

Fixed code:
n=int(input())
a=[input()]
for i in range(n-1):
  aa=input()
  if aa in a or aa[0] != a[-1][-1]:
    print("No")
    break
  if i == n-2:
    print("Yes")
  a.append(aa)
Buggy code:
n=int(input())
s=set()
flag=True
for i in range(n):
    buf=""
    str=input()
    if buf!="" and str[0]!=buf[:-1]:
        flag=False
    if str in s:
        flag=False
    s.add(str)
    buf=str

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


Fixed code:
n=int(input())
s=set()
flag=True
buf=""
for i in range(n):
    str=input()
    if buf!="" and str[0]!=buf[-1:]:
        flag=False
    if str in s:
        flag=False
    s.add(str)
    buf=str

if flag:
    print("Yes")
else:
    print("No")
Buggy code:
n = int(input())
words = [input() for i in range(n)]
checkWords = set(words)
flag = True
if len(checkWords) != n:
    print("No")
else:
    for i in range(n-1):
        print(words[i])
        print(words[i+1])
        if words[i][-1] != words[i+1][0]:
            flag = False
    print("Yes") if flag else print("No")

Fixed code:
n = int(input())
words = [input() for i in range(n)]
checkWords = set(words)
flag = True
if len(checkWords) != n:
    print("No")
else:
    for i in range(n-1):
        if words[i][-1] != words[i+1][0]:
            flag = False
    print("Yes") if flag else print("No")
Buggy code:
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())

N = int(input())
SS = [0]*N
s = set()
SS[0] = str(input())
for i in range(1,N):
    SS[i] = str(input())
    if(SS[i] in s):
        print('No')
        sys.exit()
    s.add(SS[i])
for i in range(1,N):
    if(SS[i-1][-1] != SS[i][0]):
        print('No')
        sys.exit()
print('Yes')


Fixed code:
import sys
# N,M = [int(n) for n in input().split()]
# S = str(input())
# T = str(input())

N = int(input())
SS = [0]*N
s = set()
SS[0] = str(input())
s.add(SS[0])
for i in range(1,N):
    SS[i] = str(input())
    if(SS[i] in s):
        print('No')
        sys.exit()
    s.add(SS[i])
for i in range(1,N):
    if(SS[i-1][-1] != SS[i][0]):
        print('No')
        sys.exit()
print('Yes')
Buggy code:
n = int(input())
flag = True
s = []
words = []
w1 = input()
words.append(w1)
e = w1[-1]
print(e)
for i in range(n-1):
    wi = input()
    if e != wi[0]:
        flag = False
    for w in words:
        if w == wi:
            flag = False
    words.append(wi)
    e = wi[-1]
    print(e)

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

Fixed code:
n = int(input())
flag = True
s = []
words = []
w1 = input()
words.append(w1)
e = w1[-1]

for i in range(n-1):
    wi = input()
    if e != wi[0]:
        flag = False
    for w in words:
        if w == wi:
            flag = False
    words.append(wi)
    e = wi[-1]


if flag:
  print("Yes")
else:
  print("No")
Buggy code:
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=""
for i in range(N):
  word = input()
  if word in siritori:
    print("No")
  elif prev[-1]==word[0]:
    print("No")
  siritori[word]+=1
  prev=word
print("Yes")

Fixed code:
import collections
N=int(input())
siritori=collections.defaultdict(int)
prev=" "
for i in range(N):
  word = input()
  if word in siritori:
    print("No")
    exit(0)
  elif prev[-1]!=word[0] and i != 0:
    print("No")
    exit(0)
  siritori[word]+=1
  prev=word
print("Yes")
Buggy code:
n = int(input())
w = [input() for i in range(n)]

for i in range(n-1):
    if w.count(w[i]) > 1:
        print('No')
        break
    elif w[i][-1] != w[i+1][0]:
        print('No')
        break
    else:    
        print('Yes')

Fixed code:
n = int(input())
w = [input() for i in range(n)]
a = 'Yes'
for i in range(n-1):
    if w.count(w[i]) > 1:
        a = 'No'
        break
    elif w[i][-1] != w[i+1][0]:
        a = 'No'
        break    
print(a)
Buggy code:
n= int(input())

def is_unique(seq):
    return len(seq) == len(set(seq))

warray = []
for i in range(n):
    warray.append(input())

torf = True

if not is_unique(warray):
    torf = False

for i in range(len(warray) - 1):
    if warray[i][-1] == warray[i+1][0]:
        torf = False

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



Fixed code:
n= int(input())

def is_unique(seq):
    return len(seq) == len(set(seq))

warray = []
for i in range(n):
    warray.append(input())

torf = True

if not is_unique(warray):
    torf = False

for i in range(len(warray) - 1):
    if warray[i][-1] != warray[i+1][0]:
        torf = False

if torf:
    print("Yes")
else :
    print("No")
Buggy code:
N=int(input())
L=[]
a=True
for i in range(n):
  L.append(input())
if len(L)!=len(set(L)):
  print('No')
else:
  for i in range(1,len(L)):
    if L[i][0]==L[i-1][-1]:
      continue
    else:
      a=False
  if a is True:
    print('Yes')
  else:
    print('No')



Fixed code:
n=int(input())
L=[]
a=True
for i in range(n):
  L.append(input())
if len(L)!=len(set(L)):
  print('No')
else:
  for i in range(1,len(L)):
    if L[i][0]==L[i-1][-1]:
      continue
    else:
      a=False
  if a is True:
    print('Yes')
  else:
    print('No')
Buggy code:
import sys
n = int(input())
w = input()
words=[]

words.append(w)

for i in range(1,n):
    w = input()
    words.append(w)
    if w not in words:
        if words[i-1][-1]==sords[i][0]:
            continue
        else:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()
print("Yes")

Fixed code:
import sys
n = int(input())
w = input()
words=[]

words.append(w)

for i in range(1,n):
    w = input()
    if w not in words:
        if words[-1][-1]==w[0]:
            words.append(w)
            continue
        else:
            print("No")
            sys.exit()
    else:
        print("No")
        sys.exit()
print("Yes")
Buggy code:
N = int(input())

W = [input() for w in range(N)]

for i in range(1,len(W)):
  if W[i-1][-1] == W[i][0] or W[i] in W[:i]:
    print("No")
    break
else:print("Yes")

Fixed code:
N = int(input())

W = [input() for w in range(N)]

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

Fixed code:
n = int(input())
words = []
before= input()
words.append(before)
flag = True
for _ in range(n-1):
  
  s = input()
  if before[-1] != s[0]:
    flag = False
  before = s
  words.append(s)

l = len(set(words))
if l != n:
  flag = False
if flag:
  print("Yes")
else:
  print("No")
Buggy code:
N = int(input())
hist = [input()]
res = 'No'
s = hist[0][-1]
for _ in range(N-1):
  w = input()
  if w in hist or w[-1] != s:
    break
  s = w[-1]
  hist.append(w)
else:
  res = 'Yes'
print(res)

Fixed code:
N = int(input())
hist = [input()]
res = 'No'
s = hist[0][-1]
for _ in range(N-1):
  w = input()
  if w in hist or w[0] != s:
    break
  s = w[-1]
  hist.append(w)
else:
  res = 'Yes'
print(res)
Buggy code:
N = int(input())

W = []

W.append(input())

for n in range(N):
    w = input()

    if( w[0] == W[n][-1] and w not in W):
        W.append(w)
        continue

    else:
        print('No')
        exit()

print('Yes')

Fixed code:
N = int(input())

W = []

W.append(input())

for n in range(N-1):
    w = input()

    if( w[0] == W[n][-1] and w not in W):
        W.append(w)
        continue

    else:
        print('No')
        exit()

print('Yes')
Buggy code:
n = int(input())
w = [input() for _ in range(n)]

flag = 1
if len(set(w)) == n:
    f = w[0][-1]
    for i in range(1, len(w)):
        if f != w[i][0]:
            flag = 0
else:
    flag = 0

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


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

flag = 1
if len(set(w)) == n:
    f = w[0][-1]
    for i in range(1, len(w)):
        if f != w[i][0]:
            flag = 0
        f = w[i][-1]
else:
    flag = 0

if flag:
    print("Yes")
else:
    print("No")
Buggy code:
n = int(input())
l = []
for _ in range(n):
  s = input()
  if s in l or s[0] != s[-1]:
    print('No')
    exit()
  l.append(s)
print('Yes')


Fixed code:
n = int(input())
l = [input()]
for _ in range(n-1):
  s = input()
  if s in l or s[0] != l[-1][-1]:
    print('No')
    exit()
  l.append(s)
print('Yes')
Buggy code:
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
W = read().decode('utf8').split()
temp = W[0][-1]
Ws = set(W)
if len(Ws) != N:
    print("No")
else:
    for w in W[1:]:
        if temp == w[0]:
            temp = w[-1]
        else:
            print("No")
            break
    print("Yes")


Fixed code:
"""
author : halo2halo
date : 23, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N = int(readline())
W = read().decode('utf8').split()
temp = W[0][-1]
Ws = set(W)
f = True
if len(Ws) != N:
    f = False

else:
    for w in W[1:]:
        if temp == w[0]:
            temp = w[-1]
        else:
            f = False
            break
print("Yes" if f else "No")
Buggy code:
# PROXY

N = int(input())
list = [input() for i in range(N)]


def has_duplicates(seq):
    return len(seq) != len(set(seq))
    
if has_duplicates(list):
    print("No")
else:
    i = 1
    while i < N:
        if list[i-1][-1] != list[i][0]:
            print("No")
            break
        else:
            i += 1
            print("Yes")

Fixed code:
# PROXY

N = int(input())
list = [input() for i in range(N)]
def has_duplicates(seq):
    return len(seq) != len(set(seq))    
if has_duplicates(list):
    print("No")
else:
    i = 1
    while i < N:
        if list[i-1][-1] != list[i][0]:
            print("No")
            break
        else:
            i += 1
    else:
        print("Yes")
Buggy code:
n = int(input())
w = [input() for i in range(n)]

def is_shiritori():
  if len(set(w)) != n:
    return 'No'
  for i in range(n-1):
    if w[n][-1] != w[n+1][0]:
      return 'No'
  return 'Yes'
print(is_shiritori())

Fixed code:
n = int(input())
w = [input() for i in range(n)]

def is_shiritori():
  if len(set(w)) != n:
    return 'No'
  for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
      return 'No'
  return 'Yes'

print(is_shiritori())
Buggy code:
n=int(input())
S=[input() for _ in range(n)]
ans=1
for i in range(n-1):
    if S[i][-1] == S[i+1][0]:
        ans += 1
print("Yes" if ans == n else "No")

Fixed code:
n=int(input())
S=[input() for _ in range(n)]
ans=1
for i in range(n-1):
    if (S[i][-1] == S[i+1][0])*(S[i+1] not in S[:i+1]):
        ans += 1
print("Yes" if ans == n else "No")
Buggy code:
N = int(input())
ary = []
s = 'Yes'
for i in range(N):
  w = input()
  if w in ary:
    s = 'No'
    break
  if len(ary) > 0 and w[0] != ary[-1][-1]:
    s = 'No'
    break
    
print(s)

Fixed code:
N = int(input())
ary = []
s = 'Yes'
for i in range(N):
  w = input()
  if w in ary:
    s = 'No'
    break
  if len(ary) > 0 and w[0] != ary[-1][-1]:
    s = 'No'
    break
  ary.append(w)
    
print(s)
Buggy code:
n = int(input())
word = []
for i in range(n):
	word.append(input())

if is_unique(word) == False:
	print("No")
	exit()

for i in range(1,len(word)):
	if word[i-1][-1] != word[i][0]:
		print("No")
		exit()

print("Yes")

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

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

for i in range(1,len(word)):
	if word[i-1][-1] != word[i][0]:
		print("No")
		exit()

print("Yes")
Buggy code:

N = int(input())

lst_W = []
for i in range(N):
    lst_W.extend(input().split())

ans = "Yes"

for i in range(N - 1):
    if (lst_W[i])[-1:] != (lst_W[i+1])[:1]:
        ans = "No"
        break

if len(lst_W) != len(set(lst_W)):
    #ans = "No"

print(ans)

Fixed code:

N = int(input())

lst_W = []
for i in range(N):
    lst_W.extend(input().split())

ans = "Yes"

for i in range(N - 1):
    if (lst_W[i])[-1:] != (lst_W[i+1])[:1]:
        ans = "No"
        break

if len(lst_W) != len(set(lst_W)):
    ans = "No"

print(ans)
Buggy code:
N = int(input())
dic = [input()]
for n in range(N-1):
    s = input()
    if s in dic:
        print('No')
        break
    else:
        if dic[-1][-1] == s[0]:
            dic.append(s)
        else:
            print('No')
            break


Fixed code:
N = int(input())
dic = [input()]
check = 0
for n in range(N-1):
    s = input()
    if s in dic:
        print('No')
        check = 1
        break
    else:
        if dic[-1][-1] == s[0]:
            dic.append(s)
        else:
            print('No')
            check = 1
            break
if check == 0:
    print('Yes')
Buggy code:
N = int(input())
W = [input() for i in range(N)]

f = True
for i in range(len(W)-1):
    if W[i][-1] != W[i+1][0]:
        f = False
        break

print(f)

if f and N==len(set(W)):
    print('Yes')
else:
    print('No')


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

f = True
for i in range(len(W)-1):
    if W[i][-1] != W[i+1][0]:
        f = False
        break

if f and N==len(set(W)):
    print('Yes')
else:
    print('No')
Buggy code:
import sys
n=int(input())
w=[input() for i in range(n)]
if all(w[j][len(w[j])]==w[j+1][0] for j in range(n-1)) and len(set(w))==n:
  print('Yes')
  sys.exit()
print('No')

Fixed code:
import sys
n=int(input())
w=[input() for i in range(n)]
if all(w[j][len(w[j])-1]==w[j+1][0] for j in range(n-1)) and len(set(w))==n:
  print('Yes')
  sys.exit()
print('No')
Buggy code:
num_word = int(input())
word_list=[]
word_list = [[int(i) for i in input().split()] for i in range(n)] 

word_list_temp=[]
for j in range(len(word_list)):
  if j == len(word_list)-1:
    print ("Yes")
    break
  else:
    old_word=word_list[j]
    old_word_sep=list(old_word)
    word_list_temp.append(old_word)
    new_word=word_list[j+1]
    new_word_sep=list(word_list[j+1])
    if old_word_sep[len(old_word)-1]!=new_word_sep[0]:
      print ("No")
      break
    elif new_word in list(word_list_temp):
      print ("No")
      break
    else:
      continue

Fixed code:
num_word = int(input())
word_list=[]
word_list = [str(input()) for i in range(num_word)] 
 
word_list_temp=[]
for j in range(len(word_list)):
  if j == len(word_list)-1:
    print ("Yes")
    break
  else:
    old_word=word_list[j]
    old_word_sep=list(old_word)
    word_list_temp.append(old_word)
    new_word=word_list[j+1]
    new_word_sep=list(word_list[j+1])
    if old_word_sep[len(old_word)-1]!=new_word_sep[0]:
      print ("No")
      break
    elif new_word in list(word_list_temp):
      print ("No")
      break
    else:
      continue
Buggy code:
c = int(input())
w = []
for i in range(c):
  w.append(input())
if len(set(w)) != len(w):
  print("No")
  return
for i in range(len(w) - 1):
  if w[i][-1] != w[i+1][0]:
    print("No")
    return
print("Yes")

Fixed code:
falsify = "Yes"
c = int(input())
w = []
for i in range(c):
  w.append(input())
if len(set(w)) != len(w):
  falsify = "No"
for i in range(len(w) - 1):
  if w[i][-1] != w[i+1][0]:
    falsify = "No"
print(falsify)
Buggy code:
n =int(input())
W=[]
w=''
for i in range(n):
    if i !=0 and w[-1] !=str(input())[0]:
        print('No')
        exit()
    else:
        w=str(input())
        W.append(w)
if len(W) != len(list(set(W))):
    print('No')
    exit()
print('Yes')

Fixed code:
n =int(input())
W=[]
w=''
for i in range(n):
    s=str(input())
    if i !=0 and w[-1] != s[0]:
        print('No')
        exit()
    else:
        w=s
        W.append(w)
if len(W) != len(list(set(W))):
    print('No')
    exit()
print('Yes')
Buggy code:
N = int(input())
L = []
judge = "Yes"

w1 = input()
L.append(w1)
for i in range(N - 1):
	w2 = input()
	if L.count(w2) == 1:
		judge = "No"
		break
	elif w1[-1] != w2[0]:
		judge = "No"
		break
	else:
		w1 = w2

print(judge)

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

w1 = input()
L.append(w1)
for i in range(N - 1):
	w2 = input()
	if L.count(w2) == 1:
		judge = "No"
		break
	elif w1[-1] != w2[0]:
		judge = "No"
		break
	else:
		L.append(w2)
		w1 = w2

print(judge)
Buggy code:
N=int(input())
count = 0
listA=[]
while (count <= N-1):
    try:
        listA.append(str(input()))
        count+=1
    except:
        break;
print(set(listA))
print(listA)
if(listA != set(listA)):
    print("No")
else:
    for i in range(N-1):
        if(listA[i][-1]!=listA[i+1][0]):
            print("No")
            break
        if(i==N-2):
            print("Yes")

Fixed code:
N=int(input())
count = 0
listA=[]
while (count <= N-1):
    try:
        listA.append(str(input()))
        count+=1
    except:
        break;
if(len(listA) != len(set(listA))):
    print("No")
else:
    for i in range(N-1):
        if(listA[i][-1]!=listA[i+1][0]):
            print("No")
            break
        if(i==N-2):
            print("Yes")
Buggy code:
n = int(input())
w = []
count = 0

for i in range(n):
    w.append(input())

for i in range(n):
    if len(w) >= 2:
        if w[count-1][-1] != w[count][0]:
            print('No')
            exit()

        for j in range(count-1):
            if w[count] == w[j]:
                print('No')
                exit()
    count += 1

print('Yes')
    

Fixed code:
n = int(input())
w = []
count = 0

for i in range(n):
    w.append(input())

for i in range(n):
    if i >= 1:
        if w[i-1][-1] != w[i][0]:
            print('No')
            exit()

        for j in range(i-1):
            if w[i] == w[j]:
                print('No')
                exit()

print('Yes')
Buggy code:
N = int(input())
words = [input() for _ in range(N)]

ans = 'Yes'
if len(words) != len(set(words)):
    ans = 'No1'
else:
    next_words = words[1:]+['']
    for s1,s2 in zip(words,next_words):
        if s2 and s1[-1] != s2[0]:
            ans = 'No2'
            break

print(ans)

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

ans = 'Yes'
if len(words) != len(set(words)):
    ans = 'No'
else:
    next_words = words[1:]+['']
    for s1,s2 in zip(words,next_words):
        if s2 and s1[-1] != s2[0]:
            ans = 'No'
            break

print(ans)
Buggy code:
N=input()
N=int(input())
S=[input() for i in range(N)]
ans='Yes'
if len(set(S))!=N:
    ans='No'
for i in range(N-1):
    if S[i][len(S[i])-1]!=S[i+1][0]:
        ans='No'
print(ans)


Fixed code:
N=int(input())
S=[input() for i in range(N)]
ans='Yes'
if len(set(S))!=N:
    ans='No'
for i in range(N-1):
    if S[i][len(S[i])-1]!=S[i+1][0]:
        ans='No'
print(ans)
Buggy code:
n=int(input())
w=input()
a=[w]
for i in range(n-1):
    n=input()
    if w[len(w)-1]!=n[0] or n in a:
        print('No')
        break
    a.append(n)
else:
    print('Yes')

Fixed code:
n=int(input())
w=input()
a=[w]
for i in range(n-1):
    n=input()
    if w[len(w)-1]!=n[0] or n in a:
        print('No')
        break
    a.append(n)
    w=n
else:
    print('Yes')
Buggy code:
import sys
N,*W = map(str,open().read().split())
N = int(N)
for i in range(N-1):
    if list(N[i])[-1] != list(N[i+1])[0]:
        print("No")
        sys.exit()
print("Yes")

Fixed code:
import sys
N,*W = map(str,open(0).read().split())
N = int(N)
for i in range(N-1):
    if list(W[i])[-1] != list(W[i+1])[0]:
        print("No")
        sys.exit()
if len(W) != len(set(W)):
    print("No")
    sys.exit()
print("Yes")
Buggy code:
n = input()
w = []
Flag = Trure 
for i in range(n):
  w.append(input())
for i in range(n-1):
  if w[i][-1] != w[i+1][0]:
    Flag = False
if len(w) = len(set(w)):
  Flag = False
print("Yes" if Flag else "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]:
    Flag = False
if len(w) != len(set(w)):
  Flag = False
print("Yes" if Flag else "No")
Buggy code:
n = int(input())
words = []
for i in range(n):
  words.append(input())

if len(words) != len(set(words)):
  print("No")
else:
  for i in range(n-1):
    if words[i][-1] != words[i+1][0]:
      print("No")
      break
  print("Yes")

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

ans = "Yes"
  
if len(words) != len(set(words)):
  ans = "No"
else:
  for i in range(n-1):
    if words[i][-1] != words[i+1][0]:
      ans = "No"
      break
print(ans)
Buggy code:
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *w = sys.stdin.read().split()
    n = int(n)
    for i in range(1, n):
        if w[i][0] == w[i-1][-1] and not w[i] in w[:i]:
            continue
        else:
            sys.exit('No')
    
    print('Yes')


if __name__ == "__main__":
    # execute only if run as a script
    main()


Fixed code:
#                         author:  kagemeka 
#                         created: 2019-11-10 12:28:14(JST)
import sys
# import collections
# import math
# from string import ascii_lowercase, ascii_uppercase, digits
# from bisect import bisect_left as bi_l, bisect_right as bi_r
# import itertools
# from functools import reduce
# import operator as op
# from scipy.misc import comb # float
# import numpy as np 

def main():
    n, *w = sys.stdin.read().split()
    n = int(n)
    for i in range(1, n):
        if w[i][0] == w[i-1][-1] and not w[i] in w[:i]:
            continue
        else:
            print('No')
            exit()
    
    print('Yes')


if __name__ == "__main__":
    # execute only if run as a script
    main()
Buggy code:
N = int(input())
W = []
f = True
for i in range(N):
  W.append(input())
for i in range(N):
  if W[i][0] != W[i][-1]:
    f = False
W = sorted(W)
for i in range(N-1):
  if W[i] == W[i+1]:
    f = False
if f:
  print("Yes")
else:
  print("No")

Fixed code:
N = int(input())
W = []
f = True
for i in range(N):
  W.append(input())
for i in range(N-1):
  if W[i][-1] != W[i+1][0]:
    f = False
W = sorted(W)
for i in range(N-1):
  if W[i] == W[i+1]:
    f = False
if f:
  print("Yes")
else:
  print("No")