Harryxun/GPT-100-sft-dataset huggingface dataset:
Problem p03476 (python)

Fixed submission:
def primes(n):
    primes = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            primes.append(i)
    return is_prime


Q = int(input())

ps = primes(100000)
like_numbers = [False] * 100001
for i in range(3, 100001, 2):
    if ps[i] and ps[(i + 1) // 2]:
        like_numbers[i] = True

like_numbers_cnt = [0] * 100001

for i in range(1, 100001):
    if like_numbers[i]:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1] + 1
    else:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(like_numbers_cnt[r] - like_numbers_cnt[l - 1])

Buggy submission (verdict: Runtime Error):
def primes(n):
    primes = []
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    for i in range(len(is_prime)):
        if is_prime[i]:
            primes.append(i)
    return is_prime


Q = int(input())

ps = primes(10000)
like_numbers = [False] * 10001
for i in range(3, 10001, 2):
    if ps[i] and ps[(i + 1) // 2]:
        like_numbers[i] = True

like_numbers_cnt = [0] * 10001

for i in range(1, 10001):
    if like_numbers[i]:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1] + 1
    else:
        like_numbers_cnt[i] = like_numbers_cnt[i - 1]

for _ in range(Q):
    l, r = map(int, input().split())
    print(like_numbers_cnt[r] - like_numbers_cnt[l - 1])
Problem p02639 (python)

Fixed submission:
# coding: utf-8
# Your code here!
x=input().split()



if(x[0]=="0"):
    print(1)
elif(x[1]=="0"):
    print(2)
elif(x[2]=="0"):
    print(3)
elif(x[3]=="0"):
    print(4)
elif(x[4]=="0"):
    print(5)

Buggy submission (verdict: Runtime Error):
nums = input().split()

if nums[0] == "0":
print(1)

elif nums[1] == "0":
print(2)

elif nums[2] == "0":
print(3)

elif nums[3] == "0":
print(4)

elif nums[4] == "0":
print(5)

Buggy submission (verdict: Runtime Error):
nums = input().split()

if nums[0] = "0"
print(1)

elif nums[1] = "0"
print(2)

elif nums[2] = "0"
print(3)

elif nums[3] = "0"
print(4)

elif nums[4] = "0"
print(5)

Buggy submission (verdict: Runtime Error):
nums = input().split()

if numlist[0] = "0"
print(1)

elif numlist[1] = "0"
print(2)

elif numlist[2] = "0"
print(3)

elif numlist[3] = "0"
print(4)

elif numlist[4] = "0"
print(5)

Buggy submission (verdict: Runtime Error):
nums = input()
numlist = list(nums.split(' '))

if numlist[0] = "0"
print(1)

elif numlist[1] = "0"
print(2)

elif numlist[2] = "0"
print(3)

elif numlist[3] = "0"
print(4)

elif numlist[4] = "0"
print(5)

Buggy submission (verdict: Runtime Error):
nums = input()
numlist = list(nums.split(' '))

if numlist[0] = "0"
print(0)

elif numlist[1] = "0"
print(1)

elif numlist[2] = "0"
print(2)

elif numlist[3] = "0"
print(3)

elif numlist[4] = "0"
print(4)

Buggy submission (verdict: Runtime Error):
nums = input()
numlist = list(nums.split(' '))

if numlist[0] = "0"
print(0)

if numlist[1] = "0"
print(1)

if numlist[2] = "0"
print(2)

if numlist[3] = "0"
print(3)

if numlist[4] = "0"
print(4)

Buggy submission (verdict: Runtime Error):
nums = input()
numlist = list(nums.split(' '))
for i in numlist:
  if i == '0':
    print i
Problem p02641 (python)

Fixed submission:
import operator

X, N = map(int, input().split())

p = list(map(int, input().split()))

abs_val_dict = {}

if N == 0:
    print (X)

for i in range (X-N, X+N):
    if i not in p:
        abs_val_dict[i] = abs(i-X)

if abs_val_dict != {}:
    print(min(abs_val_dict.items(), key=operator.itemgetter(1))[0])

Buggy submission (verdict: Runtime Error):
import operator

X, N = map(int, input().split())

p = list(map(int, input().split()))

abs_val_dict = {}

if N == 0:
    print (X)

for i in range (X-N, X+N):
    if i not in p:
        abs_val_dict[i] = abs(i-X)
    
print(min(abs_val_dict.items(), key=operator.itemgetter(1))[0])

Buggy submission (verdict: Runtime Error):
X, N = map(int, input().split())

p = list(map(int, input().split))

abs_val_dict = {}

if N == 0:
    print (X)

for i in range (X-N, X+N):
    if i not in p:
        abs_val_dict[i] = abs(i-X)
    
print(max(abs_val_dict, key = abs_val_dict.get()))
Problem p02642 (python)

Fixed submission:
N = int(input())
A = list(map(int, input().split()))


mx = max(A)
x = [0] * (mx + 1) # len(x)
for i in A:
    x[i] += 1
for i in range(1, mx + 1):
    if x[i] != 0:
        for j in range(2 * i, mx + 1, i):
            x[j] = 0
    if x[i] > 1:
        x[i] = 0
print(sum(x))

Buggy submission (verdict: Runtime Error):
N = int(input())
A = list(map(int, input.split()))

O = A.copy()

for i in A:
    for j in A:
        if i != j:
            if (i%j == 0):
                if i in O:
                    O.remove(i)

ans = len(O)

print(ans)
Problem p02658 (python)

Fixed submission:
import sys

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))

if 0 in list_input:
    print(0)
    exit()

a = 1
for i in list_input:
    a *= i
    if a > pow(10, 18):
        break


if a > pow(10, 18):
    print(-1)
else:
    print(a)

Buggy submission (verdict: Runtime Error):
import sys
import numpy as np

n = int(input())
list_input = list(map(int, sys.stdin.readline().strip().split()))
array = np.array(list_input)

a = array.prod()

if a > pow(10, 18):
    print(-1)
else:
    print(a)
Problem p02645 (python)

Fixed submission:
S = str(input())
nickname = S[0:3]
print(nickname)

Buggy submission (verdict: Runtime Error):
A, V = map(int, input().split())
B, W = map(int, input().split())
T = int(input())

t = 0
while A != B and t < T:
    if A < B:
        A += V
        B += W
    if A > B:
        A -= V
        B -= W
    t += 1

if A == B:
    print('YES')
else:
    print('NO')
Problem p02909 (python)

Fixed submission:
S = input()

if S == 'Sunny':
    S_tomorrow = 'Cloudy'
elif S == 'Cloudy':
    S_tomorrow = 'Rainy'
else:
    S_tomorrow = 'Sunny'

print(S_tomorrow)

Buggy submission (verdict: Runtime Error):
n , k , q = map(int, input().split())
points = [k - q] * n
for i in range(q):
    c = int(input())
    points[c-1] += 1
for i in range(n):
    if points[i] >= 1:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n , k , q = map(int, input().split())
a = [int(input()) for i in range(q)]
points = [k - q for i in range(n)]
for i in range(n):
    points[i-1] += a.count(i+1)
    if points[i] >= 1:
        print('Yes')
    else:
        print('No')

Buggy submission (verdict: Runtime Error):
n , k , q = map(int, input().split())
a = [int(input()) for i in range(q)]
points = [k - q for i in range(n)]
for i in range(n):
    points[i] += a.count(i)
    if points[i] >= 1:
        print('Yes')
    else:
        print('No')
Problem p02630 (python)

Fixed submission:
from collections import Counter

def update(dic, b, c):
    n = dic.pop(b)
    dic[c] = n + dic.get(c, 0)
    
def calc_diff(dic, b, c):
    if dic.get(b):
        return c * dic[b] - b * dic[b]
    return 0

def calc_total(dic):
    return sum(k * v for k, v in dic.items())

N = int(input())
lis = list(map(int, input().split()))
dic = dict(Counter(lis))
Q = int(input())
total = calc_total(dic)
for _ in range(Q):
    B, C = map(int, input().split())
    diff = calc_diff(dic, B, C)
    total += diff
    print(total)
    if diff:
        update(dic, B, C)

Buggy submission (verdict: Runtime Error):
from collections import Counter

def update(dic, b, c):
    n = dic.pop(b)
    dic[c] = n + dic.get(c, 0)
    
def calc_diff(dic, b, c):
    return c * dic[b] - b * dic[b]

def calc_total(dic):
    return sum(k * v for k, v in dic.items())

N = int(input())
lis = list(map(int, input().split()))
dic = dict(Counter(lis))
Q = int(input())
total = calc_total(dic)
for _ in range(Q):
    B, C = map(int, input().split())
    total += calc_diff(dic, B, C)
    print(total)
    update(dic, B, C)
Problem p03031 (python)

Fixed submission:
N, M = map(int, input().split())
lists = []
for _ in range(M):
    lists.append(list(map(int, input().split()))[1:])
p_list = list(map(int, input().split()))
num = 0
len_m = N
for n in range(2 ** N):
    flag = True
    for p, lis in zip(p_list, lists):
        flag = int(flag) * int((sum([str(bin(n)[2:]).zfill(len_m)[l - 1] == '1' for l in lis]) % 2) == p)
    num += flag
print(num)

Buggy submission (verdict: Runtime Error):
import numpy as np
N, M = map(int, input().split())
lists = []
for _ in range(M):
    lists.append(list(map(int, input().split()))[1:])
p_list = list(map(int, input().split()))
num = 0
len_m = N
for n in range(2 ** N):
    flag = True
    for p, lis in zip(p_list, lists):
        flag = flag & ((sum([f'{n:0{len_m}b}'[l - 1] == '1' for l in lis]) % 2) == p)
    num += flag
print(num)
Problem p03044 (python)

Fixed submission:
N = int(input())
lis = [[] for _ in range(N + 1)]
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    lis[u] += [v * [-1, 1][w % 2]]
    lis[v] += [u * [-1, 1][w % 2]]
colors = [-1 for _ in range(N + 1)]

q = [1]
colors[1] = 0
while q:
    start = abs(q.pop(0))
    nodes = lis[start]
    for node in nodes:
        if colors[abs(node)] < 0:
            if node < 0:
                colors[abs(node)] = colors[start]
            else:
                colors[abs(node)] = int(colors[start] == 0)
            q.append(abs(node))

for c in colors[1:]:
    print(c)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
N =int( input())
col_nodes = defaultdict(set)
node_col = {}
col = 1
for _ in range(N - 1):
    u, v, w = map(int, input().split())
    u_col, v_col = node_col.get(u, 0), node_col.get(v, 0)
    if (0 in [u_col, v_col]) and (u_col or v_col):
        if u_col == 0:
            node_col[u] = v_col * [1, -1][w % 2]
            col_nodes[v_col] = col_nodes[v_col] | {u}
        else:
            node_col[v] = u_col * [1, -1][w % 2]
            col_nodes[u_col] = col_nodes[u_col] | {v}
        continue
    col_ = col * [1, -1][w % 2]
    node_col[u] = col
    node_col[v] = col_
    if u_col and v_col:
        col_nodes[col] = col_nodes[col] | col_nodes.pop(u_col)
        col_nodes[col_] = col_nodes[col_] | col_nodes.pop(v_col)
        continue
    col_nodes[col] =  col_nodes[col] | {u}
    col_nodes[col_] = col_nodes[col_] | {v}
    col += 1
        
for n in range(1, N + 1):
    print([0, 1][node_col[n] > 0])
Problem p03088 (python)

Fixed submission:
from collections import defaultdict
import re
from itertools import product

atcg = ['A', 'T', 'C', 'G']
num = int(input())

def validate(tpl):
    string = tpl[0] + tpl[1] + tpl[2] + tpl[3]
    for pat in [r'A.GC', r'AG.C', 'ACG', 'AGC', 'GAC']:
         if re.search(pat, string):
                return False
    return True

def transition(dic):
    new_dic = defaultdict(int)
    for k, v in dic.items():
        for c in atcg:
            tpl = k[1], k[2], k[3], c
            if validate(tpl):
                new_dic[tpl] += v
    return new_dic

it = product(atcg, atcg, atcg, atcg)
dic = {}
for s in it:
    if validate(s):
        dic[s] = 1

if num == 3:
    print(61)
elif num == 4:
    print(230)
else:
    for n in range(num - 4):
        dic = transition(dic)
    print(sum(dic.values()) % 1000000007)

Buggy submission (verdict: Runtime Error):
from collections import defaultdict
import re
from itertools import product

atcg = ['A', 'T', 'C', 'G']
num = int(input())

def validate(tpl):
    string = tpl[0] + tpl[1] + tpl[2] + tpl[3]
    for pat in [r'A.GC', r'AG.C', 'ACG', 'AGC', 'GAC']:
         if re.search(pat, string):
                return False
    return True

def transition(dic):
    new_dic = defaultdict(int)
    for k, v in dic.items():
        for c in atcg:
            tpl = *k[1:], c
            if validate(tpl):
                new_dic[tpl] += v
    return new_dic

it = product(atcg, atcg, atcg, atcg)
dic = {}
for s in it:
    if validate(s):
        dic[s] = 1

if num == 3:
    print(61)
elif num == 4:
    print(230)
else:
    for n in range(num - 4):
        dic = transition(dic)
    print(sum(dic.values()) % 1000000007)
Problem p03101 (python)

Fixed submission:
H, W = map(int, input().split())
h, w = map(int, input().split())
 
total = H * W
num_del = h * W + H * w - h * w
print(total - num_del)

Buggy submission (verdict: Runtime Error):
H, W = input().split()
h, w = input().split()

total = H * W
num_del = h * W + H * w - h * w
print(total - num_del)
Problem p03612 (python)

Fixed submission:
input()
nums = list(map(int, input().split()))
lis = [num - (i + 1) for i, num in enumerate(nums)]
cnt = 0
i = 0
while i < len(lis):
    if lis[i] == 0:
        cnt += 1
        if i == (len(lis) - 1):
            break
        if lis[i + 1] == 0:
            i += 1
    i += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
input()
nums = list(map(int, input().split()))
lis = [num - (i + 1) for i, num in enumerate(nums)]
cnt = 0
i = 0
while i < len(lis):
    if lis[i] == 0:
        cnt += 1
        if lis[i + 1] == 0:
            i += 1
    i += 1
print(cnt)

Buggy submission (verdict: Runtime Error):
input()
nums = list(map(int, input().split()))
lis = [num - (i + 1) for i, num in enumerate(nums)]
cnt = 0
i = 0
while i < len(lis):
    if lis[i] == 0:
        cnt += 1
        if lis[i + 1] == 0:
            i += 1
    i += 1
print(cnt)
Problem p03649 (python)

Fixed submission:
#!/usr/bin/env python3
import sys

sys.setrecursionlimit(2000000)


def count_linear_process(lis):
    length = len(lis)
    return [l // length for l in lis]


def linear_process(lis):
    length = len(lis)
    return [l % length for l in lis]


def check_end(lis):
    return max(lis) < len(lis)


def add_processed(lis, counts):
    sum_cnt = sum(counts)
    return [l + sum_cnt - cnt for l, cnt in zip(lis, counts)]


def update(lis, n_process=0):
    if check_end(lis):
        return n_process
    next_lis = linear_process(lis)
    counts = count_linear_process(lis)
    return update(
        add_processed(next_lis, counts), 
        n_process + sum(counts)
    )


def solve(N: int, a: "List[int]"):
    print(update(a))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()

Buggy submission (verdict: Runtime Error):
#!/usr/bin/env python3
import sys


def count_linear_process(lis):
    length = len(lis)
    return [l // length for l in lis]


def linear_process(lis):
    length = len(lis)
    return [l % length for l in lis]


def check_end(lis):
    return max(lis) < len(lis)


def add_processed(lis, counts):
    sum_cnt = sum(counts)
    return [l + sum_cnt - cnt for l, cnt in zip(lis, counts)]


def update(lis, n_process=0):
    if check_end(lis):
        return n_process
    next_lis = linear_process(lis)
    counts = count_linear_process(lis)
    return update(
        add_processed(next_lis, counts), 
        n_process + sum(counts)
    )


def solve(N: int, a: "List[int]"):
    print(update(a))
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    a = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, a)

if __name__ == '__main__':
    main()
Problem p03448 (python)

Fixed submission:
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0

for i_a in range(a + 1):
  for i_b in range(b + 1):
    for i_c in range(c + 1):
      if 500*i_a + 100*i_b + 50*i_c == x:
        count += 1
        
print(count)

Buggy submission (verdict: Runtime Error):
a = input()
b = input()
c = input()
x = input()

count = 0

for i_a in range(a):
  for i_b in range(b):
    for i_c in range(c):
      if 500*a + 100*b + 50*c == x:
        count += 1
        
print(count)
Problem p03455 (python)

Fixed submission:
a, b = map(int, input().split())
print("Even" if a * b % 2 == 0 else "Odd")

Buggy submission (verdict: Runtime Error):
a, b = map.(int, input().split())
print("Even" if a * b % 2 == 0 else "Odd")

Buggy submission (verdict: Runtime Error):
a, b = (int, input().split())
print("Even" if a * b % 2 == 0 else "Odd")
Problem p03457 (python)

Fixed submission:
N = int(input())
T, X, Y = 0, 0, 0

can_reach = True
for i in range(N):
  next_T, next_X, next_Y = map(int, input().split())
  
  z = next_T - T - abs(X - next_X) - abs(Y - next_Y)
  if z >= 0 and z % 2 == 0:
    T, X, Y = next_T, next_X, next_Y
  else:
    can_reach = False
    break
    
if can_reach:
  print('Yes')
else:
  print('No')

Buggy submission (verdict: Runtime Error):
can_reach = True
for i in range(N):
  next_T, next_X, next_Y = map(int, input().split())
  
  z = next_T - T - abs(X - next_X) - abs(Y - next_Y)
  if z >= 0 and z % 2 == 0:
    T, X, Y = next_T, next_X, next_Y
  else:
    can_reach = False
    break
    
if can_reach:
  print('Yes')
else:
  print('No')
Problem p03471 (python)

Fixed submission:
N, Y = map(int, input().split())

man_max = Y // 10000
gosen_max = Y // 5000

for x in range(man_max+1):
  for y in range(gosen_max+1):
    z = N - x - y
    if 0 <= z <= 2000 and 10000*x + 5000*y + 1000*z == Y:
      print(x, y, z)
      exit()
      
print(-1, -1, -1)

Buggy submission (verdict: Runtime Error):
N, Y = map(int, input().split())

if Y / 1000 == N:
  print('0 0',N)

man_max = Y // 10000
gosen_max = Y // 5000

is_exist = False

for i_m in range(man_max+1):
  for i_g in range(gosen_max+1):
    if 99000*i_m + 4000*i_g == Y - 1000*N:
      print(i_m, i_g, int(Y / 1000 - 10*i_m - 5*i_g))
      is_exist = True
      break
      
if not is_exist:
Problem p02796 (python)

Fixed submission:
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
    a[i][0],a[i][1]=(a[i][0]-a[i][1]),(a[i][0]+a[i][1])
a.sort(key=lambda x: x[1])
INF = 10**10
preR = -INF
cnt=0
for L,R in  a:
    if L<preR:
        continue
    cnt+=1
    preR=R
print(cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
a.sort()
cnt=0
now=0
temp=1
for i in range(n-1):
    if a[now][0]+a[now][1]>a[now+temp][0]+a[now+temp][1]:
        now+=temp
        cnt+=1
    elif  a[now+temp][0]-a[now+temp][1]<a[now][0]+a[now][1]:
        temp+=1
        cnt+=1
    else:
        now+=temp
        temp=1

print(n-cnt)

Buggy submission (verdict: Runtime Error):
n = int(input())
a = [[0,0] for _ in range(n)]

for i in range(n):
    a[i][0],a[i][1]=map(int,input().split())
a.sort()
cnt=0
now=0
temp=1
for i in range(n-1):
    if a[now][0]+a[now][1]>a[now+temp][0]+a[now+temp][1]:
        cnt+=1
        now+=temp
    elif  a[now+temp][0]-a[now+temp][1]<a[now][0]+a[now][1]:
        cnt+=1
        temp+=1
    else:
        now+=temp
        temp=1

print(n-cnt)
Problem p02934 (python)

Fixed submission:
n = int(input())
a = list(map(int,input().split()))
s = 0
for i in range(n):
    s += (1/a[i])

print(1/s)

Buggy submission (verdict: Runtime Error):
n=int(input())
A=np.array(list(map(int,input().split())))
print(1/sum(1/A))
Problem p02993 (python)

Fixed submission:
import numpy as np
import sys
import math

S=input()
s=S[0]
for i in range(len(S)-1):
    if S[i+1]==s:
        print('Bad')
        sys.exit()
    s=S[i+1]
print('Good')

Buggy submission (verdict: Runtime Error):
S=input()
s=S[0]
for i in range(len(S)-1):
    if S[i+1]==s:
        print('Bad')
        sys.exit()
    s=S[i+1]
print('Good')
Problem p03605 (python)

Fixed submission:
n=input()
print('Yes' if n[0]==str(9) or n[1]==str(9) else 'No')

Buggy submission (verdict: Runtime Error):
n = int(input())
a = set()
for _ in range(n):
    a ^= {input()}
print(len(a))
Problem p03624 (python)

Fixed submission:
import sys
s = sorted(input())
a = ord('a')
for j in range(26):
    b = a
    for i in s:
        if a == ord(i):
            a += 1
            break
    if a == b:
        print(chr(a))
        sys.exit()
print('None')

Buggy submission (verdict: Runtime Error):
S=sorted(set(input()))
ans=None
for i in range(97,97+26):
  if chr(i)!=S[i-97]:
    ans=chr(i)
    break
print(ans)
Problem p03699 (python)

Fixed submission:
n=int(input())
S=sorted([int(input()) for i in range(n)])
ans=sum(S)
if ans%10==0:
    for i in range(n):
        if (ans-S[i])%10!=0:
            ans-=S[i]
            break
print(ans if ans%10!=0 else 0)

Buggy submission (verdict: Runtime Error):
import numpy as np
n=int(input())
S=np.array(sorted([int(input()) for i in range(n)]))
for i in range(n-1):
    S=np.append(S,S[i+1:]+S[:n-i-1])
ans=0
for i in range(len(S)):
    if S[i]%10!=0:
        ans=max(ans,S[i])
print(ans)
Problem p03998 (python)

Fixed submission:
a = input()
b = input()
c = input()
win = 'a'
while len(a)>=0 and len(b)>=0 and len(c)>=0:
    if win == 'a':
        if len(a)==0:
            break
        win = a[0]
        a = a[1:]
    elif win == 'b':
        if len(b)==0:
            break
        win = b[0]
        b = b[1:]
    else:
        if len(c)==0:
            break
        win = c[0]
        c = c[1:]
print('A' if win == 'a' else 'B' if win == 'b' else 'C')

Buggy submission (verdict: Runtime Error):
A,B,C = (input() for i in range(3))
count_A=1
count_B=0
count_C=0
arr = A[0]
for i in range(len(A)+len(B)+len(C)):
    if arr=='a':
        count_A+=1
    elif arr=='b':
        count_B+=1
    else:
        count_C+=1
    if count_A==len(A):
        print('A')
        break
    elif count_B==len(B):
        print('B')
        break
    elif count_C==len(C):
        print('C')
        break
    arr = A[count_A] if arr=='a' else B[count_B] if arr=='b' else C[count_C]

Buggy submission (verdict: Runtime Error):
A,B,C = (input() for i in range(3))
count_A=1
count_B=0
count_C=0
arr = A[0]
for i in range(len(A)+len(B)+len(C)):
    arr = A[count_A] if arr=='a' else B[count_B] if arr=='b' else C[count_C]
    if arr=='a':
        count_A+=1
    elif arr=='b':
        count_B+=1
    else:
        count_C+=1
    if count_A==len(A):
        print('A')
        break
    elif count_B==len(B):
        print('B')
        break
    elif count_C==len(C):
        print('C')
        break
    else:
        continue

Buggy submission (verdict: Runtime Error):
A,B,C = (input() for i in range(3))
count_A=1
count_B=0
count_C=0
arr = A[0]
for i in range(len(A)+len(B)+len(C)-1):
    arr = A[count_A] if arr=='a' else B[count_B] if arr=='b' else C[count_C]
    if arr=='a':
        count_A+=1
    elif arr=='b':
        count_B+=1
    else:
        count_C+=1
    if count_A==len(A):
        print('A')
        break
    elif count_B==len(B):
        print('B')
        break
    elif count_C==len(C):
        print('C')
        break
    else:
        continue
Problem p02621 (python)

Fixed submission:
a = int(input())
print(a+(a*a)+(a*a*a))

Buggy submission (verdict: Runtime Error):
N, M, K = map(int,input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
time = 0
books = 0
A.append(200001)
B.append(200002)

while time <= K:
    if A[0] < B[0]:
        time += A.pop(0)
    elif B[0] < A[0]:
        time += B.pop(0)
    elif B[0] == A[0]:
        if B[1] > A[1]:
            time += A.pop(0)
        else:
            time += B.pop(0)
    books += 1
if books == 0:
    print(0)
else:
    print(books - 1)