qyliang/CodeNanoFix huggingface dataset:
Buggy code:
a=input()
b=input()
c=input()
from collections import deque
da=deque(list(a))
db=deque(list(b))
dc=deque(list(c))
now=da.popleft()
while (1):
  if now=="a":
    if da:
      now=da.popleft()
    else:
      break
  elif now=="b":
    if db:
      now=db.popleft()
    else:
      break
  elif now=="c":
    if dc:
      now=dc.popleft()
    else:
      break
print(now)

Fixed code:
a=input()
b=input()
c=input()
from collections import deque
da=deque(list(a))
db=deque(list(b))
dc=deque(list(c))
now=da.popleft()
while (1):
  if now=="a":
    if da:
      now=da.popleft()
    else:
      break
  elif now=="b":
    if db:
      now=db.popleft()
    else:
      break
  elif now=="c":
    if dc:
      now=dc.popleft()
    else:
      break
print(now.upper())
Buggy code:
from collections import deque

if __name__ == "__main__":
    stacks = []
    for i in range(3):
        stacks.append(deque([x for x in input()]))
    winner = False
    turn = 0
    while not winner:
        turn = ord(stacks[turn].popleft()) - ord('a')
        for i in range(3):
            if len(stacks[i]) == 0:
                print(i)
                winner = chr(97 + i)
                break
    print(winner)


Fixed code:
from collections import deque

if __name__ == "__main__":
    stacks = []
    for i in range(3):
        stacks.append(deque([x for x in input()]))
    winner = False
    turn = 0
    while not winner:
        turn = ord(stacks[turn].popleft()) - ord('a')
        if len(stacks[turn]) == 0:
            winner = chr(65 + turn)
    print(winner)
Buggy code:
S = {c:input() 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"}
#print(S)
s = "a"
while S[s]:
  s = S[s].pop(0)
print(s.upper())
Buggy code:
s = {}
s['a'] = list(input())
s['b'] = list(input())
s['c'] = list(input())

print(s)
now = 'a'
while s[now]:
    now = s[now].pop(0)
    print(now)
    print(s['a'])
    print(s['b'])
    print(s['c'])
print(now.upper())


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

now = 'a'
while s[now]:
    now = s[now].pop(0)
print(now.upper())
Buggy code:
S = {x: list(input()) for x in 'abc'}
s = 'a'
while S[s]:
  s = S[s].pop(0)
print(upper(s))


Fixed code:
S = {x: list(input()) for x in 'abc'}
s = 'a'
while S[s]:
  s = S[s].pop(0)
print(s.upper())
Buggy code:
Alice = 'A'
Bob = 'B'
Charlie = 'C'

def answer(Sa, Sb, Sc):
    currentUser = Alice
    ai, bi, ci = (0, 0, 0)
    while(True):
        if currentUser == Alice:
            if ai == len(Sa):
                return Alice
            if Sa[ai] == 'b':
                currentUser = Bob
            if Sa[ai] == 'c':
                currentUser = Charlie
            ai += 1
            continue
        if currentUser == Bob:
            if bi == len(Sb):
                return Bob
            if Sa[bi] == 'a':
                currentUser = Alice
            if Sa[bi] == 'c':
                currentUser = Charlie
            bi += 1
            continue
        if currentUser == Charlie:
            if ci == len(Sc):
                return Charlie
            if Sa[ci] == 'a':
                currentUser = Alice
            if Sa[ci] == 'b':
                currentUser = Bob
            ci += 1
            continue
            
Sa = input()
Sb = input()
Sc = input()
print(answer(Sa, Sb, Sc))

Fixed code:
Alice = 'A'
Bob = 'B'
Charlie = 'C'

def answer(Sa, Sb, Sc):
    currentUser = Alice
    ai, bi, ci = (0, 0, 0)
    while(True):
        if currentUser == Alice:
            if ai == len(Sa):
                return Alice
            if Sa[ai] == 'b':
                currentUser = Bob
            if Sa[ai] == 'c':
                currentUser = Charlie
            ai += 1
            continue
        if currentUser == Bob:
            if bi == len(Sb):
                return Bob
            if Sb[bi] == 'a':
                currentUser = Alice
            if Sb[bi] == 'c':
                currentUser = Charlie
            bi += 1
            continue
        if currentUser == Charlie:
            if ci == len(Sc):
                return Charlie
            if Sc[ci] == 'a':
                currentUser = Alice
            if Sc[ci] == 'b':
                currentUser = Bob
            ci += 1
            continue
            
Sa = input()
Sb = input()
Sc = input()
print(answer(Sa, Sb, Sc))
Buggy code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

SA = list(input())
SB = list(input())
SC = list(input())
S = {"a":SA, "b":SB, "c":SC}
turn = "a"
while 1:
	print(turn, S[turn])
	if len(S[turn]) == 0:
		break
	turn = S[turn].pop(0)
print(turn.upper())


Fixed code:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

SA = list(input())
SB = list(input())
SC = list(input())
S = {"a":SA, "b":SB, "c":SC}
turn = "a"
while 1:
	if len(S[turn]) == 0:
		break
	turn = S[turn].pop(0)
print(turn.upper())
Buggy code:
A=input()
B=input()
C=input()
p="a"

while True:
  #print(A,B,C)
  
  if p=="a":
    if len(A)>=1:
      p=A[0]
      A=A[1:]
    else:
      break
  elif p=="b":
    if len(B)>=1:
      p=B[0]
      B=B[1:]
    else:
      break
  else:
    if len(C)>=1:
      p=C[0]
      C=C[1:]
    else:
      break
if len(A)==0:
  print("A")
elif len(B)==0:
  print("B")
else:
  print("C")

Fixed code:
A=input()
B=input()
C=input()
p="a"

while True:
  if p=="a":
    if len(A)>=1:
      p=A[0]
      A=A[1:]
    else:
      print("A")
      break
  elif p=="b":
    if len(B)>=1:
      p=B[0]
      B=B[1:]
    else:
      print("B")
      break
  else:
    if len(C)>=1:
      p=C[0]
      C=C[1:]
    else:
      print("C")
      break
Buggy code:
d = {'a':input(), 'b':input(), 'c':input()}

def func(s):
    if len(d[s]) == 0:
        return s.upper()
    next = d[s][0]
    d[s] = d[s][1:]
    func(next)

print(func('a'))

Fixed code:
d = {'a':input(), 'b':input(), 'c':input()}

def func(s):
    if len(d[s]) == 0:
        return s.upper()
    next = d[s][0]
    d[s] = d[s][1:]
    return func(next)

print(func('a'))
Buggy code:
#!/usr/bin/env python3
s={c:list(input()) for c in "abc"}
s="a"

while s[s]:s=s[s].pop(0)
print(s.upper())

Fixed code:
#!/usr/bin/env python3
S={c:list(input()) for c in "abc"}
s="a"
while S[s]:s=S[s].pop(0)
print(s.upper())
Buggy code:
import queue

a_cards = input()
b_cards = input()
c_cards = input()

a_c = list(a_cards)
b_c = list(b_cards)
c_c = list(c_cards)

a_que = queue.Queue()
b_que = queue.Queue()
c_que = queue.Queue()

for num in range(len(a_c)):
    a_que.put(a_c[num])

for num in range(len(b_c)):
    b_que.put(b_c[num])

for num in range(len(c_c)):
    c_que.put(c_c[num])




x = a_que.get()

while True:
    if x == 'a':
        if a_que.empty():
            answer = 'a'
            break
        x = a_que.get()
    elif x == 'b':
        if b_que.empty():
            answer = 'b'
            break
        x = b_que.get()
    else:
        if c_que.empty():
            answer = 'c'
            break
        x = c_que.get()

print(answer)
 

Fixed code:
import queue

a_cards = input()
b_cards = input()
c_cards = input()

a_c = list(a_cards)
b_c = list(b_cards)
c_c = list(c_cards)

a_que = queue.Queue()
b_que = queue.Queue()
c_que = queue.Queue()

for num in range(len(a_c)):
    a_que.put(a_c[num])

for num in range(len(b_c)):
    b_que.put(b_c[num])

for num in range(len(c_c)):
    c_que.put(c_c[num])




x = a_que.get()

while True:
    if x == 'a':
        if a_que.empty():
            answer = 'A'
            break
        x = a_que.get()
    elif x == 'b':
        if b_que.empty():
            answer = 'B'
            break
        x = b_que.get()
    else:
        if c_que.empty():
            answer = 'C'
            break
        x = c_que.get()

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

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:
d = {"a": input(), "b": input(), "c": input()}

def f(player):
    if len(d[player]) == 0:
        print(player)
        exit()

    next_player = d[player][0]
    d[player] = d[player][1:]
    f(next_player)

f("a")


Fixed code:
d = {"a": input(), "b": input(), "c": input()}

def f(player):
    if len(d[player]) == 0:
        print(player.upper())
        exit()

    next_player = d[player][0]
    d[player] = d[player][1:]
    f(next_player)

f("a")
Buggy code:
def str2turn(c: str) -> int:
    if c.lower() == 'a':
        return 0
    elif c.lower() == 'b':
        return 1
    return 2


def turn2str(t: int) -> str:
    if t == 0:
        return 'a'
    elif t == 1:
        return 'b'
    return 'c'


def card_game_for_three(Sa: str, Sb: str, Sc: str) -> str:
    indexes = [0, 0, 0]
    limits = [len(Sa), len(Sb), len(Sc)]
    cards = [Sa, Sb, Sc]

    turn = 0
    while indexes[turn] < limits[turn]:
        next_turn = cards[turn][indexes[turn]]
        indexes[turn] += 1
        turn = next_turn

    return turn2str(turn).upper()


if __name__ == "__main__":
    Sa = input()
    Sb = input()
    Sc = input()
    ans = card_game_for_three(Sa, Sb, Sc)
    print(ans)


Fixed code:
def str2turn(c: str) -> int:
    if c.lower() == 'a':
        return 0
    elif c.lower() == 'b':
        return 1
    return 2


def turn2str(t: int) -> str:
    if t == 0:
        return 'a'
    elif t == 1:
        return 'b'
    return 'c'


def card_game_for_three(Sa: str, Sb: str, Sc: str) -> str:
    indexes = [0, 0, 0]
    limits = [len(Sa), len(Sb), len(Sc)]
    cards = [Sa, Sb, Sc]

    turn = 0
    while indexes[turn] < limits[turn]:
        next_turn = str2turn(cards[turn][indexes[turn]])
        indexes[turn] += 1
        turn = next_turn

    return turn2str(turn).upper()


if __name__ == "__main__":
    Sa = input()
    Sb = input()
    Sc = input()
    ans = card_game_for_three(Sa, Sb, Sc)
    print(ans)
Buggy code:
import sys
a=input()
b=input()
c=input()
turn=0
ap=0
bp=0
cp=0
while True:
    if turn==0:
        ap+=1
        if ap==len(a)+1:
            print("a")
            sys.exit()
        if a[ap-1]=="a":
            turn=0
        elif a[ap-1]=="b":
            turn=1
        else:
            turn=2
    if turn==1:
        bp+=1
        if bp==len(b)+1:
            print("b")
            sys.exit()
        if b[bp-1]=="a":
            turn=0
        elif b[bp-1]=="b":
            turn=1
        else:
            turn=2
    if turn==2:
        cp+=1
        if cp==len(c)+1:
            print("c")
            sys.exit()
        if c[cp-1]=="a":
            turn=0
        elif c[cp-1]=="b":
            turn=1
        else:
            turn=2

Fixed code:
import sys
a=input()
b=input()
c=input()
turn=0
ap=0
bp=0
cp=0
while True:
    if turn==0:
        ap+=1
        if ap==len(a)+1:
            print("A")
            sys.exit()
        if a[ap-1]=="a":
            turn=0
        elif a[ap-1]=="b":
            turn=1
        else:
            turn=2
    if turn==1:
        bp+=1
        if bp==len(b)+1:
            print("B")
            sys.exit()
        if b[bp-1]=="a":
            turn=0
        elif b[bp-1]=="b":
            turn=1
        else:
            turn=2
    if turn==2:
        cp+=1
        if cp==len(c)+1:
            print("C")
            sys.exit()
        if c[cp-1]=="a":
            turn=0
        elif c[cp-1]=="b":
            turn=1
        else:
            turn=2
Buggy code:
dic={"a":input(),"b":input(),"c":input()}

print(dic)
temp="a"

while 1:
  temp2=dic[temp][:1]
  #print(temp)
  dic[temp]=dic[temp][1:]
  temp=temp2
  #print(dic)
  
  if dic[temp]=="":
    if temp=="a":
      print("A")
    elif temp=="b":
      print("B")
    elif temp=="c":
      print("C")
    break

Fixed code:
dic={"a":input(),"b":input(),"c":input()}

#print(dic)
temp="a"

while 1:
  temp2=dic[temp][:1]
  #print(temp)
  dic[temp]=dic[temp][1:]
  temp=temp2
  #print(dic)
  
  if dic[temp]=="":
    if temp=="a":
      print("A")
    elif temp=="b":
      print("B")
    elif temp=="c":
      print("C")
    break
Buggy code:
a=input()
b=input()
c=input()
dic={'a':[_ for _ in a],'b':[_ for _ in b],'c':[_ for _ in c]}
char='a'
print(dic)
for i in range(len(a)+len(b)+len(c)):
    if len(dic[char]) == 0:
        break
    char = dic[char].pop(0)
print(char)

Fixed code:
a=input()
b=input()
c=input()
dic={'a':[_ for _ in a],'b':[_ for _ in b],'c':[_ for _ in c]}
char='a'
for i in range(len(a)+len(b)+len(c)):
    if len(dic[char]) == 0:
        break
    char = dic[char].pop(0)
print(char.upper())
Buggy code:
mem = []
for i in range(3):
    mem.append(list(input()))

mem = [[ord(y)-97 for y in x] for x in mem]
print(mem)

idx = 0
while 1:
    if len(mem[idx]) >= 1:
        idx = mem[idx].pop(0)
    else:
        break

print(chr(idx+97).upper())

Fixed code:
mem = []
for i in range(3):
    mem.append(list(input()))

mem = [[ord(y)-97 for y in x] for x in mem]

idx = 0
while 1:
    if len(mem[idx]) >= 1:
        idx = mem[idx].pop(0)
    else:
        break

print(chr(idx+97).upper())
Buggy code:
s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[0])==0:
        print('A')
        break
    elif len(s[1])==0:
        print('B')
        break
    elif len(s[1])==0:
        print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after
    

Fixed code:
s = []
for _ in range(3):
    x = input().replace('a', '0').replace('b', '1').replace('c', '2')
    s.append(str(x))
    
now = 0
while True:
    if len(s[now]) == 0:
        if now == 0:
            print('A')
        if now == 1:
            print('B')   
        if now == 2:
            print('C')
        break
        
    after = int(s[now][0])
    s[now] =  s[now][1:]
    now = after
Buggy code:
sa = list(input())
sb = list(input())
sc = list(input())

turn = "a"
while True:
  if turn == "a":
    turn = sa[0]
    sa = sa[1:]
    if len(sa) == 0:
      print("A")
      break
  if turn == "b":
    turn = sb[0]
    sb = sb[1:]
    if len(sb) == 0:
      print("B")
      break
  if turn == "c":
    turn = sc[0]
    sc = sc[1:]
    if len(sc) == 0:
      print("C")
      break

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

turn = "a"
while True:
  if turn == "a":
    if len(sa) == 0:
      print("A")
      break
    turn = sa[0]
    sa = sa[1:]
  if turn == "b":
    if len(sb) == 0:
      print("B")
      break
    turn = sb[0]
    sb = sb[1:]
  if turn == "c":
    if len(sc) == 0:
      print("C")
      break
    turn = sc[0]
    sc = sc[1:]
Buggy code:
SA=input()
SB=input()
SC=input()

A_rest=len(SA)
B_rest=len(SA)
C_rest=len(SA)
next='a'

while(1):
    if next=='a':
        A_rest-=1
       	if A_rest<0:
           	break
        next=SA[len(SA)-A_rest]
    elif next=='b':
        B_rest-=1
       	if B_rest<0:
           	break
        next=SB[len(SB)-B_rest]
    else:
        C_rest-=1
       	if C_rest<0:
           	break
        next=SC[len(SC)-C_rest]

if A_rest<0:
    print('A')
elif B_rest<0:
    print('B')
else:
    print('C')

Fixed code:
SA=input()
SB=input()
SC=input()

A_rest=len(SA)
B_rest=len(SB)
C_rest=len(SC)
next='a'

while(1):
    if next=='a':
       	if A_rest==0:
            print('A')
            exit()
        next=SA[len(SA)-A_rest]
        A_rest-=1
    elif next=='b':
       	if B_rest==0:
            print('B')
            exit()
        next=SB[len(SB)-B_rest]
        B_rest-=1
    else:
       	if C_rest==0:
            print('C')
            exit()
        next=SC[len(SC)-C_rest]
        C_rest-=1
Buggy code:
sa = input()
sb = input()
sc = input()
lena = len(sa)
lenb = len(sb)
lenc = len(sc)
ans = 0
tmp = 'a'
while (lena != 0) and (lenb != 0) and (lenc != 0):
    if tmp == 'a':
        tmp = sa[len(sa)-lena]
        lena -= 1
        ans = 'A'
        
    elif tmp == 'b':
        tmp = sb[len(sb)-lenb]
        lenb -= 1
        ans = 'B'
        
    elif tmp == 'c':
        tmp = sc[len(sc)-lenc]
        lenc -= 1
        ans = 'C'
        
print(ans)

Fixed code:
sa = input()
sb = input()
sc = input()
lena = len(sa)
lenb = len(sb)
lenc = len(sc)
ans = 0
tmp = 'a'
while (lena != -1) and (lenb != -1) and (lenc != -1):
    if tmp == 'a':
        if lena == 0:
            ans = 'A'
            break
        tmp = sa[len(sa)-lena]
        lena -= 1

    elif tmp == 'b':
        if lenb == 0:
            ans = 'B'
            break
        tmp = sb[len(sb)-lenb]
        lenb -= 1
        
    elif tmp == 'c':
        if lenc == 0:
            ans = 'C'
            break
        tmp = sc[len(sc)-lenc]
        lenc -= 1
        
print(ans)
Buggy code:
a = list(input())
a.sort()
b = list(input())
b.sort()
c = list(input())
c.sort()

def solve(a,b,c,value):
    if len(a)==0:
        return print("A")
    elif len(b)==0:
        return print("B")
    elif len(c)==0:
        return print("C")
    else:
        if value == "a":
            return solve(a,b,c,a.pop(0))
        if value == "b":
            return solve(a,b,c,b.pop(0))
        if value == "c":
            return solve(a,b,c,c.pop(0))

solve(a,b,c,a.pop(0))

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


def solve(a,b,c,value):
    if len(a)==0 and value == "a":
        return print("A")
    elif len(b)==0 and value == "b":
        return print("B")
    elif len(c)==0 and value == "c":
        return print("C")
    else:
        if value == "a":
            return solve(a,b,c,a.pop(0))
        if value == "b":
            return solve(a,b,c,b.pop(0))
        if value == "c":
            return solve(a,b,c,c.pop(0))

solve(a,b,c,a.pop(0))
Buggy code:
d = {"a": input(), "b": input(), "c": input()}

def func(s):
    if len(d[s]) == 0:
        return upper()
    next = d[s][0]
    d[s] = d[s][1:]
    return func(next)

print(func(a))

Fixed code:
d = {"a": input(), "b": input(), "c": input()}

def func(s):
    if len(d[s]) == 0:
        return s.upper()
    next = d[s][0]
    d[s] = d[s][1:]
    return func(next)

print(func("a"))
Buggy code:
A=input()
B=input()
C=input()

l='a'

for i in range(300):
  if l=='a':
    
    if len(A)==0:
      print('A')
      exit()
    elif len(A)==1:
      l=A[0]
      A=''
    else:
      l=A[0]
      A=A[1:]
  elif l=='b':
    l=B[0]
    if len(B)==0:
      print('B')
      exit()
    elif len(B)==1:
      l=B[0]
      B=''
    else:
      l=B[0]
      B=B[1:]
  else:
    l=C[0]
    if len(C)==0:
      print('C')
      exit()
    elif len(C)==1:
      l=C[0]
      C=''
    else:
      l=C[0]
      C=C[1:]    

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

l='a'

for i in range(300):
  if l=='a':
    if len(A)==0:
      print('A')
      exit()
    elif len(A)==1:
      l=A[0]
      A=''
    else:
      l=A[0]
      A=A[1:]
  elif l=='b':
    if len(B)==0:
      print('B')
      exit()
    elif len(B)==1:
      l=B[0]
      B=''
    else:
      l=B[0]
      B=B[1:]
  else:
    if len(C)==0:
      print('C')
      exit()
    elif len(C)==1:
      l=C[0]
      C=''
    else:
      l=C[0]
      C=C[1:]
Buggy code:
A = input()
B = input()
C = input()

next_turn = A[0]
Acnt = 0
Bcnt = 0
Ccnt = 0
while True:
    if next_turn == 'a':
        next_turn = A[Acnt]
        Acnt += 1
        if Acnt == len(A)-1:
            print('A')
            break
    elif next_turn == 'b':
        next_turn = B[Bcnt]
        Bcnt += 1
        if Bcnt == len(B)-1:
            print('B')
            break
    elif next_turn == 'c':
        next_turn = C[Ccnt]
        Ccnt += 1
        if Ccnt == len(C)-1:
            print('C')
            break

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

next_turn = A[0]
Acnt = 1
Bcnt = 0
Ccnt = 0
while True:
    if next_turn == 'a':
        if Acnt == len(A):
            print('A')
            break
        next_turn = A[Acnt]
        Acnt += 1

    elif next_turn == 'b':
        if Bcnt == len(B):
            print('B')
            break
        next_turn = B[Bcnt]
        Bcnt += 1

    elif next_turn == 'c':
        if Ccnt == len(C):
            print('C')
            break
        next_turn = C[Ccnt]
        Ccnt += 1
Buggy code:
a = input()
b = input()
c = input()
a_pos = 0
b_pos = 0
c_pos = 0
now = 'a'

while True:
    print(a_pos, b_pos, c_pos, now)
    if now == 'a':
        if len(a) < a_pos + 1:
            print('A')
            break
        now = a[a_pos]
        a_pos += 1
    elif now == 'b':
        if len(b) < b_pos + 1:
            print('B')
            break
        now = b[b_pos]
        b_pos += 1
    elif now == 'c':
        if len(c) < c_pos + 1:
            print('C')
            break
        now = c[c_pos]
        c_pos += 1

Fixed code:
a = input()
b = input()
c = input()
a_pos = 0
b_pos = 0
c_pos = 0
now = 'a'

while True:
    if now == 'a':
        if len(a) < a_pos + 1:
            print('A')
            break
        now = a[a_pos]
        a_pos += 1
    elif now == 'b':
        if len(b) < b_pos + 1:
            print('B')
            break
        now = b[b_pos]
        b_pos += 1
    elif now == 'c':
        if len(c) < c_pos + 1:
            print('C')
            break
        now = c[c_pos]
        c_pos += 1
Buggy code:
S = [n: list(input()) for n in "abc"]
i = "a"
while S[i]:
  i = S[i].pop(0)
  
print(i.upper())
     

Fixed code:
S = {i: list(input()) for i in "abc"}
n = "a"
while S[n]:
  n = S[n].pop(0)
  
print(n.upper())
Buggy code:
s_a=list(input())
s_b=list(input())
s_c=list(input())

temp =''
temp=s_a.pop(0)
while 1:
    if temp=='a':
        if s_a:
            temp=s_a.pop(0)
        else:
            print('A')
            break
    elif temp=='b':
        if s_b:
            temp=s_b.pop(0)
        else:
            print('B')
            break
    elif temp=='c':
        if s_b:
            temp=s_c.pop(0)
        else:
            print('C')
            break


Fixed code:
s_a=list(input())
s_b=list(input())
s_c=list(input())

tmp =''
tmp=s_a.pop(0)
while 1:
    if tmp=='a':
        if s_a:
            tmp=s_a.pop(0)
        else:
            print('A')
            break
    elif tmp=='b':
        if s_b:
            tmp=s_b.pop(0)
        else:
            print('B')
            break
    elif tmp=='c':
        if s_c:
            tmp=s_c.pop(0)
        else:
            print('C')
            break
Buggy code:
S = dict()
S['a'] = list(input())[::-1]
S['b'] = list(input())[::-1]
S['c'] = list(input())[::-1]

print(S)
player = 'a'

while S[player]:
    player = S[player].pop() 

ans = player.upper()
print(ans)

Fixed code:
S = dict()
S['a'] = list(input())[::-1]
S['b'] = list(input())[::-1]
S['c'] = list(input())[::-1]

player = 'a'

while S[player]:
    player = S[player].pop() 

ans = player.upper()
print(ans)
Buggy code:
def abc():
    players = dict()
    players['a'] = list(input().rstrip())
    players['b'] = list(input().rstrip())
    players['c'] = list(input().rstrip())

    p = 'a'
    while True:
        if len(players[p]) == 0:
            print(p)
            return
        p = players[p].pop()


abc()


Fixed code:
def abc():
    players = dict()
    players['a'] = list(input().rstrip())
    players['b'] = list(input().rstrip())
    players['c'] = list(input().rstrip())

    p = 'a'
    while True:
        if len(players[p]) == 0:
            print(p.upper())
            return
        p = players[p].pop(0)


abc()