qyliang/CodeNanoFix huggingface dataset:
Buggy code:
from collections import deque

SA = deque(list(input()))
SB = deque(list(input()))
SC = deque(list(input()))

turn = 'a'

while True:
    if turn == 'a' and len(SA) == 0:
        ans = 'A'
        break
    elif turn == 'b' and len(SB) == 0:
        ans = 'B'
        break
    elif turn == 'c' and len(SC) == 0:
        ans = 'C'
        break

    if turn == 'a':
        turn = SA.popleft()
    elif turn == 'b':
        turn = SB.popleft()
    else:
        turn = SC.popleft()

Fixed code:
from collections import deque

SA = deque(list(input()))
SB = deque(list(input()))
SC = deque(list(input()))

turn = 'a'

while True:
    if turn == 'a' and len(SA) == 0:
        ans = 'A'
        break
    elif turn == 'b' and len(SB) == 0:
        ans = 'B'
        break
    elif turn == 'c' and len(SC) == 0:
        ans = 'C'
        break

    if turn == 'a':
        turn = SA.popleft()
    elif turn == 'b':
        turn = SB.popleft()
    else:
        turn = SC.popleft()
print(ans)
Buggy code:
A = [i for i in input()]
B = [i for i in input()]
C = [i for i in input()]

ps = {'a':A,'b':B,'c':C}
turn = 'a'
while True:
    if len(ps[turn]) <= 0:
        break
    turn = ps[turn].pop(0)
turn.upper()
print(turn)


Fixed code:
A = [i for i in input()]
B = [i for i in input()]
C = [i for i in input()]

ps = {'a':A,'b':B,'c':C}
turn = 'a'
while True:
    if len(ps[turn]) <= 0:
        break
    turn = ps[turn].pop(0)
print(turn.upper())
Buggy code:
a,b,c=input(),input(),input()
string=[a,b,c]
s=[0,0,0]
ban=0
print(string)
while s[0]!=len(a) and s[1]!=len(b) and s[2]!=len(c):
    temp=s[ban]
    s[ban]+=1
    if string[ban][temp]=="a": ban=0
    elif string[ban][temp]=="b": ban=1
    else: ban=2

if s[0]==len(a): print("A")
if s[1]==len(b): print("B")
if s[2]==len(c): print("C")

Fixed code:
a,b,c=input(),input(),input()
string=[a,b,c]
ans=["A","B","C"]
s=[0,0,0]
ban=0
while s[ban]!=len(string[ban]):
    temp=s[ban]
    s[ban]+=1
    if string[ban][temp]=="a": ban=0
    elif string[ban][temp]=="b": ban=1
    else: ban=2
print(ans[ban])
Buggy code:
a = list(input())
b = list(input())
c = list(input())
now_person = a
a_i = 0
b_i = 0
c_i = 0
now_person_i = 0
while True:
    if now_person_i == len(now_person):
      break
    if now_person[now_person_i] == 'a':
        now_person = a
        a_i += 1
        now_person_i = a_i
    elif now_person[now_person_i] == 'b':
        now_person = b
        if b_i != 0:
            b_i += 1
        now_person_i = b_i
    elif now_person[now_person_i] == 'c':
        now_person = c
        if c_i != 0:
            c_i += 1
        now_person_i = c_i
if now_person == a:
    print("A")
elif now_person == b:
    print("B")
else:
    print("C")

Fixed code:
a = list(input())
b = list(input())
c = list(input())
now_person = a
a_i = 0
b_i = -1
c_i = -1
now_person_i = 0
while True:
    if now_person_i == len(now_person):
      break
    if now_person[now_person_i] == 'a':
        now_person = a
        a_i += 1
        now_person_i = a_i
    elif now_person[now_person_i] == 'b':
        now_person = b
        b_i += 1
        now_person_i = b_i
    elif now_person[now_person_i] == 'c':
        now_person = c
        c_i += 1
        now_person_i = c_i
if now_person == a:
    print("A")
elif now_person == b:
    print("B")
else:
    print("C")
Buggy code:
a = input()
b = input()
c = input()

cards = {'a': a, 'b': b, 'c': c}
turn = 'a'

while True:
    if len(cards[turn]) == 0:
        print(turn)
        break
    draw = cards[turn][0]
    cards[turn] = cards[turn][1:]
    turn = draw


Fixed code:
a = input()
b = input()
c = input()

cards = {'a': a, 'b': b, 'c': c}
turn = 'a'

while True:
    if len(cards[turn]) == 0:
        print(turn.upper())
        break
    draw = cards[turn][0]
    cards[turn] = cards[turn][1:]
    turn = draw
Buggy code:
d = dict(a=input(), b=input(), c=input())
op = 'a'
while True:
    if not d[op]:
        print(op.upper())
        break
    op = d[op].pop(0)


Fixed code:
d = dict(a=list(input()), b=list(input()), c=list(input()))
op = 'a'
while True:
    if not d[op]:
        print(op.upper())
        break
    op = d[op].pop(0)
Buggy code:
from collections import defaultdict

data = defaultdict()
for i in range(3):
    s = input()
    data[chr(ord("a") + i)] = s
cnt = defaultdict(int)
turn = "a"
while 1:
    if cnt[turn] == len(data[chr(ord(turn))]):
        ans = ord(turn) - (ord("a") - ord("A"))
        break

    cnt[turn] += 1
    turn = data[chr(ord(turn))][cnt[turn]]
print(chr(ans))

Fixed code:
from collections import defaultdict

data = defaultdict()
cnt = defaultdict(int)
for i in range(3):
    s = input()
    data[chr(ord("a") + i)] = s

turn = "a"
while 1:
    cnt[turn] += 1
    if cnt[turn] > len(data[turn]):
        ans = ord(turn) - (ord("a") - ord("A"))
        break

    turn = data[turn][cnt[turn] - 1]
print(chr(ans))
Buggy code:
A = [x for x in input()]
B = [x for x in input()]
C = [x for x in input()]
next = 'a'
while True:
    if next == 'a':
        next = A.pop(0)
        if len(A) == 0:
            print('A')
            break
    elif next == 'b':
        next = B.pop(0)
        if len(B) == 0:
            print('B')
            break
    elif next == 'c':
        next = C.pop(0)
        if len(C) == 0:
            print('C')
            break

Fixed code:
A = [x for x in input()]
B = [x for x in input()]
C = [x for x in input()]
next = 'a'
while True:
    if next == 'a':
        if len(A) == 0:
            print('A')
            break
        next = A.pop(0)
    elif next == 'b':
        if len(B) == 0:
            print('B')
            break
        next = B.pop(0)
    elif next == 'c':
        if len(C) == 0:
            print('C')
            break
        next = C.pop(0)
Buggy code:
# -*- coding : utf-8 -*-

A = list(input())
B = list(input())
C = list(input())

X = [A,B,C]

x = 0
while True :
  if X[x][0] == "a":
    X[0].remove(X[0][0])
    x == 0
    if X[0] == []:
      print("A")
      break
  elif X[x][0] == "b":
    X[1].remove(X[1][0])
    x == 1
    if X[1] == []:
      print("B")
      break
  elif X[x][0] == "c":
    X[2].remove(X[2][0])
    x == 2
    if X[2] == []:
      print("C")
      break


Fixed code:
# -*- coding : utf-8 -*-

A = list(input())
B = list(input())
C = list(input())
X = [A,B,C]
t = 0

while True:
  if X[t] == []:
    if t == 0:
      print("A")
      break
    elif t == 1 :
      print("B")
      break
    elif t == 2:
      print("C")
      break
  else:
    if X[t][0] == "a":
      X[t].remove(X[t][0])
      t = 0
    elif X[t][0] == "b":
      X[t].remove(X[t][0])
      t = 1
    elif X[t][0] == "c":
      X[t].remove(X[t][0])
      t = 2
Buggy code:
a = list(input())
b = list(input())
c = list(input())
p = a.pop()
print(p)
while 1:
    if p=='a':
        if len(a)==0:
            print('A')
            exit()
        p = a.pop()
    elif p=='b':
        if len(b)==0:
            print('B')
            exit()
        p = b.pop()
    else:
        if len(c)==0:
            print('C')
            exit()
        p = c.pop()

Fixed code:
a = list(input())
b = list(input())
c = list(input())
p = a.pop()
while 1:
    if p=='a':
        if len(a)==0:
            print('A')
            exit()
        p = a.pop(0)
    elif p=='b':
        if len(b)==0:
            print('B')
            exit()
        p = b.pop(0)
    else:
        if len(c)==0:
            print('C')
            exit()
        p = c.pop(0)
Buggy code:
dic = {i:list(input()) for i in 'abc'}
while len(dic[key]) != 0:
  key = 'a'
  key = dic.pop(key)
print(key.upper())

Fixed code:
dic = {i:list(input()) for i in 'abc'}
key = 'a'
while len(dic[key]) != 0:
  key = dic[key].pop(0)
print(key.upper())
Buggy code:
S = {i: input() for i in 'abc'}
s = 'a'
while S[s]:
  s = S[s].pop(0)
print(s)

Fixed code:
S = {i: list(input()) for i in 'abc'}
s = 'a'
while S[s]:
  s = S[s].pop(0)
print(s.upper())
Buggy code:
dic_S = {c: list(input()) for c in "abc"}
s = "a"
while dic_S[s]:
  s = S[s].pop(0)
print(s.upper())  

Fixed code:
dic_S = {c: list(input()) for c in "abc"}
s = "a"
while dic_S[s]:
  s = dic_S[s].pop(0)
print(s.upper())
Buggy code:
lis=[]
ll=["a","b","c"]
for i in range(3):
  lis.append(list(input()))
turn=0
while 1:
  x=ll.index(lis[turn].pop())
  if lis[turn]=[]:
    print(ll[turn].upper())
    break
  turn=x

Fixed code:
lis=[]
ll=["a","b","c"]
for i in range(3):
  lis.append(list(input()))
turn=0
while 1:
  if lis[turn]==[]:
    print(ll[turn].upper())
    break
  turn=ll.index(lis[turn].pop(0))
Buggy code:
Sa = list(input())
Sb = list(input())
Sc = list(input())

s = Sa.pop(0)
while True:
    if Sa==[]or Sb==[] or Sc ==[]:
        break
    if s == 'a':
        s = Sa.pop(0)
    elif s == 'b':
        s = Sb.pop(0)
    else:
        s = Sc.pop(0)
if Sa ==[]:
    print('A')
elif Sb == []:
    print('B')
else:
    print('C')


Fixed code:
Sa = list(input())
Sb = list(input())
Sc = list(input())

s = Sa.pop(0)
while True:
    if s == 'a':
        if Sa ==[]:
            print('A')
            break
        s = Sa.pop(0)
    elif s == 'b':
        if Sb ==[]:
            print('B')
            break
        s = Sb.pop(0)
    else:
        if Sc ==[]:
            print('C')
            break
        s = Sc.pop(0)
Buggy code:
sa=input()
sb=input()
sc=input()
n=len(sa)+len(sb)+len(sc)
cnta=0
cntb=0
cntc=0
ban="a"
for i in range(n+1):
    if ban=="a":
        cnta+=1
        if cnta>len(sa)-1:
            print("A")
            exit()
        else:
            ban=sa[cnta-1]
    elif ban=="b":
        cntb+=1
        if cntb>len(sb)-1:
            print("B")
            exit()
        else:
            ban=sb[cntb-1]
    elif ban=="c":
        cntc+=1
        if cntc>len(sc)-1:
            print("C")
            exit()
        else:
            ban=sc[cntc-1]

Fixed code:
sa=input()
sb=input()
sc=input()
n=len(sa)+len(sb)+len(sc)
cnta=0
cntb=0
cntc=0
ban="a"
for i in range(n+1):
    if ban=="a":
        cnta+=1
        if cnta>len(sa):
            print("A")
            exit()
        else:
            ban=sa[cnta-1]
    elif ban=="b":
        cntb+=1
        if cntb>len(sb):
            print("B")
            exit()
        else:
            ban=sb[cntb-1]
    elif ban=="c":
        cntc+=1
        if cntc>len(sc):
            print("C")
            exit()
        else:
            ban=sc[cntc-1]
Buggy code:
A=input() 
B=input() 
C=input() 

i=0
j=0
k=0
c=0

while(True):
    if(c==0):
        if(i>=(len(A)+1)):
            print("A")
            exit()
        if(A[i]=="a"):
            i+=1
            c=0
        elif(A[i]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2

    elif(c==1):
        if(j>=(len(B)+1)):
            print("B")
            exit()
        if(B[j]=="a"):
            i+=1
            c=0
        elif(B[j]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2
    else:
        if(k>=(len(C)+1)):
            print("C")
            exit()
        if(C[k]=="a"):
            i+=1
            c=0
        elif(C[k]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2


    



Fixed code:
A=input() 
B=input() 
C=input() 

i=0
j=-1
k=-1
c=0

while(True):
    if(c==0):
        if(i>=(len(A))):
            print("A")
            exit()
        if(A[i]=="a"):
            i+=1
            c=0
        elif(A[i]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2

    elif(c==1):
        if(j>=(len(B))):
            print("B")
            exit()
        if(B[j]=="a"):
            i+=1
            c=0
        elif(B[j]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2
    else:
        if(k>=(len(C))):
            print("C")
            exit()
        if(C[k]=="a"):
            i+=1
            c=0
        elif(C[k]=="b"):
            j+=1
            c=1
        else:
            k+=1
            c=2
Buggy code:
A = list(input())
B = list(input())
C = list(input())

A = A[::-1]
B = B[::-1]
C = C[::-1]

next = A.pop()

while 1:
  if len(A)==0:
    print('A')
    break
  elif len(B)==0:
    print('B')
    break
  elif len(C)==0:
    print('C')
    break
    
  if next=='a':
    next = A.pop()
  elif next=='b':
    next = B.pop()
  else:
    next = C.pop()
    


Fixed code:
A = list(input())
B = list(input())
C = list(input())

A = A[::-1]
B = B[::-1]
C = C[::-1]

next = A.pop()

while 1:    
  if next=='a':
    if len(A)==0:
      print('A')
      break
    next = A.pop()
  elif next=='b':
    if len(B)==0:
      print('B')
      break
    next = B.pop()
  else:
    if len(C)==0:
      print('C')
      break
    next = C.pop()
Buggy code:
s=[input().replace('a','0').replace('b','1').replace('c','2') for _ in '111'];
while True:
	t=int(s[t][0])
	s[t]=s[t][1:]
	if len(s[t])==0:
		print('ABC'[t])
		exit()

Fixed code:
s=[input().replace('a','0').replace('b','1').replace('c','2') for _ in '111'];t=0
while True:
	if len(s[t])==0:
		print('ABC'[t])
		exit()
	a=int(s[t][0])
	s[t]=s[t][1:]
	t=a
Buggy code:
from collections import deque

A=deque(input())
B=deque(input())
C=deque(input())

NOW="a"

while True:
    #print(NOW,A,B,C)
    if NOW=="a" and len(A)>=1:
        NOW=A.popleft()
    elif NOW=="b" and len(B)>=1:
        NOW=B.popleft()
    elif NOW=="c" and len(C)>=1:
        NOW=C.popleft()

    else:
        break

print(NOW)

Fixed code:
from collections import deque

A=deque(input())
B=deque(input())
C=deque(input())

NOW="a"

while True:
    #print(NOW,A,B,C)
    if NOW=="a" and len(A)>=1:
        NOW=A.popleft()
    elif NOW=="b" and len(B)>=1:
        NOW=B.popleft()
    elif NOW=="c" and len(C)>=1:
        NOW=C.popleft()

    else:
        break

print(NOW.upper())
Buggy code:
for i in range(3):
  s.append(input())
member=["A","B","C"]
turn=0

while True:
  if s[turn]=="":
    winner=turn
    break
  elif s[turn][0]=="a":
    s[turn]=s[turn][1:]
    turn=0
  elif s[turn][0]=="b":
    s[turn]=s[turn][1:]
    turn=1
  else:
    s[turn]=s[turn][1:]
    turn=2
print(member[winner])
    


Fixed code:
s=[]
for i in range(3):
  s.append(input())
member=["A","B","C"]
turn=0

while True:
  if s[turn]=="":
      winner=turn
      break
  if s[turn][0]=="a":
    next=0
  elif s[turn][0]=="b":
    next=1
  else:
    next=2
  s[turn]=s[turn][1:]
  turn=next

print(member[winner])
Buggy code:
a, b, c = (input() for _ in range(3))
d = {"a": a, "b": b, "c": c}
nex = "a"

while len(d[nex]) != 0:
    tmp = d[nex][0]
    d[nex] = d[nex][1:]
    nex = tmp

print(nex)

Fixed code:
a, b, c = (input() for _ in range(3))
d = {"a": a, "b": b, "c": c}
nex = "a"

while len(d[nex]) != 0:
    tmp = d[nex][0]
    d[nex] = d[nex][1:]
    nex = tmp

print(nex.upper())
Buggy code:
S = {}
S['a'] = input()
S['b'] = input()
S['c'] = input()


next = 'a'
lens = {'a':len(S['a']), 'b':len(S['b']), 'c':len(S['c'])}
counts = {'a':0, 'b':0, 'c':0}

while True:
  now = next
  if counts[now] == len[now]:
    print(now)
    exit()
  next = S[now][counts[now]]
  counts[now] += 1


Fixed code:
S = {}
S['a'] = input()
S['b'] = input()
S['c'] = input()


next = 'a'
lens = {'a':len(S['a']), 'b':len(S['b']), 'c':len(S['c'])}
counts = {'a':0, 'b':0, 'c':0}

while True:
  now = next
  counts[now]
  if counts[now] == lens[now]:
    print(now.upper())
    exit()
  next = S[now][counts[now]]
  counts[now] += 1
Buggy code:
input = open(0).readline
s = {}
s['A'] = list(input().strip())
s['B'] = list(input().strip())
s['C'] = list(input().strip())

play_order = {'A':'B', 'B':'C', 'C':'A'}

def play(player):
    
    if  len(s[player]) == 0:
        play(play_order[player])
    
    next_play = s[player].pop()
    if len(s[player]) == 0:
        
        return player
    #print(next_play)
    play(next_play.upper())
        
print(play('A'))
        
        




Fixed code:
input = open(0).readline
s = {}
s['A'] = list(input().strip())
s['B'] = list(input().strip())
s['C'] = list(input().strip())

play_order = {'A':'B', 'B':'C', 'C':'A'}

def play(player):
    if s[player] == []:
        print(player.upper())
        return player
    next_play = s[player].pop(0)
    play(next_play.upper())
        
play('A')
Buggy code:
S={c:list for c in "abc"}
s="a"
while S[s]:
  s=S[s].pop(0)
print(s.upper())

Fixed code:
S={c:list(input()) for c in "abc"}
s="a"
while S[s]:
  s=S[s].pop(0)
print(s.upper())
Buggy code:
sa = input()[::-1]
sb = input()[::-1]
sc = input()[::-1]

s = {'a':sa, 'b':sb, 'c':sc}
nxt = 'a'

while 1:
  if len(s[nxt]) == 0:
    break
  nxt, s[nxt] = s[nxt][-1], s[nxt][:-1]
print(chr(ord(nxt)-32))

Fixed code:
sa = list(input())
sb = list(input())
sc = list(input())

s = {'a':sa, 'b':sb, 'c':sc}
nxt = 'a'

while 1:
  if len(s[nxt]) == 0:
    break
  nxt = s[nxt].pop(0)
print(chr(ord(nxt)-32))
Buggy code:
a=list(input())
a.reverse()
b=list(input())
b.reverse()
c=list(input())
c.reverse()
turn=1
while 1:
  if turn==1:
    if len(a)==0:
      print("A")
      exit()
    else:
      k=a.pop()
      if k=="A":
        turn=1
      elif k=="B":
        turn=2
      else:
        turn=3
  if turn==2:
    if len(b)==0:
      print("B")
      exit()
    else:
      k=b.pop()
      if k=="A":
        turn=1
      elif k=="B":
        turn=2
      else:
        turn=3
  if turn==3:
    if len(c)==0:
      print("C")
      exit()
    else:
      k=c.pop()
      if k=="A":
        turn=1
      elif k=="B":
        turn=2
      else:
        turn=3

Fixed code:
a=list(input())
a.reverse()
b=list(input())
b.reverse()
c=list(input())
c.reverse()
turn=1
while 1:
  if turn==1:
    if len(a)==0:
      print("A")
      exit()
    else:
      k=a.pop()
      if k=="a":
        turn=1
      elif k=="b":
        turn=2
      else:
        turn=3
  if turn==2:
    if len(b)==0:
      print("B")
      exit()
    else:
      k=b.pop()
      if k=="a":
        turn=1
      elif k=="b":
        turn=2
      else:
        turn=3
  if turn==3:
    if len(c)==0:
      print("C")
      exit()
    else:
      k=c.pop()
      if k=="a":
        turn=1
      elif k=="b":
        turn=2
      else:
        turn=3
Buggy code:

a = list(input())
b = list(input())
c = list(input())
po = a.pop()
ans = 0
while len(a) >= 0 or len(b)>= 0 or len(c)>=0:
    if po == 'a':
        if len(a) == 0:
            ans = 1
            break
        else:
            po = a.pop()
    elif po == 'b':
        if len(b) == 0:
            ans = 1
            break
        else:
            po = b.pop()
    else:
        if len(c) == 0:
            ans = 1
            break
        else:
            po = c.pop()
    

if ans == 1:
    print('A')
elif ans == 2:
    print('B')
elif ans == 3:
    print('C')
    
    


Fixed code:
a = list(input())
b = list(input())
c = list(input())
po = a.pop(0)

while True:
    if po == 'a':
        if len(a) == 0:
            ans = 1
            break
        else:
            po = a.pop(0)
    elif po == 'b':
        if len(b) == 0:
            ans = 2
            break
        else:
            po = b.pop(0)
    elif po == 'c':
        if len(c) == 0:
            ans = 3
            break
        else:
            po = c.pop(0)
    

if ans == 1:
    print('A')
elif ans == 2:
    print('B')
elif ans == 3:
    print('C')
Buggy code:
a = input()
b = input()
c = input()
while True:
    i = 'a'
    if i == 'a':
        if len(a)==0:
            print('A')
            exit() 
        i = a[0]
        a = a[1:]
    elif i == 'b':
        if len(b)==0:
            print('B')
            exit()
        i = b[0]
        b = b[1:]
    else:
        if len(c)==0:
            print('C')
            exit()
        i = c[0]
        c = c[1:] 

Fixed code:
a = input()
b = input()
c = input()
i = 'a'
while True:
    if i == 'a':
        if len(a)==0:
            print('A')
            break
        i = a[0]
        a = a[1:]
    elif i == 'b':
        if len(b)==0:
            print('B')
            break
        i = b[0]
        b = b[1:]
    else:
        if len(c)==0:
            print('C')
            break
        i = c[0]
        c = c[1:]
Buggy code:
a=list(input()+"A")[::-1]
b=list(input()+"B")[::-1]
c=list(input()+"C")[::-1]

turn=a

def game(turn):
    card=turn.pop()
    if len(turn)==0:
        print(card)
    
    if card=="a":
        turn=a
    elif card=="b":
        turn=b
    else:
        turn=c
    
    game(turn)
    
game(turn)

Fixed code:
a=list(input()+"A")[::-1]
b=list(input()+"B")[::-1]
c=list(input()+"C")[::-1]

turn=a

def game(turn):
    card=turn.pop()
    if len(turn)==0:
        print(card)
    else:
        
    
        if card=="a":
            turn=a
        elif card=="b":
            turn=b
        else:
            turn=c
    
        game(turn)
    
game(turn)
Buggy code:
sa = [s for s in input()]
sb = [s fir s in input()]
sc = [s for s in input()]

next_turn = "a"
flag = True

while flag:
    if next_turn == "a":
        if len(sa) == 0:
            print("A")
            flag = False
        else:
            next_turn = sa.pop(0)
    elif next_tunr == "b":
        if len(sb) == 0:
            print("B")
            flag = false
        else:
            next_turn = sb.pop(0)
    elif next_turn == "c":
        if len(sc) ==0:
            print("C")
            flag = False
        else:
            next_turn = sc.pop(0)
        



Fixed code:
sa = [s for s in input()]
sb = [s for s in input()]
sc = [s for s in input()]

next_turn = "a"
flag = True

while flag:
    if next_turn == "a":
        if len(sa) == 0:
            print("A")
            flag = False
        else:
            next_turn = sa.pop(0)
    elif next_turn == "b":
        if len(sb) == 0:
            print("B")
            flag = False
        else:
            next_turn = sb.pop(0)
    elif next_turn == "c":
        if len(sc) == 0:
            print("C")
            flag = False
        else:
            next_turn = sc.pop(0)
Buggy code:
sa = list(input())
sb = list(input())
sc = list(input())

turn = "a"

while True:
    if turn == "a":
        if len(sa) != 0:
            turn = sa.pop(0)
        else:
            print("A")
            exit()
    elif turn == "b":
        if len(sb) != 0:
            turn = sb.pop(0)
        else:
            print("B")
            exit()
    else:
        if len(sc) != "c"
            turn = sc.pop(0)
        else:
            print("C")
            exit()





Fixed code:
sa = list(input())
sb = list(input())
sc = list(input())

turn = "a"

while True:
    if turn == "a":
        if len(sa) != 0:
            turn = sa.pop(0)
        else:
            print("A")
            exit()
    elif turn == "b":
        if len(sb) != 0:
            turn = sb.pop(0)
        else:
            print("B")
            exit()
    else:
        if len(sc) != 0:
            turn = sc.pop(0)
        else:
            print("C")
            exit()
Buggy code:
s = {}
l = ["A","B","C"]
p = "A"
for x in l:
  s[x] = list(input().upper())
while True:
  if s[p] == []:
    print(p)
    break
  else:
    p, s[p] = s[p][0], s[p][1:]

Fixed code:
s = {}
l = ["A","B","C"]
p = "A"
for x in l:
  s[x] = list(input().upper())
while True:
  if s[p] == []:
    print(p)
    break
  else:
    q = s[p][0]
    s[p] = s[p][1:]
    p = q
Buggy code:

Sa = input()
Sb = input()
Sc = input()
flg=True
nxt = "a"
while flg:
    if nxt=="a":
        nxt = Sa[0]
        Sa=Sa[1:]
        if len(Sa)==0:
            flg=False
            winner = "A"
    elif nxt=="b":
        nxt = Sb[0]
        Sb=Sb[1:]
        if len(Sb)==0:
            flg=False
            winner = "B"
    elif nxt=="c":
        nxt = Sc[0]
        Sc=Sc[1:]
        if len(Sc)==0:
            flg=False
            winner = "C"

print(winner)

Fixed code:


Sa = input()
Sb = input()
Sc = input()
flg=True
nxt = "a"
while flg:
    if nxt=="a":
        if len(Sa)==0:
            winner = "A"
            break
        nxt = Sa[0]
        Sa=Sa[1:]
    elif nxt=="b":
        if len(Sb)==0:
            winner = "B"
            break
        nxt = Sb[0]
        Sb=Sb[1:]
    elif nxt=="c":
        if len(Sc)==0:
            winner = "C"
            break
        nxt = Sc[0]
        Sc=Sc[1:]

print(winner)