qyliang/CodeNanoFix huggingface dataset:
Buggy code:
n = int(input())
lst = [iuput() for _ in range(n-1)]
lstset = set(lst)
if len(lst) != len(lstset):
    print("No")
else:
    cnt = 0
    for i in range(n-1):
        if lst[i][-1] == lst[i][0]:
            cnt += 1
        else:
            break
    if cnt == len(lst):
        print('Yes')
    else:
        print('No')
    

Fixed code:
n = int(input())
lst = [input() for _ in range(n)]
lstset = set(lst)

if len(lst) != len(lstset):
    print("No")
else:
    cnt = 0
    for i in range(n-1):
        if lst[i][-1] == lst[i + 1][0]:
            cnt += 1
        else:
            break
    if cnt + 1 == len(lst):
        print('Yes')
    else:
        print('No')
Buggy code:
N=int(inout())
before=[]
ans="Yes"
for i in range(N):
        s=input()
        if s in before:
                ans="No"
        if len(before)>0:
                if before[-1][-1]!=s[0]:
                        ans="No"
        before.append(s)

print(ans)

Fixed code:
N = int(input())

before = []
answer = 'Yes'

for i in range(N):
    s = input()
    if s in before:
        answer = 'No'
    if len(before) > 0:
        if before[-1][-1] != s[0]:
            answer = 'No'

    before.append(s)

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

lastch = ''
answer = 'No'
words = []

for i in range(n):
    word = input()[0:-1]
    words.append(word)
    if lastch == word[0] and i != 0:
        answer = 'Yes'
    else:
        answer = 'No'
    lastch = word[-1]

print('Yes' if len(words) == len(set(words)) and answer == 'Yes' else 'No')


Fixed code:
n = int(input())

lastch = ''
answer = 'Yes'
words = []
for i in range(n):
    word = list(input())
    words.append(''.join(word))
    if lastch != word[0] and i != 0:
        answer = 'No'
    lastch = word[-1]

if len(set(words)) != len(words):
    answer = 'No'

print(answer)
Buggy code:
import sys
n = int (input())
words = []
No=" "
for i in range (n) :
    words.append(input())
for x in range(len(words)):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        No="No"
        print (No)
        sys.exit() 
If No != "No":
     print ("Yes")

Fixed code:
import sys
c = int (input())
words = []
No=" "
for i in range (c) :
    words.append(input())
for x in range(len(words)-1):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        No="No"
        print (No)
        sys.exit() 


if No != "No":
     print ("Yes")
Buggy code:
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())

li = [stdin.readline().rstrip() for _ in range(n)]
k = len(li)
li = list(set(li))
if len(li) != k:
    print("No")
    exit()


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

print("Yes")

Fixed code:
from sys import stdin
import fractions

n = int(stdin.readline().rstrip())

li = [stdin.readline().rstrip() for _ in range(n)]
k = len(li)
lin = list(set(li))

if len(lin) != k:
    print("No")
    exit()

for i in range(len(li)-1):
    if li[i][-1] != li[i+1][0]:
        print("No")
        exit()
print("Yes")
Buggy code:
N=int(input())
W=[]
for i in range(N):
  W.append(input())
for i in range(N-1):
  if W[i][-1] != W[i+1][0]:
    print('No')
    return
  for j in range(i+1, N):
    if W[i]==W[j]:
      print('No')
      return
print('Yes')

Fixed code:
N=int(input())
W=[]
for i in range(N):
  W.append(input())
for i in range(N-1):
  if W[i][-1] != W[i+1][0]:
    print('No')
    exit()
  for j in range(i+1, N):
    if W[i]==W[j]:
      print('No')
      exit()
print('Yes')
Buggy code:
n = int(input())

word = set()
last = ""
blnOk=True
for i in range(n):
    s = input()
    word.add(s)
    if last != "" and last != s[-1]:
        print('No')
        exit()
    last = s[-1]
print('Yes' if len(word) == n else 'No') 


Fixed code:
n = int(input())

word = set()
last = ""
blnOk=True
for i in range(n):
    s = input()
    word.add(s)
    if last != "" and last != s[0]:
        print('No')
        exit()
    last = s[-1]
print('Yes' if len(word) == n else 'No')
Buggy code:
dataNum=input()
wordList=[]
for word in input:
    wordList.append(word.strip())

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

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

print("Yes")

Fixed code:
dataNum=int(input())
wordList=[]
for n in range(dataNum):
    wordList.append(input().strip())

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

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

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


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

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

def alg1(W):
  list = []
  point = W[0]
  for i in range(1,N):
    if W[i] not in list and W[i][0] == point[-1]:
      list.append(W[i])
      point = W[i]
      pass
    else:
      return 'No'
  return 'Yes'

print(alg1(W))

Fixed code:
N = int(input())

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

def alg1(W):
  list = [W[0],]
  point = W[0]
  for i in range(1,N):
    if W[i] not in list and W[i][0] == point[-1]:
      list.append(W[i])
      point = W[i]
    else:
      return 'No'
  return 'Yes'

print(alg1(W))
Buggy code:
n=int(input)
flag=True
a=0
l=[]
for i in range(n):
    b=a
    l.append(b)
    a=list(input())
    if i>0:
        if a[0]!=b[-1] or a in l:
            flag=False
if flag:
    print('Yes')
else:
    print('No')

Fixed code:
n=int(input())
flag=True
a=0
l=[]
for i in range(n):
    b=a
    l.append(b)
    a=list(input())
    if i>0:
        if a[0]!=b[-1] or a in l:
            flag=False
if flag:
    print('Yes')
else:
    print('No')
Buggy code:
N = int(input())
out = "Yes"
S = input()
L = []

L.append(S)
for i in range(N-1):
    T = input()
    if T in L:
        out = "No"
    if T[0]!=S[-1]:
        out = "No"
    S = T
print(out)


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

L.append(S)
for i in range(N-1):
    T = input()
    if T in L:
        out = "No"
    if T[0]!=S[-1]:
        out = "No"
    S = T
    L.append(S)
print(out)
Buggy code:
n=int(input())
a=[]
for i in range(n):
    a.append(input())
flag=0
for i in range(n):
   s=a[i]
    
   if i==0:
       continue
   else:
       if last!=a[i][len(a[i])-1]:
           flag=1
           
   last=a[i][len(a[i])-1]
if flag==1:
    print("No")
else:
    print("Yes")

Fixed code:
n=int(input())
a=[]
for i in range(n):
    a.append(input())
b=[]
flag=0
for i in range(n):
    s=a[i]
    if i!=0:
        if s[0]!=last:
            flag=1
    last=s[len(s)-1]
    if s in b:
        flag=1
        break
    b.append(s)
    
    
if flag==1:
    print("No")
else:
    print("Yes")
Buggy code:
N=int(input())
s=[input() for i in range(N)]
if(len(s)!=len(set(s))):
  print('No')
else:
  for i in range(N-1):
    len_s=len(s[i])
    if(s[i][len_s-1]!=s[i+1][0]):
      print("No")
      break
    else:continue
  print('Yes')

Fixed code:
N=int(input())
s=[input() for i in range(N)]
count=0
if(len(s)!=len(set(s))):
  count=1
else:
  for i in range(N-1):
    len_s=len(s[i])
    if(s[i][len_s-1]!=s[i+1][0]):
      count=1
      break
    else:continue
if(count==0):
	print('Yes')
else:print('No')
Buggy code:
n = int(input())
w = [input() for i in range(n)]

used_words = [w[0]]

def check_shiritori(b_word, a_word):
    if b_word[-1] == a_word[0]:
        return True
    else:
        return False

rule_flag = True
for i in range(1, n):
    if w[i] in used_words:
        rule_flag = False        
    if check_shiritori(w[i-1], w[i]):
        used_words.append(w[i])

if rule_flag is True:
    print("Yes")
else:
    print("No")



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

used_words = [w[0]]

def check_shiritori(b_word, a_word):
    if b_word[-1] == a_word[0]:
        return True
    else:
        return False

rule_flag = True
for i in range(1, n):
    if w[i] in used_words:
        rule_flag = False 
        break       
    if check_shiritori(w[i-1], w[i]):
        used_words.append(w[i])
    else:
        rule_flag = False
        break

if rule_flag is True:
    print("Yes")
else:
    print("No")
Buggy code:
already = {}
n = int(input())
last = ''
for i in range(n):
  s = input()
  if i != 0 and s[0] != last[-1]:
    print('No')
    break
  last = s
else:
  print('Yes')

Fixed code:
already = {}
n = int(input())
last = ''
for i in range(n):
  s = input()
  if (i != 0 and s[0] != last[-1]) or (s in already) :
    print('No')
    break
  last = s
  already[s] = 1
else:
  print('Yes')
Buggy code:
import collections

N = int(input())
W = [input() for i in range(N)]
w = collections.Counter(W)
if sum(w.values()) > len(W):
  print('No')
else:
  for i in range(len(W)-1):
    s = W[i]
    tmp = s[len(s)-1]
    s_next = W[i+1]
    if tmp != s_next[0]:
      print('No')
      break
  else:
    print('Yes')

Fixed code:
import collections

N = int(input())
W = [input() for i in range(N)]
w = collections.Counter(W)
if len(w.values()) != len(W):
  print('No')
else:
  for i in range(len(W)-1):
    s = W[i]
    tmp = s[len(s)-1]
    s_next = W[i+1]
    if tmp != s_next[0]:
      print('No')
      break
  else:
    print('Yes')
Buggy code:
N = int(input())
l = list()

for n in range(0,N-1):
    a = input()
    l.append(a)

l_uniq = list(set(l))

if len(l) == len(l_uniq):
    for i in range(1, N):
        if a[i][0] != a[i-1][-1]:
            print("No")
            break
    print("Yes")
else:
    print("No")
    

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

for n in range(N):
    a = input()
    l.append(a)

l_uniq = list(set(l))

if len(l) == len(l_uniq):
    for i in range(0, N-1):
        if l[i+1][0] != l[i][-1]:
            print("No")
            break
    else:
        print("Yes")
else:
    print("No")
Buggy code:
N = int(input())
word = []
flag = 1
for i in range(N):
  st = input()
  if i > 0 :
    if final != st[0]:
      flag = 0
    elif st in word:
      flag = 0
    else:
      final = st[-1]
      word += [st]
if flag:
  print("Yes")
else :
  print("No")

Fixed code:
N = int(input())
word = []
flag = 1
for i in range(N):
  st = input()
  if i > 0 :
    if final != st[0]:
      flag = 0
    elif st in word:
      flag = 0
    else:
      final = st[-1]
      word += [st]
  else:
    final = st[-1]
    word += [st]
if flag:
  print("Yes")
else :
  print("No")
Buggy code:
N = int(input())
list_aaa = [input() for i in range(N)]

cnt_A=0
cnt_B=0

for i in range(N-1):
    if list_aaa[i][:-1] ==list_aaa[i+1][1:]:
        cnt_A +=1
    if list_aaa.count(list_aaa[i]) >=2:
        cnt_B +=1

if cnt_A >=1 or cnt_B>=1:
    print("No")
else:
    print("Yes")

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

cnt_A=0
cnt_B=0

for i in range(N-1):
    if not list_aaa[i][-1:] ==list_aaa[i+1][:1]:
        cnt_A +=1
    if list_aaa.count(list_aaa[i]) >=2 or list_aaa.count(list_aaa[i]) >=2 :
        cnt_B +=1


if cnt_A >=1 or cnt_B>=1:
    print("No")
else:
    print("Yes")
Buggy code:
n=int(input())
w=[input() for i in range(n)]
flag=True
for s in w:
    if w.count(s) > 1:
        flag = False
for i in range(1,n)
    if list(w[i])[0] != reversed(list(w[i-1]))[0]:
        flag = False
print("Yes" if flag else "No")

Fixed code:
n=int(input())
w=[input() for i in range(n)]
flag=True
for s in w:
    if w.count(s) > 1:
        flag = False
for i in range(1,n):
    if w[i][0] != w[i-1][-1]:
        flag = False
print("Yes" if flag else "No")
Buggy code:
def main():
    n = int(input())
    word_lst = [""] * n
    previous_word = input()
    ok = True
    for i in range(1,n):
        now_word = input()
        if not (now_word[0] == previous_word[-1]):
            ok = False
            break
        word_lst.append(now_word)
        previous_word = now_word
    if len(word_lst) != len(set(word_lst)):
        ok = False

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






if __name__ == '__main__':
    main()


Fixed code:
def main():
    n = int(input())
    word_lst = []
    previous_word = input()
    word_lst.append(previous_word)
    ok = True
    for i in range(1,n):
        now_word = input()
        if not (now_word[0] == previous_word[-1]):
            ok = False
            break
        if now_word in word_lst:
            ok = False
            break
        word_lst.append(now_word)
        previous_word = now_word
    if len(word_lst) != len(set(word_lst)):
        ok = False

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






if __name__ == '__main__':
    main()
Buggy code:
n = int(input())
w = [input() for i in range(N)]

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')

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

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())
li = []
lastChar = ''
for _ in range(n):
    li.append(input())
for word in li:
    if li.count(word) != 1 or word[0] != lastChar:
        print('No')
        exit()
    lastChar = word[-1]
print('Yes')

Fixed code:
n = int(input())
li = []
for _ in range(n):
    li.append(input())
lastChar = li[0][0]
for word in li:
    if li.count(word) != 1 or word[0] != lastChar:
        print('No')
        exit()
    lastChar = word[-1]
print('Yes')
Buggy code:
import sys
n = int (input())
words = []
for i in range (n) :
    words.append(input())
for x in range(n-1):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        print("No")
        sys.exit()
    else:
        "Yes"

Fixed code:
import sys
n = int (input())
words = []
No=" "
for i in range (n) :
    words.append(input())
for x in range(len(words)-1):
    if words.count(words[x]) > 1 or words[x+1][0] != words[x][-1]:
        No="No"
        print (No)
        sys.exit() 
if No != "No":
     print ("Yes")
Buggy code:
N = int(input())
W = []
for i in range(N):
    X = input()
    W.append(X)
    if i >= 1:
        if W[i-1][len(W[i-1])-1] != W[i][0]:
            print("No1")
            exit()
    for j in range(i):
        if W[i] == W[j]:
            print("No2")
            exit()
else:
    print("Yes")


Fixed code:
N = int(input())
W = []
for i in range(N):
    X = input()
    W.append(X)
    if i >= 1:
        if W[i-1][len(W[i-1])-1] != W[i][0]:
            print("No")
            exit()
    for j in range(i):
        if W[i] == W[j]:
            print("No")
            exit()
else:
    print("Yes")
Buggy code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
wls =[]
for i in range(N):
    wls.append(input())
count =0
if count(wls) != count(set(wls):
    print('No')
else:
    for i in range(N):
        if i == 0:
            continue
        else:
            if wls[i][0] != wls[i-1][-1]:
                count += 1
            
if count == 0:
    print('Yes')
else:
    print('No')
        





Fixed code:
#! /usr/bin/env python3
# -*- coding: utf-8 -*-
N = int(input())
wls =[]
for i in range(N):
    wls.append(input())
count =0
if len(wls) != len(set(wls)):
    print('No')
else:
    for i in range(N):
        if i == 0:
            continue
        else:
            if wls[i][0] != wls[i-1][-1]:
                count += 1
            
    if count == 0:
        print('Yes')
    else:
        print('No')
Buggy code:
import sys
N = int(input())
S = [input() for s in range(N)]
s = set(S)
if len(S) != len(s):
  print("No")
for i in range(N-1):
  if S[i][-1] != S[i+1][0]:
    print("No")
    sys.exit()
print("Yes")
  

  

Fixed code:
import sys
N = int(input())
S = [input() for s in range(N)]
s = set(S)
if len(S) != len(s):
	print("No")
	sys.exit()
for i in range(N-1):
	if S[i][-1] != S[i+1][0]:
		print("No")
		sys.exit()
print("Yes")
Buggy code:
n = int(input())
wordlist = []
for i in range(n):
    word = str(input())
    if word in wordlist:
        print('No')
        exit()
    if wordlist and wordlist[-1][-1] == word[-1]:
        print('No')
        exit()
    wordlist.append(word)
print('Yes')

Fixed code:
n = int(input())
wordlist = []
for i in range(n):
    word = str(input())
    if word in wordlist:
        print('No')
        exit()
    if wordlist and wordlist[-1][-1] != word[0]:
        print('No')
        exit()
    wordlist.append(word)
print('Yes')
Buggy code:
N=int(input())
Ws=[]
for n in range(N):
    W=input()
    Ws.append(W)

for w in range(len(Ws)):
    if Ws.count(w)>1:
        print('No')
        exit()

for x in range (1,N):
    if Ws[x][0] != Ws[x-1][-1]:
        print("No")
        exit()
print("Yes")


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

for w in range(len(Ws)):
    if Ws.count(Ws[w])>=2:
        print("No")
        exit()
        
for x in range (1,len(Ws)):
    if Ws[x][0] != Ws[x-1][-1]:
        print("No")
        exit()

print("Yes")
Buggy code:
n = int(input())
words = []

for i in range(n):
  word = input()
  if i >= 1:
    if word in words or word[1] != before_word[-1]:
      print('No')
      break
  before_word = word
  words.append(word)

else:
  print('Yes')

Fixed code:
n = int(input())
words = []
 
for i in range(n):
  word = input()
  if i >= 1:
    if word in words or word[0] != words[-1][-1]:
      print('No')
      break
      
  words.append(word)

else:
  print('Yes')
Buggy code:
N = int(input())
Word = []
tail = ""
for i in range(N):
    W = list(input())
    Word.append(W)
    tail = W[-1]
    if i != 0:
        if tail != W[0] or (W in Word):
            print("No")
            exit()
print("Yes")

Fixed code:
N = int(input())
Word = []
tail = ""
for i in range(N):
    W = list(input())
    head = W[0]
    W = ''.join(W)
    if i != 0:
        if tail != head or (W in Word):
            print("No")
            exit()
    tail = W[-1]
    Word.append(W)
print("Yes")
Buggy code:
def main():
    n = input()
    before = ''
    words = set()

    for i in range(n):
        w = input()
        if w not in words:
            words.add(w)
        else:
            print('No')
            return

        if before == '':
            before = w
            continue

        if before[-1] != w[0]:
            print('No')
            return

    print('Yes')


main()


Fixed code:
def main():
    n = int(input())
    before = ''
    words = set()

    for i in range(n):
        w = input()
        if w not in words:
            words.add(w)
        else:
            print('No')
            return

        if before == '':
            before = w
            continue

        if before[-1] != w[0]:
            print('No')
            return
        before = w

    print('Yes')


main()
Buggy code:
N = input()
w = []
for i in range(N):
    w.append(input())
# [a1, a2, a3, ..., aN]
p = 0
for i in range(N):
  for j in range(i+1,N):
    if w[i] == w[j]:
      p = 1
      break
    
v = []
for j in range(N):
  v[j] = list(w[j])

for k in range(N):
  if k != 0:
    if v[k - 1][len(v[k - 1]) - 1] != v[k][0]:
      p = 1
      break

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

Fixed code:
N = int(input())
w = []
for i in range(N):
    w.append(input())
# [a1, a2, a3, ..., aN]
p = 0
for i in range(N):
  for j in range(i+1,N):
    if w[i] == w[j]:
      p = 1
      break
v = []
    
for i in range(N):
  v.append([])

for j in range(N):
  for s in list(w[j]):
    v[j].append(s)

for k in range(N):
  if k != 0:
    if v[k - 1][len(v[k - 1]) - 1] != v[k][0]:
      p = 1
      break

if p == 0:
  print("Yes")
else:
  print("No")
Buggy code:
# abc109_b

from collections import Counter


def solve(words):
    if Counter(words).most_common()[0][1] > 1:  # repetition is present
        return "No"
    else:
        # initial letter first word not important
        # final letter final word not important
        if list(map(lambda x: x[0], words[1:])) == list(map(lambda x: x[-1], words[:-1])):
            return "Yes"
        else:
            return "No"


def solve2(words):
    for i in range(len(words)):
        if words[i] in words[i:]:
            return "No"
        else:
            if words[i][-1] != words[i + 1][0]:
                return "No"
    return "Yes"


if __name__ == "__main__":
    N = int(input(""))
    words = [input("") for i in range(N)]
    print(solve2(words))


Fixed code:
# abc109_b

from collections import Counter


def solve(words):
    if Counter(words).most_common()[0][1] > 1:  # repetition is present
        return "No"
    else:
        # initial letter first word not important
        # final letter final word not important
        if list(map(lambda x: x[0], words[1:])) == list(map(lambda x: x[-1], words[:-1])):
            return "Yes"
        else:
            return "No"


def solve2(words):
    for i in range(len(words) - 1):
        if words[i] in words[i + 1:]:
            return "No"
        else:
            if words[i][-1] != words[i + 1][0]:
                return "No"
    return "Yes"


if __name__ == "__main__":
    N = int(input(""))
    words = [input("") for i in range(N)]
    print(solve2(words))
Buggy code:
n = int(input())

l = [input() for _ in range(4)]

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

if flag and count == n:
    print("Yes")
else:
    print("No")

Fixed code:
n = int(input())

l = [input() for _ in range(n)]

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

if flag and count == n:
    print("Yes")
else:
    print("No")
Buggy code:
n = int(input())
w = [input() for _ in range(n)]

correct = True
for i in range(1, len(w)):
    if w[i] in w[i + 1:]:
        correct = False
        break
    if i > 0 and w[i][0] != w[i - 1][-1]:
        correct = False
        break

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


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

correct = True
for i in range(len(w)):
    if w[i] in w[i + 1:]:
        correct = False
        break
    if i > 0 and w[i][0] != w[i - 1][-1]:
        correct = False
        break

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

Fixed code:
n = int(input())
w = [input() for i in range(n)]
if len(w) == len(set(w)):
  ok = True
  for i in range(n-1):
    if w[i][-1] != w[i+1][0]:
      ok = False
      break
  if ok:
    print("Yes")
  else:
    print("No")
else:
  print("No")
Buggy code:
n,x = map(int,input().split())
y = list(map(int,input().split()))
a = [x-y[i] for i in range(n)]
def gcd(a,b):
    return gcd(b,a%b) if b else abs(a)
ans = a[0]
for i in range(1,n):
    ans = gcd(ans,a[i])
print(ans)

Fixed code:
n,x = map(int,input().split())
a = list(map(int,input().split()))
new_lst=[abs(i-x) for i in a]

def gcd(x,y):
    if y==0:
        return x
    else:
        return gcd(y,x%y)

ans=new_lst[0]
for i in range(1,n):
	ans =gcd(new_lst[i],ans)

print(ans)