qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
siritori_list = list()
for i in range(n):
    siritori_list.append(input())
for ii in range(n):
    word = siritori_list.pop(0)
    print(word,siritori_list)
    if siritori_list:
        if not(word[-1] == siritori_list[0][0]) or word in siritori_list:
            print("No")
            break
else:
    print("Yes")

Fixed code:
n = int(input())
siritori_list = list()
for i in range(n):
    siritori_list.append(input())
for ii in range(n):
    word = siritori_list.pop(0)
    if siritori_list:
        if not(word[-1] == siritori_list[0][0]) or word in siritori_list:
            print("No")
            break
else:
    print("Yes")
Buggy code:
import sys
n = int(input())
yetlist = []
for i in range(n):
    word = input()
    if word in yetlist:
        print("No")
        sys.exit()
    if word[0] != yetlist[-1][-1]:
        print("No")
        sys.exit()
    yetlist.append(word)
print("Yes")

Fixed code:
import sys
n = int(input())
yetlist = []
for i in range(n):
    word = input()
    if word in yetlist:
        print("No")
        sys.exit()
    if yetlist:
        if word[0] != yetlist[-1][-1]:
            print("No")
            sys.exit()
    yetlist.append(word)
print("Yes")
Buggy code:
import sys

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

if len(set(W)) != len(W):
    print('No')
    sys.exit(1)

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

print('Yes')

Fixed code:
import sys

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

if len(set(W)) != N:
    print('No')
    sys.exit()

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

print('Yes')
Buggy code:
def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n-1):
        if string_list[i-1][-1]!=string_list[i][0]:
            print(string_list[i-1][-1],string_list[i][0])
            return False

    return True

def main():
    n = int(input())
    string_list = [input() for i  in range(n)]

    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()


Fixed code:
def shiritori(n, string_list):

    if len(string_list)!=len(set(string_list)):
        return False

    for i in range(1,n):
        if string_list[i-1][-1]!=string_list[i][0]:
            return False

    return True


def main():
    n = int(input())
    string_list = [input() for i  in range(n)]

    if shiritori(n, string_list):
        print('Yes')
    else :
        print('No')

if __name__=='__main__':
    main()
Buggy code:
n=int(input())
ws=[input()]
for i in range(1,n):
  w=input()
  if w in ws or w[0]!=ws[i-1][-1]:
    print("No")
    break
else:print("Yes")

Fixed code:
n=int(input())
ws=[input()]
for i in range(1,n):
  w=input()
  if w in ws or w[0]!=ws[i-1][-1]:
    print("No")
    break
  ws.append(w)
else:print("Yes")
Buggy code:
N = int(input())

shiritori_set = set()

shiritori = input()
head = shiritori[len(shiritori) -1]

ans = "Yes"

for i in range(N-1):
  shiritori = input()
  if (shirotori[0] == head and shiritori in shiritori_set):
    head = shiritori[len(shiritori)-1]
    shiritori_set.add(shiritori)
    continue
  else:
    ans = "No"
    break

print(ans)


  
  

Fixed code:
N = int(input())

shiritori_set = set()

shiritori = input()
head = shiritori[len(shiritori) -1]

ans = "Yes"
shiritori_set.add(shiritori)
for i in range(N-1):
  shiritori = input()
  if shiritori[0] == head and shiritori not in shiritori_set:
    head = shiritori[len(shiritori)-1]
    shiritori_set.add(shiritori)
  else:
    ans = "No"
    break

print(ans)
Buggy code:
n=int(input())
W=[]
for i in range(n):
    w=input()
    W.append(w)
    if i > 0:
        if W[0] == last and str(W).count(W[i]) <= 1:
            ans=1
        else:
            ans=0
            break
    last = W[len(W)-1]
if ans==0:
    print("No")
else:
    print("Yes")


Fixed code:
n=int(input())
W=[]
for i in range(n):
    w=input()
    W.append(w)
    if i > 0:
        if W[i][0] == last and W.count(W[i]) <= 1:
            ans=1
        else:
            ans=0
            break
    last = W[i][len(W[i])-1]
if ans==0:
    print("No")
else:
    print("Yes")
Buggy code:
n=int(input())
s=set()
yn=1
w=input()
for i in range(n-1):
    a=w[-1]
    w=input()
    s.add(w)
    if a!=w[0] or w in s:
        yn=0
        break
if yn==1:
    print('Yes')
else:
    print('No')


Fixed code:
n=int(input())
s=set()
yn=1
w=input()
s.add(w)
for i in range(n-1):
    a=w[-1]
    w=input()
    
    if a!=w[0] or w in s:
        yn=0
        break
    s.add(w)
if yn==1:
    print('Yes')
else:
    print('No')
Buggy code:
N = int(input())
words = []
for _ in range(N):
    words.append(input())
print('Yes' if all(w[i].startswith(w[i-1][-1]) for i in range(1, N)) and len(set(words)) == N else 'No')

Fixed code:
N = int(input())
words = []
for _ in range(N):
    words.append(input())
print('Yes' if all(words[i].startswith(words[i-1][-1]) for i in range(1, N)) and len(set(words)) == N else 'No')
Buggy code:
import collections

N = int(input())
W = []
jud = 1

for _ in range(N):
    W.append(input())

c = collections.Counter(W)
ct = len(c)

for i in range(N-1):
    fst = W[i]
    fnl = W[i+1]
    if fst[-1] == fnl[1]:
        jud = 0

if ct != N:
    print("No")
elif jud == 0:
    print("No")
else: print("Yes")

Fixed code:
import collections

N = int(input())
W = []
jud = 1

for _ in range(N):
    W.append(input())

c = collections.Counter(W)
ct = len(c)

for i in range(N-1):
    fst = W[i]
    fnl = W[i+1]
    if fst[-1] != fnl[0]:
        jud = 0

if ct != N:
    print("No")
elif jud == 0:
    print("No")
else: print("Yes")
Buggy code:
N = int(input())

cache = []
abc = ''
ngflag = False
for i in range(N):
    word = input()
    if abc != '':
        if word[0] != abc:
            print(word)
            ngflag = True
    if word in cache:
        print(word)
        ngflag = True
    abc = word[-1]
    cache.append(word)

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

Fixed code:
N = int(input())

cache = []
abc = ''
ngflag = False
for i in range(N):
    word = input()
    if abc == '':
        pass
    elif word[0] != abc:
        ngflag = True

    if word in cache:
        ngflag = True
    abc = word[-1]
    cache.append(word)

if ngflag:
    print('No')
else:
    print('Yes')
Buggy code:
N = int(input())
W = [input() for i in range(N)]

if [W[i][-1] for i in range(N-1)] == [W[i+1][0] for i in range(N-1)] and len(list(set(W))) = len(W):
    print ("Yes")
else:
    print ("No")

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

if [W[i][-1] for i in range(N-1)] == [W[i+1][0] for i in range(N-1)] and len(list(set(W))) == len(W):
    print ("Yes")
else:
    print ("No")
Buggy code:
n = int(input())
s = set()

ok = True
t = input()
p = t[-1]
for i in range(n-1):
  t = input()
  if t in s:
    ok = False
  s.add(t)
  if t[0] != p:
    ok = False
  p = t[-1]
  
print('Yes' if ok else 'No')

Fixed code:
n = int(input())
s = set()

ok = True
t = input()
p = t[-1]
s.add(t)
for i in range(n-1):
    t = input()
    if t in s:
        ok = False
    s.add(t)
    if t[0] != p:
        ok = False
    p = t[-1]

print('Yes' if ok else 'No')
Buggy code:
n = int(input())
w = [input() for _ in range(n)]
w_l = [w[0]]
w_ = w[0][-1]
for wi in w:
    if w_ != wi[0] or wi in w_l:
        print("No")
        exit()
    w_ = wi[-1]
    w_l.append(wi)
print("Yes")

Fixed code:
n = int(input())
w = [input() for _ in range(n)]
w_l = [w[0]]
w_ = w[0][-1]
for wi in w[1:]:
    if w_ != wi[0] or wi in w_l:
        print("No")
        exit()
    w_ = wi[-1]
    w_l.append(wi)
print("Yes")
Buggy code:
# -*- coding: utf-8 -*-
N = int(input())

strList = [""] * N
strList[0] =input()
ans = "Yes"

for count in range(1,N):
    string = input()
    for s in strList:
        if s == string :
            ans = "No"
            break
        else:
            before = strList[count -1]
            if before[len(before) -1: 1] != string[1:1]:
                ans = "No"
                break
    if ans == "No":
        break
    strList.append(string)

print(ans)

Fixed code:
# -*- coding: utf-8 -*-
N = int(input())

strList = [""] * N
strList[0] =input()
ans = "Yes"

for count in range(1,N):
    string = input()
    for s in strList:
        if s == string :
            ans = "No"
            break
        else:
            before = strList[count -1]
            car = before[len(before) -1: len(before)] 
            if car != string[:1]:
                ans = "No"
                break
    if ans == "No":
        break
    strList[count] = string

print(ans)
Buggy code:
n = int(input())
s = []
f = 0

for i in range(n):
    t = input()
    if t in s:
        f = 1
    elif i != 0 and s[i-1][-1] != t[0]:
        print(s[i-1], s[i-1][-1], t[0])
        f = 1
    s.append(t)
    
if f == 0:
    print("Yes")
else:
    print("No")

Fixed code:
n = int(input())
s = []
f = 0

for i in range(n):
    t = input()
    if t in s:
        f = 1
    elif i != 0 and s[i-1][-1] != t[0]:
        f = 1
    s.append(t)
    
if f == 0:
    print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
w = input()
shiritori = []

shiritori.append(w)

ans = "Yes"

for i in shiritori:
    if shiritori.count(i) != 1:
        ans = "No"
        break
    
for k in range(N-1):
    first = shiritori[k]
    second = shiritori[k+1]
    if first[-1] != second[0]:
        ans = "No"
        break


    
print(ans)

Fixed code:
N = int(input())
shiritori = list()

for a in range(N):
	shiritori.append(input())

ans = "Yes"

for i in shiritori:
    if shiritori.count(i) != 1:
        ans = "No"
        break
    
for k in range(N-1):
    first = shiritori[k]
    second = shiritori[k+1]
    if first[-1] != second[0]:
        ans = "No"
        break


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

ok = 1
tmp_list = []
for i in range(n):
    w = str(input())

    if i == 0:
        tmp = w
        continue

    else:
        if w[0] != tmp[-1] or w in tmp_list:
            ok = 0

        else:
            tmp_list.append(w)
            tmp = w

if ok == 1:
    print('Yes')
else:
    print('No')



Fixed code:
n = int(input())

ok = 1
tmp_list = []
for i in range(n):
    w = str(input())

    if i == 0:
        tmp = w
        tmp_list.append(w)
        continue

    else:
        if w[0] != tmp[-1] or w in tmp_list:
            ok = 0

        else:
            tmp_list.append(w)
            tmp = w

if ok == 1:
    print('Yes')
else:
    print('No')
Buggy code:
# coding: utf8

if __name__ == "__main__":
    n = int(input())
    w = []
    flag = True
    for _ in range(n):
        a = input()
        last = w[len(w)-1]
        if a[0] != last[len(last)-1] and a in w:
            flag = False
            print("No")
            break
        w.append(a)
    if flag == True:
        print("Yes")



Fixed code:
# coding: utf8

if __name__ == "__main__":
    n = int(input())
    w = []
    flag = True
    for _ in range(n):
        a = input()
        if len(w) == 0:
            w.append(a)
            continue
        last = w[len(w)-1]
        if a[0] != last[len(last)-1] or a in w:
            flag = False
            break
        w.append(a)
    if flag == True:
        print("Yes")
    else:
        print("No")
Buggy code:
N=int(input())
A=[]
for _ in range(N):
    W=input()
    if W in A:
        print('No')
        exit()
    else:
        W.append(A)

for i in range(N-1):
    if A[i][-1]!=A[i+1][-1]:
        print('No')
        exit()
print('Yes')

Fixed code:
N=int(input())
A=[]
for _ in range(N):
    W=input()
    if W in A:
        print('No')
        exit()
    else:
        A.append(W)

for i in range(N-1):
    if A[i][-1]!=A[i+1][0]:
        print('No')
        exit()
print('Yes')
Buggy code:
_,a=open(0).readlines()
if len(set(a))<len(a):
  print("No")
  exit()
b=[(i[0],i[-2]) for i in a]
for k in range(len(b)-1):
  if b[k][1]!=b[k+1][0]:
    print("No")
    exit()
print("Yes")

Fixed code:
_,*a=open(0).readlines()
if len(set(a))<len(a):
  print("No")
  exit()
b=[(i[0],i[-2]) for i in a]
for k in range(len(b)-1):
  if b[k][1]!=b[k+1][0]:
    print("No")
    exit()
print("Yes")
Buggy code:
n = int(input())
lst = []
flag = True
tmp = input()
lst.append(tmp)
for i in range(n-1):
    w = input()
    if w in lst:
        flag = False
    if tmp[-1] != w[0]:
        flag = False
    lst.append(w)
    tmp = w

print('yes' if flag == True else 'No')

Fixed code:
n = int(input())
lst = []
flag = True
tmp = input()
lst.append(tmp)
for i in range(n-1):
    w = input()
    if w in lst:
        flag = False
    if tmp[-1] != w[0]:
        flag = False
    lst.append(w)
    tmp = w

print('Yes' if flag == True else 'No')
Buggy code:
n = int(input())
lst = [0] * n
for i in range(n):
    lst[i] = input()

flag = True
for i in range(n-1):
    if lst[i][-1] != lst[i + 1][0]:
        flag = False

print('yes' if flag == True and len(set(lst)) == n else 'No')

Fixed code:
n = int(input())
lst = [0] * n
for i in range(n):
    lst[i] = input()

flag = True
for i in range(n-1):
    if lst[i][-1] != lst[i + 1][0]:
        flag = False

print('Yes' if flag == True and len(set(lst)) == n else 'No')
Buggy code:
n = int(input())
#n, m = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
ls = [input() for i in range(n)]

for i in range(len(ls)-1):
  if ls[i][0] != ls[i-1][-1]:
    print("No")
    quit()
  if ls.count(ls[i]) >= 2:
    print("No")
    quit()
    
print("Yes")

Fixed code:
n = int(input())
#n, m = map(int,input().split())
#ls = list(map(int,input().split()))
#ls = [list(map(int,input().split())) for i in range(n)]
ls = [input() for i in range(n)]

for i in range(1,len(ls)):
  if ls[i][0] != ls[i-1][-1]:
    print("No")
    quit()
  if ls.count(ls[i]) >= 2:
    print("No")
    quit()
    
print("Yes")
Buggy code:
N=int(input())
W=[]
for _ in range(N):
    W.append(input())
c=1
for i in range(N-1):
     if W[i][-1]!=W[i+1][0]:
            c=0
            break
if c:
    print('Yes')
else:
    print('No')

Fixed code:
N=int(input())
W=[]
for _ in range(N):
    W.append(input())
c=1
for i in W:
    d=W.count(i)
    if d>1:
        c=0
        break
for i in range(N-1):
     if W[i][-1]!=W[i+1][0]:
            c=0
            break
if c:
    print('Yes')
else:
    print('No')
Buggy code:
count = input()
inputed = []
last = ""
judge = "Yes"
for i in range(int(count)):
    new_inputed = input()
    if i != 0 or new_inputed[-1] != last or new_inputed in inputed:
        judge = "No"
    last = new_inputed[-1]
    inputed.append(new_inputed)
print(judge)

Fixed code:
count = input()
inputed = []
last = ""
judge = "Yes"
for i in range(int(count)):
    new_inputed = input()
    if i != 0 and (new_inputed[0] != last or new_inputed in inputed):
        judge = "No"
    last = new_inputed[-1]
    inputed.append(new_inputed)
print(judge)
Buggy code:
N=int(input())
H=input()
word=[]
for i in range(N-1):
  S=input()
  if S in word:
    print('No')
    exit()
  else:
    if H[-1]==S[0]:
      H=S
      word.append(H)
    else:
      print('No')
      exit()
print('Yes')

Fixed code:
N=int(input())
H=input()
word=[]
word.append(H)
for i in range(N-1):
  S=input()
  if S in word:
    print('No')
    exit()
  else:
    if H[-1]==S[0]:
      H=S
      word.append(H)
    else:
      print('No')
      exit()
print('Yes')
Buggy code:
A=int(input())
B = [input() for _ in range(A)]
count = 0
if len(set(B)) != len(B):
  print('No')
else:
  for b in B:
    if count == 0:
      k = b[-1]
      count += 1
    else:
      if k == b[0]:
        k = b[-1]
      else:
        print('No')
        break;
  print('Yes')
      

Fixed code:
A=int(input())
B = [input() for _ in range(A)]
count = 0
if len(set(B)) != len(B):
  print('No')
else:
  for b in B:
    if count == 0:
      k = b[-1]
      count += 1
    else:
      if k == b[0]:
        k = b[-1]
      else:
        print('No')
        exit()
  print('Yes')
Buggy code:
N = int(input())
m = dict()

prev = input()
m[prev] = True
flg = True

for _ in range(N - 1):
  s = input()
  flg = all(flg, s not in m, prev[len(prev) - 1] == s[0])
  m[s] = True
  prev = s

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

Fixed code:
N = int(input())
m = dict()

prev = input()
m[prev] = True
flg = True

for _ in range(N - 1):
  s = input()
  flg = flg and s not in m
  flg = flg and prev[len(prev) - 1] == s[0]
  m[s] = True
  prev = s

print("Yes" if flg else "No")
Buggy code:
n=int(input())

a=[input() for i in range(n)]

ans=True
if all(a.count(w) == 1 for w in a):
    for i in range(n-1):
        if a[i][-1]!=a[i+1][0]:
            ans=False
    
if ans:    
    print('Yes')
else:
    print('No')

Fixed code:
n=int(input())

a=[input() for i in range(n)]

ans=True
if all(a.count(w) <2  for w in a):
    for i in range(n-1):
        if a[i][-1]!=a[i+1][0]:
            ans=False
else:
    ans=False
    
if ans:    
    print('Yes')
else:
    print('No')
Buggy code:
N = int(input())

string_list=[input() for i in range(N)]
i = 0
string_list2 = list(set(string_list))
if(len(string_list2)==N):
    check = 1
else:
    check = 0

while(i < N-1):
    string1  = string_list[i]
    string2 = string_list[i+1]
    print(string1)
    print(string2)
    str1 = string1[-1]
    str2 = string2[0]
    if(str1 != str2):
        check = 0
    i +=1

if(check ==1):
    print("Yes")
else:
    print("No")

Fixed code:
N = int(input())

string_list=[input() for i in range(N)]
i = 0
string_list2 = list(set(string_list))
if(len(string_list2)==N):
    check = 1
else:
    check = 0

while(i < N-1):
    string1  = string_list[i]
    string2 = string_list[i+1]
    str1 = string1[-1]
    str2 = string2[0]
    if(str1 != str2):
        check = 0
    i +=1

if(check ==1):
    print("Yes")
else:
    print("No")
Buggy code:
n=int(input())
used=[]
used.append(input())
chain=used[0][-1]
res="Yes"
for i in range(n-1):
    print(used)
    s=input()
    c=s[0]
    print(chain)
    if s in used or chain!=c:
        res="No"
        break
    used.append(s)
    chain=s[-1]
    


Fixed code:
n=int(input())
used=[]
used.append(input())
chain=used[0][-1]
res="Yes"
for i in range(n-1):
    s=input()
    c=s[0]
    if s in used or chain!=c:
        res="No"
        break
    used.append(s)
    chain=s[-1]
    

print(res)
Buggy code:
N = int(input())
words = [input().strip() for _ in range(N)]

def solve(words):
  s = set(words[0])
  for p, w in zip(words, words[1:]):
    if p[-1] != w[0]:
      return "No"
    if w in s:
      return "No"
    s.add(w)
  return "Yes"

print(solve(words))

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

def solve(words):
  s = {words[0]}
  for p, w in zip(words, words[1:]):
    if p[-1] != w[0]:
      return "No"
    if w in s:
      return "No"
    s.add(w)
  return "Yes"

print(solve(words))
Buggy code:
a = input()

def main():
    ed = []
    for i in range(int(a)-1):
        neww = input()
        print(i)
        if i != 0:
            if ed[i-1][-1] != neww[0] or neww in ed:
                return 'No'
        ed.append(neww)
        print(ed)

    return 'Yes'
                

if __name__ == '__main__':
    print(main())



Fixed code:
a = input()

def main():
    ed = []
    for i in range(int(a)):
        neww = input()
        if i != 0:
            if ed[i-1][-1] != neww[0] or neww in ed:
                return 'No'
        ed.append(neww)

    return 'Yes'
                

if __name__ == '__main__':
    print(main())
Buggy code:
n = int(input())
w = [input() for i in range(n)]
ans = "No"
l=0
t = w[0]
i=0
while(True):
    if len(set(w))!=n:
        break
    for s in w:
        if i==0:
            i+=1
        else:
            print(t[len(t)-1:])
            if t[len(t)-1:]==s[0]:
                l+=1
            t=s
    break
if l+1==n:
    ans="Yes"
print(ans)


Fixed code:
n = int(input())
w = [input() for i in range(n)]
ans = "No"
l=0
t = w[0]
i=0
while(True):
    if len(set(w))!=n:
        break
    for s in w:
        if i==0:
            i+=1
        else:
            if t[len(t)-1:]==s[0]:
                l+=1
            t=s
    break
if l+1==n:
    ans="Yes"
print(ans)
Buggy code:
n=int(input())
for i in range(n):
    a.append(input())
if len(a)!=len(set(a)):
    print('No')
    exit()
for i in range(n-1):
    if a[i][-1]!=a[i+1][0]:
        print('No')
        exit()
print('Yes')

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

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

print("Yes")

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

if len(set(w))!=len(w):
  print("No")
else:
  for i in range(1,n):
    if w[i][0]!=w[i-1][-1]:
      print("No")
      exit()
      
  print("Yes")
Buggy code:
N=int(input())
S=[input() for i in range(N)]
print(S)
ans='Yes'
if len(set(S))!=N:
    ans='No'
for i in range(N-1):
    if 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][-1]!=S[i+1][0]:
        ans='No'
print(ans)
Buggy code:
n = int(input())
w = [0] * n 
result = "Yes"

for i in range(n):
    w[i] = int(input())
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)

Fixed code:
n = int(input())
w = [""] * n 
result = "Yes"

for i in range(n):
    tmp = input()
    if tmp in w:
        result = "No"
    w[i] = tmp 
for i in range(n-1):
    if w[i][-1] == w[i+1][0]:
        pass
    else:
        result = "No"
print(result)
Buggy code:
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))

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

else:
    print("No")


Fixed code:
import sys
def is_unique(seq):
    return len(seq) == len(set(seq))

N = int(input())
W = []
for i in range(N):
    W.append((input()))
if is_unique(W):
    for i in range(N-1):
        if W[i][-1] != W[i+1][0]:
            print("No")
            sys.exit()
    print("Yes")

else:
    print("No")
Buggy code:
n=int(input())
w=[str(input())]
ans="Yes"
for i in range(n-1):
    x=str(input())
    w.append(x)
    y=w[i]
    if x[0]!=y[-1]:
        ans="No"
        break
print(ans)

Fixed code:
n=int(input())
w=[str(input())]
ans="Yes"
for i in range(n-1):
    x=str(input())
    if x in w:
        ans="No"
        break
    w.append(x)
    y=w[i]
    if x[0]!=y[-1]:
        ans="No"
        break
print(ans)
Buggy code:
N = int(input())
W = [input() for i in range(N)]

l = []

for i in range(N):
  if i != 0:
    if W[i-1] == W[i]:
      print('No')
      break
  
  if W[i] in l:
    print('No')
    break
    
  l.append(W[i])
else:
  print('Yes')

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

l = []

for i in range(N):
  if i != 0:
    if W[i-1][-1] != W[i][0]:
      print('No')
      break
  
  if W[i] in l:
    print('No')
    break
    
  l.append(W[i])
else:
  print('Yes')