qyliang/CodeNanoFix huggingface dataset:
Buggy code:
import sys
n=input()
w=input()
l=[]
l.append(w)
for i in range(1,n):
    w=input()
    if w[0]!=l[-1][-1] or w in l:
        print("No")
        sys.exit()
    else:
        l.append(w)
print("Yes")

Fixed code:
import sys
n=int(input())
w=input()
l=[]
l.append(w)
for i in range(1,n):
    w=input()
    if w[0]!=l[-1][-1] or w in l:
        print("No")
        sys.exit()
    else:
        l.append(w)
print("Yes")
Buggy code:
N = int(input())
word = list(str(input()) for _ in range(N))
res = 'Yes'
if len(word) != len(set(word)):
    print('No')
    exit()
last = (word[0])[0]
for i, x in enumerate(word):
    if last != x[0]:
        print('No')
        exit()
    last = x[-1]
print('Yes'

Fixed code:
N = int(input())
w = list(str(input()) for _ in range(N))
res = 'Yes'
if len(w) != len(set(w)):
    print('No')
    exit()
last = (w[0])[0]
for i, x in enumerate(w):
    if last != x[0]:
        print('No')
        exit()
    last = x[-1]
print('Yes')
Buggy code:
N = int(input().split())
a = []
flag = 1
for i in range(N):
    a.append(str(input().split()))
    if i != 0:
        for j in range(i):
            if a[i] == a[j]:
                flag =0


back = a[0][-1]
for i in range(1,N):
    front = a[i][0]
    if front != back:
        flag = 0
        break
    back = a[i][-1]

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

Fixed code:
N = int(input())
a = []
flag = 1
for i in range(N):
    a.append(str(input()))
    if i != 0:
        for j in range(i):
            if a[i] == a[j]:
                flag =0


back = a[0][-1]
for i in range(1,N):
    front = a[i][0]
    if front != back:
        flag = 0
        break
    back = a[i][-1]

if flag == 0:
    print("No") 
else:
    print("Yes")
Buggy code:
#! /usr/bin/python
from sys import stdin
n = int(input())
W = stdin.read().splitlines()
if n != len(set(W)):
    print("No")
    exit()
for i in range(1, n-1):
    if W[i][-1] != W[i][0]:
        print("No")
        exit()


Fixed code:
#! /usr/bin/python
from sys import stdin
n = int(input())
W = stdin.read().splitlines()
if n != len(set(W)):
    print("No")
    exit()
for i in range(n-1):
    if W[i][-1] != W[i+1][0]:
        print("No")
        exit()
print("Yes")
Buggy code:
n = int(input())
A = []
for _ in range(n):
    A.append(input())

for i, e in enumerate(A):
    if i == 0: continue
    if A.count(e) != 1 or A[i - 1][-1] != A[i][0]:
        print('No')
        break
    if i == n: print('Yes')

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

for i, e in enumerate(A):
    if i == 0: continue
    if A.count(e) != 1 or A[i - 1][-1] != A[i][0]:
        print('No')
        break
    if i == n - 1:
        print('Yes')
Buggy code:
icase=0
if icase==0:
    n=int(input())
    ww=set()
    w=[]
    for i in range(n):
        w.append(input())
    ww=set()
    ww.add(w[0])
    yn=""
    for i in range(n-1):
        if w[i][-1]!=w[i+1][0]:
            yn="No"
            print("No")
            break
        if w[i] in ww:
            yn="No"
            print("No")
            break
        else:
            ww.add(w[i])
    if yn!="No":
        print("Yes")

Fixed code:
icase=0
if icase==0:
    n=int(input())
    ww=set()
    w=[]
    for i in range(n):
        w.append(input())
    ww=set()
    ww.add(w[0])
    yn=""
    for i in range(n-1):
        if w[i][-1]!=w[i+1][0]:
            yn="No"
            print("No")
            break
        if w[i+1] in ww:
            yn="No"
            print("No")
            break
        else:
            ww.add(w[i+1])
    if yn!="No":
        print("Yes")
Buggy code:
n=int(input())
w=[input() for i in range(n)]
count=0
if len(w)==len(set(w)):
    for i in range(n-1):
        if w[i][-1]==w[i+1][0]:
            count+=1
else:
    print('No')
print('Yes' if count>0 else 'No')

Fixed code:
n=int(input())
w=[input() for i in range(n)]
count=0
if len(w)==len(set(w)):
    for i in range(n-1):
        if w[i][-1]==w[i+1][0]:
            count+=1
        else:
            count=count*0
            break
else:
    count=count*0
    
print('Yes' if count>0 else 'No')
Buggy code:
#coding;utf-8
n=int(input())
data=[]
check=True
data.append(input())
for i in range(n-1):
  data.append(input())
  for j in range(i):
    if(data[i]==data[j]):
      check=False
  if(data[i-1][len(data[i-1])-1]!=data[i][0]):
    check=False
if(check==False):
  print("No")
else:
  print("Yes")

Fixed code:
#coding;utf-8
n=int(input())
data=[]
check=True
data.append(input())
for i in range(1,n):
  data.append(input())
  for j in range(i):
    if(data[i]==data[j]):
      check=False
  if(data[i-1][len(data[i-1])-1]!=data[i][0]):
    check=False
if(check==False):
  print("No")
else:
  print("Yes")
Buggy code:
N=int(input())
A=list(input()for i in range(N))
if len(A)==len(set(A):
    if all(A[i][-1]==A[i+1][0]) for i in range(N-1):
        print('Yes')
    else:print('No')
else:print('No')

Fixed code:
N=int(input())
A=list(input()for i in range(N))
if len(A)==len(set(A)):
    if all(A[i][-1]==A[i+1][0] for i in range(N-1)):
        print('Yes')
    else:print('No')
else:print('No')
Buggy code:
import sys

input = sys.stdin.readline

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

check = set()
flag = True
before = W[0][-1]
for i in range(1, N):
    if before != W[i][0] or W[i] in check:
        flag = False
    else:
        before = W[i][-1]
        check.add(W[i])

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



Fixed code:
import sys

input = sys.stdin.readline

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

check = set([W[0]])
flag = True
before = W[0][-1]
for i in range(1, N):
    if before != W[i][0] or W[i] in check:
        flag = False
        break
    else:
        before = W[i][-1]
        check.add(W[i])

if flag:
    print('Yes')
else:
    print('No')
Buggy code:
N=int(input())
List=list(input() for i in range(N))
if len(set(List))!=len(List):
  print("No")

else:
  count=0
  for i in range(N-1):
    if List[i][-1]!=List[i+1][0]:
      count+=1
  if count==0:
    print("Yes")
  else:
    print("NO")

Fixed code:
N=int(input())
List=list(input() for i in range(N))

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

else:
  count=0
  for i in range(N-1):
    if List[i][-1]!=List[i+1][0]:
      count+=1
  if count==0:
    print("Yes")
  else:
    print("No")
Buggy code:
n=int(iput())
a=input()
st=set(a)
ans='Yes'
for i in range(n-1):
    s=input()
    if a[-1]!=s[0]:
        ans='No'
    st.add(s)
    a=s
if len(st)<n:
    ans='No'
print(ans)

Fixed code:
n=int(input())
a=input()
st=set()
st.add(a)
ans='Yes'
for i in range(n-1):
    s=input()
    st.add(s)
    if a[-1]!=s[0]:
        ans='No'
    a=s
if len(st)<n:
    ans='No'
print(ans)
Buggy code:
# coding: utf-8


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


def main():
    n = int(input())
    shiri = True

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

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

    if not is_unique(w):
        shiri = False

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


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


Fixed code:
# coding: utf-8
 
 
def is_unique(seq):
    return len(seq) == len(set(seq))
 
 
def main():
    n = int(input())
    shiri = True
 
    w = []
    for i in range(n):
        w.append(input())
 
    for i in range(n-1):
        if w[i][-1] != w[i + 1][0]:
            shiri = False
            break
 
    if not is_unique(w):
        shiri = False
 
    if shiri:
        print('Yes')
    else:
        print('No')
 
 
if __name__ == '__main__':
    main()
Buggy code:
n=int(input())
lw=[input() for i in range(n)]
used=set()
last=lw[0][0]
for w in lw:
    if w in used or last !=w[0]:
        cond=False
        break
    used.add(w)
    last=w[-1]
print("Yes" if cond else "No")

Fixed code:
n=int(input())
lw=[input() for i in range(n)]
used=set()
cond=True
last=lw[0][0]
for w in lw:
    if w in used or last !=w[0]:
        cond=False
        break
    used.add(w)
    last=w[-1]
print("Yes" if cond else "No")
Buggy code:
N = int(input())
W = list(input() for i in range(N))
f = True

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

Fixed code:
N = int(input())
W = list(input() for i in range(N))
f = True

for i in range(N-1):
  if W[i][-1]!=W[i+1][0]:
    f = False
    
if N==len(set(W)) and f:
  print("Yes")
else:
  print("No")
Buggy code:
N = int(input())
W = [input() for i in range(N)]
L = []
ans = "Yes"
for i in range(1,N):
  if W[i] in L:
    ans = "No"
  if W[i][0] != W[i-1][-1]:
    ans = "No"
  L.append(W[i])
print(ans)


Fixed code:
N = int(input())
W = [input() for i in range(N)]
L = [W[0]]
ans = "Yes"
for i in range(1,N):
  if W[i] in L:
    ans = "No"
  if W[i][0] != W[i-1][-1]:
    ans = "No"
  L.append(W[i])
print(ans)
Buggy code:
n = int(input())
result = "Yes"
w = list(input())
for i in range(n - 1):
  s = input()
  if s in w:
    result = "No"
  elif s[0] != w[-1][-1]:
    result = "No"
  else:
    w.append(s)
print(result)

Fixed code:
n = int(input())
result = "Yes"
w = []
s = input()
w.append(s)
for i in range(n - 1):
  s = input()
  if s in w:
    result = "No"
    break
  elif s[0] != w[-1][-1]:
    result = "No"
    break
  else:
    w.append(s)
print(result)
Buggy code:
n = int(input())
w = [input() for i 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 i 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:
x = 0
listen = []
first = []
last = []
n = int(input())
for i in range(n):
 listen.append(input())
 first.append(listen[i][:1])
 last.append(listen[i][-1:])
 for k in range(i):
  if listen[k] == listen[i]:
   x = 1
  if last[k] != first[i]:
   x = 1
if x == 0:
 print ('Yes')
else:
 print ('No')

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


Fixed code:
N=int(input())
W=[input() for i in range(N)]
if len(W)!=len(set(W)):
    print('No')
    exit()
for i in range(len(W)-1):
       if W[i][-1]!=W[i+1][0]:
          print('No')
          exit()
print('Yes')
Buggy code:
a=int(input())
x=[].append(input())
flag=0
for i in range(1,a):
    s=input()
    if s in x or x[i-1][len(x[i-1])-1]!=s[0] :
        x.append("1")
        flag=1
    else:
        x.append(s)
if flag == 0:
    print("Yes")
else:
    print("No")

Fixed code:
a=int(input())
x=[]
flag=0
for i in range(a):
    s=input()
    if i==0:
        x.append(s)
        continue
    #print(s,x[i-1])
    if s in x or x[i-1][len(x[i-1])-1]!=s[0] :
        x.append("1")
        flag=1
    else:
        x.append(s)
if flag == 0:
    print("Yes")
else:
    print("No")
Buggy code:
n = int(input())
list = []
for i in range(n):
    a = input()
    list.append(a)
def is_unique(seq):
    return len(seq) == len(set(seq))

if is_unique(a) == False:
    print('No')

else:
    for k in range(n-1):
        a = list[k]
        b = list[k + 1]
        if a[-1] == b[0]:
            pass
        else:
            print('No')
            break
    print('Yes')


Fixed code:
n = int(input())
list = []
for i in range(n):
    a = input()
    list.append(a)
def is_unique(seq):
    return len(seq) == len(set(seq))

if is_unique(list) == False:
    print('No')

else:
    s = 0
    for k in range(n-1):
        a = list[k]
        b = list[k + 1]
        if a[-1] == b[0]:
            s += 1
        else:
            print('No')
            break
    if (s+1) == n:
        print('Yes')
    else:
        pass
Buggy code:
n=int(input())
e=''
s=''
S=[input() for  _ in range(n)]
for w in S:
    if e!=s:
        print('No')
        exit()
    s=w[0]
    e=w[-1]
if S==set(S):
    print('Yes')
else:
    print('No')
    

Fixed code:
n=int(input())
e=''
S=[input() for  _ in range(n)]

for w in S:
    if e!=w[0] and e!='':
        print('No')
        exit()
    e=w[-1]

if len(set(S))==n:
    print('Yes')
else:
    print('No')
Buggy code:
n, *l = open(0).read().split()
print("Yes" if len(set(l)) == len(l) and all(l[i][-1] == l[i+1][0] for i in range(n)) else "No")

Fixed code:
n, *l = open(0).read().split()
print("Yes" if len(set(l)) == len(l) and all(l[i][-1] == l[i+1][0] for i in range(int(n)-1)) else "No")
Buggy code:
import sys
n=int(input())
now=input()
for i in range(n-1):
    w=input()
    if now[-1]!=w[0]:
        print("No")
        sys.exit()
    now=w
print("Yes")

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

w = list(input() for i in range(n))

rule = "No"

if len(w) == len(set(w)):
  rule = "Yes"
else:
  rule = "No"
  print(rule)
  exit()

c = 0
for i in range(1,n):
  if w[i-1][-1] == w[i][0]:
    c += 1
    continue
  
if c == n-1:
  rule = "Yes"
else:
  print("No")
    
    



print(rule)

Fixed code:
n = int(input())

w = list(input() for i in range(n))

rule = "No"

if len(w) == len(set(w)):
  rule = "Yes"
else:
  print("No")
  exit()

c = 0
for i in range(1,n):
  if w[i-1][-1] == w[i][0]:
    c += 1
    continue
  
if c == n-1:
  rule = "Yes"
else:
  print("No")
  exit()
    
    



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

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

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

print('Yes')
Buggy code:
N = int(input())
shiri = []
flag = 0
for i in range(N):
    tugi = str(input())
    tlist = list(tugi)
    if i!=0:
        if tugi in shiri:
            flag = 1
            break
        else:
            mae = list(shiri[i-1])
            if tlist[0]!=mae[-1]:
                flag = 1
                break
            else:
                shiri,append(tugi)
    else:
        shiri.append(tugi)
if flag == 0:
    print("Yes")
else:
    print("No")

Fixed code:
N = int(input())
shiri = []
flag = 0
for i in range(N):
    tugi = str(input())
    tlist = list(tugi)
    if i!=0:
        if tugi in shiri:
            flag = 1
            break
        else:
            mae = list(shiri[i-1])
            if tlist[0]!=mae[-1]:
                flag = 1
                break
            else:
                shiri.append(tugi)
    else:
        shiri.append(tugi)
if flag == 0:
    print("Yes")
else:
    print("No")
Buggy code:
n = int(input())
w = [input() for _ in range(n)]

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

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


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

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

print("Yes" if flag else "No")
Buggy code:
    w=[input() for _ in range(n)]
    chk=[]
    chk.append(w[0])
    ans='Yes'
    for i in range(1,n):
        if w[i-1][-1]!=w[i][0] or (w[i] in chk):
            ans='No'
            break
        chk.append(w[i])
    print(ans)

if __name__ == '__main__':
    resolve()

Fixed code:
def resolve():
    n=int(input())
    w=[input() for _ in range(n)]
    chk=[]
    chk.append(w[0])
    ans='Yes'
    for i in range(1,n):
        if w[i-1][-1]!=w[i][0] or (w[i] in chk):
            ans='No'
            break
        chk.append(w[i])
    print(ans)

if __name__ == '__main__':
    resolve()
Buggy code:
n = int(input())
ans = 'Yes'
words = [input() for _ in range(n)]
said = set()
tail = words[0][0]
for w in words:
    if w in said or w[0] != tail:
        ans = 'No'
        print(w)
        break
    said.add(w)
    tail = w[-1]

print(ans)

Fixed code:
n = int(input())
ans = 'Yes'
words = [input() for _ in range(n)]
said = set()
tail = words[0][0]
for w in words:
    if w in said or w[0] != tail:
        ans = 'No'
        break
    said.add(w)
    tail = w[-1]

print(ans)
Buggy code:
def valid(words):
  used = set()
  last = ""

  for w in words:
    if w in used:
      return False
    if last != "" and last[-1] != w[0]:
      return False
    last = w
    used.append(w)
  return True

n = int(input())
words = [input() for _ in range(n)]
print("Yes" if valid(words) else "No")

Fixed code:
def valid(words):
  used = set()
  last = ""

  for w in words:
    if w in used:
      return False
    if last != "" and last[-1] != w[0]:
      return False
    last = w
    used.add(w)

  return True


n = int(input())
words = [input() for _ in range(n)]
print("Yes" if valid(words) else "No")
Buggy code:
import sys
n=int(input())
sp=input()
l=set()
for _ in range(n-1):
    sn=input()
    if (sn in l) or (sp[-1]!=sn[0]):
        print('No')
        sys.exit()
    l.add(sn)
    sp=sn
print('Yes')

Fixed code:
import sys
n=int(input())
sp=input()
l=set()
for _ in range(n-1):
    sn=input()
    if (sn in l) or (sp[-1]!=sn[0]):
        print('No')
        sys.exit()
    l.add(sp)
    sp=sn
print('Yes')
Buggy code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = collections.defaultdict(int)
    s = [str(input().rstrip('\n')) for _ in range(n)]
    for i in range(n):
        if i != 0:
            if s[i][0] != s[i-1][-1] or s[i] in d:
                print("NO")
                exit()
        d[s[i]]
    print("YES")


if __name__ == '__main__':
    slove()


Fixed code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    d = collections.defaultdict(int)
    s = [str(input().rstrip('\n')) for _ in range(n)]
    for i in range(n):
        if i != 0:
            if s[i][0] != s[i-1][-1] or s[i] in d:
                print("No")
                exit()
        d[s[i]]
    print("Yes")


if __name__ == '__main__':
    slove()
Buggy code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    lw = ""
    d = collections.defaultdict(list)
    for i in range(n):
        w = str(input().rstrip('\n'))
        if lw != "":
            if w[0] != lw or w in d:
                print("NO")
                exit()
        lw = w[-1]
        d[w]
    print("YES")


if __name__ == '__main__':
    slove()


Fixed code:
def slove():
    import sys
    import collections
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    lw = ""
    d = collections.defaultdict(list)
    for i in range(n):
        w = str(input().rstrip('\n'))
        if lw != "":
            if w[0] != lw or w in d:
                print("No")
                exit()
        lw = w[-1]
        d[w]
    print("Yes")


if __name__ == '__main__':
    slove()
Buggy code:
N = int(input())
w = []
ans = "Yes"
for i in range(N):
  s = str(input())
  if(i>0):
    if(s[0]==w[-1][-1]):
      None
    else:
      ans = "No"
      break
  w.append(s)
j = set(N)
l = len(list(j))
if(len(N)==l):
  None
else:
  ans="No"
print(ans)

Fixed code:
N = int(input())
w = []
ans = "Yes"
for i in range(N):
  s = str(input())
  if(i>0):
    if(s[0]==w[-1][-1]):
      None
    else:
      ans = "No"
      break
  w.append(s)
j = set(w)
l = len(list(j))
if(N==l):
  None
else:
  ans="No"
print(ans)
Buggy code:
N=int(input())

words=[input() for _ in range(N)]

tmp=set(words)
print(tmp)
c=1
if len(words)!=len(tmp):
    c=0
else:
    for i in range(N):
        print(words)
        if i==0:
            continue
        elif words[i][0]!=words[i-1][-1]:
            c=0
            break


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

Fixed code:
N=int(input())

words=[input() for _ in range(N)]

tmp=set(words)
#print(tmp)
c=1
if len(words)!=len(tmp):
    c=0
else:
    for i in range(N):
#        print(words)
        if i==0:
            continue
        elif words[i][0]!=words[i-1][-1]:
            c=0
            break


#print(c)
if c:
    print("Yes")
else:
    print("No")
Buggy code:
n=int(input())
w=[input() for i in range(n)]
a=0
for i in range(1,n):
  if w[i-1][-1] == w[i][0]:
    if w[i] not in w[:i]:
      a=a
  else:
    a+=1
if a==0:print("Yes")
else:print("No")

Fixed code:
n=int(input())
w=[input() for i in range(n)]
a=0
for i in range(1,n):  
  if w[i-1][-1] == w[i][0]:
    if w[i] not in w[:i]:
      a=a
    else:
      a+=1
  else:
    a+=1
if a==0:print("Yes")
else:print("No")
Buggy code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(0, N):
  if a[num] in a:
    print('No')
    break
  if num < N:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  print('Yes')

Fixed code:
N = int(input())
a = [input() for i in range(N)]
 
for num in range(N):
  if num > 0:
    if a[num] in a[:num-1]:
    	print('No')
    	break
  if num < N-1:
    if a[num][-1] != a[num+1][0]:
    	print('No')
    	break
  if num == N-1:
    print('Yes')
Buggy code:
n = int(input())
used = list(input() for x in range(n))
ans = "Yes"
for i in range(n): 
  if used.count(used[i]) == 2:
    ans = "No"
    break
  if used[i][-1] != used[i][0]:
    ans = "No"
print(ans)

Fixed code:
n = int(input())
used = list(input() for x in range(n))
ans = "Yes"
for i in range(n-1): 
  if used.count(used[i]) == 2:
    ans = "No"
    break
  if used[i][-1] != used[i+1][0]:
    ans = "No"
print(ans)
Buggy code:
import sys
n = int(input())
w = []
for i in range(n):
    w.append(input())
if len(w) != len(set(w)):
    print("No")
    sys.exit()
for i in range(n-1):
    if w[i][len(w[i]) - 1] != w[i+1][len(w[i+1] - 1)]:
        print("No")
        sys.exit()
print("Yes")

Fixed code:
import sys
n = int(input())
w = []
for i in range(n):
    w.append(input())
if len(w) != len(set(w)):
    print("No")
    sys.exit()
for i in range(n-1):
    if w[i][len(w[i]) - 1] != w[i+1][0]:
        print("No")
        sys.exit()
print("Yes")
Buggy code:
a = int(input())
wordli = dict()
go = True
for i in range(a):
	word = input()
	if i == 0:
		wordli[word] = 1
	else:
		if word not in wordli:
			wordli[word] = 1
		else:
			print ('No')
			go = False
			break

if go == True:
	print ('Yes')

Fixed code:
a = int(input())
wordli = dict()
go = True
for i in range(a):
	word = input()
	if i == 0:
		wordli[word] = 1
		temp = word
	else:
		if word not in wordli and word[0] == temp[-1]:
			wordli[word] = 1
			temp = word
		else:
			print ('No')
			go = False
			break

if go == True:
	print ('Yes')
Buggy code:
# ABC 109, B - shiritori

n = int(input())
w = []
for i in range(n):
    w.append(input())
print(w)


used = []

for i in range(n):
    print(i)
    if i == 0:
        used.append(w[i])
        tail = w[i][-1]
    else:
        # no if the same word is used
        if w[i] in used:
            print('No')
            break
        # no if the hean and tail is not equal
        elif w[i][0] != tail:
                print('No')
                break
        else:
            used.append(w[i])
            tail = w[i][-1]
else:
    print('Yes')


Fixed code:
# ABC 109, B - shiritori

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


used = []

for i in range(n):
    if i == 0:
        used.append(w[i])
        tail = w[i][-1]
    else:
        # no if the same word is used
        if w[i] in used:
            print('No')
            break
        # no if the hean and tail is not equal
        elif w[i][0] != tail:
                print('No')
                break
        else:
            used.append(w[i])
            tail = w[i][-1]
else:
    print('Yes')